2 * Routines for DLSw packet dissection (Data Link Switching)
3 * Copyright 2001, Paul Ionescu <paul@acorp.ro>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 /* DLSw dissector ( RFC 1434, RFC 1795, RFC 2166) */
16 #include <epan/packet.h>
17 #include <epan/expert.h>
20 #include "packet-tcp.h"
22 void proto_register_dlsw(void);
23 void proto_reg_handoff_dlsw(void);
25 static dissector_handle_t dlsw_udp_handle
;
26 static dissector_handle_t dlsw_tcp_handle
;
28 static int proto_dlsw
;
29 static int hf_dlsw_flow_control_indication
;
30 static int hf_dlsw_flow_control_ack
;
31 static int hf_dlsw_flow_control_operator
;
32 static int hf_dlsw_flags_explorer_msg
;
33 /* Generated from convert_proto_tree_add_text.pl */
34 static int hf_dlsw_vector_length
;
35 static int hf_dlsw_dlc_header_sa
;
36 static int hf_dlsw_dlc_header_fc_byte
;
37 static int hf_dlsw_target_transport_id
;
38 static int hf_dlsw_error_pointer
;
39 static int hf_dlsw_capabilities_length
;
40 static int hf_dlsw_multicast_version_number
;
41 static int hf_dlsw_frame_direction
;
42 static int hf_dlsw_circuit_priority
;
43 static int hf_dlsw_origin_dlc_port_id
;
44 static int hf_dlsw_protocol_id
;
45 static int hf_dlsw_mac_address_list
;
46 static int hf_dlsw_origin_link_sap
;
47 static int hf_dlsw_header_length
;
48 static int hf_dlsw_dlc_header_ctrl
;
49 static int hf_dlsw_target_dlc_port_id
;
50 static int hf_dlsw_vector_type
;
51 static int hf_dlsw_largest_frame_size
;
52 static int hf_dlsw_error_cause
;
53 static int hf_dlsw_dlc_header_length
;
54 static int hf_dlsw_oui
;
55 static int hf_dlsw_target_dlc
;
56 static int hf_dlsw_dlc_header_ac_byte
;
57 static int hf_dlsw_tcp_connections
;
58 static int hf_dlsw_initial_pacing_window
;
59 static int hf_dlsw_old_message_type
;
60 static int hf_dlsw_capex_type
;
61 static int hf_dlsw_ssp_flags
;
62 static int hf_dlsw_target_mac_address
;
63 static int hf_dlsw_origin_mac_address
;
64 static int hf_dlsw_dlc_header_rif
;
65 static int hf_dlsw_message_type
;
66 static int hf_dlsw_header_number
;
67 static int hf_dlsw_message_length
;
68 static int hf_dlsw_remote_dlc_pid
;
69 static int hf_dlsw_vendor_oui
;
70 static int hf_dlsw_flow_ctrl_byte
;
71 static int hf_dlsw_version
;
72 static int hf_dlsw_version_string
;
73 static int hf_dlsw_dlsw_version
;
74 static int hf_dlsw_remote_dlc
;
75 static int hf_dlsw_origin_dlc
;
76 static int hf_dlsw_origin_transport_id
;
77 static int hf_dlsw_dlc_header_ssap
;
78 static int hf_dlsw_target_link_sap
;
79 static int hf_dlsw_dlc_header_da
;
80 static int hf_dlsw_netbios_name
;
81 static int hf_dlsw_dlc_header_dsap
;
82 static int hf_dlsw_reserved
;
83 static int hf_dlsw_data
;
84 static int hf_dlsw_vector_data
;
85 static int hf_dlsw_unknown_data
;
86 static int hf_dlsw_mac_address_exclusivity
;
87 static int hf_dlsw_netbios_name_exclusivity
;
88 static int hf_dlsw_gds_id
;
89 static int hf_dlsw_sap_list_support
;
90 static int hf_dlsw_sap_list_support_x0
;
91 static int hf_dlsw_sap_list_support_x2
;
92 static int hf_dlsw_sap_list_support_x4
;
93 static int hf_dlsw_sap_list_support_x6
;
94 static int hf_dlsw_sap_list_support_x8
;
95 static int hf_dlsw_sap_list_support_xA
;
96 static int hf_dlsw_sap_list_support_xC
;
97 static int hf_dlsw_sap_list_support_xE
;
100 static int ett_dlsw_header
;
101 static int ett_dlsw_fc
;
102 static int ett_dlsw_sspflags
;
103 static int ett_dlsw_data
;
104 static int ett_dlsw_vector
;
105 static int ett_dlsw_sap_list_support
;
107 static expert_field ei_dlsw_dlc_header_length
;
108 static expert_field ei_dlsw_not_used_for_capex
;
109 static expert_field ei_dlsw_vec_len_invalid
;
111 #define CANUREACH 0x03
112 #define ICANREACH 0x04
113 #define REACH_ACK 0x05
114 #define DGRMFRAME 0x06
115 #define XIDFRAME 0x07
117 #define CONTACTED 0x09
118 #define RESTART_DL 0x10
119 #define DL_RESTARTED 0x11
120 #define ENTER_BUSY 0x0C
121 #define EXIT_BUSY 0x0D
122 #define INFOFRAME 0x0A
124 #define DL_HALTED 0x0F
125 #define NETBIOS_NQ 0x12
126 #define NETBIOS_NR 0x13
127 #define DATAFRAME 0x14
128 #define HALT_DL_NOACK 0x19
129 #define NETBIOS_ANQ 0x1A
130 #define NETBIOS_ANR 0x1B
131 #define KEEPALIVE 0x1D
132 #define CAP_EXCHANGE 0x20
134 #define TEST_CIRCUIT_REQ 0x7A
135 #define TEST_CIRCUIT_RSP 0x7B
137 static const value_string dlsw_type_vals
[] = {
138 { CANUREACH
, "Can U Reach Station-circuit start" },
139 { ICANREACH
, "I Can Reach Station-circuit start" },
140 { REACH_ACK
, "Reach Acknowledgment" },
141 { DGRMFRAME
, "Datagram Frame" },
142 { XIDFRAME
, "XID Frame" },
143 { CONTACT
, "Contact Remote Station" },
144 { CONTACTED
, "Remote Station Contacted" },
145 { RESTART_DL
, "Restart Data Link" },
146 { DL_RESTARTED
, "Data Link Restarted" },
147 { ENTER_BUSY
, "Enter Busy" },
148 { EXIT_BUSY
, "Exit Busy" },
149 { INFOFRAME
, "Information (I) Frame" },
150 { HALT_DL
, "Halt Data Link" },
151 { DL_HALTED
, "Data Link Halted" },
152 { NETBIOS_NQ
, "NETBIOS Name Query-circuit setup" },
153 { NETBIOS_NR
, "NETBIOS Name Recog-circuit setup" },
154 { DATAFRAME
, "Data Frame" },
155 { HALT_DL_NOACK
, "Halt Data Link with no Ack" },
156 { NETBIOS_ANQ
, "NETBIOS Add Name Query" },
157 { NETBIOS_ANR
, "NETBIOS Add Name Response" },
158 { KEEPALIVE
, "Transport Keepalive Message" },
159 { CAP_EXCHANGE
, "Capabilities Exchange" },
160 { IFCM
, "Independent Flow Control Message" },
161 { TEST_CIRCUIT_REQ
, "Test Circuit Request" },
162 { TEST_CIRCUIT_RSP
, "Test Circuit Response" },
165 static const value_string dlsw_version_vals
[] = {
166 { 0x31 , "Version 1 (RFC 1795)" },
167 { 0x32 , "Version 2 (RFC 2166)" },
168 { 0x33 , "Vendor Specific" },
169 { 0x34 , "Vendor Specific" },
170 { 0x35 , "Vendor Specific" },
171 { 0x36 , "Vendor Specific" },
172 { 0x37 , "Vendor Specific" },
173 { 0x38 , "Vendor Specific" },
174 { 0x39 , "Vendor Specific" },
175 { 0x3A , "Vendor Specific" },
176 { 0x3B , "Vendor Specific" },
177 { 0x3C , "Vendor Specific" },
178 { 0x3D , "Vendor Specific" },
179 { 0x3E , "Vendor Specific" },
180 { 0x3F , "Vendor Specific" },
181 { 0x4B , "Pre 1 (RFC 1434)" },
185 static const value_string dlsw_fc_cmd_vals
[] = {
186 { 0x00 , "Repeat Window" },
187 { 0x01 , "Increment Window" },
188 { 0x02 , "Decrement Window" },
189 { 0x03 , "Reset Window" },
190 { 0x04 , "Halve Window" },
194 static const value_string dlsw_capex_type_vals
[] = {
195 { 0x01 , "Capabilities request" },
196 { 0x02 , "Capabilities response" },
200 static const value_string dlsw_frame_direction_vals
[] = {
201 { 0x01 , "Origin DLSw to target DLSw" },
202 { 0x02 , "Target DLSw to origin DLSw" },
206 static const value_string dlsw_vector_vals
[] = {
207 { 0x81 , "Vendor ID Control Vector" },
208 { 0x82 , "DLSw Version Control Vector" },
209 { 0x83 , "Initial Pacing Window Control Vector" },
210 { 0x84 , "Version String Control Vector" },
211 { 0x85 , "Mac Address Exclusivity Control Vector" },
212 { 0x86 , "Supported SAP List Control Vector" },
213 { 0x87 , "TCP Connections Control Vector" },
214 { 0x88 , "NetBIOS Name Exclusivity Control Vector" },
215 { 0x89 , "MAC Address List Control Vector" },
216 { 0x8a , "NetBIOS Name List Control Vector" },
217 { 0x8b , "Vendor Context Control Vector" },
218 { 0x8c , "Multicast Capabilities Control Vector" },
219 { 0x8d , "Reserved for future use" },
220 { 0x8e , "Reserved for future use" },
221 { 0x8f , "Reserved for future use" },
222 { 0x90 , "Reserved for future use" },
223 { 0x91 , "Control Vector" },
224 { 0x92 , "Control Vector" },
225 { 0x93 , "Control Vector" },
226 { 0x94 , "Control Vector" },
227 { 0x95 , "Control Vector" },
228 { 0x96 , "Control Vector" },
232 static const value_string dlsw_pri_vals
[] = {
233 { 0 , "Unsupported" },
234 { 1 , "Low Priority" },
235 { 2 , "Medium Priority" },
236 { 3 , "High Priority" },
237 { 4 , "Highest Priority" },
247 #define DLSW_GDSID_SEND 0x1520
248 #define DLSW_GDSID_ACK 0x1521
249 #define DLSW_GDSID_REF 0x1522
251 static const value_string dlsw_gds_vals
[] = {
252 { DLSW_GDSID_SEND
, "Request Capabilities GDS" },
253 { DLSW_GDSID_ACK
, "Response Capabilities GDS" },
254 { DLSW_GDSID_REF
, "Refuse Capabilities GDS" },
258 static const value_string dlsw_refuse_vals
[] = {
259 { 0x1 , "invalid GDS length for a DLWs Capabilities Exchange Request"},
260 { 0x2 , "invalid GDS id for a DLSw Capabilities Exchange Request"},
261 { 0x3 , "vendor Id control vector is missing"},
262 { 0x4 , "DLSw Version control vector is missing"},
263 { 0x5 , "initial Pacing Window control vector is missing"},
264 { 0x6 , "length of control vectors doesn't correlate to the length of the GDS variable"},
265 { 0x7 , "invalid control vector id"},
266 { 0x8 , "length of control vector invalid"},
267 { 0x9 , "invalid control vector data value"},
268 { 0xa , "duplicate control vector"},
269 { 0xb , "out-of-sequence control vector"},
270 { 0xc , "DLSw Supported SAP List control vector is missing"},
271 { 0xd , "inconsistent DLSw Version, Multicast Capabilities, and TCP Connections CV received on the inbound Capabilities exchange"},
275 #define UDP_PORT_DLSW 2067
276 #define TCP_PORT_DLSW 2065
277 #define DLSW_INFO_HEADER 16
278 #define DLSW_CMD_HEADER 72
281 dissect_dlsw_capex(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, proto_tree
*ti2
);
284 dissect_dlsw_pdu(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
286 unsigned version
,hlen
= 0,mlen
= 0,mtype
,dlchlen
= 0,flags
;
287 proto_tree
*dlsw_tree
, *dlsw_header_tree
= NULL
;
289 proto_tree
*dlsw_flags_tree
,*dlsw_data_tree
;
291 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "DLSw");
293 version
=tvb_get_uint8(tvb
,0);
295 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "DLSw %s",val_to_str_const(version
, dlsw_version_vals
, "Unknown Version"));
297 ti
= proto_tree_add_item(tree
, proto_dlsw
, tvb
, 0, -1, ENC_NA
);
298 dlsw_tree
= proto_item_add_subtree(ti
, ett_dlsw
);
300 hlen
=tvb_get_uint8(tvb
,1);
302 dlsw_header_tree
= proto_tree_add_subtree_format(dlsw_tree
, tvb
, 0, hlen
, ett_dlsw_header
, NULL
,
304 val_to_str_const(version
, dlsw_version_vals
, "Unknown Version"));
306 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_version
, tvb
, 0, 1, ENC_BIG_ENDIAN
);
307 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_header_length
, tvb
, 1, 1, ENC_BIG_ENDIAN
);
308 mlen
=tvb_get_ntohs(tvb
,2);
309 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_message_length
, tvb
, 2, 2, ENC_BIG_ENDIAN
);
310 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_remote_dlc
, tvb
, 4, 4, ENC_BIG_ENDIAN
);
311 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_remote_dlc_pid
, tvb
, 8, 4, ENC_BIG_ENDIAN
);
312 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_reserved
, tvb
, 12, 2, ENC_NA
) ;
314 mtype
=tvb_get_uint8(tvb
,14);
315 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", %s",val_to_str_const(mtype
, dlsw_type_vals
, "Unknown message Type"));
317 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_message_type
, tvb
, 14, 1, ENC_BIG_ENDIAN
);
318 if (mtype
==CAP_EXCHANGE
)
320 proto_tree_add_expert(dlsw_header_tree
, pinfo
, &ei_dlsw_not_used_for_capex
, tvb
, 15, 1);
324 flags
= tvb_get_uint8(tvb
,15);
325 ti2
= proto_tree_add_item(dlsw_header_tree
, hf_dlsw_flow_ctrl_byte
, tvb
, 15, 1, ENC_BIG_ENDIAN
);
326 dlsw_flags_tree
= proto_item_add_subtree(ti2
, ett_dlsw_fc
);
327 proto_tree_add_item(dlsw_flags_tree
, hf_dlsw_flow_control_indication
, tvb
, 15, 1, ENC_BIG_ENDIAN
);
330 proto_tree_add_item(dlsw_flags_tree
, hf_dlsw_flow_control_ack
, tvb
, 15, 1, ENC_BIG_ENDIAN
);
331 proto_tree_add_item(dlsw_flags_tree
, hf_dlsw_flow_control_operator
, tvb
, 15, 1, ENC_BIG_ENDIAN
);
334 if (hlen
!= DLSW_INFO_HEADER
)
336 if (mtype
==CAP_EXCHANGE
)
338 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_protocol_id
, tvb
, 16, 1, ENC_BIG_ENDIAN
);
339 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_header_number
, tvb
, 17, 1, ENC_BIG_ENDIAN
);
340 proto_tree_add_expert(dlsw_header_tree
, pinfo
, &ei_dlsw_not_used_for_capex
, tvb
, 18, 5);
341 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_old_message_type
, tvb
, 23, 1, ENC_BIG_ENDIAN
);
342 proto_tree_add_expert(dlsw_header_tree
, pinfo
, &ei_dlsw_not_used_for_capex
, tvb
, 24, 14);
343 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_capex_type
, tvb
, 38, 1, ENC_BIG_ENDIAN
);
344 proto_tree_add_expert(dlsw_header_tree
, pinfo
, &ei_dlsw_not_used_for_capex
, tvb
, 39, 33);
348 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_protocol_id
, tvb
, 16, 1, ENC_BIG_ENDIAN
);
349 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_header_number
, tvb
, 17, 1, ENC_BIG_ENDIAN
);
350 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_reserved
, tvb
, 18, 2, ENC_NA
) ;
351 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_largest_frame_size
, tvb
, 20, 1, ENC_BIG_ENDIAN
);
352 ti2
= proto_tree_add_item(dlsw_header_tree
, hf_dlsw_ssp_flags
, tvb
, 21, 1, ENC_BIG_ENDIAN
);
353 dlsw_flags_tree
= proto_item_add_subtree(ti2
, ett_dlsw_sspflags
);
354 proto_tree_add_item (dlsw_flags_tree
, hf_dlsw_flags_explorer_msg
, tvb
, 21, 1, ENC_BIG_ENDIAN
);
355 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_circuit_priority
, tvb
, 22, 1, ENC_BIG_ENDIAN
);
356 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_old_message_type
, tvb
, 23, 1, ENC_BIG_ENDIAN
);
357 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_target_mac_address
, tvb
, 24, 6, ENC_NA
);
358 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_origin_mac_address
, tvb
, 30, 6, ENC_NA
);
359 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_origin_link_sap
, tvb
, 36, 1, ENC_BIG_ENDIAN
);
360 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_target_link_sap
, tvb
, 37, 1, ENC_BIG_ENDIAN
);
361 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_frame_direction
, tvb
, 38, 1, ENC_BIG_ENDIAN
);
362 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_reserved
, tvb
, 39, 3, ENC_NA
) ;
363 dlchlen
=tvb_get_ntohs(tvb
,42);
364 ti
= proto_tree_add_item(dlsw_header_tree
, hf_dlsw_dlc_header_length
, tvb
, 42, 2, ENC_BIG_ENDIAN
);
365 if ( dlchlen
> mlen
)
367 expert_add_info_format(pinfo
, ti
, &ei_dlsw_dlc_header_length
,
368 "DLC Header Length = %u (bogus, must be <= message length %u)",dlchlen
, mlen
) ;
371 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_origin_dlc_port_id
, tvb
, 44, 4, ENC_BIG_ENDIAN
);
372 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_origin_dlc
, tvb
, 48, 4, ENC_BIG_ENDIAN
);
373 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_origin_transport_id
, tvb
, 52, 4, ENC_BIG_ENDIAN
);
374 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_target_dlc_port_id
, tvb
, 56, 4, ENC_BIG_ENDIAN
);
375 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_target_dlc
, tvb
, 60, 4, ENC_BIG_ENDIAN
);
376 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_target_transport_id
, tvb
, 64, 4, ENC_BIG_ENDIAN
);
377 proto_tree_add_item(dlsw_header_tree
, hf_dlsw_reserved
, tvb
, 68, 4, ENC_NA
) ;
381 /* end of header dissector */
383 dlsw_data_tree
= proto_tree_add_subtree(dlsw_tree
, tvb
, hlen
, mlen
, ett_dlsw_data
, &ti2
, "DLSw data");
388 dissect_dlsw_capex(tvb_new_subset_length_caplen(tvb
, hlen
, mlen
, -1), pinfo
, dlsw_data_tree
, ti2
);
393 proto_tree_add_item(dlsw_data_tree
, hf_dlsw_data
, tvb
, hlen
, mlen
, ENC_NA
);
399 proto_tree_add_item(dlsw_data_tree
, hf_dlsw_dlc_header_ac_byte
, tvb
, hlen
, 1, ENC_BIG_ENDIAN
);
400 proto_tree_add_item(dlsw_data_tree
, hf_dlsw_dlc_header_fc_byte
, tvb
, hlen
+1, 1, ENC_BIG_ENDIAN
);
401 proto_tree_add_item(dlsw_data_tree
, hf_dlsw_dlc_header_da
, tvb
, hlen
+2, 6, ENC_NA
|ENC_ASCII
);
402 proto_tree_add_item(dlsw_data_tree
, hf_dlsw_dlc_header_sa
, tvb
, hlen
+8, 6, ENC_NA
|ENC_ASCII
);
403 proto_tree_add_item(dlsw_data_tree
, hf_dlsw_dlc_header_rif
, tvb
, hlen
+14, 18, ENC_NA
|ENC_ASCII
);
404 proto_tree_add_item(dlsw_data_tree
, hf_dlsw_dlc_header_dsap
, tvb
, hlen
+32, 1, ENC_BIG_ENDIAN
);
405 proto_tree_add_item(dlsw_data_tree
, hf_dlsw_dlc_header_ssap
, tvb
, hlen
+33, 1, ENC_BIG_ENDIAN
);
406 proto_tree_add_item(dlsw_data_tree
, hf_dlsw_dlc_header_ctrl
, tvb
, hlen
+34, 1, ENC_BIG_ENDIAN
);
408 proto_tree_add_item(dlsw_data_tree
, hf_dlsw_data
, tvb
, hlen
+dlchlen
, mlen
-dlchlen
, ENC_NA
);
411 return tvb_captured_length(tvb
);
415 dlsw_fmt_version( char *result
, uint32_t revision
)
417 snprintf( result
, ITEM_LABEL_LENGTH
, "%d.%02d", (uint8_t)(( revision
& 0xFF00 ) >> 8), (uint8_t)(revision
& 0xFF) );
421 dissect_dlsw_capex(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, proto_tree
*ti2
)
425 uint32_t gdsid
, mlen
,offset
=4;
426 proto_tree
*dlsw_vector_tree
;
427 proto_tree_add_item_ret_uint(tree
, hf_dlsw_capabilities_length
, tvb
, 0, 2, ENC_BIG_ENDIAN
, &mlen
);
428 proto_tree_add_item_ret_uint(tree
, hf_dlsw_gds_id
, tvb
, 2, 2, ENC_BIG_ENDIAN
, &gdsid
);
429 proto_item_append_text(ti2
," - %s",val_to_str_const( gdsid
, dlsw_gds_vals
, "Invalid GDS ID"));
434 proto_tree_add_item(tree
, hf_dlsw_error_pointer
, tvb
, 4, 2, ENC_BIG_ENDIAN
);
435 proto_tree_add_item(tree
, hf_dlsw_error_cause
, tvb
, 6, 2, ENC_BIG_ENDIAN
);
437 case DLSW_GDSID_SEND
:
438 while (offset
< mlen
){
439 vlen
=tvb_get_uint8(tvb
,offset
);
441 proto_tree_add_expert(tree
, pinfo
, &ei_dlsw_vec_len_invalid
, tvb
, offset
, 1);
444 vtype
=tvb_get_uint8(tvb
,offset
+1);
445 dlsw_vector_tree
=proto_tree_add_subtree (tree
,tvb
,offset
,vlen
,ett_dlsw_vector
,NULL
,
446 val_to_str_const(vtype
,dlsw_vector_vals
,"Unknown vector type"));
447 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_vector_length
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
448 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_vector_type
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
451 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_oui
, tvb
, offset
+2, vlen
-2, ENC_BIG_ENDIAN
);
454 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_dlsw_version
, tvb
, offset
+2, 2, ENC_BIG_ENDIAN
);
457 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_initial_pacing_window
, tvb
, offset
+2, vlen
-2, ENC_BIG_ENDIAN
);
460 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_version_string
, tvb
, offset
+2, vlen
-2, ENC_NA
|ENC_ASCII
);
463 tmp8
= tvb_get_uint8(tvb
,offset
+2);
464 proto_tree_add_uint_format_value(dlsw_vector_tree
, hf_dlsw_mac_address_exclusivity
, tvb
,offset
+2, 1,
465 tmp8
, "%s",tmp8
==1?"On":"Off");
470 static int * const flags
[] = {
471 &hf_dlsw_sap_list_support_x0
,
472 &hf_dlsw_sap_list_support_x2
,
473 &hf_dlsw_sap_list_support_x4
,
474 &hf_dlsw_sap_list_support_x6
,
475 &hf_dlsw_sap_list_support_x8
,
476 &hf_dlsw_sap_list_support_xA
,
477 &hf_dlsw_sap_list_support_xC
,
478 &hf_dlsw_sap_list_support_xE
,
482 proto_tree_add_bitmask_with_flags(dlsw_vector_tree
, tvb
, offset
+2+i
, hf_dlsw_sap_list_support
, ett_dlsw_sap_list_support
, flags
, ENC_NA
, BMT_NO_FALSE
);
487 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_tcp_connections
, tvb
, offset
+2, vlen
-2, ENC_BIG_ENDIAN
);
490 tmp8
= tvb_get_uint8(tvb
,offset
+2);
491 proto_tree_add_uint_format_value(dlsw_vector_tree
, hf_dlsw_netbios_name_exclusivity
, tvb
,offset
+2,1,
492 tmp8
, "%s", tmp8
==1?"On":"Off");
495 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_mac_address_list
, tvb
, offset
+2, 6, ENC_NA
);
496 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_mac_address_list
, tvb
, offset
+8, 6, ENC_NA
);
499 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_netbios_name
, tvb
, offset
+2, vlen
-2, ENC_NA
|ENC_ASCII
);
502 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_vendor_oui
, tvb
, offset
+2, vlen
-2, ENC_BIG_ENDIAN
);
505 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_multicast_version_number
, tvb
, offset
+2, vlen
-2, ENC_BIG_ENDIAN
);
508 proto_tree_add_item(dlsw_vector_tree
, hf_dlsw_vector_data
, tvb
, offset
+2, vlen
-2, ENC_NA
);
514 proto_tree_add_item(tree
, hf_dlsw_unknown_data
, tvb
, 4, mlen
- 4, ENC_NA
);
520 dissect_dlsw_udp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
522 if (try_val_to_str(tvb_get_uint8(tvb
, 0), dlsw_version_vals
) == NULL
)
524 /* Probably not a DLSw packet. */
528 return dissect_dlsw_pdu(tvb
, pinfo
, tree
, data
);
532 get_dlsw_pdu_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
, int offset
, void *data _U_
)
537 * Get the length of the DLSw header.
539 hlen
=tvb_get_uint8(tvb
,offset
+1);
542 * Get the length of the DLSw message.
544 mlen
= tvb_get_ntohs(tvb
,offset
+2);
547 * The total length is the sum of those.
553 dissect_dlsw_tcp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
555 if (try_val_to_str(tvb_get_uint8(tvb
, 0), dlsw_version_vals
) == NULL
)
557 /* Probably not a DLSw packet. */
561 tcp_dissect_pdus(tvb
, pinfo
, tree
, true, 4, get_dlsw_pdu_len
, dissect_dlsw_pdu
, data
);
562 return tvb_captured_length(tvb
);
566 proto_register_dlsw(void)
568 static hf_register_info hf
[] = {
569 {&hf_dlsw_flow_control_indication
,
570 {"Flow Control Indication", "dlsw.flow_control_indication", FT_BOOLEAN
, 8, TFS(&tfs_yes_no
), 0x80,
572 {&hf_dlsw_flow_control_ack
,
573 {"Flow Control Acknowledgment", "dlsw.flow_control_ack", FT_BOOLEAN
, 8, TFS(&tfs_yes_no
), 0x40,
575 {&hf_dlsw_flow_control_operator
,
576 {"Flow Control Operator", "dlsw.flow_control_operator", FT_UINT8
, BASE_DEC
, VALS(dlsw_fc_cmd_vals
), 0x07,
578 {&hf_dlsw_flags_explorer_msg
,
579 {"Explorer message", "dlsw.flags.explorer_msg", FT_BOOLEAN
, 8, TFS(&tfs_yes_no
), 0x80,
581 /* Generated from convert_proto_tree_add_text.pl */
582 { &hf_dlsw_version
, { "Version", "dlsw.version", FT_UINT8
, BASE_DEC
, VALS(dlsw_version_vals
), 0x0, NULL
, HFILL
}},
583 { &hf_dlsw_header_length
, { "Header Length", "dlsw.header_length", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
584 { &hf_dlsw_message_length
, { "Message Length", "dlsw.message_length", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
585 { &hf_dlsw_remote_dlc
, { "Remote DLC", "dlsw.remote_dlc", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
586 { &hf_dlsw_remote_dlc_pid
, { "Remote DLC PID", "dlsw.remote_dlc_pid", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
587 { &hf_dlsw_message_type
, { "Message Type", "dlsw.message_type", FT_UINT8
, BASE_HEX
, VALS(dlsw_type_vals
), 0x0, NULL
, HFILL
}},
588 { &hf_dlsw_flow_ctrl_byte
, { "Flow ctrl byte", "dlsw.flow_ctrl_byte", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
589 { &hf_dlsw_protocol_id
, { "Protocol ID", "dlsw.protocol_id", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
590 { &hf_dlsw_header_number
, { "Header Number", "dlsw.header_number", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
591 { &hf_dlsw_old_message_type
, { "Old message type", "dlsw.old_message_type", FT_UINT8
, BASE_HEX
, VALS(dlsw_type_vals
), 0x0, NULL
, HFILL
}},
592 { &hf_dlsw_capex_type
, { "Capability exchange type", "dlsw.capex_type", FT_UINT8
, BASE_HEX
, VALS(dlsw_capex_type_vals
), 0x0, NULL
, HFILL
}},
593 { &hf_dlsw_largest_frame_size
, { "Largest Frame size", "dlsw.largest_frame_size", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
594 { &hf_dlsw_ssp_flags
, { "SSP Flags", "dlsw.flags", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
595 { &hf_dlsw_circuit_priority
, { "Circuit priority", "dlsw.circuit_priority", FT_UINT8
, BASE_DEC
, VALS(dlsw_pri_vals
), 0x7, NULL
, HFILL
}},
596 { &hf_dlsw_target_mac_address
, { "Target MAC Address", "dlsw.target_mac_address", FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
597 { &hf_dlsw_origin_mac_address
, { "Origin MAC Address", "dlsw.origin_mac_address", FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
598 { &hf_dlsw_origin_link_sap
, { "Origin Link SAP", "dlsw.origin_link_sap", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
599 { &hf_dlsw_target_link_sap
, { "Target Link SAP", "dlsw.target_link_sap", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
600 { &hf_dlsw_frame_direction
, { "Frame direction", "dlsw.frame_direction", FT_UINT8
, BASE_HEX
, VALS(dlsw_frame_direction_vals
), 0x0, NULL
, HFILL
}},
601 { &hf_dlsw_dlc_header_length
, { "DLC Header Length", "dlsw.dlc_header_length", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
602 { &hf_dlsw_origin_dlc_port_id
, { "Origin DLC Port ID", "dlsw.origin_dlc_port_id", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
603 { &hf_dlsw_origin_dlc
, { "Origin DLC", "dlsw.origin_dlc", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
604 { &hf_dlsw_origin_transport_id
, { "Origin Transport ID", "dlsw.origin_transport_id", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
605 { &hf_dlsw_target_dlc_port_id
, { "Target DLC Port ID", "dlsw.target_dlc_port_id", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
606 { &hf_dlsw_target_dlc
, { "Target DLC", "dlsw.target_dlc", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
607 { &hf_dlsw_target_transport_id
, { "Target Transport ID", "dlsw.target_transport_id", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
608 { &hf_dlsw_dlc_header_ac_byte
, { "DLC Header - AC byte", "dlsw.dlc_header.ac_byte", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
609 { &hf_dlsw_dlc_header_fc_byte
, { "DLC Header - FC byte", "dlsw.dlc_header.fc_byte", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
610 { &hf_dlsw_dlc_header_da
, { "DLC Header - DA", "dlsw.dlc_header.da", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
611 { &hf_dlsw_dlc_header_sa
, { "DLC Header - SA", "dlsw.dlc_header.sa", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
612 { &hf_dlsw_dlc_header_rif
, { "DLC Header - RIF", "dlsw.dlc_header.rif", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
613 { &hf_dlsw_dlc_header_dsap
, { "DLC Header - DSAP", "dlsw.dlc_header.dsap", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
614 { &hf_dlsw_dlc_header_ssap
, { "DLC Header - SSAP", "dlsw.dlc_header.ssap", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
615 { &hf_dlsw_dlc_header_ctrl
, { "DLC Header - Ctrl", "dlsw.dlc_header.ctrl", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
616 { &hf_dlsw_capabilities_length
, { "Capabilities Length", "dlsw.capabilities_length", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
617 { &hf_dlsw_error_pointer
, { "Error pointer", "dlsw.error_pointer", FT_INT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
618 { &hf_dlsw_error_cause
, { "Error cause", "dlsw.error_cause", FT_UINT16
, BASE_HEX
, VALS(dlsw_refuse_vals
), 0x0, NULL
, HFILL
}},
619 { &hf_dlsw_vector_length
, { "Vector Length", "dlsw.vector_length", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
620 { &hf_dlsw_vector_type
, { "Vector Type", "dlsw.vector_type", FT_UINT8
, BASE_HEX
, VALS(dlsw_vector_vals
), 0x0, NULL
, HFILL
}},
621 { &hf_dlsw_oui
, { "OUI", "dlsw.oui", FT_UINT24
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
622 { &hf_dlsw_initial_pacing_window
, { "Initial Pacing Window", "dlsw.initial_pacing_window", FT_INT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
623 { &hf_dlsw_dlsw_version
, { "DLSw Version", "dlsw.dlsw_version", FT_UINT16
, BASE_CUSTOM
, CF_FUNC(dlsw_fmt_version
), 0x0, NULL
, HFILL
}},
624 { &hf_dlsw_version_string
, { "Version String", "dlsw.version_string", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
625 { &hf_dlsw_tcp_connections
, { "TCP connections", "dlsw.tcp_connections", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
626 { &hf_dlsw_mac_address_list
, { "MAC Address List", "dlsw.mac_address_list", FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
627 { &hf_dlsw_netbios_name
, { "NetBIOS name", "dlsw.netbios_name", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
628 { &hf_dlsw_vendor_oui
, { "Vendor OUI", "dlsw.vendor_oui", FT_UINT24
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
629 { &hf_dlsw_multicast_version_number
, { "Multicast Version Number", "dlsw.multicast_version_number", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
630 { &hf_dlsw_reserved
, { "Reserved", "dlsw.reserved", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
631 { &hf_dlsw_data
, { "Data", "dlsw.data", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
632 { &hf_dlsw_vector_data
, { "Data", "dlsw.vector_data", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
633 { &hf_dlsw_unknown_data
, { "Data", "dlsw.unknown_data", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
634 { &hf_dlsw_mac_address_exclusivity
, { "MAC Address Exclusivity", "dlsw.mac_address_exclusivity", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
635 { &hf_dlsw_netbios_name_exclusivity
, { "NetBIOS Name Exclusivity", "dlsw.netbios_name_exclusivity", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
636 { &hf_dlsw_gds_id
, { "GDS ID", "dlsw.gds_id", FT_UINT16
, BASE_DEC
, VALS(dlsw_gds_vals
), 0x0, NULL
, HFILL
}},
637 { &hf_dlsw_sap_list_support
, { "SAP List Support", "dlsw.sap_list_support", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
638 { &hf_dlsw_sap_list_support_x0
, { "x0", "dlsw.sap_list_support.x0", FT_BOOLEAN
, 8, TFS(&tfs_on_off
), 0x80, NULL
, HFILL
}},
639 { &hf_dlsw_sap_list_support_x2
, { "x2", "dlsw.sap_list_support.x2", FT_BOOLEAN
, 8, TFS(&tfs_on_off
), 0x40, NULL
, HFILL
}},
640 { &hf_dlsw_sap_list_support_x4
, { "x4", "dlsw.sap_list_support.x4", FT_BOOLEAN
, 8, TFS(&tfs_on_off
), 0x20, NULL
, HFILL
}},
641 { &hf_dlsw_sap_list_support_x6
, { "x6", "dlsw.sap_list_support.x6", FT_BOOLEAN
, 8, TFS(&tfs_on_off
), 0x10, NULL
, HFILL
}},
642 { &hf_dlsw_sap_list_support_x8
, { "x8", "dlsw.sap_list_support.x8", FT_BOOLEAN
, 8, TFS(&tfs_on_off
), 0x08, NULL
, HFILL
}},
643 { &hf_dlsw_sap_list_support_xA
, { "xA", "dlsw.sap_list_support.xA", FT_BOOLEAN
, 8, TFS(&tfs_on_off
), 0x04, NULL
, HFILL
}},
644 { &hf_dlsw_sap_list_support_xC
, { "xC", "dlsw.sap_list_support.xC", FT_BOOLEAN
, 8, TFS(&tfs_on_off
), 0x02, NULL
, HFILL
}},
645 { &hf_dlsw_sap_list_support_xE
, { "xE", "dlsw.sap_list_support.xE", FT_BOOLEAN
, 8, TFS(&tfs_on_off
), 0x01, NULL
, HFILL
}},
648 static int *ett
[] = {
655 &ett_dlsw_sap_list_support
,
658 static ei_register_info ei
[] = {
659 { &ei_dlsw_dlc_header_length
, { "dlsw.dlc_header_length.bogus", PI_PROTOCOL
, PI_WARN
, "DLC Header Length bogus", EXPFILL
}},
660 { &ei_dlsw_not_used_for_capex
, { "dlsw.not_used_for_capex", PI_PROTOCOL
, PI_NOTE
, "Not used for CapEx", EXPFILL
}},
661 { &ei_dlsw_vec_len_invalid
, { "dlsw.vec_len_invalid", PI_MALFORMED
, PI_ERROR
, "Invalid vector length (must be >=3)", EXPFILL
}}
664 expert_module_t
* expert_dlsw
;
666 proto_dlsw
= proto_register_protocol("Data Link SWitching", "DLSw", "dlsw");
667 proto_register_field_array(proto_dlsw
, hf
, array_length(hf
));
668 proto_register_subtree_array(ett
, array_length(ett
));
669 expert_dlsw
= expert_register_protocol(proto_dlsw
);
670 expert_register_field_array(expert_dlsw
, ei
, array_length(ei
));
672 dlsw_udp_handle
= register_dissector("dlsw.udp", dissect_dlsw_udp
, proto_dlsw
);
673 dlsw_tcp_handle
= register_dissector("dlsw.tcp", dissect_dlsw_tcp
, proto_dlsw
);
677 proto_reg_handoff_dlsw(void)
679 dissector_add_uint_with_preference("udp.port", UDP_PORT_DLSW
, dlsw_udp_handle
);
680 dissector_add_uint_with_preference("tcp.port", TCP_PORT_DLSW
, dlsw_tcp_handle
);
684 * Editor modelines - https://www.wireshark.org/tools/modelines.html
689 * indent-tabs-mode: nil
692 * ex: set shiftwidth=2 tabstop=8 expandtab:
693 * :indentSize=2:tabSize=8:noTabs=true: