2 * Routines for Q.931 frame disassembly
3 * Guy Harris <guy@alum.mit.edu>
5 * $Id: packet-q931.c,v 1.22 2001/01/03 06:55:31 guy Exp $
7 * Modified by Andreas Sikkema for possible use with H.323
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@zing.org>
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
43 #include "packet-q931.h"
46 #include "packet-tpkt.h"
47 #include "packet-h225.h"
52 * http://www.acacia-net.com/Clarinet/Protocol/q9313svn.htm
53 * http://www.acacia-net.com/Clarinet/Protocol/q9311sc3.htm
54 * http://www.acacia-net.com/Clarinet/Protocol/q9317oz7.htm
55 * http://www.protocols.com/pbook/isdn.htm
56 * http://freesoft.org/CIE/Topics/126.htm
57 * http://noc.comstar.ru/miscdocs/ascend-faq-cause-codes.html
58 * http://www.andrews-arnold.co.uk/isdn/q931cause.html
59 * http://www.tulatelecom.ru/staff/german/DSSHelp/MessList/InfEl/InfElList.html
62 static int proto_q931 = -1;
63 static int hf_q931_discriminator = -1;
64 static int hf_q931_call_ref_len = -1;
65 static int hf_q931_call_ref = -1;
66 static int hf_q931_message_type = -1;
68 static gint ett_q931 = -1;
69 static gint ett_q931_ie = -1;
72 * Q.931 message types.
74 #define Q931_ESCAPE 0x00
75 #define Q931_ALERTING 0x01
76 #define Q931_CALL_PROCEEDING 0x02
77 #define Q931_CONNECT 0x07
78 #define Q931_CONNECT_ACK 0x0F
79 #define Q931_PROGRESS 0x03
80 #define Q931_SETUP 0x05
81 #define Q931_SETUP_ACK 0x0B
82 #define Q931_HOLD 0x24
83 #define Q931_HOLD_ACK 0x28
84 #define Q931_HOLD_REJECT 0x30
85 #define Q931_RESUME 0x26
86 #define Q931_RESUME_ACK 0x2E
87 #define Q931_RESUME_REJECT 0x22
88 #define Q931_RETRIEVE 0x31
89 #define Q931_RETRIEVE_ACK 0x33
90 #define Q931_RETRIEVE_REJECT 0x37
91 #define Q931_SUSPEND 0x25
92 #define Q931_SUSPEND_ACK 0x2D
93 #define Q931_SUSPEND_REJECT 0x21
94 #define Q931_USER_INFORMATION 0x20
95 #define Q931_DISCONNECT 0x45
96 #define Q931_RELEASE 0x4D
97 #define Q931_RELEASE_COMPLETE 0x5A
98 #define Q931_RESTART 0x46
99 #define Q931_RESTART_ACK 0x4E
100 #define Q931_CONGESTION_CONTROL 0x79
101 #define Q931_FACILITY 0x62
102 #define Q931_INFORMATION 0x7B
103 #define Q931_NOTIFY 0x6E
104 #define Q931_REGISTER 0x64
105 #define Q931_SEGMENT 0x60
106 #define Q931_STATUS 0x7D
107 #define Q931_STATUS_ENQUIRY 0x75
109 static const value_string q931_message_type_vals[] = {
110 { Q931_ESCAPE, "ESCAPE" },
111 { Q931_ALERTING, "ALERTING" },
112 { Q931_CALL_PROCEEDING, "CALL PROCEEDING" },
113 { Q931_CONNECT, "CONNECT" },
114 { Q931_CONNECT_ACK, "CONNECT ACKNOWLEDGE" },
115 { Q931_PROGRESS, "PROGRESS" },
116 { Q931_SETUP, "SETUP" },
117 { Q931_SETUP_ACK, "SETUP ACKNOWLEDGE" },
118 { Q931_HOLD, "HOLD" },
119 { Q931_HOLD_ACK, "HOLD_ACKNOWLEDGE" },
120 { Q931_HOLD_REJECT, "HOLD_REJECT" },
121 { Q931_RESUME, "RESUME" },
122 { Q931_RESUME_ACK, "RESUME ACKNOWLEDGE" },
123 { Q931_RESUME_REJECT, "RESUME REJECT" },
124 { Q931_RETRIEVE, "RETRIEVE" },
125 { Q931_RETRIEVE_ACK, "RETRIEVE ACKNOWLEDGE" },
126 { Q931_RETRIEVE_REJECT, "RETRIEVE REJECT" },
127 { Q931_SUSPEND, "SUSPEND" },
128 { Q931_SUSPEND_ACK, "SUSPEND ACKNOWLEDGE" },
129 { Q931_SUSPEND_REJECT, "SUSPEND REJECT" },
130 { Q931_USER_INFORMATION, "USER INFORMATION" },
131 { Q931_DISCONNECT, "DISCONNECT" },
132 { Q931_RELEASE, "RELEASE" },
133 { Q931_RELEASE_COMPLETE, "RELEASE COMPLETE" },
134 { Q931_RESTART, "RESTART" },
135 { Q931_RESTART_ACK, "RESTART ACKNOWLEDGE" },
136 { Q931_CONGESTION_CONTROL, "CONGESTION CONTROL" },
137 { Q931_FACILITY, "FACILITY" },
138 { Q931_INFORMATION, "INFORMATION" },
139 { Q931_NOTIFY, "NOTIFY" },
140 { Q931_REGISTER, "REGISTER" },
141 { Q931_SEGMENT, "SEGMENT" },
142 { Q931_STATUS, "STATUS" },
143 { Q931_STATUS_ENQUIRY, "STATUS ENQUIRY" },
148 * Information elements.
154 #define Q931_IE_SO_IDENTIFIER_MASK 0xf0 /* IE identifier mask */
155 #define Q931_IE_SO_IDENTIFIER_SHIFT 4 /* IE identifier shift */
156 #define Q931_IE_SO_IE_MASK 0x0F /* IE mask */
158 #define Q931_IE_SHIFT 0x90
159 #define Q931_IE_SHIFT_LOCKING 0x08 /* locking shift */
160 #define Q931_IE_SHIFT_CODESET 0x0F /* codeset */
162 #define Q931_IE_MORE_DATA_OR_SEND_COMP 0xA0 /* More Data or Sending Complete */
163 #define Q931_IE_MORE_DATA 0xA0
164 #define Q931_IE_SENDING_COMPLETE 0xA1
166 #define Q931_IE_CONGESTION_LEVEL 0xB0
167 #define Q931_IE_REPEAT_INDICATOR 0xD0
170 * Variable-length IEs.
172 #define Q931_IE_VL_EXTENSION 0x80 /* Extension flag */
175 * Codeset 0 (default).
177 #define Q931_IE_SEGMENTED_MESSAGE 0x00
178 #define Q931_IE_BEARER_CAPABILITY 0x04
179 #define Q931_IE_CAUSE 0x08
180 #define Q931_IE_CALL_IDENTITY 0x10
181 #define Q931_IE_CALL_STATE 0x14
182 #define Q931_IE_CHANNEL_IDENTIFICATION 0x18
183 #define Q931_IE_FACILITY 0x1C
184 #define Q931_IE_PROGRESS_INDICATOR 0x1E
185 #define Q931_IE_NETWORK_SPECIFIC_FACIL 0x20 /* Network Specific Facilities */
186 #define Q931_IE_NOTIFICATION_INDICATOR 0x27
187 #define Q931_IE_DISPLAY 0x28
188 #define Q931_IE_DATE_TIME 0x29
189 #define Q931_IE_KEYPAD_FACILITY 0x2C
190 #define Q931_IE_INFORMATION_REQUEST 0x32
191 #define Q931_IE_SIGNAL 0x34
192 #define Q931_IE_SWITCHHOOK 0x36
193 #define Q931_IE_FEATURE_ACTIVATION 0x38
194 #define Q931_IE_FEATURE_INDICATION 0x39
195 #define Q931_IE_ENDPOINT_IDENTIFIER 0x3B
196 #define Q931_IE_SERVICE_PROFILE_ID 0x3A
197 #define Q931_IE_INFORMATION_RATE 0x40
198 #define Q931_IE_E2E_TRANSIT_DELAY 0x42 /* End-to-end Transit Delay */
199 #define Q931_IE_TD_SELECTION_AND_INT 0x43 /* Transit Delay Selection and Indication */
200 #define Q931_IE_PL_BINARY_PARAMETERS 0x44 /* Packet layer binary parameters */
201 #define Q931_IE_PL_WINDOW_SIZE 0x45 /* Packet layer window size */
202 #define Q931_IE_PACKET_SIZE 0x46 /* Packet size */
203 #define Q931_IE_CUG 0x47 /* Closed user group */
204 #define Q931_IE_REVERSE_CHARGE_IND 0x4A /* Reverse charging indication */
205 #define Q931_IE_CALLING_PARTY_NUMBER 0x6C /* Calling Party Number */
206 #define Q931_IE_CALLING_PARTY_SUBADDR 0x6D /* Calling Party Subaddress */
207 #define Q931_IE_CALLED_PARTY_NUMBER 0x70 /* Called Party Number */
208 #define Q931_IE_CALLED_PARTY_SUBADDR 0x71 /* Called Party Subaddress */
209 #define Q931_IE_REDIRECTING_NUMBER 0x74
210 #define Q931_IE_REDIRECTION_NUMBER 0x76
211 #define Q931_IE_TRANSIT_NETWORK_SEL 0x78 /* Transit Network Selection */
212 #define Q931_IE_RESTART_INDICATOR 0x79
213 #define Q931_IE_LOW_LAYER_COMPAT 0x7C /* Low-Layer Compatibility */
214 #define Q931_IE_HIGH_LAYER_COMPAT 0x7D /* High-Layer Compatibility */
215 #define Q931_IE_USER_USER 0x7E /* User-User */
216 #define Q931_IE_ESCAPE 0x7F /* Escape for extension */
221 #define Q931_IE_CONNECTED_NUMBER 0x8C
222 #define Q931_IE_CONNECTED_SUBADDR 0x8D
225 * Codeset 5 (National-specific) Belgium.
227 #define Q931_IE_CHARGING_ADVICE 0x1A
230 * Codeset 5 (National-specific) Bellcore National ISDN.
232 #define Q931_IE_OPERATOR_SYSTEM_ACCESS 0x1D
235 * Codeset 6 (Network-specific) Belgium.
237 /* 0x1A is Charging Advice, as with Codeset 5 */
238 #define Q931_IE_REDIRECTING_NUMBER 0x74
241 * Codeset 6 (Network-specific) FT-Numeris.
243 /* 0x1D is User Capability */
246 * Codeset 6 (Network-specific) Bellcore National ISDN.
248 #define Q931_IE_REDIRECTING_SUBADDR 0x75 /* Redirecting Subaddress */
249 /* 0x76 is Redirection Number, but that's also Codeset 0 */
250 #define Q931_IE_CALL_APPEARANCE 0x7B
252 static const value_string q931_info_element_vals[] = {
253 { Q931_IE_SEGMENTED_MESSAGE, "Segmented message" },
254 { Q931_IE_BEARER_CAPABILITY, "Bearer capability" },
255 { Q931_IE_CAUSE, "Cause" },
256 { Q931_IE_CALL_IDENTITY, "Call identity" },
257 { Q931_IE_CALL_STATE, "Call state" },
258 { Q931_IE_CHANNEL_IDENTIFICATION, "Channel identification" },
259 { Q931_IE_FACILITY, "Facility" },
260 { Q931_IE_PROGRESS_INDICATOR, "Progress indicator" },
261 { Q931_IE_NETWORK_SPECIFIC_FACIL, "Network specific facilities" },
262 { Q931_IE_NOTIFICATION_INDICATOR, "Notification indicator" },
263 { Q931_IE_DISPLAY, "Display" },
264 { Q931_IE_DATE_TIME, "Date/Time" },
265 { Q931_IE_KEYPAD_FACILITY, "Keypad facility" },
266 { Q931_IE_INFORMATION_REQUEST, "Information request" },
267 { Q931_IE_SIGNAL, "Signal" },
268 { Q931_IE_SWITCHHOOK, "Switchhook" },
269 { Q931_IE_FEATURE_ACTIVATION, "Feature activation" },
270 { Q931_IE_FEATURE_INDICATION, "Feature Indication" },
271 { Q931_IE_ENDPOINT_IDENTIFIER, "Endpoint identifier" },
272 { Q931_IE_SERVICE_PROFILE_ID, "Service profile ID" },
273 { Q931_IE_INFORMATION_RATE, "Information rate" },
274 { Q931_IE_E2E_TRANSIT_DELAY, "End-to-end transit delay" },
275 { Q931_IE_TD_SELECTION_AND_INT, "Transit delay selection and indication" },
276 { Q931_IE_PL_BINARY_PARAMETERS, "Packet layer binary parameters" },
277 { Q931_IE_PL_WINDOW_SIZE, "Packet layer window size" },
278 { Q931_IE_PACKET_SIZE, "Packet size" },
279 { Q931_IE_CUG, "Closed user group" },
280 { Q931_IE_REVERSE_CHARGE_IND, "Reverse charging indication" },
281 { Q931_IE_CALLING_PARTY_NUMBER, "Calling party number" },
282 { Q931_IE_CALLING_PARTY_SUBADDR, "Calling party subaddress" },
283 { Q931_IE_CALLED_PARTY_NUMBER, "Called party number" },
284 { Q931_IE_CALLED_PARTY_SUBADDR, "Called party subaddress" },
285 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
286 { Q931_IE_REDIRECTION_NUMBER, "Redirection number" },
287 { Q931_IE_TRANSIT_NETWORK_SEL, "Transit network selection" },
288 { Q931_IE_RESTART_INDICATOR, "Restart indicator" },
289 { Q931_IE_LOW_LAYER_COMPAT, "Low-layer compatibility" },
290 { Q931_IE_HIGH_LAYER_COMPAT, "High-layer compatibility" },
291 { Q931_IE_USER_USER, "User-user" },
292 { Q931_IE_ESCAPE, "Escape" },
293 { Q931_IE_CONNECTED_NUMBER, "Connected number" },
294 { Q931_IE_CONNECTED_SUBADDR, "Connected subaddress" },
295 { Q931_IE_CHARGING_ADVICE, "Charging advice" },
296 { Q931_IE_OPERATOR_SYSTEM_ACCESS, "Operator system access" },
297 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
298 { Q931_IE_REDIRECTING_SUBADDR, "Redirecting subaddress" },
299 { Q931_IE_CALL_APPEARANCE, "Call appearance" },
303 static const value_string q931_congestion_level_vals[] = {
304 { 0x0, "Receiver ready" },
305 { 0xF, "Receiver not ready" },
309 static const value_string q931_repeat_indication_vals[] = {
310 { 0x2, "Prioritized list" },
315 * ITU-standardized coding.
317 #define Q931_ITU_STANDARDIZED_CODING 0x00
320 * Dissect a Segmented message information element.
323 dissect_q931_segmented_message_ie(tvbuff_t *tvb, int offset, int len,
327 proto_tree_add_text(tree, tvb, offset, len,
328 "Segmented message: length is %d, should be 2\n", len);
331 if (tvb_get_guint8(tvb, offset) & 0x80) {
332 proto_tree_add_text(tree, tvb, offset, 1,
333 "First segment: %u segments remaining",
334 tvb_get_guint8(tvb, offset) & 0x7F);
336 proto_tree_add_text(tree, tvb, offset, 1,
337 "Not first segment: %u segments remaining",
338 tvb_get_guint8(tvb, offset) & 0x7F);
340 proto_tree_add_text(tree, tvb, offset + 1, 1,
341 "Segmented message type: %u\n", tvb_get_guint8(tvb, offset + 1));
345 * Dissect a Bearer capability or Low-layer compatibility information element.
347 static const value_string q931_bc_coding_standard_vals[] = {
348 { 0x00, "ITU-T standardized coding" },
349 { 0x20, "ISO/IEC standard" },
350 { 0x40, "National standard" },
351 { 0x60, "Standard defined for this particular network" },
355 static const value_string q931_information_transfer_capability_vals[] = {
357 { 0x08, "Unrestricted digital information" },
358 { 0x09, "Restricted digital information" },
359 { 0x10, "3.1 kHz audio" },
360 { 0x11, "Unrestricted digital information with tones/announcements" },
365 static const value_string q931_transfer_mode_vals[] = {
366 { 0x00, "Circuit mode" },
367 { 0x40, "Packet mode" },
371 #define Q931_IT_RATE_MULTIRATE 0x18
373 static const value_string q931_information_transfer_rate_vals[] = {
374 { 0x00, "Packet mode" },
375 { 0x10, "64 kbit/s" },
376 { 0x11, "2 x 64 kbit/s" },
377 { 0x13, "384 kbit/s" },
378 { 0x15, "1536 kbit/s" },
379 { 0x17, "1920 kbit/s" },
380 { Q931_IT_RATE_MULTIRATE, "Multirate (64 kbit/s base rate)" },
384 static const value_string q931_uil1_vals[] = {
385 { 0x01, "V.110/I.460/X.30 rate adaption" },
386 { 0x02, "Recommendation G.711 u-law" },
387 { 0x03, "Recommendation G.711 A-law" },
388 { 0x04, "Recommendation G.721 32 kbit/s ADPCM and Recommendation I.460" },
389 { 0x05, "Recommendation H.221 and H.242" },
390 { 0x06, "Recommendation H.223 and H.245" },
391 { 0x07, "Non-ITU-T-standardized rate adaption" },
392 { 0x08, "V.120 rate adaption" },
393 { 0x09, "X.31 HDLC flag stuffing" },
397 static const value_string q931_l1_user_rate_vals[] = {
398 { 0x00, "Rate indicated by E-bits" },
399 { 0x01, "0.6 kbit/s" },
400 { 0x02, "1.2 kbit/s" },
401 { 0x03, "2.4 kbit/s" },
402 { 0x04, "3.6 kbit/s" },
403 { 0x05, "4.8 kbit/s" },
404 { 0x06, "7.2 kbit/s" },
405 { 0x07, "8 kbit/s" },
406 { 0x08, "9.6 kbit/s" },
407 { 0x09, "14.4 kbit/s" },
408 { 0x0A, "16 kbit/s" },
409 { 0x0B, "19.2 kbit/s" },
410 { 0x0C, "32 kbit/s" },
411 { 0x0E, "48 kbit/s" },
412 { 0x0F, "56 kbit/s" },
413 { 0x10, "64 kbit/s "},
414 { 0x15, "0.1345 kbit/s" },
415 { 0x16, "0.100 kbit/s" },
416 { 0x17, "0.075/1.2 kbit/s" },
417 { 0x18, "1.2/0.075 kbit/s" },
418 { 0x19, "0.050 kbit/s" },
419 { 0x1A, "0.075 kbit/s" },
420 { 0x1B, "0.110 kbit/s" },
421 { 0x1C, "0.150 kbit/s" },
422 { 0x1D, "0.200 kbit/s" },
423 { 0x1E, "0.300 kbit/s" },
424 { 0x1F, "12 kbit/s" },
428 static const value_string q931_l1_intermediate_rate_vals[] = {
429 { 0x20, "8 kbit/s" },
430 { 0x40, "16 kbit/s" },
431 { 0x60, "32 kbit/s" },
435 static const value_string q931_l1_stop_bits_vals[] = {
442 static const value_string q931_l1_data_bits_vals[] = {
449 static const value_string q931_l1_parity_vals[] = {
453 { 0x04, "Forced to 0" },
454 { 0x05, "Forced to 1" },
458 static const value_string q931_l1_modem_type_vals[] = {
461 { 0x13, "V.22 bis" },
464 { 0x16, "V.26 bis" },
465 { 0x17, "V.26 ter" },
467 { 0x19, "V.27 bis" },
468 { 0x1A, "V.27 ter" },
475 #define Q931_UIL2_USER_SPEC 0x10
477 static const value_string q931_uil2_vals[] = {
478 { 0x01, "Basic mode ISO 1745" },
479 { 0x02, "Q.921/I.441" }, /* LAPD */
480 { 0x06, "X.25, link layer" }, /* LAPB */
481 { 0x07, "X.25 multilink" }, /* or 0x0F? */
482 { 0x08, "T.71 Extended LAPB" },
483 { 0x09, "HDLC ARM" },
484 { 0x0A, "HDLC NRM" },
485 { 0x0B, "HDLC ABM" },
486 { 0x0C, "ISO 8802/2 LLC" },
487 { 0x0D, "X.75 Single Link Procedure" },
489 { 0x0F, "Core aspects of Q.922" },
490 { Q931_UIL2_USER_SPEC, "User-specified" },
491 { 0x11, "ISO 7776 DTE-DTE operation" },
495 static const value_string q931_mode_vals[] = {
496 { 0x20, "Normal mode" },
497 { 0x40, "Extended mode" },
501 #define Q931_UIL3_X25_PL 0x06
502 #define Q931_UIL3_ISO_8208 0x07 /* X.25-based */
503 #define Q931_UIL3_X223 0x08 /* X.25-based */
504 #define Q931_UIL3_TR_9577 0x0B
505 #define Q931_UIL3_USER_SPEC 0x10
507 static const value_string q931_uil3_vals[] = {
508 { 0x02, "Q.931/I.451" },
509 { Q931_UIL3_X25_PL, "X.25, packet layer" },
510 { Q931_UIL3_ISO_8208, "ISO/IEC 8208" },
511 { Q931_UIL3_X223, "X.223/ISO 8878" },
512 { 0x09, "ISO/IEC 8473" },
514 { Q931_UIL3_TR_9577, "ISO/IEC TR 9577" },
515 { Q931_UIL3_USER_SPEC, "User-specified" },
520 * XXX - should this (or, rather, a routine to return a string containing
521 * the stuff we put after "Protocol discriminator:") be in "packet-osi.c"?
523 * I.e., is the convention that 16-63 and 80-254 are for network-layer
524 * or layer-3 protocols, and 64-79 are for national use, specific to
525 * Q.931 (and maybe Q.2931), or is it a more general ISO standard?
528 dissect_q931_protocol_discriminator(tvbuff_t *tvb, int offset, proto_tree *tree)
530 unsigned int discriminator = tvb_get_guint8(tvb, offset);
533 nlpid_string = match_strval(discriminator, nlpid_vals);
534 if (nlpid_string != NULL) {
535 proto_tree_add_uint_format(tree, hf_q931_discriminator,
536 tvb, offset, 1, discriminator,
537 "Protocol discriminator: %s", nlpid_string);
539 if ((discriminator >= 16 && discriminator < 63)
540 || ((discriminator >= 80) && (discriminator < 254))) {
541 proto_tree_add_uint_format(tree, hf_q931_discriminator,
542 tvb, offset, 1, discriminator,
543 "Protocol discriminator: Network layer or layer 3 protocol (0x%02X)",
545 } else if (discriminator >= 64 && discriminator <= 79) {
546 proto_tree_add_uint_format(tree, hf_q931_discriminator,
547 tvb, offset, 1, discriminator,
548 "Protocol discriminator: National use (0x%02X)",
551 proto_tree_add_uint_format(tree, hf_q931_discriminator,
552 tvb, offset, 1, discriminator,
553 "Protocol discriminator: Reserved (0x%02X)",
560 dissect_q931_bearer_capability_ie(tvbuff_t *tvb, int offset, int len,
564 guint8 coding_standard;
567 guint8 uil2_protocol;
568 guint8 uil3_protocol;
573 octet = tvb_get_guint8(tvb, offset);
574 coding_standard = octet & 0x60;
575 proto_tree_add_text(tree, tvb, offset, 1,
576 "Coding standard: %s",
577 val_to_str(coding_standard, q931_bc_coding_standard_vals, NULL));
578 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
580 * We don't know how the bearer capability is encoded,
581 * so just dump it as data and be done with it.
583 proto_tree_add_text(tree, tvb, offset,
585 tvb_bytes_to_str(tvb, offset, len));
588 proto_tree_add_text(tree, tvb, offset, 1,
589 "Information transfer capability: %s",
590 val_to_str(octet & 0x1F, q931_information_transfer_capability_vals,
591 "Unknown (0x%02X)"));
596 * XXX - only in Low-layer compatibility information element.
598 if (!(octet & Q931_IE_VL_EXTENSION)) {
601 octet = tvb_get_guint8(tvb, offset);
602 proto_tree_add_text(tree, tvb, offset, 1,
603 "Out-band negotiation %spossible",
604 (octet & 0x40) ? "" : "not ");
611 octet = tvb_get_guint8(tvb, offset);
612 proto_tree_add_text(tree, tvb, offset, 1,
614 val_to_str(octet & 0x60, q931_transfer_mode_vals,
615 "Unknown (0x%02X)"));
616 it_rate = octet & 0x1F;
617 proto_tree_add_text(tree, tvb, offset, 1,
618 "Information transfer rate: %s",
619 val_to_str(it_rate, q931_information_transfer_rate_vals,
620 "Unknown (0x%02X)"));
624 if (it_rate == Q931_IT_RATE_MULTIRATE) {
627 proto_tree_add_text(tree, tvb, offset, 1, "Rate multiplier: %u", tvb_get_guint8(tvb, offset));
634 octet = tvb_get_guint8(tvb, offset);
635 if ((octet & 0x60) == 0x20) {
637 * Layer 1 information.
639 proto_tree_add_text(tree, tvb, offset, 1,
640 "User information layer 1 protocol: %s",
641 val_to_str(octet & 0x1F, q931_uil1_vals,
642 "Unknown (0x%02X)"));
646 if (octet & Q931_IE_VL_EXTENSION)
650 octet = tvb_get_guint8(tvb, offset);
651 proto_tree_add_text(tree, tvb, offset, 1,
653 (octet & 0x40) ? "Asynchronous" : "Synchronous");
654 proto_tree_add_text(tree, tvb, offset, 1,
655 "Layer 1 in-band negotiation is %spossible",
656 (octet & 0x20) ? "" : "not ");
657 proto_tree_add_text(tree, tvb, offset, 1,
659 val_to_str(octet & 0x1F, q931_l1_user_rate_vals,
660 "Unknown (0x%02X)"));
664 if (octet & Q931_IE_VL_EXTENSION)
668 octet = tvb_get_guint8(tvb, offset);
669 proto_tree_add_text(tree, tvb, offset, 1,
670 "Intermediate rate: %s",
671 val_to_str(octet & 0x60, q931_l1_intermediate_rate_vals,
673 proto_tree_add_text(tree, tvb, offset, 1,
674 "%s to send data with network independent clock",
675 (octet & 0x10) ? "Required" : "Not required");
676 proto_tree_add_text(tree, tvb, offset, 1,
677 "%s accept data with network independent clock",
678 (octet & 0x08) ? "Can" : "Cannot");
679 proto_tree_add_text(tree, tvb, offset, 1,
680 "%s to send data with flow control mechanism",
681 (octet & 0x04) ? "Required" : "Not required");
682 proto_tree_add_text(tree, tvb, offset, 1,
683 "%s accept data with flow control mechanism",
684 (octet & 0x02) ? "Can" : "Cannot");
688 if (octet & Q931_IE_VL_EXTENSION)
692 octet = tvb_get_guint8(tvb, offset);
693 proto_tree_add_text(tree, tvb, offset, 1,
694 "Rate adaption header %sincluded",
695 (octet & 0x40) ? "" : "not ");
696 proto_tree_add_text(tree, tvb, offset, 1,
697 "Multiple frame establishment %ssupported",
698 (octet & 0x20) ? "" : "not ");
699 proto_tree_add_text(tree, tvb, offset, 1,
700 "%s mode of operation",
701 (octet & 0x10) ? "Protocol sensitive" : "Bit transparent");
702 proto_tree_add_text(tree, tvb, offset, 1,
704 "Full protocol negotiation" : "LLI = 256 only");
705 proto_tree_add_text(tree, tvb, offset, 1,
706 "Message originator is %s",
707 (octet & 0x04) ? "Assignor only" : "Default assignee");
708 proto_tree_add_text(tree, tvb, offset, 1,
709 "Negotiation is done %s",
710 (octet & 0x02) ? "in-band" : "out-of-band");
714 if (octet & Q931_IE_VL_EXTENSION)
718 octet = tvb_get_guint8(tvb, offset);
719 proto_tree_add_text(tree, tvb, offset, 1,
721 val_to_str(octet & 0x60, q931_l1_stop_bits_vals,
723 proto_tree_add_text(tree, tvb, offset, 1,
725 val_to_str(octet & 0x18, q931_l1_data_bits_vals,
727 proto_tree_add_text(tree, tvb, offset, 1,
729 val_to_str(octet & 0x08, q931_l1_parity_vals,
732 if (octet & Q931_IE_VL_EXTENSION)
736 octet = tvb_get_guint8(tvb, offset);
737 proto_tree_add_text(tree, tvb, offset, 1,
739 (octet & 0x40) ? "Full" : "Half");
740 modem_type = octet & 0x3F;
741 if (modem_type <= 0x5 ||
742 (modem_type >= 0x20 && modem_type <= 0x2F)) {
743 proto_tree_add_text(tree, tvb, offset, 1,
744 "Modem type: National use 0x%02X", modem_type);
745 } else if (modem_type >= 0x30) {
746 proto_tree_add_text(tree, tvb, offset, 1,
747 "Modem type: User specified 0x%02X", modem_type);
749 proto_tree_add_text(tree, tvb, offset, 1,
751 val_to_str(modem_type, q931_l1_modem_type_vals,
752 "Unknown (0x%02X)"));
762 octet = tvb_get_guint8(tvb, offset);
763 if ((octet & 0x60) == 0x40) {
765 * Layer 2 information.
767 uil2_protocol = octet & 0x1F;
768 proto_tree_add_text(tree, tvb, offset, 1,
769 "User information layer 2 protocol: %s",
770 val_to_str(uil2_protocol, q931_uil2_vals,
771 "Unknown (0x%02X)"));
776 * XXX - only in Low-layer compatibility information element.
778 if (octet & Q931_IE_VL_EXTENSION)
782 octet = tvb_get_guint8(tvb, offset);
783 if (uil2_protocol == Q931_UIL2_USER_SPEC) {
784 proto_tree_add_text(tree, tvb, offset, 1,
785 "User-specified layer 2 protocol information: 0x%02X",
788 proto_tree_add_text(tree, tvb, offset, 1,
790 val_to_str(octet & 0x60, q931_mode_vals,
791 "Unknown (0x%02X)"));
796 if (octet & Q931_IE_VL_EXTENSION)
800 octet = tvb_get_guint8(tvb, offset);
801 proto_tree_add_text(tree, tvb, offset, 1,
802 "Window size: %u k", octet & 0x7F);
811 octet = tvb_get_guint8(tvb, offset);
812 if ((octet & 0x60) == 0x60) {
814 * Layer 3 information.
816 uil3_protocol = octet & 0x1F;
817 proto_tree_add_text(tree, tvb, offset, 1,
818 "User information layer 3 protocol: %s",
819 val_to_str(uil3_protocol, q931_uil3_vals,
820 "Unknown (0x%02X)"));
826 * XXX - only in Low-layer compatibility information element.
828 if (octet & Q931_IE_VL_EXTENSION)
832 octet = tvb_get_guint8(tvb, offset);
833 switch (uil3_protocol) {
835 case Q931_UIL3_X25_PL:
836 case Q931_UIL3_ISO_8208:
838 proto_tree_add_text(tree, tvb, offset, 1,
840 val_to_str(octet & 0x60, q931_mode_vals,
841 "Unknown (0x%02X)"));
845 if (octet & Q931_IE_VL_EXTENSION)
849 octet = tvb_get_guint8(tvb, offset);
850 proto_tree_add_text(tree, tvb, offset, 1,
851 "Default packet size: %u", octet & 0x0F);
855 if (octet & Q931_IE_VL_EXTENSION)
859 octet = tvb_get_guint8(tvb, offset);
860 proto_tree_add_text(tree, tvb, offset, 1,
861 "Packet window size: %u", octet & 0x7F);
866 case Q931_UIL3_USER_SPEC:
867 proto_tree_add_text(tree, tvb, offset, 1,
868 "Default packet size: %u octets",
869 1 << (octet & 0x0F));
874 case Q931_UIL3_TR_9577:
875 add_l3_info = (octet & 0x0F) << 4;
876 if (octet & Q931_IE_VL_EXTENSION)
880 octet = tvb_get_guint8(tvb, offset + 1);
881 add_l3_info |= (octet & 0x0F);
882 proto_tree_add_text(tree, tvb, offset, 2,
883 "Additional layer 3 protocol information: %s",
884 val_to_str(add_l3_info, nlpid_vals,
885 "Unknown (0x%02X)"));
896 * Dissect a Cause information element.
898 static const value_string q931_cause_coding_standard_vals[] = {
899 { 0x00, "ITU-T standardized coding" },
900 { 0x20, "ISO/IEC standard" },
901 { 0x40, "National standard" },
902 { 0x60, "Standard specific to identified location" },
906 static const value_string q931_cause_location_vals[] = {
907 { 0x00, "User (U)" },
908 { 0x01, "Private network serving the local user (LPN)" },
909 { 0x02, "Public network serving the local user (LN)" },
910 { 0x03, "Transit network (TN)" },
911 { 0x04, "Public network serving the remote user (RLN)" },
912 { 0x05, "Private network serving the remote user (RPN)" },
913 { 0x07, "International network (INTL)" },
914 { 0x0A, "Network beyond interworking point (BI)" },
918 static const value_string q931_cause_recommendation_vals[] = {
922 { 0x05, "Q.1031/Q.1051" },
927 * Cause codes for Cause.
929 static const value_string q931_cause_code_vals[] = {
930 { 0x00, "Valid cause code not yet received" },
931 { 0x01, "Unallocated (unassigned) number" },
932 { 0x02, "No route to specified transit network" },
933 { 0x03, "No route to destination" },
934 { 0x04, "Send special information tone" },
935 { 0x05, "Misdialled trunk prefix" },
936 { 0x06, "Channel unacceptable" },
937 { 0x07, "Call awarded and being delivered in an established channel" },
938 { 0x08, "Prefix 0 dialed but not allowed" },
939 { 0x09, "Prefix 1 dialed but not allowed" },
940 { 0x0A, "Prefix 1 dialed but not required" },
941 { 0x0B, "More digits received than allowed, call is proceeding" },
942 { 0x10, "Normal call clearing" },
943 { 0x11, "User busy" },
944 { 0x12, "No user responding" },
945 { 0x13, "No answer from user (user alerted)" },
946 { 0x14, "Subscriber absent" },
947 { 0x15, "Call rejected" },
948 { 0x16, "Number changed" },
949 { 0x17, "Reverse charging rejected" },
950 { 0x18, "Call suspended" },
951 { 0x19, "Call resumed" },
952 { 0x1A, "Non-selected user clearing" },
953 { 0x1B, "Destination out of order" },
954 { 0x1C, "Invalid number format (incomplete number)" },
955 { 0x1D, "Facility rejected" },
956 { 0x1E, "Response to STATUS ENQUIRY" },
957 { 0x1F, "Normal unspecified" },
958 { 0x21, "Circuit out of order" },
959 { 0x22, "No circuit/channel available" },
960 { 0x23, "Destination unattainable" },
961 { 0x25, "Degraded service" },
962 { 0x26, "Network out of order" },
963 { 0x27, "Transit delay range cannot be achieved" },
964 { 0x28, "Throughput range cannot be achieved" },
965 { 0x29, "Temporary failure" },
966 { 0x2A, "Switching equipment congestion" },
967 { 0x2B, "Access information discarded" },
968 { 0x2C, "Requested circuit/channel not available" },
969 { 0x2D, "Pre-empted" },
970 { 0x2E, "Precedence call blocked" },
971 { 0x2F, "Resources unavailable, unspecified" },
972 { 0x31, "Quality of service unavailable" },
973 { 0x32, "Requested facility not subscribed" },
974 { 0x33, "Reverse charging not allowed" },
975 { 0x34, "Outgoing calls barred" },
976 { 0x35, "Outgoing calls barred within CUG" },
977 { 0x36, "Incoming calls barred" },
978 { 0x37, "Incoming calls barred within CUG" },
979 { 0x38, "Call waiting not subscribed" },
980 { 0x39, "Bearer capability not authorized" },
981 { 0x3A, "Bearer capability not presently available" },
982 { 0x3E, "Inconsistency in designated outgoing access information and subscriber class" },
983 { 0x3F, "Service or option not available, unspecified" },
984 { 0x41, "Bearer capability not implemented" },
985 { 0x42, "Channel type not implemented" },
986 { 0x43, "Transit network selection not implemented" },
987 { 0x44, "Message not implemented" },
988 { 0x45, "Requested facility not implemented" },
989 { 0x46, "Only restricted digital information bearer capability is available" },
990 { 0x4F, "Service or option not implemented, unspecified" },
991 { 0x51, "Invalid call reference value" },
992 { 0x52, "Identified channel does not exist" },
993 { 0x53, "Call identity does not exist for suspended call" },
994 { 0x54, "Call identity in use" },
995 { 0x55, "No call suspended" },
996 { 0x56, "Call having the requested call identity has been cleared" },
997 { 0x57, "Called user not member of CUG" },
998 { 0x58, "Incompatible destination" },
999 { 0x59, "Non-existent abbreviated address entry" },
1000 { 0x5A, "Destination address missing, and direct call not subscribed" },
1001 { 0x5B, "Invalid transit network selection (national use)" },
1002 { 0x5C, "Invalid facility parameter" },
1003 { 0x5D, "Mandatory information element is missing" },
1004 { 0x5F, "Invalid message, unspecified" },
1005 { 0x60, "Mandatory information element is missing" },
1006 { 0x61, "Message type non-existent or not implemented" },
1007 { 0x62, "Message not compatible with call state or message type non-existent or not implemented" },
1008 { 0x63, "Information element nonexistant or not implemented" },
1009 { 0x64, "Invalid information element contents" },
1010 { 0x65, "Message not compatible with call state" },
1011 { 0x66, "Recovery on timer expiry" },
1012 { 0x67, "Parameter non-existent or not implemented - passed on" },
1013 { 0x6E, "Message with unrecognized parameter discarded" },
1014 { 0x6F, "Protocol error, unspecified" },
1015 { 0x7F, "Internetworking, unspecified" },
1020 dissect_q931_cause_ie(tvbuff_t *tvb, int offset, int len,
1024 guint8 coding_standard;
1028 octet = tvb_get_guint8(tvb, offset);
1029 coding_standard = octet & 0x60;
1030 proto_tree_add_text(tree, tvb, offset, 1,
1031 "Coding standard: %s",
1032 val_to_str(coding_standard, q931_cause_coding_standard_vals, NULL));
1033 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1035 * We don't know how the cause is encoded,
1036 * so just dump it as data and be done with it.
1038 proto_tree_add_text(tree, tvb, offset,
1040 tvb_bytes_to_str(tvb, offset, len));
1043 proto_tree_add_text(tree, tvb, offset, 1,
1045 val_to_str(octet & 0x0F, q931_cause_location_vals,
1050 if (!(octet & Q931_IE_VL_EXTENSION)) {
1053 octet = tvb_get_guint8(tvb, offset);
1054 proto_tree_add_text(tree, tvb, offset, 1,
1055 "Recommendation: %s",
1056 val_to_str(octet & 0x7F, q931_cause_recommendation_vals,
1057 "Unknown (0x%02X)"));
1064 octet = tvb_get_guint8(tvb, offset);
1065 proto_tree_add_text(tree, tvb, offset, 1,
1067 val_to_str(octet & 0x7F, q931_cause_code_vals,
1068 "Unknown (0x%02X)"));
1074 proto_tree_add_text(tree, tvb, offset, len,
1076 tvb_bytes_to_str(tvb, offset, len));
1080 * Dissect a Call state information element.
1082 static const value_string q931_coding_standard_vals[] = {
1083 { 0x00, "ITU-T standardized coding" },
1084 { 0x20, "ISO/IEC standard" },
1085 { 0x40, "National standard" },
1086 { 0x60, "Standard defined for the network" },
1090 static const value_string q931_call_state_vals[] = {
1092 { 0x01, "Call initiated" },
1093 { 0x02, "Overlap sending" },
1094 { 0x03, "Outgoing call proceeding" },
1095 { 0x04, "Call delivered" },
1096 { 0x06, "Call present" },
1097 { 0x07, "Call received" },
1098 { 0x09, "Connect request" },
1099 { 0x0A, "Incoming call proceeding" },
1101 { 0x0C, "Disconnect request" },
1102 { 0x0F, "Disconnect indication" },
1103 { 0x11, "Suspend request" },
1104 { 0x13, "Resume request" },
1105 { 0x16, "Release request" },
1106 { 0x19, "Overlap receiving" },
1107 { 0x3D, "Restart request" },
1108 { 0x3E, "Restart" },
1113 dissect_q931_call_state_ie(tvbuff_t *tvb, int offset, int len,
1117 guint8 coding_standard;
1121 octet = tvb_get_guint8(tvb, offset);
1122 coding_standard = octet & 0x60;
1123 proto_tree_add_text(tree, tvb, offset, 1,
1124 "Coding standard: %s",
1125 val_to_str(coding_standard, q931_coding_standard_vals, NULL));
1126 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1128 * We don't know how the call state is encoded,
1129 * so just dump it as data and be done with it.
1131 proto_tree_add_text(tree, tvb, offset,
1133 tvb_bytes_to_str(tvb, offset, len));
1136 proto_tree_add_text(tree, tvb, offset, 1,
1138 val_to_str(octet & 0x3F, q931_call_state_vals,
1139 "Unknown (0x%02X)"));
1143 * Dissect a Channel identification information element.
1145 #define Q931_INTERFACE_IDENTIFIED 0x40
1146 #define Q931_NOT_BASIC_CHANNEL 0x20
1148 static const value_string q931_basic_channel_selection_vals[] = {
1149 { 0x00, "No channel" },
1150 { 0x01, "B1 channel" },
1151 { 0x02, "B2 channel" },
1152 { 0x03, "Any channel" },
1156 static const value_string q931_not_basic_channel_selection_vals[] = {
1157 { 0x00, "No channel" },
1158 { 0x01, "Channel indicated in following octets" },
1159 { 0x03, "Any channel" },
1163 #define Q931_IS_SLOT_MAP 0x10
1165 static const value_string q931_element_type_vals[] = {
1166 { 0x03, "B-channel units" },
1167 { 0x06, "H0-channel units" },
1168 { 0x08, "H11-channel units" },
1169 { 0x09, "H12-channel units" },
1174 dissect_q931_channel_identification_ie(tvbuff_t *tvb, int offset, int len,
1178 int identifier_offset;
1180 guint8 coding_standard;
1184 octet = tvb_get_guint8(tvb, offset);
1185 proto_tree_add_text(tree, tvb, offset, 1,
1186 "Interface %s identified",
1187 (octet & Q931_INTERFACE_IDENTIFIED) ? "explicitly" : "implicitly");
1188 proto_tree_add_text(tree, tvb, offset, 1,
1190 (octet & Q931_NOT_BASIC_CHANNEL) ? "Not basic" : "Basic");
1191 proto_tree_add_text(tree, tvb, offset, 1,
1192 "Indicated channel is %s",
1193 (octet & 0x08) ? "required" : "preferred");
1194 proto_tree_add_text(tree, tvb, offset, 1,
1195 "Indicated channel is %sthe D-channel",
1196 (octet & 0x04) ? "" : "not ");
1197 if (octet & Q931_NOT_BASIC_CHANNEL) {
1198 proto_tree_add_text(tree, tvb, offset, 1,
1199 "Channel selection: %s",
1200 val_to_str(octet & 0x03, q931_not_basic_channel_selection_vals,
1203 proto_tree_add_text(tree, tvb, offset, 1,
1204 "Channel selection: %s",
1205 val_to_str(octet & 0x03, q931_basic_channel_selection_vals,
1211 if (octet & Q931_INTERFACE_IDENTIFIED) {
1212 identifier_offset = offset;
1217 octet = tvb_get_guint8(tvb, offset);
1221 } while (!(octet & Q931_IE_VL_EXTENSION));
1224 * XXX - do we want to strip off the 8th bit on the
1225 * last octet of the interface identifier?
1227 if (identifier_len != 0) {
1228 proto_tree_add_text(tree, tvb, identifier_offset,
1229 identifier_len, "Interface identifier: %s",
1231 tvb_get_ptr(tvb, identifier_offset, identifier_len),
1236 if (octet & Q931_NOT_BASIC_CHANNEL) {
1239 octet = tvb_get_guint8(tvb, offset);
1240 coding_standard = octet & 0x60;
1241 proto_tree_add_text(tree, tvb, offset, 1,
1242 "Coding standard: %s",
1243 val_to_str(coding_standard, q931_coding_standard_vals,
1245 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1247 * We don't know how the channel identifier is
1248 * encoded, so just dump it as data and be done
1251 proto_tree_add_text(tree, tvb, offset,
1253 tvb_bytes_to_str(tvb, offset, len));
1256 proto_tree_add_text(tree, tvb, offset, 1,
1257 "Channel is indicated by %s",
1258 (octet & Q931_IS_SLOT_MAP) ? "slot map" : "number");
1259 proto_tree_add_text(tree, tvb, offset, 1,
1261 (octet & Q931_IS_SLOT_MAP) ? "Map element" : "Channel",
1262 val_to_str(octet & 0x0F, q931_element_type_vals,
1263 "Unknown (0x%02X)"));
1266 * XXX - dump the channel number or slot map.
1272 * Dissect a Progress indicator information element.
1274 static const value_string q931_progress_description_vals[] = {
1275 { 0x01, "Call is not end-to-end ISDN - progress information available in-band" },
1276 { 0x02, "Destination address is non-ISDN" },
1277 { 0x03, "Origination address is non-ISDN" },
1278 { 0x04, "Call has returned to the ISDN" },
1279 { 0x05, "Interworking has occurred and has resulted in a telecommunications service change" },
1280 { 0x08, "In-band information or an appropriate pattern is now available" },
1285 dissect_q931_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
1289 guint8 coding_standard;
1293 octet = tvb_get_guint8(tvb, offset);
1294 coding_standard = octet & 0x60;
1295 proto_tree_add_text(tree, tvb, offset, 1,
1296 "Coding standard: %s",
1297 val_to_str(coding_standard, q931_cause_coding_standard_vals, NULL));
1298 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1300 * We don't know how the progress indicator is encoded,
1301 * so just dump it as data and be done with it.
1303 proto_tree_add_text(tree, tvb, offset,
1305 tvb_bytes_to_str(tvb, offset, len));
1308 proto_tree_add_text(tree, tvb, offset, 1,
1310 val_to_str(octet & 0x0F, q931_cause_location_vals,
1317 octet = tvb_get_guint8(tvb, offset);
1318 proto_tree_add_text(tree, tvb, offset, 1,
1319 "Progress description: %s",
1320 val_to_str(octet & 0x7F, q931_progress_description_vals,
1321 "Unknown (0x%02X)"));
1325 * Dissect a Network-specific facilities or Transit network selection
1326 * information element.
1328 static const value_string q931_netid_type_vals[] = {
1329 { 0x00, "User specified" },
1330 { 0x20, "National network identification" },
1331 { 0x30, "International network identification" },
1335 static const value_string q931_netid_plan_vals[] = {
1336 { 0x00, "Unknown" },
1337 { 0x01, "Carrier Identification Code" },
1338 { 0x03, "X.121 data network identification code" },
1343 dissect_q931_ns_facilities_ie(tvbuff_t *tvb, int offset, int len,
1351 octet = tvb_get_guint8(tvb, offset);
1352 netid_len = octet & 0x7F;
1353 proto_tree_add_text(tree, tvb, offset, 1,
1354 "Network identification length: %u",
1358 if (netid_len != 0) {
1361 octet = tvb_get_guint8(tvb, offset);
1362 proto_tree_add_text(tree, tvb, offset, 1,
1363 "Type of network identification: %s",
1364 val_to_str(octet & 0x70, q931_netid_type_vals,
1365 "Unknown (0x%02X)"));
1366 proto_tree_add_text(tree, tvb, offset, 1,
1367 "Network identification plan: %s",
1368 val_to_str(octet & 0x0F, q931_netid_plan_vals,
1369 "Unknown (0x%02X)"));
1376 if (netid_len > len)
1378 if (netid_len != 0) {
1379 proto_tree_add_text(tree, tvb, offset, netid_len,
1380 "Network identification: %s",
1381 tvb_format_text(tvb, offset, netid_len));
1382 offset += netid_len;
1388 * Whatever is left is the network-specific facility
1393 proto_tree_add_text(tree, tvb, offset,
1394 len, "Network-specific facility specification: %s",
1395 tvb_bytes_to_str(tvb, offset, len));
1399 * Dissect a Notification indicator information element.
1401 static const value_string q931_notification_description_vals[] = {
1402 { 0x00, "User suspended" },
1403 { 0x01, "User resumed" },
1404 { 0x02, "Bearer service change" },
1409 dissect_q931_notification_indicator_ie(tvbuff_t *tvb, int offset, int len,
1416 octet = tvb_get_guint8(tvb, offset);
1417 proto_tree_add_text(tree, tvb, offset, 1,
1418 "Notification description: %s",
1419 val_to_str(octet & 0x7F, q931_notification_description_vals,
1420 "Unknown (0x%02X)"));
1424 * Dissect a Date/time information element.
1427 dissect_q931_date_time_ie(tvbuff_t *tvb, int offset, int len,
1431 proto_tree_add_text(tree, tvb, offset, len,
1432 "Date/time: length is %d, should be 6\n", len);
1436 * XXX - what is "year" relative to? Is "month" 0-origin or
1437 * 1-origin? Q.931 doesn't say....
1439 proto_tree_add_text(tree, tvb, offset, 6,
1440 "Date/time: %02u-%02u-%02u %02u:%02u:%02u",
1441 tvb_get_guint8(tvb, offset + 0), tvb_get_guint8(tvb, offset + 1), tvb_get_guint8(tvb, offset + 2),
1442 tvb_get_guint8(tvb, offset + 3), tvb_get_guint8(tvb, offset + 4), tvb_get_guint8(tvb, offset + 5));
1446 * Dissect a Signal information element.
1448 static const value_string q931_signal_vals[] = {
1449 { 0x00, "Dial tone on" },
1450 { 0x01, "Ring tone on" },
1451 { 0x02, "Intercept tone on" },
1452 { 0x03, "Network congestion tone on" }, /* "fast busy" */
1453 { 0x04, "Busy tone on" },
1454 { 0x05, "Confirm tone on" },
1455 { 0x06, "Answer tone on" },
1456 { 0x07, "Call waiting tone on" },
1457 { 0x08, "Off-hoke warning tone on" },
1458 { 0x09, "Preemption tone on" },
1459 { 0x3F, "Tones off" },
1460 { 0x40, "Alerting on - pattern 0" },
1461 { 0x41, "Alerting on - pattern 1" },
1462 { 0x42, "Alerting on - pattern 2" },
1463 { 0x43, "Alerting on - pattern 3" },
1464 { 0x44, "Alerting on - pattern 4" },
1465 { 0x45, "Alerting on - pattern 5" },
1466 { 0x46, "Alerting on - pattern 6" },
1467 { 0x47, "Alerting on - pattern 7" },
1468 { 0x4F, "Alerting off" },
1473 dissect_q931_signal_ie(tvbuff_t *tvb, int offset, int len,
1477 proto_tree_add_text(tree, tvb, offset, len,
1478 "Signal: length is %d, should be 1\n", len);
1481 proto_tree_add_text(tree, tvb, offset, 1,
1483 val_to_str(tvb_get_guint8(tvb, offset), q931_signal_vals,
1484 "Unknown (0x%02X)"));
1488 * Dissect an Information rate information element.
1490 static const value_string q931_throughput_class_vals[] = {
1491 { 0x03, "75 bit/s" },
1492 { 0x04, "150 bit/s" },
1493 { 0x05, "300 bit/s" },
1494 { 0x06, "600 bit/s" },
1495 { 0x07, "1200 bit/s" },
1496 { 0x08, "2400 bit/s" },
1497 { 0x09, "4800 bit/s" },
1498 { 0x0A, "9600 bit/s" },
1499 { 0x0B, "19200 bit/s" },
1500 { 0x0C, "48000 bit/s" },
1501 { 0x0D, "64000 bit/s" },
1506 dissect_q931_information_rate_ie(tvbuff_t *tvb, int offset, int len,
1510 proto_tree_add_text(tree, tvb, offset, len,
1511 "Information rate: length is %d, should be 4\n", len);
1514 proto_tree_add_text(tree, tvb, offset + 0, 1,
1515 "Incoming information rate: %s",
1516 val_to_str(tvb_get_guint8(tvb, offset + 0) & 0x1F,
1517 q931_throughput_class_vals, "Unknown (0x%02X)"));
1518 proto_tree_add_text(tree, tvb, offset + 1, 1,
1519 "Outgoing information rate: %s",
1520 val_to_str(tvb_get_guint8(tvb, offset + 1) & 0x1F,
1521 q931_throughput_class_vals, "Unknown (0x%02X)"));
1522 proto_tree_add_text(tree, tvb, offset + 2, 1,
1523 "Minimum incoming information rate: %s",
1524 val_to_str(tvb_get_guint8(tvb, offset + 2) & 0x1F,
1525 q931_throughput_class_vals, "Unknown (0x%02X)"));
1526 proto_tree_add_text(tree, tvb, offset + 3, 1,
1527 "Minimum outgoing information rate: %s",
1528 val_to_str(tvb_get_guint8(tvb, offset + 3) & 0x1F,
1529 q931_throughput_class_vals, "Unknown (0x%02X)"));
1533 dissect_q931_guint16_value(tvbuff_t *tvb, int offset, int len,
1534 proto_tree *tree, char *label)
1542 octet = tvb_get_guint8(tvb, offset);
1543 if (octet & Q931_IE_VL_EXTENSION) {
1545 * Only one octet long - error.
1549 value = (octet & 0x3) << 14;
1556 * We've reached the end of the information element - error.
1560 octet = tvb_get_guint8(tvb, offset);
1561 if (octet & Q931_IE_VL_EXTENSION) {
1563 * Only two octets long - error.
1567 value |= (octet & 0x7F) << 7;
1574 * We've reached the end of the information element - error.
1578 octet = tvb_get_guint8(tvb, offset);
1579 if (!(octet & Q931_IE_VL_EXTENSION)) {
1581 * More than three octets long - error.
1585 value |= (octet & 0x7F);
1590 proto_tree_add_text(tree, tvb, offset, value_len, "%s: %u ms", label,
1595 proto_tree_add_text(tree, tvb, offset, len,
1596 "%s goes past end of information element", label);
1600 proto_tree_add_text(tree, tvb, offset, len, "%s isn't 3 octets long",
1606 * Dissect an End-to-end transit delay information element.
1609 dissect_q931_e2e_transit_delay_ie(tvbuff_t *tvb, int offset, int len,
1616 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1617 "Cumulative transit delay");
1620 offset += value_len;
1625 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1626 "Requested end-to-end transit delay");
1629 offset += value_len;
1634 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1635 "Maximum end-to-end transit delay");
1639 * Dissect a Transit delay selection and indication information element.
1642 dissect_q931_td_selection_and_int_ie(tvbuff_t *tvb, int offset, int len,
1647 dissect_q931_guint16_value(tvb, offset, len, tree,
1652 * Dissect a Packet layer binary parameters information element.
1654 static const value_string q931_fast_selected_vals[] = {
1655 { 0x00, "Fast select not requested" },
1656 { 0x08, "Fast select not requested" },
1657 { 0x10, "Fast select requested with no restriction of response" },
1658 { 0x18, "Fast select requested with restrictions of response" },
1663 dissect_q931_pl_binary_parameters_ie(tvbuff_t *tvb, int offset, int len,
1670 octet = tvb_get_guint8(tvb, offset);
1671 proto_tree_add_text(tree, tvb, offset, 1,
1673 val_to_str(octet & 0x18, q931_fast_selected_vals, NULL));
1674 proto_tree_add_text(tree, tvb, offset, 1,
1676 (octet & 0x04) ? "No request/request denied" :
1677 "Request indicated/request accepted");
1678 proto_tree_add_text(tree, tvb, offset, 1,
1680 (octet & 0x02) ? "Link-by-link" : "End-to-end");
1681 proto_tree_add_text(tree, tvb, offset, 1,
1682 "Modulus %u sequencing",
1683 (octet & 0x01) ? 8 : 128);
1687 * Dissect a Packet layer window size information element.
1690 dissect_q931_pl_window_size_ie(tvbuff_t *tvb, int offset, int len,
1695 proto_tree_add_text(tree, tvb, offset, 1,
1696 "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1702 proto_tree_add_text(tree, tvb, offset, 1,
1703 "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1707 * Dissect a Packet size information element.
1710 dissect_q931_packet_size_ie(tvbuff_t *tvb, int offset, int len,
1715 proto_tree_add_text(tree, tvb, offset, 1,
1716 "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1722 proto_tree_add_text(tree, tvb, offset, 1,
1723 "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1727 * Dissect a Closed user group information element.
1729 static const value_string q931_cug_indication_vals[] = {
1730 { 0x01, "Closed user group selection" },
1731 { 0x02, "Closed user group with outgoing access selection and indication" },
1736 dissect_q931_cug_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree)
1740 proto_tree_add_text(tree, tvb, offset, 1,
1741 "CUG indication: %s",
1742 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1743 q931_cug_indication_vals, "Unknown (0x%02X)"));
1749 proto_tree_add_text(tree, tvb, offset, len, "CUG index code: %s",
1750 tvb_format_text(tvb, offset, len));
1754 * Dissect a Reverse charging indication information element.
1756 static const value_string q931_reverse_charging_indication_vals[] = {
1757 { 0x01, "Reverse charging requested" },
1762 dissect_q931_reverse_charge_ind_ie(tvbuff_t *tvb, int offset, int len,
1767 proto_tree_add_text(tree, tvb, offset, 1,
1768 "Reverse charging indication: %s",
1769 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1770 q931_reverse_charging_indication_vals, "Unknown (0x%02X)"));
1774 * Dissect a (phone) number information element.
1776 static const value_string q931_number_type_vals[] = {
1777 { 0x00, "Unknown" },
1778 { 0x10, "International number" },
1779 { 0x20, "National number" },
1780 { 0x30, "Network specific number" },
1781 { 0x40, "Subscriber number" },
1782 { 0x60, "Abbreviated number" },
1786 static const value_string q931_numbering_plan_vals[] = {
1787 { 0x00, "Unknown" },
1788 { 0x01, "E.164 ISDN/telephony numbering" },
1789 { 0x03, "X.121 data numbering" },
1790 { 0x04, "F.69 Telex numbering" },
1791 { 0x08, "National standard numbering" },
1792 { 0x09, "Private numbering" },
1796 static const value_string q931_presentation_indicator_vals[] = {
1797 { 0x00, "Presentation allowed" },
1798 { 0x20, "Presentation restricted" },
1799 { 0x40, "Number not available due to interworking" },
1803 static const value_string q931_screening_indicator_vals[] = {
1804 { 0x00, "User-provided, not screened" },
1805 { 0x01, "User-provided, verified and passed" },
1806 { 0x02, "User-provided, verified and failed" },
1807 { 0x03, "Network-provided" },
1811 static const value_string q931_redirection_reason_vals[] = {
1812 { 0x00, "Unknown" },
1813 { 0x01, "Call forwarding busy or called DTE busy" },
1814 { 0x02, "Call forwarding no reply" },
1815 { 0x04, "Call deflection" },
1816 { 0x09, "Called DTE out of order" },
1817 { 0x0A, "Call forwarding by the called DTE" },
1818 { 0x0F, "Call forwarding unconditional or systematic call redirection" },
1823 dissect_q931_number_ie(tvbuff_t *tvb, int offset, int len,
1830 octet = tvb_get_guint8(tvb, offset);
1831 proto_tree_add_text(tree, tvb, offset, 1,
1832 "Type of number: %s",
1833 val_to_str(octet & 0x70, q931_number_type_vals,
1834 "Unknown (0x%02X)"));
1835 proto_tree_add_text(tree, tvb, offset, 1,
1836 "Numbering plan: %s",
1837 val_to_str(octet & 0x0F, q931_numbering_plan_vals,
1838 "Unknown (0x%02X)"));
1842 if (!(octet & Q931_IE_VL_EXTENSION)) {
1845 octet = tvb_get_guint8(tvb, offset);
1846 proto_tree_add_text(tree, tvb, offset, 1,
1847 "Presentation indicator: %s",
1848 val_to_str(octet & 0x60, q931_presentation_indicator_vals,
1850 proto_tree_add_text(tree, tvb, offset, 1,
1851 "Screening indicator: %s",
1852 val_to_str(octet & 0x03, q931_screening_indicator_vals,
1859 * XXX - only in a Redirecting number information element.
1861 if (!(octet & Q931_IE_VL_EXTENSION)) {
1864 octet = tvb_get_guint8(tvb, offset);
1865 proto_tree_add_text(tree, tvb, offset, 1,
1866 "Reason for redirection: %s",
1867 val_to_str(octet & 0x0F, q931_redirection_reason_vals,
1875 proto_tree_add_text(tree, tvb, offset, len, "Number: %s",
1876 tvb_format_text(tvb, offset, len));
1880 * Dissect a party subaddress information element.
1882 static const value_string q931_subaddress_type_vals[] = {
1883 { 0x00, "X.213/ISO 8348 Add.2 NSAP" },
1884 { 0x20, "User-specified" },
1888 static const value_string q931_odd_even_indicator_vals[] = {
1889 { 0x00, "Even number of address signals" },
1890 { 0x10, "Odd number of address signals" },
1895 dissect_q931_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
1902 octet = tvb_get_guint8(tvb, offset);
1903 proto_tree_add_text(tree, tvb, offset, 1,
1904 "Type of subaddress: %s",
1905 val_to_str(octet & 0x70, q931_subaddress_type_vals,
1906 "Unknown (0x%02X)"));
1907 proto_tree_add_text(tree, tvb, offset, 1,
1908 "Odd/even indicator: %s",
1909 val_to_str(octet & 0x10, q931_odd_even_indicator_vals,
1916 proto_tree_add_text(tree, tvb, offset, len, "Subaddress: %s",
1917 tvb_bytes_to_str(tvb, offset, len));
1921 * Dissect a Restart indicator information element.
1923 static const value_string q931_restart_indicator_class_vals[] = {
1924 { 0x00, "Indicated channels" },
1925 { 0x06, "Single interface" },
1926 { 0x07, "All interfaces" },
1931 dissect_q931_restart_indicator_ie(tvbuff_t *tvb, int offset, int len,
1935 proto_tree_add_text(tree, tvb, offset, len,
1936 "Restart indicator: length is %d, should be 1\n", len);
1939 proto_tree_add_text(tree, tvb, offset, 1,
1940 "Restart indicator: %s",
1941 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1942 q931_restart_indicator_class_vals, "Unknown (0x%02X)"));
1946 * Dissect a High-layer compatibility information element.
1948 #define Q931_AUDIOVISUAL 0x60
1949 static const value_string q931_high_layer_characteristics_vals[] = {
1950 { 0x01, "Telephony" },
1951 { 0x04, "F.182 Facsimile Group 2/3" },
1952 { 0x21, "F.184 Facsimile Group 4 Class I" },
1953 { 0x24, "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
1954 { 0x28, "F.220 Teletex, basic and processable mode" },
1955 { 0x31, "F.200 Teletex, basic mode" },
1956 { 0x32, "F.300 and T.102 syntax-based Videotex" },
1957 { 0x33, "F.300 and T.101 international Videotex interworking" },
1958 { 0x35, "F.60 Telex" },
1959 { 0x38, "X.400 Message Handling Systems" },
1960 { 0x41, "X.200 OSI application" },
1961 { 0x42, "FTAM application" },
1962 { 0x5E, "Reserved for maintenance" },
1963 { 0x5F, "Reserved for management" },
1964 { Q931_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
1965 { 0x61, "F.702 and F.731 Profile 1b videoconferencing" },
1966 { 0x62, "F.702 and F.731 audiographic conferencing" },
1970 static const value_string q931_audiovisual_characteristics_vals[] = {
1971 { 0x01, "Capability set of initial channel of H.221" },
1972 { 0x02, "Capability set of subsequent channel of H.221" },
1973 { 0x21, "Capability set of initial channel of an active 3.1kHz audio or speech call" },
1978 dissect_q931_high_layer_compat_ie(tvbuff_t *tvb, int offset, int len,
1982 guint8 coding_standard;
1983 guint8 characteristics;
1987 octet = tvb_get_guint8(tvb, offset);
1988 coding_standard = octet & 0x60;
1989 proto_tree_add_text(tree, tvb, offset, 1,
1990 "Coding standard: %s",
1991 val_to_str(coding_standard, q931_coding_standard_vals, NULL));
1992 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1994 * We don't know how the call state is encoded,
1995 * so just dump it as data and be done with it.
1997 proto_tree_add_text(tree, tvb, offset,
1999 tvb_bytes_to_str(tvb, offset, len));
2005 octet = tvb_get_guint8(tvb, offset);
2006 characteristics = octet & 0x7F;
2007 proto_tree_add_text(tree, tvb, offset, 1,
2008 "High layer characteristics identification: %s",
2009 val_to_str(characteristics, q931_high_layer_characteristics_vals,
2010 "Unknown (0x%02X)"));
2014 if (!(octet & Q931_IE_VL_EXTENSION)) {
2017 octet = tvb_get_guint8(tvb, offset);
2018 if (characteristics == Q931_AUDIOVISUAL) {
2019 proto_tree_add_text(tree, tvb, offset, 1,
2020 "Extended audiovisual characteristics identification: %s",
2021 val_to_str(octet & 0x7F,
2022 q931_audiovisual_characteristics_vals,
2023 "Unknown (0x%02X)"));
2025 proto_tree_add_text(tree, tvb, offset, 1,
2026 "Extended high layer characteristics identification: %s",
2027 val_to_str(octet & 0x7F,
2028 q931_high_layer_characteristics_vals,
2029 "Unknown (0x%02X)"));
2036 * Dissect a User-user information element.
2038 #define Q931_PROTOCOL_DISCRIMINATOR_IA5 0x04
2040 static const value_string q931_protocol_discriminator_vals[] = {
2041 { 0x00, "User-specific protocol" },
2042 { 0x01, "OSI high layer protocols" },
2044 { Q931_PROTOCOL_DISCRIMINATOR_IA5, "IA5 characters" },
2045 { 0x05, "X.208 and X.209 coded user information" },
2046 { 0x07, "V.120 rate adaption" },
2047 { 0x08, "Q.931/I.451 user-network call control messages" },
2052 dissect_q931_user_user_ie(tvbuff_t *tvb, int offset, int len,
2059 octet = tvb_get_guint8(tvb, offset);
2060 proto_tree_add_text(tree, tvb, offset, 1,
2061 "Protocol discriminator: %s",
2062 val_to_str(octet, q931_protocol_discriminator_vals,
2063 "Unknown (0x%02x)"));
2071 case Q931_PROTOCOL_DISCRIMINATOR_IA5:
2072 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
2073 tvb_format_text(tvb, offset, len));
2077 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
2078 tvb_bytes_to_str(tvb, offset, len));
2084 * Dissect information elements consisting of ASCII^H^H^H^H^HIA5 text.
2087 dissect_q931_ia5_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
2091 proto_tree_add_text(tree, tvb, offset, len, "%s: %s", label,
2092 tvb_format_text(tvb, offset, len));
2096 static const value_string q931_codeset_vals[] = {
2097 { 0x00, "Q.931 information elements" },
2098 { 0x04, "Information elements for ISO/IEC use" },
2099 { 0x05, "Information elements for national use" },
2100 { 0x06, "Information elements specific to the local network" },
2101 { 0x07, "User-specific information elements" },
2106 q931_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2107 gboolean started_heuristic)
2110 guint reported_length;
2111 proto_tree *q931_tree = NULL;
2113 proto_tree *ie_tree;
2114 guint8 call_ref_len;
2115 guint8 call_ref[15];
2116 guint8 message_type;
2117 guint8 info_element;
2118 guint16 info_element_len;
2120 gboolean non_locking_shift;
2121 guint8 protocol_discriminator;
2125 gboolean is_h323_h225 = FALSE;
2127 * It is very much possible to find a TPKT header here
2128 * TPKT is defined in RFC 1009 as a wrapper around ISO
2129 * defined protocols. There could even be several TPKT
2130 * wrapped messages in one TCP data field...
2131 * XXXXXXXX THIS IS NOT IMPLEMENTED YET!!! XXXXXXXXXXX
2133 * For Q.931 related messages this is easy. If a
2134 * protocol discriminator is found with a value of 3
2135 * and it's the first discriminator in the Q.931
2136 * message one can safely assume it to be a TPKT
2137 * header. See also Q.931 Table 4-1/Q.931
2141 protocol_discriminator = tvb_get_guint8( tvb, offset );
2142 /* Keep the protocol discriminator for later use */
2145 if ( started_heuristic ) {
2147 * The heuristic Q.931 message should conform to this
2149 if ( protocol_discriminator != NLPID_Q_931 )
2152 if ( ! is_tpkt( tvb, &offset ) )
2155 if ( tvb_length_remaining( tvb, offset ) <= 3 )
2160 * The first byte should be < 8 (3 is TPKT, rest is Q.931)
2162 if ( protocol_discriminator < 8 ) {
2164 * The minimum length of a Q.931 message is 3:
2165 * 1 byte for the protocol discriminator,
2166 * 1 for the call_reference length,
2167 * and one for the message type.
2169 if ( tvb_length_remaining( tvb, offset ) <= 3 )
2173 * OK, there are a couple of bytes available, but is there
2174 * also a protocol discriminator?
2176 if ( tvb_length_remaining( tvb, offset ) > 3 ) {
2177 /* Reread the protocol discriminator */
2178 protocol_discriminator =
2179 tvb_get_guint8( tvb, offset + 4);
2181 /* No discriminator available */
2182 protocol_discriminator = 0;
2186 * If it's not H.323 related Q.931 no heuristic action needed
2187 * Dangerous, there might be other uses for this code.....
2189 if ( ( started_heuristic ) && (protocol_discriminator != 8 ) )
2193 * Always check if it's a real TPKT message
2195 if ( ! is_tpkt( tvb, &offset ) )
2198 dissect_tpkt( tvb, &offset, pinfo, tree );
2201 * Reset the current_proto variable because dissect_tpkt
2204 if ( started_heuristic )
2205 pinfo->current_proto = "Q.931 HEUR";
2207 pinfo->current_proto = "Q.931";
2212 * The minimum length of a Q.931 message is
2213 * 3, 1 byte for the protocol discr. 1 for the call_reference length,
2214 * and one for the message type.
2216 if ( tvb_length_remaining( tvb, offset ) <= 3 ) {
2220 if (check_col(pinfo->fd, COL_PROTOCOL))
2221 col_set_str(pinfo->fd, COL_PROTOCOL, "Q.931");
2224 ti = proto_tree_add_item(tree, proto_q931, tvb, offset,
2225 tvb_length(tvb), FALSE);
2226 q931_tree = proto_item_add_subtree(ti, ett_q931);
2228 dissect_q931_protocol_discriminator( tvb, offset, q931_tree );
2231 call_ref_len = tvb_get_guint8(tvb, offset) & 0xF; /* XXX - do as a bit field? */
2232 if (q931_tree != NULL)
2233 proto_tree_add_uint(q931_tree, hf_q931_call_ref_len, tvb, offset, 1, call_ref_len);
2235 if (call_ref_len != 0) {
2236 /* XXX - split this into flag and value */
2237 tvb_memcpy(tvb, call_ref, offset, call_ref_len);
2238 if (q931_tree != NULL)
2239 proto_tree_add_bytes(q931_tree, hf_q931_call_ref, tvb, offset, call_ref_len, call_ref);
2240 offset += call_ref_len;
2242 message_type = tvb_get_guint8(tvb, offset);
2243 if (check_col(pinfo->fd, COL_INFO)) {
2244 col_add_str(pinfo->fd, COL_INFO,
2245 val_to_str(message_type, q931_message_type_vals,
2246 "Unknown message type (0x%02X)"));
2248 if (q931_tree != NULL)
2249 proto_tree_add_uint(q931_tree, hf_q931_message_type, tvb, offset, 1, message_type);
2253 * And now for the information elements....
2255 codeset = 0; /* start out in codeset 0 */
2256 non_locking_shift = TRUE;
2257 reported_length = tvb_reported_length(tvb);
2258 while (offset < reported_length) {
2259 info_element = tvb_get_guint8(tvb, offset);
2262 * Check for the single-octet IEs.
2264 switch (info_element & Q931_IE_SO_IDENTIFIER_MASK) {
2268 !(info_element & Q931_IE_SHIFT_LOCKING);
2269 codeset = info_element & Q931_IE_SHIFT_CODESET;
2270 if (q931_tree != NULL) {
2271 proto_tree_add_text(q931_tree, tvb, offset, 1,
2272 "%s shift to codeset %u: %s",
2273 (non_locking_shift ? "Non-locking" : "Locking"),
2275 val_to_str(codeset, q931_codeset_vals,
2276 "Unknown (0x%02X)"));
2281 case Q931_IE_MORE_DATA_OR_SEND_COMP:
2282 switch (info_element) {
2284 case Q931_IE_MORE_DATA:
2285 if (q931_tree != NULL) {
2286 proto_tree_add_text(q931_tree, tvb, offset, 1,
2291 case Q931_IE_SENDING_COMPLETE:
2292 if (q931_tree != NULL) {
2293 proto_tree_add_text(q931_tree, tvb, offset, 1,
2294 "Sending complete");
2299 if (q931_tree != NULL) {
2300 proto_tree_add_text(q931_tree, tvb, offset, 1,
2301 "Unknown information element (0x%02X",
2307 if (non_locking_shift)
2311 case Q931_IE_CONGESTION_LEVEL:
2312 if (q931_tree != NULL) {
2313 proto_tree_add_text(q931_tree, tvb, offset, 1,
2314 "Congestion level: %s",
2315 val_to_str(info_element & Q931_IE_SO_IE_MASK,
2316 q931_congestion_level_vals,
2320 if (non_locking_shift)
2324 case Q931_IE_REPEAT_INDICATOR:
2325 if (q931_tree != NULL) {
2326 proto_tree_add_text(q931_tree, tvb, offset, 1,
2327 "Repeat indicator: %s",
2328 val_to_str(info_element & Q931_IE_SO_IE_MASK,
2329 q931_repeat_indication_vals,
2333 if (non_locking_shift)
2342 * Variable-length IE.
2345 info_element_len = tvb_get_guint8(tvb, offset + 1);
2348 * According to page 18 from Recommendation H.225.0 :
2349 * " Length of user-user contents contents
2350 * - Shall be 2 octets instead of 1 (as in Figure 4-36/Q.931)"
2352 * This will be true for all messages going to / from TCP port
2353 * 1720 and with the first and fourth octet of the user-user
2354 * IE having the values 0x7E and 0x05 resp.
2355 * See http://www.mbuf.org/~moto/h323/h323decoder.html
2359 if ( ( tvb_get_guint8( tvb, offset ) == 0x7E ) &&
2360 ( tvb_get_guint8( tvb, offset + 3 ) == 0x05 ) &&
2361 /* ( ( pi.srcport == 1720 ) || ( pi.destport == 1720 ) ) && */
2362 ( protocol_discriminator == NLPID_Q_931 ) ) {
2363 info_element_len = tvb_get_ntohs( tvb, offset + 1 );
2364 is_h323_h225 = TRUE;
2365 if ( tree == NULL ) {
2366 h225_tvb = tvb_new_subset( tvb, offset + 4, info_element_len - 1, info_element_len - 1 );
2367 dissect_h225_cs( h225_tvb, pinfo, tree );
2369 * Skip the 4 bytes of the element header and then the element itself
2372 offset += info_element_len - 1;
2375 info_element_len = tvb_get_guint8( tvb, offset + 1 );
2378 if (q931_tree != NULL) {
2381 ti = proto_tree_add_text(q931_tree, tvb, offset,
2383 val_to_str(info_element,
2384 q931_info_element_vals,
2385 "Unknown information element (0x%02X)"));
2386 ie_tree = proto_item_add_subtree(ti,
2388 proto_tree_add_text(ie_tree, tvb, offset, 1,
2389 "Information element: %s",
2390 val_to_str(info_element,
2391 q931_info_element_vals, "Unknown (0x%02X)"));
2392 proto_tree_add_text(ie_tree, tvb, offset + 1,
2393 2, "Length: %u", info_element_len);
2396 ti = proto_tree_add_text(q931_tree, tvb, offset,
2397 1+1+info_element_len, "%s",
2398 val_to_str(info_element, q931_info_element_vals,
2399 "Unknown information element (0x%02X)"));
2400 ie_tree = proto_item_add_subtree(ti, ett_q931_ie);
2401 proto_tree_add_text(ie_tree, tvb, offset, 1,
2402 "Information element: %s",
2403 val_to_str(info_element, q931_info_element_vals,
2404 "Unknown (0x%02X)"));
2405 proto_tree_add_text(ie_tree, tvb, offset + 1, 1,
2406 "Length: %u", info_element_len);
2410 switch (info_element) {
2412 case Q931_IE_SEGMENTED_MESSAGE:
2413 dissect_q931_segmented_message_ie(tvb,
2414 offset + 2, info_element_len, ie_tree);
2417 case Q931_IE_BEARER_CAPABILITY:
2418 case Q931_IE_LOW_LAYER_COMPAT:
2419 dissect_q931_bearer_capability_ie(tvb,
2420 offset + 2, info_element_len, ie_tree);
2424 dissect_q931_cause_ie(tvb,
2425 offset + 2, info_element_len, ie_tree);
2428 case Q931_IE_CALL_STATE:
2429 dissect_q931_call_state_ie(tvb,
2430 offset + 2, info_element_len, ie_tree);
2433 case Q931_IE_CHANNEL_IDENTIFICATION:
2434 dissect_q931_channel_identification_ie(tvb,
2435 offset + 2, info_element_len, ie_tree);
2438 case Q931_IE_PROGRESS_INDICATOR:
2439 dissect_q931_progress_indicator_ie(tvb,
2440 offset + 2, info_element_len, ie_tree);
2443 case Q931_IE_NETWORK_SPECIFIC_FACIL:
2444 case Q931_IE_TRANSIT_NETWORK_SEL:
2445 dissect_q931_ns_facilities_ie(tvb,
2446 offset + 2, info_element_len, ie_tree);
2449 case Q931_IE_NOTIFICATION_INDICATOR:
2450 dissect_q931_notification_indicator_ie(tvb,
2451 offset + 2, info_element_len, ie_tree);
2454 case Q931_IE_DISPLAY:
2455 dissect_q931_ia5_ie(tvb, offset + 2,
2456 info_element_len, ie_tree,
2457 "Display information");
2460 case Q931_IE_DATE_TIME:
2461 dissect_q931_date_time_ie(tvb,
2462 offset + 2, info_element_len, ie_tree);
2465 case Q931_IE_KEYPAD_FACILITY:
2466 dissect_q931_ia5_ie(tvb, offset + 2,
2467 info_element_len, ie_tree,
2471 case Q931_IE_SIGNAL:
2472 dissect_q931_signal_ie(tvb,
2473 offset + 2, info_element_len, ie_tree);
2476 case Q931_IE_INFORMATION_RATE:
2477 dissect_q931_information_rate_ie(tvb,
2478 offset + 2, info_element_len, ie_tree);
2481 case Q931_IE_E2E_TRANSIT_DELAY:
2482 dissect_q931_e2e_transit_delay_ie(tvb,
2483 offset + 2, info_element_len, ie_tree);
2486 case Q931_IE_TD_SELECTION_AND_INT:
2487 dissect_q931_td_selection_and_int_ie(tvb,
2488 offset + 2, info_element_len, ie_tree);
2491 case Q931_IE_PL_BINARY_PARAMETERS:
2492 dissect_q931_pl_binary_parameters_ie(tvb,
2493 offset + 2, info_element_len, ie_tree);
2496 case Q931_IE_PL_WINDOW_SIZE:
2497 dissect_q931_pl_window_size_ie(tvb,
2498 offset + 2, info_element_len, ie_tree);
2501 case Q931_IE_PACKET_SIZE:
2502 dissect_q931_packet_size_ie(tvb,
2503 offset + 2, info_element_len, ie_tree);
2507 dissect_q931_cug_ie(tvb,
2508 offset + 2, info_element_len, ie_tree);
2511 case Q931_IE_REVERSE_CHARGE_IND:
2512 dissect_q931_reverse_charge_ind_ie(tvb,
2513 offset + 2, info_element_len, ie_tree);
2516 case Q931_IE_CALLING_PARTY_NUMBER:
2517 case Q931_IE_CALLED_PARTY_NUMBER:
2518 case Q931_IE_REDIRECTING_NUMBER:
2519 dissect_q931_number_ie(tvb,
2520 offset + 2, info_element_len, ie_tree);
2523 case Q931_IE_CALLING_PARTY_SUBADDR:
2524 case Q931_IE_CALLED_PARTY_SUBADDR:
2525 dissect_q931_party_subaddr_ie(tvb,
2526 offset + 2, info_element_len, ie_tree);
2529 case Q931_IE_RESTART_INDICATOR:
2530 dissect_q931_restart_indicator_ie(tvb,
2531 offset + 2, info_element_len, ie_tree);
2534 case Q931_IE_HIGH_LAYER_COMPAT:
2535 dissect_q931_high_layer_compat_ie(tvb,
2536 offset + 2, info_element_len, ie_tree);
2539 case Q931_IE_USER_USER:
2542 h225_tvb = tvb_new_subset(tvb,
2543 offset + 4, info_element_len - 1,
2544 info_element_len - 1);
2545 dissect_h225_cs(h225_tvb, pinfo, tree);
2547 proto_tree_add_text(ie_tree, tvb,
2549 "Protocol discriminator: %s",
2550 val_to_str(tvb_get_guint8(tvb, offset),
2551 q931_protocol_discriminator_vals,
2552 "Unknown (0x%02x)"));
2553 offset += info_element_len;
2556 dissect_q931_user_user_ie(tvb,
2557 offset + 2, info_element_len,
2565 proto_tree_add_text(ie_tree, tvb, offset + 2,
2566 info_element_len, "Data: %s",
2568 tvb_get_ptr(tvb, offset + 2, info_element_len),
2573 offset += 1 + 1 + info_element_len;
2574 if (non_locking_shift)
2579 * Heuristic should return TRUE if it get's here.
2588 dissect_q931_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2591 * XXX - should this be heuristic, or should we just make
2592 * port 1720 do Q.931-inside-TPKT; that port appears to be
2593 * intended for H.323 calls, according to
2595 * http://www.isi.edu/in-notes/iana/assignments/port-numbers
2597 * which says it's for "h323hostcall"?
2599 pinfo->current_proto = "Q.931 HEUR";
2600 return q931_dissector(tvb, pinfo, tree, TRUE);
2605 dissect_q931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2607 pinfo->current_proto = "Q.931";
2608 q931_dissector(tvb, pinfo, tree, FALSE);
2612 proto_register_q931(void)
2614 static hf_register_info hf[] = {
2615 { &hf_q931_discriminator,
2616 { "Protocol discriminator", "q931.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
2619 { &hf_q931_call_ref_len,
2620 { "Call reference value length", "q931.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
2623 { &hf_q931_call_ref,
2624 { "Call reference value", "q931.call_ref", FT_BYTES, BASE_HEX, NULL, 0x0,
2627 { &hf_q931_message_type,
2628 { "Message type", "q931.message_type", FT_UINT8, BASE_HEX, VALS(q931_message_type_vals), 0x0,
2632 static gint *ett[] = {
2637 proto_q931 = proto_register_protocol("Q.931", "Q.931", "q931");
2638 proto_register_field_array (proto_q931, hf, array_length(hf));
2639 proto_register_subtree_array(ett, array_length(ett));
2644 proto_reg_handoff_q931(void)
2647 heur_dissector_add("tcp", dissect_q931_heur);