1 /* packet-q931.c
2 * Routines for Q.931 frame disassembly
3 * Guy Harris <guy@alum.mit.edu>
4 *
5 * Modified by Andreas Sikkema for possible use with H.323
6 *
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 */
13
14 #include "config.h"
15
16 #include <epan/packet.h>
17 #include <epan/tap.h>
18 #include <epan/nlpid.h>
19 #include "packet-q931.h"
20 #include "packet-e164.h"
21 #include <epan/prefs.h>
22 #include <epan/expert.h>
23 #include <epan/reassemble.h>
24 #include <epan/sctpppids.h>
25 #include <epan/lapd_sapi.h>
26 #include "packet-tpkt.h"
27
28
29 /* Q.931 references:
30 *
31 * http://www.acacia-net.com/Clarinet/Protocol/q9313svn.htm
32 * http://www.acacia-net.com/Clarinet/Protocol/q9311sc3.htm
33 * http://www.acacia-net.com/Clarinet/Protocol/q9317oz7.htm
34 * http://web.archive.org/web/20150510102424/http://www.protocols.com/pbook/isdn.htm
35 * http://freesoft.org/CIE/Topics/126.htm
36 * http://noc.comstar.ru/miscdocs/ascend-faq-cause-codes.html
37 * http://www.andrews-arnold.co.uk/isdn/q931cause.html
38 * http://www.tulatelecom.ru/staff/german/DSSHelp/MessList/InfEl/InfElList.html
39 */
40
41 void proto_register_q931(void);
42 void proto_reg_handoff_q931(void);
43
44 static void reset_q931_packet_info(q931_packet_info *pi);
45 static int q931_tap = -1;
46
47 static dissector_handle_t q931_handle;
48 static dissector_handle_t q931_over_ip_handle;
49
50 static int proto_q931 = -1;
51 static int hf_q931_discriminator = -1;
52 static int hf_q931_coding_standard = -1;
53 static int hf_q931_interpretation = -1;
54 static int hf_q931_pres_meth_prot_prof = -1;
55 static int hf_q931_high_layer_characteristics = -1;
56 static int hf_q931_extended_high_layer_characteristics = -1;
57 static int hf_q931_extended_audiovisual_characteristics = -1;
58 static int hf_q931_information_transfer_capability = -1;
59 static int hf_q931_transfer_mode = -1;
60 static int hf_q931_information_transfer_rate = -1;
61 static int hf_q931_layer_ident = -1;
62 static int hf_q931_uil1 = -1;
63 static int hf_q931_call_ref_len = -1;
64 static int hf_q931_call_ref_flag = -1;
65 static int hf_q931_call_ref = -1;
66 static int hf_q931_message_type = -1;
67 static int hf_q931_maintenance_message_type = -1;
68 static int hf_q931_segment_type = -1;
69 static int hf_q931_cause_location = -1;
70 static int hf_q931_cause_value = -1;
71 static int hf_q931_number_type = -1;
72 static int hf_q931_numbering_plan = -1;
73 static int hf_q931_extension_ind = -1;
74 static int hf_q931_extension_ind_preference = -1;
75 static int hf_q931_extension_ind_new_status = -1;
76 static int hf_q931_calling_party_number = -1;
77 static int hf_q931_called_party_number = -1;
78 static int hf_q931_connected_number = -1;
79 static int hf_q931_redirecting_number = -1;
80 static int hf_q931_screening_ind = -1;
81 static int hf_q931_presentation_ind = -1;
82
83 /* fields for Channel Indentification IE */
84 static int hf_q931_channel_interface_explicit = -1;
85 static int hf_q931_channel_interface_type = -1;
86 static int hf_q931_channel_exclusive = -1;
87 static int hf_q931_channel_dchan = -1;
88 static int hf_q931_channel_selection_bri = -1;
89 static int hf_q931_channel_selection_pri = -1;
90 static int hf_q931_channel_map = -1;
91 static int hf_q931_channel_element_type = -1;
92 static int hf_q931_channel_number = -1;
93
94
95 static int hf_q931_segments = -1;
96 static int hf_q931_segment = -1;
97 static int hf_q931_segment_overlap = -1;
98 static int hf_q931_segment_overlap_conflict = -1;
99 static int hf_q931_segment_multiple_tails = -1;
100 static int hf_q931_segment_too_long_segment = -1;
101 static int hf_q931_segment_error = -1;
102 static int hf_q931_segment_count = -1;
103 static int hf_q931_reassembled_in = -1;
104 static int hf_q931_reassembled_length = -1;
105
106 /* Generated from convert_proto_tree_add_text.pl */
107 static int hf_q931_user_information_bytes = -1;
108 static int hf_q931_restart_indicator = -1;
109 static int hf_q931_call_state_data = -1;
110 static int hf_q931_first_segment = -1;
111 static int hf_q931_packet_size_backward_value = -1;
112 static int hf_q931_packet_size_forward_value = -1;
113 static int hf_q931_information_rate_minimum_outgoing = -1;
114 static int hf_q931_bearer_capability_data = -1;
115 static int hf_q931_uil2_info = -1;
116 static int hf_q931_netid_facility_specification = -1;
117 static int hf_q931_bearer_capability_stop_bits = -1;
118 static int hf_q931_netid_length = -1;
119 static int hf_q931_channel_data = -1;
120 static int hf_q931_call_state = -1;
121 static int hf_q931_party_subaddr_type = -1;
122 static int hf_q931_uil3 = -1;
123 static int hf_q931_user_information_str = -1;
124 static int hf_q931_bearer_capability_user_rate = -1;
125 static int hf_q931_channel_slot_map = -1;
126 static int hf_q931_bearer_capability_modem_type = -1;
127 static int hf_q931_cause_data = -1;
128 static int hf_q931_cause_recommendation = -1;
129 static int hf_q931_bearer_capability_parity = -1;
130 static int hf_q931_cause_call_rejection_reason = -1;
131 static int hf_q931_party_category = -1;
132 static int hf_q931_progress_indicator_location = -1;
133 static int hf_q931_bearer_capability_packet_window_size = -1;
134 static int hf_q931_extension_reason = -1;
135 static int hf_q931_information_rate_minimum_incoming = -1;
136 static int hf_q931_user_protocol_discriminator = -1;
137 static int hf_q931_uil2 = -1;
138 static int hf_q931_progress_indicator_description = -1;
139 static int hf_q931_bearer_capability_mode = -1;
140 static int hf_q931_not_first_segment = -1;
141 static int hf_q931_fast_select = -1;
142 static int hf_q931_netid_plan = -1;
143 static int hf_q931_cause_call_message_type = -1;
144 static int hf_q931_reverse_charging_ind = -1;
145 static int hf_q931_high_layer_compat_data = -1;
146 static int hf_q931_progress_indicator_data = -1;
147 static int hf_q931_pl_window_size_forward_value = -1;
148 static int hf_q931_cause_call_rec_timer = -1;
149 static int hf_q931_bearer_capability_window_size = -1;
150 static int hf_q931_cause_call_user_specific_diagnostic = -1;
151 static int hf_q931_channel_interface_id = -1;
152 static int hf_q931_uil3_additional = -1;
153 static int hf_q931_party_subaddr = -1;
154 static int hf_q931_bearer_capability_rate_multiplier = -1;
155 static int hf_q931_bearer_capability_data_bits = -1;
156 static int hf_q931_cug_index_code = -1;
157 static int hf_q931_bearer_capability_default_packet_size = -1;
158 static int hf_q931_notification_description = -1;
159 static int hf_q931_information_rate_outgoing = -1;
160 static int hf_q931_user_information_len = -1;
161 static int hf_q931_pl_window_size_backward_value = -1;
162 static int hf_q931_repeat_indicator = -1;
163 static int hf_q931_cause_call_diagnostic = -1;
164 static int hf_q931_netid = -1;
165 static int hf_q931_cause_call_condition = -1;
166 static int hf_q931_signal = -1;
167 static int hf_q931_congestion_level = -1;
168 static int hf_q931_bearer_capability_intermediate_rate = -1;
169 static int hf_q931_netid_type = -1;
170 static int hf_q931_information_rate_incoming = -1;
171 static int hf_q931_party_subaddr_odd_even_indicator = -1;
172 static int hf_q931_cug_indication = -1;
173 static int hf_q931_multiple_frame_establishment = -1;
174 static int hf_q931_message_originator = -1;
175 static int hf_q931_out_band_negotiation = -1;
176 static int hf_q931_negotiation_is_done = -1;
177 static int hf_q931_layer_1 = -1;
178 static int hf_q931_accept_data_flow_control = -1;
179 static int hf_q931_mode_of_operation = -1;
180 static int hf_q931_extension_condition_type = -1;
181 static int hf_q931_pl_binary_confirmation = -1;
182 static int hf_q931_pl_request = -1;
183 static int hf_q931_pl_modulus = -1;
184 static int hf_q931_network_service = -1;
185 static int hf_q931_extension_condition = -1;
186 static int hf_q931_rate_adaption_header = -1;
187 static int hf_q931_send_data_net_independent_clock = -1;
188 static int hf_q931_bearer_capability_duplex = -1;
189 static int hf_q931_accept_data_net_independent_clock = -1;
190 static int hf_q931_send_data_flow_control = -1;
191 static int hf_q931_data = -1;
192 static int hf_q931_layer_1_in_band_negotiation = -1;
193 static int hf_q931_information_element = -1;
194 static int hf_q931_information_element_len = -1;
195 static int hf_q931_date_time = -1;
196 static int hf_q931_more_data = -1;
197 static int hf_q931_sending_complete = -1;
198 static int hf_q931_message_segment = -1;
199 static int hf_q931_missing_info_element = -1;
200 static int hf_q931_insufficient_info_element = -1;
201 static int hf_q931_cumulative_transit_delay = -1;
202 static int hf_q931_requested_end_to_end_transit_delay = -1;
203 static int hf_q931_maximum_end_to_end_transit_delay = -1;
204 static int hf_q931_transit_delay = -1;
205 static int hf_q931_display_information = -1;
206 static int hf_q931_keypad_facility = -1;
207 static int hf_q931_avaya_display = -1;
208 static int hf_q931_locking_codeset = -1;
209 static int hf_q931_protocol_negotiation = -1;
210
211
212 static gint ett_q931 = -1;
213 #define NUM_IE 256
214 static gint ett_q931_ie[NUM_IE];
215
216 static gint ett_q931_segments = -1;
217 static gint ett_q931_segment = -1;
218
219 static expert_field ei_q931_invalid_length = EI_INIT;
220 static expert_field ei_q931_date_time = EI_INIT;
221 static expert_field ei_q931_information_element = EI_INIT;
222 static expert_field ei_q931_incomplete_ie = EI_INIT;
223
224 static const fragment_items q931_frag_items = {
225 &ett_q931_segment,
226 &ett_q931_segments,
227
228 &hf_q931_segments,
229 &hf_q931_segment,
230 &hf_q931_segment_overlap,
231 &hf_q931_segment_overlap_conflict,
232 &hf_q931_segment_multiple_tails,
233 &hf_q931_segment_too_long_segment,
234 &hf_q931_segment_error,
235 &hf_q931_segment_count,
236 &hf_q931_reassembled_in,
237 &hf_q931_reassembled_length,
238 /* Reassembled data field */
239 NULL,
240 "segments"
241 };
242
243 /* Table for reassembly of fragments. */
244 static reassembly_table q931_reassembly_table;
245
246 /* Preferences */
247 static gboolean q931_reassembly = TRUE;
248 static gboolean g931_iso_iec_cause = FALSE;
249
250 static dissector_table_t codeset_dissector_table;
251 static dissector_table_t ie_dissector_table;
252
253 /* desegmentation of Q.931 over TPKT over TCP */
254 static gboolean q931_desegment = TRUE;
255
256 /* Subdissectors */
257 static dissector_handle_t h225_handle;
258 static dissector_handle_t q931_tpkt_handle;
259 static dissector_handle_t q931_tpkt_pdu_handle;
260
261 static heur_dissector_list_t q931_user_heur_subdissector_list;
262
263 static void
264 dissect_q931_IEs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root_tree,
265 proto_tree *q931_tree, gboolean is_over_ip, int offset, int initial_codeset,
266 q931_packet_info *q931_pi);
267
268 const value_string q931_message_type_vals[] = {
269 /* 0 */ { Q931_ESCAPE, "ESCAPE" },
270 /* 1 */ { Q931_ALERTING, "ALERTING" },
271 /* 2 */ { Q931_CALL_PROCEEDING, "CALL PROCEEDING" },
272 /* 3 */ { Q931_PROGRESS, "PROGRESS" },
273 /* 5 */ { Q931_SETUP, "SETUP" },
274 /* 6 */ { Q931_GROUIP_SERVICE, "GROUP SERVICE" },
275 /* 7 */ { Q931_CONNECT, "CONNECT" },
276 /* 8 */ { Q931_RESYNC_REQ, "RESYNC REQ" },
277 /* 9 */ { Q931_RESYNC_RESP, "RESYNC RESP" },
278 /* 10 */ { Q931_VERSION, "VERSION" },
279 /* 11 */ { Q931_GROUIP_SERVICE_ACK, "GROUP SERVICE ACK" },
280 /* 13 */ { Q931_SETUP_ACK, "SETUP ACKNOWLEDGE" },
281 /* 15 */ { Q931_CONNECT_ACK, "CONNECT ACKNOWLEDGE" },
282 /* 32 */ { Q931_USER_INFORMATION, "USER INFORMATION" },
283 /* 33 */ { Q931_SUSPEND_REJECT, "SUSPEND REJECT" },
284 /* 34 */ { Q931_RESUME_REJECT, "RESUME REJECT" },
285 /* 36 */ { Q931_HOLD, "HOLD" },
286 /* 37 */ { Q931_SUSPEND, "SUSPEND" },
287 /* 38 */ { Q931_RESUME, "RESUME" },
288 /* 40 */ { Q931_HOLD_ACK, "HOLD_ACKNOWLEDGE" },
289 /* 45 */ { Q931_SUSPEND_ACK, "SUSPEND ACKNOWLEDGE" },
290 /* 46 */ { Q931_RESUME_ACK, "RESUME ACKNOWLEDGE" },
291 /* 48 */ { Q931_HOLD_REJECT, "HOLD_REJECT" },
292 /* 49 */ { Q931_RETRIEVE, "RETRIEVE" },
293 /* 51 */ { Q931_RETRIEVE_ACK, "RETRIEVE ACKNOWLEDGE" },
294 /* 55 */ { Q931_RETRIEVE_REJECT, "RETRIEVE REJECT" },
295 /* 64 */ { Q931_DETACH, "DETACH" },
296 /* 69 */ { Q931_DISCONNECT, "DISCONNECT" },
297 /* 70 */ { Q931_RESTART, "RESTART" },
298 /* 72 */ { Q931_DETACH_ACKNOWLEDGE, "DETACH ACKNOWLEDGE" },
299 /* 77 */ { Q931_RELEASE, "RELEASE" },
300 /* 78 */ { Q931_RESTART_ACK, "RESTART ACKNOWLEDGE" },
301 /* 90 */ { Q931_RELEASE_COMPLETE, "RELEASE COMPLETE" },
302 /* 96 */ { Q931_SEGMENT, "SEGMENT" },
303 /* 98 */ { Q931_FACILITY, "FACILITY" },
304 /*100 */ { Q931_REGISTER, "REGISTER" },
305 /*106 */ { Q931_FACILITY_ACKNOWLEDGE, "FACILITY ACKNOWLEDGE" },
306 /*110 */ { Q931_NOTIFY, "NOTIFY" },
307 /*114 */ { Q931_FACILITY_REJECT, "FACILITY REJECT" },
308 /*117 */ { Q931_STATUS_ENQUIRY, "STATUS ENQUIRY" },
309 /*121 */ { Q931_CONGESTION_CONTROL, "CONGESTION CONTROL" },
310 /*123 */ { Q931_INFORMATION, "INFORMATION" },
311 /*125 */ { Q931_STATUS, "STATUS" },
312
313 { 0, NULL }
314 };
315 static value_string_ext q931_message_type_vals_ext = VALUE_STRING_EXT_INIT(q931_message_type_vals);
316
317 static const value_string dms_message_type_vals[] = {
318 { DMS_SERVICE_ACKNOWLEDGE, "SERVICE ACKNOWLEDGE" },
319 { DMS_SERVICE, "SERVICE" },
320 { 0, NULL }
321 };
322
323 /*
324 * NOTE For call reference flag (octet 2)
325 * Bit8
326 * 0 The message is sent from the side that originates the call reference
327 * 1 The message is sent to the side that originates the call reference
328 */
329 static const true_false_string tfs_call_ref_flag = {
330 "Message sent to originating side",
331 "Message sent from originating side"
332 };
333
334 static const true_false_string tfs_interface_type = {
335 "Primary rate interface",
336 "Basic rate interface"
337 };
338
339 static const true_false_string tfs_channel_exclusive = {
340 "Exclusive; only the indicated channel is acceptable",
341 "Indicated channel is preferred"
342 };
343
344 static const true_false_string tfs_channel_map = {
345 "Channel indicated by slot map",
346 "Channel indicated by number"
347 };
348
349 /*
350 * Information elements.
351 */
352
353 /* Shifted codeset values */
354 #define CS0 0x000
355 #define CS1 0x100
356 #define CS2 0x200
357 #define CS3 0x300
358 #define CS4 0x400
359 #define CS5 0x500
360 #define CS6 0x600
361 #define CS7 0x700
362
363 #define Q931_IE_SO_MASK 0x80 /* single-octet/variable-length mask */
364 /*
365 * Single-octet IEs.
366 */
367 #define Q931_IE_SO_IDENTIFIER_MASK 0xf0 /* IE identifier mask */
368 #define Q931_IE_SO_IDENTIFIER_SHIFT 4 /* IE identifier shift */
369 #define Q931_IE_SO_IE_MASK 0x0F /* IE mask */
370
371 #define Q931_IE_SHIFT 0x90
372 #define Q931_IE_SHIFT_NON_LOCKING 0x08 /* non-locking shift */
373 #define Q931_IE_SHIFT_CODESET 0x07 /* codeset */
374
375 #define Q931_IE_MORE_DATA_OR_SEND_COMP 0xA0 /* More Data or Sending Complete */
376 #define Q931_IE_MORE_DATA 0xA0
377 #define Q931_IE_SENDING_COMPLETE 0xA1
378
379 #define Q931_IE_CONGESTION_LEVEL 0xB0
380 #define Q931_IE_REPEAT_INDICATOR 0xD0
381
382 /*
383 * Variable-length IEs.
384 */
385 #define Q931_IE_VL_EXTENSION 0x80 /* Extension flag */
386 /* extension bit. The bit value "0" indicates that the octet continues through the */
387 /* next octet. The bit value "1" indicates that this octet is the last octet */
388
389 static const true_false_string q931_extension_ind_value = {
390 "last octet",
391 "information continues through the next octet"
392 };
393
394
395 /*
396 * Codeset 0 (default).
397 */
398 #define Q931_IE_SEGMENTED_MESSAGE 0x00
399 #define Q931_IE_CHANGE_STATUS 0x01
400 #define Q931_IE_BEARER_CAPABILITY 0x04
401 #define Q931_IE_CAUSE 0x08
402 #define Q931_IE_CALL_IDENTITY 0x10
403 #define Q931_IE_CALL_STATE 0x14
404 #define Q931_IE_CHANNEL_IDENTIFICATION 0x18
405 #define Q931_IE_FACILITY 0x1C
406 #define Q931_IE_PROGRESS_INDICATOR 0x1E
407 #define Q931_IE_NETWORK_SPECIFIC_FACIL 0x20 /* Network Specific Facilities */
408 #define Q931_IE_NOTIFICATION_INDICATOR 0x27
409 #define Q931_IE_DISPLAY 0x28
410 #define Q931_IE_DATE_TIME 0x29
411 #define Q931_IE_KEYPAD_FACILITY 0x2C
412 #define Q931_IE_INFORMATION_REQUEST 0x32
413 #define Q931_IE_SIGNAL 0x34
414 #define Q931_IE_SWITCHHOOK 0x36
415 #define Q931_IE_FEATURE_ACTIVATION 0x38
416 #define Q931_IE_FEATURE_INDICATION 0x39
417 #define Q931_IE_ENDPOINT_IDENTIFIER 0x3B
418 #define Q931_IE_SERVICE_PROFILE_ID 0x3A
419 #define Q931_IE_INFORMATION_RATE 0x40
420 #define Q931_IE_E2E_TRANSIT_DELAY 0x42 /* End-to-end Transit Delay */
421 #define Q931_IE_TD_SELECTION_AND_INT 0x43 /* Transit Delay Selection and Indication */
422 #define Q931_IE_PL_BINARY_PARAMETERS 0x44 /* Packet layer binary parameters */
423 #define Q931_IE_PL_WINDOW_SIZE 0x45 /* Packet layer window size */
424 #define Q931_IE_PACKET_SIZE 0x46 /* Packet size */
425 #define Q931_IE_CUG 0x47 /* Closed user group */
426 #define Q931_IE_REVERSE_CHARGE_IND 0x4A /* Reverse charging indication */
427 #define Q931_IE_CONNECTED_NUMBER_DEFAULT 0x4C /* Connected Number */
428 #define Q931_IE_INTERFACE_SERVICE 0x66 /* q931+ Interface Service */
429 #define Q931_IE_CHANNEL_STATUS 0x67 /* q931+ Channel Status */
430 #define Q931_IE_VERSION_INFO 0x68 /* q931+ Version Info */
431 #define Q931_IE_CALLING_PARTY_NUMBER 0x6C /* Calling Party Number */
432 #define Q931_IE_CALLING_PARTY_SUBADDR 0x6D /* Calling Party Subaddress */
433 #define Q931_IE_CALLED_PARTY_NUMBER 0x70 /* Called Party Number */
434 #define Q931_IE_CALLED_PARTY_SUBADDR 0x71 /* Called Party Subaddress */
435 #define Q931_IE_REDIRECTING_NUMBER 0x74
436 #define Q931_IE_REDIRECTION_NUMBER 0x76
437 #define Q931_IE_TRANSIT_NETWORK_SEL 0x78 /* Transit Network Selection */
438 #define Q931_IE_RESTART_INDICATOR 0x79
439 #define Q931_IE_LOW_LAYER_COMPAT 0x7C /* Low-Layer Compatibility */
440 #define Q931_IE_HIGH_LAYER_COMPAT 0x7D /* High-Layer Compatibility */
441 #define Q931_IE_USER_USER 0x7E /* User-User */
442 #define Q931_IE_ESCAPE 0x7F /* Escape for extension */
443
444 /*
445 * Codeset 0 ETSI.
446 */
447 #define Q931_IE_CONNECTED_NUMBER 0x8C
448 #define Q931_IE_CONNECTED_SUBADDR 0x8D
449
450 /*
451 * Codeset 5 (National-specific) Belgium.
452 */
453 #define Q931_IE_CHARGING_ADVICE 0x1A
454
455 /*
456 * Codeset 5 (National-specific) Bellcore National ISDN.
457 */
458 #define Q931_IE_OPERATOR_SYSTEM_ACCESS 0x1D
459
460 /*
461 * Codeset 5 ETSI ETS 300 192
462 */
463 #define Q931_IE_PARTY_CATEGORY 0x32
464
465 /*
466 * Codeset 6 (Network-specific) Belgium.
467 */
468 /* 0x1A is Charging Advice, as with Codeset 5 */
469 #define Q931_IE_REDIRECTING_NUMBER 0x74
470
471 /*
472 * Codeset 6 (Network-specific) FT-Numeris.
473 */
474 /* 0x1D is User Capability */
475
476 /*
477 * Codeset 6 (Network-specific) Bellcore National ISDN.
478 */
479 #define Q931_IE_REDIRECTING_SUBADDR 0x75 /* Redirecting Subaddress */
480 /* 0x76 is Redirection Number, but that's also Codeset 0 */
481 #define Q931_IE_CALL_APPEARANCE 0x7B
482
483 /* Codeset 0 */
484 static const value_string q931_info_element_vals0[] = {
485 { Q931_IE_SEGMENTED_MESSAGE, "Segmented message" },
486 { Q931_IE_CHANGE_STATUS, "Change status" },
487 { Q931_IE_BEARER_CAPABILITY, "Bearer capability" },
488 { Q931_IE_CAUSE, "Cause" },
489 { Q931_IE_CALL_IDENTITY, "Call identity" },
490 { Q931_IE_CALL_STATE, "Call state" },
491 { Q931_IE_CHANNEL_IDENTIFICATION, "Channel identification" },
492 { Q931_IE_FACILITY, "Facility" },
493 { Q931_IE_PROGRESS_INDICATOR, "Progress indicator" },
494 { Q931_IE_NETWORK_SPECIFIC_FACIL, "Network specific facilities" },
495 { Q931_IE_NOTIFICATION_INDICATOR, "Notification indicator" },
496 { Q931_IE_DISPLAY, "Display" },
497 { Q931_IE_DATE_TIME, "Date/Time" },
498 { Q931_IE_KEYPAD_FACILITY, "Keypad facility" },
499 { Q931_IE_INFORMATION_REQUEST, "Information request" },
500 { Q931_IE_SIGNAL, "Signal" },
501 { Q931_IE_SWITCHHOOK, "Switchhook" },
502 { Q931_IE_FEATURE_ACTIVATION, "Feature activation" },
503 { Q931_IE_FEATURE_INDICATION, "Feature Indication" },
504 { Q931_IE_ENDPOINT_IDENTIFIER, "Endpoint identifier" },
505 { Q931_IE_SERVICE_PROFILE_ID, "Service profile ID" },
506 { Q931_IE_INFORMATION_RATE, "Information rate" },
507 { Q931_IE_E2E_TRANSIT_DELAY, "End-to-end transit delay" },
508 { Q931_IE_TD_SELECTION_AND_INT, "Transit delay selection and indication" },
509 { Q931_IE_PL_BINARY_PARAMETERS, "Packet layer binary parameters" },
510 { Q931_IE_PL_WINDOW_SIZE, "Packet layer window size" },
511 { Q931_IE_PACKET_SIZE, "Packet size" },
512 { Q931_IE_CUG, "Closed user group" },
513 { Q931_IE_REVERSE_CHARGE_IND, "Reverse charging indication" },
514 { Q931_IE_CONNECTED_NUMBER_DEFAULT, "Connected number" },
515 { Q931_IE_INTERFACE_SERVICE, "Interface Service" },
516 { Q931_IE_CHANNEL_STATUS, "Channel Status" },
517 { Q931_IE_VERSION_INFO, "Version Info" },
518 { Q931_IE_CALLING_PARTY_NUMBER, "Calling party number" },
519 { Q931_IE_CALLING_PARTY_SUBADDR, "Calling party subaddress" },
520 { Q931_IE_CALLED_PARTY_NUMBER, "Called party number" },
521 { Q931_IE_CALLED_PARTY_SUBADDR, "Called party subaddress" },
522 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
523 { Q931_IE_REDIRECTION_NUMBER, "Redirection number" },
524 { Q931_IE_TRANSIT_NETWORK_SEL, "Transit network selection" },
525 { Q931_IE_RESTART_INDICATOR, "Restart indicator" },
526 { Q931_IE_LOW_LAYER_COMPAT, "Low-layer compatibility" },
527 { Q931_IE_HIGH_LAYER_COMPAT, "High-layer compatibility" },
528 { Q931_IE_USER_USER, "User-user" },
529 { Q931_IE_ESCAPE, "Escape" },
530 { Q931_IE_CONNECTED_NUMBER, "Connected number" },
531 { Q931_IE_CONNECTED_SUBADDR, "Connected subaddress" },
532 { 0, NULL }
533 };
534
535 /* Codeset 1 */
536 static const value_string q931_info_element_vals1[] = {
537 { 0, NULL }
538 };
539 /* Codeset 2 */
540 static const value_string q931_info_element_vals2[] = {
541 { 0, NULL }
542 };
543 /* Codeset 3 */
544 static const value_string q931_info_element_vals3[] = {
545 { 0, NULL }
546 };
547 /* Codeset 4 */
548 static const value_string q931_info_element_vals4[] = {
549 { 0, NULL }
550 };
551 /* Codeset 5 */
552 static const value_string q931_info_element_vals5[] = {
553 { Q931_IE_CHARGING_ADVICE, "Charging advice" },
554 { Q931_IE_OPERATOR_SYSTEM_ACCESS, "Operator system access" },
555 { Q931_IE_PARTY_CATEGORY, "Party category"},
556 { 0, NULL }
557 };
558 /* Codeset 6 */
559 static const value_string q931_info_element_vals6[] = {
560 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
561 { Q931_IE_REDIRECTING_SUBADDR, "Redirecting subaddress" },
562 { Q931_IE_CALL_APPEARANCE, "Call appearance" },
563 { Q931_IE_DISPLAY, "Avaya Display" }, /* if Avaya codeset to send display = 6 */
564 { 0, NULL }
565 };
566 /* Codeset 7 */
567 static const value_string q931_info_element_vals7[] = {
568 { 0, NULL }
569 };
570
571 /* Codeset array */
572 #define NUM_INFO_ELEMENT_VALS (Q931_IE_SHIFT_CODESET+1)
573 static const value_string *q931_info_element_vals[NUM_INFO_ELEMENT_VALS] = {
574 q931_info_element_vals0,
575 q931_info_element_vals1,
576 q931_info_element_vals2,
577 q931_info_element_vals3,
578 q931_info_element_vals4,
579 q931_info_element_vals5,
580 q931_info_element_vals6,
581 q931_info_element_vals7,
582 };
583
584 static const value_string q931_congestion_level_vals[] = {
585 { 0x0, "Receiver ready" },
586 { 0xF, "Receiver not ready" },
587 { 0, NULL }
588 };
589
590 static const value_string q931_repeat_indication_vals[] = {
591 { 0x2, "Prioritized list" },
592 { 0, NULL }
593 };
594
595 /*
596 * ITU-standardized coding.
597 */
598 #define Q931_ITU_STANDARDIZED_CODING 0x00
599 #define Q931_ISO_IEC_STANDARDIZED_CODING 0x20
600
601 /*
602 * Dissect a Segmented message information element.
603 */
604 static void
dissect_q931_segmented_message_ie(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree,proto_item * item)605 dissect_q931_segmented_message_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
606 proto_tree *tree, proto_item* item)
607 {
608 guint8 octet;
609
610 if (len != 2) {
611 expert_add_info_format(pinfo, item, &ei_q931_invalid_length,
612 "Segmented message: length is %d, should be 2", len);
613 return;
614 }
615
616 octet = tvb_get_guint8(tvb, offset);
617 if (octet & 0x80) {
618 proto_tree_add_item(tree, hf_q931_first_segment, tvb, offset, 1, ENC_NA);
619 } else {
620 proto_tree_add_item(tree, hf_q931_not_first_segment, tvb, offset, 1, ENC_NA);
621 }
622 proto_tree_add_item(tree, hf_q931_segment_type, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
623 }
624
625 /*
626 * Dissect a Bearer capability or Low-layer compatibility information element.
627 */
628 static const value_string q931_coding_standard_vals[] = {
629 { 0x0, "ITU-T standardized coding" },
630 { 0x1, "ISO/IEC standard" },
631 { 0x2, "National standard" },
632 { 0x3, "Standard defined for this particular network" },
633 { 0, NULL }
634 };
635
636 static const value_string q931_information_transfer_capability_vals[] = {
637 { 0x00, "Speech" },
638 { 0x08, "Unrestricted digital information" },
639 { 0x09, "Restricted digital information" },
640 { 0x10, "3.1 kHz audio" },
641 { 0x11, "Unrestricted digital information with tones/announcements" },
642 { 0x18, "Video" },
643 { 0, NULL }
644 };
645
646 static const value_string q931_transfer_mode_vals[] = {
647 { 0x00, "Circuit mode" },
648 { 0x02, "Packet mode" },
649 { 0, NULL }
650 };
651
652 #define Q931_IT_RATE_MULTIRATE 0x18
653
654 static const value_string q931_information_transfer_rate_vals[] = {
655 { 0x00, "Packet mode" },
656 { 0x10, "64 kbit/s" },
657 { 0x11, "2 x 64 kbit/s" },
658 { 0x13, "384 kbit/s" },
659 { 0x15, "1536 kbit/s" },
660 { 0x17, "1920 kbit/s" },
661 { Q931_IT_RATE_MULTIRATE, "Multirate (64 kbit/s base rate)" },
662 { 0, NULL }
663 };
664
665 /*
666 * Values 0x0a and 0x0b added from Q.931 Amendment 1 (12/2002)
667 */
668 static const value_string q931_uil1_vals[] = {
669 { 0x01, "V.110/I.460/X.30 rate adaption" },
670 { 0x02, "Recommendation G.711 u-law" },
671 { 0x03, "Recommendation G.711 A-law" },
672 { 0x04, "Recommendation G.721 32 kbit/s ADPCM and Recommendation I.460" },
673 { 0x05, "Recommendation H.221 and H.242" },
674 { 0x06, "Recommendation H.223 and H.245" },
675 { 0x07, "Non-ITU-T-standardized rate adaption" },
676 { 0x08, "V.120 rate adaption" },
677 { 0x09, "X.31 HDLC flag stuffing" },
678 { 0x0a, "Recommendation G.728 LD-CELP" },
679 { 0x0b, "Recommendation G.729 CS-ACELP" },
680 { 0, NULL }
681 };
682 static value_string_ext q931_uil1_vals_ext = VALUE_STRING_EXT_INIT(q931_uil1_vals);
683
684 static const value_string q931_l1_user_rate_vals[] = {
685 { 0x00, "Rate indicated by E-bits" },
686 { 0x01, "0.6 kbit/s" },
687 { 0x02, "1.2 kbit/s" },
688 { 0x03, "2.4 kbit/s" },
689 { 0x04, "3.6 kbit/s" },
690 { 0x05, "4.8 kbit/s" },
691 { 0x06, "7.2 kbit/s" },
692 { 0x07, "8 kbit/s" },
693 { 0x08, "9.6 kbit/s" },
694 { 0x09, "14.4 kbit/s" },
695 { 0x0A, "16 kbit/s" },
696 { 0x0B, "19.2 kbit/s" },
697 { 0x0C, "32 kbit/s" },
698 { 0x0E, "48 kbit/s" },
699 { 0x0F, "56 kbit/s" },
700 { 0x10, "64 kbit/s "},
701 { 0x15, "0.1345 kbit/s" },
702 { 0x16, "0.100 kbit/s" },
703 { 0x17, "0.075/1.2 kbit/s" },
704 { 0x18, "1.2/0.075 kbit/s" },
705 { 0x19, "0.050 kbit/s" },
706 { 0x1A, "0.075 kbit/s" },
707 { 0x1B, "0.110 kbit/s" },
708 { 0x1C, "0.150 kbit/s" },
709 { 0x1D, "0.200 kbit/s" },
710 { 0x1E, "0.300 kbit/s" },
711 { 0x1F, "12 kbit/s" },
712 { 0, NULL }
713 };
714 static value_string_ext q931_l1_user_rate_vals_ext = VALUE_STRING_EXT_INIT(q931_l1_user_rate_vals);
715
716 static const value_string q931_l1_intermediate_rate_vals[] = {
717 { 0x20, "8 kbit/s" },
718 { 0x40, "16 kbit/s" },
719 { 0x60, "32 kbit/s" },
720 { 0, NULL }
721 };
722
723 static const value_string q931_l1_stop_bits_vals[] = {
724 { 0x20, "1" },
725 { 0x40, "1.5" },
726 { 0x60, "2" },
727 { 0, NULL }
728 };
729
730 static const value_string q931_l1_data_bits_vals[] = {
731 { 0x08, "5" },
732 { 0x10, "7" },
733 { 0x18, "8" },
734 { 0, NULL }
735 };
736
737 static const value_string q931_l1_parity_vals[] = {
738 { 0x00, "Odd" },
739 { 0x02, "Even" },
740 { 0x03, "None" },
741 { 0x04, "Forced to 0" },
742 { 0x05, "Forced to 1" },
743 { 0, NULL }
744 };
745
746 #define Q931_UIL2_USER_SPEC 0x10
747
748 static const value_string q931_uil2_vals[] = {
749 { 0x01, "Basic mode ISO 1745" },
750 { 0x02, "Q.921/I.441" }, /* LAPD */
751 { 0x06, "X.25, link layer" }, /* LAPB */
752 { 0x07, "X.25 multilink" }, /* or 0x0F? */
753 { 0x08, "T.71 Extended LAPB" },
754 { 0x09, "HDLC ARM" },
755 { 0x0A, "HDLC NRM" },
756 { 0x0B, "HDLC ABM" },
757 { 0x0C, "ISO 8802/2 LLC" },
758 { 0x0D, "X.75 Single Link Procedure" },
759 { 0x0E, "Q.922" },
760 { 0x0F, "Core aspects of Q.922" },
761 { Q931_UIL2_USER_SPEC, "User-specified" },
762 { 0x11, "ISO 7776 DTE-DTE operation" },
763 { 0, NULL }
764 };
765 static value_string_ext q931_uil2_vals_ext = VALUE_STRING_EXT_INIT(q931_uil2_vals);
766
767 static const value_string q931_mode_vals[] = {
768 { 0x20, "Normal mode" },
769 { 0x40, "Extended mode" },
770 { 0, NULL }
771 };
772
773 #define Q931_UIL3_X25_PL 0x06
774 #define Q931_UIL3_ISO_8208 0x07 /* X.25-based */
775 #define Q931_UIL3_X223 0x08 /* X.25-based */
776 #define Q931_UIL3_TR_9577 0x0B
777 #define Q931_UIL3_USER_SPEC 0x10
778
779 static const value_string q931_uil3_vals[] = {
780 { 0x02, "Q.931/I.451" },
781 { Q931_UIL3_X25_PL, "X.25, packet layer" },
782 { Q931_UIL3_ISO_8208, "ISO/IEC 8208" },
783 { Q931_UIL3_X223, "X.223/ISO 8878" },
784 { 0x09, "ISO/IEC 8473" },
785 { 0x0A, "T.70" },
786 { Q931_UIL3_TR_9577, "ISO/IEC TR 9577" },
787 { Q931_UIL3_USER_SPEC, "User-specified" },
788 { 0, NULL }
789 };
790
791 static void
dissect_q931_protocol_discriminator(tvbuff_t * tvb,int offset,proto_tree * tree)792 dissect_q931_protocol_discriminator(tvbuff_t *tvb, int offset, proto_tree *tree)
793 {
794 unsigned int discriminator = tvb_get_guint8(tvb, offset);
795
796 if (discriminator == NLPID_DMS) {
797 proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
798 tvb, offset, 1, discriminator,
799 "Maintenance messages");
800 } else if (discriminator == NLPID_Q_931) {
801 proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
802 tvb, offset, 1, discriminator,
803 "Q.931");
804 } else if (discriminator == NLPID_Q_2931) {
805 proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
806 tvb, offset, 1, discriminator,
807 "Q.2931");
808 } else if ((discriminator >= 16 && discriminator < 63)
809 || ((discriminator >= 80) && (discriminator < 254))) {
810 proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
811 tvb, offset, 1, discriminator,
812 "Network layer or layer 3 protocol (0x%02X)",
813 discriminator);
814 } else if (discriminator >= 64 && discriminator <= 79) {
815 proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
816 tvb, offset, 1, discriminator,
817 "National use (0x%02X)",
818 discriminator);
819 } else {
820 proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
821 tvb, offset, 1, discriminator,
822 "Reserved (0x%02X)",
823 discriminator);
824 }
825 }
826
827 static const value_string q931_bearer_capability_layer_ident_vals[] = {
828 { 0x01, "Layer 1 identifier" },
829 { 0x02, "Layer 2 identifier" },
830 { 0x03, "Layer 3 identifier" },
831 { 0x00, NULL }
832 };
833
834 #define Q931_UIL2_USER_SPEC 0x10
835
836 static const range_string q931_l1_modem_type_rvals[] = {
837 { 0x00, 0x05, "National use" },
838 { 0x11, 0x11, "V.21" },
839 { 0x12, 0x12, "V.22" },
840 { 0x13, 0x13, "V.22 bis" },
841 { 0x14, 0x14, "V.23" },
842 { 0x15, 0x15, "V.26" },
843 { 0x16, 0x16, "V.26 bis" },
844 { 0x17, 0x17, "V.26 ter" },
845 { 0x18, 0x18, "V.27" },
846 { 0x19, 0x19, "V.27 bis" },
847 { 0x1A, 0x1A, "V.27 ter" },
848 { 0x1B, 0x1B, "V.29" },
849 { 0x1C, 0x1C, "V.32" },
850 { 0x1E, 0x1E, "V.34" },
851 { 0x20, 0x2F, "National use" },
852 { 0x30, 0x3F, "User specified" },
853 { 0, 0, NULL }
854 };
855
856 static const true_false_string tfs_assignor_default = { "Assignor only", "Default assignee" };
857 static const true_false_string tfs_in_out_band = { "in-band", "out-of-band" };
858 static const true_false_string tfs_protocol_negotiation = { "Full protocol negotiation", "LLI = 256 only" };
859
860 void
dissect_q931_bearer_capability_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)861 dissect_q931_bearer_capability_ie(tvbuff_t *tvb, int offset, int len,
862 proto_tree *tree)
863 {
864 guint8 octet;
865 guint8 coding_standard;
866 guint8 it_rate;
867 guint8 uil2_protocol;
868 guint8 uil3_protocol;
869 guint8 add_l3_info;
870
871 if (len == 0)
872 return;
873 octet = tvb_get_guint8(tvb, offset);
874 coding_standard = octet & 0x60;
875 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
876 /*
877 * We don't know how the bearer capability is encoded,
878 * so just dump it as data and be done with it.
879 */
880 proto_tree_add_item(tree, hf_q931_bearer_capability_data, tvb, offset, len, ENC_NA);
881 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
882 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
883 return;
884 }
885 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
886 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
887 proto_tree_add_uint(tree, hf_q931_information_transfer_capability, tvb, offset, 1, octet);
888 offset += 1;
889 len -= 1;
890
891 /*
892 * XXX - only in Low-layer compatibility information element.
893 */
894 if (!(octet & Q931_IE_VL_EXTENSION)) {
895 if (len == 0)
896 return;
897 proto_tree_add_item(tree, hf_q931_out_band_negotiation, tvb, offset, 1, ENC_NA);
898 offset += 1;
899 len -= 1;
900 }
901
902 if (len == 0)
903 return;
904 octet = tvb_get_guint8(tvb, offset);
905 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
906 proto_tree_add_uint(tree, hf_q931_transfer_mode, tvb, offset, 1, octet);
907 proto_tree_add_uint(tree, hf_q931_information_transfer_rate, tvb, offset, 1, octet);
908 it_rate = octet & 0x1F;
909 offset += 1;
910 len -= 1;
911
912 if (it_rate == Q931_IT_RATE_MULTIRATE) {
913 if (len == 0)
914 return;
915 proto_tree_add_item(tree, hf_q931_bearer_capability_rate_multiplier, tvb, offset, 1, ENC_BIG_ENDIAN);
916 offset += 1;
917 len -= 1;
918 }
919
920 if (len == 0)
921 return;
922 octet = tvb_get_guint8(tvb, offset);
923 if ((octet & 0x60) == 0x20) {
924 /*
925 * Layer 1 information.
926 */
927 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
928 proto_tree_add_uint(tree, hf_q931_layer_ident, tvb, offset, 1, octet);
929 proto_tree_add_uint(tree, hf_q931_uil1, tvb, offset, 1, octet);
930 offset += 1;
931 len -= 1;
932
933 if (octet & Q931_IE_VL_EXTENSION)
934 goto l1_done;
935 if (len == 0)
936 return;
937 octet = tvb_get_guint8(tvb, offset);
938 proto_tree_add_item(tree, hf_q931_layer_1, tvb, offset, 1, ENC_NA);
939 proto_tree_add_item(tree, hf_q931_layer_1_in_band_negotiation, tvb, offset, 1, ENC_NA);
940 proto_tree_add_item(tree, hf_q931_bearer_capability_user_rate, tvb, offset, 1, ENC_BIG_ENDIAN);
941 offset += 1;
942 len -= 1;
943
944 if (octet & Q931_IE_VL_EXTENSION)
945 goto l1_done;
946 if (len == 0)
947 return;
948 octet = tvb_get_guint8(tvb, offset);
949 proto_tree_add_item(tree, hf_q931_bearer_capability_intermediate_rate, tvb, offset, 1, ENC_BIG_ENDIAN);
950 proto_tree_add_item(tree, hf_q931_send_data_net_independent_clock, tvb, offset, 1, ENC_NA);
951 proto_tree_add_item(tree, hf_q931_accept_data_net_independent_clock, tvb, offset, 1, ENC_NA);
952 proto_tree_add_item(tree, hf_q931_send_data_flow_control, tvb, offset, 1, ENC_NA);
953 proto_tree_add_item(tree, hf_q931_accept_data_flow_control, tvb, offset, 1, ENC_NA);
954 offset += 1;
955 len -= 1;
956
957 if (octet & Q931_IE_VL_EXTENSION)
958 goto l1_done;
959 if (len == 0)
960 return;
961 octet = tvb_get_guint8(tvb, offset);
962 proto_tree_add_item(tree, hf_q931_rate_adaption_header, tvb, offset, 1, ENC_NA);
963 proto_tree_add_item(tree, hf_q931_multiple_frame_establishment, tvb, offset, 1, ENC_NA);
964 proto_tree_add_item(tree, hf_q931_mode_of_operation, tvb, offset, 1, ENC_NA);
965 proto_tree_add_item(tree, hf_q931_protocol_negotiation, tvb, offset, 1, ENC_NA);
966 proto_tree_add_item(tree, hf_q931_message_originator, tvb, offset, 1, ENC_NA);
967 proto_tree_add_item(tree, hf_q931_negotiation_is_done, tvb, offset, 1, ENC_NA);
968 offset += 1;
969 len -= 1;
970
971 if (octet & Q931_IE_VL_EXTENSION)
972 goto l1_done;
973 if (len == 0)
974 return;
975 octet = tvb_get_guint8(tvb, offset);
976 proto_tree_add_item(tree, hf_q931_bearer_capability_stop_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
977 proto_tree_add_item(tree, hf_q931_bearer_capability_data_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
978 proto_tree_add_item(tree, hf_q931_bearer_capability_parity, tvb, offset, 1, ENC_BIG_ENDIAN);
979
980 if (octet & Q931_IE_VL_EXTENSION)
981 goto l1_done;
982 proto_tree_add_item(tree, hf_q931_bearer_capability_duplex, tvb, offset, 1, ENC_NA);
983 proto_tree_add_item(tree, hf_q931_bearer_capability_modem_type, tvb, offset, 1, ENC_BIG_ENDIAN);
984 offset += 1;
985 len -= 1;
986 }
987 l1_done:
988 ;
989
990 if (len == 0)
991 return;
992 octet = tvb_get_guint8(tvb, offset);
993 if ((octet & 0x60) == 0x40) {
994 /*
995 * Layer 2 information.
996 */
997 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
998 proto_tree_add_uint(tree, hf_q931_layer_ident, tvb, offset, 1, octet);
999 uil2_protocol = octet & 0x1F;
1000 proto_tree_add_item(tree, hf_q931_uil2, tvb, offset, 1, ENC_BIG_ENDIAN);
1001 offset += 1;
1002 len -= 1;
1003
1004 /*
1005 * XXX - only in Low-layer compatibility information element.
1006 */
1007 if (octet & Q931_IE_VL_EXTENSION)
1008 goto l2_done;
1009 if (len == 0)
1010 return;
1011 octet = tvb_get_guint8(tvb, offset);
1012 if (uil2_protocol == Q931_UIL2_USER_SPEC) {
1013 proto_tree_add_item(tree, hf_q931_uil2_info, tvb, offset, 1, ENC_BIG_ENDIAN);
1014 } else {
1015 proto_tree_add_item(tree, hf_q931_bearer_capability_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
1016 }
1017 offset += 1;
1018 len -= 1;
1019
1020 if (octet & Q931_IE_VL_EXTENSION)
1021 goto l2_done;
1022 if (len == 0)
1023 return;
1024 octet = tvb_get_guint8(tvb, offset) & 0x7F;
1025 proto_tree_add_uint_format_value(tree, hf_q931_bearer_capability_window_size, tvb, offset, 1,
1026 octet, "octet & 0x7F%u k", octet);
1027 offset += 1;
1028 len -= 1;
1029 }
1030 l2_done:
1031 ;
1032
1033 if (len == 0)
1034 return;
1035 octet = tvb_get_guint8(tvb, offset);
1036 if ((octet & 0x60) == 0x60) {
1037 /*
1038 * Layer 3 information.
1039 */
1040 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1041 proto_tree_add_uint(tree, hf_q931_layer_ident, tvb, offset, 1, octet);
1042 uil3_protocol = octet & 0x1F;
1043 proto_tree_add_item(tree, hf_q931_uil3, tvb, offset, 1, ENC_BIG_ENDIAN);
1044 offset += 1;
1045 len -= 1;
1046
1047
1048 /*
1049 * XXX - only in Low-layer compatibility information element.
1050 */
1051 if (octet & Q931_IE_VL_EXTENSION)
1052 goto l3_done;
1053 if (len == 0)
1054 return;
1055 octet = tvb_get_guint8(tvb, offset);
1056 switch (uil3_protocol) {
1057
1058 case Q931_UIL3_X25_PL:
1059 case Q931_UIL3_ISO_8208:
1060 case Q931_UIL3_X223:
1061 proto_tree_add_item(tree, hf_q931_bearer_capability_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
1062 offset += 1;
1063 len -= 1;
1064
1065 if (octet & Q931_IE_VL_EXTENSION)
1066 goto l3_done;
1067 if (len == 0)
1068 return;
1069 octet = tvb_get_guint8(tvb, offset);
1070 proto_tree_add_item(tree, hf_q931_bearer_capability_default_packet_size, tvb, offset, 1, ENC_BIG_ENDIAN);
1071 offset += 1;
1072 len -= 1;
1073
1074 if (octet & Q931_IE_VL_EXTENSION)
1075 goto l3_done;
1076 if (len == 0)
1077 return;
1078 proto_tree_add_item(tree, hf_q931_bearer_capability_packet_window_size, tvb, offset, 1, ENC_BIG_ENDIAN);
1079 /*offset += 1;*/
1080 /*len -= 1;*/
1081 break;
1082
1083 case Q931_UIL3_USER_SPEC:
1084 proto_tree_add_uint(tree, hf_q931_bearer_capability_default_packet_size, tvb, offset, 1, 1 << (octet & 0x0F));
1085 /*offset += 1;*/
1086 /*len -= 1;*/
1087 break;
1088
1089 case Q931_UIL3_TR_9577:
1090 add_l3_info = (octet & 0x0F) << 4;
1091 if (octet & Q931_IE_VL_EXTENSION)
1092 goto l3_done;
1093 if (len < 2)
1094 return;
1095 octet = tvb_get_guint8(tvb, offset + 1);
1096 add_l3_info |= (octet & 0x0F);
1097 proto_tree_add_uint(tree, hf_q931_uil3_additional, tvb, offset, 2, add_l3_info);
1098 /*offset += 2;*/
1099 /*len -= 2;*/
1100 break;
1101 }
1102 }
1103 l3_done:
1104 ;
1105 }
1106
1107 /*
1108 * Dissect a Cause information element.
1109 */
1110
1111
1112 static const value_string q931_cause_location_vals[] = {
1113 { 0x00, "User (U)" },
1114 { 0x01, "Private network serving the local user (LPN)" },
1115 { 0x02, "Public network serving the local user (LN)" },
1116 { 0x03, "Transit network (TN)" },
1117 { 0x04, "Public network serving the remote user (RLN)" },
1118 { 0x05, "Private network serving the remote user (RPN)" },
1119 { 0x06, "Unallocated code" },
1120 { 0x07, "International network (INTL)" },
1121 { 0x08, "Unallocated code" },
1122 { 0x09, "Unallocated code" },
1123 { 0x0A, "Network beyond interworking point (BI)" },
1124 { 0, NULL }
1125 };
1126 value_string_ext q931_cause_location_vals_ext = VALUE_STRING_EXT_INIT(q931_cause_location_vals);
1127
1128 static const value_string q931_cause_recommendation_vals[] = {
1129 { 0x00, "Q.931" },
1130 { 0x03, "X.21" },
1131 { 0x04, "X.25" },
1132 { 0x05, "Q.1031/Q.1051" },
1133 { 0, NULL }
1134 };
1135
1136 /*
1137 * Cause codes for Cause.
1138 */
1139 #define Q931_CAUSE_UNALLOC_NUMBER 0x01
1140 #define Q931_CAUSE_NO_ROUTE_TO_DEST 0x03
1141 #define Q931_CAUSE_CALL_REJECTED 0x15
1142 #define Q931_CAUSE_NUMBER_CHANGED 0x16
1143 #define Q931_CAUSE_ACCESS_INFO_DISC 0x2B
1144 #define Q931_CAUSE_QOS_UNAVAILABLE 0x31
1145 #define Q931_CAUSE_CHAN_NONEXISTENT 0x52
1146 #define Q931_CAUSE_INCOMPATIBLE_DEST 0x58
1147 #define Q931_CAUSE_MAND_IE_MISSING 0x60
1148 #define Q931_CAUSE_MT_NONEX_OR_UNIMPL 0x61
1149 #define Q931_CAUSE_IE_NONEX_OR_UNIMPL 0x63
1150 #define Q931_CAUSE_INVALID_IE_CONTENTS 0x64
1151 #define Q931_CAUSE_MSG_INCOMPAT_W_CS 0x65
1152 #define Q931_CAUSE_REC_TIMER_EXP 0x66
1153
1154 static const value_string q931_cause_code_vals[] = {
1155 { 0x00, "Valid cause code not yet received" },
1156 { Q931_CAUSE_UNALLOC_NUMBER, "Unallocated (unassigned) number" },
1157 { 0x02, "No route to specified transit network" },
1158 { Q931_CAUSE_NO_ROUTE_TO_DEST, "No route to destination" },
1159 { 0x04, "Send special information tone" },
1160 { 0x05, "Misdialled trunk prefix" },
1161 { 0x06, "Channel unacceptable" },
1162 { 0x07, "Call awarded and being delivered in an established channel" },
1163 { 0x08, "Prefix 0 dialed but not allowed" },
1164 /* Q.850 - "Preemption" */
1165 { 0x09, "Prefix 1 dialed but not allowed" },
1166 /* Q.850 - "Preemption - circuit reserved for reuse" */
1167 { 0x0A, "Prefix 1 dialed but not required" },
1168 { 0x0B, "More digits received than allowed, call is proceeding" },
1169 { 0x0E, "QoR: ported number" },
1170 { 0x10, "Normal call clearing" },
1171 { 0x11, "User busy" },
1172 { 0x12, "No user responding" },
1173 { 0x13, "No answer from user (user alerted)" },
1174 { 0x14, "Subscriber absent" },
1175 { Q931_CAUSE_CALL_REJECTED, "Call rejected" },
1176 { Q931_CAUSE_NUMBER_CHANGED, "Number changed" },
1177 { 0x17, "Reverse charging rejected" },
1178 /* Q.850 - "Redirection to new destination" */
1179 { 0x18, "Call suspended" },
1180 /* Q.850 Amendment 1 - "Call rejected due to feature at the destination" */
1181 { 0x19, "Call resumed" },
1182 /* Q.850 - "Exchange routing error */
1183 { 0x1A, "Non-selected user clearing" },
1184 { 0x1B, "Destination out of order" },
1185 { 0x1C, "Invalid number format (incomplete number)" },
1186 { 0x1D, "Facility rejected" },
1187 { 0x1E, "Response to STATUS ENQUIRY" },
1188 { 0x1F, "Normal unspecified" },
1189 { 0x21, "Circuit out of order" },
1190 { 0x22, "No circuit/channel available" },
1191 { 0x23, "Destination unattainable" },
1192 { 0x25, "Degraded service" },
1193 { 0x26, "Network out of order" },
1194 { 0x27, "Transit delay range cannot be achieved" },
1195 /* Q.850 - "Permanent frame mode connection out of service" */
1196 { 0x28, "Throughput range cannot be achieved" },
1197 /* Q.850 - "Permanent frame mode connection operational" */
1198 { 0x29, "Temporary failure" },
1199 { 0x2A, "Switching equipment congestion" },
1200 { Q931_CAUSE_ACCESS_INFO_DISC, "Access information discarded" },
1201 { 0x2C, "Requested circuit/channel not available" },
1202 { 0x2D, "Pre-empted" },
1203 { 0x2E, "Precedence call blocked" },
1204 { 0x2F, "Resources unavailable, unspecified" },
1205 { Q931_CAUSE_QOS_UNAVAILABLE, "Quality of service unavailable" },
1206 { 0x32, "Requested facility not subscribed" },
1207 { 0x33, "Reverse charging not allowed" },
1208 { 0x34, "Outgoing calls barred" },
1209 { 0x35, "Outgoing calls barred within CUG" },
1210 { 0x36, "Incoming calls barred" },
1211 { 0x37, "Incoming calls barred within CUG" },
1212 { 0x38, "Call waiting not subscribed" },
1213 { 0x39, "Bearer capability not authorized" },
1214 { 0x3A, "Bearer capability not presently available" },
1215 { 0x3E, "Inconsistency in designated outgoing access information and subscriber class" },
1216 { 0x3F, "Service or option not available, unspecified" },
1217 { 0x41, "Bearer capability not implemented" },
1218 { 0x42, "Channel type not implemented" },
1219 { 0x43, "Transit network selection not implemented" },
1220 { 0x44, "Message not implemented" },
1221 { 0x45, "Requested facility not implemented" },
1222 { 0x46, "Only restricted digital information bearer capability is available" },
1223 { 0x4F, "Service or option not implemented, unspecified" },
1224 { 0x51, "Invalid call reference value" },
1225 { Q931_CAUSE_CHAN_NONEXISTENT, "Identified channel does not exist" },
1226 { 0x53, "Call identity does not exist for suspended call" },
1227 { 0x54, "Call identity in use" },
1228 { 0x55, "No call suspended" },
1229 { 0x56, "Call having the requested call identity has been cleared" },
1230 { 0x57, "Called user not member of CUG" },
1231 { Q931_CAUSE_INCOMPATIBLE_DEST, "Incompatible destination" },
1232 { 0x59, "Non-existent abbreviated address entry" },
1233 { 0x5A, "Destination address missing, and direct call not subscribed" },
1234 /* Q.850 - "Non-existent CUG" */
1235 { 0x5B, "Invalid transit network selection (national use)" },
1236 { 0x5C, "Invalid facility parameter" },
1237 { 0x5D, "Mandatory information element is missing" },
1238 { 0x5F, "Invalid message, unspecified" },
1239 { Q931_CAUSE_MAND_IE_MISSING, "Mandatory information element is missing" },
1240 { Q931_CAUSE_MT_NONEX_OR_UNIMPL, "Message type non-existent or not implemented" },
1241 { 0x62, "Message not compatible with call state or message type non-existent or not implemented" },
1242 { Q931_CAUSE_IE_NONEX_OR_UNIMPL, "Information element non-existent or not implemented" },
1243 { Q931_CAUSE_INVALID_IE_CONTENTS, "Invalid information element contents" },
1244 { Q931_CAUSE_MSG_INCOMPAT_W_CS, "Message not compatible with call state" },
1245 { Q931_CAUSE_REC_TIMER_EXP, "Recovery on timer expiry" },
1246 { 0x67, "Parameter non-existent or not implemented - passed on" },
1247 { 0x6E, "Message with unrecognized parameter discarded" },
1248 { 0x6F, "Protocol error, unspecified" },
1249 { 0x7F, "Internetworking, unspecified" },
1250 { 0, NULL }
1251 };
1252 value_string_ext q931_cause_code_vals_ext = VALUE_STRING_EXT_INIT(q931_cause_code_vals);
1253
1254 static const value_string q931_cause_condition_vals[] = {
1255 { 0x00, "Unknown" },
1256 { 0x01, "Permanent" },
1257 { 0x02, "Transient" },
1258 { 0x00, NULL }
1259 };
1260
1261 #define Q931_REJ_USER_SPECIFIC 0x00
1262 #define Q931_REJ_IE_MISSING 0x04
1263 #define Q931_REJ_IE_INSUFFICIENT 0x08
1264
1265 static const value_string q931_rejection_reason_vals[] = {
1266 { 0x00, "User specific" },
1267 { 0x04, "Information element missing" },
1268 { 0x08, "Information element contents are not sufficient" },
1269 { 0x00, NULL }
1270 };
1271
get_message_name(guint8 prot_discr,guint8 message_type)1272 static const gchar *get_message_name(guint8 prot_discr, guint8 message_type) {
1273 if (prot_discr == NLPID_DMS)
1274 return val_to_str(message_type, dms_message_type_vals, "Unknown (0x%02X)");
1275 else
1276 return val_to_str_ext(message_type, &q931_message_type_vals_ext, "Unknown (0x%02X)");
1277 }
1278
1279 static const true_false_string tfs_abnormal_normal = { "Abnormal", "Normal" };
1280
1281 static void
dissect_q931_cause_ie_with_info(tvbuff_t * tvb,int offset,int len,proto_tree * tree,int hf_cause_value,guint8 * cause_value,const value_string * ie_vals,q931_packet_info * q931_pi)1282 dissect_q931_cause_ie_with_info(tvbuff_t *tvb, int offset, int len,
1283 proto_tree *tree, int hf_cause_value, guint8 *cause_value, const value_string *ie_vals,
1284 q931_packet_info *q931_pi)
1285 {
1286 guint8 octet;
1287 guint8 coding_standard;
1288 guint8 rejection_reason;
1289
1290 if (len == 0)
1291 return;
1292 octet = tvb_get_guint8(tvb, offset);
1293 coding_standard = octet & 0x60;
1294 if (coding_standard != Q931_ITU_STANDARDIZED_CODING &&
1295 !g931_iso_iec_cause && coding_standard != Q931_ISO_IEC_STANDARDIZED_CODING) {
1296 /*
1297 * We don't know how the cause is encoded,
1298 * so just dump it as data and be done with it.
1299 */
1300 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1301 proto_tree_add_item(tree, hf_q931_cause_data, tvb, offset, len, ENC_NA);
1302 return;
1303 }
1304 proto_tree_add_uint(tree, hf_q931_cause_location, tvb, offset, 1, octet);
1305 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1306 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1307 offset += 1;
1308 len -= 1;
1309
1310 if (!(octet & Q931_IE_VL_EXTENSION)) {
1311 if (len == 0)
1312 return;
1313 octet = tvb_get_guint8(tvb, offset);
1314 proto_tree_add_item(tree, hf_q931_cause_recommendation, tvb, offset, 1, ENC_BIG_ENDIAN);
1315 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1316 offset += 1;
1317 len -= 1;
1318 }
1319
1320 if (len == 0)
1321 return;
1322 octet = tvb_get_guint8(tvb, offset);
1323 *cause_value = octet & 0x7F;
1324
1325 /* add cause value to packet info for use in tap */
1326 if (q931_pi) {
1327 q931_pi->cause_value = *cause_value;
1328 }
1329
1330 proto_tree_add_uint(tree, hf_cause_value, tvb, offset, 1, *cause_value);
1331 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1332 offset += 1;
1333 len -= 1;
1334
1335 if (len == 0)
1336 return;
1337 switch (*cause_value) {
1338 case Q931_CAUSE_UNALLOC_NUMBER:
1339 case Q931_CAUSE_NO_ROUTE_TO_DEST:
1340 case Q931_CAUSE_QOS_UNAVAILABLE:
1341 proto_tree_add_item(tree, hf_q931_network_service, tvb, offset, 1, ENC_NA);
1342 proto_tree_add_item(tree, hf_q931_extension_condition_type, tvb, offset, 1, ENC_NA);
1343 proto_tree_add_item(tree, hf_q931_extension_condition, tvb, offset, 1, ENC_BIG_ENDIAN);
1344 break;
1345
1346 case Q931_CAUSE_CALL_REJECTED:
1347 rejection_reason = octet & 0x7C;
1348 proto_tree_add_item(tree, hf_q931_cause_call_rejection_reason, tvb, offset, 1, ENC_BIG_ENDIAN);
1349 proto_tree_add_item(tree, hf_q931_cause_call_condition, tvb, offset, 1, ENC_BIG_ENDIAN);
1350 offset += 1;
1351 len -= 1;
1352
1353 if (len == 0)
1354 return;
1355 switch (rejection_reason) {
1356
1357 case Q931_REJ_USER_SPECIFIC:
1358 proto_tree_add_item(tree, hf_q931_cause_call_user_specific_diagnostic, tvb, offset, len, ENC_NA);
1359 break;
1360
1361 case Q931_REJ_IE_MISSING:
1362 proto_tree_add_uint_format_value(tree, hf_q931_missing_info_element, tvb, offset, 1,
1363 tvb_get_guint8(tvb, offset), "%s", val_to_str(tvb_get_guint8(tvb, offset), ie_vals,
1364 "Unknown (0x%02X)"));
1365 break;
1366
1367 case Q931_REJ_IE_INSUFFICIENT:
1368 proto_tree_add_uint_format_value(tree, hf_q931_insufficient_info_element, tvb, offset, 1,
1369 tvb_get_guint8(tvb, offset), "%s", val_to_str(tvb_get_guint8(tvb, offset), ie_vals,
1370 "Unknown (0x%02X)"));
1371 break;
1372
1373 default:
1374 proto_tree_add_item(tree, hf_q931_cause_call_diagnostic, tvb, offset, len, ENC_NA);
1375 break;
1376 }
1377 break;
1378
1379 case Q931_CAUSE_ACCESS_INFO_DISC:
1380 case Q931_CAUSE_INCOMPATIBLE_DEST:
1381 case Q931_CAUSE_MAND_IE_MISSING:
1382 case Q931_CAUSE_IE_NONEX_OR_UNIMPL:
1383 case Q931_CAUSE_INVALID_IE_CONTENTS:
1384 do {
1385 proto_tree_add_uint_format_value(tree, hf_q931_information_element, tvb, offset, 1,
1386 tvb_get_guint8(tvb, offset), "%s", val_to_str(tvb_get_guint8(tvb, offset), ie_vals,
1387 "Unknown (0x%02X)"));
1388 offset += 1;
1389 len -= 1;
1390 } while (len != 0);
1391 break;
1392
1393 case Q931_CAUSE_MT_NONEX_OR_UNIMPL:
1394 case Q931_CAUSE_MSG_INCOMPAT_W_CS:
1395 proto_tree_add_item(tree, hf_q931_cause_call_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1396 break;
1397
1398 case Q931_CAUSE_REC_TIMER_EXP:
1399 if (len < 3)
1400 return;
1401 proto_tree_add_item(tree, hf_q931_cause_call_rec_timer, tvb, offset, 3, ENC_NA|ENC_ASCII);
1402 break;
1403
1404 default:
1405 proto_tree_add_item(tree, hf_q931_cause_call_diagnostic, tvb, offset, len, ENC_NA);
1406 }
1407 }
1408
1409 void
dissect_q931_cause_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree,int hf_cause_value,guint8 * cause_value,const value_string * ie_vals)1410 dissect_q931_cause_ie(tvbuff_t *tvb, int offset, int len,
1411 proto_tree *tree, int hf_cause_value, guint8 *cause_value, const value_string *ie_vals)
1412 {
1413 /* External dissectors have no use for "q931_packet_info". */
1414 dissect_q931_cause_ie_with_info(tvb, offset, len, tree, hf_cause_value, cause_value, ie_vals, NULL);
1415 }
1416
1417 /*
1418 * Dissect a Change status information element.
1419 */
1420
1421 static const value_string q931_status_preference_vals[] = {
1422 { 0x01, "Channel" },
1423 { 0, NULL }
1424 };
1425
1426 static const value_string q931_new_status_vals[] = {
1427 { 0x00, "In Service" },
1428 { 0x01, "Maintenance" },
1429 { 0x02, "Out of Service" },
1430 { 0, NULL }
1431 };
1432
1433 static void
dissect_q931_change_status_ie(tvbuff_t * tvb,int offset,int len _U_,proto_tree * tree)1434 dissect_q931_change_status_ie(tvbuff_t *tvb, int offset, int len _U_, proto_tree *tree)
1435 {
1436 if (len == 0)
1437 return;
1438
1439 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
1440 proto_tree_add_item(tree, hf_q931_extension_ind_preference, tvb, offset, 1, ENC_BIG_ENDIAN);
1441 proto_tree_add_item(tree, hf_q931_extension_ind_new_status, tvb, offset, 1, ENC_BIG_ENDIAN);
1442 }
1443
1444 /*
1445 * Dissect a Call state information element.
1446 */
1447 static const value_string q931_call_state_vals[] = {
1448 { 0x00, "Null" },
1449 { 0x01, "Call initiated" },
1450 { 0x02, "Overlap sending" },
1451 { 0x03, "Outgoing call proceeding" },
1452 { 0x04, "Call delivered" },
1453 { 0x06, "Call present" },
1454 { 0x07, "Call received" },
1455 { 0x08, "Connect request" },
1456 { 0x09, "Incoming call proceeding" },
1457 { 0x0A, "Active" },
1458 { 0x0B, "Disconnect request" },
1459 { 0x0C, "Disconnect indication" },
1460 { 0x0F, "Suspend request" },
1461 { 0x11, "Resume request" },
1462 { 0x13, "Release request" },
1463 { 0x16, "Call abort"},
1464 { 0x19, "Overlap receiving" },
1465 { 0x3D, "Restart request" },
1466 { 0x3E, "Restart" },
1467 { 0, NULL }
1468 };
1469 value_string_ext q931_call_state_vals_ext = VALUE_STRING_EXT_INIT(q931_call_state_vals);
1470
1471 static void
dissect_q931_call_state_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1472 dissect_q931_call_state_ie(tvbuff_t *tvb, int offset, int len,
1473 proto_tree *tree)
1474 {
1475 guint8 octet;
1476 guint8 coding_standard;
1477
1478 if (len == 0)
1479 return;
1480 octet = tvb_get_guint8(tvb, offset);
1481 coding_standard = octet & 0x60;
1482 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1483 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1484 /*
1485 * We don't know how the call state is encoded,
1486 * so just dump it as data and be done with it.
1487 */
1488 proto_tree_add_item(tree, hf_q931_call_state_data, tvb, offset, len, ENC_NA);
1489 return;
1490 }
1491 proto_tree_add_item(tree, hf_q931_call_state, tvb, offset, 1, ENC_BIG_ENDIAN);
1492 }
1493
1494 /*
1495 * Dissect a Channel identification information element.
1496 */
1497 #define Q931_INTERFACE_IDENTIFIED 0x40
1498 #define Q931_NOT_BASIC_CHANNEL 0x20
1499
1500 static const value_string q931_basic_channel_selection_vals[] = {
1501 { 0x00, "No channel" },
1502 { 0x01, "B1 channel" },
1503 { 0x02, "B2 channel" },
1504 { 0x03, "Any channel" },
1505 { 0, NULL }
1506 };
1507
1508 static const value_string q931_not_basic_channel_selection_vals[] = {
1509 { 0x00, "No channel" },
1510 { 0x01, "Channel indicated in following octets" },
1511 { 0x03, "Any channel" },
1512 { 0, NULL }
1513 };
1514
1515 #define Q931_IS_SLOT_MAP 0x10
1516
1517 static const value_string q931_element_type_vals[] = {
1518 { 0x03, "B-channel units" },
1519 { 0x06, "H0-channel units" },
1520 { 0x08, "H11-channel units" },
1521 { 0x09, "H12-channel units" },
1522 { 0, NULL }
1523 };
1524
1525 static void
dissect_q931_channel_identification_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1526 dissect_q931_channel_identification_ie(tvbuff_t *tvb, int offset, int len,
1527 proto_tree *tree)
1528 {
1529 guint8 octet;
1530 guint8 coding_standard;
1531
1532 if (len == 0)
1533 return;
1534 octet = tvb_get_guint8(tvb, offset);
1535
1536 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
1537 proto_tree_add_item(tree, hf_q931_channel_interface_explicit, tvb, offset, 1, ENC_BIG_ENDIAN);
1538 proto_tree_add_item(tree, hf_q931_channel_interface_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1539 proto_tree_add_item(tree, hf_q931_channel_exclusive, tvb, offset, 1, ENC_BIG_ENDIAN);
1540 proto_tree_add_item(tree, hf_q931_channel_dchan, tvb, offset, 1, ENC_BIG_ENDIAN);
1541
1542 if (octet & Q931_NOT_BASIC_CHANNEL) {
1543 proto_tree_add_item(tree, hf_q931_channel_selection_pri, tvb, offset, 1, ENC_BIG_ENDIAN);
1544 } else {
1545 proto_tree_add_item(tree, hf_q931_channel_selection_bri, tvb, offset, 1, ENC_BIG_ENDIAN);
1546 }
1547 offset += 1;
1548 len -= 1;
1549
1550 if (octet & Q931_INTERFACE_IDENTIFIED) {
1551 guint8 octet2;
1552 guint32 identifier_val = 0;
1553 int identifier_offset = offset;
1554 int identifier_len = 0;
1555 do {
1556 if (len == 0)
1557 break;
1558 octet2 = tvb_get_guint8(tvb, offset);
1559 offset += 1;
1560 len -= 1;
1561 identifier_len++;
1562 identifier_val <<= 7;
1563 identifier_val |= octet2 & 0x7F;
1564 } while (!(octet2 & Q931_IE_VL_EXTENSION));
1565
1566 if (identifier_len != 0) {
1567 proto_tree_add_uint(tree, hf_q931_channel_interface_id, tvb, identifier_offset,
1568 identifier_len, identifier_val);
1569 }
1570 }
1571
1572 if (octet & Q931_NOT_BASIC_CHANNEL) {
1573 if (len == 0)
1574 return;
1575 octet = tvb_get_guint8(tvb, offset);
1576 coding_standard = octet & 0x60;
1577 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
1578 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1579 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1580 /*
1581 * We don't know how the channel identifier is
1582 * encoded, so just dump it as data and be done
1583 * with it.
1584 */
1585 proto_tree_add_item(tree, hf_q931_channel_data, tvb, offset, len, ENC_NA);
1586 return;
1587 }
1588 proto_tree_add_item(tree, hf_q931_channel_map, tvb, offset, 1, ENC_BIG_ENDIAN);
1589 proto_tree_add_item(tree, hf_q931_channel_element_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1590
1591 offset += 1;
1592 len -= 1;
1593
1594 if (octet & Q931_IS_SLOT_MAP) {
1595 while (len) {
1596 proto_tree_add_item(tree, hf_q931_channel_slot_map, tvb, offset, 1, ENC_BIG_ENDIAN);
1597 offset += 1;
1598 len -= 1;
1599 }
1600 } else {
1601 guint8 octet2;
1602 do {
1603 if (len == 0)
1604 break;
1605 octet2 = tvb_get_guint8(tvb, offset);
1606
1607 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
1608 proto_tree_add_item(tree,hf_q931_channel_number,tvb,offset,1,ENC_BIG_ENDIAN);
1609
1610 offset += 1;
1611 len -= 1;
1612 } while (!(octet2 & Q931_IE_VL_EXTENSION));
1613 }
1614 }
1615 }
1616
1617 /*
1618 * Dissect a Progress indicator information element.
1619 */
1620 static const value_string q931_progress_description_vals[] = {
1621 { 0x01, "Call is not end-to-end ISDN - progress information available in-band" },
1622 { 0x02, "Destination address is non-ISDN" },
1623 { 0x03, "Origination address is non-ISDN" },
1624 { 0x04, "Call has returned to the ISDN" },
1625 { 0x05, "Interworking has occurred and has resulted in a telecommunications service change" },
1626 { 0x08, "In-band information or an appropriate pattern is now available" },
1627 { 0, NULL }
1628 };
1629 value_string_ext q931_progress_description_vals_ext = VALUE_STRING_EXT_INIT(q931_progress_description_vals);
1630
1631 void
dissect_q931_progress_indicator_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1632 dissect_q931_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
1633 proto_tree *tree)
1634 {
1635 guint8 octet;
1636 guint8 coding_standard;
1637
1638 if (len == 0)
1639 return;
1640 octet = tvb_get_guint8(tvb, offset);
1641 coding_standard = octet & 0x60;
1642 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1643 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1644 /*
1645 * We don't know how the progress indicator is encoded,
1646 * so just dump it as data and be done with it.
1647 */
1648 proto_tree_add_item(tree, hf_q931_progress_indicator_data, tvb, offset, len, ENC_NA);
1649 return;
1650 }
1651 proto_tree_add_item(tree, hf_q931_progress_indicator_location, tvb, offset, 1, ENC_BIG_ENDIAN);
1652 offset += 1;
1653 len -= 1;
1654
1655 if (len == 0)
1656 return;
1657
1658 proto_tree_add_item(tree, hf_q931_progress_indicator_description, tvb, offset, 1, ENC_BIG_ENDIAN);
1659 }
1660
1661 /*
1662 * Dissect a Network-specific facilities or Transit network selection
1663 * information element.
1664 */
1665 static const value_string q931_netid_type_vals[] = {
1666 { 0x00, "User specified" },
1667 { 0x20, "National network identification" },
1668 { 0x30, "International network identification" },
1669 { 0, NULL }
1670 };
1671
1672 static const value_string q931_netid_plan_vals[] = {
1673 { 0x00, "Unknown" },
1674 { 0x01, "Carrier Identification Code" },
1675 { 0x03, "X.121 data network identification code" },
1676 { 0, NULL }
1677 };
1678
1679 static void
dissect_q931_ns_facilities_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1680 dissect_q931_ns_facilities_ie(tvbuff_t *tvb, int offset, int len,
1681 proto_tree *tree)
1682 {
1683 guint8 octet;
1684 int netid_len;
1685
1686 if (len == 0)
1687 return;
1688 octet = tvb_get_guint8(tvb, offset);
1689 netid_len = octet & 0x7F;
1690 proto_tree_add_item(tree, hf_q931_netid_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1691 offset += 1;
1692 len -= 1;
1693 if (netid_len != 0) {
1694 if (len == 0)
1695 return;
1696 proto_tree_add_item(tree, hf_q931_netid_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1697 proto_tree_add_item(tree, hf_q931_netid_plan, tvb, offset, 1, ENC_BIG_ENDIAN);
1698 offset += 1;
1699 len -= 1;
1700 netid_len--;
1701
1702 if (len == 0)
1703 return;
1704 if (netid_len > len)
1705 netid_len = len;
1706 if (netid_len != 0) {
1707 proto_tree_add_item(tree, hf_q931_netid, tvb, offset, netid_len, ENC_NA|ENC_ASCII);
1708 offset += netid_len;
1709 len -= netid_len;
1710 }
1711 }
1712
1713 /*
1714 * Whatever is left is the network-specific facility
1715 * specification.
1716 */
1717 if (len == 0)
1718 return;
1719 proto_tree_add_item(tree, hf_q931_netid_facility_specification, tvb, offset, len, ENC_NA);
1720 }
1721
1722 /*
1723 * Dissect a Notification indicator information element.
1724 */
1725 static const value_string q931_notification_description_vals[] = {
1726 { 0x00, "User suspended" },
1727 { 0x01, "User resumed" },
1728 { 0x02, "Bearer service change" },
1729 { 0, NULL }
1730 };
1731
1732 static void
dissect_q931_notification_indicator_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1733 dissect_q931_notification_indicator_ie(tvbuff_t *tvb, int offset, int len,
1734 proto_tree *tree)
1735 {
1736 if (len == 0)
1737 return;
1738
1739 proto_tree_add_item(tree, hf_q931_notification_description, tvb, offset, 1, ENC_BIG_ENDIAN);
1740 }
1741
1742 /*
1743 * Dissect a Date/time information element.
1744 */
1745 static void
dissect_q931_date_time_ie(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree)1746 dissect_q931_date_time_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
1747 proto_tree *tree)
1748 {
1749 if (len == 6) {
1750 /*
1751 * XXX - what is "year" relative to? Is "month" 0-origin or
1752 * 1-origin? Q.931 doesn't say....
1753 */
1754 proto_tree_add_bytes_format_value(tree, hf_q931_date_time, tvb, offset, 6, NULL, "%02u-%02u-%02u %02u:%02u:%02u",
1755 tvb_get_guint8(tvb, offset + 0), tvb_get_guint8(tvb, offset + 1), tvb_get_guint8(tvb, offset + 2),
1756 tvb_get_guint8(tvb, offset + 3), tvb_get_guint8(tvb, offset + 4), tvb_get_guint8(tvb, offset + 5));
1757 } else if (len == 5) {
1758 proto_tree_add_bytes_format_value(tree, hf_q931_date_time, tvb, offset, 5, NULL, "%02u-%02u-%02u %02u:%02u:00",
1759 tvb_get_guint8(tvb, offset + 0), tvb_get_guint8(tvb, offset + 1), tvb_get_guint8(tvb, offset + 2),
1760 tvb_get_guint8(tvb, offset + 3), tvb_get_guint8(tvb, offset + 4));
1761 } else {
1762 proto_tree_add_expert_format(tree, pinfo, &ei_q931_date_time, tvb, offset, len, "Date/time: length is %d, should be 5 or 6", len);
1763 }
1764 }
1765
1766 /*
1767 * Dissect a Signal information element.
1768 */
1769 static const value_string q931_signal_vals[] = {
1770 { 0x00, "Dial tone on" },
1771 { 0x01, "Ring tone on" },
1772 { 0x02, "Intercept tone on" },
1773 { 0x03, "Network congestion tone on" }, /* "fast busy" */
1774 { 0x04, "Busy tone on" },
1775 { 0x05, "Confirm tone on" },
1776 { 0x06, "Answer tone on" },
1777 { 0x07, "Call waiting tone on" },
1778 { 0x08, "Off-hook warning tone on" },
1779 { 0x09, "Preemption tone on" },
1780 { 0x3F, "Tones off" },
1781 { 0x40, "Alerting on - pattern 0" },
1782 { 0x41, "Alerting on - pattern 1" },
1783 { 0x42, "Alerting on - pattern 2" },
1784 { 0x43, "Alerting on - pattern 3" },
1785 { 0x44, "Alerting on - pattern 4" },
1786 { 0x45, "Alerting on - pattern 5" },
1787 { 0x46, "Alerting on - pattern 6" },
1788 { 0x47, "Alerting on - pattern 7" },
1789 { 0x4F, "Alerting off" },
1790 { 0, NULL }
1791 };
1792 static value_string_ext q931_signal_vals_ext = VALUE_STRING_EXT_INIT(q931_signal_vals);
1793
1794 static void
dissect_q931_signal_ie(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree,proto_item * item)1795 dissect_q931_signal_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1796 proto_tree *tree, proto_item* item)
1797 {
1798 if (len != 1) {
1799 expert_add_info_format(pinfo, item, &ei_q931_invalid_length,
1800 "Signal: length is %d, should be 1", len);
1801 return;
1802 }
1803 proto_tree_add_item(tree, hf_q931_signal, tvb, offset, 1, ENC_BIG_ENDIAN);
1804 }
1805
1806 /*
1807 * Dissect an Information rate information element.
1808 */
1809 static const value_string q931_throughput_class_vals[] = {
1810 { 0x03, "75 bit/s" },
1811 { 0x04, "150 bit/s" },
1812 { 0x05, "300 bit/s" },
1813 { 0x06, "600 bit/s" },
1814 { 0x07, "1200 bit/s" },
1815 { 0x08, "2400 bit/s" },
1816 { 0x09, "4800 bit/s" },
1817 { 0x0A, "9600 bit/s" },
1818 { 0x0B, "19200 bit/s" },
1819 { 0x0C, "48000 bit/s" },
1820 { 0x0D, "64000 bit/s" },
1821 { 0, NULL }
1822 };
1823 static value_string_ext q931_throughput_class_vals_ext = VALUE_STRING_EXT_INIT(q931_throughput_class_vals);
1824
1825 static void
dissect_q931_information_rate_ie(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree,proto_item * item)1826 dissect_q931_information_rate_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1827 proto_tree *tree, proto_item* item)
1828 {
1829 if (len != 4) {
1830 expert_add_info_format(pinfo, item, &ei_q931_invalid_length,
1831 "Information rate: length is %d, should be 4", len);
1832 return;
1833 }
1834 proto_tree_add_item(tree, hf_q931_information_rate_incoming, tvb, offset + 0, 1, ENC_BIG_ENDIAN);
1835 proto_tree_add_item(tree, hf_q931_information_rate_outgoing, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
1836 proto_tree_add_item(tree, hf_q931_information_rate_minimum_incoming, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
1837 proto_tree_add_item(tree, hf_q931_information_rate_minimum_outgoing, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
1838 }
1839
1840 static int
dissect_q931_guint16_value(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree,proto_item * item,int hf_value)1841 dissect_q931_guint16_value(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1842 proto_tree *tree, proto_item* item, int hf_value)
1843 {
1844 guint8 octet;
1845 guint16 value;
1846 int value_len;
1847
1848 value_len = 0;
1849
1850 octet = tvb_get_guint8(tvb, offset);
1851 if (octet & Q931_IE_VL_EXTENSION) {
1852 /*
1853 * Only one octet long - error.
1854 */
1855 goto bad_length;
1856 }
1857 value = (octet & 0x3) << 14;
1858 offset += 1;
1859 len -= 1;
1860 value_len++;
1861
1862 if (len == 0) {
1863 /*
1864 * We've reached the end of the information element - error.
1865 */
1866 goto past_end;
1867 }
1868 octet = tvb_get_guint8(tvb, offset);
1869 if (octet & Q931_IE_VL_EXTENSION) {
1870 /*
1871 * Only two octets long - error.
1872 */
1873 goto bad_length;
1874 }
1875 value |= (octet & 0x7F) << 7;
1876 offset += 1;
1877 len -= 1;
1878 value_len++;
1879
1880 if (len == 0) {
1881 /*
1882 * We've reached the end of the information element - error.
1883 */
1884 goto past_end;
1885 }
1886 octet = tvb_get_guint8(tvb, offset);
1887 if (!(octet & Q931_IE_VL_EXTENSION)) {
1888 /*
1889 * More than three octets long - error.
1890 */
1891 goto bad_length;
1892 }
1893 value |= (octet & 0x7F);
1894 offset += 1;
1895 /*len -= 1;*/
1896 value_len++;
1897
1898 proto_tree_add_uint(tree, hf_value, tvb, offset, value_len, value);
1899 return value_len;
1900
1901 past_end:
1902 expert_add_info_format(pinfo, item, &ei_q931_invalid_length,
1903 "%s goes past end of information element", proto_registrar_get_name(hf_value));
1904 return -1;
1905
1906 bad_length:
1907 expert_add_info_format(pinfo, item, &ei_q931_invalid_length, "%s isn't 3 octets long",
1908 proto_registrar_get_name(hf_value));
1909 return -1;
1910 }
1911
1912 /*
1913 * Dissect an End-to-end transit delay information element.
1914 */
1915 static void
dissect_q931_e2e_transit_delay_ie(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree,proto_item * item)1916 dissect_q931_e2e_transit_delay_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1917 proto_tree *tree, proto_item* item)
1918 {
1919 int value_len;
1920
1921 if (len == 0)
1922 return;
1923 value_len = dissect_q931_guint16_value(tvb, pinfo, offset, len, tree, item, hf_q931_cumulative_transit_delay);
1924 if (value_len < 0)
1925 return; /* error */
1926 offset += value_len;
1927 len -= value_len;
1928
1929 if (len == 0)
1930 return;
1931 value_len = dissect_q931_guint16_value(tvb, pinfo, offset, len, tree, item, hf_q931_requested_end_to_end_transit_delay);
1932 if (value_len < 0)
1933 return; /* error */
1934 offset += value_len;
1935 len -= value_len;
1936
1937 if (len == 0)
1938 return;
1939 dissect_q931_guint16_value(tvb, pinfo, offset, len, tree, item, hf_q931_maximum_end_to_end_transit_delay);
1940 }
1941
1942 /*
1943 * Dissect a Transit delay selection and indication information element.
1944 */
1945 static void
dissect_q931_td_selection_and_int_ie(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree,proto_item * item)1946 dissect_q931_td_selection_and_int_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1947 proto_tree *tree, proto_item* item)
1948 {
1949 if (len == 0)
1950 return;
1951 dissect_q931_guint16_value(tvb, pinfo, offset, len, tree, item, hf_q931_transit_delay);
1952 }
1953
1954 /*
1955 * Dissect a Packet layer binary parameters information element.
1956 */
1957 static const value_string q931_fast_selected_vals[] = {
1958 { 0x00, "Fast select not requested" },
1959 { 0x08, "Fast select not requested" },
1960 { 0x10, "Fast select requested with no restriction of response" },
1961 { 0x18, "Fast select requested with restrictions of response" },
1962 { 0x00, NULL }
1963 };
1964
1965 static const true_false_string tfs_link_end = { "Link-by-link", "End-to-end" };
1966 static const true_false_string tfs_pl_request = { "No request/request denied", "Request indicated/request accepted" };
1967 static const true_false_string tfs_pl_modulus = { "8 sequencing", "128 sequencing" };
1968
1969 static void
dissect_q931_pl_binary_parameters_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1970 dissect_q931_pl_binary_parameters_ie(tvbuff_t *tvb, int offset, int len,
1971 proto_tree *tree)
1972 {
1973 static int * const fields[] = {
1974 &hf_q931_fast_select,
1975 &hf_q931_pl_request,
1976 &hf_q931_pl_binary_confirmation,
1977 &hf_q931_pl_modulus,
1978 NULL
1979 };
1980
1981 if (len == 0)
1982 return;
1983
1984 proto_tree_add_bitmask_list(tree, tvb, offset, 1, fields, ENC_NA);
1985 }
1986
1987 /*
1988 * Dissect a Packet layer window size information element.
1989 */
1990 static void
dissect_q931_pl_window_size_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)1991 dissect_q931_pl_window_size_ie(tvbuff_t *tvb, int offset, int len,
1992 proto_tree *tree)
1993 {
1994 if (len == 0)
1995 return;
1996 proto_tree_add_item(tree, hf_q931_pl_window_size_forward_value, tvb, offset, 1, ENC_BIG_ENDIAN);
1997 offset += 1;
1998 len -= 1;
1999
2000 if (len == 0)
2001 return;
2002 proto_tree_add_item(tree, hf_q931_pl_window_size_backward_value, tvb, offset, 1, ENC_BIG_ENDIAN);
2003 }
2004
2005 /*
2006 * Dissect a Packet size information element.
2007 */
2008 static void
dissect_q931_packet_size_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)2009 dissect_q931_packet_size_ie(tvbuff_t *tvb, int offset, int len,
2010 proto_tree *tree)
2011 {
2012 if (len == 0)
2013 return;
2014 proto_tree_add_item(tree, hf_q931_packet_size_forward_value, tvb, offset, 1, ENC_BIG_ENDIAN);
2015 offset += 1;
2016 len -= 1;
2017
2018 if (len == 0)
2019 return;
2020 proto_tree_add_item(tree, hf_q931_packet_size_backward_value, tvb, offset, 1, ENC_BIG_ENDIAN);
2021 }
2022
2023 /*
2024 * Dissect a Closed user group information element.
2025 */
2026 static const value_string q931_cug_indication_vals[] = {
2027 { 0x01, "Closed user group selection" },
2028 { 0x02, "Closed user group with outgoing access selection and indication" },
2029 { 0, NULL }
2030 };
2031
2032 static void
dissect_q931_cug_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)2033 dissect_q931_cug_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree)
2034 {
2035 if (len == 0)
2036 return;
2037 proto_tree_add_item(tree, hf_q931_cug_indication, tvb, offset, 1, ENC_BIG_ENDIAN);
2038 offset += 1;
2039 len -= 1;
2040
2041 if (len == 0)
2042 return;
2043 proto_tree_add_item(tree, hf_q931_cug_index_code, tvb, offset, len, ENC_NA|ENC_ASCII);
2044 }
2045
2046 /*
2047 * Dissect a Reverse charging indication information element.
2048 */
2049 static const value_string q931_reverse_charging_indication_vals[] = {
2050 { 0x01, "Reverse charging requested" },
2051 { 0, NULL }
2052 };
2053
2054 static void
dissect_q931_reverse_charge_ind_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)2055 dissect_q931_reverse_charge_ind_ie(tvbuff_t *tvb, int offset, int len,
2056 proto_tree *tree)
2057 {
2058 if (len == 0)
2059 return;
2060 proto_tree_add_item(tree, hf_q931_reverse_charging_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
2061 }
2062
2063 /*
2064 * Dissect a (phone) number information element.
2065 */
2066 static const value_string q931_number_type_vals[] = {
2067 { 0x0, "Unknown" },
2068 { 0x1, "International number" },
2069 { 0x2, "National number" },
2070 { 0x3, "Network specific number" },
2071 { 0x4, "Subscriber number" },
2072 { 0x6, "Abbreviated number" },
2073 { 0, NULL }
2074 };
2075
2076 static const value_string q931_numbering_plan_vals[] = {
2077 { 0x00, "Unknown" },
2078 { 0x01, "E.164 ISDN/telephony numbering" },
2079 { 0x03, "X.121 data numbering" },
2080 { 0x04, "F.69 Telex numbering" },
2081 { 0x08, "National standard numbering" },
2082 { 0x09, "Private numbering" },
2083 { 0, NULL }
2084 };
2085
2086 static const value_string q931_presentation_indicator_vals[] = {
2087 { 0x00, "Presentation allowed" },
2088 { 0x01, "Presentation restricted" },
2089 { 0x02, "Number not available due to interworking" },
2090 { 0, NULL }
2091 };
2092
2093 static const value_string q931_screening_indicator_vals[] = {
2094 { 0x00, "User-provided, not screened" },
2095 { 0x01, "User-provided, verified and passed" },
2096 { 0x02, "User-provided, verified and failed" },
2097 { 0x03, "Network-provided" },
2098 { 0, NULL }
2099 };
2100
2101 static const value_string q931_redirection_reason_vals[] = {
2102 { 0x00, "Unknown" },
2103 { 0x01, "Call forwarding busy or called DTE busy" },
2104 { 0x02, "Call forwarding no reply" },
2105 { 0x04, "Call deflection" },
2106 { 0x09, "Called DTE out of order" },
2107 { 0x0A, "Call forwarding by the called DTE" },
2108 { 0x0F, "Call forwarding unconditional or systematic call redirection" },
2109 { 0, NULL }
2110 };
2111
2112 static void
dissect_q931_number_ie(packet_info * pinfo,tvbuff_t * tvb,int offset,int len,proto_tree * tree,int hfindex,e164_info_t e164_info,q931_packet_info * q931_pi)2113 dissect_q931_number_ie(packet_info *pinfo, tvbuff_t *tvb, int offset, int len,
2114 proto_tree *tree, int hfindex, e164_info_t e164_info, q931_packet_info *q931_pi)
2115 {
2116 guint8 octet;
2117 gint number_plan;
2118
2119 if (len == 0)
2120 return;
2121 octet = tvb_get_guint8(tvb, offset);
2122 number_plan = octet & 0x0f;
2123 e164_info.nature_of_address = ( octet & 0x70 ) >> 4;
2124 proto_tree_add_uint(tree, hf_q931_numbering_plan, tvb, offset, 1, octet);
2125 proto_tree_add_uint(tree, hf_q931_number_type, tvb, offset, 1, octet);
2126 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
2127
2128 offset += 1;
2129 len -= 1;
2130
2131 if (!(octet & Q931_IE_VL_EXTENSION)) {
2132 if (len == 0)
2133 return;
2134 octet = tvb_get_guint8(tvb, offset);
2135 proto_tree_add_uint(tree, hf_q931_screening_ind, tvb, offset, 1, octet);
2136 proto_tree_add_uint(tree, hf_q931_presentation_ind, tvb, offset, 1, octet);
2137 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
2138 offset += 1;
2139 len -= 1;
2140 }
2141
2142 /*
2143 * XXX - only in a Redirecting number information element.
2144 */
2145 if (!(octet & Q931_IE_VL_EXTENSION)) {
2146 if (len == 0)
2147 return;
2148 proto_tree_add_item(tree, hf_q931_extension_reason, tvb, offset, 1, ENC_BIG_ENDIAN);
2149 offset += 1;
2150 len -= 1;
2151 }
2152
2153 if (len == 0)
2154 return;
2155 proto_tree_add_item(tree, hfindex, tvb, offset, len, ENC_ASCII|ENC_NA);
2156 proto_item_append_text(proto_tree_get_parent(tree), ": '%s'", tvb_format_text(pinfo->pool, tvb, offset, len));
2157
2158 if ( number_plan == 1 ) {
2159 if ( e164_info.e164_number_type != NONE ){
2160
2161 e164_info.E164_number_str = tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_ASCII|ENC_NA);
2162 e164_info.E164_number_length = len;
2163 dissect_e164_number(tvb, tree, offset, len, e164_info);
2164 }
2165 }
2166
2167 /* Collect q931_packet_info */
2168 if ( e164_info.e164_number_type == CALLING_PARTY_NUMBER && q931_pi)
2169 q931_pi->calling_number = tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_ASCII|ENC_NA);
2170 if ( e164_info.e164_number_type == CALLED_PARTY_NUMBER && q931_pi)
2171 q931_pi->called_number = tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_ASCII|ENC_NA);
2172 }
2173
2174 /*
2175 * Dissect a party subaddress information element.
2176 */
2177 static const value_string q931_subaddress_type_vals[] = {
2178 { 0x00, "X.213/ISO 8348 Add.2 NSAP" },
2179 { 0x20, "User-specified" },
2180 { 0, NULL }
2181 };
2182
2183 static const value_string q931_odd_even_indicator_vals[] = {
2184 { 0x00, "Even number of address signals" },
2185 { 0x08, "Odd number of address signals" },
2186 { 0, NULL }
2187 };
2188
2189 static void
dissect_q931_party_subaddr_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)2190 dissect_q931_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
2191 proto_tree *tree)
2192 {
2193 if (len == 0)
2194 return;
2195
2196 proto_tree_add_item(tree, hf_q931_party_subaddr_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2197 proto_tree_add_item(tree, hf_q931_party_subaddr_odd_even_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
2198 offset += 1;
2199 len -= 1;
2200
2201 if (len == 0)
2202 return;
2203 proto_tree_add_item(tree, hf_q931_party_subaddr, tvb, offset, len, ENC_NA);
2204 }
2205
2206 /*
2207 * Dissect a Restart indicator information element.
2208 */
2209 static const value_string q931_restart_indicator_class_vals[] = {
2210 { 0x00, "Indicated channels" },
2211 { 0x06, "Single interface" },
2212 { 0x07, "All interfaces" },
2213 { 0, NULL }
2214 };
2215
2216 static void
dissect_q931_restart_indicator_ie(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree,proto_item * item)2217 dissect_q931_restart_indicator_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
2218 proto_tree *tree, proto_item* item)
2219 {
2220 if (len != 1) {
2221 expert_add_info_format(pinfo, item, &ei_q931_invalid_length,
2222 "Restart indicator: length is %d, should be 1", len);
2223 return;
2224 }
2225 proto_tree_add_item(tree, hf_q931_restart_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
2226 }
2227
2228 /*
2229 * Dissect a High-layer compatibility information element.
2230 */
2231 #define Q931_MAINTENANCE 0x5e
2232 #define Q931_MANAGEMENT 0x5f
2233 #define Q931_AUDIOVISUAL 0x60
2234 static const value_string q931_high_layer_characteristics_vals[] = {
2235 { 0x01, "Telephony" },
2236 { 0x04, "F.182 Facsimile Group 2/3" },
2237 { 0x21, "F.184 Facsimile Group 4 Class I" },
2238 { 0x24, "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
2239 { 0x28, "F.220 Teletex, basic and processable mode" },
2240 { 0x31, "F.200 Teletex, basic mode" },
2241 { 0x32, "F.300 and T.102 syntax-based Videotex" },
2242 { 0x33, "F.300 and T.101 international Videotex interworking" },
2243 { 0x35, "F.60 Telex" },
2244 { 0x38, "X.400 Message Handling Systems" },
2245 { 0x41, "X.200 OSI application" },
2246 { 0x42, "FTAM application" },
2247 { 0x5E, "Reserved for maintenance" },
2248 { 0x5F, "Reserved for management" },
2249 { Q931_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
2250 { 0x61, "F.702 and F.731 Profile 1b videoconferencing" },
2251 { 0x62, "F.702 and F.731 audiographic conferencing" },
2252 { 0x68, "F.700-series Multimedia services" },
2253 { 0, NULL }
2254 };
2255 static value_string_ext q931_high_layer_characteristics_vals_ext = VALUE_STRING_EXT_INIT(q931_high_layer_characteristics_vals);
2256
2257 static const value_string q931_extended_high_layer_characteristics_vals[] = {
2258 { 0x01, "Telephony" },
2259 { 0x04, "F.182 Facsimile Group 2/3" },
2260 { 0x21, "F.184 Facsimile Group 4 Class I" },
2261 { 0x24, "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
2262 { 0x28, "F.220 Teletex, basic and processable mode" },
2263 { 0x31, "F.200 Teletex, basic mode" },
2264 { 0x32, "F.300 and T.102 syntax-based Videotex" },
2265 { 0x33, "F.300 and T.101 international Videotex interworking" },
2266 { 0x35, "F.60 Telex" },
2267 { 0x38, "X.400 Message Handling Systems" },
2268 { 0x41, "X.200 OSI application" },
2269 { 0x42, "FTAM application" },
2270 { 0x5E, "Not available for assignment" },
2271 { 0x5F, "Not available for assignment" },
2272 { Q931_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
2273 { 0x61, "F.702 and F.731 Profile 1b videoconferencing" },
2274 { 0x62, "F.702 and F.731 audiographic conferencing" },
2275 { 0x68, "F.700-series Multimedia services" },
2276 { 0, NULL }
2277 };
2278 static value_string_ext q931_extended_high_layer_characteristics_vals_ext = VALUE_STRING_EXT_INIT(q931_extended_high_layer_characteristics_vals);
2279
2280 static const value_string q931_audiovisual_characteristics_vals[] = {
2281 { 0x01, "Capability set of initial channel of H.221" },
2282 { 0x02, "Capability set of subsequent channel of H.221" },
2283 { 0x21, "Capability set of initial channel of an active 3.1kHz audio or speech call" },
2284 { 0x00, NULL }
2285 };
2286
2287 static const value_string q931_interpretation_vals[] = {
2288 { 0x04, "First (primary or only) high layer characteristics identification to be used in the call" },
2289 { 0x00, NULL }
2290 };
2291
2292 static const value_string q931_pres_meth_prot_prof_vals[] = {
2293 { 0x01, "High layer protocol profile (without specification of attributes)" },
2294 { 0x00, NULL }
2295 };
2296
2297 /*
2298 * High layer protocol profile
2299 */
2300 #define Q931_HIGH_LAYER_PROTOCOL_PROFILE 0x01
2301
2302 void
dissect_q931_high_layer_compat_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)2303 dissect_q931_high_layer_compat_ie(tvbuff_t *tvb, int offset, int len,
2304 proto_tree *tree)
2305 {
2306 guint8 octet;
2307 guint8 coding_standard;
2308 guint8 pres_method;
2309 guint8 characteristics;
2310
2311 if (len == 0)
2312 return;
2313 octet = tvb_get_guint8(tvb, offset);
2314 coding_standard = octet & 0x60;
2315 pres_method = octet & 0x03;
2316
2317 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
2318 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
2319 proto_tree_add_uint(tree, hf_q931_interpretation, tvb, offset, 1, octet);
2320 proto_tree_add_uint(tree, hf_q931_pres_meth_prot_prof, tvb, offset, 1, octet);
2321
2322 offset += 1;
2323 len -= 1;
2324 if ((coding_standard != Q931_ITU_STANDARDIZED_CODING) || (pres_method != Q931_HIGH_LAYER_PROTOCOL_PROFILE)) {
2325 /*
2326 * We don't know how the call state is encoded,
2327 * so just dump it as data and be done with it.
2328 */
2329 proto_tree_add_item(tree, hf_q931_high_layer_compat_data, tvb, offset, len, ENC_NA);
2330 return;
2331 }
2332 if (len == 0)
2333 return;
2334
2335 octet = tvb_get_guint8(tvb, offset);
2336 characteristics = octet & 0x7F;
2337
2338 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
2339 proto_tree_add_uint(tree, hf_q931_high_layer_characteristics, tvb, offset, 1, octet);
2340
2341 offset += 1;
2342 len -= 1;
2343
2344 if (!(octet & Q931_IE_VL_EXTENSION)) {
2345 if (len == 0)
2346 return;
2347 octet = tvb_get_guint8(tvb, offset);
2348 if ((characteristics == Q931_AUDIOVISUAL) || (characteristics == 0x61) || (characteristics == 0x62) ||
2349 (characteristics == 0x68)) {
2350 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
2351 proto_tree_add_uint(tree, hf_q931_extended_audiovisual_characteristics, tvb, offset, 1, octet);
2352 }
2353 else if ((characteristics == Q931_MANAGEMENT) || (characteristics == Q931_MAINTENANCE)) {
2354 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
2355 proto_tree_add_uint(tree, hf_q931_extended_high_layer_characteristics, tvb, offset, 1, octet);
2356 }
2357 }
2358 }
2359
2360
2361 /*
2362 * Dissect a User-user information element.
2363 */
2364 #define Q931_PROTOCOL_DISCRIMINATOR_USER 0x00
2365 #define Q931_PROTOCOL_DISCRIMINATOR_IA5 0x04
2366 #define Q931_PROTOCOL_DISCRIMINATOR_ASN1 0x05
2367
2368 static const value_string q931_protocol_discriminator_vals[] = {
2369 { Q931_PROTOCOL_DISCRIMINATOR_USER, "User-specific protocol" },
2370 { 0x01, "OSI high layer protocols" },
2371 { 0x02, "X.244" },
2372 { 0x03, "Reserved for system management convergence function" },
2373 { Q931_PROTOCOL_DISCRIMINATOR_IA5, "IA5 characters" },
2374 { Q931_PROTOCOL_DISCRIMINATOR_ASN1, "X.208 and X.209 coded user information" },
2375 { 0x06, "Undefined" },
2376 { 0x07, "V.120 rate adaption" },
2377 { 0x08, "Q.931/I.451 user-network call control messages" },
2378 { 0, NULL }
2379 };
2380 value_string_ext q931_protocol_discriminator_vals_ext = VALUE_STRING_EXT_INIT(q931_protocol_discriminator_vals);
2381
2382 void
dissect_q931_user_user_ie(tvbuff_t * tvb,packet_info * pinfo,int offset,int len,proto_tree * tree)2383 dissect_q931_user_user_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
2384 proto_tree *tree)
2385 {
2386 guint8 octet;
2387 tvbuff_t *next_tvb = NULL;
2388 heur_dtbl_entry_t *hdtbl_entry;
2389
2390 if (len == 0)
2391 return;
2392 octet = tvb_get_guint8(tvb, offset);
2393 proto_tree_add_item(tree, hf_q931_user_protocol_discriminator, tvb, offset, 1, ENC_BIG_ENDIAN);
2394 offset += 1;
2395 len -= 1;
2396
2397 if (len == 0)
2398 return;
2399 switch (octet) {
2400
2401 case Q931_PROTOCOL_DISCRIMINATOR_USER:
2402 next_tvb = tvb_new_subset_length(tvb, offset, len);
2403 proto_tree_add_uint_format_value(tree, hf_q931_user_information_len, tvb, offset, len, len, "%d octets", len);
2404 if (!dissector_try_heuristic(q931_user_heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, NULL)) {
2405 call_data_dissector(next_tvb, pinfo, tree);
2406 }
2407 break;
2408
2409 case Q931_PROTOCOL_DISCRIMINATOR_IA5:
2410 proto_tree_add_item(tree, hf_q931_user_information_str, tvb, offset, len, ENC_NA|ENC_ASCII);
2411 break;
2412
2413 default:
2414 proto_tree_add_item(tree, hf_q931_user_information_bytes, tvb, offset, len, ENC_NA);
2415 break;
2416 }
2417 }
2418
2419 static const value_string q931_party_category_vals[] = {
2420 { 0x00, "Unknown" },
2421 { 0x01, "Extension" },
2422 { 0x02, "Operator" },
2423 { 0x03, "Emergency extension" },
2424 { 0, NULL }
2425 };
2426
2427 static void
dissect_q931_party_category_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree)2428 dissect_q931_party_category_ie(tvbuff_t *tvb, int offset, int len,
2429 proto_tree *tree)
2430 {
2431 if (len == 0)
2432 return;
2433
2434 proto_tree_add_item(tree, hf_q931_party_category, tvb, offset, 1, ENC_BIG_ENDIAN);
2435 /*offset += 1;
2436 len -= 1;
2437
2438 if (len == 0)
2439 return;
2440 */
2441 }
2442
2443 /*
2444 * Dissect information elements consisting of ASCII^H^H^H^H^HIA5 text.
2445 */
2446 static void
dissect_q931_ia5_ie(tvbuff_t * tvb,int offset,int len,proto_tree * tree,int hf_value)2447 dissect_q931_ia5_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
2448 int hf_value)
2449 {
2450 if (len != 0) {
2451 proto_tree_add_item(tree, hf_value, tvb, offset, len, ENC_ASCII|ENC_NA);
2452 proto_item_append_text(proto_tree_get_parent(tree), " '%s'", tvb_format_text(wmem_packet_scope(), tvb, offset, len));
2453 }
2454 }
2455
2456 static void
dissect_q931_pdu(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,gboolean is_over_ip)2457 dissect_q931_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2458 gboolean is_over_ip)
2459 {
2460 int offset = 0;
2461 proto_tree *q931_tree = NULL;
2462 proto_tree *ie_tree = NULL;
2463 proto_item *ti;
2464 guint8 prot_discr;
2465 guint8 call_ref_len;
2466 guint8 call_ref[16];
2467 guint32 call_ref_val;
2468 guint8 message_type, segmented_message_type;
2469 guint8 info_element;
2470 guint16 info_element_len;
2471 gboolean first_frag, more_frags;
2472 guint32 frag_len;
2473 fragment_head *fd_head;
2474 tvbuff_t *next_tvb = NULL;
2475 q931_packet_info *q931_pi = NULL;
2476
2477 q931_pi=wmem_new(pinfo->pool, q931_packet_info);
2478
2479 /* Init struct for collecting q931_packet_info */
2480 reset_q931_packet_info(q931_pi);
2481
2482 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Q.931");
2483
2484 prot_discr = tvb_get_guint8(tvb, offset);
2485 ti = proto_tree_add_item(tree, proto_q931, tvb, offset, -1, ENC_NA);
2486 if (tree) {
2487 q931_tree = proto_item_add_subtree(ti, ett_q931);
2488
2489 dissect_q931_protocol_discriminator(tvb, offset, q931_tree);
2490 }
2491 offset += 1;
2492 call_ref_len = tvb_get_guint8(tvb, offset) & 0xF; /* XXX - do as a bit field? */
2493 if (q931_tree != NULL)
2494 proto_tree_add_uint(q931_tree, hf_q931_call_ref_len, tvb, offset, 1, call_ref_len);
2495 offset += 1;
2496 switch (call_ref_len) {
2497 case 0: call_ref_val = 0; break;
2498 case 1: call_ref_val = tvb_get_guint8(tvb, offset); break;
2499 case 2: call_ref_val = tvb_get_ntohs(tvb, offset); break;
2500 case 3: call_ref_val = tvb_get_ntoh24(tvb, offset); break;
2501 default: call_ref_val = tvb_get_ntohl(tvb, offset);
2502 }
2503 if (call_ref_len != 0) {
2504 tvb_memcpy(tvb, call_ref, offset, call_ref_len);
2505 if (q931_tree != NULL) {
2506 proto_tree_add_boolean(q931_tree, hf_q931_call_ref_flag,
2507 tvb, offset, 1, (call_ref[0] & 0x80) != 0);
2508 call_ref[0] &= 0x7F;
2509 proto_tree_add_bytes(q931_tree, hf_q931_call_ref,
2510 tvb, offset, call_ref_len, call_ref);
2511 } else
2512 { /* info for the tap */
2513 call_ref[0] &= 0x7F;
2514 }
2515 /* XXX - Should crv be something besides a guint32? */
2516 memcpy(&(q931_pi->crv), call_ref, call_ref_len > sizeof(q931_pi->crv) ? sizeof(q931_pi->crv) : call_ref_len );
2517 offset += call_ref_len;
2518 }
2519 message_type = tvb_get_guint8(tvb, offset);
2520 q931_pi->message_type = message_type;
2521 col_add_str(pinfo->cinfo, COL_INFO, get_message_name(prot_discr, message_type));
2522
2523 if (prot_discr == NLPID_DMS)
2524 proto_tree_add_item(q931_tree, hf_q931_maintenance_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2525 else
2526 proto_tree_add_item(q931_tree, hf_q931_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2527
2528 offset += 1;
2529
2530 /*
2531 * And now for the information elements....
2532 */
2533 if ((message_type != Q931_SEGMENT) || !q931_reassembly ||
2534 (tvb_reported_length_remaining(tvb, offset) <= 4)) {
2535 dissect_q931_IEs(tvb, pinfo, tree, q931_tree, is_over_ip, offset, 0, q931_pi);
2536 return;
2537 }
2538 info_element = tvb_get_guint8(tvb, offset);
2539 info_element_len = tvb_get_guint8(tvb, offset + 1);
2540 if ((info_element != Q931_IE_SEGMENTED_MESSAGE) || (info_element_len < 2)) {
2541 dissect_q931_IEs(tvb, pinfo, tree, q931_tree, is_over_ip, offset, 0, q931_pi);
2542 return;
2543 }
2544 /* Segmented message IE */
2545 ie_tree = proto_tree_add_subtree(q931_tree, tvb, offset, 1+1+info_element_len, ett_q931_ie[info_element], NULL,
2546 val_to_str(info_element, q931_info_element_vals[0], "Unknown information element (0x%02X)"));
2547 proto_tree_add_uint_format_value(ie_tree, hf_q931_information_element, tvb, offset, 1, info_element,
2548 "%s", val_to_str(info_element, q931_info_element_vals[0], "Unknown (0x%02X)"));
2549 proto_tree_add_item(ie_tree, hf_q931_information_element_len, tvb, offset + 1, 1, ENC_NA);
2550 dissect_q931_segmented_message_ie(tvb, pinfo, offset + 2, info_element_len, ie_tree, ti);
2551 first_frag = (tvb_get_guint8(tvb, offset + 2) & 0x80) != 0;
2552 more_frags = (tvb_get_guint8(tvb, offset + 2) & 0x7F) != 0;
2553 segmented_message_type = tvb_get_guint8(tvb, offset + 3);
2554 col_append_fstr(pinfo->cinfo, COL_INFO, " of %s",
2555 val_to_str_ext(segmented_message_type, &q931_message_type_vals_ext, "Unknown message type (0x%02X)"));
2556
2557 offset += 1 + 1 + info_element_len;
2558 /* Reassembly */
2559 frag_len = tvb_reported_length_remaining(tvb, offset);
2560 if (first_frag && fragment_get(&q931_reassembly_table, pinfo, call_ref_val, NULL)) {
2561 /* there are some unreassembled segments, ignore them */
2562 fragment_end_seq_next(&q931_reassembly_table, pinfo, call_ref_val, NULL);
2563 }
2564 fd_head = fragment_add_seq_next(&q931_reassembly_table,
2565 tvb, offset, pinfo, call_ref_val, NULL,
2566 frag_len, more_frags);
2567 if (fd_head) {
2568 if (pinfo->num == fd_head->reassembled_in) { /* last fragment */
2569 if (fd_head->next != NULL) { /* 2 or more segments */
2570 next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
2571 add_new_data_source(pinfo, next_tvb, "Reassembled Q.931 IEs");
2572 /* Show all fragments. */
2573 if (tree) {
2574 proto_item *frag_tree_item;
2575 show_fragment_seq_tree(fd_head, &q931_frag_items, q931_tree, pinfo, next_tvb, &frag_tree_item);
2576 }
2577 } else { /* only 1 segment */
2578 next_tvb = tvb_new_subset_remaining(tvb, offset);
2579 }
2580
2581 col_add_fstr(pinfo->cinfo, COL_INFO, "%s [reassembled]",
2582 val_to_str_ext(segmented_message_type, &q931_message_type_vals_ext, "Unknown message type (0x%02X)"));
2583
2584 } else {
2585 if (tree) proto_tree_add_uint(q931_tree, hf_q931_reassembled_in, tvb, offset, frag_len, fd_head->reassembled_in);
2586 }
2587 }
2588 if (next_tvb)
2589 dissect_q931_IEs(next_tvb, pinfo, tree, q931_tree, is_over_ip, 0, 0, q931_pi);
2590 }
2591
2592 static const value_string q931_codeset_vals[] = {
2593 { 0x00, "Q.931 information elements" },
2594 { 0x04, "Information elements for ISO/IEC use" },
2595 { 0x05, "Information elements for national use" },
2596 { 0x06, "Information elements specific to the local network" },
2597 { 0x07, "User-specific information elements" },
2598 { 0x00, NULL },
2599 };
2600
2601 static void
dissect_q931_IEs(tvbuff_t * tvb,packet_info * pinfo,proto_tree * root_tree,proto_tree * q931_tree,gboolean is_over_ip,int offset,int initial_codeset,q931_packet_info * q931_pi)2602 dissect_q931_IEs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root_tree,
2603 proto_tree *q931_tree, gboolean is_over_ip, int offset, int initial_codeset,
2604 q931_packet_info *q931_pi)
2605 {
2606 proto_item *ti;
2607 proto_tree *ie_tree = NULL;
2608 guint8 info_element;
2609 guint8 dummy;
2610 guint16 info_element_len;
2611 int codeset, locked_codeset;
2612 gboolean non_locking_shift, first_segment;
2613 tvbuff_t *h225_tvb, *next_tvb;
2614 e164_info_t e164_info;
2615 e164_info.e164_number_type = NONE;
2616 e164_info.nature_of_address = NONE;
2617 e164_info.E164_number_str = "";
2618 e164_info.E164_number_length = NONE;
2619
2620 codeset = locked_codeset = initial_codeset;
2621 first_segment = FALSE;
2622 while (tvb_reported_length_remaining(tvb, offset) > 0) {
2623 info_element = tvb_get_guint8(tvb, offset);
2624
2625 /* Check for the codeset shift */
2626 if ((info_element & Q931_IE_SO_MASK) &&
2627 ((info_element & Q931_IE_SO_IDENTIFIER_MASK) == Q931_IE_SHIFT)) {
2628 non_locking_shift = info_element & Q931_IE_SHIFT_NON_LOCKING;
2629 codeset = info_element & Q931_IE_SHIFT_CODESET;
2630 if (!non_locking_shift)
2631 locked_codeset = codeset;
2632 if (q931_tree != NULL) {
2633 proto_tree_add_uint_format(q931_tree, hf_q931_locking_codeset, tvb, offset, 1,
2634 codeset, "%s shift to codeset %u: %s",
2635 (non_locking_shift ? "Non-locking" : "Locking"),
2636 codeset, val_to_str(codeset, q931_codeset_vals,
2637 "Unknown (0x%02X)"));
2638 }
2639 offset += 1;
2640 continue;
2641 }
2642
2643 /*
2644 * Check for the single-octet IEs.
2645 */
2646 if (info_element & Q931_IE_SO_MASK) {
2647 /*
2648 * Check for subdissectors for this IE or
2649 * for all IEs in this codeset.
2650 */
2651 if (dissector_get_uint_handle(codeset_dissector_table, codeset) ||
2652 dissector_get_uint_handle(ie_dissector_table, (codeset << 8) | (info_element & Q931_IE_SO_IDENTIFIER_MASK))) {
2653 next_tvb = tvb_new_subset_length (tvb, offset, 1);
2654 if (dissector_try_uint(ie_dissector_table, (codeset << 8) | (info_element & Q931_IE_SO_IDENTIFIER_MASK), next_tvb, pinfo, q931_tree) ||
2655 dissector_try_uint(codeset_dissector_table, codeset, next_tvb, pinfo, q931_tree)) {
2656 offset += 1;
2657 codeset = locked_codeset;
2658 continue;
2659 }
2660 }
2661
2662 switch ((codeset << 8) | (info_element & Q931_IE_SO_IDENTIFIER_MASK)) {
2663
2664 case CS0 | Q931_IE_MORE_DATA_OR_SEND_COMP:
2665 switch (info_element) {
2666
2667 case Q931_IE_MORE_DATA:
2668 proto_tree_add_item(q931_tree, hf_q931_more_data, tvb, offset, 1, ENC_NA);
2669 break;
2670
2671 case Q931_IE_SENDING_COMPLETE:
2672 proto_tree_add_item(q931_tree, hf_q931_sending_complete, tvb, offset, 1, ENC_NA);
2673 break;
2674
2675 default:
2676 proto_tree_add_expert_format(q931_tree, pinfo, &ei_q931_information_element, tvb, offset, 1,
2677 "Unknown information element (0x%02X)", info_element);
2678 break;
2679 }
2680 break;
2681
2682 case CS0 | Q931_IE_CONGESTION_LEVEL:
2683 proto_tree_add_item(q931_tree, hf_q931_congestion_level, tvb, offset, 1, ENC_BIG_ENDIAN);
2684 break;
2685
2686 case CS0 | Q931_IE_REPEAT_INDICATOR:
2687 proto_tree_add_item(q931_tree, hf_q931_repeat_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
2688 break;
2689
2690 default:
2691 proto_tree_add_expert_format(q931_tree, pinfo, &ei_q931_information_element, tvb, offset, 1,
2692 "Unknown information element (0x%02X)", info_element);
2693 break;
2694 }
2695 offset += 1;
2696 codeset = locked_codeset;
2697 continue;
2698 }
2699
2700 /*
2701 * Variable-length IE.
2702 *
2703 * According to page 18 from Recommendation H.225.0 :
2704 * " Length of user-user contents contents
2705 * - Shall be 2 octets instead of 1 (as in Figure 4-36/Q.931)"
2706 *
2707 * We assume that if this is Q.931-over-TPKT, it might
2708 * be H.225 traffic, and check for the IE being a user-user
2709 * IE with ASN.1 encoding of the user information.
2710 */
2711 if (is_over_ip && tvb_bytes_exist(tvb, offset, 4) &&
2712 codeset == 0 && tvb_get_guint8(tvb, offset) == Q931_IE_USER_USER &&
2713 tvb_get_guint8(tvb, offset + 3) == Q931_PROTOCOL_DISCRIMINATOR_ASN1) {
2714 info_element_len = tvb_get_ntohs(tvb, offset + 1);
2715 if (q931_tree != NULL) {
2716 ie_tree = proto_tree_add_subtree(q931_tree, tvb, offset,
2717 1+2+info_element_len, ett_q931_ie[info_element], NULL,
2718 val_to_str(info_element,
2719 q931_info_element_vals[codeset],
2720 "Unknown information element (0x%02X)"));
2721 proto_tree_add_uint_format_value(ie_tree, hf_q931_information_element, tvb, offset, 1, info_element, "%s", val_to_str(info_element,
2722 q931_info_element_vals[codeset], "Unknown (0x%02X)"));
2723 proto_tree_add_item(ie_tree, hf_q931_information_element_len, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
2724 proto_tree_add_item(ie_tree, hf_q931_user_protocol_discriminator, tvb, offset + 3, 1, ENC_NA);
2725 }
2726
2727 if (info_element_len > 1) {
2728 /*
2729 * If we don't desegment limit the length
2730 * to the actual size in the frame
2731 */
2732 if (!pinfo->can_desegment) {
2733 info_element_len = MIN(info_element_len, tvb_captured_length_remaining(tvb, offset + 3));
2734 }
2735 /*
2736 * Do we have a handle for the H.225
2737 * dissector?
2738 */
2739 if (h225_handle != NULL) {
2740 /*
2741 * Yes - call it, regardless of
2742 * whether we're building a
2743 * protocol tree or not.
2744 */
2745 h225_tvb = tvb_new_subset_length(tvb,
2746 offset + 4, info_element_len - 1);
2747 call_dissector(h225_handle, h225_tvb,
2748 pinfo, root_tree);
2749 } else {
2750 /*
2751 * No - just show it as "User
2752 * information" (if "ie_tree" is
2753 * null, this won't add anything).
2754 */
2755 proto_tree_add_item(ie_tree, hf_q931_user_information_bytes, tvb, offset + 4, info_element_len - 1, ENC_NA);
2756 }
2757 }
2758 offset += 1 + 2 + info_element_len;
2759 } else {
2760 info_element_len = tvb_get_guint8(tvb, offset + 1);
2761
2762 if (first_segment && (tvb_reported_length_remaining(tvb, offset + 2) < info_element_len)) { /* incomplete IE at the end of the 1st segment */
2763 proto_tree_add_expert(q931_tree, pinfo, &ei_q931_incomplete_ie, tvb, offset, -1);
2764 break;
2765 }
2766
2767 /*
2768 * Check for subdissectors for this IE or
2769 * for all IEs in this codeset.
2770 */
2771 if (dissector_get_uint_handle(codeset_dissector_table, codeset) ||
2772 dissector_get_uint_handle(ie_dissector_table, (codeset << 8) | info_element)) {
2773 next_tvb = tvb_new_subset_length (tvb, offset, info_element_len + 2);
2774 if (dissector_try_uint(ie_dissector_table, (codeset << 8) | info_element, next_tvb, pinfo, q931_tree) ||
2775 dissector_try_uint(codeset_dissector_table, codeset, next_tvb, pinfo, q931_tree)) {
2776 offset += 2 + info_element_len;
2777 codeset = locked_codeset;
2778 continue;
2779 }
2780 }
2781
2782 ie_tree = proto_tree_add_subtree(q931_tree, tvb, offset, 1+1+info_element_len, ett_q931_ie[info_element], &ti,
2783 val_to_str(info_element, q931_info_element_vals[codeset], "Unknown information element (0x%02X)"));
2784 proto_tree_add_uint_format_value(ie_tree, hf_q931_information_element, tvb, offset, 1, info_element, "%s",
2785 val_to_str(info_element, q931_info_element_vals[codeset], "Unknown (0x%02X)"));
2786 proto_tree_add_uint(ie_tree, hf_q931_information_element_len, tvb, offset + 1, 1, info_element_len);
2787
2788 if (((codeset << 8) | info_element) == (CS0 | Q931_IE_SEGMENTED_MESSAGE)) {
2789 dissect_q931_segmented_message_ie(tvb, pinfo, offset + 2, info_element_len, ie_tree, ti);
2790 col_append_fstr(pinfo->cinfo, COL_INFO, " of %s",
2791 val_to_str_ext(tvb_get_guint8(tvb, offset + 3), &q931_message_type_vals_ext, "Unknown message type (0x%02X)"));
2792
2793 if (tvb_get_guint8(tvb, offset + 2) & 0x80) { /* the 1st segment */
2794 first_segment = TRUE;
2795 } else { /* not the 1st segment */
2796 proto_tree_add_item(q931_tree, hf_q931_message_segment, tvb, offset + 4, -1, ENC_NA);
2797 info_element_len += tvb_reported_length_remaining(tvb, offset + 4);
2798 }
2799 } else {
2800 /*
2801 * For the calling number, called number,
2802 * and release cause IEs, don't check
2803 * for the tree being null, as
2804 * the dissectors for those IEs also
2805 * supply information for the tap used
2806 * in VoIP calls.
2807 */
2808 switch ((codeset << 8) | info_element) {
2809
2810 case CS0 | Q931_IE_BEARER_CAPABILITY:
2811 case CS0 | Q931_IE_LOW_LAYER_COMPAT:
2812 if (q931_tree != NULL) {
2813 dissect_q931_bearer_capability_ie(tvb,
2814 offset + 2, info_element_len,
2815 ie_tree);
2816 }
2817 break;
2818
2819 case CS0 | Q931_IE_CAUSE:
2820 dissect_q931_cause_ie_with_info(tvb,
2821 offset + 2, info_element_len,
2822 ie_tree,
2823 hf_q931_cause_value, &dummy, q931_info_element_vals0, q931_pi);
2824 break;
2825
2826 case CS0 | Q931_IE_CHANGE_STATUS:
2827 if (q931_tree != NULL) {
2828 dissect_q931_change_status_ie(tvb,
2829 offset + 2, info_element_len,
2830 ie_tree);
2831 }
2832 break;
2833
2834 case CS0 | Q931_IE_CALL_STATE:
2835 if (q931_tree != NULL) {
2836 dissect_q931_call_state_ie(tvb,
2837 offset + 2, info_element_len,
2838 ie_tree);
2839 }
2840 break;
2841
2842 case CS0 | Q931_IE_CHANNEL_IDENTIFICATION:
2843 if (q931_tree != NULL) {
2844 dissect_q931_channel_identification_ie(
2845 tvb, offset + 2, info_element_len,
2846 ie_tree);
2847 }
2848 break;
2849
2850 case CS0 | Q931_IE_PROGRESS_INDICATOR:
2851 if (q931_tree != NULL) {
2852 dissect_q931_progress_indicator_ie(tvb,
2853 offset + 2, info_element_len,
2854 ie_tree);
2855 }
2856 break;
2857
2858 case CS0 | Q931_IE_NETWORK_SPECIFIC_FACIL:
2859 case CS0 | Q931_IE_TRANSIT_NETWORK_SEL:
2860 if (q931_tree != NULL) {
2861 dissect_q931_ns_facilities_ie(tvb,
2862 offset + 2, info_element_len,
2863 ie_tree);
2864 }
2865 break;
2866
2867 case CS0 | Q931_IE_NOTIFICATION_INDICATOR:
2868 if (q931_tree != NULL) {
2869 dissect_q931_notification_indicator_ie(
2870 tvb, offset + 2, info_element_len,
2871 ie_tree);
2872 }
2873 break;
2874
2875 case CS0 | Q931_IE_DISPLAY:
2876 if (q931_tree != NULL) {
2877 dissect_q931_ia5_ie(tvb, offset + 2, info_element_len, ie_tree, hf_q931_display_information);
2878 }
2879 break;
2880
2881 case CS0 | Q931_IE_DATE_TIME:
2882 dissect_q931_date_time_ie(tvb, pinfo,
2883 offset + 2, info_element_len,
2884 ie_tree);
2885 break;
2886
2887 case CS0 | Q931_IE_KEYPAD_FACILITY:
2888 if (q931_tree != NULL) {
2889 dissect_q931_ia5_ie(tvb, offset + 2, info_element_len, ie_tree, hf_q931_keypad_facility);
2890 }
2891 break;
2892
2893 case CS0 | Q931_IE_SIGNAL:
2894 dissect_q931_signal_ie(tvb, pinfo,
2895 offset + 2, info_element_len,
2896 ie_tree, ti);
2897 break;
2898
2899 case CS0 | Q931_IE_INFORMATION_RATE:
2900 dissect_q931_information_rate_ie(tvb, pinfo,
2901 offset + 2, info_element_len,
2902 ie_tree, ti);
2903 break;
2904
2905 case CS0 | Q931_IE_E2E_TRANSIT_DELAY:
2906 dissect_q931_e2e_transit_delay_ie(tvb, pinfo,
2907 offset + 2, info_element_len,
2908 ie_tree, ti);
2909 break;
2910
2911 case CS0 | Q931_IE_TD_SELECTION_AND_INT:
2912 dissect_q931_td_selection_and_int_ie(
2913 tvb, pinfo, offset + 2, info_element_len,
2914 ie_tree, ti);
2915 break;
2916
2917 case CS0 | Q931_IE_PL_BINARY_PARAMETERS:
2918 if (q931_tree != NULL) {
2919 dissect_q931_pl_binary_parameters_ie(
2920 tvb, offset + 2, info_element_len,
2921 ie_tree);
2922 }
2923 break;
2924
2925 case CS0 | Q931_IE_PL_WINDOW_SIZE:
2926 if (q931_tree != NULL) {
2927 dissect_q931_pl_window_size_ie(tvb,
2928 offset + 2, info_element_len,
2929 ie_tree);
2930 }
2931 break;
2932
2933 case CS0 | Q931_IE_PACKET_SIZE:
2934 if (q931_tree != NULL) {
2935 dissect_q931_packet_size_ie(tvb,
2936 offset + 2, info_element_len,
2937 ie_tree);
2938 }
2939 break;
2940
2941 case CS0 | Q931_IE_CUG:
2942 if (q931_tree != NULL) {
2943 dissect_q931_cug_ie(tvb,
2944 offset + 2, info_element_len,
2945 ie_tree);
2946 }
2947 break;
2948
2949 case CS0 | Q931_IE_REVERSE_CHARGE_IND:
2950 if (q931_tree != NULL) {
2951 dissect_q931_reverse_charge_ind_ie(tvb,
2952 offset + 2, info_element_len,
2953 ie_tree);
2954 }
2955 break;
2956
2957 case CS0 | Q931_IE_CONNECTED_NUMBER_DEFAULT:
2958 if (q931_tree != NULL) {
2959 dissect_q931_number_ie(pinfo, tvb,
2960 offset + 2, info_element_len,
2961 ie_tree,
2962 hf_q931_connected_number, e164_info, q931_pi);
2963 }
2964 break;
2965
2966
2967 case CS0 | Q931_IE_CALLING_PARTY_NUMBER:
2968 e164_info.e164_number_type = CALLING_PARTY_NUMBER;
2969 dissect_q931_number_ie(pinfo, tvb,
2970 offset + 2, info_element_len,
2971 ie_tree,
2972 hf_q931_calling_party_number, e164_info, q931_pi);
2973 break;
2974
2975 case CS0 | Q931_IE_CALLED_PARTY_NUMBER:
2976 e164_info.e164_number_type = CALLED_PARTY_NUMBER;
2977 dissect_q931_number_ie(pinfo, tvb,
2978 offset + 2, info_element_len,
2979 ie_tree,
2980 hf_q931_called_party_number, e164_info, q931_pi);
2981 break;
2982
2983 case CS0 | Q931_IE_CALLING_PARTY_SUBADDR:
2984 case CS0 | Q931_IE_CALLED_PARTY_SUBADDR:
2985 if (q931_tree != NULL) {
2986 dissect_q931_party_subaddr_ie(tvb,
2987 offset + 2, info_element_len,
2988 ie_tree);
2989 }
2990 break;
2991
2992 case CS0 | Q931_IE_REDIRECTING_NUMBER:
2993 if (q931_tree != NULL) {
2994 dissect_q931_number_ie(pinfo, tvb,
2995 offset + 2, info_element_len,
2996 ie_tree,
2997 hf_q931_redirecting_number, e164_info, q931_pi);
2998 }
2999 break;
3000
3001 case CS0 | Q931_IE_RESTART_INDICATOR:
3002 dissect_q931_restart_indicator_ie(tvb, pinfo,
3003 offset + 2, info_element_len,
3004 ie_tree, ti);
3005 break;
3006
3007 case CS0 | Q931_IE_HIGH_LAYER_COMPAT:
3008 if (q931_tree != NULL) {
3009 dissect_q931_high_layer_compat_ie(tvb,
3010 offset + 2, info_element_len,
3011 ie_tree);
3012 }
3013 break;
3014
3015 case CS0 | Q931_IE_USER_USER:
3016 if (q931_tree != NULL) {
3017 dissect_q931_user_user_ie(tvb, pinfo,
3018 offset + 2, info_element_len,
3019 ie_tree);
3020 }
3021 break;
3022
3023 case CS5 | Q931_IE_PARTY_CATEGORY:
3024 if (q931_tree != NULL) {
3025 dissect_q931_party_category_ie(tvb,
3026 offset + 2, info_element_len,
3027 ie_tree);
3028 }
3029 break;
3030
3031 case CS6 | Q931_IE_DISPLAY:
3032 if (q931_tree != NULL) {
3033 dissect_q931_ia5_ie(tvb, offset + 2, info_element_len, ie_tree, hf_q931_avaya_display);
3034 }
3035 break;
3036
3037 default:
3038 if (q931_tree != NULL) {
3039 proto_tree_add_item(ie_tree, hf_q931_data, tvb,
3040 offset + 2, info_element_len, ENC_NA);
3041 }
3042 break;
3043 }
3044 }
3045 offset += 1 + 1 + info_element_len;
3046 }
3047 codeset = locked_codeset;
3048 }
3049 if (q931_pi) {
3050 tap_queue_packet(q931_tap, pinfo, q931_pi);
3051 }
3052 }
3053
3054 /*
3055 * Q.931-over-TPKT-over-TCP.
3056 */
3057 static gboolean
dissect_q931_tpkt_heur(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)3058 dissect_q931_tpkt_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
3059 {
3060 int lv_tpkt_len;
3061
3062 /*
3063 * Check whether this looks like a TPKT-encapsulated
3064 * Q.931 packet.
3065 *
3066 * The minimum length of a Q.931 message is 3:
3067 * 1 byte for the protocol discriminator,
3068 * 1 for the call_reference length,
3069 * and one for the message type.
3070 */
3071 lv_tpkt_len = is_tpkt(tvb, 3);
3072 if (lv_tpkt_len == -1) {
3073 /*
3074 * It's not a TPKT packet; reject it.
3075 */
3076 return FALSE;
3077 }
3078
3079 /*
3080 * If this segment is *exactly* the length of a TPKT header,
3081 * we assume that, as it looks like a TPKT header, it
3082 * is one, and that the code put a TPKT header in one
3083 * segment and the rest of the PDU in another.
3084 */
3085 if (tvb_reported_length(tvb) == 4) {
3086 /*
3087 * It is - call the "dissect TPKT over a TCP stream"
3088 * routine.
3089 */
3090 dissect_tpkt_encap(tvb, pinfo, tree, q931_desegment,
3091 q931_tpkt_pdu_handle);
3092 return TRUE;
3093 }
3094
3095 /*
3096 * Well, we have more data than just the TPKT header;
3097 * check whether it looks like the beginning of a
3098 * Q.931 message.
3099 *
3100 * The minimum length of a Q.931 message is 3, as per the
3101 * above.
3102 *
3103 * Check that we have that many bytes past the TPKT header in
3104 * the tvbuff; we already know that the TPKT header says we
3105 * have that many bytes (as we passed 3 as the "min_len" argument
3106 * to "is_tpkt()").
3107 */
3108 if (!tvb_bytes_exist(tvb, 4, 3))
3109 return FALSE;
3110
3111 /* Check the protocol discriminator */
3112 if ((tvb_get_guint8(tvb, 4) != NLPID_Q_931) && (tvb_get_guint8(tvb, 4) != 0x03)) {
3113 /* Doesn't look like Q.931 inside TPKT */
3114 return FALSE;
3115 }
3116
3117 /*
3118 * OK, it looks like Q.931-over-TPKT.
3119 * Call the "dissect TPKT over a TCP stream" routine.
3120 */
3121 dissect_tpkt_encap(tvb, pinfo, tree, q931_desegment,
3122 q931_tpkt_pdu_handle);
3123
3124 return TRUE;
3125 }
3126
3127 static int
dissect_q931_tpkt(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)3128 dissect_q931_tpkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3129 {
3130 dissect_q931_tpkt_heur(tvb, pinfo, tree, NULL);
3131 return tvb_captured_length(tvb);
3132 }
3133
3134 static int
dissect_q931_tpkt_pdu(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)3135 dissect_q931_tpkt_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3136 {
3137 dissect_q931_pdu(tvb, pinfo, tree, TRUE);
3138 return tvb_captured_length(tvb);
3139 }
3140
3141 static int
dissect_q931(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)3142 dissect_q931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3143 {
3144 dissect_q931_pdu(tvb, pinfo, tree, FALSE);
3145 return tvb_captured_length(tvb);
3146 }
3147
3148 static int
dissect_q931_over_ip(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)3149 dissect_q931_over_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3150 {
3151 dissect_q931_pdu(tvb, pinfo, tree, TRUE);
3152 return tvb_captured_length(tvb);
3153 }
3154
3155 static int
dissect_q931_ie_cs0(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)3156 dissect_q931_ie_cs0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3157 {
3158 dissect_q931_IEs(tvb, pinfo, NULL, tree, FALSE, 0, 0, NULL);
3159 return tvb_captured_length(tvb);
3160 }
3161
3162 static int
dissect_q931_ie_cs7(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)3163 dissect_q931_ie_cs7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3164 {
3165 dissect_q931_IEs(tvb, pinfo, NULL, tree, FALSE, 0, 7, NULL);
3166 return tvb_captured_length(tvb);
3167 }
3168
3169 void
proto_register_q931(void)3170 proto_register_q931(void)
3171 {
3172 guint i;
3173 guint last_offset;
3174
3175 static hf_register_info hf[] = {
3176 { &hf_q931_discriminator,
3177 { "Protocol discriminator", "q931.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
3178 NULL, HFILL }},
3179
3180 { &hf_q931_call_ref_len,
3181 { "Call reference value length", "q931.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
3182 NULL, HFILL }},
3183
3184 { &hf_q931_call_ref_flag,
3185 { "Call reference flag", "q931.call_ref_flag", FT_BOOLEAN, BASE_NONE, TFS(&tfs_call_ref_flag), 0x0,
3186 NULL, HFILL }},
3187
3188 { &hf_q931_call_ref,
3189 { "Call reference value", "q931.call_ref", FT_BYTES, BASE_NONE, NULL, 0x0,
3190 NULL, HFILL }},
3191
3192 { &hf_q931_message_type,
3193 { "Message type", "q931.message_type", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_message_type_vals_ext, 0x0,
3194 NULL, HFILL }},
3195
3196 { &hf_q931_maintenance_message_type,
3197 { "Maintenance message type", "q931.maintenance_message_type", FT_UINT8, BASE_HEX, VALS(dms_message_type_vals), 0x0,
3198 NULL, HFILL }},
3199
3200 { &hf_q931_segment_type,
3201 { "Segmented message type", "q931.segment_type", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_message_type_vals_ext, 0x0,
3202 NULL, HFILL }},
3203
3204 { &hf_q931_coding_standard,
3205 { "Coding standard", "q931.coding_standard", FT_UINT8, BASE_HEX,
3206 VALS(q931_coding_standard_vals), 0x60,NULL, HFILL }},
3207
3208 { &hf_q931_interpretation,
3209 { "Interpretation", "q931.interpretation", FT_UINT8, BASE_HEX,
3210 VALS(q931_interpretation_vals), 0x1C, NULL, HFILL}},
3211
3212 { &hf_q931_pres_meth_prot_prof,
3213 { "Presentation method of protocol profile", "q931.presentation_method_protocol_profile", FT_UINT8, BASE_HEX,
3214 VALS(q931_pres_meth_prot_prof_vals), 0x03, NULL, HFILL}},
3215
3216 { &hf_q931_high_layer_characteristics,
3217 { "High layer characteristics identification", "q931.high_layer_characteristics", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
3218 &q931_high_layer_characteristics_vals_ext, 0x7f, NULL, HFILL }},
3219
3220 { &hf_q931_extended_high_layer_characteristics,
3221 { "Extended high layer characteristics identification", "q931.extended_high_layer_characteristics", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
3222 &q931_extended_high_layer_characteristics_vals_ext, 0x7f, NULL, HFILL }},
3223
3224 { &hf_q931_extended_audiovisual_characteristics,
3225 { "Extended audiovisual characteristics identification", "q931.extended_audiovisual_characteristics", FT_UINT8, BASE_HEX,
3226 VALS(q931_audiovisual_characteristics_vals), 0x7f, NULL, HFILL }},
3227
3228 { &hf_q931_information_transfer_capability,
3229 { "Information transfer capability", "q931.information_transfer_capability", FT_UINT8, BASE_HEX,
3230 VALS(q931_information_transfer_capability_vals), 0x1f,NULL, HFILL }},
3231
3232 { &hf_q931_transfer_mode,
3233 { "Transfer mode", "q931.transfer_mode", FT_UINT8, BASE_HEX,
3234 VALS(q931_transfer_mode_vals), 0x60,NULL, HFILL }},
3235
3236 { &hf_q931_information_transfer_rate,
3237 { "Information transfer rate", "q931.information_transfer_rate", FT_UINT8, BASE_HEX,
3238 VALS(q931_information_transfer_rate_vals), 0x1f,NULL, HFILL }},
3239
3240 { &hf_q931_layer_ident,
3241 { "Layer identification", "q931.layer_ident", FT_UINT8, BASE_HEX,
3242 VALS(q931_bearer_capability_layer_ident_vals), 0x60, NULL, HFILL }},
3243
3244 { &hf_q931_uil1,
3245 { "User information layer 1 protocol", "q931.uil1", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
3246 &q931_uil1_vals_ext, 0x1f,NULL, HFILL }},
3247
3248 { &hf_q931_cause_location,
3249 { "Cause location", "q931.cause_location", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &q931_cause_location_vals_ext, 0x0f,
3250 NULL, HFILL }},
3251
3252 { &hf_q931_cause_value,
3253 { "Cause value", "q931.cause_value", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &q931_cause_code_vals_ext, 0x7f,
3254 NULL, HFILL }},
3255
3256 { &hf_q931_number_type,
3257 { "Number type", "q931.number_type", FT_UINT8, BASE_HEX, VALS(q931_number_type_vals), 0x70,
3258 NULL, HFILL }},
3259
3260 { &hf_q931_numbering_plan,
3261 { "Numbering plan", "q931.numbering_plan", FT_UINT8, BASE_HEX, VALS(q931_numbering_plan_vals), 0x0f,
3262 NULL, HFILL }},
3263
3264 { &hf_q931_screening_ind,
3265 { "Screening indicator", "q931.screening_ind", FT_UINT8, BASE_HEX, VALS(q931_screening_indicator_vals), 0x03,
3266 NULL, HFILL }},
3267
3268 { &hf_q931_presentation_ind,
3269 { "Presentation indicator", "q931.presentation_ind", FT_UINT8, BASE_HEX, VALS(q931_presentation_indicator_vals), 0x60,
3270 NULL, HFILL }},
3271
3272 { &hf_q931_extension_ind,
3273 { "Extension indicator", "q931.extension_ind",
3274 FT_BOOLEAN, 8, TFS(&q931_extension_ind_value), 0x80,
3275 NULL, HFILL }},
3276
3277 { &hf_q931_extension_ind_preference,
3278 { "Preference", "q931.extension_ind_preference",
3279 FT_UINT8, BASE_DEC, VALS(q931_status_preference_vals), 0x40,
3280 NULL, HFILL }},
3281
3282 { &hf_q931_extension_ind_new_status,
3283 { "New status", "q931.extension_ind_new_status",
3284 FT_UINT8, BASE_DEC, VALS(q931_new_status_vals), 0x07,
3285 NULL, HFILL }},
3286
3287 { &hf_q931_calling_party_number,
3288 { "Calling party number digits", "q931.calling_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3289 NULL, HFILL }},
3290
3291 { &hf_q931_called_party_number,
3292 { "Called party number digits", "q931.called_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3293 NULL, HFILL }},
3294
3295 { &hf_q931_connected_number,
3296 { "Connected party number digits", "q931.connected_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3297 NULL, HFILL }},
3298
3299 { &hf_q931_redirecting_number,
3300 { "Redirecting party number digits", "q931.redirecting_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3301 NULL, HFILL }},
3302
3303 /* fields for channel identification IE */
3304 /* 0x80 is the extension bit */
3305
3306 { &hf_q931_channel_interface_explicit,
3307 { "Interface identifier present", "q931.channel.interface_id_present", FT_BOOLEAN, 8, NULL, 0x40,
3308 "True if the interface identifier is explicit in the following octets", HFILL }},
3309
3310 { &hf_q931_channel_interface_type,
3311 { "Interface type", "q931.channel.interface_type", FT_BOOLEAN, 8, TFS(&tfs_interface_type), 0x20,
3312 "Identifies the ISDN interface type", HFILL }},
3313
3314 /* 0x10 is spare */
3315
3316 { &hf_q931_channel_exclusive,
3317 { "Indicated channel", "q931.channel.exclusive", FT_BOOLEAN, 8, TFS(&tfs_channel_exclusive), 0x08,
3318 "True if only the indicated channel is acceptable", HFILL }},
3319
3320 { &hf_q931_channel_dchan,
3321 { "D-channel indicator", "q931.channel.dchan", FT_BOOLEAN, 8, NULL, 0x04,
3322 "True if the identified channel is the D-Channel", HFILL }},
3323
3324 { &hf_q931_channel_selection_bri,
3325 { "Information channel selection", "q931.channel.selection", FT_UINT8, BASE_HEX, VALS(q931_basic_channel_selection_vals), 0x03,
3326 "Identifies the information channel to be used", HFILL }},
3327
3328 { &hf_q931_channel_selection_pri,
3329 { "Information channel selection", "q931.channel.selection", FT_UINT8, BASE_HEX, VALS(q931_not_basic_channel_selection_vals), 0x03,
3330 "Identifies the information channel to be used", HFILL }},
3331
3332 { &hf_q931_channel_map,
3333 { "Number/map", "q931.channel.map", FT_BOOLEAN, 8, TFS(&tfs_channel_map), 0x10,
3334 "True if channel is indicates by channel map rather than number", HFILL }},
3335
3336 { &hf_q931_channel_element_type,
3337 { "Element type", "q931.channel.element_type", FT_UINT8, BASE_HEX, VALS(q931_element_type_vals), 0xF,
3338 "Type of element in the channel number/slot map octets", HFILL }},
3339
3340 { &hf_q931_channel_number,
3341 { "Channel number", "q931.channel.number", FT_UINT8, BASE_DEC, NULL, 0x7F,
3342 NULL, HFILL }},
3343
3344 /* desegmentation fields */
3345 { &hf_q931_segment_overlap,
3346 { "Segment overlap", "q931.segment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3347 "Fragment overlaps with other fragments", HFILL }},
3348
3349 { &hf_q931_segment_overlap_conflict,
3350 { "Conflicting data in fragment overlap", "q931.segment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3351 "Overlapping fragments contained conflicting data", HFILL }},
3352
3353 { &hf_q931_segment_multiple_tails,
3354 { "Multiple tail fragments found", "q931.segment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3355 "Several tails were found when defragmenting the packet", HFILL }},
3356
3357 { &hf_q931_segment_too_long_segment,
3358 { "Segment too long", "q931.segment.toolongfragment", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3359 "Segment contained data past end of packet", HFILL }},
3360
3361 { &hf_q931_segment_error,
3362 { "Defragmentation error", "q931.segment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3363 "Defragmentation error due to illegal fragments", HFILL }},
3364
3365 { &hf_q931_segment_count,
3366 { "Segment count", "q931.segment.count", FT_UINT32, BASE_DEC, NULL, 0x0,
3367 NULL, HFILL}},
3368
3369 { &hf_q931_segment,
3370 { "Q.931 Segment", "q931.segment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3371 NULL, HFILL }},
3372
3373 { &hf_q931_segments,
3374 { "Q.931 Segments", "q931.segments", FT_NONE, BASE_NONE, NULL, 0x0,
3375 NULL, HFILL }},
3376
3377 { &hf_q931_reassembled_in,
3378 { "Reassembled Q.931 in frame", "q931.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3379 "This Q.931 message is reassembled in this frame", HFILL}},
3380
3381 { &hf_q931_reassembled_length,
3382 { "Reassembled Q.931 length", "q931.reassembled.length", FT_UINT32, BASE_DEC, NULL, 0x0,
3383 "The total length of the reassembled payload", HFILL}},
3384
3385 /* Generated from convert_proto_tree_add_text.pl */
3386 { &hf_q931_first_segment,
3387 { "First segment", "q931.segment.first",
3388 FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_segment_remaining, 0x7F,
3389 NULL, HFILL }
3390 },
3391 { &hf_q931_not_first_segment,
3392 { "Not first segment", "q931.segment.not_first",
3393 FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_segment_remaining, 0x7F,
3394 NULL, HFILL }
3395 },
3396 { &hf_q931_bearer_capability_data,
3397 { "Data", "q931.bearer_capability.data",
3398 FT_BYTES, BASE_NONE, NULL, 0x0,
3399 NULL, HFILL }
3400 },
3401 { &hf_q931_bearer_capability_rate_multiplier,
3402 { "Rate multiplier", "q931.bearer_capability.rate_multiplier",
3403 FT_UINT8, BASE_DEC, NULL, 0x7f,
3404 NULL, HFILL }
3405 },
3406 { &hf_q931_bearer_capability_user_rate,
3407 { "User rate", "q931.bearer_capability.user_rate",
3408 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_l1_user_rate_vals_ext, 0x1F,
3409 NULL, HFILL }
3410 },
3411 { &hf_q931_bearer_capability_intermediate_rate,
3412 { "Intermediate rate", "q931.bearer_capability.intermediate_rate",
3413 FT_UINT8, BASE_HEX, VALS(q931_l1_intermediate_rate_vals), 0x60,
3414 NULL, HFILL }
3415 },
3416 { &hf_q931_bearer_capability_stop_bits,
3417 { "Stop bits", "q931.bearer_capability.stop_bits",
3418 FT_UINT8, BASE_HEX, VALS(q931_l1_stop_bits_vals), 0x60,
3419 NULL, HFILL }
3420 },
3421 { &hf_q931_bearer_capability_data_bits,
3422 { "Data bits", "q931.bearer_capability.data_bits",
3423 FT_UINT8, BASE_HEX, VALS(q931_l1_data_bits_vals), 0x18,
3424 NULL, HFILL }
3425 },
3426 { &hf_q931_bearer_capability_parity,
3427 { "Parity", "q931.bearer_capability.parity",
3428 FT_UINT8, BASE_HEX, VALS(q931_l1_parity_vals), 0x07,
3429 NULL, HFILL }
3430 },
3431 { &hf_q931_bearer_capability_modem_type,
3432 { "Modem type", "q931.bearer_capability.modem_type",
3433 FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(q931_l1_modem_type_rvals), 0x3F,
3434 NULL, HFILL }
3435 },
3436 { &hf_q931_uil2,
3437 { "User information layer 2 protocol", "q931.uil2",
3438 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_uil2_vals_ext, 0x1F,
3439 NULL, HFILL }
3440 },
3441 { &hf_q931_uil2_info,
3442 { "User-specified layer 2 protocol information", "q931.uil2_info",
3443 FT_UINT8, BASE_HEX, NULL, 0x7F,
3444 NULL, HFILL }
3445 },
3446 { &hf_q931_bearer_capability_mode,
3447 { "Mode", "q931.bearer_capability.mode",
3448 FT_UINT8, BASE_HEX, VALS(q931_mode_vals), 0x60,
3449 NULL, HFILL }
3450 },
3451 { &hf_q931_bearer_capability_window_size,
3452 { "Window size", "q931.bearer_capability.window_size",
3453 FT_UINT8, BASE_DEC, NULL, 0x7F,
3454 NULL, HFILL }
3455 },
3456 { &hf_q931_uil3,
3457 { "User information layer 3 protocol", "q931.uil3",
3458 FT_UINT8, BASE_HEX, VALS(q931_uil3_vals), 0x1F,
3459 NULL, HFILL }
3460 },
3461 { &hf_q931_bearer_capability_default_packet_size,
3462 { "Default packet size", "q931.bearer_capability.default_packet_size",
3463 FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_octet_octets, 0x0F,
3464 NULL, HFILL }
3465 },
3466 { &hf_q931_bearer_capability_packet_window_size,
3467 { "Packet window size", "q931.bearer_capability.packet_window_size",
3468 FT_UINT8, BASE_DEC, NULL, 0x7F,
3469 NULL, HFILL }
3470 },
3471 { &hf_q931_uil3_additional,
3472 { "Additional layer 3 protocol information", "q931.uil3_additional",
3473 FT_UINT16, BASE_HEX, VALS(nlpid_vals), 0x0,
3474 NULL, HFILL }
3475 },
3476 { &hf_q931_cause_data,
3477 { "Data", "q931.cause.data",
3478 FT_BYTES, BASE_NONE, NULL, 0x0,
3479 NULL, HFILL }
3480 },
3481 { &hf_q931_cause_recommendation,
3482 { "Recommendation", "q931.cause.recommendation",
3483 FT_UINT8, BASE_HEX, VALS(q931_cause_recommendation_vals), 0x7F,
3484 NULL, HFILL }
3485 },
3486 { &hf_q931_cause_call_rejection_reason,
3487 { "Rejection reason", "q931.cause_call.rejection_reason",
3488 FT_UINT8, BASE_HEX, VALS(q931_rejection_reason_vals), 0x7C,
3489 NULL, HFILL }
3490 },
3491 { &hf_q931_cause_call_condition,
3492 { "Condition", "q931.cause_call.condition",
3493 FT_UINT8, BASE_HEX, VALS(q931_cause_condition_vals), 0x03,
3494 NULL, HFILL }
3495 },
3496 { &hf_q931_cause_call_user_specific_diagnostic,
3497 { "User specific diagnostic", "q931.cause_call.user_specific_diagnostic",
3498 FT_BYTES, BASE_NONE, NULL, 0x0,
3499 NULL, HFILL }
3500 },
3501 { &hf_q931_cause_call_diagnostic,
3502 { "Diagnostic", "q931.cause_call.diagnostic",
3503 FT_BYTES, BASE_NONE, NULL, 0x0,
3504 NULL, HFILL }
3505 },
3506 { &hf_q931_cause_call_message_type,
3507 { "Message type", "q931.cause_call.message_type",
3508 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_message_type_vals_ext, 0x0,
3509 NULL, HFILL }
3510 },
3511 { &hf_q931_cause_call_rec_timer,
3512 { "Timer", "q931.cause_call.rec_timer",
3513 FT_STRING, BASE_NONE, NULL, 0x0,
3514 NULL, HFILL }
3515 },
3516 { &hf_q931_call_state_data,
3517 { "Data", "q931.call_state.data",
3518 FT_BYTES, BASE_NONE, NULL, 0x0,
3519 NULL, HFILL }
3520 },
3521 { &hf_q931_call_state,
3522 { "Call state", "q931.call_state",
3523 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_call_state_vals_ext, 0x3F,
3524 NULL, HFILL }
3525 },
3526 { &hf_q931_channel_interface_id,
3527 { "Interface ID", "q931.channel.interface_id",
3528 FT_UINT32, BASE_DEC, NULL, 0x0,
3529 NULL, HFILL }
3530 },
3531 { &hf_q931_channel_data,
3532 { "Data", "q931.channel.data",
3533 FT_BYTES, BASE_NONE, NULL, 0x0,
3534 NULL, HFILL }
3535 },
3536 { &hf_q931_channel_slot_map,
3537 { "Slot map", "q931.channel.slot_map",
3538 FT_UINT8, BASE_HEX, NULL, 0x0,
3539 NULL, HFILL }
3540 },
3541 { &hf_q931_progress_indicator_data,
3542 { "Data", "q931.progress_indicator.data",
3543 FT_BYTES, BASE_NONE, NULL, 0x0,
3544 NULL, HFILL }
3545 },
3546 { &hf_q931_progress_indicator_location,
3547 { "Location", "q931.progress_indicator.location",
3548 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_cause_location_vals_ext, 0x0F,
3549 NULL, HFILL }
3550 },
3551 { &hf_q931_progress_indicator_description,
3552 { "Progress description", "q931.progress_indicator.description",
3553 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_progress_description_vals_ext, 0x7F,
3554 NULL, HFILL }
3555 },
3556 { &hf_q931_netid_length,
3557 { "Network identification length", "q931.netid.length",
3558 FT_UINT8, BASE_DEC, NULL, 0x7F,
3559 NULL, HFILL }
3560 },
3561 { &hf_q931_netid_type,
3562 { "Type of network identification", "q931.netid.type",
3563 FT_UINT8, BASE_HEX, VALS(q931_netid_type_vals), 0x70,
3564 NULL, HFILL }
3565 },
3566 { &hf_q931_netid_plan,
3567 { "Network identification plan", "q931.netid.plan",
3568 FT_UINT8, BASE_HEX, VALS(q931_netid_plan_vals), 0x0F,
3569 NULL, HFILL }
3570 },
3571 { &hf_q931_netid,
3572 { "Network identification", "q931.netid",
3573 FT_STRING, BASE_NONE, NULL, 0x0,
3574 NULL, HFILL }
3575 },
3576 { &hf_q931_netid_facility_specification,
3577 { "Network-specific facility specification", "q931.netid.facility_specification",
3578 FT_BYTES, BASE_NONE, NULL, 0x0,
3579 NULL, HFILL }
3580 },
3581 { &hf_q931_notification_description,
3582 { "Notification description", "q931.notification_description",
3583 FT_UINT8, BASE_HEX, VALS(q931_notification_description_vals), 0x7F,
3584 NULL, HFILL }
3585 },
3586 { &hf_q931_signal,
3587 { "Signal", "q931.signal",
3588 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_signal_vals_ext, 0x0,
3589 NULL, HFILL }
3590 },
3591 { &hf_q931_information_rate_incoming,
3592 { "Incoming information rate", "q931.information_rate.incoming",
3593 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_throughput_class_vals_ext, 0x1F,
3594 NULL, HFILL }
3595 },
3596 { &hf_q931_information_rate_outgoing,
3597 { "Outgoing information rate", "q931.information_rate.outgoing",
3598 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_throughput_class_vals_ext, 0x1F,
3599 NULL, HFILL }
3600 },
3601 { &hf_q931_information_rate_minimum_incoming,
3602 { "Minimum incoming information rate", "q931.information_rate.minimum_incoming",
3603 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_throughput_class_vals_ext, 0x1F,
3604 NULL, HFILL }
3605 },
3606 { &hf_q931_information_rate_minimum_outgoing,
3607 { "Minimum outgoing information rate", "q931.information_rate.minimum_outgoing",
3608 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_throughput_class_vals_ext, 0x1F,
3609 NULL, HFILL }
3610 },
3611 { &hf_q931_fast_select,
3612 { "Fast select", "q931.fast_select",
3613 FT_UINT8, BASE_HEX, VALS(q931_fast_selected_vals), 0x18,
3614 NULL, HFILL }
3615 },
3616 { &hf_q931_pl_window_size_forward_value,
3617 { "Forward value", "q931.pl_window_size.forward_value",
3618 FT_UINT8, BASE_DEC, NULL, 0x7F,
3619 NULL, HFILL }
3620 },
3621 { &hf_q931_pl_window_size_backward_value,
3622 { "Backward value", "q931.pl_window_size.backward_value",
3623 FT_UINT8, BASE_DEC, NULL, 0x7F,
3624 NULL, HFILL }
3625 },
3626 { &hf_q931_packet_size_forward_value,
3627 { "Forward value", "q931.packet_size.forward_value",
3628 FT_UINT8, BASE_DEC, NULL, 0x7F,
3629 NULL, HFILL }
3630 },
3631 { &hf_q931_packet_size_backward_value,
3632 { "Backward value", "q931.packet_size.backward_value",
3633 FT_UINT8, BASE_DEC, NULL, 0x7F,
3634 NULL, HFILL }
3635 },
3636 { &hf_q931_cug_indication,
3637 { "CUG indication", "q931.cug_indication",
3638 FT_UINT8, BASE_HEX, VALS(q931_cug_indication_vals), 0x07,
3639 NULL, HFILL }
3640 },
3641 { &hf_q931_cug_index_code,
3642 { "CUG index code", "q931.cug_index_code",
3643 FT_STRING, BASE_NONE, NULL, 0x0,
3644 NULL, HFILL }
3645 },
3646 { &hf_q931_reverse_charging_ind,
3647 { "Reverse charging indication", "q931.reverse_charging_ind",
3648 FT_UINT8, BASE_HEX, VALS(q931_reverse_charging_indication_vals), 0x07,
3649 NULL, HFILL }
3650 },
3651 { &hf_q931_extension_reason,
3652 { "Reason for redirection", "q931.extension.reason",
3653 FT_UINT8, BASE_HEX, VALS(q931_redirection_reason_vals), 0x0F,
3654 NULL, HFILL }
3655 },
3656 { &hf_q931_party_subaddr_type,
3657 { "Type of subaddress", "q931.party_subaddr.type",
3658 FT_UINT8, BASE_HEX, VALS(q931_subaddress_type_vals), 0x70,
3659 NULL, HFILL }
3660 },
3661 { &hf_q931_party_subaddr_odd_even_indicator,
3662 { "Odd/even indicator", "q931.party_subaddr.odd_even",
3663 FT_UINT8, BASE_HEX, VALS(q931_odd_even_indicator_vals), 0x08,
3664 NULL, HFILL }
3665 },
3666 { &hf_q931_party_subaddr,
3667 { "Subaddress", "q931.party_subaddr",
3668 FT_BYTES, BASE_NONE, NULL, 0x0,
3669 NULL, HFILL }
3670 },
3671 { &hf_q931_restart_indicator,
3672 { "Restart indicator", "q931.restart_indicator",
3673 FT_UINT8, BASE_HEX, VALS(q931_restart_indicator_class_vals), 0x07,
3674 NULL, HFILL }
3675 },
3676 { &hf_q931_high_layer_compat_data,
3677 { "Data", "q931.high_layer_compat.data",
3678 FT_BYTES, BASE_NONE, NULL, 0x0,
3679 NULL, HFILL }
3680 },
3681 { &hf_q931_user_protocol_discriminator,
3682 { "Protocol discriminator", "q931.user.protocol_discriminator",
3683 FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_protocol_discriminator_vals_ext, 0x0,
3684 NULL, HFILL }
3685 },
3686 { &hf_q931_user_information_len,
3687 { "User information", "q931.user.len",
3688 FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_octet_octets, 0x0,
3689 NULL, HFILL }
3690 },
3691 { &hf_q931_user_information_str,
3692 { "User information", "q931.user.string",
3693 FT_STRING, BASE_NONE, NULL, 0x0,
3694 NULL, HFILL }
3695 },
3696 { &hf_q931_user_information_bytes,
3697 { "User information", "q931.user.bytes",
3698 FT_BYTES, BASE_NONE, NULL, 0x0,
3699 NULL, HFILL }
3700 },
3701 { &hf_q931_party_category,
3702 { "Party category", "q931.party_category",
3703 FT_UINT8, BASE_HEX, VALS(q931_party_category_vals), 0x07,
3704 NULL, HFILL }
3705 },
3706 { &hf_q931_congestion_level,
3707 { "Congestion level", "q931.congestion_level",
3708 FT_UINT8, BASE_HEX, VALS(q931_congestion_level_vals), Q931_IE_SO_IE_MASK,
3709 NULL, HFILL }
3710 },
3711 { &hf_q931_repeat_indicator,
3712 { "Repeat indicator", "q931.repeat_indicator",
3713 FT_UINT8, BASE_HEX, VALS(q931_repeat_indication_vals), Q931_IE_SO_IE_MASK,
3714 NULL, HFILL }
3715 },
3716 { &hf_q931_out_band_negotiation,
3717 { "Out-band negotiation", "q931.out_band_negotiation",
3718 FT_BOOLEAN, 8, TFS(&tfs_possible_not_possible), 0x40,
3719 NULL, HFILL }
3720 },
3721 { &hf_q931_layer_1,
3722 { "Layer 1", "q931.layer_1",
3723 FT_BOOLEAN, 8, TFS(&tfs_asynchronous_synchronous), 0x40,
3724 NULL, HFILL }
3725 },
3726 { &hf_q931_layer_1_in_band_negotiation,
3727 { "Layer 1 in-band negotiation", "q931.layer_1_in_band_negotiation",
3728 FT_BOOLEAN, 8, TFS(&tfs_possible_not_possible), 0x20,
3729 NULL, HFILL }
3730 },
3731 { &hf_q931_send_data_net_independent_clock,
3732 { "Send data with network independent clock", "q931.send_data_net_independent_clock",
3733 FT_BOOLEAN, 8, TFS(&tfs_required_not_required), 0x10,
3734 NULL, HFILL }
3735 },
3736 { &hf_q931_accept_data_net_independent_clock,
3737 { "Accept data with network independent clock", "q931.accept_data_net_independent_clock",
3738 FT_BOOLEAN, 8, TFS(&tfs_accepted_not_accepted), 0x08,
3739 NULL, HFILL }
3740 },
3741 { &hf_q931_send_data_flow_control,
3742 { "Send data with flow control mechanism", "q931.send_data_flow_control",
3743 FT_BOOLEAN, 8, TFS(&tfs_required_not_required), 0x04,
3744 NULL, HFILL }
3745 },
3746 { &hf_q931_accept_data_flow_control,
3747 { "Accept data with flow control mechanism", "q931.accept_data_flow_control",
3748 FT_BOOLEAN, 8, TFS(&tfs_accepted_not_accepted), 0x2,
3749 NULL, HFILL }
3750 },
3751 { &hf_q931_rate_adaption_header,
3752 { "Rate adaption header", "q931.rate_adaption_header",
3753 FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x40,
3754 NULL, HFILL }
3755 },
3756 { &hf_q931_multiple_frame_establishment,
3757 { "Multiple frame establishment", "q931.multiple_frame_establishment",
3758 FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x20,
3759 NULL, HFILL }
3760 },
3761 { &hf_q931_mode_of_operation,
3762 { "mode of operation", "q931.mode_of_operation",
3763 FT_BOOLEAN, 8, TFS(&tfs_protocol_sensative_bit_transparent), 0x10,
3764 NULL, HFILL }
3765 },
3766 { &hf_q931_message_originator,
3767 { "Message originator", "q931.message_originator",
3768 FT_BOOLEAN, 8, TFS(&tfs_assignor_default), 0x04,
3769 NULL, HFILL }
3770 },
3771 { &hf_q931_negotiation_is_done,
3772 { "Negotiation is done", "q931.negotiation_is_done",
3773 FT_BOOLEAN, 8, TFS(&tfs_in_out_band), 0x02,
3774 NULL, HFILL }
3775 },
3776 { &hf_q931_bearer_capability_duplex,
3777 { "Duplex", "q931.bearer_capability.duplex",
3778 FT_BOOLEAN, 8, TFS(&tfs_full_half), 0x40,
3779 NULL, HFILL }
3780 },
3781 { &hf_q931_network_service,
3782 { "Network service", "q931.network_service",
3783 FT_BOOLEAN, 8, TFS(&tfs_user_provider), 0x80,
3784 NULL, HFILL }
3785 },
3786 { &hf_q931_extension_condition_type,
3787 { "Type", "q931.extension_condition_type",
3788 FT_BOOLEAN, 8, TFS(&tfs_abnormal_normal), 0x40,
3789 NULL, HFILL }
3790 },
3791 { &hf_q931_extension_condition,
3792 { "Condition", "q931.extension_condition",
3793 FT_UINT8, BASE_HEX, VALS(q931_cause_condition_vals), 0x03,
3794 NULL, HFILL }
3795 },
3796 { &hf_q931_pl_request,
3797 { "Request", "q931.pl_request",
3798 FT_BOOLEAN, 8, TFS(&tfs_pl_request), 0x04,
3799 NULL, HFILL }
3800 },
3801 { &hf_q931_pl_binary_confirmation,
3802 { "Confirmation", "q931.pl_binary_confirmation",
3803 FT_BOOLEAN, 8, TFS(&tfs_link_end), 0x02,
3804 NULL, HFILL }
3805 },
3806 { &hf_q931_pl_modulus,
3807 { "Modulus", "q931.pl_modulus",
3808 FT_BOOLEAN, 8, TFS(&tfs_pl_modulus), 0x01,
3809 NULL, HFILL }
3810 },
3811 { &hf_q931_data,
3812 { "Data", "q931.data",
3813 FT_BYTES, BASE_NONE, NULL, 0x0,
3814 NULL, HFILL }
3815 },
3816 { &hf_q931_information_element,
3817 { "Information element", "q931.information_element",
3818 FT_UINT8, BASE_DEC, NULL, 0x0,
3819 NULL, HFILL }
3820 },
3821 { &hf_q931_information_element_len,
3822 { "Length", "q931.information_element_len",
3823 FT_UINT8, BASE_DEC, NULL, 0x0,
3824 NULL, HFILL }
3825 },
3826 { &hf_q931_date_time,
3827 { "Date/time", "q931.date_time",
3828 FT_BYTES, BASE_NONE, NULL, 0x0,
3829 NULL, HFILL }
3830 },
3831 { &hf_q931_more_data,
3832 { "More data", "q931.more_data",
3833 FT_NONE, BASE_NONE, NULL, 0x0,
3834 NULL, HFILL }
3835 },
3836 { &hf_q931_sending_complete,
3837 { "Sending complete", "q931.sending_complete",
3838 FT_NONE, BASE_NONE, NULL, 0x0,
3839 NULL, HFILL }
3840 },
3841 { &hf_q931_message_segment,
3842 { "Message segment", "q931.message_segment",
3843 FT_BYTES, BASE_NONE, NULL, 0x0,
3844 NULL, HFILL }
3845 },
3846 { &hf_q931_missing_info_element,
3847 { "Missing information element", "q931.missing_info_element",
3848 FT_UINT8, BASE_HEX, NULL, 0x0,
3849 NULL, HFILL }
3850 },
3851 { &hf_q931_insufficient_info_element,
3852 { "Insufficient information element", "q931.insufficient_info_element",
3853 FT_UINT8, BASE_HEX, NULL, 0x0,
3854 NULL, HFILL }
3855 },
3856 { &hf_q931_cumulative_transit_delay,
3857 { "Cumulative transit delay", "q931.cumulative_transit_delay",
3858 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
3859 NULL, HFILL }
3860 },
3861 { &hf_q931_requested_end_to_end_transit_delay,
3862 { "Requested end-to-end transit delay", "q931.requested_end_to_end_transit_delay",
3863 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
3864 NULL, HFILL }
3865 },
3866 { &hf_q931_maximum_end_to_end_transit_delay,
3867 { "Maximum end-to-end transit delay", "q931.maximum_end_to_end_transit_delay",
3868 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
3869 NULL, HFILL }
3870 },
3871 { &hf_q931_transit_delay,
3872 { "Transit delay", "q931.transit_delay",
3873 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
3874 NULL, HFILL }
3875 },
3876 { &hf_q931_display_information,
3877 { "Display information", "q931.display_information",
3878 FT_STRING, BASE_NONE, NULL, 0x0,
3879 NULL, HFILL }
3880 },
3881 { &hf_q931_keypad_facility,
3882 { "Keypad facility", "q931.keypad_facility",
3883 FT_STRING, BASE_NONE, NULL, 0x0,
3884 NULL, HFILL }
3885 },
3886 { &hf_q931_avaya_display,
3887 { "Avaya Display", "q931.avaya_display",
3888 FT_STRING, BASE_NONE, NULL, 0x0,
3889 NULL, HFILL }
3890 },
3891 { &hf_q931_locking_codeset,
3892 { "Locking codeset", "q931.locking_codeset",
3893 FT_UINT8, BASE_DEC, NULL, 0x0,
3894 NULL, HFILL }
3895 },
3896 { &hf_q931_protocol_negotiation,
3897 { "Protocol negotiation", "q931.protocol_negotiation",
3898 FT_BOOLEAN, 8, TFS(&tfs_protocol_negotiation), 0x08,
3899 NULL, HFILL }
3900 },
3901 };
3902
3903 #define NUM_INDIVIDUAL_ELEMS 3
3904 static gint *ett[NUM_INDIVIDUAL_ELEMS + NUM_IE];
3905
3906 static ei_register_info ei[] = {
3907 { &ei_q931_invalid_length, { "q931.invalid_length", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
3908 { &ei_q931_date_time, { "q931.date_time.invalid", PI_MALFORMED, PI_ERROR, "Date/time: Invalid length", EXPFILL }},
3909 { &ei_q931_information_element, { "q931.information_element.unknown", PI_PROTOCOL, PI_WARN, "Unknown information element", EXPFILL }},
3910 { &ei_q931_incomplete_ie, { "q931.incomplete_ie", PI_MALFORMED, PI_ERROR, "Incomplete IE in the 1st segment", EXPFILL }},
3911 };
3912
3913 module_t *q931_module;
3914 expert_module_t* expert_q931;
3915
3916 ett[0] = &ett_q931;
3917 ett[1] = &ett_q931_segments;
3918 ett[2] = &ett_q931_segment;
3919
3920 last_offset = NUM_INDIVIDUAL_ELEMS;
3921
3922 for (i=0; i < NUM_IE; i++, last_offset++)
3923 {
3924 ett_q931_ie[i] = -1;
3925 ett[last_offset] = &ett_q931_ie[i];
3926 }
3927
3928 proto_q931 = proto_register_protocol("Q.931", "Q.931", "q931");
3929 proto_register_field_array (proto_q931, hf, array_length(hf));
3930 proto_register_subtree_array(ett, array_length(ett));
3931 expert_q931 = expert_register_protocol(proto_q931);
3932 expert_register_field_array(expert_q931, ei, array_length(ei));
3933
3934 reassembly_table_register(&q931_reassembly_table,
3935 &addresses_reassembly_table_functions);
3936
3937 q931_handle = register_dissector("q931", dissect_q931, proto_q931);
3938 q931_tpkt_handle = register_dissector("q931.tpkt", dissect_q931_tpkt, proto_q931);
3939 q931_tpkt_pdu_handle = create_dissector_handle(dissect_q931_tpkt_pdu,
3940 proto_q931);
3941 q931_over_ip_handle = register_dissector("q931.over_ip", dissect_q931_over_ip, proto_q931);
3942 register_dissector("q931.ie", dissect_q931_ie_cs0, proto_q931);
3943 register_dissector("q931.ie.cs7", dissect_q931_ie_cs7, proto_q931);
3944
3945 /* subdissector code */
3946 codeset_dissector_table = register_dissector_table("q931.codeset", "Q.931 Codeset", proto_q931, FT_UINT8, BASE_HEX);
3947 ie_dissector_table = register_dissector_table("q931.ie", "Q.931 IE", proto_q931, FT_UINT16, BASE_HEX);
3948 q931_user_heur_subdissector_list = register_heur_dissector_list("q931_user", proto_q931);
3949
3950 q931_module = prefs_register_protocol(proto_q931, NULL);
3951 prefs_register_bool_preference(q931_module, "desegment_h323_messages",
3952 "Reassemble Q.931 messages spanning multiple TCP segments",
3953 "Whether the Q.931 dissector should reassemble messages spanning multiple TCP segments."
3954 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
3955 &q931_desegment);
3956 prefs_register_bool_preference(q931_module, "reassembly",
3957 "Reassemble segmented Q.931 messages",
3958 "Reassemble segmented Q.931 messages (Q.931 - Annex H)",
3959 &q931_reassembly);
3960 prefs_register_bool_preference(q931_module, "iso_iec_cause_coding",
3961 "Decode ISO/IEC cause coding standard as ITU-T",
3962 "Decode ISO/IEC cause coding standard as ITU-T",
3963 &g931_iso_iec_cause);
3964 /* Register for tapping */
3965 q931_tap = register_tap("q931");
3966 }
3967
3968 void
proto_reg_handoff_q931(void)3969 proto_reg_handoff_q931(void)
3970 {
3971 dissector_add_uint("lapd.sapi", LAPD_SAPI_Q931, q931_handle);
3972 dissector_add_uint("sctp.ppi", H323_PAYLOAD_PROTOCOL_ID, q931_over_ip_handle);
3973 dissector_add_uint("osinl.incl", NLPID_Q_931, q931_handle);
3974
3975 /*
3976 * Attempt to get a handle for the H.225 dissector.
3977 * If we can't, the handle we get is null, and we'll just
3978 * dissect putatively-H.255 Call Signaling stuff as User
3979 * Information.
3980 */
3981 h225_handle = find_dissector_add_dependency("h225", proto_q931);
3982
3983 /*
3984 * For H.323.
3985 */
3986 heur_dissector_add("tcp", dissect_q931_tpkt_heur, "Q.931 over TPKT over TCP", "q931_tcp", proto_q931, HEURISTIC_ENABLE);
3987 }
3988
reset_q931_packet_info(q931_packet_info * pi)3989 static void reset_q931_packet_info(q931_packet_info *pi)
3990 {
3991 if(pi == NULL) {
3992 return;
3993 }
3994
3995 pi->calling_number = NULL;
3996 pi->called_number = NULL;
3997 pi->cause_value = 0xFF;
3998 pi->crv = -1;
3999 }
4000
4001 /*
4002 * Editor modelines - https://www.wireshark.org/tools/modelines.html
4003 *
4004 * Local variables:
4005 * c-basic-offset: 4
4006 * tab-width: 8
4007 * indent-tabs-mode: nil
4008 * End:
4009 *
4010 * vi: set shiftwidth=4 tabstop=8 expandtab:
4011 * :indentSize=4:tabSize=8:noTabs=true:
4012 */
4013