Changeset 91c9552 for lib/trace.c
- Timestamp:
- 02/23/06 11:21:19 (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:
- aa62105
- Parents:
- c2d5f23
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/trace.c
rc1db742 r91c9552 523 523 } 524 524 525 libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet) { 526 libtrace_packet_t *dest = malloc(sizeof(libtrace_packet_t)); 527 dest->trace=packet->trace; 528 dest->buffer=malloc( 529 trace_get_framing_length(packet) 530 +trace_get_capture_length(packet)); 531 dest->header=dest->buffer; 532 dest->payload=(void*) 533 ((char*)dest->buffer+trace_get_framing_length(packet)); 534 dest->size=packet->size; 535 dest->type=packet->type; 536 dest->buf_control=TRACE_CTRL_PACKET; 537 memcpy(dest->header,packet->header,trace_get_framing_length(packet)); 538 memcpy(dest->payload,packet->payload,trace_get_capture_length(packet)); 539 } 540 525 541 /** Destroy a packet object 526 542 * … … 528 544 */ 529 545 void trace_destroy_packet(struct libtrace_packet_t **packet) { 530 if ((*packet)->buf_control ) {546 if ((*packet)->buf_control == TRACE_CTRL_PACKET) { 531 547 free((*packet)->buffer); 532 548 } … … 1289 1305 linkptr = trace_get_link(packet); 1290 1306 if (!linkptr) { 1307 trace_set_err(TRACE_ERR_BAD_PACKET,"Packet has no payload"); 1291 1308 return -1; 1292 1309 } … … 1301 1318 1, 0)) { 1302 1319 pcap_close(pcap); 1320 trace_set_err(TRACE_ERR_BAD_PACKET, 1321 "Packet has no payload"); 1303 1322 return -1; 1304 1323 } … … 1312 1331 } 1313 1332 1314 /* apply a BPF filter1315 * @param filter the filter opaque pointer1316 * @param packet the packet opaque pointer1317 * @returns 0 if the filter fails, 1 if it succeeds1318 * @author Daniel Lawson1319 */1320 1333 int trace_bpf_filter(struct libtrace_filter_t *filter, 1321 1334 const struct libtrace_packet_t *packet) { … … 1333 1346 * link type was 1334 1347 */ 1335 trace_bpf_compile(filter,packet); 1348 if (trace_bpf_compile(filter,packet)==-1) 1349 return -1; 1336 1350 1337 1351 clen = trace_get_capture_length(packet);
Note: See TracChangeset
for help on using the changeset viewer.