MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / epan / dissectors / packet-q933.c
blob5e3f1ebe84ac57611a55d1e6864f538791b38607
1 /* packet-q933.c
2 * Routines for Q.933 frame disassembly
3 * Guy Harris <guy@alum.mit.edu>
5 * $Id$
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "config.h"
28 #include <glib.h>
29 #include <epan/packet.h>
30 #include <epan/strutil.h>
31 #include <epan/nlpid.h>
33 static int proto_q933 = -1;
34 static int hf_q933_discriminator = -1;
35 static int hf_q933_coding_standard = -1;
36 static int hf_q933_information_transfer_capability = -1;
37 static int hf_q933_transfer_mode = -1;
38 static int hf_q933_uil1 = -1;
39 static int hf_q933_call_ref_len = -1;
40 static int hf_q933_call_ref_flag = -1;
41 static int hf_q933_call_ref = -1;
42 static int hf_q933_message_type = -1;
43 static int hf_q933_cause_location = -1;
44 static int hf_q933_cause_value = -1;
45 static int hf_q933_number_type = -1;
46 static int hf_q933_numbering_plan = -1;
47 static int hf_q933_extension_ind = -1;
48 static int hf_q933_calling_party_number = -1;
49 static int hf_q933_called_party_number = -1;
50 static int hf_q933_connected_number = -1;
51 /* static int hf_q933_redirecting_number = -1; */
52 static int hf_q933_screening_ind = -1;
53 static int hf_q933_presentation_ind = -1;
54 static int hf_q933_report_type = -1;
55 static int hf_q933_link_verf_txseq = -1;
56 static int hf_q933_link_verf_rxseq = -1;
58 static gint ett_q933 = -1;
59 static gint ett_q933_ie = -1;
62 * Q.933 message types.
64 #define Q933_ESCAPE 0x00
65 #define Q933_ALERTING 0x01
66 #define Q933_CALL_PROCEEDING 0x02
67 #define Q933_CONNECT 0x07
68 #define Q933_CONNECT_ACK 0x0F
69 #define Q933_PROGRESS 0x03
70 #define Q933_SETUP 0x05
71 #define Q933_DISCONNECT 0x45
72 #define Q933_RELEASE 0x4D
73 #define Q933_RELEASE_COMPLETE 0x5A
74 #define Q933_SEGMENT 0x60
75 #define Q933_STATUS 0x7D
76 #define Q933_STATUS_ENQUIRY 0x75
78 static const value_string q933_message_type_vals[] = {
79 { Q933_ESCAPE, "ESCAPE" },
80 { Q933_ALERTING, "ALERTING" },
81 { Q933_CALL_PROCEEDING, "CALL PROCEEDING" },
82 { Q933_CONNECT, "CONNECT" },
83 { Q933_CONNECT_ACK, "CONNECT ACKNOWLEDGE" },
84 { Q933_PROGRESS, "PROGRESS" },
85 { Q933_SETUP, "SETUP" },
86 { Q933_DISCONNECT, "DISCONNECT" },
87 { Q933_RELEASE, "RELEASE" },
88 { Q933_RELEASE_COMPLETE, "RELEASE COMPLETE" },
89 { Q933_SEGMENT, "SEGMENT" },
90 { Q933_STATUS, "STATUS" },
91 { Q933_STATUS_ENQUIRY, "STATUS ENQUIRY" },
92 { 0, NULL }
95 static const true_false_string tfs_call_ref_flag = {
96 "Message sent to originating side",
97 "Message sent from originating side"
101 * Information elements.
104 /* Shifted codeset values */
105 #define CS0 0x000
106 #define CS1 0x100
107 #define CS2 0x200
108 #define CS3 0x300
109 #define CS4 0x400
110 #define CS5 0x500
111 #define CS6 0x600
112 #define CS7 0x700
114 #define Q933_IE_SO_MASK 0x80 /* single-octet/variable-length mask */
116 * Single-octet IEs.
118 #define Q933_IE_SO_IDENTIFIER_MASK 0xf0 /* IE identifier mask */
119 #define Q933_IE_SO_IDENTIFIER_SHIFT 4 /* IE identifier shift */
120 #define Q933_IE_SO_IE_MASK 0x0F /* IE mask */
122 #define Q933_IE_SHIFT 0x90
123 #define Q933_IE_SHIFT_NON_LOCKING 0x08 /* non-locking shift */
124 #define Q933_IE_SHIFT_CODESET 0x07 /* codeset */
126 #define Q933_IE_REPEAT_INDICATOR 0xD0
129 * Variable-length IEs.
131 #define Q933_IE_VL_EXTENSION 0x80 /* Extension flag */
132 /* extension bit. The bit value "0" indicates that the octet continues through the */
133 /* next octet. The bit value "1" indicates that this octet is the last octet */
135 static const true_false_string q933_extension_ind_value = {
136 "last octet",
137 "information continues through the next octet",
143 * Codeset 0 (default).
145 #define Q933_IE_SEGMENTED_MESSAGE 0x00
146 #define Q933_IE_BEARER_CAPABILITY 0x04
147 #define Q933_IE_CAUSE 0x08
148 #define Q933_IE_CALL_STATE 0x14
149 #define Q933_IE_CHANNEL_IDENTIFICATION 0x18
150 #define Q933_IE_DLCI 0x19
151 #define Q933_IE_PROGRESS_INDICATOR 0x1E
152 #define Q933_IE_NETWORK_SPECIFIC_FACIL 0x20 /* Network Specific Facilities */
153 #define Q933_IE_DISPLAY 0x28
154 #define Q933_IE_E2E_TRANSIT_DELAY 0x42 /* End-to-end Transit Delay */
155 #define Q933_IE_TD_SELECTION_AND_INT 0x43 /* Transit Delay Selection and Indication */
156 #define Q933_IE_PL_BINARY_PARAMETERS 0x44 /* Packet layer binary parameters */
157 #define Q933_IE_LL_CORE_PARAMETERS 0x48 /* Link layer core parameters */
158 #define Q933_IE_LL_PROTOCOL_PARAMETERS 0x49 /* Link layer protocol parameters */
159 #define Q933_IE_REVERSE_CHARGE_IND 0x4A /* Reverse charging indication */
160 #define Q933_IE_CONNECTED_NUMBER 0x4C /* Connected Number */
161 #define Q933_IE_CONNECTED_SUBADDR 0x4D /* Connected sub-address */
162 #define Q933_IE_X_213_PRIORITY 0x50 /* X.213 priority */
163 #define Q933_IE_REPORT_TYPE 0x51
164 #define Q933_IE_LINK_INTEGRITY_VERF 0x53 /* Link integrity verification */
165 #define Q933_IE_PVC_STATUS 0x57
166 #define Q933_IE_CALLING_PARTY_NUMBER 0x6C /* Calling Party Number */
167 #define Q933_IE_CALLING_PARTY_SUBADDR 0x6D /* Calling Party Subaddress */
168 #define Q933_IE_CALLED_PARTY_NUMBER 0x70 /* Called Party Number */
169 #define Q933_IE_CALLED_PARTY_SUBADDR 0x71 /* Called Party Subaddress */
170 #define Q933_IE_TRANSIT_NETWORK_SEL 0x78 /* Transit Network Selection */
171 #define Q933_IE_LOW_LAYER_COMPAT 0x7C /* Low-Layer Compatibility */
172 #define Q933_IE_HIGH_LAYER_COMPAT 0x7D /* High-Layer Compatibility */
173 #define Q933_IE_USER_USER 0x7E /* User-User */
174 #define Q933_IE_ESCAPE 0x7F /* Escape for extension */
176 /* Codeset 0 */
177 static const value_string q933_info_element_vals0[] = {
178 { Q933_IE_SEGMENTED_MESSAGE, "Segmented message" },
179 { Q933_IE_BEARER_CAPABILITY, "Bearer capability" },
180 { Q933_IE_CAUSE, "Cause" },
181 { Q933_IE_CALL_STATE, "Call state" },
182 { Q933_IE_CHANNEL_IDENTIFICATION, "Channel identification" },
183 { Q933_IE_DLCI, "Data link connection identifier" },
184 { Q933_IE_PROGRESS_INDICATOR, "Progress indicator" },
185 { Q933_IE_NETWORK_SPECIFIC_FACIL, "Network specific facilities" },
186 { Q933_IE_E2E_TRANSIT_DELAY, "End-to-end transit delay" },
187 { Q933_IE_TD_SELECTION_AND_INT, "Transit delay selection and indication" },
188 { Q933_IE_PL_BINARY_PARAMETERS, "Packet layer binary parameters" },
189 { Q933_IE_LL_CORE_PARAMETERS, "Link layer core parameters" },
190 { Q933_IE_LL_PROTOCOL_PARAMETERS, "Link layer protocol parameters" },
191 { Q933_IE_REVERSE_CHARGE_IND, "Reverse charging indication" },
192 { Q933_IE_CONNECTED_NUMBER, "Connected number" },
193 { Q933_IE_CONNECTED_SUBADDR, "Connected subaddress" },
194 { Q933_IE_X_213_PRIORITY, "X.213 priority" },
195 { Q933_IE_REPORT_TYPE, "Report type" },
196 { Q933_IE_LINK_INTEGRITY_VERF, "Link integrity verification" },
197 { Q933_IE_PVC_STATUS, "PVC status" },
198 { Q933_IE_CALLING_PARTY_NUMBER, "Calling party number" },
199 { Q933_IE_CALLING_PARTY_SUBADDR, "Calling party subaddress" },
200 { Q933_IE_CALLED_PARTY_NUMBER, "Called party number" },
201 { Q933_IE_CALLED_PARTY_SUBADDR, "Called party subaddress" },
202 { Q933_IE_TRANSIT_NETWORK_SEL, "Transit network selection" },
203 { Q933_IE_LOW_LAYER_COMPAT, "Low-layer compatibility" },
204 { Q933_IE_HIGH_LAYER_COMPAT, "High-layer compatibility" },
205 { Q933_IE_USER_USER, "User-user" },
206 { Q933_IE_ESCAPE, "Escape" },
207 { 0, NULL }
209 /* Codeset 1 */
210 static const value_string q933_info_element_vals1[] = {
211 { 0, NULL }
213 /* Codeset 2 */
214 static const value_string q933_info_element_vals2[] = {
215 { 0, NULL }
217 /* Codeset 3 */
218 static const value_string q933_info_element_vals3[] = {
219 { 0, NULL }
221 /* Codeset 4 */
222 static const value_string q933_info_element_vals4[] = {
223 { 0, NULL }
226 /* Codeset 5 */
227 #define Q933_IE_ANSI_REPORT_TYPE 0x01
228 #define Q933_IE_ANSI_LINK_INTEGRITY_VERF 0x03
229 #define Q933_IE_ANSI_PVC_STATUS 0x07
231 /* Codeset 5 */
232 static const value_string q933_info_element_vals5[] = {
233 { Q933_IE_ANSI_REPORT_TYPE, "Report type (ANSI)" },
234 { Q933_IE_REPORT_TYPE, "Report type (CCITT)" },
235 { Q933_IE_ANSI_LINK_INTEGRITY_VERF, "Keep Alive (ANSI)" },
236 { Q933_IE_LINK_INTEGRITY_VERF, "Keep Alive (CCITT)" },
237 { Q933_IE_ANSI_PVC_STATUS, "PVC Status (ANSI)" },
238 { Q933_IE_PVC_STATUS, "PVC Status (CCITT)" },
239 { 0, NULL }
241 /* Codeset 6 */
242 static const value_string q933_info_element_vals6[] = {
243 { 0, NULL }
245 /* Codeset 7 */
246 static const value_string q933_info_element_vals7[] = {
247 { 0, NULL }
250 /* Codeset array */
251 #define NUM_INFO_ELEMENT_VALS (Q933_IE_SHIFT_CODESET+1)
252 static const value_string *q933_info_element_vals[NUM_INFO_ELEMENT_VALS] = {
253 q933_info_element_vals0,
254 q933_info_element_vals1,
255 q933_info_element_vals2,
256 q933_info_element_vals3,
257 q933_info_element_vals4,
258 q933_info_element_vals5,
259 q933_info_element_vals6,
260 q933_info_element_vals7,
263 static const value_string q933_repeat_indication_vals[] = {
264 { 0x2, "Prioritized list" },
265 { 0, NULL }
269 * ITU-standardized coding.
271 #define Q933_ITU_STANDARDIZED_CODING 0x00
274 * Dissect a Segmented message information element.
276 static void
277 dissect_q933_segmented_message_ie(tvbuff_t *tvb, int offset, int len,
278 proto_tree *tree)
280 if (len != 2) {
281 proto_tree_add_text(tree, tvb, offset, len,
282 "Segmented message: length is %d, should be 2", len);
283 return;
285 if (tvb_get_guint8(tvb, offset) & 0x80) {
286 proto_tree_add_text(tree, tvb, offset, 1,
287 "First segment: %u segments remaining",
288 tvb_get_guint8(tvb, offset) & 0x7F);
289 } else {
290 proto_tree_add_text(tree, tvb, offset, 1,
291 "Not first segment: %u segments remaining",
292 tvb_get_guint8(tvb, offset) & 0x7F);
294 proto_tree_add_text(tree, tvb, offset + 1, 1,
295 "Segmented message type: %u", tvb_get_guint8(tvb, offset + 1));
299 * Dissect a Bearer capability or Low-layer compatibility information element.
301 static const value_string q933_coding_standard_vals[] = {
302 { 0x0, "ITU-T standardized coding" },
303 { 0x1, "ISO/IEC standard" },
304 { 0x2, "National standard" },
305 { 0x3, "Standard defined for this particular network" },
306 { 0, NULL }
309 static const value_string q933_information_transfer_capability_vals[] = {
310 { 0x08, "Unrestricted digital information" },
311 { 0, NULL }
314 static const value_string q933_transfer_mode_vals[] = {
315 { 0x01, "Frame mode" },
316 { 0, NULL }
319 static const value_string q933_uil1_vals[] = {
320 { 0x01, "V.110/I.460/X.30 rate adaption" },
321 { 0x02, "Recommendation G.711 u-law" },
322 { 0x03, "Recommendation G.711 A-law" },
323 { 0x04, "Recommendation G.721 32 kbit/s ADPCM and Recommendation I.460" },
324 { 0x05, "Recommendation H.221 and H.242" },
325 { 0x06, "Recommendation H.223 and H.245" },
326 { 0x07, "Non-ITU-T-standardized rate adaption" },
327 { 0x08, "V.120 rate adaption" },
328 { 0x09, "X.31 HDLC flag stuffing" },
329 { 0, NULL },
332 static const value_string q933_l1_user_rate_vals[] = {
333 { 0x00, "Rate indicated by E-bits" },
334 { 0x01, "0.6 kbit/s" },
335 { 0x02, "1.2 kbit/s" },
336 { 0x03, "2.4 kbit/s" },
337 { 0x04, "3.6 kbit/s" },
338 { 0x05, "4.8 kbit/s" },
339 { 0x06, "7.2 kbit/s" },
340 { 0x07, "8 kbit/s" },
341 { 0x08, "9.6 kbit/s" },
342 { 0x09, "14.4 kbit/s" },
343 { 0x0A, "16 kbit/s" },
344 { 0x0B, "19.2 kbit/s" },
345 { 0x0C, "32 kbit/s" },
346 { 0x0E, "48 kbit/s" },
347 { 0x0F, "56 kbit/s" },
348 { 0x10, "64 kbit/s "},
349 { 0x15, "0.1345 kbit/s" },
350 { 0x16, "0.100 kbit/s" },
351 { 0x17, "0.075/1.2 kbit/s" },
352 { 0x18, "1.2/0.075 kbit/s" },
353 { 0x19, "0.050 kbit/s" },
354 { 0x1A, "0.075 kbit/s" },
355 { 0x1B, "0.110 kbit/s" },
356 { 0x1C, "0.150 kbit/s" },
357 { 0x1D, "0.200 kbit/s" },
358 { 0x1E, "0.300 kbit/s" },
359 { 0x1F, "12 kbit/s" },
360 { 0, NULL }
363 static const value_string q933_l1_stop_bits_vals[] = {
364 { 0x20, "1" },
365 { 0x40, "1.5" },
366 { 0x60, "2" },
367 { 0, NULL }
370 static const value_string q933_l1_data_bits_vals[] = {
371 { 0x08, "5" },
372 { 0x10, "7" },
373 { 0x18, "8" },
374 { 0, NULL }
377 static const value_string q933_l1_parity_vals[] = {
378 { 0x00, "Odd" },
379 { 0x02, "Even" },
380 { 0x03, "None" },
381 { 0x04, "Forced to 0" },
382 { 0x05, "Forced to 1" },
383 { 0, NULL }
386 #define Q933_UIL2_USER_SPEC 0x10
388 static const value_string q933_uil2_vals[] = {
389 { 0x01, "Basic mode ISO 1745" },
390 { 0x06, "X.25, link level" },
391 { 0x07, "X.25 multilink" },
392 { 0x08, "T.71 Extended LAPB" },
393 { 0x09, "HDLC ARM" },
394 { 0x0A, "HDLC NRM" },
395 { 0x0B, "HDLC ABM" },
396 { 0x0C, "ISO 8802/2 LLC" },
397 { 0x0D, "X.75 Single Link Procedure" },
398 { 0x0E, "Q.922" },
399 { 0x0F, "Core aspects of Q.922" },
400 { Q933_UIL2_USER_SPEC, "User-specified" },
401 { 0x11, "ISO 7776 DTE-DTE operation" },
402 { 0, NULL }
405 static const value_string q933_address_inclusion_vals[] = {
406 { 0x01, "Address included" },
407 { 0x02, "Encapsulation of logical control frame" },
408 { 0, NULL }
411 static const value_string q933_mode_vals[] = {
412 { 0x20, "Normal mode" },
413 { 0x40, "Extended mode" },
414 { 0, NULL }
417 #define Q933_UIL3_X25_PL 0x06
418 #define Q933_UIL3_ISO_8208 0x07 /* X.25-based */
419 #define Q933_UIL3_X223 0x08 /* X.25-based */
420 #define Q933_UIL3_TR_9577 0x0B
421 #define Q933_UIL3_USER_SPEC 0x10
423 static const value_string q933_uil3_vals[] = {
424 { Q933_UIL3_X25_PL, "X.25, packet layer" },
425 { Q933_UIL3_ISO_8208, "ISO/IEC 8208" },
426 { Q933_UIL3_X223, "X.223/ISO 8878" },
427 { 0x09, "ISO/IEC 8473" },
428 { 0x0A, "T.70" },
429 { Q933_UIL3_TR_9577, "ISO/IEC TR 9577" },
430 { Q933_UIL3_USER_SPEC, "User-specified" },
431 { 0, NULL }
434 static void
435 dissect_q933_protocol_discriminator(tvbuff_t *tvb, int offset, proto_tree *tree)
437 unsigned int discriminator = tvb_get_guint8(tvb, offset);
439 if (discriminator == NLPID_Q_933) {
440 proto_tree_add_uint_format_value(tree, hf_q933_discriminator,
441 tvb, offset, 1, discriminator,
442 "Q.933");
443 } else if (discriminator == NLPID_Q_2931) {
444 proto_tree_add_uint_format_value(tree, hf_q933_discriminator,
445 tvb, offset, 1, discriminator,
446 "Q.2931");
447 } else if ((discriminator >= 16 && discriminator < 63)
448 || ((discriminator >= 80) && (discriminator < 254))) {
449 proto_tree_add_uint_format_value(tree, hf_q933_discriminator,
450 tvb, offset, 1, discriminator,
451 "Network layer or layer 3 protocol (0x%02X)",
452 discriminator);
453 } else if (discriminator >= 64 && discriminator <= 79) {
454 proto_tree_add_uint_format_value(tree, hf_q933_discriminator,
455 tvb, offset, 1, discriminator,
456 "National use (0x%02X)",
457 discriminator);
458 } else {
459 proto_tree_add_uint_format_value(tree, hf_q933_discriminator,
460 tvb, offset, 1, discriminator,
461 "Reserved (0x%02X)",
462 discriminator);
466 static void
467 dissect_q933_bearer_capability_ie(tvbuff_t *tvb, int offset, int len,
468 proto_tree *tree)
470 guint8 octet;
471 guint8 coding_standard;
472 guint8 modem_type;
473 guint8 uil2_protocol;
474 guint8 uil3_protocol;
475 guint8 add_l3_info;
477 if (len == 0)
478 return;
479 octet = tvb_get_guint8(tvb, offset);
480 coding_standard = octet & 0x60;
481 if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
483 * We don't know how the bearer capability is encoded,
484 * so just dump it as data and be done with it.
486 proto_tree_add_text(tree, tvb, offset,
487 len, "Data: %s",
488 tvb_bytes_to_str(tvb, offset, len));
489 proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
490 proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
491 return;
493 proto_tree_add_uint(tree, hf_q933_information_transfer_capability, tvb, offset, 1, octet);
494 proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
495 proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
496 offset += 1;
497 len -= 1;
500 * XXX - only in Low-layer compatibility information element.
502 if (!(octet & Q933_IE_VL_EXTENSION)) {
503 if (len == 0)
504 return;
505 octet = tvb_get_guint8(tvb, offset);
506 proto_tree_add_text(tree, tvb, offset, 1,
507 "Out-band negotiation %spossible",
508 (octet & 0x40) ? "" : "not ");
509 offset += 1;
510 len -= 1;
513 if (len == 0)
514 return;
515 octet = tvb_get_guint8(tvb, offset);
516 proto_tree_add_uint(tree, hf_q933_transfer_mode, tvb, offset, 1, octet);
517 proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
518 offset += 1;
519 len -= 1;
521 if (len == 0)
522 return;
523 octet = tvb_get_guint8(tvb, offset);
524 if ((octet & 0x60) == 0x20) {
526 * Layer 1 information.
528 proto_tree_add_uint(tree, hf_q933_uil1, tvb, offset, 1, octet);
529 proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
530 offset += 1;
531 len -= 1;
533 if (octet & Q933_IE_VL_EXTENSION)
534 goto l1_done;
535 if (len == 0)
536 return;
537 octet = tvb_get_guint8(tvb, offset);
538 proto_tree_add_text(tree, tvb, offset, 1,
539 "Layer 1 is %s",
540 (octet & 0x40) ? "Asynchronous" : "Synchronous");
541 proto_tree_add_text(tree, tvb, offset, 1,
542 "User rate: %s",
543 val_to_str(octet & 0x1F, q933_l1_user_rate_vals,
544 "Unknown (0x%02X)"));
545 offset += 1;
546 len -= 1;
548 if (octet & Q933_IE_VL_EXTENSION)
549 goto l1_done;
550 if (len == 0)
551 return;
552 octet = tvb_get_guint8(tvb, offset);
553 proto_tree_add_text(tree, tvb, offset, 1,
554 "Rate adaption header %sincluded",
555 (octet & 0x40) ? "" : "not ");
556 proto_tree_add_text(tree, tvb, offset, 1,
557 "Multiple frame establishment %ssupported",
558 (octet & 0x20) ? "" : "not ");
559 proto_tree_add_text(tree, tvb, offset, 1,
560 "%s mode of operation",
561 (octet & 0x10) ? "Protocol sensitive" : "Bit transparent");
562 offset += 1;
563 len -= 1;
565 if (octet & Q933_IE_VL_EXTENSION)
566 goto l1_done;
567 if (len == 0)
568 return;
569 octet = tvb_get_guint8(tvb, offset);
570 proto_tree_add_text(tree, tvb, offset, 1,
571 "Stop bits: %s",
572 val_to_str(octet & 0x60, q933_l1_stop_bits_vals,
573 "Unknown (0x%X)"));
574 proto_tree_add_text(tree, tvb, offset, 1,
575 "Data bits: %s",
576 val_to_str(octet & 0x18, q933_l1_data_bits_vals,
577 "Unknown (0x%X)"));
578 proto_tree_add_text(tree, tvb, offset, 1,
579 "Parity: %s",
580 val_to_str(octet & 0x07, q933_l1_parity_vals,
581 "Unknown (0x%X)"));
582 offset += 1;
583 len -= 1;
585 if (octet & Q933_IE_VL_EXTENSION)
586 goto l1_done;
587 if (len == 0)
588 return;
589 octet = tvb_get_guint8(tvb, offset);
590 proto_tree_add_text(tree, tvb, offset, 1,
591 "%s duplex",
592 (octet & 0x40) ? "Full" : "Half");
593 modem_type = octet & 0x3F;
594 proto_tree_add_text(tree, tvb, offset, 1,
595 "Modem type: Network-specific rules 0x%02X", modem_type);
596 offset += 1;
597 len -= 1;
599 l1_done:
602 if (len == 0)
603 return;
604 octet = tvb_get_guint8(tvb, offset);
605 if ((octet & 0x60) == 0x40) {
607 * Layer 2 information.
609 uil2_protocol = octet & 0x1F;
610 proto_tree_add_text(tree, tvb, offset, 1,
611 "User information layer 2 protocol: %s",
612 val_to_str(uil2_protocol, q933_uil2_vals,
613 "Unknown (0x%02X)"));
614 offset += 1;
615 len -= 1;
618 * XXX - only in Low-layer compatibility information element.
620 if (octet & Q933_IE_VL_EXTENSION)
621 goto l2_done;
622 if (len == 0)
623 return;
624 octet = tvb_get_guint8(tvb, offset);
625 if (uil2_protocol == Q933_UIL2_USER_SPEC) {
626 proto_tree_add_text(tree, tvb, offset, 1,
627 "User-specified layer 2 protocol information: 0x%02X",
628 octet & 0x7F);
629 } else {
630 proto_tree_add_text(tree, tvb, offset, 1,
631 "Address inclusion: %s",
632 val_to_str(octet & 0x03, q933_address_inclusion_vals,
633 "Unknown (0x%02X)"));
635 offset += 1;
636 len -= 1;
638 l2_done:
641 if (len == 0)
642 return;
643 octet = tvb_get_guint8(tvb, offset);
644 if ((octet & 0x60) == 0x60) {
646 * Layer 3 information.
648 uil3_protocol = octet & 0x1F;
649 proto_tree_add_text(tree, tvb, offset, 1,
650 "User information layer 3 protocol: %s",
651 val_to_str(uil3_protocol, q933_uil3_vals,
652 "Unknown (0x%02X)"));
653 offset += 1;
654 len -= 1;
658 * XXX - only in Low-layer compatibility information element.
660 if (octet & Q933_IE_VL_EXTENSION)
661 goto l3_done;
662 if (len == 0)
663 return;
664 octet = tvb_get_guint8(tvb, offset);
665 switch (uil3_protocol) {
667 case Q933_UIL3_X25_PL:
668 case Q933_UIL3_ISO_8208:
669 case Q933_UIL3_X223:
670 proto_tree_add_text(tree, tvb, offset, 1,
671 "Mode: %s",
672 val_to_str(octet & 0x60, q933_mode_vals,
673 "Unknown (0x%02X)"));
674 offset += 1;
675 len -= 1;
677 if (octet & Q933_IE_VL_EXTENSION)
678 goto l3_done;
679 if (len == 0)
680 return;
681 octet = tvb_get_guint8(tvb, offset);
682 proto_tree_add_text(tree, tvb, offset, 1,
683 "Default packet size: %u", octet & 0x0F);
684 offset += 1;
685 len -= 1;
687 if (octet & Q933_IE_VL_EXTENSION)
688 goto l3_done;
689 if (len == 0)
690 return;
691 octet = tvb_get_guint8(tvb, offset);
692 proto_tree_add_text(tree, tvb, offset, 1,
693 "Packet window size: %u", octet & 0x7F);
694 /*offset += 1;*/
695 /*len -= 1;*/
696 break;
698 case Q933_UIL3_USER_SPEC:
699 proto_tree_add_text(tree, tvb, offset, 1,
700 "Default packet size: %u octets",
701 1 << (octet & 0x0F));
702 /*offset += 1;*/
703 /*len -= 1;*/
704 break;
706 case Q933_UIL3_TR_9577:
707 add_l3_info = (octet & 0x0F) << 4;
708 if (octet & Q933_IE_VL_EXTENSION)
709 goto l3_done;
710 #if 0 /* XXX: len is always >0 at this point; is field always 2 bytes (if not Q933_IE_VL_EXTENSION) ? */
711 if (len == 0)
712 return;
713 #endif
714 octet = tvb_get_guint8(tvb, offset + 1);
715 add_l3_info |= (octet & 0x0F);
716 proto_tree_add_text(tree, tvb, offset, 2,
717 "Additional layer 3 protocol information: %s",
718 val_to_str(add_l3_info, nlpid_vals,
719 "Unknown (0x%02X)"));
720 /*offset += 2;*/
721 /*len -= 2;*/
722 break;
725 l3_done:
730 * Dissect a Cause information element.
734 const value_string q933_cause_location_vals[] = {
735 { 0x00, "User (U)" },
736 { 0x01, "Private network serving the local user (LPN)" },
737 { 0x02, "Public network serving the local user (LN)" },
738 { 0x03, "Transit network (TN)" },
739 { 0x04, "Public network serving the remote user (RLN)" },
740 { 0x05, "Private network serving the remote user (RPN)" },
741 { 0x07, "International network (INTL)" },
742 { 0x0A, "Network beyond interworking point (BI)" },
743 { 0, NULL }
746 static const value_string q933_cause_recommendation_vals[] = {
747 { 0x00, "Q.933" },
748 { 0x03, "X.21" },
749 { 0x04, "X.25" },
750 { 0x05, "Q.1031/Q.1051" },
751 { 0, NULL }
755 * Cause codes for Cause.
757 #define Q933_CAUSE_UNALLOC_NUMBER 0x01
758 #define Q933_CAUSE_NO_ROUTE_TO_DEST 0x03
759 #define Q933_CAUSE_CALL_REJECTED 0x15
760 #define Q933_CAUSE_NUMBER_CHANGED 0x16
761 #define Q933_CAUSE_ACCESS_INFO_DISC 0x2B
762 #define Q933_CAUSE_QOS_UNAVAILABLE 0x31
763 #define Q933_CAUSE_CHAN_NONEXISTENT 0x52
764 #define Q933_CAUSE_INCOMPATIBLE_DEST 0x58
765 #define Q933_CAUSE_MAND_IE_MISSING 0x60
766 #define Q933_CAUSE_MT_NONEX_OR_UNIMPL 0x61
767 #define Q933_CAUSE_IE_NONEX_OR_UNIMPL 0x63
768 #define Q933_CAUSE_INVALID_IE_CONTENTS 0x64
769 #define Q933_CAUSE_MSG_INCOMPAT_W_CS 0x65
770 #define Q933_CAUSE_REC_TIMER_EXP 0x66
772 const value_string q933_cause_code_vals[] = {
773 { 0x00, "Valid cause code not yet received" },
774 { Q933_CAUSE_UNALLOC_NUMBER, "Unallocated (unassigned) number" },
775 { 0x02, "No route to specified transit network" },
776 { Q933_CAUSE_NO_ROUTE_TO_DEST, "No route to destination" },
777 { 0x04, "Send special information tone" },
778 { 0x05, "Misdialled trunk prefix" },
779 { 0x06, "Channel unacceptable" },
780 { 0x07, "Call awarded and being delivered in an established channel" },
781 { 0x08, "Prefix 0 dialed but not allowed" },
782 /* Q.850 - "Preemption" */
783 { 0x09, "Prefix 1 dialed but not allowed" },
784 /* Q.850 - "Preemption - circuit reserved for reuse" */
785 { 0x0A, "Prefix 1 dialed but not required" },
786 { 0x0B, "More digits received than allowed, call is proceeding" },
787 { 0x0E, "QoR: ported number" },
788 { 0x10, "Normal call clearing" },
789 { 0x11, "User busy" },
790 { 0x12, "No user responding" },
791 { 0x13, "No answer from user (user alerted)" },
792 { 0x14, "Subscriber absent" },
793 { Q933_CAUSE_CALL_REJECTED, "Call rejected" },
794 { Q933_CAUSE_NUMBER_CHANGED, "Number changed" },
795 { 0x17, "Reverse charging rejected" },
796 /* Q.850 - "Redirection to new destination" */
797 { 0x18, "Call suspended" },
798 /* Q.850 Amendment 1 - "Call rejected due to feature at the destination" */
799 { 0x19, "Call resumed" },
800 /* Q.850 - "Exchange routing error */
801 { 0x1A, "Non-selected user clearing" },
802 { 0x1B, "Destination out of order" },
803 { 0x1C, "Invalid number format (incomplete number)" },
804 { 0x1D, "Facility rejected" },
805 { 0x1E, "Response to STATUS ENQUIRY" },
806 { 0x1F, "Normal unspecified" },
807 { 0x21, "Circuit out of order" },
808 { 0x22, "No circuit/channel available" },
809 { 0x23, "Destination unattainable" },
810 { 0x25, "Degraded service" },
811 { 0x26, "Network out of order" },
812 { 0x27, "Transit delay range cannot be achieved" },
813 /* Q.850 - "Permanent frame mode connection out of service" */
814 { 0x28, "Throughput range cannot be achieved" },
815 /* Q.850 - "Permanent frame mode connection operational" */
816 { 0x29, "Temporary failure" },
817 { 0x2A, "Switching equipment congestion" },
818 { Q933_CAUSE_ACCESS_INFO_DISC, "Access information discarded" },
819 { 0x2C, "Requested circuit/channel not available" },
820 { 0x2D, "Pre-empted" },
821 { 0x2E, "Precedence call blocked" },
822 { 0x2F, "Resources unavailable, unspecified" },
823 { Q933_CAUSE_QOS_UNAVAILABLE, "Quality of service unavailable" },
824 { 0x32, "Requested facility not subscribed" },
825 { 0x33, "Reverse charging not allowed" },
826 { 0x34, "Outgoing calls barred" },
827 { 0x35, "Outgoing calls barred within CUG" },
828 { 0x36, "Incoming calls barred" },
829 { 0x37, "Incoming calls barred within CUG" },
830 { 0x38, "Call waiting not subscribed" },
831 { 0x39, "Bearer capability not authorized" },
832 { 0x3A, "Bearer capability not presently available" },
833 { 0x3E, "Inconsistency in designated outgoing access information and subscriber class" },
834 { 0x3F, "Service or option not available, unspecified" },
835 { 0x41, "Bearer capability not implemented" },
836 { 0x42, "Channel type not implemented" },
837 { 0x43, "Transit network selection not implemented" },
838 { 0x44, "Message not implemented" },
839 { 0x45, "Requested facility not implemented" },
840 { 0x46, "Only restricted digital information bearer capability is available" },
841 { 0x4F, "Service or option not implemented, unspecified" },
842 { 0x51, "Invalid call reference value" },
843 { Q933_CAUSE_CHAN_NONEXISTENT, "Identified channel does not exist" },
844 { 0x53, "Call identity does not exist for suspended call" },
845 { 0x54, "Call identity in use" },
846 { 0x55, "No call suspended" },
847 { 0x56, "Call having the requested call identity has been cleared" },
848 { 0x57, "Called user not member of CUG" },
849 { Q933_CAUSE_INCOMPATIBLE_DEST, "Incompatible destination" },
850 { 0x59, "Non-existent abbreviated address entry" },
851 { 0x5A, "Destination address missing, and direct call not subscribed" },
852 /* Q.850 - "Non-existent CUG" */
853 { 0x5B, "Invalid transit network selection (national use)" },
854 { 0x5C, "Invalid facility parameter" },
855 { 0x5D, "Mandatory information element is missing" },
856 { 0x5F, "Invalid message, unspecified" },
857 { Q933_CAUSE_MAND_IE_MISSING, "Mandatory information element is missing" },
858 { Q933_CAUSE_MT_NONEX_OR_UNIMPL,"Message type non-existent or not implemented" },
859 { 0x62, "Message not compatible with call state or message type non-existent or not implemented" },
860 { Q933_CAUSE_IE_NONEX_OR_UNIMPL,"Information element non-existent or not implemented" },
861 { Q933_CAUSE_INVALID_IE_CONTENTS,"Invalid information element contents" },
862 { Q933_CAUSE_MSG_INCOMPAT_W_CS, "Message not compatible with call state" },
863 { Q933_CAUSE_REC_TIMER_EXP, "Recovery on timer expiry" },
864 { 0x67, "Parameter non-existent or not implemented - passed on" },
865 { 0x6E, "Message with unrecognized parameter discarded" },
866 { 0x6F, "Protocol error, unspecified" },
867 { 0x7F, "Internetworking, unspecified" },
868 { 0, NULL }
871 static const value_string q933_cause_condition_vals[] = {
872 { 0x00, "Unknown" },
873 { 0x01, "Permanent" },
874 { 0x02, "Transient" },
875 { 0x00, NULL }
878 #define Q933_REJ_USER_SPECIFIC 0x00
879 #define Q933_REJ_IE_MISSING 0x04
880 #define Q933_REJ_IE_INSUFFICIENT 0x08
882 static const value_string q933_rejection_reason_vals[] = {
883 { 0x00, "User specific" },
884 { 0x04, "Information element missing" },
885 { 0x08, "Information element contents are not sufficient" },
886 { 0x00, NULL }
889 static void
890 dissect_q933_cause_ie(tvbuff_t *tvb, int offset, int len,
891 proto_tree *tree, int hf_cause_value)
893 guint8 octet;
894 guint8 cause_value;
895 guint8 coding_standard;
896 guint8 rejection_reason;
898 if (len == 0)
899 return;
900 octet = tvb_get_guint8(tvb, offset);
901 coding_standard = octet & 0x60;
902 if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
904 * We don't know how the cause is encoded,
905 * so just dump it as data and be done with it.
907 proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
908 proto_tree_add_text(tree, tvb, offset,
909 len, "Data: %s",
910 tvb_bytes_to_str(tvb, offset, len));
911 return;
913 proto_tree_add_uint(tree, hf_q933_cause_location, tvb, offset, 1, octet);
914 proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
915 proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
916 offset += 1;
917 len -= 1;
919 if (!(octet & Q933_IE_VL_EXTENSION)) {
920 if (len == 0)
921 return;
922 octet = tvb_get_guint8(tvb, offset);
923 proto_tree_add_text(tree, tvb, offset, 1,
924 "Recommendation: %s",
925 val_to_str(octet & 0x7F, q933_cause_recommendation_vals,
926 "Unknown (0x%02X)"));
927 proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
928 offset += 1;
929 len -= 1;
932 if (len == 0)
933 return;
934 octet = tvb_get_guint8(tvb, offset);
935 cause_value = octet & 0x7F;
936 proto_tree_add_uint(tree, hf_cause_value, tvb, offset, 1, cause_value);
937 proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
938 offset += 1;
939 len -= 1;
941 if (len == 0)
942 return;
943 switch (cause_value) {
945 case Q933_CAUSE_UNALLOC_NUMBER:
946 case Q933_CAUSE_NO_ROUTE_TO_DEST:
947 case Q933_CAUSE_QOS_UNAVAILABLE:
948 octet = tvb_get_guint8(tvb, offset);
949 proto_tree_add_text(tree, tvb, offset, 1,
950 "Network service: %s",
951 (octet & 0x80) ? "User" : "Provider");
952 proto_tree_add_text(tree, tvb, offset, 1,
953 "%s",
954 (octet & 0x40) ? "Abnormal" : "Normal");
955 proto_tree_add_text(tree, tvb, offset, 1,
956 "Condition: %s",
957 val_to_str(octet & 0x03, q933_cause_condition_vals,
958 "Unknown (0x%X)"));
959 break;
961 case Q933_CAUSE_CALL_REJECTED:
962 rejection_reason = octet & 0x7C;
963 proto_tree_add_text(tree, tvb, offset, 1,
964 "Rejection reason: %s",
965 val_to_str(octet & 0x7C, q933_rejection_reason_vals,
966 "Unknown (0x%X)"));
967 proto_tree_add_text(tree, tvb, offset, 1,
968 "Condition: %s",
969 val_to_str(octet & 0x03, q933_cause_condition_vals,
970 "Unknown (0x%X)"));
971 offset += 1;
972 len -= 1;
974 if (len == 0)
975 return;
976 switch (rejection_reason) {
978 case Q933_REJ_USER_SPECIFIC:
979 proto_tree_add_text(tree, tvb, offset, len,
980 "User specific diagnostic: %s",
981 tvb_bytes_to_str(tvb, offset, len));
982 break;
984 case Q933_REJ_IE_MISSING:
985 proto_tree_add_text(tree, tvb, offset, 1,
986 "Missing information element: %s",
987 val_to_str(tvb_get_guint8(tvb, offset), q933_info_element_vals0,
988 "Unknown (0x%02X)"));
989 break;
991 case Q933_REJ_IE_INSUFFICIENT:
992 proto_tree_add_text(tree, tvb, offset, 1,
993 "Insufficient information element: %s",
994 val_to_str(tvb_get_guint8(tvb, offset), q933_info_element_vals0,
995 "Unknown (0x%02X)"));
996 break;
998 default:
999 proto_tree_add_text(tree, tvb, offset, len,
1000 "Diagnostic: %s",
1001 tvb_bytes_to_str(tvb, offset, len));
1002 break;
1004 break;
1006 case Q933_CAUSE_ACCESS_INFO_DISC:
1007 case Q933_CAUSE_INCOMPATIBLE_DEST:
1008 case Q933_CAUSE_MAND_IE_MISSING:
1009 case Q933_CAUSE_IE_NONEX_OR_UNIMPL:
1010 case Q933_CAUSE_INVALID_IE_CONTENTS:
1011 do {
1012 proto_tree_add_text(tree, tvb, offset, 1,
1013 "Information element: %s",
1014 val_to_str(tvb_get_guint8(tvb, offset), q933_info_element_vals0,
1015 "Unknown (0x%02X)"));
1016 offset += 1;
1017 len -= 1;
1018 } while (len != 0);
1019 break;
1021 case Q933_CAUSE_MT_NONEX_OR_UNIMPL:
1022 case Q933_CAUSE_MSG_INCOMPAT_W_CS:
1023 proto_tree_add_text(tree, tvb, offset, 1,
1024 "Message type: %s",
1025 val_to_str(tvb_get_guint8(tvb, offset), q933_message_type_vals,
1026 "Unknown (0x%02X)"));
1027 break;
1029 case Q933_CAUSE_REC_TIMER_EXP:
1030 if (len < 3)
1031 return;
1032 proto_tree_add_text(tree, tvb, offset, 3,
1033 "Timer: %.3s", tvb_get_string(wmem_packet_scope(), tvb, offset, 3));
1034 break;
1036 default:
1037 proto_tree_add_text(tree, tvb, offset, len,
1038 "Diagnostics: %s",
1039 tvb_bytes_to_str(tvb, offset, len));
1044 * Dissect a Call state information element.
1046 static const value_string q933_call_state_vals[] = {
1047 { 0x00, "Null" },
1048 { 0x01, "Call initiated" },
1049 { 0x02, "Overlap sending" },
1050 { 0x03, "Outgoing call proceeding" },
1051 { 0x04, "Call delivered" },
1052 { 0x06, "Call present" },
1053 { 0x07, "Call received" },
1054 { 0x08, "Connect request" },
1055 { 0x09, "Incoming call proceeding" },
1056 { 0x0A, "Active" },
1057 { 0x0B, "Disconnect request" },
1058 { 0x0C, "Disconnect indication" },
1059 { 0x0F, "Suspend request" },
1060 { 0x12, "Resume request" },
1061 { 0x13, "Release request" },
1062 { 0x16, "Call abort"},
1063 { 0x19, "Overlap receiving" },
1064 { 0x3D, "Restart request" },
1065 { 0x3E, "Restart" },
1066 { 0, NULL }
1069 static void
1070 dissect_q933_call_state_ie(tvbuff_t *tvb, int offset, int len,
1071 proto_tree *tree)
1073 guint8 octet;
1074 guint8 coding_standard;
1076 if (len == 0)
1077 return;
1078 octet = tvb_get_guint8(tvb, offset);
1079 coding_standard = octet & 0x60;
1080 proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
1081 if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
1083 * We don't know how the call state is encoded,
1084 * so just dump it as data and be done with it.
1086 proto_tree_add_text(tree, tvb, offset,
1087 len, "Data: %s",
1088 tvb_bytes_to_str(tvb, offset, len));
1089 return;
1091 proto_tree_add_text(tree, tvb, offset, 1,
1092 "Call state: %s",
1093 val_to_str(octet & 0x3F, q933_call_state_vals,
1094 "Unknown (0x%02X)"));
1098 * Dissect a Report Type information element.
1100 #define Q933_IE_REPORT_TYPE_FULL_STATUS 0x00
1101 #define Q933_IE_REPORT_TYPE_LINK_VERIFY 0x01
1102 #define Q933_IE_REPORT_TYPE_ASYNC_PVC_STATUS 0x02
1104 static const value_string q933_report_type_vals[] = {
1105 { Q933_IE_REPORT_TYPE_FULL_STATUS, "Full Status" },
1106 { Q933_IE_REPORT_TYPE_LINK_VERIFY, "Link verify" },
1107 { Q933_IE_REPORT_TYPE_ASYNC_PVC_STATUS, "Async PVC Status" },
1108 { 0, NULL }
1111 static void
1112 dissect_q933_report_type_ie(tvbuff_t *tvb, int offset, int len,
1113 proto_tree *tree)
1115 guint8 report_type;
1117 if (len == 0)
1118 return;
1120 report_type = tvb_get_guint8(tvb, offset);
1121 proto_tree_add_uint(tree, hf_q933_report_type, tvb, offset, 1, report_type);
1125 * Dissect a Link Integrity Verification information element.
1127 static void
1128 dissect_q933_link_integrity_verf_ie(tvbuff_t *tvb, int offset, int len,
1129 proto_tree *tree)
1131 guint8 txseq,rxseq;
1133 if (len < 2)
1134 return;
1136 txseq = tvb_get_guint8(tvb, offset);
1137 rxseq = tvb_get_guint8(tvb, offset+1);
1139 proto_tree_add_uint(tree, hf_q933_link_verf_txseq, tvb, offset, 1, txseq);
1140 proto_tree_add_uint(tree, hf_q933_link_verf_rxseq, tvb, offset+1, 1, rxseq);
1145 * Dissect a PVC status information element.
1147 static const value_string q933_pvc_status_vals[] = {
1148 {0x00, "Inactive"},
1149 {0x02, "Active"},
1150 {0x08, "New"},
1151 {0x0a, "New, Active"},
1152 {0, NULL}
1155 static void
1156 dissect_q933_pvc_status_ie(tvbuff_t *tvb, int offset, int len,
1157 proto_tree *tree)
1159 guint32 dlci;
1160 guint8 dlci_status,dlci_len=2;
1162 if (len < 3)
1163 return;
1165 dlci = ((tvb_get_guint8(tvb, offset) & 0x3F) << 4) |
1166 ((tvb_get_guint8(tvb, offset+1) & 0x78) >> 3);
1168 /* first determine the DLCI field length */
1169 if (len == 4) {
1170 dlci = (dlci << 6) | ((tvb_get_guint8(tvb, offset+2) & 0x7E) >> 1);
1171 dlci_len++;
1172 } else if (len == 5) {
1173 dlci = (dlci << 13) | (tvb_get_guint8(tvb, offset+3) & 0x7F) |
1174 ((tvb_get_guint8(tvb, offset+4) & 0x7E) >> 1);
1175 dlci_len+=2;
1177 dlci_status=tvb_get_guint8(tvb, offset+dlci_len)&0x0a;
1179 proto_tree_add_text(tree, tvb, offset, dlci_len, "DLCI: %u", dlci);
1180 proto_tree_add_text(tree, tvb, offset+dlci_len, 1, "Status: %s",
1181 val_to_str_const(dlci_status, q933_pvc_status_vals, "Unknown"));
1185 * Dissect a Channel identification information element.
1187 #define Q933_INTERFACE_IDENTIFIED 0x40
1188 #define Q933_NOT_BASIC_CHANNEL 0x20
1190 static const value_string q933_basic_channel_selection_vals[] = {
1191 { 0x00, "No channel" },
1192 { 0x01, "B1 channel" },
1193 { 0x02, "B2 channel" },
1194 { 0x03, "Any channel" },
1195 { 0, NULL }
1198 static const value_string q933_not_basic_channel_selection_vals[] = {
1199 { 0x00, "No channel" },
1200 { 0x01, "Channel indicated in following octets" },
1201 { 0x03, "Any channel" },
1202 { 0, NULL }
1205 #define Q933_IS_SLOT_MAP 0x10
1207 static const value_string q933_element_type_vals[] = {
1208 { 0x03, "B-channel units" },
1209 { 0x06, "H0-channel units" },
1210 { 0x08, "H11-channel units" },
1211 { 0x09, "H12-channel units" },
1212 { 0, NULL }
1215 static void
1216 dissect_q933_channel_identification_ie(tvbuff_t *tvb, int offset, int len,
1217 proto_tree *tree)
1219 guint8 octet;
1220 int identifier_offset;
1221 int identifier_len;
1222 guint8 coding_standard;
1224 if (len == 0)
1225 return;
1226 octet = tvb_get_guint8(tvb, offset);
1227 proto_tree_add_text(tree, tvb, offset, 1,
1228 "Interface %s identified",
1229 (octet & Q933_INTERFACE_IDENTIFIED) ? "explicitly" : "implicitly");
1230 proto_tree_add_text(tree, tvb, offset, 1,
1231 "%s interface",
1232 (octet & Q933_NOT_BASIC_CHANNEL) ? "Not basic" : "Basic");
1233 proto_tree_add_text(tree, tvb, offset, 1,
1234 "Indicated channel is %s",
1235 (octet & 0x08) ? "required" : "preferred");
1236 proto_tree_add_text(tree, tvb, offset, 1,
1237 "Indicated channel is %sthe D-channel",
1238 (octet & 0x04) ? "" : "not ");
1239 if (octet & Q933_NOT_BASIC_CHANNEL) {
1240 proto_tree_add_text(tree, tvb, offset, 1,
1241 "Channel selection: %s",
1242 val_to_str(octet & 0x03, q933_not_basic_channel_selection_vals,
1243 "Unknown (0x%X)"));
1244 } else {
1245 proto_tree_add_text(tree, tvb, offset, 1,
1246 "Channel selection: %s",
1247 val_to_str(octet & 0x03, q933_basic_channel_selection_vals,
1248 "Unknown (0x%X)"));
1250 offset += 1;
1251 len -= 1;
1253 if (octet & Q933_INTERFACE_IDENTIFIED) {
1254 identifier_offset = offset;
1255 identifier_len = 0;
1256 do {
1257 if (len == 0)
1258 break;
1259 octet = tvb_get_guint8(tvb, offset);
1260 offset += 1;
1261 len -= 1;
1262 identifier_len++;
1263 } while (!(octet & Q933_IE_VL_EXTENSION));
1266 * XXX - do we want to strip off the 8th bit on the
1267 * last octet of the interface identifier?
1269 if (identifier_len != 0) {
1270 proto_tree_add_text(tree, tvb, identifier_offset,
1271 identifier_len, "Interface identifier: %s",
1272 tvb_bytes_to_str(tvb, identifier_offset, identifier_len));
1276 if (octet & Q933_NOT_BASIC_CHANNEL) {
1277 if (len == 0)
1278 return;
1279 octet = tvb_get_guint8(tvb, offset);
1280 coding_standard = octet & 0x60;
1281 proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
1282 if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
1284 * We don't know how the channel identifier is
1285 * encoded, so just dump it as data and be done
1286 * with it.
1288 proto_tree_add_text(tree, tvb, offset,
1289 len, "Data: %s",
1290 tvb_bytes_to_str(tvb, offset, len));
1291 return;
1293 proto_tree_add_text(tree, tvb, offset, 1,
1294 "Channel is indicated by %s",
1295 (octet & Q933_IS_SLOT_MAP) ? "slot map" : "number");
1296 proto_tree_add_text(tree, tvb, offset, 1,
1297 "%s type: %s",
1298 (octet & Q933_IS_SLOT_MAP) ? "Map element" : "Channel",
1299 val_to_str(octet & 0x0F, q933_element_type_vals,
1300 "Unknown (0x%02X)"));
1303 * XXX - dump the channel number or slot map.
1309 * Dissect a Progress indicator information element.
1311 static const value_string q933_progress_description_vals[] = {
1312 { 0x01, "Call is not end-to-end ISDN - progress information available in-band" },
1313 { 0x02, "Destination address is non-ISDN" },
1314 { 0x03, "Origination address is non-ISDN" },
1315 { 0x04, "Call has returned to the ISDN" },
1316 { 0x05, "Interworking has occurred and has resulted in a telecommunications service change" },
1317 { 0x08, "In-band information or an appropriate pattern is now available" },
1318 { 0, NULL }
1321 static void
1322 dissect_q933_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
1323 proto_tree *tree)
1325 guint8 octet;
1326 guint8 coding_standard;
1328 if (len == 0)
1329 return;
1330 octet = tvb_get_guint8(tvb, offset);
1331 coding_standard = octet & 0x60;
1332 proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
1333 if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
1335 * We don't know how the progress indicator is encoded,
1336 * so just dump it as data and be done with it.
1338 proto_tree_add_text(tree, tvb, offset,
1339 len, "Data: %s",
1340 tvb_bytes_to_str(tvb, offset, len));
1341 return;
1343 proto_tree_add_text(tree, tvb, offset, 1,
1344 "Location: %s",
1345 val_to_str(octet & 0x0F, q933_cause_location_vals,
1346 "Unknown (0x%X)"));
1347 offset += 1;
1348 len -= 1;
1350 if (len == 0)
1351 return;
1352 octet = tvb_get_guint8(tvb, offset);
1353 proto_tree_add_text(tree, tvb, offset, 1,
1354 "Progress description: %s",
1355 val_to_str(octet & 0x7F, q933_progress_description_vals,
1356 "Unknown (0x%02X)"));
1360 * Dissect a Network-specific facilities or Transit network selection
1361 * information element.
1363 static const value_string q933_netid_type_vals[] = {
1364 { 0x00, "User specified" },
1365 { 0x20, "National network identification" },
1366 { 0x30, "International network identification" },
1367 { 0, NULL }
1370 static const value_string q933_netid_plan_vals[] = {
1371 { 0x00, "Unknown" },
1372 { 0x01, "Carrier Identification Code" },
1373 { 0x03, "X.121 data network identification code" },
1374 { 0, NULL }
1377 static void
1378 dissect_q933_ns_facilities_ie(tvbuff_t *tvb, int offset, int len,
1379 proto_tree *tree)
1381 guint8 octet;
1382 int netid_len;
1384 if (len == 0)
1385 return;
1386 octet = tvb_get_guint8(tvb, offset);
1387 netid_len = octet & 0x7F;
1388 proto_tree_add_text(tree, tvb, offset, 1,
1389 "Network identification length: %u",
1390 netid_len);
1391 offset += 1;
1392 len -= 1;
1393 if (netid_len != 0) {
1394 if (len == 0)
1395 return;
1396 octet = tvb_get_guint8(tvb, offset);
1397 proto_tree_add_text(tree, tvb, offset, 1,
1398 "Type of network identification: %s",
1399 val_to_str(octet & 0x70, q933_netid_type_vals,
1400 "Unknown (0x%02X)"));
1401 proto_tree_add_text(tree, tvb, offset, 1,
1402 "Network identification plan: %s",
1403 val_to_str(octet & 0x0F, q933_netid_plan_vals,
1404 "Unknown (0x%02X)"));
1405 offset += 1;
1406 len -= 1;
1407 netid_len--;
1409 if (len == 0)
1410 return;
1411 if (netid_len > len)
1412 netid_len = len;
1413 if (netid_len != 0) {
1414 proto_tree_add_text(tree, tvb, offset, netid_len,
1415 "Network identification: %s",
1416 tvb_format_text(tvb, offset, netid_len));
1417 offset += netid_len;
1418 len -= netid_len;
1423 * Whatever is left is the network-specific facility
1424 * specification.
1426 if (len == 0)
1427 return;
1428 proto_tree_add_text(tree, tvb, offset,
1429 len, "Network-specific facility specification: %s",
1430 tvb_bytes_to_str(tvb, offset, len));
1433 static int
1434 dissect_q933_guint16_value(tvbuff_t *tvb, int offset, int len,
1435 proto_tree *tree, const char *label)
1437 guint8 octet;
1438 guint16 value;
1439 int value_len;
1441 value_len = 0;
1443 octet = tvb_get_guint8(tvb, offset);
1444 if (octet & Q933_IE_VL_EXTENSION) {
1446 * Only one octet long - error.
1448 goto bad_length;
1450 value = (octet & 0x3) << 14;
1451 offset += 1;
1452 len -= 1;
1453 value_len++;
1455 if (len == 0) {
1457 * We've reached the end of the information element - error.
1459 goto past_end;
1461 octet = tvb_get_guint8(tvb, offset);
1462 if (octet & Q933_IE_VL_EXTENSION) {
1464 * Only two octets long - error.
1466 goto bad_length;
1468 value |= (octet & 0x7F) << 7;
1469 offset += 1;
1470 len -= 1;
1471 value_len++;
1473 if (len == 0) {
1475 * We've reached the end of the information element - error.
1477 goto past_end;
1479 octet = tvb_get_guint8(tvb, offset);
1480 if (!(octet & Q933_IE_VL_EXTENSION)) {
1482 * More than three octets long - error.
1484 goto bad_length;
1486 value |= (octet & 0x7F);
1487 offset += 1;
1488 /*len -= 1;*/
1489 value_len++;
1491 proto_tree_add_text(tree, tvb, offset, value_len, "%s: %u ms", label,
1492 value);
1493 return value_len;
1495 past_end:
1496 proto_tree_add_text(tree, tvb, offset, len,
1497 "%s goes past end of information element", label);
1498 return -1;
1500 bad_length:
1501 proto_tree_add_text(tree, tvb, offset, len, "%s isn't 3 octets long",
1502 label);
1503 return -1;
1507 * Dissect an End-to-end transit delay information element.
1509 static void
1510 dissect_q933_e2e_transit_delay_ie(tvbuff_t *tvb, int offset, int len,
1511 proto_tree *tree)
1513 int value_len;
1515 if (len == 0)
1516 return;
1517 value_len = dissect_q933_guint16_value(tvb, offset, len, tree,
1518 "Cumulative transit delay");
1519 if (value_len < 0)
1520 return; /* error */
1521 offset += value_len;
1522 len -= value_len;
1524 if (len == 0)
1525 return;
1526 value_len = dissect_q933_guint16_value(tvb, offset, len, tree,
1527 "Requested end-to-end transit delay");
1528 if (value_len < 0)
1529 return; /* error */
1530 offset += value_len;
1531 len -= value_len;
1533 if (len == 0)
1534 return;
1535 /*value_len = */dissect_q933_guint16_value(tvb, offset, len, tree,
1536 "Maximum end-to-end transit delay");
1540 * Dissect a Transit delay selection and indication information element.
1542 static void
1543 dissect_q933_td_selection_and_int_ie(tvbuff_t *tvb, int offset, int len,
1544 proto_tree *tree)
1546 if (len == 0)
1547 return;
1548 dissect_q933_guint16_value(tvb, offset, len, tree,
1549 "Transit delay");
1552 static void
1553 dissect_q933_pl_binary_parameters_ie(tvbuff_t *tvb, int offset, int len,
1554 proto_tree *tree)
1556 guint8 octet;
1558 if (len == 0)
1559 return;
1560 octet = tvb_get_guint8(tvb, offset);
1561 proto_tree_add_text(tree, tvb, offset, 1,
1562 "%s",
1563 (octet & 0x04) ? "No request/request denied" :
1564 "Request indicated/request accepted");
1565 proto_tree_add_text(tree, tvb, offset, 1,
1566 "%s confirmation",
1567 (octet & 0x02) ? "Link-by-link" : "End-to-end");
1571 * Dissect a Reverse charging indication information element.
1573 static const value_string q933_reverse_charging_indication_vals[] = {
1574 { 0x01, "Reverse charging requested" },
1575 { 0, NULL }
1578 static void
1579 dissect_q933_reverse_charge_ind_ie(tvbuff_t *tvb, int offset, int len,
1580 proto_tree *tree)
1582 if (len == 0)
1583 return;
1584 proto_tree_add_text(tree, tvb, offset, 1,
1585 "Reverse charging indication: %s",
1586 val_to_str(tvb_get_guint8(tvb, offset) & 0x07,
1587 q933_reverse_charging_indication_vals, "Unknown (0x%02X)"));
1591 * Dissect a (phone) number information element.
1593 static const value_string q933_number_type_vals[] = {
1594 { 0x0, "Unknown" },
1595 { 0x1, "International number" },
1596 { 0x2, "National number" },
1597 { 0x3, "Network specific number" },
1598 { 0x4, "Subscriber number" },
1599 { 0x6, "Abbreviated number" },
1600 { 0, NULL }
1603 static const value_string q933_numbering_plan_vals[] = {
1604 { 0x00, "Unknown" },
1605 { 0x01, "E.164 ISDN/telephony numbering" },
1606 { 0x03, "X.121 data numbering" },
1607 { 0x04, "F.69 Telex numbering" },
1608 { 0x08, "National standard numbering" },
1609 { 0x09, "Private numbering" },
1610 { 0, NULL }
1613 static const value_string q933_presentation_indicator_vals[] = {
1614 { 0x00, "Presentation allowed" },
1615 { 0x01, "Presentation restricted" },
1616 { 0x02, "Number not available due to interworking" },
1617 { 0, NULL }
1620 static const value_string q933_screening_indicator_vals[] = {
1621 { 0x00, "User-provided, not screened" },
1622 { 0x01, "User-provided, verified and passed" },
1623 { 0x02, "User-provided, verified and failed" },
1624 { 0x03, "Network-provided" },
1625 { 0, NULL }
1628 static const value_string q933_redirection_reason_vals[] = {
1629 { 0x00, "Unknown" },
1630 { 0x01, "Call forwarding busy or called DTE busy" },
1631 { 0x02, "Call forwarding no reply" },
1632 { 0x04, "Call deflection" },
1633 { 0x09, "Called DTE out of order" },
1634 { 0x0A, "Call forwarding by the called DTE" },
1635 { 0x0F, "Call forwarding unconditional or systematic call redirection" },
1636 { 0, NULL }
1639 static void
1640 dissect_q933_number_ie(tvbuff_t *tvb, int offset, int len,
1641 proto_tree *tree, int hfindex)
1643 guint8 octet;
1645 if (len == 0)
1646 return;
1647 octet = tvb_get_guint8(tvb, offset);
1648 proto_tree_add_uint(tree, hf_q933_numbering_plan, tvb, offset, 1, octet);
1649 proto_tree_add_uint(tree, hf_q933_number_type, tvb, offset, 1, octet);
1650 proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
1652 offset += 1;
1653 len -= 1;
1655 if (!(octet & Q933_IE_VL_EXTENSION)) {
1656 if (len == 0)
1657 return;
1658 octet = tvb_get_guint8(tvb, offset);
1659 proto_tree_add_uint(tree, hf_q933_screening_ind, tvb, offset, 1, octet);
1660 proto_tree_add_uint(tree, hf_q933_presentation_ind, tvb, offset, 1, octet);
1661 proto_tree_add_boolean(tree, hf_q933_extension_ind, tvb, offset, 1, octet);
1662 offset += 1;
1663 len -= 1;
1667 * XXX - only in a Redirecting number information element.
1669 if (!(octet & Q933_IE_VL_EXTENSION)) {
1670 if (len == 0)
1671 return;
1672 octet = tvb_get_guint8(tvb, offset);
1673 proto_tree_add_text(tree, tvb, offset, 1,
1674 "Reason for redirection: %s",
1675 val_to_str(octet & 0x0F, q933_redirection_reason_vals,
1676 "Unknown (0x%X)"));
1677 offset += 1;
1678 len -= 1;
1681 if (len == 0)
1682 return;
1683 proto_tree_add_item(tree, hfindex, tvb, offset, len, ENC_ASCII|ENC_NA);
1687 * Dissect a party subaddress information element.
1689 static const value_string q933_subaddress_type_vals[] = {
1690 { 0x00, "X.213/ISO 8348 Add.2 NSAP" },
1691 { 0x20, "User-specified" },
1692 { 0, NULL }
1695 static const value_string q933_odd_even_indicator_vals[] = {
1696 { 0x00, "Even number of address signals" },
1697 { 0x10, "Odd number of address signals" },
1698 { 0, NULL }
1701 static void
1702 dissect_q933_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
1703 proto_tree *tree)
1705 guint8 octet;
1707 if (len == 0)
1708 return;
1709 octet = tvb_get_guint8(tvb, offset);
1710 proto_tree_add_text(tree, tvb, offset, 1,
1711 "Type of subaddress: %s",
1712 val_to_str(octet & 0x70, q933_subaddress_type_vals,
1713 "Unknown (0x%02X)"));
1714 proto_tree_add_text(tree, tvb, offset, 1,
1715 "Odd/even indicator: %s",
1716 val_to_str(octet & 0x10, q933_odd_even_indicator_vals,
1717 "Unknown (0x%02X)"));
1718 offset += 1;
1719 len -= 1;
1721 if (len == 0)
1722 return;
1723 proto_tree_add_text(tree, tvb, offset, len, "Subaddress: %s",
1724 tvb_bytes_to_str(tvb, offset, len));
1728 * Dissect a High-layer compatibility information element.
1730 #define Q933_AUDIOVISUAL 0x60
1731 static const value_string q933_high_layer_characteristics_vals[] = {
1732 { 0x01, "Telephony" },
1733 { 0x04, "F.182 Facsimile Group 2/3" },
1734 { 0x21, "F.184 Facsimile Group 4 Class I" },
1735 { 0x24, "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
1736 { 0x28, "F.220 Teletex, basic and processable mode" },
1737 { 0x31, "F.200 Teletex, basic mode" },
1738 { 0x32, "F.300 and T.102 syntax-based Videotex" },
1739 { 0x33, "F.300 and T.101 international Videotex interworking" },
1740 { 0x35, "F.60 Telex" },
1741 { 0x38, "X.400 Message Handling Systems" },
1742 { 0x41, "X.200 OSI application" },
1743 { 0x42, "FTAM application" },
1744 { 0x5E, "Reserved for maintenance" },
1745 { 0x5F, "Reserved for management" },
1746 { Q933_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
1747 { 0x61, "F.702 and F.731 Profile 1b videoconferencing" },
1748 { 0x62, "F.702 and F.731 audiographic conferencing" },
1749 { 0, NULL }
1752 static const value_string q933_audiovisual_characteristics_vals[] = {
1753 { 0x01, "Capability set of initial channel of H.221" },
1754 { 0x02, "Capability set of subsequent channel of H.221" },
1755 { 0x21, "Capability set of initial channel of an active 3.1kHz audio or speech call" },
1756 { 0x00, NULL }
1759 static void
1760 dissect_q933_high_layer_compat_ie(tvbuff_t *tvb, int offset, int len,
1761 proto_tree *tree)
1763 guint8 octet;
1764 guint8 coding_standard;
1765 guint8 characteristics;
1767 if (len == 0)
1768 return;
1769 octet = tvb_get_guint8(tvb, offset);
1770 coding_standard = octet & 0x60;
1771 proto_tree_add_uint(tree, hf_q933_coding_standard, tvb, offset, 1, octet);
1772 offset += 1;
1773 len -= 1;
1774 if (coding_standard != Q933_ITU_STANDARDIZED_CODING) {
1776 * We don't know how the call state is encoded,
1777 * so just dump it as data and be done with it.
1779 proto_tree_add_text(tree, tvb, offset,
1780 len, "Data: %s",
1781 tvb_bytes_to_str(tvb, offset, len));
1782 return;
1785 if (len == 0)
1786 return;
1787 octet = tvb_get_guint8(tvb, offset);
1788 characteristics = octet & 0x7F;
1789 proto_tree_add_text(tree, tvb, offset, 1,
1790 "High layer characteristics identification: %s",
1791 val_to_str(characteristics, q933_high_layer_characteristics_vals,
1792 "Unknown (0x%02X)"));
1793 offset += 1;
1794 len -= 1;
1796 if (!(octet & Q933_IE_VL_EXTENSION)) {
1797 if (len == 0)
1798 return;
1799 octet = tvb_get_guint8(tvb, offset);
1800 if (characteristics == Q933_AUDIOVISUAL) {
1801 proto_tree_add_text(tree, tvb, offset, 1,
1802 "Extended audiovisual characteristics identification: %s",
1803 val_to_str(octet & 0x7F,
1804 q933_audiovisual_characteristics_vals,
1805 "Unknown (0x%02X)"));
1806 } else {
1807 proto_tree_add_text(tree, tvb, offset, 1,
1808 "Extended high layer characteristics identification: %s",
1809 val_to_str(octet & 0x7F,
1810 q933_high_layer_characteristics_vals,
1811 "Unknown (0x%02X)"));
1818 * Dissect a User-user information element.
1820 #define Q933_PROTOCOL_DISCRIMINATOR_IA5 0x04
1821 #define Q933_PROTOCOL_DISCRIMINATOR_ASN1 0x05
1823 static const value_string q933_protocol_discriminator_vals[] = {
1824 { 0x00, "User-specific protocol" },
1825 { 0x01, "OSI high layer protocols" },
1826 { 0x02, "X.244" },
1827 { Q933_PROTOCOL_DISCRIMINATOR_IA5, "IA5 characters" },
1828 { Q933_PROTOCOL_DISCRIMINATOR_ASN1, "X.208 and X.209 coded user information" },
1829 { 0x07, "V.120 rate adaption" },
1830 { 0x08, "Q.933/I.451 user-network call control messages" },
1831 { 0, NULL }
1834 static void
1835 dissect_q933_user_user_ie(tvbuff_t *tvb, int offset, int len,
1836 proto_tree *tree)
1838 guint8 octet;
1840 if (len == 0)
1841 return;
1842 octet = tvb_get_guint8(tvb, offset);
1843 proto_tree_add_text(tree, tvb, offset, 1,
1844 "Protocol discriminator: %s",
1845 val_to_str(octet, q933_protocol_discriminator_vals,
1846 "Unknown (0x%02x)"));
1847 offset += 1;
1848 len -= 1;
1850 if (len == 0)
1851 return;
1852 switch (octet) {
1854 case Q933_PROTOCOL_DISCRIMINATOR_IA5:
1855 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
1856 tvb_format_text(tvb, offset, len));
1857 break;
1859 default:
1860 proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
1861 tvb_bytes_to_str(tvb, offset, len));
1862 break;
1867 * Dissect information elements consisting of ASCII^H^H^H^H^HIA5 text.
1869 static void
1870 dissect_q933_ia5_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
1871 const char *label)
1873 if (len != 0) {
1874 proto_tree_add_text(tree, tvb, offset, len, "%s: %s", label,
1875 tvb_format_text(tvb, offset, len));
1879 static const value_string q933_codeset_vals[] = {
1880 { 0x00, "Q.933 information elements" },
1881 { 0x04, "Information elements for ISO/IEC use" },
1882 { 0x05, "Information elements for national use" },
1883 { 0x06, "Information elements specific to the local network" },
1884 { 0x07, "User-specific information elements" },
1885 { 0x00, NULL },
1888 static void
1889 dissect_q933(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1891 int offset = 0;
1892 proto_tree *q933_tree = NULL;
1893 proto_item *ti;
1894 proto_tree *ie_tree = NULL;
1895 guint8 call_ref_len;
1896 guint8 call_ref[15];
1897 guint8 message_type;
1898 guint8 info_element;
1899 guint16 info_element_len;
1900 int codeset, locked_codeset;
1901 gboolean non_locking_shift;
1903 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Q.933");
1905 if (tree) {
1906 ti = proto_tree_add_item(tree, proto_q933, tvb, offset, -1,
1907 ENC_NA);
1908 q933_tree = proto_item_add_subtree(ti, ett_q933);
1910 dissect_q933_protocol_discriminator(tvb, offset, q933_tree);
1912 offset += 1;
1913 call_ref_len = tvb_get_guint8(tvb, offset) & 0xF; /* XXX - do as a bit field? */
1914 if (q933_tree != NULL)
1915 proto_tree_add_uint(q933_tree, hf_q933_call_ref_len, tvb, offset, 1, call_ref_len);
1916 offset += 1;
1917 if (call_ref_len != 0) {
1918 tvb_memcpy(tvb, call_ref, offset, call_ref_len);
1919 if (q933_tree != NULL) {
1920 proto_tree_add_boolean(q933_tree, hf_q933_call_ref_flag,
1921 tvb, offset, 1, (call_ref[0] & 0x80) != 0);
1922 call_ref[0] &= 0x7F;
1923 proto_tree_add_bytes(q933_tree, hf_q933_call_ref,
1924 tvb, offset, call_ref_len, call_ref);
1926 offset += call_ref_len;
1928 message_type = tvb_get_guint8(tvb, offset);
1929 col_add_str(pinfo->cinfo, COL_INFO,
1930 val_to_str(message_type, q933_message_type_vals,
1931 "Unknown message type (0x%02X)"));
1933 proto_tree_add_uint(q933_tree, hf_q933_message_type, tvb, offset, 1, message_type);
1934 offset += 1;
1937 * And now for the information elements....
1939 codeset = locked_codeset = 0; /* start out in codeset 0 */
1940 while (tvb_reported_length_remaining(tvb, offset) > 0) {
1941 info_element = tvb_get_guint8(tvb, offset);
1943 /* Check for the codeset shift */
1944 if ((info_element & Q933_IE_SO_MASK) &&
1945 ((info_element & Q933_IE_SO_IDENTIFIER_MASK) == Q933_IE_SHIFT)) {
1946 non_locking_shift = info_element & Q933_IE_SHIFT_NON_LOCKING;
1947 codeset = info_element & Q933_IE_SHIFT_CODESET;
1948 if (!non_locking_shift)
1949 locked_codeset = codeset;
1950 if (q933_tree != NULL) {
1951 proto_tree_add_text(q933_tree, tvb, offset, 1,
1952 "%s shift to codeset %u: %s",
1953 (non_locking_shift ? "Non-locking" : "Locking"),
1954 codeset,
1955 val_to_str(codeset, q933_codeset_vals,
1956 "Unknown (0x%02X)"));
1958 offset += 1;
1959 continue;
1963 * Check for the single-octet IEs.
1965 if (info_element & Q933_IE_SO_MASK) {
1966 switch ((codeset << 8) | (info_element & Q933_IE_SO_IDENTIFIER_MASK)) {
1968 case CS0 | Q933_IE_REPEAT_INDICATOR:
1969 if (q933_tree != NULL) {
1970 proto_tree_add_text(q933_tree, tvb, offset, 1,
1971 "Repeat indicator: %s",
1972 val_to_str(info_element & Q933_IE_SO_IE_MASK,
1973 q933_repeat_indication_vals,
1974 "Unknown (0x%X)"));
1976 break;
1978 default:
1979 if (q933_tree != NULL) {
1980 proto_tree_add_text(q933_tree, tvb, offset, 1,
1981 "Unknown information element (0x%02X)",
1982 info_element);
1984 break;
1986 offset += 1;
1987 codeset = locked_codeset;
1988 continue;
1992 * Variable-length IE.
1994 info_element_len = tvb_get_guint8(tvb, offset + 1);
1995 if (q933_tree != NULL) {
1996 ti = proto_tree_add_text(q933_tree, tvb, offset,
1997 1+1+info_element_len, "%s",
1998 val_to_str(info_element, q933_info_element_vals[codeset],
1999 "Unknown information element (0x%02X)"));
2000 ie_tree = proto_item_add_subtree(ti, ett_q933_ie);
2001 proto_tree_add_text(ie_tree, tvb, offset, 1,
2002 "Information element: %s",
2003 val_to_str(info_element, q933_info_element_vals[codeset],
2004 "Unknown (0x%02X)"));
2005 proto_tree_add_text(ie_tree, tvb, offset + 1, 1,
2006 "Length: %u", info_element_len);
2008 switch ((codeset << 8) | info_element) {
2010 case CS0 | Q933_IE_SEGMENTED_MESSAGE:
2011 dissect_q933_segmented_message_ie(tvb,
2012 offset + 2, info_element_len,
2013 ie_tree);
2014 break;
2016 case CS0 | Q933_IE_BEARER_CAPABILITY:
2017 case CS0 | Q933_IE_LOW_LAYER_COMPAT:
2018 dissect_q933_bearer_capability_ie(tvb,
2019 offset + 2, info_element_len,
2020 ie_tree);
2021 break;
2023 case CS0 | Q933_IE_CAUSE:
2024 dissect_q933_cause_ie(tvb,
2025 offset + 2, info_element_len,
2026 ie_tree,
2027 hf_q933_cause_value);
2028 break;
2030 case CS0 | Q933_IE_CALL_STATE:
2031 dissect_q933_call_state_ie(tvb,
2032 offset + 2, info_element_len,
2033 ie_tree);
2034 break;
2036 case CS0 | Q933_IE_CHANNEL_IDENTIFICATION:
2037 dissect_q933_channel_identification_ie(
2038 tvb, offset + 2, info_element_len,
2039 ie_tree);
2040 break;
2042 case CS0 | Q933_IE_PROGRESS_INDICATOR:
2043 dissect_q933_progress_indicator_ie(tvb,
2044 offset + 2, info_element_len,
2045 ie_tree);
2046 break;
2048 case CS0 | Q933_IE_NETWORK_SPECIFIC_FACIL:
2049 case CS0 | Q933_IE_TRANSIT_NETWORK_SEL:
2050 dissect_q933_ns_facilities_ie(tvb,
2051 offset + 2, info_element_len,
2052 ie_tree);
2053 break;
2055 case CS0 | Q933_IE_DISPLAY:
2056 dissect_q933_ia5_ie(tvb, offset + 2,
2057 info_element_len, ie_tree,
2058 "Display information");
2059 break;
2061 case CS0 | Q933_IE_E2E_TRANSIT_DELAY:
2062 dissect_q933_e2e_transit_delay_ie(tvb,
2063 offset + 2, info_element_len,
2064 ie_tree);
2065 break;
2067 case CS0 | Q933_IE_TD_SELECTION_AND_INT:
2068 dissect_q933_td_selection_and_int_ie(
2069 tvb, offset + 2, info_element_len,
2070 ie_tree);
2071 break;
2073 case CS0 | Q933_IE_PL_BINARY_PARAMETERS:
2074 dissect_q933_pl_binary_parameters_ie(
2075 tvb, offset + 2, info_element_len,
2076 ie_tree);
2077 break;
2079 case CS0 | Q933_IE_REVERSE_CHARGE_IND:
2080 dissect_q933_reverse_charge_ind_ie(tvb,
2081 offset + 2, info_element_len,
2082 ie_tree);
2083 break;
2085 case CS0 | Q933_IE_CALLING_PARTY_NUMBER:
2086 dissect_q933_number_ie(tvb,
2087 offset + 2, info_element_len,
2088 ie_tree,
2089 hf_q933_calling_party_number);
2090 break;
2092 case CS0 | Q933_IE_CONNECTED_NUMBER:
2093 dissect_q933_number_ie(tvb,
2094 offset + 2, info_element_len,
2095 ie_tree,
2096 hf_q933_connected_number);
2097 break;
2099 case CS0 | Q933_IE_CALLED_PARTY_NUMBER:
2100 dissect_q933_number_ie(tvb,
2101 offset + 2, info_element_len,
2102 ie_tree,
2103 hf_q933_called_party_number);
2104 break;
2106 case CS0 | Q933_IE_CALLING_PARTY_SUBADDR:
2107 case CS0 | Q933_IE_CALLED_PARTY_SUBADDR:
2108 dissect_q933_party_subaddr_ie(tvb,
2109 offset + 2, info_element_len,
2110 ie_tree);
2111 break;
2113 case CS0 | Q933_IE_HIGH_LAYER_COMPAT:
2114 dissect_q933_high_layer_compat_ie(tvb,
2115 offset + 2, info_element_len,
2116 ie_tree);
2117 break;
2119 case CS0 | Q933_IE_USER_USER:
2120 dissect_q933_user_user_ie(tvb,
2121 offset + 2, info_element_len,
2122 ie_tree);
2123 break;
2126 case CS0 | Q933_IE_REPORT_TYPE:
2127 case CS5 | Q933_IE_REPORT_TYPE:
2128 case CS5 | Q933_IE_ANSI_REPORT_TYPE:
2129 dissect_q933_report_type_ie(tvb,
2130 offset + 2, info_element_len,
2131 ie_tree);
2132 break;
2134 case CS5 | Q933_IE_LINK_INTEGRITY_VERF:
2135 case CS5 | Q933_IE_ANSI_LINK_INTEGRITY_VERF:
2136 dissect_q933_link_integrity_verf_ie(tvb,
2137 offset + 2, info_element_len,
2138 ie_tree);
2139 break;
2141 case CS5 | Q933_IE_PVC_STATUS:
2142 case CS5 | Q933_IE_ANSI_PVC_STATUS:
2143 dissect_q933_pvc_status_ie(tvb,
2144 offset + 2, info_element_len,
2145 ie_tree);
2146 break;
2148 default:
2149 proto_tree_add_text(ie_tree, tvb,
2150 offset + 2, info_element_len,
2151 "Data: %s",
2152 tvb_bytes_to_str(tvb, offset + 2,
2153 info_element_len));
2154 break;
2157 offset += 1 + 1 + info_element_len;
2158 codeset = locked_codeset;
2162 void
2163 proto_register_q933(void)
2165 static hf_register_info hf[] = {
2166 { &hf_q933_discriminator,
2167 { "Protocol discriminator", "q933.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
2168 NULL, HFILL }},
2170 { &hf_q933_call_ref_flag,
2171 { "Call reference flag", "q933.call_ref_flag", FT_BOOLEAN, BASE_NONE, TFS(&tfs_call_ref_flag), 0x0,
2172 NULL, HFILL }},
2174 { &hf_q933_call_ref,
2175 { "Call reference value", "q933.call_ref", FT_BYTES, BASE_NONE, NULL, 0x0,
2176 NULL, HFILL }},
2179 { &hf_q933_coding_standard,
2180 { "Coding standard", "q933.coding_standard", FT_UINT8, BASE_HEX,
2181 VALS(q933_coding_standard_vals), 0x60,NULL, HFILL }},
2183 { &hf_q933_information_transfer_capability,
2184 { "Information transfer capability", "q933.information_transfer_capability", FT_UINT8, BASE_HEX,
2185 VALS(q933_information_transfer_capability_vals), 0x1f,NULL, HFILL }},
2187 { &hf_q933_transfer_mode,
2188 { "Transfer mode", "q933.transfer_mode", FT_UINT8, BASE_HEX,
2189 VALS(q933_transfer_mode_vals), 0x60,NULL, HFILL }},
2191 { &hf_q933_uil1,
2192 { "User information layer 1 protocol", "q933.uil1", FT_UINT8, BASE_HEX,
2193 VALS(q933_uil1_vals), 0x1f,NULL, HFILL }},
2195 { &hf_q933_call_ref_len,
2196 { "Call reference value length", "q933.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
2197 NULL, HFILL }},
2199 { &hf_q933_message_type,
2200 { "Message type", "q933.message_type", FT_UINT8, BASE_HEX, VALS(q933_message_type_vals), 0x0,
2201 NULL, HFILL }},
2203 { &hf_q933_cause_location,
2204 { "Cause location", "q933.cause_location", FT_UINT8, BASE_DEC, VALS(q933_cause_location_vals), 0x0f,
2205 NULL, HFILL }},
2207 { &hf_q933_cause_value,
2208 { "Cause value", "q933.cause_value", FT_UINT8, BASE_DEC, VALS(q933_cause_code_vals), 0x7f,
2209 NULL, HFILL }},
2211 { &hf_q933_number_type,
2212 { "Number type", "q933.number_type", FT_UINT8, BASE_HEX, VALS(q933_number_type_vals), 0x70,
2213 NULL, HFILL }},
2215 { &hf_q933_numbering_plan,
2216 { "numbering plan", "q933.numbering_plan", FT_UINT8, BASE_HEX, VALS(q933_numbering_plan_vals), 0x0f,
2217 NULL, HFILL }},
2219 { &hf_q933_screening_ind,
2220 { "Screening indicator", "q933.screening_ind", FT_UINT8, BASE_HEX, VALS(q933_screening_indicator_vals), 0x03,
2221 NULL, HFILL }},
2223 { &hf_q933_presentation_ind,
2224 { "Presentation indicator", "q933.presentation_ind", FT_UINT8, BASE_HEX, VALS(q933_presentation_indicator_vals), 0x60,
2225 NULL, HFILL }},
2227 { &hf_q933_extension_ind,
2228 { "Extension indicator", "q933.extension_ind",
2229 FT_BOOLEAN, 8, TFS(&q933_extension_ind_value), 0x80,
2230 NULL, HFILL }},
2232 { &hf_q933_calling_party_number,
2233 { "Calling party number digits", "q933.calling_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2234 NULL, HFILL }},
2236 { &hf_q933_called_party_number,
2237 { "Called party number digits", "q933.called_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2238 NULL, HFILL }},
2240 { &hf_q933_connected_number,
2241 { "Connected party number digits", "q933.connected_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2242 NULL, HFILL }},
2244 #if 0
2245 { &hf_q933_redirecting_number,
2246 { "Redirecting party number digits", "q933.redirecting_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
2247 NULL, HFILL }},
2248 #endif
2249 { &hf_q933_report_type,
2250 { "Report type", "q933.report_type", FT_UINT8, BASE_DEC, VALS(q933_report_type_vals), 0x0,
2251 NULL, HFILL }},
2252 { &hf_q933_link_verf_txseq,
2253 { "TX Sequence", "q933.link_verification.txseq", FT_UINT8, BASE_DEC, NULL, 0x0,
2254 NULL, HFILL }},
2255 { &hf_q933_link_verf_rxseq,
2256 { "RX Sequence", "q933.link_verification.rxseq", FT_UINT8, BASE_DEC, NULL, 0x0,
2257 NULL, HFILL }},
2260 static gint *ett[] = {
2261 &ett_q933,
2262 &ett_q933_ie,
2265 proto_q933 = proto_register_protocol("Q.933", "Q.933", "q933");
2266 proto_register_field_array (proto_q933, hf, array_length(hf));
2267 proto_register_subtree_array(ett, array_length(ett));
2269 register_dissector("q933", dissect_q933, proto_q933);
2272 void
2273 proto_reg_handoff_q933(void)
2275 dissector_handle_t q933_handle;
2277 q933_handle = find_dissector("q933");
2278 dissector_add_uint("fr.osinl", NLPID_Q_933, q933_handle);