- Timestamp:
- 09/20/06 16:42:52 (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:
- e86124e
- Parents:
- d0aa87c
- Location:
- lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_erf.c
r959f88f rbad6a93 996 996 /* loss counter. Can't do this */ 997 997 erfhdr.lctr = 0; 998 /* Wire length, may contain the padding*/999 erfhdr.wlen = htons(trace_get_wire_length(packet) +pad);998 /* Wire length, does not include padding! */ 999 erfhdr.wlen = htons(trace_get_wire_length(packet)); 1000 1000 1001 1001 /* Write it out */ … … 1035 1035 static int erf_get_capture_length(const libtrace_packet_t *packet) { 1036 1036 dag_record_t *erfptr = 0; 1037 int caplen; 1037 1038 if (packet->payload == NULL) 1038 1039 return 0; 1039 1040 1040 1041 erfptr = (dag_record_t *)packet->header; 1042 caplen = ntohs(erfptr->rlen) - erf_get_framing_length(packet); 1043 if (ntohs(erfptr->wlen) < caplen) 1044 return ntohs(erfptr->wlen); 1045 1041 1046 return (ntohs(erfptr->rlen) - erf_get_framing_length(packet)); 1042 1047 } … … 1045 1050 dag_record_t *erfptr = 0; 1046 1051 erfptr = (dag_record_t *)packet->header; 1047 return ntohs(erfptr->wlen) - erf_get_padding(packet);1052 return ntohs(erfptr->wlen); 1048 1053 } 1049 1054 -
lib/format_rt.c
re502f76 rbad6a93 83 83 char *buf_current; 84 84 int buf_filled; 85 85 rt_header_t rt_hdr; 86 86 87 libtrace_t *dummy_duck; 87 88 libtrace_t *dummy_erf; … … 485 486 static int rt_read_packet_versatile(libtrace_t *libtrace, 486 487 libtrace_packet_t *packet,int blocking) { 487 static rt_header_t rt_hdr;488 488 static rt_header_t *pkt_hdr = 0; 489 489 … … 491 491 /* first time through */ 492 492 pkt_hdr = malloc(sizeof(rt_header_t)); 493 rt_hdr.type = RT_LAST; 494 } 495 493 RT_INFO->rt_hdr.type = RT_LAST; 494 } 495 496 /* 496 497 if (packet->buf_control == TRACE_CTRL_EXTERNAL || !packet->buffer) { 497 498 packet->buf_control = TRACE_CTRL_PACKET; 498 499 packet->buffer = malloc(LIBTRACE_PACKET_BUFSIZE); 499 500 } 501 */ 502 if (packet->buf_control == TRACE_CTRL_PACKET) { 503 packet->buf_control = TRACE_CTRL_EXTERNAL; 504 free(packet->buffer); 505 packet->buffer = NULL; 506 } 500 507 501 508 /* RT_LAST means that the next bytes received should be a 502 509 * rt header - I know it's hax and maybe I'll fix it later on */ 503 if ( rt_hdr.type == RT_LAST) {510 if (RT_INFO->rt_hdr.type == RT_LAST) { 504 511 505 512 /* FIXME: Better error handling required */ … … 512 519 /* Need to salvage these in case the next rt_read overwrites 513 520 * the buffer they came from! */ 514 rt_hdr.type = pkt_hdr->type;515 rt_hdr.length = pkt_hdr->length;516 rt_hdr.sequence = pkt_hdr->sequence;517 } 518 packet->type = rt_hdr.type;519 packet->size = rt_hdr.length;521 RT_INFO->rt_hdr.type = pkt_hdr->type; 522 RT_INFO->rt_hdr.length = pkt_hdr->length; 523 RT_INFO->rt_hdr.sequence = pkt_hdr->sequence; 524 } 525 packet->type = RT_INFO->rt_hdr.type; 526 packet->size = RT_INFO->rt_hdr.length; 520 527 521 528 if (packet->type >= RT_DATA_SIMPLE) { 522 if (rt_read(libtrace, &packet->buffer, rt_hdr.length,blocking) !=rt_hdr.length) {529 if (rt_read(libtrace, &packet->buffer, RT_INFO->rt_hdr.length,blocking) != RT_INFO->rt_hdr.length) { 523 530 return -1; 524 531 } … … 526 533 527 534 if (RT_INFO->reliable > 0) { 528 if (rt_send_ack(libtrace, rt_hdr.sequence)535 if (rt_send_ack(libtrace, RT_INFO->rt_hdr.sequence) 529 536 == -1) 530 537 { … … 535 542 536 543 if (rt_set_format(libtrace, packet) < 0) { 537 544 return -1; 538 545 } 539 546 rt_set_payload(packet); … … 542 549 case RT_STATUS: 543 550 if (rt_read(libtrace, &packet->buffer, 544 rt_hdr.length, blocking) !=545 rt_hdr.length) {551 RT_INFO->rt_hdr.length, blocking) != 552 RT_INFO->rt_hdr.length) { 546 553 return -1; 547 554 } … … 552 559 case RT_DUCK_2_5: 553 560 if (rt_read(libtrace, &packet->buffer, 554 rt_hdr.length, blocking) !=555 rt_hdr.length) {561 RT_INFO->rt_hdr.length, blocking) != 562 RT_INFO->rt_hdr.length) { 556 563 return -1; 557 564 } … … 563 570 break; 564 571 case RT_END_DATA: 565 return 0;572 break; 566 573 case RT_PAUSE_ACK: 567 574 /* FIXME: Do something useful */ … … 581 588 } 582 589 /* Return the number of bytes read from the stream */ 583 rt_hdr.type = RT_LAST;590 RT_INFO->rt_hdr.type = RT_LAST; 584 591 return packet->size; 585 592 } … … 615 622 case RT_KEYCHANGE: 616 623 return 0; 624 case RT_LOSTCONN: 625 return 0; 617 626 } 618 627 printf("Unknown type: %d\n", packet->type); … … 656 665 } 657 666 } else if (event.size == 0) { 658 event.type = TRACE_EVENT_TERMINATE; 667 if (packet->type == RT_END_DATA) 668 event.type = TRACE_EVENT_TERMINATE; 669 else 670 event.type = TRACE_EVENT_PACKET; 659 671 660 672 } -
lib/libtrace.h.in
r755e794 rbad6a93 872 872 uint16_t *type, uint32_t *remaining); 873 873 874 /** Skips over any 802.1q headers, if present. 875 * @param ethernet A pointer to the payload following an ethernet header -usually the result of calling trace_get_payload_from_link 876 * @param[in,out] type The ethernet type, replaced with the vlan ether type 877 * @param[in,out] remaining Updated with the number of bytes remaining 878 * 879 * @return a pointer to the header beyond the vlan header, if present. 880 * Otherwise, returns the ethernet payload that was passed in 881 * 882 * Remaining may be NULL. If Remaining is not NULL it must point to the number 883 * of bytes captured past (but not including) the link layer. It will be 884 * updated after this function to the number of bytes remaining after the 885 * vlan header. If it is unchanged then no vlan header exists. 886 * 887 * Type must point to the value of the ethernet type. Libtrace will assert 888 * fail if type is NULL. 889 * 890 */ 891 DLLEXPORT void *trace_get_vlan_payload_from_ethernet_payload( 892 void *ethernet_payload, uint16_t *type, uint32_t *remaining); 893 874 894 /** Gets a pointer to the payload given a pointer to a tcp header 875 895 * @param tcp The tcp Header -
lib/protocols.c
re5222e1 rbad6a93 46 46 * type is input/output 47 47 */ 48 staticvoid *trace_get_vlan_payload_from_ethernet_payload(void *ethernet, uint16_t *type,48 void *trace_get_vlan_payload_from_ethernet_payload(void *ethernet, uint16_t *type, 49 49 uint32_t *remaining) 50 50 { -
lib/trace.c
re502f76 rbad6a93 402 402 trace_set_err(libtrace,TRACE_ERR_BAD_FORMAT, 403 403 "Unknown format (%s)",scan); 404 return 0;405 404 } 406 405
Note: See TracChangeset
for help on using the changeset viewer.