Changeset a7d1914
- Timestamp:
- 09/27/06 15:53:27 (15 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:
- 742a332
- Parents:
- 41b7eab
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/skeleton/event.c
rbad6a93 ra7d1914 88 88 if (obj.size == -1) 89 89 return -1; 90 return packet->size;90 return 1; 91 91 92 92 /* End of trace has been reached */ -
lib/format_duck.c
r85a79b0 ra7d1914 194 194 } 195 195 196 packet->size = duck_size;197 196 return numbytes; 198 197 } … … 210 209 211 210 assert(OUTPUT->file); 212 /* Common sense size checking */213 assert(packet->size < 400);214 211 215 212 if (OUTPUT->dag_version == 0) { -
lib/format_erf.c
r5945854 ra7d1914 547 547 548 548 packet->type = RT_DUCK_2_4; 549 packet->size = sizeof(duck_inf);550 549 if (!DUCK.dummy_duck) 551 550 DUCK.dummy_duck = trace_create_dead("duck:dummy"); 552 551 packet->trace = DUCK.dummy_duck; 553 return packet->size;552 return sizeof(duck_inf); 554 553 } 555 554 #else … … 581 580 582 581 packet->type = RT_DUCK_2_5; 583 packet->size = sizeof(duckinf_t);584 582 if (!DUCK.dummy_duck) 585 583 DUCK.dummy_duck = trace_create_dead("rt:localhost:3434"); 586 584 packet->trace = DUCK.dummy_duck; 587 return packet->size;585 return sizeof(duck_inf); 588 586 } 589 587 #endif … … 662 660 DAG.diff -= size; 663 661 664 if (packet->payload != NULL)665 packet->size = trace_get_capture_length(packet) +666 erf_get_framing_length(packet);667 else668 packet->size = erf_get_framing_length(packet);669 670 662 tv = trace_get_timeval(packet); 671 663 DUCK.last_pkt = tv.tv_sec; 672 664 673 return (packet->size);665 return packet->payload ? size : erf_get_framing_length(packet); 674 666 } 675 667 -
lib/format_rt.c
r01818c6 ra7d1914 515 515 } 516 516 packet->type = RT_INFO->rt_hdr.type; 517 packet->size = RT_INFO->rt_hdr.length;518 517 519 518 if (packet->type >= RT_DATA_SIMPLE) { … … 580 579 /* Return the number of bytes read from the stream */ 581 580 RT_INFO->rt_hdr.type = RT_LAST; 582 return packet->size;581 return RT_INFO->rt_hdr.length; 583 582 } 584 583 -
lib/format_wag.c
re0f9c80 ra7d1914 338 338 packet->header = packet->buffer; 339 339 packet->payload=(char*)packet->buffer+trace_get_framing_length(packet); 340 packet->size = trace_get_framing_length(packet) + trace_get_capture_length(packet);341 340 return numbytes; 342 341 } -
lib/libtrace.h.in
rd80422e ra7d1914 177 177 void *header; /**< pointer to the framing header */ 178 178 void *payload; /**< pointer to the link layer */ 179 void *buffer; /**< allocated buffer */ 180 uint32_t type; /**< rt protocol type for the packet */ 179 181 buf_control_t buf_control; /**< who owns the memory */ 180 void *buffer; /**< allocated buffer */181 size_t size; /**< trace_get_framing_length()182 * +trace_get_capture_length() */183 uint32_t type; /**< rt protocol type for the packet */184 182 } libtrace_packet_t; 185 183 -
lib/linktypes.c
r8889370 ra7d1914 173 173 packet->payload=tmpbuffer+trace_get_framing_length(packet); 174 174 packet->type=pcap_dlt_to_rt(TRACE_DLT_LINUX_SLL); 175 packet->size+=sizeof(libtrace_sll_header_t);176 175 ((struct pcap_pkthdr*) packet->header)->caplen+= 177 176 sizeof(libtrace_sll_header_t); -
lib/trace.c
r0453ca8 ra7d1914 632 632 dest->payload=(void*) 633 633 ((char*)dest->buffer+trace_get_framing_length(packet)); 634 dest->size=packet->size;635 634 dest->type=packet->type; 636 635 dest->buf_control=TRACE_CTRL_PACKET; … … 677 676 if (libtrace->format->read_packet) { 678 677 do { 679 packet->size=libtrace->format->read_packet(libtrace,packet); 680 if (packet->size==(size_t)-1 || packet->size==0) { 681 return packet->size; 678 size_t ret; 679 ret=libtrace->format->read_packet(libtrace,packet); 680 if (ret==(size_t)-1 || ret==0) { 681 return ret; 682 682 } 683 683 if (libtrace->filter) { … … 694 694 libtrace->snaplen); 695 695 } 696 return packet->size;696 return ret; 697 697 } while(1); 698 698 } 699 699 trace_set_err(libtrace,TRACE_ERR_UNSUPPORTED,"This format does not support reading packets\n"); 700 packet->size=~0U;701 700 return ~0U; 702 701 } … … 714 713 assert(packet); 715 714 /* Verify the packet is valid */ 716 assert(packet->size<65536);717 assert(packet->size>0);718 715 assert(libtrace->started); 719 716 … … 750 747 double seconds = 0.0; 751 748 struct timeval ts; 752 753 assert(packet->size>0 && packet->size<65536);754 749 755 750 if (packet->trace->format->get_erf_timestamp) { … … 781 776 uint64_t ts = 0; 782 777 double seconds = 0.0; 783 assert(packet->size>0 && packet->size<65536);784 778 if (packet->trace->format->get_timeval) { 785 779 /* timeval -> timeval */ … … 820 814 struct timeval tv; 821 815 822 assert(packet->size>0 && packet->size<65536);823 824 816 if (packet->trace->format->get_seconds) { 825 817 /* seconds->seconds */ … … 838 830 } 839 831 840 DLLEXPORT size_t trace_get_capture_length(const libtrace_packet_t *packet) { 841 842 assert(packet->size<65536); 843 832 DLLEXPORT size_t trace_get_capture_length(const libtrace_packet_t *packet) 833 { 844 834 if (packet->trace->format->get_capture_length) { 845 835 return packet->trace->format->get_capture_length(packet); … … 858 848 */ 859 849 DLLEXPORT size_t trace_get_wire_length(const libtrace_packet_t *packet){ 860 assert(packet->size>0 && packet->size<65536);861 862 850 if (packet->trace->format->get_wire_length) { 863 851 return packet->trace->format->get_wire_length(packet); … … 1053 1041 { 1054 1042 assert(packet); 1055 assert(packet->size>0 && packet->size<65536);1056 1043 if (packet->trace->format->set_direction) { 1057 1044 return packet->trace->format->set_direction(packet,direction); … … 1072 1059 { 1073 1060 assert(packet); 1074 assert(packet->size>0 && packet->size<65536);1075 1061 if (packet->trace->format->get_direction) { 1076 1062 return packet->trace->format->get_direction(packet); … … 1207 1193 DLLEXPORT size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size) { 1208 1194 assert(packet); 1209 assert(packet->size>0 && packet->size<65536);1210 1195 1211 1196 if (packet->trace->format->set_capture_length) { 1212 1197 int caplen=packet->trace->format->set_capture_length(packet,size); 1213 1198 if (caplen!=-1) { 1214 packet->size=trace_get_framing_length(packet)+caplen;1199 trace_get_framing_length(packet)+caplen; 1215 1200 } 1216 1201 return caplen; … … 1423 1408 uint16_t len) 1424 1409 { 1410 size_t size; 1425 1411 libtrace_t *deadtrace=NULL; 1426 1412 libtrace_pcapfile_pkt_hdr_t hdr; … … 1434 1420 1435 1421 packet->trace=deadtrace; 1436 packet->size=len+sizeof(hdr);1422 size=len+sizeof(hdr); 1437 1423 if (packet->buf_control==TRACE_CTRL_PACKET) { 1438 packet->buffer=realloc(packet->buffer, packet->size);1424 packet->buffer=realloc(packet->buffer,size); 1439 1425 } 1440 1426 else { 1441 packet->buffer=malloc( packet->size);1427 packet->buffer=malloc(size); 1442 1428 } 1443 1429 packet->buf_control=TRACE_CTRL_PACKET;
Note: See TracChangeset
for help on using the changeset viewer.