2 * Routines for Q.931 frame disassembly
3 * Guy Harris <guy@alum.mit.edu>
7 * Modified by Andreas Sikkema for possible use with H.323
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include <epan/packet.h>
36 #include <epan/strutil.h>
37 #include <epan/nlpid.h>
38 #include "packet-q931.h"
39 #include "packet-e164.h"
40 #include <epan/prefs.h>
41 #include <epan/reassemble.h>
42 #include <epan/emem.h>
44 #include <epan/sctpppids.h>
45 #include <epan/lapd_sapi.h>
46 #include "packet-tpkt.h"
51 * http://www.acacia-net.com/Clarinet/Protocol/q9313svn.htm
52 * http://www.acacia-net.com/Clarinet/Protocol/q9311sc3.htm
53 * http://www.acacia-net.com/Clarinet/Protocol/q9317oz7.htm
54 * http://www.protocols.com/pbook/isdn.htm
55 * http://freesoft.org/CIE/Topics/126.htm
56 * http://noc.comstar.ru/miscdocs/ascend-faq-cause-codes.html
57 * http://www.andrews-arnold.co.uk/isdn/q931cause.html
58 * http://www.tulatelecom.ru/staff/german/DSSHelp/MessList/InfEl/InfElList.html
60 static void reset_q931_packet_info(q931_packet_info *pi);
61 static gboolean have_valid_q931_pi=FALSE;
62 static q931_packet_info *q931_pi=NULL;
63 static int q931_tap = -1;
65 static int proto_q931 = -1;
66 static int hf_q931_discriminator = -1;
67 static int hf_q931_coding_standard = -1;
68 static int hf_q931_interpretation = -1;
69 static int hf_q931_pres_meth_prot_prof = -1;
70 static int hf_q931_high_layer_characteristics = -1;
71 static int hf_q931_extended_high_layer_characteristics = -1;
72 static int hf_q931_extended_audiovisual_characteristics = -1;
73 static int hf_q931_information_transfer_capability = -1;
74 static int hf_q931_transfer_mode = -1;
75 static int hf_q931_information_transfer_rate = -1;
76 static int hf_q931_layer_ident = -1;
77 static int hf_q931_uil1 = -1;
78 static int hf_q931_call_ref_len = -1;
79 static int hf_q931_call_ref_flag = -1;
80 static int hf_q931_call_ref = -1;
81 static int hf_q931_message_type = -1;
82 static int hf_q931_maintenance_message_type = -1;
83 static int hf_q931_segment_type = -1;
84 static int hf_q931_cause_location = -1;
85 static int hf_q931_cause_value = -1;
86 static int hf_q931_number_type = -1;
87 static int hf_q931_numbering_plan = -1;
88 static int hf_q931_extension_ind = -1;
89 static int hf_q931_calling_party_number = -1;
90 static int hf_q931_called_party_number = -1;
91 static int hf_q931_connected_number = -1;
92 static int hf_q931_redirecting_number = -1;
93 static int hf_q931_screening_ind = -1;
94 static int hf_q931_presentation_ind = -1;
96 /* fields for Channel Indentification IE */
97 static int hf_q931_channel_interface_explicit = -1;
98 static int hf_q931_channel_interface_type = -1;
99 static int hf_q931_channel_exclusive = -1;
100 static int hf_q931_channel_dchan = -1;
101 static int hf_q931_channel_selection_bri = -1;
102 static int hf_q931_channel_selection_pri = -1;
103 static int hf_q931_channel_map = -1;
104 static int hf_q931_channel_element_type = -1;
105 static int hf_q931_channel_number = -1;
108 static int hf_q931_segments = -1;
109 static int hf_q931_segment = -1;
110 static int hf_q931_segment_overlap = -1;
111 static int hf_q931_segment_overlap_conflict = -1;
112 static int hf_q931_segment_multiple_tails = -1;
113 static int hf_q931_segment_too_long_segment = -1;
114 static int hf_q931_segment_error = -1;
115 static int hf_q931_reassembled_in = -1;
116 static int hf_q931_reassembled_length = -1;
118 static gint ett_q931 = -1;
119 static gint ett_q931_ie = -1;
121 static gint ett_q931_segments = -1;
122 static gint ett_q931_segment = -1;
124 static const fragment_items q931_frag_items = {
130 &hf_q931_segment_overlap,
131 &hf_q931_segment_overlap_conflict,
132 &hf_q931_segment_multiple_tails,
133 &hf_q931_segment_too_long_segment,
134 &hf_q931_segment_error,
135 &hf_q931_reassembled_in,
136 &hf_q931_reassembled_length,
140 /* Tables for reassembly of fragments. */
141 static GHashTable *q931_fragment_table = NULL;
142 static GHashTable *q931_reassembled_table = NULL;
145 static gboolean q931_reassembly = TRUE;
147 static dissector_table_t codeset_dissector_table;
148 static dissector_table_t ie_dissector_table;
150 /* desegmentation of Q.931 over TPKT over TCP */
151 static gboolean q931_desegment = TRUE;
154 static dissector_handle_t h225_handle;
155 static dissector_handle_t q931_tpkt_handle;
156 static dissector_handle_t q931_tpkt_pdu_handle;
157 static dissector_handle_t data_handle = NULL;
159 static heur_dissector_list_t q931_user_heur_subdissector_list;
162 dissect_q931_IEs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root_tree,
163 proto_tree *q931_tree, gboolean is_over_ip, int offset, int initial_codeset);
165 const value_string q931_message_type_vals[] = {
166 /* 0 */ { Q931_ESCAPE, "ESCAPE" },
167 /* 1 */ { Q931_ALERTING, "ALERTING" },
168 /* 2 */ { Q931_CALL_PROCEEDING, "CALL PROCEEDING" },
169 /* 3 */ { Q931_PROGRESS, "PROGRESS" },
170 /* 5 */ { Q931_SETUP, "SETUP" },
171 /* 6 */ { Q931_GROUIP_SERVICE, "GROUP SERVICE" },
172 /* 7 */ { Q931_CONNECT, "CONNECT" },
173 /* 8 */ { Q931_RESYNC_REQ, "RESYNC REQ" },
174 /* 9 */ { Q931_RESYNC_RESP, "RESYNC RESP" },
175 /* 10 */ { Q931_VERSION, "VERSION" },
176 /* 11 */ { Q931_GROUIP_SERVICE_ACK, "GROUP SERVICE ACK" },
177 /* 13 */ { Q931_SETUP_ACK, "SETUP ACKNOWLEDGE" },
178 /* 15 */ { Q931_CONNECT_ACK, "CONNECT ACKNOWLEDGE" },
179 /* 32 */ { Q931_USER_INFORMATION, "USER INFORMATION" },
180 /* 33 */ { Q931_SUSPEND_REJECT, "SUSPEND REJECT" },
181 /* 34 */ { Q931_RESUME_REJECT, "RESUME REJECT" },
182 /* 36 */ { Q931_HOLD, "HOLD" },
183 /* 37 */ { Q931_SUSPEND, "SUSPEND" },
184 /* 38 */ { Q931_RESUME, "RESUME" },
185 /* 40 */ { Q931_HOLD_ACK, "HOLD_ACKNOWLEDGE" },
186 /* 45 */ { Q931_SUSPEND_ACK, "SUSPEND ACKNOWLEDGE" },
187 /* 46 */ { Q931_RESUME_ACK, "RESUME ACKNOWLEDGE" },
188 /* 48 */ { Q931_HOLD_REJECT, "HOLD_REJECT" },
189 /* 49 */ { Q931_RETRIEVE, "RETRIEVE" },
190 /* 51 */ { Q931_RETRIEVE_ACK, "RETRIEVE ACKNOWLEDGE" },
191 /* 55 */ { Q931_RETRIEVE_REJECT, "RETRIEVE REJECT" },
192 /* 64 */ { Q931_DETACH, "DETACH" },
193 /* 69 */ { Q931_DISCONNECT, "DISCONNECT" },
194 /* 70 */ { Q931_RESTART, "RESTART" },
195 /* 72 */ { Q931_DETACH_ACKNOWLEDGE, "DETACH ACKNOWLEDGE" },
196 /* 77 */ { Q931_RELEASE, "RELEASE" },
197 /* 78 */ { Q931_RESTART_ACK, "RESTART ACKNOWLEDGE" },
198 /* 90 */ { Q931_RELEASE_COMPLETE, "RELEASE COMPLETE" },
199 /* 96 */ { Q931_SEGMENT, "SEGMENT" },
200 /* 98 */ { Q931_FACILITY, "FACILITY" },
201 /*100 */ { Q931_REGISTER, "REGISTER" },
202 /*106 */ { Q931_FACILITY_ACKNOWLEDGE, "FACILITY ACKNOWLEDGE" },
203 /*110 */ { Q931_NOTIFY, "NOTIFY" },
204 /*114 */ { Q931_FACILITY_REJECT, "FACILITY REJECT" },
205 /*117 */ { Q931_STATUS_ENQUIRY, "STATUS ENQUIRY" },
206 /*121 */ { Q931_CONGESTION_CONTROL, "CONGESTION CONTROL" },
207 /*123 */ { Q931_INFORMATION, "INFORMATION" },
208 /*125 */ { Q931_STATUS, "STATUS" },
212 static value_string_ext q931_message_type_vals_ext = VALUE_STRING_EXT_INIT(q931_message_type_vals);
214 static const value_string dms_message_type_vals[] = {
215 { DMS_SERVICE_ACKNOWLEDGE, "SERVICE ACKNOWLEDGE" },
216 { DMS_SERVICE, "SERVICE" },
221 * NOTE For call reference flag (octet 2)
223 * 0 The message is sent from the side that originates the call reference
224 * 1 The message is sent to the side that originates the call reference
226 static const true_false_string tfs_call_ref_flag = {
227 "Message sent to originating side",
228 "Message sent from originating side"
231 static const true_false_string tfs_interface_type = {
232 "Primary rate interface",
233 "Basic rate interface"
236 static const true_false_string tfs_channel_exclusive = {
237 "Exclusive; only the indicated channel is acceptable",
238 "Indicated channel is preferred"
241 static const true_false_string tfs_channel_map = {
242 "Channel indicated by slot map",
243 "Channel indicated by number"
247 * Information elements.
250 /* Shifted codeset values */
260 #define Q931_IE_SO_MASK 0x80 /* single-octet/variable-length mask */
264 #define Q931_IE_SO_IDENTIFIER_MASK 0xf0 /* IE identifier mask */
265 #define Q931_IE_SO_IDENTIFIER_SHIFT 4 /* IE identifier shift */
266 #define Q931_IE_SO_IE_MASK 0x0F /* IE mask */
268 #define Q931_IE_SHIFT 0x90
269 #define Q931_IE_SHIFT_NON_LOCKING 0x08 /* non-locking shift */
270 #define Q931_IE_SHIFT_CODESET 0x07 /* codeset */
272 #define Q931_IE_MORE_DATA_OR_SEND_COMP 0xA0 /* More Data or Sending Complete */
273 #define Q931_IE_MORE_DATA 0xA0
274 #define Q931_IE_SENDING_COMPLETE 0xA1
276 #define Q931_IE_CONGESTION_LEVEL 0xB0
277 #define Q931_IE_REPEAT_INDICATOR 0xD0
280 * Variable-length IEs.
282 #define Q931_IE_VL_EXTENSION 0x80 /* Extension flag */
283 /* extension bit. The bit value "0" indicates that the octet continues through the */
284 /* next octet. The bit value "1" indicates that this octet is the last octet */
286 static const true_false_string q931_extension_ind_value = {
288 "information continues through the next octet"
293 * Codeset 0 (default).
295 #define Q931_IE_SEGMENTED_MESSAGE 0x00
296 #define Q931_IE_CHANGE_STATUS 0x01
297 #define Q931_IE_BEARER_CAPABILITY 0x04
298 #define Q931_IE_CAUSE 0x08
299 #define Q931_IE_CALL_IDENTITY 0x10
300 #define Q931_IE_CALL_STATE 0x14
301 #define Q931_IE_CHANNEL_IDENTIFICATION 0x18
302 #define Q931_IE_FACILITY 0x1C
303 #define Q931_IE_PROGRESS_INDICATOR 0x1E
304 #define Q931_IE_NETWORK_SPECIFIC_FACIL 0x20 /* Network Specific Facilities */
305 #define Q931_IE_NOTIFICATION_INDICATOR 0x27
306 #define Q931_IE_DISPLAY 0x28
307 #define Q931_IE_DATE_TIME 0x29
308 #define Q931_IE_KEYPAD_FACILITY 0x2C
309 #define Q931_IE_INFORMATION_REQUEST 0x32
310 #define Q931_IE_SIGNAL 0x34
311 #define Q931_IE_SWITCHHOOK 0x36
312 #define Q931_IE_FEATURE_ACTIVATION 0x38
313 #define Q931_IE_FEATURE_INDICATION 0x39
314 #define Q931_IE_ENDPOINT_IDENTIFIER 0x3B
315 #define Q931_IE_SERVICE_PROFILE_ID 0x3A
316 #define Q931_IE_INFORMATION_RATE 0x40
317 #define Q931_IE_E2E_TRANSIT_DELAY 0x42 /* End-to-end Transit Delay */
318 #define Q931_IE_TD_SELECTION_AND_INT 0x43 /* Transit Delay Selection and Indication */
319 #define Q931_IE_PL_BINARY_PARAMETERS 0x44 /* Packet layer binary parameters */
320 #define Q931_IE_PL_WINDOW_SIZE 0x45 /* Packet layer window size */
321 #define Q931_IE_PACKET_SIZE 0x46 /* Packet size */
322 #define Q931_IE_CUG 0x47 /* Closed user group */
323 #define Q931_IE_REVERSE_CHARGE_IND 0x4A /* Reverse charging indication */
324 #define Q931_IE_CONNECTED_NUMBER_DEFAULT 0x4C /* Connected Number */
325 #define Q931_IE_INTERFACE_SERVICE 0x66 /* q931+ Interface Service */
326 #define Q931_IE_CHANNEL_STATUS 0x67 /* q931+ Channel Status */
327 #define Q931_IE_VERSION_INFO 0x68 /* q931+ Version Info */
328 #define Q931_IE_CALLING_PARTY_NUMBER 0x6C /* Calling Party Number */
329 #define Q931_IE_CALLING_PARTY_SUBADDR 0x6D /* Calling Party Subaddress */
330 #define Q931_IE_CALLED_PARTY_NUMBER 0x70 /* Called Party Number */
331 #define Q931_IE_CALLED_PARTY_SUBADDR 0x71 /* Called Party Subaddress */
332 #define Q931_IE_REDIRECTING_NUMBER 0x74
333 #define Q931_IE_REDIRECTION_NUMBER 0x76
334 #define Q931_IE_TRANSIT_NETWORK_SEL 0x78 /* Transit Network Selection */
335 #define Q931_IE_RESTART_INDICATOR 0x79
336 #define Q931_IE_LOW_LAYER_COMPAT 0x7C /* Low-Layer Compatibility */
337 #define Q931_IE_HIGH_LAYER_COMPAT 0x7D /* High-Layer Compatibility */
338 #define Q931_IE_USER_USER 0x7E /* User-User */
339 #define Q931_IE_ESCAPE 0x7F /* Escape for extension */
344 #define Q931_IE_CONNECTED_NUMBER 0x8C
345 #define Q931_IE_CONNECTED_SUBADDR 0x8D
348 * Codeset 5 (National-specific) Belgium.
350 #define Q931_IE_CHARGING_ADVICE 0x1A
353 * Codeset 5 (National-specific) Bellcore National ISDN.
355 #define Q931_IE_OPERATOR_SYSTEM_ACCESS 0x1D
358 * Codeset 5 ETSI ETS 300 192
360 #define Q931_IE_PARTY_CATEGORY 0x32
363 * Codeset 6 (Network-specific) Belgium.
365 /* 0x1A is Charging Advice, as with Codeset 5 */
366 #define Q931_IE_REDIRECTING_NUMBER 0x74
369 * Codeset 6 (Network-specific) FT-Numeris.
371 /* 0x1D is User Capability */
374 * Codeset 6 (Network-specific) Bellcore National ISDN.
376 #define Q931_IE_REDIRECTING_SUBADDR 0x75 /* Redirecting Subaddress */
377 /* 0x76 is Redirection Number, but that's also Codeset 0 */
378 #define Q931_IE_CALL_APPEARANCE 0x7B
381 static const value_string q931_info_element_vals0[] = {
382 { Q931_IE_SEGMENTED_MESSAGE, "Segmented message" },
383 { Q931_IE_CHANGE_STATUS, "Change status" },
384 { Q931_IE_BEARER_CAPABILITY, "Bearer capability" },
385 { Q931_IE_CAUSE, "Cause" },
386 { Q931_IE_CALL_IDENTITY, "Call identity" },
387 { Q931_IE_CALL_STATE, "Call state" },
388 { Q931_IE_CHANNEL_IDENTIFICATION, "Channel identification" },
389 { Q931_IE_FACILITY, "Facility" },
390 { Q931_IE_PROGRESS_INDICATOR, "Progress indicator" },
391 { Q931_IE_NETWORK_SPECIFIC_FACIL, "Network specific facilities" },
392 { Q931_IE_NOTIFICATION_INDICATOR, "Notification indicator" },
393 { Q931_IE_DISPLAY, "Display" },
394 { Q931_IE_DATE_TIME, "Date/Time" },
395 { Q931_IE_KEYPAD_FACILITY, "Keypad facility" },
396 { Q931_IE_INFORMATION_REQUEST, "Information request" },
397 { Q931_IE_SIGNAL, "Signal" },
398 { Q931_IE_SWITCHHOOK, "Switchhook" },
399 { Q931_IE_FEATURE_ACTIVATION, "Feature activation" },
400 { Q931_IE_FEATURE_INDICATION, "Feature Indication" },
401 { Q931_IE_ENDPOINT_IDENTIFIER, "Endpoint identifier" },
402 { Q931_IE_SERVICE_PROFILE_ID, "Service profile ID" },
403 { Q931_IE_INFORMATION_RATE, "Information rate" },
404 { Q931_IE_E2E_TRANSIT_DELAY, "End-to-end transit delay" },
405 { Q931_IE_TD_SELECTION_AND_INT, "Transit delay selection and indication" },
406 { Q931_IE_PL_BINARY_PARAMETERS, "Packet layer binary parameters" },
407 { Q931_IE_PL_WINDOW_SIZE, "Packet layer window size" },
408 { Q931_IE_PACKET_SIZE, "Packet size" },
409 { Q931_IE_CUG, "Closed user group" },
410 { Q931_IE_REVERSE_CHARGE_IND, "Reverse charging indication" },
411 { Q931_IE_CONNECTED_NUMBER_DEFAULT, "Connected number" },
412 { Q931_IE_INTERFACE_SERVICE, "Interface Service" },
413 { Q931_IE_CHANNEL_STATUS, "Channel Status" },
414 { Q931_IE_VERSION_INFO, "Version Info" },
415 { Q931_IE_CALLING_PARTY_NUMBER, "Calling party number" },
416 { Q931_IE_CALLING_PARTY_SUBADDR, "Calling party subaddress" },
417 { Q931_IE_CALLED_PARTY_NUMBER, "Called party number" },
418 { Q931_IE_CALLED_PARTY_SUBADDR, "Called party subaddress" },
419 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
420 { Q931_IE_REDIRECTION_NUMBER, "Redirection number" },
421 { Q931_IE_TRANSIT_NETWORK_SEL, "Transit network selection" },
422 { Q931_IE_RESTART_INDICATOR, "Restart indicator" },
423 { Q931_IE_LOW_LAYER_COMPAT, "Low-layer compatibility" },
424 { Q931_IE_HIGH_LAYER_COMPAT, "High-layer compatibility" },
425 { Q931_IE_USER_USER, "User-user" },
426 { Q931_IE_ESCAPE, "Escape" },
427 { Q931_IE_CONNECTED_NUMBER, "Connected number" },
428 { Q931_IE_CONNECTED_SUBADDR, "Connected subaddress" },
433 static const value_string q931_info_element_vals1[] = {
437 static const value_string q931_info_element_vals2[] = {
441 static const value_string q931_info_element_vals3[] = {
445 static const value_string q931_info_element_vals4[] = {
449 static const value_string q931_info_element_vals5[] = {
450 { Q931_IE_CHARGING_ADVICE, "Charging advice" },
451 { Q931_IE_OPERATOR_SYSTEM_ACCESS, "Operator system access" },
452 { Q931_IE_PARTY_CATEGORY, "Party category"},
456 static const value_string q931_info_element_vals6[] = {
457 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
458 { Q931_IE_REDIRECTING_SUBADDR, "Redirecting subaddress" },
459 { Q931_IE_CALL_APPEARANCE, "Call appearance" },
460 { Q931_IE_DISPLAY, "Avaya Display" }, /* if Avaya codeset to send display = 6 */
464 static const value_string q931_info_element_vals7[] = {
469 #define NUM_INFO_ELEMENT_VALS (Q931_IE_SHIFT_CODESET+1)
470 static const value_string *q931_info_element_vals[NUM_INFO_ELEMENT_VALS] = {
471 q931_info_element_vals0,
472 q931_info_element_vals1,
473 q931_info_element_vals2,
474 q931_info_element_vals3,
475 q931_info_element_vals4,
476 q931_info_element_vals5,
477 q931_info_element_vals6,
478 q931_info_element_vals7,
481 static const value_string q931_congestion_level_vals[] = {
482 { 0x0, "Receiver ready" },
483 { 0xF, "Receiver not ready" },
487 static const value_string q931_repeat_indication_vals[] = {
488 { 0x2, "Prioritized list" },
493 * ITU-standardized coding.
495 #define Q931_ITU_STANDARDIZED_CODING 0x00
498 * Dissect a Segmented message information element.
501 dissect_q931_segmented_message_ie(tvbuff_t *tvb, int offset, int len,
505 proto_tree_add_text(tree, tvb, offset, len,
506 "Segmented message: length is %d, should be 2", len);
509 if (tvb_get_guint8(tvb, offset) & 0x80) {
510 proto_tree_add_text(tree, tvb, offset, 1,
511 "First segment: %u segments remaining",
512 tvb_get_guint8(tvb, offset) & 0x7F);
514 proto_tree_add_text(tree, tvb, offset, 1,
515 "Not first segment: %u segments remaining",
516 tvb_get_guint8(tvb, offset) & 0x7F);
518 proto_tree_add_item(tree, hf_q931_segment_type, tvb, offset + 1, 1, FALSE);
522 * Dissect a Bearer capability or Low-layer compatibility information element.
524 static const value_string q931_coding_standard_vals[] = {
525 { 0x0, "ITU-T standardized coding" },
526 { 0x1, "ISO/IEC standard" },
527 { 0x2, "National standard" },
528 { 0x3, "Standard defined for this particular network" },
532 static const value_string q931_information_transfer_capability_vals[] = {
534 { 0x08, "Unrestricted digital information" },
535 { 0x09, "Restricted digital information" },
536 { 0x10, "3.1 kHz audio" },
537 { 0x11, "Unrestricted digital information with tones/announcements" },
542 static const value_string q931_transfer_mode_vals[] = {
543 { 0x00, "Circuit mode" },
544 { 0x02, "Packet mode" },
548 #define Q931_IT_RATE_MULTIRATE 0x18
550 static const value_string q931_information_transfer_rate_vals[] = {
551 { 0x00, "Packet mode" },
552 { 0x10, "64 kbit/s" },
553 { 0x11, "2 x 64 kbit/s" },
554 { 0x13, "384 kbit/s" },
555 { 0x15, "1536 kbit/s" },
556 { 0x17, "1920 kbit/s" },
557 { Q931_IT_RATE_MULTIRATE, "Multirate (64 kbit/s base rate)" },
562 * Values 0x0a and 0x0b added from Q.931 Amendment 1 (12/2002)
564 static const value_string q931_uil1_vals[] = {
565 { 0x01, "V.110/I.460/X.30 rate adaption" },
566 { 0x02, "Recommendation G.711 u-law" },
567 { 0x03, "Recommendation G.711 A-law" },
568 { 0x04, "Recommendation G.721 32 kbit/s ADPCM and Recommendation I.460" },
569 { 0x05, "Recommendation H.221 and H.242" },
570 { 0x06, "Recommendation H.223 and H.245" },
571 { 0x07, "Non-ITU-T-standardized rate adaption" },
572 { 0x08, "V.120 rate adaption" },
573 { 0x09, "X.31 HDLC flag stuffing" },
574 { 0x0a, "Recommendation G.728 LD-CELP" },
575 { 0x0b, "Recommendation G.729 CS-ACELP" },
578 static value_string_ext q931_uil1_vals_ext = VALUE_STRING_EXT_INIT(q931_uil1_vals);
580 static const value_string q931_l1_user_rate_vals[] = {
581 { 0x00, "Rate indicated by E-bits" },
582 { 0x01, "0.6 kbit/s" },
583 { 0x02, "1.2 kbit/s" },
584 { 0x03, "2.4 kbit/s" },
585 { 0x04, "3.6 kbit/s" },
586 { 0x05, "4.8 kbit/s" },
587 { 0x06, "7.2 kbit/s" },
588 { 0x07, "8 kbit/s" },
589 { 0x08, "9.6 kbit/s" },
590 { 0x09, "14.4 kbit/s" },
591 { 0x0A, "16 kbit/s" },
592 { 0x0B, "19.2 kbit/s" },
593 { 0x0C, "32 kbit/s" },
594 { 0x0E, "48 kbit/s" },
595 { 0x0F, "56 kbit/s" },
596 { 0x10, "64 kbit/s "},
597 { 0x15, "0.1345 kbit/s" },
598 { 0x16, "0.100 kbit/s" },
599 { 0x17, "0.075/1.2 kbit/s" },
600 { 0x18, "1.2/0.075 kbit/s" },
601 { 0x19, "0.050 kbit/s" },
602 { 0x1A, "0.075 kbit/s" },
603 { 0x1B, "0.110 kbit/s" },
604 { 0x1C, "0.150 kbit/s" },
605 { 0x1D, "0.200 kbit/s" },
606 { 0x1E, "0.300 kbit/s" },
607 { 0x1F, "12 kbit/s" },
610 static value_string_ext q931_l1_user_rate_vals_ext = VALUE_STRING_EXT_INIT(q931_l1_user_rate_vals);
612 static const value_string q931_l1_intermediate_rate_vals[] = {
613 { 0x20, "8 kbit/s" },
614 { 0x40, "16 kbit/s" },
615 { 0x60, "32 kbit/s" },
619 static const value_string q931_l1_stop_bits_vals[] = {
626 static const value_string q931_l1_data_bits_vals[] = {
633 static const value_string q931_l1_parity_vals[] = {
637 { 0x04, "Forced to 0" },
638 { 0x05, "Forced to 1" },
642 static const value_string q931_l1_modem_type_vals[] = {
645 { 0x13, "V.22 bis" },
648 { 0x16, "V.26 bis" },
649 { 0x17, "V.26 ter" },
651 { 0x19, "V.27 bis" },
652 { 0x1A, "V.27 ter" },
658 static value_string_ext q931_l1_modem_type_vals_ext = VALUE_STRING_EXT_INIT(q931_l1_modem_type_vals);
660 #define Q931_UIL2_USER_SPEC 0x10
662 static const value_string q931_uil2_vals[] = {
663 { 0x01, "Basic mode ISO 1745" },
664 { 0x02, "Q.921/I.441" }, /* LAPD */
665 { 0x06, "X.25, link layer" }, /* LAPB */
666 { 0x07, "X.25 multilink" }, /* or 0x0F? */
667 { 0x08, "T.71 Extended LAPB" },
668 { 0x09, "HDLC ARM" },
669 { 0x0A, "HDLC NRM" },
670 { 0x0B, "HDLC ABM" },
671 { 0x0C, "ISO 8802/2 LLC" },
672 { 0x0D, "X.75 Single Link Procedure" },
674 { 0x0F, "Core aspects of Q.922" },
675 { Q931_UIL2_USER_SPEC, "User-specified" },
676 { 0x11, "ISO 7776 DTE-DTE operation" },
679 static value_string_ext q931_uil2_vals_ext = VALUE_STRING_EXT_INIT(q931_uil2_vals);
681 static const value_string q931_mode_vals[] = {
682 { 0x20, "Normal mode" },
683 { 0x40, "Extended mode" },
687 #define Q931_UIL3_X25_PL 0x06
688 #define Q931_UIL3_ISO_8208 0x07 /* X.25-based */
689 #define Q931_UIL3_X223 0x08 /* X.25-based */
690 #define Q931_UIL3_TR_9577 0x0B
691 #define Q931_UIL3_USER_SPEC 0x10
693 static const value_string q931_uil3_vals[] = {
694 { 0x02, "Q.931/I.451" },
695 { Q931_UIL3_X25_PL, "X.25, packet layer" },
696 { Q931_UIL3_ISO_8208, "ISO/IEC 8208" },
697 { Q931_UIL3_X223, "X.223/ISO 8878" },
698 { 0x09, "ISO/IEC 8473" },
700 { Q931_UIL3_TR_9577, "ISO/IEC TR 9577" },
701 { Q931_UIL3_USER_SPEC, "User-specified" },
706 dissect_q931_protocol_discriminator(tvbuff_t *tvb, int offset, proto_tree *tree)
708 unsigned int discriminator = tvb_get_guint8(tvb, offset);
710 if (discriminator == NLPID_DMS) {
711 proto_tree_add_uint_format(tree, hf_q931_discriminator,
712 tvb, offset, 1, discriminator,
713 "Protocol discriminator: Maintenance messages");
714 } else if (discriminator == NLPID_Q_931) {
715 proto_tree_add_uint_format(tree, hf_q931_discriminator,
716 tvb, offset, 1, discriminator,
717 "Protocol discriminator: Q.931");
718 } else if (discriminator == NLPID_Q_2931) {
719 proto_tree_add_uint_format(tree, hf_q931_discriminator,
720 tvb, offset, 1, discriminator,
721 "Protocol discriminator: Q.2931");
722 } else if ((discriminator >= 16 && discriminator < 63)
723 || ((discriminator >= 80) && (discriminator < 254))) {
724 proto_tree_add_uint_format(tree, hf_q931_discriminator,
725 tvb, offset, 1, discriminator,
726 "Protocol discriminator: Network layer or layer 3 protocol (0x%02X)",
728 } else if (discriminator >= 64 && discriminator <= 79) {
729 proto_tree_add_uint_format(tree, hf_q931_discriminator,
730 tvb, offset, 1, discriminator,
731 "Protocol discriminator: National use (0x%02X)",
734 proto_tree_add_uint_format(tree, hf_q931_discriminator,
735 tvb, offset, 1, discriminator,
736 "Protocol discriminator: Reserved (0x%02X)",
741 static const value_string q931_bearer_capability_layer_ident_vals[] = {
742 { 0x01, "Layer 1 identifier" },
743 { 0x02, "Layer 2 identifier" },
744 { 0x03, "Layer 3 identifier" },
749 dissect_q931_bearer_capability_ie(tvbuff_t *tvb, int offset, int len,
753 guint8 coding_standard;
756 guint8 uil2_protocol;
757 guint8 uil3_protocol;
762 octet = tvb_get_guint8(tvb, offset);
763 coding_standard = octet & 0x60;
764 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
766 * We don't know how the bearer capability is encoded,
767 * so just dump it as data and be done with it.
769 proto_tree_add_text(tree, tvb, offset,
771 tvb_bytes_to_str(tvb, offset, len));
772 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
773 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
776 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
777 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
778 proto_tree_add_uint(tree, hf_q931_information_transfer_capability, tvb, offset, 1, octet);
783 * XXX - only in Low-layer compatibility information element.
785 if (!(octet & Q931_IE_VL_EXTENSION)) {
788 octet = tvb_get_guint8(tvb, offset);
789 proto_tree_add_text(tree, tvb, offset, 1,
790 "Out-band negotiation %spossible",
791 (octet & 0x40) ? "" : "not ");
798 octet = tvb_get_guint8(tvb, offset);
799 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
800 proto_tree_add_uint(tree, hf_q931_transfer_mode, tvb, offset, 1, octet);
801 proto_tree_add_uint(tree, hf_q931_information_transfer_rate, tvb, offset, 1, octet);
802 it_rate = octet & 0x1F;
806 if (it_rate == Q931_IT_RATE_MULTIRATE) {
809 proto_tree_add_text(tree, tvb, offset, 1, "Rate multiplier: %u", tvb_get_guint8(tvb, offset));
816 octet = tvb_get_guint8(tvb, offset);
817 if ((octet & 0x60) == 0x20) {
819 * Layer 1 information.
821 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
822 proto_tree_add_uint(tree, hf_q931_layer_ident, tvb, offset, 1, octet);
823 proto_tree_add_uint(tree, hf_q931_uil1, tvb, offset, 1, octet);
827 if (octet & Q931_IE_VL_EXTENSION)
831 octet = tvb_get_guint8(tvb, offset);
832 proto_tree_add_text(tree, tvb, offset, 1,
834 (octet & 0x40) ? "Asynchronous" : "Synchronous");
835 proto_tree_add_text(tree, tvb, offset, 1,
836 "Layer 1 in-band negotiation is %spossible",
837 (octet & 0x20) ? "" : "not ");
838 proto_tree_add_text(tree, tvb, offset, 1,
840 val_to_str_ext(octet & 0x1F, &q931_l1_user_rate_vals_ext,
841 "Unknown (0x%02X)"));
845 if (octet & Q931_IE_VL_EXTENSION)
849 octet = tvb_get_guint8(tvb, offset);
850 proto_tree_add_text(tree, tvb, offset, 1,
851 "Intermediate rate: %s",
852 val_to_str(octet & 0x60, q931_l1_intermediate_rate_vals,
854 proto_tree_add_text(tree, tvb, offset, 1,
855 "%s to send data with network independent clock",
856 (octet & 0x10) ? "Required" : "Not required");
857 proto_tree_add_text(tree, tvb, offset, 1,
858 "%s accept data with network independent clock",
859 (octet & 0x08) ? "Can" : "Cannot");
860 proto_tree_add_text(tree, tvb, offset, 1,
861 "%s to send data with flow control mechanism",
862 (octet & 0x04) ? "Required" : "Not required");
863 proto_tree_add_text(tree, tvb, offset, 1,
864 "%s accept data with flow control mechanism",
865 (octet & 0x02) ? "Can" : "Cannot");
869 if (octet & Q931_IE_VL_EXTENSION)
873 octet = tvb_get_guint8(tvb, offset);
874 proto_tree_add_text(tree, tvb, offset, 1,
875 "Rate adaption header %sincluded",
876 (octet & 0x40) ? "" : "not ");
877 proto_tree_add_text(tree, tvb, offset, 1,
878 "Multiple frame establishment %ssupported",
879 (octet & 0x20) ? "" : "not ");
880 proto_tree_add_text(tree, tvb, offset, 1,
881 "%s mode of operation",
882 (octet & 0x10) ? "Protocol sensitive" : "Bit transparent");
883 proto_tree_add_text(tree, tvb, offset, 1,
885 "Full protocol negotiation" : "LLI = 256 only");
886 proto_tree_add_text(tree, tvb, offset, 1,
887 "Message originator is %s",
888 (octet & 0x04) ? "Assignor only" : "Default assignee");
889 proto_tree_add_text(tree, tvb, offset, 1,
890 "Negotiation is done %s",
891 (octet & 0x02) ? "in-band" : "out-of-band");
895 if (octet & Q931_IE_VL_EXTENSION)
899 octet = tvb_get_guint8(tvb, offset);
900 proto_tree_add_text(tree, tvb, offset, 1,
902 val_to_str(octet & 0x60, q931_l1_stop_bits_vals,
904 proto_tree_add_text(tree, tvb, offset, 1,
906 val_to_str(octet & 0x18, q931_l1_data_bits_vals,
908 proto_tree_add_text(tree, tvb, offset, 1,
910 val_to_str(octet & 0x07, q931_l1_parity_vals,
913 if (octet & Q931_IE_VL_EXTENSION)
917 octet = tvb_get_guint8(tvb, offset);
918 proto_tree_add_text(tree, tvb, offset, 1,
920 (octet & 0x40) ? "Full" : "Half");
921 modem_type = octet & 0x3F;
922 if (modem_type <= 0x5 ||
923 (modem_type >= 0x20 && modem_type <= 0x2F)) {
924 proto_tree_add_text(tree, tvb, offset, 1,
925 "Modem type: National use 0x%02X", modem_type);
926 } else if (modem_type >= 0x30) {
927 proto_tree_add_text(tree, tvb, offset, 1,
928 "Modem type: User specified 0x%02X", modem_type);
930 proto_tree_add_text(tree, tvb, offset, 1,
932 val_to_str_ext(modem_type, &q931_l1_modem_type_vals_ext,
933 "Unknown (0x%02X)"));
943 octet = tvb_get_guint8(tvb, offset);
944 if ((octet & 0x60) == 0x40) {
946 * Layer 2 information.
948 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
949 proto_tree_add_uint(tree, hf_q931_layer_ident, tvb, offset, 1, octet);
950 uil2_protocol = octet & 0x1F;
951 proto_tree_add_text(tree, tvb, offset, 1,
952 "User information layer 2 protocol: %s",
953 val_to_str_ext(uil2_protocol, &q931_uil2_vals_ext,
954 "Unknown (0x%02X)"));
959 * XXX - only in Low-layer compatibility information element.
961 if (octet & Q931_IE_VL_EXTENSION)
965 octet = tvb_get_guint8(tvb, offset);
966 if (uil2_protocol == Q931_UIL2_USER_SPEC) {
967 proto_tree_add_text(tree, tvb, offset, 1,
968 "User-specified layer 2 protocol information: 0x%02X",
971 proto_tree_add_text(tree, tvb, offset, 1,
973 val_to_str(octet & 0x60, q931_mode_vals,
974 "Unknown (0x%02X)"));
979 if (octet & Q931_IE_VL_EXTENSION)
983 octet = tvb_get_guint8(tvb, offset);
984 proto_tree_add_text(tree, tvb, offset, 1,
985 "Window size: %u k", octet & 0x7F);
994 octet = tvb_get_guint8(tvb, offset);
995 if ((octet & 0x60) == 0x60) {
997 * Layer 3 information.
999 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1000 proto_tree_add_uint(tree, hf_q931_layer_ident, tvb, offset, 1, octet);
1001 uil3_protocol = octet & 0x1F;
1002 proto_tree_add_text(tree, tvb, offset, 1,
1003 "User information layer 3 protocol: %s",
1004 val_to_str(uil3_protocol, q931_uil3_vals,
1005 "Unknown (0x%02X)"));
1011 * XXX - only in Low-layer compatibility information element.
1013 if (octet & Q931_IE_VL_EXTENSION)
1017 octet = tvb_get_guint8(tvb, offset);
1018 switch (uil3_protocol) {
1020 case Q931_UIL3_X25_PL:
1021 case Q931_UIL3_ISO_8208:
1022 case Q931_UIL3_X223:
1023 proto_tree_add_text(tree, tvb, offset, 1,
1025 val_to_str(octet & 0x60, q931_mode_vals,
1026 "Unknown (0x%02X)"));
1030 if (octet & Q931_IE_VL_EXTENSION)
1034 octet = tvb_get_guint8(tvb, offset);
1035 proto_tree_add_text(tree, tvb, offset, 1,
1036 "Default packet size: %u", octet & 0x0F);
1040 if (octet & Q931_IE_VL_EXTENSION)
1044 octet = tvb_get_guint8(tvb, offset);
1045 proto_tree_add_text(tree, tvb, offset, 1,
1046 "Packet window size: %u", octet & 0x7F);
1051 case Q931_UIL3_USER_SPEC:
1052 proto_tree_add_text(tree, tvb, offset, 1,
1053 "Default packet size: %u octets",
1054 1 << (octet & 0x0F));
1059 case Q931_UIL3_TR_9577:
1060 add_l3_info = (octet & 0x0F) << 4;
1061 if (octet & Q931_IE_VL_EXTENSION)
1065 octet = tvb_get_guint8(tvb, offset + 1);
1066 add_l3_info |= (octet & 0x0F);
1067 proto_tree_add_text(tree, tvb, offset, 2,
1068 "Additional layer 3 protocol information: %s",
1069 val_to_str(add_l3_info, nlpid_vals,
1070 "Unknown (0x%02X)"));
1081 * Dissect a Cause information element.
1085 static const value_string q931_cause_location_vals[] = {
1086 { 0x00, "User (U)" },
1087 { 0x01, "Private network serving the local user (LPN)" },
1088 { 0x02, "Public network serving the local user (LN)" },
1089 { 0x03, "Transit network (TN)" },
1090 { 0x04, "Public network serving the remote user (RLN)" },
1091 { 0x05, "Private network serving the remote user (RPN)" },
1092 { 0x06, "Unallocated code" },
1093 { 0x07, "International network (INTL)" },
1094 { 0x08, "Unallocated code" },
1095 { 0x09, "Unallocated code" },
1096 { 0x0A, "Network beyond interworking point (BI)" },
1099 value_string_ext q931_cause_location_vals_ext = VALUE_STRING_EXT_INIT(q931_cause_location_vals);
1101 static const value_string q931_cause_recommendation_vals[] = {
1105 { 0x05, "Q.1031/Q.1051" },
1110 * Cause codes for Cause.
1112 #define Q931_CAUSE_UNALLOC_NUMBER 0x01
1113 #define Q931_CAUSE_NO_ROUTE_TO_DEST 0x03
1114 #define Q931_CAUSE_CALL_REJECTED 0x15
1115 #define Q931_CAUSE_NUMBER_CHANGED 0x16
1116 #define Q931_CAUSE_ACCESS_INFO_DISC 0x2B
1117 #define Q931_CAUSE_QOS_UNAVAILABLE 0x31
1118 #define Q931_CAUSE_CHAN_NONEXISTENT 0x52
1119 #define Q931_CAUSE_INCOMPATIBLE_DEST 0x58
1120 #define Q931_CAUSE_MAND_IE_MISSING 0x60
1121 #define Q931_CAUSE_MT_NONEX_OR_UNIMPL 0x61
1122 #define Q931_CAUSE_IE_NONEX_OR_UNIMPL 0x63
1123 #define Q931_CAUSE_INVALID_IE_CONTENTS 0x64
1124 #define Q931_CAUSE_MSG_INCOMPAT_W_CS 0x65
1125 #define Q931_CAUSE_REC_TIMER_EXP 0x66
1127 static const value_string q931_cause_code_vals[] = {
1128 { 0x00, "Valid cause code not yet received" },
1129 { Q931_CAUSE_UNALLOC_NUMBER, "Unallocated (unassigned) number" },
1130 { 0x02, "No route to specified transit network" },
1131 { Q931_CAUSE_NO_ROUTE_TO_DEST, "No route to destination" },
1132 { 0x04, "Send special information tone" },
1133 { 0x05, "Misdialled trunk prefix" },
1134 { 0x06, "Channel unacceptable" },
1135 { 0x07, "Call awarded and being delivered in an established channel" },
1136 { 0x08, "Prefix 0 dialed but not allowed" },
1137 /* Q.850 - "Preemption" */
1138 { 0x09, "Prefix 1 dialed but not allowed" },
1139 /* Q.850 - "Preemption - circuit reserved for reuse" */
1140 { 0x0A, "Prefix 1 dialed but not required" },
1141 { 0x0B, "More digits received than allowed, call is proceeding" },
1142 { 0x0E, "QoR: ported number" },
1143 { 0x10, "Normal call clearing" },
1144 { 0x11, "User busy" },
1145 { 0x12, "No user responding" },
1146 { 0x13, "No answer from user (user alerted)" },
1147 { 0x14, "Subscriber absent" },
1148 { Q931_CAUSE_CALL_REJECTED, "Call rejected" },
1149 { Q931_CAUSE_NUMBER_CHANGED, "Number changed" },
1150 { 0x17, "Reverse charging rejected" },
1151 /* Q.850 - "Redirection to new destination" */
1152 { 0x18, "Call suspended" },
1153 /* Q.850 Amendment 1 - "Call rejected due to feature at the destination" */
1154 { 0x19, "Call resumed" },
1155 /* Q.850 - "Exchange routing error */
1156 { 0x1A, "Non-selected user clearing" },
1157 { 0x1B, "Destination out of order" },
1158 { 0x1C, "Invalid number format (incomplete number)" },
1159 { 0x1D, "Facility rejected" },
1160 { 0x1E, "Response to STATUS ENQUIRY" },
1161 { 0x1F, "Normal unspecified" },
1162 { 0x21, "Circuit out of order" },
1163 { 0x22, "No circuit/channel available" },
1164 { 0x23, "Destination unattainable" },
1165 { 0x25, "Degraded service" },
1166 { 0x26, "Network out of order" },
1167 { 0x27, "Transit delay range cannot be achieved" },
1168 /* Q.850 - "Permanent frame mode connection out of service" */
1169 { 0x28, "Throughput range cannot be achieved" },
1170 /* Q.850 - "Permanent frame mode connection operational" */
1171 { 0x29, "Temporary failure" },
1172 { 0x2A, "Switching equipment congestion" },
1173 { Q931_CAUSE_ACCESS_INFO_DISC, "Access information discarded" },
1174 { 0x2C, "Requested circuit/channel not available" },
1175 { 0x2D, "Pre-empted" },
1176 { 0x2E, "Precedence call blocked" },
1177 { 0x2F, "Resources unavailable, unspecified" },
1178 { Q931_CAUSE_QOS_UNAVAILABLE, "Quality of service unavailable" },
1179 { 0x32, "Requested facility not subscribed" },
1180 { 0x33, "Reverse charging not allowed" },
1181 { 0x34, "Outgoing calls barred" },
1182 { 0x35, "Outgoing calls barred within CUG" },
1183 { 0x36, "Incoming calls barred" },
1184 { 0x37, "Incoming calls barred within CUG" },
1185 { 0x38, "Call waiting not subscribed" },
1186 { 0x39, "Bearer capability not authorized" },
1187 { 0x3A, "Bearer capability not presently available" },
1188 { 0x3E, "Inconsistency in designated outgoing access information and subscriber class" },
1189 { 0x3F, "Service or option not available, unspecified" },
1190 { 0x41, "Bearer capability not implemented" },
1191 { 0x42, "Channel type not implemented" },
1192 { 0x43, "Transit network selection not implemented" },
1193 { 0x44, "Message not implemented" },
1194 { 0x45, "Requested facility not implemented" },
1195 { 0x46, "Only restricted digital information bearer capability is available" },
1196 { 0x4F, "Service or option not implemented, unspecified" },
1197 { 0x51, "Invalid call reference value" },
1198 { Q931_CAUSE_CHAN_NONEXISTENT, "Identified channel does not exist" },
1199 { 0x53, "Call identity does not exist for suspended call" },
1200 { 0x54, "Call identity in use" },
1201 { 0x55, "No call suspended" },
1202 { 0x56, "Call having the requested call identity has been cleared" },
1203 { 0x57, "Called user not member of CUG" },
1204 { Q931_CAUSE_INCOMPATIBLE_DEST, "Incompatible destination" },
1205 { 0x59, "Non-existent abbreviated address entry" },
1206 { 0x5A, "Destination address missing, and direct call not subscribed" },
1207 /* Q.850 - "Non-existent CUG" */
1208 { 0x5B, "Invalid transit network selection (national use)" },
1209 { 0x5C, "Invalid facility parameter" },
1210 { 0x5D, "Mandatory information element is missing" },
1211 { 0x5F, "Invalid message, unspecified" },
1212 { Q931_CAUSE_MAND_IE_MISSING, "Mandatory information element is missing" },
1213 { Q931_CAUSE_MT_NONEX_OR_UNIMPL,"Message type non-existent or not implemented" },
1214 { 0x62, "Message not compatible with call state or message type non-existent or not implemented" },
1215 { Q931_CAUSE_IE_NONEX_OR_UNIMPL,"Information element non-existent or not implemented" },
1216 { Q931_CAUSE_INVALID_IE_CONTENTS,"Invalid information element contents" },
1217 { Q931_CAUSE_MSG_INCOMPAT_W_CS, "Message not compatible with call state" },
1218 { Q931_CAUSE_REC_TIMER_EXP, "Recovery on timer expiry" },
1219 { 0x67, "Parameter non-existent or not implemented - passed on" },
1220 { 0x6E, "Message with unrecognized parameter discarded" },
1221 { 0x6F, "Protocol error, unspecified" },
1222 { 0x7F, "Internetworking, unspecified" },
1225 value_string_ext q931_cause_code_vals_ext = VALUE_STRING_EXT_INIT(q931_cause_code_vals);
1227 static const value_string q931_cause_condition_vals[] = {
1228 { 0x00, "Unknown" },
1229 { 0x01, "Permanent" },
1230 { 0x02, "Transient" },
1234 #define Q931_REJ_USER_SPECIFIC 0x00
1235 #define Q931_REJ_IE_MISSING 0x04
1236 #define Q931_REJ_IE_INSUFFICIENT 0x08
1238 static const value_string q931_rejection_reason_vals[] = {
1239 { 0x00, "User specific" },
1240 { 0x04, "Information element missing" },
1241 { 0x08, "Information element contents are not sufficient" },
1245 static const gchar *get_message_name(guint8 prot_discr, guint8 message_type) {
1246 if (prot_discr == NLPID_DMS)
1247 return val_to_str(message_type, dms_message_type_vals, "Unknown (0x%02X)");
1249 return val_to_str_ext(message_type, &q931_message_type_vals_ext, "Unknown (0x%02X)");
1253 dissect_q931_cause_ie_unsafe(tvbuff_t *tvb, int offset, int len,
1254 proto_tree *tree, int hf_cause_value, guint8 *cause_value, const value_string *ie_vals)
1257 guint8 coding_standard;
1258 guint8 rejection_reason;
1262 octet = tvb_get_guint8(tvb, offset);
1263 coding_standard = octet & 0x60;
1264 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1266 * We don't know how the cause is encoded,
1267 * so just dump it as data and be done with it.
1269 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1270 proto_tree_add_text(tree, tvb, offset,
1272 tvb_bytes_to_str(tvb, offset, len));
1275 proto_tree_add_uint(tree, hf_q931_cause_location, tvb, offset, 1, octet);
1276 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1277 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1281 if (!(octet & Q931_IE_VL_EXTENSION)) {
1284 octet = tvb_get_guint8(tvb, offset);
1285 proto_tree_add_text(tree, tvb, offset, 1,
1286 "Recommendation: %s",
1287 val_to_str(octet & 0x7F, q931_cause_recommendation_vals,
1288 "Unknown (0x%02X)"));
1289 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1296 octet = tvb_get_guint8(tvb, offset);
1297 *cause_value = octet & 0x7F;
1299 /* add cause value to packet info for use in tap */
1300 if(have_valid_q931_pi) {
1301 q931_pi->cause_value = *cause_value;
1304 proto_tree_add_uint(tree, hf_cause_value, tvb, offset, 1, *cause_value);
1305 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1311 switch (*cause_value) {
1313 case Q931_CAUSE_UNALLOC_NUMBER:
1314 case Q931_CAUSE_NO_ROUTE_TO_DEST:
1315 case Q931_CAUSE_QOS_UNAVAILABLE:
1316 octet = tvb_get_guint8(tvb, offset);
1317 proto_tree_add_text(tree, tvb, offset, 1,
1318 "Network service: %s",
1319 (octet & 0x80) ? "User" : "Provider");
1320 proto_tree_add_text(tree, tvb, offset, 1,
1322 (octet & 0x40) ? "Abnormal" : "Normal");
1323 proto_tree_add_text(tree, tvb, offset, 1,
1325 val_to_str(octet & 0x03, q931_cause_condition_vals,
1329 case Q931_CAUSE_CALL_REJECTED:
1330 rejection_reason = octet & 0x7C;
1331 proto_tree_add_text(tree, tvb, offset, 1,
1332 "Rejection reason: %s",
1333 val_to_str(octet & 0x7C, q931_rejection_reason_vals,
1335 proto_tree_add_text(tree, tvb, offset, 1,
1337 val_to_str(octet & 0x03, q931_cause_condition_vals,
1344 switch (rejection_reason) {
1346 case Q931_REJ_USER_SPECIFIC:
1347 proto_tree_add_text(tree, tvb, offset, len,
1348 "User specific diagnostic: %s",
1349 tvb_bytes_to_str(tvb, offset, len));
1352 case Q931_REJ_IE_MISSING:
1353 proto_tree_add_text(tree, tvb, offset, 1,
1354 "Missing information element: %s",
1355 val_to_str(tvb_get_guint8(tvb, offset), ie_vals,
1356 "Unknown (0x%02X)"));
1359 case Q931_REJ_IE_INSUFFICIENT:
1360 proto_tree_add_text(tree, tvb, offset, 1,
1361 "Insufficient information element: %s",
1362 val_to_str(tvb_get_guint8(tvb, offset), ie_vals,
1363 "Unknown (0x%02X)"));
1367 proto_tree_add_text(tree, tvb, offset, len,
1369 tvb_bytes_to_str(tvb, offset, len));
1374 case Q931_CAUSE_ACCESS_INFO_DISC:
1375 case Q931_CAUSE_INCOMPATIBLE_DEST:
1376 case Q931_CAUSE_MAND_IE_MISSING:
1377 case Q931_CAUSE_IE_NONEX_OR_UNIMPL:
1378 case Q931_CAUSE_INVALID_IE_CONTENTS:
1380 proto_tree_add_text(tree, tvb, offset, 1,
1381 "Information element: %s",
1382 val_to_str(tvb_get_guint8(tvb, offset), ie_vals,
1383 "Unknown (0x%02X)"));
1389 case Q931_CAUSE_MT_NONEX_OR_UNIMPL:
1390 case Q931_CAUSE_MSG_INCOMPAT_W_CS:
1391 proto_tree_add_text(tree, tvb, offset, 1,
1393 val_to_str_ext(tvb_get_guint8(tvb, offset), &q931_message_type_vals_ext,
1394 "Unknown (0x%02X)"));
1397 case Q931_CAUSE_REC_TIMER_EXP:
1400 proto_tree_add_text(tree, tvb, offset, 3,
1401 "Timer: %.3s", tvb_get_ptr(tvb, offset, 3));
1405 proto_tree_add_text(tree, tvb, offset, len,
1407 tvb_bytes_to_str(tvb, offset, len));
1412 dissect_q931_cause_ie(tvbuff_t *tvb, int offset, int len,
1413 proto_tree *tree, int hf_cause_value, guint8 *cause_value, const value_string *ie_vals)
1415 gboolean have_valid_q931_pi_save = have_valid_q931_pi;
1416 have_valid_q931_pi = FALSE;
1417 dissect_q931_cause_ie_unsafe(tvb, offset, len, tree, hf_cause_value, cause_value, ie_vals);
1418 have_valid_q931_pi = have_valid_q931_pi_save;
1422 * Dissect a Change status information element.
1425 static const value_string q931_status_preference_vals[] = {
1426 { 0x01, "Channel" },
1430 static const value_string q931_new_status_vals[] = {
1431 { 0x00, "In Service" },
1432 { 0x01, "Maintenance" },
1433 { 0x02, "Out of Service" },
1438 dissect_q931_change_status_ie(tvbuff_t *tvb, int offset, int len _U_, proto_tree *tree)
1444 octet = tvb_get_guint8(tvb, offset);
1446 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, FALSE);
1447 proto_tree_add_text(tree, tvb, offset, 1, "%s",
1448 decode_enumerated_bitfield_shifted(octet, 0x40, 8, VALS(q931_status_preference_vals), "Preference: %s"));
1449 proto_tree_add_text(tree, tvb, offset, 1, "%s",
1450 decode_enumerated_bitfield(octet, 0x07, 8, VALS(q931_new_status_vals), "New status: %s"));
1454 * Dissect a Call state information element.
1456 static const value_string q931_call_state_vals[] = {
1458 { 0x01, "Call initiated" },
1459 { 0x02, "Overlap sending" },
1460 { 0x03, "Outgoing call proceeding" },
1461 { 0x04, "Call delivered" },
1462 { 0x06, "Call present" },
1463 { 0x07, "Call received" },
1464 { 0x08, "Connect request" },
1465 { 0x09, "Incoming call proceeding" },
1467 { 0x0B, "Disconnect request" },
1468 { 0x0C, "Disconnect indication" },
1469 { 0x0F, "Suspend request" },
1470 { 0x11, "Resume request" },
1471 { 0x13, "Release request" },
1472 { 0x16, "Call abort"},
1473 { 0x19, "Overlap receiving" },
1474 { 0x3D, "Restart request" },
1475 { 0x3E, "Restart" },
1478 value_string_ext q931_call_state_vals_ext = VALUE_STRING_EXT_INIT(q931_call_state_vals);
1481 dissect_q931_call_state_ie(tvbuff_t *tvb, int offset, int len,
1485 guint8 coding_standard;
1489 octet = tvb_get_guint8(tvb, offset);
1490 coding_standard = octet & 0x60;
1491 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1492 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1494 * We don't know how the call state is encoded,
1495 * so just dump it as data and be done with it.
1497 proto_tree_add_text(tree, tvb, offset,
1499 tvb_bytes_to_str(tvb, offset, len));
1502 proto_tree_add_text(tree, tvb, offset, 1,
1504 val_to_str_ext(octet & 0x3F, &q931_call_state_vals_ext,
1505 "Unknown (0x%02X)"));
1509 * Dissect a Channel identification information element.
1511 #define Q931_INTERFACE_IDENTIFIED 0x40
1512 #define Q931_NOT_BASIC_CHANNEL 0x20
1514 static const value_string q931_basic_channel_selection_vals[] = {
1515 { 0x00, "No channel" },
1516 { 0x01, "B1 channel" },
1517 { 0x02, "B2 channel" },
1518 { 0x03, "Any channel" },
1522 static const value_string q931_not_basic_channel_selection_vals[] = {
1523 { 0x00, "No channel" },
1524 { 0x01, "Channel indicated in following octets" },
1525 { 0x03, "Any channel" },
1529 #define Q931_IS_SLOT_MAP 0x10
1531 static const value_string q931_element_type_vals[] = {
1532 { 0x03, "B-channel units" },
1533 { 0x06, "H0-channel units" },
1534 { 0x08, "H11-channel units" },
1535 { 0x09, "H12-channel units" },
1540 dissect_q931_channel_identification_ie(tvbuff_t *tvb, int offset, int len,
1544 guint8 coding_standard;
1548 octet = tvb_get_guint8(tvb, offset);
1550 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, FALSE);
1551 proto_tree_add_item(tree, hf_q931_channel_interface_explicit, tvb, offset, 1, FALSE);
1552 proto_tree_add_item(tree, hf_q931_channel_interface_type, tvb, offset, 1, FALSE);
1553 proto_tree_add_item(tree, hf_q931_channel_exclusive, tvb, offset, 1, FALSE);
1554 proto_tree_add_item(tree, hf_q931_channel_dchan, tvb, offset, 1, FALSE);
1556 if (octet & Q931_NOT_BASIC_CHANNEL) {
1557 proto_tree_add_item(tree, hf_q931_channel_selection_pri, tvb, offset, 1, FALSE);
1559 proto_tree_add_item(tree, hf_q931_channel_selection_bri, tvb, offset, 1, FALSE);
1564 if (octet & Q931_INTERFACE_IDENTIFIED) {
1566 guint32 identifier_val = 0;
1567 int identifier_offset = offset;
1568 int identifier_len = 0;
1572 octet2 = tvb_get_guint8(tvb, offset);
1576 identifier_val <<= 7;
1577 identifier_val |= octet2 & 0x7F;
1578 } while (!(octet2 & Q931_IE_VL_EXTENSION));
1580 if (identifier_len != 0) {
1581 proto_tree_add_text(tree, tvb, identifier_offset,
1582 identifier_len, "Interface ID: %u", identifier_val);
1586 if (octet & Q931_NOT_BASIC_CHANNEL) {
1589 octet = tvb_get_guint8(tvb, offset);
1590 coding_standard = octet & 0x60;
1591 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, FALSE);
1592 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1593 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1595 * We don't know how the channel identifier is
1596 * encoded, so just dump it as data and be done
1599 proto_tree_add_text(tree, tvb, offset,
1601 tvb_bytes_to_str(tvb, offset, len));
1604 proto_tree_add_item(tree, hf_q931_channel_map, tvb, offset, 1, FALSE);
1605 proto_tree_add_item(tree, hf_q931_channel_element_type, tvb, offset, 1, FALSE);
1610 if (octet & Q931_IS_SLOT_MAP) {
1613 octet2 = tvb_get_guint8(tvb, offset);
1614 proto_tree_add_text(tree, tvb, offset, 1,
1615 "Slot map: 0x%02x", octet2);
1624 octet2 = tvb_get_guint8(tvb, offset);
1626 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, FALSE);
1627 proto_tree_add_item(tree,hf_q931_channel_number,tvb,offset,1,FALSE);
1631 } while (!(octet2 & Q931_IE_VL_EXTENSION));
1637 * Dissect a Progress indicator information element.
1639 static const value_string q931_progress_description_vals[] = {
1640 { 0x01, "Call is not end-to-end ISDN - progress information available in-band" },
1641 { 0x02, "Destination address is non-ISDN" },
1642 { 0x03, "Origination address is non-ISDN" },
1643 { 0x04, "Call has returned to the ISDN" },
1644 { 0x05, "Interworking has occurred and has resulted in a telecommunications service change" },
1645 { 0x08, "In-band information or an appropriate pattern is now available" },
1648 value_string_ext q931_progress_description_vals_ext = VALUE_STRING_EXT_INIT(q931_progress_description_vals);
1651 dissect_q931_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
1655 guint8 coding_standard;
1659 octet = tvb_get_guint8(tvb, offset);
1660 coding_standard = octet & 0x60;
1661 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1662 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1664 * We don't know how the progress indicator is encoded,
1665 * so just dump it as data and be done with it.
1667 proto_tree_add_text(tree, tvb, offset,
1669 tvb_bytes_to_str(tvb, offset, len));
1672 proto_tree_add_text(tree, tvb, offset, 1,
1674 val_to_str_ext(octet & 0x0F, &q931_cause_location_vals_ext,
1681 octet = tvb_get_guint8(tvb, offset);
1682 proto_tree_add_text(tree, tvb, offset, 1,
1683 "Progress description: %s",
1684 val_to_str_ext(octet & 0x7F, &q931_progress_description_vals_ext,
1685 "Unknown (0x%02X)"));
1689 * Dissect a Network-specific facilities or Transit network selection
1690 * information element.
1692 static const value_string q931_netid_type_vals[] = {
1693 { 0x00, "User specified" },
1694 { 0x20, "National network identification" },
1695 { 0x30, "International network identification" },
1699 static const value_string q931_netid_plan_vals[] = {
1700 { 0x00, "Unknown" },
1701 { 0x01, "Carrier Identification Code" },
1702 { 0x03, "X.121 data network identification code" },
1707 dissect_q931_ns_facilities_ie(tvbuff_t *tvb, int offset, int len,
1715 octet = tvb_get_guint8(tvb, offset);
1716 netid_len = octet & 0x7F;
1717 proto_tree_add_text(tree, tvb, offset, 1,
1718 "Network identification length: %u",
1722 if (netid_len != 0) {
1725 octet = tvb_get_guint8(tvb, offset);
1726 proto_tree_add_text(tree, tvb, offset, 1,
1727 "Type of network identification: %s",
1728 val_to_str(octet & 0x70, q931_netid_type_vals,
1729 "Unknown (0x%02X)"));
1730 proto_tree_add_text(tree, tvb, offset, 1,
1731 "Network identification plan: %s",
1732 val_to_str(octet & 0x0F, q931_netid_plan_vals,
1733 "Unknown (0x%02X)"));
1740 if (netid_len > len)
1742 if (netid_len != 0) {
1743 proto_tree_add_text(tree, tvb, offset, netid_len,
1744 "Network identification: %s",
1745 tvb_format_text(tvb, offset, netid_len));
1746 offset += netid_len;
1752 * Whatever is left is the network-specific facility
1757 proto_tree_add_text(tree, tvb, offset,
1758 len, "Network-specific facility specification: %s",
1759 tvb_bytes_to_str(tvb, offset, len));
1763 * Dissect a Notification indicator information element.
1765 static const value_string q931_notification_description_vals[] = {
1766 { 0x00, "User suspended" },
1767 { 0x01, "User resumed" },
1768 { 0x02, "Bearer service change" },
1773 dissect_q931_notification_indicator_ie(tvbuff_t *tvb, int offset, int len,
1780 octet = tvb_get_guint8(tvb, offset);
1781 proto_tree_add_text(tree, tvb, offset, 1,
1782 "Notification description: %s",
1783 val_to_str(octet & 0x7F, q931_notification_description_vals,
1784 "Unknown (0x%02X)"));
1788 * Dissect a Date/time information element.
1791 dissect_q931_date_time_ie(tvbuff_t *tvb, int offset, int len,
1796 * XXX - what is "year" relative to? Is "month" 0-origin or
1797 * 1-origin? Q.931 doesn't say....
1799 proto_tree_add_text(tree, tvb, offset, 6,
1800 "Date/time: %02u-%02u-%02u %02u:%02u:%02u",
1801 tvb_get_guint8(tvb, offset + 0), tvb_get_guint8(tvb, offset + 1), tvb_get_guint8(tvb, offset + 2),
1802 tvb_get_guint8(tvb, offset + 3), tvb_get_guint8(tvb, offset + 4), tvb_get_guint8(tvb, offset + 5));
1803 } else if (len == 5) {
1804 proto_tree_add_text(tree, tvb, offset, 5,
1805 "Date/time: %02u-%02u-%02u %02u:%02u:00",
1806 tvb_get_guint8(tvb, offset + 0), tvb_get_guint8(tvb, offset + 1), tvb_get_guint8(tvb, offset + 2),
1807 tvb_get_guint8(tvb, offset + 3), tvb_get_guint8(tvb, offset + 4));
1809 proto_tree_add_text(tree, tvb, offset, len,
1810 "Date/time: length is %d, should be 5 or 6", len);
1815 * Dissect a Signal information element.
1817 static const value_string q931_signal_vals[] = {
1818 { 0x00, "Dial tone on" },
1819 { 0x01, "Ring tone on" },
1820 { 0x02, "Intercept tone on" },
1821 { 0x03, "Network congestion tone on" }, /* "fast busy" */
1822 { 0x04, "Busy tone on" },
1823 { 0x05, "Confirm tone on" },
1824 { 0x06, "Answer tone on" },
1825 { 0x07, "Call waiting tone on" },
1826 { 0x08, "Off-hook warning tone on" },
1827 { 0x09, "Preemption tone on" },
1828 { 0x3F, "Tones off" },
1829 { 0x40, "Alerting on - pattern 0" },
1830 { 0x41, "Alerting on - pattern 1" },
1831 { 0x42, "Alerting on - pattern 2" },
1832 { 0x43, "Alerting on - pattern 3" },
1833 { 0x44, "Alerting on - pattern 4" },
1834 { 0x45, "Alerting on - pattern 5" },
1835 { 0x46, "Alerting on - pattern 6" },
1836 { 0x47, "Alerting on - pattern 7" },
1837 { 0x4F, "Alerting off" },
1840 static value_string_ext q931_signal_vals_ext = VALUE_STRING_EXT_INIT(q931_signal_vals);
1843 dissect_q931_signal_ie(tvbuff_t *tvb, int offset, int len,
1847 proto_tree_add_text(tree, tvb, offset, len,
1848 "Signal: length is %d, should be 1", len);
1851 proto_tree_add_text(tree, tvb, offset, 1,
1853 val_to_str_ext(tvb_get_guint8(tvb, offset), &q931_signal_vals_ext,
1854 "Unknown (0x%02X)"));
1858 * Dissect an Information rate information element.
1860 static const value_string q931_throughput_class_vals[] = {
1861 { 0x03, "75 bit/s" },
1862 { 0x04, "150 bit/s" },
1863 { 0x05, "300 bit/s" },
1864 { 0x06, "600 bit/s" },
1865 { 0x07, "1200 bit/s" },
1866 { 0x08, "2400 bit/s" },
1867 { 0x09, "4800 bit/s" },
1868 { 0x0A, "9600 bit/s" },
1869 { 0x0B, "19200 bit/s" },
1870 { 0x0C, "48000 bit/s" },
1871 { 0x0D, "64000 bit/s" },
1874 static value_string_ext q931_throughput_class_vals_ext = VALUE_STRING_EXT_INIT(q931_throughput_class_vals);
1877 dissect_q931_information_rate_ie(tvbuff_t *tvb, int offset, int len,
1881 proto_tree_add_text(tree, tvb, offset, len,
1882 "Information rate: length is %d, should be 4", len);
1885 proto_tree_add_text(tree, tvb, offset + 0, 1,
1886 "Incoming information rate: %s",
1887 val_to_str_ext(tvb_get_guint8(tvb, offset + 0) & 0x1F,
1888 &q931_throughput_class_vals_ext, "Unknown (0x%02X)"));
1889 proto_tree_add_text(tree, tvb, offset + 1, 1,
1890 "Outgoing information rate: %s",
1891 val_to_str_ext(tvb_get_guint8(tvb, offset + 1) & 0x1F,
1892 &q931_throughput_class_vals_ext, "Unknown (0x%02X)"));
1893 proto_tree_add_text(tree, tvb, offset + 2, 1,
1894 "Minimum incoming information rate: %s",
1895 val_to_str_ext(tvb_get_guint8(tvb, offset + 2) & 0x1F,
1896 &q931_throughput_class_vals_ext, "Unknown (0x%02X)"));
1897 proto_tree_add_text(tree, tvb, offset + 3, 1,
1898 "Minimum outgoing information rate: %s",
1899 val_to_str_ext(tvb_get_guint8(tvb, offset + 3) & 0x1F,
1900 &q931_throughput_class_vals_ext, "Unknown (0x%02X)"));
1904 dissect_q931_guint16_value(tvbuff_t *tvb, int offset, int len,
1905 proto_tree *tree, const char *label)
1913 octet = tvb_get_guint8(tvb, offset);
1914 if (octet & Q931_IE_VL_EXTENSION) {
1916 * Only one octet long - error.
1920 value = (octet & 0x3) << 14;
1927 * We've reached the end of the information element - error.
1931 octet = tvb_get_guint8(tvb, offset);
1932 if (octet & Q931_IE_VL_EXTENSION) {
1934 * Only two octets long - error.
1938 value |= (octet & 0x7F) << 7;
1945 * We've reached the end of the information element - error.
1949 octet = tvb_get_guint8(tvb, offset);
1950 if (!(octet & Q931_IE_VL_EXTENSION)) {
1952 * More than three octets long - error.
1956 value |= (octet & 0x7F);
1961 proto_tree_add_text(tree, tvb, offset, value_len, "%s: %u ms", label,
1966 proto_tree_add_text(tree, tvb, offset, len,
1967 "%s goes past end of information element", label);
1971 proto_tree_add_text(tree, tvb, offset, len, "%s isn't 3 octets long",
1977 * Dissect an End-to-end transit delay information element.
1980 dissect_q931_e2e_transit_delay_ie(tvbuff_t *tvb, int offset, int len,
1987 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1988 "Cumulative transit delay");
1991 offset += value_len;
1996 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1997 "Requested end-to-end transit delay");
2000 offset += value_len;
2005 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
2006 "Maximum end-to-end transit delay");
2010 * Dissect a Transit delay selection and indication information element.
2013 dissect_q931_td_selection_and_int_ie(tvbuff_t *tvb, int offset, int len,
2018 dissect_q931_guint16_value(tvb, offset, len, tree,
2023 * Dissect a Packet layer binary parameters information element.
2025 static const value_string q931_fast_selected_vals[] = {
2026 { 0x00, "Fast select not requested" },
2027 { 0x08, "Fast select not requested" },
2028 { 0x10, "Fast select requested with no restriction of response" },
2029 { 0x18, "Fast select requested with restrictions of response" },
2034 dissect_q931_pl_binary_parameters_ie(tvbuff_t *tvb, int offset, int len,
2041 octet = tvb_get_guint8(tvb, offset);
2042 proto_tree_add_text(tree, tvb, offset, 1,
2044 val_to_str(octet & 0x18, q931_fast_selected_vals, "Unknown (0x%02X)"));
2045 proto_tree_add_text(tree, tvb, offset, 1,
2047 (octet & 0x04) ? "No request/request denied" :
2048 "Request indicated/request accepted");
2049 proto_tree_add_text(tree, tvb, offset, 1,
2051 (octet & 0x02) ? "Link-by-link" : "End-to-end");
2052 proto_tree_add_text(tree, tvb, offset, 1,
2053 "Modulus %u sequencing",
2054 (octet & 0x01) ? 8 : 128);
2058 * Dissect a Packet layer window size information element.
2061 dissect_q931_pl_window_size_ie(tvbuff_t *tvb, int offset, int len,
2066 proto_tree_add_text(tree, tvb, offset, 1,
2067 "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
2073 proto_tree_add_text(tree, tvb, offset, 1,
2074 "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
2078 * Dissect a Packet size information element.
2081 dissect_q931_packet_size_ie(tvbuff_t *tvb, int offset, int len,
2086 proto_tree_add_text(tree, tvb, offset, 1,
2087 "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
2093 proto_tree_add_text(tree, tvb, offset, 1,
2094 "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
2098 * Dissect a Closed user group information element.
2100 static const value_string q931_cug_indication_vals[] = {
2101 { 0x01, "Closed user group selection" },
2102 { 0x02, "Closed user group with outgoing access selection and indication" },
2107 dissect_q931_cug_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree)
2111 proto_tree_add_text(tree, tvb, offset, 1,
2112 "CUG indication: %s",
2113 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
2114 q931_cug_indication_vals, "Unknown (0x%02X)"));
2120 proto_tree_add_text(tree, tvb, offset, len, "CUG index code: %s",
2121 tvb_format_text(tvb, offset, len));
2125 * Dissect a Reverse charging indication information element.
2127 static const value_string q931_reverse_charging_indication_vals[] = {
2128 { 0x01, "Reverse charging requested" },
2133 dissect_q931_reverse_charge_ind_ie(tvbuff_t *tvb, int offset, int len,
2138 proto_tree_add_text(tree, tvb, offset, 1,
2139 "Reverse charging indication: %s",
2140 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
2141 q931_reverse_charging_indication_vals, "Unknown (0x%02X)"));
2145 * Dissect a (phone) number information element.
2147 static const value_string q931_number_type_vals[] = {
2149 { 0x1, "International number" },
2150 { 0x2, "National number" },
2151 { 0x3, "Network specific number" },
2152 { 0x4, "Subscriber number" },
2153 { 0x6, "Abbreviated number" },
2157 static const value_string q931_numbering_plan_vals[] = {
2158 { 0x00, "Unknown" },
2159 { 0x01, "E.164 ISDN/telephony numbering" },
2160 { 0x03, "X.121 data numbering" },
2161 { 0x04, "F.69 Telex numbering" },
2162 { 0x08, "National standard numbering" },
2163 { 0x09, "Private numbering" },
2167 static const value_string q931_presentation_indicator_vals[] = {
2168 { 0x00, "Presentation allowed" },
2169 { 0x01, "Presentation restricted" },
2170 { 0x02, "Number not available due to interworking" },
2174 static const value_string q931_screening_indicator_vals[] = {
2175 { 0x00, "User-provided, not screened" },
2176 { 0x01, "User-provided, verified and passed" },
2177 { 0x02, "User-provided, verified and failed" },
2178 { 0x03, "Network-provided" },
2182 static const value_string q931_redirection_reason_vals[] = {
2183 { 0x00, "Unknown" },
2184 { 0x01, "Call forwarding busy or called DTE busy" },
2185 { 0x02, "Call forwarding no reply" },
2186 { 0x04, "Call deflection" },
2187 { 0x09, "Called DTE out of order" },
2188 { 0x0A, "Call forwarding by the called DTE" },
2189 { 0x0F, "Call forwarding unconditional or systematic call redirection" },
2194 dissect_q931_number_ie(tvbuff_t *tvb, int offset, int len,
2195 proto_tree *tree, int hfindex, e164_info_t e164_info)
2202 octet = tvb_get_guint8(tvb, offset);
2203 number_plan = octet & 0x0f;
2204 e164_info.nature_of_address = ( octet & 0x70 ) >> 4;
2205 proto_tree_add_uint(tree, hf_q931_numbering_plan, tvb, offset, 1, octet);
2206 proto_tree_add_uint(tree, hf_q931_number_type, tvb, offset, 1, octet);
2207 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
2212 if (!(octet & Q931_IE_VL_EXTENSION)) {
2215 octet = tvb_get_guint8(tvb, offset);
2216 proto_tree_add_uint(tree, hf_q931_screening_ind, tvb, offset, 1, octet);
2217 proto_tree_add_uint(tree, hf_q931_presentation_ind, tvb, offset, 1, octet);
2218 proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
2224 * XXX - only in a Redirecting number information element.
2226 if (!(octet & Q931_IE_VL_EXTENSION)) {
2229 octet = tvb_get_guint8(tvb, offset);
2230 proto_tree_add_text(tree, tvb, offset, 1,
2231 "Reason for redirection: %s",
2232 val_to_str(octet & 0x0F, q931_redirection_reason_vals,
2240 proto_tree_add_item(tree, hfindex, tvb, offset, len, FALSE);
2241 proto_item_append_text(proto_tree_get_parent(tree), ": '%s'", tvb_format_text(tvb, offset, len));
2243 if ( number_plan == 1 ) {
2244 if ( e164_info.e164_number_type != NONE ){
2246 e164_info.E164_number_str = tvb_get_ephemeral_string(tvb, offset, len);
2247 e164_info.E164_number_length = len;
2248 dissect_e164_number(tvb, tree, offset, len, e164_info);
2252 /* Collect q931_packet_info */
2253 if ( e164_info.e164_number_type == CALLING_PARTY_NUMBER && have_valid_q931_pi)
2254 q931_pi->calling_number = tvb_get_ephemeral_string(tvb, offset, len);
2255 if ( e164_info.e164_number_type == CALLED_PARTY_NUMBER && have_valid_q931_pi)
2256 q931_pi->called_number = tvb_get_ephemeral_string(tvb, offset, len);
2260 * Dissect a party subaddress information element.
2262 static const value_string q931_subaddress_type_vals[] = {
2263 { 0x00, "X.213/ISO 8348 Add.2 NSAP" },
2264 { 0x20, "User-specified" },
2268 static const value_string q931_odd_even_indicator_vals[] = {
2269 { 0x00, "Even number of address signals" },
2270 { 0x08, "Odd number of address signals" },
2275 dissect_q931_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
2282 octet = tvb_get_guint8(tvb, offset);
2283 proto_tree_add_text(tree, tvb, offset, 1,
2284 "Type of subaddress: %s",
2285 val_to_str(octet & 0x70, q931_subaddress_type_vals,
2286 "Unknown (0x%02X)"));
2287 proto_tree_add_text(tree, tvb, offset, 1,
2288 "Odd/even indicator: %s",
2289 val_to_str(octet & 0x08, q931_odd_even_indicator_vals,
2290 "Unknown (0x%02X)"));
2296 proto_tree_add_text(tree, tvb, offset, len, "Subaddress: %s",
2297 tvb_bytes_to_str(tvb, offset, len));
2301 * Dissect a Restart indicator information element.
2303 static const value_string q931_restart_indicator_class_vals[] = {
2304 { 0x00, "Indicated channels" },
2305 { 0x06, "Single interface" },
2306 { 0x07, "All interfaces" },
2311 dissect_q931_restart_indicator_ie(tvbuff_t *tvb, int offset, int len,
2315 proto_tree_add_text(tree, tvb, offset, len,
2316 "Restart indicator: length is %d, should be 1", len);
2319 proto_tree_add_text(tree, tvb, offset, 1,
2320 "Restart indicator: %s",
2321 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
2322 q931_restart_indicator_class_vals, "Unknown (0x%02X)"));
2326 * Dissect a High-layer compatibility information element.
2328 #define Q931_MAINTENANCE 0x5e
2329 #define Q931_MANAGEMENT 0x5f
2330 #define Q931_AUDIOVISUAL 0x60
2331 static const value_string q931_high_layer_characteristics_vals[] = {
2332 { 0x01, "Telephony" },
2333 { 0x04, "F.182 Facsimile Group 2/3" },
2334 { 0x21, "F.184 Facsimile Group 4 Class I" },
2335 { 0x24, "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
2336 { 0x28, "F.220 Teletex, basic and processable mode" },
2337 { 0x31, "F.200 Teletex, basic mode" },
2338 { 0x32, "F.300 and T.102 syntax-based Videotex" },
2339 { 0x33, "F.300 and T.101 international Videotex interworking" },
2340 { 0x35, "F.60 Telex" },
2341 { 0x38, "X.400 Message Handling Systems" },
2342 { 0x41, "X.200 OSI application" },
2343 { 0x42, "FTAM application" },
2344 { 0x5E, "Reserved for maintenance" },
2345 { 0x5F, "Reserved for management" },
2346 { Q931_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
2347 { 0x61, "F.702 and F.731 Profile 1b videoconferencing" },
2348 { 0x62, "F.702 and F.731 audiographic conferencing" },
2349 { 0x68, "F.700-series Multimedia services" },
2352 static value_string_ext q931_high_layer_characteristics_vals_ext = VALUE_STRING_EXT_INIT(q931_high_layer_characteristics_vals);
2354 static const value_string q931_extended_high_layer_characteristics_vals[] = {
2355 { 0x01, "Telephony" },
2356 { 0x04, "F.182 Facsimile Group 2/3" },
2357 { 0x21, "F.184 Facsimile Group 4 Class I" },
2358 { 0x24, "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
2359 { 0x28, "F.220 Teletex, basic and processable mode" },
2360 { 0x31, "F.200 Teletex, basic mode" },
2361 { 0x32, "F.300 and T.102 syntax-based Videotex" },
2362 { 0x33, "F.300 and T.101 international Videotex interworking" },
2363 { 0x35, "F.60 Telex" },
2364 { 0x38, "X.400 Message Handling Systems" },
2365 { 0x41, "X.200 OSI application" },
2366 { 0x42, "FTAM application" },
2367 { 0x5E, "Not available for assignment" },
2368 { 0x5F, "Not available for assignment" },
2369 { Q931_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
2370 { 0x61, "F.702 and F.731 Profile 1b videoconferencing" },
2371 { 0x62, "F.702 and F.731 audiographic conferencing" },
2372 { 0x68, "F.700-series Multimedia services" },
2375 static value_string_ext q931_extended_high_layer_characteristics_vals_ext = VALUE_STRING_EXT_INIT(q931_extended_high_layer_characteristics_vals);
2377 static const value_string q931_audiovisual_characteristics_vals[] = {
2378 { 0x01, "Capability set of initial channel of H.221" },
2379 { 0x02, "Capability set of subsequent channel of H.221" },
2380 { 0x21, "Capability set of initial channel of an active 3.1kHz audio or speech call" },
2384 static const value_string q931_interpretation_vals[] = {
2385 { 0x04, "First (primary or only) high layer characteristics identification to be used in the call" },
2389 static const value_string q931_pres_meth_prot_prof_vals[] = {
2390 { 0x01, "High layer protocol profile (without specification of attributes)" },
2395 * High layer protocol profile
2397 #define Q931_HIGH_LAYER_PROTOCOL_PROFILE 0x01
2400 dissect_q931_high_layer_compat_ie(tvbuff_t *tvb, int offset, int len,
2404 guint8 coding_standard;
2406 guint8 characteristics;
2410 octet = tvb_get_guint8(tvb, offset);
2411 coding_standard = octet & 0x60;
2412 pres_method = octet & 0x03;
2414 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, FALSE);
2415 proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
2416 proto_tree_add_uint(tree, hf_q931_interpretation, tvb, offset, 1, octet);
2417 proto_tree_add_uint(tree, hf_q931_pres_meth_prot_prof, tvb, offset, 1, octet);
2421 if ((coding_standard != Q931_ITU_STANDARDIZED_CODING) || (pres_method != Q931_HIGH_LAYER_PROTOCOL_PROFILE)) {
2423 * We don't know how the call state is encoded,
2424 * so just dump it as data and be done with it.
2426 proto_tree_add_text(tree, tvb, offset,
2428 tvb_bytes_to_str(tvb, offset, len));
2434 octet = tvb_get_guint8(tvb, offset);
2435 characteristics = octet & 0x7F;
2437 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, FALSE);
2438 proto_tree_add_uint(tree, hf_q931_high_layer_characteristics, tvb, offset, 1, octet);
2443 if (!(octet & Q931_IE_VL_EXTENSION)) {
2446 octet = tvb_get_guint8(tvb, offset);
2447 if ((characteristics == Q931_AUDIOVISUAL) || (characteristics == 0x61) || (characteristics == 0x62) ||
2448 (characteristics == 0x68)) {
2449 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, FALSE);
2450 proto_tree_add_uint(tree, hf_q931_extended_audiovisual_characteristics, tvb, offset, 1, octet);
2452 else if ((characteristics == Q931_MANAGEMENT) || (characteristics == Q931_MAINTENANCE)) {
2453 proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, FALSE);
2454 proto_tree_add_uint(tree, hf_q931_extended_high_layer_characteristics, tvb, offset, 1, octet);
2461 * Dissect a User-user information element.
2463 #define Q931_PROTOCOL_DISCRIMINATOR_USER 0x00
2464 #define Q931_PROTOCOL_DISCRIMINATOR_IA5 0x04
2465 #define Q931_PROTOCOL_DISCRIMINATOR_ASN1 0x05
2467 static const value_string q931_protocol_discriminator_vals[] = {
2468 { Q931_PROTOCOL_DISCRIMINATOR_USER, "User-specific protocol" },
2469 { 0x01, "OSI high layer protocols" },
2471 { 0x03, "Reserved for system management convergence function" },
2472 { Q931_PROTOCOL_DISCRIMINATOR_IA5, "IA5 characters" },
2473 { Q931_PROTOCOL_DISCRIMINATOR_ASN1, "X.208 and X.209 coded user information" },
2474 { 0x06, "Undefined" },
2475 { 0x07, "V.120 rate adaption" },
2476 { 0x08, "Q.931/I.451 user-network call control messages" },
2479 value_string_ext q931_protocol_discriminator_vals_ext = VALUE_STRING_EXT_INIT(q931_protocol_discriminator_vals);
2482 dissect_q931_user_user_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
2486 tvbuff_t *next_tvb = NULL;
2490 octet = tvb_get_guint8(tvb, offset);
2491 proto_tree_add_text(tree, tvb, offset, 1,
2492 "Protocol discriminator: %s",
2493 val_to_str_ext(octet, &q931_protocol_discriminator_vals_ext,
2494 "Unknown (0x%02x)"));
2502 case Q931_PROTOCOL_DISCRIMINATOR_USER:
2503 next_tvb = tvb_new_subset(tvb, offset, len, len);
2504 proto_tree_add_text(tree, tvb, offset, len, "User information: %d octets", len);
2505 if (!dissector_try_heuristic(q931_user_heur_subdissector_list, next_tvb, pinfo, tree)) {
2506 call_dissector_only(data_handle, next_tvb, pinfo, tree);
2510 case Q931_PROTOCOL_DISCRIMINATOR_IA5:
2511 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
2512 tvb_format_text(tvb, offset, len));
2516 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
2517 tvb_bytes_to_str(tvb, offset, len));
2522 static const value_string q931_party_category_vals[] = {
2523 { 0x00, "Unknown" },
2524 { 0x01, "Extension" },
2525 { 0x02, "Operator" },
2526 { 0x03, "Emergency extension" },
2531 dissect_q931_party_category_ie(tvbuff_t *tvb, int offset, int len,
2539 octet = tvb_get_guint8(tvb, offset);
2540 proto_tree_add_text(tree, tvb, offset, 1,
2541 "Party category: %s",
2542 val_to_str(octet&0x07, q931_party_category_vals,
2543 "Unknown (0x%02x)"));
2552 * Dissect information elements consisting of ASCII^H^H^H^H^HIA5 text.
2555 dissect_q931_ia5_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
2559 proto_tree_add_text(tree, tvb, offset, len, "%s: %s", label,
2560 tvb_format_text(tvb, offset, len));
2561 proto_item_append_text(proto_tree_get_parent(tree), " '%s'", tvb_format_text(tvb, offset, len));
2566 dissect_q931_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2567 gboolean is_over_ip)
2570 proto_tree *q931_tree = NULL;
2571 proto_tree *ie_tree = NULL;
2572 proto_item *ti, *ti_ie;
2574 guint8 call_ref_len;
2575 guint8 call_ref[15];
2576 guint32 call_ref_val;
2577 guint8 message_type, segmented_message_type;
2578 guint8 info_element;
2579 guint16 info_element_len;
2580 gboolean first_frag, more_frags;
2582 fragment_data *fd_head;
2583 tvbuff_t *next_tvb = NULL;
2585 q931_pi=ep_alloc(sizeof(q931_packet_info));
2587 /* Init struct for collecting q931_packet_info */
2588 reset_q931_packet_info(q931_pi);
2589 have_valid_q931_pi=TRUE;
2591 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Q.931");
2593 prot_discr = tvb_get_guint8(tvb, offset);
2595 ti = proto_tree_add_item(tree, proto_q931, tvb, offset, -1,
2597 q931_tree = proto_item_add_subtree(ti, ett_q931);
2599 dissect_q931_protocol_discriminator(tvb, offset, q931_tree);
2602 call_ref_len = tvb_get_guint8(tvb, offset) & 0xF; /* XXX - do as a bit field? */
2603 if (q931_tree != NULL)
2604 proto_tree_add_uint(q931_tree, hf_q931_call_ref_len, tvb, offset, 1, call_ref_len);
2606 switch (call_ref_len) {
2607 case 0: call_ref_val = 0; break;
2608 case 1: call_ref_val = tvb_get_guint8(tvb, offset); break;
2609 case 2: call_ref_val = tvb_get_ntohs(tvb, offset); break;
2610 case 3: call_ref_val = tvb_get_ntoh24(tvb, offset); break;
2611 default: call_ref_val = tvb_get_ntohl(tvb, offset);
2613 if (call_ref_len != 0) {
2614 tvb_memcpy(tvb, call_ref, offset, call_ref_len);
2615 if (q931_tree != NULL) {
2616 proto_tree_add_boolean(q931_tree, hf_q931_call_ref_flag,
2617 tvb, offset, 1, (call_ref[0] & 0x80) != 0);
2618 call_ref[0] &= 0x7F;
2619 proto_tree_add_bytes(q931_tree, hf_q931_call_ref,
2620 tvb, offset, call_ref_len, call_ref);
2622 { /* info for the tap */
2623 call_ref[0] &= 0x7F;
2625 /* XXX - Should crv be something besides a guint32? */
2626 memcpy(&(q931_pi->crv), call_ref, call_ref_len > sizeof(q931_pi->crv) ? sizeof(q931_pi->crv) : call_ref_len );
2627 offset += call_ref_len;
2629 message_type = tvb_get_guint8(tvb, offset);
2630 if(have_valid_q931_pi) {
2631 q931_pi->message_type = message_type;
2633 if (check_col(pinfo->cinfo, COL_INFO)) {
2634 col_add_str(pinfo->cinfo, COL_INFO, get_message_name(prot_discr, message_type));
2636 if (q931_tree != NULL){
2637 if (prot_discr == NLPID_DMS)
2638 proto_tree_add_item(q931_tree, hf_q931_maintenance_message_type, tvb, offset, 1, FALSE);
2640 proto_tree_add_item(q931_tree, hf_q931_message_type, tvb, offset, 1, FALSE);
2645 * And now for the information elements....
2647 if ((message_type != Q931_SEGMENT) || !q931_reassembly ||
2648 (tvb_reported_length_remaining(tvb, offset) <= 4)) {
2649 dissect_q931_IEs(tvb, pinfo, tree, q931_tree, is_over_ip, offset, 0);
2652 info_element = tvb_get_guint8(tvb, offset);
2653 info_element_len = tvb_get_guint8(tvb, offset + 1);
2654 if ((info_element != Q931_IE_SEGMENTED_MESSAGE) || (info_element_len < 2)) {
2655 dissect_q931_IEs(tvb, pinfo, tree, q931_tree, is_over_ip, offset, 0);
2658 /* Segmented message IE */
2659 ti_ie = proto_tree_add_text(q931_tree, tvb, offset, 1+1+info_element_len, "%s",
2660 val_to_str(info_element, q931_info_element_vals[0], "Unknown information element (0x%02X)"));
2661 ie_tree = proto_item_add_subtree(ti_ie, ett_q931_ie);
2662 proto_tree_add_text(ie_tree, tvb, offset, 1, "Information element: %s",
2663 val_to_str(info_element, q931_info_element_vals[0], "Unknown (0x%02X)"));
2664 proto_tree_add_text(ie_tree, tvb, offset + 1, 1, "Length: %u", info_element_len);
2665 dissect_q931_segmented_message_ie(tvb, offset + 2, info_element_len, ie_tree);
2666 first_frag = (tvb_get_guint8(tvb, offset + 2) & 0x80) != 0;
2667 more_frags = (tvb_get_guint8(tvb, offset + 2) & 0x7F) != 0;
2668 segmented_message_type = tvb_get_guint8(tvb, offset + 3);
2669 if (check_col(pinfo->cinfo, COL_INFO)) {
2670 col_append_fstr(pinfo->cinfo, COL_INFO, " of %s",
2671 val_to_str_ext(segmented_message_type, &q931_message_type_vals_ext, "Unknown message type (0x%02X)"));
2673 offset += 1 + 1 + info_element_len;
2675 frag_len = tvb_reported_length_remaining(tvb, offset);
2676 if (first_frag && fragment_get(pinfo, call_ref_val, q931_fragment_table)) {
2677 /* there are some unreassembled segments, ignore them */
2678 fragment_end_seq_next(pinfo, call_ref_val, q931_fragment_table, q931_reassembled_table);
2680 fd_head = fragment_add_seq_next(tvb, offset, pinfo, call_ref_val,
2681 q931_fragment_table, q931_reassembled_table,
2682 frag_len, more_frags);
2684 if (pinfo->fd->num == fd_head->reassembled_in) { /* last fragment */
2685 if (fd_head->next != NULL) { /* 2 or more segments */
2686 next_tvb = tvb_new_child_real_data(tvb, fd_head->data, fd_head->len, fd_head->len);
2687 add_new_data_source(pinfo, next_tvb, "Reassembled Q.931 IEs");
2688 /* Show all fragments. */
2690 proto_item *frag_tree_item;
2691 show_fragment_seq_tree(fd_head, &q931_frag_items, q931_tree, pinfo, next_tvb, &frag_tree_item);
2693 } else { /* only 1 segment */
2694 next_tvb = tvb_new_subset_remaining(tvb, offset);
2696 if (check_col(pinfo->cinfo, COL_INFO)) {
2697 col_add_fstr(pinfo->cinfo, COL_INFO, "%s [reassembled]",
2698 val_to_str_ext(segmented_message_type, &q931_message_type_vals_ext, "Unknown message type (0x%02X)"));
2701 if (tree) proto_tree_add_uint(q931_tree, hf_q931_reassembled_in, tvb, offset, frag_len, fd_head->reassembled_in);
2705 dissect_q931_IEs(next_tvb, pinfo, tree, q931_tree, is_over_ip, 0, 0);
2708 static const value_string q931_codeset_vals[] = {
2709 { 0x00, "Q.931 information elements" },
2710 { 0x04, "Information elements for ISO/IEC use" },
2711 { 0x05, "Information elements for national use" },
2712 { 0x06, "Information elements specific to the local network" },
2713 { 0x07, "User-specific information elements" },
2718 dissect_q931_IEs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root_tree,
2719 proto_tree *q931_tree, gboolean is_over_ip, int offset, int initial_codeset)
2722 proto_tree *ie_tree = NULL;
2723 guint8 info_element;
2725 guint16 info_element_len;
2726 int codeset, locked_codeset;
2727 gboolean non_locking_shift, first_segment;
2728 tvbuff_t *h225_tvb, *next_tvb;
2729 e164_info_t e164_info;
2730 e164_info.e164_number_type = NONE;
2732 codeset = locked_codeset = initial_codeset;
2733 non_locking_shift = TRUE;
2734 first_segment = FALSE;
2735 while (tvb_reported_length_remaining(tvb, offset) > 0) {
2736 info_element = tvb_get_guint8(tvb, offset);
2738 /* Check for the codeset shift */
2739 if ((info_element & Q931_IE_SO_MASK) &&
2740 ((info_element & Q931_IE_SO_IDENTIFIER_MASK) == Q931_IE_SHIFT)) {
2741 non_locking_shift = info_element & Q931_IE_SHIFT_NON_LOCKING;
2742 codeset = info_element & Q931_IE_SHIFT_CODESET;
2743 if (!non_locking_shift)
2744 locked_codeset = codeset;
2745 if (q931_tree != NULL) {
2746 proto_tree_add_text(q931_tree, tvb, offset, 1,
2747 "%s shift to codeset %u: %s",
2748 (non_locking_shift ? "Non-locking" : "Locking"),
2750 val_to_str(codeset, q931_codeset_vals,
2751 "Unknown (0x%02X)"));
2758 * Check for the single-octet IEs.
2760 if (info_element & Q931_IE_SO_MASK) {
2762 * Check for subdissectors for this IE or
2763 * for all IEs in this codeset.
2765 if (dissector_get_port_handle(codeset_dissector_table, codeset) ||
2766 dissector_get_port_handle(ie_dissector_table, (codeset << 8) | (info_element & Q931_IE_SO_IDENTIFIER_MASK))) {
2767 next_tvb = tvb_new_subset (tvb, offset, 1, 1);
2768 if (dissector_try_port(ie_dissector_table, (codeset << 8) | (info_element & Q931_IE_SO_IDENTIFIER_MASK), next_tvb, pinfo, q931_tree) ||
2769 dissector_try_port(codeset_dissector_table, codeset, next_tvb, pinfo, q931_tree)) {
2771 codeset = locked_codeset;
2776 switch ((codeset << 8) | (info_element & Q931_IE_SO_IDENTIFIER_MASK)) {
2778 case CS0 | Q931_IE_MORE_DATA_OR_SEND_COMP:
2779 switch (info_element) {
2781 case Q931_IE_MORE_DATA:
2782 if (q931_tree != NULL) {
2783 proto_tree_add_text(q931_tree, tvb, offset, 1,
2788 case Q931_IE_SENDING_COMPLETE:
2789 if (q931_tree != NULL) {
2790 proto_tree_add_text(q931_tree, tvb, offset, 1,
2791 "Sending complete");
2796 if (q931_tree != NULL) {
2797 proto_tree_add_text(q931_tree, tvb, offset, 1,
2798 "Unknown information element (0x%02X)",
2805 case CS0 | Q931_IE_CONGESTION_LEVEL:
2806 if (q931_tree != NULL) {
2807 proto_tree_add_text(q931_tree, tvb, offset, 1,
2808 "Congestion level: %s",
2809 val_to_str(info_element & Q931_IE_SO_IE_MASK,
2810 q931_congestion_level_vals,
2815 case CS0 | Q931_IE_REPEAT_INDICATOR:
2816 if (q931_tree != NULL) {
2817 proto_tree_add_text(q931_tree, tvb, offset, 1,
2818 "Repeat indicator: %s",
2819 val_to_str(info_element & Q931_IE_SO_IE_MASK,
2820 q931_repeat_indication_vals,
2826 if (q931_tree != NULL) {
2827 proto_tree_add_text(q931_tree, tvb, offset, 1,
2828 "Unknown information element (0x%02X)",
2834 codeset = locked_codeset;
2839 * Variable-length IE.
2841 * According to page 18 from Recommendation H.225.0 :
2842 * " Length of user-user contents contents
2843 * - Shall be 2 octets instead of 1 (as in Figure 4-36/Q.931)"
2845 * We assume that if this is Q.931-over-TPKT, it might
2846 * be H.225 traffic, and check for the IE being a user-user
2847 * IE with ASN.1 encoding of the user information.
2849 if (is_over_ip && tvb_bytes_exist(tvb, offset, 4) &&
2850 codeset == 0 && tvb_get_guint8(tvb, offset) == Q931_IE_USER_USER &&
2851 tvb_get_guint8(tvb, offset + 3) == Q931_PROTOCOL_DISCRIMINATOR_ASN1) {
2852 info_element_len = tvb_get_ntohs(tvb, offset + 1);
2853 if (q931_tree != NULL) {
2854 ti = proto_tree_add_text(q931_tree, tvb, offset,
2855 1+2+info_element_len, "%s",
2856 val_to_str(info_element,
2857 q931_info_element_vals[codeset],
2858 "Unknown information element (0x%02X)"));
2859 ie_tree = proto_item_add_subtree(ti,
2861 proto_tree_add_text(ie_tree, tvb, offset, 1,
2862 "Information element: %s",
2863 val_to_str(info_element,
2864 q931_info_element_vals[codeset], "Unknown (0x%02X)"));
2865 proto_tree_add_text(ie_tree, tvb, offset + 1,
2866 2, "Length: %u", info_element_len);
2867 proto_tree_add_text(ie_tree, tvb, offset + 3,
2868 1, "Protocol discriminator: %s",
2869 val_to_str_ext(tvb_get_guint8(tvb, offset + 3),
2870 &q931_protocol_discriminator_vals_ext,
2871 "Unknown (0x%02x)"));
2874 if (info_element_len > 1) {
2876 * If we don't desegment limit the length
2877 * to the actual size in the frame
2879 if (!pinfo->can_desegment) {
2880 info_element_len = MIN(info_element_len, tvb_length_remaining(tvb, offset + 3));
2883 * Do we have a handle for the H.225
2886 if (h225_handle != NULL) {
2888 * Yes - call it, regardless of
2889 * whether we're building a
2890 * protocol tree or not.
2892 h225_tvb = tvb_new_subset(tvb,
2893 offset + 4, info_element_len - 1,
2894 info_element_len - 1);
2895 call_dissector(h225_handle, h225_tvb,
2899 * No - just show it as "User
2900 * information" (if "ie_tree" is
2901 * null, this won't add anything).
2903 proto_tree_add_text(ie_tree, tvb,
2904 offset + 4, info_element_len - 1,
2905 "User information: %s",
2906 tvb_bytes_to_str(tvb, offset + 4,
2907 info_element_len - 1));
2910 offset += 1 + 2 + info_element_len;
2912 info_element_len = tvb_get_guint8(tvb, offset + 1);
2914 if (first_segment && (tvb_reported_length_remaining(tvb, offset + 2) < info_element_len)) { /* incomplete IE at the end of the 1st segment */
2915 proto_tree_add_text(q931_tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), "Incomplete IE in the 1st segment");
2920 * Check for subdissectors for this IE or
2921 * for all IEs in this codeset.
2923 if (dissector_get_port_handle(codeset_dissector_table, codeset) ||
2924 dissector_get_port_handle(ie_dissector_table, (codeset << 8) | info_element)) {
2925 next_tvb = tvb_new_subset (tvb, offset, info_element_len + 2, info_element_len + 2);
2926 if (dissector_try_port(ie_dissector_table, (codeset << 8) | info_element, next_tvb, pinfo, q931_tree) ||
2927 dissector_try_port(codeset_dissector_table, codeset, next_tvb, pinfo, q931_tree)) {
2928 offset += 2 + info_element_len;
2929 codeset = locked_codeset;
2934 ti = proto_tree_add_text(q931_tree, tvb, offset, 1+1+info_element_len, "%s",
2935 val_to_str(info_element, q931_info_element_vals[codeset], "Unknown information element (0x%02X)"));
2936 ie_tree = proto_item_add_subtree(ti, ett_q931_ie);
2937 proto_tree_add_text(ie_tree, tvb, offset, 1, "Information element: %s",
2938 val_to_str(info_element, q931_info_element_vals[codeset], "Unknown (0x%02X)"));
2939 proto_tree_add_text(ie_tree, tvb, offset + 1, 1, "Length: %u", info_element_len);
2941 if (((codeset << 8) | info_element) == (CS0 | Q931_IE_SEGMENTED_MESSAGE)) {
2942 dissect_q931_segmented_message_ie(tvb, offset + 2, info_element_len, ie_tree);
2943 if (check_col(pinfo->cinfo, COL_INFO)) {
2944 col_append_fstr(pinfo->cinfo, COL_INFO, " of %s",
2945 val_to_str_ext(tvb_get_guint8(tvb, offset + 3), &q931_message_type_vals_ext, "Unknown message type (0x%02X)"));
2947 if (tvb_get_guint8(tvb, offset + 2) & 0x80) { /* the 1st segment */
2948 first_segment = TRUE;
2949 } else { /* not the 1st segment */
2950 proto_tree_add_text(q931_tree, tvb, offset + 4, tvb_reported_length_remaining(tvb, offset + 4), "Message segment");
2951 info_element_len += tvb_reported_length_remaining(tvb, offset + 4);
2955 * For the calling number, called number,
2956 * and release cause IEs, don't check
2957 * for the tree being null, as
2958 * the dissectors for those IEs also
2959 * supply information for the tap used
2962 switch ((codeset << 8) | info_element) {
2964 case CS0 | Q931_IE_BEARER_CAPABILITY:
2965 case CS0 | Q931_IE_LOW_LAYER_COMPAT:
2966 if (q931_tree != NULL) {
2967 dissect_q931_bearer_capability_ie(tvb,
2968 offset + 2, info_element_len,
2973 case CS0 | Q931_IE_CAUSE:
2974 dissect_q931_cause_ie_unsafe(tvb,
2975 offset + 2, info_element_len,
2977 hf_q931_cause_value, &dummy, q931_info_element_vals0);
2980 case CS0 | Q931_IE_CHANGE_STATUS:
2981 if (q931_tree != NULL) {
2982 dissect_q931_change_status_ie(tvb,
2983 offset + 2, info_element_len,
2988 case CS0 | Q931_IE_CALL_STATE:
2989 if (q931_tree != NULL) {
2990 dissect_q931_call_state_ie(tvb,
2991 offset + 2, info_element_len,
2996 case CS0 | Q931_IE_CHANNEL_IDENTIFICATION:
2997 if (q931_tree != NULL) {
2998 dissect_q931_channel_identification_ie(
2999 tvb, offset + 2, info_element_len,
3004 case CS0 | Q931_IE_PROGRESS_INDICATOR:
3005 if (q931_tree != NULL) {
3006 dissect_q931_progress_indicator_ie(tvb,
3007 offset + 2, info_element_len,
3012 case CS0 | Q931_IE_NETWORK_SPECIFIC_FACIL:
3013 case CS0 | Q931_IE_TRANSIT_NETWORK_SEL:
3014 if (q931_tree != NULL) {
3015 dissect_q931_ns_facilities_ie(tvb,
3016 offset + 2, info_element_len,
3021 case CS0 | Q931_IE_NOTIFICATION_INDICATOR:
3022 if (q931_tree != NULL) {
3023 dissect_q931_notification_indicator_ie(
3024 tvb, offset + 2, info_element_len,
3029 case CS0 | Q931_IE_DISPLAY:
3030 if (q931_tree != NULL) {
3031 dissect_q931_ia5_ie(tvb, offset + 2,
3032 info_element_len, ie_tree,
3033 "Display information");
3037 case CS0 | Q931_IE_DATE_TIME:
3038 if (q931_tree != NULL) {
3039 dissect_q931_date_time_ie(tvb,
3040 offset + 2, info_element_len,
3045 case CS0 | Q931_IE_KEYPAD_FACILITY:
3046 if (q931_tree != NULL) {
3047 dissect_q931_ia5_ie(tvb, offset + 2,
3048 info_element_len, ie_tree,
3053 case CS0 | Q931_IE_SIGNAL:
3054 if (q931_tree != NULL) {
3055 dissect_q931_signal_ie(tvb,
3056 offset + 2, info_element_len,
3061 case CS0 | Q931_IE_INFORMATION_RATE:
3062 if (q931_tree != NULL) {
3063 dissect_q931_information_rate_ie(tvb,
3064 offset + 2, info_element_len,
3069 case CS0 | Q931_IE_E2E_TRANSIT_DELAY:
3070 if (q931_tree != NULL) {
3071 dissect_q931_e2e_transit_delay_ie(tvb,
3072 offset + 2, info_element_len,
3077 case CS0 | Q931_IE_TD_SELECTION_AND_INT:
3078 if (q931_tree != NULL) {
3079 dissect_q931_td_selection_and_int_ie(
3080 tvb, offset + 2, info_element_len,
3085 case CS0 | Q931_IE_PL_BINARY_PARAMETERS:
3086 if (q931_tree != NULL) {
3087 dissect_q931_pl_binary_parameters_ie(
3088 tvb, offset + 2, info_element_len,
3093 case CS0 | Q931_IE_PL_WINDOW_SIZE:
3094 if (q931_tree != NULL) {
3095 dissect_q931_pl_window_size_ie(tvb,
3096 offset + 2, info_element_len,
3101 case CS0 | Q931_IE_PACKET_SIZE:
3102 if (q931_tree != NULL) {
3103 dissect_q931_packet_size_ie(tvb,
3104 offset + 2, info_element_len,
3109 case CS0 | Q931_IE_CUG:
3110 if (q931_tree != NULL) {
3111 dissect_q931_cug_ie(tvb,
3112 offset + 2, info_element_len,
3117 case CS0 | Q931_IE_REVERSE_CHARGE_IND:
3118 if (q931_tree != NULL) {
3119 dissect_q931_reverse_charge_ind_ie(tvb,
3120 offset + 2, info_element_len,
3125 case CS0 | Q931_IE_CONNECTED_NUMBER_DEFAULT:
3126 if (q931_tree != NULL) {
3127 dissect_q931_number_ie(tvb,
3128 offset + 2, info_element_len,
3130 hf_q931_connected_number, e164_info);
3135 case CS0 | Q931_IE_CALLING_PARTY_NUMBER:
3136 e164_info.e164_number_type = CALLING_PARTY_NUMBER;
3137 dissect_q931_number_ie(tvb,
3138 offset + 2, info_element_len,
3140 hf_q931_calling_party_number, e164_info);
3143 case CS0 | Q931_IE_CALLED_PARTY_NUMBER:
3144 e164_info.e164_number_type = CALLED_PARTY_NUMBER;
3145 dissect_q931_number_ie(tvb,
3146 offset + 2, info_element_len,
3148 hf_q931_called_party_number, e164_info);
3151 case CS0 | Q931_IE_CALLING_PARTY_SUBADDR:
3152 case CS0 | Q931_IE_CALLED_PARTY_SUBADDR:
3153 if (q931_tree != NULL) {
3154 dissect_q931_party_subaddr_ie(tvb,
3155 offset + 2, info_element_len,
3160 case CS0 | Q931_IE_REDIRECTING_NUMBER:
3161 if (q931_tree != NULL) {
3162 dissect_q931_number_ie(tvb,
3163 offset + 2, info_element_len,
3165 hf_q931_redirecting_number, e164_info);
3169 case CS0 | Q931_IE_RESTART_INDICATOR:
3170 if (q931_tree != NULL) {
3171 dissect_q931_restart_indicator_ie(tvb,
3172 offset + 2, info_element_len,
3177 case CS0 | Q931_IE_HIGH_LAYER_COMPAT:
3178 if (q931_tree != NULL) {
3179 dissect_q931_high_layer_compat_ie(tvb,
3180 offset + 2, info_element_len,
3185 case CS0 | Q931_IE_USER_USER:
3186 if (q931_tree != NULL) {
3187 dissect_q931_user_user_ie(tvb, pinfo,
3188 offset + 2, info_element_len,
3193 case CS5 | Q931_IE_PARTY_CATEGORY:
3194 if (q931_tree != NULL) {
3195 dissect_q931_party_category_ie(tvb,
3196 offset + 2, info_element_len,
3201 case CS6 | Q931_IE_DISPLAY:
3202 if (q931_tree != NULL) {
3203 dissect_q931_ia5_ie(tvb, offset + 2,
3204 info_element_len, ie_tree,
3210 if (q931_tree != NULL) {
3211 proto_tree_add_text(ie_tree, tvb,
3212 offset + 2, info_element_len,
3215 tvb_get_ptr(tvb, offset + 2,
3222 offset += 1 + 1 + info_element_len;
3224 codeset = locked_codeset;
3226 if(have_valid_q931_pi) {
3227 tap_queue_packet(q931_tap, pinfo, q931_pi);
3229 have_valid_q931_pi=FALSE;
3233 * Q.931-over-TPKT-over-TCP.
3236 dissect_q931_tpkt_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3241 * Check whether this looks like a TPKT-encapsulated
3244 * The minimum length of a Q.931 message is 3:
3245 * 1 byte for the protocol discriminator,
3246 * 1 for the call_reference length,
3247 * and one for the message type.
3249 lv_tpkt_len = is_tpkt(tvb, 3);
3250 if (lv_tpkt_len == -1) {
3252 * It's not a TPKT packet; reject it.
3258 * If this segment is *exactly* the length of a TPKT header,
3259 * we assume that, as it looks like a TPKT header, it
3260 * is one, and that the code put a TPKT header in one
3261 * segment and the rest of the PDU in another.
3263 if (tvb_length(tvb) == 4) {
3265 * It is - call the "dissect TPKT over a TCP stream"
3268 dissect_tpkt_encap(tvb, pinfo, tree, q931_desegment,
3269 q931_tpkt_pdu_handle);
3274 * Well, we have more data than just the TPKT header;
3275 * check whether it looks like the beginning of a
3278 * The minimum length of a Q.931 message is 3, as per the
3281 * Check that we have that many bytes past the TPKT header in
3282 * the tvbuff; we already know that the TPKT header says we
3283 * have that many bytes (as we passed 3 as the "min_len" argument
3286 if (!tvb_bytes_exist(tvb, 4, 3))
3289 /* Check the protocol discriminator */
3290 if ((tvb_get_guint8(tvb, 4) != NLPID_Q_931) && (tvb_get_guint8(tvb, 4) != 0x03)) {
3291 /* Doesn't look like Q.931 inside TPKT */
3296 * OK, it looks like Q.931-over-TPKT.
3297 * Call the "dissect TPKT over a TCP stream" routine.
3299 dissect_tpkt_encap(tvb, pinfo, tree, q931_desegment,
3300 q931_tpkt_pdu_handle);
3306 dissect_q931_tpkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3308 dissect_q931_tpkt_heur(tvb, pinfo, tree);
3312 dissect_q931_tpkt_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3314 dissect_q931_pdu(tvb, pinfo, tree, TRUE);
3318 dissect_q931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3320 dissect_q931_pdu(tvb, pinfo, tree, FALSE);
3324 dissect_q931_over_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3326 dissect_q931_pdu(tvb, pinfo, tree, TRUE);
3330 dissect_q931_ie_cs0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3332 dissect_q931_IEs(tvb, pinfo, NULL, tree, FALSE, 0, 0);
3336 dissect_q931_ie_cs7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3338 dissect_q931_IEs(tvb, pinfo, NULL, tree, FALSE, 0, 7);
3343 /* Initialize the fragment and reassembly tables */
3344 fragment_table_init(&q931_fragment_table);
3345 reassembled_table_init(&q931_reassembled_table);
3349 proto_register_q931(void)
3351 static hf_register_info hf[] = {
3352 { &hf_q931_discriminator,
3353 { "Protocol discriminator", "q931.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
3356 { &hf_q931_call_ref_len,
3357 { "Call reference value length", "q931.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
3360 { &hf_q931_call_ref_flag,
3361 { "Call reference flag", "q931.call_ref_flag", FT_BOOLEAN, BASE_NONE, TFS(&tfs_call_ref_flag), 0x0,
3364 { &hf_q931_call_ref,
3365 { "Call reference value", "q931.call_ref", FT_BYTES, BASE_NONE, NULL, 0x0,
3368 { &hf_q931_message_type,
3369 { "Message type", "q931.message_type", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_message_type_vals_ext, 0x0,
3372 { &hf_q931_maintenance_message_type,
3373 { "Maintenance message type", "q931.maintenance_message_type", FT_UINT8, BASE_HEX, VALS(dms_message_type_vals), 0x0,
3376 { &hf_q931_segment_type,
3377 { "Segmented message type", "q931.segment_type", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_message_type_vals_ext, 0x0,
3380 { &hf_q931_coding_standard,
3381 { "Coding standard", "q931.coding_standard", FT_UINT8, BASE_HEX,
3382 VALS(q931_coding_standard_vals), 0x60,NULL, HFILL }},
3384 { &hf_q931_interpretation,
3385 { "Interpretation", "q931.interpretation", FT_UINT8, BASE_HEX,
3386 VALS(q931_interpretation_vals), 0x1C, NULL, HFILL}},
3388 { &hf_q931_pres_meth_prot_prof,
3389 { "Presentation method of protocol profile", "q931.presentation_method_protocol_profile", FT_UINT8, BASE_HEX,
3390 VALS(q931_pres_meth_prot_prof_vals), 0x03, NULL, HFILL}},
3392 { &hf_q931_high_layer_characteristics,
3393 { "High layer characteristics identification", "q931.high_layer_characteristics", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
3394 &q931_high_layer_characteristics_vals_ext, 0x7f, NULL, HFILL }},
3396 { &hf_q931_extended_high_layer_characteristics,
3397 { "Extended high layer characteristics identification", "q931.extended_high_layer_characteristics", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
3398 &q931_extended_high_layer_characteristics_vals_ext, 0x7f, NULL, HFILL }},
3400 { &hf_q931_extended_audiovisual_characteristics,
3401 { "Extended audiovisual characteristics identification", "q931.extended_audiovisual_characteristics", FT_UINT8, BASE_HEX,
3402 VALS(q931_audiovisual_characteristics_vals), 0x7f, NULL, HFILL }},
3404 { &hf_q931_information_transfer_capability,
3405 { "Information transfer capability", "q931.information_transfer_capability", FT_UINT8, BASE_HEX,
3406 VALS(q931_information_transfer_capability_vals), 0x1f,NULL, HFILL }},
3408 { &hf_q931_transfer_mode,
3409 { "Transfer mode", "q931.transfer_mode", FT_UINT8, BASE_HEX,
3410 VALS(q931_transfer_mode_vals), 0x60,NULL, HFILL }},
3412 { &hf_q931_information_transfer_rate,
3413 { "Information transfer rate", "q931.information_transfer_rate", FT_UINT8, BASE_HEX,
3414 VALS(q931_information_transfer_rate_vals), 0x1f,NULL, HFILL }},
3416 { &hf_q931_layer_ident,
3417 { "Layer identification", "q931.layer_ident", FT_UINT8, BASE_HEX,
3418 VALS(q931_bearer_capability_layer_ident_vals), 0x60, NULL, HFILL }},
3421 { "User information layer 1 protocol", "q931.uil1", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
3422 &q931_uil1_vals_ext, 0x1f,NULL, HFILL }},
3424 { &hf_q931_cause_location,
3425 { "Cause location", "q931.cause_location", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &q931_cause_location_vals_ext, 0x0f,
3428 { &hf_q931_cause_value,
3429 { "Cause value", "q931.cause_value", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &q931_cause_code_vals_ext, 0x7f,
3432 { &hf_q931_number_type,
3433 { "Number type", "q931.number_type", FT_UINT8, BASE_HEX, VALS(q931_number_type_vals), 0x70,
3436 { &hf_q931_numbering_plan,
3437 { "Numbering plan", "q931.numbering_plan", FT_UINT8, BASE_HEX, VALS(q931_numbering_plan_vals), 0x0f,
3440 { &hf_q931_screening_ind,
3441 { "Screening indicator", "q931.screening_ind", FT_UINT8, BASE_HEX, VALS(q931_screening_indicator_vals), 0x03,
3444 { &hf_q931_presentation_ind,
3445 { "Presentation indicator", "q931.presentation_ind", FT_UINT8, BASE_HEX, VALS(q931_presentation_indicator_vals), 0x60,
3448 { &hf_q931_extension_ind,
3449 { "Extension indicator", "q931.extension_ind",
3450 FT_BOOLEAN, 8, TFS(&q931_extension_ind_value), 0x80,
3453 { &hf_q931_calling_party_number,
3454 { "Calling party number digits", "q931.calling_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3457 { &hf_q931_called_party_number,
3458 { "Called party number digits", "q931.called_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3461 { &hf_q931_connected_number,
3462 { "Connected party number digits", "q931.connected_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3465 { &hf_q931_redirecting_number,
3466 { "Redirecting party number digits", "q931.redirecting_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3469 /* fields for channel identification IE */
3470 /* 0x80 is the extension bit */
3472 { &hf_q931_channel_interface_explicit,
3473 { "Interface identifier present", "q931.channel.interface_id_present", FT_BOOLEAN, 8, NULL, 0x40,
3474 "True if the interface identifier is explicit in the following octets", HFILL }},
3476 { &hf_q931_channel_interface_type,
3477 { "Interface type", "q931.channel.interface_type", FT_BOOLEAN, 8, TFS(&tfs_interface_type), 0x20,
3478 "Identifies the ISDN interface type", HFILL }},
3482 { &hf_q931_channel_exclusive,
3483 { "Indicated channel", "q931.channel.exclusive", FT_BOOLEAN, 8, TFS(&tfs_channel_exclusive), 0x08,
3484 "True if only the indicated channel is acceptable", HFILL }},
3486 { &hf_q931_channel_dchan,
3487 { "D-channel indicator", "q931.channel.dchan", FT_BOOLEAN, 8, NULL, 0x04,
3488 "True if the identified channel is the D-Channel", HFILL }},
3490 { &hf_q931_channel_selection_bri,
3491 { "Information channel selection", "q931.channel.selection", FT_UINT8, BASE_HEX, q931_basic_channel_selection_vals, 0x03,
3492 "Identifies the information channel to be used", HFILL }},
3494 { &hf_q931_channel_selection_pri,
3495 { "Information channel selection", "q931.channel.selection", FT_UINT8, BASE_HEX, q931_not_basic_channel_selection_vals, 0x03,
3496 "Identifies the information channel to be used", HFILL }},
3498 { &hf_q931_channel_map,
3499 { "Number/map", "q931.channel.map", FT_BOOLEAN, 8, TFS(&tfs_channel_map), 0x10,
3500 "True if channel is indicates by channel map rather than number", HFILL }},
3502 { &hf_q931_channel_element_type,
3503 { "Element type", "q931.channel.element_type", FT_UINT8, BASE_HEX, q931_element_type_vals, 0xF,
3504 "Type of element in the channel number/slot map octets", HFILL }},
3506 { &hf_q931_channel_number,
3507 { "Channel number", "q931.channel.number", FT_UINT8, BASE_DEC, NULL, 0x7F,
3510 /* desegmentation fields */
3511 { &hf_q931_segment_overlap,
3512 { "Segment overlap", "q931.segment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3513 "Fragment overlaps with other fragments", HFILL }},
3515 { &hf_q931_segment_overlap_conflict,
3516 { "Conflicting data in fragment overlap", "q931.segment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3517 "Overlapping fragments contained conflicting data", HFILL }},
3519 { &hf_q931_segment_multiple_tails,
3520 { "Multiple tail fragments found", "q931.segment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3521 "Several tails were found when defragmenting the packet", HFILL }},
3523 { &hf_q931_segment_too_long_segment,
3524 { "Segment too long", "q931.segment.toolongfragment", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3525 "Segment contained data past end of packet", HFILL }},
3527 { &hf_q931_segment_error,
3528 { "Defragmentation error", "q931.segment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3529 "Defragmentation error due to illegal fragments", HFILL }},
3532 { "Q.931 Segment", "q931.segment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3535 { &hf_q931_segments,
3536 { "Q.931 Segments", "q931.segments", FT_NONE, BASE_NONE, NULL, 0x0,
3539 { &hf_q931_reassembled_in,
3540 { "Reassembled Q.931 in frame", "q931.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3541 "This Q.931 message is reassembled in this frame", HFILL}},
3543 { &hf_q931_reassembled_length,
3544 { "Reassembled Q.931 length", "q931.reassembled.length", FT_UINT32, BASE_DEC, NULL, 0x0,
3545 "The total length of the reassembled payload", HFILL}},
3547 static gint *ett[] = {
3553 module_t *q931_module;
3555 proto_q931 = proto_register_protocol("Q.931", "Q.931", "q931");
3556 proto_register_field_array (proto_q931, hf, array_length(hf));
3557 proto_register_subtree_array(ett, array_length(ett));
3558 register_init_routine(q931_init);
3560 register_dissector("q931", dissect_q931, proto_q931);
3561 register_dissector("q931.tpkt", dissect_q931_tpkt, proto_q931);
3562 q931_tpkt_handle = find_dissector("q931.tpkt");
3563 q931_tpkt_pdu_handle = create_dissector_handle(dissect_q931_tpkt_pdu,
3565 register_dissector("q931.over_ip", dissect_q931_over_ip, proto_q931);
3566 register_dissector("q931.ie", dissect_q931_ie_cs0, proto_q931);
3567 register_dissector("q931.ie.cs7", dissect_q931_ie_cs7, proto_q931);
3569 /* subdissector code */
3570 codeset_dissector_table = register_dissector_table("q931.codeset", "Q.931 Codeset", FT_UINT8, BASE_HEX);
3571 ie_dissector_table = register_dissector_table("q931.ie", "Q.931 IE", FT_UINT16, BASE_HEX);
3572 register_heur_dissector_list("q931_user", &q931_user_heur_subdissector_list);
3574 q931_module = prefs_register_protocol(proto_q931, NULL);
3575 prefs_register_bool_preference(q931_module, "desegment_h323_messages",
3576 "Reassemble Q.931 messages spanning multiple TCP segments",
3577 "Whether the Q.931 dissector should reassemble messages spanning multiple TCP segments."
3578 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
3580 prefs_register_bool_preference(q931_module, "reassembly",
3581 "Reassemble segmented Q.931 messages",
3582 "Reassemble segmented Q.931 messages (Q.931 - Annex H)",
3584 /* Register for tapping */
3585 q931_tap = register_tap("q931");
3589 proto_reg_handoff_q931(void)
3591 dissector_handle_t q931_handle;
3592 dissector_handle_t q931_over_ip_handle;
3594 q931_handle = find_dissector("q931");
3595 dissector_add("lapd.sapi", LAPD_SAPI_Q931, q931_handle);
3597 q931_over_ip_handle = find_dissector("q931.over_ip");
3598 dissector_add("sctp.ppi", H323_PAYLOAD_PROTOCOL_ID, q931_over_ip_handle);
3601 * Attempt to get a handle for the H.225 dissector.
3602 * If we can't, the handle we get is null, and we'll just
3603 * dissect putatively-H.255 Call Signaling stuff as User
3606 h225_handle = find_dissector("h225");
3608 data_handle = find_dissector("data");
3613 heur_dissector_add("tcp", dissect_q931_tpkt_heur, proto_q931);
3616 static void reset_q931_packet_info(q931_packet_info *pi)
3622 pi->calling_number = NULL;
3623 pi->called_number = NULL;
3624 pi->cause_value = 0xFF;