Changeset 3b8a5ef for lib/trace.c
- Timestamp:
- 11/30/05 15:43: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:
- 2adf051
- Parents:
- 08594b8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/trace.c
r08594b8 r3b8a5ef 567 567 void *trace_get_link(const struct libtrace_packet_t *packet) { 568 568 return (void *)packet->payload; 569 } 570 569 571 /* 570 const void *ethptr = 0;571 572 assert(packet->size>0 && packet->size<65536);573 574 if (packet->trace->format->get_link) {575 ethptr = packet->trace->format->get_link(packet);576 }577 return (void *)ethptr;578 */579 }580 581 572 typedef struct legacy_framing { 582 573 uint64_t ts; 583 574 uint32_t crc; 584 575 uint32_t header; 585 uint32_t data[12]; / * pad to 64 bytes */576 uint32_t data[12]; // pad to 64 bytes 586 577 } legacy_framing_t; 578 */ 587 579 588 580 /* get a pointer to the IP header (if any) … … 612 604 ipptr = NULL; 613 605 614 if (eth->type == 0x0008) { 615 ipptr=(void*)eth->data; 616 } else if (eth->type == 0x0081) { 617 // VLAN 618 if ((*(uint16_t *)(eth + 16)) == 0x0008) { 619 ipptr = (void*)eth->data + 4; 620 } 606 if (ntohs(eth->type) == 0x0800) { 607 ipptr=((void*)eth) + sizeof(*eth); 608 } else if (ntohs(eth->type) == 0x8100) { 609 struct libtrace_8021q *vlanhdr = 610 (struct libtrace_8021q *)eth; 611 if (ntohs(vlanhdr->vlan_ether_type) 612 == 0x0800) { 613 ipptr=((void*)eth) + 614 sizeof(*vlanhdr); 615 } 621 616 } 622 617 } … … 634 629 ipptr = NULL; 635 630 636 if ( eth->ether_type==0x0008) {637 ipptr = ((void *)eth) + 14;638 } else if ( eth->ether_type == 0x0081) {631 if (ntohs(eth->ether_type)==0x0800) { 632 ipptr = ((void *)eth) + sizeof(*eth); 633 } else if (ntohs(eth->ether_type) == 0x8100) { 639 634 struct libtrace_8021q *vlanhdr = 640 635 (struct libtrace_8021q *)eth; 641 if (vlanhdr->vlan_ether_type == 0x0008) { 642 ipptr = ((void *)eth) + 18; 636 if (ntohs(vlanhdr->vlan_ether_type) 637 == 0x0800) { 638 ipptr = ((void *)eth) + 639 sizeof(*vlanhdr); 643 640 } 644 641 } … … 697 694 { 698 695 // 64 byte capture. 699 struct libtrace_ atm_cell *cell =696 struct libtrace_llcsnap *llc = 700 697 trace_get_link(packet); 701 if (ntohs(cell->ether_type) == 0x0800) { 702 ipptr = ((void *)cell) + sizeof(*cell); 698 699 // advance the llc ptr +4 into the link layer. 700 // need to check what is in these 4 bytes. 701 // don't have time! 702 llc = (void *)llc + 4; 703 if (ntohs(llc->type) == 0x0800) { 704 ipptr = ((void *)llc) + sizeof(*llc); 703 705 } else { 704 706 ipptr = NULL;
Note: See TracChangeset
for help on using the changeset viewer.