2 * Routines for Q.931 frame disassembly
3 * Guy Harris <guy@alum.mit.edu>
5 * $Id: packet-q931.c,v 1.32 2001/09/14 07:10:05 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>
42 #include "packet-q931.h"
44 #include "packet-tpkt.h"
46 #include "packet-h225.h"
51 * http://www.acacia-net.com/Clarinet/Protocol/q9313svn.htm
52 * http://www.acacia-net.com/Clarinet/Protocol/q9311sc3.htm
53 * http://www.acacia-net.com/Clarinet/Protocol/q9317oz7.htm
54 * http://www.protocols.com/pbook/isdn.htm
55 * http://freesoft.org/CIE/Topics/126.htm
56 * http://noc.comstar.ru/miscdocs/ascend-faq-cause-codes.html
57 * http://www.andrews-arnold.co.uk/isdn/q931cause.html
58 * http://www.tulatelecom.ru/staff/german/DSSHelp/MessList/InfEl/InfElList.html
61 static int proto_q931 = -1;
62 static int hf_q931_discriminator = -1;
63 static int hf_q931_call_ref_len = -1;
64 static int hf_q931_call_ref = -1;
65 static int hf_q931_message_type = -1;
67 static gint ett_q931 = -1;
68 static gint ett_q931_ie = -1;
71 * Q.931 message types.
73 #define Q931_ESCAPE 0x00
74 #define Q931_ALERTING 0x01
75 #define Q931_CALL_PROCEEDING 0x02
76 #define Q931_CONNECT 0x07
77 #define Q931_CONNECT_ACK 0x0F
78 #define Q931_PROGRESS 0x03
79 #define Q931_SETUP 0x05
80 #define Q931_SETUP_ACK 0x0D
81 #define Q931_HOLD 0x24
82 #define Q931_HOLD_ACK 0x28
83 #define Q931_HOLD_REJECT 0x30
84 #define Q931_RESUME 0x26
85 #define Q931_RESUME_ACK 0x2E
86 #define Q931_RESUME_REJECT 0x22
87 #define Q931_RETRIEVE 0x31
88 #define Q931_RETRIEVE_ACK 0x33
89 #define Q931_RETRIEVE_REJECT 0x37
90 #define Q931_SUSPEND 0x25
91 #define Q931_SUSPEND_ACK 0x2D
92 #define Q931_SUSPEND_REJECT 0x21
93 #define Q931_USER_INFORMATION 0x20
94 #define Q931_DISCONNECT 0x45
95 #define Q931_RELEASE 0x4D
96 #define Q931_RELEASE_COMPLETE 0x5A
97 #define Q931_RESTART 0x46
98 #define Q931_RESTART_ACK 0x4E
99 #define Q931_CONGESTION_CONTROL 0x79
100 #define Q931_FACILITY 0x62
101 #define Q931_INFORMATION 0x7B
102 #define Q931_NOTIFY 0x6E
103 #define Q931_REGISTER 0x64
104 #define Q931_SEGMENT 0x60
105 #define Q931_STATUS 0x7D
106 #define Q931_STATUS_ENQUIRY 0x75
108 static const value_string q931_message_type_vals[] = {
109 { Q931_ESCAPE, "ESCAPE" },
110 { Q931_ALERTING, "ALERTING" },
111 { Q931_CALL_PROCEEDING, "CALL PROCEEDING" },
112 { Q931_CONNECT, "CONNECT" },
113 { Q931_CONNECT_ACK, "CONNECT ACKNOWLEDGE" },
114 { Q931_PROGRESS, "PROGRESS" },
115 { Q931_SETUP, "SETUP" },
116 { Q931_SETUP_ACK, "SETUP ACKNOWLEDGE" },
117 { Q931_HOLD, "HOLD" },
118 { Q931_HOLD_ACK, "HOLD_ACKNOWLEDGE" },
119 { Q931_HOLD_REJECT, "HOLD_REJECT" },
120 { Q931_RESUME, "RESUME" },
121 { Q931_RESUME_ACK, "RESUME ACKNOWLEDGE" },
122 { Q931_RESUME_REJECT, "RESUME REJECT" },
123 { Q931_RETRIEVE, "RETRIEVE" },
124 { Q931_RETRIEVE_ACK, "RETRIEVE ACKNOWLEDGE" },
125 { Q931_RETRIEVE_REJECT, "RETRIEVE REJECT" },
126 { Q931_SUSPEND, "SUSPEND" },
127 { Q931_SUSPEND_ACK, "SUSPEND ACKNOWLEDGE" },
128 { Q931_SUSPEND_REJECT, "SUSPEND REJECT" },
129 { Q931_USER_INFORMATION, "USER INFORMATION" },
130 { Q931_DISCONNECT, "DISCONNECT" },
131 { Q931_RELEASE, "RELEASE" },
132 { Q931_RELEASE_COMPLETE, "RELEASE COMPLETE" },
133 { Q931_RESTART, "RESTART" },
134 { Q931_RESTART_ACK, "RESTART ACKNOWLEDGE" },
135 { Q931_CONGESTION_CONTROL, "CONGESTION CONTROL" },
136 { Q931_FACILITY, "FACILITY" },
137 { Q931_INFORMATION, "INFORMATION" },
138 { Q931_NOTIFY, "NOTIFY" },
139 { Q931_REGISTER, "REGISTER" },
140 { Q931_SEGMENT, "SEGMENT" },
141 { Q931_STATUS, "STATUS" },
142 { Q931_STATUS_ENQUIRY, "STATUS ENQUIRY" },
147 * Information elements.
153 #define Q931_IE_SO_IDENTIFIER_MASK 0xf0 /* IE identifier mask */
154 #define Q931_IE_SO_IDENTIFIER_SHIFT 4 /* IE identifier shift */
155 #define Q931_IE_SO_IE_MASK 0x0F /* IE mask */
157 #define Q931_IE_SHIFT 0x90
158 #define Q931_IE_SHIFT_LOCKING 0x08 /* locking shift */
159 #define Q931_IE_SHIFT_CODESET 0x0F /* codeset */
161 #define Q931_IE_MORE_DATA_OR_SEND_COMP 0xA0 /* More Data or Sending Complete */
162 #define Q931_IE_MORE_DATA 0xA0
163 #define Q931_IE_SENDING_COMPLETE 0xA1
165 #define Q931_IE_CONGESTION_LEVEL 0xB0
166 #define Q931_IE_REPEAT_INDICATOR 0xD0
169 * Variable-length IEs.
171 #define Q931_IE_VL_EXTENSION 0x80 /* Extension flag */
174 * Codeset 0 (default).
176 #define Q931_IE_SEGMENTED_MESSAGE 0x00
177 #define Q931_IE_BEARER_CAPABILITY 0x04
178 #define Q931_IE_CAUSE 0x08
179 #define Q931_IE_CALL_IDENTITY 0x10
180 #define Q931_IE_CALL_STATE 0x14
181 #define Q931_IE_CHANNEL_IDENTIFICATION 0x18
182 #define Q931_IE_FACILITY 0x1C
183 #define Q931_IE_PROGRESS_INDICATOR 0x1E
184 #define Q931_IE_NETWORK_SPECIFIC_FACIL 0x20 /* Network Specific Facilities */
185 #define Q931_IE_NOTIFICATION_INDICATOR 0x27
186 #define Q931_IE_DISPLAY 0x28
187 #define Q931_IE_DATE_TIME 0x29
188 #define Q931_IE_KEYPAD_FACILITY 0x2C
189 #define Q931_IE_INFORMATION_REQUEST 0x32
190 #define Q931_IE_SIGNAL 0x34
191 #define Q931_IE_SWITCHHOOK 0x36
192 #define Q931_IE_FEATURE_ACTIVATION 0x38
193 #define Q931_IE_FEATURE_INDICATION 0x39
194 #define Q931_IE_ENDPOINT_IDENTIFIER 0x3B
195 #define Q931_IE_SERVICE_PROFILE_ID 0x3A
196 #define Q931_IE_INFORMATION_RATE 0x40
197 #define Q931_IE_E2E_TRANSIT_DELAY 0x42 /* End-to-end Transit Delay */
198 #define Q931_IE_TD_SELECTION_AND_INT 0x43 /* Transit Delay Selection and Indication */
199 #define Q931_IE_PL_BINARY_PARAMETERS 0x44 /* Packet layer binary parameters */
200 #define Q931_IE_PL_WINDOW_SIZE 0x45 /* Packet layer window size */
201 #define Q931_IE_PACKET_SIZE 0x46 /* Packet size */
202 #define Q931_IE_CUG 0x47 /* Closed user group */
203 #define Q931_IE_REVERSE_CHARGE_IND 0x4A /* Reverse charging indication */
204 #define Q931_IE_CALLING_PARTY_NUMBER 0x6C /* Calling Party Number */
205 #define Q931_IE_CALLING_PARTY_SUBADDR 0x6D /* Calling Party Subaddress */
206 #define Q931_IE_CALLED_PARTY_NUMBER 0x70 /* Called Party Number */
207 #define Q931_IE_CALLED_PARTY_SUBADDR 0x71 /* Called Party Subaddress */
208 #define Q931_IE_REDIRECTING_NUMBER 0x74
209 #define Q931_IE_REDIRECTION_NUMBER 0x76
210 #define Q931_IE_TRANSIT_NETWORK_SEL 0x78 /* Transit Network Selection */
211 #define Q931_IE_RESTART_INDICATOR 0x79
212 #define Q931_IE_LOW_LAYER_COMPAT 0x7C /* Low-Layer Compatibility */
213 #define Q931_IE_HIGH_LAYER_COMPAT 0x7D /* High-Layer Compatibility */
214 #define Q931_IE_USER_USER 0x7E /* User-User */
215 #define Q931_IE_ESCAPE 0x7F /* Escape for extension */
220 #define Q931_IE_CONNECTED_NUMBER 0x8C
221 #define Q931_IE_CONNECTED_SUBADDR 0x8D
224 * Codeset 5 (National-specific) Belgium.
226 #define Q931_IE_CHARGING_ADVICE 0x1A
229 * Codeset 5 (National-specific) Bellcore National ISDN.
231 #define Q931_IE_OPERATOR_SYSTEM_ACCESS 0x1D
234 * Codeset 6 (Network-specific) Belgium.
236 /* 0x1A is Charging Advice, as with Codeset 5 */
237 #define Q931_IE_REDIRECTING_NUMBER 0x74
240 * Codeset 6 (Network-specific) FT-Numeris.
242 /* 0x1D is User Capability */
245 * Codeset 6 (Network-specific) Bellcore National ISDN.
247 #define Q931_IE_REDIRECTING_SUBADDR 0x75 /* Redirecting Subaddress */
248 /* 0x76 is Redirection Number, but that's also Codeset 0 */
249 #define Q931_IE_CALL_APPEARANCE 0x7B
251 static const value_string q931_info_element_vals[] = {
252 { Q931_IE_SEGMENTED_MESSAGE, "Segmented message" },
253 { Q931_IE_BEARER_CAPABILITY, "Bearer capability" },
254 { Q931_IE_CAUSE, "Cause" },
255 { Q931_IE_CALL_IDENTITY, "Call identity" },
256 { Q931_IE_CALL_STATE, "Call state" },
257 { Q931_IE_CHANNEL_IDENTIFICATION, "Channel identification" },
258 { Q931_IE_FACILITY, "Facility" },
259 { Q931_IE_PROGRESS_INDICATOR, "Progress indicator" },
260 { Q931_IE_NETWORK_SPECIFIC_FACIL, "Network specific facilities" },
261 { Q931_IE_NOTIFICATION_INDICATOR, "Notification indicator" },
262 { Q931_IE_DISPLAY, "Display" },
263 { Q931_IE_DATE_TIME, "Date/Time" },
264 { Q931_IE_KEYPAD_FACILITY, "Keypad facility" },
265 { Q931_IE_INFORMATION_REQUEST, "Information request" },
266 { Q931_IE_SIGNAL, "Signal" },
267 { Q931_IE_SWITCHHOOK, "Switchhook" },
268 { Q931_IE_FEATURE_ACTIVATION, "Feature activation" },
269 { Q931_IE_FEATURE_INDICATION, "Feature Indication" },
270 { Q931_IE_ENDPOINT_IDENTIFIER, "Endpoint identifier" },
271 { Q931_IE_SERVICE_PROFILE_ID, "Service profile ID" },
272 { Q931_IE_INFORMATION_RATE, "Information rate" },
273 { Q931_IE_E2E_TRANSIT_DELAY, "End-to-end transit delay" },
274 { Q931_IE_TD_SELECTION_AND_INT, "Transit delay selection and indication" },
275 { Q931_IE_PL_BINARY_PARAMETERS, "Packet layer binary parameters" },
276 { Q931_IE_PL_WINDOW_SIZE, "Packet layer window size" },
277 { Q931_IE_PACKET_SIZE, "Packet size" },
278 { Q931_IE_CUG, "Closed user group" },
279 { Q931_IE_REVERSE_CHARGE_IND, "Reverse charging indication" },
280 { Q931_IE_CALLING_PARTY_NUMBER, "Calling party number" },
281 { Q931_IE_CALLING_PARTY_SUBADDR, "Calling party subaddress" },
282 { Q931_IE_CALLED_PARTY_NUMBER, "Called party number" },
283 { Q931_IE_CALLED_PARTY_SUBADDR, "Called party subaddress" },
284 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
285 { Q931_IE_REDIRECTION_NUMBER, "Redirection number" },
286 { Q931_IE_TRANSIT_NETWORK_SEL, "Transit network selection" },
287 { Q931_IE_RESTART_INDICATOR, "Restart indicator" },
288 { Q931_IE_LOW_LAYER_COMPAT, "Low-layer compatibility" },
289 { Q931_IE_HIGH_LAYER_COMPAT, "High-layer compatibility" },
290 { Q931_IE_USER_USER, "User-user" },
291 { Q931_IE_ESCAPE, "Escape" },
292 { Q931_IE_CONNECTED_NUMBER, "Connected number" },
293 { Q931_IE_CONNECTED_SUBADDR, "Connected subaddress" },
294 { Q931_IE_CHARGING_ADVICE, "Charging advice" },
295 { Q931_IE_OPERATOR_SYSTEM_ACCESS, "Operator system access" },
296 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
297 { Q931_IE_REDIRECTING_SUBADDR, "Redirecting subaddress" },
298 { Q931_IE_CALL_APPEARANCE, "Call appearance" },
302 static const value_string q931_congestion_level_vals[] = {
303 { 0x0, "Receiver ready" },
304 { 0xF, "Receiver not ready" },
308 static const value_string q931_repeat_indication_vals[] = {
309 { 0x2, "Prioritized list" },
314 * ITU-standardized coding.
316 #define Q931_ITU_STANDARDIZED_CODING 0x00
319 * Dissect a Segmented message information element.
322 dissect_q931_segmented_message_ie(tvbuff_t *tvb, int offset, int len,
326 proto_tree_add_text(tree, tvb, offset, len,
327 "Segmented message: length is %d, should be 2\n", len);
330 if (tvb_get_guint8(tvb, offset) & 0x80) {
331 proto_tree_add_text(tree, tvb, offset, 1,
332 "First segment: %u segments remaining",
333 tvb_get_guint8(tvb, offset) & 0x7F);
335 proto_tree_add_text(tree, tvb, offset, 1,
336 "Not first segment: %u segments remaining",
337 tvb_get_guint8(tvb, offset) & 0x7F);
339 proto_tree_add_text(tree, tvb, offset + 1, 1,
340 "Segmented message type: %u\n", tvb_get_guint8(tvb, offset + 1));
344 * Dissect a Bearer capability or Low-layer compatibility information element.
346 static const value_string q931_bc_coding_standard_vals[] = {
347 { 0x00, "ITU-T standardized coding" },
348 { 0x20, "ISO/IEC standard" },
349 { 0x40, "National standard" },
350 { 0x60, "Standard defined for this particular network" },
354 static const value_string q931_information_transfer_capability_vals[] = {
356 { 0x08, "Unrestricted digital information" },
357 { 0x09, "Restricted digital information" },
358 { 0x10, "3.1 kHz audio" },
359 { 0x11, "Unrestricted digital information with tones/announcements" },
364 static const value_string q931_transfer_mode_vals[] = {
365 { 0x00, "Circuit mode" },
366 { 0x40, "Packet mode" },
370 #define Q931_IT_RATE_MULTIRATE 0x18
372 static const value_string q931_information_transfer_rate_vals[] = {
373 { 0x00, "Packet mode" },
374 { 0x10, "64 kbit/s" },
375 { 0x11, "2 x 64 kbit/s" },
376 { 0x13, "384 kbit/s" },
377 { 0x15, "1536 kbit/s" },
378 { 0x17, "1920 kbit/s" },
379 { Q931_IT_RATE_MULTIRATE, "Multirate (64 kbit/s base rate)" },
383 static const value_string q931_uil1_vals[] = {
384 { 0x01, "V.110/I.460/X.30 rate adaption" },
385 { 0x02, "Recommendation G.711 u-law" },
386 { 0x03, "Recommendation G.711 A-law" },
387 { 0x04, "Recommendation G.721 32 kbit/s ADPCM and Recommendation I.460" },
388 { 0x05, "Recommendation H.221 and H.242" },
389 { 0x06, "Recommendation H.223 and H.245" },
390 { 0x07, "Non-ITU-T-standardized rate adaption" },
391 { 0x08, "V.120 rate adaption" },
392 { 0x09, "X.31 HDLC flag stuffing" },
396 static const value_string q931_l1_user_rate_vals[] = {
397 { 0x00, "Rate indicated by E-bits" },
398 { 0x01, "0.6 kbit/s" },
399 { 0x02, "1.2 kbit/s" },
400 { 0x03, "2.4 kbit/s" },
401 { 0x04, "3.6 kbit/s" },
402 { 0x05, "4.8 kbit/s" },
403 { 0x06, "7.2 kbit/s" },
404 { 0x07, "8 kbit/s" },
405 { 0x08, "9.6 kbit/s" },
406 { 0x09, "14.4 kbit/s" },
407 { 0x0A, "16 kbit/s" },
408 { 0x0B, "19.2 kbit/s" },
409 { 0x0C, "32 kbit/s" },
410 { 0x0E, "48 kbit/s" },
411 { 0x0F, "56 kbit/s" },
412 { 0x10, "64 kbit/s "},
413 { 0x15, "0.1345 kbit/s" },
414 { 0x16, "0.100 kbit/s" },
415 { 0x17, "0.075/1.2 kbit/s" },
416 { 0x18, "1.2/0.075 kbit/s" },
417 { 0x19, "0.050 kbit/s" },
418 { 0x1A, "0.075 kbit/s" },
419 { 0x1B, "0.110 kbit/s" },
420 { 0x1C, "0.150 kbit/s" },
421 { 0x1D, "0.200 kbit/s" },
422 { 0x1E, "0.300 kbit/s" },
423 { 0x1F, "12 kbit/s" },
427 static const value_string q931_l1_intermediate_rate_vals[] = {
428 { 0x20, "8 kbit/s" },
429 { 0x40, "16 kbit/s" },
430 { 0x60, "32 kbit/s" },
434 static const value_string q931_l1_stop_bits_vals[] = {
441 static const value_string q931_l1_data_bits_vals[] = {
448 static const value_string q931_l1_parity_vals[] = {
452 { 0x04, "Forced to 0" },
453 { 0x05, "Forced to 1" },
457 static const value_string q931_l1_modem_type_vals[] = {
460 { 0x13, "V.22 bis" },
463 { 0x16, "V.26 bis" },
464 { 0x17, "V.26 ter" },
466 { 0x19, "V.27 bis" },
467 { 0x1A, "V.27 ter" },
474 #define Q931_UIL2_USER_SPEC 0x10
476 static const value_string q931_uil2_vals[] = {
477 { 0x01, "Basic mode ISO 1745" },
478 { 0x02, "Q.921/I.441" }, /* LAPD */
479 { 0x06, "X.25, link layer" }, /* LAPB */
480 { 0x07, "X.25 multilink" }, /* or 0x0F? */
481 { 0x08, "T.71 Extended LAPB" },
482 { 0x09, "HDLC ARM" },
483 { 0x0A, "HDLC NRM" },
484 { 0x0B, "HDLC ABM" },
485 { 0x0C, "ISO 8802/2 LLC" },
486 { 0x0D, "X.75 Single Link Procedure" },
488 { 0x0F, "Core aspects of Q.922" },
489 { Q931_UIL2_USER_SPEC, "User-specified" },
490 { 0x11, "ISO 7776 DTE-DTE operation" },
494 static const value_string q931_mode_vals[] = {
495 { 0x20, "Normal mode" },
496 { 0x40, "Extended mode" },
500 #define Q931_UIL3_X25_PL 0x06
501 #define Q931_UIL3_ISO_8208 0x07 /* X.25-based */
502 #define Q931_UIL3_X223 0x08 /* X.25-based */
503 #define Q931_UIL3_TR_9577 0x0B
504 #define Q931_UIL3_USER_SPEC 0x10
506 static const value_string q931_uil3_vals[] = {
507 { 0x02, "Q.931/I.451" },
508 { Q931_UIL3_X25_PL, "X.25, packet layer" },
509 { Q931_UIL3_ISO_8208, "ISO/IEC 8208" },
510 { Q931_UIL3_X223, "X.223/ISO 8878" },
511 { 0x09, "ISO/IEC 8473" },
513 { Q931_UIL3_TR_9577, "ISO/IEC TR 9577" },
514 { Q931_UIL3_USER_SPEC, "User-specified" },
519 dissect_q931_protocol_discriminator(tvbuff_t *tvb, int offset, proto_tree *tree)
521 unsigned int discriminator = tvb_get_guint8(tvb, offset);
523 if (discriminator == NLPID_Q_931) {
524 proto_tree_add_uint_format(tree, hf_q931_discriminator,
525 tvb, offset, 1, discriminator,
526 "Protocol discriminator: Q.931");
527 } else if (discriminator == NLPID_Q_2931) {
528 proto_tree_add_uint_format(tree, hf_q931_discriminator,
529 tvb, offset, 1, discriminator,
530 "Protocol discriminator: Q.2931");
531 } else if ((discriminator >= 16 && discriminator < 63)
532 || ((discriminator >= 80) && (discriminator < 254))) {
533 proto_tree_add_uint_format(tree, hf_q931_discriminator,
534 tvb, offset, 1, discriminator,
535 "Protocol discriminator: Network layer or layer 3 protocol (0x%02X)",
537 } else if (discriminator >= 64 && discriminator <= 79) {
538 proto_tree_add_uint_format(tree, hf_q931_discriminator,
539 tvb, offset, 1, discriminator,
540 "Protocol discriminator: National use (0x%02X)",
543 proto_tree_add_uint_format(tree, hf_q931_discriminator,
544 tvb, offset, 1, discriminator,
545 "Protocol discriminator: Reserved (0x%02X)",
551 dissect_q931_bearer_capability_ie(tvbuff_t *tvb, int offset, int len,
555 guint8 coding_standard;
558 guint8 uil2_protocol;
559 guint8 uil3_protocol;
564 octet = tvb_get_guint8(tvb, offset);
565 coding_standard = octet & 0x60;
566 proto_tree_add_text(tree, tvb, offset, 1,
567 "Coding standard: %s",
568 val_to_str(coding_standard, q931_bc_coding_standard_vals, NULL));
569 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
571 * We don't know how the bearer capability is encoded,
572 * so just dump it as data and be done with it.
574 proto_tree_add_text(tree, tvb, offset,
576 tvb_bytes_to_str(tvb, offset, len));
579 proto_tree_add_text(tree, tvb, offset, 1,
580 "Information transfer capability: %s",
581 val_to_str(octet & 0x1F, q931_information_transfer_capability_vals,
582 "Unknown (0x%02X)"));
587 * XXX - only in Low-layer compatibility information element.
589 if (!(octet & Q931_IE_VL_EXTENSION)) {
592 octet = tvb_get_guint8(tvb, offset);
593 proto_tree_add_text(tree, tvb, offset, 1,
594 "Out-band negotiation %spossible",
595 (octet & 0x40) ? "" : "not ");
602 octet = tvb_get_guint8(tvb, offset);
603 proto_tree_add_text(tree, tvb, offset, 1,
605 val_to_str(octet & 0x60, q931_transfer_mode_vals,
606 "Unknown (0x%02X)"));
607 it_rate = octet & 0x1F;
608 proto_tree_add_text(tree, tvb, offset, 1,
609 "Information transfer rate: %s",
610 val_to_str(it_rate, q931_information_transfer_rate_vals,
611 "Unknown (0x%02X)"));
615 if (it_rate == Q931_IT_RATE_MULTIRATE) {
618 proto_tree_add_text(tree, tvb, offset, 1, "Rate multiplier: %u", tvb_get_guint8(tvb, offset));
625 octet = tvb_get_guint8(tvb, offset);
626 if ((octet & 0x60) == 0x20) {
628 * Layer 1 information.
630 proto_tree_add_text(tree, tvb, offset, 1,
631 "User information layer 1 protocol: %s",
632 val_to_str(octet & 0x1F, q931_uil1_vals,
633 "Unknown (0x%02X)"));
637 if (octet & Q931_IE_VL_EXTENSION)
641 octet = tvb_get_guint8(tvb, offset);
642 proto_tree_add_text(tree, tvb, offset, 1,
644 (octet & 0x40) ? "Asynchronous" : "Synchronous");
645 proto_tree_add_text(tree, tvb, offset, 1,
646 "Layer 1 in-band negotiation is %spossible",
647 (octet & 0x20) ? "" : "not ");
648 proto_tree_add_text(tree, tvb, offset, 1,
650 val_to_str(octet & 0x1F, q931_l1_user_rate_vals,
651 "Unknown (0x%02X)"));
655 if (octet & Q931_IE_VL_EXTENSION)
659 octet = tvb_get_guint8(tvb, offset);
660 proto_tree_add_text(tree, tvb, offset, 1,
661 "Intermediate rate: %s",
662 val_to_str(octet & 0x60, q931_l1_intermediate_rate_vals,
664 proto_tree_add_text(tree, tvb, offset, 1,
665 "%s to send data with network independent clock",
666 (octet & 0x10) ? "Required" : "Not required");
667 proto_tree_add_text(tree, tvb, offset, 1,
668 "%s accept data with network independent clock",
669 (octet & 0x08) ? "Can" : "Cannot");
670 proto_tree_add_text(tree, tvb, offset, 1,
671 "%s to send data with flow control mechanism",
672 (octet & 0x04) ? "Required" : "Not required");
673 proto_tree_add_text(tree, tvb, offset, 1,
674 "%s accept data with flow control mechanism",
675 (octet & 0x02) ? "Can" : "Cannot");
679 if (octet & Q931_IE_VL_EXTENSION)
683 octet = tvb_get_guint8(tvb, offset);
684 proto_tree_add_text(tree, tvb, offset, 1,
685 "Rate adaption header %sincluded",
686 (octet & 0x40) ? "" : "not ");
687 proto_tree_add_text(tree, tvb, offset, 1,
688 "Multiple frame establishment %ssupported",
689 (octet & 0x20) ? "" : "not ");
690 proto_tree_add_text(tree, tvb, offset, 1,
691 "%s mode of operation",
692 (octet & 0x10) ? "Protocol sensitive" : "Bit transparent");
693 proto_tree_add_text(tree, tvb, offset, 1,
695 "Full protocol negotiation" : "LLI = 256 only");
696 proto_tree_add_text(tree, tvb, offset, 1,
697 "Message originator is %s",
698 (octet & 0x04) ? "Assignor only" : "Default assignee");
699 proto_tree_add_text(tree, tvb, offset, 1,
700 "Negotiation is done %s",
701 (octet & 0x02) ? "in-band" : "out-of-band");
705 if (octet & Q931_IE_VL_EXTENSION)
709 octet = tvb_get_guint8(tvb, offset);
710 proto_tree_add_text(tree, tvb, offset, 1,
712 val_to_str(octet & 0x60, q931_l1_stop_bits_vals,
714 proto_tree_add_text(tree, tvb, offset, 1,
716 val_to_str(octet & 0x18, q931_l1_data_bits_vals,
718 proto_tree_add_text(tree, tvb, offset, 1,
720 val_to_str(octet & 0x08, q931_l1_parity_vals,
723 if (octet & Q931_IE_VL_EXTENSION)
727 octet = tvb_get_guint8(tvb, offset);
728 proto_tree_add_text(tree, tvb, offset, 1,
730 (octet & 0x40) ? "Full" : "Half");
731 modem_type = octet & 0x3F;
732 if (modem_type <= 0x5 ||
733 (modem_type >= 0x20 && modem_type <= 0x2F)) {
734 proto_tree_add_text(tree, tvb, offset, 1,
735 "Modem type: National use 0x%02X", modem_type);
736 } else if (modem_type >= 0x30) {
737 proto_tree_add_text(tree, tvb, offset, 1,
738 "Modem type: User specified 0x%02X", modem_type);
740 proto_tree_add_text(tree, tvb, offset, 1,
742 val_to_str(modem_type, q931_l1_modem_type_vals,
743 "Unknown (0x%02X)"));
753 octet = tvb_get_guint8(tvb, offset);
754 if ((octet & 0x60) == 0x40) {
756 * Layer 2 information.
758 uil2_protocol = octet & 0x1F;
759 proto_tree_add_text(tree, tvb, offset, 1,
760 "User information layer 2 protocol: %s",
761 val_to_str(uil2_protocol, q931_uil2_vals,
762 "Unknown (0x%02X)"));
767 * XXX - only in Low-layer compatibility information element.
769 if (octet & Q931_IE_VL_EXTENSION)
773 octet = tvb_get_guint8(tvb, offset);
774 if (uil2_protocol == Q931_UIL2_USER_SPEC) {
775 proto_tree_add_text(tree, tvb, offset, 1,
776 "User-specified layer 2 protocol information: 0x%02X",
779 proto_tree_add_text(tree, tvb, offset, 1,
781 val_to_str(octet & 0x60, q931_mode_vals,
782 "Unknown (0x%02X)"));
787 if (octet & Q931_IE_VL_EXTENSION)
791 octet = tvb_get_guint8(tvb, offset);
792 proto_tree_add_text(tree, tvb, offset, 1,
793 "Window size: %u k", octet & 0x7F);
802 octet = tvb_get_guint8(tvb, offset);
803 if ((octet & 0x60) == 0x60) {
805 * Layer 3 information.
807 uil3_protocol = octet & 0x1F;
808 proto_tree_add_text(tree, tvb, offset, 1,
809 "User information layer 3 protocol: %s",
810 val_to_str(uil3_protocol, q931_uil3_vals,
811 "Unknown (0x%02X)"));
817 * XXX - only in Low-layer compatibility information element.
819 if (octet & Q931_IE_VL_EXTENSION)
823 octet = tvb_get_guint8(tvb, offset);
824 switch (uil3_protocol) {
826 case Q931_UIL3_X25_PL:
827 case Q931_UIL3_ISO_8208:
829 proto_tree_add_text(tree, tvb, offset, 1,
831 val_to_str(octet & 0x60, q931_mode_vals,
832 "Unknown (0x%02X)"));
836 if (octet & Q931_IE_VL_EXTENSION)
840 octet = tvb_get_guint8(tvb, offset);
841 proto_tree_add_text(tree, tvb, offset, 1,
842 "Default packet size: %u", octet & 0x0F);
846 if (octet & Q931_IE_VL_EXTENSION)
850 octet = tvb_get_guint8(tvb, offset);
851 proto_tree_add_text(tree, tvb, offset, 1,
852 "Packet window size: %u", octet & 0x7F);
857 case Q931_UIL3_USER_SPEC:
858 proto_tree_add_text(tree, tvb, offset, 1,
859 "Default packet size: %u octets",
860 1 << (octet & 0x0F));
865 case Q931_UIL3_TR_9577:
866 add_l3_info = (octet & 0x0F) << 4;
867 if (octet & Q931_IE_VL_EXTENSION)
871 octet = tvb_get_guint8(tvb, offset + 1);
872 add_l3_info |= (octet & 0x0F);
873 proto_tree_add_text(tree, tvb, offset, 2,
874 "Additional layer 3 protocol information: %s",
875 val_to_str(add_l3_info, nlpid_vals,
876 "Unknown (0x%02X)"));
887 * Dissect a Cause information element.
889 static const value_string q931_cause_coding_standard_vals[] = {
890 { 0x00, "ITU-T standardized coding" },
891 { 0x20, "ISO/IEC standard" },
892 { 0x40, "National standard" },
893 { 0x60, "Standard specific to identified location" },
897 static const value_string q931_cause_location_vals[] = {
898 { 0x00, "User (U)" },
899 { 0x01, "Private network serving the local user (LPN)" },
900 { 0x02, "Public network serving the local user (LN)" },
901 { 0x03, "Transit network (TN)" },
902 { 0x04, "Public network serving the remote user (RLN)" },
903 { 0x05, "Private network serving the remote user (RPN)" },
904 { 0x07, "International network (INTL)" },
905 { 0x0A, "Network beyond interworking point (BI)" },
909 static const value_string q931_cause_recommendation_vals[] = {
913 { 0x05, "Q.1031/Q.1051" },
918 * Cause codes for Cause.
920 static const value_string q931_cause_code_vals[] = {
921 { 0x00, "Valid cause code not yet received" },
922 { 0x01, "Unallocated (unassigned) number" },
923 { 0x02, "No route to specified transit network" },
924 { 0x03, "No route to destination" },
925 { 0x04, "Send special information tone" },
926 { 0x05, "Misdialled trunk prefix" },
927 { 0x06, "Channel unacceptable" },
928 { 0x07, "Call awarded and being delivered in an established channel" },
929 { 0x08, "Prefix 0 dialed but not allowed" },
930 { 0x09, "Prefix 1 dialed but not allowed" },
931 { 0x0A, "Prefix 1 dialed but not required" },
932 { 0x0B, "More digits received than allowed, call is proceeding" },
933 { 0x10, "Normal call clearing" },
934 { 0x11, "User busy" },
935 { 0x12, "No user responding" },
936 { 0x13, "No answer from user (user alerted)" },
937 { 0x14, "Subscriber absent" },
938 { 0x15, "Call rejected" },
939 { 0x16, "Number changed" },
940 { 0x17, "Reverse charging rejected" },
941 { 0x18, "Call suspended" },
942 { 0x19, "Call resumed" },
943 { 0x1A, "Non-selected user clearing" },
944 { 0x1B, "Destination out of order" },
945 { 0x1C, "Invalid number format (incomplete number)" },
946 { 0x1D, "Facility rejected" },
947 { 0x1E, "Response to STATUS ENQUIRY" },
948 { 0x1F, "Normal unspecified" },
949 { 0x21, "Circuit out of order" },
950 { 0x22, "No circuit/channel available" },
951 { 0x23, "Destination unattainable" },
952 { 0x25, "Degraded service" },
953 { 0x26, "Network out of order" },
954 { 0x27, "Transit delay range cannot be achieved" },
955 { 0x28, "Throughput range cannot be achieved" },
956 { 0x29, "Temporary failure" },
957 { 0x2A, "Switching equipment congestion" },
958 { 0x2B, "Access information discarded" },
959 { 0x2C, "Requested circuit/channel not available" },
960 { 0x2D, "Pre-empted" },
961 { 0x2E, "Precedence call blocked" },
962 { 0x2F, "Resources unavailable, unspecified" },
963 { 0x31, "Quality of service unavailable" },
964 { 0x32, "Requested facility not subscribed" },
965 { 0x33, "Reverse charging not allowed" },
966 { 0x34, "Outgoing calls barred" },
967 { 0x35, "Outgoing calls barred within CUG" },
968 { 0x36, "Incoming calls barred" },
969 { 0x37, "Incoming calls barred within CUG" },
970 { 0x38, "Call waiting not subscribed" },
971 { 0x39, "Bearer capability not authorized" },
972 { 0x3A, "Bearer capability not presently available" },
973 { 0x3E, "Inconsistency in designated outgoing access information and subscriber class" },
974 { 0x3F, "Service or option not available, unspecified" },
975 { 0x41, "Bearer capability not implemented" },
976 { 0x42, "Channel type not implemented" },
977 { 0x43, "Transit network selection not implemented" },
978 { 0x44, "Message not implemented" },
979 { 0x45, "Requested facility not implemented" },
980 { 0x46, "Only restricted digital information bearer capability is available" },
981 { 0x4F, "Service or option not implemented, unspecified" },
982 { 0x51, "Invalid call reference value" },
983 { 0x52, "Identified channel does not exist" },
984 { 0x53, "Call identity does not exist for suspended call" },
985 { 0x54, "Call identity in use" },
986 { 0x55, "No call suspended" },
987 { 0x56, "Call having the requested call identity has been cleared" },
988 { 0x57, "Called user not member of CUG" },
989 { 0x58, "Incompatible destination" },
990 { 0x59, "Non-existent abbreviated address entry" },
991 { 0x5A, "Destination address missing, and direct call not subscribed" },
992 { 0x5B, "Invalid transit network selection (national use)" },
993 { 0x5C, "Invalid facility parameter" },
994 { 0x5D, "Mandatory information element is missing" },
995 { 0x5F, "Invalid message, unspecified" },
996 { 0x60, "Mandatory information element is missing" },
997 { 0x61, "Message type non-existent or not implemented" },
998 { 0x62, "Message not compatible with call state or message type non-existent or not implemented" },
999 { 0x63, "Information element nonexistant or not implemented" },
1000 { 0x64, "Invalid information element contents" },
1001 { 0x65, "Message not compatible with call state" },
1002 { 0x66, "Recovery on timer expiry" },
1003 { 0x67, "Parameter non-existent or not implemented - passed on" },
1004 { 0x6E, "Message with unrecognized parameter discarded" },
1005 { 0x6F, "Protocol error, unspecified" },
1006 { 0x7F, "Internetworking, unspecified" },
1011 dissect_q931_cause_ie(tvbuff_t *tvb, int offset, int len,
1015 guint8 coding_standard;
1019 octet = tvb_get_guint8(tvb, offset);
1020 coding_standard = octet & 0x60;
1021 proto_tree_add_text(tree, tvb, offset, 1,
1022 "Coding standard: %s",
1023 val_to_str(coding_standard, q931_cause_coding_standard_vals, NULL));
1024 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1026 * We don't know how the cause is encoded,
1027 * so just dump it as data and be done with it.
1029 proto_tree_add_text(tree, tvb, offset,
1031 tvb_bytes_to_str(tvb, offset, len));
1034 proto_tree_add_text(tree, tvb, offset, 1,
1036 val_to_str(octet & 0x0F, q931_cause_location_vals,
1041 if (!(octet & Q931_IE_VL_EXTENSION)) {
1044 octet = tvb_get_guint8(tvb, offset);
1045 proto_tree_add_text(tree, tvb, offset, 1,
1046 "Recommendation: %s",
1047 val_to_str(octet & 0x7F, q931_cause_recommendation_vals,
1048 "Unknown (0x%02X)"));
1055 octet = tvb_get_guint8(tvb, offset);
1056 proto_tree_add_text(tree, tvb, offset, 1,
1058 val_to_str(octet & 0x7F, q931_cause_code_vals,
1059 "Unknown (0x%02X)"));
1065 proto_tree_add_text(tree, tvb, offset, len,
1067 tvb_bytes_to_str(tvb, offset, len));
1071 * Dissect a Call state information element.
1073 static const value_string q931_coding_standard_vals[] = {
1074 { 0x00, "ITU-T standardized coding" },
1075 { 0x20, "ISO/IEC standard" },
1076 { 0x40, "National standard" },
1077 { 0x60, "Standard defined for the network" },
1081 static const value_string q931_call_state_vals[] = {
1083 { 0x01, "Call initiated" },
1084 { 0x02, "Overlap sending" },
1085 { 0x03, "Outgoing call proceeding" },
1086 { 0x04, "Call delivered" },
1087 { 0x06, "Call present" },
1088 { 0x07, "Call received" },
1089 { 0x08, "Connect request" },
1090 { 0x09, "Incoming call proceeding" },
1092 { 0x0B, "Disconnect request" },
1093 { 0x0C, "Disconnect indication" },
1094 { 0x0F, "Suspend request" },
1095 { 0x12, "Resume request" },
1096 { 0x13, "Release request" },
1097 { 0x16, "Call abort"},
1098 { 0x19, "Overlap receiving" },
1099 { 0x3D, "Restart request" },
1100 { 0x3E, "Restart" },
1105 dissect_q931_call_state_ie(tvbuff_t *tvb, int offset, int len,
1109 guint8 coding_standard;
1113 octet = tvb_get_guint8(tvb, offset);
1114 coding_standard = octet & 0x60;
1115 proto_tree_add_text(tree, tvb, offset, 1,
1116 "Coding standard: %s",
1117 val_to_str(coding_standard, q931_coding_standard_vals, NULL));
1118 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1120 * We don't know how the call state is encoded,
1121 * so just dump it as data and be done with it.
1123 proto_tree_add_text(tree, tvb, offset,
1125 tvb_bytes_to_str(tvb, offset, len));
1128 proto_tree_add_text(tree, tvb, offset, 1,
1130 val_to_str(octet & 0x3F, q931_call_state_vals,
1131 "Unknown (0x%02X)"));
1135 * Dissect a Channel identification information element.
1137 #define Q931_INTERFACE_IDENTIFIED 0x40
1138 #define Q931_NOT_BASIC_CHANNEL 0x20
1140 static const value_string q931_basic_channel_selection_vals[] = {
1141 { 0x00, "No channel" },
1142 { 0x01, "B1 channel" },
1143 { 0x02, "B2 channel" },
1144 { 0x03, "Any channel" },
1148 static const value_string q931_not_basic_channel_selection_vals[] = {
1149 { 0x00, "No channel" },
1150 { 0x01, "Channel indicated in following octets" },
1151 { 0x03, "Any channel" },
1155 #define Q931_IS_SLOT_MAP 0x10
1157 static const value_string q931_element_type_vals[] = {
1158 { 0x03, "B-channel units" },
1159 { 0x06, "H0-channel units" },
1160 { 0x08, "H11-channel units" },
1161 { 0x09, "H12-channel units" },
1166 dissect_q931_channel_identification_ie(tvbuff_t *tvb, int offset, int len,
1170 int identifier_offset;
1172 guint8 coding_standard;
1176 octet = tvb_get_guint8(tvb, offset);
1177 proto_tree_add_text(tree, tvb, offset, 1,
1178 "Interface %s identified",
1179 (octet & Q931_INTERFACE_IDENTIFIED) ? "explicitly" : "implicitly");
1180 proto_tree_add_text(tree, tvb, offset, 1,
1182 (octet & Q931_NOT_BASIC_CHANNEL) ? "Not basic" : "Basic");
1183 proto_tree_add_text(tree, tvb, offset, 1,
1184 "Indicated channel is %s",
1185 (octet & 0x08) ? "required" : "preferred");
1186 proto_tree_add_text(tree, tvb, offset, 1,
1187 "Indicated channel is %sthe D-channel",
1188 (octet & 0x04) ? "" : "not ");
1189 if (octet & Q931_NOT_BASIC_CHANNEL) {
1190 proto_tree_add_text(tree, tvb, offset, 1,
1191 "Channel selection: %s",
1192 val_to_str(octet & 0x03, q931_not_basic_channel_selection_vals,
1195 proto_tree_add_text(tree, tvb, offset, 1,
1196 "Channel selection: %s",
1197 val_to_str(octet & 0x03, q931_basic_channel_selection_vals,
1203 if (octet & Q931_INTERFACE_IDENTIFIED) {
1204 identifier_offset = offset;
1209 octet = tvb_get_guint8(tvb, offset);
1213 } while (!(octet & Q931_IE_VL_EXTENSION));
1216 * XXX - do we want to strip off the 8th bit on the
1217 * last octet of the interface identifier?
1219 if (identifier_len != 0) {
1220 proto_tree_add_text(tree, tvb, identifier_offset,
1221 identifier_len, "Interface identifier: %s",
1223 tvb_get_ptr(tvb, identifier_offset, identifier_len),
1228 if (octet & Q931_NOT_BASIC_CHANNEL) {
1231 octet = tvb_get_guint8(tvb, offset);
1232 coding_standard = octet & 0x60;
1233 proto_tree_add_text(tree, tvb, offset, 1,
1234 "Coding standard: %s",
1235 val_to_str(coding_standard, q931_coding_standard_vals,
1237 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1239 * We don't know how the channel identifier is
1240 * encoded, so just dump it as data and be done
1243 proto_tree_add_text(tree, tvb, offset,
1245 tvb_bytes_to_str(tvb, offset, len));
1248 proto_tree_add_text(tree, tvb, offset, 1,
1249 "Channel is indicated by %s",
1250 (octet & Q931_IS_SLOT_MAP) ? "slot map" : "number");
1251 proto_tree_add_text(tree, tvb, offset, 1,
1253 (octet & Q931_IS_SLOT_MAP) ? "Map element" : "Channel",
1254 val_to_str(octet & 0x0F, q931_element_type_vals,
1255 "Unknown (0x%02X)"));
1258 * XXX - dump the channel number or slot map.
1264 * Dissect a Progress indicator information element.
1266 static const value_string q931_progress_description_vals[] = {
1267 { 0x01, "Call is not end-to-end ISDN - progress information available in-band" },
1268 { 0x02, "Destination address is non-ISDN" },
1269 { 0x03, "Origination address is non-ISDN" },
1270 { 0x04, "Call has returned to the ISDN" },
1271 { 0x05, "Interworking has occurred and has resulted in a telecommunications service change" },
1272 { 0x08, "In-band information or an appropriate pattern is now available" },
1277 dissect_q931_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
1281 guint8 coding_standard;
1285 octet = tvb_get_guint8(tvb, offset);
1286 coding_standard = octet & 0x60;
1287 proto_tree_add_text(tree, tvb, offset, 1,
1288 "Coding standard: %s",
1289 val_to_str(coding_standard, q931_cause_coding_standard_vals, NULL));
1290 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1292 * We don't know how the progress indicator is encoded,
1293 * so just dump it as data and be done with it.
1295 proto_tree_add_text(tree, tvb, offset,
1297 tvb_bytes_to_str(tvb, offset, len));
1300 proto_tree_add_text(tree, tvb, offset, 1,
1302 val_to_str(octet & 0x0F, q931_cause_location_vals,
1309 octet = tvb_get_guint8(tvb, offset);
1310 proto_tree_add_text(tree, tvb, offset, 1,
1311 "Progress description: %s",
1312 val_to_str(octet & 0x7F, q931_progress_description_vals,
1313 "Unknown (0x%02X)"));
1317 * Dissect a Network-specific facilities or Transit network selection
1318 * information element.
1320 static const value_string q931_netid_type_vals[] = {
1321 { 0x00, "User specified" },
1322 { 0x20, "National network identification" },
1323 { 0x30, "International network identification" },
1327 static const value_string q931_netid_plan_vals[] = {
1328 { 0x00, "Unknown" },
1329 { 0x01, "Carrier Identification Code" },
1330 { 0x03, "X.121 data network identification code" },
1335 dissect_q931_ns_facilities_ie(tvbuff_t *tvb, int offset, int len,
1343 octet = tvb_get_guint8(tvb, offset);
1344 netid_len = octet & 0x7F;
1345 proto_tree_add_text(tree, tvb, offset, 1,
1346 "Network identification length: %u",
1350 if (netid_len != 0) {
1353 octet = tvb_get_guint8(tvb, offset);
1354 proto_tree_add_text(tree, tvb, offset, 1,
1355 "Type of network identification: %s",
1356 val_to_str(octet & 0x70, q931_netid_type_vals,
1357 "Unknown (0x%02X)"));
1358 proto_tree_add_text(tree, tvb, offset, 1,
1359 "Network identification plan: %s",
1360 val_to_str(octet & 0x0F, q931_netid_plan_vals,
1361 "Unknown (0x%02X)"));
1368 if (netid_len > len)
1370 if (netid_len != 0) {
1371 proto_tree_add_text(tree, tvb, offset, netid_len,
1372 "Network identification: %s",
1373 tvb_format_text(tvb, offset, netid_len));
1374 offset += netid_len;
1380 * Whatever is left is the network-specific facility
1385 proto_tree_add_text(tree, tvb, offset,
1386 len, "Network-specific facility specification: %s",
1387 tvb_bytes_to_str(tvb, offset, len));
1391 * Dissect a Notification indicator information element.
1393 static const value_string q931_notification_description_vals[] = {
1394 { 0x00, "User suspended" },
1395 { 0x01, "User resumed" },
1396 { 0x02, "Bearer service change" },
1401 dissect_q931_notification_indicator_ie(tvbuff_t *tvb, int offset, int len,
1408 octet = tvb_get_guint8(tvb, offset);
1409 proto_tree_add_text(tree, tvb, offset, 1,
1410 "Notification description: %s",
1411 val_to_str(octet & 0x7F, q931_notification_description_vals,
1412 "Unknown (0x%02X)"));
1416 * Dissect a Date/time information element.
1419 dissect_q931_date_time_ie(tvbuff_t *tvb, int offset, int len,
1423 proto_tree_add_text(tree, tvb, offset, len,
1424 "Date/time: length is %d, should be 6\n", len);
1428 * XXX - what is "year" relative to? Is "month" 0-origin or
1429 * 1-origin? Q.931 doesn't say....
1431 proto_tree_add_text(tree, tvb, offset, 6,
1432 "Date/time: %02u-%02u-%02u %02u:%02u:%02u",
1433 tvb_get_guint8(tvb, offset + 0), tvb_get_guint8(tvb, offset + 1), tvb_get_guint8(tvb, offset + 2),
1434 tvb_get_guint8(tvb, offset + 3), tvb_get_guint8(tvb, offset + 4), tvb_get_guint8(tvb, offset + 5));
1438 * Dissect a Signal information element.
1440 static const value_string q931_signal_vals[] = {
1441 { 0x00, "Dial tone on" },
1442 { 0x01, "Ring tone on" },
1443 { 0x02, "Intercept tone on" },
1444 { 0x03, "Network congestion tone on" }, /* "fast busy" */
1445 { 0x04, "Busy tone on" },
1446 { 0x05, "Confirm tone on" },
1447 { 0x06, "Answer tone on" },
1448 { 0x07, "Call waiting tone on" },
1449 { 0x08, "Off-hook warning tone on" },
1450 { 0x09, "Preemption tone on" },
1451 { 0x3F, "Tones off" },
1452 { 0x40, "Alerting on - pattern 0" },
1453 { 0x41, "Alerting on - pattern 1" },
1454 { 0x42, "Alerting on - pattern 2" },
1455 { 0x43, "Alerting on - pattern 3" },
1456 { 0x44, "Alerting on - pattern 4" },
1457 { 0x45, "Alerting on - pattern 5" },
1458 { 0x46, "Alerting on - pattern 6" },
1459 { 0x47, "Alerting on - pattern 7" },
1460 { 0x4F, "Alerting off" },
1465 dissect_q931_signal_ie(tvbuff_t *tvb, int offset, int len,
1469 proto_tree_add_text(tree, tvb, offset, len,
1470 "Signal: length is %d, should be 1\n", len);
1473 proto_tree_add_text(tree, tvb, offset, 1,
1475 val_to_str(tvb_get_guint8(tvb, offset), q931_signal_vals,
1476 "Unknown (0x%02X)"));
1480 * Dissect an Information rate information element.
1482 static const value_string q931_throughput_class_vals[] = {
1483 { 0x03, "75 bit/s" },
1484 { 0x04, "150 bit/s" },
1485 { 0x05, "300 bit/s" },
1486 { 0x06, "600 bit/s" },
1487 { 0x07, "1200 bit/s" },
1488 { 0x08, "2400 bit/s" },
1489 { 0x09, "4800 bit/s" },
1490 { 0x0A, "9600 bit/s" },
1491 { 0x0B, "19200 bit/s" },
1492 { 0x0C, "48000 bit/s" },
1493 { 0x0D, "64000 bit/s" },
1498 dissect_q931_information_rate_ie(tvbuff_t *tvb, int offset, int len,
1502 proto_tree_add_text(tree, tvb, offset, len,
1503 "Information rate: length is %d, should be 4\n", len);
1506 proto_tree_add_text(tree, tvb, offset + 0, 1,
1507 "Incoming information rate: %s",
1508 val_to_str(tvb_get_guint8(tvb, offset + 0) & 0x1F,
1509 q931_throughput_class_vals, "Unknown (0x%02X)"));
1510 proto_tree_add_text(tree, tvb, offset + 1, 1,
1511 "Outgoing information rate: %s",
1512 val_to_str(tvb_get_guint8(tvb, offset + 1) & 0x1F,
1513 q931_throughput_class_vals, "Unknown (0x%02X)"));
1514 proto_tree_add_text(tree, tvb, offset + 2, 1,
1515 "Minimum incoming information rate: %s",
1516 val_to_str(tvb_get_guint8(tvb, offset + 2) & 0x1F,
1517 q931_throughput_class_vals, "Unknown (0x%02X)"));
1518 proto_tree_add_text(tree, tvb, offset + 3, 1,
1519 "Minimum outgoing information rate: %s",
1520 val_to_str(tvb_get_guint8(tvb, offset + 3) & 0x1F,
1521 q931_throughput_class_vals, "Unknown (0x%02X)"));
1525 dissect_q931_guint16_value(tvbuff_t *tvb, int offset, int len,
1526 proto_tree *tree, char *label)
1534 octet = tvb_get_guint8(tvb, offset);
1535 if (octet & Q931_IE_VL_EXTENSION) {
1537 * Only one octet long - error.
1541 value = (octet & 0x3) << 14;
1548 * We've reached the end of the information element - error.
1552 octet = tvb_get_guint8(tvb, offset);
1553 if (octet & Q931_IE_VL_EXTENSION) {
1555 * Only two octets long - error.
1559 value |= (octet & 0x7F) << 7;
1566 * We've reached the end of the information element - error.
1570 octet = tvb_get_guint8(tvb, offset);
1571 if (!(octet & Q931_IE_VL_EXTENSION)) {
1573 * More than three octets long - error.
1577 value |= (octet & 0x7F);
1582 proto_tree_add_text(tree, tvb, offset, value_len, "%s: %u ms", label,
1587 proto_tree_add_text(tree, tvb, offset, len,
1588 "%s goes past end of information element", label);
1592 proto_tree_add_text(tree, tvb, offset, len, "%s isn't 3 octets long",
1598 * Dissect an End-to-end transit delay information element.
1601 dissect_q931_e2e_transit_delay_ie(tvbuff_t *tvb, int offset, int len,
1608 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1609 "Cumulative transit delay");
1612 offset += value_len;
1617 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1618 "Requested end-to-end transit delay");
1621 offset += value_len;
1626 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1627 "Maximum end-to-end transit delay");
1631 * Dissect a Transit delay selection and indication information element.
1634 dissect_q931_td_selection_and_int_ie(tvbuff_t *tvb, int offset, int len,
1639 dissect_q931_guint16_value(tvb, offset, len, tree,
1644 * Dissect a Packet layer binary parameters information element.
1646 static const value_string q931_fast_selected_vals[] = {
1647 { 0x00, "Fast select not requested" },
1648 { 0x08, "Fast select not requested" },
1649 { 0x10, "Fast select requested with no restriction of response" },
1650 { 0x18, "Fast select requested with restrictions of response" },
1655 dissect_q931_pl_binary_parameters_ie(tvbuff_t *tvb, int offset, int len,
1662 octet = tvb_get_guint8(tvb, offset);
1663 proto_tree_add_text(tree, tvb, offset, 1,
1665 val_to_str(octet & 0x18, q931_fast_selected_vals, NULL));
1666 proto_tree_add_text(tree, tvb, offset, 1,
1668 (octet & 0x04) ? "No request/request denied" :
1669 "Request indicated/request accepted");
1670 proto_tree_add_text(tree, tvb, offset, 1,
1672 (octet & 0x02) ? "Link-by-link" : "End-to-end");
1673 proto_tree_add_text(tree, tvb, offset, 1,
1674 "Modulus %u sequencing",
1675 (octet & 0x01) ? 8 : 128);
1679 * Dissect a Packet layer window size information element.
1682 dissect_q931_pl_window_size_ie(tvbuff_t *tvb, int offset, int len,
1687 proto_tree_add_text(tree, tvb, offset, 1,
1688 "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1694 proto_tree_add_text(tree, tvb, offset, 1,
1695 "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1699 * Dissect a Packet size information element.
1702 dissect_q931_packet_size_ie(tvbuff_t *tvb, int offset, int len,
1707 proto_tree_add_text(tree, tvb, offset, 1,
1708 "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1714 proto_tree_add_text(tree, tvb, offset, 1,
1715 "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1719 * Dissect a Closed user group information element.
1721 static const value_string q931_cug_indication_vals[] = {
1722 { 0x01, "Closed user group selection" },
1723 { 0x02, "Closed user group with outgoing access selection and indication" },
1728 dissect_q931_cug_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree)
1732 proto_tree_add_text(tree, tvb, offset, 1,
1733 "CUG indication: %s",
1734 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1735 q931_cug_indication_vals, "Unknown (0x%02X)"));
1741 proto_tree_add_text(tree, tvb, offset, len, "CUG index code: %s",
1742 tvb_format_text(tvb, offset, len));
1746 * Dissect a Reverse charging indication information element.
1748 static const value_string q931_reverse_charging_indication_vals[] = {
1749 { 0x01, "Reverse charging requested" },
1754 dissect_q931_reverse_charge_ind_ie(tvbuff_t *tvb, int offset, int len,
1759 proto_tree_add_text(tree, tvb, offset, 1,
1760 "Reverse charging indication: %s",
1761 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1762 q931_reverse_charging_indication_vals, "Unknown (0x%02X)"));
1766 * Dissect a (phone) number information element.
1768 static const value_string q931_number_type_vals[] = {
1769 { 0x00, "Unknown" },
1770 { 0x10, "International number" },
1771 { 0x20, "National number" },
1772 { 0x30, "Network specific number" },
1773 { 0x40, "Subscriber number" },
1774 { 0x60, "Abbreviated number" },
1778 static const value_string q931_numbering_plan_vals[] = {
1779 { 0x00, "Unknown" },
1780 { 0x01, "E.164 ISDN/telephony numbering" },
1781 { 0x03, "X.121 data numbering" },
1782 { 0x04, "F.69 Telex numbering" },
1783 { 0x08, "National standard numbering" },
1784 { 0x09, "Private numbering" },
1788 static const value_string q931_presentation_indicator_vals[] = {
1789 { 0x00, "Presentation allowed" },
1790 { 0x20, "Presentation restricted" },
1791 { 0x40, "Number not available due to interworking" },
1795 static const value_string q931_screening_indicator_vals[] = {
1796 { 0x00, "User-provided, not screened" },
1797 { 0x01, "User-provided, verified and passed" },
1798 { 0x02, "User-provided, verified and failed" },
1799 { 0x03, "Network-provided" },
1803 static const value_string q931_redirection_reason_vals[] = {
1804 { 0x00, "Unknown" },
1805 { 0x01, "Call forwarding busy or called DTE busy" },
1806 { 0x02, "Call forwarding no reply" },
1807 { 0x04, "Call deflection" },
1808 { 0x09, "Called DTE out of order" },
1809 { 0x0A, "Call forwarding by the called DTE" },
1810 { 0x0F, "Call forwarding unconditional or systematic call redirection" },
1815 dissect_q931_number_ie(tvbuff_t *tvb, int offset, int len,
1822 octet = tvb_get_guint8(tvb, offset);
1823 proto_tree_add_text(tree, tvb, offset, 1,
1824 "Type of number: %s",
1825 val_to_str(octet & 0x70, q931_number_type_vals,
1826 "Unknown (0x%02X)"));
1827 proto_tree_add_text(tree, tvb, offset, 1,
1828 "Numbering plan: %s",
1829 val_to_str(octet & 0x0F, q931_numbering_plan_vals,
1830 "Unknown (0x%02X)"));
1834 if (!(octet & Q931_IE_VL_EXTENSION)) {
1837 octet = tvb_get_guint8(tvb, offset);
1838 proto_tree_add_text(tree, tvb, offset, 1,
1839 "Presentation indicator: %s",
1840 val_to_str(octet & 0x60, q931_presentation_indicator_vals,
1842 proto_tree_add_text(tree, tvb, offset, 1,
1843 "Screening indicator: %s",
1844 val_to_str(octet & 0x03, q931_screening_indicator_vals,
1851 * XXX - only in a Redirecting number information element.
1853 if (!(octet & Q931_IE_VL_EXTENSION)) {
1856 octet = tvb_get_guint8(tvb, offset);
1857 proto_tree_add_text(tree, tvb, offset, 1,
1858 "Reason for redirection: %s",
1859 val_to_str(octet & 0x0F, q931_redirection_reason_vals,
1867 proto_tree_add_text(tree, tvb, offset, len, "Number: %s",
1868 tvb_format_text(tvb, offset, len));
1872 * Dissect a party subaddress information element.
1874 static const value_string q931_subaddress_type_vals[] = {
1875 { 0x00, "X.213/ISO 8348 Add.2 NSAP" },
1876 { 0x20, "User-specified" },
1880 static const value_string q931_odd_even_indicator_vals[] = {
1881 { 0x00, "Even number of address signals" },
1882 { 0x10, "Odd number of address signals" },
1887 dissect_q931_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
1894 octet = tvb_get_guint8(tvb, offset);
1895 proto_tree_add_text(tree, tvb, offset, 1,
1896 "Type of subaddress: %s",
1897 val_to_str(octet & 0x70, q931_subaddress_type_vals,
1898 "Unknown (0x%02X)"));
1899 proto_tree_add_text(tree, tvb, offset, 1,
1900 "Odd/even indicator: %s",
1901 val_to_str(octet & 0x10, q931_odd_even_indicator_vals,
1908 proto_tree_add_text(tree, tvb, offset, len, "Subaddress: %s",
1909 tvb_bytes_to_str(tvb, offset, len));
1913 * Dissect a Restart indicator information element.
1915 static const value_string q931_restart_indicator_class_vals[] = {
1916 { 0x00, "Indicated channels" },
1917 { 0x06, "Single interface" },
1918 { 0x07, "All interfaces" },
1923 dissect_q931_restart_indicator_ie(tvbuff_t *tvb, int offset, int len,
1927 proto_tree_add_text(tree, tvb, offset, len,
1928 "Restart indicator: length is %d, should be 1\n", len);
1931 proto_tree_add_text(tree, tvb, offset, 1,
1932 "Restart indicator: %s",
1933 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1934 q931_restart_indicator_class_vals, "Unknown (0x%02X)"));
1938 * Dissect a High-layer compatibility information element.
1940 #define Q931_AUDIOVISUAL 0x60
1941 static const value_string q931_high_layer_characteristics_vals[] = {
1942 { 0x01, "Telephony" },
1943 { 0x04, "F.182 Facsimile Group 2/3" },
1944 { 0x21, "F.184 Facsimile Group 4 Class I" },
1945 { 0x24, "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
1946 { 0x28, "F.220 Teletex, basic and processable mode" },
1947 { 0x31, "F.200 Teletex, basic mode" },
1948 { 0x32, "F.300 and T.102 syntax-based Videotex" },
1949 { 0x33, "F.300 and T.101 international Videotex interworking" },
1950 { 0x35, "F.60 Telex" },
1951 { 0x38, "X.400 Message Handling Systems" },
1952 { 0x41, "X.200 OSI application" },
1953 { 0x42, "FTAM application" },
1954 { 0x5E, "Reserved for maintenance" },
1955 { 0x5F, "Reserved for management" },
1956 { Q931_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
1957 { 0x61, "F.702 and F.731 Profile 1b videoconferencing" },
1958 { 0x62, "F.702 and F.731 audiographic conferencing" },
1962 static const value_string q931_audiovisual_characteristics_vals[] = {
1963 { 0x01, "Capability set of initial channel of H.221" },
1964 { 0x02, "Capability set of subsequent channel of H.221" },
1965 { 0x21, "Capability set of initial channel of an active 3.1kHz audio or speech call" },
1970 dissect_q931_high_layer_compat_ie(tvbuff_t *tvb, int offset, int len,
1974 guint8 coding_standard;
1975 guint8 characteristics;
1979 octet = tvb_get_guint8(tvb, offset);
1980 coding_standard = octet & 0x60;
1981 proto_tree_add_text(tree, tvb, offset, 1,
1982 "Coding standard: %s",
1983 val_to_str(coding_standard, q931_coding_standard_vals, NULL));
1984 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1986 * We don't know how the call state is encoded,
1987 * so just dump it as data and be done with it.
1989 proto_tree_add_text(tree, tvb, offset,
1991 tvb_bytes_to_str(tvb, offset, len));
1997 octet = tvb_get_guint8(tvb, offset);
1998 characteristics = octet & 0x7F;
1999 proto_tree_add_text(tree, tvb, offset, 1,
2000 "High layer characteristics identification: %s",
2001 val_to_str(characteristics, q931_high_layer_characteristics_vals,
2002 "Unknown (0x%02X)"));
2006 if (!(octet & Q931_IE_VL_EXTENSION)) {
2009 octet = tvb_get_guint8(tvb, offset);
2010 if (characteristics == Q931_AUDIOVISUAL) {
2011 proto_tree_add_text(tree, tvb, offset, 1,
2012 "Extended audiovisual characteristics identification: %s",
2013 val_to_str(octet & 0x7F,
2014 q931_audiovisual_characteristics_vals,
2015 "Unknown (0x%02X)"));
2017 proto_tree_add_text(tree, tvb, offset, 1,
2018 "Extended high layer characteristics identification: %s",
2019 val_to_str(octet & 0x7F,
2020 q931_high_layer_characteristics_vals,
2021 "Unknown (0x%02X)"));
2028 * Dissect a User-user information element.
2030 #define Q931_PROTOCOL_DISCRIMINATOR_IA5 0x04
2032 static const value_string q931_protocol_discriminator_vals[] = {
2033 { 0x00, "User-specific protocol" },
2034 { 0x01, "OSI high layer protocols" },
2036 { Q931_PROTOCOL_DISCRIMINATOR_IA5, "IA5 characters" },
2037 { 0x05, "X.208 and X.209 coded user information" },
2038 { 0x07, "V.120 rate adaption" },
2039 { 0x08, "Q.931/I.451 user-network call control messages" },
2044 dissect_q931_user_user_ie(tvbuff_t *tvb, int offset, int len,
2051 octet = tvb_get_guint8(tvb, offset);
2052 proto_tree_add_text(tree, tvb, offset, 1,
2053 "Protocol discriminator: %s",
2054 val_to_str(octet, q931_protocol_discriminator_vals,
2055 "Unknown (0x%02x)"));
2063 case Q931_PROTOCOL_DISCRIMINATOR_IA5:
2064 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
2065 tvb_format_text(tvb, offset, len));
2069 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
2070 tvb_bytes_to_str(tvb, offset, len));
2076 * Dissect information elements consisting of ASCII^H^H^H^H^HIA5 text.
2079 dissect_q931_ia5_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
2083 proto_tree_add_text(tree, tvb, offset, len, "%s: %s", label,
2084 tvb_format_text(tvb, offset, len));
2088 static const value_string q931_codeset_vals[] = {
2089 { 0x00, "Q.931 information elements" },
2090 { 0x04, "Information elements for ISO/IEC use" },
2091 { 0x05, "Information elements for national use" },
2092 { 0x06, "Information elements specific to the local network" },
2093 { 0x07, "User-specific information elements" },
2098 q931_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2099 gboolean started_heuristic)
2102 proto_tree *q931_tree = NULL;
2104 proto_tree *ie_tree;
2105 guint8 call_ref_len;
2106 guint8 call_ref[15];
2107 guint8 message_type;
2108 guint8 info_element;
2109 guint16 info_element_len;
2111 gboolean non_locking_shift;
2112 guint8 protocol_discriminator;
2117 gboolean is_h323_h225 = FALSE;
2119 * It is very much possible to find a TPKT header here
2120 * TPKT is defined in RFC 1006 as a wrapper around ISO
2121 * defined protocols. There could even be several TPKT
2122 * wrapped messages in one TCP data field...
2123 * XXXXXXXX THIS IS NOT IMPLEMENTED YET!!! XXXXXXXXXXX
2125 * For Q.931 related messages this is easy. If a
2126 * protocol discriminator is found with a value of 3
2127 * and it's the first discriminator in the Q.931
2128 * message one can safely assume it to be a TPKT
2129 * header. See also Q.931 Table 4-1/Q.931
2133 protocol_discriminator = tvb_get_guint8( tvb, offset );
2134 /* Keep the protocol discriminator for later use */
2136 if ( started_heuristic ) {
2138 * The heuristic Q.931 message should conform to this
2140 if ( protocol_discriminator != NLPID_Q_931 )
2143 if ( ! is_tpkt( tvb, &offset ) )
2146 if ( tvb_length_remaining( tvb, offset ) <= 3 )
2151 * The first byte should be < 8 (3 is TPKT, rest is Q.931)
2153 if ( protocol_discriminator < NLPID_Q_931 ) {
2155 * The minimum length of a Q.931 message is 3:
2156 * 1 byte for the protocol discriminator,
2157 * 1 for the call_reference length,
2158 * and one for the message type.
2160 if ( tvb_length_remaining( tvb, offset ) <= 3 )
2164 * OK, there are a couple of bytes available, but is there
2165 * also a protocol discriminator?
2167 if ( tvb_length_remaining( tvb, offset ) > 4 ) {
2168 /* Reread the protocol discriminator */
2169 protocol_discriminator =
2170 tvb_get_guint8( tvb, offset + 4);
2172 /* No discriminator available */
2173 protocol_discriminator = 0;
2177 * If it's not H.323 related Q.931 no heuristic action needed
2178 * Dangerous, there might be other uses for this code.....
2180 if (started_heuristic && protocol_discriminator != NLPID_Q_931)
2184 * Always check if it's a real TPKT message
2186 if ( ! is_tpkt( tvb, &offset ) )
2189 lv_tpkt_len = dissect_tpkt_header( tvb, &offset, pinfo, tree );
2190 if (lv_tpkt_len == -1) {
2192 * TPKT isn't enabled.
2198 * Check if it's an empty TPKT message (the next one might be a
2199 * real Q.931 message)
2202 if ( tvb_length_remaining( tvb, offset ) < lv_tpkt_len - 4 ) {
2207 * Reset the current_proto variable because dissect_tpkt
2210 if ( started_heuristic )
2211 pinfo->current_proto = "Q.931 HEUR";
2213 pinfo->current_proto = "Q.931";
2217 * The minimum length of a Q.931 message is
2218 * 3, 1 byte for the protocol discr. 1 for the call_reference length,
2219 * and one for the message type.
2221 if ( tvb_length_remaining( tvb, offset ) <= 3 ) {
2225 if (check_col(pinfo->fd, COL_PROTOCOL))
2226 col_set_str(pinfo->fd, COL_PROTOCOL, "Q.931");
2229 ti = proto_tree_add_item(tree, proto_q931, tvb, offset,
2230 tvb_length(tvb), FALSE);
2231 q931_tree = proto_item_add_subtree(ti, ett_q931);
2233 dissect_q931_protocol_discriminator(tvb, offset, q931_tree);
2236 call_ref_len = tvb_get_guint8(tvb, offset) & 0xF; /* XXX - do as a bit field? */
2237 if (q931_tree != NULL)
2238 proto_tree_add_uint(q931_tree, hf_q931_call_ref_len, tvb, offset, 1, call_ref_len);
2240 if (call_ref_len != 0) {
2241 /* XXX - split this into flag and value */
2242 tvb_memcpy(tvb, call_ref, offset, call_ref_len);
2243 if (q931_tree != NULL)
2244 proto_tree_add_bytes(q931_tree, hf_q931_call_ref, tvb, offset, call_ref_len, call_ref);
2245 offset += call_ref_len;
2247 message_type = tvb_get_guint8(tvb, offset);
2248 if (check_col(pinfo->fd, COL_INFO)) {
2249 col_add_str(pinfo->fd, COL_INFO,
2250 val_to_str(message_type, q931_message_type_vals,
2251 "Unknown message type (0x%02X)"));
2253 if (q931_tree != NULL)
2254 proto_tree_add_uint(q931_tree, hf_q931_message_type, tvb, offset, 1, message_type);
2258 * And now for the information elements....
2260 codeset = 0; /* start out in codeset 0 */
2261 non_locking_shift = TRUE;
2262 while (tvb_reported_length_remaining(tvb, offset) > 0) {
2263 info_element = tvb_get_guint8(tvb, offset);
2266 * Check for the single-octet IEs.
2268 switch (info_element & Q931_IE_SO_IDENTIFIER_MASK) {
2272 !(info_element & Q931_IE_SHIFT_LOCKING);
2273 codeset = info_element & Q931_IE_SHIFT_CODESET;
2274 if (q931_tree != NULL) {
2275 proto_tree_add_text(q931_tree, tvb, offset, 1,
2276 "%s shift to codeset %u: %s",
2277 (non_locking_shift ? "Non-locking" : "Locking"),
2279 val_to_str(codeset, q931_codeset_vals,
2280 "Unknown (0x%02X)"));
2285 case Q931_IE_MORE_DATA_OR_SEND_COMP:
2286 switch (info_element) {
2288 case Q931_IE_MORE_DATA:
2289 if (q931_tree != NULL) {
2290 proto_tree_add_text(q931_tree, tvb, offset, 1,
2295 case Q931_IE_SENDING_COMPLETE:
2296 if (q931_tree != NULL) {
2297 proto_tree_add_text(q931_tree, tvb, offset, 1,
2298 "Sending complete");
2303 if (q931_tree != NULL) {
2304 proto_tree_add_text(q931_tree, tvb, offset, 1,
2305 "Unknown information element (0x%02X",
2311 if (non_locking_shift)
2315 case Q931_IE_CONGESTION_LEVEL:
2316 if (q931_tree != NULL) {
2317 proto_tree_add_text(q931_tree, tvb, offset, 1,
2318 "Congestion level: %s",
2319 val_to_str(info_element & Q931_IE_SO_IE_MASK,
2320 q931_congestion_level_vals,
2324 if (non_locking_shift)
2328 case Q931_IE_REPEAT_INDICATOR:
2329 if (q931_tree != NULL) {
2330 proto_tree_add_text(q931_tree, tvb, offset, 1,
2331 "Repeat indicator: %s",
2332 val_to_str(info_element & Q931_IE_SO_IE_MASK,
2333 q931_repeat_indication_vals,
2337 if (non_locking_shift)
2346 * Variable-length IE.
2349 info_element_len = tvb_get_guint8(tvb, offset + 1);
2352 * According to page 18 from Recommendation H.225.0 :
2353 * " Length of user-user contents contents
2354 * - Shall be 2 octets instead of 1 (as in Figure 4-36/Q.931)"
2356 * This will be true for all messages going to / from TCP port
2357 * 1720 and with the first and fourth octet of the user-user
2358 * IE having the values 0x7E and 0x05 resp.
2359 * See http://www.mbuf.org/~moto/h323/h323decoder.html
2363 if ( ( tvb_get_guint8( tvb, offset ) == 0x7E ) &&
2364 ( tvb_get_guint8( tvb, offset + 3 ) == 0x05 ) &&
2365 /* ( ( pinfo->srcport == 1720 ) || ( pinfo->destport == 1720 ) ) && */
2366 ( protocol_discriminator == NLPID_Q_931 ) ) {
2367 info_element_len = tvb_get_ntohs( tvb, offset + 1 );
2368 is_h323_h225 = TRUE;
2369 if ( tree == NULL ) {
2370 h225_tvb = tvb_new_subset( tvb, offset + 4, info_element_len - 1, info_element_len - 1 );
2371 dissect_h225_cs( h225_tvb, pinfo, tree );
2373 * Skip the 4 bytes of the element header and then the element itself
2376 offset += info_element_len - 1;
2379 info_element_len = tvb_get_guint8( tvb, offset + 1 );
2382 if (q931_tree != NULL) {
2385 ti = proto_tree_add_text(q931_tree, tvb, offset,
2387 val_to_str(info_element,
2388 q931_info_element_vals,
2389 "Unknown information element (0x%02X)"));
2390 ie_tree = proto_item_add_subtree(ti,
2392 proto_tree_add_text(ie_tree, tvb, offset, 1,
2393 "Information element: %s",
2394 val_to_str(info_element,
2395 q931_info_element_vals, "Unknown (0x%02X)"));
2396 proto_tree_add_text(ie_tree, tvb, offset + 1,
2397 2, "Length: %u", info_element_len);
2400 ti = proto_tree_add_text(q931_tree, tvb, offset,
2401 1+1+info_element_len, "%s",
2402 val_to_str(info_element, q931_info_element_vals,
2403 "Unknown information element (0x%02X)"));
2404 ie_tree = proto_item_add_subtree(ti, ett_q931_ie);
2405 proto_tree_add_text(ie_tree, tvb, offset, 1,
2406 "Information element: %s",
2407 val_to_str(info_element, q931_info_element_vals,
2408 "Unknown (0x%02X)"));
2409 proto_tree_add_text(ie_tree, tvb, offset + 1, 1,
2410 "Length: %u", info_element_len);
2414 switch (info_element) {
2416 case Q931_IE_SEGMENTED_MESSAGE:
2417 dissect_q931_segmented_message_ie(tvb,
2418 offset + 2, info_element_len, ie_tree);
2421 case Q931_IE_BEARER_CAPABILITY:
2422 case Q931_IE_LOW_LAYER_COMPAT:
2423 dissect_q931_bearer_capability_ie(tvb,
2424 offset + 2, info_element_len, ie_tree);
2428 dissect_q931_cause_ie(tvb,
2429 offset + 2, info_element_len, ie_tree);
2432 case Q931_IE_CALL_STATE:
2433 dissect_q931_call_state_ie(tvb,
2434 offset + 2, info_element_len, ie_tree);
2437 case Q931_IE_CHANNEL_IDENTIFICATION:
2438 dissect_q931_channel_identification_ie(tvb,
2439 offset + 2, info_element_len, ie_tree);
2442 case Q931_IE_PROGRESS_INDICATOR:
2443 dissect_q931_progress_indicator_ie(tvb,
2444 offset + 2, info_element_len, ie_tree);
2447 case Q931_IE_NETWORK_SPECIFIC_FACIL:
2448 case Q931_IE_TRANSIT_NETWORK_SEL:
2449 dissect_q931_ns_facilities_ie(tvb,
2450 offset + 2, info_element_len, ie_tree);
2453 case Q931_IE_NOTIFICATION_INDICATOR:
2454 dissect_q931_notification_indicator_ie(tvb,
2455 offset + 2, info_element_len, ie_tree);
2458 case Q931_IE_DISPLAY:
2459 dissect_q931_ia5_ie(tvb, offset + 2,
2460 info_element_len, ie_tree,
2461 "Display information");
2464 case Q931_IE_DATE_TIME:
2465 dissect_q931_date_time_ie(tvb,
2466 offset + 2, info_element_len, ie_tree);
2469 case Q931_IE_KEYPAD_FACILITY:
2470 dissect_q931_ia5_ie(tvb, offset + 2,
2471 info_element_len, ie_tree,
2475 case Q931_IE_SIGNAL:
2476 dissect_q931_signal_ie(tvb,
2477 offset + 2, info_element_len, ie_tree);
2480 case Q931_IE_INFORMATION_RATE:
2481 dissect_q931_information_rate_ie(tvb,
2482 offset + 2, info_element_len, ie_tree);
2485 case Q931_IE_E2E_TRANSIT_DELAY:
2486 dissect_q931_e2e_transit_delay_ie(tvb,
2487 offset + 2, info_element_len, ie_tree);
2490 case Q931_IE_TD_SELECTION_AND_INT:
2491 dissect_q931_td_selection_and_int_ie(tvb,
2492 offset + 2, info_element_len, ie_tree);
2495 case Q931_IE_PL_BINARY_PARAMETERS:
2496 dissect_q931_pl_binary_parameters_ie(tvb,
2497 offset + 2, info_element_len, ie_tree);
2500 case Q931_IE_PL_WINDOW_SIZE:
2501 dissect_q931_pl_window_size_ie(tvb,
2502 offset + 2, info_element_len, ie_tree);
2505 case Q931_IE_PACKET_SIZE:
2506 dissect_q931_packet_size_ie(tvb,
2507 offset + 2, info_element_len, ie_tree);
2511 dissect_q931_cug_ie(tvb,
2512 offset + 2, info_element_len, ie_tree);
2515 case Q931_IE_REVERSE_CHARGE_IND:
2516 dissect_q931_reverse_charge_ind_ie(tvb,
2517 offset + 2, info_element_len, ie_tree);
2520 case Q931_IE_CALLING_PARTY_NUMBER:
2521 case Q931_IE_CALLED_PARTY_NUMBER:
2522 case Q931_IE_REDIRECTING_NUMBER:
2523 dissect_q931_number_ie(tvb,
2524 offset + 2, info_element_len, ie_tree);
2527 case Q931_IE_CALLING_PARTY_SUBADDR:
2528 case Q931_IE_CALLED_PARTY_SUBADDR:
2529 dissect_q931_party_subaddr_ie(tvb,
2530 offset + 2, info_element_len, ie_tree);
2533 case Q931_IE_RESTART_INDICATOR:
2534 dissect_q931_restart_indicator_ie(tvb,
2535 offset + 2, info_element_len, ie_tree);
2538 case Q931_IE_HIGH_LAYER_COMPAT:
2539 dissect_q931_high_layer_compat_ie(tvb,
2540 offset + 2, info_element_len, ie_tree);
2543 case Q931_IE_USER_USER:
2546 h225_tvb = tvb_new_subset(tvb,
2547 offset + 4, info_element_len - 1,
2548 info_element_len - 1);
2549 dissect_h225_cs(h225_tvb, pinfo, tree);
2551 proto_tree_add_text(ie_tree, tvb,
2553 "Protocol discriminator: %s",
2554 val_to_str(tvb_get_guint8(tvb, offset),
2555 q931_protocol_discriminator_vals,
2556 "Unknown (0x%02x)"));
2557 offset += info_element_len;
2560 dissect_q931_user_user_ie(tvb,
2561 offset + 2, info_element_len,
2569 proto_tree_add_text(ie_tree, tvb, offset + 2,
2570 info_element_len, "Data: %s",
2572 tvb_get_ptr(tvb, offset + 2, info_element_len),
2577 offset += 1 + 1 + info_element_len;
2578 if (non_locking_shift)
2583 * Heuristic should return TRUE if it get's here.
2591 dissect_q931_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2594 * XXX - should this be heuristic, or should we just make
2595 * port 1720 do Q.931-inside-TPKT; that port appears to be
2596 * intended for H.323 calls, according to
2598 * http://www.isi.edu/in-notes/iana/assignments/port-numbers
2600 * which says it's for "h323hostcall"?
2602 pinfo->current_proto = "Q.931 HEUR";
2603 return q931_dissector(tvb, pinfo, tree, TRUE);
2607 dissect_q931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2609 q931_dissector(tvb, pinfo, tree, FALSE);
2613 proto_register_q931(void)
2615 static hf_register_info hf[] = {
2616 { &hf_q931_discriminator,
2617 { "Protocol discriminator", "q931.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
2620 { &hf_q931_call_ref_len,
2621 { "Call reference value length", "q931.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
2624 { &hf_q931_call_ref,
2625 { "Call reference value", "q931.call_ref", FT_BYTES, BASE_HEX, NULL, 0x0,
2628 { &hf_q931_message_type,
2629 { "Message type", "q931.message_type", FT_UINT8, BASE_HEX, VALS(q931_message_type_vals), 0x0,
2633 static gint *ett[] = {
2638 proto_q931 = proto_register_protocol("Q.931", "Q.931", "q931");
2639 proto_register_field_array (proto_q931, hf, array_length(hf));
2640 proto_register_subtree_array(ett, array_length(ett));
2642 register_dissector("q931", dissect_q931, proto_q931);
2646 proto_reg_handoff_q931(void)
2648 heur_dissector_add("tcp", dissect_q931_heur, proto_q931);