1 InfiniBand support for tcpdump. |
1 InfiniBand support for tcpdump. |
2 This is an in-house patch. Sent upstream for potential inclusion in future |
2 This is an in-house patch. Sent upstream for potential inclusion in future |
3 versions of tcpdump. |
3 versions of tcpdump. |
4 |
4 |
5 Using DLT value 162 is Solaris specific. |
5 --- tcpdump-4.9.0/Makefile.in.orig 2017-01-29 12:23:58.596267167 +0000 |
6 |
6 +++ tcpdump-4.9.0/Makefile.in 2017-01-29 12:49:27.808281048 +0000 |
7 diff -rupN tcpdump-4.7.4-orig/Makefile.in tcpdump-4.7.4/Makefile.in |
7 @@ -147,6 +147,7 @@ |
8 --- tcpdump-4.7.4-orig/Makefile.in 2015-05-26 14:13:17.000000000 -0700 |
|
9 +++ tcpdump-4.7.4/Makefile.in 2015-05-26 15:12:05.727800640 -0700 |
|
10 @@ -138,6 +138,7 @@ LIBNETDISSECT_SRC=\ |
|
11 print-ipcomp.c \ |
8 print-ipcomp.c \ |
12 print-ipfc.c \ |
9 print-ipfc.c \ |
13 print-ipnet.c \ |
10 print-ipnet.c \ |
14 + print-ipoib.c \ |
11 + print-ipoib.c \ |
15 print-ipx.c \ |
12 print-ipx.c \ |
16 print-isakmp.c \ |
13 print-isakmp.c \ |
17 print-isoclns.c \ |
14 print-isoclns.c \ |
18 diff -rupN tcpdump-4.7.4-orig/netdissect.h tcpdump-4.7.4/netdissect.h |
15 --- tcpdump-4.9.0/netdissect.h.orig 2017-01-29 12:25:29.886259423 +0000 |
19 --- tcpdump-4.7.4-orig/netdissect.h 2015-05-26 14:13:17.000000000 -0700 |
16 +++ tcpdump-4.9.0/netdissect.h 2017-01-29 12:27:00.348907240 +0000 |
20 +++ tcpdump-4.7.4/netdissect.h 2015-04-22 13:32:16.000000000 -0700 |
17 @@ -410,6 +410,7 @@ |
21 @@ -395,6 +395,8 @@ extern void ether_print(netdissect_optio |
18 extern u_int ieee802_11_radio_if_print IF_PRINTER_ARGS; |
22 |
19 extern u_int ieee802_15_4_if_print IF_PRINTER_ARGS; |
23 extern u_int ether_if_print(netdissect_options *, |
20 extern u_int ipfc_if_print IF_PRINTER_ARGS; |
24 const struct pcap_pkthdr *,const u_char *); |
21 +extern u_int ipoib_if_print IF_PRINTER_ARGS; |
25 +extern u_int ipoib_if_print(netdissect_options *, |
22 extern u_int ipnet_if_print IF_PRINTER_ARGS; |
26 + const struct pcap_pkthdr *, const u_char *); |
23 extern u_int juniper_atm1_print IF_PRINTER_ARGS; |
27 extern u_int netanalyzer_if_print(netdissect_options *, |
24 extern u_int juniper_atm2_print IF_PRINTER_ARGS; |
28 const struct pcap_pkthdr *,const u_char *); |
25 --- tcpdump-4.9.0/print-arp.c.orig 2017-01-29 12:27:35.797281364 +0000 |
29 extern u_int netanalyzer_transparent_if_print(netdissect_options *, |
26 +++ tcpdump-4.9.0/print-arp.c 2017-01-29 12:28:48.668009704 +0000 |
30 diff -rupN tcpdump-4.7.4-orig/print-arp.c tcpdump-4.7.4/print-arp.c |
27 @@ -56,6 +56,7 @@ |
31 --- tcpdump-4.7.4-orig/print-arp.c 2015-05-26 14:13:17.000000000 -0700 |
|
32 +++ tcpdump-4.7.4/print-arp.c 2015-03-09 12:07:00.000000000 -0700 |
|
33 @@ -55,6 +55,7 @@ struct arp_pkthdr { |
|
34 #define ARPHRD_ATM2225 19 /* ATM (RFC 2225) */ |
28 #define ARPHRD_ATM2225 19 /* ATM (RFC 2225) */ |
35 #define ARPHRD_STRIP 23 /* Ricochet Starmode Radio hardware format */ |
29 #define ARPHRD_STRIP 23 /* Ricochet Starmode Radio hardware format */ |
36 #define ARPHRD_IEEE1394 24 /* IEEE 1394 (FireWire) hardware format */ |
30 #define ARPHRD_IEEE1394 24 /* IEEE 1394 (FireWire) hardware format */ |
37 +#define ARPHRD_INFINIBAND 32 /* InfiniBand RFC 4391 */ |
31 +#define ARPHRD_INFINIBAND 32 /* InfiniBand RFC 4391 */ |
38 u_short ar_pro; /* format of protocol address */ |
32 u_short ar_pro; /* format of protocol address */ |
39 u_char ar_hln; /* length of hardware address */ |
33 u_char ar_hln; /* length of hardware address */ |
40 u_char ar_pln; /* length of protocol address */ |
34 u_char ar_pln; /* length of protocol address */ |
41 @@ -115,6 +115,7 @@ static const struct tok arphrd_values[] |
35 @@ -116,6 +117,7 @@ |
42 { ARPHRD_STRIP, "Strip" }, |
36 { ARPHRD_STRIP, "Strip" }, |
43 { ARPHRD_IEEE1394, "IEEE 1394" }, |
37 { ARPHRD_IEEE1394, "IEEE 1394" }, |
44 { ARPHRD_ATM2225, "ATM" }, |
38 { ARPHRD_ATM2225, "ATM" }, |
45 + { ARPHRD_INFINIBAND, "InfiniBand" }, |
39 + { ARPHRD_INFINIBAND, "InfiniBand" }, |
46 { 0, NULL } |
40 { 0, NULL } |
47 }; |
41 }; |
48 |
42 |
49 diff -rupN tcpdump-4.7.4-orig/print-ipoib.c tcpdump-4.7.4/print-ipoib.c |
43 --- tcpdump-4.9.0/print-ipoib.c.orig 2017-01-29 12:30:15.468355816 +0000 |
50 --- tcpdump-4.7.4-orig/print-ipoib.c 1969-12-31 16:00:00.000000000 -0800 |
44 +++ tcpdump-4.9.0/print-ipoib.c 2017-01-29 13:24:49.576498883 +0000 |
51 +++ tcpdump-4.7.4/print-ipoib.c 2015-05-26 14:13:17.000000000 -0700 |
45 @@ -0,0 +1,131 @@ |
52 @@ -0,0 +1,132 @@ |
|
53 +/* |
46 +/* |
54 + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, |
47 + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, |
55 + * 1997, 2000, 2011, 2012 |
48 + * 1997, 2000, 2011, 2012 |
56 + * The Regents of the University of California. All rights reserved. |
49 + * The Regents of the University of California. All rights reserved. |
57 + * |
50 + * |
81 + |
74 + |
82 +#ifdef HAVE_CONFIG_H |
75 +#ifdef HAVE_CONFIG_H |
83 +#include "config.h" |
76 +#include "config.h" |
84 +#endif |
77 +#endif |
85 + |
78 + |
86 +#include <tcpdump-stdinc.h> |
79 +#include <netdissect-stdinc.h> |
87 + |
80 + |
88 +#include <stdio.h> |
81 +#include <stdio.h> |
89 +#include <pcap.h> |
82 +#include <pcap.h> |
90 + |
83 + |
91 +#include "interface.h" |
84 +#include "netdissect.h" |
92 +#include "extract.h" |
85 +#include "extract.h" |
93 +#include "addrtoname.h" |
86 +#include "addrtoname.h" |
94 + |
87 + |
95 + |
88 + |
96 +extern const struct tok ethertype_values[]; |
89 +extern const struct tok ethertype_values[]; |
97 +extern int ethertype_print(netdissect_options *, u_short, const u_char *, u_int, u_int ); |
|
98 + |
90 + |
99 +#define IPOIB_HDRLEN 44 |
91 +#define IPOIB_HDRLEN 44 |
100 + |
92 + |
101 +static inline void |
93 +static inline void |
102 +ipoib_hdr_print(register const u_char *bp, u_int length) |
94 +ipoib_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length) |
103 +{ |
95 +{ |
104 + u_int16_t ether_type; |
96 + u_int16_t ether_type; |
105 + char abuf[40]; |
97 + char abuf[40]; |
106 + |
98 + |
107 + ether_type = EXTRACT_16BITS(&bp[40]); |
99 + ether_type = EXTRACT_16BITS(&bp[40]); |
108 + if (!qflag) { |
100 + if (!ndo->ndo_qflag) { |
109 + (void)printf(", ethertype %s (0x%04x)", |
101 + (void)printf(", ethertype %s (0x%04x)", |
110 + tok2str(ethertype_values,"Unknown", ether_type), |
102 + tok2str(ethertype_values,"Unknown", ether_type), |
111 + ether_type); |
103 + ether_type); |
112 + } else { |
104 + } else { |
113 + (void)printf(", ethertype %s", |
105 + (void)printf(", ethertype %s", |
135 + if (caplen < IPOIB_HDRLEN || length < IPOIB_HDRLEN) { |
127 + if (caplen < IPOIB_HDRLEN || length < IPOIB_HDRLEN) { |
136 + printf("[|ipoib]"); |
128 + printf("[|ipoib]"); |
137 + return; |
129 + return; |
138 + } |
130 + } |
139 + |
131 + |
140 + if (eflag) { |
132 + if (ndo->ndo_eflag) { |
141 + if (print_encap_header != NULL) |
133 + if (print_encap_header != NULL) |
142 + (*print_encap_header)(encap_header_arg); |
134 + (*print_encap_header)(encap_header_arg); |
143 + ipoib_hdr_print(p, length); |
135 + ipoib_hdr_print(ndo, p, length); |
144 + } |
136 + } |
145 + orig_length = length; |
137 + orig_length = length; |
146 + |
138 + |
147 + length -= IPOIB_HDRLEN; |
139 + length -= IPOIB_HDRLEN; |
148 + caplen -= IPOIB_HDRLEN; |
140 + caplen -= IPOIB_HDRLEN; |
149 + ether_type = EXTRACT_16BITS(&p[40]); |
141 + ether_type = EXTRACT_16BITS(&p[40]); |
150 + p += IPOIB_HDRLEN; |
142 + p += IPOIB_HDRLEN; |
151 + |
143 + |
152 + if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) { |
144 + if (ethertype_print(ndo, ether_type, p, length, caplen, NULL, NULL) == 0) { |
153 + /* ether_type not known, print raw packet */ |
145 + /* ether_type not known, print raw packet */ |
154 + if (!eflag) { |
146 + if (!ndo->ndo_eflag) { |
155 + if (print_encap_header != NULL) |
147 + if (print_encap_header != NULL) |
156 + (*print_encap_header)(encap_header_arg); |
148 + (*print_encap_header)(encap_header_arg); |
157 + ipoib_hdr_print(orig_hdr , orig_length); |
149 + ipoib_hdr_print(ndo, orig_hdr , orig_length); |
158 + } |
150 + } |
159 + |
151 + |
160 + if (!suppress_default_print) |
152 + if (!ndo->ndo_suppress_default_print) |
161 + default_print(p, caplen); |
153 + ND_DEFAULTPRINT(p, caplen); |
162 + } |
154 + } |
163 +} |
155 +} |
164 + |
156 + |
165 +/* |
157 +/* |
166 + * This is the top level routine of the printer. 'p' points |
158 + * This is the top level routine of the printer. 'p' points |
169 + * is the number of bytes actually captured. |
161 + * is the number of bytes actually captured. |
170 + */ |
162 + */ |
171 +u_int |
163 +u_int |
172 +ipoib_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) |
164 +ipoib_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) |
173 +{ |
165 +{ |
174 + ipoib_print(p, h->len, h->caplen, NULL, NULL); |
166 + ipoib_print(ndo, p, h->len, h->caplen, NULL, NULL); |
175 + |
167 + |
176 + return (IPOIB_HDRLEN); |
168 + return (IPOIB_HDRLEN); |
177 +} |
169 +} |
178 + |
170 + |
179 +/* |
171 +/* |
180 + * Local Variables: |
172 + * Local Variables: |
181 + * c-style: whitesmith |
173 + * c-style: whitesmith |
182 + * c-basic-offset: 8 |
174 + * c-basic-offset: 8 |
183 + * End: |
175 + * End: |
184 + */ |
176 + */ |
185 diff -rupN tcpdump-4.7.4-orig/tcpdump.c tcpdump-4.7.4/tcpdump.c |
177 --- tcpdump-4.9.0/print.c.orig 2017-01-29 12:32:40.142061378 +0000 |
186 --- tcpdump-4.7.4-orig/tcpdump.c 2015-05-26 14:13:17.000000000 -0700 |
178 +++ tcpdump-4.9.0/print.c 2017-01-29 12:38:05.641526344 +0000 |
187 +++ tcpdump-4.7.4/tcpdump.c 2015-05-26 15:17:43.298240116 -0700 |
179 @@ -99,6 +99,9 @@ |
188 @@ -264,6 +264,13 @@ static const struct ndo_printer ndo_prin |
|
189 #ifdef DLT_IPV6 |
180 #ifdef DLT_IPV6 |
190 { raw_if_print, DLT_IPV6 }, |
181 { raw_if_print, DLT_IPV6 }, |
191 #endif |
182 #endif |
192 +#ifdef DLT_IPOIB |
183 +#ifdef DLT_IPOIB |
193 + { ipoib_if_print, DLT_IPOIB }, |
184 + { ipoib_if_print, DLT_IPOIB }, |
194 + /* Following record is temporary at least till following bug is fixed in |
|
195 + all relevant releases: |
|
196 + 22741013 - wrong value for DLT_IPOIB in dlt.h as in ON */ |
|
197 + { ipoib_if_print, 162 }, |
|
198 +#endif |
185 +#endif |
199 #ifdef HAVE_PCAP_USB_H |
186 #ifdef HAVE_PCAP_USB_H |
200 #ifdef DLT_USB_LINUX |
187 #ifdef DLT_USB_LINUX |
201 { usb_linux_48_byte_print, DLT_USB_LINUX}, |
188 { usb_linux_48_byte_print, DLT_USB_LINUX}, |