Coverage Report

Created: 2026-01-02 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-q931.c
Line
Count
Source
1
/* packet-q931.c
2
 * Routines for Q.931 frame disassembly
3
 * Guy Harris <guy@alum.mit.edu>
4
 *
5
 * Modified by Andreas Sikkema for possible use with H.323
6
 *
7
 * Wireshark - Network traffic analyzer
8
 * By Gerald Combs <gerald@wireshark.org>
9
 * Copyright 1998
10
 *
11
 * SPDX-License-Identifier: GPL-2.0-or-later
12
 */
13
14
#include "config.h"
15
16
#include <epan/packet.h>
17
#include <epan/tfs.h>
18
#include <epan/unit_strings.h>
19
#include <epan/tap.h>
20
#include "packet-q931.h"
21
#include "packet-e164.h"
22
#include <epan/prefs.h>
23
#include <epan/expert.h>
24
#include <epan/reassemble.h>
25
#include "packet-lapd.h"
26
#include "packet-tpkt.h"
27
#include "packet-osi.h"
28
#include "packet-sctp.h"
29
30
31
/* Q.931 references:
32
 *
33
 * http://www.acacia-net.com/Clarinet/Protocol/q9313svn.htm
34
 * http://www.acacia-net.com/Clarinet/Protocol/q9311sc3.htm
35
 * http://www.acacia-net.com/Clarinet/Protocol/q9317oz7.htm
36
 * http://web.archive.org/web/20150510102424/http://www.protocols.com/pbook/isdn.htm
37
 * http://freesoft.org/CIE/Topics/126.htm
38
 * http://noc.comstar.ru/miscdocs/ascend-faq-cause-codes.html
39
 * http://www.andrews-arnold.co.uk/isdn/q931cause.html
40
 * http://www.tulatelecom.ru/staff/german/DSSHelp/MessList/InfEl/InfElList.html
41
 */
42
43
void proto_register_q931(void);
44
void proto_reg_handoff_q931(void);
45
46
static void reset_q931_packet_info(q931_packet_info *pi);
47
static int q931_tap;
48
49
static dissector_handle_t q931_handle;
50
static dissector_handle_t q931_over_ip_handle;
51
52
static int proto_q931;
53
static int hf_q931_discriminator;
54
static int hf_q931_coding_standard;
55
static int hf_q931_interpretation;
56
static int hf_q931_pres_meth_prot_prof;
57
static int hf_q931_high_layer_characteristics;
58
static int hf_q931_extended_high_layer_characteristics;
59
static int hf_q931_extended_audiovisual_characteristics;
60
static int hf_q931_information_transfer_capability;
61
static int hf_q931_transfer_mode;
62
static int hf_q931_information_transfer_rate;
63
static int hf_q931_layer_ident;
64
static int hf_q931_uil1;
65
static int hf_q931_call_ref_len;
66
static int hf_q931_call_ref_flag;
67
static int hf_q931_call_ref;
68
static int hf_q931_message_type;
69
static int hf_q931_maintenance_message_type;
70
static int hf_q931_segment_type;
71
static int hf_q931_cause_location;
72
static int hf_q931_cause_value;
73
static int hf_q931_number_type;
74
static int hf_q931_numbering_plan;
75
static int hf_q931_extension_ind;
76
static int hf_q931_extension_ind_preference;
77
static int hf_q931_extension_ind_new_status;
78
static int hf_q931_calling_party_number;
79
static int hf_q931_called_party_number;
80
static int hf_q931_connected_number;
81
static int hf_q931_redirecting_number;
82
static int hf_q931_screening_ind;
83
static int hf_q931_presentation_ind;
84
85
/* fields for Channel Identification IE */
86
static int hf_q931_channel_interface_explicit;
87
static int hf_q931_channel_interface_type;
88
static int hf_q931_channel_exclusive;
89
static int hf_q931_channel_dchan;
90
static int hf_q931_channel_selection_bri;
91
static int hf_q931_channel_selection_pri;
92
static int hf_q931_channel_map;
93
static int hf_q931_channel_element_type;
94
static int hf_q931_channel_number;
95
96
97
static int hf_q931_segments;
98
static int hf_q931_segment;
99
static int hf_q931_segment_overlap;
100
static int hf_q931_segment_overlap_conflict;
101
static int hf_q931_segment_multiple_tails;
102
static int hf_q931_segment_too_long_segment;
103
static int hf_q931_segment_error;
104
static int hf_q931_segment_count;
105
static int hf_q931_reassembled_in;
106
static int hf_q931_reassembled_length;
107
108
/* Generated from convert_proto_tree_add_text.pl */
109
static int hf_q931_user_information_bytes;
110
static int hf_q931_restart_indicator;
111
static int hf_q931_call_state_data;
112
static int hf_q931_first_segment;
113
static int hf_q931_packet_size_backward_value;
114
static int hf_q931_packet_size_forward_value;
115
static int hf_q931_information_rate_minimum_outgoing;
116
static int hf_q931_bearer_capability_data;
117
static int hf_q931_uil2_info;
118
static int hf_q931_netid_facility_specification;
119
static int hf_q931_bearer_capability_stop_bits;
120
static int hf_q931_netid_length;
121
static int hf_q931_channel_data;
122
static int hf_q931_call_state;
123
static int hf_q931_party_subaddr_type;
124
static int hf_q931_uil3;
125
static int hf_q931_user_information_str;
126
static int hf_q931_bearer_capability_user_rate;
127
static int hf_q931_channel_slot_map;
128
static int hf_q931_bearer_capability_modem_type;
129
static int hf_q931_cause_data;
130
static int hf_q931_cause_recommendation;
131
static int hf_q931_bearer_capability_parity;
132
static int hf_q931_cause_call_rejection_reason;
133
static int hf_q931_party_category;
134
static int hf_q931_progress_indicator_location;
135
static int hf_q931_bearer_capability_packet_window_size;
136
static int hf_q931_extension_reason;
137
static int hf_q931_information_rate_minimum_incoming;
138
static int hf_q931_user_protocol_discriminator;
139
static int hf_q931_uil2;
140
static int hf_q931_progress_indicator_description;
141
static int hf_q931_bearer_capability_mode;
142
static int hf_q931_not_first_segment;
143
static int hf_q931_fast_select;
144
static int hf_q931_netid_plan;
145
static int hf_q931_cause_call_message_type;
146
static int hf_q931_reverse_charging_ind;
147
static int hf_q931_high_layer_compat_data;
148
static int hf_q931_progress_indicator_data;
149
static int hf_q931_pl_window_size_forward_value;
150
static int hf_q931_cause_call_rec_timer;
151
static int hf_q931_bearer_capability_window_size;
152
static int hf_q931_cause_call_user_specific_diagnostic;
153
static int hf_q931_channel_interface_id;
154
static int hf_q931_uil3_additional;
155
static int hf_q931_party_subaddr;
156
static int hf_q931_bearer_capability_rate_multiplier;
157
static int hf_q931_bearer_capability_data_bits;
158
static int hf_q931_cug_index_code;
159
static int hf_q931_bearer_capability_default_packet_size;
160
static int hf_q931_notification_description;
161
static int hf_q931_information_rate_outgoing;
162
static int hf_q931_user_information_len;
163
static int hf_q931_pl_window_size_backward_value;
164
static int hf_q931_repeat_indicator;
165
static int hf_q931_cause_call_diagnostic;
166
static int hf_q931_netid;
167
static int hf_q931_cause_call_condition;
168
static int hf_q931_signal;
169
static int hf_q931_congestion_level;
170
static int hf_q931_bearer_capability_intermediate_rate;
171
static int hf_q931_netid_type;
172
static int hf_q931_information_rate_incoming;
173
static int hf_q931_party_subaddr_odd_even_indicator;
174
static int hf_q931_cug_indication;
175
static int hf_q931_multiple_frame_establishment;
176
static int hf_q931_message_originator;
177
static int hf_q931_out_band_negotiation;
178
static int hf_q931_negotiation_is_done;
179
static int hf_q931_layer_1;
180
static int hf_q931_accept_data_flow_control;
181
static int hf_q931_mode_of_operation;
182
static int hf_q931_extension_condition_type;
183
static int hf_q931_pl_binary_confirmation;
184
static int hf_q931_pl_request;
185
static int hf_q931_pl_modulus;
186
static int hf_q931_network_service;
187
static int hf_q931_extension_condition;
188
static int hf_q931_rate_adaption_header;
189
static int hf_q931_send_data_net_independent_clock;
190
static int hf_q931_bearer_capability_duplex;
191
static int hf_q931_accept_data_net_independent_clock;
192
static int hf_q931_send_data_flow_control;
193
static int hf_q931_data;
194
static int hf_q931_layer_1_in_band_negotiation;
195
static int hf_q931_information_element;
196
static int hf_q931_information_element_len;
197
static int hf_q931_date_time;
198
static int hf_q931_more_data;
199
static int hf_q931_sending_complete;
200
static int hf_q931_message_segment;
201
static int hf_q931_missing_info_element;
202
static int hf_q931_insufficient_info_element;
203
static int hf_q931_cumulative_transit_delay;
204
static int hf_q931_requested_end_to_end_transit_delay;
205
static int hf_q931_maximum_end_to_end_transit_delay;
206
static int hf_q931_transit_delay;
207
static int hf_q931_display_information;
208
static int hf_q931_keypad_facility;
209
static int hf_q931_avaya_display;
210
static int hf_q931_locking_codeset;
211
static int hf_q931_protocol_negotiation;
212
213
214
static int ett_q931;
215
3.59k
#define NUM_IE  256
216
static int ett_q931_ie[NUM_IE];
217
218
static int ett_q931_segments;
219
static int ett_q931_segment;
220
221
static expert_field ei_q931_invalid_length;
222
static expert_field ei_q931_date_time;
223
static expert_field ei_q931_information_element;
224
static expert_field ei_q931_incomplete_ie;
225
226
static const fragment_items q931_frag_items = {
227
    &ett_q931_segment,
228
    &ett_q931_segments,
229
230
    &hf_q931_segments,
231
    &hf_q931_segment,
232
    &hf_q931_segment_overlap,
233
    &hf_q931_segment_overlap_conflict,
234
    &hf_q931_segment_multiple_tails,
235
    &hf_q931_segment_too_long_segment,
236
    &hf_q931_segment_error,
237
    &hf_q931_segment_count,
238
    &hf_q931_reassembled_in,
239
    &hf_q931_reassembled_length,
240
    /* Reassembled data field */
241
    NULL,
242
    "segments"
243
};
244
245
/* Table for reassembly of fragments. */
246
static reassembly_table q931_reassembly_table;
247
248
/* Preferences */
249
static bool q931_reassembly = true;
250
static bool g931_iso_iec_cause;
251
252
static dissector_table_t codeset_dissector_table;
253
static dissector_table_t ie_dissector_table;
254
255
/* desegmentation of Q.931 over TPKT over TCP */
256
static bool q931_desegment = true;
257
258
/* Subdissectors */
259
static dissector_handle_t h225_handle;
260
static dissector_handle_t q931_tpkt_handle;
261
static dissector_handle_t q931_tpkt_pdu_handle;
262
263
static heur_dissector_list_t q931_user_heur_subdissector_list;
264
265
static void
266
dissect_q931_IEs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root_tree,
267
    proto_tree *q931_tree, bool is_over_ip, int offset, int initial_codeset,
268
    q931_packet_info *q931_pi);
269
270
const value_string q931_message_type_vals[] = {
271
/*  0 */    { Q931_ESCAPE,               "ESCAPE" },
272
/*  1 */    { Q931_ALERTING,             "ALERTING" },
273
/*  2 */    { Q931_CALL_PROCEEDING,      "CALL PROCEEDING" },
274
/*  3 */    { Q931_PROGRESS,             "PROGRESS" },
275
/*  5 */    { Q931_SETUP,                "SETUP" },
276
/*  6 */    { Q931_GROUIP_SERVICE,       "GROUP SERVICE" },
277
/*  7 */    { Q931_CONNECT,              "CONNECT" },
278
/*  8 */    { Q931_RESYNC_REQ,           "RESYNC REQ" },
279
/*  9 */    { Q931_RESYNC_RESP,          "RESYNC RESP" },
280
/* 10 */    { Q931_VERSION,              "VERSION" },
281
/* 11 */    { Q931_GROUIP_SERVICE_ACK,   "GROUP SERVICE ACK" },
282
/* 13 */    { Q931_SETUP_ACK,            "SETUP ACKNOWLEDGE" },
283
/* 15 */    { Q931_CONNECT_ACK,          "CONNECT ACKNOWLEDGE" },
284
/* 32 */    { Q931_USER_INFORMATION,     "USER INFORMATION" },
285
/* 33 */    { Q931_SUSPEND_REJECT,       "SUSPEND REJECT" },
286
/* 34 */    { Q931_RESUME_REJECT,        "RESUME REJECT" },
287
/* 36 */    { Q931_HOLD,                 "HOLD" },
288
/* 37 */    { Q931_SUSPEND,              "SUSPEND" },
289
/* 38 */    { Q931_RESUME,               "RESUME" },
290
/* 40 */    { Q931_HOLD_ACK,             "HOLD_ACKNOWLEDGE" },
291
/* 45 */    { Q931_SUSPEND_ACK,          "SUSPEND ACKNOWLEDGE" },
292
/* 46 */    { Q931_RESUME_ACK,           "RESUME ACKNOWLEDGE" },
293
/* 48 */    { Q931_HOLD_REJECT,          "HOLD_REJECT" },
294
/* 49 */    { Q931_RETRIEVE,             "RETRIEVE" },
295
/* 51 */    { Q931_RETRIEVE_ACK,         "RETRIEVE ACKNOWLEDGE" },
296
/* 55 */    { Q931_RETRIEVE_REJECT,      "RETRIEVE REJECT" },
297
/* 64 */    { Q931_DETACH,               "DETACH" },
298
/* 69 */    { Q931_DISCONNECT,           "DISCONNECT" },
299
/* 70 */    { Q931_RESTART,              "RESTART" },
300
/* 72 */    { Q931_DETACH_ACKNOWLEDGE,   "DETACH ACKNOWLEDGE" },
301
/* 77 */    { Q931_RELEASE,              "RELEASE" },
302
/* 78 */    { Q931_RESTART_ACK,          "RESTART ACKNOWLEDGE" },
303
/* 90 */    { Q931_RELEASE_COMPLETE,     "RELEASE COMPLETE" },
304
/* 96 */    { Q931_SEGMENT,              "SEGMENT" },
305
/* 98 */    { Q931_FACILITY,             "FACILITY" },
306
/*100 */    { Q931_REGISTER,             "REGISTER" },
307
/*106 */    { Q931_FACILITY_ACKNOWLEDGE, "FACILITY ACKNOWLEDGE" },
308
/*110 */    { Q931_NOTIFY,               "NOTIFY" },
309
/*114 */    { Q931_FACILITY_REJECT,      "FACILITY REJECT" },
310
/*117 */    { Q931_STATUS_ENQUIRY,       "STATUS ENQUIRY" },
311
/*121 */    { Q931_CONGESTION_CONTROL,   "CONGESTION CONTROL" },
312
/*123 */    { Q931_INFORMATION,          "INFORMATION" },
313
/*125 */    { Q931_STATUS,               "STATUS" },
314
315
            { 0,                         NULL }
316
};
317
static value_string_ext q931_message_type_vals_ext = VALUE_STRING_EXT_INIT(q931_message_type_vals);
318
319
static const value_string dms_message_type_vals[] = {
320
    { DMS_SERVICE_ACKNOWLEDGE,  "SERVICE ACKNOWLEDGE" },
321
    { DMS_SERVICE,              "SERVICE" },
322
    { 0,                        NULL }
323
};
324
325
/*
326
 * NOTE  For call reference flag (octet 2)
327
 * Bit8
328
 *  0 The message is sent from the side that originates the call reference
329
 *  1 The message is sent to the side that originates the call reference
330
 */
331
static const true_false_string tfs_call_ref_flag = {
332
    "Message sent to originating side",
333
    "Message sent from originating side"
334
};
335
336
static const true_false_string tfs_interface_type = {
337
    "Primary rate interface",
338
    "Basic rate interface"
339
};
340
341
static const true_false_string tfs_channel_exclusive = {
342
    "Exclusive; only the indicated channel is acceptable",
343
    "Indicated channel is preferred"
344
};
345
346
static const true_false_string tfs_channel_map = {
347
    "Channel indicated by slot map",
348
    "Channel indicated by number"
349
};
350
351
/*
352
 * Information elements.
353
 */
354
355
/* Shifted codeset values */
356
19.5k
#define CS0 0x000
357
#define CS1 0x100
358
#define CS2 0x200
359
#define CS3 0x300
360
#define CS4 0x400
361
0
#define CS5 0x500
362
16
#define CS6 0x600
363
#define CS7 0x700
364
365
55.8k
#define Q931_IE_SO_MASK 0x80    /* single-octet/variable-length mask */
366
/*
367
 * Single-octet IEs.
368
 */
369
58.2k
#define Q931_IE_SO_IDENTIFIER_MASK     0xf0    /* IE identifier mask */
370
#define Q931_IE_SO_IDENTIFIER_SHIFT       4    /* IE identifier shift */
371
28
#define Q931_IE_SO_IE_MASK             0x0F    /* IE mask */
372
373
20.5k
#define Q931_IE_SHIFT                  0x90
374
1.73k
#define Q931_IE_SHIFT_NON_LOCKING      0x08    /* non-locking shift */
375
1.73k
#define Q931_IE_SHIFT_CODESET          0x07    /* codeset */
376
377
2.44k
#define Q931_IE_MORE_DATA_OR_SEND_COMP 0xA0    /* More Data or Sending Complete */
378
248
#define Q931_IE_MORE_DATA              0xA0
379
534
#define Q931_IE_SENDING_COMPLETE       0xA1
380
381
1.66k
#define Q931_IE_CONGESTION_LEVEL       0xB0
382
1.72k
#define Q931_IE_REPEAT_INDICATOR       0xD0
383
384
/*
385
 * Variable-length IEs.
386
 */
387
3.95k
#define Q931_IE_VL_EXTENSION        0x80    /* Extension flag */
388
/*  extension bit. The bit value "0" indicates that the octet continues through the     */
389
/*  next octet. The bit value "1" indicates that this octet is the last octet       */
390
391
static const true_false_string q931_extension_ind_value = {
392
    "last octet",
393
    "information continues through the next octet"
394
};
395
396
397
/*
398
 * Codeset 0 (default).
399
 */
400
7.86k
#define Q931_IE_SEGMENTED_MESSAGE        0x00
401
989
#define Q931_IE_CHANGE_STATUS            0x01
402
1.16k
#define Q931_IE_BEARER_CAPABILITY        0x04
403
915
#define Q931_IE_CAUSE                    0x08
404
#define Q931_IE_CALL_IDENTITY            0x10
405
82
#define Q931_IE_CALL_STATE               0x14
406
150
#define Q931_IE_CHANNEL_IDENTIFICATION   0x18
407
#define Q931_IE_FACILITY                 0x1C
408
97
#define Q931_IE_PROGRESS_INDICATOR       0x1E
409
112
#define Q931_IE_NETWORK_SPECIFIC_FACIL   0x20    /* Network Specific Facilities */
410
0
#define Q931_IE_NOTIFICATION_INDICATOR   0x27
411
85
#define Q931_IE_DISPLAY                  0x28
412
36
#define Q931_IE_DATE_TIME                0x29
413
64
#define Q931_IE_KEYPAD_FACILITY          0x2C
414
#define Q931_IE_INFORMATION_REQUEST      0x32
415
27
#define Q931_IE_SIGNAL                   0x34
416
#define Q931_IE_SWITCHHOOK               0x36
417
#define Q931_IE_FEATURE_ACTIVATION       0x38
418
#define Q931_IE_FEATURE_INDICATION       0x39
419
#define Q931_IE_ENDPOINT_IDENTIFIER      0x3B
420
#define Q931_IE_SERVICE_PROFILE_ID       0x3A
421
57
#define Q931_IE_INFORMATION_RATE         0x40
422
58
#define Q931_IE_E2E_TRANSIT_DELAY        0x42    /* End-to-end Transit Delay */
423
48
#define Q931_IE_TD_SELECTION_AND_INT     0x43    /* Transit Delay Selection and Indication */
424
34
#define Q931_IE_PL_BINARY_PARAMETERS     0x44    /* Packet layer binary parameters */
425
31
#define Q931_IE_PL_WINDOW_SIZE           0x45    /* Packet layer window size */
426
34
#define Q931_IE_PACKET_SIZE              0x46    /* Packet size */
427
59
#define Q931_IE_CUG                      0x47    /* Closed user group */
428
29
#define Q931_IE_REVERSE_CHARGE_IND       0x4A    /* Reverse charging indication */
429
64
#define Q931_IE_CONNECTED_NUMBER_DEFAULT 0x4C    /* Connected Number */
430
#define Q931_IE_INTERFACE_SERVICE        0x66    /* q931+ Interface Service */
431
#define Q931_IE_CHANNEL_STATUS           0x67    /* q931+ Channel Status */
432
#define Q931_IE_VERSION_INFO             0x68    /* q931+ Version Info */
433
59
#define Q931_IE_CALLING_PARTY_NUMBER     0x6C    /* Calling Party Number */
434
29
#define Q931_IE_CALLING_PARTY_SUBADDR    0x6D    /* Calling Party Subaddress */
435
83
#define Q931_IE_CALLED_PARTY_NUMBER      0x70    /* Called Party Number */
436
57
#define Q931_IE_CALLED_PARTY_SUBADDR     0x71    /* Called Party Subaddress */
437
#define Q931_IE_REDIRECTING_NUMBER       0x74
438
#define Q931_IE_REDIRECTION_NUMBER       0x76
439
145
#define Q931_IE_TRANSIT_NETWORK_SEL      0x78    /* Transit Network Selection */
440
23
#define Q931_IE_RESTART_INDICATOR        0x79
441
1.19k
#define Q931_IE_LOW_LAYER_COMPAT         0x7C    /* Low-Layer Compatibility */
442
23
#define Q931_IE_HIGH_LAYER_COMPAT        0x7D    /* High-Layer Compatibility */
443
8.78k
#define Q931_IE_USER_USER                0x7E    /* User-User */
444
#define Q931_IE_ESCAPE                   0x7F    /* Escape for extension */
445
446
/*
447
 * Codeset 0 ETSI.
448
 */
449
#define Q931_IE_CONNECTED_NUMBER         0x8C
450
#define Q931_IE_CONNECTED_SUBADDR        0x8D
451
452
/*
453
 * Codeset 5 (National-specific) Belgium.
454
 */
455
#define Q931_IE_CHARGING_ADVICE          0x1A
456
457
/*
458
 * Codeset 5 (National-specific) Bellcore National ISDN.
459
 */
460
#define Q931_IE_OPERATOR_SYSTEM_ACCESS   0x1D
461
462
/*
463
 * Codeset 5 ETSI ETS 300 192
464
 */
465
0
#define Q931_IE_PARTY_CATEGORY           0x32
466
467
/*
468
 * Codeset 6 (Network-specific) Belgium.
469
 */
470
/* 0x1A is Charging Advice, as with Codeset 5 */
471
61
#define Q931_IE_REDIRECTING_NUMBER       0x74
472
473
/*
474
 * Codeset 6 (Network-specific) FT-Numeris.
475
 */
476
/* 0x1D is User Capability */
477
478
/*
479
 * Codeset 6 (Network-specific) Bellcore National ISDN.
480
 */
