2 * Routines for NetWare IPX WAN Protocol
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <epan/packet.h>
29 #include <epan/expert.h>
30 #include "packet-ipx.h"
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
)
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
);
146 ti
= proto_tree_add_item(tree
, proto_ipxwan
, tvb
, 0, -1,
148 ipxwan_tree
= proto_item_add_subtree(ti
, ett_ipxwan
);
152 proto_tree_add_item(ipxwan_tree
, hf_ipxwan_identifier
, tvb
,
153 offset
, 4, ENC_ASCII
|ENC_NA
);
156 packet_type
= tvb_get_guint8(tvb
, offset
);
157 col_add_str(pinfo
->cinfo
, COL_INFO
,
158 val_to_str(packet_type
, ipxwan_packet_type_vals
,
159 "Unknown packet type %u"));
162 proto_tree_add_uint(ipxwan_tree
, hf_ipxwan_packet_type
, tvb
,
163 offset
, 1, packet_type
);
165 proto_tree_add_item(ipxwan_tree
, hf_ipxwan_node_id
, tvb
,
166 offset
, 4, ENC_BIG_ENDIAN
);
168 proto_tree_add_item(ipxwan_tree
, hf_ipxwan_sequence_number
, tvb
,
169 offset
, 1, ENC_BIG_ENDIAN
);
171 num_options
= tvb_get_guint8(tvb
, offset
);
172 proto_tree_add_uint(ipxwan_tree
, hf_ipxwan_num_options
, tvb
,
173 offset
, 1, num_options
);
176 while (num_options
!= 0) {
177 option_number
= tvb_get_guint8(tvb
, offset
);
178 ti
= proto_tree_add_text(ipxwan_tree
, tvb
, offset
, -1,
180 val_to_str(option_number
, ipxwan_option_num_vals
,
182 option_tree
= proto_item_add_subtree(ti
,
185 proto_tree_add_uint(option_tree
, hf_ipxwan_option_num
,
186 tvb
, offset
, 1, option_number
);
188 proto_tree_add_item(option_tree
, hf_ipxwan_accept_option
,
189 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
191 option_data_len
= tvb_get_ntohs(tvb
, offset
);
192 proto_tree_add_uint(option_tree
, hf_ipxwan_option_data_len
,
193 tvb
, offset
, 2, option_data_len
);
195 proto_item_set_len(ti
, option_data_len
+4);
196 switch (option_number
) {
198 case OPT_ROUTING_TYPE
:
199 if (option_data_len
!= 1) {
200 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
201 "Bogus length: %u, should be 1", option_data_len
);
203 proto_tree_add_item(option_tree
,
204 hf_ipxwan_routing_type
, tvb
,
205 offset
, 1, ENC_BIG_ENDIAN
);
209 case OPT_RIP_SAP_INFO_EXCHANGE
:
210 if (option_data_len
!= 54) {
211 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
212 "Bogus length: %u, should be 54", option_data_len
);
214 wan_link_delay
= tvb_get_ntohs(tvb
,
216 proto_tree_add_uint_format_value(option_tree
,
217 hf_ipxwan_wan_link_delay
, tvb
,
218 offset
, 2, wan_link_delay
,
221 proto_tree_add_item(option_tree
,
222 hf_ipxwan_common_network_number
,
223 tvb
, offset
+2, 4, ENC_NA
);
224 proto_tree_add_item(option_tree
,
225 hf_ipxwan_router_name
, tvb
,
226 offset
+6, 48, ENC_ASCII
|ENC_NA
);
230 case OPT_NLSP_INFORMATION
:
231 if (option_data_len
!= 8) {
232 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
233 "Bogus length: %u, should be 8", option_data_len
);
235 delay
= tvb_get_ntohl(tvb
, offset
);
236 proto_tree_add_uint_format_value(option_tree
,
237 hf_ipxwan_delay
, tvb
,
240 throughput
= tvb_get_ntohl(tvb
, offset
);
241 proto_tree_add_uint_format_value(option_tree
,
242 hf_ipxwan_throughput
, tvb
,
243 offset
, 4, throughput
,
249 case OPT_NLSP_RAW_THROUGHPUT_DATA
:
250 if (option_data_len
!= 8) {
251 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
252 "Bogus length: %u, should be 8", option_data_len
);
254 proto_tree_add_item(option_tree
,
255 hf_ipxwan_request_size
, tvb
,
256 offset
, 4, ENC_BIG_ENDIAN
);
257 delta_time
= tvb_get_ntohl(tvb
, offset
);
258 proto_tree_add_uint_format_value(option_tree
,
259 hf_ipxwan_delta_time
, tvb
,
260 offset
, 4, delta_time
,
266 case OPT_EXTENDED_NODE_ID
:
267 if (option_data_len
!= 4) {
268 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
269 "Bogus length: %u, should be 4", option_data_len
);
271 proto_tree_add_item(option_tree
,
272 hf_ipxwan_extended_node_id
, tvb
,
277 case OPT_NODE_NUMBER
:
278 if (option_data_len
!= 6) {
279 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
280 "Bogus length: %u, should be 6", option_data_len
);
282 proto_tree_add_item(option_tree
,
283 hf_ipxwan_node_number
, tvb
,
288 case OPT_COMPRESSION
:
289 if (option_data_len
< 1) {
290 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
291 "Bogus length: %u, should be >= 1", option_data_len
);
293 compression_type
= tvb_get_guint8(tvb
,
295 ti
= proto_tree_add_uint(option_tree
,
296 hf_ipxwan_compression_type
, tvb
,
297 offset
, 1, compression_type
);
298 switch (compression_type
) {
300 case COMP_TYPE_TELEBIT
:
301 if (option_data_len
< 3) {
302 expert_add_info_format(pinfo
, ti
, &ei_ipxwan_option_data_len
,
303 "Bogus length: %u, should be >= 3", option_data_len
);
305 proto_tree_add_item(option_tree
, hf_ipxwan_compression_options
,
306 tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
307 proto_tree_add_item(option_tree
, hf_ipxwan_compression_slots
,
308 tvb
, offset
+2, 1, ENC_BIG_ENDIAN
);
313 proto_tree_add_item(option_tree
, hf_ipxwan_compression_parameters
,
314 tvb
, offset
+1, option_data_len
-1, ENC_NA
);
321 proto_tree_add_item(option_tree
, hf_ipxwan_padding
,
322 tvb
, offset
, option_data_len
, ENC_NA
);
326 proto_tree_add_item(option_tree
, hf_ipxwan_option_value
,
327 tvb
, offset
, option_data_len
, ENC_NA
);
331 offset
+= option_data_len
;
338 proto_register_ipxwan(void)
340 static hf_register_info hf
[] = {
341 { &hf_ipxwan_identifier
,
342 { "Identifier", "ipxwan.identifier",
343 FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
345 { &hf_ipxwan_packet_type
,
346 { "Packet Type", "ipxwan.packet_type",
347 FT_UINT8
, BASE_DEC
, VALS(ipxwan_packet_type_vals
), 0x0, NULL
,
350 { &hf_ipxwan_node_id
,
351 { "Node ID", "ipxwan.node_id", FT_UINT32
,
352 BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
354 { &hf_ipxwan_sequence_number
,
355 { "Sequence Number", "ipxwan.sequence_number", FT_UINT8
,
356 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
358 { &hf_ipxwan_num_options
,
359 { "Number of Options", "ipxwan.num_options", FT_UINT8
,
360 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
362 { &hf_ipxwan_option_num
,
363 { "Option Number", "ipxwan.option_num", FT_UINT8
,
364 BASE_HEX
, VALS(ipxwan_option_num_vals
), 0x0, NULL
, HFILL
}},
366 { &hf_ipxwan_accept_option
,
367 { "Accept Option", "ipxwan.accept_option", FT_UINT8
,
368 BASE_DEC
, VALS(ipxwan_accept_option_vals
), 0x0, NULL
, HFILL
}},
370 { &hf_ipxwan_option_data_len
,
371 { "Option Data Length", "ipxwan.option_data_len", FT_UINT16
,
372 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
374 { &hf_ipxwan_routing_type
,
375 { "Routing Type", "ipxwan.routing_type", FT_UINT8
,
376 BASE_DEC
, VALS(ipxwan_routing_type_vals
), 0x0, NULL
, HFILL
}},
378 { &hf_ipxwan_wan_link_delay
,
379 { "WAN Link Delay", "ipxwan.rip_sap_info_exchange.wan_link_delay",
380 FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
382 { &hf_ipxwan_common_network_number
,
383 { "Common Network Number", "ipxwan.rip_sap_info_exchange.common_network_number",
384 FT_IPXNET
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
386 { &hf_ipxwan_router_name
,
387 { "Router Name", "ipxwan.rip_sap_info_exchange.router_name",
388 FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
391 { "Delay", "ipxwan.nlsp_information.delay",
392 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
394 { &hf_ipxwan_throughput
,
395 { "Throughput", "ipxwan.nlsp_information.throughput",
396 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
398 { &hf_ipxwan_request_size
,
399 { "Request Size", "ipxwan.nlsp_raw_throughput_data.request_size",
400 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
402 { &hf_ipxwan_delta_time
,
403 { "Delta Time", "ipxwan.nlsp_raw_throughput_data.delta_time",
404 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
406 { &hf_ipxwan_extended_node_id
,
407 { "Extended Node ID", "ipxwan.extended_node_id",
408 FT_IPXNET
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
410 { &hf_ipxwan_node_number
,
411 { "Node Number", "ipxwan.node_number",
412 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
414 { &hf_ipxwan_compression_type
,
415 { "Compression Type", "ipxwan.compression.type",
416 FT_UINT8
, BASE_DEC
, VALS(ipxwan_compression_type_vals
), 0x0,
419 { &hf_ipxwan_compression_options
,
420 { "Compression options", "ipxwan.compression.options",
421 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
424 { &hf_ipxwan_compression_slots
,
425 { "Number of compression slots", "ipxwan.compression.slots",
426 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
429 { &hf_ipxwan_compression_parameters
,
430 { "Option parameters", "ipxwan.compression.parameters",
431 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
433 { &hf_ipxwan_padding
,
434 { "Padding", "ipxwan.padding",
435 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
437 { &hf_ipxwan_option_value
,
438 { "Option value", "ipxwan.option_value",
439 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
441 static gint
*ett
[] = {
445 static ei_register_info ei
[] = {
446 { &ei_ipxwan_option_data_len
, { "ipxwan.option_data_len.invalid", PI_MALFORMED
, PI_ERROR
, "Wrong length", EXPFILL
}},
449 expert_module_t
* expert_ipxwan
;
451 proto_ipxwan
= proto_register_protocol("IPX WAN", "IPX WAN", "ipxwan");
452 proto_register_field_array(proto_ipxwan
, hf
, array_length(hf
));
453 proto_register_subtree_array(ett
, array_length(ett
));
454 expert_ipxwan
= expert_register_protocol(proto_ipxwan
);
455 expert_register_field_array(expert_ipxwan
, ei
, array_length(ei
));
459 proto_reg_handoff_ipxwan(void)
461 dissector_handle_t ipxwan_handle
;
463 ipxwan_handle
= create_dissector_handle(dissect_ipxwan
,
465 dissector_add_uint("ipx.socket", IPX_SOCKET_IPXWAN
, ipxwan_handle
);