libtrace.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of libtrace
00003  *
00004  * Copyright (c) 2007,2008,2009,2010 The University of Waikato, Hamilton, 
00005  * New Zealand.
00006  *
00007  * Authors: Daniel Lawson 
00008  *          Perry Lorier
00009  *          Shane Alcock 
00010  *          
00011  * All rights reserved.
00012  *
00013  * This code has been developed by the University of Waikato WAND 
00014  * research group. For further information please see http://www.wand.net.nz/
00015  *
00016  * libtrace is free software; you can redistribute it and/or modify
00017  * it under the terms of the GNU General Public License as published by
00018  * the Free Software Foundation; either version 2 of the License, or
00019  * (at your option) any later version.
00020  *
00021  * libtrace is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  * GNU General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU General Public License
00027  * along with libtrace; if not, write to the Free Software
00028  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029  *
00030  * $Id: libtrace.h.in 1707 2011-06-26 22:14:15Z salcock $
00031  *
00032  */
00033 
00034 #ifndef LIBTRACE_H
00035 #define LIBTRACE_H
00036 
00064 #include <sys/types.h>
00065 #ifndef WIN32
00066 #include <sys/time.h>
00067 #endif
00068 
00069 #ifdef _MSC_VER
00070     /* define the following from MSVC's internal types */
00071     typedef             __int8  int8_t;
00072     typedef             __int16 int16_t;
00073     typedef             __int32 int32_t;
00074     typedef             __int64 int64_t;
00075     typedef unsigned    __int8  uint8_t;
00076     typedef unsigned    __int16 uint16_t;
00077     typedef unsigned    __int32 uint32_t;
00078     typedef unsigned    __int64 uint64_t;
00079     #ifdef LT_BUILDING_DLL
00080         #define DLLEXPORT __declspec(dllexport)
00081     #else
00082         #define DLLEXPORT __declspec(dllimport)
00083     #endif
00084     #define DLLLOCAL
00085     /* Windows pads bitfields out to to the size of their parent type
00086      * however gcc warns that this doesn't meet with the iso C specification
00087      * so produces warnings for this behaviour.  sigh.
00088      */
00089     #define LT_BITFIELD8        uint8_t
00090     #define LT_BITFIELD16       uint16_t
00091     #define LT_BITFIELD32       uint32_t
00092     #define LT_BITFIELD64       uint64_t
00093 #else
00094     #ifdef HAVE_STDINT_H
00095         #   include <stdint.h>
00096     #endif
00097     #if __GNUC__ >= 4
00098         #ifdef LT_BUILDING_DLL
00099                 #define DLLEXPORT __attribute__ ((visibility("default")))
00100                 #define DLLLOCAL __attribute__ ((visibility("hidden")))
00101         #else
00102                 #define DLLEXPORT
00103                 #define DLLLOCAL
00104         #endif
00105     #else
00106         #define DLLEXPORT
00107         #define DLLLOCAL
00108     #endif
00109     /* GCC warns if the bitfield type is not "unsigned int", however windows
00110      * generates incorrect code for this (see above), so we define these
00111      * macros.  How Hideous.  So much for C's portability.
00112      */
00113     #define LT_BITFIELD8        unsigned int
00114     #define LT_BITFIELD16       unsigned int
00115     #define LT_BITFIELD32       unsigned int
00116     #define LT_BITFIELD64       unsigned int
00117 #endif
00118 
00119 #ifdef WIN32
00120 #   include <winsock2.h>
00121 #   include <ws2tcpip.h>
00122     typedef short sa_family_t;
00123     /* Make up for a lack of stdbool.h */
00124 #    define bool signed char
00125 #    define false 0
00126 #    define true 1
00127 #    if !defined(ssize_t)
00128      /* XXX: Not 64-bit safe! */
00129 #    define ssize_t int
00130 #    endif    
00131 #else
00132 #    include <netinet/in.h>
00133 
00134 #ifndef __cplusplus
00135 #    include <stdbool.h>
00136 #endif
00137 
00138 #    include <sys/types.h>
00139 #    include <sys/socket.h>
00140 #endif
00141 
00143 #define LIBTRACE_API_VERSION \
00144             ((3<<16)|(0<<8)|(10))
00145 
00148 #define LIBTRACE_SVN_REVISION 0
00149 
00151 #define DAG_DRIVER_V ""
00152     
00153 #ifdef __cplusplus 
00154 extern "C" { 
00155 #endif
00156 
00157 /* Function does not depend on anything but its
00158  * parameters, used to hint gcc's optimisations
00159  */
00160 #if __GNUC__ >= 3 
00161 #  define DEPRECATED __attribute__((deprecated))
00162 #  define SIMPLE_FUNCTION __attribute__((pure))
00163 #  define UNUSED __attribute__((unused))
00164 #  define PACKED __attribute__((packed))
00165 #  define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos)))
00166 #else
00167 #  define DEPRECATED
00168 #  define SIMPLE_FUNCTION
00169 #  define UNUSED
00170 #  define PACKED 
00171 #  define PRINTF(formatpos,argpos) 
00172 #endif
00173         
00175 typedef struct libtrace_out_t libtrace_out_t;
00176         
00178 typedef struct libtrace_t libtrace_t;
00179         
00181 typedef struct libtrace_filter_t libtrace_filter_t;
00182 
00191 typedef enum {
00192         TRACE_CTRL_PACKET='p',  
00193         TRACE_CTRL_EXTERNAL='e' 
00194 } buf_control_t;
00195 
00197 #define LIBTRACE_PACKET_BUFSIZE 65536
00198 
00200 typedef struct trace_err_t{
00201         int err_num;            
00202         char problem[255];      
00203 } libtrace_err_t;
00204 
00206 enum {
00208         TRACE_ERR_NOERROR       = 0,
00210         TRACE_ERR_BAD_FORMAT    = -1,
00212         TRACE_ERR_INIT_FAILED   = -2,
00214         TRACE_ERR_UNKNOWN_OPTION= -3,
00216         TRACE_ERR_NO_CONVERSION = -4,
00218         TRACE_ERR_BAD_PACKET    = -5,
00220         TRACE_ERR_OPTION_UNAVAIL= -6,
00222         TRACE_ERR_UNSUPPORTED   = -7,
00224         TRACE_ERR_BAD_STATE     = -8
00225 };
00226 
00229 typedef enum {
00233         TRACE_DLT_NULL = 0, 
00234         TRACE_DLT_EN10MB = 1,
00235         TRACE_DLT_PPP = 9,
00236         TRACE_DLT_ATM_RFC1483 = 11,
00237         
00242 #ifdef __OpenBSD__
00243         TRACE_DLT_RAW = 14,     
00244 #else
00245         TRACE_DLT_RAW = 12,
00246 #endif
00247         TRACE_DLT_PPP_SERIAL = 50,
00248         TRACE_DLT_LINKTYPE_RAW = 101, 
00249         TRACE_DLT_C_HDLC = 104,
00250         TRACE_DLT_IEEE802_11 = 105,
00251         TRACE_DLT_LINUX_SLL = 113,
00252         TRACE_DLT_PFLOG = 117,
00253         TRACE_DLT_IEEE802_11_RADIO = 127 
00254 } libtrace_dlt_t ;
00255 
00257 typedef enum { 
00258     /* TRACE_TYPE_LEGACY = 0            Obsolete */
00259        TRACE_TYPE_HDLC_POS = 1,         
00260        TRACE_TYPE_ETH = 2,              
00261        TRACE_TYPE_ATM = 3,              
00262        TRACE_TYPE_80211 = 4,            
00263        TRACE_TYPE_NONE = 5,             
00264        TRACE_TYPE_LINUX_SLL = 6,        
00265        TRACE_TYPE_PFLOG = 7,            
00266     /* TRACE_TYPE_LEGACY_DEFAULT        Obsolete */
00267        TRACE_TYPE_POS = 9,              
00268     /* TRACE_TYPE_LEGACY_ATM            Obsolete */
00269     /* TRACE_TYPE_LEGACY_ETH            Obsolete */
00270        TRACE_TYPE_80211_PRISM = 12,     
00271        TRACE_TYPE_AAL5 = 13,            
00272        TRACE_TYPE_DUCK = 14,         
00273        TRACE_TYPE_80211_RADIO = 15,  
00274        TRACE_TYPE_LLCSNAP = 16,      
00275        TRACE_TYPE_PPP = 17,          
00276        TRACE_TYPE_METADATA = 18,        
00277        TRACE_TYPE_NONDATA = 19          
00278 } libtrace_linktype_t;
00279 
00284 enum base_format_t {
00285         TRACE_FORMAT_ERF          =1,   
00286         TRACE_FORMAT_PCAP         =2,   
00287         TRACE_FORMAT_PCAPFILE     =3,   
00288         TRACE_FORMAT_WAG          =4,   
00289         TRACE_FORMAT_RT           =5,   
00290         TRACE_FORMAT_LEGACY_ATM   =6,   
00291         TRACE_FORMAT_LEGACY_POS   =7,   
00292         TRACE_FORMAT_LEGACY_ETH   =8,   
00293         TRACE_FORMAT_LINUX_NATIVE =9,   
00294         TRACE_FORMAT_DUCK         =10,  
00295         TRACE_FORMAT_BPF          =11,  
00296         TRACE_FORMAT_TSH          =12,  
00297         TRACE_FORMAT_ATMHDR       =13,  
00298         TRACE_FORMAT_LEGACY_NZIX  =14   
00299 };
00300 
00302 typedef enum {
00303         TRACE_RT_HELLO          =1, 
00304         TRACE_RT_START          =2, 
00306         TRACE_RT_ACK            =3, 
00307         TRACE_RT_STATUS         =4, 
00308         TRACE_RT_DUCK           =5, 
00309         TRACE_RT_END_DATA       =6, 
00310         TRACE_RT_CLOSE          =7, 
00311         TRACE_RT_DENY_CONN      =8, 
00312         TRACE_RT_PAUSE          =9, 
00314         TRACE_RT_PAUSE_ACK      =10,
00315         TRACE_RT_OPTION         =11,
00316         TRACE_RT_KEYCHANGE      =12,
00317         TRACE_RT_DUCK_2_4       =13,
00318         TRACE_RT_DUCK_2_5       =14,
00319         TRACE_RT_LOSTCONN       =15,
00320         TRACE_RT_SERVERSTART    =16,
00321         TRACE_RT_CLIENTDROP     =17,
00322         TRACE_RT_METADATA       =18,
00325         TRACE_RT_DATA_SIMPLE    = 1000, 
00326         
00328         TRACE_RT_DATA_ERF       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_ERF, 
00330         TRACE_RT_DATA_WAG       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_WAG, 
00332         TRACE_RT_DATA_LEGACY_ATM=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_ATM, 
00334         TRACE_RT_DATA_LEGACY_POS=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_POS, 
00336         TRACE_RT_DATA_LEGACY_ETH=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_ETH, 
00338         TRACE_RT_DATA_LINUX_NATIVE=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LINUX_NATIVE,
00340         TRACE_RT_DATA_BPF       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_BPF,
00342         TRACE_RT_DATA_TSH       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_TSH,
00344         TRACE_RT_DATA_ATMHDR = TRACE_RT_DATA_SIMPLE + TRACE_FORMAT_ATMHDR,
00346         TRACE_RT_DATA_LEGACY_NZIX=TRACE_RT_DATA_SIMPLE + TRACE_FORMAT_LEGACY_NZIX,
00347 
00351         TRACE_RT_DATA_DLT               = 2000, 
00353         TRACE_RT_DLT_NULL               =TRACE_RT_DATA_DLT+TRACE_DLT_NULL,
00356         TRACE_RT_DLT_EN10MB             =TRACE_RT_DATA_DLT+TRACE_DLT_EN10MB,
00359         TRACE_RT_DLT_IEEE802_11         =TRACE_RT_DATA_DLT+TRACE_DLT_IEEE802_11,
00362         TRACE_RT_DLT_LINUX_SLL          =TRACE_RT_DATA_DLT+TRACE_DLT_LINUX_SLL,
00364         TRACE_RT_DLT_PFLOG              =TRACE_RT_DATA_DLT+TRACE_DLT_PFLOG,
00366         TRACE_RT_DLT_ATM_RFC1483        =TRACE_RT_DATA_DLT+TRACE_DLT_ATM_RFC1483,
00369         TRACE_RT_DATA_DLT_END           = 2999,
00372         TRACE_RT_LAST                   = (2<<31)
00373 } libtrace_rt_types_t;
00374 
00376 typedef enum {
00377         TRACE_IPPROTO_IP        = 0,    
00378         TRACE_IPPROTO_ICMP      = 1,    
00379         TRACE_IPPROTO_IGMP      = 2,    
00380         TRACE_IPPROTO_IPIP      = 4,    
00381         TRACE_IPPROTO_TCP       = 6,    
00382         TRACE_IPPROTO_UDP       = 17,   
00383         TRACE_IPPROTO_IPV6      = 41,   
00384         TRACE_IPPROTO_ROUTING   = 43,   
00385         TRACE_IPPROTO_FRAGMENT  = 44,   
00386         TRACE_IPPROTO_RSVP      = 46,   
00387         TRACE_IPPROTO_GRE       = 47,   
00388         TRACE_IPPROTO_ESP       = 50,   
00389         TRACE_IPPROTO_AH        = 51,   
00390         TRACE_IPPROTO_ICMPV6    = 58,   
00391         TRACE_IPPROTO_NONE      = 59,   
00392         TRACE_IPPROTO_DSTOPTS   = 60,   
00393         TRACE_IPPROTO_PIM       = 103,  
00394         TRACE_IPPROTO_SCTP      = 132   
00395 } libtrace_ipproto_t;
00396 
00398 typedef enum {
00399         /* Numbers <=1500 are of course, LLC/SNAP */
00400         TRACE_ETHERTYPE_IP      = 0x0800,       
00401         TRACE_ETHERTYPE_ARP     = 0x0806,       
00402         TRACE_ETHERTYPE_RARP    = 0x8035,       
00403         TRACE_ETHERTYPE_8021Q   = 0x8100,       
00404         TRACE_ETHERTYPE_IPV6    = 0x86DD,       
00405         TRACE_ETHERTYPE_MPLS    = 0x8847,       
00406         TRACE_ETHERTYPE_MPLS_MC = 0x8848,       
00407         TRACE_ETHERTYPE_PPP_DISC= 0x8863,       
00408         TRACE_ETHERTYPE_PPP_SES = 0x8864        
00409 } libtrace_ethertype_t;
00410 
00414 typedef struct libtrace_packet_t {
00415         struct libtrace_t *trace;       
00416         void *header;                   
00417         void *payload;                  
00418         void *buffer;                   
00419         libtrace_rt_types_t  type;      
00420         buf_control_t buf_control;      
00421         int capture_length;             
00422         int payload_length;             
00423         void *l3_header;                
00424         uint16_t l3_ethertype;          
00425         void *l4_header;                
00426         uint8_t transport_proto;        
00427 } libtrace_packet_t;
00428 
00429 
00435 typedef enum {
00436         TRACE_DIR_OUTGOING = 0,         
00437         TRACE_DIR_INCOMING = 1,         
00438         TRACE_DIR_OTHER    = 2          
00439 } libtrace_direction_t;
00440 
00442 typedef enum {
00443     TRACE_RADIOTAP_TSFT = 0, 
00444     TRACE_RADIOTAP_FLAGS = 1, 
00445     TRACE_RADIOTAP_RATE = 2, 
00446     TRACE_RADIOTAP_CHANNEL = 3, 
00447     TRACE_RADIOTAP_FHSS = 4, 
00448     TRACE_RADIOTAP_DBM_ANTSIGNAL = 5, 
00449     TRACE_RADIOTAP_DBM_ANTNOISE = 6, 
00450     TRACE_RADIOTAP_LOCK_QUALITY = 7, 
00451     TRACE_RADIOTAP_TX_ATTENUATION = 8, 
00452     TRACE_RADIOTAP_DB_TX_ATTENUATION = 9, 
00453     TRACE_RADIOTAP_DBM_TX_POWER = 10, 
00454     TRACE_RADIOTAP_ANTENNA = 11, 
00455     TRACE_RADIOTAP_DB_ANTSIGNAL = 12, 
00456     TRACE_RADIOTAP_DB_ANTNOISE = 13, 
00457     TRACE_RADIOTAP_RX_FLAGS = 14, 
00458     TRACE_RADIOTAP_TX_FLAGS = 15, 
00459     TRACE_RADIOTAP_RTS_RETRIES = 16, 
00460     TRACE_RADIOTAP_DATA_RETRIES = 17, 
00461     TRACE_RADIOTAP_EXT = 31
00462 } libtrace_radiotap_field_t;
00463 
00464 
00471 #ifdef WIN32
00472 #pragma pack(push)
00473 #pragma pack(1)
00474 #endif
00475 
00477 typedef struct libtrace_ip
00478 {
00479 #if BYTE_ORDER == LITTLE_ENDIAN
00480     LT_BITFIELD8 ip_hl:4;               
00481     LT_BITFIELD8 ip_v:4;                
00482 #elif BYTE_ORDER == BIG_ENDIAN
00483     LT_BITFIELD8 ip_v:4;                
00484     LT_BITFIELD8 ip_hl:4;               
00485 #else
00486 #   error "Adjust your <bits/endian.h> defines"
00487 #endif
00488     uint8_t  ip_tos;                    
00489     uint16_t ip_len;                    
00490     int16_t  ip_id;                     
00491     uint16_t ip_off;                    
00492     uint8_t  ip_ttl;                    
00493     uint8_t  ip_p;                      
00494     uint16_t ip_sum;                    
00495     struct in_addr ip_src;              
00496     struct in_addr ip_dst;              
00497 } PACKED libtrace_ip_t;
00498 
00500 typedef struct libtrace_ip6_ext
00501 {
00502         uint8_t nxt;    
00503         uint8_t len;    
00504 } PACKED libtrace_ip6_ext_t;
00505 
00506 typedef struct libtrace_ip6_frag 
00507 {
00508         uint8_t nxt;    
00509         uint8_t res;    
00510         uint16_t frag_off;      
00511         uint32_t ident; 
00512 } PACKED libtrace_ip6_frag_t;
00513 
00519 typedef struct libtrace_ip6
00520 { 
00521     uint32_t flow;                      
00522     uint16_t plen;                      
00523     uint8_t nxt;                        
00524     uint8_t hlim;                       
00525     struct in6_addr ip_src;             
00526     struct in6_addr ip_dst;             
00527 } PACKED libtrace_ip6_t;
00528 
00530 typedef struct libtrace_tcp
00531   {
00532     uint16_t source;            
00533     uint16_t dest;              
00534     uint32_t seq;               
00535     uint32_t ack_seq;           
00536 #  if BYTE_ORDER == LITTLE_ENDIAN
00537     LT_BITFIELD8 ecn_ns:1;      
00538     LT_BITFIELD8 res1:3;        
00539     LT_BITFIELD8 doff:4;        
00540     LT_BITFIELD8 fin:1;         
00541     LT_BITFIELD8 syn:1;         
00542     LT_BITFIELD8 rst:1;         
00543     LT_BITFIELD8 psh:1;         
00544     LT_BITFIELD8 ack:1;         
00545     LT_BITFIELD8 urg:1;         
00546     LT_BITFIELD8 ece:1;         
00547     LT_BITFIELD8 cwr:1;         
00548 #  elif BYTE_ORDER == BIG_ENDIAN
00549     LT_BITFIELD8 doff:4;        
00550     LT_BITFIELD8 res1:3;        
00551     LT_BITFIELD8 ecn_ns:1;      
00552     LT_BITFIELD8 cwr:1;         
00553     LT_BITFIELD8 ece:1;         
00554     LT_BITFIELD8 urg:1;         
00555     LT_BITFIELD8 ack:1;         
00556     LT_BITFIELD8 psh:1;         
00557     LT_BITFIELD8 rst:1;         
00558     LT_BITFIELD8 syn:1;         
00559     LT_BITFIELD8 fin:1;         
00560 #  else
00561 #   error "Adjust your <bits/endian.h> defines"
00562 #  endif
00563     uint16_t window;            
00564     uint16_t check;             
00565     uint16_t urg_ptr;           
00566 } PACKED libtrace_tcp_t;
00567 
00569 typedef struct libtrace_udp {
00570   uint16_t      source;         
00571   uint16_t      dest;           
00572   uint16_t      len;            
00573   uint16_t      check;          
00574 } PACKED libtrace_udp_t;
00575 
00577 typedef struct libtrace_icmp
00578 {
00579   uint8_t type;         
00580   uint8_t code;         
00581   uint16_t checksum;            
00582   union
00583   {
00584     struct
00585     {
00586       uint16_t  id;             
00587       uint16_t  sequence;       
00588     } echo;                     
00589     uint32_t    gateway;        
00590     struct
00591     {
00592       uint16_t  unused;         
00593       uint16_t  mtu;            
00594     } frag;                     
00595   } un;                         
00596 } PACKED libtrace_icmp_t;
00597 
00599 typedef struct libtrace_llcsnap
00600 {
00601 /* LLC */
00602   uint8_t dsap;                 
00603   uint8_t ssap;                 
00604   uint8_t control;              
00605 /* SNAP */
00606   LT_BITFIELD32 oui:24;         
00607   uint16_t type;                
00608 } PACKED libtrace_llcsnap_t;
00609 
00611 typedef struct libtrace_ether
00612 {
00613   uint8_t ether_dhost[6];       
00614   uint8_t ether_shost[6];       
00615   uint16_t ether_type;          
00616 } PACKED libtrace_ether_t;
00617 
00619 typedef struct libtrace_8021q 
00620 {
00621   LT_BITFIELD16 vlan_pri:3;      
00622   LT_BITFIELD16 vlan_cfi:1;      
00624   LT_BITFIELD16 vlan_id:12;      
00625   uint16_t vlan_ether_type;      
00627 } PACKED libtrace_8021q_t;
00628 
00630 typedef struct libtrace_atm_cell
00631 {
00632   LT_BITFIELD32 gfc:4;          
00633   LT_BITFIELD32 vpi:8;          
00634   LT_BITFIELD32 vci:16;         
00635   LT_BITFIELD32 pt:3;           
00636   LT_BITFIELD32 clp:1;          
00637   LT_BITFIELD32 hec:8;          
00638 } PACKED libtrace_atm_cell_t;
00639 
00641 typedef struct libtrace_atm_nni_cell
00642 {
00643   LT_BITFIELD32 vpi:12;         
00644   LT_BITFIELD32 vci:16;         
00645   LT_BITFIELD32 pt:3;           
00646   LT_BITFIELD32 clp:1;          
00647   LT_BITFIELD32 hec:8;          
00648 } PACKED libtrace_atm_nni_cell_t;
00649 
00657 typedef struct libtrace_atm_capture_cell
00658 {
00659   LT_BITFIELD32 gfc:4;          
00660   LT_BITFIELD32 vpi:8;          
00661   LT_BITFIELD32 vci:16;         
00662   LT_BITFIELD32 pt:3;           
00663   LT_BITFIELD32 clp:1;          
00664 } PACKED libtrace_atm_capture_cell_t;
00665 
00673 typedef struct libtrace_atm_nni_capture_cell
00674 {
00675   LT_BITFIELD32 vpi:12;         
00676   LT_BITFIELD32 vci:16;         
00677   LT_BITFIELD32 pt:3;           
00678   LT_BITFIELD32 clp:1;          
00679   LT_BITFIELD32 hec:8;          
00680 } PACKED libtrace_atm_nni_capture_cell_t;
00681 
00683 typedef struct libtrace_ppp
00684 {
00685  /* I can't figure out where the hell these two variables come from. They're
00686   * definitely not in RFC 1661 which defines PPP. Probably some weird thing
00687   * relating to the lack of distinction between PPP, HDLC and CHDLC */
00688         
00689 /* uint8_t address; */          
00690 /* uint8_t header;  */          
00691  uint16_t protocol;             
00692 } PACKED libtrace_ppp_t;
00693 
00695 typedef struct libtrace_pppoe
00696 {
00697  LT_BITFIELD8 version:4;        
00698  LT_BITFIELD8 type:4;           
00699  uint8_t code;                  
00700  uint16_t session_id;           
00701  uint16_t length;               
00702 } PACKED libtrace_pppoe_t;
00703 
00705 typedef struct libtrace_80211_t {
00706 #if BYTE_ORDER == LITTLE_ENDIAN
00707         LT_BITFIELD32      protocol:2;  
00708         LT_BITFIELD32      type:2;      
00709         LT_BITFIELD32      subtype:4;   
00710 #else
00711         LT_BITFIELD32      subtype:4;   
00712         LT_BITFIELD32      type:2;      
00713         LT_BITFIELD32      protocol:2;  
00714 #endif
00715 
00716 #if BYTE_ORDER == LITTLE_ENDIAN
00717         LT_BITFIELD32      to_ds:1;     
00718         LT_BITFIELD32      from_ds:1;   
00719         LT_BITFIELD32      more_frag:1; 
00720         LT_BITFIELD32      retry:1;     
00721         LT_BITFIELD32      power:1;     
00722         LT_BITFIELD32      more_data:1; 
00723         LT_BITFIELD32      wep:1;       
00724         LT_BITFIELD32      order:1;     
00725 #else
00726         LT_BITFIELD32      order:1;     
00727         LT_BITFIELD32      wep:1;       
00728         LT_BITFIELD32      more_data:1; 
00729         LT_BITFIELD32      power:1;     
00730         LT_BITFIELD32      retry:1;     
00731         LT_BITFIELD32      more_frag:1; 
00732         LT_BITFIELD32      from_ds:1;   
00733         LT_BITFIELD32      to_ds:1;     
00734 #endif
00735         uint16_t     duration;  
00736         uint8_t      mac1[6];   
00737         uint8_t      mac2[6];   
00738         uint8_t      mac3[6];   
00739         uint16_t     SeqCtl;    
00740         uint8_t      mac4[6];   
00741 } PACKED libtrace_80211_t;
00742 
00750 typedef struct libtrace_radiotap_t {
00751     uint8_t     it_version; 
00752     uint8_t     it_pad; 
00753     uint16_t    it_len; 
00754     uint32_t    it_present; 
00755 } PACKED libtrace_radiotap_t;
00756 
00757 
00758 #ifdef WIN32
00759 #pragma pack(pop)
00760 #endif
00761 
00762 
00770 DLLEXPORT void trace_help(void);
00771 
00790 DLLEXPORT const char *trace_parse_uri(const char *uri, char **format);
00791 
00812 DLLEXPORT libtrace_t *trace_create(const char *uri);
00813 
00827 DLLEXPORT libtrace_t *trace_create_dead(const char *uri);
00828 
00842 DLLEXPORT libtrace_out_t *trace_create_output(const char *uri);
00843 
00853 DLLEXPORT int trace_start(libtrace_t *libtrace);
00854 
00864 DLLEXPORT int trace_pause(libtrace_t *libtrace);
00865 
00873 DLLEXPORT int trace_start_output(libtrace_out_t *libtrace);
00874 
00876 typedef enum {
00878         TRACE_OPTION_SNAPLEN,   
00879 
00881         TRACE_OPTION_PROMISC,   
00882 
00884         TRACE_OPTION_FILTER,    
00885 
00887         TRACE_OPTION_META_FREQ, 
00888 
00891         TRACE_OPTION_EVENT_REALTIME
00892 } trace_option_t;
00893 
00901 DLLEXPORT int trace_config(libtrace_t *libtrace,
00902                 trace_option_t option,
00903                 void *value);
00904 
00908 typedef enum {
00909         TRACE_OPTION_COMPRESSTYPE_NONE = 0, 
00910         TRACE_OPTION_COMPRESSTYPE_ZLIB = 1, 
00911         TRACE_OPTION_COMPRESSTYPE_BZ2  = 2, 
00912         TRACE_OPTION_COMPRESSTYPE_LZO  = 3  
00913 } trace_option_compresstype_t;
00914 
00916 typedef enum {
00918         TRACE_OPTION_OUTPUT_FILEFLAGS,
00921         TRACE_OPTION_OUTPUT_COMPRESS,
00923         TRACE_OPTION_OUTPUT_COMPRESSTYPE
00924 } trace_option_output_t;
00925 
00935 DLLEXPORT int trace_config_output(libtrace_out_t *libtrace, 
00936                 trace_option_output_t option,
00937                 void *value
00938                 );
00939 
00945 DLLEXPORT void trace_destroy(libtrace_t *trace);
00946 
00950 DLLEXPORT void trace_destroy_dead(libtrace_t *trace);
00951 
00955 DLLEXPORT void trace_destroy_output(libtrace_out_t *trace);
00956 
00964 DLLEXPORT libtrace_err_t trace_get_err(libtrace_t *trace);
00965 
00972 DLLEXPORT bool trace_is_err(libtrace_t *trace);
00973 
00981 DLLEXPORT void trace_perror(libtrace_t *trace, const char *msg,...) PRINTF(2,3);
00982 
00990 DLLEXPORT libtrace_err_t trace_get_err_output(libtrace_out_t *trace);
00991 
00998 DLLEXPORT bool trace_is_err_output(libtrace_out_t *trace);
00999 
01006 DLLEXPORT void trace_perror_output(libtrace_out_t *trace, const char *msg,...)
01007         PRINTF(2,3);
01008 
01018 DLLEXPORT
01019 uint64_t trace_get_received_packets(libtrace_t *trace);
01020 
01029 DLLEXPORT
01030 uint64_t trace_get_filtered_packets(libtrace_t *trace);
01031 
01040 DLLEXPORT
01041 uint64_t trace_get_dropped_packets(libtrace_t *trace);
01042 
01051 DLLEXPORT
01052 uint64_t trace_get_accepted_packets(libtrace_t *trace);
01053 
01054 
01067 DLLEXPORT libtrace_packet_t *trace_create_packet(void);
01068 
01081 DLLEXPORT libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet);
01082 
01087 DLLEXPORT void trace_destroy_packet(libtrace_packet_t *packet);
01088 
01089 
01107 DLLEXPORT int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet);
01108 
01112 typedef enum {
01113         TRACE_EVENT_IOWAIT,     
01114         TRACE_EVENT_SLEEP,      
01115         TRACE_EVENT_PACKET,     
01116         TRACE_EVENT_TERMINATE   
01117 } libtrace_event_t;
01118 
01120 typedef struct libtrace_eventobj_t {
01121         libtrace_event_t type; 
01124         int fd;                
01126         double seconds;        
01128         int size; 
01129 } libtrace_eventobj_t;
01130 
01142 DLLEXPORT libtrace_eventobj_t trace_event(libtrace_t *trace,
01143                 libtrace_packet_t *packet);
01144 
01145 
01152 DLLEXPORT int trace_write_packet(libtrace_out_t *trace, libtrace_packet_t *packet);
01153 
01162 DLLEXPORT 
01163 enum base_format_t trace_get_format(struct libtrace_packet_t *packet);
01164 
01177 DLLEXPORT
01178 void trace_construct_packet(libtrace_packet_t *packet,
01179                 libtrace_linktype_t linktype, const void *data, uint16_t len);
01180 
01227 DLLEXPORT void *trace_get_packet_buffer(const libtrace_packet_t *packet,
01228                 libtrace_linktype_t *linktype, uint32_t *remaining);
01229 
01240 DLLEXPORT SIMPLE_FUNCTION DEPRECATED
01241 void *trace_get_link(const libtrace_packet_t *packet);
01242 
01253 DLLEXPORT SIMPLE_FUNCTION
01254 libtrace_ip_t *trace_get_ip(libtrace_packet_t *packet);
01255 
01266 DLLEXPORT SIMPLE_FUNCTION
01267 libtrace_ip6_t *trace_get_ip6(libtrace_packet_t *packet);
01268 
01291 DLLEXPORT void *trace_get_packet_meta(const libtrace_packet_t *packet,
01292                 libtrace_linktype_t *linktype,
01293                 uint32_t *remaining);
01294 
01332 DLLEXPORT void *trace_get_payload_from_meta(const void *meta,
01333                 libtrace_linktype_t *linktype,
01334                 uint32_t *remaining);
01335 
01336 
01353 DLLEXPORT void *trace_get_layer2(const libtrace_packet_t *packet,
01354                 libtrace_linktype_t *linktype,
01355                 uint32_t *remaining);
01356 
01380 DLLEXPORT void *trace_get_payload_from_layer2(void *l2,
01381                 libtrace_linktype_t linktype,
01382                 uint16_t *ethertype,
01383                 uint32_t *remaining);
01384 
01385 
01399 DLLEXPORT 
01400 void *trace_get_layer3(const libtrace_packet_t *packet,
01401                 uint16_t *ethertype, uint32_t *remaining);
01402 
01419 DLLEXPORT void *trace_get_transport(const libtrace_packet_t *packet, 
01420                 uint8_t *proto, uint32_t *remaining);
01421 
01445 DLLEXPORT void *trace_get_payload_from_ip(libtrace_ip_t *ip, uint8_t *proto,
01446                 uint32_t *remaining);
01447 
01470 DLLEXPORT void *trace_get_payload_from_ip6(libtrace_ip6_t *ipptr,
01471                 uint8_t *proto, uint32_t *remaining);
01472 
01491 DLLEXPORT void *trace_get_payload_from_link(void *linkptr,
01492                 libtrace_linktype_t linktype, 
01493                 uint16_t *type, uint32_t *remaining);
01494 
01518 DLLEXPORT void *trace_get_payload_from_vlan(
01519                 void *vlan, uint16_t *type, uint32_t *remaining);
01520 
01550 DLLEXPORT void *trace_get_payload_from_mpls(
01551                 void *mpls, uint16_t *type, uint32_t *remaining);
01552 
01579 DLLEXPORT void *trace_get_payload_from_pppoe(
01580                 void *pppoe, uint16_t *type, uint32_t *remaining);
01581 
01600 DLLEXPORT void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, 
01601                 uint32_t *remaining);
01602 
01621 DLLEXPORT void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining);
01622 
01645 DLLEXPORT void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, 
01646                 uint32_t *remaining);
01647 
01661 DLLEXPORT SIMPLE_FUNCTION
01662 libtrace_tcp_t *trace_get_tcp(libtrace_packet_t *packet);
01663 
01688 DLLEXPORT SIMPLE_FUNCTION
01689 libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip, uint32_t *remaining);
01690 
01704 DLLEXPORT SIMPLE_FUNCTION
01705 libtrace_udp_t *trace_get_udp(libtrace_packet_t *packet);
01706 
01731 DLLEXPORT SIMPLE_FUNCTION
01732 libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
01733 
01747 DLLEXPORT SIMPLE_FUNCTION
01748 libtrace_icmp_t *trace_get_icmp(libtrace_packet_t *packet);
01749 
01774 DLLEXPORT SIMPLE_FUNCTION
01775 libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
01776 
01787 DLLEXPORT SIMPLE_FUNCTION
01788 uint8_t *trace_get_destination_mac(libtrace_packet_t *packet);
01789 
01800 DLLEXPORT SIMPLE_FUNCTION
01801 uint8_t *trace_get_source_mac(libtrace_packet_t *packet);
01802 
01816 DLLEXPORT SIMPLE_FUNCTION
01817 struct sockaddr *trace_get_source_address(const libtrace_packet_t *packet,
01818                 struct sockaddr *addr);
01819 
01833 DLLEXPORT SIMPLE_FUNCTION
01834 struct sockaddr *trace_get_destination_address(const libtrace_packet_t *packet,
01835                 struct sockaddr *addr);
01836 
01837 
01855 DLLEXPORT int trace_get_next_option(unsigned char **ptr,int *len,
01856                         unsigned char *type,
01857                         unsigned char *optlen,
01858                         unsigned char **data);
01859 
01874 DLLEXPORT SIMPLE_FUNCTION
01875 uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet);
01876 
01882 DLLEXPORT SIMPLE_FUNCTION
01883 struct timeval trace_get_timeval(const libtrace_packet_t *packet);
01884 
01890 DLLEXPORT SIMPLE_FUNCTION
01891 struct timespec trace_get_timespec(const libtrace_packet_t *packet);
01892 
01899 DLLEXPORT SIMPLE_FUNCTION
01900 double trace_get_seconds(const libtrace_packet_t *packet);
01901 
01918 DLLEXPORT int trace_seek_seconds(libtrace_t *trace, double seconds);
01919 
01933 DLLEXPORT int trace_seek_timeval(libtrace_t *trace, struct timeval tv);
01934 
01952 DLLEXPORT int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts);
01953 
01982 DLLEXPORT SIMPLE_FUNCTION
01983 size_t trace_get_capture_length(const libtrace_packet_t *packet);
01984 
02001 DLLEXPORT SIMPLE_FUNCTION
02002 size_t trace_get_wire_length(const libtrace_packet_t *packet);
02003 
02012 DLLEXPORT SIMPLE_FUNCTION
02013 size_t trace_get_framing_length(const libtrace_packet_t *packet);
02014 
02029 DLLEXPORT SIMPLE_FUNCTION
02030 size_t trace_get_payload_length(const libtrace_packet_t *packet);
02031 
02046 DLLEXPORT size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size);
02047 
02056 DLLEXPORT SIMPLE_FUNCTION
02057 libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet);
02058 
02069 DLLEXPORT libtrace_direction_t trace_set_direction(libtrace_packet_t *packet, libtrace_direction_t direction);
02070 
02086 DLLEXPORT SIMPLE_FUNCTION
02087 libtrace_direction_t trace_get_direction(const libtrace_packet_t *packet);
02088 
02102 DLLEXPORT SIMPLE_FUNCTION
02103 libtrace_filter_t *trace_create_filter(const char *filterstring);
02104 
02114 DLLEXPORT libtrace_filter_t *
02115 trace_create_filter_from_bytecode(void *bf_insns, unsigned int bf_len);
02116 
02128 DLLEXPORT int trace_apply_filter(libtrace_filter_t *filter,
02129                 const libtrace_packet_t *packet);
02130 
02136 DLLEXPORT void trace_destroy_filter(libtrace_filter_t *filter);
02162 DLLEXPORT char *trace_ether_ntoa(const uint8_t *addr, char *buf);
02163 
02181 DLLEXPORT uint8_t *trace_ether_aton(const char *buf, uint8_t *addr);
02182 
02193 typedef enum {
02194         USE_DEST,       
02195         USE_SOURCE      
02196 } serverport_t;
02197 
02211 DLLEXPORT SIMPLE_FUNCTION
02212 uint16_t trace_get_source_port(const libtrace_packet_t *packet);
02213 
02229 DLLEXPORT SIMPLE_FUNCTION
02230 uint16_t trace_get_destination_port(const libtrace_packet_t *packet);
02231 
02248 DLLEXPORT SIMPLE_FUNCTION
02249 int8_t trace_get_server_port(uint8_t protocol, uint16_t source, uint16_t dest);
02250 
02270 #ifndef ARPHRD_80211_RADIOTAP
02271 
02272 #define ARPHRD_80211_RADIOTAP 803
02273 #endif
02274 
02286 DLLEXPORT bool trace_get_wireless_tsft(void *linkptr,
02287         libtrace_linktype_t linktype, uint64_t *tsft);
02288 
02296 DLLEXPORT bool trace_get_wireless_rate(void *linkptr,
02297         libtrace_linktype_t linktype, uint8_t *rate);
02298 
02306 DLLEXPORT bool trace_get_wireless_freq(void *linkptr,
02307         libtrace_linktype_t linktype, uint16_t *freq);
02308 
02316 DLLEXPORT bool trace_get_wireless_signal_strength_dbm(void *linkptr,
02317         libtrace_linktype_t linktype, int8_t *strength);
02318 
02326 DLLEXPORT bool trace_get_wireless_noise_strength_dbm(void *linkptr,
02327         libtrace_linktype_t linktype, int8_t *strength);
02328 
02336 DLLEXPORT bool trace_get_wireless_signal_strength_db(void *linkptr,
02337         libtrace_linktype_t linktype, uint8_t *strength);
02338 
02346 DLLEXPORT bool trace_get_wireless_noise_strength_db(void *linkptr,
02347         libtrace_linktype_t linktype, uint8_t *strength);
02348 
02357 DLLEXPORT bool trace_get_wireless_tx_attenuation(void *linkptr,
02358         libtrace_linktype_t linktype, uint16_t *attenuation);
02359 
02367 DLLEXPORT bool trace_get_wireless_tx_attenuation_db(void *linkptr,
02368         libtrace_linktype_t linktype, uint16_t *attenuation);
02369 
02377 DLLEXPORT bool trace_get_wireless_tx_power_dbm(void *linkptr, 
02378                 libtrace_linktype_t linktype, int8_t *txpower);
02379 
02387 DLLEXPORT bool trace_get_wireless_antenna(void *linkptr,
02388         libtrace_linktype_t linktype, uint8_t *antenna);
02389 
02392 #ifdef __cplusplus
02393 } /* extern "C" */
02394 #endif /* #ifdef __cplusplus */
02395 #endif /* LIBTRACE_H_ */

Generated on Fri Jul 1 09:50:24 2011 for WAND Trace processing by  doxygen 1.5.1