481
#define Q931_IE_REDIRECTING_SUBADDR      0x75    /* Redirecting Subaddress */
482
/* 0x76 is Redirection Number, but that's also Codeset 0 */
483
#define Q931_IE_CALL_APPEARANCE          0x7B
484
485
/* Codeset 0 */
486
static const value_string q931_info_element_vals0[] = {
487
    { Q931_IE_SEGMENTED_MESSAGE,        "Segmented message" },
488
    { Q931_IE_CHANGE_STATUS,            "Change status" },
489
    { Q931_IE_BEARER_CAPABILITY,        "Bearer capability" },
490
    { Q931_IE_CAUSE,                    "Cause" },
491
    { Q931_IE_CALL_IDENTITY,            "Call identity" },
492
    { Q931_IE_CALL_STATE,               "Call state" },
493
    { Q931_IE_CHANNEL_IDENTIFICATION,   "Channel identification" },
494
    { Q931_IE_FACILITY,                 "Facility" },
495
    { Q931_IE_PROGRESS_INDICATOR,       "Progress indicator" },
496
    { Q931_IE_NETWORK_SPECIFIC_FACIL,   "Network specific facilities" },
497
    { Q931_IE_NOTIFICATION_INDICATOR,   "Notification indicator" },
498
    { Q931_IE_DISPLAY,                  "Display" },
499
    { Q931_IE_DATE_TIME,                "Date/Time" },
500
    { Q931_IE_KEYPAD_FACILITY,          "Keypad facility" },
501
    { Q931_IE_INFORMATION_REQUEST,      "Information request" },
502
    { Q931_IE_SIGNAL,                   "Signal" },
503
    { Q931_IE_SWITCHHOOK,               "Switchhook" },
504
    { Q931_IE_FEATURE_ACTIVATION,       "Feature activation" },
505
    { Q931_IE_FEATURE_INDICATION,       "Feature Indication" },
506
    { Q931_IE_ENDPOINT_IDENTIFIER,      "Endpoint identifier" },
507
    { Q931_IE_SERVICE_PROFILE_ID,       "Service profile ID" },
508
    { Q931_IE_INFORMATION_RATE,         "Information rate" },
509
    { Q931_IE_E2E_TRANSIT_DELAY,        "End-to-end transit delay" },
510
    { Q931_IE_TD_SELECTION_AND_INT,     "Transit delay selection and indication" },
511
    { Q931_IE_PL_BINARY_PARAMETERS,     "Packet layer binary parameters" },
512
    { Q931_IE_PL_WINDOW_SIZE,           "Packet layer window size" },
513
    { Q931_IE_PACKET_SIZE,              "Packet size" },
514
    { Q931_IE_CUG,                      "Closed user group" },
515
    { Q931_IE_REVERSE_CHARGE_IND,       "Reverse charging indication" },
516
    { Q931_IE_CONNECTED_NUMBER_DEFAULT, "Connected number" },
517
    { Q931_IE_INTERFACE_SERVICE,        "Interface Service" },
518
    { Q931_IE_CHANNEL_STATUS,           "Channel Status" },
519
    { Q931_IE_VERSION_INFO,             "Version Info" },
520
    { Q931_IE_CALLING_PARTY_NUMBER,     "Calling party number" },
521
    { Q931_IE_CALLING_PARTY_SUBADDR,    "Calling party subaddress" },
522
    { Q931_IE_CALLED_PARTY_NUMBER,      "Called party number" },
523
    { Q931_IE_CALLED_PARTY_SUBADDR,     "Called party subaddress" },
524
    { Q931_IE_REDIRECTING_NUMBER,       "Redirecting number" },
525
    { Q931_IE_REDIRECTION_NUMBER,       "Redirection number" },
526
    { Q931_IE_TRANSIT_NETWORK_SEL,      "Transit network selection" },
527
    { Q931_IE_RESTART_INDICATOR,        "Restart indicator" },
528
    { Q931_IE_LOW_LAYER_COMPAT,         "Low-layer compatibility" },
529
    { Q931_IE_HIGH_LAYER_COMPAT,        "High-layer compatibility" },
530
    { Q931_IE_USER_USER,                "User-user" },
531
    { Q931_IE_ESCAPE,                   "Escape" },
532
    { Q931_IE_CONNECTED_NUMBER,         "Connected number" },
533
    { Q931_IE_CONNECTED_SUBADDR,        "Connected subaddress" },
534
    { 0,                                NULL }
535
};
536
537
/* Codeset 1 */
538
static const value_string q931_info_element_vals1[] = {
539
    { 0,                                NULL }
540
};
541
/* Codeset 2 */
542
static const value_string q931_info_element_vals2[] = {
543
    { 0,                                NULL }
544
};
545
/* Codeset 3 */
546
static const value_string q931_info_element_vals3[] = {
547
    { 0,                                NULL }
548
};
549
/* Codeset 4 */
550
static const value_string q931_info_element_vals4[] = {
551
    { 0,                                NULL }
552
};
553
/* Codeset 5 */
554
static const value_string q931_info_element_vals5[] = {
555
    { Q931_IE_CHARGING_ADVICE,          "Charging advice" },
556
    { Q931_IE_OPERATOR_SYSTEM_ACCESS,   "Operator system access" },
557
    { Q931_IE_PARTY_CATEGORY,           "Party category"},
558
    { 0,                                NULL }
559
};
560
/* Codeset 6 */
561
static const value_string q931_info_element_vals6[] = {
562
    { Q931_IE_REDIRECTING_NUMBER,       "Redirecting number" },
563
    { Q931_IE_REDIRECTING_SUBADDR,      "Redirecting subaddress" },
564
    { Q931_IE_CALL_APPEARANCE,          "Call appearance" },
565
    { Q931_IE_DISPLAY,                  "Avaya Display" }, /* if Avaya codeset to send display = 6 */
566
    { 0,                                NULL }
567
};
568
/* Codeset 7 */
569
static const value_string q931_info_element_vals7[] = {
570
    { 0,                                NULL }
571
};
572
573
/* Codeset array */
574
#define NUM_INFO_ELEMENT_VALS   (Q931_IE_SHIFT_CODESET+1)
575
static const value_string *q931_info_element_vals[NUM_INFO_ELEMENT_VALS] = {
576
    q931_info_element_vals0,
577
    q931_info_element_vals1,
578
    q931_info_element_vals2,
579
    q931_info_element_vals3,
580
    q931_info_element_vals4,
581
    q931_info_element_vals5,
582
    q931_info_element_vals6,
583
    q931_info_element_vals7,
584
};
585
586
static const value_string q931_congestion_level_vals[] = {
587
    { 0x0, "Receiver ready" },
588
    { 0xF, "Receiver not ready" },
589
    { 0,   NULL }
590
};
591
592
static const value_string q931_repeat_indication_vals[] = {
593
    { 0x2, "Prioritized list" },
594
    { 0,   NULL }
595
};
596
597
/*
598
 * ITU-standardized coding.
599
 */
600
3.47k
#define Q931_ITU_STANDARDIZED_CODING    0x00
601
150
#define Q931_ISO_IEC_STANDARDIZED_CODING     0x20
602
603
/*
604
 * Dissect a Segmented message information element.
605
 */
606
static void
607
dissect_q931_segmented_message_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
608
    proto_tree *tree, proto_item* item)
609
511
{
610
511
    uint8_t octet;
611
612
511
    if (len != 2) {
613
460
        expert_add_info_format(pinfo, item, &ei_q931_invalid_length,
614
460
            "Segmented message: length is %d, should be 2", len);
615
460
        return;
616
460
    }
617
618
51
    octet = tvb_get_uint8(tvb, offset);
619
51
    if (octet & 0x80) {
620
36
        proto_tree_add_item(tree, hf_q931_first_segment, tvb, offset, 1, ENC_NA);
621
36
    } else {
622
15
        proto_tree_add_item(tree, hf_q931_not_first_segment, tvb, offset, 1, ENC_NA);
623
15
    }
624
51
    proto_tree_add_item(tree, hf_q931_segment_type, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
625
51
}
626
627
/*
628
 * Dissect a Bearer capability or Low-layer compatibility information element.
629
 */
630
static const value_string q931_coding_standard_vals[] = {
631
    { 0x0, "ITU-T standardized coding" },
632
    { 0x1, "ISO/IEC standard" },
633
    { 0x2, "National standard" },
634
    { 0x3, "Standard defined for this particular network" },
635
    { 0,    NULL }
636
};
637
638
static const value_string q931_information_transfer_capability_vals[] = {
639
    { 0x00, "Speech" },
640
    { 0x08, "Unrestricted digital information" },
641
    { 0x09, "Restricted digital information" },
642
    { 0x10, "3.1 kHz audio" },
643
    { 0x11, "Unrestricted digital information with tones/announcements" },
644
    { 0x18, "Video" },
645
    { 0,    NULL }
646
};
647
648
static const value_string q931_transfer_mode_vals[] = {
649
    { 0x00, "Circuit mode" },
650
    { 0x02, "Packet mode" },
651
    { 0,    NULL }
652
};
653
654
1.08k
#define Q931_IT_RATE_MULTIRATE  0x18
655
656
static const value_string q931_information_transfer_rate_vals[] = {
657
    { 0x00,                   "Packet mode" },
658
    { 0x10,                   "64 kbit/s" },
659
    { 0x11,                   "2 x 64 kbit/s" },
660
    { 0x13,                   "384 kbit/s" },
661
    { 0x15,                   "1536 kbit/s" },
662
    { 0x17,                   "1920 kbit/s" },
663
    { Q931_IT_RATE_MULTIRATE, "Multirate (64 kbit/s base rate)" },
664
    { 0,                      NULL }
665
};
666
667
/*
668
 * Values 0x0a and 0x0b added from Q.931 Amendment 1 (12/2002)
669
 */
670
static const value_string q931_uil1_vals[] = {
671
    { 0x01, "V.110/I.460/X.30 rate adaption" },
672
    { 0x02, "Recommendation G.711 u-law" },
673
    { 0x03, "Recommendation G.711 A-law" },
674
    { 0x04, "Recommendation G.721 32 kbit/s ADPCM and Recommendation I.460" },
675
    { 0x05, "Recommendation H.221 and H.242" },
676
    { 0x06, "Recommendation H.223 and H.245" },
677
    { 0x07, "Non-ITU-T-standardized rate adaption" },
678
    { 0x08, "V.120 rate adaption" },
679
    { 0x09, "X.31 HDLC flag stuffing" },
680
    { 0x0a, "Recommendation G.728 LD-CELP" },
681
    { 0x0b, "Recommendation G.729 CS-ACELP" },
682
    { 0,    NULL }
683
};
684
static value_string_ext q931_uil1_vals_ext = VALUE_STRING_EXT_INIT(q931_uil1_vals);
685
686
static const value_string q931_l1_user_rate_vals[] = {
687
    { 0x00, "Rate indicated by E-bits" },
688
    { 0x01, "0.6 kbit/s" },
689
    { 0x02, "1.2 kbit/s" },
690
    { 0x03, "2.4 kbit/s" },
691
    { 0x04, "3.6 kbit/s" },
692
    { 0x05, "4.8 kbit/s" },
693
    { 0x06, "7.2 kbit/s" },
694
    { 0x07, "8 kbit/s" },
695
    { 0x08, "9.6 kbit/s" },
696
    { 0x09, "14.4 kbit/s" },
697
    { 0x0A, "16 kbit/s" },
698
    { 0x0B, "19.2 kbit/s" },
699
    { 0x0C, "32 kbit/s" },
700
    { 0x0E, "48 kbit/s" },
701
    { 0x0F, "56 kbit/s" },
702
    { 0x10, "64 kbit/s "},
703
    { 0x15, "0.1345 kbit/s" },
704
    { 0x16, "0.100 kbit/s" },
705
    { 0x17, "0.075/1.2 kbit/s" },
706
    { 0x18, "1.2/0.075 kbit/s" },
707
    { 0x19, "0.050 kbit/s" },
708
    { 0x1A, "0.075 kbit/s" },
709
    { 0x1B, "0.110 kbit/s" },
710
    { 0x1C, "0.150 kbit/s" },
711
    { 0x1D, "0.200 kbit/s" },
712
    { 0x1E, "0.300 kbit/s" },
713
    { 0x1F, "12 kbit/s" },
714
    { 0,    NULL }
715
};
716
static value_string_ext q931_l1_user_rate_vals_ext = VALUE_STRING_EXT_INIT(q931_l1_user_rate_vals);
717
718
static const value_string q931_l1_intermediate_rate_vals[] = {
719
    { 0x00, "Not used" },
720
    { 0x01, "8 kbit/s" },
721
    { 0x02, "16 kbit/s" },
722
    { 0x03, "32 kbit/s" },
723
    { 0,    NULL }
724
};
725
726
static const value_string q931_l1_stop_bits_vals[] = {
727
    { 0x01, "1" },
728
    { 0x02, "1.5" },
729
    { 0x03, "2" },
730
    { 0,    NULL }
731
};
732
733
static const value_string q931_l1_data_bits_vals[] = {
734
    { 0x1,  "5" },
735
    { 0x2,  "7" },
736
    { 0x3,  "8" },
737
    { 0,    NULL }
738
};
739
740
static const value_string q931_l1_parity_vals[] = {
741
    { 0x00, "Odd" },
742
    { 0x02, "Even" },
743
    { 0x03, "None" },
744
    { 0x04, "Forced to 0" },
745
    { 0x05, "Forced to 1" },
746
    { 0,    NULL }
747
};
748
749
#define Q931_UIL2_USER_SPEC 0x10
750
751
static const value_string q931_uil2_vals[] = {
752
    { 0x01,                "Basic mode ISO 1745" },
753
    { 0x02,                "Q.921/I.441" },    /* LAPD */
754
    { 0x06,                "X.25, link layer" },   /* LAPB */
755
    { 0x07,                "X.25 multilink" }, /* or 0x0F? */
756
    { 0x08,                "T.71 Extended LAPB" },
757
    { 0x09,                "HDLC ARM" },
758
    { 0x0A,                "HDLC NRM" },
759
    { 0x0B,                "HDLC ABM" },
760
    { 0x0C,                "ISO 8802/2 LLC" },
761
    { 0x0D,                "X.75 Single Link Procedure" },
762
    { 0x0E,                "Q.922" },
763
    { 0x0F,                "Core aspects of Q.922" },
764
    { Q931_UIL2_USER_SPEC, "User-specified" },
765
    { 0x11,                "ISO 7776 DTE-DTE operation" },
766
    { 0,                   NULL }
767
};
768
static value_string_ext q931_uil2_vals_ext = VALUE_STRING_EXT_INIT(q931_uil2_vals);
769
770
static const value_string q931_mode_vals[] = {
771
    { 0x1,  "Normal mode" },
772
    { 0x2,  "Extended mode" },
773
    { 0,    NULL }
774
};
775
776
0
#define Q931_UIL3_X25_PL    0x06
777
3
#define Q931_UIL3_ISO_8208  0x07    /* X.25-based */
778
4
#define Q931_UIL3_X223      0x08    /* X.25-based */
779
1
#define Q931_UIL3_TR_9577   0x0B
780
2
#define Q931_UIL3_USER_SPEC 0x10
781
782
static const value_string q931_uil3_vals[] = {
783
    { 0x02,                "Q.931/I.451" },
784
    { Q931_UIL3_X25_PL,    "X.25, packet layer" },
785
    { Q931_UIL3_ISO_8208,  "ISO/IEC 8208" },
786
    { Q931_UIL3_X223,      "X.223/ISO 8878" },
787
    { 0x09,                "ISO/IEC 8473" },
788
    { 0x0A,                "T.70" },
789
    { Q931_UIL3_TR_9577,   "ISO/IEC TR 9577" },
790
    { Q931_UIL3_USER_SPEC, "User-specified" },
791
    { 0,                   NULL }
792
};
793
794
static void
795
dissect_q931_protocol_discriminator(tvbuff_t *tvb, int offset, proto_tree *tree)
796
1.03k
{
797
1.03k
    unsigned int discriminator = tvb_get_uint8(tvb, offset);
798
799
1.03k
    if (discriminator == NLPID_DMS) {
800
49
        proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
801
49
             tvb, offset, 1, discriminator,
802
49
             "Maintenance messages");
803
985
    } else if (discriminator == NLPID_Q_931) {
804
845
        proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
805
845
             tvb, offset, 1, discriminator,
806
845
             "Q.931");
807
845
    } else if (discriminator == NLPID_Q_2931) {
808
2
        proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
809
2
             tvb, offset, 1, discriminator,
810
2
             "Q.2931");
811
138
    } else if ((discriminator >= 16 && discriminator < 63)
812
110
        || ((discriminator >= 80) && (discriminator < 254))) {
813
78
        proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
814
78
            tvb, offset, 1, discriminator,
815
78
            "Network layer or layer 3 protocol (0x%02X)",
816
78
            discriminator);
817
78
    } else if (discriminator >= 64 && discriminator <= 79) {
818
7
        proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
819
7
            tvb, offset, 1, discriminator,
820
7
            "National use (0x%02X)",
821
7
            discriminator);
822
53
    } else {
823
53
        proto_tree_add_uint_format_value(tree, hf_q931_discriminator,
824
53
            tvb, offset, 1, discriminator,
825
53
            "Reserved (0x%02X)",
826
53
            discriminator);
827
53
    }
828
1.03k
}
829
830
static const value_string q931_bearer_capability_layer_ident_vals[] = {
831
    { 0x01, "Layer 1 identifier" },
832
    { 0x02, "Layer 2 identifier" },
833
    { 0x03, "Layer 3 identifier" },
834
    { 0x00, NULL }
835
};
836
837
21
#define Q931_UIL2_USER_SPEC 0x10
838
839
static const range_string q931_l1_modem_type_rvals[] = {
840
    { 0x00, 0x05, "National use" },
841
    { 0x11, 0x11, "V.21" },
842
    { 0x12, 0x12, "V.22" },
843
    { 0x13, 0x13, "V.22 bis" },
844
    { 0x14, 0x14, "V.23" },
845
    { 0x15, 0x15, "V.26" },
846
    { 0x16, 0x16, "V.26 bis" },
847
    { 0x17, 0x17, "V.26 ter" },
848
    { 0x18, 0x18, "V.27" },
849
    { 0x19, 0x19, "V.27 bis" },
850
    { 0x1A, 0x1A, "V.27 ter" },
851
    { 0x1B, 0x1B, "V.29" },
852
    { 0x1C, 0x1C, "V.32" },
853
    { 0x1E, 0x1E, "V.34" },
854
    { 0x20, 0x2F, "National use" },
855
    { 0x30, 0x3F, "User specified" },
856
    { 0, 0,       NULL }
857
};
858
859
static const true_false_string tfs_assignor_default                   = { "Assignor only", "Default assignee" };
860
static const true_false_string tfs_in_out_band                        = { "in-band", "out-of-band" };
861
static const true_false_string tfs_protocol_negotiation               = { "Full protocol negotiation", "LLI = 256 only" };
862
863
void
864
dissect_q931_bearer_capability_ie(tvbuff_t *tvb, int offset, int len,
865
    proto_tree *tree)
866
1.29k
{
867
1.29k
    uint8_t octet;
868
1.29k
    uint8_t coding_standard;
869
1.29k
    uint8_t it_rate;
870
1.29k
    uint8_t uil2_protocol;
871
1.29k
    uint8_t uil3_protocol;
872
1.29k
    uint8_t add_l3_info;
873
874
1.29k
    if (len == 0)
875
34
        return;
876
1.25k
    octet = tvb_get_uint8(tvb, offset);
877
1.25k
    coding_standard = octet & 0x60;
878
1.25k
    if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
879
        /*
880
         * We don't know how the bearer capability is encoded,
881
         * so just dump it as data and be done with it.
882
         */
883
158
        proto_tree_add_item(tree, hf_q931_bearer_capability_data, tvb, offset, len, ENC_NA);
884
158
        proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
885
158
        proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
886
158
        return;
887
158
    }
888
1.09k
    proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
889
1.09k
    proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
890
1.09k
    proto_tree_add_uint(tree, hf_q931_information_transfer_capability, tvb, offset, 1, octet);
891
1.09k
    offset += 1;
892
1.09k
    len -= 1;
893
894
    /*
895
     * XXX - only in Low-layer compatibility information element.
896
     */
897
1.09k
    if (!(octet & Q931_IE_VL_EXTENSION)) {
898
1.06k
        if (len == 0)
899
9
            return;
900
1.05k
        proto_tree_add_item(tree, hf_q931_out_band_negotiation, tvb, offset, 1, ENC_NA);
901
1.05k
        offset += 1;
902
1.05k
        len -= 1;
903
1.05k
    }
904
905
1.08k
    if (len == 0)
906
6
        return;
907
1.08k
    octet = tvb_get_uint8(tvb, offset);
908
1.08k
    proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
909
1.08k
    proto_tree_add_uint(tree, hf_q931_transfer_mode, tvb, offset, 1, octet);
910
1.08k
    proto_tree_add_uint(tree, hf_q931_information_transfer_rate, tvb, offset, 1, octet);
911
1.08k
    it_rate = octet & 0x1F;
912
1.08k
    offset += 1;
913
1.08k
    len -= 1;
914
915
1.08k
    if (it_rate == Q931_IT_RATE_MULTIRATE) {
916
27
        if (len == 0)
917
0
            return;
918
27
        proto_tree_add_item(tree, hf_q931_bearer_capability_rate_multiplier, tvb, offset, 1, ENC_BIG_ENDIAN);
919
27
        offset += 1;
920
27
        len -= 1;
921
27
    }
922
923
1.08k
    if (len == 0)
924
15
        return;
925
1.06k
    octet = tvb_get_uint8(tvb, offset);
