2 * Routines for Q.931 frame disassembly
3 * Guy Harris <guy@alum.mit.edu>
5 * $Id: packet-q931.c,v 1.51 2003/02/28 23:16:15 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.
35 #include <epan/packet.h>
36 #include <epan/strutil.h>
38 #include "packet-q931.h"
41 #include "packet-tpkt.h"
45 * http://www.acacia-net.com/Clarinet/Protocol/q9313svn.htm
46 * http://www.acacia-net.com/Clarinet/Protocol/q9311sc3.htm
47 * http://www.acacia-net.com/Clarinet/Protocol/q9317oz7.htm
48 * http://www.protocols.com/pbook/isdn.htm
49 * http://freesoft.org/CIE/Topics/126.htm
50 * http://noc.comstar.ru/miscdocs/ascend-faq-cause-codes.html
51 * http://www.andrews-arnold.co.uk/isdn/q931cause.html
52 * http://www.tulatelecom.ru/staff/german/DSSHelp/MessList/InfEl/InfElList.html
55 static int proto_q931 = -1;
56 static int hf_q931_discriminator = -1;
57 static int hf_q931_call_ref_len = -1;
58 static int hf_q931_call_ref_flag = -1;
59 static int hf_q931_call_ref = -1;
60 static int hf_q931_message_type = -1;
61 static int hf_q931_cause_value = -1;
62 static int hf_q931_calling_party_number = -1;
63 static int hf_q931_called_party_number = -1;
64 static int hf_q931_connected_number = -1;
65 static int hf_q931_redirecting_number = -1;
67 static gint ett_q931 = -1;
68 static gint ett_q931_ie = -1;
70 /* desegmentation of Q.931 over TPKT over TCP */
71 static gboolean q931_desegment = TRUE;
73 static dissector_handle_t h225_handle;
74 static dissector_handle_t q931_tpkt_pdu_handle;
77 * Q.931 message types.
79 #define Q931_ESCAPE 0x00
80 #define Q931_ALERTING 0x01
81 #define Q931_CALL_PROCEEDING 0x02
82 #define Q931_CONNECT 0x07
83 #define Q931_CONNECT_ACK 0x0F
84 #define Q931_PROGRESS 0x03
85 #define Q931_SETUP 0x05
86 #define Q931_SETUP_ACK 0x0D
87 #define Q931_HOLD 0x24
88 #define Q931_HOLD_ACK 0x28
89 #define Q931_HOLD_REJECT 0x30
90 #define Q931_RESUME 0x26
91 #define Q931_RESUME_ACK 0x2E
92 #define Q931_RESUME_REJECT 0x22
93 #define Q931_RETRIEVE 0x31
94 #define Q931_RETRIEVE_ACK 0x33
95 #define Q931_RETRIEVE_REJECT 0x37
96 #define Q931_SUSPEND 0x25
97 #define Q931_SUSPEND_ACK 0x2D
98 #define Q931_SUSPEND_REJECT 0x21
99 #define Q931_USER_INFORMATION 0x20
100 #define Q931_DISCONNECT 0x45
101 #define Q931_RELEASE 0x4D
102 #define Q931_RELEASE_COMPLETE 0x5A
103 #define Q931_RESTART 0x46
104 #define Q931_RESTART_ACK 0x4E
105 #define Q931_CONGESTION_CONTROL 0x79
106 #define Q931_FACILITY 0x62
107 #define Q931_INFORMATION 0x7B
108 #define Q931_NOTIFY 0x6E
109 #define Q931_REGISTER 0x64
110 #define Q931_SEGMENT 0x60
111 #define Q931_STATUS 0x7D
112 #define Q931_STATUS_ENQUIRY 0x75
114 static const value_string q931_message_type_vals[] = {
115 { Q931_ESCAPE, "ESCAPE" },
116 { Q931_ALERTING, "ALERTING" },
117 { Q931_CALL_PROCEEDING, "CALL PROCEEDING" },
118 { Q931_CONNECT, "CONNECT" },
119 { Q931_CONNECT_ACK, "CONNECT ACKNOWLEDGE" },
120 { Q931_PROGRESS, "PROGRESS" },
121 { Q931_SETUP, "SETUP" },
122 { Q931_SETUP_ACK, "SETUP ACKNOWLEDGE" },
123 { Q931_HOLD, "HOLD" },
124 { Q931_HOLD_ACK, "HOLD_ACKNOWLEDGE" },
125 { Q931_HOLD_REJECT, "HOLD_REJECT" },
126 { Q931_RESUME, "RESUME" },
127 { Q931_RESUME_ACK, "RESUME ACKNOWLEDGE" },
128 { Q931_RESUME_REJECT, "RESUME REJECT" },
129 { Q931_RETRIEVE, "RETRIEVE" },
130 { Q931_RETRIEVE_ACK, "RETRIEVE ACKNOWLEDGE" },
131 { Q931_RETRIEVE_REJECT, "RETRIEVE REJECT" },
132 { Q931_SUSPEND, "SUSPEND" },
133 { Q931_SUSPEND_ACK, "SUSPEND ACKNOWLEDGE" },
134 { Q931_SUSPEND_REJECT, "SUSPEND REJECT" },
135 { Q931_USER_INFORMATION, "USER INFORMATION" },
136 { Q931_DISCONNECT, "DISCONNECT" },
137 { Q931_RELEASE, "RELEASE" },
138 { Q931_RELEASE_COMPLETE, "RELEASE COMPLETE" },
139 { Q931_RESTART, "RESTART" },
140 { Q931_RESTART_ACK, "RESTART ACKNOWLEDGE" },
141 { Q931_CONGESTION_CONTROL, "CONGESTION CONTROL" },
142 { Q931_FACILITY, "FACILITY" },
143 { Q931_INFORMATION, "INFORMATION" },
144 { Q931_NOTIFY, "NOTIFY" },
145 { Q931_REGISTER, "REGISTER" },
146 { Q931_SEGMENT, "SEGMENT" },
147 { Q931_STATUS, "STATUS" },
148 { Q931_STATUS_ENQUIRY, "STATUS ENQUIRY" },
152 static const true_false_string tfs_call_ref_flag = {
153 "Message sent to originating side",
154 "Message sent from originating side"
158 * Information elements.
164 #define Q931_IE_SO_IDENTIFIER_MASK 0xf0 /* IE identifier mask */
165 #define Q931_IE_SO_IDENTIFIER_SHIFT 4 /* IE identifier shift */
166 #define Q931_IE_SO_IE_MASK 0x0F /* IE mask */
168 #define Q931_IE_SHIFT 0x90
169 #define Q931_IE_SHIFT_LOCKING 0x08 /* locking shift */
170 #define Q931_IE_SHIFT_CODESET 0x0F /* codeset */
172 #define Q931_IE_MORE_DATA_OR_SEND_COMP 0xA0 /* More Data or Sending Complete */
173 #define Q931_IE_MORE_DATA 0xA0
174 #define Q931_IE_SENDING_COMPLETE 0xA1
176 #define Q931_IE_CONGESTION_LEVEL 0xB0
177 #define Q931_IE_REPEAT_INDICATOR 0xD0
180 * Variable-length IEs.
182 #define Q931_IE_VL_EXTENSION 0x80 /* Extension flag */
185 * Codeset 0 (default).
187 #define Q931_IE_SEGMENTED_MESSAGE 0x00
188 #define Q931_IE_BEARER_CAPABILITY 0x04
189 #define Q931_IE_CAUSE 0x08
190 #define Q931_IE_CALL_IDENTITY 0x10
191 #define Q931_IE_CALL_STATE 0x14
192 #define Q931_IE_CHANNEL_IDENTIFICATION 0x18
193 #define Q931_IE_FACILITY 0x1C
194 #define Q931_IE_PROGRESS_INDICATOR 0x1E
195 #define Q931_IE_NETWORK_SPECIFIC_FACIL 0x20 /* Network Specific Facilities */
196 #define Q931_IE_NOTIFICATION_INDICATOR 0x27
197 #define Q931_IE_DISPLAY 0x28
198 #define Q931_IE_DATE_TIME 0x29
199 #define Q931_IE_KEYPAD_FACILITY 0x2C
200 #define Q931_IE_INFORMATION_REQUEST 0x32
201 #define Q931_IE_SIGNAL 0x34
202 #define Q931_IE_SWITCHHOOK 0x36
203 #define Q931_IE_FEATURE_ACTIVATION 0x38
204 #define Q931_IE_FEATURE_INDICATION 0x39
205 #define Q931_IE_ENDPOINT_IDENTIFIER 0x3B
206 #define Q931_IE_SERVICE_PROFILE_ID 0x3A
207 #define Q931_IE_INFORMATION_RATE 0x40
208 #define Q931_IE_E2E_TRANSIT_DELAY 0x42 /* End-to-end Transit Delay */
209 #define Q931_IE_TD_SELECTION_AND_INT 0x43 /* Transit Delay Selection and Indication */
210 #define Q931_IE_PL_BINARY_PARAMETERS 0x44 /* Packet layer binary parameters */
211 #define Q931_IE_PL_WINDOW_SIZE 0x45 /* Packet layer window size */
212 #define Q931_IE_PACKET_SIZE 0x46 /* Packet size */
213 #define Q931_IE_CUG 0x47 /* Closed user group */
214 #define Q931_IE_REVERSE_CHARGE_IND 0x4A /* Reverse charging indication */
215 #define Q931_IE_CONNECTED_NUMBER_DEFAULT 0x4C /* Connected Number */
216 #define Q931_IE_CALLING_PARTY_NUMBER 0x6C /* Calling Party Number */
217 #define Q931_IE_CALLING_PARTY_SUBADDR 0x6D /* Calling Party Subaddress */
218 #define Q931_IE_CALLED_PARTY_NUMBER 0x70 /* Called Party Number */
219 #define Q931_IE_CALLED_PARTY_SUBADDR 0x71 /* Called Party Subaddress */
220 #define Q931_IE_REDIRECTING_NUMBER 0x74
221 #define Q931_IE_REDIRECTION_NUMBER 0x76
222 #define Q931_IE_TRANSIT_NETWORK_SEL 0x78 /* Transit Network Selection */
223 #define Q931_IE_RESTART_INDICATOR 0x79
224 #define Q931_IE_LOW_LAYER_COMPAT 0x7C /* Low-Layer Compatibility */
225 #define Q931_IE_HIGH_LAYER_COMPAT 0x7D /* High-Layer Compatibility */
226 #define Q931_IE_USER_USER 0x7E /* User-User */
227 #define Q931_IE_ESCAPE 0x7F /* Escape for extension */
232 #define Q931_IE_CONNECTED_NUMBER 0x8C
233 #define Q931_IE_CONNECTED_SUBADDR 0x8D
236 * Codeset 5 (National-specific) Belgium.
238 #define Q931_IE_CHARGING_ADVICE 0x1A
241 * Codeset 5 (National-specific) Bellcore National ISDN.
243 #define Q931_IE_OPERATOR_SYSTEM_ACCESS 0x1D
246 * Codeset 6 (Network-specific) Belgium.
248 /* 0x1A is Charging Advice, as with Codeset 5 */
249 #define Q931_IE_REDIRECTING_NUMBER 0x74
252 * Codeset 6 (Network-specific) FT-Numeris.
254 /* 0x1D is User Capability */
257 * Codeset 6 (Network-specific) Bellcore National ISDN.
259 #define Q931_IE_REDIRECTING_SUBADDR 0x75 /* Redirecting Subaddress */
260 /* 0x76 is Redirection Number, but that's also Codeset 0 */
261 #define Q931_IE_CALL_APPEARANCE 0x7B
263 static const value_string q931_info_element_vals[] = {
264 { Q931_IE_SEGMENTED_MESSAGE, "Segmented message" },
265 { Q931_IE_BEARER_CAPABILITY, "Bearer capability" },
266 { Q931_IE_CAUSE, "Cause" },
267 { Q931_IE_CALL_IDENTITY, "Call identity" },
268 { Q931_IE_CALL_STATE, "Call state" },
269 { Q931_IE_CHANNEL_IDENTIFICATION, "Channel identification" },
270 { Q931_IE_FACILITY, "Facility" },
271 { Q931_IE_PROGRESS_INDICATOR, "Progress indicator" },
272 { Q931_IE_NETWORK_SPECIFIC_FACIL, "Network specific facilities" },
273 { Q931_IE_NOTIFICATION_INDICATOR, "Notification indicator" },
274 { Q931_IE_DISPLAY, "Display" },
275 { Q931_IE_DATE_TIME, "Date/Time" },
276 { Q931_IE_KEYPAD_FACILITY, "Keypad facility" },
277 { Q931_IE_INFORMATION_REQUEST, "Information request" },
278 { Q931_IE_SIGNAL, "Signal" },
279 { Q931_IE_SWITCHHOOK, "Switchhook" },
280 { Q931_IE_FEATURE_ACTIVATION, "Feature activation" },
281 { Q931_IE_FEATURE_INDICATION, "Feature Indication" },
282 { Q931_IE_ENDPOINT_IDENTIFIER, "Endpoint identifier" },
283 { Q931_IE_SERVICE_PROFILE_ID, "Service profile ID" },
284 { Q931_IE_INFORMATION_RATE, "Information rate" },
285 { Q931_IE_E2E_TRANSIT_DELAY, "End-to-end transit delay" },
286 { Q931_IE_TD_SELECTION_AND_INT, "Transit delay selection and indication" },
287 { Q931_IE_PL_BINARY_PARAMETERS, "Packet layer binary parameters" },
288 { Q931_IE_PL_WINDOW_SIZE, "Packet layer window size" },
289 { Q931_IE_PACKET_SIZE, "Packet size" },
290 { Q931_IE_CUG, "Closed user group" },
291 { Q931_IE_REVERSE_CHARGE_IND, "Reverse charging indication" },
292 { Q931_IE_CONNECTED_NUMBER_DEFAULT, "Connected number" },
293 { Q931_IE_CALLING_PARTY_NUMBER, "Calling party number" },
294 { Q931_IE_CALLING_PARTY_SUBADDR, "Calling party subaddress" },
295 { Q931_IE_CALLED_PARTY_NUMBER, "Called party number" },
296 { Q931_IE_CALLED_PARTY_SUBADDR, "Called party subaddress" },
297 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
298 { Q931_IE_REDIRECTION_NUMBER, "Redirection number" },
299 { Q931_IE_TRANSIT_NETWORK_SEL, "Transit network selection" },
300 { Q931_IE_RESTART_INDICATOR, "Restart indicator" },
301 { Q931_IE_LOW_LAYER_COMPAT, "Low-layer compatibility" },
302 { Q931_IE_HIGH_LAYER_COMPAT, "High-layer compatibility" },
303 { Q931_IE_USER_USER, "User-user" },
304 { Q931_IE_ESCAPE, "Escape" },
305 { Q931_IE_CONNECTED_NUMBER, "Connected number" },
306 { Q931_IE_CONNECTED_SUBADDR, "Connected subaddress" },
307 { Q931_IE_CHARGING_ADVICE, "Charging advice" },
308 { Q931_IE_OPERATOR_SYSTEM_ACCESS, "Operator system access" },
309 { Q931_IE_REDIRECTING_NUMBER, "Redirecting number" },
310 { Q931_IE_REDIRECTING_SUBADDR, "Redirecting subaddress" },
311 { Q931_IE_CALL_APPEARANCE, "Call appearance" },
315 static const value_string q931_congestion_level_vals[] = {
316 { 0x0, "Receiver ready" },
317 { 0xF, "Receiver not ready" },
321 static const value_string q931_repeat_indication_vals[] = {
322 { 0x2, "Prioritized list" },
327 * ITU-standardized coding.
329 #define Q931_ITU_STANDARDIZED_CODING 0x00
332 * Dissect a Segmented message information element.
335 dissect_q931_segmented_message_ie(tvbuff_t *tvb, int offset, int len,
339 proto_tree_add_text(tree, tvb, offset, len,
340 "Segmented message: length is %d, should be 2\n", len);
343 if (tvb_get_guint8(tvb, offset) & 0x80) {
344 proto_tree_add_text(tree, tvb, offset, 1,
345 "First segment: %u segments remaining",
346 tvb_get_guint8(tvb, offset) & 0x7F);
348 proto_tree_add_text(tree, tvb, offset, 1,
349 "Not first segment: %u segments remaining",
350 tvb_get_guint8(tvb, offset) & 0x7F);
352 proto_tree_add_text(tree, tvb, offset + 1, 1,
353 "Segmented message type: %u\n", tvb_get_guint8(tvb, offset + 1));
357 * Dissect a Bearer capability or Low-layer compatibility information element.
359 static const value_string q931_bc_coding_standard_vals[] = {
360 { 0x00, "ITU-T standardized coding" },
361 { 0x20, "ISO/IEC standard" },
362 { 0x40, "National standard" },
363 { 0x60, "Standard defined for this particular network" },
367 static const value_string q931_information_transfer_capability_vals[] = {
369 { 0x08, "Unrestricted digital information" },
370 { 0x09, "Restricted digital information" },
371 { 0x10, "3.1 kHz audio" },
372 { 0x11, "Unrestricted digital information with tones/announcements" },
377 static const value_string q931_transfer_mode_vals[] = {
378 { 0x00, "Circuit mode" },
379 { 0x40, "Packet mode" },
383 #define Q931_IT_RATE_MULTIRATE 0x18
385 static const value_string q931_information_transfer_rate_vals[] = {
386 { 0x00, "Packet mode" },
387 { 0x10, "64 kbit/s" },
388 { 0x11, "2 x 64 kbit/s" },
389 { 0x13, "384 kbit/s" },
390 { 0x15, "1536 kbit/s" },
391 { 0x17, "1920 kbit/s" },
392 { Q931_IT_RATE_MULTIRATE, "Multirate (64 kbit/s base rate)" },
396 static const value_string q931_uil1_vals[] = {
397 { 0x01, "V.110/I.460/X.30 rate adaption" },
398 { 0x02, "Recommendation G.711 u-law" },
399 { 0x03, "Recommendation G.711 A-law" },
400 { 0x04, "Recommendation G.721 32 kbit/s ADPCM and Recommendation I.460" },
401 { 0x05, "Recommendation H.221 and H.242" },
402 { 0x06, "Recommendation H.223 and H.245" },
403 { 0x07, "Non-ITU-T-standardized rate adaption" },
404 { 0x08, "V.120 rate adaption" },
405 { 0x09, "X.31 HDLC flag stuffing" },
409 static const value_string q931_l1_user_rate_vals[] = {
410 { 0x00, "Rate indicated by E-bits" },
411 { 0x01, "0.6 kbit/s" },
412 { 0x02, "1.2 kbit/s" },
413 { 0x03, "2.4 kbit/s" },
414 { 0x04, "3.6 kbit/s" },
415 { 0x05, "4.8 kbit/s" },
416 { 0x06, "7.2 kbit/s" },
417 { 0x07, "8 kbit/s" },
418 { 0x08, "9.6 kbit/s" },
419 { 0x09, "14.4 kbit/s" },
420 { 0x0A, "16 kbit/s" },
421 { 0x0B, "19.2 kbit/s" },
422 { 0x0C, "32 kbit/s" },
423 { 0x0E, "48 kbit/s" },
424 { 0x0F, "56 kbit/s" },
425 { 0x10, "64 kbit/s "},
426 { 0x15, "0.1345 kbit/s" },
427 { 0x16, "0.100 kbit/s" },
428 { 0x17, "0.075/1.2 kbit/s" },
429 { 0x18, "1.2/0.075 kbit/s" },
430 { 0x19, "0.050 kbit/s" },
431 { 0x1A, "0.075 kbit/s" },
432 { 0x1B, "0.110 kbit/s" },
433 { 0x1C, "0.150 kbit/s" },
434 { 0x1D, "0.200 kbit/s" },
435 { 0x1E, "0.300 kbit/s" },
436 { 0x1F, "12 kbit/s" },
440 static const value_string q931_l1_intermediate_rate_vals[] = {
441 { 0x20, "8 kbit/s" },
442 { 0x40, "16 kbit/s" },
443 { 0x60, "32 kbit/s" },
447 static const value_string q931_l1_stop_bits_vals[] = {
454 static const value_string q931_l1_data_bits_vals[] = {
461 static const value_string q931_l1_parity_vals[] = {
465 { 0x04, "Forced to 0" },
466 { 0x05, "Forced to 1" },
470 static const value_string q931_l1_modem_type_vals[] = {
473 { 0x13, "V.22 bis" },
476 { 0x16, "V.26 bis" },
477 { 0x17, "V.26 ter" },
479 { 0x19, "V.27 bis" },
480 { 0x1A, "V.27 ter" },
487 #define Q931_UIL2_USER_SPEC 0x10
489 static const value_string q931_uil2_vals[] = {
490 { 0x01, "Basic mode ISO 1745" },
491 { 0x02, "Q.921/I.441" }, /* LAPD */
492 { 0x06, "X.25, link layer" }, /* LAPB */
493 { 0x07, "X.25 multilink" }, /* or 0x0F? */
494 { 0x08, "T.71 Extended LAPB" },
495 { 0x09, "HDLC ARM" },
496 { 0x0A, "HDLC NRM" },
497 { 0x0B, "HDLC ABM" },
498 { 0x0C, "ISO 8802/2 LLC" },
499 { 0x0D, "X.75 Single Link Procedure" },
501 { 0x0F, "Core aspects of Q.922" },
502 { Q931_UIL2_USER_SPEC, "User-specified" },
503 { 0x11, "ISO 7776 DTE-DTE operation" },
507 static const value_string q931_mode_vals[] = {
508 { 0x20, "Normal mode" },
509 { 0x40, "Extended mode" },
513 #define Q931_UIL3_X25_PL 0x06
514 #define Q931_UIL3_ISO_8208 0x07 /* X.25-based */
515 #define Q931_UIL3_X223 0x08 /* X.25-based */
516 #define Q931_UIL3_TR_9577 0x0B
517 #define Q931_UIL3_USER_SPEC 0x10
519 static const value_string q931_uil3_vals[] = {
520 { 0x02, "Q.931/I.451" },
521 { Q931_UIL3_X25_PL, "X.25, packet layer" },
522 { Q931_UIL3_ISO_8208, "ISO/IEC 8208" },
523 { Q931_UIL3_X223, "X.223/ISO 8878" },
524 { 0x09, "ISO/IEC 8473" },
526 { Q931_UIL3_TR_9577, "ISO/IEC TR 9577" },
527 { Q931_UIL3_USER_SPEC, "User-specified" },
532 dissect_q931_protocol_discriminator(tvbuff_t *tvb, int offset, proto_tree *tree)
534 unsigned int discriminator = tvb_get_guint8(tvb, offset);
536 if (discriminator == NLPID_Q_931) {
537 proto_tree_add_uint_format(tree, hf_q931_discriminator,
538 tvb, offset, 1, discriminator,
539 "Protocol discriminator: Q.931");
540 } else if (discriminator == NLPID_Q_2931) {
541 proto_tree_add_uint_format(tree, hf_q931_discriminator,
542 tvb, offset, 1, discriminator,
543 "Protocol discriminator: Q.2931");
544 } else if ((discriminator >= 16 && discriminator < 63)
545 || ((discriminator >= 80) && (discriminator < 254))) {
546 proto_tree_add_uint_format(tree, hf_q931_discriminator,
547 tvb, offset, 1, discriminator,
548 "Protocol discriminator: Network layer or layer 3 protocol (0x%02X)",
550 } else if (discriminator >= 64 && discriminator <= 79) {
551 proto_tree_add_uint_format(tree, hf_q931_discriminator,
552 tvb, offset, 1, discriminator,
553 "Protocol discriminator: National use (0x%02X)",
556 proto_tree_add_uint_format(tree, hf_q931_discriminator,
557 tvb, offset, 1, discriminator,
558 "Protocol discriminator: Reserved (0x%02X)",
564 dissect_q931_bearer_capability_ie(tvbuff_t *tvb, int offset, int len,
568 guint8 coding_standard;
571 guint8 uil2_protocol;
572 guint8 uil3_protocol;
577 octet = tvb_get_guint8(tvb, offset);
578 coding_standard = octet & 0x60;
579 proto_tree_add_text(tree, tvb, offset, 1,
580 "Coding standard: %s",
581 val_to_str(coding_standard, q931_bc_coding_standard_vals, NULL));
582 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
584 * We don't know how the bearer capability is encoded,
585 * so just dump it as data and be done with it.
587 proto_tree_add_text(tree, tvb, offset,
589 tvb_bytes_to_str(tvb, offset, len));
592 proto_tree_add_text(tree, tvb, offset, 1,
593 "Information transfer capability: %s",
594 val_to_str(octet & 0x1F, q931_information_transfer_capability_vals,
595 "Unknown (0x%02X)"));
600 * XXX - only in Low-layer compatibility information element.
602 if (!(octet & Q931_IE_VL_EXTENSION)) {
605 octet = tvb_get_guint8(tvb, offset);
606 proto_tree_add_text(tree, tvb, offset, 1,
607 "Out-band negotiation %spossible",
608 (octet & 0x40) ? "" : "not ");
615 octet = tvb_get_guint8(tvb, offset);
616 proto_tree_add_text(tree, tvb, offset, 1,
618 val_to_str(octet & 0x60, q931_transfer_mode_vals,
619 "Unknown (0x%02X)"));
620 it_rate = octet & 0x1F;
621 proto_tree_add_text(tree, tvb, offset, 1,
622 "Information transfer rate: %s",
623 val_to_str(it_rate, q931_information_transfer_rate_vals,
624 "Unknown (0x%02X)"));
628 if (it_rate == Q931_IT_RATE_MULTIRATE) {
631 proto_tree_add_text(tree, tvb, offset, 1, "Rate multiplier: %u", tvb_get_guint8(tvb, offset));
638 octet = tvb_get_guint8(tvb, offset);
639 if ((octet & 0x60) == 0x20) {
641 * Layer 1 information.
643 proto_tree_add_text(tree, tvb, offset, 1,
644 "User information layer 1 protocol: %s",
645 val_to_str(octet & 0x1F, q931_uil1_vals,
646 "Unknown (0x%02X)"));
650 if (octet & Q931_IE_VL_EXTENSION)
654 octet = tvb_get_guint8(tvb, offset);
655 proto_tree_add_text(tree, tvb, offset, 1,
657 (octet & 0x40) ? "Asynchronous" : "Synchronous");
658 proto_tree_add_text(tree, tvb, offset, 1,
659 "Layer 1 in-band negotiation is %spossible",
660 (octet & 0x20) ? "" : "not ");
661 proto_tree_add_text(tree, tvb, offset, 1,
663 val_to_str(octet & 0x1F, q931_l1_user_rate_vals,
664 "Unknown (0x%02X)"));
668 if (octet & Q931_IE_VL_EXTENSION)
672 octet = tvb_get_guint8(tvb, offset);
673 proto_tree_add_text(tree, tvb, offset, 1,
674 "Intermediate rate: %s",
675 val_to_str(octet & 0x60, q931_l1_intermediate_rate_vals,
677 proto_tree_add_text(tree, tvb, offset, 1,
678 "%s to send data with network independent clock",
679 (octet & 0x10) ? "Required" : "Not required");
680 proto_tree_add_text(tree, tvb, offset, 1,
681 "%s accept data with network independent clock",
682 (octet & 0x08) ? "Can" : "Cannot");
683 proto_tree_add_text(tree, tvb, offset, 1,
684 "%s to send data with flow control mechanism",
685 (octet & 0x04) ? "Required" : "Not required");
686 proto_tree_add_text(tree, tvb, offset, 1,
687 "%s accept data with flow control mechanism",
688 (octet & 0x02) ? "Can" : "Cannot");
692 if (octet & Q931_IE_VL_EXTENSION)
696 octet = tvb_get_guint8(tvb, offset);
697 proto_tree_add_text(tree, tvb, offset, 1,
698 "Rate adaption header %sincluded",
699 (octet & 0x40) ? "" : "not ");
700 proto_tree_add_text(tree, tvb, offset, 1,
701 "Multiple frame establishment %ssupported",
702 (octet & 0x20) ? "" : "not ");
703 proto_tree_add_text(tree, tvb, offset, 1,
704 "%s mode of operation",
705 (octet & 0x10) ? "Protocol sensitive" : "Bit transparent");
706 proto_tree_add_text(tree, tvb, offset, 1,
708 "Full protocol negotiation" : "LLI = 256 only");
709 proto_tree_add_text(tree, tvb, offset, 1,
710 "Message originator is %s",
711 (octet & 0x04) ? "Assignor only" : "Default assignee");
712 proto_tree_add_text(tree, tvb, offset, 1,
713 "Negotiation is done %s",
714 (octet & 0x02) ? "in-band" : "out-of-band");
718 if (octet & Q931_IE_VL_EXTENSION)
722 octet = tvb_get_guint8(tvb, offset);
723 proto_tree_add_text(tree, tvb, offset, 1,
725 val_to_str(octet & 0x60, q931_l1_stop_bits_vals,
727 proto_tree_add_text(tree, tvb, offset, 1,
729 val_to_str(octet & 0x18, q931_l1_data_bits_vals,
731 proto_tree_add_text(tree, tvb, offset, 1,
733 val_to_str(octet & 0x08, q931_l1_parity_vals,
736 if (octet & Q931_IE_VL_EXTENSION)
740 octet = tvb_get_guint8(tvb, offset);
741 proto_tree_add_text(tree, tvb, offset, 1,
743 (octet & 0x40) ? "Full" : "Half");
744 modem_type = octet & 0x3F;
745 if (modem_type <= 0x5 ||
746 (modem_type >= 0x20 && modem_type <= 0x2F)) {
747 proto_tree_add_text(tree, tvb, offset, 1,
748 "Modem type: National use 0x%02X", modem_type);
749 } else if (modem_type >= 0x30) {
750 proto_tree_add_text(tree, tvb, offset, 1,
751 "Modem type: User specified 0x%02X", modem_type);
753 proto_tree_add_text(tree, tvb, offset, 1,
755 val_to_str(modem_type, q931_l1_modem_type_vals,
756 "Unknown (0x%02X)"));
766 octet = tvb_get_guint8(tvb, offset);
767 if ((octet & 0x60) == 0x40) {
769 * Layer 2 information.
771 uil2_protocol = octet & 0x1F;
772 proto_tree_add_text(tree, tvb, offset, 1,
773 "User information layer 2 protocol: %s",
774 val_to_str(uil2_protocol, q931_uil2_vals,
775 "Unknown (0x%02X)"));
780 * XXX - only in Low-layer compatibility information element.
782 if (octet & Q931_IE_VL_EXTENSION)
786 octet = tvb_get_guint8(tvb, offset);
787 if (uil2_protocol == Q931_UIL2_USER_SPEC) {
788 proto_tree_add_text(tree, tvb, offset, 1,
789 "User-specified layer 2 protocol information: 0x%02X",
792 proto_tree_add_text(tree, tvb, offset, 1,
794 val_to_str(octet & 0x60, q931_mode_vals,
795 "Unknown (0x%02X)"));
800 if (octet & Q931_IE_VL_EXTENSION)
804 octet = tvb_get_guint8(tvb, offset);
805 proto_tree_add_text(tree, tvb, offset, 1,
806 "Window size: %u k", octet & 0x7F);
815 octet = tvb_get_guint8(tvb, offset);
816 if ((octet & 0x60) == 0x60) {
818 * Layer 3 information.
820 uil3_protocol = octet & 0x1F;
821 proto_tree_add_text(tree, tvb, offset, 1,
822 "User information layer 3 protocol: %s",
823 val_to_str(uil3_protocol, q931_uil3_vals,
824 "Unknown (0x%02X)"));
830 * XXX - only in Low-layer compatibility information element.
832 if (octet & Q931_IE_VL_EXTENSION)
836 octet = tvb_get_guint8(tvb, offset);
837 switch (uil3_protocol) {
839 case Q931_UIL3_X25_PL:
840 case Q931_UIL3_ISO_8208:
842 proto_tree_add_text(tree, tvb, offset, 1,
844 val_to_str(octet & 0x60, q931_mode_vals,
845 "Unknown (0x%02X)"));
849 if (octet & Q931_IE_VL_EXTENSION)
853 octet = tvb_get_guint8(tvb, offset);
854 proto_tree_add_text(tree, tvb, offset, 1,
855 "Default packet size: %u", octet & 0x0F);
859 if (octet & Q931_IE_VL_EXTENSION)
863 octet = tvb_get_guint8(tvb, offset);
864 proto_tree_add_text(tree, tvb, offset, 1,
865 "Packet window size: %u", octet & 0x7F);
870 case Q931_UIL3_USER_SPEC:
871 proto_tree_add_text(tree, tvb, offset, 1,
872 "Default packet size: %u octets",
873 1 << (octet & 0x0F));
878 case Q931_UIL3_TR_9577:
879 add_l3_info = (octet & 0x0F) << 4;
880 if (octet & Q931_IE_VL_EXTENSION)
884 octet = tvb_get_guint8(tvb, offset + 1);
885 add_l3_info |= (octet & 0x0F);
886 proto_tree_add_text(tree, tvb, offset, 2,
887 "Additional layer 3 protocol information: %s",
888 val_to_str(add_l3_info, nlpid_vals,
889 "Unknown (0x%02X)"));
900 * Dissect a Cause information element.
902 static const value_string q931_cause_coding_standard_vals[] = {
903 { 0x00, "ITU-T standardized coding" },
904 { 0x20, "ISO/IEC standard" },
905 { 0x40, "National standard" },
906 { 0x60, "Standard specific to identified location" },
910 const value_string q931_cause_location_vals[] = {
911 { 0x00, "User (U)" },
912 { 0x01, "Private network serving the local user (LPN)" },
913 { 0x02, "Public network serving the local user (LN)" },
914 { 0x03, "Transit network (TN)" },
915 { 0x04, "Public network serving the remote user (RLN)" },
916 { 0x05, "Private network serving the remote user (RPN)" },
917 { 0x07, "International network (INTL)" },
918 { 0x0A, "Network beyond interworking point (BI)" },
922 static const value_string q931_cause_recommendation_vals[] = {
926 { 0x05, "Q.1031/Q.1051" },
931 * Cause codes for Cause.
933 const value_string q931_cause_code_vals[] = {
934 { 0x00, "Valid cause code not yet received" },
935 { 0x01, "Unallocated (unassigned) number" },
936 { 0x02, "No route to specified transit network" },
937 { 0x03, "No route to destination" },
938 { 0x04, "Send special information tone" },
939 { 0x05, "Misdialled trunk prefix" },
940 { 0x06, "Channel unacceptable" },
941 { 0x07, "Call awarded and being delivered in an established channel" },
942 { 0x08, "Prefix 0 dialed but not allowed" },
943 { 0x09, "Prefix 1 dialed but not allowed" },
944 { 0x0A, "Prefix 1 dialed but not required" },
945 { 0x0B, "More digits received than allowed, call is proceeding" },
946 { 0x10, "Normal call clearing" },
947 { 0x11, "User busy" },
948 { 0x12, "No user responding" },
949 { 0x13, "No answer from user (user alerted)" },
950 { 0x14, "Subscriber absent" },
951 { 0x15, "Call rejected" },
952 { 0x16, "Number changed" },
953 { 0x17, "Reverse charging rejected" },
954 { 0x18, "Call suspended" },
955 { 0x19, "Call resumed" },
956 { 0x1A, "Non-selected user clearing" },
957 { 0x1B, "Destination out of order" },
958 { 0x1C, "Invalid number format (incomplete number)" },
959 { 0x1D, "Facility rejected" },
960 { 0x1E, "Response to STATUS ENQUIRY" },
961 { 0x1F, "Normal unspecified" },
962 { 0x21, "Circuit out of order" },
963 { 0x22, "No circuit/channel available" },
964 { 0x23, "Destination unattainable" },
965 { 0x25, "Degraded service" },
966 { 0x26, "Network out of order" },
967 { 0x27, "Transit delay range cannot be achieved" },
968 { 0x28, "Throughput range cannot be achieved" },
969 { 0x29, "Temporary failure" },
970 { 0x2A, "Switching equipment congestion" },
971 { 0x2B, "Access information discarded" },
972 { 0x2C, "Requested circuit/channel not available" },
973 { 0x2D, "Pre-empted" },
974 { 0x2E, "Precedence call blocked" },
975 { 0x2F, "Resources unavailable, unspecified" },
976 { 0x31, "Quality of service unavailable" },
977 { 0x32, "Requested facility not subscribed" },
978 { 0x33, "Reverse charging not allowed" },
979 { 0x34, "Outgoing calls barred" },
980 { 0x35, "Outgoing calls barred within CUG" },
981 { 0x36, "Incoming calls barred" },
982 { 0x37, "Incoming calls barred within CUG" },
983 { 0x38, "Call waiting not subscribed" },
984 { 0x39, "Bearer capability not authorized" },
985 { 0x3A, "Bearer capability not presently available" },
986 { 0x3E, "Inconsistency in designated outgoing access information and subscriber class" },
987 { 0x3F, "Service or option not available, unspecified" },
988 { 0x41, "Bearer capability not implemented" },
989 { 0x42, "Channel type not implemented" },
990 { 0x43, "Transit network selection not implemented" },
991 { 0x44, "Message not implemented" },
992 { 0x45, "Requested facility not implemented" },
993 { 0x46, "Only restricted digital information bearer capability is available" },
994 { 0x4F, "Service or option not implemented, unspecified" },
995 { 0x51, "Invalid call reference value" },
996 { 0x52, "Identified channel does not exist" },
997 { 0x53, "Call identity does not exist for suspended call" },
998 { 0x54, "Call identity in use" },
999 { 0x55, "No call suspended" },
1000 { 0x56, "Call having the requested call identity has been cleared" },
1001 { 0x57, "Called user not member of CUG" },
1002 { 0x58, "Incompatible destination" },
1003 { 0x59, "Non-existent abbreviated address entry" },
1004 { 0x5A, "Destination address missing, and direct call not subscribed" },
1005 { 0x5B, "Invalid transit network selection (national use)" },
1006 { 0x5C, "Invalid facility parameter" },
1007 { 0x5D, "Mandatory information element is missing" },
1008 { 0x5F, "Invalid message, unspecified" },
1009 { 0x60, "Mandatory information element is missing" },
1010 { 0x61, "Message type non-existent or not implemented" },
1011 { 0x62, "Message not compatible with call state or message type non-existent or not implemented" },
1012 { 0x63, "Information element nonexistant or not implemented" },
1013 { 0x64, "Invalid information element contents" },
1014 { 0x65, "Message not compatible with call state" },
1015 { 0x66, "Recovery on timer expiry" },
1016 { 0x67, "Parameter non-existent or not implemented - passed on" },
1017 { 0x6E, "Message with unrecognized parameter discarded" },
1018 { 0x6F, "Protocol error, unspecified" },
1019 { 0x7F, "Internetworking, unspecified" },
1024 dissect_q931_cause_ie(tvbuff_t *tvb, int offset, int len,
1025 proto_tree *tree, int hf_cause_value)
1028 guint8 coding_standard;
1032 octet = tvb_get_guint8(tvb, offset);
1033 coding_standard = octet & 0x60;
1034 proto_tree_add_text(tree, tvb, offset, 1,
1035 "Coding standard: %s",
1036 val_to_str(coding_standard, q931_cause_coding_standard_vals, NULL));
1037 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1039 * We don't know how the cause is encoded,
1040 * so just dump it as data and be done with it.
1042 proto_tree_add_text(tree, tvb, offset,
1044 tvb_bytes_to_str(tvb, offset, len));
1047 proto_tree_add_text(tree, tvb, offset, 1,
1049 val_to_str(octet & 0x0F, q931_cause_location_vals,
1054 if (!(octet & Q931_IE_VL_EXTENSION)) {
1057 octet = tvb_get_guint8(tvb, offset);
1058 proto_tree_add_text(tree, tvb, offset, 1,
1059 "Recommendation: %s",
1060 val_to_str(octet & 0x7F, q931_cause_recommendation_vals,
1061 "Unknown (0x%02X)"));
1068 octet = tvb_get_guint8(tvb, offset);
1069 proto_tree_add_uint(tree, hf_cause_value, tvb, 0, 1, octet & 0x7F);
1075 proto_tree_add_text(tree, tvb, offset, len,
1077 tvb_bytes_to_str(tvb, offset, len));
1081 * Dissect a Call state information element.
1083 static const value_string q931_coding_standard_vals[] = {
1084 { 0x00, "ITU-T standardized coding" },
1085 { 0x20, "ISO/IEC standard" },
1086 { 0x40, "National standard" },
1087 { 0x60, "Standard defined for the network" },
1091 static const value_string q931_call_state_vals[] = {
1093 { 0x01, "Call initiated" },
1094 { 0x02, "Overlap sending" },
1095 { 0x03, "Outgoing call proceeding" },
1096 { 0x04, "Call delivered" },
1097 { 0x06, "Call present" },
1098 { 0x07, "Call received" },
1099 { 0x08, "Connect request" },
1100 { 0x09, "Incoming call proceeding" },
1102 { 0x0B, "Disconnect request" },
1103 { 0x0C, "Disconnect indication" },
1104 { 0x0F, "Suspend request" },
1105 { 0x12, "Resume request" },
1106 { 0x13, "Release request" },
1107 { 0x16, "Call abort"},
1108 { 0x19, "Overlap receiving" },
1109 { 0x3D, "Restart request" },
1110 { 0x3E, "Restart" },
1115 dissect_q931_call_state_ie(tvbuff_t *tvb, int offset, int len,
1119 guint8 coding_standard;
1123 octet = tvb_get_guint8(tvb, offset);
1124 coding_standard = octet & 0x60;
1125 proto_tree_add_text(tree, tvb, offset, 1,
1126 "Coding standard: %s",
1127 val_to_str(coding_standard, q931_coding_standard_vals, NULL));
1128 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1130 * We don't know how the call state is encoded,
1131 * so just dump it as data and be done with it.
1133 proto_tree_add_text(tree, tvb, offset,
1135 tvb_bytes_to_str(tvb, offset, len));
1138 proto_tree_add_text(tree, tvb, offset, 1,
1140 val_to_str(octet & 0x3F, q931_call_state_vals,
1141 "Unknown (0x%02X)"));
1145 * Dissect a Channel identification information element.
1147 #define Q931_INTERFACE_IDENTIFIED 0x40
1148 #define Q931_NOT_BASIC_CHANNEL 0x20
1150 static const value_string q931_basic_channel_selection_vals[] = {
1151 { 0x00, "No channel" },
1152 { 0x01, "B1 channel" },
1153 { 0x02, "B2 channel" },
1154 { 0x03, "Any channel" },
1158 static const value_string q931_not_basic_channel_selection_vals[] = {
1159 { 0x00, "No channel" },
1160 { 0x01, "Channel indicated in following octets" },
1161 { 0x03, "Any channel" },
1165 #define Q931_IS_SLOT_MAP 0x10
1167 static const value_string q931_element_type_vals[] = {
1168 { 0x03, "B-channel units" },
1169 { 0x06, "H0-channel units" },
1170 { 0x08, "H11-channel units" },
1171 { 0x09, "H12-channel units" },
1176 dissect_q931_channel_identification_ie(tvbuff_t *tvb, int offset, int len,
1180 int identifier_offset;
1182 guint8 coding_standard;
1186 octet = tvb_get_guint8(tvb, offset);
1187 proto_tree_add_text(tree, tvb, offset, 1,
1188 "Interface %s identified",
1189 (octet & Q931_INTERFACE_IDENTIFIED) ? "explicitly" : "implicitly");
1190 proto_tree_add_text(tree, tvb, offset, 1,
1192 (octet & Q931_NOT_BASIC_CHANNEL) ? "Not basic" : "Basic");
1193 proto_tree_add_text(tree, tvb, offset, 1,
1194 "Indicated channel is %s",
1195 (octet & 0x08) ? "required" : "preferred");
1196 proto_tree_add_text(tree, tvb, offset, 1,
1197 "Indicated channel is %sthe D-channel",
1198 (octet & 0x04) ? "" : "not ");
1199 if (octet & Q931_NOT_BASIC_CHANNEL) {
1200 proto_tree_add_text(tree, tvb, offset, 1,
1201 "Channel selection: %s",
1202 val_to_str(octet & 0x03, q931_not_basic_channel_selection_vals,
1205 proto_tree_add_text(tree, tvb, offset, 1,
1206 "Channel selection: %s",
1207 val_to_str(octet & 0x03, q931_basic_channel_selection_vals,
1213 if (octet & Q931_INTERFACE_IDENTIFIED) {
1214 identifier_offset = offset;
1219 octet = tvb_get_guint8(tvb, offset);
1223 } while (!(octet & Q931_IE_VL_EXTENSION));
1226 * XXX - do we want to strip off the 8th bit on the
1227 * last octet of the interface identifier?
1229 if (identifier_len != 0) {
1230 proto_tree_add_text(tree, tvb, identifier_offset,
1231 identifier_len, "Interface identifier: %s",
1233 tvb_get_ptr(tvb, identifier_offset, identifier_len),
1238 if (octet & Q931_NOT_BASIC_CHANNEL) {
1241 octet = tvb_get_guint8(tvb, offset);
1242 coding_standard = octet & 0x60;
1243 proto_tree_add_text(tree, tvb, offset, 1,
1244 "Coding standard: %s",
1245 val_to_str(coding_standard, q931_coding_standard_vals,
1247 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1249 * We don't know how the channel identifier is
1250 * encoded, so just dump it as data and be done
1253 proto_tree_add_text(tree, tvb, offset,
1255 tvb_bytes_to_str(tvb, offset, len));
1258 proto_tree_add_text(tree, tvb, offset, 1,
1259 "Channel is indicated by %s",
1260 (octet & Q931_IS_SLOT_MAP) ? "slot map" : "number");
1261 proto_tree_add_text(tree, tvb, offset, 1,
1263 (octet & Q931_IS_SLOT_MAP) ? "Map element" : "Channel",
1264 val_to_str(octet & 0x0F, q931_element_type_vals,
1265 "Unknown (0x%02X)"));
1268 * XXX - dump the channel number or slot map.
1274 * Dissect a Progress indicator information element.
1276 static const value_string q931_progress_description_vals[] = {
1277 { 0x01, "Call is not end-to-end ISDN - progress information available in-band" },
1278 { 0x02, "Destination address is non-ISDN" },
1279 { 0x03, "Origination address is non-ISDN" },
1280 { 0x04, "Call has returned to the ISDN" },
1281 { 0x05, "Interworking has occurred and has resulted in a telecommunications service change" },
1282 { 0x08, "In-band information or an appropriate pattern is now available" },
1287 dissect_q931_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
1291 guint8 coding_standard;
1295 octet = tvb_get_guint8(tvb, offset);
1296 coding_standard = octet & 0x60;
1297 proto_tree_add_text(tree, tvb, offset, 1,
1298 "Coding standard: %s",
1299 val_to_str(coding_standard, q931_cause_coding_standard_vals, NULL));
1300 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1302 * We don't know how the progress indicator is encoded,
1303 * so just dump it as data and be done with it.
1305 proto_tree_add_text(tree, tvb, offset,
1307 tvb_bytes_to_str(tvb, offset, len));
1310 proto_tree_add_text(tree, tvb, offset, 1,
1312 val_to_str(octet & 0x0F, q931_cause_location_vals,
1319 octet = tvb_get_guint8(tvb, offset);
1320 proto_tree_add_text(tree, tvb, offset, 1,
1321 "Progress description: %s",
1322 val_to_str(octet & 0x7F, q931_progress_description_vals,
1323 "Unknown (0x%02X)"));
1327 * Dissect a Network-specific facilities or Transit network selection
1328 * information element.
1330 static const value_string q931_netid_type_vals[] = {
1331 { 0x00, "User specified" },
1332 { 0x20, "National network identification" },
1333 { 0x30, "International network identification" },
1337 static const value_string q931_netid_plan_vals[] = {
1338 { 0x00, "Unknown" },
1339 { 0x01, "Carrier Identification Code" },
1340 { 0x03, "X.121 data network identification code" },
1345 dissect_q931_ns_facilities_ie(tvbuff_t *tvb, int offset, int len,
1353 octet = tvb_get_guint8(tvb, offset);
1354 netid_len = octet & 0x7F;
1355 proto_tree_add_text(tree, tvb, offset, 1,
1356 "Network identification length: %u",
1360 if (netid_len != 0) {
1363 octet = tvb_get_guint8(tvb, offset);
1364 proto_tree_add_text(tree, tvb, offset, 1,
1365 "Type of network identification: %s",
1366 val_to_str(octet & 0x70, q931_netid_type_vals,
1367 "Unknown (0x%02X)"));
1368 proto_tree_add_text(tree, tvb, offset, 1,
1369 "Network identification plan: %s",
1370 val_to_str(octet & 0x0F, q931_netid_plan_vals,
1371 "Unknown (0x%02X)"));
1378 if (netid_len > len)
1380 if (netid_len != 0) {
1381 proto_tree_add_text(tree, tvb, offset, netid_len,
1382 "Network identification: %s",
1383 tvb_format_text(tvb, offset, netid_len));
1384 offset += netid_len;
1390 * Whatever is left is the network-specific facility
1395 proto_tree_add_text(tree, tvb, offset,
1396 len, "Network-specific facility specification: %s",
1397 tvb_bytes_to_str(tvb, offset, len));
1401 * Dissect a Notification indicator information element.
1403 static const value_string q931_notification_description_vals[] = {
1404 { 0x00, "User suspended" },
1405 { 0x01, "User resumed" },
1406 { 0x02, "Bearer service change" },
1411 dissect_q931_notification_indicator_ie(tvbuff_t *tvb, int offset, int len,
1418 octet = tvb_get_guint8(tvb, offset);
1419 proto_tree_add_text(tree, tvb, offset, 1,
1420 "Notification description: %s",
1421 val_to_str(octet & 0x7F, q931_notification_description_vals,
1422 "Unknown (0x%02X)"));
1426 * Dissect a Date/time information element.
1429 dissect_q931_date_time_ie(tvbuff_t *tvb, int offset, int len,
1433 proto_tree_add_text(tree, tvb, offset, len,
1434 "Date/time: length is %d, should be 6\n", len);
1438 * XXX - what is "year" relative to? Is "month" 0-origin or
1439 * 1-origin? Q.931 doesn't say....
1441 proto_tree_add_text(tree, tvb, offset, 6,
1442 "Date/time: %02u-%02u-%02u %02u:%02u:%02u",
1443 tvb_get_guint8(tvb, offset + 0), tvb_get_guint8(tvb, offset + 1), tvb_get_guint8(tvb, offset + 2),
1444 tvb_get_guint8(tvb, offset + 3), tvb_get_guint8(tvb, offset + 4), tvb_get_guint8(tvb, offset + 5));
1448 * Dissect a Signal information element.
1450 static const value_string q931_signal_vals[] = {
1451 { 0x00, "Dial tone on" },
1452 { 0x01, "Ring tone on" },
1453 { 0x02, "Intercept tone on" },
1454 { 0x03, "Network congestion tone on" }, /* "fast busy" */
1455 { 0x04, "Busy tone on" },
1456 { 0x05, "Confirm tone on" },
1457 { 0x06, "Answer tone on" },
1458 { 0x07, "Call waiting tone on" },
1459 { 0x08, "Off-hook warning tone on" },
1460 { 0x09, "Preemption tone on" },
1461 { 0x3F, "Tones off" },
1462 { 0x40, "Alerting on - pattern 0" },
1463 { 0x41, "Alerting on - pattern 1" },
1464 { 0x42, "Alerting on - pattern 2" },
1465 { 0x43, "Alerting on - pattern 3" },
1466 { 0x44, "Alerting on - pattern 4" },
1467 { 0x45, "Alerting on - pattern 5" },
1468 { 0x46, "Alerting on - pattern 6" },
1469 { 0x47, "Alerting on - pattern 7" },
1470 { 0x4F, "Alerting off" },
1475 dissect_q931_signal_ie(tvbuff_t *tvb, int offset, int len,
1479 proto_tree_add_text(tree, tvb, offset, len,
1480 "Signal: length is %d, should be 1\n", len);
1483 proto_tree_add_text(tree, tvb, offset, 1,
1485 val_to_str(tvb_get_guint8(tvb, offset), q931_signal_vals,
1486 "Unknown (0x%02X)"));
1490 * Dissect an Information rate information element.
1492 static const value_string q931_throughput_class_vals[] = {
1493 { 0x03, "75 bit/s" },
1494 { 0x04, "150 bit/s" },
1495 { 0x05, "300 bit/s" },
1496 { 0x06, "600 bit/s" },
1497 { 0x07, "1200 bit/s" },
1498 { 0x08, "2400 bit/s" },
1499 { 0x09, "4800 bit/s" },
1500 { 0x0A, "9600 bit/s" },
1501 { 0x0B, "19200 bit/s" },
1502 { 0x0C, "48000 bit/s" },
1503 { 0x0D, "64000 bit/s" },
1508 dissect_q931_information_rate_ie(tvbuff_t *tvb, int offset, int len,
1512 proto_tree_add_text(tree, tvb, offset, len,
1513 "Information rate: length is %d, should be 4\n", len);
1516 proto_tree_add_text(tree, tvb, offset + 0, 1,
1517 "Incoming information rate: %s",
1518 val_to_str(tvb_get_guint8(tvb, offset + 0) & 0x1F,
1519 q931_throughput_class_vals, "Unknown (0x%02X)"));
1520 proto_tree_add_text(tree, tvb, offset + 1, 1,
1521 "Outgoing information rate: %s",
1522 val_to_str(tvb_get_guint8(tvb, offset + 1) & 0x1F,
1523 q931_throughput_class_vals, "Unknown (0x%02X)"));
1524 proto_tree_add_text(tree, tvb, offset + 2, 1,
1525 "Minimum incoming information rate: %s",
1526 val_to_str(tvb_get_guint8(tvb, offset + 2) & 0x1F,
1527 q931_throughput_class_vals, "Unknown (0x%02X)"));
1528 proto_tree_add_text(tree, tvb, offset + 3, 1,
1529 "Minimum outgoing information rate: %s",
1530 val_to_str(tvb_get_guint8(tvb, offset + 3) & 0x1F,
1531 q931_throughput_class_vals, "Unknown (0x%02X)"));
1535 dissect_q931_guint16_value(tvbuff_t *tvb, int offset, int len,
1536 proto_tree *tree, char *label)
1544 octet = tvb_get_guint8(tvb, offset);
1545 if (octet & Q931_IE_VL_EXTENSION) {
1547 * Only one octet long - error.
1551 value = (octet & 0x3) << 14;
1558 * We've reached the end of the information element - error.
1562 octet = tvb_get_guint8(tvb, offset);
1563 if (octet & Q931_IE_VL_EXTENSION) {
1565 * Only two octets long - error.
1569 value |= (octet & 0x7F) << 7;
1576 * We've reached the end of the information element - error.
1580 octet = tvb_get_guint8(tvb, offset);
1581 if (!(octet & Q931_IE_VL_EXTENSION)) {
1583 * More than three octets long - error.
1587 value |= (octet & 0x7F);
1592 proto_tree_add_text(tree, tvb, offset, value_len, "%s: %u ms", label,
1597 proto_tree_add_text(tree, tvb, offset, len,
1598 "%s goes past end of information element", label);
1602 proto_tree_add_text(tree, tvb, offset, len, "%s isn't 3 octets long",
1608 * Dissect an End-to-end transit delay information element.
1611 dissect_q931_e2e_transit_delay_ie(tvbuff_t *tvb, int offset, int len,
1618 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1619 "Cumulative transit delay");
1622 offset += value_len;
1627 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1628 "Requested end-to-end transit delay");
1631 offset += value_len;
1636 value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
1637 "Maximum end-to-end transit delay");
1641 * Dissect a Transit delay selection and indication information element.
1644 dissect_q931_td_selection_and_int_ie(tvbuff_t *tvb, int offset, int len,
1649 dissect_q931_guint16_value(tvb, offset, len, tree,
1654 * Dissect a Packet layer binary parameters information element.
1656 static const value_string q931_fast_selected_vals[] = {
1657 { 0x00, "Fast select not requested" },
1658 { 0x08, "Fast select not requested" },
1659 { 0x10, "Fast select requested with no restriction of response" },
1660 { 0x18, "Fast select requested with restrictions of response" },
1665 dissect_q931_pl_binary_parameters_ie(tvbuff_t *tvb, int offset, int len,
1672 octet = tvb_get_guint8(tvb, offset);
1673 proto_tree_add_text(tree, tvb, offset, 1,
1675 val_to_str(octet & 0x18, q931_fast_selected_vals, NULL));
1676 proto_tree_add_text(tree, tvb, offset, 1,
1678 (octet & 0x04) ? "No request/request denied" :
1679 "Request indicated/request accepted");
1680 proto_tree_add_text(tree, tvb, offset, 1,
1682 (octet & 0x02) ? "Link-by-link" : "End-to-end");
1683 proto_tree_add_text(tree, tvb, offset, 1,
1684 "Modulus %u sequencing",
1685 (octet & 0x01) ? 8 : 128);
1689 * Dissect a Packet layer window size information element.
1692 dissect_q931_pl_window_size_ie(tvbuff_t *tvb, int offset, int len,
1697 proto_tree_add_text(tree, tvb, offset, 1,
1698 "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1704 proto_tree_add_text(tree, tvb, offset, 1,
1705 "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1709 * Dissect a Packet size information element.
1712 dissect_q931_packet_size_ie(tvbuff_t *tvb, int offset, int len,
1717 proto_tree_add_text(tree, tvb, offset, 1,
1718 "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1724 proto_tree_add_text(tree, tvb, offset, 1,
1725 "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
1729 * Dissect a Closed user group information element.
1731 static const value_string q931_cug_indication_vals[] = {
1732 { 0x01, "Closed user group selection" },
1733 { 0x02, "Closed user group with outgoing access selection and indication" },
1738 dissect_q931_cug_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree)
1742 proto_tree_add_text(tree, tvb, offset, 1,
1743 "CUG indication: %s",
1744 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1745 q931_cug_indication_vals, "Unknown (0x%02X)"));
1751 proto_tree_add_text(tree, tvb, offset, len, "CUG index code: %s",
1752 tvb_format_text(tvb, offset, len));
1756 * Dissect a Reverse charging indication information element.
1758 static const value_string q931_reverse_charging_indication_vals[] = {
1759 { 0x01, "Reverse charging requested" },
1764 dissect_q931_reverse_charge_ind_ie(tvbuff_t *tvb, int offset, int len,
1769 proto_tree_add_text(tree, tvb, offset, 1,
1770 "Reverse charging indication: %s",
1771 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1772 q931_reverse_charging_indication_vals, "Unknown (0x%02X)"));
1776 * Dissect a (phone) number information element.
1778 static const value_string q931_number_type_vals[] = {
1779 { 0x00, "Unknown" },
1780 { 0x10, "International number" },
1781 { 0x20, "National number" },
1782 { 0x30, "Network specific number" },
1783 { 0x40, "Subscriber number" },
1784 { 0x60, "Abbreviated number" },
1788 static const value_string q931_numbering_plan_vals[] = {
1789 { 0x00, "Unknown" },
1790 { 0x01, "E.164 ISDN/telephony numbering" },
1791 { 0x03, "X.121 data numbering" },
1792 { 0x04, "F.69 Telex numbering" },
1793 { 0x08, "National standard numbering" },
1794 { 0x09, "Private numbering" },
1798 static const value_string q931_presentation_indicator_vals[] = {
1799 { 0x00, "Presentation allowed" },
1800 { 0x20, "Presentation restricted" },
1801 { 0x40, "Number not available due to interworking" },
1805 static const value_string q931_screening_indicator_vals[] = {
1806 { 0x00, "User-provided, not screened" },
1807 { 0x01, "User-provided, verified and passed" },
1808 { 0x02, "User-provided, verified and failed" },
1809 { 0x03, "Network-provided" },
1813 static const value_string q931_redirection_reason_vals[] = {
1814 { 0x00, "Unknown" },
1815 { 0x01, "Call forwarding busy or called DTE busy" },
1816 { 0x02, "Call forwarding no reply" },
1817 { 0x04, "Call deflection" },
1818 { 0x09, "Called DTE out of order" },
1819 { 0x0A, "Call forwarding by the called DTE" },
1820 { 0x0F, "Call forwarding unconditional or systematic call redirection" },
1825 dissect_q931_number_ie(tvbuff_t *tvb, int offset, int len,
1826 proto_tree *tree, int hfindex)
1832 octet = tvb_get_guint8(tvb, offset);
1833 proto_tree_add_text(tree, tvb, offset, 1,
1834 "Type of number: %s",
1835 val_to_str(octet & 0x70, q931_number_type_vals,
1836 "Unknown (0x%02X)"));
1837 proto_tree_add_text(tree, tvb, offset, 1,
1838 "Numbering plan: %s",
1839 val_to_str(octet & 0x0F, q931_numbering_plan_vals,
1840 "Unknown (0x%02X)"));
1844 if (!(octet & Q931_IE_VL_EXTENSION)) {
1847 octet = tvb_get_guint8(tvb, offset);
1848 proto_tree_add_text(tree, tvb, offset, 1,
1849 "Presentation indicator: %s",
1850 val_to_str(octet & 0x60, q931_presentation_indicator_vals,
1852 proto_tree_add_text(tree, tvb, offset, 1,
1853 "Screening indicator: %s",
1854 val_to_str(octet & 0x03, q931_screening_indicator_vals,
1861 * XXX - only in a Redirecting number information element.
1863 if (!(octet & Q931_IE_VL_EXTENSION)) {
1866 octet = tvb_get_guint8(tvb, offset);
1867 proto_tree_add_text(tree, tvb, offset, 1,
1868 "Reason for redirection: %s",
1869 val_to_str(octet & 0x0F, q931_redirection_reason_vals,
1877 proto_tree_add_item(tree, hfindex, tvb, offset, len, FALSE);
1881 * Dissect a party subaddress information element.
1883 static const value_string q931_subaddress_type_vals[] = {
1884 { 0x00, "X.213/ISO 8348 Add.2 NSAP" },
1885 { 0x20, "User-specified" },
1889 static const value_string q931_odd_even_indicator_vals[] = {
1890 { 0x00, "Even number of address signals" },
1891 { 0x10, "Odd number of address signals" },
1896 dissect_q931_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
1903 octet = tvb_get_guint8(tvb, offset);
1904 proto_tree_add_text(tree, tvb, offset, 1,
1905 "Type of subaddress: %s",
1906 val_to_str(octet & 0x70, q931_subaddress_type_vals,
1907 "Unknown (0x%02X)"));
1908 proto_tree_add_text(tree, tvb, offset, 1,
1909 "Odd/even indicator: %s",
1910 val_to_str(octet & 0x10, q931_odd_even_indicator_vals,
1917 proto_tree_add_text(tree, tvb, offset, len, "Subaddress: %s",
1918 tvb_bytes_to_str(tvb, offset, len));
1922 * Dissect a Restart indicator information element.
1924 static const value_string q931_restart_indicator_class_vals[] = {
1925 { 0x00, "Indicated channels" },
1926 { 0x06, "Single interface" },
1927 { 0x07, "All interfaces" },
1932 dissect_q931_restart_indicator_ie(tvbuff_t *tvb, int offset, int len,
1936 proto_tree_add_text(tree, tvb, offset, len,
1937 "Restart indicator: length is %d, should be 1\n", len);
1940 proto_tree_add_text(tree, tvb, offset, 1,
1941 "Restart indicator: %s",
1942 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1943 q931_restart_indicator_class_vals, "Unknown (0x%02X)"));
1947 * Dissect a High-layer compatibility information element.
1949 #define Q931_AUDIOVISUAL 0x60
1950 static const value_string q931_high_layer_characteristics_vals[] = {
1951 { 0x01, "Telephony" },
1952 { 0x04, "F.182 Facsimile Group 2/3" },
1953 { 0x21, "F.184 Facsimile Group 4 Class I" },
1954 { 0x24, "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
1955 { 0x28, "F.220 Teletex, basic and processable mode" },
1956 { 0x31, "F.200 Teletex, basic mode" },
1957 { 0x32, "F.300 and T.102 syntax-based Videotex" },
1958 { 0x33, "F.300 and T.101 international Videotex interworking" },
1959 { 0x35, "F.60 Telex" },
1960 { 0x38, "X.400 Message Handling Systems" },
1961 { 0x41, "X.200 OSI application" },
1962 { 0x42, "FTAM application" },
1963 { 0x5E, "Reserved for maintenance" },
1964 { 0x5F, "Reserved for management" },
1965 { Q931_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
1966 { 0x61, "F.702 and F.731 Profile 1b videoconferencing" },
1967 { 0x62, "F.702 and F.731 audiographic conferencing" },
1971 static const value_string q931_audiovisual_characteristics_vals[] = {
1972 { 0x01, "Capability set of initial channel of H.221" },
1973 { 0x02, "Capability set of subsequent channel of H.221" },
1974 { 0x21, "Capability set of initial channel of an active 3.1kHz audio or speech call" },
1979 dissect_q931_high_layer_compat_ie(tvbuff_t *tvb, int offset, int len,
1983 guint8 coding_standard;
1984 guint8 characteristics;
1988 octet = tvb_get_guint8(tvb, offset);
1989 coding_standard = octet & 0x60;
1990 proto_tree_add_text(tree, tvb, offset, 1,
1991 "Coding standard: %s",
1992 val_to_str(coding_standard, q931_coding_standard_vals, NULL));
1995 if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1997 * We don't know how the call state is encoded,
1998 * so just dump it as data and be done with it.
2000 proto_tree_add_text(tree, tvb, offset,
2002 tvb_bytes_to_str(tvb, offset, len));
2008 octet = tvb_get_guint8(tvb, offset);
2009 characteristics = octet & 0x7F;
2010 proto_tree_add_text(tree, tvb, offset, 1,
2011 "High layer characteristics identification: %s",
2012 val_to_str(characteristics, q931_high_layer_characteristics_vals,
2013 "Unknown (0x%02X)"));
2017 if (!(octet & Q931_IE_VL_EXTENSION)) {
2020 octet = tvb_get_guint8(tvb, offset);
2021 if (characteristics == Q931_AUDIOVISUAL) {
2022 proto_tree_add_text(tree, tvb, offset, 1,
2023 "Extended audiovisual characteristics identification: %s",
2024 val_to_str(octet & 0x7F,
2025 q931_audiovisual_characteristics_vals,
2026 "Unknown (0x%02X)"));
2028 proto_tree_add_text(tree, tvb, offset, 1,
2029 "Extended high layer characteristics identification: %s",
2030 val_to_str(octet & 0x7F,
2031 q931_high_layer_characteristics_vals,
2032 "Unknown (0x%02X)"));
2039 * Dissect a User-user information element.
2041 #define Q931_PROTOCOL_DISCRIMINATOR_IA5 0x04
2042 #define Q931_PROTOCOL_DISCRIMINATOR_ASN1 0x05
2044 static const value_string q931_protocol_discriminator_vals[] = {
2045 { 0x00, "User-specific protocol" },
2046 { 0x01, "OSI high layer protocols" },
2048 { Q931_PROTOCOL_DISCRIMINATOR_IA5, "IA5 characters" },
2049 { Q931_PROTOCOL_DISCRIMINATOR_ASN1, "X.208 and X.209 coded user information" },
2050 { 0x07, "V.120 rate adaption" },
2051 { 0x08, "Q.931/I.451 user-network call control messages" },
2056 dissect_q931_user_user_ie(tvbuff_t *tvb, int offset, int len,
2063 octet = tvb_get_guint8(tvb, offset);
2064 proto_tree_add_text(tree, tvb, offset, 1,
2065 "Protocol discriminator: %s",
2066 val_to_str(octet, q931_protocol_discriminator_vals,
2067 "Unknown (0x%02x)"));
2075 case Q931_PROTOCOL_DISCRIMINATOR_IA5:
2076 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
2077 tvb_format_text(tvb, offset, len));
2081 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
2082 tvb_bytes_to_str(tvb, offset, len));
2088 * Dissect information elements consisting of ASCII^H^H^H^H^HIA5 text.
2091 dissect_q931_ia5_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
2095 proto_tree_add_text(tree, tvb, offset, len, "%s: %s", label,
2096 tvb_format_text(tvb, offset, len));
2100 static const value_string q931_codeset_vals[] = {
2101 { 0x00, "Q.931 information elements" },
2102 { 0x04, "Information elements for ISO/IEC use" },
2103 { 0x05, "Information elements for national use" },
2104 { 0x06, "Information elements specific to the local network" },
2105 { 0x07, "User-specific information elements" },
2110 dissect_q931_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2114 proto_tree *q931_tree = NULL;
2116 proto_tree *ie_tree = NULL;
2117 guint8 call_ref_len;
2118 guint8 call_ref[15];
2119 guint8 message_type;
2120 guint8 info_element;
2121 guint16 info_element_len;
2123 gboolean non_locking_shift;
2126 if (check_col(pinfo->cinfo, COL_PROTOCOL))
2127 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Q.931");
2130 ti = proto_tree_add_item(tree, proto_q931, tvb, offset, -1,
2132 q931_tree = proto_item_add_subtree(ti, ett_q931);
2134 dissect_q931_protocol_discriminator(tvb, offset, q931_tree);
2137 call_ref_len = tvb_get_guint8(tvb, offset) & 0xF; /* XXX - do as a bit field? */
2138 if (q931_tree != NULL)
2139 proto_tree_add_uint(q931_tree, hf_q931_call_ref_len, tvb, offset, 1, call_ref_len);
2141 if (call_ref_len != 0) {
2142 tvb_memcpy(tvb, call_ref, offset, call_ref_len);
2143 if (q931_tree != NULL) {
2144 proto_tree_add_boolean(q931_tree, hf_q931_call_ref_flag,
2145 tvb, offset, 1, (call_ref[0] & 0x80) != 0);
2146 call_ref[0] &= 0x7F;
2147 proto_tree_add_bytes(q931_tree, hf_q931_call_ref,
2148 tvb, offset, call_ref_len, call_ref);
2150 offset += call_ref_len;
2152 message_type = tvb_get_guint8(tvb, offset);
2153 if (check_col(pinfo->cinfo, COL_INFO)) {
2154 col_add_str(pinfo->cinfo, COL_INFO,
2155 val_to_str(message_type, q931_message_type_vals,
2156 "Unknown message type (0x%02X)"));
2158 if (q931_tree != NULL)
2159 proto_tree_add_uint(q931_tree, hf_q931_message_type, tvb, offset, 1, message_type);
2163 * And now for the information elements....
2165 codeset = 0; /* start out in codeset 0 */
2166 non_locking_shift = TRUE;
2167 while (tvb_reported_length_remaining(tvb, offset) > 0) {
2168 info_element = tvb_get_guint8(tvb, offset);
2171 * Check for the single-octet IEs.
2173 switch (info_element & Q931_IE_SO_IDENTIFIER_MASK) {
2177 !(info_element & Q931_IE_SHIFT_LOCKING);
2178 codeset = info_element & Q931_IE_SHIFT_CODESET;
2179 if (q931_tree != NULL) {
2180 proto_tree_add_text(q931_tree, tvb, offset, 1,
2181 "%s shift to codeset %u: %s",
2182 (non_locking_shift ? "Non-locking" : "Locking"),
2184 val_to_str(codeset, q931_codeset_vals,
2185 "Unknown (0x%02X)"));
2190 case Q931_IE_MORE_DATA_OR_SEND_COMP:
2191 switch (info_element) {
2193 case Q931_IE_MORE_DATA:
2194 if (q931_tree != NULL) {
2195 proto_tree_add_text(q931_tree, tvb, offset, 1,
2200 case Q931_IE_SENDING_COMPLETE:
2201 if (q931_tree != NULL) {
2202 proto_tree_add_text(q931_tree, tvb, offset, 1,
2203 "Sending complete");
2208 if (q931_tree != NULL) {
2209 proto_tree_add_text(q931_tree, tvb, offset, 1,
2210 "Unknown information element (0x%02X",
2216 if (non_locking_shift)
2220 case Q931_IE_CONGESTION_LEVEL:
2221 if (q931_tree != NULL) {
2222 proto_tree_add_text(q931_tree, tvb, offset, 1,
2223 "Congestion level: %s",
2224 val_to_str(info_element & Q931_IE_SO_IE_MASK,
2225 q931_congestion_level_vals,
2229 if (non_locking_shift)
2233 case Q931_IE_REPEAT_INDICATOR:
2234 if (q931_tree != NULL) {
2235 proto_tree_add_text(q931_tree, tvb, offset, 1,
2236 "Repeat indicator: %s",
2237 val_to_str(info_element & Q931_IE_SO_IE_MASK,
2238 q931_repeat_indication_vals,
2242 if (non_locking_shift)
2251 * Variable-length IE.
2253 * According to page 18 from Recommendation H.225.0 :
2254 * " Length of user-user contents contents
2255 * - Shall be 2 octets instead of 1 (as in Figure 4-36/Q.931)"
2257 * We assume that if this is Q.931-over-TPKT, it might
2258 * be H.225 traffic, and check for the IE being a user-user
2259 * IE with ASN.1 encoding of the user information.
2261 if (is_tpkt && tvb_bytes_exist(tvb, offset, 4) &&
2262 tvb_get_guint8(tvb, offset) == Q931_IE_USER_USER &&
2263 tvb_get_guint8(tvb, offset + 3) == Q931_PROTOCOL_DISCRIMINATOR_ASN1) {
2264 info_element_len = tvb_get_ntohs(tvb, offset + 1);
2265 if (q931_tree != NULL) {
2266 ti = proto_tree_add_text(q931_tree, tvb, offset,
2267 1+2+info_element_len, "%s",
2268 val_to_str(info_element,
2269 q931_info_element_vals,
2270 "Unknown information element (0x%02X)"));
2271 ie_tree = proto_item_add_subtree(ti,
2273 proto_tree_add_text(ie_tree, tvb, offset, 1,
2274 "Information element: %s",
2275 val_to_str(info_element,
2276 q931_info_element_vals, "Unknown (0x%02X)"));
2277 proto_tree_add_text(ie_tree, tvb, offset + 1,
2278 2, "Length: %u", info_element_len);
2279 proto_tree_add_text(ie_tree, tvb, offset + 3,
2280 1, "Protocol discriminator: %s",
2281 val_to_str(tvb_get_guint8(tvb, offset + 3),
2282 q931_protocol_discriminator_vals,
2283 "Unknown (0x%02x)"));
2286 if (info_element_len > 1) {
2288 * Do we have a handle for the H.225
2291 if (h225_handle != NULL) {
2293 * Yes - call it, regardless of
2294 * whether we're building a
2295 * protocol tree or not.
2297 h225_tvb = tvb_new_subset(tvb,
2298 offset + 4, info_element_len - 1,
2299 info_element_len - 1);
2300 call_dissector(h225_handle, h225_tvb,
2304 * No - just show it as "User
2305 * information" (if "ie_tree" is
2306 * null, this won't add anything).
2308 proto_tree_add_text(ie_tree, tvb,
2309 offset + 4, info_element_len - 1,
2310 "User information: %s",
2311 tvb_bytes_to_str(tvb, offset + 4,
2312 info_element_len - 1));
2315 offset += 1 + 2 + info_element_len;
2317 info_element_len = tvb_get_guint8(tvb, offset + 1);
2318 if (q931_tree != NULL) {
2319 ti = proto_tree_add_text(q931_tree, tvb, offset,
2320 1+1+info_element_len, "%s",
2321 val_to_str(info_element, q931_info_element_vals,
2322 "Unknown information element (0x%02X)"));
2323 ie_tree = proto_item_add_subtree(ti, ett_q931_ie);
2324 proto_tree_add_text(ie_tree, tvb, offset, 1,
2325 "Information element: %s",
2326 val_to_str(info_element, q931_info_element_vals,
2327 "Unknown (0x%02X)"));
2328 proto_tree_add_text(ie_tree, tvb, offset + 1, 1,
2329 "Length: %u", info_element_len);
2331 switch (info_element) {
2333 case Q931_IE_SEGMENTED_MESSAGE:
2334 dissect_q931_segmented_message_ie(tvb,
2335 offset + 2, info_element_len,
2339 case Q931_IE_BEARER_CAPABILITY:
2340 case Q931_IE_LOW_LAYER_COMPAT:
2341 dissect_q931_bearer_capability_ie(tvb,
2342 offset + 2, info_element_len,
2347 dissect_q931_cause_ie(tvb,
2348 offset + 2, info_element_len,
2350 hf_q931_cause_value);
2353 case Q931_IE_CALL_STATE:
2354 dissect_q931_call_state_ie(tvb,
2355 offset + 2, info_element_len,
2359 case Q931_IE_CHANNEL_IDENTIFICATION:
2360 dissect_q931_channel_identification_ie(
2361 tvb, offset + 2, info_element_len,
2365 case Q931_IE_PROGRESS_INDICATOR:
2366 dissect_q931_progress_indicator_ie(tvb,
2367 offset + 2, info_element_len,
2371 case Q931_IE_NETWORK_SPECIFIC_FACIL:
2372 case Q931_IE_TRANSIT_NETWORK_SEL:
2373 dissect_q931_ns_facilities_ie(tvb,
2374 offset + 2, info_element_len,
2378 case Q931_IE_NOTIFICATION_INDICATOR:
2379 dissect_q931_notification_indicator_ie(
2380 tvb, offset + 2, info_element_len,
2384 case Q931_IE_DISPLAY:
2385 dissect_q931_ia5_ie(tvb, offset + 2,
2386 info_element_len, ie_tree,
2387 "Display information");
2390 case Q931_IE_DATE_TIME:
2391 dissect_q931_date_time_ie(tvb,
2392 offset + 2, info_element_len,
2396 case Q931_IE_KEYPAD_FACILITY:
2397 dissect_q931_ia5_ie(tvb, offset + 2,
2398 info_element_len, ie_tree,
2402 case Q931_IE_SIGNAL:
2403 dissect_q931_signal_ie(tvb,
2404 offset + 2, info_element_len,
2408 case Q931_IE_INFORMATION_RATE:
2409 dissect_q931_information_rate_ie(tvb,
2410 offset + 2, info_element_len,
2414 case Q931_IE_E2E_TRANSIT_DELAY:
2415 dissect_q931_e2e_transit_delay_ie(tvb,
2416 offset + 2, info_element_len,
2420 case Q931_IE_TD_SELECTION_AND_INT:
2421 dissect_q931_td_selection_and_int_ie(
2422 tvb, offset + 2, info_element_len,
2426 case Q931_IE_PL_BINARY_PARAMETERS:
2427 dissect_q931_pl_binary_parameters_ie(
2428 tvb, offset + 2, info_element_len,
2432 case Q931_IE_PL_WINDOW_SIZE:
2433 dissect_q931_pl_window_size_ie(tvb,
2434 offset + 2, info_element_len,
2438 case Q931_IE_PACKET_SIZE:
2439 dissect_q931_packet_size_ie(tvb,
2440 offset + 2, info_element_len,
2445 dissect_q931_cug_ie(tvb,
2446 offset + 2, info_element_len,
2450 case Q931_IE_REVERSE_CHARGE_IND:
2451 dissect_q931_reverse_charge_ind_ie(tvb,
2452 offset + 2, info_element_len,
2456 case Q931_IE_CALLING_PARTY_NUMBER:
2457 dissect_q931_number_ie(tvb,
2458 offset + 2, info_element_len,
2460 hf_q931_calling_party_number);
2463 case Q931_IE_CONNECTED_NUMBER_DEFAULT:
2464 dissect_q931_number_ie(tvb,
2465 offset + 2, info_element_len,
2467 hf_q931_connected_number);
2470 case Q931_IE_CALLED_PARTY_NUMBER:
2471 dissect_q931_number_ie(tvb,
2472 offset + 2, info_element_len,
2474 hf_q931_called_party_number);
2477 case Q931_IE_REDIRECTING_NUMBER:
2478 dissect_q931_number_ie(tvb,
2479 offset + 2, info_element_len,
2481 hf_q931_redirecting_number);
2484 case Q931_IE_CALLING_PARTY_SUBADDR:
2485 case Q931_IE_CALLED_PARTY_SUBADDR:
2486 dissect_q931_party_subaddr_ie(tvb,
2487 offset + 2, info_element_len,
2491 case Q931_IE_RESTART_INDICATOR:
2492 dissect_q931_restart_indicator_ie(tvb,
2493 offset + 2, info_element_len,
2497 case Q931_IE_HIGH_LAYER_COMPAT:
2498 dissect_q931_high_layer_compat_ie(tvb,
2499 offset + 2, info_element_len,
2503 case Q931_IE_USER_USER:
2504 dissect_q931_user_user_ie(tvb,
2505 offset + 2, info_element_len,
2510 proto_tree_add_text(ie_tree, tvb,
2511 offset + 2, info_element_len,
2514 tvb_get_ptr(tvb, offset + 2,
2520 offset += 1 + 1 + info_element_len;
2522 if (non_locking_shift)
2528 * Q.931-over-TPKT-over-TCP.
2531 dissect_q931_tpkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2536 * Check whether this looks like a TPKT-encapsulated
2539 * The minimum length of a Q.931 message is 3:
2540 * 1 byte for the protocol discriminator,
2541 * 1 for the call_reference length,
2542 * and one for the message type.
2544 lv_tpkt_len = is_tpkt(tvb, 3);
2545 if (lv_tpkt_len == -1) {
2547 * It's not a TPKT packet; reject it.
2553 * If this segment is *exactly* the length of a TPKT header,
2554 * we assume that, as it looks like a TPKT header, it
2555 * is one, and that the code put a TPKT header in one
2556 * segment and the rest of the PDU in another.
2558 if (tvb_length(tvb) == 4) {
2560 * It is - call the "dissect TPKT over a TCP stream"
2563 dissect_tpkt_encap(tvb, pinfo, tree, q931_desegment,
2564 q931_tpkt_pdu_handle);
2569 * Well, we have more data than just the TPKT header;
2570 * check whether it looks like the beginning of a
2573 * The minimum length of a Q.931 message is 3, as per the
2576 * Check that we have that many bytes past the TPKT header in
2577 * the tvbuff; we already know that the TPKT header says we
2578 * have that many bytes (as we passed 3 as the "min_len" argument
2581 if (!tvb_bytes_exist(tvb, 4, 3))
2584 /* Check the protocol discriminator */
2585 if (tvb_get_guint8(tvb, 4) != NLPID_Q_931) {
2586 /* Doesn't look like Q.931 inside TPKT */
2591 * OK, it looks like Q.931-over-TPKT.
2592 * Call the "dissect TPKT over a TCP stream" routine.
2594 dissect_tpkt_encap(tvb, pinfo, tree, q931_desegment,
2595 q931_tpkt_pdu_handle);
2601 dissect_q931_tpkt_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2603 dissect_q931_pdu(tvb, pinfo, tree, TRUE);
2607 dissect_q931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2609 dissect_q931_pdu(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_flag,
2625 { "Call reference flag", "q931.call_ref_flag", FT_BOOLEAN, BASE_NONE, TFS(&tfs_call_ref_flag), 0x0,
2628 { &hf_q931_call_ref,
2629 { "Call reference value", "q931.call_ref", FT_BYTES, BASE_HEX, NULL, 0x0,
2632 { &hf_q931_message_type,
2633 { "Message type", "q931.message_type", FT_UINT8, BASE_HEX, VALS(q931_message_type_vals), 0x0,
2636 { &hf_q931_cause_value,
2637 { "Cause value", "q931.cause_value", FT_UINT8, BASE_DEC, VALS(q931_cause_code_vals), 0x0,
2640 { &hf_q931_calling_party_number,
2641 { "Calling party number digits", "q931.calling_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2644 { &hf_q931_called_party_number,
2645 { "Called party number digits", "q931.called_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2648 { &hf_q931_connected_number,
2649 { "Called party number digits", "q931.connected_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2652 { &hf_q931_redirecting_number,
2653 { "Called party number digits", "q931.redirecting_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2657 static gint *ett[] = {
2661 module_t *q931_module;
2663 proto_q931 = proto_register_protocol("Q.931", "Q.931", "q931");
2664 proto_register_field_array (proto_q931, hf, array_length(hf));
2665 proto_register_subtree_array(ett, array_length(ett));
2667 register_dissector("q931", dissect_q931, proto_q931);
2668 q931_tpkt_pdu_handle = create_dissector_handle(dissect_q931_tpkt_pdu,
2671 q931_module = prefs_register_protocol(proto_q931, NULL);
2672 prefs_register_bool_preference(q931_module, "desegment_h323_messages",
2673 "Desegment all Q.931 messages spanning multiple TCP segments",
2674 "Whether the Q.931 dissector should desegment all messages spanning multiple TCP segments",
2679 proto_reg_handoff_q931(void)
2682 * Attempt to get a handle for the H.225 dissector.
2683 * If we can't, the handle we get is null, and we'll just
2684 * dissect putatively-H.255 Call Signaling stuff as User
2687 h225_handle = find_dissector("h225");
2692 heur_dissector_add("tcp", dissect_q931_tpkt, proto_q931);