00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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
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
00080
00081
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
00097
00098
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
00111 # define bool signed char
00112 # define false 0
00113 # define true 1
00114 # if !defined(ssize_t)
00115
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)|(0))
00132
00133 #ifdef __cplusplus
00134 extern "C" {
00135 #endif
00136
00137
00138
00139
00140 #if __GNUC__ >= 3
00141 # define SIMPLE_FUNCTION __attribute__((pure))
00142 # define UNUSED __attribute__((unused))
00143 # define PACKED __attribute__((packed))
00144 # define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos)))
00145 #else
00146 # define SIMPLE_FUNCTION
00147 # define UNUSED
00148 # define PACKED
00149 # define PRINTF(formatpos,argpos)
00150 #endif
00151
00153 typedef struct libtrace_out_t libtrace_out_t;
00154
00156 typedef struct libtrace_t libtrace_t;
00157
00159 typedef struct libtrace_filter_t libtrace_filter_t;
00160
00169 typedef enum {
00170 TRACE_CTRL_PACKET='p',
00171 TRACE_CTRL_EXTERNAL='e'
00172 } buf_control_t;
00174 #define LIBTRACE_PACKET_BUFSIZE 65536
00175
00177 typedef struct trace_err_t{
00178 int err_num;
00179 char problem[255];
00180 } libtrace_err_t;
00181
00183 enum {
00185 TRACE_ERR_NOERROR = 0,
00187 TRACE_ERR_BAD_FORMAT = -1,
00189 TRACE_ERR_INIT_FAILED = -2,
00191 TRACE_ERR_UNKNOWN_OPTION= -3,
00193 TRACE_ERR_NO_CONVERSION = -4,
00195 TRACE_ERR_BAD_PACKET = -5,
00197 TRACE_ERR_OPTION_UNAVAIL= -6,
00199 TRACE_ERR_UNSUPPORTED = -7
00200 };
00201
00206 typedef enum {
00207 TRACE_DLT_NULL = 0,
00208 TRACE_DLT_EN10MB = 1,
00209 TRACE_DLT_ATM_RFC1483 = 11,
00210 TRACE_DLT_RAW = 101,
00211 TRACE_DLT_IEEE802_11 = 105,
00212 TRACE_DLT_LINUX_SLL = 113,
00213 TRACE_DLT_PFLOG = 117,
00214 TRACE_DLT_IEEE802_11_RADIO = 127
00215 } libtrace_dlt_t ;
00216
00218 typedef enum {
00219
00220 TRACE_TYPE_HDLC_POS = 1,
00221 TRACE_TYPE_ETH = 2,
00222 TRACE_TYPE_ATM = 3,
00223 TRACE_TYPE_80211 = 4,
00224 TRACE_TYPE_NONE = 5,
00225 TRACE_TYPE_LINUX_SLL = 6,
00226 TRACE_TYPE_PFLOG = 7,
00227
00228 TRACE_TYPE_POS = 9,
00229
00230
00231 TRACE_TYPE_80211_PRISM = 12,
00232 TRACE_TYPE_AAL5 = 13,
00233 TRACE_TYPE_DUCK = 14,
00234 TRACE_TYPE_80211_RADIO = 15,
00235 TRACE_TYPE_LLCSNAP = 16
00237 } libtrace_linktype_t;
00238
00242 enum base_format_t {
00243 TRACE_FORMAT_ERF =1,
00244 TRACE_FORMAT_PCAP =2,
00245 TRACE_FORMAT_PCAPFILE =3,
00246 TRACE_FORMAT_WAG =4,
00247 TRACE_FORMAT_RT =5,
00248 TRACE_FORMAT_LEGACY_ATM =6,
00249 TRACE_FORMAT_LEGACY_POS =7,
00250 TRACE_FORMAT_LEGACY_ETH =8,
00251 TRACE_FORMAT_LINUX_NATIVE =9,
00252 TRACE_FORMAT_DUCK =10,
00253 TRACE_FORMAT_BPF =11
00254 };
00255
00256
00257 typedef enum {
00258 TRACE_RT_HELLO =1,
00259 TRACE_RT_START =2,
00261 TRACE_RT_ACK =3,
00262 TRACE_RT_STATUS =4,
00263 TRACE_RT_DUCK =5,
00264 TRACE_RT_END_DATA =6,
00265 TRACE_RT_CLOSE =7,
00266 TRACE_RT_DENY_CONN =8,
00267 TRACE_RT_PAUSE =9,
00269 TRACE_RT_PAUSE_ACK =10,
00270 TRACE_RT_OPTION =11,
00271 TRACE_RT_KEYCHANGE =12,
00272 TRACE_RT_DUCK_2_4 =13,
00273 TRACE_RT_DUCK_2_5 =14,
00274 TRACE_RT_LOSTCONN =15,
00276 TRACE_RT_DATA_SIMPLE = 1000,
00279 TRACE_RT_DATA_ERF =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_ERF,
00280 TRACE_RT_DATA_WAG =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_WAG,
00281 TRACE_RT_DATA_LEGACY_ATM=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_ATM,
00282 TRACE_RT_DATA_LEGACY_POS=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_POS,
00283 TRACE_RT_DATA_LEGACY_ETH=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LEGACY_ETH,
00284 TRACE_RT_DATA_LINUX_NATIVE=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LINUX_NATIVE,
00285
00286 TRACE_RT_DATA_DLT = 2000,
00291 TRACE_RT_DLT_NULL =TRACE_RT_DATA_DLT+TRACE_DLT_NULL,
00292 TRACE_RT_DLT_EN10MB =TRACE_RT_DATA_DLT+TRACE_DLT_EN10MB,
00293 TRACE_RT_DLT_IEEE802_11 =TRACE_RT_DATA_DLT+TRACE_DLT_IEEE802_11,
00294 TRACE_RT_DLT_LINUX_SLL =TRACE_RT_DATA_DLT+TRACE_DLT_LINUX_SLL,
00295 TRACE_RT_DLT_PFLOG =TRACE_RT_DATA_DLT+TRACE_DLT_PFLOG,
00296 TRACE_RT_DLT_ATM_RFC1483 =TRACE_RT_DATA_DLT+TRACE_DLT_ATM_RFC1483,
00297 TRACE_RT_LAST = (2<<31)
00298 } libtrace_rt_types_t;
00299
00303 typedef struct libtrace_packet_t {
00304 struct libtrace_t *trace;
00305 void *header;
00306 void *payload;
00307 void *buffer;
00308 libtrace_rt_types_t type;
00309 buf_control_t buf_control;
00310 } libtrace_packet_t;
00311
00312
00318 typedef enum {
00319 TRACE_DIR_OUTGOING = 0,
00320 TRACE_DIR_INCOMING = 1,
00321 TRACE_DIR_OTHER = 2
00322 } libtrace_direction_t;
00323
00325 typedef enum {
00326 TRACE_RADIOTAP_TSFT = 0,
00327 TRACE_RADIOTAP_FLAGS = 1,
00328 TRACE_RADIOTAP_RATE = 2,
00329 TRACE_RADIOTAP_CHANNEL = 3,
00330 TRACE_RADIOTAP_FHSS = 4,
00331 TRACE_RADIOTAP_DBM_ANTSIGNAL = 5,
00332 TRACE_RADIOTAP_DBM_ANTNOISE = 6,
00333 TRACE_RADIOTAP_LOCK_QUALITY = 7,
00334 TRACE_RADIOTAP_TX_ATTENUATION = 8,
00335 TRACE_RADIOTAP_DB_TX_ATTENUATION = 9,
00336 TRACE_RADIOTAP_DBM_TX_POWER = 10,
00337 TRACE_RADIOTAP_ANTENNA = 11,
00338 TRACE_RADIOTAP_DB_ANTSIGNAL = 12,
00339 TRACE_RADIOTAP_DB_ANTNOISE = 13,
00340 TRACE_RADIOTAP_FCS = 14,
00341 TRACE_RADIOTAP_EXT = 31
00342 } libtrace_radiotap_field_t;
00343
00344
00351 #ifdef WIN32
00352 #pragma pack(push)
00353 #pragma pack(1)
00354 #endif
00355
00357 typedef struct libtrace_ip
00358 {
00359 #if BYTE_ORDER == LITTLE_ENDIAN
00360 LT_BITFIELD8 ip_hl:4;
00361 LT_BITFIELD8 ip_v:4;
00362 #elif BYTE_ORDER == BIG_ENDIAN
00363 LT_BITFIELD8 ip_v:4;
00364 LT_BITFIELD8 ip_hl:4;
00365 #else
00366 # error "Adjust your <bits/endian.h> defines"
00367 #endif
00368 uint8_t ip_tos;
00369 uint16_t ip_len;
00370 int16_t ip_id;
00371 #if BYTE_ORDER == LITTLE_ENDIAN
00372 LT_BITFIELD16 ip_off:12;
00373 LT_BITFIELD16 ip_mf:1;
00374 LT_BITFIELD16 ip_df:1;
00375 LT_BITFIELD16 ip_rf:1;
00376 #elif BYTE_ORDER == BIG_ENDIAN
00377 LT_BITFIELD16 ip_rf:1;
00378 LT_BITFIELD16 ip_df:1;
00379 LT_BITFIELD16 ip_mf:1;
00380 LT_BITFIELD16 ip_off:12;
00381 #else
00382 # error "Adjust your <bits/endian.h> defines"
00383 #endif
00384 uint8_t ip_ttl;
00385 uint8_t ip_p;
00386 uint16_t ip_sum;
00387 struct in_addr ip_src;
00388 struct in_addr ip_dst;
00389 } PACKED libtrace_ip_t;
00390
00392 typedef struct libtrace_ip6_ext
00393 {
00394 uint8_t nxt;
00395 uint8_t len;
00396 } PACKED libtrace_ip6_ext_t;
00397
00399 typedef struct libtrace_ip6
00400 {
00401 uint32_t flow;
00402 uint16_t plen;
00403 uint8_t nxt;
00404 uint8_t hlim;
00405 struct in6_addr ip_src;
00406 struct in6_addr ip_dst;
00407 } PACKED libtrace_ip6_t;
00408
00410 typedef struct libtrace_tcp
00411 {
00412 uint16_t source;
00413 uint16_t dest;
00414 uint32_t seq;
00415 uint32_t ack_seq;
00416 # if BYTE_ORDER == LITTLE_ENDIAN
00417 LT_BITFIELD8 res1:4;
00418 LT_BITFIELD8 doff:4;
00419 LT_BITFIELD8 fin:1;
00420 LT_BITFIELD8 syn:1;
00421 LT_BITFIELD8 rst:1;
00422 LT_BITFIELD8 psh:1;
00423 LT_BITFIELD8 ack:1;
00424 LT_BITFIELD8 urg:1;
00425 LT_BITFIELD8 res2:2;
00426 # elif BYTE_ORDER == BIG_ENDIAN
00427 LT_BITFIELD8 doff:4;
00428 LT_BITFIELD8 res1:4;
00429 LT_BITFIELD8 res2:2;
00430 LT_BITFIELD8 urg:1;
00431 LT_BITFIELD8 ack:1;
00432 LT_BITFIELD8 psh:1;
00433 LT_BITFIELD8 rst:1;
00434 LT_BITFIELD8 syn:1;
00435 LT_BITFIELD8 fin:1;
00436 # else
00437 # error "Adjust your <bits/endian.h> defines"
00438 # endif
00439 uint16_t window;
00440 uint16_t check;
00441 uint16_t urg_ptr;
00442 } PACKED libtrace_tcp_t;
00443
00445 typedef struct libtrace_udp {
00446 uint16_t source;
00447 uint16_t dest;
00448 uint16_t len;
00449 uint16_t check;
00450 } PACKED libtrace_udp_t;
00451
00453 typedef struct libtrace_icmp
00454 {
00455 uint8_t type;
00456 uint8_t code;
00457 uint16_t checksum;
00458 union
00459 {
00460 struct
00461 {
00462 uint16_t id;
00463 uint16_t sequence;
00464 } echo;
00465 uint32_t gateway;
00466 struct
00467 {
00468 uint16_t unused;
00469 uint16_t mtu;
00470 } frag;
00471 } un;
00472 } PACKED libtrace_icmp_t;
00473
00475 typedef struct libtrace_llcsnap
00476 {
00477
00478 uint8_t dsap;
00479 uint8_t ssap;
00480 uint8_t control;
00481
00482 LT_BITFIELD32 oui:24;
00483 uint16_t type;
00484 } PACKED libtrace_llcsnap_t;
00485
00487 typedef struct libtrace_ether
00488 {
00489 uint8_t ether_dhost[6];
00490 uint8_t ether_shost[6];
00491 uint16_t ether_type;
00492 } PACKED libtrace_ether_t;
00493
00495 typedef struct libtrace_8021q
00496 {
00497 LT_BITFIELD16 vlan_pri:3;
00498 LT_BITFIELD16 vlan_cfi:1;
00500 LT_BITFIELD16 vlan_id:12;
00501 uint16_t vlan_ether_type;
00503 } PACKED libtrace_8021q_t;
00504
00506 typedef struct libtrace_atm_cell
00507 {
00508 LT_BITFIELD32 gfc:4;
00509 LT_BITFIELD32 vpi:8;
00510 LT_BITFIELD32 vci:16;
00511 LT_BITFIELD32 pt:3;
00512 LT_BITFIELD32 clp:1;
00513 LT_BITFIELD32 hec:8;
00514 } PACKED libtrace_atm_cell_t;
00515
00517 typedef struct libtrace_atm_nni_cell
00518 {
00519 LT_BITFIELD32 vpi:12;
00520 LT_BITFIELD32 vci:16;
00521 LT_BITFIELD32 pt:3;
00522 LT_BITFIELD32 clp:1;
00523 LT_BITFIELD32 hec:8;
00524 } PACKED libtrace_atm_nni_cell_t;
00525
00533 typedef struct libtrace_atm_capture_cell
00534 {
00535 LT_BITFIELD32 gfc:4;
00536 LT_BITFIELD32 vpi:8;
00537 LT_BITFIELD32 vci:16;
00538 LT_BITFIELD32 pt:3;
00539 LT_BITFIELD32 clp:1;
00540 } PACKED libtrace_atm_capture_cell_t;
00541
00549 typedef struct libtrace_atm_nni_capture_cell
00550 {
00551 LT_BITFIELD32 vpi:12;
00552 LT_BITFIELD32 vci:16;
00553 LT_BITFIELD32 pt:3;
00554 LT_BITFIELD32 clp:1;
00555 LT_BITFIELD32 hec:8;
00556 } PACKED libtrace_atm_nni_capture_cell_t;
00557
00559 typedef struct libtrace_pos
00560 {
00561 uint16_t header;
00562 uint16_t ether_type;
00563 } PACKED libtrace_pos_t;
00564
00566 typedef struct libtrace_80211_t {
00567 #if BYTE_ORDER == LITTLE_ENDIAN
00568 LT_BITFIELD32 protocol:2;
00569 LT_BITFIELD32 type:2;
00570 LT_BITFIELD32 subtype:4;
00571 #else
00572 LT_BITFIELD32 subtype:4;
00573 LT_BITFIELD32 type:2;
00574 LT_BITFIELD32 protocol:2;
00575 #endif
00576
00577 #if BYTE_ORDER == LITTLE_ENDIAN
00578 LT_BITFIELD32 to_ds:1;
00579 LT_BITFIELD32 from_ds:1;
00580 LT_BITFIELD32 more_frag:1;
00581 LT_BITFIELD32 retry:1;
00582 LT_BITFIELD32 power:1;
00583 LT_BITFIELD32 more_data:1;
00584 LT_BITFIELD32 wep:1;
00585 LT_BITFIELD32 order:1;
00586 #else
00587 LT_BITFIELD32 order:1;
00588 LT_BITFIELD32 wep:1;
00589 LT_BITFIELD32 more_data:1;
00590 LT_BITFIELD32 power:1;
00591 LT_BITFIELD32 retry:1;
00592 LT_BITFIELD32 more_frag:1;
00593 LT_BITFIELD32 from_ds:1;
00594 LT_BITFIELD32 to_ds:1;
00595 #endif
00596 uint16_t duration;
00597 uint8_t mac1[6];
00598 uint8_t mac2[6];
00599 uint8_t mac3[6];
00600 uint16_t SeqCtl;
00601 uint8_t mac4[6];
00602 } PACKED libtrace_80211_t;
00603
00611 typedef struct libtrace_radiotap_t {
00612 uint8_t it_version;
00613 uint8_t it_pad;
00614 uint16_t it_len;
00615 uint32_t it_present;
00616 } PACKED libtrace_radiotap_t;
00617
00618
00619 #ifdef WIN32
00620 #pragma pack(pop)
00621 #endif
00622
00623
00631 DLLEXPORT void trace_help(void);
00632
00664 DLLEXPORT libtrace_t *trace_create(const char *uri);
00665
00674 DLLEXPORT libtrace_t *trace_create_dead(const char *uri);
00675
00689 DLLEXPORT libtrace_out_t *trace_create_output(const char *uri);
00690
00698 DLLEXPORT int trace_start(libtrace_t *libtrace);
00699
00708 DLLEXPORT int trace_pause(libtrace_t *libtrace);
00709
00717 DLLEXPORT int trace_start_output(libtrace_out_t *libtrace);
00718
00720 typedef enum {
00721 TRACE_OPTION_SNAPLEN,
00722 TRACE_OPTION_PROMISC,
00723 TRACE_OPTION_FILTER,
00724 TRACE_META_FREQ
00725 } trace_option_t;
00726
00734 DLLEXPORT int trace_config(libtrace_t *libtrace,
00735 trace_option_t option,
00736 void *value);
00737
00738 typedef enum {
00739 TRACE_OPTION_OUTPUT_FILEFLAGS,
00742 TRACE_OPTION_OUTPUT_COMPRESS
00743 } trace_option_output_t;
00744
00754 DLLEXPORT int trace_config_output(libtrace_out_t *libtrace,
00755 trace_option_output_t option,
00756 void *value
00757 );
00758
00762 DLLEXPORT void trace_destroy(libtrace_t *trace);
00763
00767 DLLEXPORT void trace_destroy_dead(libtrace_t *trace);
00768
00772 DLLEXPORT void trace_destroy_output(libtrace_out_t *trace);
00773
00780 DLLEXPORT libtrace_err_t trace_get_err(libtrace_t *trace);
00781
00786 DLLEXPORT bool trace_is_err(libtrace_t *trace);
00787
00793 DLLEXPORT void trace_perror(libtrace_t *trace, const char *msg,...) PRINTF(2,3);
00794
00801 DLLEXPORT libtrace_err_t trace_get_err_output(libtrace_out_t *trace);
00802
00807 DLLEXPORT bool trace_is_err_output(libtrace_out_t *trace);
00808
00814 DLLEXPORT void trace_perror_output(libtrace_out_t *trace, const char *msg,...)
00815 PRINTF(2,3);
00816
00817
00830 DLLEXPORT libtrace_packet_t *trace_create_packet(void);
00831
00842 DLLEXPORT libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet);
00843
00848 DLLEXPORT void trace_destroy_packet(libtrace_packet_t *packet);
00849
00850
00864 DLLEXPORT int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet);
00865
00869 typedef enum {
00870 TRACE_EVENT_IOWAIT,
00871 TRACE_EVENT_SLEEP,
00872 TRACE_EVENT_PACKET,
00873 TRACE_EVENT_TERMINATE
00874 } libtrace_event_t;
00875
00877 typedef struct libtrace_eventobj_t {
00878 libtrace_event_t type;
00879 int fd;
00880 double seconds;
00882 int size;
00885 } libtrace_eventobj_t;
00886
00899 DLLEXPORT libtrace_eventobj_t trace_event(libtrace_t *trace,
00900 libtrace_packet_t *packet);
00901
00902
00909 DLLEXPORT int trace_write_packet(libtrace_out_t *trace, libtrace_packet_t *packet);
00926 DLLEXPORT SIMPLE_FUNCTION
00927 void *trace_get_link(const libtrace_packet_t *packet);
00928
00934 DLLEXPORT SIMPLE_FUNCTION
00935 libtrace_ip_t *trace_get_ip(libtrace_packet_t *packet);
00936
00942 DLLEXPORT SIMPLE_FUNCTION
00943 libtrace_ip6_t *trace_get_ip6(libtrace_packet_t *packet);
00944
00953 DLLEXPORT void *trace_get_transport(libtrace_packet_t *packet, uint8_t *proto,
00954 uint32_t *remaining);
00955
00972 DLLEXPORT void *trace_get_payload_from_ip(libtrace_ip_t *ip, uint8_t *proto,
00973 uint32_t *remaining);
00974
00990 DLLEXPORT void *trace_get_payload_from_ip6(libtrace_ip6_t *ipptr,
00991 uint8_t *prot, uint32_t *remaining);
00992
01009 DLLEXPORT void *trace_get_payload_from_link(void *linkptr,
01010 libtrace_linktype_t linktype,
01011 uint16_t *type, uint32_t *remaining);
01012
01030 DLLEXPORT void *trace_get_vlan_payload_from_ethernet_payload(
01031 void *ethernet_payload, uint16_t *type, uint32_t *remaining);
01032
01046 DLLEXPORT void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, uint32_t *remaining);
01047
01061 DLLEXPORT void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining);
01062
01076 DLLEXPORT void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, uint32_t *remaining);
01077
01083 DLLEXPORT SIMPLE_FUNCTION
01084 libtrace_tcp_t *trace_get_tcp(libtrace_packet_t *packet);
01085
01099 DLLEXPORT SIMPLE_FUNCTION
01100 libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip, uint32_t *remaining);
01101
01107 DLLEXPORT SIMPLE_FUNCTION
01108 libtrace_udp_t *trace_get_udp(libtrace_packet_t *packet);
01109
01123 DLLEXPORT SIMPLE_FUNCTION
01124 libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
01125
01131 DLLEXPORT SIMPLE_FUNCTION
01132 libtrace_icmp_t *trace_get_icmp(libtrace_packet_t *packet);
01133
01147 DLLEXPORT SIMPLE_FUNCTION
01148 libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
01149
01155 DLLEXPORT SIMPLE_FUNCTION
01156 uint8_t *trace_get_destination_mac(libtrace_packet_t *packet);
01157
01162 DLLEXPORT SIMPLE_FUNCTION
01163 uint8_t *trace_get_source_mac(libtrace_packet_t *packet);
01164
01171 DLLEXPORT SIMPLE_FUNCTION
01172 struct sockaddr *trace_get_source_address(const libtrace_packet_t *packet,
01173 struct sockaddr *addr);
01174
01181 DLLEXPORT SIMPLE_FUNCTION
01182 struct sockaddr *trace_get_destination_address(const libtrace_packet_t *packet,
01183 struct sockaddr *addr);
01184
01204 DLLEXPORT int trace_get_next_option(unsigned char **ptr,int *len,
01205 unsigned char *type,
01206 unsigned char *optlen,
01207 unsigned char **data);
01208
01209
01221 DLLEXPORT SIMPLE_FUNCTION
01222 uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet);
01223
01229 DLLEXPORT SIMPLE_FUNCTION
01230 struct timeval trace_get_timeval(const libtrace_packet_t *packet);
01231
01237 DLLEXPORT SIMPLE_FUNCTION
01238 double trace_get_seconds(const libtrace_packet_t *packet);
01239
01249 DLLEXPORT int trace_seek_seconds(libtrace_t *trace, double seconds);
01250
01260 DLLEXPORT int trace_seek_timeval(libtrace_t *trace, struct timeval tv);
01261
01271 DLLEXPORT int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts);
01272
01293 DLLEXPORT SIMPLE_FUNCTION
01294 size_t trace_get_capture_length(const libtrace_packet_t *packet);
01295
01303 DLLEXPORT SIMPLE_FUNCTION
01304 size_t trace_get_wire_length(const libtrace_packet_t *packet);
01305
01312 DLLEXPORT SIMPLE_FUNCTION
01313 size_t trace_get_framing_length(const libtrace_packet_t *packet);
01314
01321 DLLEXPORT size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size);
01322
01330 DLLEXPORT SIMPLE_FUNCTION
01331 libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet);
01332
01338 DLLEXPORT libtrace_direction_t trace_set_direction(libtrace_packet_t *packet, libtrace_direction_t direction);
01339
01348 DLLEXPORT SIMPLE_FUNCTION
01349 libtrace_direction_t trace_get_direction(const libtrace_packet_t *packet);
01350
01363 DLLEXPORT SIMPLE_FUNCTION
01364 libtrace_filter_t *trace_create_filter(const char *filterstring);
01365
01376 DLLEXPORT int trace_apply_filter(libtrace_filter_t *filter,
01377 const libtrace_packet_t *packet);
01378
01383 DLLEXPORT void trace_destroy_filter(libtrace_filter_t *filter);
01405 DLLEXPORT char *trace_ether_ntoa(const uint8_t *addr, char *buf);
01406
01420 DLLEXPORT uint8_t *trace_ether_aton(const char *buf, uint8_t *addr);
01421
01426 typedef enum {
01427 USE_DEST,
01428 USE_SOURCE
01429 } serverport_t;
01430
01436 DLLEXPORT SIMPLE_FUNCTION
01437 uint16_t trace_get_source_port(const libtrace_packet_t *packet);
01438
01444 DLLEXPORT SIMPLE_FUNCTION
01445 uint16_t trace_get_destination_port(const libtrace_packet_t *packet);
01446
01454 DLLEXPORT SIMPLE_FUNCTION
01455 int8_t trace_get_server_port(uint8_t protocol, uint16_t source, uint16_t dest);
01456
01462 DLLEXPORT const char *trace_parse_uri(const char *uri, char **format);
01463
01468 DLLEXPORT
01469 enum base_format_t trace_get_format(struct libtrace_packet_t *packet);
01470
01478 DLLEXPORT
01479 void trace_construct_packet(libtrace_packet_t *packet,
01480 libtrace_linktype_t linktype, const void *data, uint16_t len);
01481
01501 #ifndef ARPHRD_80211_RADIOTAP
01502
01503
01504 #define ARPHRD_80211_RADIOTAP 803
01505 #endif
01506
01518 DLLEXPORT bool trace_get_wireless_tsft(void *linkptr,
01519 libtrace_linktype_t linktype, uint64_t *tsft);
01520
01527 DLLEXPORT bool trace_get_wireless_rate(void *linkptr,
01528 libtrace_linktype_t linktype, uint8_t *rate);
01529
01537 DLLEXPORT bool trace_get_wireless_freq(void *linkptr,
01538 libtrace_linktype_t linktype, uint16_t *freq);
01539
01547 DLLEXPORT bool trace_get_wireless_signal_strength_dbm(void *linkptr,
01548 libtrace_linktype_t linktype, int8_t *strength);
01549
01557 DLLEXPORT bool trace_get_wireless_noise_strength_dbm(void *linkptr,
01558 libtrace_linktype_t linktype, int8_t *strength);
01559
01567 DLLEXPORT bool trace_get_wireless_signal_strength_db(void *linkptr,
01568 libtrace_linktype_t linktype, uint8_t *strength);
01569
01577 DLLEXPORT bool trace_get_wireless_noise_strength_db(void *linkptr,
01578 libtrace_linktype_t linktype, uint8_t *strength);
01579
01587 DLLEXPORT bool trace_get_wireless_tx_attenuation(void *linkptr,
01588 libtrace_linktype_t linktype, uint16_t *attenuation);
01589
01597 DLLEXPORT bool trace_get_wireless_tx_attenuation_db(void *linkptr,
01598 libtrace_linktype_t linktype, uint16_t *attenuation);
01599
01605 DLLEXPORT bool trace_get_wireless_tx_power_dbm(void *linkptr, libtrace_linktype_t
01606 linktype, int8_t *txpower);
01607
01614 DLLEXPORT bool trace_get_wireless_antenna(void *linkptr,
01615 libtrace_linktype_t linktype, uint8_t *antenna);
01616
01623 DLLEXPORT bool trace_get_wireless_fcs(void *linkptr,
01624 libtrace_linktype_t linktype, uint32_t *fcs);
01625
01628 #ifdef __cplusplus
01629 }
01630 #endif
01631 #endif