2 * Routines for Q.931 frame disassembly
3 * Guy Harris <guy@alum.mit.edu>
5 * $Id: packet-q931.c,v 1.42 2002/03/25 20:23:17 guy Exp $
7 * Modified by Andreas Sikkema for possible use with H.323
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@ethereal.com>
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #ifdef HAVE_SYS_TYPES_H
33 # include <sys/types.h>
39 #include <epan/packet.h>
40 #include <epan/strutil.h>
42 #include "packet-q931.h"
45 #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
59 static int proto_q931 = -1;
60 static int hf_q931_discriminator = -1;
61 static int hf_q931_call_ref_len = -1;
62 static int hf_q931_call_ref = -1;
63 static int hf_q931_message_type = -1;
65 static gint ett_q931 = -1;
66 static gint ett_q931_ie = -1;
68 /* desegmentation of Q.931 over TPKT over TCP */
69 static gboolean q931_desegment = TRUE;
71 static dissector_handle_t h225_handle;
72 static dissector_handle_t q931_tpkt_pdu_handle;
75 * Q.931 message types.
77 #define Q931_ESCAPE 0x00
78 #define Q931_ALERTING 0x01
79 #define Q931_CALL_PROCEEDING 0x02
80 #define Q931_CONNECT 0x07
81 #define Q931_CONNECT_ACK 0x0F
82 #define Q931_PROGRESS 0x03
83 #define Q931_SETUP 0x05
84 #define Q931_SETUP_ACK 0x0D
85 #define Q931_HOLD 0x24
86 #define Q931_HOLD_ACK 0x28
87 #define Q931_HOLD_REJECT 0x30
88 #define Q931_RESUME 0x26
89 #define Q931_RESUME_ACK 0x2E
90 #define Q931_RESUME_REJECT 0x22
91 #define Q931_RETRIEVE 0x31
92 #define Q931_RETRIEVE_ACK 0x33
93 #define Q931_RETRIEVE_REJECT 0x37
94 #define Q931_SUSPEND 0x25
95 #define Q931_SUSPEND_ACK 0x2D
96 #define Q931_SUSPEND_REJECT 0x21
97 #define Q931_USER_INFORMATION 0x20
98 #define Q931_DISCONNECT 0x45
99 #define Q931_RELEASE 0x4D
100 #define Q931_RELEASE_COMPLETE 0x5A
101 #define Q931_RESTART 0x46
102 #define Q931_RESTART_ACK 0x4E
103 #define Q931_CONGESTION_CONTROL 0x79
104 #define Q931_FACILITY 0x62
105 #define Q931_INFORMATION 0x7B
106 #define Q931_NOTIFY 0x6E
107 #define Q931_REGISTER 0x64
108 #define Q931_SEGMENT 0x60
109 #define Q931_STATUS 0x7D
110 #define Q931_STATUS_ENQUIRY 0x75
112 static const value_string q931_message_type_vals[] = {
113 { Q931_ESCAPE, "ESCAPE" },
114 { Q931_ALERTING, "ALERTING" },
115 { Q931_CALL_PROCEEDING, "CALL PROCEEDING" },
116 { Q931_CONNECT, "CONNECT" },
117 { Q931_CONNECT_ACK, "CONNECT ACKNOWLEDGE" },
118 { Q931_PROGRESS, "PROGRESS" },
119 { Q931_SETUP, "SETUP" },
120 { Q931_SETUP_ACK, "SETUP ACKNOWLEDGE" },
121 { Q931_HOLD, "HOLD" },
122 { Q931_HOLD_ACK, "HOLD_ACKNOWLEDGE" },
123 { Q931_HOLD_REJECT, "HOLD_REJECT" },
124 { Q931_RESUME, "RESUME" },
125 { Q931_RESUME_ACK, "RESUME ACKNOWLEDGE" },
126 { Q931_RESUME_REJECT, "RESUME REJECT" },
127 { Q931_RETRIEVE, "RETRIEVE" },
128 { Q931_RETRIEVE_ACK, "RETRIEVE ACKNOWLEDGE" },
129 { Q931_RETRIEVE_REJECT, "RETRIEVE REJECT" },
130 { Q931_SUSPEND, "SUSPEND" },
131 { Q931_SUSPEND_ACK, "SUSPEND ACKNOWLEDGE" },
132 { Q931_SUSPEND_REJECT, "SUSPEND REJECT" },
133 { Q931_USER_INFORMATION, "USER INFORMATION" },
134 { Q931_DISCONNECT, "DISCONNECT" },
135 { Q931_RELEASE, "RELEASE" },
136 { Q931_RELEASE_COMPLETE, "RELEASE COMPLETE" },
137 { Q931_RESTART, "RESTART" },
138 { Q931_RESTART_ACK, "RESTART ACKNOWLEDGE" },
139 { Q931_CONGESTION_CONTROL, "CONGESTION CONTROL" },
140 { Q931_FACILITY, "FACILITY" },
141 { Q931_INFORMATION, "INFORMATION" },
142 { Q931_NOTIFY, "NOTIFY" },
143 { Q931_REGISTER, "REGISTER" },
144 { Q931_SEGMENT, "SEGMENT" },
145 { Q931_STATUS, "STATUS" },
146 { Q931_STATUS_ENQUIRY, "STATUS ENQUIRY" },
151 * Information elements.
157 #define Q931_IE_SO_IDENTIFIER_MASK 0xf0 /* IE identifier mask */
158 #define Q931_IE_SO_IDENTIFIER_SHIFT 4 /* IE identifier shift */
159 #define Q931_IE_SO_IE_MASK 0x0F /* IE mask */
161 #define Q931_IE_SHIFT 0x90
162 #define Q931_IE_SHIFT_LOCKING 0x08 /* locking shift */
163 #define Q931_IE_SHIFT_CODESET 0x0F /* codeset */
165 #define Q931_IE_MORE_DATA_OR_SEND_COMP 0xA0 /* More Data or Sending Complete */
166 #define Q931_IE_MORE_DATA 0xA0
167 #define Q931_IE_SENDING_COMPLETE 0xA1
169 #define Q931_IE_CONGESTION_LEVEL 0xB0
170 #define Q931_IE_REPEAT_INDICATOR 0xD0
173 * Variable-length IEs.
175 #define Q931_IE_VL_EXTENSION 0x80 /* Extension flag */
178 * Codeset 0 (default).
180 #define Q931_IE_SEGMENTED_MESSAGE 0x00
181 #define Q931_IE_BEARER_CAPABILITY 0x04
182 #define Q931_IE_CAUSE 0x08
183 #define Q931_IE_CALL_IDENTITY 0x10
184 #define Q931_IE_CALL_STATE 0x14
185 #define Q931_IE_CHANNEL_IDENTIFICATION 0x18
186 #define Q931_IE_FACILITY 0x1C
187 #define Q931_IE_PROGRESS_INDICATOR 0x1E
188 #define Q931_IE_NETWORK_SPECIFIC_FACIL 0x20 /* Network Specific Facilities */
189 #define Q931_IE_NOTIFICATION_INDICATOR 0x27
190 #define Q931_IE_DISPLAY 0x28
191 #define Q931_IE_DATE_TIME 0x29
192 #define Q931_IE_KEYPAD_FACILITY 0x2C
193 #define Q931_IE_INFORMATION_REQUEST 0x32
194 #define Q931_IE_SIGNAL 0x34
195 #define Q931_IE_SWITCHHOOK 0x36
196 #define Q931_IE_FEATURE_ACTIVATION 0x38
197 #define Q931_IE_FEATURE_INDICATION 0x39
198 #define Q931_IE_ENDPOINT_IDENTIFIER 0x3B
199 #define Q931_IE_SERVICE_PROFILE_ID 0x3A
200 #define Q931_IE_INFORMATION_RATE 0x40
201 #define Q931_IE_E2E_TRANSIT_DELAY 0x42 /* End-to-end Transit Delay */
202 #define Q931_IE_TD_SELECTION_AND_INT 0x43 /* Transit Delay Selection and Indication */
203 #define Q931_IE_PL_BINARY_PARAMETERS 0x44 /* Packet layer binary parameters */
204 #define Q931_IE_PL_WINDOW_SIZE 0x45 /* Packet layer window size */
205 #define Q931_IE_PACKET_SIZE 0x46 /* Packet size */
206 #define Q931_IE_CUG 0x47 /* Closed user group */
207 #define Q931_IE_REVERSE_CHARGE_IND 0x4A /* Reverse charging indication */
208 #define Q931_IE_CALLING_PARTY_NUMBER 0x6C /* Calling Party Number */
209 #define Q931_IE_CALLING_PARTY_SUBADDR 0x6D /* Calling Party Subaddress */
210 #define Q931_IE_CALLED_PARTY_NUMBER 0x70 /* Called Party Number */
211 #define Q931_IE_CALLED_PARTY_SUBADDR 0x71 /* Called Party Subaddress */
212 #define Q931_IE_REDIRECTING_NUMBER 0x74
213 #define Q931_IE_REDIRECTION_NUMBER 0x76
214 #define Q931_IE_TRANSIT_NETWORK_SEL 0x78 /* Transit Network Selection */
215 #define Q931_IE_RESTART_INDICATOR 0x79
216 #define Q931_IE_LOW_LAYER_COMPAT 0x7C /* Low-Layer Compatibility */
217 #define Q931_IE_HIGH_LAYER_COMPAT 0x7D /* High-Layer Compatibility */
218 #define Q931_IE_USER_USER 0x7E /* User-User */
219 #define Q931_IE_ESCAPE 0x7F /* Escape for extension */
224 #define Q931_IE_CONNECTED_NUMBER 0x8C
225 #define Q931_IE_CONNECTED_SUBADDR 0x8D
228 * Codeset 5 (National-specific) Belgium.
230 #define Q931_IE_CHARGING_ADVICE 0x1A
233 * Codeset 5 (National-specific) Bellcore National ISDN.
235 #define Q931_IE_OPERATOR_SYSTEM_ACCESS 0x1D
238 * Codeset 6 (Network-specific) Belgium.
240 /* 0x1A is Charging Advice, as with Codeset 5 */
241 #define Q931_IE_REDIRECTING_NUMBER 0x74
244 * Codeset 6 (Network-specific) FT-Numeris.
246 /* 0x1D is User Capability */
249 * Codeset 6 (Network-specific) Bellcore National ISDN.
251 #define Q931_IE_REDIRECTING_SUBADDR 0x75 /* Redirecting Subaddress */
252 /* 0x76 is Redirection Number, but that's also Codeset 0 */
253 #define Q931_IE_CALL_APPEARANCE 0x7B
255 static const value_string q931_info_element_vals[] = {
256 { Q931_IE_SEGMENTED_MESSAGE, "Segmented message" },
257 { Q931_IE_BEARER_CAPABILITY, "Bearer capability" },
258 { Q931_IE_CAUSE, "Cause" },
259 { Q931_IE_CALL_IDENTITY, "Call identity" },
260 { Q931_IE_CALL_STATE, "Call state" },
261 { Q931_IE_CHANNEL_IDENTIFICATION, "Channel identification" },
262 { Q931_IE_FACILITY, "Facility" },
263 { Q931_IE_PROGRESS_INDICATOR, "Progress indicator" },
264 { Q931_IE_NETWORK_SPECIFIC_FACIL, "Network specific facilities" },
265 { Q931_IE_NOTIFICATION_INDICATOR, "Notification indicator" },
266 { Q931_IE_DISPLAY, "Display" },
267 { Q931_IE_DATE_TIME, "Date/Time" },
268 { Q931_IE_KEYPAD_FACILITY, "Keypad facility" },
269 { Q931_IE_INFORMATION_REQUEST, "Information request" },
270 { Q931_IE_SIGNAL, "Signal" },
271 { Q931_IE_SWITCHHOOK, "Switchhook" },
272 { Q931_IE_FEATURE_ACTIVATION, "Feature activation" },
273 { Q931_IE_FEATURE_INDICATION, "Feature Indication" },
274 { Q931_IE_ENDPOINT_IDENTIFIER, "Endpoint identifier" },
275 { Q931_IE_SERVICE_PROFILE_ID, "Service profile ID" },
276 { Q931_IE_INFORMATION_RATE, "Information rate" },
277 { Q931_IE_E2E_TRANSIT_DELAY, "End-to-end transit delay" },
278 { Q931_IE_TD_SELECTION_AND_INT, "Transit delay selection and indication" },
279 { Q931_IE_PL_BINARY_PARAMETERS, "Packet layer binary parameters" },
280 { Q931_IE_PL_WINDOW_SIZE, "Packet layer window size" },
281 { Q931_IE_PACKET_SIZE, "Packet size" },
282 { Q931_IE_CUG, "Closed user group" },
283 { Q931_IE_REVERSE_CHARGE_IND, "Reverse charging indication" },
284 { Q931_IE_CALLING_PARTY_NUMBER, "Calling party number" },
285 { Q931_IE_CALLING_PARTY_SUBADDR, "Calling party subaddress" },
286 { Q931_IE_CALLED_PARTY_NUMBER, "Called party number" },
287 { Q931_IE_CALLED_PARTY_SUBADDR, "Called party subaddress" },
288 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
289 { Q931_IE_REDIRECTION_NUMBER, "Redirection number" },
290 { Q931_IE_TRANSIT_NETWORK_SEL, "Transit network selection" },
291 { Q931_IE_RESTART_INDICATOR, "Restart indicator" },
292 { Q931_IE_LOW_LAYER_COMPAT, "Low-layer compatibility" },
293 { Q931_IE_HIGH_LAYER_COMPAT, "High-layer compatibility" },
294 { Q931_IE_USER_USER, "User-user" },
295 { Q931_IE_ESCAPE, "Escape" },
296 { Q931_IE_CONNECTED_NUMBER, "Connected number" },
297 { Q931_IE_CONNECTED_SUBADDR, "Connected subaddress" },
298 { Q931_IE_CHARGING_ADVICE, "Charging advice" },
299 { Q931_IE_OPERATOR_SYSTEM_ACCESS, "Operator system access" },
300 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
301 { Q931_IE_REDIRECTING_SUBADDR, "Redirecting subaddress" },
302 { Q931_IE_CALL_APPEARANCE, "Call appearance" },
306 static const value_string q931_congestion_level_vals[] = {
307 { 0x0, "Receiver ready" },
308 { 0xF, "Receiver not ready" },
312 static const value_string q931_repeat_indication_vals[] = {
313 { 0x2, "Prioritized list" },
318 * ITU-standardized coding.
320 #define Q931_ITU_STANDARDIZED_CODING 0x00
323 * Dissect a Segmented message information element.
326 dissect_q931_segmented_message_ie(tvbuff_t *tvb, int offset, int len,
330 proto_tree_add_text(tree, tvb, offset, len,
331 "Segmented message: length is %d, should be 2\n", len);
334 if (tvb_get_guint8(tvb, offset) & 0x80) {
335 proto_tree_add_text(tree, tvb, offset, 1,
336 "First segment: %u segments remaining",
337 tvb_get_guint8(tvb, offset) & 0x7F);
339 proto_tree_add_text(tree, tvb, offset, 1,
340 "Not first segment: %u segments remaining",
341 tvb_get_guint8(tvb, offset) & 0x7F);
343 proto_tree_add_text(tree, tvb, offset + 1, 1,
344 "Segmented message type: %u\n", tvb_get_guint8(tvb, offset + 1));
348 * Dissect a Bearer capability or Low-layer compatibility information element.
350 static const value_string q931_bc_coding_standard_vals[] = {
351 { 0x00, "ITU-T standardized coding" },
352 { 0x20, "ISO/IEC standard" },
353 { 0x40, "National standard" },
354 { 0x60, "Standard defined for this particular network" },
358 static const value_string q931_information_transfer_capability_vals[] = {
360 { 0x08, "Unrestricted digital information" },
361 { 0x09, "Restricted digital information" },
362 { 0x10, "3.1 kHz audio" },
363 { 0x11, "Unrestricted digital information with tones/announcements" },
368 static const value_string q931_transfer_mode_vals[] = {
369 { 0x00, "Circuit mode" },
370 { 0x40, "Packet mode" },
374 #define Q931_IT_RATE_MULTIRATE 0x18
376 static const value_string q931_information_transfer_rate_vals[] = {
377 { 0x00, "Packet mode" },
378 { 0x10, "64 kbit/s" },
379 { 0x11, "2 x 64 kbit/s" },
380 { 0x13, "384 kbit/s" },
381 { 0x15, "1536 kbit/s" },
382 { 0x17, "1920 kbit/s" },
383 { Q931_IT_RATE_MULTIRATE, "Multirate (64 kbit/s base rate)" },
387 static const value_string q931_uil1_vals[] = {
388 { 0x01, "V.110/I.460/X.30 rate adaption" },
389 { 0x02, "Recommendation G.711 u-law" },
390 { 0x03, "Recommendation G.711 A-law" },
391 { 0x04, "Recommendation G.721 32 kbit/s ADPCM and Recommendation I.460" },
392 { 0x05, "Recommendation H.221 and H.242" },
393 { 0x06, "Recommendation H.223 and H.245" },
394 { 0x07, "Non-ITU-T-standardized rate adaption" },
395 { 0x08, "V.120 rate adaption" },
396 { 0x09, "X.31 HDLC flag stuffing" },
400 static const value_string q931_l1_user_rate_vals[] = {
401 { 0x00, "Rate indicated by E-bits" },
402 { 0x01, "0.6 kbit/s" },
403 { 0x02, "1.2 kbit/s" },
404 { 0x03, "2.4 kbit/s" },
405 { 0x04, "3.6 kbit/s" },
406 { 0x05, "4.8 kbit/s" },
407 { 0x06, "7.2 kbit/s" },
408 { 0x07, "8 kbit/s" },
409 { 0x08, "9.6 kbit/s" },
410 { 0x09, "14.4 kbit/s" },
411 { 0x0A, "16 kbit/s" },
412 { 0x0B, "19.2 kbit/s" },
413 { 0x0C, "32 kbit/s" },
414 { 0x0E, "48 kbit/s" },
415 { 0x0F, "56 kbit/s" },
416 { 0x10, "64 kbit/s "},
417 { 0x15, "0.1345 kbit/s" },
418 { 0x16, "0.100 kbit/s" },
419 { 0x17, "0.075/1.2 kbit/s" },
420 { 0x18, "1.2/0.075 kbit/s" },
421 { 0x19, "0.050 kbit/s" },
422 { 0x1A, "0.075 kbit/s" },
423 { 0x1B, "0.110 kbit/s" },
424 { 0x1C, "0.150 kbit/s" },
425 { 0x1D, "0.200 kbit/s" },
426 { 0x1E, "0.300 kbit/s" },
427 { 0x1F, "12 kbit/s" },
431 static const value_string q931_l1_intermediate_rate_vals[] = {
432 { 0x20, "8 kbit/s" },
433 { 0x40, "16 kbit/s" },
434 { 0x60, "32 kbit/s" },
438 static const value_string q931_l1_stop_bits_vals[] = {
445 static const value_string q931_l1_data_bits_vals[] = {
452 static const value_string q931_l1_parity_vals[] = {
456 { 0x04, "Forced to 0" },
457 { 0x05, "Forced to 1" },
461 static const value_string q931_l1_modem_type_vals[] = {
464 { 0x13, "V.22 bis" },
467 { 0x16, "V.26 bis" },
468 { 0x17, "V.26 ter" },
470 { 0x19, "V.27 bis" },
471 { 0x1A, "V.27 ter" },
478 #define Q931_UIL2_USER_SPEC 0x10
480 static const value_string q931_uil2_vals[] = {
481 { 0x01, "Basic mode ISO 1745" },
482 { 0x02, "Q.921/I.441" }, /* LAPD */
483 { 0x06, "X.25, link layer" }, /* LAPB */
484 { 0x07, "X.25 multilink" }, /* or 0x0F? */
485 { 0x08, "T.71 Extended LAPB" },
486 { 0x09, "HDLC ARM" },
487 { 0x0A, "HDLC NRM" },
488 { 0x0B, "HDLC ABM" },
489 { 0x0C, "ISO 8802/2 LLC" },
490 { 0x0D, "X.75 Single Link Procedure" },
492 { 0x0F, "Core aspects of Q.922" },
493 { Q931_UIL2_USER_SPEC, "User-specified" },
494 { 0x11, "ISO 7776 DTE-DTE operation" },
498 static const value_string q931_mode_vals[] = {
499 { 0x20, "Normal mode" },
500 { 0x40, "Extended mode" },
504 #define Q931_UIL3_X25_PL 0x06
505 #define Q931_UIL3_ISO_8208 0x07 /* X.25-based */
506 #define Q931_UIL3_X223 0x08 /* X.25-based */
507 #define Q931_UIL3_TR_9577 0x0B
508 #define Q931_UIL3_USER_SPEC 0x10
510 static const value_string q931_uil3_vals[] = {
511 { 0x02, "Q.931/I.451" },
512 { Q931_UIL3_X25_PL, "X.25, packet layer" },
513 { Q931_UIL3_ISO_8208, "ISO/IEC 8208" },
514 { Q931_UIL3_X223, "X.223/ISO 8878" },
515 { 0x09, "ISO/IEC 8473" },
517 { Q931_UIL3_TR_9577, "ISO/IEC TR 9577" },
518 { Q931_UIL3_USER_SPEC, "User-specified" },
523 dissect_q931_protocol_discriminator(tvbuff_t *tvb, int offset, proto_tree *tree)
525 unsigned int discriminator = tvb_get_guint8(tvb, offset);
527 if (discriminator == NLPID_Q_931) {
528 proto_tree_add_uint_format(tree, hf_q931_discriminator,
529 tvb, offset, 1, discriminator,
530 "Protocol discriminator: Q.931");
531 } else if (discriminator == NLPID_Q_2931) {
532 proto_tree_add_uint_format(tree, hf_q931_discriminator,
533 tvb, offset, 1, discriminator,
534 "Protocol discriminator: Q.2931");
535 } else if ((discriminator >= 16 && discriminator < 63)
536 || ((discriminator >= 80) && (discriminator < 254))) {
537 proto_tree_add_uint_format(tree, hf_q931_discriminator,
538 tvb, offset, 1, discriminator,
539 "Protocol discriminator: Network layer or layer 3 protocol (0x%02X)",
541 } else if (discriminator >= 64 && discriminator <= 79) {
542 proto_tree_add_uint_format(tree, hf_q931_discriminator,
543 tvb, offset, 1, discriminator,
544 "Protocol discriminator: National use (0x%02X)",
547 proto_tree_add_uint_format(tree, hf_q931_discriminator,
548 tvb, offset, 1, discriminator,
549 "Protocol discriminator: Reserved (0x%02X)",
555 dissect_q931_bearer_capability_ie(tvbuff_t *tvb, int offset, int len,
559 guint8 coding_standard;
562 guint8 uil2_protocol;
563 guint8 uil3_protocol;
568 octet = tvb_get_guint8(tvb, offset);
569 coding_standard = octet & 0x60;
570 proto_tree_add_text(tree, tvb, offset, 1,
571 "Coding standard: %s",
572 val_to_str(coding_standard, q931_bc_coding_standard_vals, NULL));
573 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
575 * We don't know how the bearer capability is encoded,
576 * so just dump it as data and be done with it.
578 proto_tree_add_text(tree, tvb, offset,
580 tvb_bytes_to_str(tvb, offset, len));
583 proto_tree_add_text(tree, tvb, offset, 1,
584 "Information transfer capability: %s",
585 val_to_str(octet & 0x1F, q931_information_transfer_capability_vals,
586 "Unknown (0x%02X)"));
591 * XXX - only in Low-layer compatibility information element.
593 if (!(octet & Q931_IE_VL_EXTENSION)) {
596 octet = tvb_get_guint8(tvb, offset);
597 proto_tree_add_text(tree, tvb, offset, 1,
598 "Out-band negotiation %spossible",
599 (octet & 0x40) ? "" : "not ");
606 octet = tvb_get_guint8(tvb, offset);
607 proto_tree_add_text(tree, tvb, offset, 1,
609 val_to_str(octet & 0x60, q931_transfer_mode_vals,
610 "Unknown (0x%02X)"));
611 it_rate = octet & 0x1F;
612 proto_tree_add_text(tree, tvb, offset, 1,
613 "Information transfer rate: %s",
614 val_to_str(it_rate, q931_information_transfer_rate_vals,
615 "Unknown (0x%02X)"));
619 if (it_rate == Q931_IT_RATE_MULTIRATE) {
622 proto_tree_add_text(tree, tvb, offset, 1, "Rate multiplier: %u", tvb_get_guint8(tvb, offset));
629 octet = tvb_get_guint8(tvb, offset);
630 if ((octet & 0x60) == 0x20) {
632 * Layer 1 information.
634 proto_tree_add_text(tree, tvb, offset, 1,
635 "User information layer 1 protocol: %s",
636 val_to_str(octet & 0x1F, q931_uil1_vals,
637 "Unknown (0x%02X)"));
641 if (octet & Q931_IE_VL_EXTENSION)
645 octet = tvb_get_guint8(tvb, offset);
646 proto_tree_add_text(tree, tvb, offset, 1,
648 (octet & 0x40) ? "Asynchronous" : "Synchronous");
649 proto_tree_add_text(tree, tvb, offset, 1,
650 "Layer 1 in-band negotiation is %spossible",
651 (octet & 0x20) ? "" : "not ");
652 proto_tree_add_text(tree, tvb, offset, 1,
654 val_to_str(octet & 0x1F, q931_l1_user_rate_vals,
655 "Unknown (0x%02X)"));
659 if (octet & Q931_IE_VL_EXTENSION)
663 octet = tvb_get_guint8(tvb, offset);
664 proto_tree_add_text(tree, tvb, offset, 1,
665 "Intermediate rate: %s",
666 val_to_str(octet & 0x60, q931_l1_intermediate_rate_vals,
668 proto_tree_add_text(tree, tvb, offset, 1,
669 "%s to send data with network independent clock",
670 (octet & 0x10) ? "Required" : "Not required");
671 proto_tree_add_text(tree, tvb, offset, 1,
672 "%s accept data with network independent clock",
673 (octet & 0x08) ? "Can" : "Cannot");
674 proto_tree_add_text(tree, tvb, offset, 1,
675 "%s to send data with flow control mechanism",
676 (octet & 0x04) ? "Required" : "Not required");
677 proto_tree_add_text(tree, tvb, offset, 1,
678 "%s accept data with flow control mechanism",
679 (octet & 0x02) ? "Can" : "Cannot");
683 if (octet & Q931_IE_VL_EXTENSION)
687 octet = tvb_get_guint8(tvb, offset);
688 proto_tree_add_text(tree, tvb, offset, 1,
689 "Rate adaption header %sincluded",
690 (octet & 0x40) ? "" : "not ");
691 proto_tree_add_text(tree, tvb, offset, 1,
692 "Multiple frame establishment %ssupported",
693 (octet & 0x20) ? "" : "not ");
694 proto_tree_add_text(tree, tvb, offset, 1,
695 "%s mode of operation",
696 (octet & 0x10) ? "Protocol sensitive" : "Bit transparent");
697 proto_tree_add_text(tree, tvb, offset, 1,
699 "Full protocol negotiation" : "LLI = 256 only");
700 proto_tree_add_text(tree, tvb, offset, 1,
701 "Message originator is %s",
702 (octet & 0x04) ? "Assignor only" : "Default assignee");
703 proto_tree_add_text(tree, tvb, offset, 1,
704 "Negotiation is done %s",
705 (octet & 0x02) ? "in-band" : "out-of-band");
709 if (octet & Q931_IE_VL_EXTENSION)
713 octet = tvb_get_guint8(tvb, offset);
714 proto_tree_add_text(tree, tvb, offset, 1,
716 val_to_str(octet & 0x60, q931_l1_stop_bits_vals,
718 proto_tree_add_text(tree, tvb, offset, 1,
720 val_to_str(octet & 0x18, q931_l1_data_bits_vals,
722 proto_tree_add_text(tree, tvb, offset, 1,
724 val_to_str(octet & 0x08, q931_l1_parity_vals,
727 if (octet & Q931_IE_VL_EXTENSION)
731 octet = tvb_get_guint8(tvb, offset);
732 proto_tree_add_text(tree, tvb, offset, 1,
734 (octet & 0x40) ? "Full" : "Half");
735 modem_type = octet & 0x3F;
736 if (modem_type <= 0x5 ||
737 (modem_type >= 0x20 && modem_type <= 0x2F)) {
738 proto_tree_add_text(tree, tvb, offset, 1,
739 "Modem type: National use 0x%02X", modem_type);
740 } else if (modem_type >= 0x30) {
741 proto_tree_add_text(tree, tvb, offset, 1,
742 "Modem type: User specified 0x%02X", modem_type);
744 proto_tree_add_text(tree, tvb, offset, 1,
746 val_to_str(modem_type, q931_l1_modem_type_vals,
747 "Unknown (0x%02X)"));
757 octet = tvb_get_guint8(tvb, offset);
758 if ((octet & 0x60) == 0x40) {
760 * Layer 2 information.
762 uil2_protocol = octet & 0x1F;
763 proto_tree_add_text(tree, tvb, offset, 1,
764 "User information layer 2 protocol: %s",
765 val_to_str(uil2_protocol, q931_uil2_vals,
766 "Unknown (0x%02X)"));
771 * XXX - only in Low-layer compatibility information element.
773 if (octet & Q931_IE_VL_EXTENSION)
777 octet = tvb_get_guint8(tvb, offset);
778 if (uil2_protocol == Q931_UIL2_USER_SPEC) {
779 proto_tree_add_text(tree, tvb, offset, 1,
780 "User-specified layer 2 protocol information: 0x%02X",
783 proto_tree_add_text(tree, tvb, offset, 1,
785 val_to_str(octet & 0x60, q931_mode_vals,
786 "Unknown (0x%02X)"));
791 if (octet & Q931_IE_VL_EXTENSION)
795 octet = tvb_get_guint8(tvb, offset);
796 proto_tree_add_text(tree, tvb, offset, 1,
797 "Window size: %u k", octet & 0x7F);
806 octet = tvb_get_guint8(tvb, offset);
807 if ((octet & 0x60) == 0x60) {
809 * Layer 3 information.
811 uil3_protocol = octet & 0x1F;
812 proto_tree_add_text(tree, tvb, offset, 1,
813 "User information layer 3 protocol: %s",
814 val_to_str(uil3_protocol, q931_uil3_vals,
815 "Unknown (0x%02X)"));
821 * XXX - only in Low-layer compatibility information element.
823 if (octet & Q931_IE_VL_EXTENSION)
827 octet = tvb_get_guint8(tvb, offset);
828 switch (uil3_protocol) {
830 case Q931_UIL3_X25_PL:
831 case Q931_UIL3_ISO_8208:
833 proto_tree_add_text(tree, tvb, offset, 1,
835 val_to_str(octet & 0x60, q931_mode_vals,
836 "Unknown (0x%02X)"));
840 if (octet & Q931_IE_VL_EXTENSION)
844 octet = tvb_get_guint8(tvb, offset);
845 proto_tree_add_text(tree, tvb, offset, 1,
846 "Default packet size: %u", octet & 0x0F);
850 if (octet & Q931_IE_VL_EXTENSION)
854 octet = tvb_get_guint8(tvb, offset);
855 proto_tree_add_text(tree, tvb, offset, 1,
856 "Packet window size: %u", octet & 0x7F);
861 case Q931_UIL3_USER_SPEC:
862 proto_tree_add_text(tree, tvb, offset, 1,
863 "Default packet size: %u octets",
864 1 << (octet & 0x0F));
869 case Q931_UIL3_TR_9577:
870 add_l3_info = (octet & 0x0F) << 4;
871 if (octet & Q931_IE_VL_EXTENSION)
875 octet = tvb_get_guint8(tvb, offset + 1);
876 add_l3_info |= (octet & 0x0F);
877 proto_tree_add_text(tree, tvb, offset, 2,
878 "Additional layer 3 protocol information: %s",
879 val_to_str(add_l3_info, nlpid_vals,
880 "Unknown (0x%02X)"));
891 * Dissect a Cause information element.
893 static const value_string q931_cause_coding_standard_vals[] = {
894 { 0x00, "ITU-T standardized coding" },
895 { 0x20, "ISO/IEC standard" },
896 { 0x40, "National standard" },
897 { 0x60, "Standard specific to identified location" },
901 static const value_string q931_cause_location_vals[] = {
902 { 0x00, "User (U)" },
903 { 0x01, "Private network serving the local user (LPN)" },
904 { 0x02, "Public network serving the local user (LN)" },
905 { 0x03, "Transit network (TN)" },
906 { 0x04, "Public network serving the remote user (RLN)" },
907 { 0x05, "Private network serving the remote user (RPN)" },
908 { 0x07, "International network (INTL)" },
909 { 0x0A, "Network beyond interworking point (BI)" },
913 static const value_string q931_cause_recommendation_vals[] = {
917 { 0x05, "Q.1031/Q.1051" },
922 * Cause codes for Cause.
924 static const value_string q931_cause_code_vals[] = {
925 { 0x00, "Valid cause code not yet received" },
926 { 0x01, "Unallocated (unassigned) number" },
927 { 0x02, "No route to specified transit network" },
928 { 0x03, "No route to destination" },
929 { 0x04, "Send special information tone" },
930 { 0x05, "Misdialled trunk prefix" },
931 { 0x06, "Channel unacceptable" },
932 { 0x07, "Call awarded and being delivered in an established channel" },
933 { 0x08, "Prefix 0 dialed but not allowed" },
934 { 0x09, "Prefix 1 dialed but not allowed" },
935 { 0x0A, "Prefix 1 dialed but not required" },
936 { 0x0B, "More digits received than allowed, call is proceeding" },
937 { 0x10, "Normal call clearing" },
938 { 0x11, "User busy" },
939 { 0x12, "No user responding" },
940 { 0x13, "No answer from user (user alerted)" },
941 { 0x14, "Subscriber absent" },
942 { 0x15, "Call rejected" },
943 { 0x16, "Number changed" },
944 { 0x17, "Reverse charging rejected" },
945 { 0x18, "Call suspended" },
946 { 0x19, "Call resumed" },
947 { 0x1A, "Non-selected user clearing" },
948 { 0x1B, "Destination out of order" },
949 { 0x1C, "Invalid number format (incomplete number)" },
950 { 0x1D, "Facility rejected" },
951 { 0x1E, "Response to STATUS ENQUIRY" },
952 { 0x1F, "Normal unspecified" },
953 { 0x21, "Circuit out of order" },
954 { 0x22, "No circuit/channel available" },
955 { 0x23, "Destination unattainable" },
956 { 0x25, "Degraded service" },
957 { 0x26, "Network out of order" },
958 { 0x27, "Transit delay range cannot be achieved" },
959 { 0x28, "Throughput range cannot be achieved" },
960 { 0x29, "Temporary failure" },
961 { 0x2A, "Switching equipment congestion" },
962 { 0x2B, "Access information discarded" },
963 { 0x2C, "Requested circuit/channel not available" },
964 { 0x2D, "Pre-empted" },
965 { 0x2E, "Precedence call blocked" },
966 { 0x2F, "Resources unavailable, unspecified" },
967 { 0x31, "Quality of service unavailable" },
968 { 0x32, "Requested facility not subscribed" },
969 { 0x33, "Reverse charging not allowed" },
970 { 0x34, "Outgoing calls barred" },
971 { 0x35, "Outgoing calls barred within CUG" },
972 { 0x36, "Incoming calls barred" },
973 { 0x37, "Incoming calls barred within CUG" },
974 { 0x38, "Call waiting not subscribed" },
975 { 0x39, "Bearer capability not authorized" },
976 { 0x3A, "Bearer capability not presently available" },
977 { 0x3E, "Inconsistency in designated outgoing access information and subscriber class" },
978 { 0x3F, "Service or option not available, unspecified" },
979 { 0x41, "Bearer capability not implemented" },
980 { 0x42, "Channel type not implemented" },
981 { 0x43, "Transit network selection not implemented" },
982 { 0x44, "Message not implemented" },
983 { 0x45, "Requested facility not implemented" },
984 { 0x46, "Only restricted digital information bearer capability is available" },
985 { 0x4F, "Service or option not implemented, unspecified" },
986 { 0x51, "Invalid call reference value" },
987 { 0x52, "Identified channel does not exist" },
988 { 0x53, "Call identity does not exist for suspended call" },
989 { 0x54, "Call identity in use" },
990 { 0x55, "No call suspended" },
991 { 0x56, "Call having the requested call identity has been cleared" },
992 { 0x57, "Called user not member of CUG" },
993 { 0x58, "Incompatible destination" },
994 { 0x59, "Non-existent abbreviated address entry" },
995 { 0x5A, "Destination address missing, and direct call not subscribed" },
996 { 0x5B, "Invalid transit network selection (national use)" },
997 { 0x5C, "Invalid facility parameter" },
998 { 0x5D, "Mandatory information element is missing" },
999 { 0x5F, "Invalid message, unspecified" },
1000 { 0x60, "Mandatory information element is missing" },
1001 { 0x61, "Message type non-existent or not implemented" },
1002 { 0x62, "Message not compatible with call state or message type non-existent or not implemented" },
1003 { 0x63, "Information element nonexistant or not implemented" },
1004 { 0x64, "Invalid information element contents" },
1005 { 0x65, "Message not compatible with call state" },
1006 { 0x66, "Recovery on timer expiry" },
1007 { 0x67, "Parameter non-existent or not implemented - passed on" },
1008 { 0x6E, "Message with unrecognized parameter discarded" },
1009 { 0x6F, "Protocol error, unspecified" },
1010 { 0x7F, "Internetworking, unspecified" },
1015 dissect_q931_cause_ie(tvbuff_t *tvb, int offset, int len,
1019 guint8 coding_standard;
1023 octet = tvb_get_guint8(tvb, offset);
1024 coding_standard = octet & 0x60;
1025 proto_tree_add_text(tree, tvb, offset, 1,
1026 "Coding standard: %s",
1027 val_to_str(coding_standard, q931_cause_coding_standard_vals, NULL));
1028 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1030 * We don't know how the cause is encoded,
1031 * so just dump it as data and be done with it.
1033 proto_tree_add_text(tree, tvb, offset,
1035 tvb_bytes_to_str(tvb, offset, len));
1038 proto_tree_add_text(tree, tvb, offset, 1,
1040 val_to_str(octet & 0x0F, q931_cause_location_vals,
1045 if (!(octet & Q931_IE_VL_EXTENSION)) {
1048 octet = tvb_get_guint8(tvb, offset);
1049 proto_tree_add_text(tree, tvb, offset, 1,
1050 "Recommendation: %s",
1051 val_to_str(octet & 0x7F, q931_cause_recommendation_vals,
1052 "Unknown (0x%02X)"));
1059 octet = tvb_get_guint8(tvb, offset);
1060 proto_tree_add_text(tree, tvb, offset, 1,
1062 val_to_str(octet & 0x7F, q931_cause_code_vals,
1063 "Unknown (0x%02X)"));
1069 proto_tree_add_text(tree, tvb, offset, len,
1071 tvb_bytes_to_str(tvb, offset, len));
1075 * Dissect a Call state information element.
1077 static const value_string q931_coding_standard_vals[] = {
1078 { 0x00, "ITU-T standardized coding" },
1079 { 0x20, "ISO/IEC standard" },
1080 { 0x40, "National standard" },
1081 { 0x60, "Standard defined for the network" },
1085 static const value_string q931_call_state_vals[] = {
1087 { 0x01, "Call initiated" },
1088 { 0x02, "Overlap sending" },
1089 { 0x03, "Outgoing call proceeding" },
1090 { 0x04, "Call delivered" },
1091 { 0x06, "Call present" },
1092 { 0x07, "Call received" },
1093 { 0x08, "Connect request" },
1094 { 0x09, "Incoming call proceeding" },
1096 { 0x0B, "Disconnect request" },
1097 { 0x0C, "Disconnect indication" },
1098 { 0x0F, "Suspend request" },
1099 { 0x12, "Resume request" },
1100 { 0x13, "Release request" },
1101 { 0x16, "Call abort"},
1102 { 0x19, "Overlap receiving" },
1103 { 0x3D, "Restart request" },
1104 { 0x3E, "Restart" },
1109 dissect_q931_call_state_ie(tvbuff_t *tvb, int offset, int len,
1113 guint8 coding_standard;
1117 octet = tvb_get_guint8(tvb, offset);
1118 coding_standard = octet & 0x60;
1119 proto_tree_add_text(tree, tvb, offset, 1,
1120 "Coding standard: %s",
1121 val_to_str(coding_standard, q931_coding_standard_vals, NULL));
1122 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1124 * We don't know how the call state is encoded,
1125 * so just dump it as data and be done with it.
1127 proto_tree_add_text(tree, tvb, offset,
1129 tvb_bytes_to_str(tvb, offset, len));
1132 proto_tree_add_text(tree, tvb, offset, 1,
1134 val_to_str(octet & 0x3F, q931_call_state_vals,
1135 "Unknown (0x%02X)"));
1139 * Dissect a Channel identification information element.
1141 #define Q931_INTERFACE_IDENTIFIED 0x40
1142 #define Q931_NOT_BASIC_CHANNEL 0x20
1144 static const value_string q931_basic_channel_selection_vals[] = {
1145 { 0x00, "No channel" },
1146 { 0x01, "B1 channel" },
1147 { 0x02, "B2 channel" },
1148 { 0x03, "Any channel" },
1152 static const value_string q931_not_basic_channel_selection_vals[] = {
1153 { 0x00, "No channel" },
1154 { 0x01, "Channel indicated in following octets" },
1155 { 0x03, "Any channel" },
1159 #define Q931_IS_SLOT_MAP 0x10
1161 static const value_string q931_element_type_vals[] = {
1162 { 0x03, "B-channel units" },
1163 { 0x06, "H0-channel units" },
1164 { 0x08, "H11-channel units" },
1165 { 0x09, "H12-channel units" },
1170 dissect_q931_channel_identification_ie(tvbuff_t *tvb, int offset, int len,
1174 int identifier_offset;
1176 guint8 coding_standard;
1180 octet = tvb_get_guint8(tvb, offset);
1181 proto_tree_add_text(tree, tvb, offset, 1,
1182 "Interface %s identified",
1183 (octet & Q931_INTERFACE_IDENTIFIED) ? "explicitly" : "implicitly");
1184 proto_tree_add_text(tree, tvb, offset, 1,
1186 (octet & Q931_NOT_BASIC_CHANNEL) ? "Not basic" : "Basic");
1187 proto_tree_add_text(tree, tvb, offset, 1,
1188 "Indicated channel is %s",
1189 (octet & 0x08) ? "required" : "preferred");
1190 proto_tree_add_text(tree, tvb, offset, 1,
1191 "Indicated channel is %sthe D-channel",
1192 (octet & 0x04) ? "" : "not ");
1193 if (octet & Q931_NOT_BASIC_CHANNEL) {
1194 proto_tree_add_text(tree, tvb, offset, 1,
1195 "Channel selection: %s",
1196 val_to_str(octet & 0x03, q931_not_basic_channel_selection_vals,
1199 proto_tree_add_text(tree, tvb, offset, 1,
1200 "Channel selection: %s",
1201 val_to_str(octet & 0x03, q931_basic_channel_selection_vals,
1207 if (octet & Q931_INTERFACE_IDENTIFIED) {
1208 identifier_offset = offset;
1213 octet = tvb_get_guint8(tvb, offset);
1217 } while (!(octet & Q931_IE_VL_EXTENSION));
1220 * XXX - do we want to strip off the 8th bit on the
1221 * last octet of the interface identifier?
1223 if (identifier_len != 0) {
1224 proto_tree_add_text(tree, tvb, identifier_offset,
1225 identifier_len, "Interface identifier: %s",
1227 tvb_get_ptr(tvb, identifier_offset, identifier_len),
1232 if (octet & Q931_NOT_BASIC_CHANNEL) {
1235 octet = tvb_get_guint8(tvb, offset);
1236 coding_standard = octet & 0x60;
1237 proto_tree_add_text(tree, tvb, offset, 1,
1238 "Coding standard: %s",
1239 val_to_str(coding_standard, q931_coding_standard_vals,
1241 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1243 * We don't know how the channel identifier is
1244 * encoded, so just dump it as data and be done
1247 proto_tree_add_text(tree, tvb, offset,
1249 tvb_bytes_to_str(tvb, offset, len));
1252 proto_tree_add_text(tree, tvb, offset, 1,
1253 "Channel is indicated by %s",
1254 (octet & Q931_IS_SLOT_MAP) ? "slot map" : "number");
1255 proto_tree_add_text(tree, tvb, offset, 1,
1257 (octet & Q931_IS_SLOT_MAP) ? "Map element" : "Channel",
1258 val_to_str(octet & 0x0F, q931_element_type_vals,
1259 "Unknown (0x%02X)"));
1262 * XXX - dump the channel number or slot map.
1268 * Dissect a Progress indicator information element.
1270 static const value_string q931_progress_description_vals[] = {
1271 { 0x01, "Call is not end-to-end ISDN - progress information available in-band" },
1272 { 0x02, "Destination address is non-ISDN" },
1273 { 0x03, "Origination address is non-ISDN" },
1274 { 0x04, "Call has returned to the ISDN" },
1275 { 0x05, "Interworking has occurred and has resulted in a telecommunications service change" },
1276 { 0x08, "In-band information or an appropriate pattern is now available" },
1281 dissect_q931_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
1285 guint8 coding_standard;
1289 octet = tvb_get_guint8(tvb, offset);
1290 coding_standard = octet & 0x60;
1291 proto_tree_add_text(tree, tvb, offset, 1,
1292 "Coding standard: %s",
1293 val_to_str(coding_standard, q931_cause_coding_standard_vals, NULL));
1294 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1296 * We don't know how the progress indicator is encoded,
1297 * so just dump it as data and be done with it.
1299 proto_tree_add_text(tree, tvb, offset,
1301 tvb_bytes_to_str(tvb, offset, len));
1304 proto_tree_add_text(tree, tvb, offset, 1,
1306 val_to_str(octet & 0x0F, q931_cause_location_vals,
1313 octet = tvb_get_guint8(tvb, offset);
1314 proto_tree_add_text(tree, tvb, offset, 1,
1315 "Progress description: %s",
1316 val_to_str(octet & 0x7F, q931_progress_description_vals,
1317 "Unknown (0x%02X)"));
1321 * Dissect a Network-specific facilities or Transit network selection
1322 * information element.
1324 static const value_string q931_netid_type_vals[] = {
1325 { 0x00, "User specified" },
1326 { 0x20, "National network identification" },
1327 { 0x30, "International network identification" },
1331 static const value_string q931_netid_plan_vals[] = {
1332 { 0x00, "Unknown" },
1333 { 0x01, "Carrier Identification Code" },
1334 { 0x03, "X.121 data network identification code" },
1339 dissect_q931_ns_facilities_ie(tvbuff_t *tvb, int offset, int len,
1347 octet = tvb_get_guint8(tvb, offset);
1348 netid_len = octet & 0x7F;
1349 proto_tree_add_text(tree, tvb, offset, 1,
1350 "Network identification length: %u",
1354 if (netid_len != 0) {
1357 octet = tvb_get_guint8(tvb, offset);
1358 proto_tree_add_text(tree, tvb, offset, 1,
1359 "Type of network identification: %s",
1360 val_to_str(octet & 0x70, q931_netid_type_vals,
1361 "Unknown (0x%02X)"));
1362 proto_tree_add_text(tree, tvb, offset, 1,
1363 "Network identification plan: %s",
1364 val_to_str(octet & 0x0F, q931_netid_plan_vals,
1365 "Unknown (0x%02X)"));
1372 if (netid_len > len)
1374 if (netid_len != 0) {
1375 proto_tree_add_text(tree, tvb, offset, netid_len,
1376 "Network identification: %s",
1377 tvb_format_text(tvb, offset, netid_len));
1378 offset += netid_len;
1384 * Whatever is left is the network-specific facility
1389 proto_tree_add_text(tree, tvb, offset,
1390 len, "Network-specific facility specification: %s",
1391 tvb_bytes_to_str(tvb, offset, len));
1395 * Dissect a Notification indicator information element.
1397 static const value_string q931_notification_description_vals[] = {
1398 { 0x00, "User suspended" },
1399 { 0x01, "User resumed" },
1400 { 0x02, "Bearer service change" },
1405 dissect_q931_notification_indicator_ie(tvbuff_t *tvb, int offset, int len,
1412 octet = tvb_get_guint8(tvb, offset);
1413 proto_tree_add_text(tree, tvb, offset, 1,
1414 "Notification description: %s",
1415 val_to_str(octet & 0x7F, q931_notification_description_vals,
1416 "Unknown (0x%02X)"));
1420 * Dissect a Date/time information element.
1423 dissect_q931_date_time_ie(tvbuff_t *tvb, int offset, int len,
1427 proto_tree_add_text(tree, tvb, offset, len,
1428 "Date/time: length is %d, should be 6\n", len);
1432 * XXX - what is "year" relative to? Is "month" 0-origin or
1433 * 1-origin? Q.931 doesn't say....
1435 proto_tree_add_text(tree, tvb, offset, 6,
1436 "Date/time: %02u-%02u-%02u %02u:%02u:%02u",
1437 tvb_get_guint8(tvb, offset + 0), tvb_get_guint8(tvb, offset + 1), tvb_get_guint8(tvb, offset + 2),
1438 tvb_get_guint8(tvb, offset + 3), tvb_get_guint8(tvb, offset + 4), tvb_get_guint8(tvb, offset + 5));
1442 * Dissect a Signal information element.
1444 static const value_string q931_signal_vals[] = {
1445 { 0x00, "Dial tone on" },
1446 { 0x01, "Ring tone on" },
1447 { 0x02, "Intercept tone on" },
1448 { 0x03, "Network congestion tone on" }, /* "fast busy" */
1449 { 0x04, "Busy tone on" },
1450 { 0x05, "Confirm tone on" },
1451 { 0x06, "Answer tone on" },
1452 { 0x07, "Call waiting tone on" },
1453 { 0x08, "Off-hook warning tone on" },
1454 { 0x09, "Preemption tone on" },
1455 { 0x3F, "Tones off" },
1456 { 0x40, "Alerting on - pattern 0" },
1457 { 0x41, "Alerting on - pattern 1" },
1458 { 0x42, "Alerting on - pattern 2" },
1459 { 0x43, "Alerting on - pattern 3" },
1460 { 0x44, "Alerting on - pattern 4" },
1461 { 0x45, "Alerting on - pattern 5" },
1462 { 0x46, "Alerting on - pattern 6" },
1463 { 0x47, "Alerting on - pattern 7" },
1464 { 0x4F, "Alerting off" },
1469 dissect_q931_signal_ie(tvbuff_t *tvb, int offset, int len,
1473 proto_tree_add_text(tree, tvb, offset, len,
1474 "Signal: length is %d, should be 1\n", len);
1477 proto_tree_add_text(tree, tvb, offset, 1,
1479 val_to_str(tvb_get_guint8(tvb, offset), q931_signal_vals,
1480 "Unknown (0x%02X)"));
1484 * Dissect an Information rate information element.
1486 static const value_string q931_throughput_class_vals[] = {
1487 { 0x03, "75 bit/s" },
1488 { 0x04, "150 bit/s" },
1489 { 0x05, "300 bit/s" },
1490 { 0x06, "600 bit/s" },
1491 { 0x07, "1200 bit/s" },
1492 { 0x08, "2400 bit/s" },
1493 { 0x09, "4800 bit/s" },
1494 { 0x0A, "9600 bit/s" },
1495 { 0x0B, "19200 bit/s" },
1496 { 0x0C, "48000 bit/s" },
1497 { 0x0D, "64000 bit/s" },
1502 dissect_q931_information_rate_ie(tvbuff_t *tvb, int offset, int len,
1506 proto_tree_add_text(tree, tvb, offset, len,
1507 "Information rate: length is %d, should be 4\n", len);
1510 proto_tree_add_text(tree, tvb, offset + 0, 1,
1511 "Incoming information rate: %s",
1512 val_to_str(tvb_get_guint8(tvb, offset + 0) & 0x1F,
1513 q931_throughput_class_vals, "Unknown (0x%02X)"));
1514 proto_tree_add_text(tree, tvb, offset + 1, 1,
1515 "Outgoing information rate: %s",
1516 val_to_str(tvb_get_guint8(tvb, offset + 1) & 0x1F,
1517 q931_throughput_class_vals, "Unknown (0x%02X)"));
1518 proto_tree_add_text(tree, tvb, offset + 2, 1,
1519 "Minimum incoming information rate: %s",
1520 val_to_str(tvb_get_guint8(tvb, offset + 2) & 0x1F,
1521 q931_throughput_class_vals, "Unknown (0x%02X)"));
1522 proto_tree_add_text(tree, tvb, offset + 3, 1,
1523 "Minimum outgoing information rate: %s",
1524 val_to_str(tvb_get_guint8(tvb, offset + 3) & 0x1F,
1525 q931_throughput_class_vals, "Unknown (0x%02X)"));
1529 dissect_q931_guint16_value(tvbuff_t *tvb, int offset, int len,
1530 proto_tree *tree, char *label)
1538 octet = tvb_get_guint8(tvb, offset);
1539 if (octet & Q931_IE_VL_EXTENSION) {
1541 * Only one octet long - error.
1545 value = (octet & 0x3) << 14;
1552 * We've reached the end of the information element - error.
1556 octet = tvb_get_guint8(tvb, offset);
1557 if (octet & Q931_IE_VL_EXTENSION) {
1559 * Only two octets long - error.
1563 value |= (octet & 0x7F) << 7;
1570 * We've reached the end of the information element - error.
1574 octet = tvb_get_guint8(tvb, offset);
1575 if (!(octet & Q931_IE_VL_EXTENSION)) {
1577 * More than three octets long - error.
1581 value |= (octet & 0x7F);
1586 proto_tree_add_text(tree, tvb, offset, value_len, "%s: %u ms", label,
1591 proto_tree_add_text(tree, tvb, offset, len,
1592 "%s goes past end of information element", label);
1596 proto_tree_add_text(tree, tvb, offset, len, "%s isn't 3 octets long",
1602 * Dissect an End-to-end transit delay information element.
1605 dissect_q931_e2e_transit_delay_ie(tvbuff_t *tvb, int offset, int len,
1612 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1613 "Cumulative transit delay");
1616 offset += value_len;
1621 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1622 "Requested end-to-end transit delay");
1625 offset += value_len;
1630 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1631 "Maximum end-to-end transit delay");
1635 * Dissect a Transit delay selection and indication information element.
1638 dissect_q931_td_selection_and_int_ie(tvbuff_t *tvb, int offset, int len,
1643 dissect_q931_guint16_value(tvb, offset, len, tree,
1648 * Dissect a Packet layer binary parameters information element.
1650 static const value_string q931_fast_selected_vals[] = {
1651 { 0x00, "Fast select not requested" },
1652 { 0x08, "Fast select not requested" },
1653 { 0x10, "Fast select requested with no restriction of response" },
1654 { 0x18, "Fast select requested with restrictions of response" },
1659 dissect_q931_pl_binary_parameters_ie(tvbuff_t *tvb, int offset, int len,
1666 octet = tvb_get_guint8(tvb, offset);
1667 proto_tree_add_text(tree, tvb, offset, 1,
1669 val_to_str(octet & 0x18, q931_fast_selected_vals, NULL));
1670 proto_tree_add_text(tree, tvb, offset, 1,
1672 (octet & 0x04) ? "No request/request denied" :
1673 "Request indicated/request accepted");
1674 proto_tree_add_text(tree, tvb, offset, 1,
1676 (octet & 0x02) ? "Link-by-link" : "End-to-end");
1677 proto_tree_add_text(tree, tvb, offset, 1,
1678 "Modulus %u sequencing",
1679 (octet & 0x01) ? 8 : 128);
1683 * Dissect a Packet layer window size information element.
1686 dissect_q931_pl_window_size_ie(tvbuff_t *tvb, int offset, int len,
1691 proto_tree_add_text(tree, tvb, offset, 1,
1692 "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1698 proto_tree_add_text(tree, tvb, offset, 1,
1699 "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1703 * Dissect a Packet size information element.
1706 dissect_q931_packet_size_ie(tvbuff_t *tvb, int offset, int len,
1711 proto_tree_add_text(tree, tvb, offset, 1,
1712 "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1718 proto_tree_add_text(tree, tvb, offset, 1,
1719 "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1723 * Dissect a Closed user group information element.
1725 static const value_string q931_cug_indication_vals[] = {
1726 { 0x01, "Closed user group selection" },
1727 { 0x02, "Closed user group with outgoing access selection and indication" },
1732 dissect_q931_cug_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree)
1736 proto_tree_add_text(tree, tvb, offset, 1,
1737 "CUG indication: %s",
1738 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1739 q931_cug_indication_vals, "Unknown (0x%02X)"));
1745 proto_tree_add_text(tree, tvb, offset, len, "CUG index code: %s",
1746 tvb_format_text(tvb, offset, len));
1750 * Dissect a Reverse charging indication information element.
1752 static const value_string q931_reverse_charging_indication_vals[] = {
1753 { 0x01, "Reverse charging requested" },
1758 dissect_q931_reverse_charge_ind_ie(tvbuff_t *tvb, int offset, int len,
1763 proto_tree_add_text(tree, tvb, offset, 1,
1764 "Reverse charging indication: %s",
1765 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1766 q931_reverse_charging_indication_vals, "Unknown (0x%02X)"));
1770 * Dissect a (phone) number information element.
1772 static const value_string q931_number_type_vals[] = {
1773 { 0x00, "Unknown" },
1774 { 0x10, "International number" },
1775 { 0x20, "National number" },
1776 { 0x30, "Network specific number" },
1777 { 0x40, "Subscriber number" },
1778 { 0x60, "Abbreviated number" },
1782 static const value_string q931_numbering_plan_vals[] = {
1783 { 0x00, "Unknown" },
1784 { 0x01, "E.164 ISDN/telephony numbering" },
1785 { 0x03, "X.121 data numbering" },
1786 { 0x04, "F.69 Telex numbering" },
1787 { 0x08, "National standard numbering" },
1788 { 0x09, "Private numbering" },
1792 static const value_string q931_presentation_indicator_vals[] = {
1793 { 0x00, "Presentation allowed" },
1794 { 0x20, "Presentation restricted" },
1795 { 0x40, "Number not available due to interworking" },
1799 static const value_string q931_screening_indicator_vals[] = {
1800 { 0x00, "User-provided, not screened" },
1801 { 0x01, "User-provided, verified and passed" },
1802 { 0x02, "User-provided, verified and failed" },
1803 { 0x03, "Network-provided" },
1807 static const value_string q931_redirection_reason_vals[] = {
1808 { 0x00, "Unknown" },
1809 { 0x01, "Call forwarding busy or called DTE busy" },
1810 { 0x02, "Call forwarding no reply" },
1811 { 0x04, "Call deflection" },
1812 { 0x09, "Called DTE out of order" },
1813 { 0x0A, "Call forwarding by the called DTE" },
1814 { 0x0F, "Call forwarding unconditional or systematic call redirection" },
1819 dissect_q931_number_ie(tvbuff_t *tvb, int offset, int len,
1826 octet = tvb_get_guint8(tvb, offset);
1827 proto_tree_add_text(tree, tvb, offset, 1,
1828 "Type of number: %s",
1829 val_to_str(octet & 0x70, q931_number_type_vals,
1830 "Unknown (0x%02X)"));
1831 proto_tree_add_text(tree, tvb, offset, 1,
1832 "Numbering plan: %s",
1833 val_to_str(octet & 0x0F, q931_numbering_plan_vals,
1834 "Unknown (0x%02X)"));
1838 if (!(octet & Q931_IE_VL_EXTENSION)) {
1841 octet = tvb_get_guint8(tvb, offset);
1842 proto_tree_add_text(tree, tvb, offset, 1,
1843 "Presentation indicator: %s",
1844 val_to_str(octet & 0x60, q931_presentation_indicator_vals,
1846 proto_tree_add_text(tree, tvb, offset, 1,
1847 "Screening indicator: %s",
1848 val_to_str(octet & 0x03, q931_screening_indicator_vals,
1855 * XXX - only in a Redirecting number information element.
1857 if (!(octet & Q931_IE_VL_EXTENSION)) {
1860 octet = tvb_get_guint8(tvb, offset);
1861 proto_tree_add_text(tree, tvb, offset, 1,
1862 "Reason for redirection: %s",
1863 val_to_str(octet & 0x0F, q931_redirection_reason_vals,
1871 proto_tree_add_text(tree, tvb, offset, len, "Number: %s",
1872 tvb_format_text(tvb, offset, len));
1876 * Dissect a party subaddress information element.
1878 static const value_string q931_subaddress_type_vals[] = {
1879 { 0x00, "X.213/ISO 8348 Add.2 NSAP" },
1880 { 0x20, "User-specified" },
1884 static const value_string q931_odd_even_indicator_vals[] = {
1885 { 0x00, "Even number of address signals" },
1886 { 0x10, "Odd number of address signals" },
1891 dissect_q931_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
1898 octet = tvb_get_guint8(tvb, offset);
1899 proto_tree_add_text(tree, tvb, offset, 1,
1900 "Type of subaddress: %s",
1901 val_to_str(octet & 0x70, q931_subaddress_type_vals,
1902 "Unknown (0x%02X)"));
1903 proto_tree_add_text(tree, tvb, offset, 1,
1904 "Odd/even indicator: %s",
1905 val_to_str(octet & 0x10, q931_odd_even_indicator_vals,
1912 proto_tree_add_text(tree, tvb, offset, len, "Subaddress: %s",
1913 tvb_bytes_to_str(tvb, offset, len));
1917 * Dissect a Restart indicator information element.
1919 static const value_string q931_restart_indicator_class_vals[] = {
1920 { 0x00, "Indicated channels" },
1921 { 0x06, "Single interface" },
1922 { 0x07, "All interfaces" },
1927 dissect_q931_restart_indicator_ie(tvbuff_t *tvb, int offset, int len,
1931 proto_tree_add_text(tree, tvb, offset, len,
1932 "Restart indicator: length is %d, should be 1\n", len);
1935 proto_tree_add_text(tree, tvb, offset, 1,
1936 "Restart indicator: %s",
1937 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1938 q931_restart_indicator_class_vals, "Unknown (0x%02X)"));
1942 * Dissect a High-layer compatibility information element.
1944 #define Q931_AUDIOVISUAL 0x60
1945 static const value_string q931_high_layer_characteristics_vals[] = {
1946 { 0x01, "Telephony" },
1947 { 0x04, "F.182 Facsimile Group 2/3" },
1948 { 0x21, "F.184 Facsimile Group 4 Class I" },
1949 { 0x24, "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
1950 { 0x28, "F.220 Teletex, basic and processable mode" },
1951 { 0x31, "F.200 Teletex, basic mode" },
1952 { 0x32, "F.300 and T.102 syntax-based Videotex" },
1953 { 0x33, "F.300 and T.101 international Videotex interworking" },
1954 { 0x35, "F.60 Telex" },
1955 { 0x38, "X.400 Message Handling Systems" },
1956 { 0x41, "X.200 OSI application" },
1957 { 0x42, "FTAM application" },
1958 { 0x5E, "Reserved for maintenance" },
1959 { 0x5F, "Reserved for management" },
1960 { Q931_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
1961 { 0x61, "F.702 and F.731 Profile 1b videoconferencing" },
1962 { 0x62, "F.702 and F.731 audiographic conferencing" },
1966 static const value_string q931_audiovisual_characteristics_vals[] = {
1967 { 0x01, "Capability set of initial channel of H.221" },
1968 { 0x02, "Capability set of subsequent channel of H.221" },
1969 { 0x21, "Capability set of initial channel of an active 3.1kHz audio or speech call" },
1974 dissect_q931_high_layer_compat_ie(tvbuff_t *tvb, int offset, int len,
1978 guint8 coding_standard;
1979 guint8 characteristics;
1983 octet = tvb_get_guint8(tvb, offset);
1984 coding_standard = octet & 0x60;
1985 proto_tree_add_text(tree, tvb, offset, 1,
1986 "Coding standard: %s",
1987 val_to_str(coding_standard, q931_coding_standard_vals, NULL));
1988 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1990 * We don't know how the call state is encoded,
1991 * so just dump it as data and be done with it.
1993 proto_tree_add_text(tree, tvb, offset,
1995 tvb_bytes_to_str(tvb, offset, len));
2001 octet = tvb_get_guint8(tvb, offset);
2002 characteristics = octet & 0x7F;
2003 proto_tree_add_text(tree, tvb, offset, 1,
2004 "High layer characteristics identification: %s",
2005 val_to_str(characteristics, q931_high_layer_characteristics_vals,
2006 "Unknown (0x%02X)"));
2010 if (!(octet & Q931_IE_VL_EXTENSION)) {
2013 octet = tvb_get_guint8(tvb, offset);
2014 if (characteristics == Q931_AUDIOVISUAL) {
2015 proto_tree_add_text(tree, tvb, offset, 1,
2016 "Extended audiovisual characteristics identification: %s",
2017 val_to_str(octet & 0x7F,
2018 q931_audiovisual_characteristics_vals,
2019 "Unknown (0x%02X)"));
2021 proto_tree_add_text(tree, tvb, offset, 1,
2022 "Extended high layer characteristics identification: %s",
2023 val_to_str(octet & 0x7F,
2024 q931_high_layer_characteristics_vals,
2025 "Unknown (0x%02X)"));
2032 * Dissect a User-user information element.
2034 #define Q931_PROTOCOL_DISCRIMINATOR_IA5 0x04
2035 #define Q931_PROTOCOL_DISCRIMINATOR_ASN1 0x05
2037 static const value_string q931_protocol_discriminator_vals[] = {
2038 { 0x00, "User-specific protocol" },
2039 { 0x01, "OSI high layer protocols" },
2041 { Q931_PROTOCOL_DISCRIMINATOR_IA5, "IA5 characters" },
2042 { Q931_PROTOCOL_DISCRIMINATOR_ASN1, "X.208 and X.209 coded user information" },
2043 { 0x07, "V.120 rate adaption" },
2044 { 0x08, "Q.931/I.451 user-network call control messages" },
2049 dissect_q931_user_user_ie(tvbuff_t *tvb, int offset, int len,
2056 octet = tvb_get_guint8(tvb, offset);
2057 proto_tree_add_text(tree, tvb, offset, 1,
2058 "Protocol discriminator: %s",
2059 val_to_str(octet, q931_protocol_discriminator_vals,
2060 "Unknown (0x%02x)"));
2068 case Q931_PROTOCOL_DISCRIMINATOR_IA5:
2069 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
2070 tvb_format_text(tvb, offset, len));
2074 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
2075 tvb_bytes_to_str(tvb, offset, len));
2081 * Dissect information elements consisting of ASCII^H^H^H^H^HIA5 text.
2084 dissect_q931_ia5_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
2088 proto_tree_add_text(tree, tvb, offset, len, "%s: %s", label,
2089 tvb_format_text(tvb, offset, len));
2093 static const value_string q931_codeset_vals[] = {
2094 { 0x00, "Q.931 information elements" },
2095 { 0x04, "Information elements for ISO/IEC use" },
2096 { 0x05, "Information elements for national use" },
2097 { 0x06, "Information elements specific to the local network" },
2098 { 0x07, "User-specific information elements" },
2103 dissect_q931_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2107 proto_tree *q931_tree = NULL;
2109 proto_tree *ie_tree = NULL;
2110 guint8 call_ref_len;
2111 guint8 call_ref[15];
2112 guint8 message_type;
2113 guint8 info_element;
2114 guint16 info_element_len;
2116 gboolean non_locking_shift;
2119 if (check_col(pinfo->cinfo, COL_PROTOCOL))
2120 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Q.931");
2123 ti = proto_tree_add_item(tree, proto_q931, tvb, offset, -1,
2125 q931_tree = proto_item_add_subtree(ti, ett_q931);
2127 dissect_q931_protocol_discriminator(tvb, offset, q931_tree);
2130 call_ref_len = tvb_get_guint8(tvb, offset) & 0xF; /* XXX - do as a bit field? */
2131 if (q931_tree != NULL)
2132 proto_tree_add_uint(q931_tree, hf_q931_call_ref_len, tvb, offset, 1, call_ref_len);
2134 if (call_ref_len != 0) {
2135 /* XXX - split this into flag and value */
2136 tvb_memcpy(tvb, call_ref, offset, call_ref_len);
2137 if (q931_tree != NULL)
2138 proto_tree_add_bytes(q931_tree, hf_q931_call_ref, tvb, offset, call_ref_len, call_ref);
2139 offset += call_ref_len;
2141 message_type = tvb_get_guint8(tvb, offset);
2142 if (check_col(pinfo->cinfo, COL_INFO)) {
2143 col_add_str(pinfo->cinfo, COL_INFO,
2144 val_to_str(message_type, q931_message_type_vals,
2145 "Unknown message type (0x%02X)"));
2147 if (q931_tree != NULL)
2148 proto_tree_add_uint(q931_tree, hf_q931_message_type, tvb, offset, 1, message_type);
2152 * And now for the information elements....
2154 codeset = 0; /* start out in codeset 0 */
2155 non_locking_shift = TRUE;
2156 while (tvb_reported_length_remaining(tvb, offset) > 0) {
2157 info_element = tvb_get_guint8(tvb, offset);
2160 * Check for the single-octet IEs.
2162 switch (info_element & Q931_IE_SO_IDENTIFIER_MASK) {
2166 !(info_element & Q931_IE_SHIFT_LOCKING);
2167 codeset = info_element & Q931_IE_SHIFT_CODESET;
2168 if (q931_tree != NULL) {
2169 proto_tree_add_text(q931_tree, tvb, offset, 1,
2170 "%s shift to codeset %u: %s",
2171 (non_locking_shift ? "Non-locking" : "Locking"),
2173 val_to_str(codeset, q931_codeset_vals,
2174 "Unknown (0x%02X)"));
2179 case Q931_IE_MORE_DATA_OR_SEND_COMP:
2180 switch (info_element) {
2182 case Q931_IE_MORE_DATA:
2183 if (q931_tree != NULL) {
2184 proto_tree_add_text(q931_tree, tvb, offset, 1,
2189 case Q931_IE_SENDING_COMPLETE:
2190 if (q931_tree != NULL) {
2191 proto_tree_add_text(q931_tree, tvb, offset, 1,
2192 "Sending complete");
2197 if (q931_tree != NULL) {
2198 proto_tree_add_text(q931_tree, tvb, offset, 1,
2199 "Unknown information element (0x%02X",
2205 if (non_locking_shift)
2209 case Q931_IE_CONGESTION_LEVEL:
2210 if (q931_tree != NULL) {
2211 proto_tree_add_text(q931_tree, tvb, offset, 1,
2212 "Congestion level: %s",
2213 val_to_str(info_element & Q931_IE_SO_IE_MASK,
2214 q931_congestion_level_vals,
2218 if (non_locking_shift)
2222 case Q931_IE_REPEAT_INDICATOR:
2223 if (q931_tree != NULL) {
2224 proto_tree_add_text(q931_tree, tvb, offset, 1,
2225 "Repeat indicator: %s",
2226 val_to_str(info_element & Q931_IE_SO_IE_MASK,
2227 q931_repeat_indication_vals,
2231 if (non_locking_shift)
2240 * Variable-length IE.
2242 * According to page 18 from Recommendation H.225.0 :
2243 * " Length of user-user contents contents
2244 * - Shall be 2 octets instead of 1 (as in Figure 4-36/Q.931)"
2246 * We assume that if this is Q.931-over-TPKT, it might
2247 * be H.225 traffic, and check for the IE being a user-user
2248 * IE with ASN.1 encoding of the user information.
2250 if (is_tpkt && tvb_bytes_exist(tvb, offset, 4) &&
2251 tvb_get_guint8(tvb, offset) == Q931_IE_USER_USER &&
2252 tvb_get_guint8(tvb, offset + 3) == Q931_PROTOCOL_DISCRIMINATOR_ASN1) {
2253 info_element_len = tvb_get_ntohs(tvb, offset + 1);
2254 if (q931_tree != NULL) {
2255 ti = proto_tree_add_text(q931_tree, tvb, offset,
2256 1+2+info_element_len, "%s",
2257 val_to_str(info_element,
2258 q931_info_element_vals,
2259 "Unknown information element (0x%02X)"));
2260 ie_tree = proto_item_add_subtree(ti,
2262 proto_tree_add_text(ie_tree, tvb, offset, 1,
2263 "Information element: %s",
2264 val_to_str(info_element,
2265 q931_info_element_vals, "Unknown (0x%02X)"));
2266 proto_tree_add_text(ie_tree, tvb, offset + 1,
2267 2, "Length: %u", info_element_len);
2268 proto_tree_add_text(ie_tree, tvb, offset + 3,
2269 1, "Protocol discriminator: %s",
2270 val_to_str(tvb_get_guint8(tvb, offset + 3),
2271 q931_protocol_discriminator_vals,
2272 "Unknown (0x%02x)"));
2275 if (info_element_len > 1) {
2277 * Do we have a handle for the H.225
2280 if (h225_handle != NULL) {
2282 * Yes - call it, regardless of
2283 * whether we're building a
2284 * protocol tree or not.
2286 h225_tvb = tvb_new_subset(tvb,
2287 offset + 4, info_element_len - 1,
2288 info_element_len - 1);
2289 call_dissector(h225_handle, h225_tvb,
2293 * No - just show it as "User
2294 * information" (if "ie_tree" is
2295 * null, this won't add anything).
2297 proto_tree_add_text(ie_tree, tvb,
2298 offset + 4, info_element_len - 1,
2299 "User information: %s",
2300 tvb_bytes_to_str(tvb, offset + 4,
2301 info_element_len - 1));
2304 offset += 1 + 2 + info_element_len;
2306 info_element_len = tvb_get_guint8(tvb, offset + 1);
2307 if (q931_tree != NULL) {
2308 ti = proto_tree_add_text(q931_tree, tvb, offset,
2309 1+1+info_element_len, "%s",
2310 val_to_str(info_element, q931_info_element_vals,
2311 "Unknown information element (0x%02X)"));
2312 ie_tree = proto_item_add_subtree(ti, ett_q931_ie);
2313 proto_tree_add_text(ie_tree, tvb, offset, 1,
2314 "Information element: %s",
2315 val_to_str(info_element, q931_info_element_vals,
2316 "Unknown (0x%02X)"));
2317 proto_tree_add_text(ie_tree, tvb, offset + 1, 1,
2318 "Length: %u", info_element_len);
2320 switch (info_element) {
2322 case Q931_IE_SEGMENTED_MESSAGE:
2323 dissect_q931_segmented_message_ie(tvb,
2324 offset + 2, info_element_len,
2328 case Q931_IE_BEARER_CAPABILITY:
2329 case Q931_IE_LOW_LAYER_COMPAT:
2330 dissect_q931_bearer_capability_ie(tvb,
2331 offset + 2, info_element_len,
2336 dissect_q931_cause_ie(tvb,
2337 offset + 2, info_element_len,
2341 case Q931_IE_CALL_STATE:
2342 dissect_q931_call_state_ie(tvb,
2343 offset + 2, info_element_len,
2347 case Q931_IE_CHANNEL_IDENTIFICATION:
2348 dissect_q931_channel_identification_ie(
2349 tvb, offset + 2, info_element_len,
2353 case Q931_IE_PROGRESS_INDICATOR:
2354 dissect_q931_progress_indicator_ie(tvb,
2355 offset + 2, info_element_len,
2359 case Q931_IE_NETWORK_SPECIFIC_FACIL:
2360 case Q931_IE_TRANSIT_NETWORK_SEL:
2361 dissect_q931_ns_facilities_ie(tvb,
2362 offset + 2, info_element_len,
2366 case Q931_IE_NOTIFICATION_INDICATOR:
2367 dissect_q931_notification_indicator_ie(
2368 tvb, offset + 2, info_element_len,
2372 case Q931_IE_DISPLAY:
2373 dissect_q931_ia5_ie(tvb, offset + 2,
2374 info_element_len, ie_tree,
2375 "Display information");
2378 case Q931_IE_DATE_TIME:
2379 dissect_q931_date_time_ie(tvb,
2380 offset + 2, info_element_len,
2384 case Q931_IE_KEYPAD_FACILITY:
2385 dissect_q931_ia5_ie(tvb, offset + 2,
2386 info_element_len, ie_tree,
2390 case Q931_IE_SIGNAL:
2391 dissect_q931_signal_ie(tvb,
2392 offset + 2, info_element_len,
2396 case Q931_IE_INFORMATION_RATE:
2397 dissect_q931_information_rate_ie(tvb,
2398 offset + 2, info_element_len,
2402 case Q931_IE_E2E_TRANSIT_DELAY:
2403 dissect_q931_e2e_transit_delay_ie(tvb,
2404 offset + 2, info_element_len,
2408 case Q931_IE_TD_SELECTION_AND_INT:
2409 dissect_q931_td_selection_and_int_ie(
2410 tvb, offset + 2, info_element_len,
2414 case Q931_IE_PL_BINARY_PARAMETERS:
2415 dissect_q931_pl_binary_parameters_ie(
2416 tvb, offset + 2, info_element_len,
2420 case Q931_IE_PL_WINDOW_SIZE:
2421 dissect_q931_pl_window_size_ie(tvb,
2422 offset + 2, info_element_len,
2426 case Q931_IE_PACKET_SIZE:
2427 dissect_q931_packet_size_ie(tvb,
2428 offset + 2, info_element_len,
2433 dissect_q931_cug_ie(tvb,
2434 offset + 2, info_element_len,
2438 case Q931_IE_REVERSE_CHARGE_IND:
2439 dissect_q931_reverse_charge_ind_ie(tvb,
2440 offset + 2, info_element_len,
2444 case Q931_IE_CALLING_PARTY_NUMBER:
2445 case Q931_IE_CALLED_PARTY_NUMBER:
2446 case Q931_IE_REDIRECTING_NUMBER:
2447 dissect_q931_number_ie(tvb,
2448 offset + 2, info_element_len,
2452 case Q931_IE_CALLING_PARTY_SUBADDR:
2453 case Q931_IE_CALLED_PARTY_SUBADDR:
2454 dissect_q931_party_subaddr_ie(tvb,
2455 offset + 2, info_element_len,
2459 case Q931_IE_RESTART_INDICATOR:
2460 dissect_q931_restart_indicator_ie(tvb,
2461 offset + 2, info_element_len,
2465 case Q931_IE_HIGH_LAYER_COMPAT:
2466 dissect_q931_high_layer_compat_ie(tvb,
2467 offset + 2, info_element_len,
2471 case Q931_IE_USER_USER:
2472 dissect_q931_user_user_ie(tvb,
2473 offset + 2, info_element_len,
2478 proto_tree_add_text(ie_tree, tvb,
2479 offset + 2, info_element_len,
2482 tvb_get_ptr(tvb, offset + 2,
2488 offset += 1 + 1 + info_element_len;
2490 if (non_locking_shift)
2496 * Q.931-over-TPKT-over-TCP.
2499 dissect_q931_tpkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2504 * Check whether this looks like a TPKT-encapsulated
2507 lv_tpkt_len = is_tpkt(tvb);
2508 if (lv_tpkt_len == -1) {
2510 * It's not a TPKT packet; reject it.
2516 * If this segment is *exactly* the length of a TPKT header,
2517 * we assume that, as it looks like a TPKT header, it
2518 * is one, and that the code put a TPKT header in one
2519 * segment and the rest of the PDU in another.
2521 if (tvb_length(tvb) == 4) {
2523 * It is - call the "dissect TPKT over a TCP stream"
2526 dissect_tpkt_encap(tvb, pinfo, tree, q931_desegment,
2527 q931_tpkt_pdu_handle);
2532 * Well, we have more data than just the TPKT header;
2533 * check whether it looks like the beginning of a
2536 * The minimum length of a Q.931 message is 3:
2537 * 1 byte for the protocol discriminator,
2538 * 1 for the call_reference length,
2539 * and one for the message type.
2541 * Check that we have that many bytes past the
2544 if (!tvb_bytes_exist(tvb, 4, 3))
2548 * And check that we have that many bytes in the TPKT
2551 if (lv_tpkt_len < 3)
2554 /* Check the protocol discriminator */
2555 if (tvb_get_guint8(tvb, 4) != NLPID_Q_931) {
2556 /* Doesn't look like Q.931 inside TPKT */
2561 * OK, it looks like Q.931-over-TPKT.
2562 * Call the "dissect TPKT over a TCP stream" routine.
2564 dissect_tpkt_encap(tvb, pinfo, tree, q931_desegment,
2565 q931_tpkt_pdu_handle);
2571 dissect_q931_tpkt_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2573 dissect_q931_pdu(tvb, pinfo, tree, TRUE);
2577 dissect_q931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2579 dissect_q931_pdu(tvb, pinfo, tree, FALSE);
2583 proto_register_q931(void)
2585 static hf_register_info hf[] = {
2586 { &hf_q931_discriminator,
2587 { "Protocol discriminator", "q931.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
2590 { &hf_q931_call_ref_len,
2591 { "Call reference value length", "q931.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
2594 { &hf_q931_call_ref,
2595 { "Call reference value", "q931.call_ref", FT_BYTES, BASE_HEX, NULL, 0x0,
2598 { &hf_q931_message_type,
2599 { "Message type", "q931.message_type", FT_UINT8, BASE_HEX, VALS(q931_message_type_vals), 0x0,
2602 static gint *ett[] = {
2606 module_t *q931_module;
2608 proto_q931 = proto_register_protocol("Q.931", "Q.931", "q931");
2609 proto_register_field_array (proto_q931, hf, array_length(hf));
2610 proto_register_subtree_array(ett, array_length(ett));
2612 register_dissector("q931", dissect_q931, proto_q931);
2613 q931_tpkt_pdu_handle = create_dissector_handle(dissect_q931_tpkt_pdu,
2616 q931_module = prefs_register_protocol(proto_q931, NULL);
2617 prefs_register_bool_preference(q931_module, "desegment_h323_messages",
2618 "Desegment all Q.931 messages spanning multiple TCP segments",
2619 "Whether the Q.931 dissector should desegment all messages spanning multiple TCP segments",
2624 proto_reg_handoff_q931(void)
2627 * Attempt to get a handle for the H.225 dissector.
2628 * If we can't, the handle we get is null, and we'll just
2629 * dissect putatively-H.255 Call Signaling stuff as User
2632 h225_handle = find_dissector("h225");
2637 heur_dissector_add("tcp", dissect_q931_tpkt, proto_q931);