HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-ndp.c
blob752eddb0423271ccfcc31e57c784a765f20c01a4
1 /* packet-ndp.c
2 * Routines for the disassembly of the Nortel Discovery Protocol, formerly
3 * the SynOptics Network Management Protocol (SONMP).
4 * (c) Copyright Giles Scott <giles.scott1 [AT] arubanetworks.com>
6 * $Id$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * This protocol has gone by many names over the years:
28 * Bay Discovery Protocol (BDP), Bay Topology Protocol, Bay Network Management
29 * Protocol (BNMP), Nortel Management MIB (NMM), Nortel Topology Discovery
30 * Protocol (NTDP), SynOptics Network Management Protocol (SONMP).
31 * (source: Wikipedia article on "Nortel Discovery Protocol")
35 #include "config.h"
37 #include <glib.h>
39 #include <epan/packet.h>
40 #include <epan/nlpid.h>
42 /* Although this protocol is proprietary it is documented in the SynOptics MIB's
43 * So I'm not giving anything away :-)
44 * The only thing I have not done is decode the segment identifier;
45 * This changes so much depending on whether the chassis supports
46 * multi-segment autotopology. As the 5000 is now EOL don't see much point.
48 * MIB's s5emt104.mib, s5tcs112.mib, synro199.mib these should be available via
49 * http://www.nortelnetworks.com
53 /* chassis types */
54 /* Last updated from version 229 ("200609010000Z") of SnpxChassisType in SYNOPTICS-ROOT-MIB.mib */
55 static const value_string ndp_chassis_val[] =
57 {1, "other"},
58 {2, "3000"},
59 {3, "3030"},
60 {4, "2310"},
61 {5, "2810"},
62 {6, "2912"},
63 {7, "2914"},
64 {8, "271x"},
65 {9, "2813"},
66 {10, "2814"},
67 {11, "2915"},
68 {12, "5000"},
69 {13, "2813SA"},
70 {14, "2814SA"},
71 {15, "810M"},
72 {16, "Ethercell"},
73 {17, "5005"},
74 {18, "Alcatel Ethernet workgroup conc."},
76 {20, "2715SA"},
77 {21, "2486"},
78 {22, "28000 series"},
79 {23, "23000 series"},
80 {24, "5DN00x series"},
81 {25, "BayStack Ethernet"},
82 {26, "23100 series"},
83 {27, "100Base-T Hub"},
84 {28, "3000 Fast Ethernet"},
85 {29, "Orion switch"},
86 /* 30 is "not used" */
87 {31, "DDS"},
88 {32, "Centillion (6 slot)"},
89 {33, "Centillion (12 slot)"},
90 {34, "Centillion (1 slot)"},
91 {35, "BayStack 301"},
92 {36, "BayStack TokenRing Hub"},
93 {37, "FVC Multimedia Switch"},
94 {38, "Switch Node"},
95 {39, "BayStack 302 Switch"},
96 {40, "BayStack 350 Switch"},
97 {41, "BayStack 150 Ethernet Hub"},
98 {42, "Centillion 50N switch"},
99 {43, "Centillion 50T switch"},
100 {44, "BayStack 303 and 304 Switches"},
101 {45, "BayStack 200 Ethernet Hub"},
102 {46, "BayStack 250 10/100 Ethernet Hub"},
103 /*{47, "StackProbe"}, XXX - No longer listed */
104 {48, "BayStack 450 10/100/1000 Switches"},
105 {49, "BayStack 410 10/100 Switches"},
106 {50, "Passport 1200 L3 Switch"},
107 {51, "Passport 1250 L3 Switch"},
108 {52, "Passport 1100 L3 Switch"},
109 {53, "Passport 1150 L3 Switch"},
110 {54, "Passport 1050 L3 Switch"},
111 {55, "Passport 1051 L3 Switch"},
112 {56, "Passport 8610 L3 Switch"},
113 {57, "Passport 8606 L3 Switch"},
114 {58, "Passport 8010"},
115 {59, "Passport 8006"},
116 {60, "BayStack 670 wireless access point"},
117 {61, "Passport 740"},
118 {62, "Passport 750"},
119 {63, "Passport 790"},
120 {64, "Business Policy Switch 2000 10/100 Switches"},
121 {65, "Passport 8110 L2 Switch"},
122 {66, "Passport 8106 L2 Switch"},
123 {67, "BayStack 3580 Gig Switch"},
124 {68, "BayStack 10 Power Supply Unit"},
125 {69, "BayStack 420 10/100 Switch"},
126 {70, "OPTera Metro 1200 Ethernet Service Module"},
127 {71, "OPTera 8010co"},
128 {72, "OPTera 8610co L3 switch"},
129 {73, "OPTera 8110co L2 switch"},
130 {74, "OPTera 8003"},
131 {75, "OPTera 8603 L3 switch"},
132 {76, "OPTera 8103 L2 switch"},
133 {77, "BayStack 380 10/100/1000 Switch"},
134 {78, "Ethernet Switch 470-48T"},
135 {79, "OPTera Metro 1450 Ethernet Service Module"},
136 {80, "OPTera Metro 1400 Ethernet Service Module"},
137 {81, "Alteon Switch Family"},
138 {82, "Ethernet Switch 460-24T-PWR"},
139 {83, "OPTera Metro 8010 OPM L2 Switch"},
140 {84, "OPTera Metro 8010co OPM L2 Switch"},
141 {85, "OPTera Metro 8006 OPM L2 Switch"},
142 {86, "OPTera Metro 8003 OPM L2 Switch"},
143 {87, "Alteon 180e"},
144 {88, "Alteon AD3"},
145 {89, "Alteon 184"},
146 {90, "Alteon AD4"},
147 {91, "Passport 1424 L3 switch"},
148 {92, "Passport 1648 L3 switch"},
149 {93, "Passport 1612 L3 switch"},
150 {94, "Passport 1624 L3 switch"},
151 {95, "BayStack 380-24F Fiber 1000 Switch"},
152 {96, "Ethernet Routing Switch 5510-24T"},
153 {97, "Ethernet Routing Switch 5510-48T"},
154 {98, "Ethernet Switch 470-24T"},
155 {99, "Nortel Networks Wireless LAN Access Point 2220"},
156 {100, "Passport RBS 2402 L3 switch"},
157 {101, "Alteon Application Switch 2424"},
158 {102, "Alteon Application Switch 2224"},
159 {103, "Alteon Application Switch 2208"},
160 {104, "Alteon Application Switch 2216"},
161 {105, "Alteon Application Switch 3408"},
162 {106, "Alteon Application Switch 3416"},
163 {107, "Nortel Networks Wireless LAN SecuritySwitch 2250"},
164 {108, "Ethernet Switch 425-48T"},
165 {109, "Ethernet Switch 425-24T"},
166 {110, "Nortel Networks Wireless LAN Access Point 2221"},
167 {111, "Nortel Metro Ethernet Service Unit 24-T SPF switch"},
168 {112, " Nortel Metro Ethernet Service Unit 24-T LX DC switch"},
169 {113, "Passport 8300 10-slot chassis"},
170 {114, "Passport 8300 6-slot chassis"},
171 {115, "Ethernet Routing Switch 5520-24T-PWR"},
172 {116, "Ethernet Routing Switch 5520-48T-PWR"},
173 {117, "Nortel Networks VPN Gateway 3050"},
174 {118, "Alteon SSL 310 10/100"},
175 {119, "Alteon SSL 310 10/100 Fiber"},
176 {120, "Alteon SSL 310 10/100 FIPS"},
177 {121, "Alteon SSL 410 10/100/1000"},
178 {122, "Alteon SSL 410 10/100/1000 Fiber"},
179 {123, "Alteon Application Switch 2424-SSL"},
180 {124, "Ethernet Switch 325-24T"},
181 {125, "Ethernet Switch 325-24G"},
182 {126, "Nortel Networks Wireless LAN Access Point 2225"},
183 {127, "Nortel Networks Wireless LAN SecuritySwitch 2270"},
184 {128, "24-port Ethernet Switch 470-24T-PWR"},
185 {129, "48-port Ethernet Switch 470-48T-PWR"},
186 {130, "Ethernet Routing Switch 5530-24TFD"},
187 {131, "Ethernet Switch 3510-24T"},
188 {132, "Nortel Metro Ethernet Service Unit 12G AC L3 switch"},
189 {133, "Nortel Metro Ethernet Service Unit 12G DC L3 switch"},
190 {134, "Nortel Secure Access Switch"},
191 {135, "Nortel Networks VPN Gateway 3070"},
192 {136, "OPTera Metro 3500"},
193 {137, "SMB BES 1010 24T"},
194 {138, "SMB BES 1010 48T"},
195 {139, "SMB BES 1020 24T PWR"},
196 {140, "SMB BES 1020 48T PWR"},
197 {141, "SMB BES 2010 24T"},
198 {142, "SMB BES 2010 48T"},
199 {143, "SMB BES 2020 24T PWR"},
200 {144, "SMB BES 2020 48T PWR"},
201 {145, "SMB BES 110 24T"},
202 {146, "SMB BES 110 48T"},
203 {147, "SMB BES 120 24T PWR"},
204 {148, "SMB BES 120 48T PWR"},
205 {149, "SMB BES 210 24T"},
206 {150, "SMB BES 210 48T"},
207 {151, "SMB BES 220 24T PWR"},
208 {152, "SMB BES 220 48T PWR"},
209 {153, "OME 6500"},
210 {154, "Ethernet Routing Switch 4548GT"},
211 {155, "Ethernet Routing Switch 4548GT-PWR"},
212 {156, "Ethernet Routing Switch 4550T"},
213 {157, "Ethernet Routing Switch 4550T-PWR"},
214 {158, "Ethernet Routing Switch 4526FX"},
215 {159, "Ethernet Routing Switch 2500-26T"},
216 {160, "Ethernet Routing Switch 2500-26T-PWR"},
217 {161, "Ethernet Routing Switch 2500-50T"},
218 {162, "Ethernet Routing Switch 2500-50T-PWR"},
219 {0, NULL}
221 static value_string_ext ndp_chassis_val_ext = VALUE_STRING_EXT_INIT(ndp_chassis_val);
223 /* from synro179.mib - SnpxBackplaneType */
224 static const value_string ndp_backplane_val[] =
226 {1, "Other"},
227 {2, "Ethernet"},
228 {3, "Ethernet and Tokenring"},
229 {4, "Ethernet and FDDI"},
230 {5, "Ethernet, Tokenring and FDDI"},
231 {6, "Ethernet and Tokenring with redundant power"},
232 {7, "Ethernet, Tokenring, FDDI with redundant power"},
233 {8, "Token Ring"},
234 {9, "Ethernet, Tokenring and Fast Ethernet"},
235 {10, "Ethernet and Fast Ethernet"},
236 {11, "Ethernet, Tokenring, Fast Ethernet with redundant power"},
237 {12, "Ethernet, Fast Ethernet and Gigabit Ethernet"},
238 {0, NULL}
240 static value_string_ext ndp_backplane_val_ext = VALUE_STRING_EXT_INIT(ndp_backplane_val);
242 static const value_string ndp_state_val[] =
244 {1, "Topology Change"},
245 {2, "Heartbeat"},
246 {3, "New"},
247 {0, NULL}
251 /* Offsets in NDP Hello structure. */
252 #define NDP_IP_ADDRESS 0
253 #define NDP_SEGMENT_IDENTIFIER 4
254 #define NDP_CHASSIS_TYPE 7
255 #define NDP_BACKPLANE_TYPE 8
256 #define NDP_STATE 9
257 #define NDP_NUMBER_OF_LINKS 10
259 static int proto_ndp = -1;
260 static int hf_ndp_ip_address = -1;
261 static int hf_ndp_segment_identifier = -1;
262 static int hf_ndp_chassis_type = -1;
263 static int hf_ndp_backplane_type = -1;
264 static int hf_ndp_state = -1;
265 static int hf_ndp_number_of_links = -1;
267 static gint ett_ndp = -1;
270 static void
271 dissect_ndp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
273 const char *hello_type;
274 proto_tree *ndp_tree = NULL;
275 proto_item *ti;
277 col_set_str(pinfo->cinfo, COL_PROTOCOL, "NDP");
279 hello_type = "";
280 if (pinfo->dl_dst.type == AT_ETHER) {
281 const guint8 *dstmac = (const guint8 *)pinfo->dl_dst.data;
283 switch (dstmac[5]) {
285 case 0:
286 hello_type = "Segment ";
287 break;
289 case 1:
290 hello_type = "FlatNet ";
291 break;
294 col_add_fstr(pinfo->cinfo, COL_INFO, "%sHello", hello_type);
296 if (tree) {
297 ti = proto_tree_add_protocol_format(tree, proto_ndp, tvb, 0, 11,
298 "Nortel Discovery Protocol");
300 ndp_tree = proto_item_add_subtree(ti, ett_ndp);
302 proto_tree_add_item(ndp_tree, hf_ndp_ip_address, tvb,
303 NDP_IP_ADDRESS, 4, ENC_BIG_ENDIAN);
306 proto_tree_add_item(ndp_tree, hf_ndp_segment_identifier, tvb,
307 NDP_SEGMENT_IDENTIFIER, 3, ENC_BIG_ENDIAN);
310 proto_tree_add_item(ndp_tree, hf_ndp_chassis_type, tvb,
311 NDP_CHASSIS_TYPE, 1, ENC_BIG_ENDIAN);
313 proto_tree_add_item(ndp_tree, hf_ndp_backplane_type, tvb,
314 NDP_BACKPLANE_TYPE, 1, ENC_BIG_ENDIAN);
317 proto_tree_add_item(ndp_tree, hf_ndp_state, tvb,
318 NDP_STATE, 1, ENC_BIG_ENDIAN);
320 proto_tree_add_item(ndp_tree, hf_ndp_number_of_links, tvb,
321 NDP_NUMBER_OF_LINKS, 1, ENC_BIG_ENDIAN);
329 void
330 proto_register_ndp(void)
332 static hf_register_info hf[] = {
333 { &hf_ndp_ip_address,
334 { "IP address", "ndp.ipaddress", FT_IPv4, BASE_NONE, NULL, 0x0,
335 "IP address of the Network Management Module (NMM))", HFILL }},
337 { &hf_ndp_segment_identifier,
338 { "Segment Identifier", "ndp.segmentident", FT_UINT24, BASE_HEX, NULL, 0x0,
339 "Segment id of the segment from which the agent is sending the topology message", HFILL }},
341 { &hf_ndp_chassis_type,
342 { "Chassis type", "ndp.chassis", FT_UINT8, BASE_DEC|BASE_EXT_STRING,
343 &ndp_chassis_val_ext, 0x0,
344 "Chassis type of the agent sending the topology message", HFILL }},
346 { &hf_ndp_backplane_type,
347 { "Backplane type", "ndp.backplane", FT_UINT8, BASE_DEC|BASE_EXT_STRING,
348 &ndp_backplane_val_ext, 0x0,
349 "Backplane type of the agent sending the topology message", HFILL }},
351 { &hf_ndp_state,
352 { "State", "ndp.state", FT_UINT8, BASE_DEC,
353 VALS(ndp_state_val), 0x0,
354 "Current state of this Network Management Module (NMM)", HFILL }},
356 { &hf_ndp_number_of_links,
357 { "Number of links", "ndp.numberoflinks", FT_UINT8, BASE_DEC, NULL, 0x0,
358 "Number of interconnect ports", HFILL }},
361 static gint *ett[] = {
362 &ett_ndp,
364 proto_ndp = proto_register_protocol("Nortel Discovery Protocol", "NDP", "ndp");
365 proto_register_field_array(proto_ndp, hf, array_length(hf));
366 proto_register_subtree_array(ett, array_length(ett));
368 register_dissector("ndp", dissect_ndp, proto_ndp);
371 void
372 proto_reg_handoff_ndp(void)
374 dissector_handle_t ndp_handle;
376 ndp_handle = find_dissector("ndp");
378 dissector_add_uint("llc.nortel_pid", 0x01a1, ndp_handle); /* flatnet hello */
379 dissector_add_uint("llc.nortel_pid", 0x01a2, ndp_handle); /* Segment hello */
380 /* not got round to adding this but it's really old, so I'm not sure people will see it */
381 /* it uses a different packet format */
382 /* dissector_add_uint("llc.nortel_pid", 0x01a3, ndp_handle); */ /* Bridge hello */