|
1 From 5ca557c31e3e799068c4531deaed78792845027d Mon Sep 17 00:00:00 2001 |
|
2 From: Petr Sumbera <[email protected]> |
|
3 Date: Wed, 23 Mar 2016 02:02:34 -0700 |
|
4 Subject: [PATCH] support for IP-over-Infiniband - pcap encapsulation |
|
5 |
|
6 Bug: 12279 |
|
7 Change-Id: Ib6c54f8b86d95c5546bc800749f124cd0dbb8ff0 |
|
8 Reviewed-on: https://code.wireshark.org/review/14585 |
|
9 Petri-Dish: Alexis La Goutte <[email protected]> |
|
10 Tested-by: Petri Dish Buildbot <[email protected]> |
|
11 Reviewed-by: Alexis La Goutte <[email protected]> |
|
12 --- |
|
13 epan/dissectors/packet-ipoib.c | 97 +++++++++++++++++++++++++++++++++++----- |
|
14 wiretap/pcap-common.c | 2 +- |
|
15 wiretap/snoop.c | 2 +- |
|
16 wiretap/wtap.h | 3 +- |
|
17 4 files changed, 91 insertions(+), 13 deletions(-) |
|
18 |
|
19 diff --git a/epan/dissectors/packet-ipoib.c b/epan/dissectors/packet-ipoib.c |
|
20 index 7d8c527..91af43a 100644 |
|
21 --- epan/dissectors/packet-ipoib.c |
|
22 +++ epan/dissectors/packet-ipoib.c |
|
23 @@ -30,11 +30,21 @@ |
|
24 void proto_register_ipoib(void); |
|
25 void proto_reg_handoff_ipoib(void); |
|
26 |
|
27 -static int proto_ipoib = -1; |
|
28 -static int hf_type = -1; |
|
29 -static int hf_reserved = -1; |
|
30 +static int proto_ipoib = -1; |
|
31 +static int hf_dgid = -1; |
|
32 +static int hf_daddr = -1; |
|
33 +static int hf_daddr_qpn = -1; |
|
34 +static int hf_grh = -1; |
|
35 +static int hf_grh_ip_version = -1; |
|
36 +static int hf_grh_traffic_class = -1; |
|
37 +static int hf_grh_flow_label = -1; |
|
38 +static int hf_grh_sqpn = -1; |
|
39 +static int hf_grh_sgid = -1; |
|
40 +static int hf_type = -1; |
|
41 +static int hf_reserved = -1; |
|
42 |
|
43 static gint ett_raw = -1; |
|
44 +static gint ett_hdr = -1; |
|
45 |
|
46 static dissector_handle_t arp_handle; |
|
47 static dissector_handle_t ip_handle; |
|
48 @@ -44,9 +54,14 @@ |
|
49 dissect_ipoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) |
|
50 { |
|
51 proto_tree *fh_tree; |
|
52 + proto_tree *fh_subtree; |
|
53 proto_item *ti; |
|
54 tvbuff_t *next_tvb; |
|
55 guint16 type; |
|
56 + int grh_size = 0; |
|
57 + |
|
58 + if (pinfo->phdr->pkt_encap == WTAP_ENCAP_IP_OVER_IB_PCAP) |
|
59 + grh_size = 40; |
|
60 |
|
61 /* load the top pane info. This should be overwritten by |
|
62 the next protocol in the stack */ |
|
63 @@ -55,16 +70,40 @@ dissect_ipoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U |
|
64 |
|
65 /* populate a tree in the second pane with the IPoIB header data */ |
|
66 if (tree) { |
|
67 - ti = proto_tree_add_item (tree, proto_ipoib, tvb, 0, 4, ENC_NA); |
|
68 + ti = proto_tree_add_item (tree, proto_ipoib, tvb, 0, grh_size + 4, ENC_NA); |
|
69 fh_tree = proto_item_add_subtree(ti, ett_raw); |
|
70 |
|
71 - proto_tree_add_item(fh_tree, hf_type, tvb, 0, 2, ENC_BIG_ENDIAN); |
|
72 - proto_tree_add_item(fh_tree, hf_reserved, tvb, 2, 2, ENC_BIG_ENDIAN); |
|
73 + /* for PCAP data populate subtree with GRH pseudo header data */ |
|
74 + if (pinfo->phdr->pkt_encap == WTAP_ENCAP_IP_OVER_IB_PCAP) { |
|
75 + |
|
76 + /* Zero means GRH is not valid (unicast). Only destination |
|
77 + address is set. */ |
|
78 + if (tvb_get_ntohs(tvb, 0) == 0) { |
|
79 + ti = proto_tree_add_item (fh_tree, hf_daddr, tvb, 20, 20, ENC_NA); |
|
80 + fh_subtree = proto_item_add_subtree(ti, ett_hdr); |
|
81 + |
|
82 + proto_tree_add_item(fh_subtree, hf_daddr_qpn, tvb, 21, 3, ENC_BIG_ENDIAN); |
|
83 + proto_tree_add_item(fh_subtree, hf_dgid, tvb, 24, 16, ENC_NA); |
|
84 + } else { |
|
85 + ti = proto_tree_add_item (fh_tree, hf_grh, tvb, 0, 40, ENC_NA); |
|
86 + fh_subtree = proto_item_add_subtree(ti, ett_hdr); |
|
87 + |
|
88 + proto_tree_add_item(fh_subtree, hf_grh_ip_version, tvb, 0, 1, ENC_BIG_ENDIAN); |
|
89 + proto_tree_add_item(fh_subtree, hf_grh_traffic_class, tvb, 0, 2, ENC_BIG_ENDIAN); |
|
90 + proto_tree_add_item(fh_subtree, hf_grh_flow_label,tvb, 0, 4, ENC_BIG_ENDIAN); |
|
91 + proto_tree_add_item(fh_subtree, hf_grh_sqpn, tvb, 5, 3, ENC_BIG_ENDIAN); |
|
92 + proto_tree_add_item(fh_subtree, hf_grh_sgid, tvb, 8, 16, ENC_NA); |
|
93 + proto_tree_add_item(fh_subtree, hf_dgid, tvb, 24, 16, ENC_NA); |
|
94 + } |
|
95 + } |
|
96 + |
|
97 + proto_tree_add_item(fh_tree, hf_type, tvb, grh_size + 0, 2, ENC_BIG_ENDIAN); |
|
98 + proto_tree_add_item(fh_tree, hf_reserved, tvb, grh_size + 2, 2, ENC_BIG_ENDIAN); |
|
99 } |
|
100 |
|
101 - next_tvb = tvb_new_subset_remaining(tvb, 4); |
|
102 + next_tvb = tvb_new_subset_remaining(tvb, grh_size + 4); |
|
103 |
|
104 - type = tvb_get_ntohs(tvb, 0); |
|
105 + type = tvb_get_ntohs(tvb, grh_size + 0); |
|
106 switch (type) { |
|
107 case ETHERTYPE_IP: |
|
108 call_dissector(ip_handle, next_tvb, pinfo, tree); |
|
109 @@ -85,6 +124,42 @@ void |
|
110 proto_register_ipoib(void) |
|
111 { |
|
112 static hf_register_info hf[] = { |
|
113 + { &hf_daddr, |
|
114 + { "Destination address", "ipoib.daddr", |
|
115 + FT_NONE, BASE_NONE, NULL, 0x0, |
|
116 + NULL, HFILL}}, |
|
117 + { &hf_daddr_qpn, |
|
118 + { "Destination QPN", "ipoib.daddr.qpn", |
|
119 + FT_UINT24, BASE_HEX, NULL, 0x0, |
|
120 + NULL, HFILL}}, |
|
121 + { &hf_dgid, |
|
122 + { "Destination GID", "ipoib.dgid", |
|
123 + FT_IPv6, BASE_NONE, NULL, 0x0, |
|
124 + NULL, HFILL }}, |
|
125 + { &hf_grh, |
|
126 + { "Global Route Header", "ipoib.grh", |
|
127 + FT_NONE, BASE_NONE, NULL, 0x0, |
|
128 + NULL, HFILL}}, |
|
129 + { &hf_grh_ip_version, { |
|
130 + "IP Version", "ipoib.grh.ipver", |
|
131 + FT_UINT8, BASE_DEC, NULL, 0xF0, |
|
132 + NULL, HFILL}}, |
|
133 + { &hf_grh_traffic_class, { |
|
134 + "Traffic Class", "ipoib.grh.tclass", |
|
135 + FT_UINT16, BASE_DEC, NULL, 0x0FF0, |
|
136 + NULL, HFILL}}, |
|
137 + { &hf_grh_flow_label, { |
|
138 + "Flow Label", "ipoib.grh.flowlabel", |
|
139 + FT_UINT32, BASE_DEC, NULL, 0x000FFFFF, |
|
140 + NULL, HFILL}}, |
|
141 + { &hf_grh_sqpn, |
|
142 + { "Source QPN", "ipoib.grh.sqpn", |
|
143 + FT_UINT24, BASE_HEX, NULL, 0x0, |
|
144 + NULL, HFILL}}, |
|
145 + { &hf_grh_sgid, |
|
146 + { "Source GID", "ipoib.grh.sgid", |
|
147 + FT_IPv6, BASE_NONE, NULL, 0x0, |
|
148 + NULL, HFILL }}, |
|
149 { &hf_type, |
|
150 { "Type", "ipoib.type", |
|
151 FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, |
|
152 @@ -96,7 +171,8 @@ proto_register_ipoib(void) |
|
153 }; |
|
154 |
|
155 static gint *ett[] = { |
|
156 - &ett_raw |
|
157 + &ett_raw, |
|
158 + &ett_hdr |
|
159 }; |
|
160 |
|
161 proto_ipoib = proto_register_protocol("IP over Infiniband", "IPoIB", "ipoib"); |
|
162 @@ -117,7 +193,8 @@ |
|
163 ipv6_handle = find_dissector("ipv6"); |
|
164 |
|
165 ipoib_handle = create_dissector_handle(dissect_ipoib, proto_ipoib); |
|
166 - dissector_add_uint("wtap_encap", WTAP_ENCAP_IP_OVER_IB, ipoib_handle); |
|
167 + dissector_add_uint("wtap_encap", WTAP_ENCAP_IP_OVER_IB_SNOOP, ipoib_handle); |
|
168 + dissector_add_uint("wtap_encap", WTAP_ENCAP_IP_OVER_IB_PCAP, ipoib_handle); |
|
169 } |
|
170 |
|
171 /* |
|
172 diff --git a/wiretap/pcap-common.c b/wiretap/pcap-common.c |
|
173 index 9d6826b..297387a 100644 |
|
174 --- wiretap/pcap-common.c |
|
175 +++ wiretap/pcap-common.c |
|
176 @@ -400,7 +400,7 @@ static const struct { |
|
177 /* netANALYZER pseudo-header in transparent mode */ |
|
178 { 241, WTAP_ENCAP_NETANALYZER_TRANSPARENT }, |
|
179 /* IP-over-Infiniband, as specified by RFC 4391 section 6 */ |
|
180 - { 242, WTAP_ENCAP_IP_OVER_IB }, |
|
181 + { 242, WTAP_ENCAP_IP_OVER_IB_PCAP }, |
|
182 /* ISO/IEC 13818-1 MPEG2-TS packets */ |
|
183 { 243, WTAP_ENCAP_MPEG_2_TS }, |
|
184 /* NFC LLCP */ |
|
185 diff --git a/wiretap/snoop.c b/wiretap/snoop.c |
|
186 index da88bb4..3a7cc9e 100644 |
|
187 --- wiretap/snoop.c |
|
188 +++ wiretap/snoop.c |
|
189 @@ -210,7 +210,7 @@ wtap_open_return_val snoop_open(wtap *wth, int *err, gchar **err_info) |
|
190 WTAP_ENCAP_UNKNOWN, /* 100VG-AnyLAN Token Ring */ |
|
191 WTAP_ENCAP_UNKNOWN, /* "ISO 8802/3 and Ethernet" */ |
|
192 WTAP_ENCAP_UNKNOWN, /* 100BaseT (but that's just Ethernet) */ |
|
193 - WTAP_ENCAP_IP_OVER_IB, /* Infiniband */ |
|
194 + WTAP_ENCAP_IP_OVER_IB_SNOOP, /* Infiniband */ |
|
195 }; |
|
196 #define NUM_SNOOP_ENCAPS (sizeof snoop_encap / sizeof snoop_encap[0]) |
|
197 #define SNOOP_PRIVATE_BIT 0x80000000 |
|
198 diff --git a/wiretap/wtap.h b/wiretap/wtap.h |
|
199 index 169f26c..3e10101 100644 |
|
200 --- wiretap/wtap.h |
|
201 +++ wiretap/wtap.h |
|
202 @@ -223,7 +223,7 @@ |
|
203 #define WTAP_ENCAP_MIME 134 |
|
204 #define WTAP_ENCAP_NETANALYZER 135 |
|
205 #define WTAP_ENCAP_NETANALYZER_TRANSPARENT 136 |
|
206 -#define WTAP_ENCAP_IP_OVER_IB 137 |
|
207 +#define WTAP_ENCAP_IP_OVER_IB_SNOOP 137 |
|
208 #define WTAP_ENCAP_MPEG_2_TS 138 |
|
209 #define WTAP_ENCAP_PPP_ETHER 139 |
|
210 #define WTAP_ENCAP_NFC_LLCP 140 |
|
211 @@ -264,6 +264,7 @@ |
|
212 #define WTAP_ENCAP_LOOP 175 |
|
213 #define WTAP_ENCAP_JSON 176 |
|
214 #define WTAP_ENCAP_NSTRACE_3_5 177 |
|
215 +#define WTAP_ENCAP_IP_OVER_IB_PCAP 180 |
|
216 /* After adding new item here, please also add new item to encap_table_base array */ |
|
217 |
|
218 #define WTAP_NUM_ENCAP_TYPES wtap_get_num_encap_types() |