Changeset 7c8eacf
- Timestamp:
- 10/27/05 14:05:36 (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:
- 2458162
- Parents:
- 0d82205
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r9847b48 r7c8eacf 32 32 * configure fixes for dag 33 33 * set attributes on functions to improve compiler caching 34 * include tools/ dir in distributed tar.gz 35 * added get_framing_length format function, to return the length 36 of any framing headers added by the capture process (eg, pcap or 37 ERF headers) 34 38 35 39 - Version 2.0.22 -
lib/format_erf.c
rf1a1f5e r7c8eacf 81 81 #endif 82 82 83 static struct libtrace_format_t *erf_ptr = 0;84 static struct libtrace_format_t *rtclient_ptr = 0;83 extern struct libtrace_format_t erf; 84 extern struct libtrace_format_t rtclient; 85 85 #if HAVE_DAG 86 static struct libtrace_format_t *dag_ptr = 0;86 extern struct libtrace_format_t dag; 87 87 #endif 88 static struct libtrace_format_t *legacypos_ptr = 0;89 static struct libtrace_format_t *legacyeth_ptr = 0;90 static struct libtrace_format_t *legacyatm_ptr = 0;88 extern struct libtrace_format_t legacypos; 89 extern struct libtrace_format_t legacyeth; 90 extern struct libtrace_format_t legacyatm; 91 91 92 92 #define CONNINFO libtrace->format_data->conn_info … … 203 203 } 204 204 205 static int erf_get_ erf_headersize(const struct libtrace_packet_t *packet)205 static int erf_get_framing_length(const struct libtrace_packet_t *packet) 206 206 { 207 207 return dag_record_size + erf_get_padding(packet); … … 521 521 * with 00's if the packet is smaller, so this doesn't work. Sigh. 522 522 assert(ntohs(((dag_record_t *)buffer)->rlen) <= 523 ntohs(((dag_record_t*)buffer)->wlen)+erf_get_ erf_headersize(packet));523 ntohs(((dag_record_t*)buffer)->wlen)+erf_get_framing_length(packet)); 524 524 */ 525 525 /* Unknown/corrupt */ … … 640 640 641 641 pad = erf_get_padding(packet); 642 if (packet->trace->format == erf_ptr||642 if (packet->trace->format == &erf || 643 643 #if HAVE_DAG 644 packet->trace->format == dag_ptr||645 #endif 646 packet->trace->format == rtclient_ptr) {644 packet->trace->format == &dag || 645 #endif 646 packet->trace->format == &rtclient ) { 647 647 numbytes = erf_dump_packet(libtrace, 648 648 (dag_record_t *)packet->buffer, … … 658 658 memset(&erfhdr.flags,1,1); 659 659 // Packet length (rlen includes format overhead) 660 erfhdr.rlen = trace_get_capture_length(packet) + erf_get_ erf_headersize(packet);660 erfhdr.rlen = trace_get_capture_length(packet) + erf_get_framing_length(packet); 661 661 // loss counter. Can't do this 662 662 erfhdr.lctr = 0; … … 669 669 pad, 670 670 payload, 671 erfhdr.rlen);671 trace_get_capture_length(packet)); 672 672 } 673 673 return numbytes; … … 704 704 } 705 705 ethptr = ((uint8_t *)packet->buffer + 706 erf_get_ erf_headersize(packet));706 erf_get_framing_length(packet)); 707 707 return (void *)ethptr; 708 708 } … … 745 745 } 746 746 747 static int legacy_get_framing_length(const struct libtrace_packet_t *packet __attribute__((unused))) { 748 749 } 747 750 static int legacypos_get_wire_length(const struct libtrace_packet_t *packet) { 748 751 legacy_pos_t *lpos = (legacy_pos_t *)packet->buffer; … … 761 764 dag_record_t *erfptr = 0; 762 765 erfptr = (dag_record_t *)packet->buffer; 763 return (ntohs(erfptr->rlen) - erf_get_ erf_headersize(packet));766 return (ntohs(erfptr->rlen) - erf_get_framing_length(packet)); 764 767 } 765 768 … … 773 776 dag_record_t *erfptr = 0; 774 777 assert(packet); 775 if((size + erf_get_ erf_headersize(packet)) > packet->size) {778 if((size + erf_get_framing_length(packet)) > packet->size) { 776 779 // can't make a packet larger 777 return (packet->size - erf_get_ erf_headersize(packet));780 return (packet->size - erf_get_framing_length(packet)); 778 781 } 779 782 erfptr = (dag_record_t *)packet->buffer; 780 erfptr->rlen = htons(size + erf_get_ erf_headersize(packet));781 packet->size = size + erf_get_ erf_headersize(packet);783 erfptr->rlen = htons(size + erf_get_framing_length(packet)); 784 packet->size = size + erf_get_framing_length(packet); 782 785 return size; 783 786 } … … 902 905 legacy_get_capture_length, /* get_capture_length */ 903 906 legacyatm_get_wire_length, /* get_wire_length */ 907 legacy_get_framing_length, /* get_framing_length */ 904 908 NULL, /* set_capture_length */ 905 909 NULL, /* get_fd */ … … 928 932 legacy_get_capture_length, /* get_capture_length */ 929 933 legacyeth_get_wire_length, /* get_wire_length */ 934 legacy_get_framing_length, /* get_framing_length */ 930 935 NULL, /* set_capture_length */ 931 936 NULL, /* get_fd */ … … 954 959 legacy_get_capture_length, /* get_capture_length */ 955 960 legacypos_get_wire_length, /* get_wire_length */ 961 legacy_get_framing_length, /* get_framing_length */ 956 962 NULL, /* set_capture_length */ 957 963 NULL, /* get_fd */ … … 981 987 erf_get_capture_length, /* get_capture_length */ 982 988 erf_get_wire_length, /* get_wire_length */ 989 erf_get_framing_length, /* get_framing_length */ 983 990 erf_set_capture_length, /* set_capture_length */ 984 991 erf_get_fd, /* get_fd */ … … 1008 1015 erf_get_capture_length, /* get_capture_length */ 1009 1016 erf_get_wire_length, /* get_wire_length */ 1017 erf_get_framing_length, /* get_framing_length */ 1010 1018 erf_set_capture_length, /* set_capture_length */ 1011 1019 NULL, /* get_fd */ … … 1035 1043 erf_get_capture_length, /* get_capture_length */ 1036 1044 erf_get_wire_length, /* get_wire_length */ 1045 erf_get_framing_length, /* get_framing_length */ 1037 1046 erf_set_capture_length, /* set_capture_length */ 1038 1047 rtclient_get_fd, /* get_fd */ … … 1042 1051 1043 1052 void __attribute__((constructor)) erf_constructor() { 1044 erf_ptr = &erf; 1045 register_format(erf_ptr); 1053 register_format(&erf); 1046 1054 #ifdef HAVE_DAG 1047 dag_ptr = &dag; 1048 register_format(dag_ptr); 1049 #endif 1050 rtclient_ptr = &rtclient; 1051 register_format(rtclient_ptr); 1052 1053 legacypos_ptr = &legacypos; 1054 register_format(legacypos_ptr); 1055 1056 legacyeth_ptr = &legacyeth; 1057 register_format(legacyeth_ptr); 1058 1059 legacyatm_ptr = &legacyatm; 1060 register_format(legacyatm_ptr); 1061 1062 } 1055 register_format(&dag); 1056 #endif 1057 register_format(&rtclient); 1058 register_format(&legacypos); 1059 register_format(&legacyeth); 1060 register_format(&legacyatm); 1061 } -
lib/format_pcap.c
r006bbf7 r7c8eacf 65 65 66 66 #if HAVE_PCAP 67 68 static struct libtrace_format_t *pcap_ptr = 0;69 static struct libtrace_format_t *pcapint_ptr = 0; 67 extern struct libtrace_format_t pcap; 68 extern struct libtrace_format_t pcapint; 69 70 70 71 71 #define CONNINFO libtrace->format_data->conn_info … … 243 243 fflush((FILE *)OUTPUT.trace.dump); 244 244 } 245 if (packet->trace->format == pcap_ptr || 246 packet->trace->format == pcapint_ptr) { 247 //if (!strncasecmp(packet->trace->format->name,"pcap",4)) { 248 // this is a pcap trace anyway 245 if (packet->trace->format == &pcap || 246 packet->trace->format == &pcapint) { 249 247 250 248 pcap_dump((u_char*)OUTPUT.trace.dump,(struct pcap_pkthdr *)packet->buffer,link); … … 366 364 } 367 365 366 static int pcap_get_framing_length(const struct libtrace_packet_t *packet) { 367 return sizeof(struct pcap_pkthdr); 368 } 369 368 370 static size_t pcap_set_capture_length(struct libtrace_packet_t *packet,size_t size) { 369 371 struct pcap_pkthdr *pcapptr = 0; … … 428 430 pcap_get_capture_length, /* get_capture_length */ 429 431 pcap_get_wire_length, /* get_wire_length */ 432 pcap_get_framing_length, /* get_framing_length */ 430 433 pcap_set_capture_length, /* set_capture_length */ 431 434 NULL, /* get_fd */ … … 454 457 pcap_get_capture_length, /* get_capture_length */ 455 458 pcap_get_wire_length, /* get_wire_length */ 459 pcap_get_framing_length, /* get_framing_length */ 456 460 pcap_set_capture_length, /* set_capture_length */ 457 461 pcap_get_fd, /* get_fd */ … … 464 468 465 469 void __attribute__((constructor)) pcap_constructor() { 466 pcap_ptr = &pcap; 467 pcapint_ptr = &pcapint; 468 register_format(pcap_ptr); 469 register_format(pcapint_ptr); 470 register_format(&pcap); 471 register_format(&pcapint); 470 472 } 471 473 -
lib/format_template.c
r8f4152b r7c8eacf 40 40 # error "Can't find inttypes.h" 41 41 #endif 42 43 extern struct libtrace_format_t template; 42 44 43 45 struct libtrace_format_data_t { … … 111 113 } 112 114 115 static int template_get_framing_length(const struct libtrace_packet_t *packet) { 116 return -1; 117 } 118 113 119 static size_t template_set_capture_length(struct libtrace_packet_t *packet,size_t size) { 114 120 return -1; … … 142 148 template_get_capture_length, /* get_capture_length */ 143 149 template_get_wire_length, /* get_wire_length */ 150 template_get_framing_length, /* get_framing_length */ 144 151 template_set_capture_length, /* set_capture_length */ 145 152 template_get_fd, /* get_fd */ -
lib/format_wag.c
r17ffb8a r7c8eacf 88 88 #endif 89 89 90 static struct libtrace_format_t *wag_ptr = 0;90 extern struct libtrace_format_t wag; 91 91 92 92 #define CONNINFO libtrace->format_data->conn_info … … 334 334 static int wag_write_packet(struct libtrace_out_t *libtrace, const struct libtrace_packet_t *packet) { 335 335 int numbytes =0 ; 336 if (packet->trace->format != wag_ptr) {336 if (packet->trace->format != &wag) { 337 337 fprintf(stderr,"Cannot convert from wag to %s format yet\n", 338 338 packet->trace->format->name); … … 384 384 //return (wagptr->hdr.size); 385 385 return ntohs(wagptr->hdr.size); 386 } 387 388 static int wag_get_framing_length(const struct libtrace_packet_t *packet) { 389 return sizeof(struct wag_data_frame); 386 390 } 387 391 … … 433 437 wag_get_capture_length, /* get_capture_length */ 434 438 wag_get_wire_length, /* get_wire_length */ 439 wag_get_framing_length, /* get_framing_length */ 435 440 NULL, /* set_capture_length */ 436 441 wag_get_fd, /* get_fd */ … … 440 445 441 446 void __attribute__((constructor)) wag_constructor() { 442 wag_ptr = &wag; 443 register_format(wag_ptr); 444 } 447 register_format(&wag); 448 } -
lib/libtrace.h
r0d82205 r7c8eacf 493 493 int trace_get_wire_length(const struct libtrace_packet_t *packet); 494 494 495 /** Get the length of the capture framing headers. 496 * @param packet the packet opaque pointer 497 * @returns the size of the packet as it was on the wire. 498 * @author Perry Lorier 499 * @author Daniel Lawson 500 * @note this length corresponds to the difference between the size of a 501 * captured packet in memory, and the captured length of the packet 502 */ 503 SIMPLE_FUNCTION 504 int trace_get_framing_length(const struct libtrace_packet_t *packet); 505 506 495 507 /** Link layer types 496 508 * This enumates the various different link types that libtrace understands -
lib/libtrace_int.h
rf1a1f5e r7c8eacf 165 165 int (*get_capture_length)(const struct libtrace_packet_t *packet); 166 166 int (*get_wire_length)(const struct libtrace_packet_t *packet); 167 int (*get_framing_length)(const struct libtrace_packet_t *packet); 167 168 size_t (*set_capture_length)(struct libtrace_packet_t *packet,size_t size); 168 169 int (*get_fd)(const struct libtrace_packet_t *packet); -
lib/trace.c
r6f75b9d r7c8eacf 1007 1007 } 1008 1008 1009 /* Get the length of the capture framing headers. 1010 * @param packet the packet opaque pointer 1011 * @returns the size of the packet as it was on the wire. 1012 * @author Perry Lorier 1013 * @author Daniel Lawson 1014 * @note this length corresponds to the difference between the size of a 1015 * captured packet in memory, and the captured length of the packet 1016 */ 1017 SIMPLE_FUNCTION 1018 int trace_get_framing_length(const struct libtrace_packet_t *packet) { 1019 if (packet->trace->format->get_framing_length) { 1020 return packet->trace->format->get_framing_length(packet); 1021 } 1022 return -1; 1023 } 1024 1025 1009 1026 /* Get the type of the link layer 1010 1027 * @param packet a pointer to a libtrace_packet structure
Note: See TracChangeset
for help on using the changeset viewer.