- Timestamp:
- 02/24/06 14:31:30 (16 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 0d768c8
- Parents:
- c6a6c3a
- Location:
- lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/libtrace.h
r0ea3526 r2e223eca 86 86 typedef struct libtrace_filter_t libtrace_filter_t; 87 87 88 /* the letters p and e are magic numbers used to detect if the packet 88 /** if a packet has memory allocated 89 * If the packet has allocated it's own memory it's buffer_control should 90 * be TRACE_CTRL_PACKET, when the packet is destroyed it's memory will be 91 * free()'d. If it's doing zerocopy out of memory owned by something else 92 * it should be TRACE_CTRL_EXTERNAL. 93 * @note the letters p and e are magic numbers used to detect if the packet 89 94 * wasn't created properly 90 95 */ 91 typedef enum {TRACE_CTRL_PACKET='p', TRACE_CTRL_EXTERNAL='e' } buf_control_t; 96 typedef enum { 97 TRACE_CTRL_PACKET='p', 98 TRACE_CTRL_EXTERNAL='e' 99 } buf_control_t; 92 100 /** Structure holding information about a packet */ 93 101 #define LIBTRACE_PACKET_BUFSIZE 65536 … … 247 255 typedef struct libtrace_ether 248 256 { 249 u_int8_t ether_dhost[6]; /* destination ether addr */250 u_int8_t ether_shost[6]; /* source ether addr */251 u_int16_t ether_type; /* packet type ID field (next-header) */257 u_int8_t ether_dhost[6]; /**< destination ether addr */ 258 u_int8_t ether_shost[6]; /**< source ether addr */ 259 u_int16_t ether_type; /**< packet type ID field (next-header) */ 252 260 } __attribute__ ((packed)) libtrace_ether_t; 253 261 … … 255 263 typedef struct libtrace_8021q 256 264 { 257 u_int8_t ether_dhost[6]; /* destination eth addr */ 258 u_int8_t ether_shost[6]; /* source ether addr */ 259 u_int16_t ether_type; /* packet type ID field , 0x8100 for VLAN */ 260 unsigned int vlan_pri:3; /* vlan user priority */ 261 unsigned int vlan_cfi:1; /* vlan format indicator, 0 for ethernet, 1 for token ring */ 262 unsigned int vlan_id:12; /* vlan id */ 263 u_int16_t vlan_ether_type; /* vlan sub-packet type ID field (next-header)*/ 265 u_int8_t ether_dhost[6]; /**< destination eth addr */ 266 u_int8_t ether_shost[6]; /**< source ether addr */ 267 u_int16_t ether_type; /**< packet type ID field , 0x8100 for VLAN */ 268 unsigned int vlan_pri:3; /**< vlan user priority */ 269 unsigned int vlan_cfi:1; /**< vlan format indicator, 270 * 0 for ethernet, 1 for token ring */ 271 unsigned int vlan_id:12; /**< vlan id */ 272 u_int16_t vlan_ether_type; /**< vlan sub-packet type ID field 273 * (next-header)*/ 264 274 } __attribute__ ((packed)) libtrace_8021q_t; 265 275 … … 326 336 * - wag:/path/to/wag/socket 327 337 * 328 * If an error occured when attempting to open the trace file, NULL is returned329 * and trace_errno is set. Use trace_perror() to get more information.330 * The trace is created in the configuration state, you must call trace_start331 * to start the capture.332 */ 333 structlibtrace_t *trace_create(const char *uri);338 * If an error occured when attempting to open the trace file, an error 339 * trace is returned and trace_get_error should be called to find out 340 * if an error occured, and what that error was. The trace is created in the 341 * configuration state, you must call trace_start to start the capture. 342 */ 343 libtrace_t *trace_create(const char *uri); 334 344 335 345 /** Creates a "dummy" trace file that has only the format type set. … … 337 347 * @return opaque pointer to a (sparsely initialised) libtrace_t 338 348 * 339 * IMPORTANT: Do not attempt to call trace_read_packet or other such functions with340 * the dummy trace. Its intended purpose is to act as a packet->trace for libtrace_packet_t's341 * that are not associated with a libtrace_t structure.342 */ 343 structlibtrace_t *trace_create_dead(const char *uri);349 * IMPORTANT: Do not attempt to call trace_read_packet or other such functions 350 * with the dummy trace. Its intended purpose is to act as a packet->trace for 351 * libtrace_packet_t's that are not associated with a libtrace_t structure. 352 */ 353 libtrace_t *trace_create_dead(const char *uri); 344 354 345 355 /** Creates a trace output file from a URI. … … 927 937 const char *trace_parse_uri(const char *uri, char **format); 928 938 929 /* Base format type definitions */ 939 /** RT protocol base format identifiers 940 * This is used to say what kind of packet is being sent over the rt protocol 941 */ 930 942 enum base_format_t { 931 943 TRACE_FORMAT_ERF =1, -
lib/libtrace_int.h
r0ea3526 r2e223eca 94 94 struct libtrace_format_t *format; /**< format driver pointer */ 95 95 struct libtrace_format_data_t *format_data; /**<format data pointer */ 96 bool started; 97 libtrace_err_t err; 98 struct libtrace_event_t event; 99 char *uridata; 100 struct tracefifo_t *fifo; 96 bool started; /**< if this trace has started */ 97 libtrace_err_t err; /**< error information */ 98 struct libtrace_event_t event; /**< the next event */ 99 char *uridata; /**< the uri of this trace */ 100 struct tracefifo_t *fifo; /**< fifo used in this trace */ 101 101 struct libtrace_filter_t *filter; /**< used by libtrace if the module 102 102 * doesn't support filters natively … … 107 107 }; 108 108 109 /** Information about output traces 110 * @internal 111 */ 109 112 struct libtrace_out_t { 110 struct libtrace_format_t *format; 111 struct libtrace_format_data_out_t *format_data; 113 struct libtrace_format_t *format; /**< format driver */ 114 struct libtrace_format_data_out_t *format_data; /**< format data */ 112 115 bool started; 113 libtrace_err_t err; 114 char *uridata; 115 struct tracefifo_t *fifo; 116 libtrace_err_t err; /**< Associated error */ 117 char *uridata; /**< URI associated with this trace */ 116 118 }; 117 119 -
lib/trace.c
r0ea3526 r2e223eca 386 386 387 387 388 libtrace->fifo = create_tracefifo(1048576);389 assert( libtrace->fifo);390 388 free(scan); 391 389 libtrace->started=false; … … 511 509 libtrace->format->fin_output(libtrace); 512 510 free(libtrace->uridata); 513 destroy_tracefifo(libtrace->fifo);514 511 free(libtrace); 515 512 } … … 1074 1071 #error "What on earth are you running this on?" 1075 1072 #endif 1076 ts = (1000000 * (ts & 0xffffffffULL)); 1077 ts += (ts & 0x80000000ULL) << 1; 1078 tv.tv_usec = ts >> 32; 1073 tv.tv_usec = ((ts&0xFFFFFFFF)*1000000)>>32; 1079 1074 if (tv.tv_usec >= 1000000) { 1080 1075 tv.tv_usec -= 1000000;
Note: See TracChangeset
for help on using the changeset viewer.