- Timestamp:
- 10/28/05 16:57:37 (17 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:
- 950d54a
- Parents:
- b190686
- Location:
- lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_erf.c
r7c8eacf rf04e489 62 62 #include <string.h> 63 63 #include <stdlib.h> 64 #include "daglegacy.h" 64 65 65 66 #if HAVE_ZLIB … … 208 209 } 209 210 211 static int legacyeth_get_framing_length(const struct libtrace_packet_t *packet) 212 { 213 /* the legacy ethernet format consists of: 214 * uint64_t ts; 215 * uint16_t wlen; 216 * The legacy ethernet framing is therefore five (5) octets; 217 */ 218 return sizeof(legacy_ether_t); 219 } 220 221 static int legacypos_get_framing_length(const struct libtrace_packet_t *packet) 222 { 223 /* the legacy POS format consists of: 224 * uint64_t ts; 225 * uint32_t slen; 226 * uint32_t wlen; 227 * The legacy pos framing is therefore eight (8) octets; 228 */ 229 return sizeof(legacy_pos_t); 230 } 231 232 static int legacyatm_get_framing_length(const struct libtrace_packet_t *packet) 233 { 234 /* the legacy ATM format consists of: 235 * uint64_t ts; 236 * uint32_t crc; 237 * The legacy atm framing is therefore six (6) octets; 238 */ 239 return sizeof(legacy_cell_t); 240 } 210 241 211 242 static int erf_init_input(struct libtrace_t *libtrace) { … … 675 706 676 707 677 static void *legacy_get_link(const struct libtrace_packet_t *packet) { 678 return (void *)packet->buffer; 679 } 680 681 static libtrace_linktype_t legacy_get_link_type(const struct libtrace_packet_t *packet) { 682 return TRACE_TYPE_LEGACY; 708 static void *legacypos_get_link(const struct libtrace_packet_t *packet) { 709 const void *posptr = 0; 710 posptr = ((uint8_t *)packet->buffer + 711 legacypos_get_framing_length(packet)); 712 return (void *)posptr; 713 } 714 715 static libtrace_linktype_t legacypos_get_link_type(const struct libtrace_packet_t *packet) { 716 return TRACE_TYPE_LEGACY_POS; 717 } 718 719 static void *legacyatm_get_link(const struct libtrace_packet_t *packet) { 720 const void *atmptr = 0; 721 atmptr = ((uint8_t *)packet->buffer + 722 legacyatm_get_framing_length(packet)); 723 return (void *)atmptr; 724 } 725 726 static libtrace_linktype_t legacyatm_get_link_type(const struct libtrace_packet_t *packet) { 727 return TRACE_TYPE_LEGACY_ATM; 728 } 729 730 static void *legacyeth_get_link(const struct libtrace_packet_t *packet) { 731 const void *ethptr = 0; 732 ethptr = ((uint8_t *)packet->buffer + 733 legacyeth_get_framing_length(packet)); 734 return (void *)ethptr; 683 735 } 684 736 … … 687 739 } 688 740 689 static libtrace_linktype_t legacyatm_get_link_type(const struct libtrace_packet_t *packet) { 690 return TRACE_TYPE_LEGACY_ATM; 691 } 692 693 static libtrace_linktype_t legacypos_get_link_type(const struct libtrace_packet_t *packet) { 694 return TRACE_TYPE_LEGACY_POS; 695 } 741 696 742 697 743 static void *erf_get_link(const struct libtrace_packet_t *packet) { … … 745 791 } 746 792 747 static int legacy_get_framing_length(const struct libtrace_packet_t *packet __attribute__((unused))) {748 749 }750 793 static int legacypos_get_wire_length(const struct libtrace_packet_t *packet) { 751 794 legacy_pos_t *lpos = (legacy_pos_t *)packet->buffer; … … 896 939 legacy_read_packet, /* read_packet */ 897 940 NULL, /* write_packet */ 898 legacy _get_link, /* get_link */941 legacyatm_get_link, /* get_link */ 899 942 legacyatm_get_link_type, /* get_link_type */ 900 943 NULL, /* get_direction */ … … 905 948 legacy_get_capture_length, /* get_capture_length */ 906 949 legacyatm_get_wire_length, /* get_wire_length */ 907 legacy _get_framing_length, /* get_framing_length */950 legacyatm_get_framing_length, /* get_framing_length */ 908 951 NULL, /* set_capture_length */ 909 952 NULL, /* get_fd */ … … 923 966 legacy_read_packet, /* read_packet */ 924 967 NULL, /* write_packet */ 925 legacy _get_link, /* get_link */968 legacyeth_get_link, /* get_link */ 926 969 legacyeth_get_link_type, /* get_link_type */ 927 970 NULL, /* get_direction */ … … 932 975 legacy_get_capture_length, /* get_capture_length */ 933 976 legacyeth_get_wire_length, /* get_wire_length */ 934 legacy _get_framing_length, /* get_framing_length */977 legacyeth_get_framing_length, /* get_framing_length */ 935 978 NULL, /* set_capture_length */ 936 979 NULL, /* get_fd */ … … 950 993 legacy_read_packet, /* read_packet */ 951 994 NULL, /* write_packet */ 952 legacy _get_link, /* get_link */995 legacypos_get_link, /* get_link */ 953 996 legacypos_get_link_type, /* get_link_type */ 954 997 NULL, /* get_direction */ … … 959 1002 legacy_get_capture_length, /* get_capture_length */ 960 1003 legacypos_get_wire_length, /* get_wire_length */ 961 legacy _get_framing_length, /* get_framing_length */1004 legacypos_get_framing_length, /* get_framing_length */ 962 1005 NULL, /* set_capture_length */ 963 1006 NULL, /* get_fd */ -
lib/libtrace.h
rba0017c rf04e489 43 43 44 44 /* HAVE_ATTR_PURE is replaced by autoconf */ 45 #define HAVE_ATTR_PURE 045 #define HAVE_ATTR_PURE 1 46 46 47 47 /* Function does not depend on anything but its … … 217 217 } __attribute__ ((packed)); 218 218 219 /** ATM cell */ 220 struct libtrace_atm_cell 221 { 222 u_int8_t gfc:4; 223 u_int8_t vpi; 224 u_int16_t vci; 225 u_int8_t pt:3; 226 u_int8_t clp:1; 227 u_int8_t hec; 228 u_int16_t ether_type; 229 }; 230 231 /** POS header */ 232 struct libtrace_pos 233 { 234 u_int16_t header; 235 u_int16_t ether_type; 236 }; 237 219 238 /** Prints help information for libtrace 220 239 * -
lib/trace.c
ra8a9355 rf04e489 598 598 break; 599 599 case TRACE_TYPE_ETH: 600 case TRACE_TYPE_LEGACY_ETH: 600 601 { 601 602 struct libtrace_ether *eth = … … 653 654 } 654 655 break; 655 case TRACE_TYPE_ATM:656 {657 struct atm_rec *atm =658 trace_get_link(packet);659 // TODO: Find out what ATM does, and return660 // NULL for non IP data661 // Presumably it uses the normal stuff662 if (!atm) {663 ipptr = NULL;664 break;665 }666 ipptr = (void*)&atm->pload;667 break;668 }669 656 case TRACE_TYPE_LEGACY_POS: 670 657 { 671 658 // 64 byte capture. 672 legacy_framing_t *cell=659 struct libtrace_pos *pos = 673 660 trace_get_link(packet); 674 // check ethertype 675 uint16_t *etype = (uint16_t *)cell->data + 1; 676 if (*etype == 0x0008) { 677 ipptr = (void *)&cell->data[1]; 661 if (ntohs(pos->ether_type) == 0x0800) { 662 ipptr = ((void *)pos) + sizeof(*pos); 678 663 } else { 679 664 ipptr = NULL; … … 683 668 } 684 669 case TRACE_TYPE_LEGACY_ATM: 685 case TRACE_TYPE_LEGACY_ETH: 686 case TRACE_TYPE_LEGACY: 670 case TRACE_TYPE_ATM: 687 671 { 688 672 // 64 byte capture. 689 legacy_framing_t*cell =673 struct libtrace_atm_cell *cell = 690 674 trace_get_link(packet); 691 uint16_t *etype = (uint16_t *)cell->data + 3; 692 if (*etype == 0x0008) { 693 ipptr = (void *)&cell->data[2]; 675 if (ntohs(cell->ether_type) == 0x0800) { 676 ipptr = ((void *)cell) + sizeof(*cell); 694 677 } else { 695 678 ipptr = NULL;
Note: See TracChangeset
for help on using the changeset viewer.