1 /* packet-q2931.c
2  * Routines for Q.2931 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/oui.h>
16 #include <epan/nlpid.h>
17 #include <epan/etypes.h>
18 #include <epan/expert.h>
19 #include <wsutil/str_util.h>
20 #include "packet-q931.h"
21 #include "packet-arp.h"
22 
23 /*
24  * See
25  *
26  *	http://web.archive.org/web/20150408122122/http://www.protocols.com/pbook/atmsig.htm
27  *
28  * for some information on Q.2931, although, alas, not the actual message
29  * type and information element values - those I got from the FreeBSD 3.2
30  * ATM code, and from Q.2931 (and Q.931) itself.
31  */
32 
33 void proto_register_q2931(void);
34 
35 static int proto_q2931 = -1;
36 static int hf_q2931_discriminator = -1;
37 static int hf_q2931_call_ref_len = -1;
38 static int hf_q2931_call_ref_flag = -1;
39 static int hf_q2931_call_ref = -1;
40 static int hf_q2931_message_type = -1;
41 static int hf_q2931_message_type_ext = -1;
42 static int hf_q2931_message_flag = -1;
43 static int hf_q2931_message_action_indicator = -1;
44 static int hf_q2931_message_len = -1;
45 static int hf_q2931_ie_handling_instructions = -1;
46 static int hf_q2931_ie_coding_standard = -1;
47 static int hf_q2931_ie_action_indicator = -1;
48 /* Generated from convert_proto_tree_add_text.pl */
49 static int hf_q2931_number_bytes = -1;
50 static int hf_q2931_conn_id_vci = -1;
51 static int hf_q2931_restart_indicator = -1;
52 static int hf_q2931_conn_id_vpci = -1;
53 static int hf_q2931_bband_low_layer_info_mode = -1;
54 static int hf_q2931_cause_rejection_insufficient_information_element = -1;
55 static int hf_q2931_bband_low_layer_info_user_info_l3_proto = -1;
56 static int hf_q2931_number_string = -1;
57 static int hf_q2931_aal1_backward_max_cpcs_sdu_size = -1;
58 static int hf_q2931_user_plane_connection_configuration = -1;
59 static int hf_q2931_party_subaddr_subaddress = -1;
60 static int hf_q2931_aal1_mode = -1;
61 static int hf_q2931_cause_location = -1;
62 static int hf_q2931_bband_low_layer_info_user_specified_l2_proto = -1;
63 static int hf_q2931_information_element = -1;
64 static int hf_q2931_conn_id_preferred_exclusive = -1;
65 static int hf_q2931_cause_vci = -1;
66 static int hf_q2931_cause_information_element = -1;
67 static int hf_q2931_oam_traffic_descriptor_backward_f5_flow_indicator = -1;
68 static int hf_q2931_cause_rejection_reason = -1;
69 static int hf_q2931_ethernet_type = -1;
70 static int hf_q2931_cause_value = -1;
71 static int hf_q2931_information_element_length = -1;
72 static int hf_q2931_cause_rejection_user_specific_diagnostic = -1;
73 static int hf_q2931_transit_network_sel_type = -1;
74 static int hf_q2931_user_defined_aal_information = -1;
75 static int hf_q2931_aal1_forward_max_cpcs_sdu_size = -1;
Content()76 static int hf_q2931_atm_transfer_capability = -1;
77 static int hf_q2931_aal1_subtype = -1;
78 static int hf_q2931_information_element_extension = -1;
79 static int hf_q2931_party_subaddr_type_of_subaddress = -1;
80 static int hf_q2931_number_plan = -1;
SetParent(nsMenuChainItem * aParent)81 static int hf_q2931_aal1_error_correction_method = -1;
82 static int hf_q2931_call_state = -1;
83 static int hf_q2931_bearer_class = -1;
84 static int hf_q2931_protocol_id = -1;
85 static int hf_q2931_information_element_data = -1;
86 static int hf_q2931_aal1_partially_filled_cells_method = -1;
87 static int hf_q2931_lane_protocol_id = -1;
88 static int hf_q2931_party_subaddr_odd_even_indicator = -1;
89 static int hf_q2931_qos_class_backward = -1;
90 static int hf_q2931_cause_rejection_condition = -1;
91 static int hf_q2931_aal1_source_clock_frequency_recovery_method = -1;
92 static int hf_q2931_broadband_repeat_indicator = -1;
93 static int hf_q2931_cause_rejection_missing_information_element = -1;
94 static int hf_q2931_e2e_transit_delay_maximum_end_to_end = -1;
Detach(nsMenuChainItem ** aRoot)95 static int hf_q2931_endpoint_reference_flag = -1;
96 static int hf_q2931_endpoint_reference_identifier_value = -1;
97 static int hf_q2931_cause_vpci = -1;
98 static int hf_q2931_endpoint_state = -1;
99 static int hf_q2931_high_layer_information_type = -1;
100 static int hf_q2931_transit_network_sel_network_id = -1;
101 static int hf_q2931_aal1_sscs_type = -1;
102 static int hf_q2931_bband_low_layer_info_packet_window_size = -1;
103 static int hf_q2931_aal1_structured_data_transfer_block_size = -1;
104 static int hf_q2931_cause_timer = -1;
105 static int hf_q2931_cause_message_type = -1;
106 static int hf_q2931_e2e_transit_delay_cumulative = -1;
107 static int hf_q2931_oam_traffic_descriptor_shaping_indicator = -1;
108 static int hf_q2931_oam_end_to_end_f5_flow = -1;
109 static int hf_q2931_oam_traffic_descriptor_forward_f5_flow_indicator = -1;
110 static int hf_q2931_organization_code = -1;
111 static int hf_q2931_bband_low_layer_info_additional_l3_proto = -1;
112 static int hf_q2931_transit_network_sel_plan = -1;
113 static int hf_q2931_bband_low_layer_info_user_info_l2_proto = -1;
114 static int hf_q2931_aal1_multiplier = -1;
115 static int hf_q2931_aal_type = -1;
116 static int hf_q2931_aal1_cbr_rate = -1;
117 static int hf_q2931_number_type = -1;
NS_IMPL_ISUPPORTS(nsXULPopupManager,nsIDOMEventListener,nsITimerCallback,nsIObserver)118 static int hf_q2931_cause_rejection_diagnostic = -1;
119 static int hf_q2931_bband_low_layer_info_default_packet_size = -1;
120 static int hf_q2931_susceptibility_to_clipping = -1;
121 static int hf_q2931_oam_traffic_descriptor_management_indicator = -1;
122 static int hf_q2931_qos_class_forward = -1;
123 static int hf_q2931_endpoint_reference_type = -1;
124 static int hf_q2931_number_presentation_indicator = -1;
125 static int hf_q2931_bband_low_layer_info_user_info_l1_proto = -1;
126 static int hf_q2931_number_screening_indicator = -1;
127 static int hf_q2931_bband_low_layer_info_window_size = -1;
128 static int hf_q2931_conn_id_vp_associated_signalling = -1;
129 static int hf_q2931_cause_cell_rate_subfield_identifier = -1;
130 static int hf_q2931_frame_discard_forward_dir = -1;
131 static int hf_q2931_frame_discard_backward_dir = -1;
132 static int hf_q2931_tagging_backward_dir = -1;
133 static int hf_q2931_tagging_forward_dir = -1;
134 static int hf_q2931_midrange = -1;
135 static int hf_q2931_cause_network_service = -1;
136 static int hf_q2931_cause_network_behavior = -1;
137 static int hf_q2931_nsap_address_number_short = -1;
138 static int hf_q2931_atm_identifier = -1;
139 static int hf_q2931_atm_identifier_value = -1;
~nsXULPopupManager()140 static int hf_q2931_aal_parameter_identifier = -1;
141 static int hf_q2931_e2e_transit_delay_identifier = -1;
142 static int hf_q2931_bband_sending_complete_id = -1;
143 static int hf_q2931_bband_sending_complete = -1;
144 static int hf_q2931_locking_codeset = -1;
145 
Init()146 static gint ett_q2931 = -1;
147 static gint ett_q2931_ext = -1;
148 static gint ett_q2931_ie = -1;
149 static gint ett_q2931_ie_ext = -1;
150 static gint ett_q2931_nsap = -1;
151 
152 static expert_field ei_q2931_atm_identifier = EI_INIT;
153 static expert_field ei_q2931_aal_parameter_identifier = EI_INIT;
154 static expert_field ei_q2931_e2e_transit_delay_identifier = EI_INIT;
Shutdown()155 static expert_field ei_q2931_bband_sending_complete_id = EI_INIT;
156 
157 static void dissect_q2931_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
158 			     proto_tree *tree, guint8 info_element, guint8 info_element_ext);
159 
160 /*
Observe(nsISupports * aSubject,const char * aTopic,const char16_t * aData)161  * Q.2931 message types.
162  */
163 #define	Q2931_ALERTING		0x01
164 #define	Q2931_CALL_PROCEEDING	0x02
165 #define	Q2931_PROGRESS		0x03
166 #define	Q2931_SETUP		0x05
167 #define	Q2931_CONNECT		0x07
168 #define	Q2931_SETUP_ACK		0x0B
169 #define	Q2931_CONNECT_ACK	0x0F
170 #define	Q2931_RESTART		0x46
171 #define	Q2931_RELEASE		0x4D
172 #define	Q2931_RESTART_ACK	0x4E
173 #define	Q2931_RELEASE_COMPLETE	0x5A
174 #define	Q2931_NOTIFY		0x6E
175 #define	Q2931_STATUS_ENQUIRY	0x75
176 #define	Q2931_INFORMATION	0x7B
177 #define	Q2931_STATUS		0x7D
178 #define	Q2931_ADD_PARTY		0x80
179 #define	Q2931_ADD_PARTY_ACK	0x81
180 #define	Q2931_ADD_PARTY_REJ	0x82
181 #define	Q2931_DROP_PARTY	0x83
182 #define	Q2931_DROP_PARTY_ACK	0x84
183 #define	Q2931_LEAF_SETUP_FAIL	0x90
184 #define	Q2931_LEAF_SETUP_REQ	0x91
185 
186 static const value_string q2931_message_type_vals[] = {
187 	{ Q2931_ALERTING,		"ALERTING" },
188 	{ Q2931_CALL_PROCEEDING,	"CALL PROCEEDING" },
189 	{ Q2931_PROGRESS,		"PROGRESS" },
190 	{ Q2931_SETUP,			"SETUP" },
191 	{ Q2931_CONNECT,		"CONNECT" },
192 	{ Q2931_SETUP_ACK,		"SETUP ACKNOWLEDGE" },
193 	{ Q2931_CONNECT_ACK,		"CONNECT ACKNOWLEDGE" },
194 	{ Q2931_RESTART,		"RESTART" },
195 	{ Q2931_RELEASE,		"RELEASE" },
196 	{ Q2931_RESTART_ACK,		"RESTART ACKNOWLEDGE" },
197 	{ Q2931_RELEASE_COMPLETE,	"RELEASE COMPLETE" },
198 	{ Q2931_NOTIFY,			"NOTIFY" },
199 	{ Q2931_STATUS_ENQUIRY,		"STATUS ENQUIRY" },
200 	{ Q2931_INFORMATION,		"INFORMATION" },
201 	{ Q2931_STATUS,			"STATUS" },
202 	{ Q2931_ADD_PARTY,		"ADD PARTY" },
203 	{ Q2931_ADD_PARTY_ACK,		"ADD PARTY ACKNOWLEDGE" },
204 	{ Q2931_ADD_PARTY_REJ,		"ADD PARTY REJECT" },
205 	{ Q2931_DROP_PARTY,		"DROP PARTY" },
206 	{ Q2931_DROP_PARTY_ACK,		"DROP PARTY ACKNOWLEDGE" },
207 	{ Q2931_LEAF_SETUP_FAIL,	"LEAF SETUP FAILURE" },
208 	{ Q2931_LEAF_SETUP_REQ,		"LEAF SETUP REQUEST" },
209 	{ 0,				NULL }
210 };
211 
212 static value_string_ext q2931_message_type_vals_ext = VALUE_STRING_EXT_INIT(q2931_message_type_vals);
213 
214 static const true_false_string tfs_call_ref_flag = {
215 	"Message sent to originating side",
216 	"Message sent from originating side"
217 };
218 
219 /*
220  * Bits in the message type extension.
221  */
222 #define	Q2931_MSG_TYPE_EXT_FOLLOW_INST	0x10	/* follow instructions in action indicator */
223 #define	Q2931_MSG_TYPE_EXT_ACTION_IND	0x03	/* said instructions */
224 
225 static const true_false_string tos_msg_flag = {
226 	"Regular error handling procedures apply",
227 	"Follow explicit error handling instructions"
228 };
229 
230 static const value_string msg_action_ind_vals[] = {
231 	{ 0x00, "Clear call" },
232 	{ 0x01, "Discard and ignore" },
233 	{ 0x02, "Discard and report status" },
234 	{ 0x00, NULL }
235 };
236 
237 /*
238  * Bits in the compatibility instruction indicator octet of an
239  * information element.
240  */
241 #define	Q2931_IE_COMPAT_CODING_STD	0x60	/* Coding standard */
242 #define	Q2931_IE_COMPAT_FOLLOW_INST	0x10	/* follow instructions in action indicator */
243 #define	Q2931_IE_COMPAT_ACTION_IND	0x07
244 
245 /*
246  * ITU-standardized coding.
247  */
248 #define	Q2931_ITU_STANDARDIZED_CODING	0x00
249 
250 static const value_string coding_std_vals[] = {
251 	{ 0x00, "ITU-T standardized coding" },
252 	{ 0x20, "ISO/IEC standard" },
253 	{ 0x40, "National standard" },
254 	{ 0x60, "Standard defined for the network" },
255 	{ 0,    NULL }
256 };
257 
258 static const value_string ie_action_ind_vals[] = {
259 	{ 0x00, "Clear call" },
260 	{ 0x01, "Discard information element and proceed" },
261 	{ 0x02, "Discard information element, proceed, and report status" },
262 	{ 0x05, "Discard message, and ignore" },
263 	{ 0x06, "Discard message, and report status" },
264 	{ 0x00, NULL }
265 };
266 
267 /*
268  * Information elements.
269  */
270 #define	Q2931_IE_EXTENSION		0x80	/* Extension flag */
271 
272 #define	Q2931_IE_NBAND_BEARER_CAP	0x04	/* Narrowband bearer capability */
273 #define	Q2931_IE_CAUSE			0x08
274 #define	Q2931_IE_CALL_STATE		0x14
275 #define	Q2931_IE_PROGRESS_INDICATOR	0x1E
276 #define	Q2931_IE_NOTIFICATION_INDICATOR	0x27
277 #define	Q2931_IE_E2E_TRANSIT_DELAY	0x42	/* End-to-end Transit Delay */
278 #define	Q2931_IE_ENDPOINT_REFERENCE	0x54
279 #define	Q2931_IE_ENDPOINT_STATE		0x55
280 #define	Q2931_IE_AAL_PARAMETERS		0x58	/* ATM adaptation layer parameters */
281 #define	Q2931_IE_ATM_USER_CELL_RATE	0x59	/* ATM traffic descriptor */
282 #define	Q2931_IE_CONNECTION_IDENTIFIER	0x5A
283 #define	Q2931_IE_OAM_TRAFFIC_DESCRIPTOR	0x5B
284 #define	Q2931_IE_QOS_PARAMETER		0x5C	/* Quality of Service parameter */
285 #define	Q2931_IE_BBAND_HI_LAYER_INFO	0x5D	/* Broadband high-layer information */
286 #define	Q2931_IE_BBAND_BEARER_CAP	0x5E	/* Broadband bearer capability */
287 #define	Q2931_IE_BBAND_LOW_LAYER_INFO	0x5F	/* Broadband low-layer information */
288 #define	Q2931_IE_BBAND_LOCKING_SHIFT	0x60	/* Broadband locking shift */
289 #define	Q2931_IE_BBAND_NLOCKING_SHIFT	0x61	/* Broadband non-locking shift */
290 #define	Q2931_IE_BBAND_SENDING_COMPL	0x62	/* Broadband sending complete */
291 #define	Q2931_IE_BBAND_RPT_INDICATOR	0x63	/* Broadband repeat indicator */
292 #define	Q2931_IE_CALLING_PARTY_NUMBER	0x6C	/* Calling Party Number */
293 #define	Q2931_IE_CALLING_PARTY_SUBADDR	0x6D	/* Calling Party Subaddress */
294 #define	Q2931_IE_CALLED_PARTY_NUMBER	0x70	/* Called Party Number */
295 #define	Q2931_IE_CALLED_PARTY_SUBADDR	0x71	/* Called Party Subaddress */
296 #define	Q2931_IE_TRANSIT_NETWORK_SEL	0x78	/* Transit Network Selection */
297 #define	Q2931_IE_RESTART_INDICATOR	0x79
298 #define	Q2931_IE_NBAND_LOW_LAYER_COMPAT	0x7C	/* Narrowband Low-Layer Compatibility */
299 #define	Q2931_IE_NBAND_HIGH_LAYER_COMPAT 0x7D	/* Narrowband High-Layer Compatibility */
300 #define	Q2931_IE_GENERIC_IDENT_TRANSPORT 0x7F	/* Generic identifier transport */
301 
302 static const value_string q2931_info_element_vals[] = {
303 	{ Q2931_IE_NBAND_BEARER_CAP,		"Narrowband bearer capability" },
304 	{ Q2931_IE_CAUSE,			"Cause" },
305 	{ Q2931_IE_CALL_STATE,			"Call state" },
306 	{ Q2931_IE_PROGRESS_INDICATOR,		"Progress indicator" },
307 	{ Q2931_IE_NOTIFICATION_INDICATOR,	"Notification indicator" },
308 	{ Q2931_IE_E2E_TRANSIT_DELAY,		"End-to-end transit delay" },
309 	{ Q2931_IE_ENDPOINT_REFERENCE,		"Endpoint reference" },
310 	{ Q2931_IE_ENDPOINT_STATE,		"Endpoint state" },
311 	{ Q2931_IE_AAL_PARAMETERS,		"AAL parameters" },
312 	{ Q2931_IE_ATM_USER_CELL_RATE,		"ATM user cell rate" },
313 	{ Q2931_IE_CONNECTION_IDENTIFIER,	"Connection identifier" },
314 	{ Q2931_IE_OAM_TRAFFIC_DESCRIPTOR,	"OAM traffic descriptor" },
315 	{ Q2931_IE_QOS_PARAMETER,		"Quality of service parameter" },
316 	{ Q2931_IE_BBAND_HI_LAYER_INFO,		"Broadband high-layer information" },
317 	{ Q2931_IE_BBAND_BEARER_CAP,		"Broadband bearer capability" },
318 	{ Q2931_IE_BBAND_LOW_LAYER_INFO,	"Broadband low-layer information" },
319 	{ Q2931_IE_BBAND_LOCKING_SHIFT,		"Broadband locking shift" },
320 	{ Q2931_IE_BBAND_NLOCKING_SHIFT,	"Broadband non-locking shift" },
321 	{ Q2931_IE_BBAND_SENDING_COMPL,		"Broadband sending complete" },
322 	{ Q2931_IE_BBAND_RPT_INDICATOR,		"Broadband repeat indicator" },
323 	{ Q2931_IE_CALLING_PARTY_NUMBER,	"Calling party number" },
324 	{ Q2931_IE_CALLING_PARTY_SUBADDR,	"Calling party subaddress" },
325 	{ Q2931_IE_CALLED_PARTY_NUMBER,		"Called party number" },
326 	{ Q2931_IE_CALLED_PARTY_SUBADDR,	"Called party subaddress" },
327 	{ Q2931_IE_TRANSIT_NETWORK_SEL,		"Transit network selection" },
ShouldRollupOnMouseWheelEvent()328 	{ Q2931_IE_RESTART_INDICATOR,		"Restart indicator" },
329 	{ Q2931_IE_NBAND_LOW_LAYER_COMPAT,	"Narrowband low-layer compatibility" },
330 	{ Q2931_IE_NBAND_HIGH_LAYER_COMPAT,	"Narrowband high-layer compatibility" },
331 	{ Q2931_IE_GENERIC_IDENT_TRANSPORT,	"Generic identifier transport" },
332 	{ 0,					NULL }
333 };
334 
335 static value_string_ext q2931_info_element_vals_ext = VALUE_STRING_EXT_INIT(q2931_info_element_vals);
336 
337 /*
338  * Dissect a locking or non-locking shift information element.
339  */
340 static const value_string q2931_codeset_vals[] = {
341 	{ 0x00, "Q.2931 information elements" },
342 	{ 0x04, "Information elements for ISO/IEC use" },
343 	{ 0x05, "Information elements for national use" },
344 	{ 0x06, "Information elements specific to the local network" },
345 	{ 0x07, "User-specific information elements" },
346 	{ 0x00, NULL },
347 };
348 
349 static const true_false_string tfs_q2931_handling_instructions = { "Follow explicit error handling instructions",
350 																   "Regular error handling procedures apply" };
351 
352 static void
353 dissect_q2931_shift_ie(tvbuff_t *tvb, int offset, int len,
ShouldConsumeOnMouseWheelEvent()354 		       proto_tree *tree, guint8 info_element)
355 {
356 	gboolean non_locking_shift;
357 	guint8 codeset;
358 
359 	if (len == 0)
360 		return;
361 	non_locking_shift = (info_element == Q2931_IE_BBAND_NLOCKING_SHIFT);
362 	codeset = tvb_get_guint8(tvb, offset) & 0x07;
363 	proto_tree_add_uint_format(tree, hf_q2931_locking_codeset, tvb, offset, 1, codeset,
364 		"%s shift to codeset %u: %s",
365 		(non_locking_shift ? "Non-locking" : "Locking"),
366 		codeset, val_to_str(codeset, q2931_codeset_vals, "Unknown (0x%02X)"));
367 }
368 
369 /*
ShouldRollupOnMouseActivate()370  * Dissect an ATM adaptation layer parameters information element.
371  */
372 #define	Q2931_AAL_VOICE		0x00
373 #define	Q2931_AAL1		0x01
374 #define	Q2931_AAL2		0x02
375 #define	Q2931_AAL3_4		0x03
376 #define	Q2931_AAL5		0x05
377 #define	Q2931_USER_DEFINED_AAL	0x10
378 
379 static const value_string q9231_aal_type_vals[] = {
380 	{ 0x00, "AAL for voice" },
381 	{ 0x01, "AAL type 1" },
382 	{ 0x02, "AAL type 2" },
383 	{ 0x03, "AAL type 3/4" },
384 	{ 0x05, "AAL type 5" },
385 	{ 0x10, "User-defined AAL" },
386 	{ 0,    NULL }
387 };
388 
389 static const value_string q9231_aal1_subtype_vals[] = {
390 	{ 0x00, "Null" },
391 	{ 0x01, "64 kbit/s voice-band signal transport (G.711/G.722)" },
392 	{ 0x02, "Circuit transport (I.363)" },
393 	{ 0x03, "Circuit emulation (asynchronous)" },
394 	{ 0x04, "High-quality audio signal transport (I.363)" },
395 	{ 0x05, "Video signal transport (I.363)" },
396 	{ 0x00, NULL }
397 };
398 
399 #define	Q2931_AAL1_nx64_KBIT_S	0x40
400 #define	Q2931_AAL1_nx8_KBIT_S	0x41
401 
402 static const value_string q9231_aal1_cbr_rate_vals[] = {
403 	{ 0x01,                   "64 kbit/s" },
404 	{ 0x04,                   "1544 kbit/s" },
405 	{ 0x05,                   "6312 kbit/s" },
406 	{ 0x06,                   "32064 kbit/s" },
GetRollupWidget()407 	{ 0x07,                   "44736 kbit/s" },
408 	{ 0x08,                   "97728 kbit/s" },
409 	{ 0x10,                   "2048 kbit/s" },
410 	{ 0x11,                   "8448 kibt/s" },
411 	{ 0x12,                   "34368 kbit/s" },
412 	{ 0x13,                   "139264 kbit/s" },
413 	{ Q2931_AAL1_nx64_KBIT_S, "nx64 kbit/s" },
AdjustPopupsOnWindowChange(nsPIDOMWindowOuter * aWindow)414 	{ Q2931_AAL1_nx8_KBIT_S,  "nx8 kbit/s" },
415 	{ 0x00,                   NULL }
416 };
417 
418 static const value_string q2931_aal1_src_clk_rec_meth_vals[] = {
419 	{ 0x00, "Null (synchronous circuit transport)" },
420 	{ 0x01, "SRTS method (asynchronous circuit transport" },
421 	{ 0x02, "Adaptive clock method" },
422 	{ 0x00, NULL }
423 };
424 
425 static const value_string q2931_aal1_err_correction_method_vals[] = {
426 	{ 0x00, "Null" },
427 	{ 0x01, "FEC method for less sensitive signal transport" },
428 	{ 0x02, "FEC method for delay-sensitive signal transport" },
429 	{ 0x00, NULL }
430 };
431 
432 static const value_string q2931_aal_mode_vals[] = {
433 	{ 0x01, "Message" },
434 	{ 0x02, "Streaming" },
435 	{ 0x00, NULL }
436 };
437 
438 static const value_string q2931_sscs_type_vals[] = {
439 	{ 0x00, "Null" },
440 	{ 0x01, "Data SSCS based on SSCOP (assured operation)" },
441 	{ 0x02, "Data SSCS based on SSCOP (non-assured operation)" },
442 	{ 0x04, "Frame relay SSCS" },
443 	{ 0x00, NULL }
444 };
445 
446 static void
447 dissect_q2931_aal_parameters_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
448 				proto_tree *tree)
449 {
450 	guint8 aal_type;
AdjustPopupsOnWindowChange(nsIPresShell * aPresShell)451 	guint8 identifier;
452 	guint32 value;
453 	guint32 low_mid, high_mid;
454 	proto_item* ti;
455 
456 	if (len == 0)
457 		return;
458 	aal_type = tvb_get_guint8(tvb, offset);
GetPopupToMoveOrResize(nsIFrame * aFrame)459 	proto_tree_add_item(tree, hf_q2931_aal_type, tvb, offset, 1, ENC_BIG_ENDIAN);
460 	offset += 1;
461 	len -= 1;
462 
463 	/*
464 	 * Now get the rest of the IE.
465 	 */
466 	if (aal_type == 0x40) {
467 		/*
468 		 * User-defined AAL.
469 		 */
470 		if (len > 4)
471 			len = 4;
472 		proto_tree_add_item(tree, hf_q2931_user_defined_aal_information, tvb, offset, len, ENC_NA);
473 		return;
474 	}
475 
476 	while (len >= 0) {
PopupMoved(nsIFrame * aFrame,nsIntPoint aPnt)477 		identifier = tvb_get_guint8(tvb, offset);
478 		ti = proto_tree_add_item(tree, hf_q2931_aal_parameter_identifier, tvb, offset, 1, ENC_NA);
479 		offset++;
480 		len--;
481 		switch (identifier) {
482 
483 		case 0x85:	/* Subtype identifier for AAL1 */
484 			if (len < 1)
485 				return;
486 			proto_tree_add_item(tree, hf_q2931_aal1_subtype, tvb, offset, 1, ENC_NA);
487 			offset++;
488 			len--;
489 			break;
490 
491 		case 0x86:	/* CBR identifier for AAL1 */
492 			if (len < 1)
493 				return;
494 			proto_tree_add_item(tree, hf_q2931_aal1_cbr_rate, tvb, offset, 1, ENC_NA);
495 			offset++;
496 			len--;
497 			break;
498 
499 		case 0x87:	/* Multiplier identifier for AAL1 */
500 			if (len < 2)
501 				return;
502 			proto_tree_add_item(tree, hf_q2931_aal1_multiplier, tvb, offset, 2, ENC_BIG_ENDIAN);
503 			offset += 2;
504 			len -= 2;
505 			break;
506 
507 		case 0x88:	/* Source clock frequency recovery method identifier for AAL1 */
508 			if (len < 1)
509 				return;
510 			proto_tree_add_item(tree, hf_q2931_aal1_source_clock_frequency_recovery_method, tvb, offset, 1, ENC_NA);
511 			offset++;
512 			len--;
PopupResized(nsIFrame * aFrame,LayoutDeviceIntSize aSize)513 			break;
514 
515 		case 0x89:	/* Error correction method identifier for AAL1 */
516 			if (len < 1)
517 				return;
518 			proto_tree_add_item(tree, hf_q2931_aal1_error_correction_method, tvb, offset, 1, ENC_NA);
519 			offset++;
520 			len--;
521 			break;
522 
523 		case 0x8A:	/* Structured data transfer block size identifier for AAL1 */
524 			if (len < 2)
525 				return;
526 			proto_tree_add_item(tree, hf_q2931_aal1_structured_data_transfer_block_size, tvb, offset, 2, ENC_BIG_ENDIAN);
527 			offset += 2;
528 			len -= 2;
529 			break;
530 
531 		case 0x8B:	/* Partially filled cells identifier for AAL1 */
532 			if (len < 1)
533 				return;
534 			value = tvb_get_guint8(tvb, offset);
535 			proto_tree_add_uint_format_value(tree, hf_q2931_aal1_partially_filled_cells_method, tvb, offset, 1,
536 			    value, "%u octets", value);
537 			offset++;
538 			len--;
539 			break;
540 
541 		case 0x8C:	/* Forward maximum CPCS-SDU size identifier for AAL3/4 and AAL5 */
542 			if (len < 2)
543 				return;
544 			proto_tree_add_item(tree, hf_q2931_aal1_forward_max_cpcs_sdu_size, tvb, offset, 2, ENC_BIG_ENDIAN);
545 			offset += 2;
546 			len -= 2;
547 			break;
548 
549 		case 0x81:	/* Backward maximum CPCS-SDU size identifier for AAL3/4 and AAL5 */
550 			if (len < 2)
GetPopupFrameForContent(nsIContent * aContent,bool aShouldFlush)551 				return;
552 			proto_tree_add_item(tree, hf_q2931_aal1_backward_max_cpcs_sdu_size, tvb, offset, 2, ENC_BIG_ENDIAN);
553 			offset += 2;
554 			len -= 2;
555 			break;
556 
557 		case 0x82:	/* MID range identifier for AAL3/4 */
558 			if (len < 4)
559 				return;
560 			low_mid = tvb_get_ntohs(tvb, offset);
561 			high_mid = tvb_get_ntohs(tvb, offset + 2);
562 			proto_tree_add_uint_format_value(tree, hf_q2931_midrange, tvb, offset, 4, tvb_get_ntohl(tvb, offset),
563 											"%u - %u", low_mid, high_mid);
564 			offset += 4;
565 			len -= 4;
GetTopVisibleMenu()566 			break;
567 
568 		case 0x83:	/* Mode identifier for AAL3/4 and AAL5 */
569 			if (len < 1)
570 				return;
571 			proto_tree_add_item(tree, hf_q2931_aal1_mode, tvb, offset, 1, ENC_NA);
572 			offset++;
573 			len--;
574 			break;
GetMouseLocation(nsIDOMNode ** aNode,int32_t * aOffset)575 
576 		case 0x84:	/* SSCS type identifier for AAL3/4 and AAL5 */
577 			if (len < 1)
578 				return;
579 			proto_tree_add_item(tree, hf_q2931_aal1_sscs_type, tvb, offset, 1, ENC_NA);
580 			offset++;
581 			len--;
582 			break;
InitTriggerEvent(nsIDOMEvent * aEvent,nsIContent * aPopup,nsIContent ** aTriggerContent)583 
584 		default:	/* unknown AAL parameter */
585 			expert_add_info(pinfo, ti, &ei_q2931_aal_parameter_identifier);
586 			return;	/* give up */
587 		}
588 	}
589 }
590 
591 /*
592  * Dissect an ATM traffic descriptor information element.
593  */
594 #define	Q2931_ATM_CR_FW_PEAK_CLP_0		0x82	/* Forward peak cell rate (CLP = 0) */
595 #define	Q2931_ATM_CR_BW_PEAK_CLP_0		0x83	/* Backward peak cell rate (CLP = 0) */
596 #define	Q2931_ATM_CR_FW_PEAK_CLP_0_1	0x84	/* Forward peak cell rate (CLP = 0 + 1) */
597 #define	Q2931_ATM_CR_BW_PEAK_CLP_0_1	0x85	/* Backward peak cell rate (CLP = 0 + 1) */
598 #define	Q2931_ATM_CR_FW_SUST_CLP_0		0x88	/* Forward sustainable cell rate (CLP = 0) */
599 #define	Q2931_ATM_CR_BW_SUST_CLP_0		0x89	/* Backward sustainable cell rate (CLP = 0) */
600 #define	Q2931_ATM_CR_FW_SUST_CLP_0_1	0x90	/* Forward sustainable cell rate (CLP = 0 + 1) */
601 #define	Q2931_ATM_CR_BW_SUST_CLP_0_1	0x91	/* Backward sustainable cell rate (CLP = 0 + 1) */
602 #define	Q2931_ATM_CR_FW_MAXB_CLP_0		0xA0	/* Forward maximum burst size (CLP = 0) */
603 #define	Q2931_ATM_CR_BW_MAXB_CLP_0		0xA1	/* Backward maximum burst size (CLP = 0) */
604 #define	Q2931_ATM_CR_FW_MAXB_CLP_0_1	0xB0	/* Forward maximum burst size (CLP = 0 + 1) */
605 #define	Q2931_ATM_CR_BW_MAXB_CLP_0_1	0xB1	/* Backward maximum burst size (CLP = 0 + 1) */
606 #define	Q2931_ATM_CR_BEST_EFFORT_IND	0xBE	/* Best effort indicator */
607 #define	Q2931_ATM_CR_TRAFFIC_MGMT_OPT	0xBF	/* Traffic management options */
608 
609 static const value_string q2931_atm_td_subfield_vals[] = {
610 	{ Q2931_ATM_CR_FW_PEAK_CLP_0,	"Forward peak cell rate (CLP = 0)" },
611 	{ Q2931_ATM_CR_BW_PEAK_CLP_0,	"Backward peak cell rate (CLP = 0)" },
612 	{ Q2931_ATM_CR_FW_PEAK_CLP_0_1,	"Forward peak cell rate (CLP = 0 + 1)" },
613 	{ Q2931_ATM_CR_BW_PEAK_CLP_0_1,	"Backward peak cell rate (CLP = 0 + 1)" },
614 	{ Q2931_ATM_CR_FW_SUST_CLP_0,	"Forward sustainable cell rate (CLP = 0)" },
615 	{ Q2931_ATM_CR_BW_SUST_CLP_0,	"Backward sustainable cell rate (CLP = 0)" },
616 	{ Q2931_ATM_CR_FW_SUST_CLP_0_1,	"Forward sustainable cell rate (CLP = 0 + 1)" },
617 	{ Q2931_ATM_CR_BW_SUST_CLP_0_1,	"Backward sustainable cell rate (CLP = 0 + 1)" },
618 	{ Q2931_ATM_CR_FW_MAXB_CLP_0,	"Forward maximum burst size (CLP = 0)" },
619 	{ Q2931_ATM_CR_BW_MAXB_CLP_0,	"Backward maximum burst size (CLP = 0)" },
620 	{ Q2931_ATM_CR_FW_MAXB_CLP_0_1,	"Forward maximum burst size (CLP = 0 + 1)" },
621 	{ Q2931_ATM_CR_BW_MAXB_CLP_0_1,	"Backward maximum burst size (CLP = 0 + 1)" },
622 	{ Q2931_ATM_CR_BEST_EFFORT_IND,	"Best effort indicator" },
623 	{ Q2931_ATM_CR_TRAFFIC_MGMT_OPT,"Traffic management options" },
624 	{ 0x0,				NULL }
625 };
626 
627 static const unit_name_string units_cells_s = { " cell/s", " cells/s" };
628 
629 static void
630 dissect_q2931_atm_cell_rate_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
631 			       proto_tree *tree)
632 {
633 	guint8 identifier;
634 	guint32 value;
635 	proto_item* ti;
636 
637 	while (len >= 0) {
638 		identifier = tvb_get_guint8(tvb, offset);
639 		ti = proto_tree_add_item(tree, hf_q2931_atm_identifier, tvb, offset, 1, ENC_NA);
640 
641 		switch (identifier) {
642 
643 		case Q2931_ATM_CR_FW_PEAK_CLP_0:
644 		case Q2931_ATM_CR_BW_PEAK_CLP_0:
645 		case Q2931_ATM_CR_FW_PEAK_CLP_0_1:
646 		case Q2931_ATM_CR_BW_PEAK_CLP_0_1:
647 		case Q2931_ATM_CR_FW_SUST_CLP_0:
648 		case Q2931_ATM_CR_BW_SUST_CLP_0:
649 		case Q2931_ATM_CR_FW_SUST_CLP_0_1:
650 		case Q2931_ATM_CR_BW_SUST_CLP_0_1:
651 		case Q2931_ATM_CR_FW_MAXB_CLP_0:
652 		case Q2931_ATM_CR_BW_MAXB_CLP_0:
653 		case Q2931_ATM_CR_FW_MAXB_CLP_0_1:
654 		case Q2931_ATM_CR_BW_MAXB_CLP_0_1:
655 			if (len < 4)
656 				return;
657 
658 			value = tvb_get_ntoh24(tvb, offset + 1);
659 			proto_tree_add_uint(tree, hf_q2931_atm_identifier_value, tvb, offset+3, 3, value);
660 			offset += 4;
SetActiveMenuBar(nsMenuBarFrame * aMenuBar,bool aActivate)661 			len -= 4;
662 			break;
663 
664 		case Q2931_ATM_CR_BEST_EFFORT_IND:
665 			/* Yes, its value *IS* 0xBE.... */
666 			offset += 1;
667 			len -= 1;
668 			break;
669 
670 		case Q2931_ATM_CR_TRAFFIC_MGMT_OPT:
671 			if (len < 2)
ShowMenu(nsIContent * aMenu,bool aSelectFirstItem,bool aAsynchronous)672 				return;
673 			proto_tree_add_item(tree, hf_q2931_frame_discard_forward_dir, tvb, offset + 1, 1, ENC_NA);
674 			proto_tree_add_item(tree, hf_q2931_frame_discard_backward_dir, tvb, offset + 1, 1, ENC_NA);
675 			proto_tree_add_item(tree, hf_q2931_tagging_backward_dir, tvb, offset + 1, 1, ENC_NA);
676 			proto_tree_add_item(tree, hf_q2931_tagging_forward_dir, tvb, offset + 1, 1, ENC_NA);
677 			offset += 2;
678 			len -= 2;
679 			break;
680 
681 		default:	/* unknown ATM traffic descriptor element */
682 			expert_add_info(pinfo, ti, &ei_q2931_atm_identifier);
683 			return;	/* give up */
684 		}
685 	}
686 }
687 
688 /*
689  * Dissect a broadband bearer capability information element.
690  */
691 static const value_string q2931_bearer_class_vals[] = {
692 	{ 0x01, "BCOB-A" },
693 	{ 0x03, "BCOB-C" },
694 	{ 0x10, "BCOB-X" },
695 	{ 0x18, "Transparent VP Service" },
696 	{ 0x00, NULL }
697 };
698 
699 static const value_string q2931_transfer_capability_vals[] = {
700 	{ 0x00, "No bit rate indication" },
701 	{ 0x01, "No bit rate indication, end-to-end timing required" },
702 	{ 0x02, "No bit rate indication, end-to-end timing not required" },
703 	{ 0x04, "CBR" },
704 	{ 0x05, "CBR, end-to-end timing required" },
705 	{ 0x06, "CBR, end-to-end timing not required" },
706 	{ 0x07, "CBR with CLR commitment on CLP=0+1" },
707 	{ 0x08, "VBR, no timing requirements indication" },
708 	{ 0x09, "Real time VBR" },
709 	{ 0x0A, "Non-real time VBR" },
710 	{ 0x0B, "Non-real time VBR with CLR commitment on CLP=0+1" },
711 	{ 0x0C, "ABR" },
712 	{ 0x00, NULL }
713 };
714 
715 static const value_string q2931_susc_clip_vals[] = {
716 	{ 0x00, "Not susceptible to clipping" },
717 	{ 0x20, "Susceptible to clipping" },
718 	{ 0x00, NULL }
719 };
720 
721 static const value_string q2931_up_conn_config_vals[] = {
722 	{ 0x00, "Point-to-point" },
723 	{ 0x01, "Point-to-multipoint" },
724 	{ 0x00, NULL }
725 };
726 
727 static void
728 dissect_q2931_bband_bearer_cap_ie(tvbuff_t *tvb, int offset, int len,
729 				  proto_tree *tree)
730 {
731 	guint8 octet;
732 
733 	if (len == 0)
734 		return;
735 	octet = tvb_get_guint8(tvb, offset);
736 	proto_tree_add_item(tree, hf_q2931_bearer_class, tvb, offset, 1, ENC_BIG_ENDIAN);
737 	offset += 1;
738 	len -= 1;
739 
740 	if (len == 0)
741 		return;
742 	if (!(octet & Q2931_IE_EXTENSION)) {
743 		proto_tree_add_item(tree, hf_q2931_atm_transfer_capability, tvb, offset, 1, ENC_BIG_ENDIAN);
744 		offset += 1;
745 		len -= 1;
746 	}
747 
748 	if (len == 0)
749 		return;
750 	proto_tree_add_item(tree, hf_q2931_susceptibility_to_clipping, tvb, offset, 1, ENC_BIG_ENDIAN);
751 	proto_tree_add_item(tree, hf_q2931_user_plane_connection_configuration, tvb, offset, 1, ENC_BIG_ENDIAN);
752 }
ShowPopup(nsIContent * aPopup,nsIContent * aAnchorContent,const nsAString & aPosition,int32_t aXPos,int32_t aYPos,bool aIsContextMenu,bool aAttributesOverride,bool aSelectFirstItem,nsIDOMEvent * aTriggerEvent)753 
754 /*
755  * Dissect a broadband high layer information information element.
756  */
757 static const value_string q2931_hi_layer_info_type_vals[] = {
758 	{ 0x00, "ISO/IEC" },
759 	{ 0x01, "User-specific" },
760 	{ 0x03, "Vendor-specific" },
761 	{ 0x04, "ITU-T SG 1 B-ISDN teleservice recommendation" },
762 	{ 0x00, NULL }
763 };
764 
765 static void
766 dissect_q2931_bband_hi_layer_info_ie(tvbuff_t *tvb, int offset, int len,
767 				     proto_tree *tree)
768 {
769 	if (len == 0)
770 		return;
771 
772 	proto_tree_add_item(tree, hf_q2931_high_layer_information_type, tvb, offset, 1, ENC_BIG_ENDIAN);
773 	/*offset += 1; */
774 	/* len -= 1; */
775 }
ShowPopupAtScreen(nsIContent * aPopup,int32_t aXPos,int32_t aYPos,bool aIsContextMenu,nsIDOMEvent * aTriggerEvent)776 
777 /*
778  * Dissect a Bearer capability or Low-layer compatibility information element.
779  */
780 #define	Q2931_UIL2_USER_SPEC	0x10
781 
782 static const value_string q2931_uil2_vals[] = {
783 	{ 0x01,			"Basic mode ISO 1745" },
784 	{ 0x02,			"Q.921/I.441" },	/* LAPD */
785 	{ 0x06,			"X.25, link layer" },	/* LAPB */
786 	{ 0x07,			"X.25 multilink" },	/* or 0x0F? */
787 	{ 0x08,			"T.71 Extended LAPB" },
788 	{ 0x09,			"HDLC ARM" },
789 	{ 0x0A,			"HDLC NRM" },
790 	{ 0x0B,			"HDLC ABM" },
791 	{ 0x0C,			"ISO 8802/2 LLC" },
792 	{ 0x0D,			"X.75 Single Link Procedure" },
793 	{ 0x0E,			"Q.922" },
794 	{ Q2931_UIL2_USER_SPEC,	"User-specified" },
795 	{ 0x11,			"ISO 7776 DTE-DTE operation" },
796 	{ 0,			NULL }
797 };
798 
799 static const value_string q2931_mode_vals[] = {
800 	{ 0x20, "Normal mode" },
801 	{ 0x40, "Extended mode" },
802 	{ 0,    NULL }
803 };
804 
805 #define	Q2931_UIL3_X25_PL	0x06
806 #define	Q2931_UIL3_ISO_8208	0x07	/* X.25-based */
807 #define	Q2931_UIL3_X223		0x08	/* X.25-based */
808 #define	Q2931_UIL3_TR_9577	0x0B
809 #define	Q2931_UIL3_USER_SPEC	0x10
810 
811 static const value_string q2931_uil3_vals[] = {
812 	{ Q2931_UIL3_X25_PL,	"X.25, packet layer" },
813 	{ Q2931_UIL3_ISO_8208,	"ISO/IEC 8208" },
ShowTooltipAtScreen(nsIContent * aPopup,nsIContent * aTriggerContent,int32_t aXPos,int32_t aYPos)814 	{ Q2931_UIL3_X223,	"X.223/ISO 8878" },
815 	{ 0x09,			"ISO/IEC 8473" },
816 	{ 0x0A,			"T.70" },
817 	{ Q2931_UIL3_TR_9577,	"ISO/IEC TR 9577" },
818 	{ Q2931_UIL3_USER_SPEC,	"User-specified" },
819 	{ 0,			NULL }
820 };
821 
822 static const value_string lane_pid_vals[] = {
823 	{ 0x0001, "LE Configuration Direct/Control Direct/Control Distribute" },
824 	{ 0x0002, "Ethernet/IEEE 002.3 LE Data Direct" },
825 	{ 0x0003, "IEEE 802.5 LE Data Direct" },
826 	{ 0x0004, "Ethernet/IEEE 802.3 LE Multicast Send/Multicast Forward" },
827 	{ 0x0005, "IEEE 802.5 LE Multicast Send/Multicast Forward" },
828 	{ 0,      NULL },
829 };
830 
831 /*
832  * Dissect a broadband low layer information information element.
833  */
834 static void
835 dissect_q2931_bband_low_layer_info_ie(tvbuff_t *tvb, int offset, int len,
836 				      proto_tree *tree)
837 {
838 	guint8 octet;
839 	guint8 uil2_protocol;
840 	guint8 uil3_protocol;
841 	guint8 add_l3_info;
842 	guint32 organization_code;
ShowPopupWithAnchorAlign(nsIContent * aPopup,nsIContent * aAnchorContent,nsAString & aAnchor,nsAString & aAlign,int32_t aXPos,int32_t aYPos,bool aIsContextMenu)843 
844 	if (len == 0)
845 		return;
846 	octet = tvb_get_guint8(tvb, offset);
847 	if ((octet & 0x60) == 0x20) {
848 		/*
849 		 * Layer 1 information.
850 		 */
851 		proto_tree_add_item(tree, hf_q2931_bband_low_layer_info_user_info_l1_proto, tvb, offset, 1, ENC_BIG_ENDIAN);
852 		offset += 1;
853 		len -= 1;
854 	}
855 
856 	if (len == 0)
857 		return;
858 	octet = tvb_get_guint8(tvb, offset);
859 	if ((octet & 0x60) == 0x40) {
860 		/*
861 		 * Layer 2 information.
CheckCaretDrawingState()862 		 */
863 		uil2_protocol = octet & 0x1F;
864 		proto_tree_add_item(tree, hf_q2931_bband_low_layer_info_user_info_l2_proto, tvb, offset, 1, ENC_BIG_ENDIAN);
865 		offset += 1;
866 		len -= 1;
867 
868 		if (octet & Q2931_IE_EXTENSION)
869 			goto l2_done;
870 		if (len == 0)
871 			return;
872 		octet = tvb_get_guint8(tvb, offset);
873 		if (uil2_protocol == Q2931_UIL2_USER_SPEC) {
874 			proto_tree_add_item(tree, hf_q2931_bband_low_layer_info_user_specified_l2_proto, tvb, offset, 1, ENC_BIG_ENDIAN);
875 		} else {
876 			proto_tree_add_item(tree, hf_q2931_bband_low_layer_info_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
877 		}
878 		offset += 1;
879 		len -= 1;
880 
881 		if (octet & Q2931_IE_EXTENSION)
882 			goto l2_done;
883 		if (len == 0)
884 			return;
885 		octet = tvb_get_guint8(tvb, offset);
886 		proto_tree_add_uint_format_value(tree, hf_q2931_bband_low_layer_info_window_size, tvb, offset, 1,
887 		    octet & 0x7F, "%u k", octet & 0x7F);
888 		offset += 1;
889 		len -= 1;
890 	}
891 l2_done:
ShowPopupCallback(nsIContent * aPopup,nsMenuPopupFrame * aPopupFrame,bool aIsContextMenu,bool aSelectFirstItem)892 	;
893 
894 	if (len == 0)
895 		return;
896 	octet = tvb_get_guint8(tvb, offset);
897 	if ((octet & 0x60) == 0x60) {
898 		/*
899 		 * Layer 3 information.
900 		 */
901 		uil3_protocol = octet & 0x1F;
902 		proto_tree_add_item(tree, hf_q2931_bband_low_layer_info_user_info_l3_proto, tvb, offset, 1, ENC_BIG_ENDIAN);
903 		offset += 1;
904 		len -= 1;
905 
906 
907 		/*
908 		 * XXX - only in Low-layer compatibility information element.
909 		 */
910 		if (octet & Q2931_IE_EXTENSION)
911 			goto l3_done;
912 		if (len == 0)
913 			return;
914 		octet = tvb_get_guint8(tvb, offset);
915 		switch (uil3_protocol) {
916 
917 		case Q2931_UIL3_X25_PL:
918 		case Q2931_UIL3_ISO_8208:
919 		case Q2931_UIL3_X223:
920 			proto_tree_add_item(tree, hf_q2931_bband_low_layer_info_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
921 			offset += 1;
922 			len -= 1;
923 
924 			if (octet & Q2931_IE_EXTENSION)
925 				goto l3_done;
926 			if (len == 0)
927 				return;
928 			octet = tvb_get_guint8(tvb, offset);
929 			proto_tree_add_item(tree, hf_q2931_bband_low_layer_info_default_packet_size, tvb, offset, 1, ENC_BIG_ENDIAN);
930 			offset += 1;
931 			len -= 1;
932 
933 			if (octet & Q2931_IE_EXTENSION)
934 				goto l3_done;
935 			if (len == 0)
936 				return;
937 			proto_tree_add_item(tree, hf_q2931_bband_low_layer_info_packet_window_size, tvb, offset, 1, ENC_BIG_ENDIAN);
938 			/*offset += 1;*/
939 			/*len -= 1;*/
940 			break;
941 
942 		case Q2931_UIL3_USER_SPEC:
943 			proto_tree_add_uint(tree, hf_q2931_bband_low_layer_info_default_packet_size, tvb, offset, 1, 1 << (octet & 0x0F));
944 			/*offset += 1;*/
945 			/*len -= 1;*/
946 			break;
947 
948 		case Q2931_UIL3_TR_9577:
949 			add_l3_info = (octet & 0x7F) << 1;
950 			if (octet & Q2931_IE_EXTENSION)
951 				goto l3_done;
952 			if (len < 2)
953 				return;
954 			add_l3_info |= (tvb_get_guint8(tvb, offset + 1) & 0x40) >> 6;
955 			proto_tree_add_uint(tree, hf_q2931_bband_low_layer_info_additional_l3_proto, tvb, offset, 2, add_l3_info);
956 			offset += 2;
957 			len -= 2;
958 			if (add_l3_info == NLPID_SNAP) {
959 				if (len < 6)
960 					return;
HidePopup(nsIContent * aPopup,bool aHideChain,bool aDeselectMenu,bool aAsynchronous,bool aIsCancel,nsIContent * aLastPopup)961 				offset += 1;
962 				/*len -= 1;*/
963 				organization_code = tvb_get_ntoh24(tvb, offset);
964 				proto_tree_add_item(tree, hf_q2931_organization_code, tvb, offset, 3, ENC_BIG_ENDIAN);
965 				offset += 3;
966 				/*len -= 3;*/
967 
968 				switch (organization_code) {
969 
970 				case OUI_ENCAP_ETHER:
971 					proto_tree_add_item(tree, hf_q2931_ethernet_type, tvb, offset, 2, ENC_BIG_ENDIAN);
972 					break;
973 
974 				case OUI_ATM_FORUM:
975 					proto_tree_add_item(tree, hf_q2931_lane_protocol_id, tvb, offset, 2, ENC_BIG_ENDIAN);
976 					break;
977 
978 				default:
979 					proto_tree_add_item(tree, hf_q2931_protocol_id, tvb, offset, 2, ENC_BIG_ENDIAN);
980 					break;
981 				}
982 			}
983 			break;
984 		}
985 	}
986 l3_done:
987 	;
988 }
989 
990 /*
991  * Dissect a Cause information element.
992  */
993 static const value_string q2931_cause_location_vals[] = {
994 	{ 0x00, "User (U)" },
995 	{ 0x01, "Private network serving the local user (LPN)" },
996 	{ 0x02, "Public network serving the local user (LN)" },
997 	{ 0x03, "Transit network (TN)" },
998 	{ 0x04, "Public network serving the remote user (RLN)" },
999 	{ 0x05, "Private network serving the remote user (RPN)" },
1000 	{ 0x07, "International network (INTL)" },
1001 	{ 0x0A, "Network beyond interworking point (BI)" },
1002 	{ 0,    NULL }
1003 };
1004 
1005 /*
1006  * Cause codes for Cause.
1007  */
1008 #define	Q2931_CAUSE_UNALLOC_NUMBER	0x01
1009 #define	Q2931_CAUSE_NO_ROUTE_TO_DEST	0x03
1010 #define	Q2931_CAUSE_CALL_REJECTED	0x15
1011 #define	Q2931_CAUSE_NUMBER_CHANGED	0x16
1012 #define	Q2931_CAUSE_CELL_RATE_UNAVAIL	0x25
1013 #define	Q2931_CAUSE_ACCESS_INFO_DISC	0x2B
1014 #define	Q2931_CAUSE_QOS_UNAVAILABLE	0x31
1015 #define	Q2931_CAUSE_CHAN_NONEXISTENT	0x52
1016 #define	Q2931_CAUSE_INCOMPATIBLE_DEST	0x58
1017 #define	Q2931_CAUSE_MAND_IE_MISSING	0x60
1018 #define	Q2931_CAUSE_MT_NONEX_OR_UNIMPL	0x61
1019 #define	Q2931_CAUSE_IE_NONEX_OR_UNIMPL	0x63
1020 #define	Q2931_CAUSE_INVALID_IE_CONTENTS	0x64
1021 #define	Q2931_CAUSE_MSG_INCOMPAT_W_CS	0x65
1022 #define	Q2931_CAUSE_REC_TIMER_EXP	0x66
1023 
1024 static const value_string q2931_cause_code_vals[] = {
1025 	{ Q2931_CAUSE_UNALLOC_NUMBER,	"Unallocated (unassigned) number" },
1026 	{ 0x02,				"No route to specified transit network" },
1027 	{ Q2931_CAUSE_NO_ROUTE_TO_DEST,	"No route to destination" },
1028 	{ 0x04,				"Send special information tone" },
1029 	{ 0x05,				"Misdialled trunk prefix" },
1030 	{ 0x06,				"Channel unacceptable" },
1031 	{ 0x07,				"Call awarded and being delivered in an established channel" },
1032 	{ 0x08,				"Preemption" },
1033 	{ 0x09,				"Preemption - circuit reserved for reuse" },
1034 	{ 0x0E,				"QoR: ported number" },
1035 	{ 0x10,				"Normal call clearing" },
1036 	{ 0x11,				"User busy" },
1037 	{ 0x12,				"No user responding" },
1038 	{ 0x13,				"No answer from user (user alerted)" },
1039 	{ 0x14,				"Subscriber absent" },
1040 	{ Q2931_CAUSE_CALL_REJECTED,	"Call rejected" },
1041 	{ Q2931_CAUSE_NUMBER_CHANGED,	"Number changed" },
1042 	{ 0x17,				"Redirection to new destination" },
1043 	{ 0x18,				"Call rejected due to feature at the destination" },
1044 	{ 0x19,				"Exchange routing error" },
1045 	{ 0x1A,				"Non-selected user clearing" },
1046 	{ 0x1B,				"Destination out of order" },
1047 	{ 0x1C,				"Invalid number format (incomplete number)" },
1048 	{ 0x1E,				"Response to STATUS ENQUIRY" },
1049 	{ 0x1F,				"Normal unspecified" },
1050 	{ 0x20,				"Too many pending add party request" },
1051 	{ 0x23,				"Requested VPCI/VCI not available" },
1052 	{ 0x24,				"VPCI/VCI assignment failure" },
1053 	{ Q2931_CAUSE_CELL_RATE_UNAVAIL,"User cell rate not available" },
1054 	{ 0x26,				"Network out of order" },
1055 	{ 0x27,				"Permanent frame mode connection out of service" },
1056 	{ 0x28,				"Permanent frame mode connection operational" },
1057 	{ 0x29,				"Temporary failure" },
1058 	{ 0x2A,				"Switching equipment congestion" },
1059 	{ Q2931_CAUSE_ACCESS_INFO_DISC,	"Access information discarded" },
1060 	{ 0x2C,				"Requested circuit/channel not available" },
1061 	{ 0x2D,				"No VPCI/VCI available" },
1062 	{ 0x2F,				"Resources unavailable, unspecified" },
1063 	{ Q2931_CAUSE_QOS_UNAVAILABLE,	"Quality of service unavailable" },
1064 	{ 0x32,				"Requested facility not subscribed" },
1065 	{ 0x35,				"Outgoing calls barred within CUG" },
1066 	{ 0x37,				"Incoming calls barred within CUG" },
1067 	{ 0x39,				"Bearer capability not authorized" },
1068 	{ 0x3A,				"Bearer capability not presently available" },
1069 	{ 0x3E,				"Inconsistency in designated outgoing access information and subscriber class" },
1070 	{ 0x3F,				"Service or option not available, unspecified" },
1071 	{ 0x41,				"Bearer capability not implemented" },
1072 	{ 0x42,				"Channel type not implemented" },
1073 	{ 0x45,				"Requested facility not implemented" },
1074 	{ 0x46,				"Only restricted digital information bearer capability is available" },
1075 	{ 0x49,				"Unsupported combination of traffic parameters" },
1076 	{ 0x4E,				"AAL parameters cannot be supported" },
1077 	{ 0x4F,				"Service or option not implemented, unspecified" },
1078 	{ 0x51,				"Invalid call reference value" },
1079 	{ Q2931_CAUSE_CHAN_NONEXISTENT,	"Identified channel does not exist" },
1080 	{ 0x53,				"Call identity does not exist for suspended call" },
1081 	{ 0x54,				"Call identity in use" },
1082 	{ 0x55,				"No call suspended" },
1083 	{ 0x56,				"Call having the requested call identity has been cleared" },
1084 	{ 0x57,				"Called user not member of CUG" },
1085 	{ Q2931_CAUSE_INCOMPATIBLE_DEST,"Incompatible destination" },
1086 	{ 0x59,				"Invalid endpoint reference" },
1087 	{ 0x5A,				"Non-existent CUG" },
1088 	{ 0x5B,				"Invalid transit network selection" },
1089 	{ 0x5C,				"Too many pending ADD PARTY requests" },
~TransitionEnder()1090 	{ 0x5D,				"AAL parameters cannot be supported" },
1091 	{ 0x5F,				"Invalid message, unspecified" },
1092 	{ Q2931_CAUSE_MAND_IE_MISSING,	"Mandatory information element is missing" },
1093 	{ Q2931_CAUSE_MT_NONEX_OR_UNIMPL,"Message type non-existent or not implemented" },
1094 	{ 0x62,				"Message not compatible with call state or message type non-existent or not implemented" },
1095 	{ Q2931_CAUSE_IE_NONEX_OR_UNIMPL,"Information element non-existent or not implemented" },
1096 	{ Q2931_CAUSE_INVALID_IE_CONTENTS,"Invalid information element contents" },
1097 	{ Q2931_CAUSE_MSG_INCOMPAT_W_CS,"Message not compatible with call state" },
NS_DECL_CYCLE_COLLECTION_CLASS(TransitionEnder)1098 	{ Q2931_CAUSE_REC_TIMER_EXP,	"Recovery on timer expiry" },
1099 	{ 0x67,				"Parameter non-existent or not implemented - passed on" },
1100 	{ 0x68,				"Incorrect message length" },
1101 	{ 0x6E,				"Message with unrecognized parameter discarded" },
1102 	{ 0x6F,				"Protocol error, unspecified" },
1103 	{ 0x7F,				"Internetworking, unspecified" },
1104 	{ 0,				NULL }
HandleEvent(nsIDOMEvent * aEvent)1105 };
1106 
1107 static value_string_ext q2931_cause_code_vals_ext = VALUE_STRING_EXT_INIT(q2931_cause_code_vals);
1108 
1109 static const value_string q2931_cause_condition_vals[] = {
1110 	{ 0x00, "Unknown" },
1111 	{ 0x01, "Permanent" },
1112 	{ 0x02, "Transient" },
1113 	{ 0x00, NULL }
1114 };
1115 
1116 #define	Q2931_REJ_USER_SPECIFIC		0x00
1117 #define	Q2931_REJ_IE_MISSING		0x04
1118 #define	Q2931_REJ_IE_INSUFFICIENT	0x08
1119 
1120 static const value_string q2931_rejection_reason_vals[] = {
1121 	{ 0x00, "User specific" },
1122 	{ 0x04, "Information element missing" },
1123 	{ 0x08, "Information element contents are not sufficient" },
1124 	{ 0x00, NULL }
1125 };
1126 
1127 static const true_false_string tfs_abnormal_normal           = { "Abnormal", "Normal" };
1128 
1129 static void
1130 dissect_q2931_cause_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
1131 		       proto_tree *tree)
1132 {
1133 	guint8 octet;
HidePopupCallback(nsIContent * aPopup,nsMenuPopupFrame * aPopupFrame,nsIContent * aNextPopup,nsIContent * aLastPopup,nsPopupType aPopupType,bool aDeselectMenu)1134 	guint8 cause_value;
1135 	guint8 rejection_reason;
1136 	guint8 info_element;
1137 	guint8 info_element_ext;
1138 	guint16 info_element_len;
1139 
1140 	if (len == 0)
1141 		return;
1142 	proto_tree_add_item(tree, hf_q2931_cause_location, tvb, offset, 1, ENC_BIG_ENDIAN);
1143 	offset += 1;
1144 	len -= 1;
1145 
1146 	if (len == 0)
1147 		return;
1148 	octet = tvb_get_guint8(tvb, offset);
1149 	cause_value = octet & 0x7F;
1150 	proto_tree_add_item(tree, hf_q2931_cause_value, tvb, offset, 1, ENC_BIG_ENDIAN);
1151 	offset += 1;
1152 	len -= 1;
1153 
1154 	if (len == 0)
1155 		return;
1156 	switch (cause_value) {
1157 
1158 	case Q2931_CAUSE_UNALLOC_NUMBER:
1159 	case Q2931_CAUSE_NO_ROUTE_TO_DEST:
1160 	case Q2931_CAUSE_QOS_UNAVAILABLE:
1161 		proto_tree_add_item(tree, hf_q2931_cause_network_service, tvb, offset, 1, ENC_NA);
1162 		proto_tree_add_item(tree, hf_q2931_cause_network_behavior, tvb, offset, 1, ENC_NA);
1163 		proto_tree_add_item(tree, hf_q2931_cause_rejection_condition, tvb, offset, 1, ENC_NA);
1164 		break;
1165 
1166 	case Q2931_CAUSE_CALL_REJECTED:
1167 		rejection_reason = octet & 0x7C;
1168 		proto_tree_add_item(tree, hf_q2931_cause_rejection_reason, tvb, offset, 1, ENC_BIG_ENDIAN);
1169 		proto_tree_add_item(tree, hf_q2931_cause_rejection_condition, tvb, offset, 1, ENC_BIG_ENDIAN);
1170 		offset += 1;
1171 		len -= 1;
1172 
1173 		if (len == 0)
1174 			return;
1175 		switch (rejection_reason) {
1176 
1177 		case Q2931_REJ_USER_SPECIFIC:
1178 			proto_tree_add_item(tree, hf_q2931_cause_rejection_user_specific_diagnostic, tvb, offset, len, ENC_NA);
1179 			break;
1180 
1181 		case Q2931_REJ_IE_MISSING:
1182 			proto_tree_add_item(tree, hf_q2931_cause_rejection_missing_information_element, tvb, offset, 1, ENC_BIG_ENDIAN);
1183 			break;
1184 
1185 		case Q2931_REJ_IE_INSUFFICIENT:
1186 			proto_tree_add_item(tree, hf_q2931_cause_rejection_insufficient_information_element, tvb, offset, 1, ENC_BIG_ENDIAN);
1187 			break;
1188 
1189 		default:
1190 			proto_tree_add_item(tree, hf_q2931_cause_rejection_diagnostic, tvb, offset, len, ENC_NA);
1191 			break;
1192 		}
1193 		break;
1194 
1195 	case Q2931_CAUSE_NUMBER_CHANGED:
1196 		/*
1197 		 * UNI 3.1 claims this "is formatted as the called party
1198 		 * number information element, including information
1199 		 * element identifier.
1200 		 */
1201 		info_element = tvb_get_guint8(tvb, offset);
1202 		info_element_ext = tvb_get_guint8(tvb, offset + 1);
1203 		info_element_len = tvb_get_ntohs(tvb, offset + 2);
1204 		dissect_q2931_ie(tvb, pinfo, offset, info_element_len, tree,
1205 		    info_element, info_element_ext);
1206 		break;
1207 
1208 	case Q2931_CAUSE_ACCESS_INFO_DISC:
1209 	case Q2931_CAUSE_INCOMPATIBLE_DEST:
1210 	case Q2931_CAUSE_MAND_IE_MISSING:
1211 	case Q2931_CAUSE_IE_NONEX_OR_UNIMPL:
1212 	case Q2931_CAUSE_INVALID_IE_CONTENTS:
1213 		do {
1214 			proto_tree_add_item(tree, hf_q2931_cause_information_element, tvb, offset, 1, ENC_BIG_ENDIAN);
1215 			offset += 1;
1216 			len -= 1;
1217 		} while (len >= 0);
1218 		break;
1219 
1220 	case Q2931_CAUSE_CELL_RATE_UNAVAIL:
1221 		do {
1222 			proto_tree_add_item(tree, hf_q2931_cause_cell_rate_subfield_identifier, tvb, offset, 1, ENC_BIG_ENDIAN);
1223 			offset += 1;
1224 			len -= 1;
1225 		} while (len >= 0);
1226 		break;
1227 
1228 	case Q2931_CAUSE_CHAN_NONEXISTENT:
HidePopup(nsIFrame * aFrame)1229 		if (len < 2)
1230 			return;
1231 		proto_tree_add_item(tree, hf_q2931_cause_vpci, tvb, offset, 2, ENC_BIG_ENDIAN);
1232 		offset += 2;
1233 		len -= 2;
1234 
1235 		if (len < 2)
1236 			return;
HidePopupAfterDelay(nsMenuPopupFrame * aPopup)1237 		proto_tree_add_item(tree, hf_q2931_cause_vci, tvb, offset, 2, ENC_BIG_ENDIAN);
1238 		break;
1239 
1240 	case Q2931_CAUSE_MT_NONEX_OR_UNIMPL:
1241 	case Q2931_CAUSE_MSG_INCOMPAT_W_CS:
1242 		proto_tree_add_item(tree, hf_q2931_cause_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1243 		break;
1244 
1245 	case Q2931_CAUSE_REC_TIMER_EXP:
1246 		if (len < 3)
1247 			return;
1248 		proto_tree_add_item(tree, hf_q2931_cause_timer, tvb, offset, 3, ENC_ASCII|ENC_NA);
1249 		break;
1250 
1251 	default:
1252 		proto_tree_add_item(tree, hf_q2931_cause_rejection_diagnostic, tvb, offset, len, ENC_NA);
1253 	}
1254 }
1255 
HidePopupsInList(const nsTArray<nsMenuPopupFrame * > & aFrames)1256 /*
1257  * Dissect a Call state information element.
1258  */
1259 static const value_string q2931_call_state_vals[] = {
1260 	{ 0x00, "Null" },
1261 	{ 0x01, "Call initiated" },
1262 	{ 0x02, "Overlap sending" },
1263 	{ 0x03, "Outgoing call proceeding" },
1264 	{ 0x04, "Call delivered" },
1265 	{ 0x06, "Call present" },
1266 	{ 0x07, "Call received" },
1267 	{ 0x09, "Connect request" },
1268 	{ 0x0A, "Incoming call proceeding" },
1269 	{ 0x0B, "Active" },
1270 	{ 0x0C, "Disconnect request" },
1271 	{ 0x0F, "Disconnect indication" },
1272 	{ 0x11, "Suspend request" },
1273 	{ 0x13, "Resume request" },
1274 	{ 0x16, "Release request" },
1275 	{ 0x19, "Overlap receiving" },
1276 	{ 0x3D, "Restart request" },
1277 	{ 0x3E, "Restart" },
1278 	{ 0,    NULL }
1279 };
1280 
1281 static void
EnableRollup(nsIContent * aPopup,bool aShouldRollup)1282 dissect_q2931_call_state_ie(tvbuff_t *tvb, int offset, int len,
1283 			    proto_tree *tree)
1284 {
1285 	if (len == 0)
1286 		return;
1287 
1288 	proto_tree_add_item(tree, hf_q2931_call_state, tvb, offset, 1, ENC_BIG_ENDIAN);
1289 }
1290 
1291 /*
1292  * Dissect a (phone) number information element.
1293  */
1294 static const value_string q2931_number_type_vals[] = {
1295 	{ 0x00, "Unknown" },
1296 	{ 0x10, "International number" },
1297 	{ 0x20, "National number" },
1298 	{ 0x30, "Network specific number" },
1299 	{ 0x40, "Subscriber number" },
1300 	{ 0x60, "Abbreviated number" },
1301 	{ 0,    NULL }
1302 };
1303 
1304 #define	Q2931_ISDN_NUMBERING	0x01
1305 #define	Q2931_NSAP_ADDRESSING	0x02
1306 
1307 static const value_string q2931_numbering_plan_vals[] = {
1308 	{ 0x00,                  "Unknown" },
1309 	{ Q2931_ISDN_NUMBERING,  "E.164 ISDN/telephony numbering" },
1310 	{ Q2931_NSAP_ADDRESSING, "ISO/IEC 8348 NSAP addressing" },
1311 	{ 0x09,                  "Private numbering" },
1312 	{ 0,                     NULL }
1313 };
1314 
1315 static const value_string q2931_presentation_indicator_vals[] = {
1316 	{ 0x00, "Presentation allowed" },
IsChildOfDocShell(nsIDocument * aDoc,nsIDocShellTreeItem * aExpected)1317 	{ 0x20, "Presentation restricted" },
1318 	{ 0x40, "Number not available" },
1319 	{ 0,    NULL }
1320 };
1321 
1322 static const value_string q2931_screening_indicator_vals[] = {
1323 	{ 0x00, "User-provided, not screened" },
1324 	{ 0x01, "User-provided, verified and passed" },
1325 	{ 0x02, "User-provided, verified and failed" },
1326 	{ 0x03, "Network-provided" },
1327 	{ 0,    NULL }
1328 };
1329 
1330 static void
1331 dissect_q2931_number_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
1332 			proto_tree *tree)
HidePopupsInDocShell(nsIDocShellTreeItem * aDocShellToHide)1333 {
1334 	guint8 octet;
1335 	guint8 numbering_plan;
1336 	proto_tree *nsap_tree;
1337 
1338 	if (len == 0)
1339 		return;
1340 	octet = tvb_get_guint8(tvb, offset);
1341 	proto_tree_add_item(tree, hf_q2931_number_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1342 	numbering_plan = octet & 0x0F;
1343 	proto_tree_add_item(tree, hf_q2931_number_plan, tvb, offset, 1, ENC_BIG_ENDIAN);
1344 	offset += 1;
1345 	len -= 1;
1346 
1347 	if (!(octet & Q2931_IE_EXTENSION)) {
1348 		if (len == 0)
1349 			return;
1350 
1351 		proto_tree_add_item(tree, hf_q2931_number_presentation_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1352 		proto_tree_add_item(tree, hf_q2931_number_screening_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1353 		offset += 1;
1354 		len -= 1;
1355 	}
1356 
1357 	if (len == 0)
1358 		return;
1359 	switch (numbering_plan) {
1360 
1361 	case Q2931_ISDN_NUMBERING:
1362 		proto_tree_add_item(tree, hf_q2931_number_string, tvb, offset, len, ENC_ASCII|ENC_NA);
1363 		break;
1364 
1365 	case Q2931_NSAP_ADDRESSING:
1366 		if (len < 20) {
1367 			proto_tree_add_item(tree, hf_q2931_nsap_address_number_short, tvb, offset, len, ENC_NA);
1368 			return;
1369 		}
1370 		nsap_tree = proto_tree_add_subtree(tree, tvb, offset, len, ett_q2931_nsap, NULL, "Number");
1371 		dissect_atm_nsap(tvb, pinfo, offset, len, nsap_tree);
1372 		break;
1373 
1374 	default:
1375 		proto_tree_add_item(tree, hf_q2931_number_bytes, tvb, offset, len, ENC_NA);
1376 		break;
1377 	}
1378 }
1379 
1380 /*
1381  * Dissect a party subaddress information element.
1382  */
1383 static const value_string q2931_subaddress_type_vals[] = {
1384 	{ 0x00, "X.213/ISO 8348 NSAP" },
1385 	{ 0x10, "User-specified ATM endsystem address" },
1386 	{ 0x20, "User-specified" },
1387 	{ 0,    NULL }
1388 };
1389 
1390 static const value_string q2931_odd_even_indicator_vals[] = {
1391 	{ 0x00, "Even number of address signals" },
1392 	{ 0x10, "Odd number of address signals" },
1393 	{ 0,    NULL }
1394 };
1395 
1396 static void
1397 dissect_q2931_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
1398 			       proto_tree *tree)
1399 {
1400 	if (len == 0)
1401 		return;
1402 
1403 	proto_tree_add_item(tree, hf_q2931_party_subaddr_type_of_subaddress, tvb, offset, 1, ENC_BIG_ENDIAN);
1404 	proto_tree_add_item(tree, hf_q2931_party_subaddr_odd_even_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1405 	offset += 1;
1406 	len -= 1;
1407 
1408 	if (len == 0)
1409 		return;
1410 	proto_tree_add_item(tree, hf_q2931_party_subaddr_subaddress, tvb, offset, len, ENC_NA);
1411 }
1412 
1413 /*
1414  * Dissect a connection identifier information element.
1415  */
1416 static const value_string q2931_vp_associated_signalling_vals[] = {
1417 	{ 0x00, "Yes" },
FirePopupShowingEvent(nsIContent * aPopup,bool aIsContextMenu,bool aSelectFirstItem)1418 	{ 0x08, "No - explicit indication of VPCI" },
1419 	{ 0x00, NULL }
1420 };
1421 
1422 static const value_string q2931_preferred_exclusive_vals[] = {
1423 	{ 0x00, "Exclusive VPCI; exclusive VCI" },
1424 	{ 0x01, "Exclusive VPCI; any VCI" },
1425 	{ 0x04, "Exclusive VPCI; no VCI" },
1426 	{ 0x00, NULL }
1427 };
1428 
1429 static void
1430 dissect_q2931_connection_identifier_ie(tvbuff_t *tvb, int offset, int len,
1431 				       proto_tree *tree)
1432 {
1433 	if (len == 0)
1434 		return;
1435 
1436 	proto_tree_add_item(tree, hf_q2931_conn_id_vp_associated_signalling, tvb, offset, 1, ENC_BIG_ENDIAN);
1437 	proto_tree_add_item(tree, hf_q2931_conn_id_preferred_exclusive, tvb, offset, 1, ENC_BIG_ENDIAN);
1438 	offset += 1;
1439 	len -= 1;
1440 
1441 	if (len < 2)
1442 		return;
1443 	proto_tree_add_item(tree, hf_q2931_conn_id_vpci, tvb, offset, 2, ENC_BIG_ENDIAN);
1444 	offset += 2;
1445 	len -= 2;
1446 
1447 	if (len < 2)
1448 		return;
1449 	proto_tree_add_item(tree, hf_q2931_conn_id_vci, tvb, offset, 2, ENC_BIG_ENDIAN);
1450 }
1451 
1452 /*
1453  * Dissect an End-to-end transit delay information element.
1454  */
1455 static void
1456 dissect_q2931_e2e_transit_delay_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len, proto_tree *tree)
1457 {
1458 	guint8 identifier;
1459 	guint16 value;
1460 	proto_item* ti;
1461 
1462 	while (len >= 3) {
1463 		ti = proto_tree_add_item(tree, hf_q2931_e2e_transit_delay_identifier, tvb, offset, 1, ENC_BIG_ENDIAN);
1464 		identifier = tvb_get_guint8(tvb, offset);
1465 		offset++;
1466 		value = tvb_get_ntohs(tvb, offset);
1467 		len -=3;
1468 		switch (identifier) {
1469 
1470 		case 0x01:	/* Cumulative transit delay identifier */
1471 			proto_tree_add_uint(tree, hf_q2931_e2e_transit_delay_cumulative, tvb, offset, 2, value);
1472 			break;
1473 
1474 		case 0x03:	/* Maximum transit delay identifier */
1475 			if (value == 0xFFFF) {
1476 				proto_tree_add_uint_format_value(tree, hf_q2931_e2e_transit_delay_maximum_end_to_end, tvb, offset, 2,
1477 				    value, "Any end-to-end transit delay value acceptable");
1478 			} else {
1479 				proto_tree_add_uint_format_value(tree, hf_q2931_e2e_transit_delay_maximum_end_to_end, tvb, offset, 2,
1480 				    value, "%u ms", value);
1481 			}
1482 			break;
1483 
1484 		default:	/* Unknown transit delay identifier */
1485 			expert_add_info(pinfo, ti, &ei_q2931_e2e_transit_delay_identifier);
1486 			return;	/* give up */
1487 		}
1488 	}
1489 }
1490 
1491 /*
1492  * Dissect a Quality of Service parameter information element.
1493  */
1494 static const value_string q2931_qos_parameter_vals[] = {
1495 	{ 0x00, "Unspecified QOS class" },
1496 	{ 0x00, NULL }
1497 };
1498 
1499 static void
1500 dissect_q2931_qos_parameter_ie(tvbuff_t *tvb, int offset, int len,
1501 			       proto_tree *tree)
1502 {
1503 	if (len == 0)
1504 		return;
1505 
1506 	proto_tree_add_item(tree, hf_q2931_qos_class_forward, tvb, offset, 1, ENC_BIG_ENDIAN);
1507 	offset += 1;
1508 	len -= 1;
1509 
1510 	if (len == 0)
1511 		return;
1512 	proto_tree_add_item(tree, hf_q2931_qos_class_backward, tvb, offset, 1, ENC_BIG_ENDIAN);
1513 }
1514 
1515 /*
1516  * Dissect a broadband repeat indicator.
1517  */
1518 static const value_string q2931_bband_rpt_indicator_vals[] = {
1519 	{ 0x02, "Prioritized list for selecting one possibility (descending order)" },
1520 	{ 0x00, NULL }
1521 };
1522 
1523 static void
1524 dissect_q2931_bband_rpt_indicator(tvbuff_t *tvb, int offset, int len,
1525 				  proto_tree *tree)
1526 {
1527 	if (len == 0)
1528 		return;
1529 
1530 	proto_tree_add_item(tree, hf_q2931_broadband_repeat_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1531 }
1532 
FirePopupHidingEvent(nsIContent * aPopup,nsIContent * aNextPopup,nsIContent * aLastPopup,nsPresContext * aPresContext,nsPopupType aPopupType,bool aDeselectMenu,bool aIsCancel)1533 /*
1534  * Dissect a restart indicator.
1535  */
1536 static const value_string q2931_class_vals[] = {
1537 	{ 0x00, "Indicated VC" },
1538 	{ 0x01, "All VC's in the indicated VPC controlled via this channel" },
1539 	{ 0x02, "All VC's controlled by the L3 entity that sent this message" },
1540 	{ 0x00, NULL }
1541 };
1542 
1543 static void
1544 dissect_q2931_restart_indicator(tvbuff_t *tvb, int offset, int len,
1545 				proto_tree *tree)
1546 {
1547 	if (len == 0)
1548 		return;
1549 
1550 	proto_tree_add_item(tree, hf_q2931_restart_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1551 }
1552 
1553 /*
1554  * Dissect an broadband sending complete information element.
1555  */
1556 static void
1557 dissect_q2931_bband_sending_compl_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
1558 				     proto_tree *tree)
1559 {
1560 	guint8 identifier;
1561 	proto_item* ti;
1562 
1563 	while (len >= 0) {
1564 		ti = proto_tree_add_item(tree, hf_q2931_bband_sending_complete_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1565 		identifier = tvb_get_guint8(tvb, offset);
1566 		switch (identifier) {
1567 
1568 		case 0xA1:	/* Sending complete indication */
1569 			proto_tree_add_item(tree, hf_q2931_bband_sending_complete, tvb, offset, 1, ENC_NA);
1570 			offset += 1;
1571 			len -= 1;
1572 			break;
1573 
1574 		default:	/* unknown broadband sending complete element */
1575 			expert_add_info(pinfo, ti, &ei_q2931_bband_sending_complete_id);
1576 			return;	/* give up */
1577 		}
1578 	}
1579 }
1580 
1581 /*
1582  * Dissect a Transit network selection information element.
1583  */
1584 static const value_string q2931_netid_type_vals[] = {
1585 	{ 0x00, "User specified" },
1586 	{ 0x20, "National network identification" },
1587 	{ 0x30, "International network identification" },
1588 	{ 0,    NULL }
1589 };
1590 
1591 static const value_string q2931_netid_plan_vals[] = {
1592 	{ 0x00, "Unknown" },
1593 	{ 0x01, "Carrier Identification Code" },
1594 	{ 0x03, "X.121 data network identification code" },
1595 	{ 0,    NULL }
1596 };
1597 
1598 static void
1599 dissect_q2931_transit_network_sel_ie(tvbuff_t *tvb, int offset, int len,
1600 				     proto_tree *tree)
1601 {
1602 	if (len == 0)
1603 		return;
1604 
1605 	proto_tree_add_item(tree, hf_q2931_transit_network_sel_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1606 	proto_tree_add_item(tree, hf_q2931_transit_network_sel_plan, tvb, offset, 1, ENC_BIG_ENDIAN);
1607 	offset += 1;
1608 	len -= 1;
1609 
1610 	if (len == 0)
1611 		return;
1612 	proto_tree_add_item(tree, hf_q2931_transit_network_sel_network_id, tvb, offset, len, ENC_NA|ENC_ASCII);
1613 }
1614 
1615 /*
1616  * Dissect an OAM traffic descriptor information element.
1617  */
1618 static const value_string q2931_shaping_indicator_vals[] = {
1619 	{ 0x00, "No user specified requirement" },
1620 	{ 0x20, "Aggregate shaping of user and OAM cells not allowed" },
1621 	{ 0,    NULL }
1622 };
1623 
IsPopupOpen(nsIContent * aPopup)1624 static const value_string q2931_user_net_fault_mgmt_vals[] = {
1625 	{ 0x00, "No user-originated fault management indications" },
1626 	{ 0x01, "User-originated fault management indications, cell rate 1 cell/s" },
1627 	{ 0,    NULL }
1628 };
1629 
1630 static const value_string q2931_fwd_e2e_oam_f5_flow_indicator_vals[] = {
1631 	{ 0x00, "0% of the forward cell rate" },
1632 	{ 0x10, "0.1% of the forward cell rate" },
1633 	{ 0x40, "1% of the forward cell rate" },
1634 	{ 0x0,  NULL }
1635 };
1636 
1637 static const value_string q2931_bwd_e2e_oam_f5_flow_indicator_vals[] = {
1638 	{ 0x00, "0% of the backward cell rate" },
1639 	{ 0x01, "0.1% of the backward cell rate" },
1640 	{ 0x04, "1% of the backward cell rate" },
1641 	{ 0x0,  NULL }
1642 };
1643 
1644 static const true_false_string tfs_mandatory_optional = { "Mandatory", "Optional" };
1645 
1646 static void
1647 dissect_q2931_oam_traffic_descriptor_ie(tvbuff_t *tvb, int offset, int len,
1648 					proto_tree *tree)
1649 {
1650 	if (len == 0)
1651 		return;
1652 
1653 	proto_tree_add_item(tree, hf_q2931_oam_traffic_descriptor_shaping_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1654 	proto_tree_add_item(tree, hf_q2931_oam_end_to_end_f5_flow, tvb, offset, 1, ENC_BIG_ENDIAN);
1655 	proto_tree_add_item(tree, hf_q2931_oam_traffic_descriptor_management_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1656 	offset += 1;
IsPopupOpenForMenuParent(nsMenuParent * aMenuParent)1657 	len -= 1;
1658 
1659 	if (len == 0)
1660 		return;
1661 
1662 	proto_tree_add_item(tree, hf_q2931_oam_traffic_descriptor_forward_f5_flow_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1663 	proto_tree_add_item(tree, hf_q2931_oam_traffic_descriptor_backward_f5_flow_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1664 }
1665 
1666 /*
1667  * Dissect an Endpoint reference information element.
1668  */
1669 static const value_string q2931_endpoint_reference_type_vals[] = {
1670 	{ 0x00, "Locally defined integer" },
1671 	{ 0,    NULL }
1672 };
1673 
1674 static const true_false_string tfs_endpoint_reference_flag = { "Message sent to side that originates the endpoint reference",
GetTopPopup(nsPopupType aType)1675 																"Message sent from side that originates the endpoint reference" };
1676 
1677 static void
1678 dissect_q2931_endpoint_reference_ie(tvbuff_t *tvb, int offset, int len,
1679 				    proto_tree *tree)
1680 {
1681 	if (len == 0)
1682 		return;
1683 
1684 	proto_tree_add_item(tree, hf_q2931_endpoint_reference_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1685 	offset += 1;
1686 	len -= 1;
1687 
1688 	if (len < 2)
1689 		return;
1690 
GetVisiblePopups(nsTArray<nsIFrame * > & aPopups)1691 	proto_tree_add_item(tree, hf_q2931_endpoint_reference_flag, tvb, offset, 2, ENC_BIG_ENDIAN);
1692 	proto_tree_add_item(tree, hf_q2931_endpoint_reference_identifier_value, tvb, offset, 2, ENC_BIG_ENDIAN);
1693 }
1694 
1695 /*
1696  * Dissect an Endpoint state information element.
1697  */
1698 static const value_string q2931_endpoint_reference_party_state_vals[] = {
1699 	{ 0x00, "Null" },
1700 	{ 0x01, "ADD PARTY initiated" },
1701 	{ 0x06, "ADD PARTY received" },
1702 	{ 0x0B, "DROP PARTY initiated" },
1703 	{ 0x0C, "DROP PARTY received" },
1704 	{ 0x0A, "Active" },
1705 	{ 0,    NULL }
1706 };
1707 
1708 static void
1709 dissect_q2931_endpoint_state_ie(tvbuff_t *tvb, int offset, int len,
1710 				proto_tree *tree)
1711 {
1712 	if (len == 0)
GetLastTriggerNode(nsIDocument * aDocument,bool aIsTooltip)1713 		return;
1714 
1715 	proto_tree_add_item(tree, hf_q2931_endpoint_state, tvb, offset, 1, ENC_BIG_ENDIAN);
1716 }
1717 
1718 static void
1719 dissect_q2931_ie_contents(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
1720 			  proto_tree *tree, guint8 info_element)
1721 {
1722 	switch (info_element) {
1723 
1724 	case Q2931_IE_BBAND_LOCKING_SHIFT:
1725 	case Q2931_IE_BBAND_NLOCKING_SHIFT:
1726 		dissect_q2931_shift_ie(tvb, offset, len, tree, info_element);
1727 		break;
1728 
1729 	case Q2931_IE_NBAND_BEARER_CAP:
1730 	case Q2931_IE_NBAND_LOW_LAYER_COMPAT:
1731 		dissect_q931_bearer_capability_ie(tvb, offset, len, tree);
1732 		break;
1733 
1734 	case Q2931_IE_NBAND_HIGH_LAYER_COMPAT:
1735 		dissect_q931_high_layer_compat_ie(tvb, offset, len, tree);
1736 		break;
1737 
1738 	case Q2931_IE_PROGRESS_INDICATOR:
1739 		dissect_q931_progress_indicator_ie(tvb, offset, len, tree);
1740 		break;
1741 
1742 	case Q2931_IE_AAL_PARAMETERS:
1743 		dissect_q2931_aal_parameters_ie(tvb, pinfo, offset, len, tree);
1744 		break;
MayShowPopup(nsMenuPopupFrame * aPopup)1745 
1746 	case Q2931_IE_ATM_USER_CELL_RATE:
1747 		dissect_q2931_atm_cell_rate_ie(tvb, pinfo, offset, len, tree);
1748 		break;
1749 
1750 	case Q2931_IE_BBAND_BEARER_CAP:
1751 		dissect_q2931_bband_bearer_cap_ie(tvb, offset, len, tree);
1752 		break;
1753 
1754 	case Q2931_IE_BBAND_HI_LAYER_INFO:
1755 		dissect_q2931_bband_hi_layer_info_ie(tvb, offset, len, tree);
1756 		break;
1757 
1758 	case Q2931_IE_BBAND_LOW_LAYER_INFO:
1759 		dissect_q2931_bband_low_layer_info_ie(tvb, offset, len, tree);
1760 		break;
1761 
1762 	case Q2931_IE_CALL_STATE:
1763 		dissect_q2931_call_state_ie(tvb, offset, len, tree);
1764 		break;
1765 
1766 	case Q2931_IE_CALLED_PARTY_NUMBER:
1767 	case Q2931_IE_CALLING_PARTY_NUMBER:
1768 		dissect_q2931_number_ie(tvb, pinfo, offset, len, tree);
1769 		break;
1770 
1771 	case Q2931_IE_CALLED_PARTY_SUBADDR:
1772 	case Q2931_IE_CALLING_PARTY_SUBADDR:
1773 		dissect_q2931_party_subaddr_ie(tvb, offset, len, tree);
1774 		break;
1775 
1776 	case Q2931_IE_CAUSE:
1777 		dissect_q2931_cause_ie(tvb, pinfo, offset, len, tree);
1778 		break;
1779 
1780 	case Q2931_IE_CONNECTION_IDENTIFIER:
1781 		dissect_q2931_connection_identifier_ie(tvb, offset, len, tree);
1782 		break;
1783 
1784 	case Q2931_IE_E2E_TRANSIT_DELAY:
1785 		dissect_q2931_e2e_transit_delay_ie(tvb, pinfo, offset, len, tree);
1786 		break;
1787 
1788 	case Q2931_IE_QOS_PARAMETER:
1789 		dissect_q2931_qos_parameter_ie(tvb, offset, len, tree);
1790 		break;
1791 
1792 	case Q2931_IE_BBAND_RPT_INDICATOR:
1793 		dissect_q2931_bband_rpt_indicator(tvb, offset, len, tree);
1794 		break;
1795 
1796 	case Q2931_IE_RESTART_INDICATOR:
1797 		dissect_q2931_restart_indicator(tvb, offset, len, tree);
1798 		break;
1799 
1800 	case Q2931_IE_BBAND_SENDING_COMPL:
1801 		dissect_q2931_bband_sending_compl_ie(tvb, pinfo, offset, len, tree);
1802 		break;
1803 
1804 	case Q2931_IE_TRANSIT_NETWORK_SEL:
1805 		dissect_q2931_transit_network_sel_ie(tvb, offset, len, tree);
1806 		break;
1807 
1808 	case Q2931_IE_OAM_TRAFFIC_DESCRIPTOR:
1809 		dissect_q2931_oam_traffic_descriptor_ie(tvb, offset, len, tree);
1810 		break;
1811 
1812 	case Q2931_IE_ENDPOINT_REFERENCE:
1813 		dissect_q2931_endpoint_reference_ie(tvb, offset, len, tree);
1814 		break;
1815 
1816 	case Q2931_IE_ENDPOINT_STATE:
1817 		dissect_q2931_endpoint_state_ie(tvb, offset, len, tree);
1818 		break;
1819 	}
1820 }
1821 
1822 static void
1823 dissect_q2931_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len, proto_tree *tree,
1824 		 guint8 info_element, guint8 info_element_ext)
1825 {
1826 	proto_item	*ti;
1827 	proto_tree	*ie_tree;
1828 	proto_tree	*ie_ext_tree;
1829 
1830 	ie_tree = proto_tree_add_subtree(tree, tvb, offset, 1+1+2+len, ett_q2931_ie, NULL,
1831 	    val_to_str_ext(info_element, &q2931_info_element_vals_ext,
1832 	      "Unknown information element (0x%02X)"));
1833 	proto_tree_add_uint(ie_tree, hf_q2931_information_element, tvb, offset, 1, info_element);
1834 	ti = proto_tree_add_uint(ie_tree, hf_q2931_information_element_extension, tvb, offset + 1, 1, info_element_ext);
1835 	ie_ext_tree = proto_item_add_subtree(ti, ett_q2931_ie_ext);
1836 	proto_tree_add_item(ie_ext_tree, hf_q2931_ie_coding_standard, tvb, offset+1, 1, ENC_BIG_ENDIAN);
1837 	proto_tree_add_item(ie_ext_tree, hf_q2931_ie_handling_instructions, tvb, offset+1, 1, ENC_BIG_ENDIAN);
PopupDestroyed(nsMenuPopupFrame * aPopup)1838 	if (info_element_ext & Q2931_IE_COMPAT_FOLLOW_INST) {
1839 	    proto_tree_add_item(ie_ext_tree, hf_q2931_ie_action_indicator, tvb, offset+1, 1, ENC_BIG_ENDIAN);
1840 	}
1841 	proto_tree_add_uint(ie_tree, hf_q2931_information_element_length, tvb, offset + 2, 2, len);
1842 
1843 	if ((info_element_ext & Q2931_IE_COMPAT_CODING_STD)
1844 	    == Q2931_ITU_STANDARDIZED_CODING) {
1845 		dissect_q2931_ie_contents(tvb, pinfo, offset + 4,
1846 		    len, ie_tree, info_element);
1847 	} else {
1848 		/*
1849 		 * We don't know how it's encoded, so just
1850 		 * dump it as data and be done with it.
1851 		 */
1852 		proto_tree_add_item(ie_tree, hf_q2931_information_element_data, tvb, offset + 4, len, ENC_NA);
1853 	}
1854 }
1855 
1856 static int
1857 dissect_q2931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1858 {
1859 	int	    offset     = 0;
1860 	proto_tree *q2931_tree;
1861 	proto_item *ti;
1862 	guint32	    call_ref_len;
1863 	guint8	    call_ref[16];
1864 	guint8	    message_type;
1865 	guint8	    message_type_ext;
1866 	guint16	    message_len;
1867 	guint8	    info_element;
1868 	guint8	    info_element_ext;
1869 	guint16	    info_element_len;
1870 #if 0
1871 	int	    codeset;
1872 	gboolean    non_locking_shift;
1873 #endif
1874 	static int * const ext_flags[] = {
1875 		&hf_q2931_message_flag,
1876 		NULL
1877 	};
1878 	static int * const ext_flags_follow_inst[] = {
1879 		&hf_q2931_message_flag,
1880 		&hf_q2931_message_action_indicator,
1881 		NULL
1882 	};
1883 
1884 	col_set_str(pinfo->cinfo, COL_PROTOCOL, "Q.2931");
1885 
1886 	ti = proto_tree_add_item(tree, proto_q2931, tvb, offset, -1, ENC_NA);
1887 	q2931_tree = proto_item_add_subtree(ti, ett_q2931);
1888 
1889 	proto_tree_add_item(q2931_tree, hf_q2931_discriminator, tvb, offset, 1, ENC_NA);
1890 	offset += 1;
1891 
1892 	proto_tree_add_item_ret_uint(q2931_tree, hf_q2931_call_ref_len, tvb, offset, 1, ENC_NA, &call_ref_len);
1893 	offset += 1;
1894 	if (call_ref_len != 0) {
1895 		tvb_memcpy(tvb, call_ref, offset, call_ref_len);
1896 		proto_tree_add_boolean(q2931_tree, hf_q2931_call_ref_flag,
1897 			tvb, offset, 1, (call_ref[0] & 0x80) != 0);
1898 		call_ref[0] &= 0x7F;
1899 		proto_tree_add_bytes(q2931_tree, hf_q2931_call_ref, tvb, offset, call_ref_len, call_ref);
1900 		offset += call_ref_len;
1901 	}
1902 	message_type = tvb_get_guint8(tvb, offset);
1903 	col_add_str(pinfo->cinfo, COL_INFO,
HasContextMenu(nsMenuPopupFrame * aPopup)1904 		    val_to_str_ext(message_type, &q2931_message_type_vals_ext,
1905 		      "Unknown message type (0x%02X)"));
1906 
1907 	proto_tree_add_uint(q2931_tree, hf_q2931_message_type, tvb, offset, 1, message_type);
1908 	offset += 1;
1909 
1910 	message_type_ext = tvb_get_guint8(tvb, offset);
1911 	if (message_type_ext & Q2931_MSG_TYPE_EXT_FOLLOW_INST) {
1912 		proto_tree_add_bitmask(q2931_tree, tvb, offset, hf_q2931_message_type_ext, ett_q2931_ext, ext_flags_follow_inst, ENC_NA);
1913 	} else {
1914 		proto_tree_add_bitmask(q2931_tree, tvb, offset, hf_q2931_message_type_ext, ett_q2931_ext, ext_flags, ENC_NA);
1915 	}
1916 	offset += 1;
SetCaptureState(nsIContent * aOldPopup)1917 
1918 	message_len = tvb_get_ntohs(tvb, offset);
1919 	if (q2931_tree != NULL)
1920 		proto_tree_add_uint(q2931_tree, hf_q2931_message_len, tvb, offset, 2, message_len);
1921 	offset += 2;
1922 
1923 	/*
1924 	 * And now for the information elements....
1925 	 */
1926 #if 0
1927 	codeset = 0;	/* start out in codeset 0 */
1928 	non_locking_shift = TRUE;
1929 #endif
1930 	while (tvb_reported_length_remaining(tvb, offset) > 0) {
1931 		info_element = tvb_get_guint8(tvb, offset);
1932 		info_element_ext = tvb_get_guint8(tvb, offset + 1);
1933 		info_element_len = tvb_get_ntohs(tvb, offset + 2);
1934 		if (q2931_tree != NULL) {
1935 			dissect_q2931_ie(tvb, pinfo, offset, info_element_len,
1936 			    q2931_tree, info_element, info_element_ext);
1937 		}
1938 #if 0 /* XXX: Is codeset & etc supposed to be used somehow ? */
1939 		if (non_locking_shift)
1940 			codeset = 0;
UpdateKeyboardListeners()1941 		/*
1942 		 * Handle shifts.
1943 		 */
1944 		switch (info_element) {
1945 
1946 		case Q2931_IE_BBAND_LOCKING_SHIFT:
1947 			if (info_element_len >= 1) {
1948 				non_locking_shift = FALSE;
1949 				codeset = tvb_get_guint8(tvb, offset + 4) & 0x07;
1950 			}
1951 			break;
1952 
1953 		case Q2931_IE_BBAND_NLOCKING_SHIFT:
1954 			if (info_element_len >= 1) {
1955 				non_locking_shift = TRUE;
1956 				codeset = tvb_get_guint8(tvb, offset + 4) & 0x07;
1957 			}
1958 			break;
1959 		}
1960 #endif
1961 		offset += 1 + 1 + 2 + info_element_len;
1962 	}
1963 	return tvb_captured_length(tvb);
1964 }
1965 
1966 void
1967 proto_register_q2931(void)
1968 {
1969 	static hf_register_info hf[] = {
1970 		{ &hf_q2931_discriminator,
1971 		  { "Protocol discriminator", "q2931.disc",
1972 		    FT_UINT8, BASE_HEX, NULL, 0x0,
1973 		    NULL, HFILL }
1974 		},
1975 
1976 		{ &hf_q2931_call_ref_len,
UpdateMenuItems(nsIContent * aPopup)1977 		  { "Call reference value length", "q2931.call_ref_len",
1978 		    FT_UINT8, BASE_DEC, NULL, 0x0F,
1979 		    NULL, HFILL }
1980 		},
1981 
1982 		{ &hf_q2931_call_ref_flag,
1983 		  { "Call reference flag", "q2931.call_ref_flag",
1984 		    FT_BOOLEAN, BASE_NONE, TFS(&tfs_call_ref_flag), 0x0,
1985 		    NULL, HFILL }
1986 		},
1987 
1988 		{ &hf_q2931_call_ref,
1989 		  { "Call reference value", "q2931.call_ref",
1990 		    FT_BYTES, BASE_NONE, NULL, 0x0,
1991 		    NULL, HFILL }
1992 		},
1993 
1994 		{ &hf_q2931_message_type,
1995 		  { "Message type", "q2931.message_type",
1996 		    FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q2931_message_type_vals_ext, 0x0,
1997 		    NULL, HFILL }
1998 		},
1999 
2000 		{ &hf_q2931_message_type_ext,
2001 		  { "Message type extension", "q2931.message_type_ext",
2002 		    FT_UINT8, BASE_HEX, NULL, 0x0,
2003 		    NULL, HFILL }
2004 		},
2005 
2006 		{ &hf_q2931_message_flag,
2007 		  { "Flag", "q2931.message_flag",
2008 		    FT_BOOLEAN, 8, TFS(&tos_msg_flag), Q2931_MSG_TYPE_EXT_FOLLOW_INST,
2009 		    NULL, HFILL }
2010 		},
2011 
2012 		{ &hf_q2931_message_action_indicator,
2013 		  { "Action indicator", "q2931.message_action_indicator",
2014 		    FT_UINT8, BASE_DEC, VALS(msg_action_ind_vals), Q2931_MSG_TYPE_EXT_ACTION_IND,
2015 		    NULL, HFILL }
2016 		},
2017 
2018 		{ &hf_q2931_message_len,
2019 		  { "Message length", "q2931.message_len",
2020 		    FT_UINT16, BASE_DEC, NULL, 0x0,
2021 		    NULL, HFILL }
2022 		},
2023 
2024 		{ &hf_q2931_ie_handling_instructions,
2025 		  { "Handling Instructions", "q2931.ie_handling_instructions",
2026 		    FT_BOOLEAN, 8, TFS(&tfs_q2931_handling_instructions), Q2931_IE_COMPAT_FOLLOW_INST,
2027 		    NULL, HFILL }
2028 		},
2029 
2030 		{ &hf_q2931_ie_coding_standard,
2031 		  { "Coding standard", "q2931.ie_coding_standard",
2032 		    FT_UINT8, BASE_DEC, VALS(coding_std_vals), Q2931_IE_COMPAT_CODING_STD,
2033 		    NULL, HFILL }
2034 		},
2035 
2036 		{ &hf_q2931_ie_action_indicator,
2037 		  { "Action indicator", "q2931.ie_action_indicator",
2038 		    FT_UINT8, BASE_DEC, VALS(ie_action_ind_vals), Q2931_IE_COMPAT_ACTION_IND,
2039 		    NULL, HFILL }
2040 		},
2041 
2042 		/* Generated from convert_proto_tree_add_text.pl */
2043 		{ &hf_q2931_aal_type,
2044 		  { "AAL type", "q2931.aal_type",
2045 		    FT_UINT8, BASE_HEX, VALS(q9231_aal_type_vals), 0x0,
2046 		    NULL, HFILL }
2047 		},
2048 		{ &hf_q2931_user_defined_aal_information,
2049 		  { "User defined AAL information", "q2931.user_defined_aal_information",
2050 		    FT_BYTES, BASE_NONE, NULL, 0x0,
2051 		    NULL, HFILL }
2052 		},
2053 		{ &hf_q2931_aal1_subtype,
2054 		  { "Subtype", "q2931.aal1.subtype",
2055 		    FT_UINT8, BASE_HEX, VALS(q9231_aal1_subtype_vals), 0x0,
2056 		    NULL, HFILL }
2057 		},
2058 		{ &hf_q2931_aal1_cbr_rate,
2059 		  { "CBR rate", "q2931.aal1.cbr_rate",
2060 		    FT_UINT8, BASE_HEX, VALS(q9231_aal1_cbr_rate_vals), 0x0,
2061 		    NULL, HFILL }
2062 		},
2063 		{ &hf_q2931_aal1_multiplier,
2064 		  { "Multiplier", "q2931.aal1.multiplier",
2065 		    FT_UINT16, BASE_DEC, NULL, 0x0,
2066 		    NULL, HFILL }
2067 		},
2068 		{ &hf_q2931_aal1_source_clock_frequency_recovery_method,
2069 		  { "Source clock frequency recovery method", "q2931.aal1.source_clock_frequency_recovery_method",
2070 		    FT_UINT8, BASE_HEX, VALS(q2931_aal1_src_clk_rec_meth_vals), 0x0,
2071 		    NULL, HFILL }
2072 		},
2073 		{ &hf_q2931_aal1_error_correction_method,
2074 		  { "Error correction method", "q2931.aal1.error_correction_method",
2075 		    FT_UINT8, BASE_HEX, VALS(q2931_aal1_err_correction_method_vals), 0x0,
2076 		    NULL, HFILL }
2077 		},
2078 		{ &hf_q2931_aal1_structured_data_transfer_block_size,
Notify(nsITimer * aTimer)2079 		  { "Structured data transfer block size", "q2931.aal1.structured_data_transfer_block_size",
2080 		    FT_UINT16, BASE_DEC, NULL, 0x0,
2081 		    NULL, HFILL }
2082 		},
2083 		{ &hf_q2931_aal1_partially_filled_cells_method,
2084 		  { "Partially filled cells method", "q2931.aal1.partially_filled_cells_method",
2085 		    FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_octet_octets, 0x0,
2086 		    NULL, HFILL }
2087 		},
KillMenuTimer()2088 		{ &hf_q2931_aal1_forward_max_cpcs_sdu_size,
2089 		  { "Forward maximum CPCS-SDU size", "q2931.aal1.forward_max_cpcs_sdu_size",
2090 		    FT_UINT16, BASE_DEC, NULL, 0x0,
2091 		    NULL, HFILL }
2092 		},
2093 		{ &hf_q2931_aal1_backward_max_cpcs_sdu_size,
2094 		  { "Backward maximum CPCS-SDU size", "q2931.aal1.backward_max_cpcs_sdu_size",
2095 		    FT_UINT16, BASE_DEC, NULL, 0x0,
2096 		    NULL, HFILL }
2097 		},
2098 		{ &hf_q2931_aal1_mode,
2099 		  { "Mode", "q2931.aal1.mode",
2100 		    FT_UINT8, BASE_HEX, VALS(q2931_aal_mode_vals), 0x0,
2101 		    NULL, HFILL }
CancelMenuTimer(nsMenuParent * aMenuParent)2102 		},
2103 		{ &hf_q2931_aal1_sscs_type,
2104 		  { "SSCS type", "q2931.aal1.sscs_type",
2105 		    FT_UINT8, BASE_HEX, VALS(q2931_sscs_type_vals), 0x0,
2106 		    NULL, HFILL }
2107 		},
2108 		{ &hf_q2931_bearer_class,
2109 		  { "Bearer class", "q2931.bearer_class",
2110 		    FT_UINT8, BASE_HEX, VALS(q2931_bearer_class_vals), 0x1F,
2111 		    NULL, HFILL }
HandleShortcutNavigation(nsIDOMKeyEvent * aKeyEvent,nsMenuPopupFrame * aFrame)2112 		},
2113 		{ &hf_q2931_atm_transfer_capability,
2114 		  { "ATM Transfer Capability", "q2931.atm_transfer_capability",
2115 		    FT_UINT8, BASE_HEX, VALS(q2931_transfer_capability_vals), 0x1F,
2116 		    NULL, HFILL }
2117 		},
2118 		{ &hf_q2931_susceptibility_to_clipping,
2119 		  { "Susceptibility to clipping", "q2931.susceptibility_to_clipping",
2120 		    FT_UINT8, BASE_HEX, VALS(q2931_susc_clip_vals), 0x60,
2121 		    NULL, HFILL }
2122 		},
2123 		{ &hf_q2931_user_plane_connection_configuration,
2124 		  { "User-plane connection configuration", "q2931.user_plane_connection_configuration",
2125 		    FT_UINT8, BASE_HEX, VALS(q2931_up_conn_config_vals), 0x03,
2126 		    NULL, HFILL }
2127 		},
2128 		{ &hf_q2931_high_layer_information_type,
2129 		  { "High layer information type", "q2931.high_layer_information_type",
2130 		    FT_UINT8, BASE_HEX, VALS(q2931_hi_layer_info_type_vals), 0x7F,
2131 		    NULL, HFILL }
2132 		},
2133 		{ &hf_q2931_bband_low_layer_info_user_info_l1_proto,
2134 		  { "User information layer 1 protocol", "q2931.bband_low_layer_info.user_info_l1_proto",
2135 		    FT_UINT8, BASE_HEX, NULL, 0x1F,
2136 		    NULL, HFILL }
2137 		},
2138 		{ &hf_q2931_bband_low_layer_info_user_info_l2_proto,
2139 		  { "User information layer 2 protocol", "q2931.bband_low_layer_info.user_info_l2_proto",
2140 		    FT_UINT8, BASE_HEX, VALS(q2931_uil2_vals), 0x1F,
2141 		    NULL, HFILL }
2142 		},
2143 		{ &hf_q2931_bband_low_layer_info_user_specified_l2_proto,
2144 		  { "User-specified layer 2 protocol information", "q2931.bband_low_layer_info.user_specified_l2_proto",
2145 		    FT_UINT8, BASE_HEX, NULL, 0x7F,
2146 		    NULL, HFILL }
2147 		},
2148 		{ &hf_q2931_bband_low_layer_info_mode,
2149 		  { "Mode", "q2931.bband_low_layer_info.mode",
2150 		    FT_UINT8, BASE_HEX, VALS(q2931_mode_vals), 0x60,
2151 		    NULL, HFILL }
2152 		},
2153 		{ &hf_q2931_bband_low_layer_info_window_size,
2154 		  { "Window size", "q2931.bband_low_layer_info.window_size",
2155 		    FT_UINT8, BASE_DEC, NULL, 0x7F,
2156 		    NULL, HFILL }
2157 		},
2158 		{ &hf_q2931_bband_low_layer_info_user_info_l3_proto,
2159 		  { "User information layer 3 protocol", "q2931.bband_low_layer_info.user_info_l3_proto",
HandleKeyboardNavigation(uint32_t aKeyCode)2160 		    FT_UINT8, BASE_HEX, VALS(q2931_uil3_vals), 0x1F,
2161 		    NULL, HFILL }
2162 		},
2163 		{ &hf_q2931_bband_low_layer_info_default_packet_size,
2164 		  { "Default packet size", "q2931.bband_low_layer_info.default_packet_size",
2165 		    FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_octet_octets, 0x0F,
2166 		    NULL, HFILL }
2167 		},
2168 		{ &hf_q2931_bband_low_layer_info_packet_window_size,
2169 		  { "Packet window size", "q2931.bband_low_layer_info.packet_window_size",
2170 		    FT_UINT8, BASE_DEC, NULL, 0x7F,
2171 		    NULL, HFILL }
2172 		},
2173 		{ &hf_q2931_bband_low_layer_info_additional_l3_proto,
2174 		  { "Additional layer 3 protocol information", "q2931.bband_low_layer_info.additional_l3_proto",
2175 		    FT_UINT8, BASE_HEX, VALS(nlpid_vals), 0x0,
2176 		    NULL, HFILL }
2177 		},
2178 		{ &hf_q2931_organization_code,
2179 		  { "Organization Code", "q2931.bband_low_layer_info.organization_code",
2180 		    FT_UINT24, BASE_OUI, NULL, 0x0,
2181 		    NULL, HFILL }
2182 		},
2183 		{ &hf_q2931_ethernet_type,
2184 		  { "Ethernet type", "q2931.bband_low_layer_info.ethernet_type",
2185 		    FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
2186 		    NULL, HFILL }
2187 		},
2188 		{ &hf_q2931_lane_protocol_id,
2189 		  { "LANE Protocol ID", "q2931.bband_low_layer_info.lane_protocol_id",
2190 		    FT_UINT16, BASE_HEX, VALS(lane_pid_vals), 0x0,
2191 		    NULL, HFILL }
2192 		},
2193 		{ &hf_q2931_protocol_id,
2194 		  { "Protocol ID", "q2931.bband_low_layer_info.protocol_id",
2195 		    FT_UINT16, BASE_HEX, NULL, 0x0,
2196 		    NULL, HFILL }
2197 		},
2198 		{ &hf_q2931_cause_location,
2199 		  { "Location", "q2931.cause.location",
2200 		    FT_UINT8, BASE_HEX, VALS(q2931_cause_location_vals), 0x0F,
2201 		    NULL, HFILL }
2202 		},
2203 		{ &hf_q2931_cause_value,
2204 		  { "Cause value", "q2931.cause.value",
2205 		    FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q2931_cause_code_vals_ext, 0x7F,
2206 		    NULL, HFILL }
2207 		},
2208 		{ &hf_q2931_cause_rejection_reason,
2209 		  { "Rejection reason", "q2931.cause.rejection.reason",
2210 		    FT_UINT8, BASE_HEX, VALS(q2931_rejection_reason_vals), 0x7C,
2211 		    NULL, HFILL }
2212 		},
2213 		{ &hf_q2931_cause_rejection_condition,
2214 		  { "Condition", "q2931.cause.rejection.condition",
2215 		    FT_UINT8, BASE_HEX, VALS(q2931_cause_condition_vals), 0x03,
2216 		    NULL, HFILL }
2217 		},
2218 		{ &hf_q2931_cause_rejection_user_specific_diagnostic,
2219 		  { "User specific diagnostic", "q2931.cause.rejection.user_specific_diagnostic",
2220 		    FT_BYTES, BASE_NONE, NULL, 0x0,
2221 		    NULL, HFILL }
2222 		},
2223 		{ &hf_q2931_cause_rejection_missing_information_element,
2224 		  { "Missing information element", "q2931.cause.rejection.missing_information_element",
2225 		    FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q2931_info_element_vals_ext, 0x0,
2226 		    NULL, HFILL }
2227 		},
2228 		{ &hf_q2931_cause_rejection_insufficient_information_element,
HandleKeyboardNavigationInPopup(nsMenuChainItem * item,nsMenuPopupFrame * aFrame,nsNavigationDirection aDir)2229 		  { "Insufficient information element", "q2931.cause.rejection.insufficient_information_element",
2230 		    FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q2931_info_element_vals_ext, 0x0,
2231 		    NULL, HFILL }
2232 		},
2233 		{ &hf_q2931_cause_rejection_diagnostic,
2234 		  { "Diagnostic", "q2931.cause.rejection.diagnostic",
2235 		    FT_BYTES, BASE_NONE, NULL, 0x0,
2236 		    NULL, HFILL }
2237 		},
2238 		{ &hf_q2931_cause_information_element,
2239 		  { "Information element", "q2931.cause.information_element",
2240 		    FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q2931_info_element_vals_ext, 0x0,
2241 		    NULL, HFILL }
2242 		},
2243 		{ &hf_q2931_cause_cell_rate_subfield_identifier,
2244 		  { "Cell rate subfield identifier", "q2931.cause.cell_rate_subfield_identifier",
2245 		    FT_UINT8, BASE_HEX, VALS(q2931_atm_td_subfield_vals), 0x0,
2246 		    NULL, HFILL }
2247 		},
2248 		{ &hf_q2931_cause_vpci,
2249 		  { "VPCI", "q2931.cause.vpci",
2250 		    FT_UINT16, BASE_DEC, NULL, 0x0,
2251 		    NULL, HFILL }
2252 		},
2253 		{ &hf_q2931_cause_vci,
2254 		  { "VCI", "q2931.cause.vci",
2255 		    FT_UINT16, BASE_DEC, NULL, 0x0,
2256 		    NULL, HFILL }
2257 		},
2258 		{ &hf_q2931_cause_message_type,
2259 		  { "Message type", "q2931.cause.message_type",
2260 		    FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q2931_message_type_vals_ext, 0x0,
2261 		    NULL, HFILL }
2262 		},
2263 		{ &hf_q2931_cause_timer,
2264 		  { "Timer", "q2931.cause.timer",
2265 		    FT_STRING, BASE_NONE, NULL, 0x0,
2266 		    NULL, HFILL }
2267 		},
2268 		{ &hf_q2931_call_state,
2269 		  { "Call state", "q2931.call_state",
2270 		    FT_UINT8, BASE_HEX, VALS(q2931_call_state_vals), 0x3F,
2271 		    NULL, HFILL }
2272 		},
2273 		{ &hf_q2931_number_type,
2274 		  { "Type of number", "q2931.number.type",
2275 		    FT_UINT8, BASE_HEX, VALS(q2931_number_type_vals), 0x70,
2276 		    NULL, HFILL }
2277 		},
2278 		{ &hf_q2931_number_plan,
2279 		  { "Numbering plan", "q2931.number.plan",
2280 		    FT_UINT8, BASE_HEX, VALS(q2931_numbering_plan_vals), 0x0F,
2281 		    NULL, HFILL }
2282 		},
2283 		{ &hf_q2931_number_presentation_indicator,
2284 		  { "Presentation indicator", "q2931.number.presentation_indicator",
2285 		    FT_UINT8, BASE_HEX, VALS(q2931_presentation_indicator_vals), 0x60,
2286 		    NULL, HFILL }
2287 		},
2288 		{ &hf_q2931_number_screening_indicator,
2289 		  { "Screening indicator", "q2931.number.screening_indicator",
2290 		    FT_UINT8, BASE_HEX, VALS(q2931_screening_indicator_vals), 0x03,
2291 		    NULL, HFILL }
2292 		},
2293 		{ &hf_q2931_number_string,
2294 		  { "Number", "q2931.number.string",
2295 		    FT_STRING, BASE_NONE, NULL, 0x0,
2296 		    NULL, HFILL }
2297 		},
2298 		{ &hf_q2931_number_bytes,
2299 		  { "Number", "q2931.number.bytes",
2300 		    FT_BYTES, BASE_NONE, NULL, 0x0,
2301 		    NULL, HFILL }
2302 		},
2303 		{ &hf_q2931_party_subaddr_type_of_subaddress,
2304 		  { "Type of subaddress", "q2931.party_subaddr.type_of_subaddress",
2305 		    FT_UINT8, BASE_HEX, VALS(q2931_subaddress_type_vals), 0x70,
2306 		    NULL, HFILL }
2307 		},
HandleKeyboardEventWithKeyCode(nsIDOMKeyEvent * aKeyEvent,nsMenuChainItem * aTopVisibleMenuItem)2308 		{ &hf_q2931_party_subaddr_odd_even_indicator,
2309 		  { "Odd/even indicator", "q2931.party_subaddr.odd_even_indicator",
2310 		    FT_UINT8, BASE_HEX, VALS(q2931_odd_even_indicator_vals), 0x10,
2311 		    NULL, HFILL }
2312 		},
2313 		{ &hf_q2931_party_subaddr_subaddress,
2314 		  { "Subaddress", "q2931.party_subaddr.subaddress",
2315 		    FT_BYTES, BASE_NONE, NULL, 0x0,
2316 		    NULL, HFILL }
2317 		},
2318 		{ &hf_q2931_conn_id_vp_associated_signalling,
2319 		  { "VP-associated signalling", "q2931.conn_id.vp_associated_signalling",
2320 		    FT_UINT8, BASE_HEX, VALS(q2931_vp_associated_signalling_vals), 0x18,
2321 		    NULL, HFILL }
2322 		},
2323 		{ &hf_q2931_conn_id_preferred_exclusive,
2324 		  { "Preferred/exclusive", "q2931.conn_id.preferred_exclusive",
2325 		    FT_UINT8, BASE_HEX, VALS(q2931_preferred_exclusive_vals), 0x07,
2326 		    NULL, HFILL }
2327 		},
2328 		{ &hf_q2931_conn_id_vpci,
2329 		  { "VPCI", "q2931.conn_id.vpci",
2330 		    FT_UINT16, BASE_DEC, NULL, 0x0,
2331 		    NULL, HFILL }
2332 		},
2333 		{ &hf_q2931_conn_id_vci,
2334 		  { "VCI", "q2931.conn_id.vci",
2335 		    FT_UINT16, BASE_DEC, NULL, 0x0,
2336 		    NULL, HFILL }
2337 		},
2338 		{ &hf_q2931_e2e_transit_delay_cumulative,
2339 		  { "Cumulative transit delay", "q2931.e2e_transit_delay.cumulative",
2340 		    FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
2341 		    NULL, HFILL }
2342 		},
2343 		{ &hf_q2931_e2e_transit_delay_maximum_end_to_end,
2344 		  { "Maximum end-to-end transit delay", "q2931.e2e_transit_delay.maximum_end_to_end",
2345 		    FT_UINT16, BASE_DEC, NULL, 0x0,
2346 		    NULL, HFILL }
2347 		},
2348 		{ &hf_q2931_qos_class_forward,
2349 		  { "QOS class forward", "q2931.qos_class_forward",
2350 		    FT_UINT8, BASE_HEX, VALS(q2931_qos_parameter_vals), 0x0,
2351 		    NULL, HFILL }
2352 		},
2353 		{ &hf_q2931_qos_class_backward,
2354 		  { "QOS class backward", "q2931.qos_class_backward",
2355 		    FT_UINT8, BASE_HEX, VALS(q2931_qos_parameter_vals), 0x0,
2356 		    NULL, HFILL }
2357 		},
2358 		{ &hf_q2931_broadband_repeat_indicator,
2359 		  { "Broadband repeat indicator", "q2931.broadband_repeat_indicator",
2360 		    FT_UINT8, BASE_HEX, VALS(q2931_bband_rpt_indicator_vals), 0x0F,
2361 		    NULL, HFILL }
2362 		},
2363 		{ &hf_q2931_restart_indicator,
2364 		  { "Restart indicator", "q2931.restart_indicator",
2365 		    FT_UINT8, BASE_HEX, VALS(q2931_class_vals), 0x07,
2366 		    NULL, HFILL }
2367 		},
2368 		{ &hf_q2931_transit_network_sel_type,
2369 		  { "Type of network identification", "q2931.transit_network_sel.type",
2370 		    FT_UINT8, BASE_HEX, VALS(q2931_netid_type_vals), 0x70,
2371 		    NULL, HFILL }
2372 		},
2373 		{ &hf_q2931_transit_network_sel_plan,
2374 		  { "Network identification plan", "q2931.transit_network_sel.plan",
2375 		    FT_UINT8, BASE_HEX, VALS(q2931_netid_plan_vals), 0x0F,
2376 		    NULL, HFILL }
2377 		},
2378 		{ &hf_q2931_transit_network_sel_network_id,
2379 		  { "Network identification", "q2931.transit_network_sel.network_identification",
2380 		    FT_STRING, BASE_NONE, NULL, 0x0,
2381 		    NULL, HFILL }
2382 		},
2383 		{ &hf_q2931_oam_traffic_descriptor_shaping_indicator,
2384 		  { "Shaping indicator", "q2931.oam_traffic_descriptor.shaping_indicator",
2385 		    FT_UINT8, BASE_HEX, VALS(q2931_shaping_indicator_vals), 0x60,
2386 		    NULL, HFILL }
2387 		},
2388 		{ &hf_q2931_oam_end_to_end_f5_flow,
2389 		  { "Use of end-to-end OAM F5 flow", "q2931.oam_end_to_end_f5_flow",
2390 		    FT_BOOLEAN, 8, TFS(&tfs_mandatory_optional), 0x10,
2391 		    NULL, HFILL }
2392 		},
2393 		{ &hf_q2931_oam_traffic_descriptor_management_indicator,
2394 		  { "User-Network fault management indicator", "q2931.oam_traffic_descriptor.management_indicator",
2395 		    FT_UINT8, BASE_HEX, VALS(q2931_user_net_fault_mgmt_vals), 0x07,
2396 		    NULL, HFILL }
2397 		},
2398 		{ &hf_q2931_oam_traffic_descriptor_forward_f5_flow_indicator,
2399 		  { "Forward end-to-end OAM F5 flow indicator", "q2931.oam_traffic_descriptor.forward_f5_flow_indicator",
2400 		    FT_UINT8, BASE_HEX, VALS(q2931_fwd_e2e_oam_f5_flow_indicator_vals), 0x70,
2401 		    NULL, HFILL }
2402 		},
2403 		{ &hf_q2931_oam_traffic_descriptor_backward_f5_flow_indicator,
2404 		  { "Backward end-to-end OAM F5 flow indicator", "q2931.oam_traffic_descriptor.backward_f5_flow_indicator",
2405 		    FT_UINT8, BASE_HEX, VALS(q2931_bwd_e2e_oam_f5_flow_indicator_vals), 0x07,
2406 		    NULL, HFILL }
2407 		},
2408 		{ &hf_q2931_endpoint_reference_type,
2409 		  { "Endpoint reference type", "q2931.endpoint_reference.type",
2410 		    FT_UINT8, BASE_HEX, VALS(q2931_endpoint_reference_type_vals), 0x0,
2411 		    NULL, HFILL }
2412 		},
2413 		{ &hf_q2931_endpoint_reference_flag,
2414 		  { "Endpoint reference identifier value", "q2931.endpoint_reference.flag",
2415 		    FT_BOOLEAN, 16, TFS(&tfs_endpoint_reference_flag), 0x8000,
2416 		    NULL, HFILL }
2417 		},
GetNextMenuItem(nsContainerFrame * aParent,nsMenuFrame * aStart,bool aIsPopup)2418 		{ &hf_q2931_endpoint_reference_identifier_value,
2419 		  { "Endpoint reference identifier value", "q2931.endpoint_reference.identifier_value",
2420 		    FT_UINT16, BASE_DEC, NULL, 0x7FFF,
2421 		    NULL, HFILL }
2422 		},
2423 		{ &hf_q2931_endpoint_state,
2424 		  { "Endpoint reference party-state", "q2931.endpoint_state",
2425 		    FT_UINT8, BASE_HEX, VALS(q2931_endpoint_reference_party_state_vals), 0x3F,
2426 		    NULL, HFILL }
2427 		},
2428 		{ &hf_q2931_information_element,
2429 		  { "Information element", "q2931.information_element",
2430 		    FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q2931_info_element_vals_ext, 0x0,
2431 		    NULL, HFILL }
2432 		},
2433 		{ &hf_q2931_information_element_extension,
2434 		  { "Information element extension", "q2931.information_element.extension",
2435 		    FT_UINT8, BASE_HEX, NULL, 0x0,
2436 		    NULL, HFILL }
2437 		},
2438 		{ &hf_q2931_information_element_length,
2439 		  { "Length", "q2931.information_element.length",
2440 		    FT_UINT16, BASE_DEC, NULL, 0x0,
2441 		    NULL, HFILL }
2442 		},
2443 		{ &hf_q2931_information_element_data,
2444 		  { "Data", "q2931.information_element.data",
2445 		    FT_BYTES, BASE_NONE, NULL, 0x0,
2446 		    NULL, HFILL }
2447 		},
2448 		{ &hf_q2931_frame_discard_forward_dir,
2449 		  { "Frame discard in forward direction", "q2931.frame_discard_forward_dir",
2450 		    FT_BOOLEAN, 8, TFS(&tfs_allowed_not_allowed), 0x80,
2451 		    NULL, HFILL }
2452 		},
2453 		{ &hf_q2931_frame_discard_backward_dir,
2454 		  { "Frame discard in backward direction", "q2931.frame_discard_backward_dir",
2455 		    FT_BOOLEAN, 8, TFS(&tfs_allowed_not_allowed), 0x40,
2456 		    NULL, HFILL }
2457 		},
2458 		{ &hf_q2931_tagging_backward_dir,
2459 		  { "Tagging in backward direction", "q2931.tagging_backward_dir",
2460 		    FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x02,
2461 		    NULL, HFILL }
2462 		},
2463 		{ &hf_q2931_tagging_forward_dir,
2464 		  { "Tagging in forward direction", "q2931.tagging_forward_dir",
2465 		    FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested), 0x01,
2466 		    NULL, HFILL }
2467 		},
2468 		{ &hf_q2931_midrange,
2469 		  { "MID range", "q2931.midrange",
2470 		    FT_UINT32, BASE_HEX, NULL, 0x0,
2471 		    NULL, HFILL }
2472 		},
2473 		{ &hf_q2931_cause_network_service,
2474 		  { "Network service", "q2931.cause.network_service",
2475 		    FT_BOOLEAN, 8, TFS(&tfs_user_provider), 0x80,
2476 		    NULL, HFILL }
2477 		},
2478 		{ &hf_q2931_cause_network_behavior,
GetPreviousMenuItem(nsContainerFrame * aParent,nsMenuFrame * aStart,bool aIsPopup)2479 		  { "Network behavior", "q2931.cause.network_behavior",
2480 		    FT_BOOLEAN, 8, TFS(&tfs_abnormal_normal), 0x40,
2481 		    NULL, HFILL }
2482 		},
2483 		{ &hf_q2931_nsap_address_number_short,
2484 		  { "Number (too short)", "q2931.nsap_address.number_short",
2485 		    FT_BYTES, BASE_NONE, NULL, 0x0,
2486 		    NULL, HFILL }
2487 		},
2488 		{ &hf_q2931_atm_identifier,
2489 		  { "Identifier", "q2931.atm_identifier",
2490 		    FT_UINT8, BASE_HEX, VALS(q2931_atm_td_subfield_vals), 0x0,
2491 		    NULL, HFILL }
2492 		},
2493 		{ &hf_q2931_atm_identifier_value,
2494 		  { "Value", "q2931.atm_identifier_value",
2495 		    FT_UINT24, BASE_DEC|BASE_UNIT_STRING, &units_cells_s, 0x0,
2496 		    NULL, HFILL }
2497 		},
2498 		{ &hf_q2931_aal_parameter_identifier,
2499 		  { "Identifier", "q2931.aal.parameter_identifier",
2500 		    FT_UINT8, BASE_HEX, NULL, 0x0,
2501 		    NULL, HFILL }
2502 		},
2503 		{ &hf_q2931_e2e_transit_delay_identifier,
2504 		  { "Identifier", "q2931.transit_delay.identifier",
2505 		    FT_UINT8, BASE_HEX, NULL, 0x0,
2506 		    NULL, HFILL }
2507 		},
2508 		{ &hf_q2931_bband_sending_complete_id,
2509 		  { "Identifier", "q2931.bband_sending_complete.id",
2510 		    FT_UINT8, BASE_HEX, NULL, 0x0,
2511 		    NULL, HFILL }
2512 		},
2513 		{ &hf_q2931_bband_sending_complete,
2514 		  { "Broadband sending complete indication", "q2931.bband_sending_complete",
2515 		    FT_NONE, BASE_NONE, NULL, 0x0,
2516 		    NULL, HFILL }
2517 		},
2518 		{ &hf_q2931_locking_codeset,
2519 		  { "Locking codeset", "q2931.locking_codeset",
2520 		    FT_UINT8, BASE_DEC, NULL, 0x0,
2521 		    NULL, HFILL }
2522 		},
2523 	};
2524 
2525 	static gint *ett[] = {
2526 		&ett_q2931,
2527 		&ett_q2931_ext,
2528 		&ett_q2931_ie,
2529 		&ett_q2931_ie_ext,
2530 		&ett_q2931_nsap,
2531 	};
2532 
2533 	static ei_register_info ei[] = {
2534 		{ &ei_q2931_atm_identifier, { "q2931.atm_identifier.unknown", PI_PROTOCOL, PI_WARN, "Unknown ATM traffic descriptor element", EXPFILL }},
2535 		{ &ei_q2931_aal_parameter_identifier, { "q2931.aal.parameter_identifier.unknown", PI_PROTOCOL, PI_WARN, "Unknown AAL parameter", EXPFILL }},
2536 		{ &ei_q2931_e2e_transit_delay_identifier, { "q2931.transit_delay.parameter_identifier.unknown", PI_PROTOCOL, PI_WARN, "Unknown transit delay identifier", EXPFILL }},
2537 		{ &ei_q2931_bband_sending_complete_id, { "q2931.bband_sending_complete.id.unknown", PI_PROTOCOL, PI_WARN, "Unknown broadband sending complete element", EXPFILL }},
2538 	};
2539 
2540 	expert_module_t* expert_q2931;
2541 
2542 	proto_q2931 = proto_register_protocol("Q.2931", "Q.2931", "q2931");
2543 	proto_register_field_array (proto_q2931, hf, array_length(hf));
2544 	proto_register_subtree_array(ett, array_length(ett));
2545 	expert_q2931 = expert_register_protocol(proto_q2931);
IsValidMenuItem(nsIContent * aContent,bool aOnPopup)2546 	expert_register_field_array(expert_q2931, ei, array_length(ei));
2547 
2548 	register_dissector("q2931", dissect_q2931, proto_q2931);
2549 }
2550 
2551 /*
2552  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
2553  *
2554  * Local variables:
2555  * c-basic-offset: 8
2556  * tab-width: 8
2557  * indent-tabs-mode: t
2558  * End:
2559  *
2560  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
2561  * :indentSize=8:tabSize=8:noTabs=false:
2562  */
2563