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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include <epan/packet.h>
34 #include <epan/strutil.h>
35 #include <epan/nlpid.h>
36 #include "packet-q931.h"
37 #include "packet-e164.h"
38 #include <epan/prefs.h>
39 #include <epan/reassemble.h>
40 #include <epan/wmem/wmem.h>
42 #include <epan/sctpppids.h>
43 #include <epan/lapd_sapi.h>
44 #include "packet-tpkt.h"
49 * http://www.acacia-net.com/Clarinet/Protocol/q9313svn.htm
50 * http://www.acacia-net.com/Clarinet/Protocol/q9311sc3.htm
51 * http://www.acacia-net.com/Clarinet/Protocol/q9317oz7.htm
52 * http://www.protocols.com/pbook/isdn.htm
53 * http://freesoft.org/CIE/Topics/126.htm
54 * http://noc.comstar.ru/miscdocs/ascend-faq-cause-codes.html
55 * http://www.andrews-arnold.co.uk/isdn/q931cause.html
56 * http://www.tulatelecom.ru/staff/german/DSSHelp/MessList/InfEl/InfElList.html
58 static void reset_q931_packet_info(q931_packet_info
*pi
);
59 static gboolean have_valid_q931_pi
=FALSE
;
60 static q931_packet_info
*q931_pi
=NULL
;
61 static int q931_tap
= -1;
63 static int proto_q931
= -1;
64 static int hf_q931_discriminator
= -1;
65 static int hf_q931_coding_standard
= -1;
66 static int hf_q931_interpretation
= -1;
67 static int hf_q931_pres_meth_prot_prof
= -1;
68 static int hf_q931_high_layer_characteristics
= -1;
69 static int hf_q931_extended_high_layer_characteristics
= -1;
70 static int hf_q931_extended_audiovisual_characteristics
= -1;
71 static int hf_q931_information_transfer_capability
= -1;
72 static int hf_q931_transfer_mode
= -1;
73 static int hf_q931_information_transfer_rate
= -1;
74 static int hf_q931_layer_ident
= -1;
75 static int hf_q931_uil1
= -1;
76 static int hf_q931_call_ref_len
= -1;
77 static int hf_q931_call_ref_flag
= -1;
78 static int hf_q931_call_ref
= -1;
79 static int hf_q931_message_type
= -1;
80 static int hf_q931_maintenance_message_type
= -1;
81 static int hf_q931_segment_type
= -1;
82 static int hf_q931_cause_location
= -1;
83 static int hf_q931_cause_value
= -1;
84 static int hf_q931_number_type
= -1;
85 static int hf_q931_numbering_plan
= -1;
86 static int hf_q931_extension_ind
= -1;
87 static int hf_q931_extension_ind_preference
= -1;
88 static int hf_q931_extension_ind_new_status
= -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_segment_count
= -1;
116 static int hf_q931_reassembled_in
= -1;
117 static int hf_q931_reassembled_length
= -1;
119 static gint ett_q931
= -1;
120 static gint ett_q931_ie
= -1;
122 static gint ett_q931_segments
= -1;
123 static gint ett_q931_segment
= -1;
125 static const fragment_items q931_frag_items
= {
131 &hf_q931_segment_overlap
,
132 &hf_q931_segment_overlap_conflict
,
133 &hf_q931_segment_multiple_tails
,
134 &hf_q931_segment_too_long_segment
,
135 &hf_q931_segment_error
,
136 &hf_q931_segment_count
,
137 &hf_q931_reassembled_in
,
138 &hf_q931_reassembled_length
,
139 /* Reassembled data field */
144 /* Table for reassembly of fragments. */
145 static reassembly_table q931_reassembly_table
;
148 static gboolean q931_reassembly
= TRUE
;
150 static dissector_table_t codeset_dissector_table
;
151 static dissector_table_t ie_dissector_table
;
153 /* desegmentation of Q.931 over TPKT over TCP */
154 static gboolean q931_desegment
= TRUE
;
157 static dissector_handle_t h225_handle
;
158 static dissector_handle_t q931_tpkt_handle
;
159 static dissector_handle_t q931_tpkt_pdu_handle
;
160 static dissector_handle_t data_handle
= NULL
;
162 static heur_dissector_list_t q931_user_heur_subdissector_list
;
165 dissect_q931_IEs(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*root_tree
,
166 proto_tree
*q931_tree
, gboolean is_over_ip
, int offset
, int initial_codeset
);
168 const value_string q931_message_type_vals
[] = {
169 /* 0 */ { Q931_ESCAPE
, "ESCAPE" },
170 /* 1 */ { Q931_ALERTING
, "ALERTING" },
171 /* 2 */ { Q931_CALL_PROCEEDING
, "CALL PROCEEDING" },
172 /* 3 */ { Q931_PROGRESS
, "PROGRESS" },
173 /* 5 */ { Q931_SETUP
, "SETUP" },
174 /* 6 */ { Q931_GROUIP_SERVICE
, "GROUP SERVICE" },
175 /* 7 */ { Q931_CONNECT
, "CONNECT" },
176 /* 8 */ { Q931_RESYNC_REQ
, "RESYNC REQ" },
177 /* 9 */ { Q931_RESYNC_RESP
, "RESYNC RESP" },
178 /* 10 */ { Q931_VERSION
, "VERSION" },
179 /* 11 */ { Q931_GROUIP_SERVICE_ACK
, "GROUP SERVICE ACK" },
180 /* 13 */ { Q931_SETUP_ACK
, "SETUP ACKNOWLEDGE" },
181 /* 15 */ { Q931_CONNECT_ACK
, "CONNECT ACKNOWLEDGE" },
182 /* 32 */ { Q931_USER_INFORMATION
, "USER INFORMATION" },
183 /* 33 */ { Q931_SUSPEND_REJECT
, "SUSPEND REJECT" },
184 /* 34 */ { Q931_RESUME_REJECT
, "RESUME REJECT" },
185 /* 36 */ { Q931_HOLD
, "HOLD" },
186 /* 37 */ { Q931_SUSPEND
, "SUSPEND" },
187 /* 38 */ { Q931_RESUME
, "RESUME" },
188 /* 40 */ { Q931_HOLD_ACK
, "HOLD_ACKNOWLEDGE" },
189 /* 45 */ { Q931_SUSPEND_ACK
, "SUSPEND ACKNOWLEDGE" },
190 /* 46 */ { Q931_RESUME_ACK
, "RESUME ACKNOWLEDGE" },
191 /* 48 */ { Q931_HOLD_REJECT
, "HOLD_REJECT" },
192 /* 49 */ { Q931_RETRIEVE
, "RETRIEVE" },
193 /* 51 */ { Q931_RETRIEVE_ACK
, "RETRIEVE ACKNOWLEDGE" },
194 /* 55 */ { Q931_RETRIEVE_REJECT
, "RETRIEVE REJECT" },
195 /* 64 */ { Q931_DETACH
, "DETACH" },
196 /* 69 */ { Q931_DISCONNECT
, "DISCONNECT" },
197 /* 70 */ { Q931_RESTART
, "RESTART" },
198 /* 72 */ { Q931_DETACH_ACKNOWLEDGE
, "DETACH ACKNOWLEDGE" },
199 /* 77 */ { Q931_RELEASE
, "RELEASE" },
200 /* 78 */ { Q931_RESTART_ACK
, "RESTART ACKNOWLEDGE" },
201 /* 90 */ { Q931_RELEASE_COMPLETE
, "RELEASE COMPLETE" },
202 /* 96 */ { Q931_SEGMENT
, "SEGMENT" },
203 /* 98 */ { Q931_FACILITY
, "FACILITY" },
204 /*100 */ { Q931_REGISTER
, "REGISTER" },
205 /*106 */ { Q931_FACILITY_ACKNOWLEDGE
, "FACILITY ACKNOWLEDGE" },
206 /*110 */ { Q931_NOTIFY
, "NOTIFY" },
207 /*114 */ { Q931_FACILITY_REJECT
, "FACILITY REJECT" },
208 /*117 */ { Q931_STATUS_ENQUIRY
, "STATUS ENQUIRY" },
209 /*121 */ { Q931_CONGESTION_CONTROL
, "CONGESTION CONTROL" },
210 /*123 */ { Q931_INFORMATION
, "INFORMATION" },
211 /*125 */ { Q931_STATUS
, "STATUS" },
215 static value_string_ext q931_message_type_vals_ext
= VALUE_STRING_EXT_INIT(q931_message_type_vals
);
217 static const value_string dms_message_type_vals
[] = {
218 { DMS_SERVICE_ACKNOWLEDGE
, "SERVICE ACKNOWLEDGE" },
219 { DMS_SERVICE
, "SERVICE" },
224 * NOTE For call reference flag (octet 2)
226 * 0 The message is sent from the side that originates the call reference
227 * 1 The message is sent to the side that originates the call reference
229 static const true_false_string tfs_call_ref_flag
= {
230 "Message sent to originating side",
231 "Message sent from originating side"
234 static const true_false_string tfs_interface_type
= {
235 "Primary rate interface",
236 "Basic rate interface"
239 static const true_false_string tfs_channel_exclusive
= {
240 "Exclusive; only the indicated channel is acceptable",
241 "Indicated channel is preferred"
244 static const true_false_string tfs_channel_map
= {
245 "Channel indicated by slot map",
246 "Channel indicated by number"
250 * Information elements.
253 /* Shifted codeset values */
263 #define Q931_IE_SO_MASK 0x80 /* single-octet/variable-length mask */
267 #define Q931_IE_SO_IDENTIFIER_MASK 0xf0 /* IE identifier mask */
268 #define Q931_IE_SO_IDENTIFIER_SHIFT 4 /* IE identifier shift */
269 #define Q931_IE_SO_IE_MASK 0x0F /* IE mask */
271 #define Q931_IE_SHIFT 0x90
272 #define Q931_IE_SHIFT_NON_LOCKING 0x08 /* non-locking shift */
273 #define Q931_IE_SHIFT_CODESET 0x07 /* codeset */
275 #define Q931_IE_MORE_DATA_OR_SEND_COMP 0xA0 /* More Data or Sending Complete */
276 #define Q931_IE_MORE_DATA 0xA0
277 #define Q931_IE_SENDING_COMPLETE 0xA1
279 #define Q931_IE_CONGESTION_LEVEL 0xB0
280 #define Q931_IE_REPEAT_INDICATOR 0xD0
283 * Variable-length IEs.
285 #define Q931_IE_VL_EXTENSION 0x80 /* Extension flag */
286 /* extension bit. The bit value "0" indicates that the octet continues through the */
287 /* next octet. The bit value "1" indicates that this octet is the last octet */
289 static const true_false_string q931_extension_ind_value
= {
291 "information continues through the next octet"
296 * Codeset 0 (default).
298 #define Q931_IE_SEGMENTED_MESSAGE 0x00
299 #define Q931_IE_CHANGE_STATUS 0x01
300 #define Q931_IE_BEARER_CAPABILITY 0x04
301 #define Q931_IE_CAUSE 0x08
302 #define Q931_IE_CALL_IDENTITY 0x10
303 #define Q931_IE_CALL_STATE 0x14
304 #define Q931_IE_CHANNEL_IDENTIFICATION 0x18
305 #define Q931_IE_FACILITY 0x1C
306 #define Q931_IE_PROGRESS_INDICATOR 0x1E
307 #define Q931_IE_NETWORK_SPECIFIC_FACIL 0x20 /* Network Specific Facilities */
308 #define Q931_IE_NOTIFICATION_INDICATOR 0x27
309 #define Q931_IE_DISPLAY 0x28
310 #define Q931_IE_DATE_TIME 0x29
311 #define Q931_IE_KEYPAD_FACILITY 0x2C
312 #define Q931_IE_INFORMATION_REQUEST 0x32
313 #define Q931_IE_SIGNAL 0x34
314 #define Q931_IE_SWITCHHOOK 0x36
315 #define Q931_IE_FEATURE_ACTIVATION 0x38
316 #define Q931_IE_FEATURE_INDICATION 0x39
317 #define Q931_IE_ENDPOINT_IDENTIFIER 0x3B
318 #define Q931_IE_SERVICE_PROFILE_ID 0x3A
319 #define Q931_IE_INFORMATION_RATE 0x40
320 #define Q931_IE_E2E_TRANSIT_DELAY 0x42 /* End-to-end Transit Delay */
321 #define Q931_IE_TD_SELECTION_AND_INT 0x43 /* Transit Delay Selection and Indication */
322 #define Q931_IE_PL_BINARY_PARAMETERS 0x44 /* Packet layer binary parameters */
323 #define Q931_IE_PL_WINDOW_SIZE 0x45 /* Packet layer window size */
324 #define Q931_IE_PACKET_SIZE 0x46 /* Packet size */
325 #define Q931_IE_CUG 0x47 /* Closed user group */
326 #define Q931_IE_REVERSE_CHARGE_IND 0x4A /* Reverse charging indication */
327 #define Q931_IE_CONNECTED_NUMBER_DEFAULT 0x4C /* Connected Number */
328 #define Q931_IE_INTERFACE_SERVICE 0x66 /* q931+ Interface Service */
329 #define Q931_IE_CHANNEL_STATUS 0x67 /* q931+ Channel Status */
330 #define Q931_IE_VERSION_INFO 0x68 /* q931+ Version Info */
331 #define Q931_IE_CALLING_PARTY_NUMBER 0x6C /* Calling Party Number */
332 #define Q931_IE_CALLING_PARTY_SUBADDR 0x6D /* Calling Party Subaddress */
333 #define Q931_IE_CALLED_PARTY_NUMBER 0x70 /* Called Party Number */
334 #define Q931_IE_CALLED_PARTY_SUBADDR 0x71 /* Called Party Subaddress */
335 #define Q931_IE_REDIRECTING_NUMBER 0x74
336 #define Q931_IE_REDIRECTION_NUMBER 0x76
337 #define Q931_IE_TRANSIT_NETWORK_SEL 0x78 /* Transit Network Selection */
338 #define Q931_IE_RESTART_INDICATOR 0x79
339 #define Q931_IE_LOW_LAYER_COMPAT 0x7C /* Low-Layer Compatibility */
340 #define Q931_IE_HIGH_LAYER_COMPAT 0x7D /* High-Layer Compatibility */
341 #define Q931_IE_USER_USER 0x7E /* User-User */
342 #define Q931_IE_ESCAPE 0x7F /* Escape for extension */
347 #define Q931_IE_CONNECTED_NUMBER 0x8C
348 #define Q931_IE_CONNECTED_SUBADDR 0x8D
351 * Codeset 5 (National-specific) Belgium.
353 #define Q931_IE_CHARGING_ADVICE 0x1A
356 * Codeset 5 (National-specific) Bellcore National ISDN.
358 #define Q931_IE_OPERATOR_SYSTEM_ACCESS 0x1D
361 * Codeset 5 ETSI ETS 300 192
363 #define Q931_IE_PARTY_CATEGORY 0x32
366 * Codeset 6 (Network-specific) Belgium.
368 /* 0x1A is Charging Advice, as with Codeset 5 */
369 #define Q931_IE_REDIRECTING_NUMBER 0x74
372 * Codeset 6 (Network-specific) FT-Numeris.
374 /* 0x1D is User Capability */
377 * Codeset 6 (Network-specific) Bellcore National ISDN.
379 #define Q931_IE_REDIRECTING_SUBADDR 0x75 /* Redirecting Subaddress */
380 /* 0x76 is Redirection Number, but that's also Codeset 0 */
381 #define Q931_IE_CALL_APPEARANCE 0x7B
384 static const value_string q931_info_element_vals0
[] = {
385 { Q931_IE_SEGMENTED_MESSAGE
, "Segmented message" },
386 { Q931_IE_CHANGE_STATUS
, "Change status" },
387 { Q931_IE_BEARER_CAPABILITY
, "Bearer capability" },
388 { Q931_IE_CAUSE
, "Cause" },
389 { Q931_IE_CALL_IDENTITY
, "Call identity" },
390 { Q931_IE_CALL_STATE
, "Call state" },
391 { Q931_IE_CHANNEL_IDENTIFICATION
, "Channel identification" },
392 { Q931_IE_FACILITY
, "Facility" },
393 { Q931_IE_PROGRESS_INDICATOR
, "Progress indicator" },
394 { Q931_IE_NETWORK_SPECIFIC_FACIL
, "Network specific facilities" },
395 { Q931_IE_NOTIFICATION_INDICATOR
, "Notification indicator" },
396 { Q931_IE_DISPLAY
, "Display" },
397 { Q931_IE_DATE_TIME
, "Date/Time" },
398 { Q931_IE_KEYPAD_FACILITY
, "Keypad facility" },
399 { Q931_IE_INFORMATION_REQUEST
, "Information request" },
400 { Q931_IE_SIGNAL
, "Signal" },
401 { Q931_IE_SWITCHHOOK
, "Switchhook" },
402 { Q931_IE_FEATURE_ACTIVATION
, "Feature activation" },
403 { Q931_IE_FEATURE_INDICATION
, "Feature Indication" },
404 { Q931_IE_ENDPOINT_IDENTIFIER
, "Endpoint identifier" },
405 { Q931_IE_SERVICE_PROFILE_ID
, "Service profile ID" },
406 { Q931_IE_INFORMATION_RATE
, "Information rate" },
407 { Q931_IE_E2E_TRANSIT_DELAY
, "End-to-end transit delay" },
408 { Q931_IE_TD_SELECTION_AND_INT
, "Transit delay selection and indication" },
409 { Q931_IE_PL_BINARY_PARAMETERS
, "Packet layer binary parameters" },
410 { Q931_IE_PL_WINDOW_SIZE
, "Packet layer window size" },
411 { Q931_IE_PACKET_SIZE
, "Packet size" },
412 { Q931_IE_CUG
, "Closed user group" },
413 { Q931_IE_REVERSE_CHARGE_IND
, "Reverse charging indication" },
414 { Q931_IE_CONNECTED_NUMBER_DEFAULT
, "Connected number" },
415 { Q931_IE_INTERFACE_SERVICE
, "Interface Service" },
416 { Q931_IE_CHANNEL_STATUS
, "Channel Status" },
417 { Q931_IE_VERSION_INFO
, "Version Info" },
418 { Q931_IE_CALLING_PARTY_NUMBER
, "Calling party number" },
419 { Q931_IE_CALLING_PARTY_SUBADDR
, "Calling party subaddress" },
420 { Q931_IE_CALLED_PARTY_NUMBER
, "Called party number" },
421 { Q931_IE_CALLED_PARTY_SUBADDR
, "Called party subaddress" },
422 { Q931_IE_REDIRECTING_NUMBER
, "Redirecting number" },
423 { Q931_IE_REDIRECTION_NUMBER
, "Redirection number" },
424 { Q931_IE_TRANSIT_NETWORK_SEL
, "Transit network selection" },
425 { Q931_IE_RESTART_INDICATOR
, "Restart indicator" },
426 { Q931_IE_LOW_LAYER_COMPAT
, "Low-layer compatibility" },
427 { Q931_IE_HIGH_LAYER_COMPAT
, "High-layer compatibility" },
428 { Q931_IE_USER_USER
, "User-user" },
429 { Q931_IE_ESCAPE
, "Escape" },
430 { Q931_IE_CONNECTED_NUMBER
, "Connected number" },
431 { Q931_IE_CONNECTED_SUBADDR
, "Connected subaddress" },
436 static const value_string q931_info_element_vals1
[] = {
440 static const value_string q931_info_element_vals2
[] = {
444 static const value_string q931_info_element_vals3
[] = {
448 static const value_string q931_info_element_vals4
[] = {
452 static const value_string q931_info_element_vals5
[] = {
453 { Q931_IE_CHARGING_ADVICE
, "Charging advice" },
454 { Q931_IE_OPERATOR_SYSTEM_ACCESS
, "Operator system access" },
455 { Q931_IE_PARTY_CATEGORY
, "Party category"},
459 static const value_string q931_info_element_vals6
[] = {
460 { Q931_IE_REDIRECTING_NUMBER
, "Redirecting number" },
461 { Q931_IE_REDIRECTING_SUBADDR
, "Redirecting subaddress" },
462 { Q931_IE_CALL_APPEARANCE
, "Call appearance" },
463 { Q931_IE_DISPLAY
, "Avaya Display" }, /* if Avaya codeset to send display = 6 */
467 static const value_string q931_info_element_vals7
[] = {
472 #define NUM_INFO_ELEMENT_VALS (Q931_IE_SHIFT_CODESET+1)
473 static const value_string
*q931_info_element_vals
[NUM_INFO_ELEMENT_VALS
] = {
474 q931_info_element_vals0
,
475 q931_info_element_vals1
,
476 q931_info_element_vals2
,
477 q931_info_element_vals3
,
478 q931_info_element_vals4
,
479 q931_info_element_vals5
,
480 q931_info_element_vals6
,
481 q931_info_element_vals7
,
484 static const value_string q931_congestion_level_vals
[] = {
485 { 0x0, "Receiver ready" },
486 { 0xF, "Receiver not ready" },
490 static const value_string q931_repeat_indication_vals
[] = {
491 { 0x2, "Prioritized list" },
496 * ITU-standardized coding.
498 #define Q931_ITU_STANDARDIZED_CODING 0x00
501 * Dissect a Segmented message information element.
504 dissect_q931_segmented_message_ie(tvbuff_t
*tvb
, int offset
, int len
,
508 proto_tree_add_text(tree
, tvb
, offset
, len
,
509 "Segmented message: length is %d, should be 2", len
);
512 if (tvb_get_guint8(tvb
, offset
) & 0x80) {
513 proto_tree_add_text(tree
, tvb
, offset
, 1,
514 "First segment: %u segments remaining",
515 tvb_get_guint8(tvb
, offset
) & 0x7F);
517 proto_tree_add_text(tree
, tvb
, offset
, 1,
518 "Not first segment: %u segments remaining",
519 tvb_get_guint8(tvb
, offset
) & 0x7F);
521 proto_tree_add_item(tree
, hf_q931_segment_type
, tvb
, offset
+ 1, 1, ENC_BIG_ENDIAN
);
525 * Dissect a Bearer capability or Low-layer compatibility information element.
527 static const value_string q931_coding_standard_vals
[] = {
528 { 0x0, "ITU-T standardized coding" },
529 { 0x1, "ISO/IEC standard" },
530 { 0x2, "National standard" },
531 { 0x3, "Standard defined for this particular network" },
535 static const value_string q931_information_transfer_capability_vals
[] = {
537 { 0x08, "Unrestricted digital information" },
538 { 0x09, "Restricted digital information" },
539 { 0x10, "3.1 kHz audio" },
540 { 0x11, "Unrestricted digital information with tones/announcements" },
545 static const value_string q931_transfer_mode_vals
[] = {
546 { 0x00, "Circuit mode" },
547 { 0x02, "Packet mode" },
551 #define Q931_IT_RATE_MULTIRATE 0x18
553 static const value_string q931_information_transfer_rate_vals
[] = {
554 { 0x00, "Packet mode" },
555 { 0x10, "64 kbit/s" },
556 { 0x11, "2 x 64 kbit/s" },
557 { 0x13, "384 kbit/s" },
558 { 0x15, "1536 kbit/s" },
559 { 0x17, "1920 kbit/s" },
560 { Q931_IT_RATE_MULTIRATE
, "Multirate (64 kbit/s base rate)" },
565 * Values 0x0a and 0x0b added from Q.931 Amendment 1 (12/2002)
567 static const value_string q931_uil1_vals
[] = {
568 { 0x01, "V.110/I.460/X.30 rate adaption" },
569 { 0x02, "Recommendation G.711 u-law" },
570 { 0x03, "Recommendation G.711 A-law" },
571 { 0x04, "Recommendation G.721 32 kbit/s ADPCM and Recommendation I.460" },
572 { 0x05, "Recommendation H.221 and H.242" },
573 { 0x06, "Recommendation H.223 and H.245" },
574 { 0x07, "Non-ITU-T-standardized rate adaption" },
575 { 0x08, "V.120 rate adaption" },
576 { 0x09, "X.31 HDLC flag stuffing" },
577 { 0x0a, "Recommendation G.728 LD-CELP" },
578 { 0x0b, "Recommendation G.729 CS-ACELP" },
581 static value_string_ext q931_uil1_vals_ext
= VALUE_STRING_EXT_INIT(q931_uil1_vals
);
583 static const value_string q931_l1_user_rate_vals
[] = {
584 { 0x00, "Rate indicated by E-bits" },
585 { 0x01, "0.6 kbit/s" },
586 { 0x02, "1.2 kbit/s" },
587 { 0x03, "2.4 kbit/s" },
588 { 0x04, "3.6 kbit/s" },
589 { 0x05, "4.8 kbit/s" },
590 { 0x06, "7.2 kbit/s" },
591 { 0x07, "8 kbit/s" },
592 { 0x08, "9.6 kbit/s" },
593 { 0x09, "14.4 kbit/s" },
594 { 0x0A, "16 kbit/s" },
595 { 0x0B, "19.2 kbit/s" },
596 { 0x0C, "32 kbit/s" },
597 { 0x0E, "48 kbit/s" },
598 { 0x0F, "56 kbit/s" },
599 { 0x10, "64 kbit/s "},
600 { 0x15, "0.1345 kbit/s" },
601 { 0x16, "0.100 kbit/s" },
602 { 0x17, "0.075/1.2 kbit/s" },
603 { 0x18, "1.2/0.075 kbit/s" },
604 { 0x19, "0.050 kbit/s" },
605 { 0x1A, "0.075 kbit/s" },
606 { 0x1B, "0.110 kbit/s" },
607 { 0x1C, "0.150 kbit/s" },
608 { 0x1D, "0.200 kbit/s" },
609 { 0x1E, "0.300 kbit/s" },
610 { 0x1F, "12 kbit/s" },
613 static value_string_ext q931_l1_user_rate_vals_ext
= VALUE_STRING_EXT_INIT(q931_l1_user_rate_vals
);
615 static const value_string q931_l1_intermediate_rate_vals
[] = {
616 { 0x20, "8 kbit/s" },
617 { 0x40, "16 kbit/s" },
618 { 0x60, "32 kbit/s" },
622 static const value_string q931_l1_stop_bits_vals
[] = {
629 static const value_string q931_l1_data_bits_vals
[] = {
636 static const value_string q931_l1_parity_vals
[] = {
640 { 0x04, "Forced to 0" },
641 { 0x05, "Forced to 1" },
645 static const value_string q931_l1_modem_type_vals
[] = {
648 { 0x13, "V.22 bis" },
651 { 0x16, "V.26 bis" },
652 { 0x17, "V.26 ter" },
654 { 0x19, "V.27 bis" },
655 { 0x1A, "V.27 ter" },
661 static value_string_ext q931_l1_modem_type_vals_ext
= VALUE_STRING_EXT_INIT(q931_l1_modem_type_vals
);
663 #define Q931_UIL2_USER_SPEC 0x10
665 static const value_string q931_uil2_vals
[] = {
666 { 0x01, "Basic mode ISO 1745" },
667 { 0x02, "Q.921/I.441" }, /* LAPD */
668 { 0x06, "X.25, link layer" }, /* LAPB */
669 { 0x07, "X.25 multilink" }, /* or 0x0F? */
670 { 0x08, "T.71 Extended LAPB" },
671 { 0x09, "HDLC ARM" },
672 { 0x0A, "HDLC NRM" },
673 { 0x0B, "HDLC ABM" },
674 { 0x0C, "ISO 8802/2 LLC" },
675 { 0x0D, "X.75 Single Link Procedure" },
677 { 0x0F, "Core aspects of Q.922" },
678 { Q931_UIL2_USER_SPEC
, "User-specified" },
679 { 0x11, "ISO 7776 DTE-DTE operation" },
682 static value_string_ext q931_uil2_vals_ext
= VALUE_STRING_EXT_INIT(q931_uil2_vals
);
684 static const value_string q931_mode_vals
[] = {
685 { 0x20, "Normal mode" },
686 { 0x40, "Extended mode" },
690 #define Q931_UIL3_X25_PL 0x06
691 #define Q931_UIL3_ISO_8208 0x07 /* X.25-based */
692 #define Q931_UIL3_X223 0x08 /* X.25-based */
693 #define Q931_UIL3_TR_9577 0x0B
694 #define Q931_UIL3_USER_SPEC 0x10
696 static const value_string q931_uil3_vals
[] = {
697 { 0x02, "Q.931/I.451" },
698 { Q931_UIL3_X25_PL
, "X.25, packet layer" },
699 { Q931_UIL3_ISO_8208
, "ISO/IEC 8208" },
700 { Q931_UIL3_X223
, "X.223/ISO 8878" },
701 { 0x09, "ISO/IEC 8473" },
703 { Q931_UIL3_TR_9577
, "ISO/IEC TR 9577" },
704 { Q931_UIL3_USER_SPEC
, "User-specified" },
709 dissect_q931_protocol_discriminator(tvbuff_t
*tvb
, int offset
, proto_tree
*tree
)
711 unsigned int discriminator
= tvb_get_guint8(tvb
, offset
);
713 if (discriminator
== NLPID_DMS
) {
714 proto_tree_add_uint_format_value(tree
, hf_q931_discriminator
,
715 tvb
, offset
, 1, discriminator
,
716 "Maintenance messages");
717 } else if (discriminator
== NLPID_Q_931
) {
718 proto_tree_add_uint_format_value(tree
, hf_q931_discriminator
,
719 tvb
, offset
, 1, discriminator
,
721 } else if (discriminator
== NLPID_Q_2931
) {
722 proto_tree_add_uint_format_value(tree
, hf_q931_discriminator
,
723 tvb
, offset
, 1, discriminator
,
725 } else if ((discriminator
>= 16 && discriminator
< 63)
726 || ((discriminator
>= 80) && (discriminator
< 254))) {
727 proto_tree_add_uint_format_value(tree
, hf_q931_discriminator
,
728 tvb
, offset
, 1, discriminator
,
729 "Network layer or layer 3 protocol (0x%02X)",
731 } else if (discriminator
>= 64 && discriminator
<= 79) {
732 proto_tree_add_uint_format_value(tree
, hf_q931_discriminator
,
733 tvb
, offset
, 1, discriminator
,
734 "National use (0x%02X)",
737 proto_tree_add_uint_format_value(tree
, hf_q931_discriminator
,
738 tvb
, offset
, 1, discriminator
,
744 static const value_string q931_bearer_capability_layer_ident_vals
[] = {
745 { 0x01, "Layer 1 identifier" },
746 { 0x02, "Layer 2 identifier" },
747 { 0x03, "Layer 3 identifier" },
752 dissect_q931_bearer_capability_ie(tvbuff_t
*tvb
, int offset
, int len
,
756 guint8 coding_standard
;
759 guint8 uil2_protocol
;
760 guint8 uil3_protocol
;
765 octet
= tvb_get_guint8(tvb
, offset
);
766 coding_standard
= octet
& 0x60;
767 if (coding_standard
!= Q931_ITU_STANDARDIZED_CODING
) {
769 * We don't know how the bearer capability is encoded,
770 * so just dump it as data and be done with it.
772 proto_tree_add_text(tree
, tvb
, offset
,
774 tvb_bytes_to_str(tvb
, offset
, len
));
775 proto_tree_add_boolean(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, octet
);
776 proto_tree_add_uint(tree
, hf_q931_coding_standard
, tvb
, offset
, 1, octet
);
779 proto_tree_add_boolean(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, octet
);
780 proto_tree_add_uint(tree
, hf_q931_coding_standard
, tvb
, offset
, 1, octet
);
781 proto_tree_add_uint(tree
, hf_q931_information_transfer_capability
, tvb
, offset
, 1, octet
);
786 * XXX - only in Low-layer compatibility information element.
788 if (!(octet
& Q931_IE_VL_EXTENSION
)) {
791 octet
= tvb_get_guint8(tvb
, offset
);
792 proto_tree_add_text(tree
, tvb
, offset
, 1,
793 "Out-band negotiation %spossible",
794 (octet
& 0x40) ? "" : "not ");
801 octet
= tvb_get_guint8(tvb
, offset
);
802 proto_tree_add_boolean(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, octet
);
803 proto_tree_add_uint(tree
, hf_q931_transfer_mode
, tvb
, offset
, 1, octet
);
804 proto_tree_add_uint(tree
, hf_q931_information_transfer_rate
, tvb
, offset
, 1, octet
);
805 it_rate
= octet
& 0x1F;
809 if (it_rate
== Q931_IT_RATE_MULTIRATE
) {
812 proto_tree_add_text(tree
, tvb
, offset
, 1, "Rate multiplier: %u", tvb_get_guint8(tvb
, offset
) & 0x7f);
819 octet
= tvb_get_guint8(tvb
, offset
);
820 if ((octet
& 0x60) == 0x20) {
822 * Layer 1 information.
824 proto_tree_add_boolean(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, octet
);
825 proto_tree_add_uint(tree
, hf_q931_layer_ident
, tvb
, offset
, 1, octet
);
826 proto_tree_add_uint(tree
, hf_q931_uil1
, tvb
, offset
, 1, octet
);
830 if (octet
& Q931_IE_VL_EXTENSION
)
834 octet
= tvb_get_guint8(tvb
, offset
);
835 proto_tree_add_text(tree
, tvb
, offset
, 1,
837 (octet
& 0x40) ? "Asynchronous" : "Synchronous");
838 proto_tree_add_text(tree
, tvb
, offset
, 1,
839 "Layer 1 in-band negotiation is %spossible",
840 (octet
& 0x20) ? "" : "not ");
841 proto_tree_add_text(tree
, tvb
, offset
, 1,
843 val_to_str_ext(octet
& 0x1F, &q931_l1_user_rate_vals_ext
,
844 "Unknown (0x%02X)"));
848 if (octet
& Q931_IE_VL_EXTENSION
)
852 octet
= tvb_get_guint8(tvb
, offset
);
853 proto_tree_add_text(tree
, tvb
, offset
, 1,
854 "Intermediate rate: %s",
855 val_to_str(octet
& 0x60, q931_l1_intermediate_rate_vals
,
857 proto_tree_add_text(tree
, tvb
, offset
, 1,
858 "%s to send data with network independent clock",
859 (octet
& 0x10) ? "Required" : "Not required");
860 proto_tree_add_text(tree
, tvb
, offset
, 1,
861 "%s accept data with network independent clock",
862 (octet
& 0x08) ? "Can" : "Cannot");
863 proto_tree_add_text(tree
, tvb
, offset
, 1,
864 "%s to send data with flow control mechanism",
865 (octet
& 0x04) ? "Required" : "Not required");
866 proto_tree_add_text(tree
, tvb
, offset
, 1,
867 "%s accept data with flow control mechanism",
868 (octet
& 0x02) ? "Can" : "Cannot");
872 if (octet
& Q931_IE_VL_EXTENSION
)
876 octet
= tvb_get_guint8(tvb
, offset
);
877 proto_tree_add_text(tree
, tvb
, offset
, 1,
878 "Rate adaption header %sincluded",
879 (octet
& 0x40) ? "" : "not ");
880 proto_tree_add_text(tree
, tvb
, offset
, 1,
881 "Multiple frame establishment %ssupported",
882 (octet
& 0x20) ? "" : "not ");
883 proto_tree_add_text(tree
, tvb
, offset
, 1,
884 "%s mode of operation",
885 (octet
& 0x10) ? "Protocol sensitive" : "Bit transparent");
886 proto_tree_add_text(tree
, tvb
, offset
, 1,
888 "Full protocol negotiation" : "LLI = 256 only");
889 proto_tree_add_text(tree
, tvb
, offset
, 1,
890 "Message originator is %s",
891 (octet
& 0x04) ? "Assignor only" : "Default assignee");
892 proto_tree_add_text(tree
, tvb
, offset
, 1,
893 "Negotiation is done %s",
894 (octet
& 0x02) ? "in-band" : "out-of-band");
898 if (octet
& Q931_IE_VL_EXTENSION
)
902 octet
= tvb_get_guint8(tvb
, offset
);
903 proto_tree_add_text(tree
, tvb
, offset
, 1,
905 val_to_str(octet
& 0x60, q931_l1_stop_bits_vals
,
907 proto_tree_add_text(tree
, tvb
, offset
, 1,
909 val_to_str(octet
& 0x18, q931_l1_data_bits_vals
,
911 proto_tree_add_text(tree
, tvb
, offset
, 1,
913 val_to_str(octet
& 0x07, q931_l1_parity_vals
,
916 if (octet
& Q931_IE_VL_EXTENSION
)
918 octet
= tvb_get_guint8(tvb
, offset
);
919 proto_tree_add_text(tree
, tvb
, offset
, 1,
921 (octet
& 0x40) ? "Full" : "Half");
922 modem_type
= octet
& 0x3F;
923 if (modem_type
<= 0x5 ||
924 (modem_type
>= 0x20 && modem_type
<= 0x2F)) {
925 proto_tree_add_text(tree
, tvb
, offset
, 1,
926 "Modem type: National use 0x%02X", modem_type
);
927 } else if (modem_type
>= 0x30) {
928 proto_tree_add_text(tree
, tvb
, offset
, 1,
929 "Modem type: User specified 0x%02X", modem_type
);
931 proto_tree_add_text(tree
, tvb
, offset
, 1,
933 val_to_str_ext(modem_type
, &q931_l1_modem_type_vals_ext
,
934 "Unknown (0x%02X)"));
944 octet
= tvb_get_guint8(tvb
, offset
);
945 if ((octet
& 0x60) == 0x40) {
947 * Layer 2 information.
949 proto_tree_add_boolean(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, octet
);
950 proto_tree_add_uint(tree
, hf_q931_layer_ident
, tvb
, offset
, 1, octet
);
951 uil2_protocol
= octet
& 0x1F;
952 proto_tree_add_text(tree
, tvb
, offset
, 1,
953 "User information layer 2 protocol: %s",
954 val_to_str_ext(uil2_protocol
, &q931_uil2_vals_ext
,
955 "Unknown (0x%02X)"));
960 * XXX - only in Low-layer compatibility information element.
962 if (octet
& Q931_IE_VL_EXTENSION
)
966 octet
= tvb_get_guint8(tvb
, offset
);
967 if (uil2_protocol
== Q931_UIL2_USER_SPEC
) {
968 proto_tree_add_text(tree
, tvb
, offset
, 1,
969 "User-specified layer 2 protocol information: 0x%02X",
972 proto_tree_add_text(tree
, tvb
, offset
, 1,
974 val_to_str(octet
& 0x60, q931_mode_vals
,
975 "Unknown (0x%02X)"));
980 if (octet
& Q931_IE_VL_EXTENSION
)
984 octet
= tvb_get_guint8(tvb
, offset
);
985 proto_tree_add_text(tree
, tvb
, offset
, 1,
986 "Window size: %u k", octet
& 0x7F);
995 octet
= tvb_get_guint8(tvb
, offset
);
996 if ((octet
& 0x60) == 0x60) {
998 * Layer 3 information.
1000 proto_tree_add_boolean(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, octet
);
1001 proto_tree_add_uint(tree
, hf_q931_layer_ident
, tvb
, offset
, 1, octet
);
1002 uil3_protocol
= octet
& 0x1F;
1003 proto_tree_add_text(tree
, tvb
, offset
, 1,
1004 "User information layer 3 protocol: %s",
1005 val_to_str(uil3_protocol
, q931_uil3_vals
,
1006 "Unknown (0x%02X)"));
1012 * XXX - only in Low-layer compatibility information element.
1014 if (octet
& Q931_IE_VL_EXTENSION
)
1018 octet
= tvb_get_guint8(tvb
, offset
);
1019 switch (uil3_protocol
) {
1021 case Q931_UIL3_X25_PL
:
1022 case Q931_UIL3_ISO_8208
:
1023 case Q931_UIL3_X223
:
1024 proto_tree_add_text(tree
, tvb
, offset
, 1,
1026 val_to_str(octet
& 0x60, q931_mode_vals
,
1027 "Unknown (0x%02X)"));
1031 if (octet
& Q931_IE_VL_EXTENSION
)
1035 octet
= tvb_get_guint8(tvb
, offset
);
1036 proto_tree_add_text(tree
, tvb
, offset
, 1,
1037 "Default packet size: %u", octet
& 0x0F);
1041 if (octet
& Q931_IE_VL_EXTENSION
)
1045 octet
= tvb_get_guint8(tvb
, offset
);
1046 proto_tree_add_text(tree
, tvb
, offset
, 1,
1047 "Packet window size: %u", octet
& 0x7F);
1052 case Q931_UIL3_USER_SPEC
:
1053 proto_tree_add_text(tree
, tvb
, offset
, 1,
1054 "Default packet size: %u octets",
1055 1 << (octet
& 0x0F));
1060 case Q931_UIL3_TR_9577
:
1061 add_l3_info
= (octet
& 0x0F) << 4;
1062 if (octet
& Q931_IE_VL_EXTENSION
)
1066 octet
= tvb_get_guint8(tvb
, offset
+ 1);
1067 add_l3_info
|= (octet
& 0x0F);
1068 proto_tree_add_text(tree
, tvb
, offset
, 2,
1069 "Additional layer 3 protocol information: %s",
1070 val_to_str(add_l3_info
, nlpid_vals
,
1071 "Unknown (0x%02X)"));
1082 * Dissect a Cause information element.
1086 static const value_string q931_cause_location_vals
[] = {
1087 { 0x00, "User (U)" },
1088 { 0x01, "Private network serving the local user (LPN)" },
1089 { 0x02, "Public network serving the local user (LN)" },
1090 { 0x03, "Transit network (TN)" },
1091 { 0x04, "Public network serving the remote user (RLN)" },
1092 { 0x05, "Private network serving the remote user (RPN)" },
1093 { 0x06, "Unallocated code" },
1094 { 0x07, "International network (INTL)" },
1095 { 0x08, "Unallocated code" },
1096 { 0x09, "Unallocated code" },
1097 { 0x0A, "Network beyond interworking point (BI)" },
1100 value_string_ext q931_cause_location_vals_ext
= VALUE_STRING_EXT_INIT(q931_cause_location_vals
);
1102 static const value_string q931_cause_recommendation_vals
[] = {
1106 { 0x05, "Q.1031/Q.1051" },
1111 * Cause codes for Cause.
1113 #define Q931_CAUSE_UNALLOC_NUMBER 0x01
1114 #define Q931_CAUSE_NO_ROUTE_TO_DEST 0x03
1115 #define Q931_CAUSE_CALL_REJECTED 0x15
1116 #define Q931_CAUSE_NUMBER_CHANGED 0x16
1117 #define Q931_CAUSE_ACCESS_INFO_DISC 0x2B
1118 #define Q931_CAUSE_QOS_UNAVAILABLE 0x31
1119 #define Q931_CAUSE_CHAN_NONEXISTENT 0x52
1120 #define Q931_CAUSE_INCOMPATIBLE_DEST 0x58
1121 #define Q931_CAUSE_MAND_IE_MISSING 0x60
1122 #define Q931_CAUSE_MT_NONEX_OR_UNIMPL 0x61
1123 #define Q931_CAUSE_IE_NONEX_OR_UNIMPL 0x63
1124 #define Q931_CAUSE_INVALID_IE_CONTENTS 0x64
1125 #define Q931_CAUSE_MSG_INCOMPAT_W_CS 0x65
1126 #define Q931_CAUSE_REC_TIMER_EXP 0x66
1128 static const value_string q931_cause_code_vals
[] = {
1129 { 0x00, "Valid cause code not yet received" },
1130 { Q931_CAUSE_UNALLOC_NUMBER
, "Unallocated (unassigned) number" },
1131 { 0x02, "No route to specified transit network" },
1132 { Q931_CAUSE_NO_ROUTE_TO_DEST
, "No route to destination" },
1133 { 0x04, "Send special information tone" },
1134 { 0x05, "Misdialled trunk prefix" },
1135 { 0x06, "Channel unacceptable" },
1136 { 0x07, "Call awarded and being delivered in an established channel" },
1137 { 0x08, "Prefix 0 dialed but not allowed" },
1138 /* Q.850 - "Preemption" */
1139 { 0x09, "Prefix 1 dialed but not allowed" },
1140 /* Q.850 - "Preemption - circuit reserved for reuse" */
1141 { 0x0A, "Prefix 1 dialed but not required" },
1142 { 0x0B, "More digits received than allowed, call is proceeding" },
1143 { 0x0E, "QoR: ported number" },
1144 { 0x10, "Normal call clearing" },
1145 { 0x11, "User busy" },
1146 { 0x12, "No user responding" },
1147 { 0x13, "No answer from user (user alerted)" },
1148 { 0x14, "Subscriber absent" },
1149 { Q931_CAUSE_CALL_REJECTED
, "Call rejected" },
1150 { Q931_CAUSE_NUMBER_CHANGED
, "Number changed" },
1151 { 0x17, "Reverse charging rejected" },
1152 /* Q.850 - "Redirection to new destination" */
1153 { 0x18, "Call suspended" },
1154 /* Q.850 Amendment 1 - "Call rejected due to feature at the destination" */
1155 { 0x19, "Call resumed" },
1156 /* Q.850 - "Exchange routing error */
1157 { 0x1A, "Non-selected user clearing" },
1158 { 0x1B, "Destination out of order" },
1159 { 0x1C, "Invalid number format (incomplete number)" },
1160 { 0x1D, "Facility rejected" },
1161 { 0x1E, "Response to STATUS ENQUIRY" },
1162 { 0x1F, "Normal unspecified" },
1163 { 0x21, "Circuit out of order" },
1164 { 0x22, "No circuit/channel available" },
1165 { 0x23, "Destination unattainable" },
1166 { 0x25, "Degraded service" },
1167 { 0x26, "Network out of order" },
1168 { 0x27, "Transit delay range cannot be achieved" },
1169 /* Q.850 - "Permanent frame mode connection out of service" */
1170 { 0x28, "Throughput range cannot be achieved" },
1171 /* Q.850 - "Permanent frame mode connection operational" */
1172 { 0x29, "Temporary failure" },
1173 { 0x2A, "Switching equipment congestion" },
1174 { Q931_CAUSE_ACCESS_INFO_DISC
, "Access information discarded" },
1175 { 0x2C, "Requested circuit/channel not available" },
1176 { 0x2D, "Pre-empted" },
1177 { 0x2E, "Precedence call blocked" },
1178 { 0x2F, "Resources unavailable, unspecified" },
1179 { Q931_CAUSE_QOS_UNAVAILABLE
, "Quality of service unavailable" },
1180 { 0x32, "Requested facility not subscribed" },
1181 { 0x33, "Reverse charging not allowed" },
1182 { 0x34, "Outgoing calls barred" },
1183 { 0x35, "Outgoing calls barred within CUG" },
1184 { 0x36, "Incoming calls barred" },
1185 { 0x37, "Incoming calls barred within CUG" },
1186 { 0x38, "Call waiting not subscribed" },
1187 { 0x39, "Bearer capability not authorized" },
1188 { 0x3A, "Bearer capability not presently available" },
1189 { 0x3E, "Inconsistency in designated outgoing access information and subscriber class" },
1190 { 0x3F, "Service or option not available, unspecified" },
1191 { 0x41, "Bearer capability not implemented" },
1192 { 0x42, "Channel type not implemented" },
1193 { 0x43, "Transit network selection not implemented" },
1194 { 0x44, "Message not implemented" },
1195 { 0x45, "Requested facility not implemented" },
1196 { 0x46, "Only restricted digital information bearer capability is available" },
1197 { 0x4F, "Service or option not implemented, unspecified" },
1198 { 0x51, "Invalid call reference value" },
1199 { Q931_CAUSE_CHAN_NONEXISTENT
, "Identified channel does not exist" },
1200 { 0x53, "Call identity does not exist for suspended call" },
1201 { 0x54, "Call identity in use" },
1202 { 0x55, "No call suspended" },
1203 { 0x56, "Call having the requested call identity has been cleared" },
1204 { 0x57, "Called user not member of CUG" },
1205 { Q931_CAUSE_INCOMPATIBLE_DEST
, "Incompatible destination" },
1206 { 0x59, "Non-existent abbreviated address entry" },
1207 { 0x5A, "Destination address missing, and direct call not subscribed" },
1208 /* Q.850 - "Non-existent CUG" */
1209 { 0x5B, "Invalid transit network selection (national use)" },
1210 { 0x5C, "Invalid facility parameter" },
1211 { 0x5D, "Mandatory information element is missing" },
1212 { 0x5F, "Invalid message, unspecified" },
1213 { Q931_CAUSE_MAND_IE_MISSING
, "Mandatory information element is missing" },
1214 { Q931_CAUSE_MT_NONEX_OR_UNIMPL
,"Message type non-existent or not implemented" },
1215 { 0x62, "Message not compatible with call state or message type non-existent or not implemented" },
1216 { Q931_CAUSE_IE_NONEX_OR_UNIMPL
,"Information element non-existent or not implemented" },
1217 { Q931_CAUSE_INVALID_IE_CONTENTS
,"Invalid information element contents" },
1218 { Q931_CAUSE_MSG_INCOMPAT_W_CS
, "Message not compatible with call state" },
1219 { Q931_CAUSE_REC_TIMER_EXP
, "Recovery on timer expiry" },
1220 { 0x67, "Parameter non-existent or not implemented - passed on" },
1221 { 0x6E, "Message with unrecognized parameter discarded" },
1222 { 0x6F, "Protocol error, unspecified" },
1223 { 0x7F, "Internetworking, unspecified" },
1226 value_string_ext q931_cause_code_vals_ext
= VALUE_STRING_EXT_INIT(q931_cause_code_vals
);
1228 static const value_string q931_cause_condition_vals
[] = {
1229 { 0x00, "Unknown" },
1230 { 0x01, "Permanent" },
1231 { 0x02, "Transient" },
1235 #define Q931_REJ_USER_SPECIFIC 0x00
1236 #define Q931_REJ_IE_MISSING 0x04
1237 #define Q931_REJ_IE_INSUFFICIENT 0x08
1239 static const value_string q931_rejection_reason_vals
[] = {
1240 { 0x00, "User specific" },
1241 { 0x04, "Information element missing" },
1242 { 0x08, "Information element contents are not sufficient" },
1246 static const gchar
*get_message_name(guint8 prot_discr
, guint8 message_type
) {
1247 if (prot_discr
== NLPID_DMS
)
1248 return val_to_str(message_type
, dms_message_type_vals
, "Unknown (0x%02X)");
1250 return val_to_str_ext(message_type
, &q931_message_type_vals_ext
, "Unknown (0x%02X)");
1254 dissect_q931_cause_ie_unsafe(tvbuff_t
*tvb
, int offset
, int len
,
1255 proto_tree
*tree
, int hf_cause_value
, guint8
*cause_value
, const value_string
*ie_vals
)
1258 guint8 coding_standard
;
1259 guint8 rejection_reason
;
1263 octet
= tvb_get_guint8(tvb
, offset
);
1264 coding_standard
= octet
& 0x60;
1265 if (coding_standard
!= Q931_ITU_STANDARDIZED_CODING
) {
1267 * We don't know how the cause is encoded,
1268 * so just dump it as data and be done with it.
1270 proto_tree_add_uint(tree
, hf_q931_coding_standard
, tvb
, offset
, 1, octet
);
1271 proto_tree_add_text(tree
, tvb
, offset
,
1273 tvb_bytes_to_str(tvb
, offset
, len
));
1276 proto_tree_add_uint(tree
, hf_q931_cause_location
, tvb
, offset
, 1, octet
);
1277 proto_tree_add_uint(tree
, hf_q931_coding_standard
, tvb
, offset
, 1, octet
);
1278 proto_tree_add_boolean(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, octet
);
1282 if (!(octet
& Q931_IE_VL_EXTENSION
)) {
1285 octet
= tvb_get_guint8(tvb
, offset
);
1286 proto_tree_add_text(tree
, tvb
, offset
, 1,
1287 "Recommendation: %s",
1288 val_to_str(octet
& 0x7F, q931_cause_recommendation_vals
,
1289 "Unknown (0x%02X)"));
1290 proto_tree_add_boolean(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, octet
);
1297 octet
= tvb_get_guint8(tvb
, offset
);
1298 *cause_value
= octet
& 0x7F;
1300 /* add cause value to packet info for use in tap */
1301 if(have_valid_q931_pi
) {
1302 q931_pi
->cause_value
= *cause_value
;
1305 proto_tree_add_uint(tree
, hf_cause_value
, tvb
, offset
, 1, *cause_value
);
1306 proto_tree_add_boolean(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, octet
);
1312 switch (*cause_value
) {
1314 case Q931_CAUSE_UNALLOC_NUMBER
:
1315 case Q931_CAUSE_NO_ROUTE_TO_DEST
:
1316 case Q931_CAUSE_QOS_UNAVAILABLE
:
1317 octet
= tvb_get_guint8(tvb
, offset
);
1318 proto_tree_add_text(tree
, tvb
, offset
, 1,
1319 "Network service: %s",
1320 (octet
& 0x80) ? "User" : "Provider");
1321 proto_tree_add_text(tree
, tvb
, offset
, 1,
1323 (octet
& 0x40) ? "Abnormal" : "Normal");
1324 proto_tree_add_text(tree
, tvb
, offset
, 1,
1326 val_to_str(octet
& 0x03, q931_cause_condition_vals
,
1330 case Q931_CAUSE_CALL_REJECTED
:
1331 rejection_reason
= octet
& 0x7C;
1332 proto_tree_add_text(tree
, tvb
, offset
, 1,
1333 "Rejection reason: %s",
1334 val_to_str(octet
& 0x7C, q931_rejection_reason_vals
,
1336 proto_tree_add_text(tree
, tvb
, offset
, 1,
1338 val_to_str(octet
& 0x03, q931_cause_condition_vals
,
1345 switch (rejection_reason
) {
1347 case Q931_REJ_USER_SPECIFIC
:
1348 proto_tree_add_text(tree
, tvb
, offset
, len
,
1349 "User specific diagnostic: %s",
1350 tvb_bytes_to_str(tvb
, offset
, len
));
1353 case Q931_REJ_IE_MISSING
:
1354 proto_tree_add_text(tree
, tvb
, offset
, 1,
1355 "Missing information element: %s",
1356 val_to_str(tvb_get_guint8(tvb
, offset
), ie_vals
,
1357 "Unknown (0x%02X)"));
1360 case Q931_REJ_IE_INSUFFICIENT
:
1361 proto_tree_add_text(tree
, tvb
, offset
, 1,
1362 "Insufficient information element: %s",
1363 val_to_str(tvb_get_guint8(tvb
, offset
), ie_vals
,
1364 "Unknown (0x%02X)"));
1368 proto_tree_add_text(tree
, tvb
, offset
, len
,
1370 tvb_bytes_to_str(tvb
, offset
, len
));
1375 case Q931_CAUSE_ACCESS_INFO_DISC
:
1376 case Q931_CAUSE_INCOMPATIBLE_DEST
:
1377 case Q931_CAUSE_MAND_IE_MISSING
:
1378 case Q931_CAUSE_IE_NONEX_OR_UNIMPL
:
1379 case Q931_CAUSE_INVALID_IE_CONTENTS
:
1381 proto_tree_add_text(tree
, tvb
, offset
, 1,
1382 "Information element: %s",
1383 val_to_str(tvb_get_guint8(tvb
, offset
), ie_vals
,
1384 "Unknown (0x%02X)"));
1390 case Q931_CAUSE_MT_NONEX_OR_UNIMPL
:
1391 case Q931_CAUSE_MSG_INCOMPAT_W_CS
:
1392 proto_tree_add_text(tree
, tvb
, offset
, 1,
1394 val_to_str_ext(tvb_get_guint8(tvb
, offset
), &q931_message_type_vals_ext
,
1395 "Unknown (0x%02X)"));
1398 case Q931_CAUSE_REC_TIMER_EXP
:
1401 proto_tree_add_text(tree
, tvb
, offset
, 3,
1402 "Timer: %.3s", tvb_get_string(wmem_packet_scope(), tvb
, offset
, 3));
1406 proto_tree_add_text(tree
, tvb
, offset
, len
,
1408 tvb_bytes_to_str(tvb
, offset
, len
));
1413 dissect_q931_cause_ie(tvbuff_t
*tvb
, int offset
, int len
,
1414 proto_tree
*tree
, int hf_cause_value
, guint8
*cause_value
, const value_string
*ie_vals
)
1416 gboolean have_valid_q931_pi_save
= have_valid_q931_pi
;
1417 have_valid_q931_pi
= FALSE
;
1418 dissect_q931_cause_ie_unsafe(tvb
, offset
, len
, tree
, hf_cause_value
, cause_value
, ie_vals
);
1419 have_valid_q931_pi
= have_valid_q931_pi_save
;
1423 * Dissect a Change status information element.
1426 static const value_string q931_status_preference_vals
[] = {
1427 { 0x01, "Channel" },
1431 static const value_string q931_new_status_vals
[] = {
1432 { 0x00, "In Service" },
1433 { 0x01, "Maintenance" },
1434 { 0x02, "Out of Service" },
1439 dissect_q931_change_status_ie(tvbuff_t
*tvb
, int offset
, int len _U_
, proto_tree
*tree
)
1444 proto_tree_add_item(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1445 proto_tree_add_item(tree
, hf_q931_extension_ind_preference
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1446 proto_tree_add_item(tree
, hf_q931_extension_ind_new_status
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1450 * Dissect a Call state information element.
1452 static const value_string q931_call_state_vals
[] = {
1454 { 0x01, "Call initiated" },
1455 { 0x02, "Overlap sending" },
1456 { 0x03, "Outgoing call proceeding" },
1457 { 0x04, "Call delivered" },
1458 { 0x06, "Call present" },
1459 { 0x07, "Call received" },
1460 { 0x08, "Connect request" },
1461 { 0x09, "Incoming call proceeding" },
1463 { 0x0B, "Disconnect request" },
1464 { 0x0C, "Disconnect indication" },
1465 { 0x0F, "Suspend request" },
1466 { 0x11, "Resume request" },
1467 { 0x13, "Release request" },
1468 { 0x16, "Call abort"},
1469 { 0x19, "Overlap receiving" },
1470 { 0x3D, "Restart request" },
1471 { 0x3E, "Restart" },
1474 value_string_ext q931_call_state_vals_ext
= VALUE_STRING_EXT_INIT(q931_call_state_vals
);
1477 dissect_q931_call_state_ie(tvbuff_t
*tvb
, int offset
, int len
,
1481 guint8 coding_standard
;
1485 octet
= tvb_get_guint8(tvb
, offset
);
1486 coding_standard
= octet
& 0x60;
1487 proto_tree_add_uint(tree
, hf_q931_coding_standard
, tvb
, offset
, 1, octet
);
1488 if (coding_standard
!= Q931_ITU_STANDARDIZED_CODING
) {
1490 * We don't know how the call state is encoded,
1491 * so just dump it as data and be done with it.
1493 proto_tree_add_text(tree
, tvb
, offset
,
1495 tvb_bytes_to_str(tvb
, offset
, len
));
1498 proto_tree_add_text(tree
, tvb
, offset
, 1,
1500 val_to_str_ext(octet
& 0x3F, &q931_call_state_vals_ext
,
1501 "Unknown (0x%02X)"));
1505 * Dissect a Channel identification information element.
1507 #define Q931_INTERFACE_IDENTIFIED 0x40
1508 #define Q931_NOT_BASIC_CHANNEL 0x20
1510 static const value_string q931_basic_channel_selection_vals
[] = {
1511 { 0x00, "No channel" },
1512 { 0x01, "B1 channel" },
1513 { 0x02, "B2 channel" },
1514 { 0x03, "Any channel" },
1518 static const value_string q931_not_basic_channel_selection_vals
[] = {
1519 { 0x00, "No channel" },
1520 { 0x01, "Channel indicated in following octets" },
1521 { 0x03, "Any channel" },
1525 #define Q931_IS_SLOT_MAP 0x10
1527 static const value_string q931_element_type_vals
[] = {
1528 { 0x03, "B-channel units" },
1529 { 0x06, "H0-channel units" },
1530 { 0x08, "H11-channel units" },
1531 { 0x09, "H12-channel units" },
1536 dissect_q931_channel_identification_ie(tvbuff_t
*tvb
, int offset
, int len
,
1540 guint8 coding_standard
;
1544 octet
= tvb_get_guint8(tvb
, offset
);
1546 proto_tree_add_item(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1547 proto_tree_add_item(tree
, hf_q931_channel_interface_explicit
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1548 proto_tree_add_item(tree
, hf_q931_channel_interface_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1549 proto_tree_add_item(tree
, hf_q931_channel_exclusive
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1550 proto_tree_add_item(tree
, hf_q931_channel_dchan
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1552 if (octet
& Q931_NOT_BASIC_CHANNEL
) {
1553 proto_tree_add_item(tree
, hf_q931_channel_selection_pri
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1555 proto_tree_add_item(tree
, hf_q931_channel_selection_bri
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1560 if (octet
& Q931_INTERFACE_IDENTIFIED
) {
1562 guint32 identifier_val
= 0;
1563 int identifier_offset
= offset
;
1564 int identifier_len
= 0;
1568 octet2
= tvb_get_guint8(tvb
, offset
);
1572 identifier_val
<<= 7;
1573 identifier_val
|= octet2
& 0x7F;
1574 } while (!(octet2
& Q931_IE_VL_EXTENSION
));
1576 if (identifier_len
!= 0) {
1577 proto_tree_add_text(tree
, tvb
, identifier_offset
,
1578 identifier_len
, "Interface ID: %u", identifier_val
);
1582 if (octet
& Q931_NOT_BASIC_CHANNEL
) {
1585 octet
= tvb_get_guint8(tvb
, offset
);
1586 coding_standard
= octet
& 0x60;
1587 proto_tree_add_item(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1588 proto_tree_add_uint(tree
, hf_q931_coding_standard
, tvb
, offset
, 1, octet
);
1589 if (coding_standard
!= Q931_ITU_STANDARDIZED_CODING
) {
1591 * We don't know how the channel identifier is
1592 * encoded, so just dump it as data and be done
1595 proto_tree_add_text(tree
, tvb
, offset
,
1597 tvb_bytes_to_str(tvb
, offset
, len
));
1600 proto_tree_add_item(tree
, hf_q931_channel_map
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1601 proto_tree_add_item(tree
, hf_q931_channel_element_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1606 if (octet
& Q931_IS_SLOT_MAP
) {
1609 octet2
= tvb_get_guint8(tvb
, offset
);
1610 proto_tree_add_text(tree
, tvb
, offset
, 1,
1611 "Slot map: 0x%02x", octet2
);
1620 octet2
= tvb_get_guint8(tvb
, offset
);
1622 proto_tree_add_item(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1623 proto_tree_add_item(tree
,hf_q931_channel_number
,tvb
,offset
,1,ENC_BIG_ENDIAN
);
1627 } while (!(octet2
& Q931_IE_VL_EXTENSION
));
1633 * Dissect a Progress indicator information element.
1635 static const value_string q931_progress_description_vals
[] = {
1636 { 0x01, "Call is not end-to-end ISDN - progress information available in-band" },
1637 { 0x02, "Destination address is non-ISDN" },
1638 { 0x03, "Origination address is non-ISDN" },
1639 { 0x04, "Call has returned to the ISDN" },
1640 { 0x05, "Interworking has occurred and has resulted in a telecommunications service change" },
1641 { 0x08, "In-band information or an appropriate pattern is now available" },
1644 value_string_ext q931_progress_description_vals_ext
= VALUE_STRING_EXT_INIT(q931_progress_description_vals
);
1647 dissect_q931_progress_indicator_ie(tvbuff_t
*tvb
, int offset
, int len
,
1651 guint8 coding_standard
;
1655 octet
= tvb_get_guint8(tvb
, offset
);
1656 coding_standard
= octet
& 0x60;
1657 proto_tree_add_uint(tree
, hf_q931_coding_standard
, tvb
, offset
, 1, octet
);
1658 if (coding_standard
!= Q931_ITU_STANDARDIZED_CODING
) {
1660 * We don't know how the progress indicator is encoded,
1661 * so just dump it as data and be done with it.
1663 proto_tree_add_text(tree
, tvb
, offset
,
1665 tvb_bytes_to_str(tvb
, offset
, len
));
1668 proto_tree_add_text(tree
, tvb
, offset
, 1,
1670 val_to_str_ext(octet
& 0x0F, &q931_cause_location_vals_ext
,
1677 octet
= tvb_get_guint8(tvb
, offset
);
1678 proto_tree_add_text(tree
, tvb
, offset
, 1,
1679 "Progress description: %s",
1680 val_to_str_ext(octet
& 0x7F, &q931_progress_description_vals_ext
,
1681 "Unknown (0x%02X)"));
1685 * Dissect a Network-specific facilities or Transit network selection
1686 * information element.
1688 static const value_string q931_netid_type_vals
[] = {
1689 { 0x00, "User specified" },
1690 { 0x20, "National network identification" },
1691 { 0x30, "International network identification" },
1695 static const value_string q931_netid_plan_vals
[] = {
1696 { 0x00, "Unknown" },
1697 { 0x01, "Carrier Identification Code" },
1698 { 0x03, "X.121 data network identification code" },
1703 dissect_q931_ns_facilities_ie(tvbuff_t
*tvb
, int offset
, int len
,
1711 octet
= tvb_get_guint8(tvb
, offset
);
1712 netid_len
= octet
& 0x7F;
1713 proto_tree_add_text(tree
, tvb
, offset
, 1,
1714 "Network identification length: %u",
1718 if (netid_len
!= 0) {
1721 octet
= tvb_get_guint8(tvb
, offset
);
1722 proto_tree_add_text(tree
, tvb
, offset
, 1,
1723 "Type of network identification: %s",
1724 val_to_str(octet
& 0x70, q931_netid_type_vals
,
1725 "Unknown (0x%02X)"));
1726 proto_tree_add_text(tree
, tvb
, offset
, 1,
1727 "Network identification plan: %s",
1728 val_to_str(octet
& 0x0F, q931_netid_plan_vals
,
1729 "Unknown (0x%02X)"));
1736 if (netid_len
> len
)
1738 if (netid_len
!= 0) {
1739 proto_tree_add_text(tree
, tvb
, offset
, netid_len
,
1740 "Network identification: %s",
1741 tvb_format_text(tvb
, offset
, netid_len
));
1742 offset
+= netid_len
;
1748 * Whatever is left is the network-specific facility
1753 proto_tree_add_text(tree
, tvb
, offset
,
1754 len
, "Network-specific facility specification: %s",
1755 tvb_bytes_to_str(tvb
, offset
, len
));
1759 * Dissect a Notification indicator information element.
1761 static const value_string q931_notification_description_vals
[] = {
1762 { 0x00, "User suspended" },
1763 { 0x01, "User resumed" },
1764 { 0x02, "Bearer service change" },
1769 dissect_q931_notification_indicator_ie(tvbuff_t
*tvb
, int offset
, int len
,
1776 octet
= tvb_get_guint8(tvb
, offset
);
1777 proto_tree_add_text(tree
, tvb
, offset
, 1,
1778 "Notification description: %s",
1779 val_to_str(octet
& 0x7F, q931_notification_description_vals
,
1780 "Unknown (0x%02X)"));
1784 * Dissect a Date/time information element.
1787 dissect_q931_date_time_ie(tvbuff_t
*tvb
, int offset
, int len
,
1792 * XXX - what is "year" relative to? Is "month" 0-origin or
1793 * 1-origin? Q.931 doesn't say....
1795 proto_tree_add_text(tree
, tvb
, offset
, 6,
1796 "Date/time: %02u-%02u-%02u %02u:%02u:%02u",
1797 tvb_get_guint8(tvb
, offset
+ 0), tvb_get_guint8(tvb
, offset
+ 1), tvb_get_guint8(tvb
, offset
+ 2),
1798 tvb_get_guint8(tvb
, offset
+ 3), tvb_get_guint8(tvb
, offset
+ 4), tvb_get_guint8(tvb
, offset
+ 5));
1799 } else if (len
== 5) {
1800 proto_tree_add_text(tree
, tvb
, offset
, 5,
1801 "Date/time: %02u-%02u-%02u %02u:%02u:00",
1802 tvb_get_guint8(tvb
, offset
+ 0), tvb_get_guint8(tvb
, offset
+ 1), tvb_get_guint8(tvb
, offset
+ 2),
1803 tvb_get_guint8(tvb
, offset
+ 3), tvb_get_guint8(tvb
, offset
+ 4));
1805 proto_tree_add_text(tree
, tvb
, offset
, len
,
1806 "Date/time: length is %d, should be 5 or 6", len
);
1811 * Dissect a Signal information element.
1813 static const value_string q931_signal_vals
[] = {
1814 { 0x00, "Dial tone on" },
1815 { 0x01, "Ring tone on" },
1816 { 0x02, "Intercept tone on" },
1817 { 0x03, "Network congestion tone on" }, /* "fast busy" */
1818 { 0x04, "Busy tone on" },
1819 { 0x05, "Confirm tone on" },
1820 { 0x06, "Answer tone on" },
1821 { 0x07, "Call waiting tone on" },
1822 { 0x08, "Off-hook warning tone on" },
1823 { 0x09, "Preemption tone on" },
1824 { 0x3F, "Tones off" },
1825 { 0x40, "Alerting on - pattern 0" },
1826 { 0x41, "Alerting on - pattern 1" },
1827 { 0x42, "Alerting on - pattern 2" },
1828 { 0x43, "Alerting on - pattern 3" },
1829 { 0x44, "Alerting on - pattern 4" },
1830 { 0x45, "Alerting on - pattern 5" },
1831 { 0x46, "Alerting on - pattern 6" },
1832 { 0x47, "Alerting on - pattern 7" },
1833 { 0x4F, "Alerting off" },
1836 static value_string_ext q931_signal_vals_ext
= VALUE_STRING_EXT_INIT(q931_signal_vals
);
1839 dissect_q931_signal_ie(tvbuff_t
*tvb
, int offset
, int len
,
1843 proto_tree_add_text(tree
, tvb
, offset
, len
,
1844 "Signal: length is %d, should be 1", len
);
1847 proto_tree_add_text(tree
, tvb
, offset
, 1,
1849 val_to_str_ext(tvb_get_guint8(tvb
, offset
), &q931_signal_vals_ext
,
1850 "Unknown (0x%02X)"));
1854 * Dissect an Information rate information element.
1856 static const value_string q931_throughput_class_vals
[] = {
1857 { 0x03, "75 bit/s" },
1858 { 0x04, "150 bit/s" },
1859 { 0x05, "300 bit/s" },
1860 { 0x06, "600 bit/s" },
1861 { 0x07, "1200 bit/s" },
1862 { 0x08, "2400 bit/s" },
1863 { 0x09, "4800 bit/s" },
1864 { 0x0A, "9600 bit/s" },
1865 { 0x0B, "19200 bit/s" },
1866 { 0x0C, "48000 bit/s" },
1867 { 0x0D, "64000 bit/s" },
1870 static value_string_ext q931_throughput_class_vals_ext
= VALUE_STRING_EXT_INIT(q931_throughput_class_vals
);
1873 dissect_q931_information_rate_ie(tvbuff_t
*tvb
, int offset
, int len
,
1877 proto_tree_add_text(tree
, tvb
, offset
, len
,
1878 "Information rate: length is %d, should be 4", len
);
1881 proto_tree_add_text(tree
, tvb
, offset
+ 0, 1,
1882 "Incoming information rate: %s",
1883 val_to_str_ext(tvb_get_guint8(tvb
, offset
+ 0) & 0x1F,
1884 &q931_throughput_class_vals_ext
, "Unknown (0x%02X)"));
1885 proto_tree_add_text(tree
, tvb
, offset
+ 1, 1,
1886 "Outgoing information rate: %s",
1887 val_to_str_ext(tvb_get_guint8(tvb
, offset
+ 1) & 0x1F,
1888 &q931_throughput_class_vals_ext
, "Unknown (0x%02X)"));
1889 proto_tree_add_text(tree
, tvb
, offset
+ 2, 1,
1890 "Minimum incoming information rate: %s",
1891 val_to_str_ext(tvb_get_guint8(tvb
, offset
+ 2) & 0x1F,
1892 &q931_throughput_class_vals_ext
, "Unknown (0x%02X)"));
1893 proto_tree_add_text(tree
, tvb
, offset
+ 3, 1,
1894 "Minimum outgoing information rate: %s",
1895 val_to_str_ext(tvb_get_guint8(tvb
, offset
+ 3) & 0x1F,
1896 &q931_throughput_class_vals_ext
, "Unknown (0x%02X)"));
1900 dissect_q931_guint16_value(tvbuff_t
*tvb
, int offset
, int len
,
1901 proto_tree
*tree
, const char *label
)
1909 octet
= tvb_get_guint8(tvb
, offset
);
1910 if (octet
& Q931_IE_VL_EXTENSION
) {
1912 * Only one octet long - error.
1916 value
= (octet
& 0x3) << 14;
1923 * We've reached the end of the information element - error.
1927 octet
= tvb_get_guint8(tvb
, offset
);
1928 if (octet
& Q931_IE_VL_EXTENSION
) {
1930 * Only two octets long - error.
1934 value
|= (octet
& 0x7F) << 7;
1941 * We've reached the end of the information element - error.
1945 octet
= tvb_get_guint8(tvb
, offset
);
1946 if (!(octet
& Q931_IE_VL_EXTENSION
)) {
1948 * More than three octets long - error.
1952 value
|= (octet
& 0x7F);
1957 proto_tree_add_text(tree
, tvb
, offset
, value_len
, "%s: %u ms", label
,
1962 proto_tree_add_text(tree
, tvb
, offset
, len
,
1963 "%s goes past end of information element", label
);
1967 proto_tree_add_text(tree
, tvb
, offset
, len
, "%s isn't 3 octets long",
1973 * Dissect an End-to-end transit delay information element.
1976 dissect_q931_e2e_transit_delay_ie(tvbuff_t
*tvb
, int offset
, int len
,
1983 value_len
= dissect_q931_guint16_value(tvb
, offset
, len
, tree
,
1984 "Cumulative transit delay");
1987 offset
+= value_len
;
1992 value_len
= dissect_q931_guint16_value(tvb
, offset
, len
, tree
,
1993 "Requested end-to-end transit delay");
1996 offset
+= value_len
;
2001 /*value_len =*/ dissect_q931_guint16_value(tvb
, offset
, len
, tree
,
2002 "Maximum end-to-end transit delay");
2006 * Dissect a Transit delay selection and indication information element.
2009 dissect_q931_td_selection_and_int_ie(tvbuff_t
*tvb
, int offset
, int len
,
2014 dissect_q931_guint16_value(tvb
, offset
, len
, tree
,
2019 * Dissect a Packet layer binary parameters information element.
2021 static const value_string q931_fast_selected_vals
[] = {
2022 { 0x00, "Fast select not requested" },
2023 { 0x08, "Fast select not requested" },
2024 { 0x10, "Fast select requested with no restriction of response" },
2025 { 0x18, "Fast select requested with restrictions of response" },
2030 dissect_q931_pl_binary_parameters_ie(tvbuff_t
*tvb
, int offset
, int len
,
2037 octet
= tvb_get_guint8(tvb
, offset
);
2038 proto_tree_add_text(tree
, tvb
, offset
, 1,
2040 val_to_str(octet
& 0x18, q931_fast_selected_vals
, "Unknown (0x%02X)"));
2041 proto_tree_add_text(tree
, tvb
, offset
, 1,
2043 (octet
& 0x04) ? "No request/request denied" :
2044 "Request indicated/request accepted");
2045 proto_tree_add_text(tree
, tvb
, offset
, 1,
2047 (octet
& 0x02) ? "Link-by-link" : "End-to-end");
2048 proto_tree_add_text(tree
, tvb
, offset
, 1,
2049 "Modulus %u sequencing",
2050 (octet
& 0x01) ? 8 : 128);
2054 * Dissect a Packet layer window size information element.
2057 dissect_q931_pl_window_size_ie(tvbuff_t
*tvb
, int offset
, int len
,
2062 proto_tree_add_text(tree
, tvb
, offset
, 1,
2063 "Forward value: %u", tvb_get_guint8(tvb
, offset
) & 0x7F);
2069 proto_tree_add_text(tree
, tvb
, offset
, 1,
2070 "Backward value: %u", tvb_get_guint8(tvb
, offset
) & 0x7F);
2074 * Dissect a Packet size information element.
2077 dissect_q931_packet_size_ie(tvbuff_t
*tvb
, int offset
, int len
,
2082 proto_tree_add_text(tree
, tvb
, offset
, 1,
2083 "Forward value: %u", tvb_get_guint8(tvb
, offset
) & 0x7F);
2089 proto_tree_add_text(tree
, tvb
, offset
, 1,
2090 "Backward value: %u", tvb_get_guint8(tvb
, offset
) & 0x7F);
2094 * Dissect a Closed user group information element.
2096 static const value_string q931_cug_indication_vals
[] = {
2097 { 0x01, "Closed user group selection" },
2098 { 0x02, "Closed user group with outgoing access selection and indication" },
2103 dissect_q931_cug_ie(tvbuff_t
*tvb
, int offset
, int len
, proto_tree
*tree
)
2107 proto_tree_add_text(tree
, tvb
, offset
, 1,
2108 "CUG indication: %s",
2109 val_to_str(tvb_get_guint8(tvb
, offset
) & 0x07,
2110 q931_cug_indication_vals
, "Unknown (0x%02X)"));
2116 proto_tree_add_text(tree
, tvb
, offset
, len
, "CUG index code: %s",
2117 tvb_format_text(tvb
, offset
, len
));
2121 * Dissect a Reverse charging indication information element.
2123 static const value_string q931_reverse_charging_indication_vals
[] = {
2124 { 0x01, "Reverse charging requested" },
2129 dissect_q931_reverse_charge_ind_ie(tvbuff_t
*tvb
, int offset
, int len
,
2134 proto_tree_add_text(tree
, tvb
, offset
, 1,
2135 "Reverse charging indication: %s",
2136 val_to_str(tvb_get_guint8(tvb
, offset
) & 0x07,
2137 q931_reverse_charging_indication_vals
, "Unknown (0x%02X)"));
2141 * Dissect a (phone) number information element.
2143 static const value_string q931_number_type_vals
[] = {
2145 { 0x1, "International number" },
2146 { 0x2, "National number" },
2147 { 0x3, "Network specific number" },
2148 { 0x4, "Subscriber number" },
2149 { 0x6, "Abbreviated number" },
2153 static const value_string q931_numbering_plan_vals
[] = {
2154 { 0x00, "Unknown" },
2155 { 0x01, "E.164 ISDN/telephony numbering" },
2156 { 0x03, "X.121 data numbering" },
2157 { 0x04, "F.69 Telex numbering" },
2158 { 0x08, "National standard numbering" },
2159 { 0x09, "Private numbering" },
2163 static const value_string q931_presentation_indicator_vals
[] = {
2164 { 0x00, "Presentation allowed" },
2165 { 0x01, "Presentation restricted" },
2166 { 0x02, "Number not available due to interworking" },
2170 static const value_string q931_screening_indicator_vals
[] = {
2171 { 0x00, "User-provided, not screened" },
2172 { 0x01, "User-provided, verified and passed" },
2173 { 0x02, "User-provided, verified and failed" },
2174 { 0x03, "Network-provided" },
2178 static const value_string q931_redirection_reason_vals
[] = {
2179 { 0x00, "Unknown" },
2180 { 0x01, "Call forwarding busy or called DTE busy" },
2181 { 0x02, "Call forwarding no reply" },
2182 { 0x04, "Call deflection" },
2183 { 0x09, "Called DTE out of order" },
2184 { 0x0A, "Call forwarding by the called DTE" },
2185 { 0x0F, "Call forwarding unconditional or systematic call redirection" },
2190 dissect_q931_number_ie(tvbuff_t
*tvb
, int offset
, int len
,
2191 proto_tree
*tree
, int hfindex
, e164_info_t e164_info
)
2198 octet
= tvb_get_guint8(tvb
, offset
);
2199 number_plan
= octet
& 0x0f;
2200 e164_info
.nature_of_address
= ( octet
& 0x70 ) >> 4;
2201 proto_tree_add_uint(tree
, hf_q931_numbering_plan
, tvb
, offset
, 1, octet
);
2202 proto_tree_add_uint(tree
, hf_q931_number_type
, tvb
, offset
, 1, octet
);
2203 proto_tree_add_boolean(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, octet
);
2208 if (!(octet
& Q931_IE_VL_EXTENSION
)) {
2211 octet
= tvb_get_guint8(tvb
, offset
);
2212 proto_tree_add_uint(tree
, hf_q931_screening_ind
, tvb
, offset
, 1, octet
);
2213 proto_tree_add_uint(tree
, hf_q931_presentation_ind
, tvb
, offset
, 1, octet
);
2214 proto_tree_add_boolean(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, octet
);
2220 * XXX - only in a Redirecting number information element.
2222 if (!(octet
& Q931_IE_VL_EXTENSION
)) {
2225 octet
= tvb_get_guint8(tvb
, offset
);
2226 proto_tree_add_text(tree
, tvb
, offset
, 1,
2227 "Reason for redirection: %s",
2228 val_to_str(octet
& 0x0F, q931_redirection_reason_vals
,
2236 proto_tree_add_item(tree
, hfindex
, tvb
, offset
, len
, ENC_ASCII
|ENC_NA
);
2237 proto_item_append_text(proto_tree_get_parent(tree
), ": '%s'", tvb_format_text(tvb
, offset
, len
));
2239 if ( number_plan
== 1 ) {
2240 if ( e164_info
.e164_number_type
!= NONE
){
2242 e164_info
.E164_number_str
= tvb_get_string(wmem_packet_scope(), tvb
, offset
, len
);
2243 e164_info
.E164_number_length
= len
;
2244 dissect_e164_number(tvb
, tree
, offset
, len
, e164_info
);
2248 /* Collect q931_packet_info */
2249 if ( e164_info
.e164_number_type
== CALLING_PARTY_NUMBER
&& have_valid_q931_pi
)
2250 q931_pi
->calling_number
= tvb_get_string(wmem_packet_scope(), tvb
, offset
, len
);
2251 if ( e164_info
.e164_number_type
== CALLED_PARTY_NUMBER
&& have_valid_q931_pi
)
2252 q931_pi
->called_number
= tvb_get_string(wmem_packet_scope(), tvb
, offset
, len
);
2256 * Dissect a party subaddress information element.
2258 static const value_string q931_subaddress_type_vals
[] = {
2259 { 0x00, "X.213/ISO 8348 Add.2 NSAP" },
2260 { 0x20, "User-specified" },
2264 static const value_string q931_odd_even_indicator_vals
[] = {
2265 { 0x00, "Even number of address signals" },
2266 { 0x08, "Odd number of address signals" },
2271 dissect_q931_party_subaddr_ie(tvbuff_t
*tvb
, int offset
, int len
,
2278 octet
= tvb_get_guint8(tvb
, offset
);
2279 proto_tree_add_text(tree
, tvb
, offset
, 1,
2280 "Type of subaddress: %s",
2281 val_to_str(octet
& 0x70, q931_subaddress_type_vals
,
2282 "Unknown (0x%02X)"));
2283 proto_tree_add_text(tree
, tvb
, offset
, 1,
2284 "Odd/even indicator: %s",
2285 val_to_str(octet
& 0x08, q931_odd_even_indicator_vals
,
2286 "Unknown (0x%02X)"));
2292 proto_tree_add_text(tree
, tvb
, offset
, len
, "Subaddress: %s",
2293 tvb_bytes_to_str(tvb
, offset
, len
));
2297 * Dissect a Restart indicator information element.
2299 static const value_string q931_restart_indicator_class_vals
[] = {
2300 { 0x00, "Indicated channels" },
2301 { 0x06, "Single interface" },
2302 { 0x07, "All interfaces" },
2307 dissect_q931_restart_indicator_ie(tvbuff_t
*tvb
, int offset
, int len
,
2311 proto_tree_add_text(tree
, tvb
, offset
, len
,
2312 "Restart indicator: length is %d, should be 1", len
);
2315 proto_tree_add_text(tree
, tvb
, offset
, 1,
2316 "Restart indicator: %s",
2317 val_to_str(tvb_get_guint8(tvb
, offset
) & 0x07,
2318 q931_restart_indicator_class_vals
, "Unknown (0x%02X)"));
2322 * Dissect a High-layer compatibility information element.
2324 #define Q931_MAINTENANCE 0x5e
2325 #define Q931_MANAGEMENT 0x5f
2326 #define Q931_AUDIOVISUAL 0x60
2327 static const value_string q931_high_layer_characteristics_vals
[] = {
2328 { 0x01, "Telephony" },
2329 { 0x04, "F.182 Facsimile Group 2/3" },
2330 { 0x21, "F.184 Facsimile Group 4 Class I" },
2331 { 0x24, "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
2332 { 0x28, "F.220 Teletex, basic and processable mode" },
2333 { 0x31, "F.200 Teletex, basic mode" },
2334 { 0x32, "F.300 and T.102 syntax-based Videotex" },
2335 { 0x33, "F.300 and T.101 international Videotex interworking" },
2336 { 0x35, "F.60 Telex" },
2337 { 0x38, "X.400 Message Handling Systems" },
2338 { 0x41, "X.200 OSI application" },
2339 { 0x42, "FTAM application" },
2340 { 0x5E, "Reserved for maintenance" },
2341 { 0x5F, "Reserved for management" },
2342 { Q931_AUDIOVISUAL
, "F.720/F.821 and F.731 Profile 1a videotelephony" },
2343 { 0x61, "F.702 and F.731 Profile 1b videoconferencing" },
2344 { 0x62, "F.702 and F.731 audiographic conferencing" },
2345 { 0x68, "F.700-series Multimedia services" },
2348 static value_string_ext q931_high_layer_characteristics_vals_ext
= VALUE_STRING_EXT_INIT(q931_high_layer_characteristics_vals
);
2350 static const value_string q931_extended_high_layer_characteristics_vals
[] = {
2351 { 0x01, "Telephony" },
2352 { 0x04, "F.182 Facsimile Group 2/3" },
2353 { 0x21, "F.184 Facsimile Group 4 Class I" },
2354 { 0x24, "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
2355 { 0x28, "F.220 Teletex, basic and processable mode" },
2356 { 0x31, "F.200 Teletex, basic mode" },
2357 { 0x32, "F.300 and T.102 syntax-based Videotex" },
2358 { 0x33, "F.300 and T.101 international Videotex interworking" },
2359 { 0x35, "F.60 Telex" },
2360 { 0x38, "X.400 Message Handling Systems" },
2361 { 0x41, "X.200 OSI application" },
2362 { 0x42, "FTAM application" },
2363 { 0x5E, "Not available for assignment" },
2364 { 0x5F, "Not available for assignment" },
2365 { Q931_AUDIOVISUAL
, "F.720/F.821 and F.731 Profile 1a videotelephony" },
2366 { 0x61, "F.702 and F.731 Profile 1b videoconferencing" },
2367 { 0x62, "F.702 and F.731 audiographic conferencing" },
2368 { 0x68, "F.700-series Multimedia services" },
2371 static value_string_ext q931_extended_high_layer_characteristics_vals_ext
= VALUE_STRING_EXT_INIT(q931_extended_high_layer_characteristics_vals
);
2373 static const value_string q931_audiovisual_characteristics_vals
[] = {
2374 { 0x01, "Capability set of initial channel of H.221" },
2375 { 0x02, "Capability set of subsequent channel of H.221" },
2376 { 0x21, "Capability set of initial channel of an active 3.1kHz audio or speech call" },
2380 static const value_string q931_interpretation_vals
[] = {
2381 { 0x04, "First (primary or only) high layer characteristics identification to be used in the call" },
2385 static const value_string q931_pres_meth_prot_prof_vals
[] = {
2386 { 0x01, "High layer protocol profile (without specification of attributes)" },
2391 * High layer protocol profile
2393 #define Q931_HIGH_LAYER_PROTOCOL_PROFILE 0x01
2396 dissect_q931_high_layer_compat_ie(tvbuff_t
*tvb
, int offset
, int len
,
2400 guint8 coding_standard
;
2402 guint8 characteristics
;
2406 octet
= tvb_get_guint8(tvb
, offset
);
2407 coding_standard
= octet
& 0x60;
2408 pres_method
= octet
& 0x03;
2410 proto_tree_add_item(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2411 proto_tree_add_uint(tree
, hf_q931_coding_standard
, tvb
, offset
, 1, octet
);
2412 proto_tree_add_uint(tree
, hf_q931_interpretation
, tvb
, offset
, 1, octet
);
2413 proto_tree_add_uint(tree
, hf_q931_pres_meth_prot_prof
, tvb
, offset
, 1, octet
);
2417 if ((coding_standard
!= Q931_ITU_STANDARDIZED_CODING
) || (pres_method
!= Q931_HIGH_LAYER_PROTOCOL_PROFILE
)) {
2419 * We don't know how the call state is encoded,
2420 * so just dump it as data and be done with it.
2422 proto_tree_add_text(tree
, tvb
, offset
,
2424 tvb_bytes_to_str(tvb
, offset
, len
));
2430 octet
= tvb_get_guint8(tvb
, offset
);
2431 characteristics
= octet
& 0x7F;
2433 proto_tree_add_item(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2434 proto_tree_add_uint(tree
, hf_q931_high_layer_characteristics
, tvb
, offset
, 1, octet
);
2439 if (!(octet
& Q931_IE_VL_EXTENSION
)) {
2442 octet
= tvb_get_guint8(tvb
, offset
);
2443 if ((characteristics
== Q931_AUDIOVISUAL
) || (characteristics
== 0x61) || (characteristics
== 0x62) ||
2444 (characteristics
== 0x68)) {
2445 proto_tree_add_item(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2446 proto_tree_add_uint(tree
, hf_q931_extended_audiovisual_characteristics
, tvb
, offset
, 1, octet
);
2448 else if ((characteristics
== Q931_MANAGEMENT
) || (characteristics
== Q931_MAINTENANCE
)) {
2449 proto_tree_add_item(tree
, hf_q931_extension_ind
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2450 proto_tree_add_uint(tree
, hf_q931_extended_high_layer_characteristics
, tvb
, offset
, 1, octet
);
2457 * Dissect a User-user information element.
2459 #define Q931_PROTOCOL_DISCRIMINATOR_USER 0x00
2460 #define Q931_PROTOCOL_DISCRIMINATOR_IA5 0x04
2461 #define Q931_PROTOCOL_DISCRIMINATOR_ASN1 0x05
2463 static const value_string q931_protocol_discriminator_vals
[] = {
2464 { Q931_PROTOCOL_DISCRIMINATOR_USER
, "User-specific protocol" },
2465 { 0x01, "OSI high layer protocols" },
2467 { 0x03, "Reserved for system management convergence function" },
2468 { Q931_PROTOCOL_DISCRIMINATOR_IA5
, "IA5 characters" },
2469 { Q931_PROTOCOL_DISCRIMINATOR_ASN1
, "X.208 and X.209 coded user information" },
2470 { 0x06, "Undefined" },
2471 { 0x07, "V.120 rate adaption" },
2472 { 0x08, "Q.931/I.451 user-network call control messages" },
2475 value_string_ext q931_protocol_discriminator_vals_ext
= VALUE_STRING_EXT_INIT(q931_protocol_discriminator_vals
);
2478 dissect_q931_user_user_ie(tvbuff_t
*tvb
, packet_info
*pinfo
, int offset
, int len
,
2482 tvbuff_t
*next_tvb
= NULL
;
2486 octet
= tvb_get_guint8(tvb
, offset
);
2487 proto_tree_add_text(tree
, tvb
, offset
, 1,
2488 "Protocol discriminator: %s",
2489 val_to_str_ext(octet
, &q931_protocol_discriminator_vals_ext
,
2490 "Unknown (0x%02x)"));
2498 case Q931_PROTOCOL_DISCRIMINATOR_USER
:
2499 next_tvb
= tvb_new_subset(tvb
, offset
, len
, len
);
2500 proto_tree_add_text(tree
, tvb
, offset
, len
, "User information: %d octets", len
);
2501 if (!dissector_try_heuristic(q931_user_heur_subdissector_list
, next_tvb
, pinfo
, tree
, NULL
)) {
2502 call_dissector_only(data_handle
, next_tvb
, pinfo
, tree
, NULL
);
2506 case Q931_PROTOCOL_DISCRIMINATOR_IA5
:
2507 proto_tree_add_text(tree
, tvb
, offset
, len
, "User information: %s",
2508 tvb_format_text(tvb
, offset
, len
));
2512 proto_tree_add_text(tree
, tvb
, offset
, len
, "User information: %s",
2513 tvb_bytes_to_str(tvb
, offset
, len
));
2518 static const value_string q931_party_category_vals
[] = {
2519 { 0x00, "Unknown" },
2520 { 0x01, "Extension" },
2521 { 0x02, "Operator" },
2522 { 0x03, "Emergency extension" },
2527 dissect_q931_party_category_ie(tvbuff_t
*tvb
, int offset
, int len
,
2535 octet
= tvb_get_guint8(tvb
, offset
);
2536 proto_tree_add_text(tree
, tvb
, offset
, 1,
2537 "Party category: %s",
2538 val_to_str(octet
&0x07, q931_party_category_vals
,
2539 "Unknown (0x%02x)"));
2548 * Dissect information elements consisting of ASCII^H^H^H^H^HIA5 text.
2551 dissect_q931_ia5_ie(tvbuff_t
*tvb
, int offset
, int len
, proto_tree
*tree
,
2555 proto_tree_add_text(tree
, tvb
, offset
, len
, "%s: %s", label
,
2556 tvb_format_text(tvb
, offset
, len
));
2557 proto_item_append_text(proto_tree_get_parent(tree
), " '%s'", tvb_format_text(tvb
, offset
, len
));
2562 dissect_q931_pdu(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
2563 gboolean is_over_ip
)
2566 proto_tree
*q931_tree
= NULL
;
2567 proto_tree
*ie_tree
= NULL
;
2568 proto_item
*ti
, *ti_ie
;
2570 guint8 call_ref_len
;
2571 guint8 call_ref
[15];
2572 guint32 call_ref_val
;
2573 guint8 message_type
, segmented_message_type
;
2574 guint8 info_element
;
2575 guint16 info_element_len
;
2576 gboolean first_frag
, more_frags
;
2578 fragment_head
*fd_head
;
2579 tvbuff_t
*next_tvb
= NULL
;
2581 q931_pi
=wmem_new(wmem_packet_scope(), q931_packet_info
);
2583 /* Init struct for collecting q931_packet_info */
2584 reset_q931_packet_info(q931_pi
);
2585 have_valid_q931_pi
=TRUE
;
2587 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Q.931");
2589 prot_discr
= tvb_get_guint8(tvb
, offset
);
2591 ti
= proto_tree_add_item(tree
, proto_q931
, tvb
, offset
, -1,
2593 q931_tree
= proto_item_add_subtree(ti
, ett_q931
);
2595 dissect_q931_protocol_discriminator(tvb
, offset
, q931_tree
);
2598 call_ref_len
= tvb_get_guint8(tvb
, offset
) & 0xF; /* XXX - do as a bit field? */
2599 if (q931_tree
!= NULL
)
2600 proto_tree_add_uint(q931_tree
, hf_q931_call_ref_len
, tvb
, offset
, 1, call_ref_len
);
2602 switch (call_ref_len
) {
2603 case 0: call_ref_val
= 0; break;
2604 case 1: call_ref_val
= tvb_get_guint8(tvb
, offset
); break;
2605 case 2: call_ref_val
= tvb_get_ntohs(tvb
, offset
); break;
2606 case 3: call_ref_val
= tvb_get_ntoh24(tvb
, offset
); break;
2607 default: call_ref_val
= tvb_get_ntohl(tvb
, offset
);
2609 if (call_ref_len
!= 0) {
2610 tvb_memcpy(tvb
, call_ref
, offset
, call_ref_len
);
2611 if (q931_tree
!= NULL
) {
2612 proto_tree_add_boolean(q931_tree
, hf_q931_call_ref_flag
,
2613 tvb
, offset
, 1, (call_ref
[0] & 0x80) != 0);
2614 call_ref
[0] &= 0x7F;
2615 proto_tree_add_bytes(q931_tree
, hf_q931_call_ref
,
2616 tvb
, offset
, call_ref_len
, call_ref
);
2618 { /* info for the tap */
2619 call_ref
[0] &= 0x7F;
2621 /* XXX - Should crv be something besides a guint32? */
2622 memcpy(&(q931_pi
->crv
), call_ref
, call_ref_len
> sizeof(q931_pi
->crv
) ? sizeof(q931_pi
->crv
) : call_ref_len
);
2623 offset
+= call_ref_len
;
2625 message_type
= tvb_get_guint8(tvb
, offset
);
2626 if(have_valid_q931_pi
) {
2627 q931_pi
->message_type
= message_type
;
2629 col_add_str(pinfo
->cinfo
, COL_INFO
, get_message_name(prot_discr
, message_type
));
2631 if (prot_discr
== NLPID_DMS
)
2632 proto_tree_add_item(q931_tree
, hf_q931_maintenance_message_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2634 proto_tree_add_item(q931_tree
, hf_q931_message_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2639 * And now for the information elements....
2641 if ((message_type
!= Q931_SEGMENT
) || !q931_reassembly
||
2642 (tvb_reported_length_remaining(tvb
, offset
) <= 4)) {
2643 dissect_q931_IEs(tvb
, pinfo
, tree
, q931_tree
, is_over_ip
, offset
, 0);
2646 info_element
= tvb_get_guint8(tvb
, offset
);
2647 info_element_len
= tvb_get_guint8(tvb
, offset
+ 1);
2648 if ((info_element
!= Q931_IE_SEGMENTED_MESSAGE
) || (info_element_len
< 2)) {
2649 dissect_q931_IEs(tvb
, pinfo
, tree
, q931_tree
, is_over_ip
, offset
, 0);
2652 /* Segmented message IE */
2653 ti_ie
= proto_tree_add_text(q931_tree
, tvb
, offset
, 1+1+info_element_len
, "%s",
2654 val_to_str(info_element
, q931_info_element_vals
[0], "Unknown information element (0x%02X)"));
2655 ie_tree
= proto_item_add_subtree(ti_ie
, ett_q931_ie
);
2656 proto_tree_add_text(ie_tree
, tvb
, offset
, 1, "Information element: %s",
2657 val_to_str(info_element
, q931_info_element_vals
[0], "Unknown (0x%02X)"));
2658 proto_tree_add_text(ie_tree
, tvb
, offset
+ 1, 1, "Length: %u", info_element_len
);
2659 dissect_q931_segmented_message_ie(tvb
, offset
+ 2, info_element_len
, ie_tree
);
2660 first_frag
= (tvb_get_guint8(tvb
, offset
+ 2) & 0x80) != 0;
2661 more_frags
= (tvb_get_guint8(tvb
, offset
+ 2) & 0x7F) != 0;
2662 segmented_message_type
= tvb_get_guint8(tvb
, offset
+ 3);
2663 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " of %s",
2664 val_to_str_ext(segmented_message_type
, &q931_message_type_vals_ext
, "Unknown message type (0x%02X)"));
2666 offset
+= 1 + 1 + info_element_len
;
2668 frag_len
= tvb_reported_length_remaining(tvb
, offset
);
2669 if (first_frag
&& fragment_get(&q931_reassembly_table
, pinfo
, call_ref_val
, NULL
)) {
2670 /* there are some unreassembled segments, ignore them */
2671 fragment_end_seq_next(&q931_reassembly_table
, pinfo
, call_ref_val
, NULL
);
2673 fd_head
= fragment_add_seq_next(&q931_reassembly_table
,
2674 tvb
, offset
, pinfo
, call_ref_val
, NULL
,
2675 frag_len
, more_frags
);
2677 if (pinfo
->fd
->num
== fd_head
->reassembled_in
) { /* last fragment */
2678 if (fd_head
->next
!= NULL
) { /* 2 or more segments */
2679 next_tvb
= tvb_new_chain(tvb
, fd_head
->tvb_data
);
2680 add_new_data_source(pinfo
, next_tvb
, "Reassembled Q.931 IEs");
2681 /* Show all fragments. */
2683 proto_item
*frag_tree_item
;
2684 show_fragment_seq_tree(fd_head
, &q931_frag_items
, q931_tree
, pinfo
, next_tvb
, &frag_tree_item
);
2686 } else { /* only 1 segment */
2687 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
2690 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s [reassembled]",
2691 val_to_str_ext(segmented_message_type
, &q931_message_type_vals_ext
, "Unknown message type (0x%02X)"));
2694 if (tree
) proto_tree_add_uint(q931_tree
, hf_q931_reassembled_in
, tvb
, offset
, frag_len
, fd_head
->reassembled_in
);
2698 dissect_q931_IEs(next_tvb
, pinfo
, tree
, q931_tree
, is_over_ip
, 0, 0);
2701 static const value_string q931_codeset_vals
[] = {
2702 { 0x00, "Q.931 information elements" },
2703 { 0x04, "Information elements for ISO/IEC use" },
2704 { 0x05, "Information elements for national use" },
2705 { 0x06, "Information elements specific to the local network" },
2706 { 0x07, "User-specific information elements" },
2711 dissect_q931_IEs(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*root_tree
,
2712 proto_tree
*q931_tree
, gboolean is_over_ip
, int offset
, int initial_codeset
)
2715 proto_tree
*ie_tree
= NULL
;
2716 guint8 info_element
;
2718 guint16 info_element_len
;
2719 int codeset
, locked_codeset
;
2720 gboolean non_locking_shift
, first_segment
;
2721 tvbuff_t
*h225_tvb
, *next_tvb
;
2722 e164_info_t e164_info
;
2723 e164_info
.e164_number_type
= NONE
;
2724 e164_info
.nature_of_address
= NONE
;
2725 e164_info
.E164_number_str
= "";
2726 e164_info
.E164_number_length
= NONE
;
2728 codeset
= locked_codeset
= initial_codeset
;
2729 first_segment
= FALSE
;
2730 while (tvb_reported_length_remaining(tvb
, offset
) > 0) {
2731 info_element
= tvb_get_guint8(tvb
, offset
);
2733 /* Check for the codeset shift */
2734 if ((info_element
& Q931_IE_SO_MASK
) &&
2735 ((info_element
& Q931_IE_SO_IDENTIFIER_MASK
) == Q931_IE_SHIFT
)) {
2736 non_locking_shift
= info_element
& Q931_IE_SHIFT_NON_LOCKING
;
2737 codeset
= info_element
& Q931_IE_SHIFT_CODESET
;
2738 if (!non_locking_shift
)
2739 locked_codeset
= codeset
;
2740 if (q931_tree
!= NULL
) {
2741 proto_tree_add_text(q931_tree
, tvb
, offset
, 1,
2742 "%s shift to codeset %u: %s",
2743 (non_locking_shift
? "Non-locking" : "Locking"),
2745 val_to_str(codeset
, q931_codeset_vals
,
2746 "Unknown (0x%02X)"));
2753 * Check for the single-octet IEs.
2755 if (info_element
& Q931_IE_SO_MASK
) {
2757 * Check for subdissectors for this IE or
2758 * for all IEs in this codeset.
2760 if (dissector_get_uint_handle(codeset_dissector_table
, codeset
) ||
2761 dissector_get_uint_handle(ie_dissector_table
, (codeset
<< 8) | (info_element
& Q931_IE_SO_IDENTIFIER_MASK
))) {
2762 next_tvb
= tvb_new_subset (tvb
, offset
, 1, 1);
2763 if (dissector_try_uint(ie_dissector_table
, (codeset
<< 8) | (info_element
& Q931_IE_SO_IDENTIFIER_MASK
), next_tvb
, pinfo
, q931_tree
) ||
2764 dissector_try_uint(codeset_dissector_table
, codeset
, next_tvb
, pinfo
, q931_tree
)) {
2766 codeset
= locked_codeset
;
2771 switch ((codeset
<< 8) | (info_element
& Q931_IE_SO_IDENTIFIER_MASK
)) {
2773 case CS0
| Q931_IE_MORE_DATA_OR_SEND_COMP
:
2774 switch (info_element
) {
2776 case Q931_IE_MORE_DATA
:
2777 if (q931_tree
!= NULL
) {
2778 proto_tree_add_text(q931_tree
, tvb
, offset
, 1,
2783 case Q931_IE_SENDING_COMPLETE
:
2784 if (q931_tree
!= NULL
) {
2785 proto_tree_add_text(q931_tree
, tvb
, offset
, 1,
2786 "Sending complete");
2791 if (q931_tree
!= NULL
) {
2792 proto_tree_add_text(q931_tree
, tvb
, offset
, 1,
2793 "Unknown information element (0x%02X)",
2800 case CS0
| Q931_IE_CONGESTION_LEVEL
:
2801 if (q931_tree
!= NULL
) {
2802 proto_tree_add_text(q931_tree
, tvb
, offset
, 1,
2803 "Congestion level: %s",
2804 val_to_str(info_element
& Q931_IE_SO_IE_MASK
,
2805 q931_congestion_level_vals
,
2810 case CS0
| Q931_IE_REPEAT_INDICATOR
:
2811 if (q931_tree
!= NULL
) {
2812 proto_tree_add_text(q931_tree
, tvb
, offset
, 1,
2813 "Repeat indicator: %s",
2814 val_to_str(info_element
& Q931_IE_SO_IE_MASK
,
2815 q931_repeat_indication_vals
,
2821 if (q931_tree
!= NULL
) {
2822 proto_tree_add_text(q931_tree
, tvb
, offset
, 1,
2823 "Unknown information element (0x%02X)",
2829 codeset
= locked_codeset
;
2834 * Variable-length IE.
2836 * According to page 18 from Recommendation H.225.0 :
2837 * " Length of user-user contents contents
2838 * - Shall be 2 octets instead of 1 (as in Figure 4-36/Q.931)"
2840 * We assume that if this is Q.931-over-TPKT, it might
2841 * be H.225 traffic, and check for the IE being a user-user
2842 * IE with ASN.1 encoding of the user information.
2844 if (is_over_ip
&& tvb_bytes_exist(tvb
, offset
, 4) &&
2845 codeset
== 0 && tvb_get_guint8(tvb
, offset
) == Q931_IE_USER_USER
&&
2846 tvb_get_guint8(tvb
, offset
+ 3) == Q931_PROTOCOL_DISCRIMINATOR_ASN1
) {
2847 info_element_len
= tvb_get_ntohs(tvb
, offset
+ 1);
2848 if (q931_tree
!= NULL
) {
2849 ti
= proto_tree_add_text(q931_tree
, tvb
, offset
,
2850 1+2+info_element_len
, "%s",
2851 val_to_str(info_element
,
2852 q931_info_element_vals
[codeset
],
2853 "Unknown information element (0x%02X)"));
2854 ie_tree
= proto_item_add_subtree(ti
,
2856 proto_tree_add_text(ie_tree
, tvb
, offset
, 1,
2857 "Information element: %s",
2858 val_to_str(info_element
,
2859 q931_info_element_vals
[codeset
], "Unknown (0x%02X)"));
2860 proto_tree_add_text(ie_tree
, tvb
, offset
+ 1,
2861 2, "Length: %u", info_element_len
);
2862 proto_tree_add_text(ie_tree
, tvb
, offset
+ 3,
2863 1, "Protocol discriminator: %s",
2864 val_to_str_ext(tvb_get_guint8(tvb
, offset
+ 3),
2865 &q931_protocol_discriminator_vals_ext
,
2866 "Unknown (0x%02x)"));
2869 if (info_element_len
> 1) {
2871 * If we don't desegment limit the length
2872 * to the actual size in the frame
2874 if (!pinfo
->can_desegment
) {
2875 info_element_len
= MIN(info_element_len
, tvb_length_remaining(tvb
, offset
+ 3));
2878 * Do we have a handle for the H.225
2881 if (h225_handle
!= NULL
) {
2883 * Yes - call it, regardless of
2884 * whether we're building a
2885 * protocol tree or not.
2887 h225_tvb
= tvb_new_subset(tvb
,
2888 offset
+ 4, info_element_len
- 1,
2889 info_element_len
- 1);
2890 call_dissector(h225_handle
, h225_tvb
,
2894 * No - just show it as "User
2895 * information" (if "ie_tree" is
2896 * null, this won't add anything).
2898 proto_tree_add_text(ie_tree
, tvb
,
2899 offset
+ 4, info_element_len
- 1,
2900 "User information: %s",
2901 tvb_bytes_to_str(tvb
, offset
+ 4,
2902 info_element_len
- 1));
2905 offset
+= 1 + 2 + info_element_len
;
2907 info_element_len
= tvb_get_guint8(tvb
, offset
+ 1);
2909 if (first_segment
&& (tvb_reported_length_remaining(tvb
, offset
+ 2) < info_element_len
)) { /* incomplete IE at the end of the 1st segment */
2910 proto_tree_add_text(q931_tree
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
), "Incomplete IE in the 1st segment");
2915 * Check for subdissectors for this IE or
2916 * for all IEs in this codeset.
2918 if (dissector_get_uint_handle(codeset_dissector_table
, codeset
) ||
2919 dissector_get_uint_handle(ie_dissector_table
, (codeset
<< 8) | info_element
)) {
2920 next_tvb
= tvb_new_subset (tvb
, offset
, info_element_len
+ 2, info_element_len
+ 2);
2921 if (dissector_try_uint(ie_dissector_table
, (codeset
<< 8) | info_element
, next_tvb
, pinfo
, q931_tree
) ||
2922 dissector_try_uint(codeset_dissector_table
, codeset
, next_tvb
, pinfo
, q931_tree
)) {
2923 offset
+= 2 + info_element_len
;
2924 codeset
= locked_codeset
;
2929 ti
= proto_tree_add_text(q931_tree
, tvb
, offset
, 1+1+info_element_len
, "%s",
2930 val_to_str(info_element
, q931_info_element_vals
[codeset
], "Unknown information element (0x%02X)"));
2931 ie_tree
= proto_item_add_subtree(ti
, ett_q931_ie
);
2932 proto_tree_add_text(ie_tree
, tvb
, offset
, 1, "Information element: %s",
2933 val_to_str(info_element
, q931_info_element_vals
[codeset
], "Unknown (0x%02X)"));
2934 proto_tree_add_text(ie_tree
, tvb
, offset
+ 1, 1, "Length: %u", info_element_len
);
2936 if (((codeset
<< 8) | info_element
) == (CS0
| Q931_IE_SEGMENTED_MESSAGE
)) {
2937 dissect_q931_segmented_message_ie(tvb
, offset
+ 2, info_element_len
, ie_tree
);
2938 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " of %s",
2939 val_to_str_ext(tvb_get_guint8(tvb
, offset
+ 3), &q931_message_type_vals_ext
, "Unknown message type (0x%02X)"));
2941 if (tvb_get_guint8(tvb
, offset
+ 2) & 0x80) { /* the 1st segment */
2942 first_segment
= TRUE
;
2943 } else { /* not the 1st segment */
2944 proto_tree_add_text(q931_tree
, tvb
, offset
+ 4, tvb_reported_length_remaining(tvb
, offset
+ 4), "Message segment");
2945 info_element_len
+= tvb_reported_length_remaining(tvb
, offset
+ 4);
2949 * For the calling number, called number,
2950 * and release cause IEs, don't check
2951 * for the tree being null, as
2952 * the dissectors for those IEs also
2953 * supply information for the tap used
2956 switch ((codeset
<< 8) | info_element
) {
2958 case CS0
| Q931_IE_BEARER_CAPABILITY
:
2959 case CS0
| Q931_IE_LOW_LAYER_COMPAT
:
2960 if (q931_tree
!= NULL
) {
2961 dissect_q931_bearer_capability_ie(tvb
,
2962 offset
+ 2, info_element_len
,
2967 case CS0
| Q931_IE_CAUSE
:
2968 dissect_q931_cause_ie_unsafe(tvb
,
2969 offset
+ 2, info_element_len
,
2971 hf_q931_cause_value
, &dummy
, q931_info_element_vals0
);
2974 case CS0
| Q931_IE_CHANGE_STATUS
:
2975 if (q931_tree
!= NULL
) {
2976 dissect_q931_change_status_ie(tvb
,
2977 offset
+ 2, info_element_len
,
2982 case CS0
| Q931_IE_CALL_STATE
:
2983 if (q931_tree
!= NULL
) {
2984 dissect_q931_call_state_ie(tvb
,
2985 offset
+ 2, info_element_len
,
2990 case CS0
| Q931_IE_CHANNEL_IDENTIFICATION
:
2991 if (q931_tree
!= NULL
) {
2992 dissect_q931_channel_identification_ie(
2993 tvb
, offset
+ 2, info_element_len
,
2998 case CS0
| Q931_IE_PROGRESS_INDICATOR
:
2999 if (q931_tree
!= NULL
) {
3000 dissect_q931_progress_indicator_ie(tvb
,
3001 offset
+ 2, info_element_len
,
3006 case CS0
| Q931_IE_NETWORK_SPECIFIC_FACIL
:
3007 case CS0
| Q931_IE_TRANSIT_NETWORK_SEL
:
3008 if (q931_tree
!= NULL
) {
3009 dissect_q931_ns_facilities_ie(tvb
,
3010 offset
+ 2, info_element_len
,
3015 case CS0
| Q931_IE_NOTIFICATION_INDICATOR
:
3016 if (q931_tree
!= NULL
) {
3017 dissect_q931_notification_indicator_ie(
3018 tvb
, offset
+ 2, info_element_len
,
3023 case CS0
| Q931_IE_DISPLAY
:
3024 if (q931_tree
!= NULL
) {
3025 dissect_q931_ia5_ie(tvb
, offset
+ 2,
3026 info_element_len
, ie_tree
,
3027 "Display information");
3031 case CS0
| Q931_IE_DATE_TIME
:
3032 if (q931_tree
!= NULL
) {
3033 dissect_q931_date_time_ie(tvb
,
3034 offset
+ 2, info_element_len
,
3039 case CS0
| Q931_IE_KEYPAD_FACILITY
:
3040 if (q931_tree
!= NULL
) {
3041 dissect_q931_ia5_ie(tvb
, offset
+ 2,
3042 info_element_len
, ie_tree
,
3047 case CS0
| Q931_IE_SIGNAL
:
3048 if (q931_tree
!= NULL
) {
3049 dissect_q931_signal_ie(tvb
,
3050 offset
+ 2, info_element_len
,
3055 case CS0
| Q931_IE_INFORMATION_RATE
:
3056 if (q931_tree
!= NULL
) {
3057 dissect_q931_information_rate_ie(tvb
,
3058 offset
+ 2, info_element_len
,
3063 case CS0
| Q931_IE_E2E_TRANSIT_DELAY
:
3064 if (q931_tree
!= NULL
) {
3065 dissect_q931_e2e_transit_delay_ie(tvb
,
3066 offset
+ 2, info_element_len
,
3071 case CS0
| Q931_IE_TD_SELECTION_AND_INT
:
3072 if (q931_tree
!= NULL
) {
3073 dissect_q931_td_selection_and_int_ie(
3074 tvb
, offset
+ 2, info_element_len
,
3079 case CS0
| Q931_IE_PL_BINARY_PARAMETERS
:
3080 if (q931_tree
!= NULL
) {
3081 dissect_q931_pl_binary_parameters_ie(
3082 tvb
, offset
+ 2, info_element_len
,
3087 case CS0
| Q931_IE_PL_WINDOW_SIZE
:
3088 if (q931_tree
!= NULL
) {
3089 dissect_q931_pl_window_size_ie(tvb
,
3090 offset
+ 2, info_element_len
,
3095 case CS0
| Q931_IE_PACKET_SIZE
:
3096 if (q931_tree
!= NULL
) {
3097 dissect_q931_packet_size_ie(tvb
,
3098 offset
+ 2, info_element_len
,
3103 case CS0
| Q931_IE_CUG
:
3104 if (q931_tree
!= NULL
) {
3105 dissect_q931_cug_ie(tvb
,
3106 offset
+ 2, info_element_len
,
3111 case CS0
| Q931_IE_REVERSE_CHARGE_IND
:
3112 if (q931_tree
!= NULL
) {
3113 dissect_q931_reverse_charge_ind_ie(tvb
,
3114 offset
+ 2, info_element_len
,
3119 case CS0
| Q931_IE_CONNECTED_NUMBER_DEFAULT
:
3120 if (q931_tree
!= NULL
) {
3121 dissect_q931_number_ie(tvb
,
3122 offset
+ 2, info_element_len
,
3124 hf_q931_connected_number
, e164_info
);
3129 case CS0
| Q931_IE_CALLING_PARTY_NUMBER
:
3130 e164_info
.e164_number_type
= CALLING_PARTY_NUMBER
;
3131 dissect_q931_number_ie(tvb
,
3132 offset
+ 2, info_element_len
,
3134 hf_q931_calling_party_number
, e164_info
);
3137 case CS0
| Q931_IE_CALLED_PARTY_NUMBER
:
3138 e164_info
.e164_number_type
= CALLED_PARTY_NUMBER
;
3139 dissect_q931_number_ie(tvb
,
3140 offset
+ 2, info_element_len
,
3142 hf_q931_called_party_number
, e164_info
);
3145 case CS0
| Q931_IE_CALLING_PARTY_SUBADDR
:
3146 case CS0
| Q931_IE_CALLED_PARTY_SUBADDR
:
3147 if (q931_tree
!= NULL
) {
3148 dissect_q931_party_subaddr_ie(tvb
,
3149 offset
+ 2, info_element_len
,
3154 case CS0
| Q931_IE_REDIRECTING_NUMBER
:
3155 if (q931_tree
!= NULL
) {
3156 dissect_q931_number_ie(tvb
,
3157 offset
+ 2, info_element_len
,
3159 hf_q931_redirecting_number
, e164_info
);
3163 case CS0
| Q931_IE_RESTART_INDICATOR
:
3164 if (q931_tree
!= NULL
) {
3165 dissect_q931_restart_indicator_ie(tvb
,
3166 offset
+ 2, info_element_len
,
3171 case CS0
| Q931_IE_HIGH_LAYER_COMPAT
:
3172 if (q931_tree
!= NULL
) {
3173 dissect_q931_high_layer_compat_ie(tvb
,
3174 offset
+ 2, info_element_len
,
3179 case CS0
| Q931_IE_USER_USER
:
3180 if (q931_tree
!= NULL
) {
3181 dissect_q931_user_user_ie(tvb
, pinfo
,
3182 offset
+ 2, info_element_len
,
3187 case CS5
| Q931_IE_PARTY_CATEGORY
:
3188 if (q931_tree
!= NULL
) {
3189 dissect_q931_party_category_ie(tvb
,
3190 offset
+ 2, info_element_len
,
3195 case CS6
| Q931_IE_DISPLAY
:
3196 if (q931_tree
!= NULL
) {
3197 dissect_q931_ia5_ie(tvb
, offset
+ 2,
3198 info_element_len
, ie_tree
,
3204 if (q931_tree
!= NULL
) {
3205 proto_tree_add_text(ie_tree
, tvb
,
3206 offset
+ 2, info_element_len
,
3208 tvb_bytes_to_str(tvb
, offset
+ 2,
3214 offset
+= 1 + 1 + info_element_len
;
3216 codeset
= locked_codeset
;
3218 if(have_valid_q931_pi
) {
3219 tap_queue_packet(q931_tap
, pinfo
, q931_pi
);
3221 have_valid_q931_pi
=FALSE
;
3225 * Q.931-over-TPKT-over-TCP.
3228 dissect_q931_tpkt_heur(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
3233 * Check whether this looks like a TPKT-encapsulated
3236 * The minimum length of a Q.931 message is 3:
3237 * 1 byte for the protocol discriminator,
3238 * 1 for the call_reference length,
3239 * and one for the message type.
3241 lv_tpkt_len
= is_tpkt(tvb
, 3);
3242 if (lv_tpkt_len
== -1) {
3244 * It's not a TPKT packet; reject it.
3250 * If this segment is *exactly* the length of a TPKT header,
3251 * we assume that, as it looks like a TPKT header, it
3252 * is one, and that the code put a TPKT header in one
3253 * segment and the rest of the PDU in another.
3255 if (tvb_length(tvb
) == 4) {
3257 * It is - call the "dissect TPKT over a TCP stream"
3260 dissect_tpkt_encap(tvb
, pinfo
, tree
, q931_desegment
,
3261 q931_tpkt_pdu_handle
);
3266 * Well, we have more data than just the TPKT header;
3267 * check whether it looks like the beginning of a
3270 * The minimum length of a Q.931 message is 3, as per the
3273 * Check that we have that many bytes past the TPKT header in
3274 * the tvbuff; we already know that the TPKT header says we
3275 * have that many bytes (as we passed 3 as the "min_len" argument
3278 if (!tvb_bytes_exist(tvb
, 4, 3))
3281 /* Check the protocol discriminator */
3282 if ((tvb_get_guint8(tvb
, 4) != NLPID_Q_931
) && (tvb_get_guint8(tvb
, 4) != 0x03)) {
3283 /* Doesn't look like Q.931 inside TPKT */
3288 * OK, it looks like Q.931-over-TPKT.
3289 * Call the "dissect TPKT over a TCP stream" routine.
3291 dissect_tpkt_encap(tvb
, pinfo
, tree
, q931_desegment
,
3292 q931_tpkt_pdu_handle
);
3298 dissect_q931_tpkt(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
3300 dissect_q931_tpkt_heur(tvb
, pinfo
, tree
, NULL
);
3304 dissect_q931_tpkt_pdu(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
3306 dissect_q931_pdu(tvb
, pinfo
, tree
, TRUE
);
3310 dissect_q931(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
3312 dissect_q931_pdu(tvb
, pinfo
, tree
, FALSE
);
3316 dissect_q931_over_ip(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
3318 dissect_q931_pdu(tvb
, pinfo
, tree
, TRUE
);
3322 dissect_q931_ie_cs0(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
3324 dissect_q931_IEs(tvb
, pinfo
, NULL
, tree
, FALSE
, 0, 0);
3328 dissect_q931_ie_cs7(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
3330 dissect_q931_IEs(tvb
, pinfo
, NULL
, tree
, FALSE
, 0, 7);
3335 /* Initialize the fragment and reassembly tables */
3336 reassembly_table_init(&q931_reassembly_table
,
3337 &addresses_reassembly_table_functions
);
3341 proto_register_q931(void)
3343 static hf_register_info hf
[] = {
3344 { &hf_q931_discriminator
,
3345 { "Protocol discriminator", "q931.disc", FT_UINT8
, BASE_HEX
, NULL
, 0x0,
3348 { &hf_q931_call_ref_len
,
3349 { "Call reference value length", "q931.call_ref_len", FT_UINT8
, BASE_DEC
, NULL
, 0x0,
3352 { &hf_q931_call_ref_flag
,
3353 { "Call reference flag", "q931.call_ref_flag", FT_BOOLEAN
, BASE_NONE
, TFS(&tfs_call_ref_flag
), 0x0,
3356 { &hf_q931_call_ref
,
3357 { "Call reference value", "q931.call_ref", FT_BYTES
, BASE_NONE
, NULL
, 0x0,
3360 { &hf_q931_message_type
,
3361 { "Message type", "q931.message_type", FT_UINT8
, BASE_HEX
|BASE_EXT_STRING
, &q931_message_type_vals_ext
, 0x0,
3364 { &hf_q931_maintenance_message_type
,
3365 { "Maintenance message type", "q931.maintenance_message_type", FT_UINT8
, BASE_HEX
, VALS(dms_message_type_vals
), 0x0,
3368 { &hf_q931_segment_type
,
3369 { "Segmented message type", "q931.segment_type", FT_UINT8
, BASE_HEX
|BASE_EXT_STRING
, &q931_message_type_vals_ext
, 0x0,
3372 { &hf_q931_coding_standard
,
3373 { "Coding standard", "q931.coding_standard", FT_UINT8
, BASE_HEX
,
3374 VALS(q931_coding_standard_vals
), 0x60,NULL
, HFILL
}},
3376 { &hf_q931_interpretation
,
3377 { "Interpretation", "q931.interpretation", FT_UINT8
, BASE_HEX
,
3378 VALS(q931_interpretation_vals
), 0x1C, NULL
, HFILL
}},
3380 { &hf_q931_pres_meth_prot_prof
,
3381 { "Presentation method of protocol profile", "q931.presentation_method_protocol_profile", FT_UINT8
, BASE_HEX
,
3382 VALS(q931_pres_meth_prot_prof_vals
), 0x03, NULL
, HFILL
}},
3384 { &hf_q931_high_layer_characteristics
,
3385 { "High layer characteristics identification", "q931.high_layer_characteristics", FT_UINT8
, BASE_HEX
|BASE_EXT_STRING
,
3386 &q931_high_layer_characteristics_vals_ext
, 0x7f, NULL
, HFILL
}},
3388 { &hf_q931_extended_high_layer_characteristics
,
3389 { "Extended high layer characteristics identification", "q931.extended_high_layer_characteristics", FT_UINT8
, BASE_HEX
|BASE_EXT_STRING
,
3390 &q931_extended_high_layer_characteristics_vals_ext
, 0x7f, NULL
, HFILL
}},
3392 { &hf_q931_extended_audiovisual_characteristics
,
3393 { "Extended audiovisual characteristics identification", "q931.extended_audiovisual_characteristics", FT_UINT8
, BASE_HEX
,
3394 VALS(q931_audiovisual_characteristics_vals
), 0x7f, NULL
, HFILL
}},
3396 { &hf_q931_information_transfer_capability
,
3397 { "Information transfer capability", "q931.information_transfer_capability", FT_UINT8
, BASE_HEX
,
3398 VALS(q931_information_transfer_capability_vals
), 0x1f,NULL
, HFILL
}},
3400 { &hf_q931_transfer_mode
,
3401 { "Transfer mode", "q931.transfer_mode", FT_UINT8
, BASE_HEX
,
3402 VALS(q931_transfer_mode_vals
), 0x60,NULL
, HFILL
}},
3404 { &hf_q931_information_transfer_rate
,
3405 { "Information transfer rate", "q931.information_transfer_rate", FT_UINT8
, BASE_HEX
,
3406 VALS(q931_information_transfer_rate_vals
), 0x1f,NULL
, HFILL
}},
3408 { &hf_q931_layer_ident
,
3409 { "Layer identification", "q931.layer_ident", FT_UINT8
, BASE_HEX
,
3410 VALS(q931_bearer_capability_layer_ident_vals
), 0x60, NULL
, HFILL
}},
3413 { "User information layer 1 protocol", "q931.uil1", FT_UINT8
, BASE_HEX
|BASE_EXT_STRING
,
3414 &q931_uil1_vals_ext
, 0x1f,NULL
, HFILL
}},
3416 { &hf_q931_cause_location
,
3417 { "Cause location", "q931.cause_location", FT_UINT8
, BASE_DEC
|BASE_EXT_STRING
, &q931_cause_location_vals_ext
, 0x0f,
3420 { &hf_q931_cause_value
,
3421 { "Cause value", "q931.cause_value", FT_UINT8
, BASE_DEC
|BASE_EXT_STRING
, &q931_cause_code_vals_ext
, 0x7f,
3424 { &hf_q931_number_type
,
3425 { "Number type", "q931.number_type", FT_UINT8
, BASE_HEX
, VALS(q931_number_type_vals
), 0x70,
3428 { &hf_q931_numbering_plan
,
3429 { "Numbering plan", "q931.numbering_plan", FT_UINT8
, BASE_HEX
, VALS(q931_numbering_plan_vals
), 0x0f,
3432 { &hf_q931_screening_ind
,
3433 { "Screening indicator", "q931.screening_ind", FT_UINT8
, BASE_HEX
, VALS(q931_screening_indicator_vals
), 0x03,
3436 { &hf_q931_presentation_ind
,
3437 { "Presentation indicator", "q931.presentation_ind", FT_UINT8
, BASE_HEX
, VALS(q931_presentation_indicator_vals
), 0x60,
3440 { &hf_q931_extension_ind
,
3441 { "Extension indicator", "q931.extension_ind",
3442 FT_BOOLEAN
, 8, TFS(&q931_extension_ind_value
), 0x80,
3445 { &hf_q931_extension_ind_preference
,
3446 { "Preference", "q931.extension_ind_preference",
3447 FT_UINT8
, BASE_DEC
, VALS(q931_status_preference_vals
), 0x40,
3450 { &hf_q931_extension_ind_new_status
,
3451 { "New status", "q931.extension_ind_new_status",
3452 FT_UINT8
, BASE_DEC
, VALS(q931_new_status_vals
), 0x07,
3455 { &hf_q931_calling_party_number
,
3456 { "Calling party number digits", "q931.calling_party_number.digits", FT_STRING
, BASE_NONE
, NULL
, 0x0,
3459 { &hf_q931_called_party_number
,
3460 { "Called party number digits", "q931.called_party_number.digits", FT_STRING
, BASE_NONE
, NULL
, 0x0,
3463 { &hf_q931_connected_number
,
3464 { "Connected party number digits", "q931.connected_number.digits", FT_STRING
, BASE_NONE
, NULL
, 0x0,
3467 { &hf_q931_redirecting_number
,
3468 { "Redirecting party number digits", "q931.redirecting_number.digits", FT_STRING
, BASE_NONE
, NULL
, 0x0,
3471 /* fields for channel identification IE */
3472 /* 0x80 is the extension bit */
3474 { &hf_q931_channel_interface_explicit
,
3475 { "Interface identifier present", "q931.channel.interface_id_present", FT_BOOLEAN
, 8, NULL
, 0x40,
3476 "True if the interface identifier is explicit in the following octets", HFILL
}},
3478 { &hf_q931_channel_interface_type
,
3479 { "Interface type", "q931.channel.interface_type", FT_BOOLEAN
, 8, TFS(&tfs_interface_type
), 0x20,
3480 "Identifies the ISDN interface type", HFILL
}},
3484 { &hf_q931_channel_exclusive
,
3485 { "Indicated channel", "q931.channel.exclusive", FT_BOOLEAN
, 8, TFS(&tfs_channel_exclusive
), 0x08,
3486 "True if only the indicated channel is acceptable", HFILL
}},
3488 { &hf_q931_channel_dchan
,
3489 { "D-channel indicator", "q931.channel.dchan", FT_BOOLEAN
, 8, NULL
, 0x04,
3490 "True if the identified channel is the D-Channel", HFILL
}},
3492 { &hf_q931_channel_selection_bri
,
3493 { "Information channel selection", "q931.channel.selection", FT_UINT8
, BASE_HEX
, q931_basic_channel_selection_vals
, 0x03,
3494 "Identifies the information channel to be used", HFILL
}},
3496 { &hf_q931_channel_selection_pri
,
3497 { "Information channel selection", "q931.channel.selection", FT_UINT8
, BASE_HEX
, q931_not_basic_channel_selection_vals
, 0x03,
3498 "Identifies the information channel to be used", HFILL
}},
3500 { &hf_q931_channel_map
,
3501 { "Number/map", "q931.channel.map", FT_BOOLEAN
, 8, TFS(&tfs_channel_map
), 0x10,
3502 "True if channel is indicates by channel map rather than number", HFILL
}},
3504 { &hf_q931_channel_element_type
,
3505 { "Element type", "q931.channel.element_type", FT_UINT8
, BASE_HEX
, q931_element_type_vals
, 0xF,
3506 "Type of element in the channel number/slot map octets", HFILL
}},
3508 { &hf_q931_channel_number
,
3509 { "Channel number", "q931.channel.number", FT_UINT8
, BASE_DEC
, NULL
, 0x7F,
3512 /* desegmentation fields */
3513 { &hf_q931_segment_overlap
,
3514 { "Segment overlap", "q931.segment.overlap", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0,
3515 "Fragment overlaps with other fragments", HFILL
}},
3517 { &hf_q931_segment_overlap_conflict
,
3518 { "Conflicting data in fragment overlap", "q931.segment.overlap.conflict", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0,
3519 "Overlapping fragments contained conflicting data", HFILL
}},
3521 { &hf_q931_segment_multiple_tails
,
3522 { "Multiple tail fragments found", "q931.segment.multipletails", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0,
3523 "Several tails were found when defragmenting the packet", HFILL
}},
3525 { &hf_q931_segment_too_long_segment
,
3526 { "Segment too long", "q931.segment.toolongfragment", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0,
3527 "Segment contained data past end of packet", HFILL
}},
3529 { &hf_q931_segment_error
,
3530 { "Defragmentation error", "q931.segment.error", FT_FRAMENUM
, BASE_NONE
, NULL
, 0x0,
3531 "Defragmentation error due to illegal fragments", HFILL
}},
3533 { &hf_q931_segment_count
,
3534 { "Segment count", "q931.segment.count", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
3538 { "Q.931 Segment", "q931.segment", FT_FRAMENUM
, BASE_NONE
, NULL
, 0x0,
3541 { &hf_q931_segments
,
3542 { "Q.931 Segments", "q931.segments", FT_NONE
, BASE_NONE
, NULL
, 0x0,
3545 { &hf_q931_reassembled_in
,
3546 { "Reassembled Q.931 in frame", "q931.reassembled_in", FT_FRAMENUM
, BASE_NONE
, NULL
, 0x0,
3547 "This Q.931 message is reassembled in this frame", HFILL
}},
3549 { &hf_q931_reassembled_length
,
3550 { "Reassembled Q.931 length", "q931.reassembled.length", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
3551 "The total length of the reassembled payload", HFILL
}},
3553 static gint
*ett
[] = {
3559 module_t
*q931_module
;
3561 proto_q931
= proto_register_protocol("Q.931", "Q.931", "q931");
3562 proto_register_field_array (proto_q931
, hf
, array_length(hf
));
3563 proto_register_subtree_array(ett
, array_length(ett
));
3564 register_init_routine(q931_init
);
3566 register_dissector("q931", dissect_q931
, proto_q931
);
3567 register_dissector("q931.tpkt", dissect_q931_tpkt
, proto_q931
);
3568 q931_tpkt_handle
= find_dissector("q931.tpkt");
3569 q931_tpkt_pdu_handle
= create_dissector_handle(dissect_q931_tpkt_pdu
,
3571 register_dissector("q931.over_ip", dissect_q931_over_ip
, proto_q931
);
3572 register_dissector("q931.ie", dissect_q931_ie_cs0
, proto_q931
);
3573 register_dissector("q931.ie.cs7", dissect_q931_ie_cs7
, proto_q931
);
3575 /* subdissector code */
3576 codeset_dissector_table
= register_dissector_table("q931.codeset", "Q.931 Codeset", FT_UINT8
, BASE_HEX
);
3577 ie_dissector_table
= register_dissector_table("q931.ie", "Q.931 IE", FT_UINT16
, BASE_HEX
);
3578 register_heur_dissector_list("q931_user", &q931_user_heur_subdissector_list
);
3580 q931_module
= prefs_register_protocol(proto_q931
, NULL
);
3581 prefs_register_bool_preference(q931_module
, "desegment_h323_messages",
3582 "Reassemble Q.931 messages spanning multiple TCP segments",
3583 "Whether the Q.931 dissector should reassemble messages spanning multiple TCP segments."
3584 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
3586 prefs_register_bool_preference(q931_module
, "reassembly",
3587 "Reassemble segmented Q.931 messages",
3588 "Reassemble segmented Q.931 messages (Q.931 - Annex H)",
3590 /* Register for tapping */
3591 q931_tap
= register_tap("q931");
3595 proto_reg_handoff_q931(void)
3597 dissector_handle_t q931_handle
;
3598 dissector_handle_t q931_over_ip_handle
;
3600 q931_handle
= find_dissector("q931");
3601 dissector_add_uint("lapd.sapi", LAPD_SAPI_Q931
, q931_handle
);
3603 q931_over_ip_handle
= find_dissector("q931.over_ip");
3604 dissector_add_uint("sctp.ppi", H323_PAYLOAD_PROTOCOL_ID
, q931_over_ip_handle
);
3607 * Attempt to get a handle for the H.225 dissector.
3608 * If we can't, the handle we get is null, and we'll just
3609 * dissect putatively-H.255 Call Signaling stuff as User
3612 h225_handle
= find_dissector("h225");
3614 data_handle
= find_dissector("data");
3619 heur_dissector_add("tcp", dissect_q931_tpkt_heur
, proto_q931
);
3622 static void reset_q931_packet_info(q931_packet_info
*pi
)
3628 pi
->calling_number
= NULL
;
3629 pi
->called_number
= NULL
;
3630 pi
->cause_value
= 0xFF;