926
1.06k
    if ((octet & 0x60) == 0x20) {
927
        /*
928
         * Layer 1 information.
929
         */
930
116
        proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
931
116
        proto_tree_add_uint(tree, hf_q931_layer_ident, tvb, offset, 1, octet);
932
116
        proto_tree_add_uint(tree, hf_q931_uil1, tvb, offset, 1, octet);
933
116
        offset += 1;
934
116
        len -= 1;
935
936
116
        if (octet & Q931_IE_VL_EXTENSION)
937
35
            goto l1_done;
938
81
        if (len == 0)
939
45
            return;
940
36
        octet = tvb_get_uint8(tvb, offset);
941
36
        proto_tree_add_item(tree, hf_q931_layer_1, tvb, offset, 1, ENC_NA);
942
36
        proto_tree_add_item(tree, hf_q931_layer_1_in_band_negotiation, tvb, offset, 1, ENC_NA);
943
36
        proto_tree_add_item(tree, hf_q931_bearer_capability_user_rate, tvb, offset, 1, ENC_BIG_ENDIAN);
944
36
        offset += 1;
945
36
        len -= 1;
946
947
36
        if (octet & Q931_IE_VL_EXTENSION)
948
7
            goto l1_done;
949
29
        if (len == 0)
950
3
            return;
951
26
        octet = tvb_get_uint8(tvb, offset);
952
26
        proto_tree_add_item(tree, hf_q931_bearer_capability_intermediate_rate, tvb, offset, 1, ENC_BIG_ENDIAN);
953
26
        proto_tree_add_item(tree, hf_q931_send_data_net_independent_clock, tvb, offset, 1, ENC_NA);
954
26
        proto_tree_add_item(tree, hf_q931_accept_data_net_independent_clock, tvb, offset, 1, ENC_NA);
955
26
        proto_tree_add_item(tree, hf_q931_send_data_flow_control, tvb, offset, 1, ENC_NA);
956
26
        proto_tree_add_item(tree, hf_q931_accept_data_flow_control, tvb, offset, 1, ENC_NA);
957
26
        offset += 1;
958
26
        len -= 1;
959
960
26
        if (octet & Q931_IE_VL_EXTENSION)
961
4
            goto l1_done;
962
22
        if (len == 0)
963
2
            return;
964
20
        octet = tvb_get_uint8(tvb, offset);
965
20
        proto_tree_add_item(tree, hf_q931_rate_adaption_header, tvb, offset, 1, ENC_NA);
966
20
        proto_tree_add_item(tree, hf_q931_multiple_frame_establishment, tvb, offset, 1, ENC_NA);
967
20
        proto_tree_add_item(tree, hf_q931_mode_of_operation, tvb, offset, 1, ENC_NA);
968
20
        proto_tree_add_item(tree, hf_q931_protocol_negotiation, tvb, offset, 1, ENC_NA);
969
20
        proto_tree_add_item(tree, hf_q931_message_originator, tvb, offset, 1, ENC_NA);
970
20
        proto_tree_add_item(tree, hf_q931_negotiation_is_done, tvb, offset, 1, ENC_NA);
971
20
        offset += 1;
972
20
        len -= 1;
973
974
20
        if (octet & Q931_IE_VL_EXTENSION)
975
4
            goto l1_done;
976
16
        if (len == 0)
977
0
            return;
978
16
        octet = tvb_get_uint8(tvb, offset);
979
16
        proto_tree_add_item(tree, hf_q931_bearer_capability_stop_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
980
16
        proto_tree_add_item(tree, hf_q931_bearer_capability_data_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
981
16
        proto_tree_add_item(tree, hf_q931_bearer_capability_parity, tvb, offset, 1, ENC_BIG_ENDIAN);
982
983
16
        if (octet & Q931_IE_VL_EXTENSION)
984
4
            goto l1_done;
985
12
        proto_tree_add_item(tree, hf_q931_bearer_capability_duplex, tvb, offset, 1, ENC_NA);
986
12
        proto_tree_add_item(tree, hf_q931_bearer_capability_modem_type, tvb, offset, 1, ENC_BIG_ENDIAN);
987
12
        offset += 1;
988
12
        len -= 1;
989
12
    }
990
1.01k
l1_done:
991
1.01k
    ;
992
993
1.01k
    if (len == 0)
994
25
        return;
995
988
    octet = tvb_get_uint8(tvb, offset);
996
988
    if ((octet & 0x60) == 0x40) {
997
        /*
998
         * Layer 2 information.
999
         */
1000
60
        proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1001
60
        proto_tree_add_uint(tree, hf_q931_layer_ident, tvb, offset, 1, octet);
1002
60
        uil2_protocol = octet & 0x1F;
1003
60
        proto_tree_add_item(tree, hf_q931_uil2, tvb, offset, 1, ENC_BIG_ENDIAN);
1004
60
        offset += 1;
1005
60
        len -= 1;
1006
1007
        /*
1008
         * XXX - only in Low-layer compatibility information element.
1009
         */
1010
60
        if (octet & Q931_IE_VL_EXTENSION)
1011
20
            goto l2_done;
1012
40
        if (len == 0)
1013
19
            return;
1014
21
        octet = tvb_get_uint8(tvb, offset);
1015
21
        if (uil2_protocol == Q931_UIL2_USER_SPEC) {
1016
0
            proto_tree_add_item(tree, hf_q931_uil2_info, tvb, offset, 1, ENC_BIG_ENDIAN);
1017
21
        } else {
1018
21
            proto_tree_add_item(tree, hf_q931_bearer_capability_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
1019
21
        }
1020
21
        offset += 1;
1021
21
        len -= 1;
1022
1023
21
        if (octet & Q931_IE_VL_EXTENSION)
1024
1
            goto l2_done;
1025
20
        if (len == 0)
1026
4
            return;
1027
16
        octet = tvb_get_uint8(tvb, offset) & 0x7F;
1028
16
        proto_tree_add_uint_format_value(tree, hf_q931_bearer_capability_window_size, tvb, offset, 1,
1029
16
            octet, "octet & 0x7F%u k", octet);
1030
16
        offset += 1;
1031
16
        len -= 1;
1032
16
    }
1033
965
l2_done:
1034
965
    ;
1035
1036
965
    if (len == 0)
1037
14
        return;
1038
951
    octet = tvb_get_uint8(tvb, offset);
1039
951
    if ((octet & 0x60) == 0x60) {
1040
        /*
1041
         * Layer 3 information.
1042
         */
1043
118
        proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1044
118
        proto_tree_add_uint(tree, hf_q931_layer_ident, tvb, offset, 1, octet);
1045
118
        uil3_protocol = octet & 0x1F;
1046
118
        proto_tree_add_item(tree, hf_q931_uil3, tvb, offset, 1, ENC_BIG_ENDIAN);
1047
118
        offset += 1;
1048
118
        len -= 1;
1049
1050
1051
        /*
1052
         * XXX - only in Low-layer compatibility information element.
1053
         */
1054
118
        if (octet & Q931_IE_VL_EXTENSION)
1055
60
            goto l3_done;
1056
58
        if (len == 0)
1057
38
            return;
1058
20
        octet = tvb_get_uint8(tvb, offset);
1059
20
        switch (uil3_protocol) {
1060
1061
0
        case Q931_UIL3_X25_PL:
1062
3
        case Q931_UIL3_ISO_8208:
1063
4
        case Q931_UIL3_X223:
1064
4
            proto_tree_add_item(tree, hf_q931_bearer_capability_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
1065
4
            offset += 1;
1066
4
            len -= 1;
1067
1068
4
            if (octet & Q931_IE_VL_EXTENSION)
1069
1
                goto l3_done;
1070
3
            if (len == 0)
1071
0
                return;
1072
3
            octet = tvb_get_uint8(tvb, offset);
1073
3
            proto_tree_add_item(tree, hf_q931_bearer_capability_default_packet_size, tvb, offset, 1, ENC_BIG_ENDIAN);
1074
3
            offset += 1;
1075
3
            len -= 1;
1076
1077
3
            if (octet & Q931_IE_VL_EXTENSION)
1078
1
                goto l3_done;
1079
2
            if (len == 0)
1080
0
                return;
1081
2
            proto_tree_add_item(tree, hf_q931_bearer_capability_packet_window_size, tvb, offset, 1, ENC_BIG_ENDIAN);
1082
            /*offset += 1;*/
1083
            /*len -= 1;*/
1084
2
            break;
1085
1086
2
        case Q931_UIL3_USER_SPEC:
1087
2
            proto_tree_add_uint(tree, hf_q931_bearer_capability_default_packet_size, tvb, offset, 1, 1 << (octet & 0x0F));
1088
            /*offset += 1;*/
1089
            /*len -= 1;*/
1090
2
            break;
1091
1092
1
        case Q931_UIL3_TR_9577:
1093
1
            add_l3_info = (octet & 0x0F) << 4;
1094
1
            if (octet & Q931_IE_VL_EXTENSION)
1095
0
                goto l3_done;
1096
1
            if (len < 2)
1097
0
                return;
1098
1
            octet = tvb_get_uint8(tvb, offset + 1);
1099
1
            add_l3_info |= (octet & 0x0F);
1100
1
            proto_tree_add_uint(tree, hf_q931_uil3_additional, tvb, offset, 2, add_l3_info);
1101
            /*offset += 2;*/
1102
            /*len -= 2;*/
1103
1
            break;
1104
20
        }
1105
20
    }
1106
913
l3_done:
1107
913
    ;
1108
913
}
1109
1110
/*
1111
 * Dissect a Cause information element.
1112
 */
1113
1114
1115
static const value_string q931_cause_location_vals[] = {
1116
    { 0x00, "User (U)" },
1117
    { 0x01, "Private network serving the local user (LPN)" },
1118
    { 0x02, "Public network serving the local user (LN)" },
1119
    { 0x03, "Transit network (TN)" },
1120
    { 0x04, "Public network serving the remote user (RLN)" },
1121
    { 0x05, "Private network serving the remote user (RPN)" },
1122
    { 0x06, "Unallocated code" },
1123
    { 0x07, "International network (INTL)" },
1124
    { 0x08, "Unallocated code" },
1125
    { 0x09, "Unallocated code" },
1126
    { 0x0A, "Network beyond interworking point (BI)" },
1127
    { 0,    NULL }
1128
};
1129
value_string_ext q931_cause_location_vals_ext = VALUE_STRING_EXT_INIT(q931_cause_location_vals);
1130
1131
static const value_string q931_cause_recommendation_vals[] = {
1132
    { 0x00, "Q.931" },
1133
    { 0x03, "X.21" },
1134
    { 0x04, "X.25" },
1135
    { 0x05, "Q.1031/Q.1051" },
1136
    { 0,    NULL }
1137
};
1138
1139
/*
1140
 * Cause codes for Cause.
1141
 */
1142
32
#define Q931_CAUSE_UNALLOC_NUMBER   0x01
1143
52
#define Q931_CAUSE_NO_ROUTE_TO_DEST 0x03
1144
1
#define Q931_CAUSE_CALL_REJECTED    0x15
1145
#define Q931_CAUSE_NUMBER_CHANGED   0x16
1146
14
#define Q931_CAUSE_ACCESS_INFO_DISC 0x2B
1147
57
#define Q931_CAUSE_QOS_UNAVAILABLE  0x31
1148
#define Q931_CAUSE_CHAN_NONEXISTENT 0x52
1149
19
#define Q931_CAUSE_INCOMPATIBLE_DEST    0x58
1150
28
#define Q931_CAUSE_MAND_IE_MISSING  0x60
1151
7
#define Q931_CAUSE_MT_NONEX_OR_UNIMPL   0x61
1152
34
#define Q931_CAUSE_IE_NONEX_OR_UNIMPL   0x63
1153
45
#define Q931_CAUSE_INVALID_IE_CONTENTS  0x64
1154
11
#define Q931_CAUSE_MSG_INCOMPAT_W_CS    0x65
1155
2
#define Q931_CAUSE_REC_TIMER_EXP    0x66
1156
1157
static const value_string q931_cause_code_vals[] = {
1158
    { 0x00,                                "Valid cause code not yet received" },
1159
    { Q931_CAUSE_UNALLOC_NUMBER,           "Unallocated (unassigned) number" },
1160
    { 0x02,                                "No route to specified transit network" },
1161
    { Q931_CAUSE_NO_ROUTE_TO_DEST,         "No route to destination" },
1162
    { 0x04,                                "Send special information tone" },
1163
    { 0x05,                                "Misdialled trunk prefix" },
1164
    { 0x06,                                "Channel unacceptable" },
1165
    { 0x07,                                "Call awarded and being delivered in an established channel" },
1166
    { 0x08,                                "Prefix 0 dialed but not allowed" },
1167
                    /* Q.850 -             "Preemption" */
1168
    { 0x09,                                "Prefix 1 dialed but not allowed" },
1169
                    /* Q.850 -             "Preemption - circuit reserved for reuse" */
1170
    { 0x0A,                                "Prefix 1 dialed but not required" },
1171
    { 0x0B,                                "More digits received than allowed, call is proceeding" },
1172
    { 0x0E,                                "QoR: ported number" },
1173
    { 0x10,                                "Normal call clearing" },
1174
    { 0x11,                                "User busy" },
1175
    { 0x12,                                "No user responding" },
1176
    { 0x13,                                "No answer from user (user alerted)" },
1177
    { 0x14,                                "Subscriber absent" },
1178
    { Q931_CAUSE_CALL_REJECTED,            "Call rejected" },
1179
    { Q931_CAUSE_NUMBER_CHANGED,           "Number changed" },
1180
    { 0x17,                                "Reverse charging rejected" },
1181
                    /* Q.850 -             "Redirection to new destination" */
1182
    { 0x18,                                "Call suspended" },
1183
                    /* Q.850 Amendment 1 - "Call rejected due to feature at the destination" */
1184
    { 0x19,                                "Call resumed" },
1185
                    /* Q.850 -             "Exchange routing error */
1186
    { 0x1A,                                "Non-selected user clearing" },
1187
    { 0x1B,                                "Destination out of order" },
1188
    { 0x1C,                                "Invalid number format (incomplete number)" },
1189
    { 0x1D,                                "Facility rejected" },
1190
    { 0x1E,                                "Response to STATUS ENQUIRY" },
1191
    { 0x1F,                                "Normal unspecified" },
1192
    { 0x21,                                "Circuit out of order" },
1193
    { 0x22,                                "No circuit/channel available" },
1194
    { 0x23,                                "Destination unattainable" },
1195
    { 0x25,                                "Degraded service" },
1196
    { 0x26,                                "Network out of order" },
1197
    { 0x27,                                "Transit delay range cannot be achieved" },
1198
                    /* Q.850 -             "Permanent frame mode connection out of service" */
1199
    { 0x28,                                "Throughput range cannot be achieved" },
1200
                    /* Q.850 -             "Permanent frame mode connection operational" */
1201
    { 0x29,                                "Temporary failure" },
1202
    { 0x2A,                                "Switching equipment congestion" },
1203
    { Q931_CAUSE_ACCESS_INFO_DISC,         "Access information discarded" },
1204
    { 0x2C,                                "Requested circuit/channel not available" },
1205
    { 0x2D,                                "Pre-empted" },
1206
    { 0x2E,                                "Precedence call blocked" },
1207
    { 0x2F,                                "Resources unavailable, unspecified" },
1208
    { Q931_CAUSE_QOS_UNAVAILABLE,          "Quality of service unavailable" },
1209
    { 0x32,                                "Requested facility not subscribed" },
1210
    { 0x33,                                "Reverse charging not allowed" },
1211
    { 0x34,                                "Outgoing calls barred" },
1212
    { 0x35,                                "Outgoing calls barred within CUG" },
1213
    { 0x36,                                "Incoming calls barred" },
1214
    { 0x37,                                "Incoming calls barred within CUG" },
1215
    { 0x38,                                "Call waiting not subscribed" },
1216
    { 0x39,                                "Bearer capability not authorized" },
1217
    { 0x3A,                                "Bearer capability not presently available" },
1218
    { 0x3E,                                "Inconsistency in designated outgoing access information and subscriber class" },
1219
    { 0x3F,                                "Service or option not available, unspecified" },
1220
    { 0x41,                                "Bearer capability not implemented" },
1221
    { 0x42,                                "Channel type not implemented" },
1222
    { 0x43,                                "Transit network selection not implemented" },
1223
    { 0x44,                                "Message not implemented" },
1224
    { 0x45,                                "Requested facility not implemented" },
1225
    { 0x46,                                "Only restricted digital information bearer capability is available" },
1226
    { 0x4F,                                "Service or option not implemented, unspecified" },
1227
    { 0x51,                                "Invalid call reference value" },
1228
    { Q931_CAUSE_CHAN_NONEXISTENT,         "Identified channel does not exist" },
1229
    { 0x53,                                "Call identity does not exist for suspended call" },
1230
    { 0x54,                                "Call identity in use" },
1231
    { 0x55,                                "No call suspended" },
1232
    { 0x56,                                "Call having the requested call identity has been cleared" },
1233
    { 0x57,                                "Called user not member of CUG" },
1234
    { Q931_CAUSE_INCOMPATIBLE_DEST,        "Incompatible destination" },
1235
    { 0x59,                                "Non-existent abbreviated address entry" },
1236
    { 0x5A,                                "Destination address missing, and direct call not subscribed" },
1237
                                           /* Q.850 -             "Non-existent CUG" */
1238
    { 0x5B,                                "Invalid transit network selection (national use)" },
1239
    { 0x5C,                                "Invalid facility parameter" },
1240
    { 0x5D,                                "Mandatory information element is missing" },
1241
    { 0x5F,                                "Invalid message, unspecified" },
1242
    { Q931_CAUSE_MAND_IE_MISSING,          "Mandatory information element is missing" },
1243
    { Q931_CAUSE_MT_NONEX_OR_UNIMPL,       "Message type non-existent or not implemented" },
1244
    { 0x62,                                "Message not compatible with call state or message type non-existent or not implemented" },
1245
    { Q931_CAUSE_IE_NONEX_OR_UNIMPL,       "Information element non-existent or not implemented" },
1246
    { Q931_CAUSE_INVALID_IE_CONTENTS,      "Invalid information element contents" },
1247
    { Q931_CAUSE_MSG_INCOMPAT_W_CS,        "Message not compatible with call state" },
1248
    { Q931_CAUSE_REC_TIMER_EXP,            "Recovery on timer expiry" },
1249
    { 0x67,                                "Parameter non-existent or not implemented - passed on" },
1250
    { 0x6E,                                "Message with unrecognized parameter discarded" },
1251
    { 0x6F,                                "Protocol error, unspecified" },
1252
    { 0x7F,                                "Internetworking, unspecified" },
1253
    { 0,                                   NULL }
1254
};
1255
value_string_ext q931_cause_code_vals_ext = VALUE_STRING_EXT_INIT(q931_cause_code_vals);
1256
1257
static const value_string q931_cause_condition_vals[] = {
1258
    { 0x00, "Unknown" },
1259
    { 0x01, "Permanent" },
1260
    { 0x02, "Transient" },
1261
    { 0x00, NULL }
1262
};
1263
1264
0
#define Q931_REJ_USER_SPECIFIC   0x00
1265
0
#define Q931_REJ_IE_MISSING      0x04
1266
0
#define Q931_REJ_IE_INSUFFICIENT 0x08
1267
1268
static const value_string q931_rejection_reason_vals[] = {
1269
    { 0x00, "User specific" },
1270
    { 0x04, "Information element missing" },
1271
    { 0x08, "Information element contents are not sufficient" },
1272
    { 0x00, NULL }
1273
};
1274
1275
1.02k
static const char *get_message_name(wmem_allocator_t* scope, uint8_t prot_discr, uint8_t message_type) {
1276
1.02k
    if (prot_discr == NLPID_DMS)
1277
48
        return val_to_str(scope, message_type, dms_message_type_vals, "Unknown (0x%02X)");
1278
975
    else
1279
975
        return val_to_str_ext(scope, message_type, &q931_message_type_vals_ext, "Unknown (0x%02X)");
1280
1.02k
}
1281
1282
static const true_false_string tfs_abnormal_normal = { "Abnormal", "Normal" };
1283
1284
static void
1285
dissect_q931_cause_ie_with_info(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
1286
    proto_tree *tree, int hf_cause_value, uint8_t *cause_value, const value_string *ie_vals,
1287
    q931_packet_info *q931_pi)
1288
1.01k
{
1289
1.01k
    uint8_t octet;
1290
1.01k
    uint8_t coding_standard;
1291
1.01k
    uint8_t rejection_reason;
1292
1293
1.01k
    if (len == 0)
1294
32
        return;
1295
982
    octet = tvb_get_uint8(tvb, offset);
1296
982
    coding_standard = octet & 0x60;
1297
982
    if (coding_standard != Q931_ITU_STANDARDIZED_CODING &&
1298
150
        !g931_iso_iec_cause && coding_standard != Q931_ISO_IEC_STANDARDIZED_CODING) {
1299
        /*
1300
         * We don't know how the cause is encoded,
1301
         * so just dump it as data and be done with it.
1302
         */
1303
71
        proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1304
71
        proto_tree_add_item(tree, hf_q931_cause_data, tvb, offset, len, ENC_NA);
1305
71
        return;
1306
71
    }
1307
911
    proto_tree_add_uint(tree, hf_q931_cause_location, tvb, offset, 1, octet);
1308
911
    proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1309
911
    proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1310
911
    offset += 1;
1311
911
    len -= 1;
1312
1313
911
    if (!(octet & Q931_IE_VL_EXTENSION)) {
1314
855
        if (len == 0)
1315
9
            return;
1316
846
        octet = tvb_get_uint8(tvb, offset);
1317
846
        proto_tree_add_item(tree, hf_q931_cause_recommendation, tvb, offset, 1, ENC_BIG_ENDIAN);
1318
846
        proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1319
846
        offset += 1;
1320
846
        len -= 1;
1321
846
    }
1322
1323
902
    if (len == 0)
1324
16
        return;
1325
886
    octet = tvb_get_uint8(tvb, offset);
1326
886
    *cause_value = octet & 0x7F;
1327
1328
    /* add cause value to packet info for use in tap */
1329
886
    if (q931_pi) {
1330
799
        q931_pi->cause_value = *cause_value;
1331
799
    }
1332
1333
886
    proto_tree_add_uint(tree, hf_cause_value, tvb, offset, 1, *cause_value);
1334
886
    proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
1335
886
    offset += 1;
1336
886
    len -= 1;
1337
1338
886
    if (len == 0)
1339
4
        return;
1340
882
    switch (*cause_value) {
1341
32
    case Q931_CAUSE_UNALLOC_NUMBER:
1342
52
    case Q931_CAUSE_NO_ROUTE_TO_DEST:
1343
57
    case Q931_CAUSE_QOS_UNAVAILABLE:
1344
57
        proto_tree_add_item(tree, hf_q931_network_service, tvb, offset, 1, ENC_NA);
1345
57
        proto_tree_add_item(tree, hf_q931_extension_condition_type, tvb, offset, 1, ENC_NA);
1346
57
        proto_tree_add_item(tree, hf_q931_extension_condition, tvb, offset, 1, ENC_BIG_ENDIAN);
1347
57
        break;
1348
1349
1
    case Q931_CAUSE_CALL_REJECTED:
1350
1
        rejection_reason = octet & 0x7C;
1351
1
        proto_tree_add_item(tree, hf_q931_cause_call_rejection_reason, tvb, offset, 1, ENC_BIG_ENDIAN);
1352
1
        proto_tree_add_item(tree, hf_q931_cause_call_condition, tvb, offset, 1, ENC_BIG_ENDIAN);
1353
1
        offset += 1;
1354
1
        len -= 1;
1355
1356
1
        if (len == 0)
1357
0
            return;
1358
1
        switch (rejection_reason) {
1359
1360
0
        case Q931_REJ_USER_SPECIFIC:
1361
0
            proto_tree_add_item(tree, hf_q931_cause_call_user_specific_diagnostic, tvb, offset, len, ENC_NA);
1362
0
            break;
1363
1364
0
        case Q931_REJ_IE_MISSING:
1365
0
            proto_tree_add_uint_format_value(tree, hf_q931_missing_info_element, tvb, offset, 1,
1366
0
                 tvb_get_uint8(tvb, offset), "%s", val_to_str(pinfo->pool,tvb_get_uint8(tvb, offset), ie_vals,
1367
0
                  "Unknown (0x%02X)"));
1368
0
            break;
1369
1370
0
        case Q931_REJ_IE_INSUFFICIENT:
1371
0
            proto_tree_add_uint_format_value(tree, hf_q931_insufficient_info_element, tvb, offset, 1,
1372
0
                tvb_get_uint8(tvb, offset), "%s", val_to_str(pinfo->pool,tvb_get_uint8(tvb, offset), ie_vals,
1373
0
                  "Unknown (0x%02X)"));
1374
0
            break;
1375
1376
1
        default:
1377
1
            proto_tree_add_item(tree, hf_q931_cause_call_diagnostic, tvb, offset, len, ENC_NA);
1378
1
            break;
1379
1
        }
1380
1
        break;
1381
1382
14
    case Q931_CAUSE_ACCESS_INFO_DISC:
1383
19
    case Q931_CAUSE_INCOMPATIBLE_DEST:
1384
28
    case Q931_CAUSE_MAND_IE_MISSING:
1385
34
    case Q931_CAUSE_IE_NONEX_OR_UNIMPL:
1386
45
    case Q931_CAUSE_INVALID_IE_CONTENTS:
1387
1.36k
        do {
1388
1.36k
            proto_tree_add_uint_format_value(tree, hf_q931_information_element, tvb, offset, 1,
1389
1.36k
                tvb_get_uint8(tvb, offset), "%s", val_to_str(pinfo->pool,tvb_get_uint8(tvb, offset), ie_vals,
1390
1.36k
                  "Unknown (0x%02X)"));
1391
1.36k
            offset += 1;
1392
1.36k
            len -= 1;
1393
1.36k
        } while (len != 0);
1394
45
        break;
1395
1396
7
    case Q931_CAUSE_MT_NONEX_OR_UNIMPL:
1397
11
    case Q931_CAUSE_MSG_INCOMPAT_W_CS:
1398
11
        proto_tree_add_item(tree, hf_q931_cause_call_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1399
11
        break;
1400
1401
2
    case Q931_CAUSE_REC_TIMER_EXP:
1402
2
        if (len < 3)
1403
0
            return;
1404
2
        proto_tree_add_item(tree, hf_q931_cause_call_rec_timer, tvb, offset, 3, ENC_ASCII);
1405
2
        break;
1406
1407
757
    default:
1408
757
        proto_tree_add_item(tree, hf_q931_cause_call_diagnostic, tvb, offset, len, ENC_NA);
1409
882
    }
1410
882
}
1411
1412
void
1413
dissect_q931_cause_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
1414
              proto_tree *tree, int hf_cause_value, uint8_t *cause_value, const value_string *ie_vals)
1415
99
{
1416
    /* External dissectors have no use for "q931_packet_info". */
1417
99
    dissect_q931_cause_ie_with_info(tvb, pinfo, offset, len, tree, hf_cause_value, cause_value, ie_vals, NULL);
1418
99
}
1419
1420
/*
1421
 * Dissect a Change status information element.
1422
 */
1423
1424
static const value_string q931_status_preference_vals[] = {
1425
    { 0x01, "Channel" },
1426
    { 0,    NULL }
1427
};
1428
1429
static const value_string q931_new_status_vals[] = {
1430
    { 0x00, "In Service" },
1431
    { 0x01, "Maintenance" },
1432
    { 0x02, "Out of Service" },
1433
    { 0,    NULL }
1434
};
1435
1436
static void
1437
dissect_q931_change_status_ie(tvbuff_t *tvb, int offset, int len _U_, proto_tree *tree)
1438
989
{
1439
989
    if (len == 0)
1440
54
        return;
1441
1442
935
    proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
1443
935
    proto_tree_add_item(tree, hf_q931_extension_ind_preference, tvb, offset, 1, ENC_BIG_ENDIAN);
1444
935
    proto_tree_add_item(tree, hf_q931_extension_ind_new_status, tvb, offset, 1, ENC_BIG_ENDIAN);
1445
935
}
1446
1447
/*
1448
 * Dissect a Call state information element.
1449
 */
1450
static const value_string q931_call_state_vals[] = {
1451
    { 0x00, "Null" },
1452
    { 0x01, "Call initiated" },
1453
    { 0x02, "Overlap sending" },
1454
    { 0x03, "Outgoing call proceeding" },
1455
    { 0x04, "Call delivered" },
1456
    { 0x06, "Call present" },
1457
    { 0x07, "Call received" },
1458
    { 0x08, "Connect request" },
1459
    { 0x09, "Incoming call proceeding" },
1460
    { 0x0A, "Active" },
1461
    { 0x0B, "Disconnect request" },
1462
    { 0x0C, "Disconnect indication" },
1463
    { 0x0F, "Suspend request" },
1464
    { 0x11, "Resume request" },
1465
    { 0x13, "Release request" },
1466
    { 0x16, "Call abort"},
1467
    { 0x19, "Overlap receiving" },
1468
    { 0x3D, "Restart request" },
1469
    { 0x3E, "Restart" },
1470
    { 0,    NULL }
1471
};
1472
value_string_ext q931_call_state_vals_ext = VALUE_STRING_EXT_INIT(q931_call_state_vals);
1473
1474
static void
1475
dissect_q931_call_state_ie(tvbuff_t *tvb, int offset, int len,
1476
    proto_tree *tree)
1477
82
{
1478
82
    uint8_t octet;
1479
82
    uint8_t coding_standard;
1480
1481
82
    if (len == 0)
1482
13
        return;
1483
69
    octet = tvb_get_uint8(tvb, offset);
1484
69
    coding_standard = octet & 0x60;
1485
69
    proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1486
69
    if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1487
        /*
1488
         * We don't know how the call state is encoded,
1489
         * so just dump it as data and be done with it.
1490
         */
1491
15
        proto_tree_add_item(tree, hf_q931_call_state_data, tvb, offset, len, ENC_NA);
1492
15
        return;
1493
15
    }
1494
54
    proto_tree_add_item(tree, hf_q931_call_state, tvb, offset, 1, ENC_BIG_ENDIAN);
1495
54
}
1496
1497
/*
1498
 * Dissect a Channel identification information element.
1499
 */
1500
147
#define Q931_INTERFACE_IDENTIFIED   0x40
1501
294
#define Q931_NOT_BASIC_CHANNEL      0x20
1502
1503
static const value_string q931_basic_channel_selection_vals[] = {
1504
    { 0x00, "No channel" },
1505
    { 0x01, "B1 channel" },
1506
    { 0x02, "B2 channel" },
1507
    { 0x03, "Any channel" },
1508
    { 0,    NULL }
1509
};
1510
1511
static const value_string q931_not_basic_channel_selection_vals[] = {
1512
    { 0x00, "No channel" },
1513
    { 0x01, "Channel indicated in following octets" },
1514
    { 0x03, "Any channel" },
1515
    { 0,    NULL }
1516
};
1517
1518
37
#define Q931_IS_SLOT_MAP        0x10
1519
1520
static const value_string q931_element_type_vals[] = {
1521
    { 0x03, "B-channel units" },
1522
    { 0x06, "H0-channel units" },
1523
    { 0x08, "H11-channel units" },
1524
    { 0x09, "H12-channel units" },
1525
    { 0,    NULL }
1526
};
1527
1528
static void
1529
dissect_q931_channel_identification_ie(tvbuff_t *tvb, int offset, int len,
1530
    proto_tree *tree)
1531
150
{
1532
150
    uint8_t octet;
1533
150
    uint8_t coding_standard;
1534
1535
150
    if (len == 0)
1536
3
        return;
1537
147
    octet = tvb_get_uint8(tvb, offset);
1538
1539
147
    proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
1540
147
    proto_tree_add_item(tree, hf_q931_channel_interface_explicit, tvb, offset, 1, ENC_BIG_ENDIAN);
1541
147
    proto_tree_add_item(tree, hf_q931_channel_interface_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1542
147
    proto_tree_add_item(tree, hf_q931_channel_exclusive, tvb, offset, 1, ENC_BIG_ENDIAN);
1543
147
    proto_tree_add_item(tree, hf_q931_channel_dchan, tvb, offset, 1, ENC_BIG_ENDIAN);
1544
1545
147
    if (octet & Q931_NOT_BASIC_CHANNEL) {
1546
69
        proto_tree_add_item(tree, hf_q931_channel_selection_pri, tvb, offset, 1, ENC_BIG_ENDIAN);
1547
78
    } else {
1548
78
        proto_tree_add_item(tree, hf_q931_channel_selection_bri, tvb, offset, 1, ENC_BIG_ENDIAN);
1549
78
    }
1550
147
    offset += 1;
1551
147
    len -= 1;
1552
1553
147
    if (octet & Q931_INTERFACE_IDENTIFIED) {
1554
59
        uint8_t octet2;
1555
59
        uint32_t identifier_val = 0;
1556
59
        int identifier_offset = offset;
1557
59
        int identifier_len = 0;
1558
630
        do {
1559
630
            if (len == 0)
1560
16
                break;
1561
614
            octet2 = tvb_get_uint8(tvb, offset);
1562
614
            offset += 1;
1563
614
            len -= 1;
1564
614
            identifier_len++;
1565
614
            identifier_val <<= 7;
1566
614
            identifier_val |= octet2 & 0x7F;
1567
614
        } while (!(octet2 & Q931_IE_VL_EXTENSION));
1568
1569
59
        if (identifier_len != 0) {
1570
50
            proto_tree_add_uint(tree, hf_q931_channel_interface_id, tvb, identifier_offset,
1571
50
                identifier_len, identifier_val);
1572
50
        }
1573
59
    }
1574
1575
147
    if (octet & Q931_NOT_BASIC_CHANNEL) {
1576
66
        if (len == 0)
1577
12
            return;
1578
54
        octet = tvb_get_uint8(tvb, offset);
1579
54
        coding_standard = octet & 0x60;
1580
54
        proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
1581
54
        proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1582
54
        if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1583
            /*
1584
             * We don't know how the channel identifier is
1585
             * encoded, so just dump it as data and be done
1586
             * with it.
1587
             */
1588
17
            proto_tree_add_item(tree, hf_q931_channel_data, tvb, offset, len, ENC_NA);
1589
17
            return;
1590
17
        }
1591
37
        proto_tree_add_item(tree, hf_q931_channel_map, tvb, offset, 1, ENC_BIG_ENDIAN);
1592
37
        proto_tree_add_item(tree, hf_q931_channel_element_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1593
1594
37
        offset += 1;
1595
37
        len -= 1;
1596
1597
37
        if (octet & Q931_IS_SLOT_MAP) {
1598
649
            while (len) {
1599
634
                proto_tree_add_item(tree, hf_q931_channel_slot_map, tvb, offset, 1, ENC_BIG_ENDIAN);
1600
634
                offset += 1;
1601
634
                len -= 1;
1602
634
            }
1603
22
        } else {
1604
22
            uint8_t octet2;
1605
151
            do {
1606
151
                if (len == 0)
1607
2
                    break;
1608
149
                octet2 = tvb_get_uint8(tvb, offset);
1609
1610
149
                proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
1611
149
                proto_tree_add_item(tree,hf_q931_channel_number,tvb,offset,1,ENC_BIG_ENDIAN);
1612
1613
149
                offset += 1;
1614
149
                len -= 1;
1615
149
            } while (!(octet2 & Q931_IE_VL_EXTENSION));
1616
22
        }
1617
37
    }
1618
147
}
1619
1620
/*
1621
 * Dissect a Progress indicator information element.
1622
 */
1623
static const value_string q931_progress_description_vals[] = {
1624
    { 0x01, "Call is not end-to-end ISDN - progress information available in-band" },
1625
    { 0x02, "Destination address is non-ISDN" },
1626
    { 0x03, "Origination address is non-ISDN" },
1627
    { 0x04, "Call has returned to the ISDN" },
1628
    { 0x05, "Interworking has occurred and has resulted in a telecommunications service change" },
1629
    { 0x08, "In-band information or an appropriate pattern is now available" },
1630
    { 0,    NULL }
1631
};
1632
value_string_ext q931_progress_description_vals_ext = VALUE_STRING_EXT_INIT(q931_progress_description_vals);
1633
1634
void
1635
dissect_q931_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
1636
    proto_tree *tree)
1637
97
{
1638
97
    uint8_t octet;
1639
97
    uint8_t coding_standard;
1640
1641
97
    if (len == 0)
1642
7
        return;
1643
90
    octet = tvb_get_uint8(tvb, offset);
1644
90
    coding_standard = octet & 0x60;
1645
90
    proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
1646
90
    if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
1647
        /*
1648
         * We don't know how the progress indicator is encoded,
1649
         * so just dump it as data and be done with it.
1650
         */
1651
12
        proto_tree_add_item(tree, hf_q931_progress_indicator_data, tvb, offset, len, ENC_NA);
1652
12
        return;
1653
12
    }
1654
78
    proto_tree_add_item(tree, hf_q931_progress_indicator_location, tvb, offset, 1, ENC_BIG_ENDIAN);
1655
78
    offset += 1;
1656
78
    len -= 1;
1657
1658
78
    if (len == 0)
1659
3
        return;
1660
1661
75
    proto_tree_add_item(tree, hf_q931_progress_indicator_description, tvb, offset, 1, ENC_BIG_ENDIAN);
1662
75
}
1663
1664
/*
1665
 * Dissect a Network-specific facilities or Transit network selection
1666
 * information element.
1667
 */
1668
static const value_string q931_netid_type_vals[] = {
1669
    { 0x0,  "User specified" },
1670
    { 0x2,  "National network identification" },
1671
    { 0x3,  "International network identification" },
1672
    { 0,    NULL }
1673
};
1674
1675
static const value_string q931_netid_plan_vals[] = {
1676
    { 0x00, "Unknown" },
1677
    { 0x01, "Carrier Identification Code" },
1678
    { 0x03, "X.121 data network identification code" },
1679
    { 0,    NULL }
1680
};
1681
1682
static void
1683
dissect_q931_ns_facilities_ie(tvbuff_t *tvb, int offset, int len,
1684
    proto_tree *tree)
1685
145
{
1686
145
    uint8_t octet;
1687
145
    int netid_len;
1688
1689
145
    if (len == 0)
1690
30
        return;
1691
115
    octet = tvb_get_uint8(tvb, offset);
1692
115
    netid_len = octet & 0x7F;
1693
115
    proto_tree_add_item(tree, hf_q931_netid_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1694
115
    offset += 1;
1695
115
    len -= 1;
1696
115
    if (netid_len != 0) {
1697
105
        if (len == 0)
1698
3
            return;
1699
102
        proto_tree_add_item(tree, hf_q931_netid_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1700
102
        proto_tree_add_item(tree, hf_q931_netid_plan, tvb, offset, 1, ENC_BIG_ENDIAN);
1701
102
        offset += 1;
1702
102
        len -= 1;
1703
102
        netid_len--;
1704
1705
102
        if (len == 0)
1706
6
            return;
1707
96
        if (netid_len > len)
1708
75
            netid_len = len;
1709
96
        if (netid_len != 0) {
1710
91
            proto_tree_add_item(tree, hf_q931_netid, tvb, offset, netid_len, ENC_ASCII);
1711
91
            offset += netid_len;
1712
91
            len -= netid_len;
1713
91
        }
1714
96
    }
1715
1716
    /*
1717
     * Whatever is left is the network-specific facility
1718
     * specification.
1719
     */
1720
106
    if (len == 0)
1721
68
        return;
1722
38
    proto_tree_add_item(tree, hf_q931_netid_facility_specification, tvb, offset, len, ENC_NA);
1723
38
}
1724
1725
/*
1726
 * Dissect a Notification indicator information element.
1727
 */
1728
static const value_string q931_notification_description_vals[] = {
1729
    { 0x00, "User suspended" },
1730
    { 0x01, "User resumed" },
1731
    { 0x02, "Bearer service change" },
1732
    { 0,    NULL }
1733
};
1734
1735
static void
1736
dissect_q931_notification_indicator_ie(tvbuff_t *tvb, int offset, int len,
1737
    proto_tree *tree)
1738
0
{
1739
0
    if (len == 0)
1740
0
        return;
1741
1742
0
    proto_tree_add_item(tree, hf_q931_notification_description, tvb, offset, 1, ENC_BIG_ENDIAN);
1743
0
}
1744
1745
/*
1746
 * Dissect a Date/time information element.
1747
 */
1748
static void
1749
dissect_q931_date_time_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
1750
    proto_tree *tree)
1751
36
{
1752
36
    if (len == 6) {
1753
        /*
1754
         * XXX - what is "year" relative to?  Is "month" 0-origin or
1755
         * 1-origin?  Q.931 doesn't say....
1756
         */
1757
1
        proto_tree_add_bytes_format_value(tree, hf_q931_date_time, tvb, offset, 6, NULL, "%02u-%02u-%02u %02u:%02u:%02u",
1758
1
            tvb_get_uint8(tvb, offset + 0), tvb_get_uint8(tvb, offset + 1), tvb_get_uint8(tvb, offset + 2),
1759
1
            tvb_get_uint8(tvb, offset + 3), tvb_get_uint8(tvb, offset + 4), tvb_get_uint8(tvb, offset + 5));
1760
35
    } else if (len == 5) {
1761
3
        proto_tree_add_bytes_format_value(tree, hf_q931_date_time, tvb, offset, 5, NULL, "%02u-%02u-%02u %02u:%02u:00",
1762
3
            tvb_get_uint8(tvb, offset + 0), tvb_get_uint8(tvb, offset + 1), tvb_get_uint8(tvb, offset + 2),
1763
3
            tvb_get_uint8(tvb, offset + 3), tvb_get_uint8(tvb, offset + 4));
1764
32
    } else {
1765
32
        proto_tree_add_expert_format(tree, pinfo, &ei_q931_date_time, tvb, offset, len, "Date/time: length is %d, should be 5 or 6", len);
1766
32
    }
1767
36
}
1768
1769
/*
1770
 * Dissect a Signal information element.
1771
 */
1772
static const value_string q931_signal_vals[] = {
1773
    { 0x00, "Dial tone on" },
1774
    { 0x01, "Ring tone on" },
1775
    { 0x02, "Intercept tone on" },
1776
    { 0x03, "Network congestion tone on" }, /* "fast busy" */
1777
    { 0x04, "Busy tone on" },
1778
    { 0x05, "Confirm tone on" },
1779
    { 0x06, "Answer tone on" },
1780
    { 0x07, "Call waiting tone on" },
1781
    { 0x08, "Off-hook warning tone on" },
1782
    { 0x09, "Preemption tone on" },
1783
    { 0x3F, "Tones off" },
1784
    { 0x40, "Alerting on - pattern 0" },
1785
    { 0x41, "Alerting on - pattern 1" },
1786
    { 0x42, "Alerting on - pattern 2" },
1787
    { 0x43, "Alerting on - pattern 3" },
1788
    { 0x44, "Alerting on - pattern 4" },
1789
    { 0x45, "Alerting on - pattern 5" },
1790
    { 0x46, "Alerting on - pattern 6" },
1791
    { 0x47, "Alerting on - pattern 7" },
1792
    { 0x4F, "Alerting off" },
1793
    { 0,    NULL }
1794
};
1795
static value_string_ext q931_signal_vals_ext = VALUE_STRING_EXT_INIT(q931_signal_vals);
1796
1797
static void
1798
dissect_q931_signal_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1799
    proto_tree *tree, proto_item* item)
1800
27
{
1801
27
    if (len != 1) {
1802
21
        expert_add_info_format(pinfo, item, &ei_q931_invalid_length,
1803
21
            "Signal: length is %d, should be 1", len);
1804
21
        return;
1805
21
    }
1806
6
    proto_tree_add_item(tree, hf_q931_signal, tvb, offset, 1, ENC_BIG_ENDIAN);
1807
6
}
1808
1809
/*
1810
 * Dissect an Information rate information element.
1811
 */
1812
static const value_string q931_throughput_class_vals[] = {
1813
    { 0x03, "75 bit/s" },
1814
    { 0x04, "150 bit/s" },
1815
    { 0x05, "300 bit/s" },
1816
    { 0x06, "600 bit/s" },
1817
    { 0x07, "1200 bit/s" },
1818
    { 0x08, "2400 bit/s" },
1819
    { 0x09, "4800 bit/s" },
1820
    { 0x0A, "9600 bit/s" },
1821
    { 0x0B, "19200 bit/s" },
1822
    { 0x0C, "48000 bit/s" },
1823
    { 0x0D, "64000 bit/s" },
1824
    { 0,    NULL }
1825
};
1826
static value_string_ext q931_throughput_class_vals_ext = VALUE_STRING_EXT_INIT(q931_throughput_class_vals);
1827
1828
static void
1829
dissect_q931_information_rate_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1830
    proto_tree *tree, proto_item* item)
1831
57
{
1832
57
    if (len != 4) {
1833
53
        expert_add_info_format(pinfo, item, &ei_q931_invalid_length,
1834
53
            "Information rate: length is %d, should be 4", len);
1835
53
        return;
1836
53
    }
1837
4
    proto_tree_add_item(tree, hf_q931_information_rate_incoming, tvb, offset + 0, 1, ENC_BIG_ENDIAN);
1838
4
    proto_tree_add_item(tree, hf_q931_information_rate_outgoing, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
1839
4
    proto_tree_add_item(tree, hf_q931_information_rate_minimum_incoming, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
1840
4
    proto_tree_add_item(tree, hf_q931_information_rate_minimum_outgoing, tvb, offset + 3, 1, ENC_BIG_ENDIAN);
1841
4
}
1842
1843
static int
1844
dissect_q931_uint16_value(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1845
    proto_tree *tree, proto_item* item, int hf_value)
1846
109
{
1847
109
    uint8_t octet;
1848
109
    uint16_t value;
1849
109
    int value_len;
1850
1851
109
    value_len = 0;
1852
1853
109
    octet = tvb_get_uint8(tvb, offset);
1854
109
    if (octet & Q931_IE_VL_EXTENSION) {
1855
        /*
1856
         * Only one octet long - error.
1857
         */
1858
20
        goto bad_length;
1859
20
    }
1860
89
    value = (octet & 0x3) << 14;
1861
89
    offset += 1;
1862
89
    len -= 1;
1863
89
    value_len++;
1864
1865
89
    if (len == 0) {
1866
        /*
1867
         * We've reached the end of the information element - error.
1868
         */
1869
2
        goto past_end;
1870
2
    }
1871
87
    octet = tvb_get_uint8(tvb, offset);
1872
87
    if (octet & Q931_IE_VL_EXTENSION) {
1873
        /*
1874
         * Only two octets long - error.
1875
         */
1876
11
        goto bad_length;
1877
11
    }
1878
76
    value |= (octet & 0x7F) << 7;
1879
76
    offset += 1;
1880
76
    len -= 1;
1881
76
    value_len++;
1882
1883
76
    if (len == 0) {
1884
        /*
1885
         * We've reached the end of the information element - error.
1886
         */
1887
4
        goto past_end;
1888
4
    }
1889
72
    octet = tvb_get_uint8(tvb, offset);
1890
72
    if (!(octet & Q931_IE_VL_EXTENSION)) {
1891
        /*
1892
         * More than three octets long - error.
1893
         */
1894
42
        goto bad_length;
1895
42
    }
1896
30
    value |= (octet & 0x7F);
1897
30
    offset += 1;
1898
    /*len -= 1;*/
1899
30
    value_len++;
1900
1901
30
    proto_tree_add_uint(tree, hf_value, tvb, offset, value_len, value);
1902
30
    return value_len;
1903
1904
6
past_end:
1905
6
    expert_add_info_format(pinfo, item, &ei_q931_invalid_length,
1906
6
        "%s goes past end of information element", proto_registrar_get_name(hf_value));
1907
6
    return -1;
1908
1909
73
bad_length:
1910
73
    expert_add_info_format(pinfo, item, &ei_q931_invalid_length, "%s isn't 3 octets long",
1911
73
        proto_registrar_get_name(hf_value));
1912
73
    return -1;
1913
72
}
1914
1915
/*
1916
 * Dissect an End-to-end transit delay information element.
1917
 */
1918
static void
1919
dissect_q931_e2e_transit_delay_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1920
    proto_tree *tree, proto_item* item)
1921
58
{
1922
58
    int value_len;
1923
1924
58
    if (len == 0)
1925
4
        return;
1926
54
    value_len = dissect_q931_uint16_value(tvb, pinfo, offset, len, tree, item, hf_q931_cumulative_transit_delay);
1927
54
    if (value_len < 0)
1928
43
        return; /* error */
1929
11
    offset += value_len;
1930
11
    len -= value_len;
1931
1932
11
    if (len == 0)
1933
1
        return;
1934
10
    value_len = dissect_q931_uint16_value(tvb, pinfo, offset, len, tree, item, hf_q931_requested_end_to_end_transit_delay);
1935
10
    if (value_len < 0)
1936
9
        return; /* error */
1937
1
    offset += value_len;
1938
1
    len -= value_len;
1939
1940
1
    if (len == 0)
1941
0
        return;
1942
1
    dissect_q931_uint16_value(tvb, pinfo, offset, len, tree, item, hf_q931_maximum_end_to_end_transit_delay);
1943
1
}
1944
1945
/*
1946
 * Dissect a Transit delay selection and indication information element.
1947
 */
1948
static void
1949
dissect_q931_td_selection_and_int_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
1950
    proto_tree *tree, proto_item* item)
1951
48
{
1952
48
    if (len == 0)
1953
4
        return;
1954
44
    dissect_q931_uint16_value(tvb, pinfo, offset, len, tree, item, hf_q931_transit_delay);
1955
44
}
1956
1957
/*
1958
 * Dissect a Packet layer binary parameters information element.
1959
 */
1960
static const value_string q931_fast_selected_vals[] = {
1961
    { 0x0,  "Fast select not requested" },
1962
    { 0x1,  "Fast select not requested" },
1963
    { 0x2,  "Fast select requested with no restriction of response" },
1964
    { 0x3,  "Fast select requested with restrictions of response" },
1965
    { 0x00, NULL }
1966
};
1967
1968
static const true_false_string tfs_link_end = { "Link-by-link", "End-to-end" };
1969
static const true_false_string tfs_pl_request = { "No request/request denied", "Request indicated/request accepted" };
1970
static const true_false_string tfs_pl_modulus = { "8 sequencing", "128 sequencing" };
1971
1972
static void
1973
dissect_q931_pl_binary_parameters_ie(tvbuff_t *tvb, int offset, int len,
1974
    proto_tree *tree)
1975
34
{
1976
34
    static int * const fields[] = {
1977
34
        &hf_q931_fast_select,
1978
34
        &hf_q931_pl_request,
1979
34
        &hf_q931_pl_binary_confirmation,
1980
34
        &hf_q931_pl_modulus,
1981
34
        NULL
1982
34
    };
1983
1984
34
    if (len == 0)
1985
4
        return;
1986
1987
30
    proto_tree_add_bitmask_list(tree, tvb, offset, 1, fields, ENC_NA);
1988
30
}
1989
1990
/*
1991
 * Dissect a Packet layer window size information element.
1992
 */
1993
static void
1994
dissect_q931_pl_window_size_ie(tvbuff_t *tvb, int offset, int len,
1995
    proto_tree *tree)
1996
31
{
1997
31
    if (len == 0)
1998
5
        return;
1999
26
    proto_tree_add_item(tree, hf_q931_pl_window_size_forward_value, tvb, offset, 1, ENC_BIG_ENDIAN);
2000
26
    offset += 1;
2001
26
    len -= 1;
2002
2003
26
    if (len == 0)
2004
2
        return;
2005
24
    proto_tree_add_item(tree, hf_q931_pl_window_size_backward_value, tvb, offset, 1, ENC_BIG_ENDIAN);
2006
24
}
2007
2008
/*
2009
 * Dissect a Packet size information element.
2010
 */
2011
static void
2012
dissect_q931_packet_size_ie(tvbuff_t *tvb, int offset, int len,
2013
    proto_tree *tree)
2014
34
{
2015
34
    if (len == 0)
2016
4
        return;
2017
30
    proto_tree_add_item(tree, hf_q931_packet_size_forward_value, tvb, offset, 1, ENC_BIG_ENDIAN);
2018
30
    offset += 1;
2019
30
    len -= 1;
2020
2021
30
    if (len == 0)
2022
3
        return;
2023
27
    proto_tree_add_item(tree, hf_q931_packet_size_backward_value, tvb, offset, 1, ENC_BIG_ENDIAN);
2024
27
}
2025
2026
/*
2027
 * Dissect a Closed user group information element.
2028
 */
2029
static const value_string q931_cug_indication_vals[] = {
2030
    { 0x01, "Closed user group selection" },
2031
    { 0x02, "Closed user group with outgoing access selection and indication" },
2032
    { 0,    NULL }
2033
};
2034
2035
static void
2036
dissect_q931_cug_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree)
2037
59
{
2038
59
    if (len == 0)
2039
16
        return;
2040
43
    proto_tree_add_item(tree, hf_q931_cug_indication, tvb, offset, 1, ENC_BIG_ENDIAN);
2041
43
    offset += 1;
2042
43
    len -= 1;
2043
2044
43
    if (len == 0)
2045
4
        return;
2046
39
    proto_tree_add_item(tree, hf_q931_cug_index_code, tvb, offset, len, ENC_ASCII);
2047
39
}
2048
2049
/*
2050
 * Dissect a Reverse charging indication information element.
2051
 */
2052
static const value_string q931_reverse_charging_indication_vals[] = {
2053
    { 0x01, "Reverse charging requested" },
2054
    { 0,    NULL }
2055
};
2056
2057
static void
2058
dissect_q931_reverse_charge_ind_ie(tvbuff_t *tvb, int offset, int len,
2059
    proto_tree *tree)
