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

libtrace.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of libtrace
00003  *
00004  * Copyright (c) 2007 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 SIMPLE_FUNCTION __attribute__((pure))
00145 #  define UNUSED __attribute__((unused))
00146 #  define PACKED __attribute__((packed))
00147 #  define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos)))
00148 #else
00149 #  define SIMPLE_FUNCTION
00150 #  define UNUSED
00151 #  define PACKED 
00152 #  define PRINTF(formatpos,argpos) 
00153 #endif
00154         
00156 typedef struct libtrace_out_t libtrace_out_t;
00157         
00159 typedef struct libtrace_t libtrace_t;
00160         
00162 typedef struct libtrace_filter_t libtrace_filter_t;
00163 
00172 typedef enum {
00173         TRACE_CTRL_PACKET='p',
00174         TRACE_CTRL_EXTERNAL='e' 
00175 } buf_control_t;
00177 #define LIBTRACE_PACKET_BUFSIZE 65536
00178 
00180 typedef struct trace_err_t{
00181         int err_num;            
00182         char problem[255];      
00183 } libtrace_err_t;
00184 
00186 enum {
00188         TRACE_ERR_NOERROR       = 0,
00190         TRACE_ERR_BAD_FORMAT    = -1,
00192         TRACE_ERR_INIT_FAILED   = -2,
00194         TRACE_ERR_UNKNOWN_OPTION= -3,
00196         TRACE_ERR_NO_CONVERSION = -4,
00198         TRACE_ERR_BAD_PACKET    = -5,
00200         TRACE_ERR_OPTION_UNAVAIL= -6,
00202         TRACE_ERR_UNSUPPORTED   = -7
00203 };
00204 
00207 typedef enum {
00208         TRACE_DLT_NULL = 0,
00209         TRACE_DLT_EN10MB = 1,
00210         TRACE_DLT_PPP = 9,
00211         TRACE_DLT_ATM_RFC1483 = 11,
00212         /* Sigh. This is handled in files with LINKTYPE's */
00213 #ifdef __OpenBSD__
00214         TRACE_DLT_RAW = 14,     
00215 #else
00216         TRACE_DLT_RAW = 12,
00217 #endif
00218         TRACE_DLT_LINKTYPE_RAW = 101,
00219         TRACE_DLT_IEEE802_11 = 105,
00220         TRACE_DLT_LINUX_SLL = 113,
00221         TRACE_DLT_PFLOG = 117,
00222         TRACE_DLT_IEEE802_11_RADIO = 127 
00223 } libtrace_dlt_t ;
00224 
00226 typedef enum { 
00227     /* TRACE_TYPE_LEGACY = 0            Obsolete */
00228        TRACE_TYPE_HDLC_POS = 1, 
00229        TRACE_TYPE_ETH = 2,              
00230        TRACE_TYPE_ATM = 3,              
00231        TRACE_TYPE_80211 = 4,            
00232        TRACE_TYPE_NONE = 5,             
00233        TRACE_TYPE_LINUX_SLL = 6,        
00234        TRACE_TYPE_PFLOG = 7,            
00235     /* TRACE_TYPE_LEGACY_DEFAULT        Obsolete */
00236        TRACE_TYPE_POS = 9,
00237     /* TRACE_TYPE_LEGACY_ATM            Obsolete */
00238     /* TRACE_TYPE_LEGACY_ETH            Obsolete */
00239        TRACE_TYPE_80211_PRISM = 12,
00240        TRACE_TYPE_AAL5 = 13,
00241        TRACE_TYPE_DUCK = 14,         
00242        TRACE_TYPE_80211_RADIO = 15,  
00243        TRACE_TYPE_LLCSNAP = 16,      
00244        TRACE_TYPE_PPP = 17,          
00245        TRACE_TYPE_METADATA = 18         
00247 } libtrace_linktype_t;
00248 
00252 enum base_format_t {
00253         TRACE_FORMAT_ERF          =1,
00254         TRACE_FORMAT_PCAP         =2,
00255         TRACE_FORMAT_PCAPFILE     =3,
00256         TRACE_FORMAT_WAG          =4,
00257         TRACE_FORMAT_RT           =5,
00258         TRACE_FORMAT_LEGACY_ATM   =6,
00259         TRACE_FORMAT_LEGACY_POS   =7,
00260         TRACE_FORMAT_LEGACY_ETH   =8,
00261         TRACE_FORMAT_LINUX_NATIVE =9,
00262         TRACE_FORMAT_DUCK         =10,
00263         TRACE_FORMAT_BPF          =11,
00264         TRACE_FORMAT_TSH          =12,
00265         TRACE_FORMAT_ATMHDR       =13,
00266         TRACE_FORMAT_LEGACY_NZIX  =14
00267 };
00268 
00269 /* RT protocol packet types */
00270 typedef enum {
00271         TRACE_RT_HELLO          =1, 
00272         TRACE_RT_START          =2, 
00274         TRACE_RT_ACK            =3, 
00275         TRACE_RT_STATUS         =4, 
00276         TRACE_RT_DUCK           =5, 
00277         TRACE_RT_END_DATA       =6, 
00278         TRACE_RT_CLOSE          =7, 
00279         TRACE_RT_DENY_CONN      =8, 
00280         TRACE_RT_PAUSE          =9, 
00282         TRACE_RT_PAUSE_ACK      =10,
00283         TRACE_RT_OPTION         =11,
00284         TRACE_RT_KEYCHANGE      =12,
00285         TRACE_RT_DUCK_2_4       =13,
00286         TRACE_RT_DUCK_2_5       =14,
00287         TRACE_RT_LOSTCONN       =15,
00288         TRACE_RT_SERVERSTART    =16,
00289         TRACE_RT_CLIENTDROP     =17,
00290         TRACE_RT_METADATA       =18,
00292         TRACE_RT_DATA_SIMPLE    = 1000, 
00295         TRACE_RT_DATA_ERF       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_ERF, 
00296         TRACE_RT_DATA_WAG       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_WAG, 
00297         TRACE_RT_DATA_LEGACY_ATM=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_ATM, 
00298         TRACE_RT_DATA_LEGACY_POS=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_POS, 
00299         TRACE_RT_DATA_LEGACY_ETH=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_ETH, 
00300         TRACE_RT_DATA_LINUX_NATIVE=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LINUX_NATIVE,
00301         TRACE_RT_DATA_TSH       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_TSH,
00302 
00303         TRACE_RT_DATA_ATMHDR = TRACE_RT_DATA_SIMPLE + TRACE_FORMAT_ATMHDR,
00304         TRACE_RT_DATA_LEGACY_NZIX=TRACE_RT_DATA_SIMPLE + TRACE_FORMAT_LEGACY_NZIX,
00305         TRACE_RT_DATA_DLT               = 2000, 
00310         TRACE_RT_DLT_NULL               =TRACE_RT_DATA_DLT+TRACE_DLT_NULL,
00311         TRACE_RT_DLT_EN10MB             =TRACE_RT_DATA_DLT+TRACE_DLT_EN10MB,
00312         TRACE_RT_DLT_IEEE802_11         =TRACE_RT_DATA_DLT+TRACE_DLT_IEEE802_11,
00313         TRACE_RT_DLT_LINUX_SLL          =TRACE_RT_DATA_DLT+TRACE_DLT_LINUX_SLL,
00314         TRACE_RT_DLT_PFLOG              =TRACE_RT_DATA_DLT+TRACE_DLT_PFLOG,
00315         TRACE_RT_DLT_ATM_RFC1483        =TRACE_RT_DATA_DLT+TRACE_DLT_ATM_RFC1483,
00316         TRACE_RT_LAST                   = (2<<31)
00317 } libtrace_rt_types_t;
00318 
00322 typedef struct libtrace_packet_t {
00323         struct libtrace_t *trace;       
00324         void *header;                   
00325         void *payload;                  
00326         void *buffer;                   
00327         libtrace_rt_types_t  type;      
00328         buf_control_t buf_control;      
00329         int capture_length;             
00330         void *l3_header;                
00331         uint16_t l3_ethertype;          
00332 } libtrace_packet_t;
00333 
00334 
00340 typedef enum {
00341         TRACE_DIR_OUTGOING = 0,         
00342         TRACE_DIR_INCOMING = 1,         
00343         TRACE_DIR_OTHER    = 2          
00344 } libtrace_direction_t;
00345 
00347 typedef enum {
00348     TRACE_RADIOTAP_TSFT = 0, 
00349     TRACE_RADIOTAP_FLAGS = 1, 
00350     TRACE_RADIOTAP_RATE = 2, 
00351     TRACE_RADIOTAP_CHANNEL = 3, 
00352     TRACE_RADIOTAP_FHSS = 4, 
00353     TRACE_RADIOTAP_DBM_ANTSIGNAL = 5, 
00354     TRACE_RADIOTAP_DBM_ANTNOISE = 6, 
00355     TRACE_RADIOTAP_LOCK_QUALITY = 7, 
00356     TRACE_RADIOTAP_TX_ATTENUATION = 8, 
00357     TRACE_RADIOTAP_DB_TX_ATTENUATION = 9, 
00358     TRACE_RADIOTAP_DBM_TX_POWER = 10, 
00359     TRACE_RADIOTAP_ANTENNA = 11, 
00360     TRACE_RADIOTAP_DB_ANTSIGNAL = 12, 
00361     TRACE_RADIOTAP_DB_ANTNOISE = 13, 
00362     TRACE_RADIOTAP_RX_FLAGS = 14, 
00363     TRACE_RADIOTAP_TX_FLAGS = 15, 
00364     TRACE_RADIOTAP_RTS_RETRIES = 16, 
00365     TRACE_RADIOTAP_DATA_RETRIES = 17, 
00366     TRACE_RADIOTAP_EXT = 31
00367 } libtrace_radiotap_field_t;
00368 
00369 
00376 #ifdef WIN32
00377 #pragma pack(push)
00378 #pragma pack(1)
00379 #endif
00380 
00382 typedef struct libtrace_ip
00383 {
00384 #if BYTE_ORDER == LITTLE_ENDIAN
00385     LT_BITFIELD8 ip_hl:4;               
00386     LT_BITFIELD8 ip_v:4;                
00387 #elif BYTE_ORDER == BIG_ENDIAN
00388     LT_BITFIELD8 ip_v:4;                
00389     LT_BITFIELD8 ip_hl:4;               
00390 #else
00391 #   error "Adjust your <bits/endian.h> defines"
00392 #endif
00393     uint8_t  ip_tos;                    
00394     uint16_t ip_len;                    
00395     int16_t  ip_id;                     
00396 #if BYTE_ORDER == LITTLE_ENDIAN
00397     LT_BITFIELD16 ip_off:12;            
00398     LT_BITFIELD16 ip_mf:1;              
00399     LT_BITFIELD16 ip_df:1;              
00400     LT_BITFIELD16 ip_rf:1;              
00401 #elif BYTE_ORDER == BIG_ENDIAN
00402     LT_BITFIELD16 ip_rf:1;              
00403     LT_BITFIELD16 ip_df:1;              
00404     LT_BITFIELD16 ip_mf:1;              
00405     LT_BITFIELD16 ip_off:12;            
00406 #else
00407 #   error "Adjust your <bits/endian.h> defines"
00408 #endif
00409     uint8_t  ip_ttl;                    
00410     uint8_t  ip_p;                      
00411     uint16_t ip_sum;                    
00412     struct in_addr ip_src;              
00413     struct in_addr ip_dst;              
00414 } PACKED libtrace_ip_t;
00415 
00417 typedef struct libtrace_ip6_ext
00418 {
00419         uint8_t nxt;
00420         uint8_t len;
00421 } PACKED libtrace_ip6_ext_t;
00422 
00424 typedef struct libtrace_ip6
00425 { 
00426     uint32_t flow;
00427     uint16_t plen;                      
00428     uint8_t nxt;                        
00429     uint8_t hlim;                       
00430     struct in6_addr ip_src;             
00431     struct in6_addr ip_dst;             
00432 } PACKED libtrace_ip6_t;
00433 
00435 typedef struct libtrace_tcp
00436   {
00437     uint16_t source;            
00438     uint16_t dest;              
00439     uint32_t seq;               
00440     uint32_t ack_seq;           
00441 #  if BYTE_ORDER == LITTLE_ENDIAN
00442     LT_BITFIELD8 res1:4;        
00443     LT_BITFIELD8 doff:4;        
00444     LT_BITFIELD8 fin:1;         
00445     LT_BITFIELD8 syn:1;         
00446     LT_BITFIELD8 rst:1;         
00447     LT_BITFIELD8 psh:1;         
00448     LT_BITFIELD8 ack:1;         
00449     LT_BITFIELD8 urg:1;         
00450     LT_BITFIELD8 res2:2;        
00451 #  elif BYTE_ORDER == BIG_ENDIAN
00452     LT_BITFIELD8 doff:4;        
00453     LT_BITFIELD8 res1:4;        
00454     LT_BITFIELD8 res2:2;        
00455     LT_BITFIELD8 urg:1;         
00456     LT_BITFIELD8 ack:1;         
00457     LT_BITFIELD8 psh:1;         
00458     LT_BITFIELD8 rst:1;         
00459     LT_BITFIELD8 syn:1;         
00460     LT_BITFIELD8 fin:1;         
00461 #  else
00462 #   error "Adjust your <bits/endian.h> defines"
00463 #  endif
00464     uint16_t window;            
00465     uint16_t check;             
00466     uint16_t urg_ptr;           
00467 } PACKED libtrace_tcp_t;
00468 
00470 typedef struct libtrace_udp {
00471   uint16_t      source;         
00472   uint16_t      dest;           
00473   uint16_t      len;            
00474   uint16_t      check;          
00475 } PACKED libtrace_udp_t;
00476 
00478 typedef struct libtrace_icmp
00479 {
00480   uint8_t type;         
00481   uint8_t code;         
00482   uint16_t checksum;            
00483   union
00484   {
00485     struct
00486     {
00487       uint16_t  id;
00488       uint16_t  sequence;
00489     } echo;                     
00490     uint32_t    gateway;        
00491     struct
00492     {
00493       uint16_t  unused;
00494       uint16_t  mtu;
00495     } frag;                     
00496   } un;                         
00497 } PACKED libtrace_icmp_t;
00498 
00500 typedef struct libtrace_llcsnap
00501 {
00502 /* LLC */
00503   uint8_t dsap;                 
00504   uint8_t ssap;                 
00505   uint8_t control;
00506 /* SNAP */
00507   LT_BITFIELD32 oui:24;         
00508   uint16_t type;                
00509 } PACKED libtrace_llcsnap_t;
00510 
00512 typedef struct libtrace_ether
00513 {
00514   uint8_t ether_dhost[6];       
00515   uint8_t ether_shost[6];       
00516   uint16_t ether_type;          
00517 } PACKED libtrace_ether_t;
00518 
00520 typedef struct libtrace_8021q 
00521 {
00522   LT_BITFIELD16 vlan_pri:3;      
00523   LT_BITFIELD16 vlan_cfi:1;      
00525   LT_BITFIELD16 vlan_id:12;      
00526   uint16_t vlan_ether_type;      
00528 } PACKED libtrace_8021q_t;
00529 
00531 typedef struct libtrace_atm_cell
00532 {
00533   LT_BITFIELD32 gfc:4;          
00534   LT_BITFIELD32 vpi:8;          
00535   LT_BITFIELD32 vci:16;         
00536   LT_BITFIELD32 pt:3;           
00537   LT_BITFIELD32 clp:1;          
00538   LT_BITFIELD32 hec:8;          
00539 } PACKED libtrace_atm_cell_t;
00540 
00542 typedef struct libtrace_atm_nni_cell
00543 {
00544   LT_BITFIELD32 vpi:12;         
00545   LT_BITFIELD32 vci:16;         
00546   LT_BITFIELD32 pt:3;           
00547   LT_BITFIELD32 clp:1;          
00548   LT_BITFIELD32 hec:8;          
00549 } PACKED libtrace_atm_nni_cell_t;
00550 
00558 typedef struct libtrace_atm_capture_cell
00559 {
00560   LT_BITFIELD32 gfc:4;          
00561   LT_BITFIELD32 vpi:8;          
00562   LT_BITFIELD32 vci:16;         
00563   LT_BITFIELD32 pt:3;           
00564   LT_BITFIELD32 clp:1;          
00565 } PACKED libtrace_atm_capture_cell_t;
00566 
00574 typedef struct libtrace_atm_nni_capture_cell
00575 {
00576   LT_BITFIELD32 vpi:12;         
00577   LT_BITFIELD32 vci:16;         
00578   LT_BITFIELD32 pt:3;           
00579   LT_BITFIELD32 clp:1;          
00580   LT_BITFIELD32 hec:8;          
00581 } PACKED libtrace_atm_nni_capture_cell_t;
00582 
00584 typedef struct libtrace_pps
00585 {
00586  uint8_t addres;                
00587  uint8_t header;                
00588  uint16_t protocol;             
00589 } PACKED libtrace_ppp_t;
00590 
00592 typedef struct libtrace_80211_t {
00593 #if BYTE_ORDER == LITTLE_ENDIAN
00594         LT_BITFIELD32      protocol:2;
00595         LT_BITFIELD32      type:2;
00596         LT_BITFIELD32      subtype:4;
00597 #else
00598         LT_BITFIELD32      subtype:4;
00599         LT_BITFIELD32      type:2;
00600         LT_BITFIELD32      protocol:2;
00601 #endif
00602 
00603 #if BYTE_ORDER == LITTLE_ENDIAN
00604         LT_BITFIELD32      to_ds:1;     
00605         LT_BITFIELD32      from_ds:1;   
00606         LT_BITFIELD32      more_frag:1; 
00607         LT_BITFIELD32      retry:1;     
00608         LT_BITFIELD32      power:1;
00609         LT_BITFIELD32      more_data:1;
00610         LT_BITFIELD32      wep:1;
00611         LT_BITFIELD32      order:1;
00612 #else
00613         LT_BITFIELD32      order:1;
00614         LT_BITFIELD32      wep:1;
00615         LT_BITFIELD32      more_data:1;
00616         LT_BITFIELD32      power:1;
00617         LT_BITFIELD32      retry:1;     
00618         LT_BITFIELD32      more_frag:1; 
00619         LT_BITFIELD32      from_ds:1;   
00620         LT_BITFIELD32      to_ds:1;     
00621 #endif
00622         uint16_t     duration;
00623         uint8_t      mac1[6];
00624         uint8_t      mac2[6];
00625         uint8_t      mac3[6];
00626         uint16_t     SeqCtl;
00627         uint8_t      mac4[6];
00628 } PACKED libtrace_80211_t;
00629 
00637 typedef struct libtrace_radiotap_t {
00638     uint8_t     it_version; 
00639     uint8_t     it_pad; 
00640     uint16_t    it_len; 
00641     uint32_t    it_present; 
00642 } PACKED libtrace_radiotap_t;
00643 
00644 
00645 #ifdef WIN32
00646 #pragma pack(pop)
00647 #endif
00648 
00649 
00657 DLLEXPORT void trace_help(void);
00658 
00687 DLLEXPORT libtrace_t *trace_create(const char *uri);
00688 
00697 DLLEXPORT libtrace_t *trace_create_dead(const char *uri);
00698 
00712 DLLEXPORT libtrace_out_t *trace_create_output(const char *uri);
00713 
00721 DLLEXPORT int trace_start(libtrace_t *libtrace);
00722 
00731 DLLEXPORT int trace_pause(libtrace_t *libtrace);
00732 
00740 DLLEXPORT int trace_start_output(libtrace_out_t *libtrace);
00741 
00743 typedef enum {
00744         TRACE_OPTION_SNAPLEN,   
00745         TRACE_OPTION_PROMISC,   
00746         TRACE_OPTION_FILTER,    
00747         TRACE_OPTION_META_FREQ, 
00749         TRACE_OPTION_EVENT_REALTIME
00750 } trace_option_t;
00751 
00759 DLLEXPORT int trace_config(libtrace_t *libtrace,
00760                 trace_option_t option,
00761                 void *value);
00762 
00763 typedef enum {
00764         TRACE_OPTION_OUTPUT_FILEFLAGS, 
00767         TRACE_OPTION_OUTPUT_COMPRESS   
00768 } trace_option_output_t;
00769 
00779 DLLEXPORT int trace_config_output(libtrace_out_t *libtrace, 
00780                 trace_option_output_t option,
00781                 void *value
00782                 );
00783 
00787 DLLEXPORT void trace_destroy(libtrace_t *trace);
00788 
00792 DLLEXPORT void trace_destroy_dead(libtrace_t *trace);
00793 
00797 DLLEXPORT void trace_destroy_output(libtrace_out_t *trace);
00798 
00805 DLLEXPORT libtrace_err_t trace_get_err(libtrace_t *trace);
00806 
00811 DLLEXPORT bool trace_is_err(libtrace_t *trace);
00812 
00818 DLLEXPORT void trace_perror(libtrace_t *trace, const char *msg,...) PRINTF(2,3);
00819 
00826 DLLEXPORT libtrace_err_t trace_get_err_output(libtrace_out_t *trace);
00827 
00832 DLLEXPORT bool trace_is_err_output(libtrace_out_t *trace);
00833 
00839 DLLEXPORT void trace_perror_output(libtrace_out_t *trace, const char *msg,...)
00840         PRINTF(2,3);
00841 
00842 
00855 DLLEXPORT libtrace_packet_t *trace_create_packet(void);
00856 
00867 DLLEXPORT libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet);
00868 
00873 DLLEXPORT void trace_destroy_packet(libtrace_packet_t *packet);
00874 
00875 
00889 DLLEXPORT int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet);
00890 
00894 typedef enum {
00895         TRACE_EVENT_IOWAIT,     
00896         TRACE_EVENT_SLEEP,      
00897         TRACE_EVENT_PACKET,     
00898         TRACE_EVENT_TERMINATE   
00899 } libtrace_event_t;
00900 
00902 typedef struct libtrace_eventobj_t {
00903         libtrace_event_t type; 
00904         int fd;                
00905         double seconds;        
00907         int size;              
00910 } libtrace_eventobj_t;
00911 
00924 DLLEXPORT libtrace_eventobj_t trace_event(libtrace_t *trace,
00925                 libtrace_packet_t *packet);
00926 
00927 
00934 DLLEXPORT int trace_write_packet(libtrace_out_t *trace, libtrace_packet_t *packet);
00951 DLLEXPORT SIMPLE_FUNCTION
00952 void *trace_get_link(const libtrace_packet_t *packet);
00953 
00959 DLLEXPORT SIMPLE_FUNCTION
00960 libtrace_ip_t *trace_get_ip(libtrace_packet_t *packet);
00961 
00967 DLLEXPORT SIMPLE_FUNCTION
00968 libtrace_ip6_t *trace_get_ip6(libtrace_packet_t *packet);
00969 
00980 DLLEXPORT SIMPLE_FUNCTION
00981 void *trace_get_layer3(libtrace_packet_t *packet,
00982                 uint16_t *ethertype, uint32_t *remaining);
00983 
00992 DLLEXPORT void *trace_get_transport(libtrace_packet_t *packet, uint8_t *proto, 
00993                 uint32_t *remaining);
00994 
01011 DLLEXPORT void *trace_get_payload_from_ip(libtrace_ip_t *ip, uint8_t *proto,
01012                 uint32_t *remaining);
01013 
01029 DLLEXPORT void *trace_get_payload_from_ip6(libtrace_ip6_t *ipptr,
01030                 uint8_t *prot, uint32_t *remaining);
01031 
01048 DLLEXPORT void *trace_get_payload_from_link(void *linkptr,
01049                 libtrace_linktype_t linktype, 
01050                 uint16_t *type, uint32_t *remaining);
01051 
01069 DLLEXPORT void *trace_get_vlan_payload_from_ethernet_payload(
01070                 void *ethernet_payload, uint16_t *type, uint32_t *remaining);
01071 
01084 DLLEXPORT void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, 
01085                 uint32_t *remaining);
01086 
01098 DLLEXPORT void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining);
01099 
01111 DLLEXPORT void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, 
01112                 uint32_t *remaining);
01113 
01119 DLLEXPORT SIMPLE_FUNCTION
01120 libtrace_tcp_t *trace_get_tcp(libtrace_packet_t *packet);
01121 
01135 DLLEXPORT SIMPLE_FUNCTION
01136 libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip, uint32_t *remaining);
01137 
01143 DLLEXPORT SIMPLE_FUNCTION
01144 libtrace_udp_t *trace_get_udp(libtrace_packet_t *packet);
01145 
01159 DLLEXPORT SIMPLE_FUNCTION
01160 libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
01161 
01167 DLLEXPORT SIMPLE_FUNCTION
01168 libtrace_icmp_t *trace_get_icmp(libtrace_packet_t *packet);
01169 
01182 DLLEXPORT SIMPLE_FUNCTION
01183 libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
01184 
01190 DLLEXPORT SIMPLE_FUNCTION
01191 uint8_t *trace_get_destination_mac(libtrace_packet_t *packet);
01192 
01197 DLLEXPORT SIMPLE_FUNCTION
01198 uint8_t *trace_get_source_mac(libtrace_packet_t *packet);
01199 
01207 DLLEXPORT SIMPLE_FUNCTION
01208 struct sockaddr *trace_get_source_address(const libtrace_packet_t *packet,
01209                 struct sockaddr *addr);
01210 
01218 DLLEXPORT SIMPLE_FUNCTION
01219 struct sockaddr *trace_get_destination_address(const libtrace_packet_t *packet,
01220                 struct sockaddr *addr);
01221 
01241 DLLEXPORT int trace_get_next_option(unsigned char **ptr,int *len,
01242                         unsigned char *type,
01243                         unsigned char *optlen,
01244                         unsigned char **data);
01245 
01246 
01258 DLLEXPORT SIMPLE_FUNCTION
01259 uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet);
01260 
01266 DLLEXPORT SIMPLE_FUNCTION
01267 struct timeval trace_get_timeval(const libtrace_packet_t *packet);
01268 
01275 DLLEXPORT SIMPLE_FUNCTION
01276 double trace_get_seconds(const libtrace_packet_t *packet);
01277 
01287 DLLEXPORT int trace_seek_seconds(libtrace_t *trace, double seconds);
01288 
01298 DLLEXPORT int trace_seek_timeval(libtrace_t *trace, struct timeval tv);
01299 
01309 DLLEXPORT int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts);
01310 
01332 DLLEXPORT SIMPLE_FUNCTION
01333 size_t trace_get_capture_length(libtrace_packet_t *packet);
01334 
01347 DLLEXPORT SIMPLE_FUNCTION
01348 size_t trace_get_wire_length(const libtrace_packet_t *packet);
01349 
01356 DLLEXPORT SIMPLE_FUNCTION
01357 size_t trace_get_framing_length(const libtrace_packet_t *packet);
01358 
01365 DLLEXPORT size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size);
01366 
01374 DLLEXPORT SIMPLE_FUNCTION
01375 libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet);
01376 
01382 DLLEXPORT libtrace_direction_t trace_set_direction(libtrace_packet_t *packet, libtrace_direction_t direction);
01383 
01392 DLLEXPORT SIMPLE_FUNCTION
01393 libtrace_direction_t trace_get_direction(const libtrace_packet_t *packet);
01394 
01407 DLLEXPORT SIMPLE_FUNCTION
01408 libtrace_filter_t *trace_create_filter(const char *filterstring);
01409 
01420 DLLEXPORT int trace_apply_filter(libtrace_filter_t *filter,
01421                 const libtrace_packet_t *packet);
01422 
01427 DLLEXPORT void trace_destroy_filter(libtrace_filter_t *filter);
01449 DLLEXPORT char *trace_ether_ntoa(const uint8_t *addr, char *buf);
01450 
01464 DLLEXPORT uint8_t *trace_ether_aton(const char *buf, uint8_t *addr);
01465 
01470 typedef enum {
01471         USE_DEST,       
01472         USE_SOURCE      
01473 } serverport_t;
01474 
01480 DLLEXPORT SIMPLE_FUNCTION
01481 uint16_t trace_get_source_port(const libtrace_packet_t *packet);
01482 
01488 DLLEXPORT SIMPLE_FUNCTION
01489 uint16_t trace_get_destination_port(const libtrace_packet_t *packet);
01490 
01498 DLLEXPORT SIMPLE_FUNCTION
01499 int8_t trace_get_server_port(uint8_t protocol, uint16_t source, uint16_t dest);
01500 
01506 DLLEXPORT const char *trace_parse_uri(const char *uri, char **format);
01507 
01512 DLLEXPORT 
01513 enum base_format_t trace_get_format(struct libtrace_packet_t *packet);
01514 
01522 DLLEXPORT
01523 void trace_construct_packet(libtrace_packet_t *packet,
01524                 libtrace_linktype_t linktype, const void *data, uint16_t len);
01525 
01545 #ifndef ARPHRD_80211_RADIOTAP
01546 /* libc doesn't define this yet, but it seems to be what everyone is using
01547  */
01548 #define ARPHRD_80211_RADIOTAP 803
01549 #endif
01550 
01562 DLLEXPORT bool trace_get_wireless_tsft(void *linkptr,
01563         libtrace_linktype_t linktype, uint64_t *tsft);
01564 
01571 DLLEXPORT bool trace_get_wireless_rate(void *linkptr,
01572         libtrace_linktype_t linktype, uint8_t *rate);
01573 
01581 DLLEXPORT bool trace_get_wireless_freq(void *linkptr,
01582         libtrace_linktype_t linktype, uint16_t *freq);
01583 
01591 DLLEXPORT bool trace_get_wireless_signal_strength_dbm(void *linkptr,
01592         libtrace_linktype_t linktype, int8_t *strength);
01593 
01601 DLLEXPORT bool trace_get_wireless_noise_strength_dbm(void *linkptr,
01602         libtrace_linktype_t linktype, int8_t *strength);
01603 
01611 DLLEXPORT bool trace_get_wireless_signal_strength_db(void *linkptr,
01612         libtrace_linktype_t linktype, uint8_t *strength);
01613 
01621 DLLEXPORT bool trace_get_wireless_noise_strength_db(void *linkptr,
01622         libtrace_linktype_t linktype, uint8_t *strength);
01623 
01631 DLLEXPORT bool trace_get_wireless_tx_attenuation(void *linkptr,
01632         libtrace_linktype_t linktype, uint16_t *attenuation);
01633 
01641 DLLEXPORT bool trace_get_wireless_tx_attenuation_db(void *linkptr,
01642         libtrace_linktype_t linktype, uint16_t *attenuation);
01643 
01649 DLLEXPORT bool trace_get_wireless_tx_power_dbm(void *linkptr, libtrace_linktype_t
01650                 linktype, int8_t *txpower);
01651 
01658 DLLEXPORT bool trace_get_wireless_antenna(void *linkptr,
01659         libtrace_linktype_t linktype, uint8_t *antenna);
01660 
01663 #ifdef __cplusplus
01664 } /* extern "C" */
01665 #endif /* #ifdef __cplusplus */
01666 #endif /* LIBTRACE_H_ */

Generated on Wed Sep 5 17:48:05 2007 for WAND Trace processing by  doxygen 1.4.2