source: lib/libtrace.h @ c37ab9f

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

More documentation, add some enum's documenting the convention for directions

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