2060
29
{
2061
29
    if (len == 0)
2062
9
        return;
2063
20
    proto_tree_add_item(tree, hf_q931_reverse_charging_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
2064
20
}
2065
2066
/*
2067
 * Dissect a (phone) number information element.
2068
 */
2069
static const value_string q931_number_type_vals[] = {
2070
    { 0x0, "Unknown" },
2071
    { 0x1, "International number" },
2072
    { 0x2, "National number" },
2073
    { 0x3, "Network specific number" },
2074
    { 0x4, "Subscriber number" },
2075
    { 0x6, "Abbreviated number" },
2076
    { 0,    NULL }
2077
};
2078
2079
static const value_string q931_numbering_plan_vals[] = {
2080
    { 0x00, "Unknown" },
2081
    { 0x01, "E.164 ISDN/telephony numbering" },
2082
    { 0x03, "X.121 data numbering" },
2083
    { 0x04, "F.69 Telex numbering" },
2084
    { 0x08, "National standard numbering" },
2085
    { 0x09, "Private numbering" },
2086
    { 0,    NULL }
2087
};
2088
2089
static const value_string q931_presentation_indicator_vals[] = {
2090
    { 0x00, "Presentation allowed" },
2091
    { 0x01, "Presentation restricted" },
2092
    { 0x02, "Number not available due to interworking" },
2093
    { 0,    NULL }
2094
};
2095
2096
static const value_string q931_screening_indicator_vals[] = {
2097
    { 0x00, "User-provided, not screened" },
2098
    { 0x01, "User-provided, verified and passed" },
2099
    { 0x02, "User-provided, verified and failed" },
2100
    { 0x03, "Network-provided" },
2101
    { 0,    NULL }
2102
};
2103
2104
static const value_string q931_redirection_reason_vals[] = {
2105
    { 0x00, "Unknown" },
2106
    { 0x01, "Call forwarding busy or called DTE busy" },
2107
    { 0x02, "Call forwarding no reply" },
2108
    { 0x04, "Call deflection" },
2109
    { 0x09, "Called DTE out of order" },
2110
    { 0x0A, "Call forwarding by the called DTE" },
2111
    { 0x0F, "Call forwarding unconditional or systematic call redirection" },
2112
    { 0,    NULL }
2113
};
2114
2115
static void
2116
dissect_q931_number_ie(packet_info *pinfo, tvbuff_t *tvb, int offset, int len,
2117
    proto_tree *tree, int hfindex, e164_info_t e164_info, q931_packet_info *q931_pi)
2118
267
{
2119
267
    uint8_t octet;
2120
267
    int number_plan;
2121
2122
267
    if (len == 0)
2123
17
        return;
2124
250
    octet = tvb_get_uint8(tvb, offset);
2125
250
    number_plan = octet & 0x0f;
2126
250
    e164_info.nature_of_address = ( octet & 0x70 ) >> 4;
2127
250
    proto_tree_add_uint(tree, hf_q931_numbering_plan, tvb, offset, 1, octet);
2128
250
    proto_tree_add_uint(tree, hf_q931_number_type, tvb, offset, 1, octet);
2129
250
    proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
2130
2131
250
    offset += 1;
2132
250
    len -= 1;
2133
2134
250
    if (!(octet & Q931_IE_VL_EXTENSION)) {
2135
198
        if (len == 0)
2136
18
            return;
2137
180
        octet = tvb_get_uint8(tvb, offset);
2138
180
        proto_tree_add_uint(tree, hf_q931_screening_ind, tvb, offset, 1, octet);
2139
180
        proto_tree_add_uint(tree, hf_q931_presentation_ind, tvb, offset, 1, octet);
2140
180
        proto_tree_add_boolean(tree, hf_q931_extension_ind, tvb, offset, 1, octet);
2141
180
        offset += 1;
2142
180
        len -= 1;
2143
180
    }
2144
2145
    /*
2146
     * XXX - only in a Redirecting number information element.
2147
     */
2148
232
    if (!(octet & Q931_IE_VL_EXTENSION)) {
2149
163
        if (len == 0)
2150
4
            return;
2151
159
        proto_tree_add_item(tree, hf_q931_extension_reason, tvb, offset, 1, ENC_BIG_ENDIAN);
2152
159
        offset += 1;
2153
159
        len -= 1;
2154
159
    }
2155
2156
228
    if (len == 0)
2157
13
        return;
2158
215
    proto_tree_add_item(tree, hfindex, tvb, offset, len, ENC_ASCII|ENC_NA);
2159
215
    proto_item_append_text(proto_tree_get_parent(tree), ": '%s'", tvb_format_text(pinfo->pool, tvb, offset, len));
2160
2161
215
    if ( number_plan == 1 ) {
2162
18
        if ( e164_info.e164_number_type != NONE ){
2163
2164
8
            e164_info.E164_number_str = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_ASCII|ENC_NA);
2165
8
            e164_info.E164_number_length = len;
2166
8
            dissect_e164_number(tvb, tree, offset, len, e164_info);
2167
8
        }
2168
18
    }
2169
2170
    /* Collect q931_packet_info */
2171
215
    if ( e164_info.e164_number_type == CALLING_PARTY_NUMBER && q931_pi)
2172
41
        q931_pi->calling_number = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_ASCII|ENC_NA);
2173
215
    if ( e164_info.e164_number_type == CALLED_PARTY_NUMBER && q931_pi)
2174
67
        q931_pi->called_number = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_ASCII|ENC_NA);
2175
215
}
2176
2177
/*
2178
 * Dissect a party subaddress information element.
2179
 */
2180
static const value_string q931_subaddress_type_vals[] = {
2181
    { 0x0,  "X.213/ISO 8348 Add.2 NSAP" },
2182
    { 0x2,  "User-specified" },
2183
    { 0,    NULL }
2184
};
2185
2186
static const value_string q931_odd_even_indicator_vals[] = {
2187
    { 0x0,  "Even number of address signals" },
2188
    { 0x1,  "Odd number of address signals" },
2189
    { 0,    NULL }
2190
};
2191
2192
static void
2193
dissect_q931_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
2194
    proto_tree *tree)
2195
57
{
2196
57
    if (len == 0)
2197
9
        return;
2198
2199
48
    proto_tree_add_item(tree, hf_q931_party_subaddr_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2200
48
    proto_tree_add_item(tree, hf_q931_party_subaddr_odd_even_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
2201
48
    offset += 1;
2202
48
    len -= 1;
2203
2204
48
    if (len == 0)
2205
6
        return;
2206
42
    proto_tree_add_item(tree, hf_q931_party_subaddr, tvb, offset, len, ENC_NA);
2207
42
}
2208
2209
/*
2210
 * Dissect a Restart indicator information element.
2211
 */
2212
static const value_string q931_restart_indicator_class_vals[] = {
2213
    { 0x00, "Indicated channels" },
2214
    { 0x06, "Single interface" },
2215
    { 0x07, "All interfaces" },
2216
    { 0,    NULL }
2217
};
2218
2219
static void
2220
dissect_q931_restart_indicator_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
2221
    proto_tree *tree, proto_item* item)
2222
23
{
2223
23
    if (len != 1) {
2224
22
        expert_add_info_format(pinfo, item, &ei_q931_invalid_length,
2225
22
            "Restart indicator: length is %d, should be 1", len);
2226
22
        return;
2227
22
    }
2228
1
    proto_tree_add_item(tree, hf_q931_restart_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
2229
1
}
2230
2231
/*
2232
 * Dissect a High-layer compatibility information element.
2233
 */
2234
6
#define Q931_MAINTENANCE    0x5e
2235
6
#define Q931_MANAGEMENT     0x5f
2236
6
#define Q931_AUDIOVISUAL    0x60
2237
static const value_string q931_high_layer_characteristics_vals[] = {
2238
    { 0x01,             "Telephony" },
2239
    { 0x04,             "F.182 Facsimile Group 2/3" },
2240
    { 0x21,             "F.184 Facsimile Group 4 Class I" },
2241
    { 0x24,             "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
2242
    { 0x28,             "F.220 Teletex, basic and processable mode" },
2243
    { 0x31,             "F.200 Teletex, basic mode" },
2244
    { 0x32,             "F.300 and T.102 syntax-based Videotex" },
2245
    { 0x33,             "F.300 and T.101 international Videotex interworking" },
2246
    { 0x35,             "F.60 Telex" },
2247
    { 0x38,             "X.400 Message Handling Systems" },
2248
    { 0x41,             "X.200 OSI application" },
2249
    { 0x42,             "FTAM application" },
2250
    { 0x5E,             "Reserved for maintenance" },
2251
    { 0x5F,             "Reserved for management" },
2252
    { Q931_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
2253
    { 0x61,             "F.702 and F.731 Profile 1b videoconferencing" },
2254
    { 0x62,             "F.702 and F.731 audiographic conferencing" },
2255
    { 0x68,             "F.700-series Multimedia services" },
2256
    { 0,                NULL }
2257
};
2258
static value_string_ext q931_high_layer_characteristics_vals_ext = VALUE_STRING_EXT_INIT(q931_high_layer_characteristics_vals);
2259
2260
static const value_string q931_extended_high_layer_characteristics_vals[] = {
2261
    { 0x01,             "Telephony" },
2262
    { 0x04,             "F.182 Facsimile Group 2/3" },
2263
    { 0x21,             "F.184 Facsimile Group 4 Class I" },
2264
    { 0x24,             "F.230 Teletex, basic and mixed mode, and F.184 Facsimile Group 4, Classes II and III" },
2265
    { 0x28,             "F.220 Teletex, basic and processable mode" },
2266
    { 0x31,             "F.200 Teletex, basic mode" },
2267
    { 0x32,             "F.300 and T.102 syntax-based Videotex" },
2268
    { 0x33,             "F.300 and T.101 international Videotex interworking" },
2269
    { 0x35,             "F.60 Telex" },
2270
    { 0x38,             "X.400 Message Handling Systems" },
2271
    { 0x41,             "X.200 OSI application" },
2272
    { 0x42,             "FTAM application" },
2273
    { 0x5E,             "Not available for assignment" },
2274
    { 0x5F,             "Not available for assignment" },
2275
    { Q931_AUDIOVISUAL, "F.720/F.821 and F.731 Profile 1a videotelephony" },
2276
    { 0x61,             "F.702 and F.731 Profile 1b videoconferencing" },
2277
    { 0x62,             "F.702 and F.731 audiographic conferencing" },
2278
    { 0x68,             "F.700-series Multimedia services" },
2279
    { 0,                NULL }
2280
};
2281
static value_string_ext q931_extended_high_layer_characteristics_vals_ext = VALUE_STRING_EXT_INIT(q931_extended_high_layer_characteristics_vals);
2282
2283
static const value_string q931_audiovisual_characteristics_vals[] = {
2284
    { 0x01, "Capability set of initial channel of H.221" },
2285
    { 0x02, "Capability set of subsequent channel of H.221" },
2286
    { 0x21, "Capability set of initial channel of an active 3.1kHz audio or speech call" },
2287
    { 0x00, NULL }
2288
};
2289
2290
static const value_string q931_interpretation_vals[] = {
2291
    { 0x04, "First (primary or only) high layer characteristics identification to be used in the call" },
2292
    { 0x00, NULL }
2293
};
2294
2295
static const value_string q931_pres_meth_prot_prof_vals[] = {
2296
    { 0x01, "High layer protocol profile (without specification of attributes)" },
2297
    { 0x00, NULL }
2298
};
2299
2300
/*
2301
 * High layer protocol profile
2302
 */
2303
16
#define Q931_HIGH_LAYER_PROTOCOL_PROFILE 0x01
2304
2305
void
2306
dissect_q931_high_layer_compat_ie(tvbuff_t *tvb, int offset, int len,
2307
    proto_tree *tree)
2308
44
{
2309
44
    uint8_t octet;
2310
44
    uint8_t coding_standard;
2311
44
    uint8_t pres_method;
2312
44
    uint8_t characteristics;
2313
2314
44
    if (len == 0)
2315
2
        return;
2316
42
    octet = tvb_get_uint8(tvb, offset);
2317
42
    coding_standard = octet & 0x60;
2318
42
    pres_method = octet & 0x03;
2319
2320
42
    proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
2321
42
    proto_tree_add_uint(tree, hf_q931_coding_standard, tvb, offset, 1, octet);
2322
42
    proto_tree_add_uint(tree, hf_q931_interpretation, tvb, offset, 1, octet);
2323
42
    proto_tree_add_uint(tree, hf_q931_pres_meth_prot_prof, tvb, offset, 1, octet);
2324
2325
42
    offset += 1;
2326
42
    len -= 1;
2327
42
    if ((coding_standard != Q931_ITU_STANDARDIZED_CODING) || (pres_method != Q931_HIGH_LAYER_PROTOCOL_PROFILE)) {
2328
        /*
2329
         * We don't know how the call state is encoded,
2330
         * so just dump it as data and be done with it.
2331
         */
2332
33
        proto_tree_add_item(tree, hf_q931_high_layer_compat_data, tvb, offset, len, ENC_NA);
2333
33
        return;
2334
33
    }
2335
9
    if (len == 0)
2336
2
        return;
2337
2338
7
    octet = tvb_get_uint8(tvb, offset);
2339
7
    characteristics = octet & 0x7F;
2340
2341
7
    proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
2342
7
    proto_tree_add_uint(tree, hf_q931_high_layer_characteristics, tvb, offset, 1, octet);
2343
2344
7
    offset += 1;
2345
7
    len -= 1;
2346
2347
7
    if (!(octet & Q931_IE_VL_EXTENSION)) {
2348
6
        if (len == 0)
2349
0
            return;
2350
6
        octet = tvb_get_uint8(tvb, offset);
2351
6
        if ((characteristics == Q931_AUDIOVISUAL) || (characteristics == 0x61) || (characteristics == 0x62) ||
2352
6
            (characteristics == 0x68)) {
2353
0
            proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
2354
0
            proto_tree_add_uint(tree, hf_q931_extended_audiovisual_characteristics, tvb, offset, 1, octet);
2355
0
        }
2356
6
        else if ((characteristics == Q931_MANAGEMENT) || (characteristics == Q931_MAINTENANCE)) {
2357
0
            proto_tree_add_item(tree, hf_q931_extension_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
2358
0
            proto_tree_add_uint(tree, hf_q931_extended_high_layer_characteristics, tvb, offset, 1, octet);
2359
0
        }
2360
6
    }
2361
7
}
2362
2363
2364
/*
2365
 * Dissect a User-user information element.
2366
 */
2367
35
#define Q931_PROTOCOL_DISCRIMINATOR_USER    0x00
2368
19
#define Q931_PROTOCOL_DISCRIMINATOR_IA5     0x04
2369
18
#define Q931_PROTOCOL_DISCRIMINATOR_ASN1    0x05
2370
2371
static const value_string q931_protocol_discriminator_vals[] = {
2372
    { Q931_PROTOCOL_DISCRIMINATOR_USER, "User-specific protocol" },
2373
    { 0x01,                             "OSI high layer protocols" },
2374
    { 0x02,                             "X.244" },
2375
    { 0x03,                             "Reserved for system management convergence function" },
2376
    { Q931_PROTOCOL_DISCRIMINATOR_IA5,  "IA5 characters" },
2377
    { Q931_PROTOCOL_DISCRIMINATOR_ASN1, "X.208 and X.209 coded user information" },
2378
    { 0x06,                             "Undefined" },
2379
    { 0x07,                             "V.120 rate adaption" },
2380
    { 0x08,                             "Q.931/I.451 user-network call control messages" },
2381
    { 0,                                NULL }
2382
};
2383
value_string_ext q931_protocol_discriminator_vals_ext = VALUE_STRING_EXT_INIT(q931_protocol_discriminator_vals);
2384
2385
void
2386
dissect_q931_user_user_ie(tvbuff_t *tvb, packet_info *pinfo, int offset, int len,
2387
    proto_tree *tree)
2388
194
{
2389
194
    uint8_t octet;
2390
194
    tvbuff_t *next_tvb = NULL;
2391
194
    heur_dtbl_entry_t *hdtbl_entry;
2392
2393
194
    if (len == 0)
2394
56
        return;
2395
138
    octet = tvb_get_uint8(tvb, offset);
2396
138
    proto_tree_add_item(tree, hf_q931_user_protocol_discriminator, tvb, offset, 1, ENC_BIG_ENDIAN);
2397
138
    offset += 1;
2398
138
    len -= 1;
2399
2400
138
    if (len == 0)
2401
5
        return;
2402
133
    switch (octet) {
2403
2404
35
    case Q931_PROTOCOL_DISCRIMINATOR_USER:
2405
35
        next_tvb = tvb_new_subset_length(tvb, offset, len);
2406
35
        proto_tree_add_uint_format_value(tree, hf_q931_user_information_len, tvb, offset, len, len, "%d octets", len);
2407
35
        if (!dissector_try_heuristic(q931_user_heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, NULL)) {
2408
35
            call_data_dissector(next_tvb, pinfo, tree);
2409
35
        }
2410
35
        break;
2411
2412
19
    case Q931_PROTOCOL_DISCRIMINATOR_IA5:
2413
19
        proto_tree_add_item(tree, hf_q931_user_information_str, tvb, offset, len, ENC_ASCII);
2414
19
        break;
2415
2416
79
    default:
2417
79
        proto_tree_add_item(tree, hf_q931_user_information_bytes, tvb, offset, len, ENC_NA);
2418
79
        break;
2419
133
    }
2420
133
}
2421
2422
static const value_string q931_party_category_vals[] = {
2423
    { 0x00, "Unknown" },
2424
    { 0x01, "Extension" },
2425
    { 0x02, "Operator" },
2426
    { 0x03, "Emergency extension" },
2427
    { 0,    NULL }
2428
};
2429
2430
static void
2431
dissect_q931_party_category_ie(tvbuff_t *tvb, int offset, int len,
2432
    proto_tree *tree)
2433
0
{
2434
0
    if (len == 0)
2435
0
        return;
2436
2437
0
    proto_tree_add_item(tree, hf_q931_party_category, tvb, offset, 1, ENC_BIG_ENDIAN);
2438
    /*offset += 1;
2439
    len -= 1;
2440
2441
    if (len == 0)
2442
        return;
2443
    */
2444
0
}
2445
2446
/*
2447
 * Dissect information elements consisting of ASCII^H^H^H^H^HIA5 text.
2448
 */
2449
static void
2450
dissect_q931_ia5_ie(tvbuff_t *tvb, int offset, int len, packet_info *pinfo, proto_tree *tree,
2451
    int hf_value)
2452
149
{
2453
149
    if (len != 0) {
2454
138
        proto_tree_add_item(tree, hf_value, tvb, offset, len, ENC_ASCII|ENC_NA);
2455
138
        proto_item_append_text(proto_tree_get_parent(tree), "  '%s'", tvb_format_text(pinfo->pool, tvb, offset, len));
2456
138
    }
2457
149
}
2458
2459
static void
2460
dissect_q931_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2461
    bool is_over_ip)
2462
1.03k
{
2463
1.03k
    int         offset = 0;
2464
1.03k
    proto_tree  *q931_tree = NULL;
2465
1.03k
    proto_tree  *ie_tree = NULL;
2466
1.03k
    proto_item  *ti;
2467
1.03k
    uint8_t     prot_discr;
2468
1.03k
    uint8_t     call_ref_len;
2469
1.03k
    uint8_t     call_ref[16];
2470
1.03k
    uint32_t    call_ref_val;
2471
1.03k
    uint8_t     message_type, segmented_message_type;
2472
1.03k
    uint8_t     info_element;
2473
1.03k
    uint16_t    info_element_len;
2474
1.03k
    bool        first_frag, more_frags;
2475
1.03k
    uint32_t    frag_len;
2476
1.03k
    fragment_head *fd_head;
2477
1.03k
    tvbuff_t *next_tvb = NULL;
2478
1.03k
    q931_packet_info *q931_pi = NULL;
2479
2480
1.03k
    q931_pi=wmem_new(pinfo->pool, q931_packet_info);
2481
2482
    /* Init struct for collecting q931_packet_info */
2483
1.03k
    reset_q931_packet_info(q931_pi);
2484
2485
1.03k
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "Q.931");
2486
2487
1.03k
    prot_discr = tvb_get_uint8(tvb, offset);
2488
1.03k
    ti = proto_tree_add_item(tree, proto_q931, tvb, offset, -1, ENC_NA);
2489
1.03k
    if (tree) {
2490
1.03k
        q931_tree = proto_item_add_subtree(ti, ett_q931);
2491
2492
1.03k
        dissect_q931_protocol_discriminator(tvb, offset, q931_tree);
2493
1.03k
    }
2494
1.03k
    offset += 1;
2495
1.03k
    call_ref_len = tvb_get_uint8(tvb, offset) & 0xF;   /* XXX - do as a bit field? */
2496
1.03k
    if (q931_tree != NULL)
2497
1.03k
        proto_tree_add_uint(q931_tree, hf_q931_call_ref_len, tvb, offset, 1, call_ref_len);
2498
1.03k
    offset += 1;
2499
1.03k
    switch (call_ref_len) {
2500
190
        case 0: call_ref_val = 0; break;
2501
83
        case 1: call_ref_val = tvb_get_uint8(tvb, offset); break;
2502
58
        case 2: call_ref_val = tvb_get_ntohs(tvb, offset); break;
2503
91
        case 3: call_ref_val = tvb_get_ntoh24(tvb, offset); break;
2504
611
        default: call_ref_val = tvb_get_ntohl(tvb, offset);
2505
1.03k
    }
2506
1.02k
    if (call_ref_len != 0) {
2507
835
        tvb_memcpy(tvb, call_ref, offset, call_ref_len);
2508
835
        if (q931_tree != NULL) {
2509
833
            proto_tree_add_boolean(q931_tree, hf_q931_call_ref_flag,
2510
833
                tvb, offset, 1, (call_ref[0] & 0x80) != 0);
2511
833
            call_ref[0] &= 0x7F;
2512
833
            proto_tree_add_bytes(q931_tree, hf_q931_call_ref,
2513
833
                tvb, offset, call_ref_len, call_ref);
2514
833
        } else
2515
2
        {       /* info for the tap */
2516
2
            call_ref[0] &= 0x7F;
2517
2
        }
2518
        /* XXX - Should crv be something besides a uint32_t? */
2519
835
        memcpy(&(q931_pi->crv), call_ref, call_ref_len > sizeof(q931_pi->crv) ? sizeof(q931_pi->crv) : call_ref_len );
2520
835
        offset += call_ref_len;
2521
835
    }
2522
1.02k
    message_type = tvb_get_uint8(tvb, offset);
2523
1.02k
    q931_pi->message_type = message_type;
2524
1.02k
    col_add_str(pinfo->cinfo, COL_INFO, get_message_name(pinfo->pool, prot_discr, message_type));
2525
2526
1.02k
    if (prot_discr == NLPID_DMS)
2527
48
        proto_tree_add_item(q931_tree, hf_q931_maintenance_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2528
977
    else
2529
977
        proto_tree_add_item(q931_tree, hf_q931_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2530
2531
1.02k
    offset += 1;
2532
2533
    /*
2534
     * And now for the information elements....
2535
     */
2536
1.02k
    if ((message_type != Q931_SEGMENT) || !q931_reassembly ||
2537
1.01k
            (tvb_reported_length_remaining(tvb, offset) <= 4)) {
2538
1.01k
        dissect_q931_IEs(tvb, pinfo, tree, q931_tree, is_over_ip, offset, 0, q931_pi);
2539
1.01k
        return;
2540
1.01k
    }
2541
12
    info_element = tvb_get_uint8(tvb, offset);
2542
12
    info_element_len = tvb_get_uint8(tvb, offset + 1);
2543
12
    if ((info_element != Q931_IE_SEGMENTED_MESSAGE) || (info_element_len < 2)) {
2544
5
        dissect_q931_IEs(tvb, pinfo, tree, q931_tree, is_over_ip, offset, 0, q931_pi);
2545
5
        return;
2546
5
    }
2547
    /* Segmented message IE */
2548
7
    ie_tree = proto_tree_add_subtree(q931_tree, tvb, offset, 1+1+info_element_len, ett_q931_ie[info_element], NULL,
2549
7
                    val_to_str(pinfo->pool,info_element, q931_info_element_vals[0], "Unknown information element (0x%02X)"));
2550
7
    proto_tree_add_uint_format_value(ie_tree, hf_q931_information_element, tvb, offset, 1, info_element,
2551
7
                            "%s", val_to_str(pinfo->pool,info_element, q931_info_element_vals[0], "Unknown (0x%02X)"));
2552
7
    proto_tree_add_item(ie_tree, hf_q931_information_element_len, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
2553
7
    dissect_q931_segmented_message_ie(tvb, pinfo, offset + 2, info_element_len, ie_tree, ti);
2554
7
    first_frag = (tvb_get_uint8(tvb, offset + 2) & 0x80) != 0;
2555
7
    more_frags = (tvb_get_uint8(tvb, offset + 2) & 0x7F) != 0;
2556
7
    segmented_message_type = tvb_get_uint8(tvb, offset + 3);
2557
7
    col_append_fstr(pinfo->cinfo, COL_INFO, " of %s",
2558
7
            val_to_str_ext(pinfo->pool, segmented_message_type, &q931_message_type_vals_ext, "Unknown message type (0x%02X)"));
2559
2560
7
    offset += 1 + 1 + info_element_len;
2561
    /* Reassembly */
2562
7
    frag_len = tvb_reported_length_remaining(tvb, offset);
2563
7
    if (first_frag && fragment_get(&q931_reassembly_table, pinfo, call_ref_val, NULL)) {
2564
        /* there are some unreassembled segments, ignore them */
2565
1
        fragment_end_seq_next(&q931_reassembly_table, pinfo, call_ref_val, NULL);
2566
1
    }
2567
7
    fd_head = fragment_add_seq_next(&q931_reassembly_table,
2568
7
                    tvb, offset, pinfo, call_ref_val, NULL,
2569
7
                    frag_len, more_frags);
2570
7
    if (fd_head) {
2571
2
        if (pinfo->num == fd_head->reassembled_in) {  /* last fragment */
2572
2
            if (fd_head->next != NULL) {  /* 2 or more segments */
2573
1
                next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
2574
1
                add_new_data_source(pinfo, next_tvb, "Reassembled Q.931 IEs");
2575
                /* Show all fragments. */
2576
1
                if (tree) {
2577
1
                    proto_item *frag_tree_item;
2578
1
                    show_fragment_seq_tree(fd_head, &q931_frag_items, q931_tree, pinfo, next_tvb, &frag_tree_item);
2579
1
                }
2580
1
            } else {  /* only 1 segment */
2581
1
                next_tvb = tvb_new_subset_remaining(tvb, offset);
2582
1
            }
2583
2584
2
            col_add_fstr(pinfo->cinfo, COL_INFO, "%s [reassembled]",
2585
2
                    val_to_str_ext(pinfo->pool, segmented_message_type, &q931_message_type_vals_ext, "Unknown message type (0x%02X)"));
2586
2587
2
        } else {
2588
0
            if (tree) proto_tree_add_uint(q931_tree, hf_q931_reassembled_in, tvb, offset, frag_len, fd_head->reassembled_in);
2589
0
        }
2590
2
    }
2591
7
    if (next_tvb)
2592
1
        dissect_q931_IEs(next_tvb, pinfo, tree, q931_tree, is_over_ip, 0, 0, q931_pi);
2593
7
}
2594
2595
static const value_string q931_codeset_vals[] = {
2596
    { 0x00, "Q.931 information elements" },
2597
    { 0x04, "Information elements for ISO/IEC use" },
2598
    { 0x05, "Information elements for national use" },
2599
    { 0x06, "Information elements specific to the local network" },
2600
    { 0x07, "User-specific information elements" },
2601
    { 0x00, NULL },
2602
};
2603
2604
static void
2605
dissect_q931_IEs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root_tree,
2606
    proto_tree *q931_tree, bool is_over_ip, int offset, int initial_codeset,
2607
    q931_packet_info *q931_pi)
2608
1.14k
{
2609
1.14k
    proto_item  *ti;
2610
1.14k
    proto_tree  *ie_tree = NULL;
2611
1.14k
    uint8_t     info_element;
2612
1.14k
    uint8_t     dummy;
2613
1.14k
    uint16_t    info_element_len;
2614
1.14k
    int         codeset, locked_codeset;
2615
1.14k
    bool        non_locking_shift, first_segment;
2616
1.14k
    tvbuff_t    *h225_tvb, *next_tvb;
2617
1.14k
    e164_info_t e164_info;
2618
1.14k
    e164_info.e164_number_type = NONE;
2619
1.14k
    e164_info.nature_of_address = NONE;
2620
1.14k
    e164_info.E164_number_str = "";
2621
1.14k
    e164_info.E164_number_length = NONE;
2622
2623
1.14k
    codeset = locked_codeset = initial_codeset;
2624
1.14k
    first_segment = false;
2625
29.1k
    while (tvb_reported_length_remaining(tvb, offset) > 0) {
2626
28.7k
        info_element = tvb_get_uint8(tvb, offset);
2627
2628
        /* Check for the codeset shift */
2629
28.7k
        if ((info_element & Q931_IE_SO_MASK) &&
2630
20.5k
            ((info_element & Q931_IE_SO_IDENTIFIER_MASK) == Q931_IE_SHIFT)) {
2631
1.73k
            non_locking_shift = info_element & Q931_IE_SHIFT_NON_LOCKING;
2632
1.73k
            codeset = info_element & Q931_IE_SHIFT_CODESET;
2633
1.73k
            if (!non_locking_shift)
2634
917
                locked_codeset = codeset;
2635
1.73k
            if (q931_tree != NULL) {
2636
1.73k
                proto_tree_add_uint_format(q931_tree, hf_q931_locking_codeset, tvb, offset, 1,
2637
1.73k
                    codeset, "%s shift to codeset %u: %s",
2638
1.73k
                    (non_locking_shift ? "Non-locking" : "Locking"),
2639
1.73k
                    codeset, val_to_str(pinfo->pool,codeset, q931_codeset_vals,
2640
1.73k
                      "Unknown (0x%02X)"));
2641
1.73k
            }
2642
1.73k
            offset += 1;
2643
1.73k
            continue;
2644
1.73k
        }
2645
2646
        /*
2647
         * Check for the single-octet IEs.
2648
         */
2649
27.0k
        if (info_element & Q931_IE_SO_MASK) {
2650
            /*
2651
             * Check for subdissectors for this IE or
2652
             * for all IEs in this codeset.
2653
             */
2654
18.8k
            if (dissector_get_uint_handle(codeset_dissector_table, codeset) ||
2655
18.8k
                dissector_get_uint_handle(ie_dissector_table, (codeset << 8) | (info_element & Q931_IE_SO_IDENTIFIER_MASK))) {
2656
0
                next_tvb = tvb_new_subset_length (tvb, offset, 1);
2657
0
                if (dissector_try_uint(ie_dissector_table, (codeset << 8) | (info_element & Q931_IE_SO_IDENTIFIER_MASK), next_tvb, pinfo, q931_tree) ||
2658
0
                    dissector_try_uint(codeset_dissector_table, codeset, next_tvb, pinfo, q931_tree)) {
2659
0
                    offset += 1;
2660
0
                    codeset = locked_codeset;
2661
0
                    continue;
2662
0
                }
2663
0
            }
2664
2665
18.8k
            switch ((codeset << 8) | (info_element & Q931_IE_SO_IDENTIFIER_MASK)) {
2666
2667
2.44k
            case CS0 | Q931_IE_MORE_DATA_OR_SEND_COMP:
2668
2.44k
                switch (info_element) {
2669
2670
248
                case Q931_IE_MORE_DATA:
2671
248
                    proto_tree_add_item(q931_tree, hf_q931_more_data, tvb, offset, 1, ENC_NA);
2672
248
                    break;
2673
2674
534
                case Q931_IE_SENDING_COMPLETE:
2675
534
                    proto_tree_add_item(q931_tree, hf_q931_sending_complete, tvb, offset, 1, ENC_NA);
2676
534
                    break;
2677
2678
1.65k
                default:
2679
1.65k
                    proto_tree_add_expert_format(q931_tree, pinfo, &ei_q931_information_element, tvb, offset, 1,
2680
1.65k
                            "Unknown information element (0x%02X)", info_element);
2681
1.65k
                    break;
2682
2.44k
                }
2683
2.44k
                break;
2684
2685
2.44k
            case CS0 | Q931_IE_CONGESTION_LEVEL:
2686
1.66k
                proto_tree_add_item(q931_tree, hf_q931_congestion_level, tvb, offset, 1, ENC_BIG_ENDIAN);
2687
1.66k
                break;
2688
2689
1.72k
            case CS0 | Q931_IE_REPEAT_INDICATOR:
2690
1.72k
                proto_tree_add_item(q931_tree, hf_q931_repeat_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
2691
1.72k
                break;
2692
2693
13.0k
            default:
2694
13.0k
                proto_tree_add_expert_format(q931_tree, pinfo, &ei_q931_information_element, tvb, offset, 1,
2695
13.0k
                        "Unknown information element (0x%02X)", info_element);
2696
13.0k
                break;
2697
18.8k
            }
2698
18.8k
            offset += 1;
2699
18.8k
            codeset = locked_codeset;
2700
18.8k
            continue;
2701
18.8k
        }
2702
2703
        /*
2704
         * Variable-length IE.
2705
         *
2706
         * According to page 18 from Recommendation H.225.0 :
2707
         * " Length of user-user contents contents
2708
         * - Shall be 2 octets instead of 1 (as in Figure 4-36/Q.931)"
2709
         *
2710
         * We assume that if this is Q.931-over-TPKT, it might
2711
         * be H.225 traffic, and check for the IE being a user-user
2712
         * IE with ASN.1 encoding of the user information.
2713
         */
2714
8.22k
        if (is_over_ip && tvb_bytes_exist(tvb, offset, 4) &&
2715
746
            codeset == 0 && tvb_get_uint8(tvb, offset) == Q931_IE_USER_USER &&
2716
18
            tvb_get_uint8(tvb, offset + 3) == Q931_PROTOCOL_DISCRIMINATOR_ASN1)  {
2717
12
            info_element_len = tvb_get_ntohs(tvb, offset + 1);
2718
12
            if (q931_tree != NULL) {
2719
12
                ie_tree = proto_tree_add_subtree(q931_tree, tvb, offset,
2720
12
                    1+2+info_element_len, ett_q931_ie[info_element], NULL,
2721
12
                    val_to_str(pinfo->pool,info_element,
2722
12
                      q931_info_element_vals[codeset],
2723
12
                      "Unknown information element (0x%02X)"));
2724
12
                proto_tree_add_uint_format_value(ie_tree, hf_q931_information_element, tvb, offset, 1, info_element, "%s", val_to_str(pinfo->pool,info_element,
2725
12
                      q931_info_element_vals[codeset], "Unknown (0x%02X)"));
2726
12
                proto_tree_add_item(ie_tree, hf_q931_information_element_len, tvb, offset + 1, 2, ENC_BIG_ENDIAN);
2727
12
                proto_tree_add_item(ie_tree, hf_q931_user_protocol_discriminator, tvb, offset + 3, 1, ENC_NA);
2728
12
            }
2729
2730
12
            if (info_element_len > 1) {
2731
                /*
2732
                 * If we don't desegment limit the length
2733
                 * to the actual size in the frame
2734
                 */
2735
12
                if (!pinfo->can_desegment) {
2736
12
                    info_element_len = MIN(info_element_len, tvb_captured_length_remaining(tvb, offset + 3));
2737
12
                }
2738
                /*
2739
                 * Do we have a handle for the H.225
2740
                 * dissector?
2741
                 */
2742
12
                if (h225_handle != NULL) {
2743
                    /*
2744
                     * Yes - call it, regardless of
2745
                     * whether we're building a
2746
                     * protocol tree or not.
2747
                     */
2748
12
                    h225_tvb = tvb_new_subset_length(tvb,
2749
12
                        offset + 4, info_element_len - 1);
2750
12
                    call_dissector(h225_handle, h225_tvb,
2751
12
                        pinfo, root_tree);
2752
12
                } else {
2753
                    /*
2754
                     * No - just show it as "User
2755
                     * information" (if "ie_tree" is
2756
                     * null, this won't add anything).
2757
                     */
2758
0
                    proto_tree_add_item(ie_tree, hf_q931_user_information_bytes, tvb, offset + 4, info_element_len - 1, ENC_NA);
2759
0
                }
2760
12
            }
2761
12
            offset += 1 + 2 + info_element_len;
2762
8.21k
        } else {
2763
8.21k
            info_element_len = tvb_get_uint8(tvb, offset + 1);
2764
2765
8.21k
            if (first_segment && (tvb_reported_length_remaining(tvb, offset + 2) < info_element_len)) {  /* incomplete IE at the end of the 1st segment */
2766
114
                proto_tree_add_expert(q931_tree, pinfo, &ei_q931_incomplete_ie, tvb, offset, -1);
2767
114
                break;
2768
114
            }
2769
2770
            /*
2771
             * Check for subdissectors for this IE or
2772
             * for all IEs in this codeset.
2773
             */
2774
8.10k
            if (dissector_get_uint_handle(codeset_dissector_table, codeset) ||
2775
8.04k
                dissector_get_uint_handle(ie_dissector_table, (codeset << 8) | info_element)) {
2776
319
                next_tvb = tvb_new_subset_length (tvb, offset, info_element_len + 2);
2777
319
                if (dissector_try_uint(ie_dissector_table, (codeset << 8) | info_element, next_tvb, pinfo, q931_tree) ||
2778
248
                    dissector_try_uint(codeset_dissector_table, codeset, next_tvb, pinfo, q931_tree)) {
2779
248
                    offset += 2 + info_element_len;
2780
248
                    codeset = locked_codeset;
2781
248
                    continue;
2782
248
                }
2783
319
            }
2784
2785
7.85k
            ie_tree = proto_tree_add_subtree(q931_tree, tvb, offset, 1+1+info_element_len, ett_q931_ie[info_element], &ti,
2786
7.85k
                    val_to_str(pinfo->pool,info_element, q931_info_element_vals[codeset], "Unknown information element (0x%02X)"));
2787
7.85k
            proto_tree_add_uint_format_value(ie_tree, hf_q931_information_element, tvb, offset, 1, info_element, "%s",
2788
7.85k
                    val_to_str(pinfo->pool,info_element, q931_info_element_vals[codeset], "Unknown (0x%02X)"));
2789
7.85k
            proto_tree_add_uint(ie_tree, hf_q931_information_element_len, tvb, offset + 1, 1, info_element_len);
2790
2791
7.85k
            if (((codeset << 8) | info_element) == (CS0 | Q931_IE_SEGMENTED_MESSAGE)) {
2792
506
                dissect_q931_segmented_message_ie(tvb, pinfo, offset + 2, info_element_len, ie_tree, ti);
2793
506
                col_append_fstr(pinfo->cinfo, COL_INFO, " of %s",
2794
506
                        val_to_str_ext(pinfo->pool, tvb_get_uint8(tvb, offset + 3), &q931_message_type_vals_ext, "Unknown message type (0x%02X)"));
2795
2796
506
                if (tvb_get_uint8(tvb, offset + 2) & 0x80) {  /* the 1st segment */
2797
264
                    first_segment = true;
2798
264
                } else {  /* not the 1st segment */
2799
242
                    proto_tree_add_item(q931_tree, hf_q931_message_segment, tvb, offset + 4, -1, ENC_NA);
2800
242
                    info_element_len += tvb_reported_length_remaining(tvb, offset + 4);
2801
242
                }
2802
7.34k
            } else {
2803
                /*
2804
                 * For the calling number, called number,
2805
                 * and release cause IEs, don't check
2806
                 * for the tree being null, as
2807
                 * the dissectors for those IEs also
2808
                 * supply information for the tap used
2809
                 * in VoIP calls.
2810
                 */
2811
7.34k
                switch ((codeset << 8) | info_element) {
2812
2813
1.16k
                case CS0 | Q931_IE_BEARER_CAPABILITY:
2814
1.19k
                case CS0 | Q931_IE_LOW_LAYER_COMPAT:
2815
1.19k
                    if (q931_tree != NULL) {
2816
1.19k
                        dissect_q931_bearer_capability_ie(tvb,
2817
1.19k
                            offset + 2, info_element_len,
2818
1.19k
                            ie_tree);
2819
1.19k
                    }
2820
1.19k
                    break;
2821
2822
915
                case CS0 | Q931_IE_CAUSE:
2823
915
                    dissect_q931_cause_ie_with_info(tvb, pinfo,
2824
915
                        offset + 2, info_element_len,
2825
915
                        ie_tree,
2826
915
                        hf_q931_cause_value, &dummy, q931_info_element_vals0, q931_pi);
2827
915
                    break;
2828
2829
989
                case CS0 | Q931_IE_CHANGE_STATUS:
2830
989
                    if (q931_tree != NULL) {
2831
989
                        dissect_q931_change_status_ie(tvb,
2832
989
                            offset + 2, info_element_len,
2833
989
                            ie_tree);
2834
989
                    }
2835
989
                    break;
2836
2837
82
                case CS0 | Q931_IE_CALL_STATE:
2838
82
                    if (q931_tree != NULL) {
2839
82
                        dissect_q931_call_state_ie(tvb,
2840
82
                            offset + 2, info_element_len,
2841
82
                            ie_tree);
2842
82
                    }
2843
82
                    break;
2844
2845
150
                case CS0 | Q931_IE_CHANNEL_IDENTIFICATION:
2846
150
                    if (q931_tree != NULL) {
2847
150
                        dissect_q931_channel_identification_ie(
2848
150
                            tvb, offset + 2, info_element_len,
2849
150
                            ie_tree);
2850
150
                    }
2851
150
                    break;
2852
2853
97
                case CS0 | Q931_IE_PROGRESS_INDICATOR:
2854
97
                    if (q931_tree != NULL) {
2855
97
                        dissect_q931_progress_indicator_ie(tvb,
2856
97
                            offset + 2, info_element_len,
2857
97
                            ie_tree);
2858
97
                    }
2859
97
                    break;
2860
2861
112
                case CS0 | Q931_IE_NETWORK_SPECIFIC_FACIL:
2862
145
                case CS0 | Q931_IE_TRANSIT_NETWORK_SEL:
2863
145
                    if (q931_tree != NULL) {
2864
145
                        dissect_q931_ns_facilities_ie(tvb,
2865
145
                            offset + 2, info_element_len,
2866
145
                            ie_tree);
2867
145
                    }
2868
145
                    break;
2869
2870
0
                case CS0 | Q931_IE_NOTIFICATION_INDICATOR:
2871
0
                    if (q931_tree != NULL) {
2872
0
                        dissect_q931_notification_indicator_ie(
2873
0
                            tvb, offset + 2, info_element_len,
2874
0
                            ie_tree);
2875
0
                    }
2876
0
                    break;
2877
2878
69
                case CS0 | Q931_IE_DISPLAY:
2879
69
                    if (q931_tree != NULL) {
2880
69
                        dissect_q931_ia5_ie(tvb, offset + 2, info_element_len, pinfo, ie_tree, hf_q931_display_information);
2881
69
                    }
2882
69
                    break;
2883
2884
36
                case CS0 | Q931_IE_DATE_TIME:
2885
36
                    dissect_q931_date_time_ie(tvb, pinfo,
2886
36
                            offset + 2, info_element_len,
2887
36
                            ie_tree);
2888
36
                    break;
2889
2890
64
                case CS0 | Q931_IE_KEYPAD_FACILITY:
2891
64
                    if (q931_tree != NULL) {
2892
64
                        dissect_q931_ia5_ie(tvb, offset + 2, info_element_len, pinfo, ie_tree, hf_q931_keypad_facility);
2893
64
                    }
2894
64
                    break;
2895
2896
27
                case CS0 | Q931_IE_SIGNAL:
2897
27
                    dissect_q931_signal_ie(tvb, pinfo,
2898
27
                            offset + 2, info_element_len,
2899
27
                            ie_tree, ti);
2900
27
                    break;
2901
2902
57
                case CS0 | Q931_IE_INFORMATION_RATE:
2903
57
                    dissect_q931_information_rate_ie(tvb, pinfo,
2904
57
                            offset + 2, info_element_len,
2905
57
                            ie_tree, ti);
2906
57
                    break;
2907
2908
58
                case CS0 | Q931_IE_E2E_TRANSIT_DELAY:
2909
58
                    dissect_q931_e2e_transit_delay_ie(tvb, pinfo,
2910
58
                            offset + 2, info_element_len,
2911
58
                            ie_tree, ti);
2912
58
                    break;
2913
2914
48
                case CS0 | Q931_IE_TD_SELECTION_AND_INT:
2915
48
                    dissect_q931_td_selection_and_int_ie(
2916
48
                            tvb, pinfo, offset + 2, info_element_len,
2917
48
                            ie_tree, ti);
2918
48
                    break;
2919
2920
34
                case CS0 | Q931_IE_PL_BINARY_PARAMETERS:
2921
34
                    if (q931_tree != NULL) {
2922
34
                        dissect_q931_pl_binary_parameters_ie(
2923
34
                            tvb, offset + 2, info_element_len,
2924
34
                            ie_tree);
2925
34
                    }
2926
34
                    break;
2927
2928
31
                case CS0 | Q931_IE_PL_WINDOW_SIZE:
2929
31
                    if (q931_tree != NULL) {
2930
31
                        dissect_q931_pl_window_size_ie(tvb,
2931
31
                            offset + 2, info_element_len,
2932
31
                            ie_tree);
2933
31
                    }
2934
31
                    break;
2935
2936
34
                case CS0 | Q931_IE_PACKET_SIZE:
2937
34
                    if (q931_tree != NULL) {
2938
34
                        dissect_q931_packet_size_ie(tvb,
2939
34
                            offset + 2, info_element_len,
2940
34
                            ie_tree);
2941
34
                    }
2942
34
                    break;
2943
2944
59
                case CS0 | Q931_IE_CUG:
2945
59
                    if (q931_tree != NULL) {
2946
59
                        dissect_q931_cug_ie(tvb,
2947
59
                            offset + 2, info_element_len,
2948
59
                            ie_tree);
2949
59
                    }
2950
59
                    break;
2951
2952
29
                case CS0 | Q931_IE_REVERSE_CHARGE_IND:
2953
29
                    if (q931_tree != NULL) {
2954
29
                        dissect_q931_reverse_charge_ind_ie(tvb,
2955
29
                            offset + 2, info_element_len,
2956
29
                            ie_tree);
2957
29
                    }
2958
29
                    break;
2959
2960
64
                case CS0 | Q931_IE_CONNECTED_NUMBER_DEFAULT:
2961
64
                    if (q931_tree != NULL) {
2962
64
                        dissect_q931_number_ie(pinfo, tvb,
2963
64
                            offset + 2, info_element_len,
2964
64
                            ie_tree,
2965
64
                            hf_q931_connected_number, e164_info, q931_pi);
2966
64
                    }
2967
64
                    break;
2968
2969
2970
59
                case CS0 | Q931_IE_CALLING_PARTY_NUMBER:
2971
59
                    e164_info.e164_number_type = CALLING_PARTY_NUMBER;
2972
59
                    dissect_q931_number_ie(pinfo, tvb,
2973
59
                        offset + 2, info_element_len,
2974
59
                        ie_tree,
2975
59
                        hf_q931_calling_party_number, e164_info, q931_pi);
2976
59
                    break;
2977
2978
83
                case CS0 | Q931_IE_CALLED_PARTY_NUMBER:
2979
83
                    e164_info.e164_number_type = CALLED_PARTY_NUMBER;
2980
83
                    dissect_q931_number_ie(pinfo, tvb,
2981
83
                        offset + 2, info_element_len,
2982
83
                        ie_tree,
2983
83
                        hf_q931_called_party_number, e164_info, q931_pi);
2984
83
                    break;
2985
2986
29
                case CS0 | Q931_IE_CALLING_PARTY_SUBADDR:
2987
57
                case CS0 | Q931_IE_CALLED_PARTY_SUBADDR:
2988
57
                    if (q931_tree != NULL) {
2989
57
                        dissect_q931_party_subaddr_ie(tvb,
2990
57
                            offset + 2, info_element_len,
2991
57
                            ie_tree);
2992
57
                    }
2993
57
                    break;
2994
2995
61
                case CS0 | Q931_IE_REDIRECTING_NUMBER:
2996
61
                    if (q931_tree != NULL) {
2997
61
                        dissect_q931_number_ie(pinfo, tvb,
2998
61
                            offset + 2, info_element_len,
2999
61
                            ie_tree,
3000
61
                            hf_q931_redirecting_number, e164_info, q931_pi);
3001
61
                    }
3002
61
                    break;
3003
3004
23
                case CS0 | Q931_IE_RESTART_INDICATOR:
3005
23
                    dissect_q931_restart_indicator_ie(tvb, pinfo,
3006
23
                            offset + 2, info_element_len,
3007
23
                            ie_tree, ti);
3008
23
                    break;
3009
3010
23
                case CS0 | Q931_IE_HIGH_LAYER_COMPAT:
3011
23
                    if (q931_tree != NULL) {
3012
23
                        dissect_q931_high_layer_compat_ie(tvb,
3013
23
                            offset + 2, info_element_len,
3014
23
                            ie_tree);
3015
23
                    }
3016
23
                    break;
3017
3018
100
                case CS0 | Q931_IE_USER_USER:
3019
100
                    if (q931_tree != NULL) {
3020
100
                        dissect_q931_user_user_ie(tvb, pinfo,
3021
100
                            offset + 2, info_element_len,
3022
100
                            ie_tree);
3023
100
                    }
3024
100
                    break;
3025
3026
0
                case CS5 | Q931_IE_PARTY_CATEGORY:
3027
0
                    if (q931_tree != NULL) {
3028
0
                        dissect_q931_party_category_ie(tvb,
3029
0
                            offset + 2, info_element_len,
3030
0
                            ie_tree);
3031
0
                    }
3032
0
                    break;
3033
3034
16
                case CS6 | Q931_IE_DISPLAY:
3035
16
                    if (q931_tree != NULL) {
3036
16
                        dissect_q931_ia5_ie(tvb, offset + 2, info_element_len, pinfo, ie_tree, hf_q931_avaya_display);
3037
16
                    }
3038
16
                    break;
3039
3040
2.62k
                default:
3041
2.62k
                    if (q931_tree != NULL) {
3042
2.62k
                        proto_tree_add_item(ie_tree, hf_q931_data, tvb,
3043
2.62k
                            offset + 2, info_element_len, ENC_NA);
3044
2.62k
                    }
3045
2.62k
                    break;
3046
7.34k
                }
3047
7.34k
            }
3048
7.22k
            offset += 1 + 1 + info_element_len;
3049
7.22k
        }
3050
7.23k
        codeset = locked_codeset;
3051
7.23k
    }
3052
514
    if (q931_pi) {
3053
421
        tap_queue_packet(q931_tap, pinfo, q931_pi);
3054
421
    }
3055
514
}
3056
3057
/*
3058
 * Q.931-over-TPKT-over-TCP.
3059
 */
3060
static bool
3061
dissect_q931_tpkt_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
3062
4.31k
{
3063
4.31k
    int lv_tpkt_len;
3064
3065
    /*
3066
     * Check whether this looks like a TPKT-encapsulated
3067
     * Q.931 packet.
3068
     *
3069
     * The minimum length of a Q.931 message is 3:
3070
     * 1 byte for the protocol discriminator,
3071
     * 1 for the call_reference length,
3072
     * and one for the message type.
3073
     */
3074
4.31k
    lv_tpkt_len = is_tpkt(tvb, 3);
3075
4.31k
    if (lv_tpkt_len == -1) {
3076
        /*
3077
         * It's not a TPKT packet; reject it.
3078
         */
3079
4.25k
        return false;
3080
4.25k
    }
3081
3082
    /*
3083
     * If this segment is *exactly* the length of a TPKT header,
3084
     * we assume that, as it looks like a TPKT header, it
3085
     * is one, and that the code put a TPKT header in one
3086
     * segment and the rest of the PDU in another.
3087
     */
3088
58
    if (tvb_reported_length(tvb) == 4) {
3089
        /*
3090
         * It is - call the "dissect TPKT over a TCP stream"
3091
         * routine.
3092
         */
3093
1
        dissect_tpkt_encap(tvb, pinfo, tree, q931_desegment,
3094
1
            q931_tpkt_pdu_handle);
3095
1
        return true;
3096
1
    }
3097
3098
    /*
3099
     * Well, we have more data than just the TPKT header;
3100
     * check whether it looks like the beginning of a
3101
     * Q.931 message.
3102
     *
3103
     * The minimum length of a Q.931 message is 3, as per the
3104
     * above.
3105
     *
3106
     * Check that we have that many bytes past the TPKT header in
3107
     * the tvbuff; we already know that the TPKT header says we
3108
     * have that many bytes (as we passed 3 as the "min_len" argument
3109
     * to "is_tpkt()").
3110
     */
3111
57
    if (!tvb_bytes_exist(tvb, 4, 3))
3112
1
        return false;
3113
3114
    /* Check the protocol discriminator */
3115
56
    if ((tvb_get_uint8(tvb, 4) != NLPID_Q_931) && (tvb_get_uint8(tvb, 4) != 0x03)) {
3116
        /* Doesn't look like Q.931 inside TPKT */
3117
16
        return false;
3118
16
    }
3119
3120
    /*
3121
     * OK, it looks like Q.931-over-TPKT.
3122
     * Call the "dissect TPKT over a TCP stream" routine.
3123
     */
3124
40
    dissect_tpkt_encap(tvb, pinfo, tree, q931_desegment,
3125
40
        q931_tpkt_pdu_handle);
3126
3127
40
    return true;
3128
56
}
3129
3130
static int
3131
dissect_q931_tpkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3132
0
{
3133
0
    dissect_q931_tpkt_heur(tvb, pinfo, tree, NULL);
3134
0
    return tvb_captured_length(tvb);
3135
0
}
3136
3137
static int
3138
dissect_q931_tpkt_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3139
60
{
3140
60
    dissect_q931_pdu(tvb, pinfo, tree, true);
3141
60
    return tvb_captured_length(tvb);
3142
60
}
3143
3144
static int
3145
dissect_q931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3146
922
{
3147
922
    dissect_q931_pdu(tvb, pinfo, tree, false);
3148
922
    return tvb_captured_length(tvb);
3149
922
}
3150
3151
static int
3152
dissect_q931_over_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3153
53
{
3154
53
    dissect_q931_pdu(tvb, pinfo, tree, true);
3155
53
  return tvb_captured_length(tvb);
3156
53
}
3157
3158
static int
3159
dissect_q931_ie_cs0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3160
123
{
3161
123
    dissect_q931_IEs(tvb, pinfo, NULL, tree, false, 0, 0, NULL);
3162
123
    return tvb_captured_length(tvb);
3163
123
}
3164
3165
static int
3166
dissect_q931_ie_cs7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
3167
0
{
3168
0
    dissect_q931_IEs(tvb, pinfo, NULL, tree, false, 0, 7, NULL);
3169
0
    return tvb_captured_length(tvb);
3170
0
}
3171
3172
void
3173
proto_register_q931(void)
3174
14
{
3175
14
    unsigned i;
3176
14
    unsigned last_offset;
3177
3178
14
    static hf_register_info hf[] = {
3179
14
        { &hf_q931_discriminator,
3180
14
          { "Protocol discriminator", "q931.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
3181
14
            NULL, HFILL }},
3182
3183
14
        { &hf_q931_call_ref_len,
3184
14
          { "Call reference value length", "q931.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
3185
14
            NULL, HFILL }},
3186
3187
14
        { &hf_q931_call_ref_flag,
3188
14
          { "Call reference flag", "q931.call_ref_flag", FT_BOOLEAN, BASE_NONE, TFS(&tfs_call_ref_flag), 0x0,
3189
14
            NULL, HFILL }},
3190
3191
14
        { &hf_q931_call_ref,
3192
14
          { "Call reference value", "q931.call_ref", FT_BYTES, BASE_NONE, NULL, 0x0,
3193
14
            NULL, HFILL }},
3194
3195
14
        { &hf_q931_message_type,
3196
14
          { "Message type", "q931.message_type", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_message_type_vals_ext, 0x0,
3197
14
            NULL, HFILL }},
3198
3199
14
        { &hf_q931_maintenance_message_type,
3200
14
          { "Maintenance message type", "q931.maintenance_message_type", FT_UINT8, BASE_HEX, VALS(dms_message_type_vals), 0x0,
3201
14
            NULL, HFILL }},
3202
3203
14
        { &hf_q931_segment_type,
3204
14
          { "Segmented message type", "q931.segment_type", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_message_type_vals_ext, 0x0,
3205
14
            NULL, HFILL }},
3206
3207
14
        { &hf_q931_coding_standard,
3208
14
          { "Coding standard", "q931.coding_standard", FT_UINT8, BASE_HEX,
3209
14
             VALS(q931_coding_standard_vals), 0x60,NULL, HFILL }},
3210
3211
14
        { &hf_q931_interpretation,
3212
14
          { "Interpretation", "q931.interpretation", FT_UINT8, BASE_HEX,
3213
14
            VALS(q931_interpretation_vals), 0x1C, NULL, HFILL}},
3214
3215
14
        { &hf_q931_pres_meth_prot_prof,
3216
14
          { "Presentation method of protocol profile", "q931.presentation_method_protocol_profile", FT_UINT8, BASE_HEX,
3217
14
            VALS(q931_pres_meth_prot_prof_vals), 0x03, NULL, HFILL}},
3218
3219
14
        { &hf_q931_high_layer_characteristics,
3220
14
          { "High layer characteristics identification", "q931.high_layer_characteristics", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
3221
14
            &q931_high_layer_characteristics_vals_ext, 0x7f, NULL, HFILL }},
3222
3223
14
        { &hf_q931_extended_high_layer_characteristics,
3224
14
          { "Extended high layer characteristics identification", "q931.extended_high_layer_characteristics", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
3225
14
            &q931_extended_high_layer_characteristics_vals_ext, 0x7f, NULL, HFILL }},
3226
3227
14
        { &hf_q931_extended_audiovisual_characteristics,
3228
14
          { "Extended audiovisual characteristics identification", "q931.extended_audiovisual_characteristics", FT_UINT8, BASE_HEX,
3229
14
            VALS(q931_audiovisual_characteristics_vals), 0x7f, NULL, HFILL }},
3230
3231
14
        { &hf_q931_information_transfer_capability,
3232
14
          { "Information transfer capability", "q931.information_transfer_capability", FT_UINT8, BASE_HEX,
3233
14
             VALS(q931_information_transfer_capability_vals), 0x1f,NULL, HFILL }},
3234
3235
14
        { &hf_q931_transfer_mode,
3236
14
          { "Transfer mode", "q931.transfer_mode", FT_UINT8, BASE_HEX,
3237
14
             VALS(q931_transfer_mode_vals), 0x60,NULL, HFILL }},
3238
3239
14
        { &hf_q931_information_transfer_rate,
3240
14
          { "Information transfer rate", "q931.information_transfer_rate", FT_UINT8, BASE_HEX,
3241
14
             VALS(q931_information_transfer_rate_vals), 0x1f,NULL, HFILL }},
3242
3243
14
        { &hf_q931_layer_ident,
3244
14
          { "Layer identification", "q931.layer_ident", FT_UINT8, BASE_HEX,
3245
14
             VALS(q931_bearer_capability_layer_ident_vals), 0x60, NULL, HFILL }},
3246
3247
14
        { &hf_q931_uil1,
3248
14
          { "User information layer 1 protocol", "q931.uil1", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
3249
14
             &q931_uil1_vals_ext, 0x1f,NULL, HFILL }},
3250
3251
14
        { &hf_q931_cause_location,
3252
14
          { "Cause location", "q931.cause_location", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &q931_cause_location_vals_ext, 0x0f,
3253
14
            NULL, HFILL }},
3254
3255
14
        { &hf_q931_cause_value,
3256
14
          { "Cause value", "q931.cause_value", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &q931_cause_code_vals_ext, 0x7f,
3257
14
            NULL, HFILL }},
3258
3259
14
        { &hf_q931_number_type,
3260
14
          { "Number type", "q931.number_type", FT_UINT8, BASE_HEX, VALS(q931_number_type_vals), 0x70,
3261
14
            NULL, HFILL }},
3262
3263
14
        { &hf_q931_numbering_plan,
3264
14
          { "Numbering plan", "q931.numbering_plan", FT_UINT8, BASE_HEX, VALS(q931_numbering_plan_vals), 0x0f,
3265
14
            NULL, HFILL }},
3266
3267
14
        { &hf_q931_screening_ind,
3268
14
          { "Screening indicator", "q931.screening_ind", FT_UINT8, BASE_HEX, VALS(q931_screening_indicator_vals), 0x03,
3269
14
            NULL, HFILL }},
3270
3271
14
        { &hf_q931_presentation_ind,
3272
14
          { "Presentation indicator", "q931.presentation_ind", FT_UINT8, BASE_HEX, VALS(q931_presentation_indicator_vals), 0x60,
3273
14
            NULL, HFILL }},
3274
3275
14
        { &hf_q931_extension_ind,
3276
14
          { "Extension indicator",  "q931.extension_ind",
3277
14
            FT_BOOLEAN, 8, TFS(&q931_extension_ind_value), 0x80,
3278
14
            NULL, HFILL }},
3279
3280
14
        { &hf_q931_extension_ind_preference,
3281
14
          { "Preference",  "q931.extension_ind_preference",
3282
14
            FT_UINT8, BASE_DEC, VALS(q931_status_preference_vals), 0x40,
3283
14
            NULL, HFILL }},
3284
3285
14
        { &hf_q931_extension_ind_new_status,
3286
14
          { "New status",  "q931.extension_ind_new_status",
3287
14
            FT_UINT8, BASE_DEC, VALS(q931_new_status_vals), 0x07,
3288
14
            NULL, HFILL }},
3289
3290
14
        { &hf_q931_calling_party_number,
3291
14
          { "Calling party number digits", "q931.calling_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3292
14
            NULL, HFILL }},
3293
3294
14
        { &hf_q931_called_party_number,
3295
14
          { "Called party number digits", "q931.called_party_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3296
14
            NULL, HFILL }},
3297
3298
14
        { &hf_q931_connected_number,
3299
14
          { "Connected party number digits", "q931.connected_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3300
14
            NULL, HFILL }},
3301
3302
14
        { &hf_q931_redirecting_number,
3303
14
          { "Redirecting party number digits", "q931.redirecting_number.digits", FT_STRING, BASE_NONE, NULL, 0x0,
3304
14
            NULL, HFILL }},
3305
3306
        /* fields for channel identification IE */
3307
        /* 0x80 is the extension bit */
3308
3309
14
        { &hf_q931_channel_interface_explicit,
3310
14
          { "Interface identifier present", "q931.channel.interface_id_present", FT_BOOLEAN, 8, NULL, 0x40,
3311
14
            "True if the interface identifier is explicit in the following octets", HFILL }},
3312
3313
14
        { &hf_q931_channel_interface_type,
3314
14
          { "Interface type", "q931.channel.interface_type", FT_BOOLEAN, 8, TFS(&tfs_interface_type), 0x20,
3315
14
            "Identifies the ISDN interface type", HFILL }},
3316
3317
        /* 0x10 is spare */
3318
3319
14
        { &hf_q931_channel_exclusive,
3320
14
          { "Indicated channel", "q931.channel.exclusive", FT_BOOLEAN, 8, TFS(&tfs_channel_exclusive), 0x08,
3321
14
            "True if only the indicated channel is acceptable", HFILL }},
3322
3323
14
        { &hf_q931_channel_dchan,
3324
14
          { "D-channel indicator", "q931.channel.dchan", FT_BOOLEAN, 8, NULL, 0x04,
3325
14
            "True if the identified channel is the D-Channel", HFILL }},
3326
3327
14
        { &hf_q931_channel_selection_bri,
3328
14
          { "Information channel selection", "q931.channel.selection", FT_UINT8, BASE_HEX, VALS(q931_basic_channel_selection_vals), 0x03,
3329
14
            "Identifies the information channel to be used", HFILL }},
3330
3331
14
        { &hf_q931_channel_selection_pri,
3332
14
          { "Information channel selection", "q931.channel.selection", FT_UINT8, BASE_HEX, VALS(q931_not_basic_channel_selection_vals), 0x03,
3333
14
            "Identifies the information channel to be used", HFILL }},
3334
3335
14
        { &hf_q931_channel_map,
3336
14
          { "Number/map", "q931.channel.map", FT_BOOLEAN, 8, TFS(&tfs_channel_map), 0x10,
3337
14
            "True if channel is indicates by channel map rather than number", HFILL }},
3338
3339
14
        { &hf_q931_channel_element_type,
3340
14
          { "Element type", "q931.channel.element_type", FT_UINT8, BASE_HEX, VALS(q931_element_type_vals), 0xF,
3341
14
            "Type of element in the channel number/slot map octets", HFILL }},
3342
3343
14
        { &hf_q931_channel_number,
3344
14
          { "Channel number", "q931.channel.number", FT_UINT8, BASE_DEC, NULL, 0x7F,
3345
14
            NULL, HFILL }},
3346
3347
        /* desegmentation fields */
3348
14
        { &hf_q931_segment_overlap,
3349
14
          { "Segment overlap", "q931.segment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3350
14
            "Fragment overlaps with other fragments", HFILL }},
3351
3352
14
        { &hf_q931_segment_overlap_conflict,
3353
14
          { "Conflicting data in fragment overlap", "q931.segment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3354
14
            "Overlapping fragments contained conflicting data", HFILL }},
3355
3356
14
        { &hf_q931_segment_multiple_tails,
3357
14
          { "Multiple tail fragments found", "q931.segment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3358
14
            "Several tails were found when defragmenting the packet", HFILL }},
3359
3360
14
        { &hf_q931_segment_too_long_segment,
3361
14
          { "Segment too long", "q931.segment.toolongfragment", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3362
14
            "Segment contained data past end of packet", HFILL }},
3363
3364
14
        { &hf_q931_segment_error,
3365
14
          { "Defragmentation error", "q931.segment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3366
14
            "Defragmentation error due to illegal fragments", HFILL }},
3367
3368
14
        { &hf_q931_segment_count,
3369
14
          { "Segment count", "q931.segment.count", FT_UINT32, BASE_DEC, NULL, 0x0,
3370
14
            NULL, HFILL}},
3371
3372
14
        { &hf_q931_segment,
3373
14
          { "Q.931 Segment", "q931.segment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3374
14
            NULL, HFILL }},
3375
3376
14
        { &hf_q931_segments,
3377
14
          { "Q.931 Segments", "q931.segments", FT_NONE, BASE_NONE, NULL, 0x0,
3378
14
            NULL, HFILL }},
3379
3380
14
        { &hf_q931_reassembled_in,
3381
14
          { "Reassembled Q.931 in frame", "q931.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3382
14
            "This Q.931 message is reassembled in this frame", HFILL}},
3383
3384
14
        { &hf_q931_reassembled_length,
3385
14
          { "Reassembled Q.931 length", "q931.reassembled.length", FT_UINT32, BASE_DEC, NULL, 0x0,
3386
14
            "The total length of the reassembled payload", HFILL}},
3387
3388
        /* Generated from convert_proto_tree_add_text.pl */
3389
14
        { &hf_q931_first_segment,
3390
14
          { "First segment", "q931.segment.first",
3391
14
            FT_UINT8, BASE_DEC|BASE_UNIT_STRING, UNS(&units_segment_remaining), 0x7F,
3392
14
            NULL, HFILL }
3393
14
        },
3394
14
        { &hf_q931_not_first_segment,
3395
14
          { "Not first segment", "q931.segment.not_first",
3396
14
            FT_UINT8, BASE_DEC|BASE_UNIT_STRING, UNS(&units_segment_remaining), 0x7F,
3397
14
            NULL, HFILL }
3398
14
        },
3399
14
        { &hf_q931_bearer_capability_data,
3400
14
          { "Data", "q931.bearer_capability.data",
3401
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3402
14
            NULL, HFILL }
3403
14
        },
3404
14
        { &hf_q931_bearer_capability_rate_multiplier,
3405
14
          { "Rate multiplier", "q931.bearer_capability.rate_multiplier",
3406
14
            FT_UINT8, BASE_DEC, NULL, 0x7f,
3407
14
            NULL, HFILL }
3408
14
        },
3409
14
        { &hf_q931_bearer_capability_user_rate,
3410
14
          { "User rate", "q931.bearer_capability.user_rate",
3411
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_l1_user_rate_vals_ext, 0x1F,
3412
14
            NULL, HFILL }
3413
14
        },
3414
14
        { &hf_q931_bearer_capability_intermediate_rate,
3415
14
          { "Intermediate rate", "q931.bearer_capability.intermediate_rate",
3416
14
            FT_UINT8, BASE_HEX, VALS(q931_l1_intermediate_rate_vals), 0x60,
3417
14
            NULL, HFILL }
3418
14
        },
3419
14
        { &hf_q931_bearer_capability_stop_bits,
3420
14
          { "Stop bits", "q931.bearer_capability.stop_bits",
3421
14
            FT_UINT8, BASE_HEX, VALS(q931_l1_stop_bits_vals), 0x60,
3422
14
            NULL, HFILL }
3423
14
        },
3424
14
        { &hf_q931_bearer_capability_data_bits,
3425
14
          { "Data bits", "q931.bearer_capability.data_bits",
3426
14
            FT_UINT8, BASE_HEX, VALS(q931_l1_data_bits_vals), 0x18,
3427
14
            NULL, HFILL }
3428
14
        },
3429
14
        { &hf_q931_bearer_capability_parity,
3430
14
          { "Parity", "q931.bearer_capability.parity",
3431
14
            FT_UINT8, BASE_HEX, VALS(q931_l1_parity_vals), 0x07,
3432
14
            NULL, HFILL }
3433
14
        },
3434
14
        { &hf_q931_bearer_capability_modem_type,
3435
14
          { "Modem type", "q931.bearer_capability.modem_type",
3436
14
            FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(q931_l1_modem_type_rvals), 0x3F,
3437
14
            NULL, HFILL }
3438
14
        },
3439
14
        { &hf_q931_uil2,
3440
14
          { "User information layer 2 protocol", "q931.uil2",
3441
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_uil2_vals_ext, 0x1F,
3442
14
            NULL, HFILL }
3443
14
        },
3444
14
        { &hf_q931_uil2_info,
3445
14
          { "User-specified layer 2 protocol information", "q931.uil2_info",
3446
14
            FT_UINT8, BASE_HEX, NULL, 0x7F,
3447
14
            NULL, HFILL }
3448
14
        },
3449
14
        { &hf_q931_bearer_capability_mode,
3450
14
          { "Mode", "q931.bearer_capability.mode",
3451
14
            FT_UINT8, BASE_HEX, VALS(q931_mode_vals), 0x60,
3452
14
            NULL, HFILL }
3453
14
        },
3454
14
        { &hf_q931_bearer_capability_window_size,
3455
14
          { "Window size", "q931.bearer_capability.window_size",
3456
14
            FT_UINT8, BASE_DEC, NULL, 0x7F,
3457
14
            NULL, HFILL }
3458
14
        },
3459
14
        { &hf_q931_uil3,
3460
14
          { "User information layer 3 protocol", "q931.uil3",
3461
14
            FT_UINT8, BASE_HEX, VALS(q931_uil3_vals), 0x1F,
3462
14
            NULL, HFILL }
3463
14
        },
3464
14
        { &hf_q931_bearer_capability_default_packet_size,
3465
14
          { "Default packet size", "q931.bearer_capability.default_packet_size",
3466
14
            FT_UINT8, BASE_DEC|BASE_UNIT_STRING, UNS(&units_octet_octets), 0x0F,
3467
14
            NULL, HFILL }
3468
14
        },
3469
14
        { &hf_q931_bearer_capability_packet_window_size,
3470
14
          { "Packet window size", "q931.bearer_capability.packet_window_size",
3471
14
            FT_UINT8, BASE_DEC, NULL, 0x7F,
3472
14
            NULL, HFILL }
3473
14
        },
3474
14
        { &hf_q931_uil3_additional,
3475
14
          { "Additional layer 3 protocol information", "q931.uil3_additional",
3476
14
            FT_UINT16, BASE_HEX, VALS(nlpid_vals), 0x0,
3477
14
            NULL, HFILL }
3478
14
        },
3479
14
        { &hf_q931_cause_data,
3480
14
          { "Data", "q931.cause.data",
3481
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3482
14
            NULL, HFILL }
3483
14
        },
3484
14
        { &hf_q931_cause_recommendation,
3485
14
          { "Recommendation", "q931.cause.recommendation",
3486
14
            FT_UINT8, BASE_HEX, VALS(q931_cause_recommendation_vals), 0x7F,
3487
14
            NULL, HFILL }
3488
14
        },
3489
14
        { &hf_q931_cause_call_rejection_reason,
3490
14
          { "Rejection reason", "q931.cause_call.rejection_reason",
3491
14
            FT_UINT8, BASE_HEX, VALS(q931_rejection_reason_vals), 0x7C,
3492
14
            NULL, HFILL }
3493
14
        },
3494
14
        { &hf_q931_cause_call_condition,
3495
14
          { "Condition", "q931.cause_call.condition",
3496
14
            FT_UINT8, BASE_HEX, VALS(q931_cause_condition_vals), 0x03,
3497
14
            NULL, HFILL }
3498
14
        },
3499
14
        { &hf_q931_cause_call_user_specific_diagnostic,
3500
14
          { "User specific diagnostic", "q931.cause_call.user_specific_diagnostic",
3501
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3502
14
            NULL, HFILL }
3503
14
        },
3504
14
        { &hf_q931_cause_call_diagnostic,
3505
14
          { "Diagnostic", "q931.cause_call.diagnostic",
3506
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3507
14
            NULL, HFILL }
3508
14
        },
3509
14
        { &hf_q931_cause_call_message_type,
3510
14
          { "Message type", "q931.cause_call.message_type",
3511
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_message_type_vals_ext, 0x0,
3512
14
            NULL, HFILL }
3513
14
        },
3514
14
        { &hf_q931_cause_call_rec_timer,
3515
14
          { "Timer", "q931.cause_call.rec_timer",
3516
14
            FT_STRING, BASE_NONE, NULL, 0x0,
3517
14
            NULL, HFILL }
3518
14
        },
3519
14
        { &hf_q931_call_state_data,
3520
14
          { "Data", "q931.call_state.data",
3521
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3522
14
            NULL, HFILL }
3523
14
        },
3524
14
        { &hf_q931_call_state,
3525
14
          { "Call state", "q931.call_state",
3526
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_call_state_vals_ext, 0x3F,
3527
14
            NULL, HFILL }
3528
14
        },
3529
14
        { &hf_q931_channel_interface_id,
3530
14
          { "Interface ID", "q931.channel.interface_id",
3531
14
            FT_UINT32, BASE_DEC, NULL, 0x0,
3532
14
            NULL, HFILL }
3533
14
        },
3534
14
        { &hf_q931_channel_data,
3535
14
          { "Data", "q931.channel.data",
3536
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3537
14
            NULL, HFILL }
3538
14
        },
3539
14
        { &hf_q931_channel_slot_map,
3540
14
          { "Slot map", "q931.channel.slot_map",
3541
14
            FT_UINT8, BASE_HEX, NULL, 0x0,
3542
14
            NULL, HFILL }
3543
14
        },
3544
14
        { &hf_q931_progress_indicator_data,
3545
14
          { "Data", "q931.progress_indicator.data",
3546
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3547
14
            NULL, HFILL }
3548
14
        },
3549
14
        { &hf_q931_progress_indicator_location,
3550
14
          { "Location", "q931.progress_indicator.location",
3551
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_cause_location_vals_ext, 0x0F,
3552
14
            NULL, HFILL }
3553
14
        },
3554
14
        { &hf_q931_progress_indicator_description,
3555
14
          { "Progress description", "q931.progress_indicator.description",
3556
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_progress_description_vals_ext, 0x7F,
3557
14
            NULL, HFILL }
3558
14
        },
3559
14
        { &hf_q931_netid_length,
3560
14
          { "Network identification length", "q931.netid.length",
3561
14
            FT_UINT8, BASE_DEC, NULL, 0x7F,
3562
14
            NULL, HFILL }
3563
14
        },
3564
14
        { &hf_q931_netid_type,
3565
14
          { "Type of network identification", "q931.netid.type",
3566
14
            FT_UINT8, BASE_HEX, VALS(q931_netid_type_vals), 0x70,
3567
14
            NULL, HFILL }
3568
14
        },
3569
14
        { &hf_q931_netid_plan,
3570
14
          { "Network identification plan", "q931.netid.plan",
3571
14
            FT_UINT8, BASE_HEX, VALS(q931_netid_plan_vals), 0x0F,
3572
14
            NULL, HFILL }
3573
14
        },
3574
14
        { &hf_q931_netid,
3575
14
          { "Network identification", "q931.netid",
3576
14
            FT_STRING, BASE_NONE, NULL, 0x0,
3577
14
            NULL, HFILL }
3578
14
        },
3579
14
        { &hf_q931_netid_facility_specification,
3580
14
          { "Network-specific facility specification", "q931.netid.facility_specification",
3581
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3582
14
            NULL, HFILL }
3583
14
        },
3584
14
        { &hf_q931_notification_description,
3585
14
          { "Notification description", "q931.notification_description",
3586
14
            FT_UINT8, BASE_HEX, VALS(q931_notification_description_vals), 0x7F,
3587
14
            NULL, HFILL }
3588
14
        },
3589
14
        { &hf_q931_signal,
3590
14
          { "Signal", "q931.signal",
3591
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_signal_vals_ext, 0x0,
3592
14
            NULL, HFILL }
3593
14
        },
3594
14
        { &hf_q931_information_rate_incoming,
3595
14
          { "Incoming information rate", "q931.information_rate.incoming",
3596
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_throughput_class_vals_ext, 0x1F,
3597
14
            NULL, HFILL }
3598
14
        },
3599
14
        { &hf_q931_information_rate_outgoing,
3600
14
          { "Outgoing information rate", "q931.information_rate.outgoing",
3601
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_throughput_class_vals_ext, 0x1F,
3602
14
            NULL, HFILL }
3603
14
        },
3604
14
        { &hf_q931_information_rate_minimum_incoming,
3605
14
          { "Minimum incoming information rate", "q931.information_rate.minimum_incoming",
3606
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_throughput_class_vals_ext, 0x1F,
3607
14
            NULL, HFILL }
3608
14
        },
3609
14
        { &hf_q931_information_rate_minimum_outgoing,
3610
14
          { "Minimum outgoing information rate", "q931.information_rate.minimum_outgoing",
3611
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_throughput_class_vals_ext, 0x1F,
3612
14
            NULL, HFILL }
3613
14
        },
3614
14
        { &hf_q931_fast_select,
3615
14
          { "Fast select", "q931.fast_select",
3616
14
            FT_UINT8, BASE_HEX, VALS(q931_fast_selected_vals), 0x18,
3617
14
            NULL, HFILL }
3618
14
        },
3619
14
        { &hf_q931_pl_window_size_forward_value,
3620
14
          { "Forward value", "q931.pl_window_size.forward_value",
3621
14
            FT_UINT8, BASE_DEC, NULL, 0x7F,
3622
14
            NULL, HFILL }
3623
14
        },
3624
14
        { &hf_q931_pl_window_size_backward_value,
3625
14
          { "Backward value", "q931.pl_window_size.backward_value",
3626
14
            FT_UINT8, BASE_DEC, NULL, 0x7F,
3627
14
            NULL, HFILL }
3628
14
        },
3629
14
        { &hf_q931_packet_size_forward_value,
3630
14
          { "Forward value", "q931.packet_size.forward_value",
3631
14
            FT_UINT8, BASE_DEC, NULL, 0x7F,
3632
14
            NULL, HFILL }
3633
14
        },
3634
14
        { &hf_q931_packet_size_backward_value,
3635
14
          { "Backward value", "q931.packet_size.backward_value",
3636
14
            FT_UINT8, BASE_DEC, NULL, 0x7F,
3637
14
            NULL, HFILL }
3638
14
        },
3639
14
        { &hf_q931_cug_indication,
3640
14
          { "CUG indication", "q931.cug_indication",
3641
14
            FT_UINT8, BASE_HEX, VALS(q931_cug_indication_vals), 0x07,
3642
14
            NULL, HFILL }
3643
14
        },
3644
14
        { &hf_q931_cug_index_code,
3645
14
          { "CUG index code", "q931.cug_index_code",
3646
14
            FT_STRING, BASE_NONE, NULL, 0x0,
3647
14
            NULL, HFILL }
3648
14
        },
3649
14
        { &hf_q931_reverse_charging_ind,
3650
14
          { "Reverse charging indication", "q931.reverse_charging_ind",
3651
14
            FT_UINT8, BASE_HEX, VALS(q931_reverse_charging_indication_vals), 0x07,
3652
14
            NULL, HFILL }
3653
14
        },
3654
14
        { &hf_q931_extension_reason,
3655
14
          { "Reason for redirection", "q931.extension.reason",
3656
14
            FT_UINT8, BASE_HEX, VALS(q931_redirection_reason_vals), 0x0F,
3657
14
            NULL, HFILL }
3658
14
        },
3659
14
        { &hf_q931_party_subaddr_type,
3660
14
          { "Type of subaddress", "q931.party_subaddr.type",
3661
14
            FT_UINT8, BASE_HEX, VALS(q931_subaddress_type_vals), 0x70,
3662
14
            NULL, HFILL }
3663
14
        },
3664
14
        { &hf_q931_party_subaddr_odd_even_indicator,
3665
14
          { "Odd/even indicator", "q931.party_subaddr.odd_even",
3666
14
            FT_UINT8, BASE_HEX, VALS(q931_odd_even_indicator_vals), 0x08,
3667
14
            NULL, HFILL }
3668
14
        },
3669
14
        { &hf_q931_party_subaddr,
3670
14
          { "Subaddress", "q931.party_subaddr",
3671
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3672
14
            NULL, HFILL }
3673
14
        },
3674
14
        { &hf_q931_restart_indicator,
3675
14
          { "Restart indicator", "q931.restart_indicator",
3676
14
            FT_UINT8, BASE_HEX, VALS(q931_restart_indicator_class_vals), 0x07,
3677
14
            NULL, HFILL }
3678
14
        },
3679
14
        { &hf_q931_high_layer_compat_data,
3680
14
          { "Data", "q931.high_layer_compat.data",
3681
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3682
14
            NULL, HFILL }
3683
14
        },
3684
14
        { &hf_q931_user_protocol_discriminator,
3685
14
          { "Protocol discriminator", "q931.user.protocol_discriminator",
3686
14
            FT_UINT8, BASE_HEX|BASE_EXT_STRING, &q931_protocol_discriminator_vals_ext, 0x0,
3687
14
            NULL, HFILL }
3688
14
        },
3689
14
        { &hf_q931_user_information_len,
3690
14
          { "User information", "q931.user.len",
3691
14
            FT_UINT32, BASE_DEC|BASE_UNIT_STRING, UNS(&units_octet_octets), 0x0,
3692
14
            NULL, HFILL }
3693
14
        },
3694
14
        { &hf_q931_user_information_str,
3695
14
          { "User information", "q931.user.string",
3696
14
            FT_STRING, BASE_NONE, NULL, 0x0,
3697
14
            NULL, HFILL }
3698
14
        },
3699
14
        { &hf_q931_user_information_bytes,
3700
14
          { "User information", "q931.user.bytes",
3701
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3702
14
            NULL, HFILL }
3703
14
        },
3704
14
        { &hf_q931_party_category,
3705
14
          { "Party category", "q931.party_category",
3706
14
            FT_UINT8, BASE_HEX, VALS(q931_party_category_vals), 0x07,
3707
14
            NULL, HFILL }
3708
14
        },
3709
14
        { &hf_q931_congestion_level,
3710
14
          { "Congestion level", "q931.congestion_level",
3711
14
            FT_UINT8, BASE_HEX, VALS(q931_congestion_level_vals), Q931_IE_SO_IE_MASK,
3712
14
            NULL, HFILL }
3713
14
        },
3714
14
        { &hf_q931_repeat_indicator,
3715
14
          { "Repeat indicator", "q931.repeat_indicator",
3716
14
            FT_UINT8, BASE_HEX, VALS(q931_repeat_indication_vals), Q931_IE_SO_IE_MASK,
3717
14
            NULL, HFILL }
3718
14
        },
3719
14
        { &hf_q931_out_band_negotiation,
3720
14
          { "Out-band negotiation", "q931.out_band_negotiation",
3721
14
            FT_BOOLEAN, 8, TFS(&tfs_possible_not_possible), 0x40,
3722
14
            NULL, HFILL }
3723
14
        },
3724
14
        { &hf_q931_layer_1,
3725
14
          { "Layer 1", "q931.layer_1",
3726
14
            FT_BOOLEAN, 8, TFS(&tfs_asynchronous_synchronous), 0x40,
3727
14
            NULL, HFILL }
3728
14
        },
3729
14
        { &hf_q931_layer_1_in_band_negotiation,
3730
14
          { "Layer 1 in-band negotiation", "q931.layer_1_in_band_negotiation",
3731
14
            FT_BOOLEAN, 8, TFS(&tfs_possible_not_possible), 0x20,
3732
14
            NULL, HFILL }
3733
14
        },
3734
14
        { &hf_q931_send_data_net_independent_clock,
3735
14
          { "Send data with network independent clock", "q931.send_data_net_independent_clock",
3736
14
            FT_BOOLEAN, 8, TFS(&tfs_required_not_required), 0x10,
3737
14
            NULL, HFILL }
3738
14
        },
3739
14
        { &hf_q931_accept_data_net_independent_clock,
3740
14
          { "Accept data with network independent clock", "q931.accept_data_net_independent_clock",
3741
14
            FT_BOOLEAN, 8, TFS(&tfs_accepted_not_accepted), 0x08,
3742
14
            NULL, HFILL }
3743
14
        },
3744
14
        { &hf_q931_send_data_flow_control,
3745
14
          { "Send data with flow control mechanism", "q931.send_data_flow_control",
3746
14
            FT_BOOLEAN, 8, TFS(&tfs_required_not_required), 0x04,
3747
14
            NULL, HFILL }
3748
14
        },
3749
14
        { &hf_q931_accept_data_flow_control,
3750
14
          { "Accept data with flow control mechanism", "q931.accept_data_flow_control",
3751
14
            FT_BOOLEAN, 8, TFS(&tfs_accepted_not_accepted), 0x2,
3752
14
            NULL, HFILL }
3753
14
        },
3754
14
        { &hf_q931_rate_adaption_header,
3755
14
          { "Rate adaption header", "q931.rate_adaption_header",
3756
14
            FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x40,
3757
14
            NULL, HFILL }
3758
14
        },
3759
14
        { &hf_q931_multiple_frame_establishment,
3760
14
          { "Multiple frame establishment", "q931.multiple_frame_establishment",
3761
14
            FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), 0x20,
3762
14
            NULL, HFILL }
3763
14
        },
3764
14
        { &hf_q931_mode_of_operation,
3765
14
          { "mode of operation", "q931.mode_of_operation",
3766
14
            FT_BOOLEAN, 8, TFS(&tfs_protocol_sensative_bit_transparent), 0x10,
3767
14
            NULL, HFILL }
3768
14
        },
3769
14
        { &hf_q931_message_originator,
3770
14
          { "Message originator", "q931.message_originator",
3771
14
            FT_BOOLEAN, 8, TFS(&tfs_assignor_default), 0x04,
3772
14
            NULL, HFILL }
3773
14
        },
3774
14
        { &hf_q931_negotiation_is_done,
3775
14
          { "Negotiation is done", "q931.negotiation_is_done",
3776
14
            FT_BOOLEAN, 8, TFS(&tfs_in_out_band), 0x02,
3777
14
            NULL, HFILL }
3778
14
        },
3779
14
        { &hf_q931_bearer_capability_duplex,
3780
14
          { "Duplex", "q931.bearer_capability.duplex",
3781
14
            FT_BOOLEAN, 8, TFS(&tfs_full_half), 0x40,
3782
14
            NULL, HFILL }
3783
14
        },
3784
14
        { &hf_q931_network_service,
3785
14
          { "Network service", "q931.network_service",
3786
14
            FT_BOOLEAN, 8, TFS(&tfs_user_provider), 0x80,
3787
14
            NULL, HFILL }
3788
14
        },
3789
14
        { &hf_q931_extension_condition_type,
3790
14
          { "Type", "q931.extension_condition_type",
3791
14
            FT_BOOLEAN, 8, TFS(&tfs_abnormal_normal), 0x40,
3792
14
            NULL, HFILL }
3793
14
        },
3794
14
        { &hf_q931_extension_condition,
3795
14
          { "Condition", "q931.extension_condition",
3796
14
            FT_UINT8, BASE_HEX, VALS(q931_cause_condition_vals), 0x03,
3797
14
            NULL, HFILL }
3798
14
        },
3799
14
        { &hf_q931_pl_request,
3800
14
          { "Request", "q931.pl_request",
3801
14
            FT_BOOLEAN, 8, TFS(&tfs_pl_request), 0x04,
3802
14
            NULL, HFILL }
3803
14
        },
3804
14
        { &hf_q931_pl_binary_confirmation,
3805
14
          { "Confirmation", "q931.pl_binary_confirmation",
3806
14
            FT_BOOLEAN, 8, TFS(&tfs_link_end), 0x02,
3807
14
            NULL, HFILL }
3808
14
        },
3809
14
        { &hf_q931_pl_modulus,
3810
14
          { "Modulus", "q931.pl_modulus",
3811
14
            FT_BOOLEAN, 8, TFS(&tfs_pl_modulus), 0x01,
3812
14
            NULL, HFILL }
3813
14
        },
3814
14
        { &hf_q931_data,
3815
14
          { "Data", "q931.data",
3816
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3817
14
            NULL, HFILL }
3818
14
        },
3819
14
        { &hf_q931_information_element,
3820
14
          { "Information element", "q931.information_element",
3821
14
            FT_UINT8, BASE_DEC, NULL, 0x0,
3822
14
            NULL, HFILL }
3823
14
        },
3824
14
        { &hf_q931_information_element_len,
3825
14
          { "Length", "q931.information_element_len",
3826
14
            FT_UINT16, BASE_DEC, NULL, 0x0,
3827
14
            NULL, HFILL }
3828
14
        },
3829
14
        { &hf_q931_date_time,
3830
14
          { "Date/time", "q931.date_time",
3831
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3832
14
            NULL, HFILL }
3833
14
        },
3834
14
        { &hf_q931_more_data,
3835
14
          { "More data", "q931.more_data",
3836
14
            FT_NONE, BASE_NONE, NULL, 0x0,
3837
14
            NULL, HFILL }
3838
14
        },
3839
14
        { &hf_q931_sending_complete,
3840
14
          { "Sending complete", "q931.sending_complete",
3841
14
            FT_NONE, BASE_NONE, NULL, 0x0,
3842
14
            NULL, HFILL }
3843
14
        },
3844
14
        { &hf_q931_message_segment,
3845
14
          { "Message segment", "q931.message_segment",
3846
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
3847
14
            NULL, HFILL }
3848
14
        },
3849
14
        { &hf_q931_missing_info_element,
3850
14
          { "Missing information element", "q931.missing_info_element",
3851
14
            FT_UINT8, BASE_HEX, NULL, 0x0,
3852
14
            NULL, HFILL }
3853
14
        },
3854
14
        { &hf_q931_insufficient_info_element,
3855
14
          { "Insufficient information element", "q931.insufficient_info_element",
3856
14
            FT_UINT8, BASE_HEX, NULL, 0x0,
3857
14
            NULL, HFILL }
3858
14
        },
3859
14
        { &hf_q931_cumulative_transit_delay,
3860
14
          { "Cumulative transit delay", "q931.cumulative_transit_delay",
3861
14
            FT_UINT16, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
3862
14
            NULL, HFILL }
3863
14
        },
3864
14
        { &hf_q931_requested_end_to_end_transit_delay,
3865
14
          { "Requested end-to-end transit delay", "q931.requested_end_to_end_transit_delay",
3866
14
            FT_UINT16, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
3867
14
            NULL, HFILL }
3868
14
        },
3869
14
        { &hf_q931_maximum_end_to_end_transit_delay,
3870
14
          { "Maximum end-to-end transit delay", "q931.maximum_end_to_end_transit_delay",
3871
14
            FT_UINT16, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
3872
14
            NULL, HFILL }
3873
14
        },
3874
14
        { &hf_q931_transit_delay,
3875
14
          { "Transit delay", "q931.transit_delay",
3876
14
            FT_UINT16, BASE_DEC|BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0,
3877
14
            NULL, HFILL }
3878
14
        },
3879
14
        { &hf_q931_display_information,
3880
14
          { "Display information", "q931.display_information",
3881
14
            FT_STRING, BASE_NONE, NULL, 0x0,
3882
14
            NULL, HFILL }
3883
14
        },
3884
14
        { &hf_q931_keypad_facility,
3885
14
          { "Keypad facility", "q931.keypad_facility",
3886
14
            FT_STRING, BASE_NONE, NULL, 0x0,
3887
14
            NULL, HFILL }
3888
14
        },
3889
14
        { &hf_q931_avaya_display,
3890
14
          { "Avaya Display", "q931.avaya_display",
3891
14
            FT_STRING, BASE_NONE, NULL, 0x0,
3892
14
            NULL, HFILL }
3893
14
        },
3894
14
        { &hf_q931_locking_codeset,
3895
14
          { "Locking codeset", "q931.locking_codeset",
3896
14
            FT_UINT8, BASE_DEC, NULL, 0x0,
3897
14
            NULL, HFILL }
3898
14
        },
3899
14
        { &hf_q931_protocol_negotiation,
3900
14
          { "Protocol negotiation", "q931.protocol_negotiation",
3901
14
            FT_BOOLEAN, 8, TFS(&tfs_protocol_negotiation), 0x08,
3902
14
            NULL, HFILL }
3903
14
        },
3904
14
    };
3905
3906
14
#define NUM_INDIVIDUAL_ELEMS    3
3907
14
    static int *ett[NUM_INDIVIDUAL_ELEMS + NUM_IE];
3908
3909
14
    static ei_register_info ei[] = {
3910
14
        { &ei_q931_invalid_length, { "q931.invalid_length", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
3911
14
        { &ei_q931_date_time, { "q931.date_time.invalid", PI_MALFORMED, PI_ERROR, "Date/time: Invalid length", EXPFILL }},
3912
14
        { &ei_q931_information_element, { "q931.information_element.unknown", PI_PROTOCOL, PI_WARN, "Unknown information element", EXPFILL }},
3913
14
        { &ei_q931_incomplete_ie, { "q931.incomplete_ie", PI_MALFORMED, PI_ERROR, "Incomplete IE in the 1st segment", EXPFILL }},
3914
14
    };
3915
3916
14
    module_t *q931_module;
3917
14
    expert_module_t* expert_q931;
3918
3919
14
    ett[0] = &ett_q931;
3920
14
    ett[1] = &ett_q931_segments;
3921
14
    ett[2] = &ett_q931_segment;
3922
3923
14
    last_offset = NUM_INDIVIDUAL_ELEMS;
3924
3925
3.59k
    for (i=0; i < NUM_IE; i++, last_offset++)
3926
3.58k
    {
3927
3.58k
        ett[last_offset] = &ett_q931_ie[i];
3928
3.58k
    }
3929
3930
14
    proto_q931 = proto_register_protocol("Q.931", "Q.931", "q931");
3931
14
    proto_register_field_array (proto_q931, hf, array_length(hf));
3932
14
    proto_register_subtree_array(ett, array_length(ett));
3933
14
    expert_q931 = expert_register_protocol(proto_q931);
3934
14
    expert_register_field_array(expert_q931, ei, array_length(ei));
3935
3936
14
    reassembly_table_register(&q931_reassembly_table,
3937
14
                &addresses_reassembly_table_functions);
3938
3939
14
    q931_handle = register_dissector("q931", dissect_q931, proto_q931);
3940
14
    q931_tpkt_handle = register_dissector("q931.tpkt", dissect_q931_tpkt, proto_q931);
3941
14
    q931_tpkt_pdu_handle = create_dissector_handle(dissect_q931_tpkt_pdu,
3942
14
        proto_q931);
3943
14
    q931_over_ip_handle = register_dissector("q931.over_ip", dissect_q931_over_ip, proto_q931);
3944
14
    register_dissector("q931.ie", dissect_q931_ie_cs0, proto_q931);
3945
14
    register_dissector("q931.ie.cs7", dissect_q931_ie_cs7, proto_q931);
3946
3947
    /* subdissector code */
3948
14
    codeset_dissector_table = register_dissector_table("q931.codeset", "Q.931 Codeset", proto_q931, FT_UINT8, BASE_HEX);
3949
14
    ie_dissector_table = register_dissector_table("q931.ie", "Q.931 IE", proto_q931, FT_UINT16, BASE_HEX);
3950
14
    q931_user_heur_subdissector_list = register_heur_dissector_list_with_description("q931_user", "Q.931 IE User payload", proto_q931);
3951
3952
14
    q931_module = prefs_register_protocol(proto_q931, NULL);
3953
14
    prefs_register_bool_preference(q931_module, "desegment_h323_messages",
3954
14
        "Reassemble Q.931 messages spanning multiple TCP segments",
3955
14
        "Whether the Q.931 dissector should reassemble messages spanning multiple TCP segments."
3956
14
        " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
3957
14
        &q931_desegment);
3958
14
    prefs_register_bool_preference(q931_module, "reassembly",
3959
14
        "Reassemble segmented Q.931 messages",
3960
14
        "Reassemble segmented Q.931 messages (Q.931 - Annex H)",
3961
14
        &q931_reassembly);
3962
14
    prefs_register_bool_preference(q931_module, "iso_iec_cause_coding",
3963
14
        "Decode ISO/IEC cause coding standard as ITU-T",
3964
14
        "Decode ISO/IEC cause coding standard as ITU-T",
3965
14
        &g931_iso_iec_cause);
3966
    /* Register for tapping */
3967
14
    q931_tap = register_tap("q931");
3968
3969
14
    register_external_value_string_ext("q931_cause_code_vals_ext", &q931_cause_code_vals_ext);
3970
14
    register_external_value_string("q931_message_type_vals", q931_message_type_vals);
3971
14
}
3972
3973
void
3974
proto_reg_handoff_q931(void)
3975
14
{
3976
14
    dissector_add_uint("lapd.sapi", LAPD_SAPI_Q931, q931_handle);
3977
14
    dissector_add_uint("sctp.ppi", H323_PAYLOAD_PROTOCOL_ID, q931_over_ip_handle);
3978
14
    dissector_add_uint("osinl.incl", NLPID_Q_931, q931_handle);
3979
3980
    /*
3981
     * Attempt to get a handle for the H.225 dissector.
3982
     * If we can't, the handle we get is null, and we'll just
3983
     * dissect putatively-H.255 Call Signaling stuff as User
3984
     * Information.
3985
     */
3986
14
    h225_handle = find_dissector_add_dependency("h225", proto_q931);
3987
3988
    /*
3989
     * For H.323.
3990
     */
3991
14
    heur_dissector_add("tcp", dissect_q931_tpkt_heur, "Q.931 over TPKT over TCP", "q931_tcp", proto_q931, HEURISTIC_ENABLE);
3992
14
}
3993
3994
static void reset_q931_packet_info(q931_packet_info *pi)
3995
1.03k
{
3996
1.03k
    if(pi == NULL) {
3997
0
        return;
3998
0
    }
3999
4000
1.03k
    pi->calling_number = NULL;
4001
    pi->called_number = NULL;
4002
1.03k
    pi->cause_value = 0xFF;
4003
1.03k
    pi->crv = -1;
4004
1.03k
}
4005
4006
/*
4007
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
4008
 *
4009
 * Local variables:
4010
 * c-basic-offset: 4
4011
 * tab-width: 8
4012
 * indent-tabs-mode: nil
4013
 * End:
4014
 *
4015
 * vi: set shiftwidth=4 tabstop=8 expandtab:
4016
 * :indentSize=4:tabSize=8:noTabs=true:
4017
 */