source: lib/format_helper.h @ 29760bc

cachetimestampsdevelopdpdk-ndagetsilivendag_formatrc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformance
Last change on this file since 29760bc was 633339d, checked in by Shane Alcock <salcock@…>, 4 years ago

Push pcap_get_direction() function to format_helper.c

This means we don't have duplicate "get direction" code
in multiple pcap-based format modules. The future addition of
pcapng will be able to use this function too.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 *
3 * Copyright (c) 2007-2016 The University of Waikato, Hamilton, New Zealand.
4 * All rights reserved.
5 *
6 * This file is part of libtrace.
7 *
8 * This code has been developed by the University of Waikato WAND
9 * research group. For further information please see http://www.wand.net.nz/
10 *
11 * libtrace is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * libtrace is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 *
24 *
25 */
26#ifndef FORMAT_HELPER_H
27#define FORMAT_HELPER_H
28#include "common.h"
29#include "wandio.h"
30
31/** @file
32 *
33 * @brief Header file containing prototypes for functions that are useful for
34 * multiple format modules
35 *
36 * @author Daniel Lawson
37 * @author Perry Lorier
38 * @author Shane Alcock
39 *
40 * @version $Id$
41 */
42
43/** Generic event function for a live capture device
44 *
45 * @param trace         The input trace for the live capture device
46 * @param packet        A libtrace packet to read the next available packet
47 *                      into
48 * @return A libtrace event describing the next event of interest
49 *
50 * Any live capture format that does not require a custom event handler
51 * should use this function.
52 */
53struct libtrace_eventobj_t trace_event_device(libtrace_t *trace, libtrace_packet_t *packet);
54
55/** Generic event function for a offline trace file
56 *
57 * @param trace         The input trace for the trace file
58 * @param packet        A libtrace packet to read the next available packet
59 *                      into
60 * @return A libtrace event describing the next event of interest
61 *
62 * Any trace file format that does not require a custom event handler should
63 * use this function
64 */
65struct libtrace_eventobj_t trace_event_trace(libtrace_t *trace, libtrace_packet_t *packet);
66
67/** Opens an input trace file for reading
68 *
69 * @param libtrace      The input trace to be opened
70 * @return A libtrace IO reader for the newly opened file or NULL if the file
71 * was unable to be opened
72 */
73io_t *trace_open_file(libtrace_t *libtrace);
74
75/** Opens an output trace file for writing
76 *
77 * @param libtrace      The output trace to be opened
78 * @param compress_type The compression type to use when writing
79 * @param level         The compression level to use when writing, ranging from
80 *                      0 to 9
81 * @param filemode      The file status flags for the file, bitwise-ORed.
82 * @return A libtrace IO writer for the newly opened file or NULL if the file
83 * was unable to be opened
84 */
85iow_t *trace_open_file_out(libtrace_out_t *libtrace,
86                int compress_type,
87                int level,
88                int filemode);
89
90
91/** Attempts to determine the direction for a pcap (or pcapng) packet.
92 *
93 * @param packet        The packet in question.
94 * @return A valid libtrace_direction_t describing the direction that the
95 *         packet was travelling, if direction can be determined. Otherwise
96 *         returns TRACE_DIR_UNKNOWN.
97 *
98 * Note that we can determine the direction for only certain types of packets
99 * if they are captured using pcap/pcapng, specifically SLL and PFLOG captures.
100 */
101libtrace_direction_t pcap_get_direction(const libtrace_packet_t *packet);
102
103
104
105#endif /* FORMAT_HELPER_H */
Note: See TracBrowser for help on using the repository browser.