1 /* packet-q933.c
2  * Routines for Q.933 frame disassembly
3  * Guy Harris <guy@alum.mit.edu>
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  */
11 
12 #include "config.h"
13 
14 #include <epan/packet.h>
15 #include <epan/expert.h>
16 #include <epan/nlpid.h>
17 #include "packet-juniper.h"
18 
19 void proto_register_q933(void);
20 void proto_reg_handoff_q933(void);
21 
22 static int proto_q933 					= -1;
23 static int hf_q933_discriminator			= -1;
24 static int hf_q933_coding_standard			= -1;
25 static int hf_q933_information_transfer_capability	= -1;
26 static int hf_q933_transfer_mode			= -1;
27 static int hf_q933_uil1					= -1;
28 static int hf_q933_call_ref_len 			= -1;
29 static int hf_q933_call_ref_flag 			= -1;
30 static int hf_q933_call_ref 				= -1;
31 static int hf_q933_message_type 			= -1;
32 static int hf_q933_cause_location			= -1;
33 static int hf_q933_cause_value 				= -1;
34 static int hf_q933_number_type				= -1;
35 static int hf_q933_numbering_plan			= -1;
36 static int hf_q933_extension_ind			= -1;
37 static int hf_q933_calling_party_number 		= -1;
38 static int hf_q933_called_party_number 			= -1;
39 static int hf_q933_connected_number 			= -1;
40 /* static int hf_q933_redirecting_number 			= -1; */
41 static int hf_q933_screening_ind			= -1;
42 static int hf_q933_presentation_ind			= -1;
43 static int hf_q933_report_type				= -1;
44 static int hf_q933_link_verf_txseq		       	= -1;
45 static int hf_q933_link_verf_rxseq		       	= -1;
46 static int hf_q933_data		       	        = -1;
47 
48 /* Generated from convert_proto_tree_add_text.pl */
49 static int hf_q933_user_information_layer_3_protocol = -1;
50 static int hf_q933_additional_layer_3_protocol_information = -1;
51 static int hf_q933_network_identification_plan = -1;
52 static int hf_q933_map_element_type = -1;
53 static int hf_q933_channel_type = -1;
54 static int hf_q933_channel_indicated_by = -1;
55 static int hf_q933_extended_audiovisual_characteristics_id = -1;
56 static int hf_q933_location = -1;
57 static int hf_q933_subaddress = -1;
58 static int hf_q933_type_of_network_identification = -1;
59 static int hf_q933_address_inclusion = -1;
60 static int hf_q933_odd_even_indicator = -1;
61 static int hf_q933_reverse_charging_indication = -1;
62 static int hf_q933_call_state = -1;
63 static int hf_q933_user_information_layer_2_protocol = -1;
64 static int hf_q933_packet_window_size = -1;
65 static int hf_q933_locking_shift_to_codeset = -1;
66 static int hf_q933_non_locking_shift_to_codeset = -1;
67 static int hf_q933_not_first_segment = -1;
68 static int hf_q933_user_rate = -1;
69 static int hf_q933_indicated_channel_required = -1;
70 static int hf_q933_high_layer_characteristics_identification = -1;
71 static int hf_q933_rejection_reason = -1;
72 static int hf_q933_progress_description = -1;
73 static int hf_q933_parity = -1;
74 static int hf_q933_extended_high_layer_characteristics_id = -1;
75 static int hf_q933_dlci = -1;
76 static int hf_q933_recommendation = -1;
77 static int hf_q933_mode = -1;
78 static int hf_q933_user_information_str = -1;
79 static int hf_q933_network_service = -1;
80 static int hf_q933_interface_basic = -1;
81 static int hf_q933_missing_information_element = -1;
82 static int hf_q933_information_element = -1;
83 static int hf_q933_condition_normal = -1;
84 static int hf_q933_not_channel_selection = -1;
85 static int hf_q933_network_identification_length = -1;
86 static int hf_q933_segmented_message_type = -1;
87 static int hf_q933_diagnostic = -1;
88 static int hf_q933_user_specified_layer_2_protocol_information = -1;
89 static int hf_q933_interface_identified = -1;
90 static int hf_q933_network_specific_facility_specification = -1;
91 static int hf_q933_data_bits = -1;
92 static int hf_q933_default_packet_size = -1;
93 static int hf_q933_insufficient_information_element = -1;
94 static int hf_q933_modem_type = -1;
95 static int hf_q933_user_information_bytes = -1;
96 static int hf_q933_multiple_frame_establishment = -1;
97 static int hf_q933_duplex = -1;
98 static int hf_q933_mode_of_operation = -1;
99 static int hf_q933_condition = -1;
100 static int hf_q933_status = -1;
101 static int hf_q933_repeat_indicator = -1;
102 static int hf_q933_confirmation = -1;
103 static int hf_q933_default_packet_size_0F = -1;
104 static int hf_q933_interface_identifier = -1;
105 static int hf_q933_stop_bits = -1;
106 static int hf_q933_indicated_channel_d_channel = -1;
107 static int hf_q933_channel_selection = -1;
108 static int hf_q933_user_specific_diagnostic = -1;
109 static int hf_q933_timer = -1;
110 static int hf_q933_first_segment = -1;
111 static int hf_q933_network_identification = -1;
112 static int hf_q933_out_band_negotiation = -1;
113 static int hf_q933_layer_1 = -1;
114 static int hf_q933_type_of_subaddress = -1;
115 static int hf_q933_protocol_discriminator = -1;
116 static int hf_q933_rate_adaption_header = -1;
117 static int hf_q933_reason_for_redirection = -1;
118 static int hf_q933_length = -1;
119 static int hf_q933_diagnostics = -1;
120 static int hf_q933_display_information = -1;
121 static int hf_q933_cumulative_transit_delay = -1;
122 static int hf_q933_requested_end_to_end_transit_delay = -1;
123 static int hf_q933_max_end_to_end_transit_delay = -1;
124 static int hf_q933_transit_delay = -1;
125 static int hf_q933_request = -1;
126 
127 static gint ett_q933 					= -1;
128 static gint ett_q933_ie 				= -1;
129 
130 static expert_field ei_q933_invalid_length = EI_INIT;
131 static expert_field ei_q933_information_element = EI_INIT;
132 
133 static dissector_handle_t q933_handle;
134 
135 /*
136  * Q.933 message types.
137  */
138 #define	Q933_ESCAPE		0x00
139 #define	Q933_ALERTING		0x01
140 #define	Q933_CALL_PROCEEDING	0x02
141 #define	Q933_CONNECT		0x07
142 #define	Q933_CONNECT_ACK	0x0F
143 #define	Q933_PROGRESS		0x03
144 #define	Q933_SETUP		0x05
145 #define	Q933_DISCONNECT		0x45
146 #define	Q933_RELEASE		0x4D
147 #define	Q933_RELEASE_COMPLETE	0x5A
148 #define	Q933_SEGMENT		0x60
149 #define	Q933_STATUS		0x7D
150 #define	Q933_STATUS_ENQUIRY	0x75
151 
152 static const value_string q933_message_type_vals[] = {
153 	{ Q933_ESCAPE,			"ESCAPE" },
154 	{ Q933_ALERTING,		"ALERTING" },
155 	{ Q933_CALL_PROCEEDING,		"CALL PROCEEDING" },
156 	{ Q933_CONNECT,			"CONNECT" },
157 	{ Q933_CONNECT_ACK,		"CONNECT ACKNOWLEDGE" },
158 	{ Q933_PROGRESS,		"PROGRESS" },
159 	{ Q933_SETUP,			"SETUP" },
160 	{ Q933_DISCONNECT,		"DISCONNECT" },
161 	{ Q933_RELEASE,			"RELEASE" },
162 	{ Q933_RELEASE_COMPLETE,	"RELEASE COMPLETE" },
163 	{ Q933_SEGMENT,			"SEGMENT" },
164 	{ Q933_STATUS,			"STATUS" },
165 	{ Q933_STATUS_ENQUIRY,		"STATUS ENQUIRY" },
166 	{ 0,				NULL }
167 };
168 
169 static const true_false_string tfs_call_ref_flag = {
170 	"Message sent to originating side",
171 	"Message sent from originating side"
172 };
173 
174 /*
175  * Information elements.
176  */
177 
178 /* Shifted codeset values */
179 #define CS0 0x000
180 #define CS1 0x100
181 #define CS2 0x200
182 #define CS3 0x300
183 #define CS4 0x400
184 #define CS5 0x500
185 #define CS6 0x600
186 #define CS7 0x700
187 
188 #define	Q933_IE_SO_MASK	0x80	/* single-octet/variable-length mask */
189 /*
190  * Single-octet IEs.
191  */
192 #define	Q933_IE_SO_IDENTIFIER_MASK	0xf0	/* IE identifier mask */
193 #define	Q933_IE_SO_IDENTIFIER_SHIFT	4	/* IE identifier shift */
194 #define	Q933_IE_SO_IE_MASK		0x0F	/* IE mask */
195 
196 #define	Q933_IE_SHIFT			0x90
197 #define	Q933_IE_SHIFT_NON_LOCKING	0x08	/* non-locking shift */
198 #define	Q933_IE_SHIFT_CODESET		0x07	/* codeset */
199 
200 #define	Q933_IE_REPEAT_INDICATOR	0xD0
201 
202 /*
203  * Variable-length IEs.
204  */
205 #define	Q933_IE_VL_EXTENSION		0x80	/* Extension flag */
206 /*	extension bit. The bit value "0" indicates that the octet continues through the		*/
207 /*	next octet. The bit value "1" indicates that this octet is the last octet		*/
208 
209 static const true_false_string q933_extension_ind_value = {
210 	"last octet",
211 	"information continues through the next octet",
212 
213 };
214 
215 
216 /*
217  * Codeset 0 (default).
218  */
219 #define	Q933_IE_SEGMENTED_MESSAGE	0x00
220 #define	Q933_IE_BEARER_CAPABILITY	0x04
221 #define	Q933_IE_CAUSE			0x08
222 #define	Q933_IE_CALL_STATE		0x14
223 #define	Q933_IE_CHANNEL_IDENTIFICATION	0x18
224 #define	Q933_IE_DLCI			0x19
225 #define	Q933_IE_PROGRESS_INDICATOR	0x1E
226 #define	Q933_IE_NETWORK_SPECIFIC_FACIL	0x20	/* Network Specific Facilities */
227 #define	Q933_IE_DISPLAY			0x28
228 #define	Q933_IE_E2E_TRANSIT_DELAY	0x42	/* End-to-end Transit Delay */
229 #define	Q933_IE_TD_SELECTION_AND_INT	0x43	/* Transit Delay Selection and Indication */
230 #define	Q933_IE_PL_BINARY_PARAMETERS	0x44	/* Packet layer binary parameters */
231 #define	Q933_IE_LL_CORE_PARAMETERS	0x48	/* Link layer core parameters */
232 #define	Q933_IE_LL_PROTOCOL_PARAMETERS	0x49	/* Link layer protocol parameters */
233 #define	Q933_IE_REVERSE_CHARGE_IND	0x4A	/* Reverse charging indication */
234 #define	Q933_IE_CONNECTED_NUMBER	0x4C	/* Connected Number */
235 #define	Q933_IE_CONNECTED_SUBADDR	0x4D	/* Connected sub-address */
236 #define	Q933_IE_X_213_PRIORITY		0x50	/* X.213 priority */
237 #define	Q933_IE_REPORT_TYPE		0x51
238 #define	Q933_IE_LINK_INTEGRITY_VERF	0x53	/* Link integrity verification */
239 #define	Q933_IE_PVC_STATUS		0x57
240 #define	Q933_IE_CALLING_PARTY_NUMBER	0x6C	/* Calling Party Number */
241 #define	Q933_IE_CALLING_PARTY_SUBADDR	0x6D	/* Calling Party Subaddress */
242 #define	Q933_IE_CALLED_PARTY_NUMBER	0x70	/* Called Party Number */
243 #define	Q933_IE_CALLED_PARTY_SUBADDR	0x71	/* Called Party Subaddress */
244 #define	Q933_IE_TRANSIT_NETWORK_SEL	0x78	/* Transit Network Selection */
245 #define	Q933_IE_LOW_LAYER_COMPAT	0x7C	/* Low-Layer Compatibility */
246 #define	Q933_IE_HIGH_LAYER_COMPAT	0x7D	/* High-Layer Compatibility */
247 #define	Q933_IE_USER_USER		0x7E	/* User-User */
248 #define	Q933_IE_ESCAPE			0x7F	/* Escape for extension */
249 
250 /* Codeset 0 */
251 static const value_string q933_info_element_vals0[] = {
252 	{ Q933_IE_SEGMENTED_MESSAGE,		"Segmented message" },
253 	{ Q933_IE_BEARER_CAPABILITY,		"Bearer capability" },
254 	{ Q933_IE_CAUSE,			"Cause" },
255 	{ Q933_IE_CALL_STATE,			"Call state" },
256 	{ Q933_IE_CHANNEL_IDENTIFICATION,	"Channel identification" },
257 	{ Q933_IE_DLCI,				"Data link connection identifier" },
258 	{ Q933_IE_PROGRESS_INDICATOR,		"Progress indicator" },
259 	{ Q933_IE_NETWORK_SPECIFIC_FACIL,	"Network specific facilities" },
260 	{ Q933_IE_E2E_TRANSIT_DELAY,		"End-to-end transit delay" },
261 	{ Q933_IE_TD_SELECTION_AND_INT,		"Transit delay selection and indication" },
262 	{ Q933_IE_PL_BINARY_PARAMETERS,		"Packet layer binary parameters" },
263 	{ Q933_IE_LL_CORE_PARAMETERS,		"Link layer core parameters" },
264 	{ Q933_IE_LL_PROTOCOL_PARAMETERS,	"Link layer protocol parameters" },
265 	{ Q933_IE_REVERSE_CHARGE_IND,		"Reverse charging indication" },
266 	{ Q933_IE_CONNECTED_NUMBER,		"Connected number" },
267 	{ Q933_IE_CONNECTED_SUBADDR,		"Connected subaddress" },
268 	{ Q933_IE_X_213_PRIORITY,		"X.213 priority" },
269 	{ Q933_IE_REPORT_TYPE,			"Report type" },
270 	{ Q933_IE_LINK_INTEGRITY_VERF,		"Link integrity verification" },
271 	{ Q933_IE_PVC_STATUS,			"PVC status" },
272 	{ Q933_IE_CALLING_PARTY_NUMBER,		"Calling party number" },
273 	{ Q933_IE_CALLING_PARTY_SUBADDR,	"Calling party subaddress" },
274 	{ Q933_IE_CALLED_PARTY_NUMBER,		"Called party number" },
275 	{ Q933_IE_CALLED_PARTY_SUBADDR,		"Called party subaddress" },
276 	{ Q933_IE_TRANSIT_NETWORK_SEL,		"Transit network selection" },
277 	{ Q933_IE_LOW_LAYER_COMPAT,		"Low-layer compatibility" },
278 	{ Q933_IE_HIGH_LAYER_COMPAT,		"High-layer compatibility" },
279 	{ Q933_IE_USER_USER,			"User-user" },
280 	{ Q933_IE_ESCAPE,			"Escape" },
281 	{ 0,					NULL }
282 };
283 /* Codeset 1 */
284 static const value_string q933_info_element_vals1[] = {
285 	{ 0,					NULL }
286 };
287 /* Codeset 2 */
288 static const value_string q933_info_element_vals2[] = {
289 	{ 0,					NULL }
290 };
291 /* Codeset 3 */
292 static const value_string q933_info_element_vals3[] = {
293 	{ 0,					NULL }
294 };
295 /* Codeset 4 */
296 static const value_string q933_info_element_vals4[] = {
297 	{ 0,					NULL }
298 };
299 
300 /* Codeset 5 */
301 #define Q933_IE_ANSI_REPORT_TYPE         0x01
302 #define Q933_IE_ANSI_LINK_INTEGRITY_VERF 0x03
303 #define Q933_IE_ANSI_PVC_STATUS          0x07
304 
305 /* Codeset 5 */
306 static const value_string q933_info_element_vals5[] = {
307 	{ Q933_IE_ANSI_REPORT_TYPE,             "Report type (ANSI)" },
308 	{ Q933_IE_REPORT_TYPE,                  "Report type (CCITT)" },
309 	{ Q933_IE_ANSI_LINK_INTEGRITY_VERF,     "Keep Alive (ANSI)" },
310 	{ Q933_IE_LINK_INTEGRITY_VERF,          "Keep Alive (CCITT)" },
311 	{ Q933_IE_ANSI_PVC_STATUS,              "PVC Status (ANSI)" },
312 	{ Q933_IE_PVC_STATUS,                   "PVC Status (CCITT)" },
313 	{ 0,					NULL }
314 };
315 /* Codeset 6 */
316 static const value_string q933_info_element_vals6[] = {
317 	{ 0,					NULL }
318 };
319 /* Codeset 7 */
320 static const value_string q933_info_element_vals7[] = {
321 	{ 0,					NULL }
322 };
323 
324 /* Codeset array */
325 #define NUM_INFO_ELEMENT_VALS	(Q933_IE_SHIFT_CODESET+1)
326 static const value_string *q933_info_element_vals[NUM_INFO_ELEMENT_VALS] = {
327 	q933_info_element_vals0,
328 	q933_info_element_vals1,
329 	q933_info_element_vals2,
330 	q933_info_element_vals3,
331 	q933_info_element_vals4,
332 	q933_info_element_vals5,
333 	q933_info_element_vals6,
334 	q933_info_element_vals7,
335 };
336 
337 static const value_string q933_repeat_indication_vals[] = {
338 	{ 0x2, "Prioritized list" },
339 	{ 0,   NULL }
340 };
341 
342 /*
343  * ITU-standardized coding.
344  */
345 #define	Q933_ITU_STANDARDIZED_CODING	0x00
346 
347 /*
348  * Dissect a Segmented message information element.
349  */
350 static void
dissect_q933_segmented_message_ie(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree)351 dissect_q933_segmented_message_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
352 				  proto_tree *tree)
353 {
354 	guint8 octet;
355 	if (len != 2) {
356 		proto_tree_add_expert_format(tree, pinfo, &ei_q933_invalid_length, tvb, offset, len, "Segmented message: length is %d, should be 2", len);
357 		return;
358 	}
359 
360 	octet = tvb_get_guint8(tvb, offset);
361 	if (octet & 0x80) {
362 		proto_tree_add_item(tree, hf_q933_first_segment, tvb, offset, 1, ENC_NA);
363 	} else {
364 		proto_tree_add_item(tree, hf_q933_not_first_segment, tvb, offset, 1, ENC_NA);
365 	}
366 	proto_tree_add_item(tree, hf_q933_segmented_message_type, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
367 }
368 
369 /*
370  * Dissect a Bearer capability or Low-layer compatibility information element.
371  */
372 static const value_string q933_coding_standard_vals[] = {
373 	{ 0x0, "ITU-T standardized coding" },
374 	{ 0x1, "ISO/IEC standard" },
375 	{ 0x2, "National standard" },
376 	{ 0x3, "Standard defined for this particular network" },
377 	{ 0,    NULL }
378 };
379 
380 static const value_string q933_information_transfer_capability_vals[] = {
381 	{ 0x08, "Unrestricted digital information" },
382 	{ 0,    NULL }
383 };
384 
385 static const value_string q933_transfer_mode_vals[] = {
386 	{ 0x01, "Frame mode" },
387 	{ 0,    NULL }
388 };
389 
390 static const value_string q933_uil1_vals[] = {
391 	{ 0x01, "V.110/I.460/X.30 rate adaption" },
392 	{ 0x02, "Recommendation G.711 u-law" },
393 	{ 0x03, "Recommendation G.711 A-law" },
394 	{ 0x04, "Recommendation G.721 32 kbit/s ADPCM and Recommendation I.460" },
395 	{ 0x05, "Recommendation H.221 and H.242" },
396 	{ 0x06, "Recommendation H.223 and H.245" },
397 	{ 0x07, "Non-ITU-T-standardized rate adaption" },
398 	{ 0x08, "V.120 rate adaption" },
399 	{ 0x09, "X.31 HDLC flag stuffing" },
400 	{ 0,    NULL },
401 };
402 
403 static const value_string q933_l1_user_rate_vals[] = {
404 	{ 0x00, "Rate indicated by E-bits" },
405 	{ 0x01, "0.6 kbit/s" },
406 	{ 0x02, "1.2 kbit/s" },
407 	{ 0x03, "2.4 kbit/s" },
408 	{ 0x04, "3.6 kbit/s" },
409 	{ 0x05, "4.8 kbit/s" },
410 	{ 0x06, "7.2 kbit/s" },
411 	{ 0x07, "8 kbit/s" },
412 	{ 0x08, "9.6 kbit/s" },
413 	{ 0x09, "14.4 kbit/s" },
414 	{ 0x0A, "16 kbit/s" },
415 	{ 0x0B, "19.2 kbit/s" },
416 	{ 0x0C, "32 kbit/s" },
417 	{ 0x0E, "48 kbit/s" },
418 	{ 0x0F, "56 kbit/s" },
419 	{ 0x10, "64 kbit/s "},
420 	{ 0x15, "0.1345 kbit/s" },
421 	{ 0x16, "0.100 kbit/s" },
422 	{ 0x17, "0.075/1.2 kbit/s" },
423 	{ 0x18, "1.2/0.075 kbit/s" },
424 	{ 0x19, "0.050 kbit/s" },
425 	{ 0x1A, "0.075 kbit/s" },
426 	{ 0x1B, "0.110 kbit/s" },
427 	{ 0x1C, "0.150 kbit/s" },
428 	{ 0x1D, "0.200 kbit/s" },
429 	{ 0x1E, "0.300 kbit/s" },
430 	{ 0x1F, "12 kbit/s" },
431 	{ 0,    NULL }
432 };
433 
434 static const value_string q933_l1_stop_bits_vals[] = {
435 	{ 0x20, "1" },
436 	{ 0x40, "1.5" },
437 	{ 0x60, "2" },
438 	{ 0,    NULL }
439 };
440 
441 static const value_string q933_l1_data_bits_vals[] = {
442 	{ 0x08, "5" },
443 	{ 0x10, "7" },
444 	{ 0x18, "8" },
445 	{ 0,    NULL }
446 };
447 
448 static const value_string q933_l1_parity_vals[] = {
449 	{ 0x00, "Odd" },
450 	{ 0x02, "Even" },
451 	{ 0x03, "None" },
452 	{ 0x04, "Forced to 0" },
453 	{ 0x05, "Forced to 1" },
454 	{ 0,    NULL }
455 };
456 
457 #define	Q933_UIL2_USER_SPEC	0x10
458 
459 static const value_string q933_uil2_vals[] = {
460 	{ 0x01,			"Basic mode ISO 1745" },
461 	{ 0x06,			"X.25, link level" },
462 	{ 0x07,			"X.25 multilink" },
463 	{ 0x08,			"T.71 Extended LAPB" },
464 	{ 0x09,			"HDLC ARM" },
465 	{ 0x0A,			"HDLC NRM" },
466 	{ 0x0B,			"HDLC ABM" },
467 	{ 0x0C,			"ISO 8802/2 LLC" },
468 	{ 0x0D,			"X.75 Single Link Procedure" },
469 	{ 0x0E,			"Q.922" },
470 	{ 0x0F,			"Core aspects of Q.922" },
471 	{ Q933_UIL2_USER_SPEC,	"User-specified" },
472 	{ 0x11,			"ISO 7776 DTE-DTE operation" },
473 	{ 0,			NULL }
474 };
475 
476 static const value_string q933_address_inclusion_vals[] = {
477 	{ 0x01,			"Address included" },
478 	{ 0x02,			"Encapsulation of logical control frame" },
479 	{ 0,			NULL }
480 };
481 
482 static const value_string q933_mode_vals[] = {
483 	{ 0x20, "Normal mode" },
484 	{ 0x40, "Extended mode" },
485 	{ 0,    NULL }
486 };
487 
488 #define	Q933_UIL3_X25_PL	0x06
489 #define	Q933_UIL3_ISO_8208	0x07	/* X.25-based */
490 #define	Q933_UIL3_X223		0x08	/* X.25-based */
491 #define	Q933_UIL3_TR_9577	0x0B
492 #define	Q933_UIL3_USER_SPEC	0x10
493 
494 static const value_string q933_uil3_vals[] = {
495 	{ Q933_UIL3_X25_PL,	"X.25, packet layer" },
496 	{ Q933_UIL3_ISO_8208,	"ISO/IEC 8208" },
497 	{ Q933_UIL3_X223,	"X.223/ISO 8878" },
498 	{ 0x09,			"ISO/IEC 8473" },
499 	{ 0x0A,			"T.70" },
500 	{ Q933_UIL3_TR_9577,	"ISO/IEC TR 9577" },
501 	{ Q933_UIL3_USER_SPEC,	"User-specified" },
502 	{ 0,			NULL }
503 };
504 
505 static void
dissect_q933_protocol_discriminator(tvbuff_t * tvb,int offset,proto_tree * tree)506 dissect_q933_protocol_discriminator(tvbuff_t *tvb, int offset, proto_tree *tree)
507 {
508 	unsigned int discriminator = tvb_get_guint8(tvb, offset);
509 
510 	if (discriminator == NLPID_Q_933) {
511 		proto_tree_add_uint_format_value(tree, hf_q933_discriminator,
512 			 tvb, offset, 1, discriminator,
513 			 "Q.933");
514 	} else if (discriminator == NLPID_Q_2931) {
515 		proto_tree_add_uint_format_value(tree, hf_q933_discriminator,
516 			 tvb, offset, 1, discriminator,
517 			 "Q.2931");
518 	} else if ((discriminator >= 16 && discriminator < 63)
519 	    || ((discriminator >= 80) && (discriminator < 254))) {
520 		proto_tree_add_uint_format_value(tree, hf_q933_discriminator,
521 		    tvb, offset, 1, discriminator,
522 		    "Network layer or layer 3 protocol (0x%02X)",
523 		    discriminator);
524 	} else if (discriminator >= 64 && discriminator <= 79) {
525 		proto_tree_add_uint_format_value(tree, hf_q933_discriminator,
526 		    tvb, offset, 1, discriminator,
527 		    "National use (0x%02X)",
528 		    discriminator);
529 	} else {
530 		proto_tree_add_uint_format_value(tree, hf_q933_discriminator,
531 		    tvb, offset, 1, discriminator,
532 		    "Reserved (0x%02X)",
533 		    discriminator);
534 	}
535 }
536 
537 static void
dissect_q933_bearer_capability_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)538 dissect_q933_bearer_capability_ie(tvbuff_t *tvb, int offset, int len,
539 				  proto_tree *tree)
540 {
541 	guint8 octet;
542 	guint8 coding_standard;
543 	guint8 uil2_protocol;
544 	guint8 uil3_protocol;
545 
546 	if (len == 0)
547 		return;
548 	octet = tvb_get_guint8(tvb, offset);
549 	coding_standard = octet & 0x60;
550 	if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
551 		/*
552 		 * We don't know how the bearer capability is encoded,
553 		 * so just dump it as data and be done with it.
554 		 */
555 		proto_tree_add_item(tree, hf_q933_data, tvb, offset, len, ENC_NA);
556 		proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
557 		proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
558 		return;
559 	}
560 	proto_tree_add_uint(tree, hf_q933_information_transfer_capability, tvb, offset, 1, octet);
561 	proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
562 	proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
563 	offset += 1;
564 	len -= 1;
565 
566 	/*
567 	 * XXX - only in Low-layer compatibility information element.
568 	 */
569 	if (!(octet & Q933_IE_VL_EXTENSION)) {
570 		if (len == 0)
571 			return;
572 		proto_tree_add_item(tree, hf_q933_out_band_negotiation, tvb, offset, 1, ENC_NA);
573 		offset += 1;
574 		len -= 1;
575 	}
576 
577 	if (len == 0)
578 		return;
579 	octet = tvb_get_guint8(tvb, offset);
580 	proto_tree_add_uint(tree, hf_q933_transfer_mode, tvb, offset, 1, octet);
581 	proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
582 	offset += 1;
583 	len -= 1;
584 
585 	if (len == 0)
586 		return;
587 	octet = tvb_get_guint8(tvb, offset);
588 	if ((octet & 0x60) == 0x20) {
589 		/*
590 		 * Layer 1 information.
591 		 */
592 		proto_tree_add_uint(tree, hf_q933_uil1, tvb, offset, 1, octet);
593 		proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
594 		offset += 1;
595 		len -= 1;
596 
597 		if (octet & Q933_IE_VL_EXTENSION)
598 			goto l1_done;
599 		if (len == 0)
600 			return;
601 		octet = tvb_get_guint8(tvb, offset);
602 		proto_tree_add_item(tree, hf_q933_layer_1, tvb, offset, 1, ENC_NA);
603 		proto_tree_add_item(tree, hf_q933_user_rate, tvb, offset, 1, ENC_BIG_ENDIAN);
604 		offset += 1;
605 		len -= 1;
606 
607 		if (octet & Q933_IE_VL_EXTENSION)
608 			goto l1_done;
609 		if (len == 0)
610 			return;
611 		octet = tvb_get_guint8(tvb, offset);
612 		proto_tree_add_item(tree, hf_q933_rate_adaption_header, tvb, offset, 1, ENC_NA);
613 		proto_tree_add_item(tree, hf_q933_multiple_frame_establishment, tvb, offset, 1, ENC_NA);
614 		proto_tree_add_item(tree, hf_q933_mode_of_operation, tvb, offset, 1, ENC_NA);
615 		offset += 1;
616 		len -= 1;
617 
618 		if (octet & Q933_IE_VL_EXTENSION)
619 			goto l1_done;
620 		if (len == 0)
621 			return;
622 		octet = tvb_get_guint8(tvb, offset);
623 		proto_tree_add_item(tree, hf_q933_stop_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
624 		proto_tree_add_item(tree, hf_q933_data_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
625 		proto_tree_add_item(tree, hf_q933_parity, tvb, offset, 1, ENC_BIG_ENDIAN);
626 		offset += 1;
627 		len -= 1;
628 
629 		if (octet & Q933_IE_VL_EXTENSION)
630 			goto l1_done;
631 		if (len == 0)
632 			return;
633 		proto_tree_add_item(tree, hf_q933_duplex, tvb, offset, 1, ENC_NA);
634 		proto_tree_add_item(tree, hf_q933_modem_type, tvb, offset, 1, ENC_BIG_ENDIAN);
635 		offset += 1;
636 		len -= 1;
637 	}
638 l1_done:
639 	;
640 
641 	if (len == 0)
642 		return;
643 	octet = tvb_get_guint8(tvb, offset);
644 	if ((octet & 0x60) == 0x40) {
645 		/*
646 		 * Layer 2 information.
647 		 */
648 		uil2_protocol = octet & 0x1F;
649 		proto_tree_add_item(tree, hf_q933_user_information_layer_2_protocol, tvb, offset, 1, ENC_BIG_ENDIAN);
650 		offset += 1;
651 		len -= 1;
652 
653 		/*
654 		 * XXX - only in Low-layer compatibility information element.
655 		 */
656 		if (octet & Q933_IE_VL_EXTENSION)
657 			goto l2_done;
658 		if (len == 0)
659 			return;
660 		if (uil2_protocol == Q933_UIL2_USER_SPEC) {
661 			proto_tree_add_item(tree, hf_q933_user_specified_layer_2_protocol_information, tvb, offset, 1, ENC_BIG_ENDIAN);
662 		} else {
663 			proto_tree_add_item(tree, hf_q933_address_inclusion, tvb, offset, 1, ENC_BIG_ENDIAN);
664 		}
665 		offset += 1;
666 		len -= 1;
667 	}
668 l2_done:
669 	;
670 
671 	if (len == 0)
672 		return;
673 	octet = tvb_get_guint8(tvb, offset);
674 	if ((octet & 0x60) == 0x60) {
675 		/*
676 		 * Layer 3 information.
677 		 */
678 		uil3_protocol = octet & 0x1F;
679 		proto_tree_add_item(tree, hf_q933_user_information_layer_3_protocol, tvb, offset, 1, ENC_BIG_ENDIAN);
680 		offset += 1;
681 		len -= 1;
682 
683 
684 		/*
685 		 * XXX - only in Low-layer compatibility information element.
686 		 */
687 		if (octet & Q933_IE_VL_EXTENSION)
688 			goto l3_done;
689 		if (len == 0)
690 			return;
691 		octet = tvb_get_guint8(tvb, offset);
692 		switch (uil3_protocol) {
693 
694 		case Q933_UIL3_X25_PL:
695 		case Q933_UIL3_ISO_8208:
696 		case Q933_UIL3_X223:
697 			proto_tree_add_item(tree, hf_q933_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
698 			offset += 1;
699 			len -= 1;
700 
701 			if (octet & Q933_IE_VL_EXTENSION)
702 				goto l3_done;
703 			if (len == 0)
704 				return;
705 			octet = tvb_get_guint8(tvb, offset);
706 			proto_tree_add_item(tree, hf_q933_default_packet_size_0F, tvb, offset, 1, ENC_BIG_ENDIAN);
707 			offset += 1;
708 			len -= 1;
709 
710 			if (octet & Q933_IE_VL_EXTENSION)
711 				goto l3_done;
712 			if (len == 0)
713 				return;
714 			proto_tree_add_item(tree, hf_q933_packet_window_size, tvb, offset, 1, ENC_BIG_ENDIAN);
715 			/*offset += 1;*/
716 			/*len -= 1;*/
717 			break;
718 
719 		case Q933_UIL3_USER_SPEC:
720 			proto_tree_add_uint_format_value(tree, hf_q933_default_packet_size, tvb, offset, 1,
721 						1 << (octet & 0x0F), "%u octets", 1 << (octet & 0x0F));
722 			/*offset += 1;*/
723 			/*len -= 1;*/
724 			break;
725 
726 		case Q933_UIL3_TR_9577:
727 			if (octet & Q933_IE_VL_EXTENSION)
728 				goto l3_done;
729 #if 0 /* XXX: len is always >0 at this point; is field always 2 bytes (if not Q933_IE_VL_EXTENSION) ? */
730 			if (len == 0)
731 				return;
732 #endif
733 			proto_tree_add_item(tree, hf_q933_additional_layer_3_protocol_information, tvb, offset, 2, ENC_BIG_ENDIAN);
734 			/*offset += 2;*/
735 			/*len -= 2;*/
736 			break;
737 		}
738 	}
739 l3_done:
740 	;
741 }
742 
743 /*
744  * Dissect a Cause information element.
745  */
746 
747 
748 static const value_string q933_cause_location_vals[] = {
749 	{ 0x00, "User (U)" },
750 	{ 0x01, "Private network serving the local user (LPN)" },
751 	{ 0x02, "Public network serving the local user (LN)" },
752 	{ 0x03, "Transit network (TN)" },
753 	{ 0x04, "Public network serving the remote user (RLN)" },
754 	{ 0x05, "Private network serving the remote user (RPN)" },
755 	{ 0x07, "International network (INTL)" },
756 	{ 0x0A, "Network beyond interworking point (BI)" },
757 	{ 0,    NULL }
758 };
759 
760 static const value_string q933_cause_recommendation_vals[] = {
761 	{ 0x00, "Q.933" },
762 	{ 0x03, "X.21" },
763 	{ 0x04, "X.25" },
764 	{ 0x05, "Q.1031/Q.1051" },
765 	{ 0,    NULL }
766 };
767 
768 /*
769  * Cause codes for Cause.
770  */
771 #define	Q933_CAUSE_UNALLOC_NUMBER	0x01
772 #define	Q933_CAUSE_NO_ROUTE_TO_DEST	0x03
773 #define	Q933_CAUSE_CALL_REJECTED	0x15
774 #define	Q933_CAUSE_NUMBER_CHANGED	0x16
775 #define	Q933_CAUSE_ACCESS_INFO_DISC	0x2B
776 #define	Q933_CAUSE_QOS_UNAVAILABLE	0x31
777 #define	Q933_CAUSE_CHAN_NONEXISTENT	0x52
778 #define	Q933_CAUSE_INCOMPATIBLE_DEST	0x58
779 #define	Q933_CAUSE_MAND_IE_MISSING	0x60
780 #define	Q933_CAUSE_MT_NONEX_OR_UNIMPL	0x61
781 #define	Q933_CAUSE_IE_NONEX_OR_UNIMPL	0x63
782 #define	Q933_CAUSE_INVALID_IE_CONTENTS	0x64
783 #define	Q933_CAUSE_MSG_INCOMPAT_W_CS	0x65
784 #define	Q933_CAUSE_REC_TIMER_EXP	0x66
785 
786 static const value_string q933_cause_code_vals[] = {
787 	{ 0x00,				"Valid cause code not yet received" },
788 	{ Q933_CAUSE_UNALLOC_NUMBER,	"Unallocated (unassigned) number" },
789 	{ 0x02,				"No route to specified transit network" },
790 	{ Q933_CAUSE_NO_ROUTE_TO_DEST,	"No route to destination" },
791 	{ 0x04,				"Send special information tone" },
792 	{ 0x05,				"Misdialled trunk prefix" },
793 	{ 0x06,				"Channel unacceptable" },
794 	{ 0x07,				"Call awarded and being delivered in an established channel" },
795 	{ 0x08,				"Prefix 0 dialed but not allowed" },
796 					/* Q.850 - "Preemption" */
797 	{ 0x09,				"Prefix 1 dialed but not allowed" },
798 					/* Q.850 - "Preemption - circuit reserved for reuse" */
799 	{ 0x0A,				"Prefix 1 dialed but not required" },
800 	{ 0x0B,				"More digits received than allowed, call is proceeding" },
801 	{ 0x0E,				"QoR: ported number" },
802 	{ 0x10,				"Normal call clearing" },
803 	{ 0x11,				"User busy" },
804 	{ 0x12,				"No user responding" },
805 	{ 0x13,				"No answer from user (user alerted)" },
806 	{ 0x14,				"Subscriber absent" },
807 	{ Q933_CAUSE_CALL_REJECTED,	"Call rejected" },
808 	{ Q933_CAUSE_NUMBER_CHANGED,	"Number changed" },
809 	{ 0x17,				"Reverse charging rejected" },
810 					/* Q.850 - "Redirection to new destination" */
811 	{ 0x18,				"Call suspended" },
812 					/* Q.850 Amendment 1 - "Call rejected due to feature at the destination" */
813 	{ 0x19,				"Call resumed" },
814 					/* Q.850 - "Exchange routing error */
815 	{ 0x1A,				"Non-selected user clearing" },
816 	{ 0x1B,				"Destination out of order" },
817 	{ 0x1C,				"Invalid number format (incomplete number)" },
818 	{ 0x1D,				"Facility rejected" },
819 	{ 0x1E,				"Response to STATUS ENQUIRY" },
820 	{ 0x1F,				"Normal unspecified" },
821 	{ 0x21,				"Circuit out of order" },
822 	{ 0x22,				"No circuit/channel available" },
823 	{ 0x23,				"Destination unattainable" },
824 	{ 0x25,				"Degraded service" },
825 	{ 0x26,				"Network out of order" },
826 	{ 0x27,				"Transit delay range cannot be achieved" },
827 					/* Q.850 - "Permanent frame mode connection out of service" */
828 	{ 0x28,				"Throughput range cannot be achieved" },
829 					/* Q.850 - "Permanent frame mode connection operational" */
830 	{ 0x29,				"Temporary failure" },
831 	{ 0x2A,				"Switching equipment congestion" },
832 	{ Q933_CAUSE_ACCESS_INFO_DISC,	"Access information discarded" },
833 	{ 0x2C,				"Requested circuit/channel not available" },
834 	{ 0x2D,				"Pre-empted" },
835 	{ 0x2E,				"Precedence call blocked" },
836 	{ 0x2F,				"Resources unavailable, unspecified" },
837 	{ Q933_CAUSE_QOS_UNAVAILABLE,	"Quality of service unavailable" },
838 	{ 0x32,				"Requested facility not subscribed" },
839 	{ 0x33,				"Reverse charging not allowed" },
840 	{ 0x34,				"Outgoing calls barred" },
841 	{ 0x35,				"Outgoing calls barred within CUG" },
842 	{ 0x36,				"Incoming calls barred" },
843 	{ 0x37,				"Incoming calls barred within CUG" },
844 	{ 0x38,				"Call waiting not subscribed" },
845 	{ 0x39,				"Bearer capability not authorized" },
846 	{ 0x3A,				"Bearer capability not presently available" },
847 	{ 0x3E,				"Inconsistency in designated outgoing access information and subscriber class" },
848 	{ 0x3F,				"Service or option not available, unspecified" },
849 	{ 0x41,				"Bearer capability not implemented" },
850 	{ 0x42,				"Channel type not implemented" },
851 	{ 0x43,				"Transit network selection not implemented" },
852 	{ 0x44,				"Message not implemented" },
853 	{ 0x45,				"Requested facility not implemented" },
854 	{ 0x46,				"Only restricted digital information bearer capability is available" },
855 	{ 0x4F,				"Service or option not implemented, unspecified" },
856 	{ 0x51,				"Invalid call reference value" },
857 	{ Q933_CAUSE_CHAN_NONEXISTENT,	"Identified channel does not exist" },
858 	{ 0x53,				"Call identity does not exist for suspended call" },
859 	{ 0x54,				"Call identity in use" },
860 	{ 0x55,				"No call suspended" },
861 	{ 0x56,				"Call having the requested call identity has been cleared" },
862 	{ 0x57,				"Called user not member of CUG" },
863 	{ Q933_CAUSE_INCOMPATIBLE_DEST,	"Incompatible destination" },
864 	{ 0x59,				"Non-existent abbreviated address entry" },
865 	{ 0x5A,				"Destination address missing, and direct call not subscribed" },
866 					/* Q.850 - "Non-existent CUG" */
867 	{ 0x5B,				"Invalid transit network selection (national use)" },
868 	{ 0x5C,				"Invalid facility parameter" },
869 	{ 0x5D,				"Mandatory information element is missing" },
870 	{ 0x5F,				"Invalid message, unspecified" },
871 	{ Q933_CAUSE_MAND_IE_MISSING,	"Mandatory information element is missing" },
872 	{ Q933_CAUSE_MT_NONEX_OR_UNIMPL,"Message type non-existent or not implemented" },
873 	{ 0x62,				"Message not compatible with call state or message type non-existent or not implemented" },
874 	{ Q933_CAUSE_IE_NONEX_OR_UNIMPL,"Information element non-existent or not implemented" },
875 	{ Q933_CAUSE_INVALID_IE_CONTENTS,"Invalid information element contents" },
876 	{ Q933_CAUSE_MSG_INCOMPAT_W_CS,	"Message not compatible with call state" },
877 	{ Q933_CAUSE_REC_TIMER_EXP,	"Recovery on timer expiry" },
878 	{ 0x67,				"Parameter non-existent or not implemented - passed on" },
879 	{ 0x6E,				"Message with unrecognized parameter discarded" },
880 	{ 0x6F,				"Protocol error, unspecified" },
881 	{ 0x7F,				"Internetworking, unspecified" },
882 	{ 0,				NULL }
883 };
884 
885 static const value_string q933_cause_condition_vals[] = {
886 	{ 0x00, "Unknown" },
887 	{ 0x01, "Permanent" },
888 	{ 0x02, "Transient" },
889 	{ 0x00, NULL }
890 };
891 
892 #define	Q933_REJ_USER_SPECIFIC		0x00
893 #define	Q933_REJ_IE_MISSING		0x04
894 #define	Q933_REJ_IE_INSUFFICIENT	0x08
895 
896 static const value_string q933_rejection_reason_vals[] = {
897 	{ 0x00, "User specific" },
898 	{ 0x04, "Information element missing" },
899 	{ 0x08, "Information element contents are not sufficient" },
900 	{ 0x00, NULL }
901 };
902 
903 
904 static void
dissect_q933_cause_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree,int hf_cause_value)905 dissect_q933_cause_ie(tvbuff_t *tvb, int offset, int len,
906 		      proto_tree *tree, int hf_cause_value)
907 {
908 	guint8 octet;
909 	guint8 cause_value;
910 	guint8 coding_standard;
911 	guint8 rejection_reason;
912 
913 	if (len == 0)
914 		return;
915 	octet = tvb_get_guint8(tvb, offset);
916 	coding_standard = octet & 0x60;
917 	if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
918 		/*
919 		 * We don't know how the cause is encoded,
920 		 * so just dump it as data and be done with it.
921 		 */
922 		proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
923 		proto_tree_add_item(tree, hf_q933_data, tvb, offset, len, ENC_NA);
924 		return;
925 	}
926 	proto_tree_add_uint(tree, hf_q933_cause_location, tvb, offset, 1, octet);
927 	proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
928 	proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
929 	offset += 1;
930 	len -= 1;
931 
932 	if (!(octet & Q933_IE_VL_EXTENSION)) {
933 		if (len == 0)
934 			return;
935 		octet = tvb_get_guint8(tvb, offset);
936 		proto_tree_add_item(tree, hf_q933_recommendation, tvb, offset, 1, ENC_BIG_ENDIAN);
937 		proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
938 		offset += 1;
939 		len -= 1;
940 	}
941 
942 	if (len == 0)
943 		return;
944 	octet = tvb_get_guint8(tvb, offset);
945 	cause_value = octet & 0x7F;
946 	proto_tree_add_uint(tree, hf_cause_value, tvb, offset, 1, cause_value);
947 	proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
948 	offset += 1;
949 	len -= 1;
950 
951 	if (len == 0)
952 		return;
953 	switch (cause_value) {
954 
955 	case Q933_CAUSE_UNALLOC_NUMBER:
956 	case Q933_CAUSE_NO_ROUTE_TO_DEST:
957 	case Q933_CAUSE_QOS_UNAVAILABLE:
958 		proto_tree_add_item(tree, hf_q933_network_service, tvb, offset, 1, ENC_NA);
959 		proto_tree_add_item(tree, hf_q933_condition_normal, tvb, offset, 1, ENC_NA);
960 		proto_tree_add_item(tree, hf_q933_condition, tvb, offset, 1, ENC_BIG_ENDIAN);
961 		break;
962 
963 	case Q933_CAUSE_CALL_REJECTED:
964 		rejection_reason = octet & 0x7C;
965 		proto_tree_add_item(tree, hf_q933_rejection_reason, tvb, offset, 1, ENC_BIG_ENDIAN);
966 		proto_tree_add_item(tree, hf_q933_condition, tvb, offset, 1, ENC_BIG_ENDIAN);
967 		offset += 1;
968 		len -= 1;
969 
970 		if (len == 0)
971 			return;
972 		switch (rejection_reason) {
973 
974 		case Q933_REJ_USER_SPECIFIC:
975 			proto_tree_add_item(tree, hf_q933_user_specific_diagnostic, tvb, offset, len, ENC_NA);
976 			break;
977 
978 		case Q933_REJ_IE_MISSING:
979 			proto_tree_add_item(tree, hf_q933_missing_information_element, tvb, offset, 1, ENC_BIG_ENDIAN);
980 			break;
981 
982 		case Q933_REJ_IE_INSUFFICIENT:
983 			proto_tree_add_item(tree, hf_q933_insufficient_information_element, tvb, offset, 1, ENC_BIG_ENDIAN);
984 			break;
985 
986 		default:
987 			proto_tree_add_item(tree, hf_q933_diagnostic, tvb, offset, len, ENC_NA);
988 			break;
989 		}
990 		break;
991 
992 	case Q933_CAUSE_ACCESS_INFO_DISC:
993 	case Q933_CAUSE_INCOMPATIBLE_DEST:
994 	case Q933_CAUSE_MAND_IE_MISSING:
995 	case Q933_CAUSE_IE_NONEX_OR_UNIMPL:
996 	case Q933_CAUSE_INVALID_IE_CONTENTS:
997 		do {
998 			proto_tree_add_item(tree, hf_q933_information_element, tvb, offset, 1, ENC_BIG_ENDIAN);
999 			offset += 1;
1000 			len -= 1;
1001 		} while (len != 0);
1002 		break;
1003 
1004 	case Q933_CAUSE_MT_NONEX_OR_UNIMPL:
1005 	case Q933_CAUSE_MSG_INCOMPAT_W_CS:
1006 		proto_tree_add_item(tree, hf_q933_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1007 		break;
1008 
1009 	case Q933_CAUSE_REC_TIMER_EXP:
1010 		if (len < 3)
1011 			return;
1012 		proto_tree_add_item(tree, hf_q933_timer, tvb, offset, 3, ENC_ASCII|ENC_NA);
1013 		break;
1014 
1015 	default:
1016 		proto_tree_add_item(tree, hf_q933_diagnostics, tvb, offset, len, ENC_NA);
1017 	}
1018 }
1019 
1020 /*
1021  * Dissect a Call state information element.
1022  */
1023 static const value_string q933_call_state_vals[] = {
1024 	{ 0x00, "Null" },
1025 	{ 0x01, "Call initiated" },
1026 	{ 0x02, "Overlap sending" },
1027 	{ 0x03, "Outgoing call proceeding" },
1028 	{ 0x04, "Call delivered" },
1029 	{ 0x06, "Call present" },
1030 	{ 0x07, "Call received" },
1031 	{ 0x08, "Connect request" },
1032 	{ 0x09, "Incoming call proceeding" },
1033 	{ 0x0A, "Active" },
1034 	{ 0x0B, "Disconnect request" },
1035 	{ 0x0C, "Disconnect indication" },
1036 	{ 0x0F, "Suspend request" },
1037 	{ 0x12, "Resume request" },
1038 	{ 0x13, "Release request" },
1039 	{ 0x16, "Call abort"},
1040 	{ 0x19, "Overlap receiving" },
1041 	{ 0x3D, "Restart request" },
1042 	{ 0x3E, "Restart" },
1043 	{ 0,    NULL }
1044 };
1045 
1046 static void
dissect_q933_call_state_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1047 dissect_q933_call_state_ie(tvbuff_t *tvb, int offset, int len,
1048 			   proto_tree *tree)
1049 {
1050 	guint8 octet;
1051 	guint8 coding_standard;
1052 
1053 	if (len == 0)
1054 		return;
1055 	octet = tvb_get_guint8(tvb, offset);
1056 	coding_standard = octet & 0x60;
1057 	proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
1058 	if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
1059 		/*
1060 		 * We don't know how the call state is encoded,
1061 		 * so just dump it as data and be done with it.
1062 		 */
1063 		proto_tree_add_item(tree, hf_q933_data, tvb, offset, len, ENC_NA);
1064 		return;
1065 	}
1066 	proto_tree_add_item(tree, hf_q933_call_state, tvb, offset, 1, ENC_BIG_ENDIAN);
1067 }
1068 
1069 /*
1070  * Dissect a Report Type information element.
1071  */
1072 #define Q933_IE_REPORT_TYPE_FULL_STATUS 0x00
1073 #define Q933_IE_REPORT_TYPE_LINK_VERIFY 0x01
1074 #define Q933_IE_REPORT_TYPE_ASYNC_PVC_STATUS 0x02
1075 
1076 static const value_string q933_report_type_vals[] = {
1077 	{ Q933_IE_REPORT_TYPE_FULL_STATUS, "Full Status" },
1078 	{ Q933_IE_REPORT_TYPE_LINK_VERIFY, "Link verify" },
1079 	{ Q933_IE_REPORT_TYPE_ASYNC_PVC_STATUS, "Async PVC Status" },
1080 	{ 0,    NULL }
1081 };
1082 
1083 static void
dissect_q933_report_type_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1084 dissect_q933_report_type_ie(tvbuff_t *tvb, int offset, int len,
1085 			    proto_tree *tree)
1086 {
1087 	guint8 report_type;
1088 
1089 	if (len == 0)
1090 		return;
1091 
1092 	report_type = tvb_get_guint8(tvb, offset);
1093 	proto_tree_add_uint(tree, hf_q933_report_type, tvb, offset, 1, report_type);
1094 }
1095 
1096 /*
1097  * Dissect a Link Integrity Verification information element.
1098  */
1099 static void
dissect_q933_link_integrity_verf_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1100 dissect_q933_link_integrity_verf_ie(tvbuff_t *tvb, int offset, int len,
1101 				    proto_tree *tree)
1102 {
1103 	guint8 txseq,rxseq;
1104 
1105 	if (len < 2)
1106 		return;
1107 
1108 	txseq = tvb_get_guint8(tvb, offset);
1109 	rxseq = tvb_get_guint8(tvb, offset+1);
1110 
1111 	proto_tree_add_uint(tree, hf_q933_link_verf_txseq, tvb, offset, 1, txseq);
1112 	proto_tree_add_uint(tree, hf_q933_link_verf_rxseq, tvb, offset+1, 1, rxseq);
1113 
1114 }
1115 
1116 /*
1117  * Dissect a PVC status information element.
1118  */
1119 static const value_string q933_pvc_status_vals[] = {
1120 	{0x00, "Inactive"},
1121 	{0x01, "Active"},
1122 	{0x02, "Deleted"},
1123 	{0x04, "New"},
1124 	{0x05, "New, Active"},
1125 	{0, NULL}
1126 };
1127 
1128 static void
dissect_q933_pvc_status_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1129 dissect_q933_pvc_status_ie(tvbuff_t *tvb, int offset, int len,
1130 			   proto_tree *tree)
1131 {
1132 	guint32 dlci;
1133 	guint8 dlci_len=2;
1134 
1135 	if (len < 3)
1136 		return;
1137 
1138 	dlci = ((tvb_get_guint8(tvb, offset) & 0x3F) << 4) |
1139 		((tvb_get_guint8(tvb, offset+1) & 0x78) >> 3);
1140 
1141 	/* first determine the DLCI field length */
1142 	if (len == 4) {
1143 		dlci = (dlci << 6) | ((tvb_get_guint8(tvb, offset+2) & 0x7E) >> 1);
1144 		dlci_len++;
1145 	} else if (len == 5) {
1146 		dlci = (dlci << 13) | (tvb_get_guint8(tvb, offset+3) & 0x7F) |
1147 			((tvb_get_guint8(tvb, offset+4) & 0x7E) >> 1);
1148 		dlci_len+=2;
1149 	}
1150 
1151 	proto_tree_add_uint(tree, hf_q933_dlci, tvb, offset, dlci_len, dlci);
1152 	proto_tree_add_item(tree, hf_q933_status, tvb, offset+dlci_len, 1, ENC_BIG_ENDIAN);
1153 }
1154 
1155 /*
1156  * Dissect a Channel identification information element.
1157  */
1158 #define	Q933_INTERFACE_IDENTIFIED	0x40
1159 #define	Q933_NOT_BASIC_CHANNEL		0x20
1160 
1161 static const value_string q933_basic_channel_selection_vals[] = {
1162 	{ 0x00, "No channel" },
1163 	{ 0x01, "B1 channel" },
1164 	{ 0x02, "B2 channel" },
1165 	{ 0x03, "Any channel" },
1166 	{ 0,    NULL }
1167 };
1168 
1169 static const value_string q933_not_basic_channel_selection_vals[] = {
1170 	{ 0x00, "No channel" },
1171 	{ 0x01, "Channel indicated in following octets" },
1172 	{ 0x03, "Any channel" },
1173 	{ 0,    NULL }
1174 };
1175 
1176 #define	Q933_IS_SLOT_MAP		0x10
1177 
1178 static const value_string q933_element_type_vals[] = {
1179 	{ 0x03, "B-channel units" },
1180 	{ 0x06, "H0-channel units" },
1181 	{ 0x08, "H11-channel units" },
1182 	{ 0x09, "H12-channel units" },
1183 	{ 0,    NULL }
1184 };
1185 
1186 static const true_false_string tfs_explicitly_implicitly_identified = { "Explicitly identified", "Implicitly identified" };
1187 static const true_false_string tfs_not_basic_basic = { "Not basic", "Basic" };
1188 static const true_false_string tfs_required_preferred = { "Required", "Preferred" };
1189 static const true_false_string tfs_dchannel_not_dchannel = { "D-channel", "Not D-channel" };
1190 static const true_false_string tfs_slot_map_number = { "slot map", "number" };
1191 
1192 
1193 static void
dissect_q933_channel_identification_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1194 dissect_q933_channel_identification_ie(tvbuff_t *tvb, int offset, int len,
1195 				       proto_tree *tree)
1196 {
1197 	guint8 octet;
1198 	int identifier_offset;
1199 	int identifier_len;
1200 	guint8 coding_standard;
1201 
1202 	if (len == 0)
1203 		return;
1204 	octet = tvb_get_guint8(tvb, offset);
1205 	proto_tree_add_item(tree, hf_q933_interface_identified, tvb, offset, 1, ENC_NA);
1206 	proto_tree_add_item(tree, hf_q933_interface_basic, tvb, offset, 1, ENC_NA);
1207 	proto_tree_add_item(tree, hf_q933_indicated_channel_required, tvb, offset, 1, ENC_NA);
1208 	proto_tree_add_item(tree, hf_q933_indicated_channel_d_channel, tvb, offset, 1, ENC_NA);
1209 	if (octet & Q933_NOT_BASIC_CHANNEL) {
1210 		proto_tree_add_item(tree, hf_q933_not_channel_selection, tvb, offset, 1, ENC_BIG_ENDIAN);
1211 	} else {
1212 		proto_tree_add_item(tree, hf_q933_channel_selection, tvb, offset, 1, ENC_BIG_ENDIAN);
1213 	}
1214 	offset += 1;
1215 	len -= 1;
1216 
1217 	if (octet & Q933_INTERFACE_IDENTIFIED) {
1218 		identifier_offset = offset;
1219 		identifier_len = 0;
1220 		do {
1221 			if (len == 0)
1222 				break;
1223 			octet = tvb_get_guint8(tvb, offset);
1224 			offset += 1;
1225 			len -= 1;
1226 			identifier_len++;
1227 		} while (!(octet & Q933_IE_VL_EXTENSION));
1228 
1229 		/*
1230 		 * XXX - do we want to strip off the 8th bit on the
1231 		 * last octet of the interface identifier?
1232 		 */
1233 		if (identifier_len != 0) {
1234 			proto_tree_add_item(tree, hf_q933_interface_identifier, tvb, identifier_offset, identifier_len, ENC_NA);
1235 		}
1236 	}
1237 
1238 	if (octet & Q933_NOT_BASIC_CHANNEL) {
1239 		if (len == 0)
1240 			return;
1241 		octet = tvb_get_guint8(tvb, offset);
1242 		coding_standard = octet & 0x60;
1243 		proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
1244 		if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
1245 			/*
1246 			 * We don't know how the channel identifier is
1247 			 * encoded, so just dump it as data and be done
1248 			 * with it.
1249 			 */
1250 			proto_tree_add_item(tree, hf_q933_data, tvb, offset, len, ENC_NA);
1251 			return;
1252 		}
1253 		proto_tree_add_item(tree, hf_q933_channel_indicated_by, tvb, offset, 1, ENC_NA);
1254 		proto_tree_add_item(tree, (octet & Q933_IS_SLOT_MAP) ? hf_q933_map_element_type : hf_q933_channel_type, tvb, offset, 1, ENC_NA);
1255 
1256 		/*
1257 		 * XXX - dump the channel number or slot map.
1258 		 */
1259 	}
1260 }
1261 
1262 /*
1263  * Dissect a Progress indicator information element.
1264  */
1265 static const value_string q933_progress_description_vals[] = {
1266 	{ 0x01, "Call is not end-to-end ISDN - progress information available in-band" },
1267 	{ 0x02, "Destination address is non-ISDN" },
1268 	{ 0x03, "Origination address is non-ISDN" },
1269 	{ 0x04, "Call has returned to the ISDN" },
1270 	{ 0x05, "Interworking has occurred and has resulted in a telecommunications service change" },
1271 	{ 0x08, "In-band information or an appropriate pattern is now available" },
1272 	{ 0,    NULL }
1273 };
1274 
1275 static void
dissect_q933_progress_indicator_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1276 dissect_q933_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
1277 				   proto_tree *tree)
1278 {
1279 	guint8 octet;
1280 	guint8 coding_standard;
1281 
1282 	if (len == 0)
1283 		return;
1284 	octet = tvb_get_guint8(tvb, offset);
1285 	coding_standard = octet & 0x60;
1286 	proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
1287 	if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
1288 		/*
1289 		 * We don't know how the progress indicator is encoded,
1290 		 * so just dump it as data and be done with it.
1291 		 */
1292 		proto_tree_add_item(tree, hf_q933_data, tvb, offset, len, ENC_NA);
1293 		return;
1294 	}
1295 	proto_tree_add_item(tree, hf_q933_location, tvb, offset, 1, ENC_BIG_ENDIAN);
1296 	offset += 1;
1297 	len -= 1;
1298 
1299 	if (len == 0)
1300 		return;
1301 	proto_tree_add_item(tree, hf_q933_progress_description, tvb, offset, 1, ENC_BIG_ENDIAN);
1302 }
1303 
1304 /*
1305  * Dissect a Network-specific facilities or Transit network selection
1306  * information element.
1307  */
1308 static const value_string q933_netid_type_vals[] = {
1309 	{ 0x00, "User specified" },
1310 	{ 0x20, "National network identification" },
1311 	{ 0x30, "International network identification" },
1312 	{ 0,    NULL }
1313 };
1314 
1315 static const value_string q933_netid_plan_vals[] = {
1316 	{ 0x00, "Unknown" },
1317 	{ 0x01, "Carrier Identification Code" },
1318 	{ 0x03, "X.121 data network identification code" },
1319 	{ 0,    NULL }
1320 };
1321 
1322 static void
dissect_q933_ns_facilities_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1323 dissect_q933_ns_facilities_ie(tvbuff_t *tvb, int offset, int len,
1324 			      proto_tree *tree)
1325 {
1326 	guint8 octet;
1327 	int netid_len;
1328 
1329 	if (len == 0)
1330 		return;
1331 	octet = tvb_get_guint8(tvb, offset);
1332 	netid_len = octet & 0x7F;
1333 	proto_tree_add_item(tree, hf_q933_network_identification_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1334 	offset += 1;
1335 	len -= 1;
1336 	if (netid_len != 0) {
1337 		if (len == 0)
1338 			return;
1339 		proto_tree_add_item(tree, hf_q933_type_of_network_identification, tvb, offset, 1, ENC_BIG_ENDIAN);
1340 		proto_tree_add_item(tree, hf_q933_network_identification_plan, tvb, offset, 1, ENC_BIG_ENDIAN);
1341 		offset += 1;
1342 		len -= 1;
1343 		netid_len--;
1344 
1345 		if (len == 0)
1346 			return;
1347 		if (netid_len > len)
1348 			netid_len = len;
1349 		if (netid_len != 0) {
1350 			proto_tree_add_item(tree, hf_q933_network_identification, tvb, offset, netid_len, ENC_NA|ENC_ASCII);
1351 			offset += netid_len;
1352 			len -= netid_len;
1353 		}
1354 	}
1355 
1356 	/*
1357 	 * Whatever is left is the network-specific facility
1358 	 * specification.
1359 	 */
1360 	 if (len == 0)
1361 	 	return;
1362 	proto_tree_add_item(tree, hf_q933_network_specific_facility_specification, tvb, offset, len, ENC_NA);
1363 }
1364 
1365 static int
dissect_q933_guint16_value(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree,int hf)1366 dissect_q933_guint16_value(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1367 			   proto_tree *tree, int hf)
1368 {
1369 	guint8 octet;
1370 	guint16 value;
1371 	int value_len;
1372 
1373 	value_len = 0;
1374 
1375 	octet = tvb_get_guint8(tvb, offset);
1376 	if (octet & Q933_IE_VL_EXTENSION) {
1377 		/*
1378 		 * Only one octet long - error.
1379 		 */
1380 		goto bad_length;
1381 	}
1382 	value = (octet & 0x3) << 14;
1383 	offset += 1;
1384 	len -= 1;
1385 	value_len++;
1386 
1387 	if (len == 0) {
1388 		/*
1389 		 * We've reached the end of the information element - error.
1390 		 */
1391 		goto past_end;
1392 	}
1393 	octet = tvb_get_guint8(tvb, offset);
1394 	if (octet & Q933_IE_VL_EXTENSION) {
1395 		/*
1396 		 * Only two octets long - error.
1397 		 */
1398 		goto bad_length;
1399 	}
1400 	value |= (octet & 0x7F) << 7;
1401 	offset += 1;
1402 	len -= 1;
1403 	value_len++;
1404 
1405 	if (len == 0) {
1406 		/*
1407 		 * We've reached the end of the information element - error.
1408 		 */
1409 		goto past_end;
1410 	}
1411 	octet = tvb_get_guint8(tvb, offset);
1412 	if (!(octet & Q933_IE_VL_EXTENSION)) {
1413 		/*
1414 		 * More than three octets long - error.
1415 		 */
1416 		goto bad_length;
1417 	}
1418 	value |= (octet & 0x7F);
1419 	offset += 1;
1420 	/*len -= 1;*/
1421 	value_len++;
1422 
1423 	proto_tree_add_uint(tree, hf, tvb, offset, value_len, value);
1424 	return value_len;
1425 
1426 past_end:
1427 	proto_tree_add_expert_format(tree, pinfo, &ei_q933_invalid_length, tvb, offset, len,
1428 			"%s goes past end of information element", proto_registrar_get_name(hf));
1429 	return -1;
1430 
1431 bad_length:
1432 	proto_tree_add_expert_format(tree, pinfo, &ei_q933_invalid_length, tvb, offset, len,
1433 			"%s isn't 3 octets long", proto_registrar_get_name(hf));
1434 	return -1;
1435 }
1436 
1437 /*
1438  * Dissect an End-to-end transit delay information element.
1439  */
1440 static void
dissect_q933_e2e_transit_delay_ie(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree)1441 dissect_q933_e2e_transit_delay_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1442 				  proto_tree *tree)
1443 {
1444 	int value_len;
1445 
1446 	if (len == 0)
1447 		return;
1448 	value_len = dissect_q933_guint16_value(tvb, pinfo, offset, len, tree,
1449 	    hf_q933_cumulative_transit_delay);
1450 	if (value_len < 0)
1451 		return;	/* error */
1452 	offset += value_len;
1453 	len -= value_len;
1454 
1455 	if (len == 0)
1456 		return;
1457 	value_len = dissect_q933_guint16_value(tvb, pinfo, offset, len, tree,
1458 	    hf_q933_requested_end_to_end_transit_delay);
1459 	if (value_len < 0)
1460 		return;	/* error */
1461 	offset += value_len;
1462 	len -= value_len;
1463 
1464 	if (len == 0)
1465 		return;
1466 	/*value_len = */dissect_q933_guint16_value(tvb, pinfo, offset, len, tree,
1467 	     hf_q933_max_end_to_end_transit_delay);
1468 }
1469 
1470 /*
1471  * Dissect a Transit delay selection and indication information element.
1472  */
1473 static void
dissect_q933_td_selection_and_int_ie(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree)1474 dissect_q933_td_selection_and_int_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1475 				     proto_tree *tree)
1476 {
1477 	if (len == 0)
1478 		return;
1479 	dissect_q933_guint16_value(tvb, pinfo, offset, len, tree, hf_q933_transit_delay);
1480 }
1481 
1482 static const true_false_string tfs_link_by_link_end_to_end = { "Link-by-link", "End-to-end" };
1483 static const true_false_string tfs_no_request_request_indicated = { "No request/request denied", "Request indicated/request accepted" };
1484 
1485 
1486 static void
dissect_q933_pl_binary_parameters_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1487 dissect_q933_pl_binary_parameters_ie(tvbuff_t *tvb, int offset, int len,
1488 				     proto_tree *tree)
1489 {
1490 	if (len == 0)
1491 		return;
1492 
1493 	proto_tree_add_item(tree, hf_q933_request, tvb, offset, 1, ENC_NA);
1494 	proto_tree_add_item(tree, hf_q933_confirmation, tvb, offset, 1, ENC_NA);
1495 }
1496 
1497 /*
1498  * Dissect a Reverse charging indication information element.
1499  */
1500 static const value_string q933_reverse_charging_indication_vals[] = {
1501 	{ 0x01, "Reverse charging requested" },
1502 	{ 0,    NULL }
1503 };
1504 
1505 static void
dissect_q933_reverse_charge_ind_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1506 dissect_q933_reverse_charge_ind_ie(tvbuff_t *tvb, int offset, int len,
1507 				   proto_tree *tree)
1508 {
1509 	if (len == 0)
1510 		return;
1511 	proto_tree_add_item(tree, hf_q933_reverse_charging_indication, tvb, offset, 1, ENC_BIG_ENDIAN);
1512 }
1513 
1514 /*
1515  * Dissect a (phone) number information element.
1516  */
1517 static const value_string q933_number_type_vals[] = {
1518 	{ 0x0, "Unknown" },
1519 	{ 0x1, "International number" },
1520 	{ 0x2, "National number" },
1521 	{ 0x3, "Network specific number" },
1522 	{ 0x4, "Subscriber number" },
1523 	{ 0x6, "Abbreviated number" },
1524 	{ 0,    NULL }
1525 };
1526 
1527 static const value_string q933_numbering_plan_vals[] = {
1528 	{ 0x00, "Unknown" },
1529 	{ 0x01, "E.164 ISDN/telephony numbering" },
1530 	{ 0x03, "X.121 data numbering" },
1531 	{ 0x04, "F.69 Telex numbering" },
1532 	{ 0x08, "National standard numbering" },
1533 	{ 0x09, "Private numbering" },
1534 	{ 0,    NULL }
1535 };
1536 
1537 static const value_string q933_presentation_indicator_vals[] = {
1538 	{ 0x00, "Presentation allowed" },
1539 	{ 0x01, "Presentation restricted" },
1540 	{ 0x02, "Number not available due to interworking" },
1541 	{ 0,    NULL }
1542 };
1543 
1544 static const value_string q933_screening_indicator_vals[] = {
1545 	{ 0x00, "User-provided, not screened" },
1546 	{ 0x01, "User-provided, verified and passed" },
1547 	{ 0x02, "User-provided, verified and failed" },
1548 	{ 0x03, "Network-provided" },
1549 	{ 0,    NULL }
1550 };
1551 
1552 static const value_string q933_redirection_reason_vals[] = {
1553 	{ 0x00, "Unknown" },
1554 	{ 0x01, "Call forwarding busy or called DTE busy" },
1555 	{ 0x02, "Call forwarding no reply" },
1556 	{ 0x04, "Call deflection" },
1557 	{ 0x09, "Called DTE out of order" },
1558 	{ 0x0A, "Call forwarding by the called DTE" },
1559 	{ 0x0F, "Call forwarding unconditional or systematic call redirection" },
1560 	{ 0,    NULL }
1561 };
1562 
1563 static void
dissect_q933_number_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree,int hfindex)1564 dissect_q933_number_ie(tvbuff_t *tvb, int offset, int len,
1565 		       proto_tree *tree, int hfindex)
1566 {
1567 	guint8 octet;
1568 
1569 	if (len == 0)
1570 		return;
1571 	octet = tvb_get_guint8(tvb, offset);
1572 	proto_tree_add_uint(tree, hf_q933_numbering_plan, tvb, offset, 1, octet);
1573 	proto_tree_add_uint(tree, hf_q933_number_type, tvb, offset, 1, octet);
1574 	proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
1575 
1576 	offset += 1;
1577 	len -= 1;
1578 
1579 	if (!(octet & Q933_IE_VL_EXTENSION)) {
1580 		if (len == 0)
1581 			return;
1582 		octet = tvb_get_guint8(tvb, offset);
1583 		proto_tree_add_uint(tree, hf_q933_screening_ind, tvb, offset, 1, octet);
1584 		proto_tree_add_uint(tree, hf_q933_presentation_ind, tvb, offset, 1, octet);
1585 		proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
1586 		offset += 1;
1587 		len -= 1;
1588 	}
1589 
1590 	/*
1591 	 * XXX - only in a Redirecting number information element.
1592 	 */
1593 	if (!(octet & Q933_IE_VL_EXTENSION)) {
1594 		if (len == 0)
1595 			return;
1596 		proto_tree_add_item(tree, hf_q933_reason_for_redirection, tvb, offset, 1, ENC_BIG_ENDIAN);
1597 		offset += 1;
1598 		len -= 1;
1599 	}
1600 
1601 	if (len == 0)
1602 		return;
1603 	proto_tree_add_item(tree, hfindex, tvb, offset, len, ENC_ASCII|ENC_NA);
1604 }
1605 
1606 /*
1607  * Dissect a party subaddress information element.
1608  */
1609 static const value_string q933_subaddress_type_vals[] = {
1610 	{ 0x00, "X.213/ISO 8348 Add.2 NSAP" },
1611 	{ 0x20, "User-specified" },
1612 	{ 0,    NULL }
1613 };
1614 
1615 static const value_string q933_odd_even_indicator_vals[] = {
1616 	{ 0x00, "Even number of address signals" },
1617 	{ 0x10, "Odd number of address signals" },
1618 	{ 0,    NULL }
1619 };
1620 
1621 static void
dissect_q933_party_subaddr_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1622 dissect_q933_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
1623 			      proto_tree *tree)
1624 {
1625 	if (len == 0)
1626 		return;
1627 
1628 	proto_tree_add_item(tree, hf_q933_type_of_subaddress, tvb, offset, 1, ENC_BIG_ENDIAN);
1629 	proto_tree_add_item(tree, hf_q933_odd_even_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1630 	offset += 1;
1631 	len -= 1;
1632 
1633 	if (len == 0)
1634 		return;
1635 	proto_tree_add_item(tree, hf_q933_subaddress, tvb, offset, len, ENC_NA);
1636 }
1637 
1638 /*
1639  * Dissect a High-layer compatibility information element.
1640  */
1641 #define	Q933_AUDIOVISUAL	0x60
1642 static const value_string q933_high_layer_characteristics_vals[] = {
1643 	{ 0x01,             "Telephony" },
1644 	{ 0x04,             "F.182 Facsimile Group 2/3" },
1645 	{ 0x21,             "F.184 Facsimile Group 4 Class I" },
1646 	{ 0x24,             "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
1647 	{ 0x28,             "F.220 Teletex, basic and processable mode" },
1648 	{ 0x31,             "F.200 Teletex, basic mode" },
1649 	{ 0x32,             "F.300 and T.102 syntax-based Videotex" },
1650 	{ 0x33,             "F.300 and T.101 international Videotex interworking" },
1651 	{ 0x35,             "F.60 Telex" },
1652 	{ 0x38,             "X.400 Message Handling Systems" },
1653 	{ 0x41,             "X.200 OSI application" },
1654 	{ 0x42,             "FTAM application" },
1655 	{ 0x5E,             "Reserved for maintenance" },
1656 	{ 0x5F,             "Reserved for management" },
1657 	{ Q933_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
1658 	{ 0x61,             "F.702 and F.731 Profile 1b videoconferencing" },
1659 	{ 0x62,             "F.702 and F.731 audiographic conferencing" },
1660 	{ 0,                NULL }
1661 };
1662 
1663 static const value_string q933_audiovisual_characteristics_vals[] = {
1664 	{ 0x01, "Capability set of initial channel of H.221" },
1665 	{ 0x02, "Capability set of subsequent channel of H.221" },
1666 	{ 0x21, "Capability set of initial channel of an active 3.1kHz audio or speech call" },
1667 	{ 0x00, NULL }
1668 };
1669 
1670 static void
dissect_q933_high_layer_compat_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1671 dissect_q933_high_layer_compat_ie(tvbuff_t *tvb, int offset, int len,
1672 				  proto_tree *tree)
1673 {
1674 	guint8 octet;
1675 	guint8 coding_standard;
1676 	guint8 characteristics;
1677 
1678 	if (len == 0)
1679 		return;
1680 	octet = tvb_get_guint8(tvb, offset);
1681 	coding_standard = octet & 0x60;
1682 	proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
1683 	offset += 1;
1684 	len -= 1;
1685 	if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
1686 		/*
1687 		 * We don't know how the call state is encoded,
1688 		 * so just dump it as data and be done with it.
1689 		 */
1690 		proto_tree_add_item(tree, hf_q933_data, tvb, offset, len, ENC_NA);
1691 		return;
1692 	}
1693 
1694 	if (len == 0)
1695 		return;
1696 	octet = tvb_get_guint8(tvb, offset);
1697 	characteristics = octet & 0x7F;
1698 	proto_tree_add_item(tree, hf_q933_high_layer_characteristics_identification, tvb, offset, 1, ENC_BIG_ENDIAN);
1699 	offset += 1;
1700 	len -= 1;
1701 
1702 	if (!(octet & Q933_IE_VL_EXTENSION)) {
1703 		if (len == 0)
1704 			return;
1705 		if (characteristics == Q933_AUDIOVISUAL) {
1706 			proto_tree_add_item(tree, hf_q933_extended_audiovisual_characteristics_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1707 		} else {
1708 			proto_tree_add_item(tree, hf_q933_extended_high_layer_characteristics_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1709 		}
1710 	}
1711 }
1712 
1713 
1714 /*
1715  * Dissect a User-user information element.
1716  */
1717 #define	Q933_PROTOCOL_DISCRIMINATOR_IA5		0x04
1718 #define Q933_PROTOCOL_DISCRIMINATOR_ASN1	0x05
1719 
1720 static const value_string q933_protocol_discriminator_vals[] = {
1721 	{ 0x00,					"User-specific protocol" },
1722 	{ 0x01,					"OSI high layer protocols" },
1723 	{ 0x02,					"X.244" },
1724 	{ Q933_PROTOCOL_DISCRIMINATOR_IA5,	"IA5 characters" },
1725 	{ Q933_PROTOCOL_DISCRIMINATOR_ASN1,	"X.208 and X.209 coded user information" },
1726 	{ 0x07,					"V.120 rate adaption" },
1727 	{ 0x08,					"Q.933/I.451 user-network call control messages" },
1728 	{ 0,					NULL }
1729 };
1730 
1731 static void
dissect_q933_user_user_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1732 dissect_q933_user_user_ie(tvbuff_t *tvb, int offset, int len,
1733 			  proto_tree *tree)
1734 {
1735 	guint8 octet;
1736 
1737 	if (len == 0)
1738 		return;
1739 	octet = tvb_get_guint8(tvb, offset);
1740 	proto_tree_add_item(tree, hf_q933_protocol_discriminator, tvb, offset, 1, ENC_BIG_ENDIAN);
1741 	offset += 1;
1742 	len -= 1;
1743 
1744 	if (len == 0)
1745 		return;
1746 	switch (octet) {
1747 
1748 	case Q933_PROTOCOL_DISCRIMINATOR_IA5:
1749 		proto_tree_add_item(tree, hf_q933_user_information_str, tvb, offset, len, ENC_NA|ENC_ASCII);
1750 		break;
1751 
1752 	default:
1753 		proto_tree_add_item(tree, hf_q933_user_information_bytes, tvb, offset, len, ENC_NA);
1754 		break;
1755 	}
1756 }
1757 
1758 /*
1759  * Dissect information elements consisting of ASCII^H^H^H^H^HIA5 text.
1760  */
1761 static void
dissect_q933_ia5_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree,int hf)1762 dissect_q933_ia5_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree, int hf)
1763 {
1764 	if (len != 0) {
1765 		proto_tree_add_item(tree, hf, tvb, offset, len, ENC_ASCII|ENC_NA);
1766 	}
1767 }
1768 
1769 static const value_string q933_codeset_vals[] = {
1770 	{ 0x00, "Q.933 information elements" },
1771 	{ 0x04, "Information elements for ISO/IEC use" },
1772 	{ 0x05, "Information elements for national use" },
1773 	{ 0x06, "Information elements specific to the local network" },
1774 	{ 0x07, "User-specific information elements" },
1775 	{ 0x00, NULL },
1776 };
1777 
1778 static int
dissect_q933(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)1779 dissect_q933(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1780 {
1781 	int		offset = 0;
1782 	proto_tree	*q933_tree = NULL;
1783 	proto_item	*ti;
1784 	proto_tree	*ie_tree = NULL;
1785 	guint8		call_ref_len;
1786 	guint8		call_ref[16];
1787 	guint8		message_type;
1788 	guint8		info_element;
1789 	guint16		info_element_len;
1790 	int		codeset, locked_codeset;
1791 	gboolean	non_locking_shift;
1792 
1793 	col_set_str(pinfo->cinfo, COL_PROTOCOL, "Q.933");
1794 
1795 	if (tree) {
1796 		ti = proto_tree_add_item(tree, proto_q933, tvb, offset, -1,
1797 		    ENC_NA);
1798 		q933_tree = proto_item_add_subtree(ti, ett_q933);
1799 
1800 		dissect_q933_protocol_discriminator(tvb, offset, q933_tree);
1801 	}
1802 	offset += 1;
1803 	call_ref_len = tvb_get_guint8(tvb, offset) & 0xF;	/* XXX - do as a bit field? */
1804 	if (q933_tree != NULL)
1805 		proto_tree_add_uint(q933_tree, hf_q933_call_ref_len, tvb, offset, 1, call_ref_len);
1806 	offset += 1;
1807 	if (call_ref_len != 0) {
1808 		tvb_memcpy(tvb, call_ref, offset, call_ref_len);
1809 		proto_tree_add_boolean(q933_tree, hf_q933_call_ref_flag,
1810 			tvb, offset, 1, (call_ref[0] & 0x80) != 0);
1811 		call_ref[0] &= 0x7F;
1812 		proto_tree_add_bytes(q933_tree, hf_q933_call_ref,
1813 			tvb, offset, call_ref_len, call_ref);
1814 		offset += call_ref_len;
1815 	}
1816 	message_type = tvb_get_guint8(tvb, offset);
1817 	col_add_str(pinfo->cinfo, COL_INFO,
1818 		    val_to_str(message_type, q933_message_type_vals,
1819 		      "Unknown message type (0x%02X)"));
1820 
1821 	proto_tree_add_uint(q933_tree, hf_q933_message_type, tvb, offset, 1, message_type);
1822 	offset += 1;
1823 
1824 	/*
1825 	 * And now for the information elements....
1826 	 */
1827 	codeset = locked_codeset = 0;	/* start out in codeset 0 */
1828 	while (tvb_reported_length_remaining(tvb, offset) > 0) {
1829 		info_element = tvb_get_guint8(tvb, offset);
1830 
1831 		 /* Check for the codeset shift */
1832 		if ((info_element & Q933_IE_SO_MASK) &&
1833 		    ((info_element & Q933_IE_SO_IDENTIFIER_MASK) == Q933_IE_SHIFT)) {
1834 			non_locking_shift = info_element & Q933_IE_SHIFT_NON_LOCKING;
1835 			codeset = info_element & Q933_IE_SHIFT_CODESET;
1836 			if (!non_locking_shift)
1837 				locked_codeset = codeset;
1838 			proto_tree_add_item(q933_tree, non_locking_shift ? hf_q933_non_locking_shift_to_codeset : hf_q933_locking_shift_to_codeset, tvb, offset, 1, ENC_NA);
1839 			offset += 1;
1840 			continue;
1841 		}
1842 
1843 		/*
1844 		 * Check for the single-octet IEs.
1845 		 */
1846 		if (info_element & Q933_IE_SO_MASK) {
1847 			switch ((codeset << 8) | (info_element & Q933_IE_SO_IDENTIFIER_MASK)) {
1848 
1849 			case CS0 | Q933_IE_REPEAT_INDICATOR:
1850 				proto_tree_add_item(q933_tree, hf_q933_repeat_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1851 				break;
1852 
1853 			default:
1854 				proto_tree_add_expert_format(q933_tree, pinfo, &ei_q933_information_element, tvb, offset, 1,
1855 						"Unknown information element (0x%02X)", info_element);
1856 				break;
1857 			}
1858 			offset += 1;
1859 			codeset = locked_codeset;
1860 			continue;
1861 		}
1862 
1863 		/*
1864 		 * Variable-length IE.
1865 		 */
1866 		info_element_len = tvb_get_guint8(tvb, offset + 1);
1867 		if (q933_tree != NULL) {
1868 			ie_tree = proto_tree_add_subtree(q933_tree, tvb, offset,
1869 			    1+1+info_element_len, ett_q933_ie, NULL,
1870 			    val_to_str(info_element, q933_info_element_vals[codeset],
1871 			      "Unknown information element (0x%02X)"));
1872 			proto_tree_add_uint_format_value(ie_tree, hf_q933_information_element, tvb, offset, 1, info_element,
1873 								"%s", val_to_str(info_element, q933_info_element_vals[codeset], "Unknown (0x%02X)"));
1874 			proto_tree_add_item(ie_tree, hf_q933_length, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
1875 
1876 			switch ((codeset << 8) | info_element) {
1877 
1878 			case CS0 | Q933_IE_SEGMENTED_MESSAGE:
1879 				dissect_q933_segmented_message_ie(tvb,
1880 				    pinfo, offset + 2, info_element_len,
1881 				    ie_tree);
1882 				break;
1883 
1884 			case CS0 | Q933_IE_BEARER_CAPABILITY:
1885 			case CS0 | Q933_IE_LOW_LAYER_COMPAT:
1886 				dissect_q933_bearer_capability_ie(tvb,
1887 				    offset + 2, info_element_len,
1888 				    ie_tree);
1889 				break;
1890 
1891 			case CS0 | Q933_IE_CAUSE:
1892 				dissect_q933_cause_ie(tvb,
1893 				    offset + 2, info_element_len,
1894 				    ie_tree,
1895 				    hf_q933_cause_value);
1896 				break;
1897 
1898 			case CS0 | Q933_IE_CALL_STATE:
1899 				dissect_q933_call_state_ie(tvb,
1900 				    offset + 2, info_element_len,
1901 				    ie_tree);
1902 				break;
1903 
1904 			case CS0 | Q933_IE_CHANNEL_IDENTIFICATION:
1905 				dissect_q933_channel_identification_ie(
1906 				    tvb, offset + 2, info_element_len,
1907 				    ie_tree);
1908 				break;
1909 
1910 			case CS0 | Q933_IE_PROGRESS_INDICATOR:
1911 				dissect_q933_progress_indicator_ie(tvb,
1912 				    offset + 2, info_element_len,
1913 				    ie_tree);
1914 				break;
1915 
1916 			case CS0 | Q933_IE_NETWORK_SPECIFIC_FACIL:
1917 			case CS0 | Q933_IE_TRANSIT_NETWORK_SEL:
1918 				dissect_q933_ns_facilities_ie(tvb,
1919 				    offset + 2, info_element_len,
1920 				    ie_tree);
1921 				break;
1922 
1923 			case CS0 | Q933_IE_DISPLAY:
1924 				dissect_q933_ia5_ie(tvb, offset + 2,
1925 				    info_element_len, ie_tree,
1926 				    hf_q933_display_information);
1927 				break;
1928 
1929 			case CS0 | Q933_IE_E2E_TRANSIT_DELAY:
1930 				dissect_q933_e2e_transit_delay_ie(tvb,
1931 				    pinfo, offset + 2, info_element_len,
1932 				    ie_tree);
1933 				break;
1934 
1935 			case CS0 | Q933_IE_TD_SELECTION_AND_INT:
1936 				dissect_q933_td_selection_and_int_ie(
1937 				    tvb, pinfo, offset + 2, info_element_len,
1938 				    ie_tree);
1939 				break;
1940 
1941 			case CS0 | Q933_IE_PL_BINARY_PARAMETERS:
1942 				dissect_q933_pl_binary_parameters_ie(
1943 				    tvb, offset + 2, info_element_len,
1944 				    ie_tree);
1945 				break;
1946 
1947 			case CS0 | Q933_IE_REVERSE_CHARGE_IND:
1948 				dissect_q933_reverse_charge_ind_ie(tvb,
1949 				    offset + 2, info_element_len,
1950 				    ie_tree);
1951 				break;
1952 
1953 			case CS0 | Q933_IE_CALLING_PARTY_NUMBER:
1954 				dissect_q933_number_ie(tvb,
1955 				    offset + 2, info_element_len,
1956 				    ie_tree,
1957 				    hf_q933_calling_party_number);
1958 				break;
1959 
1960 			case CS0 | Q933_IE_CONNECTED_NUMBER:
1961 				dissect_q933_number_ie(tvb,
1962 				    offset + 2, info_element_len,
1963 				    ie_tree,
1964 				    hf_q933_connected_number);
1965 				break;
1966 
1967 			case CS0 | Q933_IE_CALLED_PARTY_NUMBER:
1968 				dissect_q933_number_ie(tvb,
1969 				    offset + 2, info_element_len,
1970 				    ie_tree,
1971 				    hf_q933_called_party_number);
1972 				break;
1973 
1974 			case CS0 | Q933_IE_CALLING_PARTY_SUBADDR:
1975 			case CS0 | Q933_IE_CALLED_PARTY_SUBADDR:
1976 				dissect_q933_party_subaddr_ie(tvb,
1977 				    offset + 2, info_element_len,
1978 				    ie_tree);
1979 				break;
1980 
1981 			case CS0 | Q933_IE_HIGH_LAYER_COMPAT:
1982 				dissect_q933_high_layer_compat_ie(tvb,
1983 				    offset + 2, info_element_len,
1984 				    ie_tree);
1985 				break;
1986 
1987 			case CS0 | Q933_IE_USER_USER:
1988 				dissect_q933_user_user_ie(tvb,
1989 				    offset + 2, info_element_len,
1990 				    ie_tree);
1991 				break;
1992 
1993 
1994 			case CS0 | Q933_IE_REPORT_TYPE:
1995 			case CS5 | Q933_IE_REPORT_TYPE:
1996 			case CS5 | Q933_IE_ANSI_REPORT_TYPE:
1997 				dissect_q933_report_type_ie(tvb,
1998 				    offset + 2, info_element_len,
1999 				    ie_tree);
2000 				break;
2001 
2002 			case CS0 | Q933_IE_LINK_INTEGRITY_VERF:
2003 			case CS5 | Q933_IE_LINK_INTEGRITY_VERF:
2004 			case CS5 | Q933_IE_ANSI_LINK_INTEGRITY_VERF:
2005 				dissect_q933_link_integrity_verf_ie(tvb,
2006 				    offset + 2, info_element_len,
2007 				    ie_tree);
2008 				break;
2009 
2010 			case CS0 | Q933_IE_PVC_STATUS:
2011 			case CS5 | Q933_IE_PVC_STATUS:
2012 			case CS5 | Q933_IE_ANSI_PVC_STATUS:
2013 				dissect_q933_pvc_status_ie(tvb,
2014 				    offset + 2, info_element_len,
2015 				    ie_tree);
2016 				break;
2017 
2018 			default:
2019 				proto_tree_add_item(ie_tree, hf_q933_data, tvb, offset + 2, info_element_len, ENC_NA);
2020 				break;
2021 			}
2022 		}
2023 		offset += 1 + 1 + info_element_len;
2024 		codeset = locked_codeset;
2025 	}
2026 	return tvb_captured_length(tvb);
2027 }
2028 
2029 void
proto_register_q933(void)2030 proto_register_q933(void)
2031 {
2032 	static hf_register_info hf[] = {
2033 		{ &hf_q933_discriminator,
2034 		  { "Protocol discriminator", "q933.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
2035 			NULL, HFILL }},
2036 
2037 		{ &hf_q933_call_ref_flag,
2038 		  { "Call reference flag", "q933.call_ref_flag", FT_BOOLEAN, BASE_NONE, TFS(&tfs_call_ref_flag), 0x0,
2039 			NULL, HFILL }},
2040 
2041 		{ &hf_q933_call_ref,
2042 		  { "Call reference value", "q933.call_ref", FT_BYTES, BASE_NONE, NULL, 0x0,
2043 			NULL, HFILL }},
2044 
2045 
2046 		{ &hf_q933_coding_standard,
2047 		  { "Coding standard", "q933.coding_standard", FT_UINT8, BASE_HEX,
2048 			 VALS(q933_coding_standard_vals), 0x60,NULL, HFILL }},
2049 
2050 		{ &hf_q933_information_transfer_capability,
2051 		  { "Information transfer capability", "q933.information_transfer_capability", FT_UINT8, BASE_HEX,
2052 			 VALS(q933_information_transfer_capability_vals), 0x1f,NULL, HFILL }},
2053 
2054 		{ &hf_q933_transfer_mode,
2055 		  { "Transfer mode", "q933.transfer_mode", FT_UINT8, BASE_HEX,
2056 			 VALS(q933_transfer_mode_vals), 0x60,NULL, HFILL }},
2057 
2058 		{ &hf_q933_uil1,
2059 		  { "User information layer 1 protocol", "q933.uil1", FT_UINT8, BASE_HEX,
2060 			 VALS(q933_uil1_vals), 0x1f,NULL, HFILL }},
2061 
2062 		{ &hf_q933_call_ref_len,
2063 		  { "Call reference value length", "q933.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
2064 			NULL, HFILL }},
2065 
2066 		{ &hf_q933_message_type,
2067 		  { "Message type", "q933.message_type", FT_UINT8, BASE_HEX, VALS(q933_message_type_vals), 0x0,
2068 			NULL, HFILL }},
2069 
2070 		{ &hf_q933_cause_location,
2071 		  { "Cause location", "q933.cause_location", FT_UINT8, BASE_DEC, VALS(q933_cause_location_vals), 0x0f,
2072 			NULL, HFILL }},
2073 
2074 		{ &hf_q933_cause_value,
2075 		  { "Cause value", "q933.cause_value", FT_UINT8, BASE_DEC, VALS(q933_cause_code_vals), 0x7f,
2076 			NULL, HFILL }},
2077 
2078 		{ &hf_q933_number_type,
2079 		  { "Number type", "q933.number_type", FT_UINT8, BASE_HEX, VALS(q933_number_type_vals), 0x70,
2080 			NULL, HFILL }},
2081 
2082 		{ &hf_q933_numbering_plan,
2083 		  { "numbering plan", "q933.numbering_plan", FT_UINT8, BASE_HEX, VALS(q933_numbering_plan_vals), 0x0f,
2084 			NULL, HFILL }},
2085 
2086 		{ &hf_q933_screening_ind,
2087 		  { "Screening indicator", "q933.screening_ind", FT_UINT8, BASE_HEX, VALS(q933_screening_indicator_vals), 0x03,
2088 			NULL, HFILL }},
2089 
2090 		{ &hf_q933_presentation_ind,
2091 		  { "Presentation indicator", "q933.presentation_ind", FT_UINT8, BASE_HEX, VALS(q933_presentation_indicator_vals), 0x60,
2092 			NULL, HFILL }},
2093 
2094 		{ &hf_q933_extension_ind,
2095 		  { "Extension indicator",  "q933.extension_ind",
2096 			FT_BOOLEAN, 8, TFS(&q933_extension_ind_value), 0x80,
2097 			NULL, HFILL }},
2098 
2099 		{ &hf_q933_calling_party_number,
2100 		  { "Calling party number digits", "q933.calling_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2101 			NULL, HFILL }},
2102 
2103 		{ &hf_q933_called_party_number,
2104 		  { "Called party number digits", "q933.called_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2105 			NULL, HFILL }},
2106 
2107 		{ &hf_q933_connected_number,
2108 		  { "Connected party number digits", "q933.connected_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2109 			NULL, HFILL }},
2110 
2111 #if 0
2112 		{ &hf_q933_redirecting_number,
2113 		  { "Redirecting party number digits", "q933.redirecting_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2114 			NULL, HFILL }},
2115 #endif
2116 		{ &hf_q933_report_type,
2117 		  { "Report type", "q933.report_type", FT_UINT8, BASE_DEC, VALS(q933_report_type_vals), 0x0,
2118 			NULL, HFILL }},
2119 		{ &hf_q933_link_verf_txseq,
2120 		  { "TX Sequence", "q933.link_verification.txseq", FT_UINT8, BASE_DEC, NULL, 0x0,
2121 			NULL, HFILL }},
2122 		{ &hf_q933_link_verf_rxseq,
2123 		  { "RX Sequence", "q933.link_verification.rxseq", FT_UINT8, BASE_DEC, NULL, 0x0,
2124 			NULL, HFILL }},
2125 		{ &hf_q933_data,
2126 		  { "Data", "q933.data", FT_BYTES, BASE_NONE, NULL, 0x0,
2127 			NULL, HFILL }},
2128 
2129       /* Generated from convert_proto_tree_add_text.pl */
2130       { &hf_q933_first_segment, { "First segment", "q933.first_segment", FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_segment_remaining, 0x7F, NULL, HFILL }},
2131       { &hf_q933_not_first_segment, { "Not first segment", "q933.not_first_segment", FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_segment_remaining, 0x7F, NULL, HFILL }},
2132       { &hf_q933_segmented_message_type, { "Segmented message type", "q933.segmented_message_type", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2133       { &hf_q933_out_band_negotiation, { "Out-band negotiation", "q933.out_band_negotiation", FT_BOOLEAN, 8, TFS(&tfs_possible_not_possible), 0x40, NULL, HFILL }},
2134       { &hf_q933_layer_1, { "Layer 1", "q933.layer_1", FT_BOOLEAN, 8, TFS(&tfs_asynchronous_synchronous), 0x40, NULL, HFILL }},
2135       { &hf_q933_user_rate, { "User rate", "q933.user_rate", FT_UINT8, BASE_DEC, VALS(q933_l1_user_rate_vals), 0x1F, NULL, HFILL }},
2136       { &hf_q933_rate_adaption_header, { "Rate adaption header", "q933.rate_adaption_header", FT_BOOLEAN, 8, TFS(&tfs_included_not_included), 0x40, NULL, HFILL }},
2137       { &hf_q933_multiple_frame_establishment, { "Multiple frame establishment", "q933.multiple_frame_establishment", FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x20, NULL, HFILL }},
2138       { &hf_q933_mode_of_operation, { "Mode of operation", "q933.mode_of_operation", FT_BOOLEAN, 8, TFS(&tfs_protocol_sensative_bit_transparent), 0x10, NULL, HFILL }},
2139       { &hf_q933_stop_bits, { "Stop bits", "q933.stop_bits", FT_UINT8, BASE_DEC, VALS(q933_l1_stop_bits_vals), 0x60, NULL, HFILL }},
2140       { &hf_q933_data_bits, { "Data bits", "q933.data_bits", FT_UINT8, BASE_DEC, VALS(q933_l1_data_bits_vals), 0x18, NULL, HFILL }},
2141       { &hf_q933_parity, { "Parity", "q933.parity", FT_UINT8, BASE_DEC, VALS(q933_l1_parity_vals), 0x07, NULL, HFILL }},
2142       { &hf_q933_duplex, { "Duplex", "q933.duplex", FT_BOOLEAN, 8, TFS(&tfs_full_half), 0x40, NULL, HFILL }},
2143       { &hf_q933_modem_type, { "Modem type (Network-specific rules)", "q933.modem_type", FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL }},
2144       { &hf_q933_user_information_layer_2_protocol, { "User information layer 2 protocol", "q933.user_information_layer_2_protocol", FT_UINT8, BASE_HEX, VALS(q933_uil2_vals), 0x1F, NULL, HFILL }},
2145       { &hf_q933_user_specified_layer_2_protocol_information, { "User-specified layer 2 protocol information", "q933.user_specified_layer_2_protocol_information", FT_UINT8, BASE_HEX, NULL, 0x7F, NULL, HFILL }},
2146       { &hf_q933_address_inclusion, { "Address inclusion", "q933.address_inclusion", FT_UINT8, BASE_HEX, VALS(q933_address_inclusion_vals), 0x03, NULL, HFILL }},
2147       { &hf_q933_user_information_layer_3_protocol, { "User information layer 3 protocol", "q933.user_information_layer_3_protocol", FT_UINT8, BASE_HEX, VALS(q933_uil3_vals), 0x1F, NULL, HFILL }},
2148       { &hf_q933_mode, { "Mode", "q933.mode", FT_UINT8, BASE_HEX, VALS(q933_mode_vals), 0x60, NULL, HFILL }},
2149       { &hf_q933_default_packet_size_0F, { "Default packet size", "q933.default_packet_size", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL }},
2150       { &hf_q933_packet_window_size, { "Packet window size", "q933.packet_window_size", FT_UINT8, BASE_DEC, NULL, 0x7F, NULL, HFILL }},
2151       { &hf_q933_default_packet_size, { "Default packet size", "q933.default_packet_size", FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_octet_octets, 0x0, NULL, HFILL }},
2152       { &hf_q933_additional_layer_3_protocol_information, { "Additional layer 3 protocol information", "q933.additional_layer_3_protocol_information", FT_UINT16, BASE_HEX, VALS(nlpid_vals), 0x0FF0, NULL, HFILL }},
2153       { &hf_q933_recommendation, { "Recommendation", "q933.recommendation", FT_UINT8, BASE_HEX, VALS(q933_cause_recommendation_vals), 0x7F, NULL, HFILL }},
2154       { &hf_q933_network_service, { "Network service", "q933.network_service", FT_BOOLEAN, 8, TFS(&tfs_user_provider), 0x80, NULL, HFILL }},
2155       { &hf_q933_condition_normal, { "Condition", "q933.condition_normal", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
2156       { &hf_q933_condition, { "Condition", "q933.condition", FT_UINT8, BASE_HEX, VALS(q933_cause_condition_vals), 0x03, NULL, HFILL }},
2157       { &hf_q933_rejection_reason, { "Rejection reason", "q933.rejection_reason", FT_UINT8, BASE_HEX, VALS(q933_rejection_reason_vals), 0x7C, NULL, HFILL }},
2158       { &hf_q933_user_specific_diagnostic, { "User specific diagnostic", "q933.user_specific_diagnostic", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2159       { &hf_q933_missing_information_element, { "Missing information element", "q933.missing_information_element", FT_UINT8, BASE_HEX, VALS(q933_info_element_vals0), 0x0, NULL, HFILL }},
2160       { &hf_q933_insufficient_information_element, { "Insufficient information element", "q933.insufficient_information_element", FT_UINT8, BASE_HEX, VALS(q933_info_element_vals0), 0x0, NULL, HFILL }},
2161       { &hf_q933_diagnostic, { "Diagnostic", "q933.diagnostic", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2162       { &hf_q933_information_element, { "Information element", "q933.information_element", FT_UINT8, BASE_HEX, VALS(q933_info_element_vals0), 0x0, NULL, HFILL }},
2163       { &hf_q933_timer, { "Timer", "q933.timer", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2164       { &hf_q933_call_state, { "Call state", "q933.call_state", FT_UINT8, BASE_HEX, VALS(q933_call_state_vals), 0x3F, NULL, HFILL }},
2165       { &hf_q933_dlci, { "DLCI", "q933.dlci", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2166       { &hf_q933_status, { "Status", "q933.status", FT_UINT8, BASE_DEC, VALS(q933_pvc_status_vals), 0x0E, NULL, HFILL }},
2167       { &hf_q933_interface_identified, { "Interface", "q933.interface_identified", FT_BOOLEAN, 8, TFS(&tfs_explicitly_implicitly_identified), Q933_INTERFACE_IDENTIFIED, NULL, HFILL }},
2168       { &hf_q933_interface_basic, { "Interface", "q933.interface_basic", FT_BOOLEAN, 8, TFS(&tfs_not_basic_basic), Q933_NOT_BASIC_CHANNEL, NULL, HFILL }},
2169       { &hf_q933_indicated_channel_required, { "Indicated channel", "q933.indicated_channel_required", FT_BOOLEAN, 8, TFS(&tfs_required_preferred), 0x08, NULL, HFILL }},
2170       { &hf_q933_indicated_channel_d_channel, { "Indicated channel", "q933.indicated_channel_d_channel", FT_BOOLEAN, 8, TFS(&tfs_dchannel_not_dchannel), 0x04, NULL, HFILL }},
2171       { &hf_q933_not_channel_selection, { "Channel selection", "q933.channel_selection", FT_UINT8, BASE_HEX, VALS(q933_not_basic_channel_selection_vals), 0x03, NULL, HFILL }},
2172       { &hf_q933_channel_selection, { "Channel selection", "q933.channel_selection", FT_UINT8, BASE_HEX, VALS(q933_basic_channel_selection_vals), 0x03, NULL, HFILL }},
2173       { &hf_q933_interface_identifier, { "Interface identifier", "q933.interface_identifier", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2174       { &hf_q933_channel_indicated_by, { "Channel indicated by", "q933.channel_indicated_by", FT_BOOLEAN, 8, TFS(&tfs_slot_map_number), Q933_IS_SLOT_MAP, NULL, HFILL }},
2175       { &hf_q933_map_element_type, { "Map element type", "q933.map_element_type", FT_UINT8, BASE_HEX, VALS(q933_element_type_vals), 0x0F, NULL, HFILL }},
2176       { &hf_q933_channel_type, { "Channel", "q933.channel_type", FT_UINT8, BASE_HEX, VALS(q933_element_type_vals), 0x0F, NULL, HFILL }},
2177       { &hf_q933_location, { "Location", "q933.location", FT_UINT8, BASE_HEX, VALS(q933_cause_location_vals), 0x0F, NULL, HFILL }},
2178       { &hf_q933_progress_description, { "Progress description", "q933.progress_description", FT_UINT8, BASE_HEX, VALS(q933_progress_description_vals), 0x7F, NULL, HFILL }},
2179       { &hf_q933_network_identification_length, { "Network identification length", "q933.network_identification_length", FT_UINT8, BASE_DEC, NULL, 0x7F, NULL, HFILL }},
2180       { &hf_q933_type_of_network_identification, { "Type of network identification", "q933.type_of_network_identification", FT_UINT8, BASE_HEX, VALS(q933_netid_type_vals), 0x70, NULL, HFILL }},
2181       { &hf_q933_network_identification_plan, { "Network identification plan", "q933.network_identification_plan", FT_UINT8, BASE_HEX, VALS(q933_netid_plan_vals), 0x0F, NULL, HFILL }},
2182       { &hf_q933_network_identification, { "Network identification", "q933.network_identification", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2183       { &hf_q933_network_specific_facility_specification, { "Network-specific facility specification", "q933.network_specific_facility_specification", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2184       { &hf_q933_confirmation, { "Confirmation", "q933.confirmation", FT_BOOLEAN, 8, TFS(&tfs_link_by_link_end_to_end), 0x02, NULL, HFILL }},
2185       { &hf_q933_reverse_charging_indication, { "Reverse charging indication", "q933.reverse_charging_indication", FT_UINT8, BASE_HEX, VALS(q933_reverse_charging_indication_vals), 0x07, NULL, HFILL }},
2186       { &hf_q933_reason_for_redirection, { "Reason for redirection", "q933.reason_for_redirection", FT_UINT8, BASE_HEX, VALS(q933_redirection_reason_vals), 0x0F, NULL, HFILL }},
2187       { &hf_q933_type_of_subaddress, { "Type of subaddress", "q933.type_of_subaddress", FT_UINT8, BASE_HEX, VALS(q933_subaddress_type_vals), 0x70, NULL, HFILL }},
2188       { &hf_q933_odd_even_indicator, { "Odd/even indicator", "q933.odd_even_indicator", FT_UINT8, BASE_HEX, VALS(q933_odd_even_indicator_vals), 0x10, NULL, HFILL }},
2189       { &hf_q933_subaddress, { "Subaddress", "q933.subaddress", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2190       { &hf_q933_high_layer_characteristics_identification, { "High layer characteristics identification", "q933.high_layer_characteristics_identification", FT_UINT8, BASE_HEX, VALS(q933_high_layer_characteristics_vals), 0x7F, NULL, HFILL }},
2191       { &hf_q933_extended_audiovisual_characteristics_id, { "Extended audiovisual characteristics identification", "q933.extended_audiovisual_characteristics_id", FT_UINT8, BASE_HEX, VALS(q933_audiovisual_characteristics_vals), 0x7F, NULL, HFILL }},
2192       { &hf_q933_extended_high_layer_characteristics_id, { "Extended high layer characteristics identification", "q933.extended_high_layer_characteristics_id", FT_UINT8, BASE_HEX, VALS(q933_high_layer_characteristics_vals), 0x7F, NULL, HFILL }},
2193       { &hf_q933_protocol_discriminator, { "Protocol discriminator", "q933.protocol_discriminator", FT_UINT8, BASE_HEX, VALS(q933_protocol_discriminator_vals), 0x0, NULL, HFILL }},
2194       { &hf_q933_user_information_str, { "User information", "q933.user_information_str", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2195       { &hf_q933_user_information_bytes, { "User information", "q933.user_information_bytes", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2196       { &hf_q933_locking_shift_to_codeset, { "Locking shift to codeset", "q933.locking_shift_to_codeset", FT_UINT8, BASE_DEC, VALS(q933_codeset_vals), Q933_IE_SHIFT_CODESET, NULL, HFILL }},
2197       { &hf_q933_non_locking_shift_to_codeset, { "Non-locking shift to codeset", "q933.non_locking_shift_to_codeset", FT_UINT8, BASE_DEC, VALS(q933_codeset_vals), Q933_IE_SHIFT_CODESET, NULL, HFILL }},
2198       { &hf_q933_repeat_indicator, { "Repeat indicator", "q933.repeat_indicator", FT_UINT8, BASE_HEX, VALS(q933_repeat_indication_vals), Q933_IE_SO_IE_MASK, NULL, HFILL }},
2199       { &hf_q933_length, { "Length", "q933.length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2200       { &hf_q933_diagnostics, { "Diagnostics", "q933.diagnostics", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2201       { &hf_q933_display_information, { "Display information", "q933.display_information", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2202       { &hf_q933_cumulative_transit_delay, { "Cumulative transit delay", "q933.cumulative_transit_delay", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0, NULL, HFILL }},
2203       { &hf_q933_requested_end_to_end_transit_delay, { "Requested end-to-end transit delay", "q933.requested_end_to_end_transit_delay", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0, NULL, HFILL }},
2204       { &hf_q933_max_end_to_end_transit_delay, { "Maximum end-to-end transit delay", "q933.max_end_to_end_transit_delay", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0, NULL, HFILL }},
2205       { &hf_q933_transit_delay, { "Transit Delay", "q933.transit_delay", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0, NULL, HFILL }},
2206       { &hf_q933_request, { "Request", "q933.request", FT_BOOLEAN, 8, TFS(&tfs_no_request_request_indicated), 0x04, NULL, HFILL }},
2207 
2208 	};
2209 	static gint *ett[] = {
2210 		&ett_q933,
2211 		&ett_q933_ie,
2212 	};
2213 
2214 	static ei_register_info ei[] = {
2215 		{ &ei_q933_invalid_length, { "q933.invalid_length", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
2216 		{ &ei_q933_information_element, { "q933.information_element.unknown", PI_PROTOCOL, PI_WARN, "Unknown information element", EXPFILL }},
2217 	};
2218 	expert_module_t* expert_q933;
2219 
2220 	proto_q933 = proto_register_protocol("Q.933", "Q.933", "q933");
2221 	proto_register_field_array (proto_q933, hf, array_length(hf));
2222 	proto_register_subtree_array(ett, array_length(ett));
2223 	expert_q933 = expert_register_protocol(proto_q933);
2224 	expert_register_field_array(expert_q933, ei, array_length(ei));
2225 
2226 	q933_handle = register_dissector("q933", dissect_q933, proto_q933);
2227 }
2228 
2229 void
proto_reg_handoff_q933(void)2230 proto_reg_handoff_q933(void)
2231 {
2232 	dissector_add_uint("fr.osinl", NLPID_Q_933, q933_handle);
2233 	dissector_add_uint("juniper.proto", JUNIPER_PROTO_Q933, q933_handle);
2234 }
2235 
2236 /*
2237  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
2238  *
2239  * Local variables:
2240  * c-basic-offset: 8
2241  * tab-width: 8
2242  * indent-tabs-mode: t
2243  * End:
2244  *
2245  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
2246  * :indentSize=8:tabSize=8:noTabs=false:
2247  */
2248