Changeset 3fc3267
- Timestamp:
- 02/02/15 16:59:34 (6 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, 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:
- 3440627
- Parents:
- 68d3308
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/Makefile.am
re5dedd5 r3fc3267 21 21 22 22 if HAVE_LLVM 23 BPFJITSOURCE=bpf-jit/bpf-jit.cc 23 BPFJITSOURCE=bpf-jit/bpf-jit.cc 24 24 else 25 25 BPFJITSOURCE= … … 54 54 protocols_pktmeta.c protocols_l2.c protocols_l3.c \ 55 55 protocols_transport.c protocols.h protocols_ospf.c \ 56 protocols_application.c \ 56 57 $(DAGSOURCE) format_erf.h \ 57 58 $(BPFJITSOURCE) \ -
lib/libtrace.h.in
ra2ce0a6 r3fc3267 810 810 } PACKED libtrace_pppoe_t; 811 811 812 /** Libtrace local definition of GRE (Generalised Routing Protocol) header 813 * RFC2890 814 */ 815 typedef struct libtrace_gre_t 816 { 817 uint16_t flags; /**< Flags and version */ 818 uint16_t ethertype; /**< Payload ethertype */ 819 uint16_t checksum; /**< Optional checksum */ 820 uint16_t reserved1; /**< Optional reserved */ 821 uint16_t key; /**< Optional key (or Tenant Network ID) */ 822 uint16_t seq; /**< Optional sequence number */ 823 } PACKED libtrace_gre_t; 824 825 #define LIBTRACE_GRE_FLAG_CHECKSUM 0x8000 826 #define LIBTRACE_GRE_FLAG_KEY 0x2000 827 #define LIBTRACE_GRE_FLAG_SEQ 0x1000 828 #define LIBTRACE_GRE_FLAG_VERMASK 0x0007 829 830 /** Libtrace local definition of VXLAN Header 831 * (draft-mahalingam-dutt-dcops-vxlan) 832 */ 833 typedef struct libtrace_vxlan_t 834 { 835 uint8_t flags; /**< Flags */ 836 uint8_t reserved1[3]; /**< Reserved */ 837 uint8_t vni[3]; /**< VXLAN Network Identifier (VNI) */ 838 uint8_t reserved2; 839 } PACKED libtrace_vxlan_t; 840 812 841 /** 802.11 header */ 813 842 typedef struct libtrace_80211_t { … … 2073 2102 uint32_t *remaining); 2074 2103 2104 /** Gets a pointer to the payload following a GRE header 2105 * @param gre A pointer to the beginning of the GRE header. 2106 * @param[in,out] remaining Updated with the number of captured bytes remaining. 2107 * 2108 * @return A pointer to the GRE payload, or NULL if the GRE header is truncated. 2109 * 2110 * When calling this function, remaining must contain the number of captured 2111 * bytes remaining in the packet starting from the GRE header (including the 2112 * GRE header itself). remaining will be updated to contain the number of 2113 * bytes remaining after the GRE header has been skipped. 2114 * 2115 * If the GRE header is complete but there are zero bytes of payload after 2116 * the header, a pointer to where the payload would be is returned and 2117 * remaining will be set to 0. If the GRE header is incomplete, NULL will be 2118 * returned and remaining will be set to 0. Therefore, it is important to check 2119 * the value of remaining after calling this function. 2120 */ 2121 DLLEXPORT void *trace_get_payload_from_gre(libtrace_gre_t *gre, 2122 uint32_t *remaining); 2123 2124 /** Gets a pointer to the payload following a VXLAN header 2125 * @param udp A pointer to the beginning of the UDP header. 2126 * @param[in,out] remaining Updated with the number of captured bytes remaining. 2127 * 2128 * @return A pointer to the beginning of the VXLAN header, or NULL if the UDP 2129 * header is truncated, or this is not a VXLAN packet. 2130 * 2131 */ 2132 DLLEXPORT libtrace_vxlan_t *trace_get_vxlan_from_udp(libtrace_udp_t *udp, 2133 uint32_t *remaining); 2134 2135 /** Gets a pointer to the payload following a VXLAN header 2136 * @param vxlan A pointer to the beginning of the VXLAN header. 2137 * @param[in,out] remaining Updated with the number of captured bytes remaining. 2138 * 2139 * @return A pointer to the VXLAN payload, or NULL if the VXLAN header is 2140 * truncated. 2141 * 2142 * When calling this function, remaining must contain the number of captured 2143 * bytes remaining in the packet starting from the VXLAN header (including the 2144 * VXLAN header itself). remaining will be updated to contain the number of 2145 * bytes remaining after the VXLAN header has been skipped. 2146 * 2147 * If the VXLAN header is complete but there are zero bytes of payload after 2148 * the header, a pointer to where the payload would be is returned and 2149 * remaining will be set to 0. If the VXLAN header is incomplete, NULL will be 2150 * returned and remaining will be set to 0. Therefore, it is important to check 2151 * the value of remaining after calling this function. 2152 */ 2153 DLLEXPORT void *trace_get_payload_from_vxlan(libtrace_vxlan_t *vxlan, 2154 uint32_t *remaining); 2155 2075 2156 /** Get a pointer to the TCP header (if present) 2076 2157 * @param packet The packet to get the TCP header from -
lib/protocols_transport.c
re0bea4e5 r3fc3267 553 553 return csum_ptr; 554 554 } 555 556 DLLEXPORT void *trace_get_payload_from_gre(libtrace_gre_t *gre, 557 uint32_t *remaining) 558 { 559 uint32_t size = 4; /* GRE is 4 bytes long by default */ 560 if (remaining && *remaining < size) { 561 *remaining = 0; 562 return NULL; 563 } 564 565 if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_CHECKSUM) != 0) { 566 size += 4; /* An extra 4 bytes. */ 567 } 568 569 if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_KEY) != 0) { 570 size += 4; /* An extra 4 bytes. */ 571 } 572 573 if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_SEQ) != 0) { 574 size += 4; /* An extra 4 bytes. */ 575 } 576 577 if (remaining) { 578 if (*remaining < size) { 579 *remaining = 0; 580 return NULL; 581 } 582 *remaining -= size; 583 } 584 return (char*)gre+size; 585 } -
test/Makefile
r262a093 r3fc3267 9 9 CFLAGS += $(INCLUDE) 10 10 libdir = $(PREFIX)/lib/.libs:$(PREFIX)/libpacketdump/.libs 11 LDLIBS = -L$(PREFIX)/lib/.libs -L$(PREFIX)/libpacketdump/.libs -ltrace -lpacketdump 11 LDLIBS = -L$(PREFIX)/lib/.libs -L$(PREFIX)/libpacketdump/.libs -ltrace -lpacketdump 12 12 13 13 BINS = test-pcap-bpf test-event test-time test-dir test-wireless test-errors \ 14 test-plen test-autodetect test-ports test-fragment test-live test-live-snaplen 14 test-plen test-autodetect test-ports test-fragment test-live \ 15 test-live-snaplen test-vxlan 15 16 16 17 .PHONY: all clean distclean install depend test -
test/do-tests.sh
r95b6218 r3fc3267 230 230 do_test ./test-autodetect traces/5_packets.erf.xz 231 231 232 echo " * VXLan decode" 233 do_test ./test-vxlan 234 232 235 echo 233 236 echo "Tests passed: $OK"
Note: See TracChangeset
for help on using the changeset viewer.