2 * Routines for NetWare IPX WAN Protocol
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <epan/packet.h>
26 #include <epan/expert.h>
27 #include "packet-ipx.h"
29 void proto_register_ipxwan(void);
30 void proto_reg_handoff_ipxwan(void);
33 * See RFC 1362 for version 1 of this protocol; see the NetWare Link
34 * Services Protocol Specification, chapter 3, for version 2.
36 static int proto_ipxwan = -1;
38 static int hf_ipxwan_identifier = -1;
39 static int hf_ipxwan_packet_type = -1;
40 static int hf_ipxwan_node_id = -1;
41 static int hf_ipxwan_sequence_number = -1;
42 static int hf_ipxwan_num_options = -1;
43 static int hf_ipxwan_option_num = -1;
44 static int hf_ipxwan_accept_option = -1;
45 static int hf_ipxwan_option_data_len = -1;
46 static int hf_ipxwan_routing_type = -1;
47 static int hf_ipxwan_wan_link_delay = -1;
48 static int hf_ipxwan_common_network_number = -1;
49 static int hf_ipxwan_router_name = -1;
50 static int hf_ipxwan_delay = -1;
51 static int hf_ipxwan_throughput = -1;
52 static int hf_ipxwan_request_size = -1;
53 static int hf_ipxwan_delta_time = -1;
54 static int hf_ipxwan_extended_node_id = -1;
55 static int hf_ipxwan_node_number = -1;
56 static int hf_ipxwan_compression_type = -1;
57 static int hf_ipxwan_compression_options = -1;
58 static int hf_ipxwan_compression_slots = -1;
59 static int hf_ipxwan_compression_parameters = -1;
60 static int hf_ipxwan_padding = -1;
61 static int hf_ipxwan_option_value = -1;
63 static gint ett_ipxwan = -1;
64 static gint ett_ipxwan_option = -1;
66 static expert_field ei_ipxwan_option_data_len = EI_INIT;
68 static const value_string ipxwan_packet_type_vals[] = {
69 { 0, "Timer Request" },
70 { 1, "Timer Response" },
71 { 2, "Information Request" },
72 { 3, "Information Response" },
73 { 4, "Throughput Request" },
74 { 5, "Throughput Response" },
75 { 6, "Delay Request" },
76 { 7, "Delay Response" },
81 #define OPT_ROUTING_TYPE 0x00
82 #define OPT_RIP_SAP_INFO_EXCHANGE 0x01
83 #define OPT_NLSP_INFORMATION 0x02
84 #define OPT_NLSP_RAW_THROUGHPUT_DATA 0x03
85 #define OPT_EXTENDED_NODE_ID 0x04
86 #define OPT_NODE_NUMBER 0x05
87 #define OPT_COMPRESSION 0x80
90 static const value_string ipxwan_option_num_vals[] = {
91 { OPT_ROUTING_TYPE, "Routing Type" },
92 { OPT_RIP_SAP_INFO_EXCHANGE, "RIP/SAP Info Exchange" },
93 { OPT_NLSP_INFORMATION, "NLSP Information" },
94 { OPT_NLSP_RAW_THROUGHPUT_DATA, "NLSP Raw Throughput Data" },
95 { OPT_EXTENDED_NODE_ID, "Extended Node ID" },
96 { OPT_NODE_NUMBER, "Node Number" },
97 { OPT_COMPRESSION, "Compression" },
102 static const value_string ipxwan_accept_option_vals[] = {
105 { 3, "Not Applicable" },
109 static const value_string ipxwan_routing_type_vals[] = {
112 { 2, "Unnumbered RIP" },
113 { 3, "On-demand, static routing" },
114 { 4, "Client-router connection" },
118 #define COMP_TYPE_TELEBIT 0
120 static const value_string ipxwan_compression_type_vals[] = {
121 { COMP_TYPE_TELEBIT, "Telebit" },
126 dissect_ipxwan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
129 proto_tree *ipxwan_tree = NULL;
133 guint8 option_number;
134 proto_tree *option_tree;
135 guint16 option_data_len;
136 guint16 wan_link_delay;
140 guint8 compression_type;
142 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPX WAN");
143 col_clear(pinfo->cinfo, COL_INFO);
145 ti = proto_tree_add_item(tree, proto_ipxwan, tvb, 0, -1,
147 ipxwan_tree = proto_item_add_subtree(ti, ett_ipxwan);
149 proto_tree_add_item(ipxwan_tree, hf_ipxwan_identifier, tvb,
150 offset, 4, ENC_ASCII|ENC_NA);
153 packet_type = tvb_get_guint8(tvb, offset);
154 col_add_str(pinfo->cinfo, COL_INFO,
155 val_to_str(packet_type, ipxwan_packet_type_vals,
156 "Unknown packet type %u"));
158 proto_tree_add_uint(ipxwan_tree, hf_ipxwan_packet_type, tvb,
159 offset, 1, packet_type);
161 proto_tree_add_item(ipxwan_tree, hf_ipxwan_node_id, tvb,
162 offset, 4, ENC_BIG_ENDIAN);
164 proto_tree_add_item(ipxwan_tree, hf_ipxwan_sequence_number, tvb,
165 offset, 1, ENC_BIG_ENDIAN);
167 num_options = tvb_get_guint8(tvb, offset);
168 proto_tree_add_uint(ipxwan_tree, hf_ipxwan_num_options, tvb,
169 offset, 1, num_options);
172 while (num_options != 0) {
173 option_number = tvb_get_guint8(tvb, offset);
174 option_tree = proto_tree_add_subtree_format(ipxwan_tree, tvb, offset, -1,
175 ett_ipxwan_option, &ti, "Option: %s",
176 val_to_str(option_number, ipxwan_option_num_vals,
179 proto_tree_add_uint(option_tree, hf_ipxwan_option_num,
180 tvb, offset, 1, option_number);
182 proto_tree_add_item(option_tree, hf_ipxwan_accept_option,
183 tvb, offset, 1, ENC_BIG_ENDIAN);
185 option_data_len = tvb_get_ntohs(tvb, offset);
186 proto_tree_add_uint(option_tree, hf_ipxwan_option_data_len,
187 tvb, offset, 2, option_data_len);
189 proto_item_set_len(ti, option_data_len+4);
190 switch (option_number) {
192 case OPT_ROUTING_TYPE:
193 if (option_data_len != 1) {
194 expert_add_info_format(pinfo, ti, &ei_ipxwan_option_data_len,
195 "Bogus length: %u, should be 1", option_data_len);
197 proto_tree_add_item(option_tree,
198 hf_ipxwan_routing_type, tvb,
199 offset, 1, ENC_BIG_ENDIAN);
203 case OPT_RIP_SAP_INFO_EXCHANGE:
204 if (option_data_len != 54) {
205 expert_add_info_format(pinfo, ti, &ei_ipxwan_option_data_len,
206 "Bogus length: %u, should be 54", option_data_len);
208 wan_link_delay = tvb_get_ntohs(tvb,
210 proto_tree_add_uint_format_value(option_tree,
211 hf_ipxwan_wan_link_delay, tvb,
212 offset, 2, wan_link_delay,
215 proto_tree_add_item(option_tree,
216 hf_ipxwan_common_network_number,
217 tvb, offset+2, 4, ENC_NA);
218 proto_tree_add_item(option_tree,
219 hf_ipxwan_router_name, tvb,
220 offset+6, 48, ENC_ASCII|ENC_NA);
224 case OPT_NLSP_INFORMATION:
225 if (option_data_len != 8) {
226 expert_add_info_format(pinfo, ti, &ei_ipxwan_option_data_len,
227 "Bogus length: %u, should be 8", option_data_len);
229 delay = tvb_get_ntohl(tvb, offset);
230 proto_tree_add_uint_format_value(option_tree,
231 hf_ipxwan_delay, tvb,
234 throughput = tvb_get_ntohl(tvb, offset);
235 proto_tree_add_uint_format_value(option_tree,
236 hf_ipxwan_throughput, tvb,
237 offset, 4, throughput,
243 case OPT_NLSP_RAW_THROUGHPUT_DATA:
244 if (option_data_len != 8) {
245 expert_add_info_format(pinfo, ti, &ei_ipxwan_option_data_len,
246 "Bogus length: %u, should be 8", option_data_len);
248 proto_tree_add_item(option_tree,
249 hf_ipxwan_request_size, tvb,
250 offset, 4, ENC_BIG_ENDIAN);
251 delta_time = tvb_get_ntohl(tvb, offset);
252 proto_tree_add_uint_format_value(option_tree,
253 hf_ipxwan_delta_time, tvb,
254 offset, 4, delta_time,
260 case OPT_EXTENDED_NODE_ID:
261 if (option_data_len != 4) {
262 expert_add_info_format(pinfo, ti, &ei_ipxwan_option_data_len,
263 "Bogus length: %u, should be 4", option_data_len);
265 proto_tree_add_item(option_tree,
266 hf_ipxwan_extended_node_id, tvb,
271 case OPT_NODE_NUMBER:
272 if (option_data_len != 6) {
273 expert_add_info_format(pinfo, ti, &ei_ipxwan_option_data_len,
274 "Bogus length: %u, should be 6", option_data_len);
276 proto_tree_add_item(option_tree,
277 hf_ipxwan_node_number, tvb,
282 case OPT_COMPRESSION:
283 if (option_data_len < 1) {
284 expert_add_info_format(pinfo, ti, &ei_ipxwan_option_data_len,
285 "Bogus length: %u, should be >= 1", option_data_len);
287 compression_type = tvb_get_guint8(tvb,
289 ti = proto_tree_add_uint(option_tree,
290 hf_ipxwan_compression_type, tvb,
291 offset, 1, compression_type);
292 switch (compression_type) {
294 case COMP_TYPE_TELEBIT:
295 if (option_data_len < 3) {
296 expert_add_info_format(pinfo, ti, &ei_ipxwan_option_data_len,
297 "Bogus length: %u, should be >= 3", option_data_len);
299 proto_tree_add_item(option_tree, hf_ipxwan_compression_options,
300 tvb, offset+1, 1, ENC_BIG_ENDIAN);
301 proto_tree_add_item(option_tree, hf_ipxwan_compression_slots,
302 tvb, offset+2, 1, ENC_BIG_ENDIAN);
307 proto_tree_add_item(option_tree, hf_ipxwan_compression_parameters,
308 tvb, offset+1, option_data_len-1, ENC_NA);
315 proto_tree_add_item(option_tree, hf_ipxwan_padding,
316 tvb, offset, option_data_len, ENC_NA);
320 proto_tree_add_item(option_tree, hf_ipxwan_option_value,
321 tvb, offset, option_data_len, ENC_NA);
325 offset += option_data_len;
328 return tvb_captured_length(tvb);
332 proto_register_ipxwan(void)
334 static hf_register_info hf[] = {
335 { &hf_ipxwan_identifier,
336 { "Identifier", "ipxwan.identifier",
337 FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
339 { &hf_ipxwan_packet_type,
340 { "Packet Type", "ipxwan.packet_type",
341 FT_UINT8, BASE_DEC, VALS(ipxwan_packet_type_vals), 0x0, NULL,
344 { &hf_ipxwan_node_id,
345 { "Node ID", "ipxwan.node_id", FT_UINT32,
346 BASE_HEX, NULL, 0x0, NULL, HFILL }},
348 { &hf_ipxwan_sequence_number,
349 { "Sequence Number", "ipxwan.sequence_number", FT_UINT8,
350 BASE_DEC, NULL, 0x0, NULL, HFILL }},
352 { &hf_ipxwan_num_options,
353 { "Number of Options", "ipxwan.num_options", FT_UINT8,
354 BASE_DEC, NULL, 0x0, NULL, HFILL }},
356 { &hf_ipxwan_option_num,
357 { "Option Number", "ipxwan.option_num", FT_UINT8,
358 BASE_HEX, VALS(ipxwan_option_num_vals), 0x0, NULL, HFILL }},
360 { &hf_ipxwan_accept_option,
361 { "Accept Option", "ipxwan.accept_option", FT_UINT8,
362 BASE_DEC, VALS(ipxwan_accept_option_vals), 0x0, NULL, HFILL }},
364 { &hf_ipxwan_option_data_len,
365 { "Option Data Length", "ipxwan.option_data_len", FT_UINT16,
366 BASE_DEC, NULL, 0x0, NULL, HFILL }},
368 { &hf_ipxwan_routing_type,
369 { "Routing Type", "ipxwan.routing_type", FT_UINT8,
370 BASE_DEC, VALS(ipxwan_routing_type_vals), 0x0, NULL, HFILL }},
372 { &hf_ipxwan_wan_link_delay,
373 { "WAN Link Delay", "ipxwan.rip_sap_info_exchange.wan_link_delay",
374 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
376 { &hf_ipxwan_common_network_number,
377 { "Common Network Number", "ipxwan.rip_sap_info_exchange.common_network_number",
378 FT_IPXNET, BASE_NONE, NULL, 0x0, NULL, HFILL }},
380 { &hf_ipxwan_router_name,
381 { "Router Name", "ipxwan.rip_sap_info_exchange.router_name",
382 FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
385 { "Delay", "ipxwan.nlsp_information.delay",
386 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
388 { &hf_ipxwan_throughput,
389 { "Throughput", "ipxwan.nlsp_information.throughput",
390 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
392 { &hf_ipxwan_request_size,
393 { "Request Size", "ipxwan.nlsp_raw_throughput_data.request_size",
394 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
396 { &hf_ipxwan_delta_time,
397 { "Delta Time", "ipxwan.nlsp_raw_throughput_data.delta_time",
398 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
400 { &hf_ipxwan_extended_node_id,
401 { "Extended Node ID", "ipxwan.extended_node_id",
402 FT_IPXNET, BASE_NONE, NULL, 0x0, NULL, HFILL }},
404 { &hf_ipxwan_node_number,
405 { "Node Number", "ipxwan.node_number",
406 FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
408 { &hf_ipxwan_compression_type,
409 { "Compression Type", "ipxwan.compression.type",
410 FT_UINT8, BASE_DEC, VALS(ipxwan_compression_type_vals), 0x0,
413 { &hf_ipxwan_compression_options,
414 { "Compression options", "ipxwan.compression.options",
415 FT_UINT8, BASE_HEX, NULL, 0x0,
418 { &hf_ipxwan_compression_slots,
419 { "Number of compression slots", "ipxwan.compression.slots",
420 FT_UINT8, BASE_DEC, NULL, 0x0,
423 { &hf_ipxwan_compression_parameters,
424 { "Option parameters", "ipxwan.compression.parameters",
425 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
427 { &hf_ipxwan_padding,
428 { "Padding", "ipxwan.padding",
429 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
431 { &hf_ipxwan_option_value,
432 { "Option value", "ipxwan.option_value",
433 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
435 static gint *ett[] = {
439 static ei_register_info ei[] = {
440 { &ei_ipxwan_option_data_len, { "ipxwan.option_data_len.invalid", PI_MALFORMED, PI_ERROR, "Wrong length", EXPFILL }},
443 expert_module_t* expert_ipxwan;
445 proto_ipxwan = proto_register_protocol("IPX WAN", "IPX WAN", "ipxwan");
446 proto_register_field_array(proto_ipxwan, hf, array_length(hf));
447 proto_register_subtree_array(ett, array_length(ett));
448 expert_ipxwan = expert_register_protocol(proto_ipxwan);
449 expert_register_field_array(expert_ipxwan, ei, array_length(ei));
453 proto_reg_handoff_ipxwan(void)
455 dissector_handle_t ipxwan_handle;
457 ipxwan_handle = create_dissector_handle(dissect_ipxwan,
459 dissector_add_uint("ipx.socket", IPX_SOCKET_IPXWAN, ipxwan_handle);
463 * Editor modelines - http://www.wireshark.org/tools/modelines.html
468 * indent-tabs-mode: t
471 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
472 * :indentSize=8:tabSize=8:noTabs=false: