Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

libtrace.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of libtrace
00003  *
00004  * Copyright (c) 2007,2008 The University of Waikato, Hamilton, New Zealand.
00005  * Authors: Daniel Lawson 
00006  *          Perry Lorier 
00007  *          
00008  * All rights reserved.
00009  *
00010  * This code has been developed by the University of Waikato WAND 
00011  * research group. For further information please see http://www.wand.net.nz/
00012  *
00013  * libtrace is free software; you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation; either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * libtrace is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with libtrace; if not, write to the Free Software
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  *
00027  * $Id: libtrace.h 773 2006-05-01 12:58:09Z perry $
00028  *
00029  */
00030 
00031 #ifndef LIBTRACE_H
00032 #define LIBTRACE_H
00033 
00058 #include <sys/types.h>
00059 #ifndef WIN32
00060 #include <sys/time.h>
00061 #endif
00062 
00063 #ifdef _MSC_VER
00064     /* define the following from MSVC's internal types */
00065     typedef             __int8  int8_t;
00066     typedef             __int16 int16_t;
00067     typedef             __int32 int32_t;
00068     typedef             __int64 int64_t;
00069     typedef unsigned    __int8  uint8_t;
00070     typedef unsigned    __int16 uint16_t;
00071     typedef unsigned    __int32 uint32_t;
00072     typedef unsigned    __int64 uint64_t;
00073     #ifdef BUILDING_DLL
00074         #define DLLEXPORT __declspec(dllexport)
00075     #else
00076         #define DLLEXPORT __declspec(dllimport)
00077     #endif
00078     #define DLLLOCAL
00079     /* Windows pads bitfields out to to the size of their parent type
00080      * however gcc warns that this doesn't meet with the iso C specification
00081      * so produces warnings for this behaviour.  sigh.
00082      */
00083     #define LT_BITFIELD8        uint8_t
00084     #define LT_BITFIELD16       uint16_t
00085     #define LT_BITFIELD32       uint32_t
00086     #define LT_BITFIELD64       uint64_t
00087 #else
00088 #   include <stdint.h>
00089     #ifdef HAVE_GCCVISIBILITYPATCH
00090         #define DLLEXPORT __attribute__ (visibility("default"))
00091         #define DLLLOCAL __attribute__ (visibility("hidden"))
00092     #else
00093         #define DLLEXPORT
00094         #define DLLLOCAL
00095     #endif
00096     /* GCC warns if the bitfield type is not "unsigned int", however windows
00097      * generates incorrect code for this (see above), so we define these
00098      * macros.  How Hidious.  So much for C's portability.
00099      */
00100     #define LT_BITFIELD8        unsigned int
00101     #define LT_BITFIELD16       unsigned int
00102     #define LT_BITFIELD32       unsigned int
00103     #define LT_BITFIELD64       unsigned int
00104 #endif
00105 
00106 #ifdef WIN32
00107 #   include <winsock2.h>
00108 #   include <ws2tcpip.h>
00109     typedef short sa_family_t;
00110     /* Make up for a lack of stdbool.h */
00111 #    define bool signed char
00112 #    define false 0
00113 #    define true 1
00114 #    if !defined(ssize_t)
00115      /* XXX: Not 64-bit safe! */
00116 #    define ssize_t int
00117 #    endif    
00118 #else
00119 #    include <netinet/in.h>
00120 
00121 #ifndef __cplusplus
00122 #    include <stdbool.h>
00123 #endif
00124 
00125 #    include <sys/types.h>
00126 #    include <sys/socket.h>
00127 #endif
00128 
00130 #define LIBTRACE_API_VERSION \
00131             ((3<<16)|(0<<8)|(3))
00132 
00133 #define LIBTRACE_SVN_REVISION 0
00134 #define DAG_DRIVER_V ""
00135     
00136 #ifdef __cplusplus 
00137 extern "C" { 
00138 #endif
00139 
00140 /* Function does not depend on anything but its
00141  * parameters, used to hint gcc's optimisations
00142  */
00143 #if __GNUC__ >= 3 
00144 #  define DEPRECATED __attribute__((deprecated))
00145 #  define SIMPLE_FUNCTION __attribute__((pure))
00146 #  define UNUSED __attribute__((unused))
00147 #  define PACKED __attribute__((packed))
00148 #  define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos)))
00149 #else
00150 #  define DEPRECATED
00151 #  define SIMPLE_FUNCTION
00152 #  define UNUSED
00153 #  define PACKED 
00154 #  define PRINTF(formatpos,argpos) 
00155 #endif
00156         
00158 typedef struct libtrace_out_t libtrace_out_t;
00159         
00161 typedef struct libtrace_t libtrace_t;
00162         
00164 typedef struct libtrace_filter_t libtrace_filter_t;
00165 
00174 typedef enum {
00175         TRACE_CTRL_PACKET='p',
00176         TRACE_CTRL_EXTERNAL='e' 
00177 } buf_control_t;
00179 #define LIBTRACE_PACKET_BUFSIZE 65536
00180 
00182 typedef struct trace_err_t{
00183         int err_num;            
00184         char problem[255];      
00185 } libtrace_err_t;
00186 
00188 enum {
00190         TRACE_ERR_NOERROR       = 0,
00192         TRACE_ERR_BAD_FORMAT    = -1,
00194         TRACE_ERR_INIT_FAILED   = -2,
00196         TRACE_ERR_UNKNOWN_OPTION= -3,
00198         TRACE_ERR_NO_CONVERSION = -4,
00200         TRACE_ERR_BAD_PACKET    = -5,
00202         TRACE_ERR_OPTION_UNAVAIL= -6,
00204         TRACE_ERR_UNSUPPORTED   = -7,
00206         TRACE_ERR_BAD_STATE     = -8
00207 };
00208 
00211 typedef enum {
00212         TRACE_DLT_NULL = 0,
00213         TRACE_DLT_EN10MB = 1,
00214         TRACE_DLT_PPP = 9,
00215         TRACE_DLT_ATM_RFC1483 = 11,
00216         /* Sigh. This is handled in files with LINKTYPE's */
00217 #ifdef __OpenBSD__
00218         TRACE_DLT_RAW = 14,     
00219 #else
00220         TRACE_DLT_RAW = 12,
00221 #endif
00222         TRACE_DLT_LINKTYPE_RAW = 101,
00223         TRACE_DLT_C_HDLC = 104,
00224         TRACE_DLT_IEEE802_11 = 105,
00225         TRACE_DLT_LINUX_SLL = 113,
00226         TRACE_DLT_PFLOG = 117,
00227         TRACE_DLT_IEEE802_11_RADIO = 127 
00228 } libtrace_dlt_t ;
00229 
00231 typedef enum { 
00232     /* TRACE_TYPE_LEGACY = 0            Obsolete */
00233        TRACE_TYPE_HDLC_POS = 1, 
00234        TRACE_TYPE_ETH = 2,              
00235        TRACE_TYPE_ATM = 3,              
00236        TRACE_TYPE_80211 = 4,            
00237        TRACE_TYPE_NONE = 5,             
00238        TRACE_TYPE_LINUX_SLL = 6,        
00239        TRACE_TYPE_PFLOG = 7,            
00240     /* TRACE_TYPE_LEGACY_DEFAULT        Obsolete */
00241        TRACE_TYPE_POS = 9,
00242     /* TRACE_TYPE_LEGACY_ATM            Obsolete */
00243     /* TRACE_TYPE_LEGACY_ETH            Obsolete */
00244        TRACE_TYPE_80211_PRISM = 12,
00245        TRACE_TYPE_AAL5 = 13,
00246        TRACE_TYPE_DUCK = 14,         
00247        TRACE_TYPE_80211_RADIO = 15,  
00248        TRACE_TYPE_LLCSNAP = 16,      
00249        TRACE_TYPE_PPP = 17,          
00250        TRACE_TYPE_METADATA = 18         
00252 } libtrace_linktype_t;
00253 
00257 enum base_format_t {
00258         TRACE_FORMAT_ERF          =1,
00259         TRACE_FORMAT_PCAP         =2,
00260         TRACE_FORMAT_PCAPFILE     =3,
00261         TRACE_FORMAT_WAG          =4,
00262         TRACE_FORMAT_RT           =5,
00263         TRACE_FORMAT_LEGACY_ATM   =6,
00264         TRACE_FORMAT_LEGACY_POS   =7,
00265         TRACE_FORMAT_LEGACY_ETH   =8,
00266         TRACE_FORMAT_LINUX_NATIVE =9,
00267         TRACE_FORMAT_DUCK         =10,
00268         TRACE_FORMAT_BPF          =11,
00269         TRACE_FORMAT_TSH          =12,
00270         TRACE_FORMAT_ATMHDR       =13,
00271         TRACE_FORMAT_LEGACY_NZIX  =14
00272 };
00273 
00274 /* RT protocol packet types */
00275 typedef enum {
00276         TRACE_RT_HELLO          =1, 
00277         TRACE_RT_START          =2, 
00279         TRACE_RT_ACK            =3, 
00280         TRACE_RT_STATUS         =4, 
00281         TRACE_RT_DUCK           =5, 
00282         TRACE_RT_END_DATA       =6, 
00283         TRACE_RT_CLOSE          =7, 
00284         TRACE_RT_DENY_CONN      =8, 
00285         TRACE_RT_PAUSE          =9, 
00287         TRACE_RT_PAUSE_ACK      =10,
00288         TRACE_RT_OPTION         =11,
00289         TRACE_RT_KEYCHANGE      =12,
00290         TRACE_RT_DUCK_2_4       =13,
00291         TRACE_RT_DUCK_2_5       =14,
00292         TRACE_RT_LOSTCONN       =15,
00293         TRACE_RT_SERVERSTART    =16,
00294         TRACE_RT_CLIENTDROP     =17,
00295         TRACE_RT_METADATA       =18,
00297         TRACE_RT_DATA_SIMPLE    = 1000, 
00300         TRACE_RT_DATA_ERF       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_ERF, 
00301         TRACE_RT_DATA_WAG       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_WAG, 
00302         TRACE_RT_DATA_LEGACY_ATM=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_ATM, 
00303         TRACE_RT_DATA_LEGACY_POS=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_POS, 
00304         TRACE_RT_DATA_LEGACY_ETH=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_ETH, 
00305         TRACE_RT_DATA_LINUX_NATIVE=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LINUX_NATIVE,
00306         TRACE_RT_DATA_TSH       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_TSH,
00307 
00308         TRACE_RT_DATA_ATMHDR = TRACE_RT_DATA_SIMPLE + TRACE_FORMAT_ATMHDR,
00309         TRACE_RT_DATA_LEGACY_NZIX=TRACE_RT_DATA_SIMPLE + TRACE_FORMAT_LEGACY_NZIX,
00310         TRACE_RT_DATA_DLT               = 2000, 
00315         TRACE_RT_DLT_NULL               =TRACE_RT_DATA_DLT+TRACE_DLT_NULL,
00316         TRACE_RT_DLT_EN10MB             =TRACE_RT_DATA_DLT+TRACE_DLT_EN10MB,
00317         TRACE_RT_DLT_IEEE802_11         =TRACE_RT_DATA_DLT+TRACE_DLT_IEEE802_11,
00318         TRACE_RT_DLT_LINUX_SLL          =TRACE_RT_DATA_DLT+TRACE_DLT_LINUX_SLL,
00319         TRACE_RT_DLT_PFLOG              =TRACE_RT_DATA_DLT+TRACE_DLT_PFLOG,
00320         TRACE_RT_DLT_ATM_RFC1483        =TRACE_RT_DATA_DLT+TRACE_DLT_ATM_RFC1483,
00321         TRACE_RT_DATA_DLT_END           = 2999,
00322         TRACE_RT_LAST                   = (2<<31)
00323 } libtrace_rt_types_t;
00324 
00328 typedef struct libtrace_packet_t {
00329         struct libtrace_t *trace;       
00330         void *header;                   
00331         void *payload;                  
00332         void *buffer;                   
00333         libtrace_rt_types_t  type;      
00334         buf_control_t buf_control;      
00335         int capture_length;             
00336         void *l3_header;                
00337         uint16_t l3_ethertype;          
00338 } libtrace_packet_t;
00339 
00340 
00346 typedef enum {
00347         TRACE_DIR_OUTGOING = 0,         
00348         TRACE_DIR_INCOMING = 1,         
00349         TRACE_DIR_OTHER    = 2          
00350 } libtrace_direction_t;
00351 
00353 typedef enum {
00354     TRACE_RADIOTAP_TSFT = 0, 
00355     TRACE_RADIOTAP_FLAGS = 1, 
00356     TRACE_RADIOTAP_RATE = 2, 
00357     TRACE_RADIOTAP_CHANNEL = 3, 
00358     TRACE_RADIOTAP_FHSS = 4, 
00359     TRACE_RADIOTAP_DBM_ANTSIGNAL = 5, 
00360     TRACE_RADIOTAP_DBM_ANTNOISE = 6, 
00361     TRACE_RADIOTAP_LOCK_QUALITY = 7, 
00362     TRACE_RADIOTAP_TX_ATTENUATION = 8, 
00363     TRACE_RADIOTAP_DB_TX_ATTENUATION = 9, 
00364     TRACE_RADIOTAP_DBM_TX_POWER = 10, 
00365     TRACE_RADIOTAP_ANTENNA = 11, 
00366     TRACE_RADIOTAP_DB_ANTSIGNAL = 12, 
00367     TRACE_RADIOTAP_DB_ANTNOISE = 13, 
00368     TRACE_RADIOTAP_RX_FLAGS = 14, 
00369     TRACE_RADIOTAP_TX_FLAGS = 15, 
00370     TRACE_RADIOTAP_RTS_RETRIES = 16, 
00371     TRACE_RADIOTAP_DATA_RETRIES = 17, 
00372     TRACE_RADIOTAP_EXT = 31
00373 } libtrace_radiotap_field_t;
00374 
00375 
00382 #ifdef WIN32
00383 #pragma pack(push)
00384 #pragma pack(1)
00385 #endif
00386 
00388 typedef struct libtrace_ip
00389 {
00390 #if BYTE_ORDER == LITTLE_ENDIAN
00391     LT_BITFIELD8 ip_hl:4;               
00392     LT_BITFIELD8 ip_v:4;                
00393 #elif BYTE_ORDER == BIG_ENDIAN
00394     LT_BITFIELD8 ip_v:4;                
00395     LT_BITFIELD8 ip_hl:4;               
00396 #else
00397 #   error "Adjust your <bits/endian.h> defines"
00398 #endif
00399     uint8_t  ip_tos;                    
00400     uint16_t ip_len;                    
00401     int16_t  ip_id;                     
00402     uint16_t ip_off;                    
00403     uint8_t  ip_ttl;                    
00404     uint8_t  ip_p;                      
00405     uint16_t ip_sum;                    
00406     struct in_addr ip_src;              
00407     struct in_addr ip_dst;              
00408 } PACKED libtrace_ip_t;
00409 
00411 typedef struct libtrace_ip6_ext
00412 {
00413         uint8_t nxt;
00414         uint8_t len;
00415 } PACKED libtrace_ip6_ext_t;
00416 
00418 typedef struct libtrace_ip6
00419 { 
00420     uint32_t flow;
00421     uint16_t plen;                      
00422     uint8_t nxt;                        
00423     uint8_t hlim;                       
00424     struct in6_addr ip_src;             
00425     struct in6_addr ip_dst;             
00426 } PACKED libtrace_ip6_t;
00427 
00429 typedef struct libtrace_tcp
00430   {
00431     uint16_t source;            
00432     uint16_t dest;              
00433     uint32_t seq;               
00434     uint32_t ack_seq;           
00435 #  if BYTE_ORDER == LITTLE_ENDIAN
00436     LT_BITFIELD8 res1:4;        
00437     LT_BITFIELD8 doff:4;        
00438     LT_BITFIELD8 fin:1;         
00439     LT_BITFIELD8 syn:1;         
00440     LT_BITFIELD8 rst:1;         
00441     LT_BITFIELD8 psh:1;         
00442     LT_BITFIELD8 ack:1;         
00443     LT_BITFIELD8 urg:1;         
00444     LT_BITFIELD8 res2:2;        
00445 #  elif BYTE_ORDER == BIG_ENDIAN
00446     LT_BITFIELD8 doff:4;        
00447     LT_BITFIELD8 res1:4;        
00448     LT_BITFIELD8 res2:2;        
00449     LT_BITFIELD8 urg:1;         
00450     LT_BITFIELD8 ack:1;         
00451     LT_BITFIELD8 psh:1;         
00452     LT_BITFIELD8 rst:1;         
00453     LT_BITFIELD8 syn:1;         
00454     LT_BITFIELD8 fin:1;         
00455 #  else
00456 #   error "Adjust your <bits/endian.h> defines"
00457 #  endif
00458     uint16_t window;            
00459     uint16_t check;             
00460     uint16_t urg_ptr;           
00461 } PACKED libtrace_tcp_t;
00462 
00464 typedef struct libtrace_udp {
00465   uint16_t      source;         
00466   uint16_t      dest;           
00467   uint16_t      len;            
00468   uint16_t      check;          
00469 } PACKED libtrace_udp_t;
00470 
00472 typedef struct libtrace_icmp
00473 {
00474   uint8_t type;         
00475   uint8_t code;         
00476   uint16_t checksum;            
00477   union
00478   {
00479     struct
00480     {
00481       uint16_t  id;
00482       uint16_t  sequence;
00483     } echo;                     
00484     uint32_t    gateway;        
00485     struct
00486     {
00487       uint16_t  unused;
00488       uint16_t  mtu;
00489     } frag;                     
00490   } un;                         
00491 } PACKED libtrace_icmp_t;
00492 
00494 typedef struct libtrace_llcsnap
00495 {
00496 /* LLC */
00497   uint8_t dsap;                 
00498   uint8_t ssap;                 
00499   uint8_t control;
00500 /* SNAP */
00501   LT_BITFIELD32 oui:24;         
00502   uint16_t type;                
00503 } PACKED libtrace_llcsnap_t;
00504 
00506 typedef struct libtrace_ether
00507 {
00508   uint8_t ether_dhost[6];       
00509   uint8_t ether_shost[6];       
00510   uint16_t ether_type;          
00511 } PACKED libtrace_ether_t;
00512 
00514 typedef struct libtrace_8021q 
00515 {
00516   LT_BITFIELD16 vlan_pri:3;      
00517   LT_BITFIELD16 vlan_cfi:1;      
00519   LT_BITFIELD16 vlan_id:12;      
00520   uint16_t vlan_ether_type;      
00522 } PACKED libtrace_8021q_t;
00523 
00525 typedef struct libtrace_atm_cell
00526 {
00527   LT_BITFIELD32 gfc:4;          
00528   LT_BITFIELD32 vpi:8;          
00529   LT_BITFIELD32 vci:16;         
00530   LT_BITFIELD32 pt:3;           
00531   LT_BITFIELD32 clp:1;          
00532   LT_BITFIELD32 hec:8;          
00533 } PACKED libtrace_atm_cell_t;
00534 
00536 typedef struct libtrace_atm_nni_cell
00537 {
00538   LT_BITFIELD32 vpi:12;         
00539   LT_BITFIELD32 vci:16;         
00540   LT_BITFIELD32 pt:3;           
00541   LT_BITFIELD32 clp:1;          
00542   LT_BITFIELD32 hec:8;          
00543 } PACKED libtrace_atm_nni_cell_t;
00544 
00552 typedef struct libtrace_atm_capture_cell
00553 {
00554   LT_BITFIELD32 gfc:4;          
00555   LT_BITFIELD32 vpi:8;          
00556   LT_BITFIELD32 vci:16;         
00557   LT_BITFIELD32 pt:3;           
00558   LT_BITFIELD32 clp:1;          
00559 } PACKED libtrace_atm_capture_cell_t;
00560 
00568 typedef struct libtrace_atm_nni_capture_cell
00569 {
00570   LT_BITFIELD32 vpi:12;         
00571   LT_BITFIELD32 vci:16;         
00572   LT_BITFIELD32 pt:3;           
00573   LT_BITFIELD32 clp:1;          
00574   LT_BITFIELD32 hec:8;          
00575 } PACKED libtrace_atm_nni_capture_cell_t;
00576 
00578 typedef struct libtrace_pps
00579 {
00580  uint8_t addres;                
00581  uint8_t header;                
00582  uint16_t protocol;             
00583 } PACKED libtrace_ppp_t;
00584 
00586 typedef struct libtrace_80211_t {
00587 #if BYTE_ORDER == LITTLE_ENDIAN
00588         LT_BITFIELD32      protocol:2;
00589         LT_BITFIELD32      type:2;
00590         LT_BITFIELD32      subtype:4;
00591 #else
00592         LT_BITFIELD32      subtype:4;
00593         LT_BITFIELD32      type:2;
00594         LT_BITFIELD32      protocol:2;
00595 #endif
00596 
00597 #if BYTE_ORDER == LITTLE_ENDIAN
00598         LT_BITFIELD32      to_ds:1;     
00599         LT_BITFIELD32      from_ds:1;   
00600         LT_BITFIELD32      more_frag:1; 
00601         LT_BITFIELD32      retry:1;     
00602         LT_BITFIELD32      power:1;
00603         LT_BITFIELD32      more_data:1;
00604         LT_BITFIELD32      wep:1;
00605         LT_BITFIELD32      order:1;
00606 #else
00607         LT_BITFIELD32      order:1;
00608         LT_BITFIELD32      wep:1;
00609         LT_BITFIELD32      more_data:1;
00610         LT_BITFIELD32      power:1;
00611         LT_BITFIELD32      retry:1;     
00612         LT_BITFIELD32      more_frag:1; 
00613         LT_BITFIELD32      from_ds:1;   
00614         LT_BITFIELD32      to_ds:1;     
00615 #endif
00616         uint16_t     duration;
00617         uint8_t      mac1[6];
00618         uint8_t      mac2[6];
00619         uint8_t      mac3[6];
00620         uint16_t     SeqCtl;
00621         uint8_t      mac4[6];
00622 } PACKED libtrace_80211_t;
00623 
00631 typedef struct libtrace_radiotap_t {
00632     uint8_t     it_version; 
00633     uint8_t     it_pad; 
00634     uint16_t    it_len; 
00635     uint32_t    it_present; 
00636 } PACKED libtrace_radiotap_t;
00637 
00638 
00639 #ifdef WIN32
00640 #pragma pack(pop)
00641 #endif
00642 
00643 
00651 DLLEXPORT void trace_help(void);
00652 
00681 DLLEXPORT libtrace_t *trace_create(const char *uri);
00682 
00691 DLLEXPORT libtrace_t *trace_create_dead(const char *uri);
00692 
00706 DLLEXPORT libtrace_out_t *trace_create_output(const char *uri);
00707 
00715 DLLEXPORT int trace_start(libtrace_t *libtrace);
00716 
00725 DLLEXPORT int trace_pause(libtrace_t *libtrace);
00726 
00734 DLLEXPORT int trace_start_output(libtrace_out_t *libtrace);
00735 
00737 typedef enum {
00738         TRACE_OPTION_SNAPLEN,   
00739         TRACE_OPTION_PROMISC,   
00740         TRACE_OPTION_FILTER,    
00741         TRACE_OPTION_META_FREQ, 
00743         TRACE_OPTION_EVENT_REALTIME
00744 } trace_option_t;
00745 
00753 DLLEXPORT int trace_config(libtrace_t *libtrace,
00754                 trace_option_t option,
00755                 void *value);
00756 
00757 typedef enum {
00758         TRACE_OPTION_OUTPUT_FILEFLAGS, 
00761         TRACE_OPTION_OUTPUT_COMPRESS   
00762 } trace_option_output_t;
00763 
00773 DLLEXPORT int trace_config_output(libtrace_out_t *libtrace, 
00774                 trace_option_output_t option,
00775                 void *value
00776                 );
00777 
00781 DLLEXPORT void trace_destroy(libtrace_t *trace);
00782 
00786 DLLEXPORT void trace_destroy_dead(libtrace_t *trace);
00787 
00791 DLLEXPORT void trace_destroy_output(libtrace_out_t *trace);
00792 
00799 DLLEXPORT libtrace_err_t trace_get_err(libtrace_t *trace);
00800 
00805 DLLEXPORT bool trace_is_err(libtrace_t *trace);
00806 
00812 DLLEXPORT void trace_perror(libtrace_t *trace, const char *msg,...) PRINTF(2,3);
00813 
00820 DLLEXPORT libtrace_err_t trace_get_err_output(libtrace_out_t *trace);
00821 
00826 DLLEXPORT bool trace_is_err_output(libtrace_out_t *trace);
00827 
00833 DLLEXPORT void trace_perror_output(libtrace_out_t *trace, const char *msg,...)
00834         PRINTF(2,3);
00835 
00845 uint64_t trace_get_received_packets(libtrace_t *trace);
00846 
00856 uint64_t trace_get_filtered_packets(libtrace_t *trace);
00857 
00862 uint64_t trace_get_dropped_packets(libtrace_t *trace);
00863 
00868 uint64_t trace_get_accepted_packets(libtrace_t *trace);
00869 
00870 
00883 DLLEXPORT libtrace_packet_t *trace_create_packet(void);
00884 
00895 DLLEXPORT libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet);
00896 
00901 DLLEXPORT void trace_destroy_packet(libtrace_packet_t *packet);
00902 
00903 
00917 DLLEXPORT int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet);
00918 
00922 typedef enum {
00923         TRACE_EVENT_IOWAIT,     
00924         TRACE_EVENT_SLEEP,      
00925         TRACE_EVENT_PACKET,     
00926         TRACE_EVENT_TERMINATE   
00927 } libtrace_event_t;
00928 
00930 typedef struct libtrace_eventobj_t {
00931         libtrace_event_t type; 
00932         int fd;                
00933         double seconds;        
00935         int size;              
00938 } libtrace_eventobj_t;
00939 
00952 DLLEXPORT libtrace_eventobj_t trace_event(libtrace_t *trace,
00953                 libtrace_packet_t *packet);
00954 
00955 
00962 DLLEXPORT int trace_write_packet(libtrace_out_t *trace, libtrace_packet_t *packet);
00983 DLLEXPORT void *trace_get_packet_buffer(const libtrace_packet_t *packet,
00984                 libtrace_linktype_t *linktype, uint32_t *remaining);
00985 
00996 DLLEXPORT SIMPLE_FUNCTION DEPRECATED
00997 void *trace_get_link(const libtrace_packet_t *packet);
00998 
01006 DLLEXPORT SIMPLE_FUNCTION
01007 libtrace_ip_t *trace_get_ip(libtrace_packet_t *packet);
01008 
01016 DLLEXPORT SIMPLE_FUNCTION
01017 libtrace_ip6_t *trace_get_ip6(libtrace_packet_t *packet);
01018 
01041 DLLEXPORT void *trace_get_packet_meta(const libtrace_packet_t *packet,
01042                 libtrace_linktype_t *linktype,
01043                 uint32_t *remaining);
01044 
01072 DLLEXPORT void *trace_get_payload_from_meta(const void *meta,
01073                 libtrace_linktype_t *linktype,
01074                 uint32_t *remaining);
01075 
01076 
01093 DLLEXPORT void *trace_get_layer2(const libtrace_packet_t *packet,
01094                 libtrace_linktype_t *linktype,
01095                 uint32_t *remaining);
01096 
01114 DLLEXPORT void *trace_get_payload_from_layer2(void *l2,
01115                 libtrace_linktype_t linktype,
01116                 uint16_t *ethertype,
01117                 uint32_t *remaining);
01118 
01119 
01130 DLLEXPORT 
01131 void *trace_get_layer3(const libtrace_packet_t *packet,
01132                 uint16_t *ethertype, uint32_t *remaining);
01133 
01143 DLLEXPORT void *trace_get_transport(const libtrace_packet_t *packet, 
01144                 uint8_t *proto, uint32_t *remaining);
01145 
01162 DLLEXPORT void *trace_get_payload_from_ip(libtrace_ip_t *ip, uint8_t *proto,
01163                 uint32_t *remaining);
01164 
01180 DLLEXPORT void *trace_get_payload_from_ip6(libtrace_ip6_t *ipptr,
01181                 uint8_t *prot, uint32_t *remaining);
01182 
01199 DLLEXPORT void *trace_get_payload_from_link(void *linkptr,
01200                 libtrace_linktype_t linktype, 
01201                 uint16_t *type, uint32_t *remaining);
01202 
01220 DLLEXPORT void *trace_get_vlan_payload_from_ethernet_payload(
01221                 void *ethernet_payload, uint16_t *type, uint32_t *remaining);
01222 
01234 DLLEXPORT void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, 
01235                 uint32_t *remaining);
01236 
01248 DLLEXPORT void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining);
01249 
01261 DLLEXPORT void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, 
01262                 uint32_t *remaining);
01263 
01271 DLLEXPORT SIMPLE_FUNCTION
01272 libtrace_tcp_t *trace_get_tcp(libtrace_packet_t *packet);
01273 
01286 DLLEXPORT SIMPLE_FUNCTION
01287 libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip, uint32_t *remaining);
01288 
01294 DLLEXPORT SIMPLE_FUNCTION
01295 libtrace_udp_t *trace_get_udp(libtrace_packet_t *packet);
01296 
01309 DLLEXPORT SIMPLE_FUNCTION
01310 libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
01311 
01317 DLLEXPORT SIMPLE_FUNCTION
01318 libtrace_icmp_t *trace_get_icmp(libtrace_packet_t *packet);
01319 
01332 DLLEXPORT SIMPLE_FUNCTION
01333 libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
01334 
01340 DLLEXPORT SIMPLE_FUNCTION
01341 uint8_t *trace_get_destination_mac(libtrace_packet_t *packet);
01342 
01347 DLLEXPORT SIMPLE_FUNCTION
01348 uint8_t *trace_get_source_mac(libtrace_packet_t *packet);
01349 
01357 DLLEXPORT SIMPLE_FUNCTION
01358 struct sockaddr *trace_get_source_address(const libtrace_packet_t *packet,
01359                 struct sockaddr *addr);
01360 
01368 DLLEXPORT SIMPLE_FUNCTION
01369 struct sockaddr *trace_get_destination_address(const libtrace_packet_t *packet,
01370                 struct sockaddr *addr);
01371 
01391 DLLEXPORT int trace_get_next_option(unsigned char **ptr,int *len,
01392                         unsigned char *type,
01393                         unsigned char *optlen,
01394                         unsigned char **data);
01395 
01396 
01408 DLLEXPORT SIMPLE_FUNCTION
01409 uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet);
01410 
01416 DLLEXPORT SIMPLE_FUNCTION
01417 struct timeval trace_get_timeval(const libtrace_packet_t *packet);
01418 
01425 DLLEXPORT SIMPLE_FUNCTION
01426 double trace_get_seconds(const libtrace_packet_t *packet);
01427 
01437 DLLEXPORT int trace_seek_seconds(libtrace_t *trace, double seconds);
01438 
01448 DLLEXPORT int trace_seek_timeval(libtrace_t *trace, struct timeval tv);
01449 
01459 DLLEXPORT int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts);
01460 
01482 DLLEXPORT SIMPLE_FUNCTION
01483 size_t trace_get_capture_length(const libtrace_packet_t *packet);
01484 
01497 DLLEXPORT SIMPLE_FUNCTION
01498 size_t trace_get_wire_length(const libtrace_packet_t *packet);
01499 
01506 DLLEXPORT SIMPLE_FUNCTION
01507 size_t trace_get_framing_length(const libtrace_packet_t *packet);
01508 
01515 DLLEXPORT size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size);
01516 
01524 DLLEXPORT SIMPLE_FUNCTION
01525 libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet);
01526 
01532 DLLEXPORT libtrace_direction_t trace_set_direction(libtrace_packet_t *packet, libtrace_direction_t direction);
01533 
01542 DLLEXPORT SIMPLE_FUNCTION
01543 libtrace_direction_t trace_get_direction(const libtrace_packet_t *packet);
01544 
01557 DLLEXPORT SIMPLE_FUNCTION
01558 libtrace_filter_t *trace_create_filter(const char *filterstring);
01559 
01567 DLLEXPORT libtrace_filter_t *
01568 trace_create_filter_from_bytecode(void *bf_insns, unsigned int bf_len);
01569 
01580 DLLEXPORT int trace_apply_filter(libtrace_filter_t *filter,
01581                 const libtrace_packet_t *packet);
01582 
01587 DLLEXPORT void trace_destroy_filter(libtrace_filter_t *filter);
01609 DLLEXPORT char *trace_ether_ntoa(const uint8_t *addr, char *buf);
01610 
01624 DLLEXPORT uint8_t *trace_ether_aton(const char *buf, uint8_t *addr);
01625 
01630 typedef enum {
01631         USE_DEST,       
01632         USE_SOURCE      
01633 } serverport_t;
01634 
01640 DLLEXPORT SIMPLE_FUNCTION
01641 uint16_t trace_get_source_port(const libtrace_packet_t *packet);
01642 
01648 DLLEXPORT SIMPLE_FUNCTION
01649 uint16_t trace_get_destination_port(const libtrace_packet_t *packet);
01650 
01658 DLLEXPORT SIMPLE_FUNCTION
01659 int8_t trace_get_server_port(uint8_t protocol, uint16_t source, uint16_t dest);
01660 
01666 DLLEXPORT const char *trace_parse_uri(const char *uri, char **format);
01667 
01672 DLLEXPORT 
01673 enum base_format_t trace_get_format(struct libtrace_packet_t *packet);
01674 
01682 DLLEXPORT
01683 void trace_construct_packet(libtrace_packet_t *packet,
01684                 libtrace_linktype_t linktype, const void *data, uint16_t len);
01685 
01705 #ifndef ARPHRD_80211_RADIOTAP
01706 /* libc doesn't define this yet, but it seems to be what everyone is using
01707  */
01708 #define ARPHRD_80211_RADIOTAP 803
01709 #endif
01710 
01722 DLLEXPORT bool trace_get_wireless_tsft(void *linkptr,
01723         libtrace_linktype_t linktype, uint64_t *tsft);
01724 
01731 DLLEXPORT bool trace_get_wireless_rate(void *linkptr,
01732         libtrace_linktype_t linktype, uint8_t *rate);
01733 
01741 DLLEXPORT bool trace_get_wireless_freq(void *linkptr,
01742         libtrace_linktype_t linktype, uint16_t *freq);
01743 
01751 DLLEXPORT bool trace_get_wireless_signal_strength_dbm(void *linkptr,
01752         libtrace_linktype_t linktype, int8_t *strength);
01753 
01761 DLLEXPORT bool trace_get_wireless_noise_strength_dbm(void *linkptr,
01762         libtrace_linktype_t linktype, int8_t *strength);
01763 
01771 DLLEXPORT bool trace_get_wireless_signal_strength_db(void *linkptr,
01772         libtrace_linktype_t linktype, uint8_t *strength);
01773 
01781 DLLEXPORT bool trace_get_wireless_noise_strength_db(void *linkptr,
01782         libtrace_linktype_t linktype, uint8_t *strength);
01783 
01791 DLLEXPORT bool trace_get_wireless_tx_attenuation(void *linkptr,
01792         libtrace_linktype_t linktype, uint16_t *attenuation);
01793 
01801 DLLEXPORT bool trace_get_wireless_tx_attenuation_db(void *linkptr,
01802         libtrace_linktype_t linktype, uint16_t *attenuation);
01803 
01809 DLLEXPORT bool trace_get_wireless_tx_power_dbm(void *linkptr, libtrace_linktype_t
01810                 linktype, int8_t *txpower);
01811 
01818 DLLEXPORT bool trace_get_wireless_antenna(void *linkptr,
01819         libtrace_linktype_t linktype, uint8_t *antenna);
01820 
01823 #ifdef __cplusplus
01824 } /* extern "C" */
01825 #endif /* #ifdef __cplusplus */
01826 #endif /* LIBTRACE_H_ */

Generated on Thu Jan 3 10:28:47 2008 for WAND Trace processing by  doxygen 1.4.2