source: lib/libtrace.h.in @ 02b7297

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 02b7297 was 02b7297, checked in by Perry Lorier <perry@…>, 15 years ago

Add new DUCK link type (for duck packets obviously).
Make get_payload_from_link on a duck packet return "NULL" (no payload)

  • Property mode set to 100644
File size: 42.3 KB
Line 
1/*
2 * This file is part of libtrace
3 *
4 * Copyright (c) 2004 The University of Waikato, Hamilton, New Zealand.
5 * Authors: Daniel Lawson
6 *          Perry Lorier
7 *         
8 * All rights reserved.
9 *
10 * This code has been developed by the University of Waikato WAND
11 * research group. For further information please see http://www.wand.net.nz/
12 *
13 * libtrace is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * libtrace is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with libtrace; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 *
27 * $Id: libtrace.h 773 2006-05-01 12:58:09Z perry $
28 *
29 */
30
31#ifndef LIBTRACE_H
32#define LIBTRACE_H
33
34/** @file
35 *
36 * @brief Trace file processing library header
37 *
38 * @author Daniel Lawson
39 * @author Perry Lorier
40 *
41 * @version $Id: libtrace.h 773 2006-05-01 12:58:09Z perry $
42 *
43 * This library provides a per packet interface into a trace file, or a live
44 * captures.  It supports ERF, DAG cards, WAG cards, WAG's event format,
45 * pcap etc.
46 *
47 * @par Usage
48 * See the example/ directory in the source distribution for some simple examples
49 * @par Linking
50 * To use this library you need to link against libtrace by passing -ltrace
51 * to your linker. You may also need to link against a version of libpcap
52 * and of zlib which are compiled for largefile support (if you wish to access
53 * traces larger than 2 GB). This is left as an exercise for the reader. Debian
54 * Woody, at least, does not support large file offsets.
55 *
56 */
57
58#include <sys/types.h>
59#include <sys/time.h>
60
61#ifdef _MSC_VER
62    /* define the following from MSVC's internal types */
63    typedef             __int8  int8_t;
64    typedef             __int16 int16_t;
65    typedef             __int32 int32_t;
66    typedef             __int64 int64_t;
67    typedef unsigned    __int8  uint8_t;
68    typedef unsigned    __int16 uint16_t;
69    typedef unsigned    __int32 uint32_t;
70    typedef unsigned    __int64 uint64_t;
71        #ifdef BUILDING_DLL
72                #define DLLEXPORT __declspec(dllexport)
73        #else
74                #define DLLEXPORT __declspec(dllimport)
75        #endif
76        #define DLLLOCAL
77#else
78        #ifdef HAVE_GCCVISIBILITYPATCH
79                #define DLLEXPORT __attribute__ (visibility("default"))
80                #define DLLLOCAL __attribute__ (visibility("hidden"))
81        #else
82                #define DLLEXPORT
83                #define DLLLOCAL
84        #endif
85#endif
86
87#ifdef WIN32
88#   include <winsock2.h>
89#   include <ws2tcpip.h>
90    typedef short sa_family_t;
91    /* Make up for a lack of stdbool.h */
92#    define bool signed char
93#    define false 0
94#    define true 1
95#    if !defined(ssize_t)
96     /* XXX: Not 64-bit safe! */
97#    define ssize_t int
98#    endif   
99#else
100#    include <netinet/in.h>
101
102#ifndef __cplusplus
103#    include <stdbool.h>
104#endif
105
106#    include <sys/types.h>
107#    include <sys/socket.h>
108#endif
109
110/** API version as 2 byte hex digits, eg 0xXXYYZZ */
111#define LIBTRACE_API_VERSION \
112            ((@LIBTRACE_MAJOR@<<16)|(@LIBTRACE_MID@<<8)|(@LIBTRACE_MINOR@))
113
114#ifdef __cplusplus
115extern "C" {
116#endif
117
118/* Function does not depend on anything but its
119 * parameters, used to hint gcc's optimisations
120 */
121#if __GNUC__ >= 3
122#  define SIMPLE_FUNCTION __attribute__((pure))
123#  define UNUSED __attribute__((unused))
124#  define PACKED __attribute__((packed))
125#  define CONSTRUCTOR __attribute__((constructor))
126#else
127#  define SIMPLE_FUNCTION
128#  define UNUSED
129#  define PACKED
130#  define CONSTRUCTOR
131#endif
132       
133/** Opaque structure holding information about an output trace */
134typedef struct libtrace_out_t libtrace_out_t;
135       
136/** Opaque structure holding information about a trace */
137typedef struct libtrace_t libtrace_t;
138       
139/** Opaque structure holding information about a bpf filter */
140typedef struct libtrace_filter_t libtrace_filter_t;
141
142/** If a packet has memory allocated
143 * If the packet has allocated it's own memory it's buffer_control should
144 * be TRACE_CTRL_PACKET, when the packet is destroyed it's memory will be
145 * free()'d.  If it's doing zerocopy out of memory owned by something else
146 * it should be TRACE_CTRL_EXTERNAL.
147 * @note the letters p and e are magic numbers used to detect if the packet
148 * wasn't created properly
149 */
150typedef enum {
151        TRACE_CTRL_PACKET='p',
152        TRACE_CTRL_EXTERNAL='e'
153} buf_control_t;
154/** The size of a packet's buffer when managed by libtrace */
155#define LIBTRACE_PACKET_BUFSIZE 65536
156
157/** The libtrace packet structure, applications shouldn't be
158 * meddling around in here
159 */
160typedef struct libtrace_packet_t {
161        struct libtrace_t *trace; /**< pointer to the trace */
162        void *header;           /**< pointer to the framing header */
163        void *payload;          /**< pointer to the link layer */
164        buf_control_t buf_control; /**< who owns the memory */
165        void *buffer;           /**< allocated buffer */
166        size_t size;            /**< trace_get_framing_length()
167                                 * +trace_get_capture_length() */
168        uint32_t type;          /**< rt protocol type for the packet */
169} libtrace_packet_t;
170
171/** libtrace error information */
172typedef struct trace_err_t{
173        int err_num;            /**< error code */
174        char problem[255];      /**< the format, uri etc that caused the error for reporting purposes */
175} libtrace_err_t;
176
177/** Enumeration of error codes */
178enum {
179        /** No Error has occured.... yet. */
180        TRACE_ERR_NOERROR       = 0,
181        /** The URI passed to trace_create() is unsupported, or badly formed */
182        TRACE_ERR_BAD_FORMAT    = -1,
183        /** The trace failed to initialise */
184        TRACE_ERR_INIT_FAILED   = -2,
185        /** Unknown config option */
186        TRACE_ERR_UNKNOWN_OPTION= -3,
187        /** This output uri cannot write packets of this type */
188        TRACE_ERR_NO_CONVERSION = -4,
189        /** This packet is corrupt, or unusable for the action required */
190        TRACE_ERR_BAD_PACKET    = -5,
191        /** Option known, but unsupported by this format */
192        TRACE_ERR_OPTION_UNAVAIL= -6,
193        /** This feature is unsupported */
194        TRACE_ERR_UNSUPPORTED   = -7
195};
196
197/** Enumeration of DLT types supported by libtrace */
198typedef enum {
199        TRACE_DLT_NULL = 0,
200        TRACE_DLT_EN10MB = 1,
201        TRACE_DLT_ATM_RFC1483 = 11,
202        TRACE_DLT_IEEE802_11 = 105,
203        TRACE_DLT_LINUX_SLL = 113,
204        TRACE_DLT_PFLOG = 117
205} libtrace_dlt_t ;
206
207/** Enumeration of link layer types supported by libtrace */
208typedef enum {
209       TRACE_TYPE_HDLC_POS = 1,
210       TRACE_TYPE_ETH,                  /**< 802.3 style Ethernet */
211       TRACE_TYPE_ATM,                  /**< ATM frame */
212       TRACE_TYPE_AAL5,
213       TRACE_TYPE_80211,                /**< 802.11 frames */
214       TRACE_TYPE_NONE,                 /**< Raw IP frames */
215       TRACE_TYPE_LINUX_SLL,            /**< Linux "null" framing */
216       TRACE_TYPE_PFLOG,                /**< FreeBSD's PFlug */
217       TRACE_TYPE_POS,
218       TRACE_TYPE_80211_PRISM = 12,
219       TRACE_TYPE_DUCK,                 /**< Pseudo link layer for DUCK packets */
220     } libtrace_linktype_t;
221
222/** Trace directions
223 * Note that these are the directions used by convention, more directions
224 * are possible, not just these 3, and that they may not conform to this
225 * convention.
226 */
227typedef enum {
228        TRACE_DIR_OUTGOING = 0,         /**< Packets originating "outside" */
229        TRACE_DIR_INCOMING = 1,         /**< Packets originating "inside" */
230        TRACE_DIR_OTHER    = 2          /**< Packets with an unknown direction, or one that's unknown */
231} libtrace_direction_t;
232
233/** @name Protocol structures
234 * These convenience structures are here as they are portable ways of dealing
235 * with various protocols.
236 * @{
237 */
238
239#ifdef WIN32
240#pragma pack(push)
241#pragma pack(1)
242#endif
243
244/** Generic IP header structure */
245typedef struct libtrace_ip
246{
247#if BYTE_ORDER == LITTLE_ENDIAN
248    uint8_t ip_hl:4;            /**< Header Length */
249    uint8_t ip_v:4;             /**< Version */
250#elif BYTE_ORDER == BIG_ENDIAN
251    uint8_t ip_v:4;             /**< Version */
252    uint8_t ip_hl:4;            /**< Header Length */
253#else
254#   error "Adjust your <bits/endian.h> defines"
255#endif
256    uint8_t  ip_tos;                    /**< Type of Service */
257    uint16_t ip_len;                    /**< Total Length */
258    int16_t  ip_id;                     /**< Identification */
259#if BYTE_ORDER == LITTLE_ENDIAN
260    uint16_t ip_off:12;         /**< Fragment Offset */
261    uint16_t ip_mf:1;           /**< More Fragments Flag */
262    uint16_t ip_df:1;           /**< Dont Fragment Flag */
263    uint16_t ip_rf:1;           /**< Reserved Fragment Flag */
264#elif BYTE_ORDER == BIG_ENDIAN
265    uint16_t ip_rf:1;           /**< Fragment Offset */
266    uint16_t ip_df:1;           /**< More Fragments Flag */
267    uint16_t ip_mf:1;           /**< Dont Fragment Flag */
268    uint16_t ip_off:12;         /**< Reserved Fragment Flag */
269#else
270#   error "Adjust your <bits/endian.h> defines"
271#endif
272    uint8_t  ip_ttl;                    /**< Time to Live */
273    uint8_t  ip_p;                      /**< Protocol */
274    uint16_t ip_sum;                    /**< Checksum */
275    struct in_addr ip_src;              /**< Source Address */
276    struct in_addr ip_dst;              /**< Destination Address */
277} PACKED libtrace_ip_t;
278
279/** IPv6 header extension structure */
280typedef struct libtrace_ip6_ext
281{
282        uint8_t nxt;
283        uint8_t len;
284} PACKED libtrace_ip6_ext_t;
285
286/** Generic IPv6 header structure */
287typedef struct libtrace_ip6
288{
289    uint32_t flow;
290    uint16_t plen;                      /**< Payload length */
291    uint8_t nxt;                        /**< Next header */
292    uint8_t hlim;                       /**< Hop limit */
293    struct in6_addr ip_src;             /**< source address */
294    struct in6_addr ip_dst;             /**< dest address */
295} PACKED libtrace_ip6_t;
296
297/** Generic TCP header structure */
298typedef struct libtrace_tcp
299  {
300    uint16_t source;            /**< Source Port */
301    uint16_t dest;              /**< Destination port */
302    uint32_t seq;               /**< Sequence number */
303    uint32_t ack_seq;           /**< Acknowledgement Number */
304#  if BYTE_ORDER == LITTLE_ENDIAN
305    uint8_t res1:4;     /**< Reserved bits */
306    uint8_t doff:4;     /**< Data Offset */     
307    uint8_t fin:1;              /**< FIN */
308    uint8_t syn:1;              /**< SYN flag */
309    uint8_t rst:1;              /**< RST flag */
310    uint8_t psh:1;              /**< PuSH flag */
311    uint8_t ack:1;              /**< ACK flag */
312    uint8_t urg:1;              /**< URG flag */
313    uint8_t res2:2;     /**< Reserved */
314#  elif BYTE_ORDER == BIG_ENDIAN
315    uint8_t doff:4;     /**< Data offset */
316    uint8_t res1:4;     /**< Reserved bits */
317    uint8_t res2:2;     /**< Reserved */
318    uint8_t urg:1;              /**< URG flag */
319    uint8_t ack:1;              /**< ACK flag */
320    uint8_t psh:1;              /**< PuSH flag */
321    uint8_t rst:1;              /**< RST flag */
322    uint8_t syn:1;              /**< SYN flag */
323    uint8_t fin:1;              /**< FIN flag */
324#  else
325#   error "Adjust your <bits/endian.h> defines"
326#  endif
327    uint16_t window;            /**< Window Size */
328    uint16_t check;             /**< Checksum */
329    uint16_t urg_ptr;           /**< Urgent Pointer */
330} PACKED libtrace_tcp_t;
331
332/** Generic UDP header structure */
333typedef struct libtrace_udp {
334  uint16_t      source;         /**< Source port */
335  uint16_t      dest;           /**< Destination port */
336  uint16_t      len;            /**< Length */
337  uint16_t      check;          /**< Checksum */
338} PACKED libtrace_udp_t;
339
340/** Generic ICMP header structure */
341typedef struct libtrace_icmp
342{
343  uint8_t type;         /**< Message Type */
344  uint8_t code;         /**< Type Sub-code */
345  uint16_t checksum;            /**< Checksum */
346  union
347  {
348    struct
349    {
350      uint16_t  id;
351      uint16_t  sequence;
352    } echo;                     /**< Echo Datagram */
353    uint32_t    gateway;        /**< Gateway Address */
354    struct
355    {
356      uint16_t  unused;
357      uint16_t  mtu;
358    } frag;                     /**< Path MTU Discovery */
359  } un;                         /**< Union for Payloads of Various ICMP Codes */
360} PACKED libtrace_icmp_t;
361
362/** Generic LLC/SNAP header structure */
363typedef struct libtrace_llcsnap
364{
365/* LLC */
366  uint8_t dsap;                 /**< Destination Service Access Point */
367  uint8_t ssap;                 /**< Source Service Access Point */
368  uint8_t control;
369/* SNAP */
370  uint32_t oui:24;              /**< Organisationally Unique Identifier (scope)*/
371  uint16_t type;                /**< Protocol within OUI */
372} PACKED libtrace_llcsnap_t;
373
374/** 802.3 frame */
375typedef struct libtrace_ether
376{
377  uint8_t ether_dhost[6];       /**< Destination Ether Addr */
378  uint8_t ether_shost[6];       /**< Source Ether Addr */
379  uint16_t ether_type;          /**< Packet Type ID Field (next-header) */
380} PACKED libtrace_ether_t;
381
382/** 802.1Q frame */
383typedef struct libtrace_8021q
384{
385  uint16_t vlan_pri:3;   /**< VLAN User Priority */
386  uint16_t vlan_cfi:1;   /**< VLAN Format Indicator,
387                                   * 0 for ethernet, 1 for token ring */
388  uint16_t vlan_id:12;   /**< VLAN Id */
389  uint16_t vlan_ether_type;      /**< VLAN Sub-packet Type ID Field
390                                   * (next-header)*/
391} PACKED libtrace_8021q_t;
392
393/** ATM cell */
394typedef struct libtrace_atm_cell
395{
396  uint32_t gfc:4;               /**< Generic Flow Control */
397  uint32_t vpi:8;               /**< Virtual Path Identifier */
398  uint32_t vci:8;               /**< Virtual Channel Identifier */
399  uint32_t pt:3;                /**< Payload Type */
400  uint32_t clp:1;               /**< Cell Loss Priority */
401  uint32_t hec:8;               /**< Header Error Control */
402} PACKED libtrace_atm_cell_t;
403
404/** POS header */
405typedef struct libtrace_pos
406{
407 uint16_t header;
408 uint16_t ether_type;           /**< Ether Type */
409} PACKED libtrace_pos_t;
410
411/** 802.11 header */
412typedef struct libtrace_80211_t {
413        uint16_t      protocol:2;
414        uint16_t      type:2;
415        uint16_t      subtype:4;
416        uint16_t      to_ds:1;          /**< Packet to Distribution Service */
417        uint16_t      from_ds:1;        /**< Packet from Distribution Service */
418        uint16_t      more_frag:1;      /**< Packet has more fragments */
419        uint16_t      retry:1;          /**< Packet is a retry */
420        uint16_t      power:1;
421        uint16_t      more_data:1;
422        uint16_t      wep:1;
423        uint16_t      order:1;
424        uint16_t     duration;
425        uint8_t      mac1[6];
426        uint8_t      mac2[6];
427        uint8_t      mac3[6];
428        uint16_t     SeqCtl;
429        uint8_t      mac4[6];
430} PACKED libtrace_80211_t;
431
432#ifdef WIN32
433#pragma pack(pop)
434#endif
435
436
437/*@}*/
438
439/** Prints help information for libtrace
440 *
441 * Function prints out some basic help information regarding libtrace,
442 * and then prints out the help() function registered with each input module
443 */
444DLLEXPORT void trace_help();
445
446/** @name Trace management
447 * These members deal with creating, configuring, starting, pausing and
448 * cleaning up a trace object
449 *@{
450 */
451
452/** Create a trace file from a URI
453 *
454 * @param uri containing a valid libtrace URI
455 * @return an opaque pointer to a libtrace_t
456 *
457 * Valid URI's are:
458 *  - erf:/path/to/erf/file
459 *  - erf:-  (stdin)
460 *  - dag:/dev/dagcard                 
461 *  - pcapint:pcapinterface                (eg: pcap:eth0)
462 *  - pcap:/path/to/pcap/file
463 *  - pcap:-
464 *  - rt:hostname
465 *  - rt:hostname:port
466 *  - rtclient:hostname (deprecated)
467 *  - rtclient:hostname:port (deprecated)
468 *  - wag:/dev/wagcard
469 *  - wtf:-
470 *  - wtf:/path/to/wtf/file
471 *
472 *  If an error occured when attempting to open the trace file, an error
473 *  trace is returned and trace_get_error should be called to find out
474 *  if an error occured, and what that error was.  The trace is created in the
475 *  configuration state, you must call trace_start to start the capture.
476 */
477DLLEXPORT libtrace_t *trace_create(const char *uri);
478
479/** Creates a "dummy" trace file that has only the format type set.
480 *
481 * @return an opaque pointer to a (sparsely initialised) libtrace_t
482 *
483 * IMPORTANT: Do not attempt to call trace_read_packet or other such functions
484 * with the dummy trace. Its intended purpose is to act as a packet->trace for
485 * libtrace_packet_t's that are not associated with a libtrace_t structure.
486 */
487DLLEXPORT libtrace_t *trace_create_dead(const char *uri);
488
489/** Creates a trace output file from a URI.
490 *
491 * @param uri   the uri string describing the output format and destination
492 * @return an opaque pointer to a libtrace_output_t
493 *
494 * Valid URI's are:
495 *  - erf:/path/to/erf/file
496 *  - pcap:/path/to/pcap/file
497 *  - wtf:/path/to/wtf/file
498 *
499 *  If an error occured when attempting to open the output trace, NULL is returned
500 *  and trace_errno is set. Use trace_perror() to get more information
501 */
502DLLEXPORT libtrace_out_t *trace_create_output(const char *uri);
503
504/** Start the capture
505 * @param libtrace      The trace to start
506 * @return 0 on success, -1 on failure
507 *
508 * This does the actual work with starting the trace capture, and applying
509 * all the config options.  This may fail.
510 */
511DLLEXPORT int trace_start(libtrace_t *libtrace);
512
513/** Pause the capture
514 * @param libtrace      The trace to pause
515 * @return 0 on success, -1 on failure
516 *
517 * This stops a capture in progress and returns you to the configuration
518 * state.  Any packets that arrive after trace_pause() has been called
519 * will be discarded.  To resume capture, call trace_start().
520 */
521DLLEXPORT int trace_pause(libtrace_t *libtrace);
522
523/** Start an output trace
524 * @param libtrace      The trace to start
525 * @return 0 on success, -1 on failure
526 *
527 * This does the actual work with starting a trace for write.  This generally
528 * creates the file.
529 */
530DLLEXPORT int trace_start_output(libtrace_out_t *libtrace);
531
532/** Valid trace capture options */
533typedef enum {
534        TRACE_OPTION_SNAPLEN, /**< Number of bytes captured */
535        TRACE_OPTION_PROMISC, /**< Capture packets to other hosts */
536        TRACE_OPTION_FILTER,  /**< Apply this filter to all packets recieved */
537        TRACE_META_FREQ       /**< Frequency of meta-data information, e.g. DUCK packets */
538} trace_option_t;
539
540/** Sets an input config option
541 * @param libtrace      the trace object to apply the option to
542 * @param option        the option to set
543 * @param value         the value to set the option to
544 * @return -1 if option configuration failed, 0 otherwise
545 * This should be called after trace_create, and before trace_start
546 */
547DLLEXPORT int trace_config(libtrace_t *libtrace,
548                trace_option_t option,
549                void *value);
550
551typedef enum {
552        TRACE_OPTION_OUTPUT_FILEFLAGS, /**< File flags to open the trace file
553                                        * with.  eg O_APPEND
554                                        */
555        TRACE_OPTION_OUTPUT_COMPRESS   /**< Compression level, eg 6. */
556} trace_option_output_t;
557
558/** Sets an output config option
559 *
560 * @param libtrace      the output trace object to apply the option to
561 * @param option        the option to set
562 * @param value         the value to set the option to
563 * @return -1 if option configuration failed, 0 otherwise
564 * This should be called after trace_create_output, and before
565 * trace_start_output
566 */
567DLLEXPORT int trace_config_output(libtrace_out_t *libtrace,
568                trace_option_output_t option,
569                void *value
570                );
571
572/** Close a trace file, freeing up any resources it may have been using
573 *
574 */
575DLLEXPORT void trace_destroy(libtrace_t *trace);
576
577/** Close a trace file, freeing up any resources it may have been using
578 * @param trace         trace file to be destroyed
579 */
580DLLEXPORT void trace_destroy_dead(libtrace_t *trace);
581
582/** Close a trace output file, freeing up any resources it may have been using
583 * @param trace         the output trace file to be destroyed
584 */
585DLLEXPORT void trace_destroy_output(libtrace_out_t *trace);
586
587/** Check (and clear) the current error state of an input trace
588 * @param trace         the trace file to check the error state on
589 * @return Error report
590 * This reads and returns the current error state and sets the current error
591 * to "no error".
592 */
593DLLEXPORT libtrace_err_t trace_get_err(libtrace_t *trace);
594
595/** Return if there is an error
596 * @param trace         the trace file to check the error state on
597 * This does not clear the error status, and only returns true or false.
598 */
599DLLEXPORT bool trace_is_err(libtrace_t *trace);
600
601/** Output an error message to stderr and clear the error status.
602 * @param trace         the trace with the error to output
603 * @param msg           the message to prefix to the error
604 * This function does clear the error status.
605 */
606DLLEXPORT void trace_perror(libtrace_t *trace, const char *msg,...);
607
608/** Check (and clear) the current error state of an output trace
609 * @param trace         the output trace file to check the error state on
610 * @return Error report
611 * This reads and returns the current error state and sets the current error
612 * to "no error".
613 */
614DLLEXPORT libtrace_err_t trace_get_err_output(libtrace_out_t *trace);
615
616/** Return if there is an error
617 * @param trace         the trace file to check the error state on
618 * This does not clear the error status, and only returns true or false.
619 */
620DLLEXPORT bool trace_is_err_output(libtrace_out_t *trace);
621
622/** Output an error message to stderr and clear the error status.
623 * @param trace         the trace with the error to output
624 * @param msg           the message to prefix to the error
625 * This function does clear the error status.
626 */
627DLLEXPORT void trace_perror_output(libtrace_out_t *trace, const char *msg,...);
628
629
630/*@}*/
631
632/** @name Reading/Writing packets
633 * These members deal with creating, reading and writing packets
634 *
635 * @{
636 */
637
638/** Create a new packet object
639 *
640 * @return a pointer to an initialised libtrace_packet_t object
641 */
642DLLEXPORT libtrace_packet_t *trace_create_packet();
643
644/** Copy a packet
645 * @param packet        the source packet to copy
646 * @return a new packet which has the same content as the source packet
647 * @note This always involves a copy, which can be slow.  Use of this
648 * function should be avoided where possible.
649 * @par The reason you would want to use this function is that a zerocopied
650 * packet from a device is using the devices memory which may be a limited
651 * resource.  Copying the packet will cause it to be copied into the systems
652 * memory.
653 */
654DLLEXPORT libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet);
655
656/** Destroy a packet object
657 *
658 * sideeffect: sets packet to NULL
659 */
660DLLEXPORT void trace_destroy_packet(libtrace_packet_t **packet);
661
662
663/** Read one packet from the trace
664 *
665 * @param trace         the libtrace opaque pointer
666 * @param packet        the packet opaque pointer
667 * @return 0 on EOF, negative value on error, number of bytes read when
668 * successful.
669 *
670 * @note the number of bytes read is usually (but not always) the same as
671 * trace_get_framing_length()+trace_get_capture_length() depending on the
672 * trace format.
673 * @note the trace must have been started with trace_start before calling
674 * this function
675 */
676DLLEXPORT int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet);
677
678/** Event types
679 * see \ref libtrace_eventobj_t and \ref trace_event
680 */
681typedef enum {
682        TRACE_EVENT_IOWAIT,     /**< Need to block on fd */
683        TRACE_EVENT_SLEEP,      /**< Sleep for some time */
684        TRACE_EVENT_PACKET,     /**< packet has arrived */
685        TRACE_EVENT_TERMINATE   /**< End of trace */
686} libtrace_event_t;
687
688/** Structure returned by libtrace_event explaining what the current event is */
689typedef struct libtrace_eventobj_t {
690        libtrace_event_t type; /**< event type (iowait,sleep,packet) */
691        int fd;                /**< if IOWAIT, the fd to sleep on */
692        double seconds;        /**< if SLEEP, the amount of time to sleep for
693                                */
694        int size;              /**< if PACKET, the value returned from
695                                *  trace_read_packet
696                                */
697} libtrace_eventobj_t;
698
699/** Processes the next libtrace event
700 * @param trace the libtrace opaque pointer
701 * @param packet the libtrace_packet opaque pointer
702 * @return libtrace_event struct containing the type, and potential
703 *      fd or seconds to sleep on
704 *
705 * Type can be:
706 *  TRACE_EVENT_IOWAIT  Waiting on I/O on fd
707 *  TRACE_EVENT_SLEEP   Next event in seconds
708 *  TRACE_EVENT_PACKET  Packet arrived in buffer with size size
709 *  TRACE_EVENT_TERMINATE Trace terminated (perhaps with an error condition)
710 */
711DLLEXPORT libtrace_eventobj_t trace_event(libtrace_t *trace,
712                libtrace_packet_t *packet);
713
714
715/** Write one packet out to the output trace
716 *
717 * @param trace         the libtrace_out opaque pointer
718 * @param packet        the packet opaque pointer
719 * @return the number of bytes written out, if zero or negative then an error has occured.
720 */
721DLLEXPORT int trace_write_packet(libtrace_out_t *trace, const libtrace_packet_t *packet);
722/*@}*/
723
724/** @name Protocol decodes
725 * These functions locate and return a pointer to various headers inside a
726 * packet
727 * @{
728 */
729
730/** get a pointer to the link layer
731 * @param packet        the packet opaque pointer
732 *
733 * @return a pointer to the link layer, or NULL if there is no link layer
734 *
735 * @note you should call trace_get_link_type to find out what type of link
736 * layer this is
737 */
738DLLEXPORT SIMPLE_FUNCTION
739void *trace_get_link(const libtrace_packet_t *packet);
740
741/** get a pointer to the IP header (if any)
742 * @param packet        the packet opaque pointer
743 *
744 * @return a pointer to the IP header, or NULL if there is no IP header
745 */
746DLLEXPORT SIMPLE_FUNCTION
747libtrace_ip_t *trace_get_ip(libtrace_packet_t *packet);
748
749/** Gets a pointer to the transport layer header (if any)
750 * @param packet        a pointer to a libtrace_packet structure
751 * @param[out] proto    transport layer protocol
752 *
753 * @return a pointer to the transport layer header, or NULL if there is no header
754 *
755 * @note proto may be NULL if proto is unneeded.
756 */
757DLLEXPORT void *trace_get_transport(libtrace_packet_t *packet, uint8_t *proto,
758                uint32_t *remaining);
759
760/** Gets a pointer to the payload given a pointer to the IP header
761 * @param ip            The IP Header
762 * @param[out] proto    An output variable of the IP protocol
763 * @param[in,out] remaining Updated with the number of bytes remaining
764 *
765 * @return a pointer to the transport layer header, or NULL if header isn't present.
766 *
767 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
768 * of bytes captured of the IP header and beyond.  It will be updated after this
769 * function to the number of bytes remaining after the IP header (and any IP options)
770 * have been removed.
771 *
772 * proto may be NULL if not needed.
773 *
774 * @note This is similar to trace_get_transport_from_ip in libtrace2
775 */
776DLLEXPORT void *trace_get_payload_from_ip(libtrace_ip_t *ip, uint8_t *proto,
777                uint32_t *remaining);
778
779/** Gets a pointer to the payload given a pointer to a tcp header
780 * @param tcp           The tcp Header
781 * @param[in,out] remaining Updated with the number of bytes remaining
782 *
783 * @return a pointer to the tcp payload, or NULL if the payload isn't present.
784 *
785 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
786 * of bytes captured of the TCP header and beyond.  It will be updated after this
787 * function to the number of bytes remaining after the TCP header (and any TCP options)
788 * have been removed.
789 *
790 * @note This is similar to trace_get_transport_from_ip in libtrace2
791 */
792DLLEXPORT void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, uint32_t *remaining);
793
794/** Gets a pointer to the payload given a pointer to a udp header
795 * @param udp           The udp Header
796 * @param[in,out] remaining Updated with the number of bytes remaining
797 *
798 * @return a pointer to the udp payload, or NULL if the payload isn't present.
799 *
800 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
801 * of bytes captured of the TCP header and beyond.  It will be updated after this
802 * function to the number of bytes remaining after the TCP header (and any TCP options)
803 * have been removed.
804 *
805 * @note This is similar trace_get_transport_from_ip in libtrace2
806 */
807DLLEXPORT void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining);
808
809/** Gets a pointer to the payload given a pointer to a icmp header
810 * @param icmp          The icmp Header
811 * @param[in,out] remaining Updated with the number of bytes remaining
812 *
813 * @return a pointer to the icmp payload, or NULL if the payload isn't present.
814 *
815 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
816 * of bytes captured of the TCP header and beyond.  It will be updated after this
817 * function to the number of bytes remaining after the TCP header (and any TCP options)
818 * have been removed.
819 *
820 * @note This is similar to trace_get_payload_from_icmp in libtrace2
821 */
822DLLEXPORT void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, uint32_t *remaining);
823
824/** get a pointer to the TCP header (if any)
825 * @param packet        the packet opaque pointer
826 *
827 * @return a pointer to the TCP header, or NULL if there is not a TCP packet
828 */
829DLLEXPORT SIMPLE_FUNCTION
830libtrace_tcp_t *trace_get_tcp(libtrace_packet_t *packet);
831
832/** get a pointer to the TCP header (if any) given a pointer to the IP header
833 * @param ip            The IP header
834 * @param[in,out] remaining Updated with the number of bytes remaining
835 *
836 * @return a pointer to the TCP header, or NULL if this is not a TCP packet
837 *
838 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
839 * of bytes captured of the TCP header and beyond.  It will be updated after this
840 * function to the number of bytes remaining after the TCP header (and any TCP options)
841 * have been removed.
842 *
843 * @note The last parameter has changed from libtrace2
844 */
845DLLEXPORT SIMPLE_FUNCTION
846libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip, uint32_t *remaining);
847
848/** get a pointer to the UDP header (if any)
849 * @param packet        the packet opaque pointer
850 *
851 * @return a pointer to the UDP header, or NULL if this is not a UDP packet
852 */
853DLLEXPORT SIMPLE_FUNCTION
854libtrace_udp_t *trace_get_udp(libtrace_packet_t *packet);
855
856/** get a pointer to the UDP header (if any) given a pointer to the IP header
857 * @param       ip      The IP header
858 * @param[in,out] remaining Updated with the number of bytes remaining
859 *
860 * @return a pointer to the UDP header, or NULL if this is not an UDP packet
861 *
862 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
863 * of bytes captured of the TCP header and beyond.  It will be updated after this
864 * function to the number of bytes remaining after the TCP header (and any TCP options)
865 * have been removed.
866 *
867 * @note Beware the change from libtrace2 from skipped to remaining
868 */
869DLLEXPORT SIMPLE_FUNCTION
870libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
871
872/** get a pointer to the ICMP header (if any)
873 * @param packet        the packet opaque pointer
874 *
875 * @return a pointer to the ICMP header, or NULL if this is not a ICMP packet
876 */
877DLLEXPORT SIMPLE_FUNCTION
878libtrace_icmp_t *trace_get_icmp(libtrace_packet_t *packet);
879
880/** get a pointer to the ICMP header (if any) given a pointer to the IP header
881 * @param ip            The IP header
882 * @param[in,out] remaining Updated with the number of bytes remaining
883 *
884 * @return a pointer to the ICMP header, or NULL if this is not an ICMP packet
885 *
886 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
887 * of bytes captured of the TCP header and beyond.  It will be updated after this
888 * function to the number of bytes remaining after the TCP header (and any TCP options)
889 * have been removed.
890 *
891 * @note Beware the change from libtrace2 from skipped to remaining
892 */
893DLLEXPORT SIMPLE_FUNCTION
894libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
895
896/** Get the destination MAC addres
897 * @param packet        the packet opaque pointer
898 * @return a pointer to the destination mac, (or NULL if there is no
899 * destination MAC)
900 */
901DLLEXPORT SIMPLE_FUNCTION
902uint8_t *trace_get_destination_mac(libtrace_packet_t *packet);
903
904/** Get the source MAC addres
905 * @param packet        the packet opaque pointer
906 * @return a pointer to the source mac, (or NULL if there is no source MAC)
907 */
908DLLEXPORT SIMPLE_FUNCTION
909uint8_t *trace_get_source_mac(libtrace_packet_t *packet);
910
911/** Get the source addres
912 * @param packet        the packet opaque pointer
913 * @param addr          a pointer to a sockaddr to store the address in, or NULL to use
914 *                      static storage.
915 * @return NULL if there is no source address, or a sockaddr holding a v4 or v6 address
916 */
917DLLEXPORT SIMPLE_FUNCTION
918struct sockaddr *trace_get_source_address(const libtrace_packet_t *packet,
919                struct sockaddr *addr);
920
921/** Get the source addres
922 * @param packet        the packet opaque pointer
923 * @param addr          a pointer to a sockaddr to store the address in, or NULL to use
924 *                      static storage.
925 * @return NULL if there is no source address, or a sockaddr holding a v4 or v6 address
926 */
927DLLEXPORT SIMPLE_FUNCTION
928struct sockaddr *trace_get_destination_address(const libtrace_packet_t *packet,
929                struct sockaddr *addr);
930
931/*@}*/
932
933/** parse an ip or tcp option
934 * @param[in,out] ptr   the pointer to the current option
935 * @param[in,out] len   the length of the remaining buffer
936 * @param[out] type     the type of the option
937 * @param[out] optlen   the length of the option
938 * @param[out] data     the data of the option
939 *
940 * @return bool true if there is another option (and the fields are filled in)
941 *               or false if this was the last option.
942 *
943 * This updates ptr to point to the next option after this one, and updates
944 * len to be the number of bytes remaining in the options area.  Type is updated
945 * to be the code of this option, and data points to the data of this option,
946 * with optlen saying how many bytes there are.
947 *
948 * @note Beware of fragmented packets.
949 */
950DLLEXPORT int trace_get_next_option(unsigned char **ptr,int *len,
951                        unsigned char *type,
952                        unsigned char *optlen,
953                        unsigned char **data);
954
955
956/** @name Time
957 * These functions deal with time that a packet arrived and return it
958 * in various formats
959 * @{
960 */
961/** Get the current time in DAG time format
962 * @param packet        the packet opaque pointer
963 *
964 * @return a 64 bit timestamp in DAG ERF format (upper 32 bits are the seconds
965 * past 1970-01-01, the lower 32bits are partial seconds)
966 */
967DLLEXPORT SIMPLE_FUNCTION
968uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet);
969
970/** Get the current time in struct timeval
971 * @param packet        the packet opaque pointer
972 *
973 * @return time that this packet was seen in a struct timeval
974 */
975DLLEXPORT SIMPLE_FUNCTION
976struct timeval trace_get_timeval(const libtrace_packet_t *packet);
977
978/** Get the current time in floating point seconds
979 * @param packet        the packet opaque pointer
980 *
981 * @return time that this packet was seen in 64bit floating point seconds
982 */
983DLLEXPORT SIMPLE_FUNCTION
984double trace_get_seconds(const libtrace_packet_t *packet);
985
986/** Seek within a trace
987 * @param trace         trace to seek
988 * @param seconds       time to seek to
989 * @return 0 on success.
990 * Make the next packet read to be the first packet to occur at or after the
991 * time searched for.  This must be called in the configuration state (ie,
992 * before trace_start() or after trace_pause().
993 * @note This function may be extremely slow.
994 */
995DLLEXPORT int trace_seek_seconds(libtrace_t *trace, double seconds);
996
997/** Seek within a trace
998 * @param trace         trace to seek
999 * @param tv            time to seek to
1000 * @return 0 on success.
1001 * Make the next packet read to be the first packet to occur at or after the
1002 * time searched for.  This must be called in the configuration state (ie,
1003 * before trace_start() or after trace_pause().
1004 * @note This function may be extremely slow.
1005 */
1006DLLEXPORT int trace_seek_timeval(libtrace_t *trace, struct timeval tv);
1007
1008/** Seek within a trace
1009 * @param trace         trace to seek
1010 * @param ts            erf timestamp
1011 * @return 0 on success.
1012 * Make the next packet read to be the first packet to occur at or after the
1013 * time searched for.  This must be called in the configuration state (ie,
1014 * before trace_start() or after trace_pause().
1015 * @note This function may be extremely slow.
1016 */
1017DLLEXPORT int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts);
1018
1019/*@}*/
1020
1021/** @name Sizes
1022 * This section deals with finding or setting the various different lengths
1023 * a packet can have
1024 * @{
1025 */
1026/** Get the size of the packet in the trace
1027 * @param packet        the packet opaque pointer
1028 * @return the size of the packet in the trace
1029 * @note Due to this being a header capture, or anonymisation, this may not
1030 * be the same size as the original packet.  See get_wire_length() for the
1031 * original size of the packet.
1032 * @note This can (and often is) different for different packets in a trace!
1033 * @note This is sometimes called the "snaplen".
1034 * @note The return size refers to the network-level payload of the packet and
1035 * does not include any capture framing headers. For example, an Ethernet
1036 * packet with an empty TCP packet will return sizeof(ethernet_header) +
1037 * sizeof(ip_header) + sizeof(tcp_header).
1038 */
1039DLLEXPORT SIMPLE_FUNCTION
1040size_t trace_get_capture_length(const libtrace_packet_t *packet);
1041
1042/** Get the size of the packet as it was seen on the wire.
1043 * @param packet        the packet opaque pointer
1044 * @return the size of the packet as it was on the wire.
1045 * @note Due to the trace being a header capture, or anonymisation this may
1046 * not be the same as the Capture Len.
1047 * @note trace_getwire_length \em{includes} FCS.
1048 */
1049DLLEXPORT SIMPLE_FUNCTION
1050size_t trace_get_wire_length(const libtrace_packet_t *packet);
1051
1052/** Get the length of the capture framing headers.
1053 * @param packet        the packet opaque pointer
1054 * @return the size of the packet as it was on the wire.
1055 * @note this length corresponds to the difference between the size of a
1056 * captured packet in memory, and the captured length of the packet
1057 */
1058DLLEXPORT SIMPLE_FUNCTION
1059size_t trace_get_framing_length(const libtrace_packet_t *packet);
1060
1061/** Truncate ("snap") the packet at the suggested length
1062 * @param packet        the packet opaque pointer
1063 * @param size          the new length of the packet
1064 * @return the new capture length of the packet, or the original capture
1065 * length of the packet if unchanged
1066 */
1067DLLEXPORT size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size);
1068
1069/*@}*/
1070
1071
1072/** Get the type of the link layer
1073 * @param packet        the packet opaque pointer
1074 * @return libtrace_linktype_t
1075 */
1076DLLEXPORT SIMPLE_FUNCTION
1077libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet);
1078
1079/** Set the direction flag, if it has one
1080 * @param packet        the packet opaque pointer
1081 * @param direction     the new direction
1082 * @returns -1 on error, or the direction that was set.
1083 */
1084DLLEXPORT libtrace_direction_t trace_set_direction(libtrace_packet_t *packet, libtrace_direction_t direction);
1085
1086/** Get the direction flag, if it has one
1087 * @param packet        the packet opaque pointer
1088 * @return a value containing the direction flag, or -1 if this is not supported
1089 * The direction is defined as 0 for packets originating locally (ie, outbound)
1090 * and 1 for packets originating remotely (ie, inbound).
1091 * Other values are possible, which might be overloaded to mean special things
1092 * for a special trace.
1093 */
1094DLLEXPORT SIMPLE_FUNCTION
1095libtrace_direction_t trace_get_direction(const libtrace_packet_t *packet);
1096
1097/** @name BPF
1098 * This section deals with using Berkley Packet Filters
1099 * @{
1100 */
1101/** setup a BPF filter
1102 * @param filterstring a char * containing the bpf filter string
1103 * @return opaque pointer pointer to a libtrace_filter_t object
1104 * @note The filter is not actually compiled at this point, so no correctness
1105 * tests are performed here. trace_bpf_setfilter will always return ok, but
1106 * if the filter is poorly constructed an error will be generated when the
1107 * filter is actually used
1108 */
1109DLLEXPORT SIMPLE_FUNCTION
1110libtrace_filter_t *trace_bpf_setfilter(const char *filterstring);
1111
1112/** apply a BPF filter
1113 * @param filter        the filter opaque pointer
1114 * @param packet        the packet opaque pointer
1115 * @return 1 if the filter matches, 0 if it doesn't.
1116 * @note Due to the way BPF filters are built, the filter is not actually
1117 * compiled until the first time trace_bpf_filter is called. If your filter is
1118 * incorrect, it will generate an error message and assert, exiting the
1119 * program. This behaviour may change to more graceful handling of this error
1120 * in the future.
1121 */
1122DLLEXPORT int trace_bpf_filter(libtrace_filter_t *filter,
1123                const libtrace_packet_t *packet);
1124
1125/** destory of BPF filter
1126 * @param filter        the filter opaque pointer
1127 * Deallocate all the resources associated with a BPF filter
1128 */
1129DLLEXPORT void trace_destroy_bpf(libtrace_filter_t *filter);
1130/*@}*/
1131
1132/** @name Portability
1133 * This section has functions that causes annoyances to portability for one
1134 * reason or another.
1135 * @{
1136 */
1137
1138/** Convert an ethernet address to a string
1139 * @param addr  Ethernet address in network byte order
1140 * @param buf   Buffer to store the ascii representation, or NULL
1141 * @return buf, or if buf is NULL then a statically allocated buffer.
1142 *
1143 * This function is similar to the GNU ether_ntoa_r function, with a few
1144 * minor differences.  if NULL is passed as buf, then the function will
1145 * use an internal static buffer, if NULL isn't passed then the function
1146 * will use that buffer instead.
1147 *
1148 * @note the type of addr isn't struct ether_addr as it is with ether_ntoa_r,
1149 * however it is bit compatible so that a cast will work.
1150 */
1151DLLEXPORT char *trace_ether_ntoa(const uint8_t *addr, char *buf);
1152
1153/** Convert a string to an ethernet address
1154 * @param buf   Ethernet address in hex format delimited with :'s.
1155 * @param addr  buffer to store the binary representation, or NULL
1156 * @return addr, or if addr is NULL, then a statically allocated buffer.
1157 *
1158 * This function is similar to the GNU ether_aton_r function, with a few
1159 * minor differences.  if NULL is passed as addr, then the function will
1160 * use an internal static buffer, if NULL isn't passed then the function will
1161 * use that buffer instead.
1162 *
1163 * @note the type of addr isn't struct ether_addr as it is with ether_aton_r,
1164 * however it is bit compatible so that a cast will work.
1165 */
1166DLLEXPORT uint8_t *trace_ether_aton(const char *buf, uint8_t *addr);
1167
1168/*@}*/
1169
1170
1171/** Which port is the server port */
1172typedef enum {
1173        USE_DEST,       /**< Destination port is the server port */
1174        USE_SOURCE      /**< Source port is the server port */
1175} serverport_t;
1176
1177/** Get the source port
1178 * @param packet        the packet to read from
1179 * @return a port in \em HOST byte order, or equivalent to ports for this
1180 * protocol, or 0 if this protocol has no ports.
1181 */
1182DLLEXPORT SIMPLE_FUNCTION
1183uint16_t trace_get_source_port(const libtrace_packet_t *packet);
1184
1185/** Get the destination port
1186 * @param packet        the packet to read from
1187 * @return a port in \em HOST byte order, or equivilent to ports for this
1188 * protocol, or 0 if this protocol has no ports.
1189 */
1190DLLEXPORT SIMPLE_FUNCTION
1191uint16_t trace_get_destination_port(const libtrace_packet_t *packet);
1192
1193/** hint at the server port in specified protocol
1194 * @param protocol      the IP layer protocol, eg 6 (tcp), 17 (udp)
1195 * @param source        the source port from the packet
1196 * @param dest          the destination port from the packet
1197 * @return one of USE_SOURCE or USE_DEST depending on which one you should use
1198 * @note ports must be in \em HOST byte order!
1199 */
1200DLLEXPORT SIMPLE_FUNCTION
1201int8_t trace_get_server_port(uint8_t protocol, uint16_t source, uint16_t dest);
1202
1203/** Takes a uri and splits it into a format and uridata component.
1204 * @param uri           the uri to be parsed
1205 * @param format        destination location for the format component of the uri
1206 * @return 0 if an error occured, otherwise return the uridata component
1207 */
1208DLLEXPORT const char *trace_parse_uri(const char *uri, char **format);
1209
1210/** RT protocol base format identifiers
1211 * This is used to say what kind of packet is being sent over the rt protocol
1212 */
1213enum base_format_t {
1214        TRACE_FORMAT_ERF          =1,
1215        TRACE_FORMAT_PCAP         =2,
1216        TRACE_FORMAT_PCAPFILE     =3,
1217        TRACE_FORMAT_WAG          =4,
1218        TRACE_FORMAT_RT           =5,
1219        TRACE_FORMAT_LEGACY_ATM   =6,
1220        TRACE_FORMAT_LEGACY_POS   =7,
1221        TRACE_FORMAT_LEGACY_ETH   =8,
1222        TRACE_FORMAT_LINUX_NATIVE =9,
1223        TRACE_FORMAT_DUCK         =10
1224};
1225
1226/** Gets the format type for a given packet.
1227 * @param packet        the packet opaque pointer
1228 * @return the format of the packet
1229 */
1230DLLEXPORT
1231enum base_format_t trace_get_format(struct libtrace_packet_t *packet);
1232
1233
1234#ifdef __cplusplus
1235} /* extern "C" */
1236#endif /* #ifdef __cplusplus */
1237#endif /* LIBTRACE_H_ */
Note: See TracBrowser for help on using the repository browser.