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 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include <epan/packet.h>
14 #include <epan/expert.h>
15 #include <epan/unit_strings.h>
16 #include "packet-ipx.h"
18 void proto_register_ipxwan(void);
19 void proto_reg_handoff_ipxwan(void);
21 static dissector_handle_t ipxwan_handle
;
24 * See RFC 1362 for version 1 of this protocol; see the NetWare Link
25 * Services Protocol Specification, chapter 3, for version 2.
27 static int proto_ipxwan
;
29 static int hf_ipxwan_identifier
;
30 static int hf_ipxwan_packet_type
;
31 static int hf_ipxwan_node_id
;
32 static int hf_ipxwan_sequence_number
;
33 static int hf_ipxwan_num_options
;
34 static int hf_ipxwan_option_num
;
35 static int hf_ipxwan_accept_option
;
36 static int hf_ipxwan_option_data_len
;
37 static int hf_ipxwan_routing_type
;
38 static int hf_ipxwan_wan_link_delay
;
39 static int hf_ipxwan_common_network_number
;
40 static int hf_ipxwan_router_name
;
41 static int hf_ipxwan_delay
;
42 static int hf_ipxwan_throughput
;
43 static int hf_ipxwan_request_size
;
44 static int hf_ipxwan_delta_time
;
45 static int hf_ipxwan_extended_node_id
;
46 static int hf_ipxwan_node_number
;
47 static int hf_ipxwan_compression_type
;
48 static int hf_ipxwan_compression_options
;
49 static int hf_ipxwan_compression_slots
;
50 static int hf_ipxwan_compression_parameters
;
51 static int hf_ipxwan_padding
;
52 static int hf_ipxwan_option_value
;
54 static int ett_ipxwan
;
55 static int ett_ipxwan_option
;
57 static expert_field ei_ipxwan_option_data_len
;
59 static const value_string ipxwan_packet_type_vals
[] = {
60 { 0, "Timer Request" },
61 { 1, "Timer Response" },
62 { 2, "Information Request" },
63 { 3, "Information Response" },
64 { 4, "Throughput Request" },
65 { 5, "Throughput Response" },
66 { 6, "Delay Request" },
67 { 7, "Delay Response" },
72 #define OPT_ROUTING_TYPE 0x00
73 #define OPT_RIP_SAP_INFO_EXCHANGE 0x01
74 #define OPT_NLSP_INFORMATION 0x02
75 #define OPT_NLSP_RAW_THROUGHPUT_DATA 0x03
76 #define OPT_EXTENDED_NODE_ID 0x04
77 #define OPT_NODE_NUMBER 0x05
78 #define OPT_COMPRESSION 0x80
81 static const value_string ipxwan_option_num_vals
[] = {
82 { OPT_ROUTING_TYPE
, "Routing Type" },
83 { OPT_RIP_SAP_INFO_EXCHANGE
, "RIP/SAP Info Exchange" },
84 { OPT_NLSP_INFORMATION
, "NLSP Information" },
85 { OPT_NLSP_RAW_THROUGHPUT_DATA
, "NLSP Raw Throughput Data" },
86 { OPT_EXTENDED_NODE_ID
, "Extended Node ID" },
87 { OPT_NODE_NUMBER
, "Node Number" },
88 { OPT_COMPRESSION
, "Compression" },
93 static const value_string ipxwan_accept_option_vals
[] = {
96 { 3, "Not Applicable" },
100 static const value_string ipxwan_routing_type_vals
[] = {
103 { 2, "Unnumbered RIP" },
104 { 3, "On-demand, static routing" },
105 { 4, "Client-router connection" },
109 #define COMP_TYPE_TELEBIT 0
111 static const value_string ipxwan_compression_type_vals
[] = {
112 { COMP_TYPE_TELEBIT
, "Telebit" },
117 dissect_ipxwan(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
120 proto_tree
*ipxwan_tree
= NULL
;
124 uint8_t option_number
;
125 proto_tree
*option_tree
;
126 uint16_t option_data_len
;
127 uint8_t compression_type
;
129 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "IPX WAN");
130 col_clear(pinfo
->cinfo
, COL_INFO
);
132 ti
= proto_tree_add_item(tree
, proto_ipxwan
, tvb
, 0, -1,
134 ipxwan_tree
= proto_item_add_subtree(ti
, ett_ipxwan
);
136 proto_tree_add_item(ipxwan_tree
, hf_ipxwan_identifier
, tvb
,
137 offset
, 4, ENC_ASCII
);
140 packet_type
= tvb_get_uint8(tvb
, offset
);
141 col_add_str(pinfo
->cinfo
, COL_INFO
,
142 val_to_str(packet_type
, ipxwan_packet_type_vals
,
143 "Unknown packet type %u"));
145 proto_tree_add_uint(ipxwan_tree
, hf_ipxwan_packet_type
, tvb
,
146 offset
, 1, packet_type
);
148 proto_tree_add_item(ipxwan_tree
, hf_ipxwan_node_id
, tvb
,
149 offset
, 4, ENC_BIG_ENDIAN
);
151 proto_tree_add_item(ipxwan_tree
, hf_ipxwan_sequence_number
, tvb
,
152 offset
, 1, ENC_BIG_ENDIAN
);
154 num_options
= tvb_get_uint8(tvb
, offset
);
155 proto_tree_add_uint(ipxwan_tree
, hf_ipxwan_num_options
, tvb
,
156 offset
, 1, num_options
);
159 while (num_options
!= 0) {
160 option_number
= tvb_get_uint8(tvb
, offset
);
161 option_tree
= proto_tree_add_subtree_format(ipxwan_tree
, tvb
, offset
, -1,
162 ett_ipxwan_option
, &ti
, "Option: %s",
163 val_to_str(option_number
, ipxwan_option_num_vals
,
166 proto_tree_add_uint(option_tree
, hf_ipxwan_option_num
,
167 tvb
, offset
, 1, option_number
);
169 proto_tree_add_item(option_tree
, hf_ipxwan_accept_option
,
170 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
172 option_data_len
= tvb_get_ntohs(tvb
, offset
);
173 proto_tree_add_uint(option_tree
, hf_ipxwan_option_data_len
,
174 tvb
, offset
, 2, option_data_len
);
176 proto_item_set_len(ti
, option_data_len
+4);
177 switch (option_number
) {
179 case OPT_ROUTING_TYPE
:
180 if (option_data_len
!= 1) {
181 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
182 "Bogus length: %u, should be 1", option_data_len
);
184 proto_tree_add_item(option_tree
,
185 hf_ipxwan_routing_type
, tvb
,
186 offset
, 1, ENC_BIG_ENDIAN
);
190 case OPT_RIP_SAP_INFO_EXCHANGE
:
191 if (option_data_len
!= 54) {
192 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
193 "Bogus length: %u, should be 54", option_data_len
);
195 proto_tree_add_item(option_tree
,
196 hf_ipxwan_wan_link_delay
, tvb
,
197 offset
, 2, ENC_BIG_ENDIAN
);
198 proto_tree_add_item(option_tree
,
199 hf_ipxwan_common_network_number
,
200 tvb
, offset
+2, 4, ENC_NA
);
201 proto_tree_add_item(option_tree
,
202 hf_ipxwan_router_name
, tvb
,
203 offset
+6, 48, ENC_ASCII
);
207 case OPT_NLSP_INFORMATION
:
208 if (option_data_len
!= 8) {
209 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
210 "Bogus length: %u, should be 8", option_data_len
);
212 proto_tree_add_item(option_tree
,
213 hf_ipxwan_delay
, tvb
,
214 offset
, 4, ENC_BIG_ENDIAN
);
215 proto_tree_add_item(option_tree
,
216 hf_ipxwan_throughput
, tvb
,
217 offset
, 4, ENC_BIG_ENDIAN
);
221 case OPT_NLSP_RAW_THROUGHPUT_DATA
:
222 if (option_data_len
!= 8) {
223 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
224 "Bogus length: %u, should be 8", option_data_len
);
226 proto_tree_add_item(option_tree
,
227 hf_ipxwan_request_size
, tvb
,
228 offset
, 4, ENC_BIG_ENDIAN
);
229 proto_tree_add_item(option_tree
,
230 hf_ipxwan_delta_time
, tvb
,
231 offset
, 4, ENC_BIG_ENDIAN
);
235 case OPT_EXTENDED_NODE_ID
:
236 if (option_data_len
!= 4) {
237 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
238 "Bogus length: %u, should be 4", option_data_len
);
240 proto_tree_add_item(option_tree
,
241 hf_ipxwan_extended_node_id
, tvb
,
246 case OPT_NODE_NUMBER
:
247 if (option_data_len
!= 6) {
248 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
249 "Bogus length: %u, should be 6", option_data_len
);
251 proto_tree_add_item(option_tree
,
252 hf_ipxwan_node_number
, tvb
,
257 case OPT_COMPRESSION
:
258 if (option_data_len
< 1) {
259 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
260 "Bogus length: %u, should be >= 1", option_data_len
);
262 compression_type
= tvb_get_uint8(tvb
,
264 ti
= proto_tree_add_uint(option_tree
,
265 hf_ipxwan_compression_type
, tvb
,
266 offset
, 1, compression_type
);
267 switch (compression_type
) {
269 case COMP_TYPE_TELEBIT
:
270 if (option_data_len
< 3) {
271 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
272 "Bogus length: %u, should be >= 3", option_data_len
);
274 proto_tree_add_item(option_tree
, hf_ipxwan_compression_options
,
275 tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
276 proto_tree_add_item(option_tree
, hf_ipxwan_compression_slots
,
277 tvb
, offset
+2, 1, ENC_BIG_ENDIAN
);
282 proto_tree_add_item(option_tree
, hf_ipxwan_compression_parameters
,
283 tvb
, offset
+1, option_data_len
-1, ENC_NA
);
290 proto_tree_add_item(option_tree
, hf_ipxwan_padding
,
291 tvb
, offset
, option_data_len
, ENC_NA
);
295 proto_tree_add_item(option_tree
, hf_ipxwan_option_value
,
296 tvb
, offset
, option_data_len
, ENC_NA
);
300 offset
+= option_data_len
;
303 return tvb_captured_length(tvb
);
307 proto_register_ipxwan(void)
309 static hf_register_info hf
[] = {
310 { &hf_ipxwan_identifier
,
311 { "Identifier", "ipxwan.identifier",
312 FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
314 { &hf_ipxwan_packet_type
,
315 { "Packet Type", "ipxwan.packet_type",
316 FT_UINT8
, BASE_DEC
, VALS(ipxwan_packet_type_vals
), 0x0, NULL
,
319 { &hf_ipxwan_node_id
,
320 { "Node ID", "ipxwan.node_id", FT_UINT32
,
321 BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
323 { &hf_ipxwan_sequence_number
,
324 { "Sequence Number", "ipxwan.sequence_number", FT_UINT8
,
325 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
327 { &hf_ipxwan_num_options
,
328 { "Number of Options", "ipxwan.num_options", FT_UINT8
,
329 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
331 { &hf_ipxwan_option_num
,
332 { "Option Number", "ipxwan.option_num", FT_UINT8
,
333 BASE_HEX
, VALS(ipxwan_option_num_vals
), 0x0, NULL
, HFILL
}},
335 { &hf_ipxwan_accept_option
,
336 { "Accept Option", "ipxwan.accept_option", FT_UINT8
,
337 BASE_DEC
, VALS(ipxwan_accept_option_vals
), 0x0, NULL
, HFILL
}},
339 { &hf_ipxwan_option_data_len
,
340 { "Option Data Length", "ipxwan.option_data_len", FT_UINT16
,
341 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
343 { &hf_ipxwan_routing_type
,
344 { "Routing Type", "ipxwan.routing_type", FT_UINT8
,
345 BASE_DEC
, VALS(ipxwan_routing_type_vals
), 0x0, NULL
, HFILL
}},
347 { &hf_ipxwan_wan_link_delay
,
348 { "WAN Link Delay", "ipxwan.rip_sap_info_exchange.wan_link_delay",
349 FT_UINT16
, BASE_DEC
|BASE_UNIT_STRING
, UNS(&units_milliseconds
), 0x0, NULL
, HFILL
}},
351 { &hf_ipxwan_common_network_number
,
352 { "Common Network Number", "ipxwan.rip_sap_info_exchange.common_network_number",
353 FT_IPXNET
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
355 { &hf_ipxwan_router_name
,
356 { "Router Name", "ipxwan.rip_sap_info_exchange.router_name",
357 FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
360 { "Delay", "ipxwan.nlsp_information.delay",
361 FT_UINT32
, BASE_DEC
|BASE_UNIT_STRING
, UNS(&units_microseconds
), 0x0, NULL
, HFILL
}},
363 { &hf_ipxwan_throughput
,
364 { "Throughput", "ipxwan.nlsp_information.throughput",
365 FT_UINT32
, BASE_DEC
|BASE_UNIT_STRING
, UNS(&units_microseconds
), 0x0, NULL
, HFILL
}},
367 { &hf_ipxwan_request_size
,
368 { "Request Size", "ipxwan.nlsp_raw_throughput_data.request_size",
369 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
371 { &hf_ipxwan_delta_time
,
372 { "Delta Time", "ipxwan.nlsp_raw_throughput_data.delta_time",
373 FT_UINT32
, BASE_DEC
|BASE_UNIT_STRING
, UNS(&units_microseconds
), 0x0, NULL
, HFILL
}},
375 { &hf_ipxwan_extended_node_id
,
376 { "Extended Node ID", "ipxwan.extended_node_id",
377 FT_IPXNET
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
379 { &hf_ipxwan_node_number
,
380 { "Node Number", "ipxwan.node_number",
381 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
383 { &hf_ipxwan_compression_type
,
384 { "Compression Type", "ipxwan.compression.type",
385 FT_UINT8
, BASE_DEC
, VALS(ipxwan_compression_type_vals
), 0x0,
388 { &hf_ipxwan_compression_options
,
389 { "Compression options", "ipxwan.compression.options",
390 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
393 { &hf_ipxwan_compression_slots
,
394 { "Number of compression slots", "ipxwan.compression.slots",
395 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
398 { &hf_ipxwan_compression_parameters
,
399 { "Option parameters", "ipxwan.compression.parameters",
400 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
402 { &hf_ipxwan_padding
,
403 { "Padding", "ipxwan.padding",
404 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
406 { &hf_ipxwan_option_value
,
407 { "Option value", "ipxwan.option_value",
408 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
410 static int *ett
[] = {
414 static ei_register_info ei
[] = {
415 { &ei_ipxwan_option_data_len
, { "ipxwan.option_data_len.invalid", PI_MALFORMED
, PI_ERROR
, "Wrong length", EXPFILL
}},
418 expert_module_t
* expert_ipxwan
;
420 proto_ipxwan
= proto_register_protocol("IPX WAN", "IPX WAN", "ipxwan");
421 proto_register_field_array(proto_ipxwan
, hf
, array_length(hf
));
422 proto_register_subtree_array(ett
, array_length(ett
));
423 expert_ipxwan
= expert_register_protocol(proto_ipxwan
);
424 expert_register_field_array(expert_ipxwan
, ei
, array_length(ei
));
426 ipxwan_handle
= register_dissector("ipxwan", dissect_ipxwan
, proto_ipxwan
);
430 proto_reg_handoff_ipxwan(void)
432 dissector_add_uint("ipx.socket", IPX_SOCKET_IPXWAN
, ipxwan_handle
);
436 * Editor modelines - https://www.wireshark.org/tools/modelines.html
441 * indent-tabs-mode: t
444 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
445 * :indentSize=8:tabSize=8:noTabs=false: