Coverage Report

Created: 2026-09-28 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-v5ua.c
Line
Count
Source
1
/* packet-v5ua.c
2
 *
3
 * Extension of all V5.2-User Adaptation Layer dissection elements
4
 * References:
5
 * RFC 3807
6
 * RFC 4233
7
 * RFC 5133
8
 *
9
 * Copyright 2009
10
 *
11
 * ISKRATEL d.o.o.            |       4S d.o.o.
12
 * http://www.iskratel.si/    |       http://www.4es.si/
13
 * <info@iskratel.si>         |       <projects@4es.si>
14
 * Vladimir Smrekar <vladimir.smrekar@gmail.com>
15
 *
16
 * Routines for V5.2-User Adaptation Layer dissection
17
 *
18
 * Extension of ISDN Q.921-User Adaptation Layer dissection
19
 * Copyright 2002, Michael Tuexen <Michael.Tuexen[AT]siemens.com>
20
 *
21
 * Christoph Neusch <christoph.neusch@nortelnetworks.com>
22
 *
23
 * Wireshark - Network traffic analyzer
24
 * By Gerald Combs <gerald@wireshark.org>
25
 * Copyright 1998 Gerald Combs
26
 *
27
 * SPDX-License-Identifier: GPL-2.0-or-later
28
 */
29
30
#include "config.h"
31
32
#include <epan/packet.h>
33
34
#include <wsutil/str_util.h>
35
#include <wsutil/ws_roundup.h>
36
37
#include "packet-sctp.h"
38
39
void proto_register_v5ua(void);
40
void proto_reg_handoff_v5ua(void);
41
42
static dissector_handle_t v5ua_handle;
43
44
static int paddingl;
45
static int dlci_efa = -1;
46
47
/* Initialize the protocol and registered fields */
48
static int proto_v5ua;
49
50
static dissector_handle_t q931_handle;
51
static dissector_handle_t v52_handle;
52
53
/* common msg-header */
54
static int hf_version;
55
static int hf_reserved;
56
static int hf_msg_class;
57
static int hf_msg_type;
58
/* static int hf_msg_type_id; */
59
static int hf_msg_length;
60
/* V5UA message header */
61
static int hf_link_id;
62
static int hf_chnl_id;
63
static int hf_adaptation_layer_id;
64
static int hf_text_if_id;
65
static int hf_scn_protocol_id;
66
static int hf_info_string;
67
static int hf_asp_identifier;
68
static int hf_dlci_zero_bit;
69
static int hf_dlci_spare_bit;
70
static int hf_dlci_sapi;
71
static int hf_dlci_one_bit;
72
static int hf_dlci_tei;
73
static int hf_efa;
74
/* static int hf_spare_efa; */
75
/* variable length parameter (msg) */
76
static int hf_parameter_tag;
77
static int hf_parameter_tag_draft;
78
static int hf_parameter_length;
79
static int hf_parameter_value;
80
static int hf_parameter_padding;
81
82
 /* parameter fields */
83
static int hf_link_status;
84
static int hf_sa_bit_id;
85
static int hf_sa_bit_value;
86
static int hf_diagnostic_info;
87
static int hf_if_range_start;
88
static int hf_if_range_end;
89
static int hf_heartbeat_data;
90
static int hf_traffic_mode_type;
91
static int hf_error_code;
92
static int hf_draft_error_code;
93
static int hf_status_type;
94
static int hf_status_id;
95
static int hf_error_reason;
96
static int hf_asp_reason;
97
static int hf_tei_status;
98
static int hf_tei_draft_status;
99
static int hf_release_reason;
100
101
/* Initialize the subtree pointers */
102
static int ett_v5ua;
103
static int ett_v5ua_common_header;
104
static int ett_v5ua_parameter;
105
static int ett_v5ua_layer3;
106
107
393
#define RFC             0x1
108
16.3k
#define DRAFT           0x2
109
 /* Version of IUA */
110
static int iua_version = RFC;
111
/* Variables necessary for dissection of draft messages */
112
static int msg_class   = -1;
113
static int msg_type    = -1;
114
static int msg_length  = -1;
115
static int messageclassCopy = -1;
116
static int sa_bit_id = -1;
117
static int link_status_operational = -1;
118
119
/* Code to actually dissect the packets */
120
121
 /* define the parameters for the Tags: Tag-Type,Tag-Length,Tag-Value (Payload) */
122
2.22k
#define PARAMETER_TAG_OFFSET    0
123
1.78k
#define PARAMETER_TAG_LENGTH    2
124
1.16k
#define PARAMETER_LENGTH_OFFSET (PARAMETER_TAG_OFFSET + PARAMETER_TAG_LENGTH)
125
860
#define PARAMETER_LENGTH_LENGTH 2
126
240
#define PARAMETER_VALUE_OFFSET  (PARAMETER_LENGTH_OFFSET + PARAMETER_LENGTH_LENGTH)
127
273
#define PARAMETER_HEADER_OFFSET PARAMETER_TAG_OFFSET
128
389
#define PARAMETER_HEADER_LENGTH (PARAMETER_TAG_LENGTH + PARAMETER_LENGTH_LENGTH)
129
130
131
/*----------------------V5UA Interface Identifier (int) (Draft,RFC)------------*/
132
133
 /* define parameter for the format of the integer formatted Interface Identifier */
134
6
#define INT_IF_ID_LINK_OFFSET PARAMETER_VALUE_OFFSET
135
300
#define INT_IF_ID_LINK_LENGTH 4
136
#define INT_IF_ID_CHNL_OFFSET INT_IF_ID_LINK_OFFSET
137
300
#define INT_IF_ID_CHNL_LENGTH 1
138
306
#define INT_INTERFACE_ID_LENGTH 4
139
140
static int linkIdentifier = -1;
141
142
static void
143
dissect_int_interface_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
144
6
{
145
6
   uint32_t identifier;
146
6
   uint16_t number_of_ids, id_number;
147
6
   int offset;
148
149
6
   number_of_ids= (tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH) / INT_INTERFACE_ID_LENGTH;
150
151
6
   offset = INT_IF_ID_LINK_OFFSET;
152
6
   proto_item_append_text(parameter_item, "(");
153
306
   for (id_number = 0; id_number < number_of_ids; id_number++) {
154
300
      proto_tree_add_item(parameter_tree, hf_link_id, parameter_tvb, offset, INT_IF_ID_LINK_LENGTH, ENC_BIG_ENDIAN);
155
300
      identifier = tvb_get_ntohl(parameter_tvb,offset)>>5;
156
300
      if (id_number < 1) {
157
4
         proto_item_append_text(parameter_item, "L:%d",identifier);
158
296
      } else {
159
296
         proto_item_append_text(parameter_item, " | L:%d",identifier);
160
296
      }
161
300
      linkIdentifier = identifier;
162
163
300
      proto_tree_add_item(parameter_tree, hf_chnl_id, parameter_tvb, offset+3, INT_IF_ID_CHNL_LENGTH, ENC_BIG_ENDIAN);
164
300
      identifier = tvb_get_uint8(parameter_tvb,offset+3)&0x1f;
165
300
      proto_item_append_text(parameter_item, " C:%d", identifier);
166
300
      offset += INT_INTERFACE_ID_LENGTH;
167
300
   }
168
6
   proto_item_append_text(parameter_item, ")");
169
6
}
170
/*----------------------V5UA Interface Identifier (int) (Draft,RFC)------------*/
171
172
/*----------------------Text Interface Identifier (RFC)------------------------*/
173
174
0
#define TEXT_IF_ID_LENGTH_OFFSET PARAMETER_LENGTH_OFFSET
175
0
#define TEXT_IF_ID_VALUE_OFFSET  PARAMETER_VALUE_OFFSET
176
0
#define TEXT_IF_ID_HEADER_LENGTH PARAMETER_HEADER_LENGTH
177
178
static void
179
dissect_text_interface_identifier_parameter(packet_info *pinfo, tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
180
0
{
181
0
   uint16_t if_id_length;
182
0
   const uint8_t* str;
183
184
0
   if_id_length = tvb_get_ntohs(parameter_tvb, TEXT_IF_ID_LENGTH_OFFSET) - TEXT_IF_ID_HEADER_LENGTH;
185
186
0
   proto_tree_add_item_ret_string(parameter_tree, hf_text_if_id, parameter_tvb, TEXT_IF_ID_VALUE_OFFSET, if_id_length, ENC_ASCII, pinfo->pool, &str);
187
0
   proto_item_append_text(parameter_item, " (0x%s)", str);
188
0
}
189
/*----------------------Text Interface Identifier (RFC)------------------------*/
190
191
/*----------------------DLCI & Envelope Function Address------------------------*/
192
193
194
/* interpretation of EFA-values */
195
static const value_string efa_values[] = {
196
 { 8175, "ISDN Protocol" },
197
 { 8176, "PSTN Protocol" },
198
 { 8177, "CONTROL Protocol" },
199
 { 8178, "BCC Protocol" },
200
 { 8179, "PROT Protocol" },
201
 { 8180, "Link Control Protocol" },
202
 { 8191, "VALUE RESERVED" },
203
 { 0,    NULL } };
204
205
3
#define DLCI_LENGTH_OFFSET PARAMETER_LENGTH_OFFSET
206
1
#define DLCI_SAPI_OFFSET   PARAMETER_VALUE_OFFSET
207
3
#define DLCI_HEADER_LENGTH PARAMETER_HEADER_LENGTH
208
209
16
#define DLCI_SAPI_LENGTH   1
210
12
#define DLCI_TEI_LENGTH    1
211
4
#define EFA_LENGTH         2
212
213
static void
214
dissect_dlci_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, packet_info *pinfo)
215
4
{
216
4
   uint16_t efa = 0, offset = 0;
217
218
4
   uint32_t sapi, tei;
219
220
4
   if     (iua_version == RFC)   offset = DLCI_SAPI_OFFSET;
221
3
   else if(iua_version == DRAFT) offset = DLCI_HEADER_LENGTH + tvb_get_ntohs(parameter_tvb, DLCI_LENGTH_OFFSET);
222
223
4
   proto_tree_add_item(parameter_tree, hf_dlci_zero_bit,      parameter_tvb, offset,  DLCI_SAPI_LENGTH,  ENC_BIG_ENDIAN);
224
4
   proto_tree_add_item(parameter_tree, hf_dlci_spare_bit,     parameter_tvb, offset,  DLCI_SAPI_LENGTH,  ENC_BIG_ENDIAN);
225
4
   proto_tree_add_item_ret_uint(parameter_tree, hf_dlci_sapi, parameter_tvb, offset,  DLCI_SAPI_LENGTH,  ENC_BIG_ENDIAN, &sapi);
226
227
4
   offset += DLCI_SAPI_LENGTH;
228
4
   proto_tree_add_item(parameter_tree, hf_dlci_one_bit,       parameter_tvb, offset,  DLCI_TEI_LENGTH,   ENC_BIG_ENDIAN);
229
4
   proto_tree_add_item_ret_uint(parameter_tree, hf_dlci_tei,  parameter_tvb, offset,  DLCI_TEI_LENGTH,   ENC_BIG_ENDIAN, &tei);
230
231
4
   offset += DLCI_TEI_LENGTH;
232
4
   efa = tvb_get_ntohs(parameter_tvb, offset);
233
4
   dlci_efa = tvb_get_ntohs(parameter_tvb, offset);
234
235
4
   if (dlci_efa >= 0 && dlci_efa <= 8175) { col_append_fstr(pinfo->cinfo, COL_INFO, " | ISDN: %u", dlci_efa); }
236
0
   else if (dlci_efa == 8176) { col_append_str(pinfo->cinfo, COL_INFO, " | PSTN"); }
237
0
   else if (dlci_efa == 8177) { col_append_str(pinfo->cinfo, COL_INFO, " | Ctrl"); }
238
0
   else if (dlci_efa == 8178) { col_append_str(pinfo->cinfo, COL_INFO, " | BCC"); }
239
0
   else if (dlci_efa == 8179) { col_append_str(pinfo->cinfo, COL_INFO, " | ProtProt"); }
240
0
   else if (dlci_efa == 8180) { col_append_str(pinfo->cinfo, COL_INFO, " | LinkCtrl"); }
241
242
4
   if(efa <= 8175) {
243
4
      proto_tree_add_uint_format_value(parameter_tree, hf_efa,  parameter_tvb, offset, EFA_LENGTH, efa,
244
4
            "ISDN (%u)", efa);
245
4
      proto_item_append_text(parameter_item, " (SAPI:%u TEI:%u EFA:ISDN (%u))",sapi,tei,efa);
246
4
   }
247
0
   else if (efa <= 8180){
248
0
      proto_tree_add_uint_format_value(parameter_tree, hf_efa,  parameter_tvb, offset, EFA_LENGTH, efa,
249
0
            "%s (%u)", val_to_str_const(efa, efa_values, "unknown EFA"),tvb_get_ntohs(parameter_tvb, offset));
250
0
      proto_item_append_text(parameter_item, " (SAPI:%u TEI:%u EFA:%s (%u))",sapi,tei,val_to_str_const(efa, efa_values, "unknown EFA-value"),efa);
251
0
   }
252
0
   else {
253
0
      proto_tree_add_uint_format_value(parameter_tree, hf_efa,  parameter_tvb, offset, EFA_LENGTH, efa,
254
0
            "RESERVED (%u)", efa);
255
0
      proto_item_append_text(parameter_item, " (SAPI:%u TEI:%u EFA:RESERVED (%u))",sapi,tei,efa);
256
0
   }
257
258
259
4
}
260
/*----------------------DLCI & Envelope Function Address------------------------*/
261
262
/*----------------------Error Indication (Draft)-------------------------------*/
263
264
 /* define Error Code Parameter for Layer Management (MGMT) Messages */
265
#define MGMT_ERROR_INVALID_TEI_DRAFT                       0x00
266
#define MGMT_ERROR_INVALID_IFID_DRAFT                      0x01
267
#define MGMT_ERROR_UNDEFINIED_MSG_DRAFT                    0x02
268
#define MGMT_ERROR_VERSION_ERR_DRAFT                       0x03
269
#define MGMT_ERROR_INVALID_STID_DRAFT                      0x04
270
#define MGMT_ERROR_INVALID_SCNV_DRAFT                      0x05
271
#define MGMT_ERROR_INVALID_ALI_DRAFT                       0x06
272
273
static const value_string draft_error_code_values[] = {
274
  { MGMT_ERROR_INVALID_TEI_DRAFT,     "Invalid TEI" },
275
  { MGMT_ERROR_INVALID_IFID_DRAFT,    "Invalid interface ID" },
276
  { MGMT_ERROR_UNDEFINIED_MSG_DRAFT,  "An unexpected message was received" },
277
  { MGMT_ERROR_VERSION_ERR_DRAFT,     "The IUA layers are of different version" },
278
  { MGMT_ERROR_INVALID_STID_DRAFT,    "Invalid SCTP stream identifier" },
279
  { MGMT_ERROR_INVALID_SCNV_DRAFT,    "Invalid SCN version" },
280
  { MGMT_ERROR_INVALID_ALI_DRAFT,     "Invalid Adaptation Layer Identifier" },
281
  { 0,                                NULL } };
282
283
1
#define MGMT_ERROR_MSG_LENGTH_OFFSET PARAMETER_LENGTH_OFFSET
284
1
#define MGMT_ERROR_MSG_HEADER_LENGTH PARAMETER_HEADER_LENGTH
285
286
0
#define MGMT_ERROR_CODE_LENGTH 4
287
288
static void
289
dissect_draft_error_code_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
290
0
{
291
0
   uint16_t offset = MGMT_ERROR_MSG_HEADER_LENGTH + tvb_get_ntohs(parameter_tvb, MGMT_ERROR_MSG_LENGTH_OFFSET) + 4;
292
0
   proto_tree_add_item(parameter_tree, hf_draft_error_code, parameter_tvb, offset, MGMT_ERROR_CODE_LENGTH, ENC_BIG_ENDIAN);
293
0
   offset += MGMT_ERROR_CODE_LENGTH ;
294
0
   if( tvb_reported_length_remaining(parameter_tvb,offset) > 0 )
295
0
      proto_tree_add_item(parameter_tree, hf_info_string, parameter_tvb, offset, msg_length - offset,ENC_ASCII);
296
0
}
297
/*----------------------Error Indication (Draft)-------------------------------*/
298
299
/*----------------------Error Indication (RFC)---------------------------------*/
300
301
 /* define Error Code Parameter for Layer Management (MGMT) Messages */
302
#define MGMT_ERROR_INVALID_VERSION                     0x01
303
#define MGMT_ERROR_INVALID_IF_ID                       0x02
304
#define MGMT_ERROR_UNSUPPORTED_MSG_CLASS               0x03
305
#define MGMT_ERROR_UNSUPPORTED_MSG_TYPE                0x04
306
#define MGMT_ERROR_UNSUPPORTED_TRAFFIC_HANDLING_MODE   0x05
307
#define MGMT_ERROR_UNEXPECTED_MSG                      0x06
308
#define MGMT_ERROR_PROTOCOL_ERROR                      0x07
309
#define MGMT_ERROR_UNSUPPORTED_IF_ID_TYPE              0x08
310
#define MGMT_ERROR_INVALID_STREAM_ID                   0x09
311
#define MGMT_ERROR_UNASSIGNED_TEI                      0x0a
312
#define MGMT_ERROR_UNRECOGNIZED_SAPI                   0x0b
313
#define MGMT_ERROR_INVALID_TEI_SAPI_COMBINATION        0x0c
314
315
static const value_string error_code_values[] = {
316
  { MGMT_ERROR_INVALID_VERSION,                       "Invalid version" },
317
  { MGMT_ERROR_INVALID_IF_ID,                         "Invalid interface identifier" },
318
  { MGMT_ERROR_UNSUPPORTED_MSG_CLASS,                 "Unsupported message class" },
319
  { MGMT_ERROR_UNSUPPORTED_MSG_TYPE,                  "Unsupported message type" },
320
  { MGMT_ERROR_UNSUPPORTED_TRAFFIC_HANDLING_MODE,     "Unsupported traffic handling mode" },
321
  { MGMT_ERROR_UNEXPECTED_MSG,                        "Unexpected message" },
322
  { MGMT_ERROR_PROTOCOL_ERROR,                        "Protocol error" },
323
  { MGMT_ERROR_UNSUPPORTED_IF_ID_TYPE,                "Unsupported interface identifier type" },
324
  { MGMT_ERROR_INVALID_STREAM_ID,                     "Invalid stream identifier" },
325
  { MGMT_ERROR_UNASSIGNED_TEI,                        "Unassigned TEI" },
326
  { MGMT_ERROR_UNRECOGNIZED_SAPI,                     "Unrecognized SAPI" },
327
  { MGMT_ERROR_INVALID_TEI_SAPI_COMBINATION,          "Invalid TEI/SAPI combination" },
328
  { 0,                                                NULL } };
329
330
0
#define MGMT_ERROR_CODE_OFFSET PARAMETER_VALUE_OFFSET
331
332
static void
333
dissect_error_code_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
334
0
{
335
0
   proto_tree_add_item(parameter_tree, hf_error_code, parameter_tvb, MGMT_ERROR_CODE_OFFSET, MGMT_ERROR_CODE_LENGTH, ENC_BIG_ENDIAN);
336
0
   proto_item_append_text(parameter_item, " (%s)",
337
0
         val_to_str_const(tvb_get_ntohl(parameter_tvb, MGMT_ERROR_CODE_OFFSET), error_code_values, "Unknown error code"));
338
0
}
339
340
static void
341
dissect_diagnostic_information_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
342
1
{
343
1
   uint16_t diag_info_length;
344
345
1
   diag_info_length = tvb_get_ntohs(parameter_tvb, MGMT_ERROR_MSG_LENGTH_OFFSET) - MGMT_ERROR_MSG_HEADER_LENGTH;
346
1
   proto_tree_add_item(parameter_tree, hf_diagnostic_info, parameter_tvb, PARAMETER_VALUE_OFFSET, diag_info_length, ENC_NA);
347
1
   proto_item_append_text(parameter_item, " (%u byte%s)", diag_info_length, plurality(diag_info_length, "", "s"));
348
1
}
349
/*----------------------Error Indication (RFC)---------------------------------*/
350
351
/*----------------------Notify (RFC)-------------------------------------------*/
352
353
 /* define Status Type parameters for Notify (NTFY) Messages */
354
#define NTFY_STATUS_TYPE_AS_STATE_CHANGE  0x01
355
#define NTFY_STATUS_TYPE_OTHER            0x02
356
357
static const value_string status_type_values[] = {
358
   { NTFY_STATUS_TYPE_AS_STATE_CHANGE,        "Application server state change" },
359
   { NTFY_STATUS_TYPE_OTHER,                  "Other" },
360
   { 0,                                       NULL } };
361
362
 /* define Status Identification parameters for NTFY Messages (AS state change)*/
363
#define NTFY_STATUS_IDENT_AS_DOWN          0x01
364
#define NTFY_STATUS_IDENT_AS_INACTIVE      0x02
365
#define NTFY_STATUS_IDENT_AS_ACTIVE        0x03
366
#define NTFY_STATUS_IDENT_AS_PENDING       0x04
367
 /* define Status Identification parameters for NTFY Messages (Other)*/
368
#define NTFY_STATUS_INSUFFICIENT_ASP_RES_ACTIVE 0x01
369
#define NTFY_STATUS_ALTERNATE_ASP_ACTIVE        0x02
370
371
static const value_string status_type_id_values[] = {
372
   { NTFY_STATUS_TYPE_AS_STATE_CHANGE * 256 * 256 + NTFY_STATUS_IDENT_AS_DOWN,         "Application server down" },
373
   { NTFY_STATUS_TYPE_AS_STATE_CHANGE * 256 * 256 + NTFY_STATUS_IDENT_AS_INACTIVE,     "Application server inactive" },
374
   { NTFY_STATUS_TYPE_AS_STATE_CHANGE * 256 * 256 + NTFY_STATUS_IDENT_AS_ACTIVE,       "Application server active" },
375
   { NTFY_STATUS_TYPE_AS_STATE_CHANGE * 256 * 256 + NTFY_STATUS_IDENT_AS_PENDING,      "Application server pending" },
376
   { NTFY_STATUS_TYPE_OTHER * 256 * 256 + NTFY_STATUS_INSUFFICIENT_ASP_RES_ACTIVE,     "Insufficient ASP resources active in AS" },
377
   { NTFY_STATUS_TYPE_OTHER * 256 * 256 + NTFY_STATUS_ALTERNATE_ASP_ACTIVE,            "Alternate ASP active" },
378
   { 0,                                           NULL } };
379
380
8
#define NTFY_STATUS_TYPE_OFFSET  PARAMETER_VALUE_OFFSET
381
6
#define NTFY_STATUS_TYPE_LENGTH  2
382
4
#define NTFY_STATUS_IDENT_OFFSET (NTFY_STATUS_TYPE_OFFSET + NTFY_STATUS_TYPE_LENGTH)
383
2
#define NTFY_STATUS_IDENT_LENGTH 2
384
385
static void
386
dissect_status_type_identification_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
387
2
{
388
2
   uint16_t status_type, status_id;
389
390
2
   status_type = tvb_get_ntohs(parameter_tvb, NTFY_STATUS_TYPE_OFFSET);
391
2
   status_id   = tvb_get_ntohs(parameter_tvb, NTFY_STATUS_IDENT_OFFSET);
392
393
2
   proto_tree_add_item(parameter_tree, hf_status_type, parameter_tvb, NTFY_STATUS_TYPE_OFFSET, NTFY_STATUS_TYPE_LENGTH, ENC_BIG_ENDIAN);
394
2
   proto_tree_add_uint_format_value(parameter_tree, hf_status_id,  parameter_tvb, NTFY_STATUS_IDENT_OFFSET, NTFY_STATUS_IDENT_LENGTH,
395
2
         status_id, "%u (%s)", status_id,
396
2
         val_to_str_const((unsigned)status_type * 256 * 256 + status_id, status_type_id_values, "unknown"));
397
398
2
   proto_item_append_text(parameter_item, " (%s)",
399
2
         val_to_str_const((unsigned)status_type * 256 * 256 + status_id, status_type_id_values, "Unknown status information"));
400
2
}
401
/*----------------------Notify (RFC)-------------------------------------------*/
402
403
/*----------------------TEI Status Indication,Confirm (RFC)--------------------*/
404
405
 /* define parameters for TEI Status (Indication,Confirm) Messages */
406
#define TEI_STATUS_ASSIGNED       0x0
407
#define TEI_STATUS_UNASSIGNED     0x1
408
409
static const value_string tei_status_values[] = {
410
   { TEI_STATUS_ASSIGNED,   "TEI is considered assigned by Q.921" },
411
   { TEI_STATUS_UNASSIGNED, "TEI is considered unassigned by Q.921" },
412
   { 0,                     NULL } };
413
414
6
#define TEI_STATUS_OFFSET PARAMETER_VALUE_OFFSET
415
4
#define TEI_STATUS_LENGTH 4
416
417
static void
418
dissect_tei_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
419
3
{
420
3
   proto_tree_add_item(parameter_tree, hf_tei_status, parameter_tvb, TEI_STATUS_OFFSET, TEI_STATUS_LENGTH, ENC_BIG_ENDIAN);
421
3
   proto_item_append_text(parameter_item, " (%s)",
422
3
         val_to_str_const(tvb_get_ntohl(parameter_tvb, TEI_STATUS_OFFSET), tei_status_values, "Unknown TEI status"));
423
3
}
424
/*----------------------TEI Status (RFC)---------------------------------------*/
425
426
/*----------------------TEI Status Indication,Confirm (Draft)------------------*/
427
#define TEI_DRAFT_IN_SERVICE     0x0
428
#define TEI_DRAFT_OUT_OF_SERVICE 0x1
429
430
static const value_string tei_draft_status_values[] = {
431
   { TEI_DRAFT_IN_SERVICE,    "TEI is in service" },
432
   { TEI_DRAFT_OUT_OF_SERVICE,"TEI is out of service" },
433
   { 0,                       NULL } };
434
435
1
#define TEI_STATUS_LENGTH_OFFSET PARAMETER_LENGTH_OFFSET
436
437
static void
438
dissect_draft_tei_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
439
1
{
440
1
   int offset;
441
1
   offset = tvb_get_ntohs(parameter_tvb, TEI_STATUS_LENGTH_OFFSET) + 8;
442
1
   if(tvb_reported_length_remaining(parameter_tvb, offset) > 0 ){
443
1
      proto_tree_add_item(parameter_tree, hf_tei_draft_status, parameter_tvb, offset, TEI_STATUS_LENGTH, ENC_BIG_ENDIAN);
444
1
      proto_item_append_text(parameter_item, " (%s)",
445
1
            val_to_str_const(tvb_get_ntohl(parameter_tvb, offset), tei_draft_status_values, "Unknown TEI Status"));
446
1
   }
447
1
}
448
/*----------------------TEI Status (Draft)-------------------------------------*/
449
450
/*----------------------ASP Up,Down,Active,Inactive (Draft)--------------------*/
451
452
static void
453
dissect_asp_msg_parameter(packet_info *pinfo, tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
454
1
{
455
1
   const uint8_t* str;
456
1
   uint16_t adaptation_layer_id_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
457
458
1
   proto_tree_add_item_ret_string(parameter_tree, hf_adaptation_layer_id, parameter_tvb, PARAMETER_VALUE_OFFSET, adaptation_layer_id_length, ENC_ASCII, pinfo->pool, &str);
459
1
   proto_item_append_text(parameter_item, " (%s)", str);
460
1
}
461
462
static void
463
dissect_scn_protocol_id_parameter(packet_info *pinfo, tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
464
1
{
465
1
   const uint8_t* str;
466
1
   uint16_t id_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
467
1
   proto_tree_add_item_ret_string(parameter_tree, hf_scn_protocol_id, parameter_tvb, PARAMETER_VALUE_OFFSET, id_length, ENC_ASCII, pinfo->pool, &str);
468
1
   proto_item_append_text(parameter_item, " (%s)", str);
469
1
}
470
471
/*----------------------ASP (Draft)--------------------------------------------*/
472
473
/*----------------------ASP Down + Ack (RFC)--------------------------------*/
474
 /* define reason parameter for Application Server Process Maintenance (ASPM) Messages */
475
#define ASP_REASON_MGMT   1
476
477
static const value_string asp_reason_values[] = {
478
   { ASP_REASON_MGMT,      "Management inhibit" },
479
   { 0,                    NULL } };
480
481
2
#define ASP_REASON_OFFSET PARAMETER_VALUE_OFFSET
482
1
#define ASP_REASON_LENGTH 4
483
484
static void
485
dissect_asp_reason_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
486
1
{
487
1
   proto_tree_add_item(parameter_tree, hf_asp_reason, parameter_tvb, ASP_REASON_OFFSET, ASP_REASON_LENGTH, ENC_BIG_ENDIAN);
488
1
   proto_item_append_text(parameter_item, " (%s)", val_to_str_const(tvb_get_ntohl(parameter_tvb, ASP_REASON_OFFSET), asp_reason_values, "Unknown ASP down reason"));
489
1
}
490
491
492
/*----------------------ASP (RFC)----------------------------------------------*/
493
494
/*----------------------Heartbeat Data + Ack (RFC)-----------------------------*/
495
496
0
#define HEARTBEAT_MSG_LENGTH_OFFSET PARAMETER_LENGTH_OFFSET
497
0
#define HEARTBEAT_DATA_OFFSET       PARAMETER_VALUE_OFFSET
498
0
#define HEARTBEAT_MSG_HEADER_LENGTH PARAMETER_HEADER_LENGTH
499
500
static void
501
dissect_heartbeat_data_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
502
0
{
503
0
   uint16_t heartbeat_data_length;
504
505
0
   heartbeat_data_length = tvb_get_ntohs(parameter_tvb, HEARTBEAT_MSG_LENGTH_OFFSET) - HEARTBEAT_MSG_HEADER_LENGTH;
506
0
   proto_tree_add_item(parameter_tree, hf_heartbeat_data, parameter_tvb, HEARTBEAT_DATA_OFFSET, heartbeat_data_length, ENC_NA);
507
0
   proto_item_append_text(parameter_item, " (%u byte%s)", heartbeat_data_length, plurality(heartbeat_data_length, "", "s"));
508
0
}
509
/*----------------------Heartbeat Data (RFC)-----------------------------------*/
510
511
512
/*----------------------ASP Active,Inactive + Ack (RFC)------------------------*/
513
#define OVER_RIDE_TRAFFIC_MODE_TYPE  1
514
#define LOAD_SHARE_TRAFFIC_MODE_TYPE 2
515
516
static const value_string traffic_mode_type_values[] = {
517
   { OVER_RIDE_TRAFFIC_MODE_TYPE,      "Over-ride" },
518
   { LOAD_SHARE_TRAFFIC_MODE_TYPE,     "Load-share" },
519
   { 0,                    NULL } };
520
521
0
#define TRAFFIC_MODE_TYPE_LENGTH 4
522
0
#define TRAFFIC_MODE_TYPE_OFFSET PARAMETER_VALUE_OFFSET
523
524
static void
525
dissect_traffic_mode_type_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
526
0
{
527
0
   proto_tree_add_item(parameter_tree, hf_traffic_mode_type, parameter_tvb, TRAFFIC_MODE_TYPE_OFFSET, TRAFFIC_MODE_TYPE_LENGTH, ENC_BIG_ENDIAN);
528
0
   proto_item_append_text(parameter_item, " (%s)",
529
0
         val_to_str_const(tvb_get_ntohl(parameter_tvb, TRAFFIC_MODE_TYPE_OFFSET), traffic_mode_type_values, "Unknown traffic mode type"));
530
0
}
531
532
5
#define INT_RANGE_START_OFFSET  PARAMETER_VALUE_OFFSET
533
5
#define INT_RANGE_LENGTH_OFFSET PARAMETER_LENGTH_OFFSET
534
5
#define INT_RANGE_HEADER_LENGTH PARAMETER_HEADER_LENGTH
535
536
204
#define IF_ID_START_OFFSET      0
537
311
#define IF_ID_START_LENGTH      4
538
102
#define IF_ID_END_OFFSET        (IF_ID_START_OFFSET + IF_ID_START_LENGTH)
539
209
#define IF_ID_END_LENGTH        4
540
107
#define IF_ID_INTERVAL_LENGTH   (IF_ID_START_LENGTH + IF_ID_END_LENGTH)
541
542
543
static void
544
dissect_integer_range_interface_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
545
5
{
546
5
   uint16_t number_of_ranges, range_number, offset;
547
548
5
   number_of_ranges = (tvb_get_ntohs(parameter_tvb, INT_RANGE_LENGTH_OFFSET) - INT_RANGE_HEADER_LENGTH) / IF_ID_INTERVAL_LENGTH;
549
5
   offset = INT_RANGE_START_OFFSET;
550
107
   for(range_number = 0; range_number < number_of_ranges; range_number++) {
551
102
      proto_tree_add_item(parameter_tree, hf_if_range_start, parameter_tvb, offset + IF_ID_START_OFFSET, IF_ID_START_LENGTH, ENC_BIG_ENDIAN);
552
102
      proto_tree_add_item(parameter_tree, hf_if_range_end,   parameter_tvb, offset + IF_ID_END_OFFSET,   IF_ID_END_LENGTH,   ENC_BIG_ENDIAN);
553
102
      offset += IF_ID_INTERVAL_LENGTH;
554
102
   };
555
556
5
   proto_item_append_text(parameter_item, " (%u range%s)", number_of_ranges, plurality(number_of_ranges, "", "s"));
557
5
}
558
/*----------------------ASP Active,Inactive (RFC)------------------------------*/
559
560
/*----------------------Data Request,Indication (Draft,RFC)--------------------*/
561
562
121
#define DISCRIMINATOR_OFFSET 0
563
#define DISCRIMINATOR_LENGTH 1
564
#define ADDRESS_OFFSET       1
565
#define ADDRESS_LENGTH       1
566
#define LOW_ADDRESS_OFFSET   2
567
#define LOW_ADDRESS_LENGTH   1
568
569
#define ALL_ADDRESS_OFFSET   1
570
#define ALL_ADDRESS_LENGTH   2
571
572
#define MSG_TYPE_OFFSET      3
573
#define MSG_TYPE_LENGTH      1
574
#define MSG_HEADER_LENGTH    4
575
#define INFO_ELEMENT_OFFSET  4
576
#define INFO_ELEMENT_LENGTH  1
577
578
static void
579
dissect_layer3_message(tvbuff_t *layer3_data_tvb, proto_tree *v5ua_tree,proto_item *parameter_item, packet_info *pinfo)
580
121
{
581
121
   uint16_t discriminator_offset;
582
583
121
   if(iua_version == DRAFT){
584
6
      discriminator_offset = DISCRIMINATOR_OFFSET;
585
6
   }
586
115
   else{
587
115
      discriminator_offset = DISCRIMINATOR_OFFSET + PARAMETER_HEADER_LENGTH;
588
115
   }
589
590
121
   if (tvb_get_uint8(layer3_data_tvb, discriminator_offset) == 0x48){
591
102
      uint16_t protocol_data_length;
592
102
      tvbuff_t *protocol_data_tvb;
593
594
102
      protocol_data_length = tvb_get_ntohs(layer3_data_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
595
102
      protocol_data_tvb    = tvb_new_subset_length(layer3_data_tvb, PARAMETER_VALUE_OFFSET, protocol_data_length);
596
597
102
      call_dissector(v52_handle, protocol_data_tvb, pinfo, v5ua_tree);
598
599
102
      proto_item_append_text(parameter_item, " (%u byte%s)", protocol_data_length, plurality(protocol_data_length, "", "s"));
600
601
102
   }
602
19
   else{
603
19
      uint16_t protocol_data_length;
604
19
      tvbuff_t *protocol_data_tvb;
605
606
19
      protocol_data_length = tvb_get_ntohs(layer3_data_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
607
19
      protocol_data_tvb    = tvb_new_subset_length(layer3_data_tvb, PARAMETER_VALUE_OFFSET, protocol_data_length);
608
19
      call_dissector(q931_handle, protocol_data_tvb, pinfo, v5ua_tree);
609
610
19
      proto_item_append_text(parameter_item, " (%u byte%s)", protocol_data_length, plurality(protocol_data_length, "", "s"));
611
19
   }
612
121
}
613
614
/*----------------------Data Request,Indication (Draft,RFC)------------------------*/
615
616
/*----------------------Establish Request,Confirm,Indication (Draft,RFC)-------*/
617
/*
618
 * no additional parameter
619
 */
620
/*----------------------Establish Request,Confirm,Indication (Draft,RFC)-------*/
621
622
/*----------------------Release Indication, Request (Draft,RFC)----------------*/
623
624
 /* define parameters for Release Request and Indication Messages */
625
#define RELEASE_MGMT   0x0
626
#define RELEASE_PHYS   0x1
627
#define RELEASE_DM     0x2
628
#define RELEASE_OTHER  0x3
629
630
static const value_string release_reason_values[] = {
631
   { RELEASE_MGMT,    "Management layer generated release" },
632
   { RELEASE_PHYS,    "Physical layer alarm generated release" },
633
   { RELEASE_DM,      "Specific to a request" },
634
   { RELEASE_OTHER,   "Other reason" },
635
   { 0,               NULL } };
636
637
0
#define RELEASE_REASON_LENGTH_OFFSET PARAMETER_LENGTH_OFFSET
638
0
#define RELEASE_REASON_OFFSET        PARAMETER_VALUE_OFFSET
639
0
#define RELEASE_REASON_LENGTH        4
640
641
static void
642
dissect_release_reason_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
643
0
{
644
0
   int offset = RELEASE_REASON_OFFSET;
645
0
   if(iua_version == DRAFT) offset = tvb_get_ntohs(parameter_tvb, RELEASE_REASON_LENGTH_OFFSET)+8;
646
0
   proto_tree_add_item(parameter_tree, hf_release_reason, parameter_tvb, offset, RELEASE_REASON_LENGTH, ENC_BIG_ENDIAN);
647
0
   if(iua_version != DRAFT)
648
0
      proto_item_append_text(parameter_item, " (%s)",
649
0
            val_to_str_const(tvb_get_ntohl(parameter_tvb, offset), release_reason_values, "Unknown release reason"));
650
0
}
651
/*----------------------Release Indication,Request (Draft,RFC)-----------------*/
652
653
/*----------------------Link Status Start,Stop Report (Draft,RFC)--------------*/
654
/*
655
 * No additional Parameter
656
 */
657
/*----------------------Link Status Start,Stop Report (Draft,RFC)--------------*/
658
659
/*----------------------Link Status Indication (Draft,RFC)---------------------*/
660
661
 /* define parameters for Link Status Indication */
662
#define LINK_STATUS_OPERTIONAL      0x0
663
#define LINK_STATUS_NON_OPERTIONAL  0x1
664
665
static const value_string link_status_values[] = {
666
   { LINK_STATUS_OPERTIONAL,      "Link operational" },
667
   { LINK_STATUS_NON_OPERTIONAL,  "Link not operational" },
668
   { 0,                           NULL } };
669
670
0
#define LINK_STATUS_OFFSET   PARAMETER_VALUE_OFFSET
671
0
#define LINK_STATUS_LENGTH   4
672
673
static void
674
dissect_link_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
675
0
{
676
0
   proto_tree_add_item(parameter_tree, hf_link_status, parameter_tvb, LINK_STATUS_OFFSET, LINK_STATUS_LENGTH, ENC_BIG_ENDIAN);
677
0
   proto_item_append_text(parameter_item, " (%s)",
678
0
         val_to_str_const(tvb_get_ntohl(parameter_tvb, LINK_STATUS_OFFSET),link_status_values, "Unknown Link status"));
679
680
0
   link_status_operational = tvb_get_ntohl(parameter_tvb, LINK_STATUS_OFFSET);
681
0
}
682
/*----------------------Link Status Indication (Draft,RFC)---------------------*/
683
684
/*----------------------Sa-Bit (Draft,RFC)-------------------------------------*/
685
686
 /* define parameter for sa-bit message */
687
#define SA_BIT_ID_ZERO     0x0
688
#define SA_BIT_ID_ONE      0x1
689
#define SA_BIT_VALUE_SA7   0x7
690
691
static const value_string sa_bit_values[] = {
692
   { SA_BIT_ID_ZERO,    "set value ZERO" },
693
   { SA_BIT_ID_ONE,     "set value ONE" },
694
   { SA_BIT_VALUE_SA7,  "Addresses the Sa7 Bit" },
695
   { 0,                 NULL } };
696
697
0
#define SA_BIT_ID_OFFSET     PARAMETER_VALUE_OFFSET
698
0
#define SA_BIT_ID_LENGTH     2
699
0
#define SA_BIT_VALUE_OFFSET  (SA_BIT_ID_OFFSET + SA_BIT_ID_LENGTH)
700
0
#define SA_BIT_VALUE_LENGTH  2
701
702
static void
703
dissect_sa_bit_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
704
0
{
705
0
   proto_tree_add_item(parameter_tree, hf_sa_bit_id, parameter_tvb, SA_BIT_ID_OFFSET, SA_BIT_ID_LENGTH, ENC_BIG_ENDIAN);
706
0
   proto_tree_add_item(parameter_tree, hf_sa_bit_value, parameter_tvb, SA_BIT_VALUE_OFFSET, SA_BIT_VALUE_LENGTH, ENC_BIG_ENDIAN);
707
0
   proto_item_append_text(parameter_item, " (%s %s)",
708
0
         val_to_str_const(tvb_get_ntohs(parameter_tvb, SA_BIT_ID_OFFSET), sa_bit_values, "unknown"),
709
0
         val_to_str_const(tvb_get_ntohs(parameter_tvb, SA_BIT_VALUE_OFFSET), sa_bit_values, "unknown Bit"));
710
711
0
   sa_bit_id = tvb_get_ntohs(parameter_tvb, SA_BIT_VALUE_OFFSET);
712
0
}
713
/*----------------------Sa-Bit (Draft,RFC)-------------------------------------*/
714
715
/*----------------------Error Indication (RFC)---------------------------------*/
716
717
#define ERROR_REASON_OVERLOAD 0x1
718
719
static const value_string error_reason_values[] = {
720
   { ERROR_REASON_OVERLOAD, "C-Channel is in overload state" },
721
   { 0,                     NULL } };
722
723
0
#define ERROR_REASON_LENGTH 4
724
0
#define ERROR_REASON_OFFSET PARAMETER_VALUE_OFFSET
725
726
static void
727
dissect_error_indication_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
728
0
{
729
0
   proto_tree_add_item(parameter_tree, hf_error_reason, parameter_tvb, ERROR_REASON_OFFSET, ERROR_REASON_LENGTH, ENC_BIG_ENDIAN);
730
0
   proto_item_append_text(parameter_item, " (%s)",
731
0
         val_to_str_const(tvb_get_ntohl(parameter_tvb, ERROR_REASON_OFFSET), error_reason_values, "unknown"));
732
0
}
733
/*----------------------Error Indication (RFC)---------------------------------*/
734
735
/*--------------------------ASP identifier-------------------------------------*/
736
1
#define ASP_IDENTIFIER_LENGTH 4
737
2
#define ASP_IDENTIFIER_OFFSET PARAMETER_VALUE_OFFSET
738
739
static void
740
dissect_asp_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
741
1
{
742
1
   proto_tree_add_item(parameter_tree, hf_asp_identifier, parameter_tvb, ASP_IDENTIFIER_OFFSET, ASP_IDENTIFIER_LENGTH, ENC_BIG_ENDIAN);
743
1
   proto_item_append_text(parameter_item, " (%d) ",tvb_get_ntohl(parameter_tvb,ASP_IDENTIFIER_OFFSET));
744
1
}
745
/*--------------------------ASP identifier-------------------------------------*/
746
747
2
#define INFO_STRING_OFFSET PARAMETER_VALUE_OFFSET
748
749
static void
750
dissect_info_string_parameter(packet_info *pinfo, tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
751
2
{
752
2
   uint16_t info_string_length;
753
2
   const uint8_t* str;
754
755
2
   info_string_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
756
2
   if(iua_version == DRAFT) info_string_length += 4;
757
2
   if(info_string_length > 4){
758
2
      info_string_length -= PARAMETER_HEADER_LENGTH;
759
2
      proto_tree_add_item_ret_string(parameter_tree, hf_info_string, parameter_tvb, INFO_STRING_OFFSET, info_string_length, ENC_ASCII, pinfo->pool, &str);
760
2
      proto_item_append_text(parameter_item, " (%s)", str);
761
2
   }
762
2
}
763
764
765
static void
766
dissect_unknown_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
767
86
{
768
769
86
   uint16_t parameter_value_length;
770
771
86
   parameter_value_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
772
86
   if (parameter_value_length > 0)
773
84
      proto_tree_add_item(parameter_tree, hf_parameter_value, parameter_tvb, PARAMETER_VALUE_OFFSET, parameter_value_length, ENC_NA);
774
775
86
   proto_item_append_text(parameter_item, " with tag %u and %u byte%s value",
776
86
         tvb_get_ntohs(parameter_tvb, PARAMETER_TAG_OFFSET), parameter_value_length, plurality(parameter_value_length, "", "s"));
777
86
}
778
779
#define Reserved_TAG               0x00
780
6
#define INT_INTERFACE_IDENTIFIER_PARAMETER_TAG           0x01
781
1
#define ASP_MSG_PARAMETER_TAG                            0x02
782
1
#define TEXT_INTERFACE_IDENTIFIER_PARAMETER_TAG          0x03
783
2
#define INFO_PARAMETER_TAG                               0x04
784
1
#define DLCI_PARAMETER_TAG                               0x81
785
1
#define DIAGNOSTIC_INFORMATION_PARAMETER_TAG             0x07
786
5
#define INTEGER_RANGE_INTERFACE_IDENTIFIER_PARAMETER_TAG 0x08
787
0
#define HEARTBEAT_DATA_PARAMETER_TAG                     0x09
788
1
#define ASP_DOWN_REASON_PARAMETER_TAG                    0x0a
789
0
#define TRAFFIC_MODE_TYPE_PARAMETER_TAG                  0x0b
790
0
#define ERROR_CODE_PARAMETER_TAG                         0x0c
791
2
#define STATUS_TYPE_INDENTIFICATION_PARAMETER_TAG        0x0d
792
121
#define PROTOCOL_DATA_PARAMETER_TAG                      0x0e
793
0
#define RELEASE_REASON_PARAMETER_TAG                     0x0f
794
3
#define TEI_STATUS_PARAMETER_TAG                         0x10
795
1
#define ASP_IDENTIFIER_PARAMETER_TAG                     0x11
796
#define NOT_USED_IN_IUA_PARAMETER_TAG                    0x12
797
0
#define LINK_STATUS_PARAMETER_TAG                        0x82
798
0
#define SA_BIT_STATUS_PARAMETER_TAG                      0x83
799
0
#define ERROR_INDICATION_PARAMETER_TAG                   0x84
800
801
static const value_string parameter_tag_values[] = {
802
   { Reserved_TAG,                   "Reserved" },
803
   { INT_INTERFACE_IDENTIFIER_PARAMETER_TAG,              "Interface Identifier (integer)" },
804
   { TEXT_INTERFACE_IDENTIFIER_PARAMETER_TAG,             "Interface Identifier (text)" },
805
   { INFO_PARAMETER_TAG,                                  "Info string" },
806
   { DLCI_PARAMETER_TAG,                                  "DLCI" },
807
   { DIAGNOSTIC_INFORMATION_PARAMETER_TAG,                "Diagnostic information" },
808
   { INTEGER_RANGE_INTERFACE_IDENTIFIER_PARAMETER_TAG,    "Interface Identifier Range" },
809
   { HEARTBEAT_DATA_PARAMETER_TAG,                        "Hearbeat data" },
810
   { ASP_DOWN_REASON_PARAMETER_TAG,                       "ASP DOWN Reason" },
811
   { TRAFFIC_MODE_TYPE_PARAMETER_TAG,                     "Traffic mode type" },
812
   { ERROR_CODE_PARAMETER_TAG,                            "Error code" },
813
   { STATUS_TYPE_INDENTIFICATION_PARAMETER_TAG,           "Status type/identification" },
814
   { PROTOCOL_DATA_PARAMETER_TAG,                         "Protocol Data" },
815
   { RELEASE_REASON_PARAMETER_TAG,                        "Release Reason" },
816
   { TEI_STATUS_PARAMETER_TAG,                            "TEI status" },
817
   { ASP_IDENTIFIER_PARAMETER_TAG,                        "ASP Identifier" },
818
   { NOT_USED_IN_IUA_PARAMETER_TAG,                       "Not used in IUA" },
819
   { LINK_STATUS_PARAMETER_TAG,                           "Link status" },
820
   { SA_BIT_STATUS_PARAMETER_TAG,                         "SA-Bit status" },
821
   { ERROR_INDICATION_PARAMETER_TAG,                      "Error reason" },
822
   { 0,                                                    NULL } };
823
824
static const value_string parameter_tag_draft_values[] = {
825
   { INT_INTERFACE_IDENTIFIER_PARAMETER_TAG,              "V5UA Interface Identifier (int)" },
826
   { ASP_MSG_PARAMETER_TAG,                               "ASP Adaption Layer ID" },
827
   { TEXT_INTERFACE_IDENTIFIER_PARAMETER_TAG,             "SCN Protocol Identifier" },
828
   { INFO_PARAMETER_TAG,                                  "Info" },
829
   { PROTOCOL_DATA_PARAMETER_TAG,                         "Protocol Data" },
830
   { LINK_STATUS_PARAMETER_TAG,                           "Link status" },
831
   { SA_BIT_STATUS_PARAMETER_TAG,                         "SA-Bit status" },
832
   { ERROR_INDICATION_PARAMETER_TAG,                      "Error reason" },
833
   { 0,                                                   NULL } };
834
835
static void
836
dissect_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *v5ua_tree)
837
234
{
838
234
   uint16_t tag, length, padding_length;
839
234
   proto_item *parameter_item;
840
234
   proto_tree *parameter_tree;
841
842
   /* extract tag and length from the parameter */
843
234
   tag      = tvb_get_ntohs(parameter_tvb, PARAMETER_TAG_OFFSET);
844
234
   length   = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
845
   /* on IUA-Draft messages the message length not including the message header */
846
234
   if((iua_version==DRAFT)&&(tag<=0x4)){
847
      /* at V5UA Header, length of header and length of DLCI+EFA must be added */
848
29
      if(tag==0x1)       length += 8;
849
      /* at ASP message tags only length of header must be added */
850
25
      else if(tag<=0x4)  length += PARAMETER_HEADER_LENGTH;
851
      /* for following message-tags are no length information available. Only in common msg header */
852
29
      if((msg_class==0 || msg_class==1 || msg_class==9) && msg_type<=10)
853
1
         length = msg_length;
854
29
   }
855
234
   padding_length = tvb_reported_length(parameter_tvb) - length;
856
234
   paddingl = padding_length;
857
858
   /* create proto_tree stuff */
859
234
   switch(iua_version){
860
156
      case RFC:
861
156
         parameter_tree   = proto_tree_add_subtree(v5ua_tree, parameter_tvb, PARAMETER_HEADER_OFFSET, -1, ett_v5ua_parameter, &parameter_item,
862
156
               val_to_str_const(tag, parameter_tag_values, "Unknown parameter"));
863
         /* add tag to the v5ua tree */
864
156
         proto_tree_add_item(parameter_tree, hf_parameter_tag, parameter_tvb, PARAMETER_TAG_OFFSET, PARAMETER_TAG_LENGTH, ENC_BIG_ENDIAN);
865
156
         break;
866
75
      case DRAFT:
867
75
      default:
868
75
         parameter_tree   = proto_tree_add_subtree(v5ua_tree, parameter_tvb, PARAMETER_HEADER_OFFSET, -1, ett_v5ua_parameter, &parameter_item,
869
75
               val_to_str_const(tag, parameter_tag_draft_values, "Unknown parameter"));
870
871
         /* add tag to the v5ua tree */
872
75
         proto_tree_add_item(parameter_tree, hf_parameter_tag_draft, parameter_tvb, PARAMETER_TAG_OFFSET, PARAMETER_TAG_LENGTH, ENC_BIG_ENDIAN);
873
75
         break;
874
234
   };
875
876
   /* add length to the v5ua tree */
877
231
   proto_tree_add_item(parameter_tree, hf_parameter_length, parameter_tvb, PARAMETER_LENGTH_OFFSET, PARAMETER_LENGTH_LENGTH, ENC_BIG_ENDIAN);
878
879
231
   switch(tag) {
880
6
      case INT_INTERFACE_IDENTIFIER_PARAMETER_TAG:
881
6
         if(iua_version == RFC) dissect_int_interface_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
882
6
         if(iua_version == DRAFT){
883
4
            dissect_int_interface_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
884
4
            dissect_dlci_parameter(parameter_tvb, parameter_tree, parameter_item, pinfo);
885
886
            /* for the following parameters no tag- and length-informations available. Parameters must be dissect with info from common msg header */
887
4
            if(msg_class==0 && msg_type==0)    dissect_draft_error_code_parameter(parameter_tvb, parameter_tree);
888
4
            if(msg_class==1)                   dissect_draft_tei_status_parameter(parameter_tvb, parameter_tree, parameter_item);
889
4
            if(msg_class==9){
890
0
               if(msg_type==1||msg_type==2||msg_type==3||msg_type==4){
891
0
                  uint16_t length_2, offset;
892
0
                  tvbuff_t *layer3_data_tvb;
893
0
                  offset = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) + 8;
894
0
                  length_2 = msg_length - offset;
895
0
                  if(length_2 > 0){
896
0
                     if(tvb_get_uint8(parameter_tvb, offset) == 0x48){
897
0
                        layer3_data_tvb = tvb_new_subset_length(parameter_tvb, offset, length_2);
898
0
                        dissect_layer3_message(layer3_data_tvb, v5ua_tree, parameter_item, pinfo);
899
0
                     }
900
0
                  }
901
0
               }
902
0
               else if(msg_type==8||msg_type==10) dissect_release_reason_parameter(parameter_tvb, parameter_tree, parameter_item);
903
0
            }
904
4
         }
905
6
         break;
906
1
      case ASP_MSG_PARAMETER_TAG:
907
1
         dissect_asp_msg_parameter(pinfo, parameter_tvb, parameter_tree, parameter_item);
908
1
         break;
909
1
      case TEXT_INTERFACE_IDENTIFIER_PARAMETER_TAG:
910
1
         if(iua_version == RFC)
911
0
            dissect_text_interface_identifier_parameter(pinfo, parameter_tvb, parameter_tree, parameter_item);
912
1
         if(iua_version == DRAFT)
913
1
            dissect_scn_protocol_id_parameter(pinfo, parameter_tvb, parameter_tree, parameter_item);
914
1
         break;
915
2
      case INFO_PARAMETER_TAG:
916
2
         dissect_info_string_parameter(pinfo, parameter_tvb, parameter_tree, parameter_item);
917
2
         break;
918
1
      case DLCI_PARAMETER_TAG:
919
1
         dissect_dlci_parameter(parameter_tvb, parameter_tree, parameter_item, pinfo);
920
1
         break;
921
1
      case DIAGNOSTIC_INFORMATION_PARAMETER_TAG:
922
1
         dissect_diagnostic_information_parameter(parameter_tvb, parameter_tree, parameter_item);
923
1
         break;
924
5
      case INTEGER_RANGE_INTERFACE_IDENTIFIER_PARAMETER_TAG:
925
5
         dissect_integer_range_interface_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
926
5
         break;
927
0
      case HEARTBEAT_DATA_PARAMETER_TAG:
928
0
         dissect_heartbeat_data_parameter(parameter_tvb, parameter_tree, parameter_item);
929
0
         break;
930
1
      case ASP_DOWN_REASON_PARAMETER_TAG:
931
1
         dissect_asp_reason_parameter(parameter_tvb, parameter_tree, parameter_item);
932
1
         break;
933
0
      case TRAFFIC_MODE_TYPE_PARAMETER_TAG:
934
0
         dissect_traffic_mode_type_parameter(parameter_tvb, parameter_tree, parameter_item);
935
0
         break;
936
0
      case ERROR_CODE_PARAMETER_TAG:
937
0
         dissect_error_code_parameter(parameter_tvb, parameter_tree, parameter_item);
938
0
         break;
939
2
      case STATUS_TYPE_INDENTIFICATION_PARAMETER_TAG:
940
2
         dissect_status_type_identification_parameter(parameter_tvb, parameter_tree, parameter_item);
941
2
         break;
942
121
      case PROTOCOL_DATA_PARAMETER_TAG:
943
121
         dissect_layer3_message(parameter_tvb, v5ua_tree, parameter_item, pinfo);
944
121
         break;
945
0
      case RELEASE_REASON_PARAMETER_TAG:
946
0
         dissect_release_reason_parameter(parameter_tvb, parameter_tree, parameter_item);
947
0
         break;
948
3
      case TEI_STATUS_PARAMETER_TAG:
949
3
         dissect_tei_status_parameter(parameter_tvb, parameter_tree, parameter_item);
950
3
         break;
951
1
      case ASP_IDENTIFIER_PARAMETER_TAG:
952
1
         dissect_asp_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
953
1
         break;
954
0
      case LINK_STATUS_PARAMETER_TAG:
955
0
         dissect_link_status_parameter(parameter_tvb, parameter_tree, parameter_item);
956
0
         break;
957
0
      case SA_BIT_STATUS_PARAMETER_TAG:
958
0
         dissect_sa_bit_status_parameter(parameter_tvb, parameter_tree, parameter_item);
959
0
         break;
960
0
      case ERROR_INDICATION_PARAMETER_TAG:
961
0
         dissect_error_indication_parameter( parameter_tvb, parameter_tree, parameter_item);
962
0
         break;
963
86
      default:
964
86
         dissect_unknown_parameter(parameter_tvb, parameter_tree, parameter_item);
965
86
         break;
966
231
   };
967
968
142
   if (padding_length > 0){
969
42
      proto_tree_add_item(parameter_tree, hf_parameter_padding, parameter_tvb, PARAMETER_HEADER_OFFSET + length, padding_length, ENC_NA);
970
42
   }
971
142
}
972
/* dissect the V5UA-Parameters into subsets which are separated by Tag-Length-Header and call up the dissector for the subsets */
973
static void
974
dissect_parameters(tvbuff_t *parameters_tvb, packet_info *pinfo, proto_tree *tree _U_, proto_tree *v5ua_tree)
975
177
{
976
177
   int tag, offset, length, total_length, remaining_length;
977
177
   tvbuff_t *parameter_tvb;
978
979
980
177
   offset = 0;
981
411
   while((remaining_length = tvb_reported_length_remaining(parameters_tvb, offset))) {
982
234
      tag = tvb_get_ntohs(parameters_tvb, offset + PARAMETER_TAG_OFFSET);
983
234
      length = tvb_get_ntohs(parameters_tvb, offset + PARAMETER_LENGTH_OFFSET);
984
234
      if(iua_version==DRAFT){
985
76
         if(tag==0x1) length += 8;  /* V5UA Header */
986
72
         else if(tag<=0x4) length += PARAMETER_HEADER_LENGTH; /* ASP MSGs */
987
988
         /* add the parameters which are not separated by tag-length-header to the V5UA header */
989
76
         if((msg_class==0 || msg_class==1 || msg_class==9)&&msg_type<=10)
990
2
            length = msg_length;
991
76
      }
992
234
      total_length = WS_ROUNDUP_4(length);
993
234
      if (remaining_length >= length)
994
70
         total_length = MIN(total_length, remaining_length);
995
      /* create a tvb for the parameter including the padding bytes */
996
234
      parameter_tvb  = tvb_new_subset_length(parameters_tvb, offset, total_length);
997
234
      dissect_parameter(parameter_tvb, pinfo, v5ua_tree);
998
      /* get rid of the handled parameter */
999
234
      offset += total_length;
1000
234
   }
1001
177
}
1002
1003
1004
 /* define the common header fields of V5UA MSG */
1005
1.82k
#define COMMON_HEADER_VERSION_LENGTH        1
1006
1.64k
#define COMMON_HEADER_RESERVED_LENGTH       1
1007
1.28k
#define COMMON_HEADER_MSG_CLASS_LENGTH      1
1008
929
#define COMMON_HEADER_MSG_TYPE_LENGTH       1
1009
717
#define COMMON_HEADER_MSG_LENGTH_LENGTH     4
1010
539
#define COMMON_HEADER_LENGTH                (COMMON_HEADER_VERSION_LENGTH + COMMON_HEADER_RESERVED_LENGTH +\
1011
539
                                             COMMON_HEADER_MSG_CLASS_LENGTH + COMMON_HEADER_MSG_TYPE_LENGTH +\
1012
539
                                             COMMON_HEADER_MSG_LENGTH_LENGTH)
1013
1014
 /* define the offsets of common header */
1015
1.63k
#define COMMON_HEADER_OFFSET            0
1016
1.28k
#define COMMON_HEADER_VERSION_OFFSET    COMMON_HEADER_OFFSET
1017
1.10k
#define COMMON_HEADER_RESERVED_OFFSET   (COMMON_HEADER_VERSION_OFFSET       + COMMON_HEADER_VERSION_LENGTH)
1018
926
#define COMMON_HEADER_MSG_CLASS_OFFSET  (COMMON_HEADER_RESERVED_OFFSET      + COMMON_HEADER_RESERVED_LENGTH)
1019
569
#define COMMON_HEADER_MSG_TYPE_OFFSET   (COMMON_HEADER_MSG_CLASS_OFFSET     + COMMON_HEADER_MSG_CLASS_LENGTH)
1020
212
#define COMMON_HEADER_MSG_LENGTH_OFFSET (COMMON_HEADER_MSG_TYPE_OFFSET      + COMMON_HEADER_MSG_TYPE_LENGTH)
1021
#define COMMON_HEADER_PARAMETERS_OFFSET (COMMON_HEADER_OFFSET               + COMMON_HEADER_LENGTH)
1022
1023
 /* version of V5UA protocol */
1024
#define V5UA_PROTOCOL_VERSION_RELEASE_1     1
1025
1026
static const value_string v5ua_protocol_version_values[] = {
1027
   { V5UA_PROTOCOL_VERSION_RELEASE_1,  "Release 1.0" },
1028
   { 0,                                NULL } };
1029
1030
 /* define V5UA MSGs */
1031
#define MSG_CLASS_MGMT_MSG        0
1032
#define MSG_CLASS_MGMT_MSG_DRAFT  1
1033
#define MSG_CLASS_ASPSM_MSG       3
1034
#define MSG_CLASS_ASPTM_MSG       4
1035
#define MSG_CLASS_V5PTM_MSG_DRAFT 9
1036
#define MSG_CLASS_V5PTM_MSG      14
1037
1038
static const value_string msg_class_values[] = {
1039
   { MSG_CLASS_MGMT_MSG,  "Management Messages" },
1040
   { MSG_CLASS_MGMT_MSG_DRAFT,"Management Messages"},
1041
   { MSG_CLASS_ASPSM_MSG, "ASP State Maintenance Message" },
1042
   { MSG_CLASS_ASPTM_MSG, "ASP Traffic Maintenance Message" },
1043
   { MSG_CLASS_V5PTM_MSG_DRAFT, "V5 Boundary Primitives Transport Message" },
1044
   { MSG_CLASS_V5PTM_MSG, "V5 Boundary Primitives Transport Message" },
1045
   { 0,                           NULL } };
1046
1047
 /* message types for MGMT messages */
1048
#define MGMT_MSG_TYPE_ERR                  0
1049
#define MGMT_MSG_TYPE_NTFY                 1
1050
#define MGMT_MSG_TYPE_TEI_STATUS_REQ       2
1051
#define MGMT_MSG_TYPE_TEI_STATUS_CON       3
1052
#define MGMT_MSG_TYPE_TEI_STATUS_IND       4
1053
#define MGMT_MSG_TYPE_TEI_QUERY_REQUEST5  5
1054
#define MGMT_MSG_TYPE_TEI_QUERY_REQUEST   8
1055
 /* end */
1056
1057
 /* MGMT messages for Nortel draft version*/
1058
#define MGMT_MSG_DRAFT_TYPE_TEI_STATUS_REQ       1
1059
#define MGMT_MSG_DRAFT_TYPE_TEI_STATUS_CON       2
1060
#define MGMT_MSG_DRAFT_TYPE_TEI_STATUS_IND       3
1061
#define MGMT_MSG_DRAFT_TYPE_TEI_QUERY_REQUEST5  5
1062
#define MGMT_MSG_DRAFT_TYPE_TEI_QUERY_REQUEST   8
1063
 /* end */
1064
1065
 /* message types for ASPSM messages */
1066
#define ASPSM_MSG_TYPE_Reserved             0
1067
#define ASPSM_MSG_TYPE_UP                   1
1068
#define ASPSM_MSG_TYPE_DOWN                 2
1069
#define ASPSM_MSG_TYPE_BEAT                 3
1070
#define ASPSM_MSG_TYPE_UP_ACK               4
1071
#define ASPSM_MSG_TYPE_DOWN_ACK             5
1072
#define ASPSM_MSG_TYPE_BEAT_ACK             6
1073
1074
 /* message types for ASPTM messages */
1075
#define ASPTM_MSG_TYPE_Reserved             0
1076
#define ASPTM_MSG_TYPE_ACTIVE               1
1077
#define ASPTM_MSG_TYPE_INACTIVE             2
1078
#define ASPTM_MSG_TYPE_ACTIVE_ACK           3
1079
#define ASPTM_MSG_TYPE_INACTIVE_ACK         4
1080
1081
 /* message types for V5PTM messages */
1082
#define V5PTM_MSG_TYPE_Reserved                     0
1083
#define V5PTM_MSG_TYPE_DATA_REQUEST                 1
1084
#define V5PTM_MSG_TYPE_DATA_INDICATION              2
1085
#define V5PTM_MSG_TYPE_UNIT_DATA_REQUEST            3
1086
#define V5PTM_MSG_TYPE_UNIT_DATA_INDICATION         4
1087
#define V5PTM_MSG_TYPE_ESTABLISH_REQUEST            5
1088
#define V5PTM_MSG_TYPE_ESTABLISH_CONFIRM            6
1089
#define V5PTM_MSG_TYPE_ESTABLISH_INDICATION         7
1090
#define V5PTM_MSG_TYPE_RELEASE_REQUEST              8
1091
#define V5PTM_MSG_TYPE_RELEASE_CONFIRM              9
1092
#define V5PTM_MSG_TYPE_RELEASE_INDICATION          10
1093
#define V5PTM_MSG_TYPE_LINK_STATUS_START_REPORTING 11
1094
#define V5PTM_MSG_TYPE_LINK_STATUS_STOP_REPORTING  12
1095
#define V5PTM_MSG_TYPE_LINK_STATUS_INDICATION      13
1096
#define V5PTM_MSG_TYPE_SA_BIT_SET_REQUEST          14
1097
#define V5PTM_MSG_TYPE_SA_BIT_SET_CONFIRM          15
1098
#define V5PTM_MSG_TYPE_SA_BIT_STATUS_REQUEST       16
1099
#define V5PTM_MSG_TYPE_SA_BIT_STATUS_INDICATION    17
1100
#define V5PTM_MSG_TYPE_ERROR_INDICATION            18
1101
1102
#define MGMT_MSG_TYPE_TEI_STATUS_REQUEST5  5
1103
#define MGMT_MSG_TYPE_TEI_STATUS_REQUEST   8
1104
1105
static const value_string msg_class_type_values[] = {
1106
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_ERR,                         "Error" },
1107
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_NTFY,                        "Notify" },
1108
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_TEI_STATUS_REQ,              "TEI status request" },
1109
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_TEI_STATUS_CON,              "TEI status confirmation" },
1110
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_TEI_STATUS_IND,              "TEI status indication" },
1111
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_TEI_QUERY_REQUEST,           "TEI query request" },
1112
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_TEI_QUERY_REQUEST5,          "TEI query request" },
1113
1114
   { MSG_CLASS_MGMT_MSG_DRAFT * 256 + MGMT_MSG_DRAFT_TYPE_TEI_STATUS_REQ,   "TEI status request" },
1115
   { MSG_CLASS_MGMT_MSG_DRAFT * 256 + MGMT_MSG_DRAFT_TYPE_TEI_STATUS_CON,   "TEI status confirmation" },
1116
   { MSG_CLASS_MGMT_MSG_DRAFT * 256 + MGMT_MSG_DRAFT_TYPE_TEI_STATUS_IND,   "TEI status indication" },
1117
   { MSG_CLASS_MGMT_MSG_DRAFT * 256 + MGMT_MSG_DRAFT_TYPE_TEI_QUERY_REQUEST,  "TEI query request" },
1118
   { MSG_CLASS_MGMT_MSG_DRAFT * 256 + MGMT_MSG_DRAFT_TYPE_TEI_QUERY_REQUEST5, "TEI query request" },
1119
1120
1121
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_Reserved,                   "Reserved" },
1122
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_UP,                         "ASP up" },
1123
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_DOWN,                       "ASP down" },
1124
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_BEAT,                       "Heartbeat" },
1125
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_UP_ACK,                     "ASP up ack" },
1126
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_DOWN_ACK,                   "ASP down ack" },
1127
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_BEAT_ACK,                   "Heartbeat ack" },
1128
1129
   { MSG_CLASS_ASPTM_MSG * 256 + ASPTM_MSG_TYPE_Reserved ,                  "Reserved" },
1130
   { MSG_CLASS_ASPTM_MSG * 256 + ASPTM_MSG_TYPE_ACTIVE ,                    "ASP active" },
1131
   { MSG_CLASS_ASPTM_MSG * 256 + ASPTM_MSG_TYPE_INACTIVE ,                  "ASP inactive" },
1132
   { MSG_CLASS_ASPTM_MSG * 256 + ASPTM_MSG_TYPE_ACTIVE_ACK ,                "ASP active ack" },
1133
   { MSG_CLASS_ASPTM_MSG * 256 + ASPTM_MSG_TYPE_INACTIVE_ACK ,              "ASP inactive ack" },
1134
1135
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_Reserved,                   "Reserved" },
1136
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_DATA_REQUEST,               "Data request" },
1137
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_DATA_INDICATION,            "Data indication" },
1138
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_UNIT_DATA_REQUEST,          "Unit data request" },
1139
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_UNIT_DATA_INDICATION,       "Unit data indication" },
1140
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_ESTABLISH_REQUEST,          "Establish request" },
1141
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_ESTABLISH_CONFIRM,          "Establish confirmation" },
1142
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_ESTABLISH_INDICATION,       "Establish indication" },
1143
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_RELEASE_REQUEST,            "Release request" },
1144
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_RELEASE_CONFIRM,            "Release confirmation" },
1145
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_RELEASE_INDICATION,         "Release indication" },
1146
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_LINK_STATUS_START_REPORTING,"Link status start reporting" },
1147
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_LINK_STATUS_STOP_REPORTING, "Link status stop reporting" },
1148
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_LINK_STATUS_INDICATION,     "Link status indication" },
1149
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_SA_BIT_SET_REQUEST,         "Sa-Bit set request" },
1150
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_SA_BIT_SET_CONFIRM,         "Sa-Bit set confirm" },
1151
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_SA_BIT_STATUS_REQUEST,      "Sa-Bit status request" },
1152
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_SA_BIT_STATUS_INDICATION,   "Sa-Bit status indication" },
1153
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_ERROR_INDICATION,           "Error indication" },
1154
1155
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_Reserved,                   "Reserved" },
1156
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_DATA_REQUEST,               "Data request" },
1157
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_DATA_INDICATION,            "Data indication" },
1158
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_UNIT_DATA_REQUEST,          "Unit data request" },
1159
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_UNIT_DATA_INDICATION,       "Unit data indication" },
1160
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_ESTABLISH_REQUEST,          "Establish request" },
1161
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_ESTABLISH_CONFIRM,          "Establish confirmation" },
1162
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_ESTABLISH_INDICATION,       "Establish indication" },
1163
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_RELEASE_REQUEST,            "Release request" },
1164
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_RELEASE_CONFIRM,            "Release confirmation" },
1165
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_RELEASE_INDICATION,         "Release indication" },
1166
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_LINK_STATUS_START_REPORTING,"Link status start reporting" },
1167
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_LINK_STATUS_STOP_REPORTING, "Link status stop reporting" },
1168
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_LINK_STATUS_INDICATION,     "Link status indication" },
1169
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_SA_BIT_SET_REQUEST,         "Sa-Bit set request" },
1170
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_SA_BIT_SET_CONFIRM,         "Sa-Bit set confirm" },
1171
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_SA_BIT_STATUS_REQUEST,      "Sa-Bit status request" },
1172
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_SA_BIT_STATUS_INDICATION,   "Sa-Bit status indication" },
1173
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_ERROR_INDICATION,           "Error indication" },
1174
1175
   { 0,                                                                                  NULL } };
1176
1177
static const value_string msg_class_type_values_short[] = {
1178
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_ERR,                         "Error" },
1179
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_NTFY,                        "Notify" },
1180
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_TEI_STATUS_REQ,              "TEI status request" },
1181
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_TEI_STATUS_CON,              "TEI status confirmation" },
1182
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_TEI_STATUS_IND,              "TEI status indication" },
1183
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_TEI_QUERY_REQUEST,           "TEI query request" },
1184
   { MSG_CLASS_MGMT_MSG  * 256 + MGMT_MSG_TYPE_TEI_QUERY_REQUEST5,          "TEI query request" },
1185
1186
   { MSG_CLASS_MGMT_MSG_DRAFT * 256 + MGMT_MSG_DRAFT_TYPE_TEI_STATUS_REQ,   "TEI status request" },
1187
   { MSG_CLASS_MGMT_MSG_DRAFT * 256 + MGMT_MSG_DRAFT_TYPE_TEI_STATUS_CON,   "TEI status confirmation" },
1188
   { MSG_CLASS_MGMT_MSG_DRAFT * 256 + MGMT_MSG_DRAFT_TYPE_TEI_STATUS_IND,   "TEI status indication" },
1189
   { MSG_CLASS_MGMT_MSG_DRAFT * 256 + MGMT_MSG_DRAFT_TYPE_TEI_QUERY_REQUEST,  "TEI query request" },
1190
   { MSG_CLASS_MGMT_MSG_DRAFT * 256 + MGMT_MSG_DRAFT_TYPE_TEI_QUERY_REQUEST5, "TEI query request" },
1191
1192
1193
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_Reserved,                   "Reserved" },
1194
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_UP,                         "ASP up" },
1195
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_DOWN,                       "ASP down" },
1196
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_BEAT,                       "Heartbeat" },
1197
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_UP_ACK,                     "ASP up ack" },
1198
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_DOWN_ACK,                   "ASP down ack" },
1199
   { MSG_CLASS_ASPSM_MSG * 256 + ASPSM_MSG_TYPE_BEAT_ACK,                   "Heartbeat ack" },
1200
1201
   { MSG_CLASS_ASPTM_MSG * 256 + ASPTM_MSG_TYPE_Reserved ,                  "Reserved" },
1202
   { MSG_CLASS_ASPTM_MSG * 256 + ASPTM_MSG_TYPE_ACTIVE ,                    "ASP active" },
1203
   { MSG_CLASS_ASPTM_MSG * 256 + ASPTM_MSG_TYPE_INACTIVE ,                  "ASP inactive" },
1204
   { MSG_CLASS_ASPTM_MSG * 256 + ASPTM_MSG_TYPE_ACTIVE_ACK ,                "ASP active ack" },
1205
   { MSG_CLASS_ASPTM_MSG * 256 + ASPTM_MSG_TYPE_INACTIVE_ACK ,              "ASP inactive ack" },
1206
1207
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_Reserved,                   "Reserved" },
1208
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_DATA_REQUEST,               "Data request" },
1209
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_DATA_INDICATION,            "Data indication" },
1210
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_UNIT_DATA_REQUEST,          "Unit data request" },
1211
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_UNIT_DATA_INDICATION,       "Unit data indication" },
1212
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_ESTABLISH_REQUEST,          "Establish request" },
1213
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_ESTABLISH_CONFIRM,          "Establish confirmation" },
1214
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_ESTABLISH_INDICATION,       "Establish indication" },
1215
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_RELEASE_REQUEST,            "Release request" },
1216
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_RELEASE_CONFIRM,            "Release confirmation" },
1217
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_RELEASE_INDICATION,         "Release indication" },
1218
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_LINK_STATUS_START_REPORTING,"Link status start reporting" },
1219
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_LINK_STATUS_STOP_REPORTING, "Link status stop reporting" },
1220
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_LINK_STATUS_INDICATION,     "Link status indication" },
1221
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_SA_BIT_SET_REQUEST,         "Sa-Bit set request" },
1222
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_SA_BIT_SET_CONFIRM,         "Sa-Bit set confirm" },
1223
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_SA_BIT_STATUS_REQUEST,      "Sa-Bit status request" },
1224
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_SA_BIT_STATUS_INDICATION,   "Sa-Bit status indication" },
1225
   { MSG_CLASS_V5PTM_MSG_DRAFT * 256 + V5PTM_MSG_TYPE_ERROR_INDICATION,           "Error indication" },
1226
1227
1228
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_Reserved,                   "Reserved" },
1229
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_DATA_REQUEST,               "Data Req" },
1230
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_DATA_INDICATION,            "Data Ind" },
1231
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_UNIT_DATA_REQUEST,          "U Data Req" },
1232
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_UNIT_DATA_INDICATION,       "U Data Ind" },
1233
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_ESTABLISH_REQUEST,          "Est Req" },
1234
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_ESTABLISH_CONFIRM,          "Est Conf" },
1235
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_ESTABLISH_INDICATION,       "Est Ind" },
1236
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_RELEASE_REQUEST,            "Rel Req" },
1237
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_RELEASE_CONFIRM,            "Rel Con" },
1238
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_RELEASE_INDICATION,         "Rel Ind" },
1239
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_LINK_STATUS_START_REPORTING,"Link Status Start Rep" },
1240
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_LINK_STATUS_STOP_REPORTING, "Link Status Stop Rep" },
1241
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_LINK_STATUS_INDICATION,     "Link Status Ind" },
1242
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_SA_BIT_SET_REQUEST,         "Sa-Bit Set Req" },
1243
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_SA_BIT_SET_CONFIRM,         "Sa-Bit set Conf" },
1244
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_SA_BIT_STATUS_REQUEST,      "Sa-Bit Status Req" },
1245
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_SA_BIT_STATUS_INDICATION,   "Sa-Bit Status Ind" },
1246
   { MSG_CLASS_V5PTM_MSG * 256 + V5PTM_MSG_TYPE_ERROR_INDICATION,           "Error Ind" },
1247
   { 0,                                                                                  NULL } };
1248
1249
1250
static void
1251
dissect_common_header(tvbuff_t *common_header_tvb, packet_info *pinfo, proto_tree *v5ua_tree)
1252
179
{
1253
179
   proto_item *common_header_item;
1254
179
   proto_tree *common_header_tree;
1255
1256
179
   uint8_t message_class, message_type;
1257
1258
179
   message_class  = tvb_get_uint8(common_header_tvb, COMMON_HEADER_MSG_CLASS_OFFSET);
1259
179
   message_type   = tvb_get_uint8(common_header_tvb, COMMON_HEADER_MSG_TYPE_OFFSET);
1260
1261
   /* Add message type into info column */
1262
179
   col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(message_class * 256 + message_type, msg_class_type_values_short, "UNKNOWN"));
1263
1264
1265
179
   if (v5ua_tree) {
1266
1267
      /* create proto_tree stuff */
1268
178
      common_header_tree   = proto_tree_add_subtree(v5ua_tree, common_header_tvb, COMMON_HEADER_OFFSET, -1,
1269
178
                                ett_v5ua_common_header, &common_header_item, "Common Msg-Header");
1270
1271
      /* add the components of the common header to the protocol tree */
1272
178
      proto_tree_add_item(common_header_tree, hf_version, common_header_tvb, COMMON_HEADER_VERSION_OFFSET, COMMON_HEADER_VERSION_LENGTH, ENC_BIG_ENDIAN);
1273
178
      proto_tree_add_item(common_header_tree, hf_reserved, common_header_tvb, COMMON_HEADER_RESERVED_OFFSET, COMMON_HEADER_RESERVED_LENGTH, ENC_BIG_ENDIAN);
1274
178
      proto_tree_add_item(common_header_tree, hf_msg_class, common_header_tvb, COMMON_HEADER_MSG_CLASS_OFFSET, COMMON_HEADER_MSG_CLASS_LENGTH, ENC_BIG_ENDIAN);
1275
178
      proto_tree_add_uint_format_value(common_header_tree, hf_msg_type,
1276
178
            common_header_tvb, COMMON_HEADER_MSG_TYPE_OFFSET, COMMON_HEADER_MSG_TYPE_LENGTH,
1277
178
            message_type, "%s ( %u )",
1278
178
            val_to_str_const(message_class * 256 + message_type, msg_class_type_values, "reserved"), message_type);
1279
178
      proto_tree_add_item(common_header_tree, hf_msg_length, common_header_tvb, COMMON_HEADER_MSG_LENGTH_OFFSET, COMMON_HEADER_MSG_LENGTH_LENGTH, ENC_BIG_ENDIAN);
1280
1281
      /* Add message type to the Common Msg-Header line */
1282
178
      proto_item_append_text(common_header_item, " (%s)",val_to_str_const(message_class * 256 + message_type, msg_class_type_values, "Unknown Msg-Type"));
1283
178
      messageclassCopy = message_class;
1284
178
   }
1285
1286
   /* the following info are required to dissect IUA-Draft messages.
1287
      In the DRAFT-Specification V5UA-Parameters are not separated by Tag-Length-Header (as defined in RFC-Spec) */
1288
179
   if (iua_version == DRAFT){
1289
34
      msg_class = message_class;
1290
34
      msg_type  = message_type;
1291
34
      msg_length = tvb_get_ntohl (common_header_tvb, COMMON_HEADER_MSG_LENGTH_OFFSET);
1292
34
   }
1293
179
}
1294
1295
/* dissect the V5UA-packet in two subsets: Common Msg-Header (used by all msgs) and V5UA-parameter */
1296
static void
1297
dissect_v5ua_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *v5ua_tree)
1298
179
{
1299
179
   tvbuff_t *common_header_tvb, *parameters_tvb;
1300
1301
179
   common_header_tvb = tvb_new_subset_length(tvb, COMMON_HEADER_OFFSET, COMMON_HEADER_LENGTH);
1302
179
   dissect_common_header(common_header_tvb, pinfo, v5ua_tree);
1303
1304
179
   parameters_tvb    = tvb_new_subset_remaining(tvb, COMMON_HEADER_LENGTH);
1305
179
   dissect_parameters(parameters_tvb, pinfo, tree, v5ua_tree);
1306
179
   if (dlci_efa >= 0 && dlci_efa <= 8175) {
1307
71
      if ((messageclassCopy == 0) || (messageclassCopy == 3) || (messageclassCopy == 4)) {
1308
1
         messageclassCopy = -1;
1309
1
      }
1310
70
      else {
1311
70
         col_append_str(pinfo->cinfo, COL_INFO, " | ");
1312
70
         col_append_fstr(pinfo->cinfo, COL_INFO, "LinkId: %u", linkIdentifier);
1313
70
      }
1314
71
   }
1315
1316
179
   if (sa_bit_id > -1) {
1317
0
      col_append_str(pinfo->cinfo, COL_INFO, " | ");
1318
0
      col_append_fstr(pinfo->cinfo, COL_INFO, "SA7bit: %u", sa_bit_id);
1319
0
      sa_bit_id = -1;
1320
0
   }
1321
1322
179
   if (link_status_operational > -1) {
1323
0
      if (link_status_operational == 0) {
1324
0
         col_append_str(pinfo->cinfo, COL_INFO, " | operational");
1325
0
      }
1326
0
      else if (link_status_operational == 1) {
1327
0
         col_append_str(pinfo->cinfo, COL_INFO, " | non-operational");
1328
0
      }
1329
0
      link_status_operational = -1;
1330
0
   }
1331
1332
179
}
1333
1334
static int
1335
dissect_v5ua(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1336
181
{
1337
181
   int     offset, remaining_length, length, tag, one_bit;
1338
1339
1340
   /* Set up structures needed to add the protocol subtree and manage it */
1341
181
   proto_tree *v5ua_tree;
1342
181
   proto_item *ti;
1343
1344
   /* Make entries in Protocol column and Info column on summary display */
1345
181
   col_set_str(pinfo->cinfo, COL_PROTOCOL, "V5UA");
1346
   /* end */
1347
181
   col_clear(pinfo->cinfo, COL_INFO);
1348
1349
   /* create display subtree for the protocol */
1350
181
   ti = proto_tree_add_item(tree, proto_v5ua, tvb, 0, -1, ENC_NA);
1351
181
   v5ua_tree = proto_item_add_subtree(ti, ett_v5ua);
1352
1353
   /* detect version of IUA */
1354
181
   iua_version = RFC;
1355
181
   offset = COMMON_HEADER_LENGTH;
1356
1357
181
   remaining_length = tvb_reported_length_remaining(tvb, offset);
1358
1359
15.6k
   while(remaining_length) {
1360
15.4k
      tag = tvb_get_ntohs(tvb, offset);
1361
      /*0x01,0x03: Inerface Id (draft&RFC)*/
1362
15.4k
      if(tag==0x1){
1363
15
         length = tvb_get_ntohs(tvb, offset+2);
1364
15
         tag = tvb_get_ntohs(tvb, offset+length);
1365
         /* tag 0x5 indicates the DLCI in the V5UA-Header accoriding to RFC spec */
1366
15
         if(tag==0x81){
1367
0
            remaining_length = false;
1368
0
         }
1369
15
         else{
1370
15
            one_bit = tvb_get_uint8(tvb, offset+4+length+1);
1371
            /* no indication from DLCI by tag (in the V5UA-Header according DRAFT).
1372
               Thus the ONE-Bit within DLCI have to compare */
1373
15
            if((one_bit & 0x01) == 0x01){
1374
7
               iua_version = DRAFT;
1375
7
               remaining_length = false;
1376
7
            }
1377
            /* an indication to incorrect bit in DLCI.
1378
               Must be include to decode an incorrect implemented message on Nortels PVG*/
1379
8
            else{
1380
8
               proto_item_append_text(v5ua_tree, "   !! DLCI INCORRECT !!");
1381
1382
8
               iua_version = DRAFT;
1383
8
               remaining_length = false;
1384
8
            }
1385
15
         }
1386
15
      }
1387
      /*0x02: AL Id (draft) following after common msg header without V5UA header*/
1388
15.4k
      else if(tag==0x02){
1389
20
         iua_version = DRAFT;
1390
20
         remaining_length = false;
1391
20
      }
1392
      /*0x03: Text formatted IId SHALL not be supported by draft*/
1393
15.4k
      else if(tag==0x03){
1394
45
         iua_version = RFC;
1395
45
         remaining_length = false;
1396
45
      }
1397
15.4k
      else if(tag==0x11){
1398
12
         remaining_length = false;
1399
12
      }
1400
      /*ASP, Notify and Error messages (RFC) only contain common msg header followed by parameter*/
1401
15.3k
      else if(tag==0x04 || tag == 0x0a || tag == 0x0b || tag == 0x0c || tag == 0x0d){
1402
42
         remaining_length = false;
1403
42
      }
1404
15.3k
      else{
1405
15.3k
         offset+=2;
1406
15.3k
         remaining_length = tvb_reported_length_remaining(tvb, offset);
1407
15.3k
      }
1408
      /* add a notice for the draft version */
1409
15.4k
      if(iua_version == DRAFT){
1410
34
         col_set_str(pinfo->cinfo, COL_PROTOCOL, "V5UA (draft)");
1411
34
      }
1412
15.4k
   }
1413
1414
   /* dissect the message */
1415
181
   dissect_v5ua_message(tvb, pinfo, tree, v5ua_tree);
1416
181
   return tvb_captured_length(tvb);
1417
181
}
1418
1419
1420
/* Register the protocol with Wireshark */
1421
1422
/* this format is require because a script is used to build the C function
1423
   that calls all the protocol registration. */
1424
1425
void
1426
proto_register_v5ua(void)
1427
16
{
1428
1429
   /* Setup list of header fields  */
1430
16
   static hf_register_info hf[] = {
1431
16
      { &hf_version,
1432
16
         { "Version", "v5ua.version",
1433
16
            FT_UINT8, BASE_DEC, VALS(v5ua_protocol_version_values), 0x0,
1434
16
            NULL, HFILL } },
1435
16
      { &hf_reserved,
1436
16
         { "Reserved", "v5ua.reserved",
1437
16
            FT_UINT8, BASE_HEX, NULL, 0x0,
1438
16
            NULL, HFILL } },
1439
16
      { &hf_msg_class,
1440
16
         { "Message class", "v5ua.msg_class",
1441
16
            FT_UINT8, BASE_DEC, VALS(msg_class_values), 0x0,
1442
16
            NULL, HFILL } },
1443
16
      { &hf_msg_type,
1444
16
         { "Message Type", "v5ua.msg_type",
1445
16
            FT_UINT8, BASE_DEC, NULL, 0x0,
1446
16
            NULL, HFILL } },
1447
#if 0
1448
      { &hf_msg_type_id,
1449
         { "Message Type ID", "v5ua.msg_type_id",
1450
            FT_UINT8, BASE_DEC, VALS(msg_class_type_values), 0x0,
1451
            NULL, HFILL } },
1452
#endif
1453
16
      { &hf_msg_length,
1454
16
         { "Message length", "v5ua.msg_length",
1455
16
            FT_UINT32, BASE_DEC, NULL, 0x0,
1456
16
            NULL, HFILL } },
1457
16
      { &hf_link_id,
1458
16
         { "Link Identifier", "v5ua.link_id",
1459
16
            FT_UINT32, BASE_DEC, NULL, 0xffffffe0,
1460
16
            NULL, HFILL } },
1461
16
      { &hf_chnl_id,
1462
16
         { "Channel Identifier", "v5ua.channel_id",
1463
16
            FT_UINT8, BASE_DEC, NULL, 0x1f,
1464
16
            NULL, HFILL } },
1465
1466
16
      { &hf_adaptation_layer_id,
1467
16
         { "Adaptation Layer ID", "v5ua.adaptation_layer_id",
1468
16
            FT_STRING, BASE_NONE,NULL, 0x0,
1469
16
            NULL, HFILL } },
1470
16
      { &hf_text_if_id,
1471
16
         { "Text interface identifier","v5ua.text_interface_id",
1472
16
            FT_STRING, BASE_NONE,NULL, 0x0,
1473
16
            NULL, HFILL } },
1474
16
      { &hf_scn_protocol_id,
1475
16
         { "SCN Protocol Identifier","v5ua.scn_protocol_id",
1476
16
            FT_STRING, BASE_NONE,NULL, 0x0,
1477
16
            NULL, HFILL } },
1478
16
      { &hf_info_string,
1479
16
         { "Info String", "v5ua.info_string",
1480
16
            FT_STRING, BASE_NONE,NULL, 0x0,
1481
16
            NULL, HFILL } },
1482
16
      { &hf_asp_identifier,
1483
16
         { "ASP Identifier", "v5ua.asp_identifier",
1484
16
            FT_UINT32, BASE_HEX, NULL, 0x0,
1485
16
            NULL, HFILL } },
1486
16
      { &hf_dlci_zero_bit,
1487
16
         { "Zero bit", "v5ua.dlci_zero_bit",
1488
16
            FT_BOOLEAN, 8, NULL, 0x01,
1489
16
            NULL, HFILL } },
1490
16
      { &hf_dlci_spare_bit,
1491
16
         { "Spare bit", "v5ua.dlci_spare_bit",
1492
16
            FT_BOOLEAN, 8, NULL, 0x02,
1493
16
            NULL, HFILL } },
1494
16
      { &hf_dlci_sapi,
1495
16
         { "SAPI", "v5ua.dlci_sapi",
1496
16
            FT_UINT8, BASE_HEX, NULL, 0xfc,
1497
16
            NULL, HFILL } },
1498
16
      { &hf_dlci_one_bit,
1499
16
         { "One bit", "v5ua.dlci_one_bit",
1500
16
            FT_BOOLEAN, 8, NULL, 0x01,
1501
16
            NULL, HFILL } },
1502
16
      { &hf_dlci_tei,
1503
16
         { "TEI", "v5ua.dlci_tei",
1504
16
            FT_UINT8, BASE_HEX, NULL, 0xfe,
1505
16
            NULL, HFILL } },
1506
16
      { &hf_efa,
1507
16
         { "Envelope Function Address","v5ua.efa",
1508
16
            FT_UINT16, BASE_DEC, VALS(efa_values), 0x0,
1509
16
            NULL, HFILL } },
1510
#if 0
1511
      { &hf_spare_efa,
1512
         { "Envelope Function Address (spare)","v5ua.efa",
1513
            FT_UINT16, BASE_DEC, NULL, ~7,
1514
            NULL, HFILL } },
1515
#endif
1516
16
      { &hf_asp_reason,
1517
16
         { "Reason", "v5ua.asp_reason",
1518
16
            FT_UINT32, BASE_HEX, VALS(asp_reason_values), 0x0,
1519
16
            NULL, HFILL } },
1520
16
      { &hf_release_reason,
1521
16
         { "Release Reason", "v5ua.release_reason",
1522
16
            FT_UINT32, BASE_HEX, VALS(release_reason_values), 0x0,
1523
16
            NULL, HFILL } },
1524
16
      { &hf_tei_status,
1525
16
         { "TEI status", "v5ua.tei_status",
1526
16
            FT_UINT32, BASE_HEX, VALS(tei_status_values), 0x0,
1527
16
            NULL, HFILL } },
1528
16
      { &hf_tei_draft_status,
1529
16
         { "TEI status", "v5ua.tei_draft_status",
1530
16
            FT_UINT32, BASE_HEX, VALS(tei_draft_status_values), 0x0,
1531
16
            NULL, HFILL } },
1532
16
      { &hf_link_status,
1533
16
         { "Link Status", "v5ua.link_status",
1534
16
            FT_UINT32, BASE_HEX, VALS(link_status_values), 0x0,
1535
16
            NULL, HFILL } },
1536
16
      { &hf_sa_bit_id,
1537
16
         { "BIT ID", "v5ua.sa_bit_id",
1538
16
            FT_UINT16, BASE_HEX, VALS(sa_bit_values), 0x0,
1539
16
            NULL, HFILL } },
1540
16
      { &hf_sa_bit_value,
1541
16
         { "Bit Value", "v5ua.sa_bit_value",
1542
16
            FT_UINT16, BASE_HEX, VALS(sa_bit_values), 0x0,
1543
16
            NULL, HFILL } },
1544
16
      { &hf_parameter_tag,
1545
16
         { "Parameter Tag", "v5ua.parameter_tag",
1546
16
            FT_UINT16, BASE_HEX, VALS(parameter_tag_values), 0x0,
1547
16
            NULL, HFILL } },
1548
16
      { &hf_parameter_tag_draft,
1549
16
         { "Parameter Tag", "v5ua.parameter_tag",
1550
16
            FT_UINT16, BASE_HEX, VALS(parameter_tag_draft_values), 0x0,
1551
16
            NULL, HFILL } },
1552
16
      { &hf_parameter_length,
1553
16
         { "Parameter length", "v5ua.parameter_length",
1554
16
            FT_UINT16, BASE_DEC, NULL, 0x0,
1555
16
            NULL, HFILL } },
1556
16
      { &hf_parameter_value,
1557
16
         { "Parameter value", "v5ua.parameter_value",
1558
16
            FT_BYTES, BASE_NONE,NULL, 0x0,
1559
16
            NULL, HFILL } },
1560
16
      { &hf_parameter_padding,
1561
16
         { "Parameter padding", "v5ua.parameter_padding",
1562
16
            FT_BYTES, BASE_NONE,NULL, 0x0,
1563
16
            NULL, HFILL } },
1564
16
      { &hf_diagnostic_info,
1565
16
         { "Diagnostic Information", "v5ua.diagnostic_info",
1566
16
            FT_BYTES, BASE_NONE,NULL, 0x0,
1567
16
            NULL, HFILL } },
1568
16
      { &hf_if_range_start,
1569
16
         { "Interface range Start", "v5ua.interface_range_start",
1570
16
            FT_UINT32, BASE_HEX, NULL, 0x0,
1571
16
            NULL, HFILL } },
1572
16
      { &hf_if_range_end,
1573
16
         { "Interface range End", "v5ua.interface_range_end",
1574
16
            FT_UINT32, BASE_HEX, NULL, 0x0,
1575
16
            NULL, HFILL } },
1576
16
      { &hf_heartbeat_data,
1577
16
         { "Heartbeat data", "v5ua.heartbeat_data",
1578
16
            FT_BYTES, BASE_NONE,NULL, 0x0,
1579
16
            NULL, HFILL } },
1580
16
      { &hf_traffic_mode_type,
1581
16
         { "Traffic mode type", "v5ua.traffic_mode_type",
1582
16
            FT_UINT32, BASE_HEX, VALS(traffic_mode_type_values), 0x0,
1583
16
            NULL, HFILL } },
1584
16
      { &hf_error_code,
1585
16
         { "Error code", "v5ua.error_code",
1586
16
            FT_UINT32, BASE_HEX, VALS(error_code_values), 0x0,
1587
16
            NULL, HFILL } },
1588
16
      { &hf_draft_error_code,
1589
16
         { "Error code (draft)", "v5ua.draft_error_code",
1590
16
            FT_UINT32, BASE_HEX, VALS(draft_error_code_values), 0x0,
1591
16
            NULL, HFILL } },
1592
16
      { &hf_status_type,
1593
16
         { "Status type", "v5ua.status_type",
1594
16
            FT_UINT16, BASE_DEC, VALS(status_type_values), 0x0,
1595
16
            NULL, HFILL } },
1596
16
      { &hf_status_id,
1597
16
         { "Status identification", "v5ua.status_id",
1598
16
            FT_UINT16, BASE_DEC, NULL, 0x0,
1599
16
            NULL, HFILL } },
1600
16
      { &hf_error_reason,
1601
16
         { "Error Reason", "v5ua.error_reason",
1602
16
            FT_UINT32, BASE_HEX, VALS(error_reason_values), 0x0,
1603
16
            NULL, HFILL } }
1604
16
   };
1605
1606
   /* Setup protocol subtree array */
1607
16
   static int *ett[] = {
1608
16
      &ett_v5ua,
1609
16
      &ett_v5ua_common_header,
1610
16
      &ett_v5ua_parameter,
1611
16
      &ett_v5ua_layer3
1612
16
   };
1613
1614
   /* Register the protocol name and description */
1615
16
   proto_v5ua = proto_register_protocol("V5.2-User Adaptation Layer", "V5UA", "v5ua");
1616
1617
   /* Required function calls to register the header fields and subtrees used */
1618
16
   proto_register_field_array(proto_v5ua, hf, array_length(hf));
1619
16
   proto_register_subtree_array(ett, array_length(ett));
1620
1621
   /* Register the dissector handle */
1622
16
   v5ua_handle = register_dissector("v5ua", dissect_v5ua, proto_v5ua);
1623
16
}
1624
1625
1626
/* In RFC specification the SCTP registered User Port Number Assignment for V5UA is 5675 */
1627
16
#define SCTP_PORT_V5UA_RFC         5675
1628
16
#define SCTP_PORT_V5UA_DRAFT      10001
1629
1630
void
1631
proto_reg_handoff_v5ua(void)
1632
16
{
1633
16
   q931_handle = find_dissector_add_dependency("q931", proto_v5ua);
1634
16
   v52_handle = find_dissector_add_dependency("v52", proto_v5ua);
1635
1636
16
   dissector_add_uint("sctp.port", SCTP_PORT_V5UA_DRAFT, v5ua_handle);
1637
16
   dissector_add_uint("sctp.port", SCTP_PORT_V5UA_RFC, v5ua_handle);
1638
16
   dissector_add_uint("sctp.ppi",  V5UA_PAYLOAD_PROTOCOL_ID, v5ua_handle);
1639
16
}
1640
1641
/*
1642
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
1643
 *
1644
 * Local variables:
1645
 * c-basic-offset: 4
1646
 * tab-width: 8
1647
 * indent-tabs-mode: nil
1648
 * End:
1649
 *
1650
 * vi: set shiftwidth=4 tabstop=8 expandtab:
1651
 * :indentSize=4:tabSize=8:noTabs=true:
1652
 */