Create a list of MTP Service Indicator macros and use them.
[obnox/wireshark/wip.git] / epan / dissectors / packet-alcap.c
1 /* packet-alcap.c
2 * Routines for ALCAP (Q.2630.3) dissection
3 * AAL type 2 signalling protocol - Capability set 3
4 * 10/2003
5 *
6 * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
7 * In association with Telos Technology Inc.
8 *
9 * Copyright 2005, Luis E. Garcia Ontanon <luis.ontanon [AT] gmail.com>
10 *
11 * $Id$
12 *
13 * Wireshark - Network traffic analyzer
14 * By Gerald Combs <gerald@wireshark.org>
15 * Copyright 1998 Gerald Combs
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version 2
20 * of the License, or (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 */
31
32 #ifdef HAVE_CONFIG_H
33 # include "config.h"
34 #endif
35
36 #include <glib.h>
37
38 #include <wsutil/str_util.h>
39
40 #include <epan/packet.h>
41 #include <epan/emem.h>
42 #include <epan/prefs.h>
43 #include "packet-alcap.h"
44 #include "packet-mtp3.h"
45 #include <epan/dissectors/packet-isup.h>
46 #include <epan/expert.h>
47
48 #define ALCAP_MSG_HEADER_LEN     6
49 #define ALCAP_PARM_HEADER_LEN    3
50 #define FIELD_NSAP_ADDRESS_LEN  20
51
52 static const value_string msg_type_strings[] = {
53     {  1,   "Block confirm (BLC)" },
54     {  2,   "Block request (BLO)" },
55     {  3,   "Confusion (CFN)" },
56     {  4,   "Establish confirm (ECF)" },
57     {  5,   "Establish request (ERQ)" },
58     {  6,   "Release confirm (RLC)" },
59     {  7,   "Release request (REL)" },
60     {  8,   "Reset confirm (RSC)" },
61     {  9,   "Reset request (RES)" },
62     { 10,   "Unblock confirm (UBC)" },
63     { 11,   "Unblock request (UBL)" },
64     { 12,   "Modify Ack (MOA)" },
65     { 13,   "Modify Reject (MOR)" },
66     { 14,   "Modify Request (MOD)" },
67     { 0, NULL }
68 };
69
70 static const value_string send_notification[] = {
71     { 0, "Do Not Send Notification"},
72     { 1, "Send Notification" },
73     { 0, NULL }
74 };
75
76 static const value_string instruction_indicator[] = {
77     { 0, "Pass On Message or Parameter"},
78     { 1, "Discard Parameter" },
79     { 2, "Discard Message" },
80     { 3, "Release Connection" },
81     { 0, NULL }
82 };
83
84 static const value_string msg_parm_strings[] = {
85     {  1,  "Cause (CAU)" },
86     {  2,  "Connection element identifier (CEID)" },
87     {  3,  "Destination E.164 service endpoint address (DESEA)" },
88     {  4,  "Destination NSAP service endpoint address (DNSEA)" },
89     {  5,  "Link characteristics (ALC)" },
90     {  6,  "Originating signalling association identifier (OSAID)" },
91     {  7,  "Served user generated reference (SUGR)" },
92     {  8,  "Served user transport (SUT)" },
93     {  9,  "Service specific information (audio) (SSIA)" },
94     { 10,  "Service specific information (multirate) (SSIM)" },
95     { 11,  "Service specific information (SAR-assured) (SSISA)" },
96     { 12,  "Service specific information (SAR-unassured) (SSISU)" },
97     { 13,  "Test connection identifier (TCI)" },
98     { 14,  "Modify Support for Link Characteristics (MSLC)" },
99     { 15,  "Modify Support for Service Specific Information (MSSSI)" },
100     { 16,  "Path Type (PT)" },
101     { 17,  "Preferred Link Characteristics (PLC)" },
102     { 18,  "Preferred Service Specific Information - Audio Extended (PSSIAE)" },
103     { 19,  "Preferred Service Specific Information - Multirate Extended (PSSIME)" },
104     { 20,  "Served User Correlation ID (SUCI)" },
105     { 21,  "Origination NSAP Service Endpoint Address (ONSEA)" },
106     { 22,  "Service Specific Information - Audio Extended (SSIAE)" },
107     { 23,  "Service Specific Information - Multirate Extended (SSIME)" },
108     { 24,  "Automatic Congestion Control (ACC)" },
109     { 25,  "Connection Priority (CP)" },
110     { 26,  "Hop Counter (HC)" },
111     { 27,  "Origination E.164 Service Endpoint Address (OESEA)" },
112     { 28,  "Preferred Transfer Capability - FBW (PFBW)" },
113     { 29,  "Preferred Transfer Capability - VBWS (PVBWS)" },
114     { 30,  "Preferred Transfer Capability - VBWT (PVBWT)" },
115     { 31,  "TAR Controlled Connection (TCC)" },
116     { 32,  "Transfer Capability (FBW)" },
117     { 33,  "Transfer Capability (VBWS)" },
118     { 34,  "Transfer Capability (VBWT)" },
119     { 35,  "Transfer Capability Support (TCS)" },
120     { 0, NULL },
121 };
122
123
124 static const value_string enabled_disabled[] = {
125     {0, "disabled" },
126     {1, "enabled" },
127     {0,NULL}
128 };
129
130 static const value_string alaw_ulaw[] = {
131     {0, "A-Law" },
132     {1, "u-Law" },
133     {0,NULL}
134 };
135
136 static const value_string cause_coding_vals[] = {
137     {0, "ITU (Q.850 - Q.2610)"},
138     {1, "ISO/IEC"},
139     {2, "National"},
140     {3, "Private"},
141     {0,NULL}
142 };
143
144
145 static const value_string cause_values_itu[] = {
146     { 1, "Unallocated (unassigned) number"},
147     { 3, "No route to destination"},
148     { 31, "Normal, unspecified"},
149     { 34, "No circuit/channel available"},
150     { 38, "Network out of order"},
151     { 41, "Temporary failure"},
152     { 42, "Switching equipment congestion"},
153     { 44, "Requested circuit/channel not available"},
154     { 47, "Resource unavailable, unspecified"},
155     { 93, "AAL parameters cannot be supported"},
156     { 95, "Invalid message, unspecified"},
157     { 96, "Mandatory information element is missing"},
158     { 97, "Message type non-existent or not implemented"},
159     { 99, "Information element/parameter non-existent or not implemented"},
160     { 100, "Invalid information element contents"},
161     { 102, "Recovery on timer expiry"},
162     { 110, "Message with unrecognized parameter, discarded"},
163     { 111, "Protocol error, unspecified"},
164     { 0, NULL }
165 };
166
167 static const value_string audio_profile_type[] = {
168     { 0, "From I.366.2" },
169     { 1, "From Organization" },
170     { 2, "Custom" },
171     { 3, "Reserved" },
172     { 0, NULL }
173 };
174
175 static const value_string congestion_level[] = {
176     { 0, "Spare" },
177     { 1, "Congestion Level 1 exceeded" },
178     { 2, "Congestion Level 2 exceeded" },
179     { 0, NULL }
180 };
181
182 static const value_string connection_priority[] = {
183     { 0, "Level 1 (Highest)" },
184     { 1, "Level 2" },
185     { 2, "Level 3" },
186     { 3, "Level 4" },
187     { 4, "Level 5 (Lowest)" },
188     { 5, "Reserved" },
189     { 6, "Reserved" },
190     { 7, "Reserved" },
191     { 0, NULL }
192 };
193
194
195
196 static const char *alcap_proto_name = "AAL type 2 signalling protocol (Q.2630)";
197 static const char *alcap_proto_name_short = "ALCAP";
198
199 /* Initialize the subtree pointers */
200 static gint ett_alcap = -1;
201 static gint ett_leg = -1;
202 static gint ett_compat = -1;
203 static gint ett_cau_diag = -1;
204
205 /* Initialize the protocol and registered fields */
206 static int proto_alcap = -1;
207
208 static int hf_alcap_dsaid = -1;
209 static int hf_alcap_msg_id = -1;
210 static int hf_alcap_compat = -1;
211 static int hf_alcap_compat_pass_on_sni = -1;
212 static int hf_alcap_compat_pass_on_ii = -1;
213 static int hf_alcap_compat_general_sni = -1;
214 static int hf_alcap_compat_general_ii = -1;
215
216 static int hf_alcap_param_id = -1;
217 static int hf_alcap_param_len = -1;
218
219 static int hf_alcap_unknown = -1;
220
221 static int hf_alcap_cau_coding = -1;
222 static int hf_alcap_cau_value_itu = -1;
223 static int hf_alcap_cau_value_non_itu = -1;
224 static int hf_alcap_cau_diag = -1;
225 static int hf_alcap_cau_diag_len = -1;
226 static int hf_alcap_cau_diag_msg = -1;
227 static int hf_alcap_cau_diag_param_id = -1;
228 static int hf_alcap_cau_diag_field_num = -1;
229
230 static int hf_alcap_ceid_pathid = -1;
231 static int hf_alcap_ceid_cid = -1;
232
233 static int hf_alcap_dnsea = -1;
234
235 static int hf_alcap_alc_max_br_fw = -1;
236 static int hf_alcap_alc_max_br_bw = -1;
237 static int hf_alcap_alc_avg_br_fw = -1;
238 static int hf_alcap_alc_avg_br_bw = -1;
239 static int hf_alcap_alc_max_sdu_fw = -1;
240 static int hf_alcap_alc_max_sdu_bw = -1;
241 static int hf_alcap_alc_avg_sdu_fw = -1;
242 static int hf_alcap_alc_avg_sdu_bw = -1;
243
244 static int hf_alcap_osaid = -1;
245
246 static int hf_alcap_sugr = -1;
247
248 static int hf_alcap_sut_len = -1;
249 static int hf_alcap_sut = -1;
250
251 static int hf_alcap_ssia_pr_type = -1;
252 static int hf_alcap_ssia_pr_id = -1;
253 static int hf_alcap_ssia_frm = -1;
254 static int hf_alcap_ssia_cmd = -1;
255 static int hf_alcap_ssia_mfr2 = -1;
256 static int hf_alcap_ssia_mfr1 = -1;
257 static int hf_alcap_ssia_dtmf = -1;
258 static int hf_alcap_ssia_cas = -1;
259 static int hf_alcap_ssia_fax = -1;
260 static int hf_alcap_ssia_pcm = -1;
261 static int hf_alcap_ssia_max_len = -1;
262 static int hf_alcap_ssia_oui = -1;
263
264 static int hf_alcap_ssim_frm = -1;
265 static int hf_alcap_ssim_mult = -1;
266 static int hf_alcap_ssim_max = -1;
267
268 static int hf_alcap_ssisa_max_sssar_fw = -1;
269 static int hf_alcap_ssisa_max_sssar_bw = -1;
270 static int hf_alcap_ssisa_max_sscop_sdu_fw = -1;
271 static int hf_alcap_ssisa_max_sscop_sdu_bw = -1;
272 static int hf_alcap_ssisa_max_sscop_uu_fw = -1;
273 static int hf_alcap_ssisa_max_sscop_uu_bw = -1;
274
275 static int hf_alcap_ssisu_max_sssar_fw = -1;
276 static int hf_alcap_ssisu_max_sssar_bw = -1;
277 static int hf_alcap_ssisu_ted = -1;
278
279 static int hf_alcap_pt = -1;
280
281 static int hf_alcap_plc_max_br_fw = -1;
282 static int hf_alcap_plc_max_br_bw = -1;
283 static int hf_alcap_plc_avg_br_fw = -1;
284 static int hf_alcap_plc_avg_br_bw = -1;
285 static int hf_alcap_plc_max_sdu_fw = -1;
286 static int hf_alcap_plc_max_sdu_bw = -1;
287 static int hf_alcap_plc_avg_sdu_fw = -1;
288 static int hf_alcap_plc_avg_sdu_bw = -1;
289
290 static int hf_alcap_pssiae_pr_type = -1;
291 static int hf_alcap_pssiae_pr_id = -1;
292 static int hf_alcap_pssiae_lb = -1;
293 static int hf_alcap_pssiae_rc = -1;
294 static int hf_alcap_pssiae_syn = -1;
295 static int hf_alcap_pssiae_frm = -1;
296 static int hf_alcap_pssiae_cmd = -1;
297 static int hf_alcap_pssiae_mfr2 = -1;
298 static int hf_alcap_pssiae_mfr1 = -1;
299 static int hf_alcap_pssiae_dtmf = -1;
300 static int hf_alcap_pssiae_cas = -1;
301 static int hf_alcap_pssiae_fax = -1;
302 static int hf_alcap_pssiae_pcm = -1;
303 static int hf_alcap_pssiae_max_len = -1;
304 static int hf_alcap_pssiae_oui = -1;
305
306 static int hf_alcap_pssime_frm = -1;
307 static int hf_alcap_pssime_lb = -1;
308 static int hf_alcap_pssime_mult = -1;
309 static int hf_alcap_pssime_max = -1;
310
311 static int hf_alcap_suci = -1;
312
313 static int hf_alcap_onsea = -1;
314
315 static int hf_alcap_ssiae_pr_type = -1;
316 static int hf_alcap_ssiae_pr_id = -1;
317 static int hf_alcap_ssiae_lb = -1;
318 static int hf_alcap_ssiae_rc = -1;
319 static int hf_alcap_ssiae_syn = -1;
320 static int hf_alcap_ssiae_frm = -1;
321 static int hf_alcap_ssiae_cmd = -1;
322 static int hf_alcap_ssiae_mfr2 = -1;
323 static int hf_alcap_ssiae_mfr1 = -1;
324 static int hf_alcap_ssiae_dtmf = -1;
325 static int hf_alcap_ssiae_cas = -1;
326 static int hf_alcap_ssiae_fax = -1;
327 static int hf_alcap_ssiae_pcm = -1;
328 static int hf_alcap_ssiae_max_len = -1;
329 static int hf_alcap_ssiae_oui = -1;
330
331 static int hf_alcap_ssime_frm = -1;
332 static int hf_alcap_ssime_lb = -1;
333 static int hf_alcap_ssime_mult = -1;
334 static int hf_alcap_ssime_max = -1;
335
336 static int hf_alcap_acc_level = -1;
337
338 static int hf_alcap_cp = -1;
339
340 static int hf_alcap_hc = -1;
341
342 static int hf_alcap_pfbw_br_fw = -1;
343 static int hf_alcap_pfbw_br_bw = -1;
344 static int hf_alcap_pfbw_bucket_fw = -1;
345 static int hf_alcap_pfbw_bucket_bw = -1;
346 static int hf_alcap_pfbw_size_fw = -1;
347 static int hf_alcap_pfbw_size_bw = -1;
348
349 static int hf_alcap_pvbws_br_fw = -1;
350 static int hf_alcap_pvbws_br_bw = -1;
351 static int hf_alcap_pvbws_bucket_fw = -1;
352 static int hf_alcap_pvbws_bucket_bw = -1;
353 static int hf_alcap_pvbws_size_fw = -1;
354 static int hf_alcap_pvbws_size_bw = -1;
355 static int hf_alcap_pvbws_stt = -1;
356
357 static int hf_alcap_pvbwt_peak_br_fw = -1;
358 static int hf_alcap_pvbwt_peak_br_bw = -1;
359 static int hf_alcap_pvbwt_peak_bucket_fw = -1;
360 static int hf_alcap_pvbwt_peak_bucket_bw = -1;
361 static int hf_alcap_pvbwt_sust_br_fw = -1;
362 static int hf_alcap_pvbwt_sust_br_bw = -1;
363 static int hf_alcap_pvbwt_sust_bucket_fw = -1;
364 static int hf_alcap_pvbwt_sust_bucket_bw = -1;
365 static int hf_alcap_pvbwt_size_fw = -1;
366 static int hf_alcap_pvbwt_size_bw = -1;
367
368 static int hf_alcap_fbw_br_fw = -1;
369 static int hf_alcap_fbw_br_bw = -1;
370 static int hf_alcap_fbw_bucket_fw = -1;
371 static int hf_alcap_fbw_bucket_bw = -1;
372 static int hf_alcap_fbw_size_fw = -1;
373 static int hf_alcap_fbw_size_bw = -1;
374
375 static int hf_alcap_vbws_br_fw = -1;
376 static int hf_alcap_vbws_br_bw = -1;
377 static int hf_alcap_vbws_bucket_fw = -1;
378 static int hf_alcap_vbws_bucket_bw = -1;
379 static int hf_alcap_vbws_size_fw = -1;
380 static int hf_alcap_vbws_size_bw = -1;
381 static int hf_alcap_vbws_stt = -1;
382
383 static int hf_alcap_vbwt_peak_br_fw = -1;
384 static int hf_alcap_vbwt_peak_br_bw = -1;
385 static int hf_alcap_vbwt_peak_bucket_fw = -1;
386 static int hf_alcap_vbwt_peak_bucket_bw = -1;
387 static int hf_alcap_vbwt_sust_br_fw = -1;
388 static int hf_alcap_vbwt_sust_br_bw = -1;
389 static int hf_alcap_vbwt_sust_bucket_fw = -1;
390 static int hf_alcap_vbwt_sust_bucket_bw = -1;
391 static int hf_alcap_vbwt_size_fw = -1;
392 static int hf_alcap_vbwt_size_bw = -1;
393
394
395 static int hf_alcap_leg_osaid = -1;
396 static int hf_alcap_leg_dsaid = -1;
397 static int hf_alcap_leg_pathid = -1;
398 static int hf_alcap_leg_cid = -1;
399 static int hf_alcap_leg_sugr = -1;
400 static int hf_alcap_leg_dnsea = -1;
401 static int hf_alcap_leg_onsea = -1;
402 static int hf_alcap_leg_frame = -1;
403 static int hf_alcap_leg_release_cause = -1;
404
405 static gboolean keep_persistent_info = TRUE;
406
407 static emem_tree_t* legs_by_dsaid = NULL;
408 static emem_tree_t* legs_by_osaid = NULL;
409 static emem_tree_t* legs_by_bearer = NULL;
410
411 static const gchar* dissect_fields_unknown(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
412     proto_item* pi = proto_tree_add_item(tree,hf_alcap_unknown,tvb,offset,len,ENC_NA);
413     proto_item_set_expert_flags(pi, PI_UNDECODED, PI_WARN);
414     return NULL;
415 }
416
417 static const gchar* dissect_fields_cau(packet_info* pinfo, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info) {
418     /*
419      * Q.2630.1 -> 7.3.1 Cause
420      *
421      * 7.4.16 Cause Value
422      * 7.4.17 Diagnostics
423      */
424
425     guint coding;
426     const gchar* ret_str;
427     proto_item* pi;
428
429     if (len < 2) {
430         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
431         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
432         return NULL;
433     }
434
435     msg_info->release_cause = tvb_get_guint8(tvb, offset+1) & 0x7f;
436
437     coding = tvb_get_guint8(tvb, offset) & 0x3;
438
439     proto_tree_add_item(tree, hf_alcap_cau_coding, tvb, offset, 1, ENC_BIG_ENDIAN);
440
441     if (coding == 0) {
442         pi = proto_tree_add_item(tree, hf_alcap_cau_value_itu, tvb, offset+1, 1, ENC_BIG_ENDIAN);
443
444         if ( msg_info->release_cause && msg_info->release_cause != 31 )
445             expert_add_info_format(pinfo, pi, PI_RESPONSE_CODE, PI_WARN, "Abnormal Release");
446
447         ret_str = val_to_str(msg_info->release_cause, cause_values_itu, "Unknown(%u)");
448     } else {
449         proto_tree_add_item(tree, hf_alcap_cau_value_non_itu, tvb, offset+1 , 1, ENC_BIG_ENDIAN);
450         ret_str = ep_strdup_printf("%u", msg_info->release_cause);
451     }
452
453     if (!tree) return ret_str;
454
455     offset += 2;
456
457     if (len > 2)  {
458         int diag_len = tvb_get_guint8(tvb,offset);
459
460         pi = proto_tree_add_item(tree,hf_alcap_cau_diag, tvb, offset,len-2,ENC_NA);
461         tree = proto_item_add_subtree(pi,ett_cau_diag);
462
463         proto_tree_add_item(tree, hf_alcap_cau_diag_len, tvb, offset, 1, ENC_BIG_ENDIAN);
464
465         if (diag_len) {
466             switch (msg_info->release_cause) {
467                 case 97:
468                 case 99:
469                 case 110:
470                     proto_tree_add_item(tree, hf_alcap_cau_diag_msg, tvb, ++offset, 1, ENC_BIG_ENDIAN);
471
472                     while(diag_len >= 2) {
473                         proto_tree_add_item(tree, hf_alcap_cau_diag_param_id, tvb, ++offset, 1, ENC_BIG_ENDIAN);
474                         proto_tree_add_item(tree, hf_alcap_cau_diag_field_num, tvb, ++offset, 1, ENC_BIG_ENDIAN);
475                         diag_len -= 2;
476                     }
477                     break;
478                 default:
479                     /* XXX - TODO Q.2610 */
480                     pi = proto_tree_add_text(tree,tvb,offset,diag_len,"Undecoded");
481                     proto_item_set_expert_flags(pi, PI_UNDECODED, PI_WARN);
482                     break;
483             }
484         }
485     }
486     return ret_str;
487 }
488
489 static const gchar* dissect_fields_ceid(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info) {
490     /*
491      * Q.2630.1 -> 7.3.2 Connection Element Identifier
492      *
493      * 7.4.3 Path Identifier
494      * 7.4.4 Channel Identifier
495      */
496     proto_item* pi;
497
498     if (len != 5) {
499         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
500         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
501         return NULL;
502     }
503
504     pi = proto_tree_add_item(tree,hf_alcap_ceid_pathid,tvb,offset,4,ENC_BIG_ENDIAN);
505
506     msg_info->pathid = tvb_get_ntohl(tvb,offset);
507     msg_info->cid = tvb_get_guint8(tvb,offset+4);
508
509     if (msg_info->pathid == 0) {
510         proto_item_append_text(pi," (All Paths in association)");
511         return "Path: 0 (All Paths)";
512     }
513
514     pi = proto_tree_add_item(tree,hf_alcap_ceid_cid,tvb,offset+4,1,ENC_BIG_ENDIAN);
515
516     if (msg_info->cid == 0) {
517         proto_item_append_text(pi," (All CIDs in the Path)");
518         return ep_strdup_printf("Path: %u CID: 0 (Every CID)",msg_info->pathid);
519     } else {
520         return ep_strdup_printf("Path: %u CID: %u",msg_info->pathid,msg_info->cid);
521     }
522 }
523
524 static const gchar* dissect_fields_desea(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
525     /*
526      * Q.2630.1 -> 7.3.3 Destination E.164 service endpoint address
527      *
528      * 7.4.13 Nature of Address
529      * 7.4.14 E.164 Address
530      */
531     e164_info_t* e164;
532
533     if (len < 2) {
534         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
535         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
536         return NULL;
537     }
538
539     e164 = ep_alloc(sizeof(e164_info_t));
540
541     e164->e164_number_type = CALLED_PARTY_NUMBER;
542     e164->nature_of_address = tvb_get_guint8(tvb,offset) & 0x7f;
543     e164->E164_number_str = (gchar*)tvb_get_ephemeral_string(tvb,offset+1,len);
544     e164->E164_number_length = len-1;
545
546     dissect_e164_number(tvb, tree, offset-1, len, *e164);
547
548     return NULL;
549 }
550
551 static const gchar* dissect_fields_oesea(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
552     /*
553      * Q.2630.3 -> 7.3.23 Origination E.164 service endpoint address
554      *
555      * 7.4.13 Nature of Address
556      * 7.4.14 E.164 Address
557      */
558     e164_info_t* e164;
559
560     if (len < 2) {
561         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
562         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
563         return NULL;
564     }
565
566     e164 = ep_alloc(sizeof(e164_info_t));
567
568     e164->e164_number_type = CALLING_PARTY_NUMBER;
569     e164->nature_of_address = tvb_get_guint8(tvb,offset) & 0x7f;
570     e164->E164_number_str = (gchar*)tvb_get_ephemeral_string(tvb,offset+1,len);
571     e164->E164_number_length = len-1;
572
573     dissect_e164_number(tvb, tree, offset-1, len, *e164);
574
575     return NULL;
576 }
577
578 static const gchar* dissect_fields_dnsea(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
579     /*
580      * Q.2630.1 -> 7.3.4 Destination NSAP service endpoint address
581      *
582      * 7.4.15 NSAP Address
583      */
584
585     if (len < 1) {
586         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
587         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
588         return NULL;
589     }
590
591     msg_info->dest_nsap = tvb_bytes_to_str(tvb,offset,20);
592
593     proto_tree_add_item(tree, hf_alcap_dnsea, tvb, offset, 20, ENC_NA);
594     dissect_nsap(tvb, offset,20, tree);
595
596     return NULL;
597 }
598
599 static const gchar* dissect_fields_onsea(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
600     /*
601      * Q.2630.3 -> 7.3.24 Origination NSAP service endpoint address
602      *
603      * 7.4.15 NSAP Address
604      */
605
606     if (len < 1) {
607         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
608         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
609         return NULL;
610     }
611
612     msg_info->orig_nsap = tvb_bytes_to_str(tvb,offset,20);
613
614     proto_tree_add_item(tree, hf_alcap_onsea, tvb, offset, 20, ENC_NA);
615     dissect_nsap(tvb, offset,20, tree);
616
617     return NULL;
618 }
619
620 static const gchar* dissect_fields_alc(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
621     /*
622      * Q.2630.1 -> 7.3.5 Link characteristics
623      *
624      * 7.4.11 CPS-SDU Bit Rate -> Maximum CPS-SDU Bit Rate
625      * 7.4.11 CPS-SDU Bit Rate -> Average CPS-SDU Bit Rate
626      * 7.4.12 CPS-SDU Size -> Maximum CPS-SDU Size
627      * 7.4.12 CPS-SDU Size -> Average CPS-SDU Size
628      */
629
630     if (len != 12) {
631         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
632         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
633         return NULL;
634     }
635
636     proto_tree_add_item(tree, hf_alcap_alc_max_br_fw, tvb, offset+0, 2, ENC_BIG_ENDIAN);
637     proto_tree_add_item(tree, hf_alcap_alc_max_br_bw, tvb, offset+2, 2, ENC_BIG_ENDIAN);
638     proto_tree_add_item(tree, hf_alcap_alc_avg_br_fw, tvb, offset+4, 2, ENC_BIG_ENDIAN);
639     proto_tree_add_item(tree, hf_alcap_alc_avg_br_bw, tvb, offset+6, 2, ENC_BIG_ENDIAN);
640     proto_tree_add_item(tree, hf_alcap_alc_max_sdu_fw, tvb, offset+8, 1, ENC_BIG_ENDIAN);
641     proto_tree_add_item(tree, hf_alcap_alc_max_sdu_bw, tvb, offset+9, 1, ENC_BIG_ENDIAN);
642     proto_tree_add_item(tree, hf_alcap_alc_avg_sdu_fw, tvb, offset+10, 1, ENC_BIG_ENDIAN);
643     proto_tree_add_item(tree, hf_alcap_alc_avg_sdu_bw, tvb, offset+11, 1, ENC_BIG_ENDIAN);
644
645     return NULL;
646 }
647
648 static const gchar* dissect_fields_plc(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
649     /*
650      * Q.2630.2 -> 7.3.19 Preferred Link characteristics
651      *
652      * 7.4.11 CPS-SDU Bit Rate -> Maximum CPS-SDU Bit Rate
653      * 7.4.11 CPS-SDU Bit Rate -> Average CPS-SDU Bit Rate
654      * 7.4.12 CPS-SDU Size -> Maximum CPS-SDU Size
655      * 7.4.12 CPS-SDU Size -> Average CPS-SDU Size
656      */
657
658     if (len != 12) {
659         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
660         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
661         return NULL;
662     }
663
664     proto_tree_add_item(tree, hf_alcap_plc_max_br_fw, tvb, offset+0, 2, ENC_BIG_ENDIAN);
665     proto_tree_add_item(tree, hf_alcap_plc_max_br_bw, tvb, offset+2, 2, ENC_BIG_ENDIAN);
666     proto_tree_add_item(tree, hf_alcap_plc_avg_br_fw, tvb, offset+4, 2, ENC_BIG_ENDIAN);
667     proto_tree_add_item(tree, hf_alcap_plc_avg_br_bw, tvb, offset+6, 2, ENC_BIG_ENDIAN);
668     proto_tree_add_item(tree, hf_alcap_plc_max_sdu_fw, tvb, offset+8, 1, ENC_BIG_ENDIAN);
669     proto_tree_add_item(tree, hf_alcap_plc_max_sdu_bw, tvb, offset+9, 1, ENC_BIG_ENDIAN);
670     proto_tree_add_item(tree, hf_alcap_plc_avg_sdu_fw, tvb, offset+10, 1, ENC_BIG_ENDIAN);
671     proto_tree_add_item(tree, hf_alcap_plc_avg_sdu_bw, tvb, offset+11, 1, ENC_BIG_ENDIAN);
672
673     return NULL;
674 }
675
676 static const gchar* dissect_fields_osaid(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
677     /*
678      * Q.2630.1 -> 7.3.6 Originating signalling association identifier
679      *
680      * 7.4.2 Signalling Association Identifier -> Originating Signalling Association
681      */
682     if (len != 4) {
683         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
684         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
685         return NULL;
686     }
687
688     msg_info->osaid = tvb_get_ntohl(tvb,offset);
689
690     proto_tree_add_item(tree, hf_alcap_osaid, tvb, offset, 4, ENC_BIG_ENDIAN);
691
692     return NULL;
693 }
694
695 static const gchar* dissect_fields_sugr(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
696     /*
697      * Q.2630.1 -> 7.3.7 Served user generated reference
698      *
699      * 7.4.10 Served User Generated Reference
700      */
701     if (len != 4) {
702         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
703         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
704         return NULL;
705     }
706
707     msg_info->sugr = tvb_get_ntohl(tvb,offset);
708
709     proto_tree_add_item(tree, hf_alcap_sugr, tvb, offset, 4, ENC_NA);
710
711     return NULL;
712 }
713
714 static const gchar* dissect_fields_suci(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
715     /*
716      * Q.2630.2 -> 7.3.22 Served user correlation ID
717      *
718      * 7.4.22 Served user correlation ID
719      */
720     if (len != 4) {
721         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
722         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
723         return NULL;
724     }
725
726     proto_tree_add_item(tree, hf_alcap_suci, tvb, offset, len, ENC_BIG_ENDIAN);
727
728     return NULL;
729 }
730
731 static const gchar* dissect_fields_ssia(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
732     /*
733      * Q.2630.2 -> 7.3.9 Service specific information (Audio)
734      *
735      * 7.4.5 Organizational Unique Identifier
736      */
737     if (len != 8) {
738         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
739         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
740         return NULL;
741     }
742
743     proto_tree_add_item(tree, hf_alcap_ssia_pr_type, tvb, offset+0,1,ENC_BIG_ENDIAN);
744
745     proto_tree_add_item(tree, hf_alcap_ssia_pr_id, tvb, offset+2,1,ENC_BIG_ENDIAN);
746
747     proto_tree_add_item(tree, hf_alcap_ssia_frm, tvb, offset+3,1,ENC_BIG_ENDIAN);
748     proto_tree_add_item(tree, hf_alcap_ssia_cmd, tvb, offset+3,1,ENC_BIG_ENDIAN);
749     proto_tree_add_item(tree, hf_alcap_ssia_mfr2, tvb, offset+3,1,ENC_BIG_ENDIAN);
750     proto_tree_add_item(tree, hf_alcap_ssia_mfr1, tvb, offset+3,1,ENC_BIG_ENDIAN);
751     proto_tree_add_item(tree, hf_alcap_ssia_dtmf, tvb, offset+3,1,ENC_BIG_ENDIAN);
752     proto_tree_add_item(tree, hf_alcap_ssia_cas, tvb, offset+3,1,ENC_BIG_ENDIAN);
753     proto_tree_add_item(tree, hf_alcap_ssia_fax, tvb, offset+3,1,ENC_BIG_ENDIAN);
754     proto_tree_add_item(tree, hf_alcap_ssia_pcm, tvb, offset+3,1,ENC_BIG_ENDIAN);
755
756     proto_tree_add_item(tree, hf_alcap_ssia_max_len, tvb, offset+4,2,ENC_BIG_ENDIAN);
757
758     proto_tree_add_item(tree, hf_alcap_ssia_oui, tvb, offset+5,3,ENC_NA);
759
760     return NULL;
761 }
762
763 static const gchar* dissect_fields_ssim(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
764     /*
765      * Q.2630.1 -> 7.3.10 Service specific information (Multirate)
766      *
767      * 7.4.7 Multirate Service
768      */
769     if (len != 3) {
770         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
771         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
772         return NULL;
773     }
774
775     proto_tree_add_item(tree,hf_alcap_ssim_frm,tvb,offset,1,ENC_BIG_ENDIAN);
776     proto_tree_add_item(tree,hf_alcap_ssim_mult,tvb,offset,1,ENC_BIG_ENDIAN);
777     proto_tree_add_item(tree,hf_alcap_ssim_max,tvb,offset+1,2,ENC_BIG_ENDIAN);
778
779     return NULL;
780 }
781
782 static const gchar* dissect_fields_ssisa(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
783     /*
784      * Q.2630.1 -> 7.3.11 Service specific information (SAR-assured)
785      *
786      * 7.4.8 Segmentation and Reassembly (Assured Data Transfer)
787      */
788     if (len != 14) {
789         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
790         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
791         return NULL;
792     }
793
794     proto_tree_add_item(tree,hf_alcap_ssisa_max_sssar_fw,tvb,offset,3,ENC_BIG_ENDIAN);
795     proto_tree_add_item(tree,hf_alcap_ssisa_max_sssar_bw,tvb,offset+3,3,ENC_BIG_ENDIAN);
796     proto_tree_add_item(tree,hf_alcap_ssisa_max_sscop_sdu_fw,tvb,offset+6,2,ENC_BIG_ENDIAN);
797     proto_tree_add_item(tree,hf_alcap_ssisa_max_sscop_sdu_bw,tvb,offset+8,2,ENC_BIG_ENDIAN);
798     proto_tree_add_item(tree,hf_alcap_ssisa_max_sscop_uu_fw,tvb,offset+10,2,ENC_BIG_ENDIAN);
799     proto_tree_add_item(tree,hf_alcap_ssisa_max_sscop_uu_bw,tvb,offset+12,2,ENC_BIG_ENDIAN);
800
801     proto_tree_add_text(tree,tvb,offset,14,"Not yet decoded: Q.2630.1 7.4.8");
802
803     return NULL;
804 }
805
806 static const gchar* dissect_fields_ssisu(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
807     /*
808      * Q.2630.1 -> 7.3.12 Service specific information (SAR-unassured)
809      *
810      * 7.4.9 Segmentation and Reassembly (Unassured Data Transfer)
811      */
812     if (len != 7) {
813         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
814         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
815         return NULL;
816     }
817
818     proto_tree_add_item(tree,hf_alcap_ssisu_max_sssar_fw,tvb,offset,3,ENC_BIG_ENDIAN);
819     proto_tree_add_item(tree,hf_alcap_ssisu_max_sssar_bw,tvb,offset+3,3,ENC_BIG_ENDIAN);
820     proto_tree_add_item(tree,hf_alcap_ssisu_ted,tvb,offset+6,1,ENC_BIG_ENDIAN);
821     proto_tree_add_text(tree,tvb,offset,7,"Not yet decoded: Q.2630.1 7.4.9");
822
823     return NULL;
824 }
825
826 static const gchar* dissect_fields_none(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
827     /*
828      * used for parameters that have no fields, just checks if len==0
829      *
830      * Q.2630.1 -> 7.3.13 Test connection indicator
831      * Q.2630.2 -> 7.3.20 Modify support for link characteristics
832      * Q.2630.2 -> 7.3.21 Modify support for service specific information
833      * Q.2630.3 -> 7.3.35 Transfer capability support
834      *
835      */
836     if (len != 0) {
837         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
838         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
839         return NULL;
840     }
841
842     return NULL;
843 }
844
845 static const gchar* dissect_fields_ssiae(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
846     /*
847      * Q.2630.2 -> 7.3.15 Service specific information (Audio Extended)
848      *
849      * 7.4.19 Audio extended service
850      * 7.4.5 Organizational unique identifier
851      */
852     if (len != 8) {
853         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
854         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
855         return NULL;
856     }
857
858     proto_tree_add_item(tree, hf_alcap_ssiae_pr_type, tvb, offset,1,ENC_BIG_ENDIAN);
859     proto_tree_add_item(tree, hf_alcap_ssiae_lb, tvb, offset,1,ENC_BIG_ENDIAN);
860     proto_tree_add_item(tree, hf_alcap_ssiae_rc, tvb, offset,1,ENC_BIG_ENDIAN);
861     proto_tree_add_item(tree, hf_alcap_ssiae_syn, tvb, offset,1,ENC_BIG_ENDIAN);
862
863     proto_tree_add_item(tree, hf_alcap_ssiae_pr_id, tvb, offset+1,1,ENC_BIG_ENDIAN);
864
865     proto_tree_add_item(tree, hf_alcap_ssiae_frm, tvb, offset+3,1,ENC_BIG_ENDIAN);
866     proto_tree_add_item(tree, hf_alcap_ssiae_cmd, tvb, offset+3,1,ENC_BIG_ENDIAN);
867     proto_tree_add_item(tree, hf_alcap_ssiae_mfr2, tvb, offset+3,1,ENC_BIG_ENDIAN);
868     proto_tree_add_item(tree, hf_alcap_ssiae_mfr1, tvb, offset+3,1,ENC_BIG_ENDIAN);
869     proto_tree_add_item(tree, hf_alcap_ssiae_dtmf, tvb, offset+3,1,ENC_BIG_ENDIAN);
870     proto_tree_add_item(tree, hf_alcap_ssiae_cas, tvb, offset+3,1,ENC_BIG_ENDIAN);
871     proto_tree_add_item(tree, hf_alcap_ssiae_fax, tvb, offset+3,1,ENC_BIG_ENDIAN);
872     proto_tree_add_item(tree, hf_alcap_ssiae_pcm, tvb, offset+3,1,ENC_BIG_ENDIAN);
873
874     proto_tree_add_item(tree, hf_alcap_ssiae_max_len, tvb, offset+4,2,ENC_BIG_ENDIAN);
875
876     proto_tree_add_item(tree, hf_alcap_ssiae_oui, tvb, offset+5,3,ENC_NA);
877
878     return NULL;
879 }
880
881 static const gchar* dissect_fields_pssiae(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
882     /*
883      * Q.2630.2 -> 7.3.17 Preferred service specific information (Audio Extended)
884      *
885      * 7.4.19 Audio extended service
886      * 7.4.5 Organizational unique identifier
887      */
888     if (len != 8) {
889         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
890         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
891         return NULL;
892     }
893
894     proto_tree_add_item(tree, hf_alcap_pssiae_pr_type, tvb, offset,1,ENC_BIG_ENDIAN);
895     proto_tree_add_item(tree, hf_alcap_pssiae_lb, tvb, offset,1,ENC_BIG_ENDIAN);
896     proto_tree_add_item(tree, hf_alcap_pssiae_rc, tvb, offset,1,ENC_BIG_ENDIAN);
897     proto_tree_add_item(tree, hf_alcap_pssiae_syn, tvb, offset,1,ENC_BIG_ENDIAN);
898
899     proto_tree_add_item(tree, hf_alcap_pssiae_pr_id, tvb, offset+1,1,ENC_BIG_ENDIAN);
900
901     proto_tree_add_item(tree, hf_alcap_pssiae_frm, tvb, offset+3,1,ENC_BIG_ENDIAN);
902     proto_tree_add_item(tree, hf_alcap_pssiae_cmd, tvb, offset+3,1,ENC_BIG_ENDIAN);
903     proto_tree_add_item(tree, hf_alcap_pssiae_mfr2, tvb, offset+3,1,ENC_BIG_ENDIAN);
904     proto_tree_add_item(tree, hf_alcap_pssiae_mfr1, tvb, offset+3,1,ENC_BIG_ENDIAN);
905     proto_tree_add_item(tree, hf_alcap_pssiae_dtmf, tvb, offset+3,1,ENC_BIG_ENDIAN);
906     proto_tree_add_item(tree, hf_alcap_pssiae_cas, tvb, offset+3,1,ENC_BIG_ENDIAN);
907     proto_tree_add_item(tree, hf_alcap_pssiae_fax, tvb, offset+3,1,ENC_BIG_ENDIAN);
908     proto_tree_add_item(tree, hf_alcap_pssiae_pcm, tvb, offset+3,1,ENC_BIG_ENDIAN);
909
910     proto_tree_add_item(tree, hf_alcap_pssiae_max_len, tvb, offset+4,2,ENC_BIG_ENDIAN);
911
912     proto_tree_add_item(tree, hf_alcap_pssiae_oui, tvb, offset+5,3,ENC_NA);
913
914     return NULL;
915 }
916
917 static const gchar* dissect_fields_ssime(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
918     /*
919      * Q.2630.2 -> 7.3.16 Service specific information (Multirate Extended)
920      *
921      * 7.4.20 Multirate extended service
922      */
923     if (len != 3) {
924         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
925         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
926         return NULL;
927     }
928
929     proto_tree_add_item(tree,hf_alcap_ssime_frm,tvb,offset,1,ENC_BIG_ENDIAN);
930     proto_tree_add_item(tree,hf_alcap_ssime_lb,tvb,offset,1,ENC_BIG_ENDIAN);
931     proto_tree_add_item(tree,hf_alcap_ssime_mult,tvb,offset,1,ENC_BIG_ENDIAN);
932     proto_tree_add_item(tree,hf_alcap_ssime_max,tvb,offset+1,2,ENC_BIG_ENDIAN);
933
934     return NULL;
935 }
936
937 static const gchar* dissect_fields_pssime(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
938     /*
939      * Q.2630.2 -> 7.3.18 Preferred service specific information (Multirate Extended)
940      *
941      * 7.4.20 Multirate extended service
942      */
943     if (len != 3) {
944         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
945         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
946         return NULL;
947     }
948
949     proto_tree_add_item(tree,hf_alcap_pssime_frm,tvb,offset,1,ENC_BIG_ENDIAN);
950     proto_tree_add_item(tree,hf_alcap_pssime_lb,tvb,offset,1,ENC_BIG_ENDIAN);
951     proto_tree_add_item(tree,hf_alcap_pssime_mult,tvb,offset,1,ENC_BIG_ENDIAN);
952     proto_tree_add_item(tree,hf_alcap_pssime_max,tvb,offset+1,2,ENC_BIG_ENDIAN);
953
954     return NULL;
955 }
956
957 static const gchar* dissect_fields_acc(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
958     /*
959      * Q.2630.3 -> 7.3.25 Automatic congestion control
960      *
961      * 7.4.23 AAL type 2 Node Automatic Congestion Level
962      */
963     if (len != 1) {
964         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
965         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
966         return NULL;
967     }
968
969     proto_tree_add_item(tree,hf_alcap_acc_level,tvb,offset,len,ENC_BIG_ENDIAN);
970     return NULL;
971 }
972
973
974 static const gchar* dissect_fields_cp(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
975     /*
976      * Q.2630.3 -> 7.3.26 Connection Priority
977      *
978      * 7.4.24 Priority
979      */
980     if (len != 1) {
981         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
982         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
983         return NULL;
984     }
985
986     proto_tree_add_item(tree,hf_alcap_cp,tvb,offset,len,ENC_BIG_ENDIAN);
987     return NULL;
988 }
989
990 static const gchar* dissect_fields_pt(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
991     /*
992      * Q.2630.2 -> 7.3.14 Path Type
993      *
994      * 7.4.21 AAL Type 2 Path QoS Codepoint
995      */
996     if (len != 1) {
997         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
998         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
999         return NULL;
1000     }
1001
1002     proto_tree_add_item(tree,hf_alcap_pt,tvb,offset,len,ENC_BIG_ENDIAN);
1003     return NULL;
1004 }
1005
1006
1007 static const gchar* dissect_fields_hc(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
1008     /*
1009      * Q.2630.3 -> 7.3.27 Hop counter
1010      *
1011      * 7.4.25 AAL type 2 Hop Counter
1012      */
1013     if (len != 1) {
1014         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
1015         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
1016         return NULL;
1017     }
1018
1019     proto_tree_add_item(tree,hf_alcap_hc,tvb,offset,len,ENC_BIG_ENDIAN);
1020     return NULL;
1021 }
1022
1023
1024 static const gchar* dissect_fields_fbw(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
1025     /*
1026      * Q.2630.3 -> 7.3.32 Fixed bandwidth transfer capability
1027      *
1028      * 7.4.26 CPS Bit rate -> Peak CPS bit rate
1029      * 7.4.27 CPS Token Bucket Size -> CPS token bucket size associated with Peak CPS bit rate
1030      * 7.4.28 Maximum allowed CPS packet size
1031      */
1032     if (len != 12) {
1033         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
1034         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
1035         return NULL;
1036     }
1037
1038     proto_tree_add_item(tree,hf_alcap_fbw_br_fw,tvb,offset,3,ENC_BIG_ENDIAN);
1039     proto_tree_add_item(tree,hf_alcap_fbw_br_bw,tvb,offset+3,3,ENC_BIG_ENDIAN);
1040     proto_tree_add_item(tree,hf_alcap_fbw_bucket_fw,tvb,offset+6,2,ENC_BIG_ENDIAN);
1041     proto_tree_add_item(tree,hf_alcap_fbw_bucket_bw,tvb,offset+8,2,ENC_BIG_ENDIAN);
1042     proto_tree_add_item(tree,hf_alcap_fbw_size_fw,tvb,offset+10,1,ENC_BIG_ENDIAN);
1043     proto_tree_add_item(tree,hf_alcap_fbw_size_bw,tvb,offset+11,1,ENC_BIG_ENDIAN);
1044
1045     return NULL;
1046 }
1047
1048 static const gchar* dissect_fields_pfbw(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
1049     /*
1050      * Q.2630.3 -> 7.3.29 Preferred fixed bandwidth transfer capability
1051      *
1052      * 7.4.26 CPS Bit rate -> Peak CPS bit rate
1053      * 7.4.27 CPS Token Bucket Size -> CPS token bucket size associated with Peak CPS bit rate
1054      * 7.4.28 Maximum allowed CPS packet size
1055      */
1056     if (len != 12) {
1057         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
1058         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
1059         return NULL;
1060     }
1061
1062     proto_tree_add_item(tree,hf_alcap_pfbw_br_fw,tvb,offset,3,ENC_BIG_ENDIAN);
1063     proto_tree_add_item(tree,hf_alcap_pfbw_br_bw,tvb,offset+3,3,ENC_BIG_ENDIAN);
1064     proto_tree_add_item(tree,hf_alcap_pfbw_bucket_fw,tvb,offset+6,2,ENC_BIG_ENDIAN);
1065     proto_tree_add_item(tree,hf_alcap_pfbw_bucket_bw,tvb,offset+8,2,ENC_BIG_ENDIAN);
1066     proto_tree_add_item(tree,hf_alcap_pfbw_size_fw,tvb,offset+10,1,ENC_BIG_ENDIAN);
1067     proto_tree_add_item(tree,hf_alcap_pfbw_size_bw,tvb,offset+11,1,ENC_BIG_ENDIAN);
1068
1069     return NULL;
1070 }
1071
1072 static const gchar* dissect_fields_vbws(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
1073     /*
1074      * Q.2630.3 -> 7.3.33 Variable bandwidth stringent transfer capability
1075      *
1076      * 7.4.26 CPS Bit rate -> Peak CPS bit rate
1077      * 7.4.27 CPS Token Bucket Size -> CPS token bucket size associated with Peak CPS bit rate
1078      * 7.4.28 Maximum allowed CPS packet size
1079      * 7.4.29 Source Traffic Type
1080      */
1081     if (len != 13) {
1082         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
1083         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
1084         return NULL;
1085     }
1086
1087     proto_tree_add_item(tree,hf_alcap_vbws_br_fw,tvb,offset,3,ENC_BIG_ENDIAN);
1088     proto_tree_add_item(tree,hf_alcap_vbws_br_bw,tvb,offset+3,3,ENC_BIG_ENDIAN);
1089     proto_tree_add_item(tree,hf_alcap_vbws_bucket_fw,tvb,offset+6,2,ENC_BIG_ENDIAN);
1090     proto_tree_add_item(tree,hf_alcap_vbws_bucket_bw,tvb,offset+8,2,ENC_BIG_ENDIAN);
1091     proto_tree_add_item(tree,hf_alcap_vbws_size_fw,tvb,offset+10,1,ENC_BIG_ENDIAN);
1092     proto_tree_add_item(tree,hf_alcap_vbws_size_bw,tvb,offset+11,1,ENC_BIG_ENDIAN);
1093     proto_tree_add_item(tree,hf_alcap_vbws_size_bw,tvb,offset+11,1,ENC_BIG_ENDIAN);
1094     proto_tree_add_item(tree,hf_alcap_vbws_stt,tvb,offset+12,1,ENC_BIG_ENDIAN);
1095
1096     return NULL;
1097 }
1098
1099 static const gchar* dissect_fields_pvbws(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
1100     /*
1101      * Q.2630.3 -> 7.3.30 Preferred variable bandwidth stringent transfer capability
1102      *
1103      * 7.4.26 CPS Bit rate -> Peak CPS bit rate
1104      * 7.4.27 CPS Token Bucket Size -> CPS token bucket size associated with Peak CPS bit rate
1105      * 7.4.28 Maximum allowed CPS packet size
1106      * 7.4.29 Source Traffic Type
1107      */
1108     if (len != 13) {
1109         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
1110         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
1111         return NULL;
1112     }
1113
1114     proto_tree_add_item(tree,hf_alcap_pvbws_br_fw,tvb,offset,3,ENC_BIG_ENDIAN);
1115     proto_tree_add_item(tree,hf_alcap_pvbws_br_bw,tvb,offset+3,3,ENC_BIG_ENDIAN);
1116     proto_tree_add_item(tree,hf_alcap_pvbws_bucket_fw,tvb,offset+6,2,ENC_BIG_ENDIAN);
1117     proto_tree_add_item(tree,hf_alcap_pvbws_bucket_bw,tvb,offset+8,2,ENC_BIG_ENDIAN);
1118     proto_tree_add_item(tree,hf_alcap_pvbws_size_fw,tvb,offset+10,1,ENC_BIG_ENDIAN);
1119     proto_tree_add_item(tree,hf_alcap_pvbws_size_bw,tvb,offset+11,1,ENC_BIG_ENDIAN);
1120     proto_tree_add_item(tree,hf_alcap_pvbws_size_bw,tvb,offset+11,1,ENC_BIG_ENDIAN);
1121     proto_tree_add_item(tree,hf_alcap_pvbws_stt,tvb,offset+12,1,ENC_BIG_ENDIAN);
1122
1123     return NULL;
1124 }
1125
1126
1127 static const gchar* dissect_fields_pvbwt(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
1128     /*
1129      * Q.2630.3 -> 7.3.31 Preferred variable bandwidth tolerant transfer capability
1130      *
1131      * 7.4.26 CPS Bit rate -> Peak CPS bit rate
1132      * 7.4.27 CPS Token Bucket Size -> CPS token bucket size associated with Peak CPS bit rate
1133      * 7.4.26 CPS Bit rate -> Sustainable CPS bit rate
1134      * 7.4.27 CPS Token Bucket Size -> CPS token bucket size associated with Sustainable CPS bit rate
1135      * 7.4.28 Maximum allowed CPS packet size
1136      */
1137
1138     if (len != 22) {
1139         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
1140         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
1141         return NULL;
1142     }
1143
1144     proto_tree_add_item(tree,hf_alcap_pvbwt_peak_br_fw,tvb,offset,3,ENC_BIG_ENDIAN);
1145     proto_tree_add_item(tree,hf_alcap_pvbwt_peak_br_bw,tvb,offset+3,3,ENC_BIG_ENDIAN);
1146
1147     proto_tree_add_item(tree,hf_alcap_pvbwt_peak_bucket_fw,tvb,offset+6,2,ENC_BIG_ENDIAN);
1148     proto_tree_add_item(tree,hf_alcap_pvbwt_peak_bucket_bw,tvb,offset+8,2,ENC_BIG_ENDIAN);
1149
1150     proto_tree_add_item(tree,hf_alcap_pvbwt_sust_br_fw,tvb,offset+10,3,ENC_BIG_ENDIAN);
1151     proto_tree_add_item(tree,hf_alcap_pvbwt_sust_br_bw,tvb,offset+13,3,ENC_BIG_ENDIAN);
1152
1153     proto_tree_add_item(tree,hf_alcap_pvbwt_sust_bucket_fw,tvb,offset+16,2,ENC_BIG_ENDIAN);
1154     proto_tree_add_item(tree,hf_alcap_pvbwt_sust_bucket_bw,tvb,offset+18,2,ENC_BIG_ENDIAN);
1155
1156     proto_tree_add_item(tree,hf_alcap_pvbwt_size_fw,tvb,offset+20,1,ENC_BIG_ENDIAN);
1157     proto_tree_add_item(tree,hf_alcap_pvbwt_size_bw,tvb,offset+21,1,ENC_BIG_ENDIAN);
1158
1159     return NULL;
1160 }
1161
1162 static const gchar* dissect_fields_vbwt(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
1163     /*
1164      * Q.2630.3 -> 7.3.34 Variable bandwidth tolerant transfer capability
1165      *
1166      * 7.4.26 CPS Bit rate -> Peak CPS bit rate
1167      * 7.4.27 CPS Token Bucket Size -> CPS token bucket size associated with Peak CPS bit rate
1168      * 7.4.26 CPS Bit rate -> Sustainable CPS bit rate
1169      * 7.4.27 CPS Token Bucket Size -> CPS token bucket size associated with Sustainable CPS bit rate
1170      * 7.4.28 Maximum allowed CPS packet size
1171      */
1172     if (len != 22) {
1173         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
1174         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
1175         return NULL;
1176     }
1177
1178     proto_tree_add_item(tree,hf_alcap_vbwt_peak_br_fw,tvb,offset,3,ENC_BIG_ENDIAN);
1179     proto_tree_add_item(tree,hf_alcap_vbwt_peak_br_bw,tvb,offset+3,3,ENC_BIG_ENDIAN);
1180
1181     proto_tree_add_item(tree,hf_alcap_vbwt_peak_bucket_fw,tvb,offset+6,2,ENC_BIG_ENDIAN);
1182     proto_tree_add_item(tree,hf_alcap_vbwt_peak_bucket_bw,tvb,offset+8,2,ENC_BIG_ENDIAN);
1183
1184     proto_tree_add_item(tree,hf_alcap_vbwt_sust_br_fw,tvb,offset+10,3,ENC_BIG_ENDIAN);
1185     proto_tree_add_item(tree,hf_alcap_vbwt_sust_br_bw,tvb,offset+13,3,ENC_BIG_ENDIAN);
1186
1187     proto_tree_add_item(tree,hf_alcap_vbwt_sust_bucket_fw,tvb,offset+16,2,ENC_BIG_ENDIAN);
1188     proto_tree_add_item(tree,hf_alcap_vbwt_sust_bucket_bw,tvb,offset+18,2,ENC_BIG_ENDIAN);
1189
1190     proto_tree_add_item(tree,hf_alcap_vbwt_size_fw,tvb,offset+20,1,ENC_BIG_ENDIAN);
1191     proto_tree_add_item(tree,hf_alcap_vbwt_size_bw,tvb,offset+21,1,ENC_BIG_ENDIAN);
1192
1193     return NULL;
1194 }
1195
1196 static const gchar* dissect_fields_sut(packet_info* pinfo _U_, tvbuff_t *tvb, proto_tree *tree, int offset, int len, alcap_message_info_t* msg_info _U_) {
1197     /*
1198      * Q.2630.1 -> 7.3.8 Served user transport
1199      *
1200      * 7.4.18 Served User Transport
1201      */
1202     guint sut_len;
1203
1204     if (len < 2) {
1205         proto_item* bad_length = proto_tree_add_text(tree, tvb, offset, len,"[Wrong length for parameter fields]");
1206         proto_item_set_expert_flags(bad_length, PI_MALFORMED, PI_WARN);
1207         return NULL;
1208     }
1209
1210     sut_len = tvb_get_guint8(tvb,offset);
1211
1212     proto_tree_add_item(tree, hf_alcap_sut_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1213     proto_tree_add_item(tree, hf_alcap_sut, tvb, offset, sut_len, ENC_NA);
1214
1215     return NULL;
1216 }
1217
1218 typedef const gchar* (*alcap_parameter_dissector_t) (packet_info* pinfo, tvbuff_t*, proto_tree*, int, int, alcap_message_info_t*);
1219
1220 typedef struct _alcap_param_info_t {
1221     gint ett;
1222     const gchar* name;
1223     alcap_parameter_dissector_t dissect_fields;
1224     gboolean run_wo_tree;
1225 } alcap_param_info_t;
1226
1227 static alcap_param_info_t param_infos[]  = {
1228     {-1, "Unknown", dissect_fields_unknown , FALSE},
1229     {-1, "CAU", dissect_fields_cau, TRUE},
1230     {-1, "CEID", dissect_fields_ceid, TRUE},
1231     {-1, "DESEA", dissect_fields_desea, FALSE},
1232     {-1, "DNSEA", dissect_fields_dnsea, TRUE},
1233     {-1, "ALC", dissect_fields_alc, FALSE},
1234     {-1, "OSAID", dissect_fields_osaid, TRUE},
1235     {-1, "SUGR", dissect_fields_sugr, TRUE},
1236     {-1, "SUT", dissect_fields_sut, FALSE},
1237     {-1, "SSIA", dissect_fields_ssia, FALSE},
1238     {-1, "SSIM", dissect_fields_ssim, FALSE},
1239     {-1, "SSISA", dissect_fields_ssisa, FALSE},
1240     {-1, "SSISU", dissect_fields_ssisu, FALSE},
1241     {-1, "TCI", dissect_fields_none, FALSE},
1242     {-1, "MSLC", dissect_fields_none, FALSE},
1243     {-1, "MSSSI", dissect_fields_none, FALSE},
1244     {-1, "PT", dissect_fields_pt, FALSE},
1245     {-1, "PLC", dissect_fields_plc, FALSE},
1246     {-1, "PSSIAE", dissect_fields_pssiae, FALSE},
1247     {-1, "PSSIME", dissect_fields_pssime, FALSE},
1248     {-1, "SUCI", dissect_fields_suci, FALSE},
1249     {-1, "ONSEA", dissect_fields_onsea, TRUE},
1250     {-1, "SSIAE", dissect_fields_ssiae, FALSE},
1251     {-1, "SSIME", dissect_fields_ssime, FALSE},
1252     {-1, "ACC", dissect_fields_acc, FALSE},
1253     {-1, "CP", dissect_fields_cp, FALSE},
1254     {-1, "HC", dissect_fields_hc, FALSE},
1255     {-1, "OESEA", dissect_fields_oesea, FALSE},
1256     {-1, "PFBW", dissect_fields_pfbw, FALSE},
1257     {-1, "PVBWS", dissect_fields_pvbws, FALSE},
1258     {-1, "PVBWT", dissect_fields_pvbwt, FALSE},
1259     {-1, "TTC", dissect_fields_none, FALSE},
1260     {-1, "FBW", dissect_fields_fbw, FALSE},
1261     {-1, "VBWS", dissect_fields_vbws, FALSE},
1262     {-1, "VBWT", dissect_fields_vbwt, FALSE},
1263     {-1, "TCS", dissect_fields_none, FALSE}
1264 };
1265
1266 #define GET_PARAM_INFO(id) ( array_length(param_infos) <= id ? &(param_infos[0]) : &(param_infos[id]) )
1267
1268 typedef struct _alcap_msg_type_info_t {
1269     const gchar* abbr;
1270     int severity;
1271 } alcap_msg_type_info_t;
1272
1273 static const alcap_msg_type_info_t msg_types[] = {
1274     { "Unknown Message ", PI_ERROR },
1275     { "BLC ", PI_NOTE },
1276     { "BLO ", PI_NOTE },
1277     { "CFN ", PI_WARN },
1278     { "ECF ", PI_CHAT },
1279     { "ERQ ", PI_CHAT },
1280     { "RLC ", PI_CHAT },
1281     { "REL ", PI_CHAT },
1282     { "RSC ", PI_NOTE },
1283     { "RES ", PI_NOTE },
1284     { "UBC ", PI_NOTE },
1285     { "UBL ", PI_NOTE },
1286     { "MOA ", PI_CHAT },
1287     { "MOR ", PI_CHAT },
1288     { "MOD ", PI_CHAT },
1289 };
1290
1291 static void alcap_leg_tree(proto_tree* tree, tvbuff_t* tvb, const alcap_leg_info_t* leg) {
1292     proto_item* pi = proto_tree_add_text(tree,tvb,0,0,"[ALCAP Leg Info]");
1293
1294     tree = proto_item_add_subtree(pi,ett_leg);
1295
1296     if (leg->dsaid) {
1297         pi = proto_tree_add_uint(tree,hf_alcap_leg_dsaid,tvb,0,0,leg->dsaid);
1298         PROTO_ITEM_SET_GENERATED(pi);
1299     }
1300
1301     if (leg->osaid) {
1302         pi = proto_tree_add_uint(tree,hf_alcap_leg_osaid,tvb,0,0,leg->osaid);
1303         PROTO_ITEM_SET_GENERATED(pi);
1304     }
1305
1306     if (leg->pathid) {
1307         pi = proto_tree_add_uint(tree,hf_alcap_leg_pathid,tvb,0,0,leg->pathid);
1308         PROTO_ITEM_SET_GENERATED(pi);
1309     }
1310
1311     if (leg->cid) {
1312         pi = proto_tree_add_uint(tree,hf_alcap_leg_cid,tvb,0,0,leg->cid);
1313         PROTO_ITEM_SET_GENERATED(pi);
1314     }
1315
1316     if (leg->sugr) {
1317         pi = proto_tree_add_uint(tree,hf_alcap_leg_sugr,tvb,0,0,leg->sugr);
1318         PROTO_ITEM_SET_GENERATED(pi);
1319     }
1320
1321     if (leg->orig_nsap) {
1322         pi = proto_tree_add_string(tree,hf_alcap_leg_onsea,tvb,0,0,leg->orig_nsap);
1323         PROTO_ITEM_SET_GENERATED(pi);
1324     }
1325
1326     if (leg->dest_nsap) {
1327         pi = proto_tree_add_string(tree,hf_alcap_leg_dnsea,tvb,0,0,leg->dest_nsap);
1328         PROTO_ITEM_SET_GENERATED(pi);
1329     }
1330
1331     if(leg->release_cause) {
1332         pi = proto_tree_add_uint(tree,hf_alcap_leg_release_cause,tvb,0,0,leg->release_cause);
1333         PROTO_ITEM_SET_GENERATED(pi);
1334         if (leg->release_cause && leg->release_cause != 31)
1335             proto_item_set_expert_flags(pi, PI_RESPONSE_CODE, PI_WARN);
1336     }
1337
1338     if(leg->msgs) {
1339         alcap_msg_data_t* msg = leg->msgs;
1340         proto_item* pi_local = proto_tree_add_text(tree,tvb,0,0,"[Messages in this leg]");
1341         proto_tree* tree_local = proto_item_add_subtree(pi_local,ett_leg);
1342
1343
1344         do {
1345             pi_local = proto_tree_add_uint(tree_local,hf_alcap_leg_frame,tvb,0,0,msg->framenum);
1346             proto_item_set_text(pi_local,"%s in frame %u", val_to_str(msg->msg_type,msg_type_strings,"Unknown message"),msg->framenum);
1347             PROTO_ITEM_SET_GENERATED(pi_local);
1348         } while (( msg = msg->next));
1349
1350     }
1351
1352 }
1353
1354
1355 extern void alcap_tree_from_bearer_key(proto_tree* tree, tvbuff_t* tvb, const  gchar* key) {
1356     alcap_leg_info_t* leg = se_tree_lookup_string(legs_by_bearer,key,0);
1357
1358     if (leg) {
1359         alcap_leg_tree(tree,tvb,leg);
1360     }
1361 }
1362
1363 #define GET_MSG_TYPE(id) ( array_length(msg_types) <= id ? &(msg_types[0]) : &(msg_types[id]) )
1364
1365 static void dissect_alcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1366     proto_tree *alcap_tree = NULL;
1367     alcap_message_info_t* msg_info = ep_alloc0(sizeof(alcap_message_info_t));
1368     int len = tvb_length(tvb);
1369     int offset;
1370     proto_item* pi;
1371     proto_tree* compat_tree;
1372     const alcap_msg_type_info_t* msg_type;
1373
1374     col_set_str(pinfo->cinfo, COL_PROTOCOL, alcap_proto_name_short);
1375
1376     if (tree) {
1377         proto_item *alcap_item = proto_tree_add_item(tree, proto_alcap, tvb, 0, -1, ENC_NA);
1378         alcap_tree = proto_item_add_subtree(alcap_item, ett_alcap);
1379     }
1380
1381     proto_tree_add_item(alcap_tree,hf_alcap_dsaid,tvb,0,4,ENC_BIG_ENDIAN);
1382     pi = proto_tree_add_item(alcap_tree,hf_alcap_msg_id,tvb,4,1,ENC_BIG_ENDIAN);
1383
1384     msg_info->dsaid = tvb_get_ntohl(tvb, 0);
1385     msg_info->msg_type = tvb_get_guint8(tvb, 4);
1386
1387     msg_type = GET_MSG_TYPE(msg_info->msg_type);
1388
1389     expert_add_info_format(pinfo, pi, PI_RESPONSE_CODE, msg_type->severity, " ");
1390
1391     col_set_str(pinfo->cinfo, COL_INFO, msg_type->abbr);
1392
1393     pi = proto_tree_add_item(alcap_tree,hf_alcap_compat,tvb,5,1,ENC_NA);
1394     compat_tree = proto_item_add_subtree(pi,ett_compat);
1395     proto_tree_add_item(compat_tree,hf_alcap_compat_pass_on_sni,tvb,5,1,ENC_BIG_ENDIAN);
1396     proto_tree_add_item(compat_tree,hf_alcap_compat_pass_on_ii,tvb,5,1,ENC_BIG_ENDIAN);
1397     proto_tree_add_item(compat_tree,hf_alcap_compat_general_sni,tvb,5,1,ENC_BIG_ENDIAN);
1398     proto_tree_add_item(compat_tree,hf_alcap_compat_general_ii,tvb,5,1,ENC_BIG_ENDIAN);
1399
1400     len -= ALCAP_MSG_HEADER_LEN;
1401     offset = ALCAP_MSG_HEADER_LEN;
1402
1403     while(len > 0) {
1404         guint param_id = tvb_get_guint8(tvb,offset);
1405         guint param_len = tvb_get_guint8(tvb,offset+2);
1406         const alcap_param_info_t* param_info = GET_PARAM_INFO(param_id);
1407         proto_tree* param_tree;
1408         const gchar* colinfo_str = NULL;
1409
1410         pi = proto_tree_add_item(alcap_tree,hf_alcap_param_id,tvb,offset,1,ENC_BIG_ENDIAN);
1411         param_tree = proto_item_add_subtree(pi,param_info->ett);
1412
1413         pi = proto_tree_add_item(param_tree,hf_alcap_compat,tvb,offset+1,1,ENC_NA);
1414         compat_tree = proto_item_add_subtree(pi,ett_compat);
1415         proto_tree_add_item(compat_tree,hf_alcap_compat_pass_on_sni,tvb,offset+1,1,ENC_BIG_ENDIAN);
1416         proto_tree_add_item(compat_tree,hf_alcap_compat_pass_on_ii,tvb,offset+1,1,ENC_BIG_ENDIAN);
1417         proto_tree_add_item(compat_tree,hf_alcap_compat_general_sni,tvb,offset+1,1,ENC_BIG_ENDIAN);
1418         proto_tree_add_item(compat_tree,hf_alcap_compat_general_ii,tvb,offset+1,1,ENC_BIG_ENDIAN);
1419
1420         proto_tree_add_item(param_tree,hf_alcap_param_len,tvb,offset+2,1,ENC_BIG_ENDIAN);
1421
1422         if ( alcap_tree || param_info->run_wo_tree )
1423             colinfo_str = param_info->dissect_fields(pinfo,tvb,param_tree,offset+3,param_len,msg_info);
1424
1425         col_append_fstr(pinfo->cinfo, COL_INFO, " %s",colinfo_str);
1426
1427         len -= 3 + param_len;
1428         offset += 3 + param_len;
1429     }
1430
1431     if (keep_persistent_info) {
1432         alcap_leg_info_t* leg = NULL;
1433         switch (msg_info->msg_type) {
1434             case 5: /* ERQ */
1435                 if( ! ( leg = se_tree_lookup32(legs_by_osaid,msg_info->osaid) )) {
1436                     leg = se_alloc(sizeof(alcap_leg_info_t));
1437
1438                     leg->dsaid = 0;
1439                     leg->osaid = msg_info->osaid;
1440                     leg->pathid = msg_info->pathid;
1441                     leg->cid = msg_info->cid;
1442                     leg->sugr = msg_info->sugr;
1443                     leg->orig_nsap = NULL;
1444                     leg->dest_nsap = NULL;
1445
1446                     if (msg_info->orig_nsap) {
1447                         gchar* key = se_strdup_printf("%s:%.8X",msg_info->orig_nsap,leg->sugr);
1448                         ascii_strdown_inplace(key);
1449
1450                         leg->orig_nsap = se_strdup(msg_info->orig_nsap);
1451
1452                         if (!se_tree_lookup_string(legs_by_bearer,key,0)) {
1453                             se_tree_insert_string(legs_by_bearer,key,leg,0);
1454                         }
1455                     }
1456
1457                     if (msg_info->dest_nsap) {
1458                         gchar* key = se_strdup_printf("%s:%.8X",msg_info->dest_nsap,leg->sugr);
1459                         ascii_strdown_inplace(key);
1460
1461                         leg->dest_nsap = se_strdup(msg_info->dest_nsap);
1462
1463                         if (!se_tree_lookup_string(legs_by_bearer,key,0)) {
1464                             se_tree_insert_string(legs_by_bearer,key,leg,0);
1465                         }
1466                     }
1467
1468                     leg->msgs = NULL;
1469                     leg->release_cause = 0;
1470
1471                     se_tree_insert32(legs_by_osaid,leg->osaid,leg);
1472                 }
1473                 break;
1474             case 4: /* ECF */
1475                 if(( leg = se_tree_lookup32(legs_by_osaid,msg_info->dsaid) )) {
1476                     leg->dsaid = msg_info->osaid;
1477                     se_tree_insert32(legs_by_dsaid,leg->dsaid,leg);
1478                 }
1479                 break;
1480             case 6: /* RLC */
1481             case 12:  /* MOA */
1482             case 13: /* MOR */
1483             case 14: /* MOD */
1484                 if( ( leg = se_tree_lookup32(legs_by_osaid,msg_info->dsaid) )
1485                     || ( leg = se_tree_lookup32(legs_by_dsaid,msg_info->dsaid) ) ) {
1486
1487                     if(msg_info->release_cause)
1488                         leg->release_cause =  msg_info->release_cause;
1489
1490                 }
1491                 break;
1492             case 7: /* REL */
1493                 leg = se_tree_lookup32(legs_by_osaid,msg_info->dsaid);
1494
1495                 if(leg) {
1496                     leg->release_cause =  msg_info->release_cause;
1497                 } else if (( leg = se_tree_lookup32(legs_by_dsaid,msg_info->dsaid) )) {
1498                     leg->release_cause =  msg_info->release_cause;
1499                 }
1500                     break;
1501             default:
1502                 break;
1503         }
1504
1505         if (leg != NULL && ( (! leg->msgs) || leg->msgs->last->framenum < pinfo->fd->num ) ) {
1506             alcap_msg_data_t* msg = se_alloc(sizeof(alcap_msg_data_t));
1507             msg->msg_type = msg_info->msg_type;
1508             msg->framenum = pinfo->fd->num;
1509             msg->next = NULL;
1510             msg->last = NULL;
1511
1512             if (leg->msgs) {
1513                 leg->msgs->last->next = msg;
1514             } else {
1515                 leg->msgs = msg;
1516             }
1517
1518             leg->msgs->last = msg;
1519
1520         }
1521
1522         if (tree && leg) alcap_leg_tree(alcap_tree,tvb,leg);
1523     }
1524 }
1525
1526 void
1527 proto_register_alcap(void)
1528 {
1529     module_t *alcap_module;
1530
1531     static hf_register_info hf[] = {
1532     { &hf_alcap_dsaid, { "DSAID", "alcap.dsaid", FT_UINT32, BASE_HEX, NULL, 0, "Destination Service Association ID", HFILL }},
1533     { &hf_alcap_msg_id, { "Message Type", "alcap.msg_type", FT_UINT8, BASE_DEC, VALS(msg_type_strings), 0, NULL, HFILL }},
1534     { &hf_alcap_compat, { "Message Compatibility", "alcap.compat", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1535     { &hf_alcap_compat_pass_on_sni, { "Pass-On SNI", "alcap.compat.pass.sni", FT_UINT8, BASE_DEC, VALS(send_notification), 0x40, "Send Notificaation Indicator", HFILL }},
1536     { &hf_alcap_compat_pass_on_ii, { "Pass-On II", "alcap.compat.pass.ii", FT_UINT8, BASE_DEC, VALS(instruction_indicator), 0x30, "Instruction Indicator", HFILL }},
1537     { &hf_alcap_compat_general_sni, { "General SNI", "alcap.compat.general.sni", FT_UINT8, BASE_DEC, VALS(send_notification), 0x04, "Send Notificaation Indicator", HFILL }},
1538     { &hf_alcap_compat_general_ii, { "General II", "alcap.compat.general.ii", FT_UINT8, BASE_DEC, VALS(instruction_indicator), 0x03, "Instruction Indicator", HFILL }},
1539
1540     { &hf_alcap_unknown, { "Unknown Field Data", "alcap.unknown.field", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1541
1542     { &hf_alcap_param_id, { "Parameter", "alcap.param", FT_UINT8, BASE_DEC, VALS(msg_parm_strings), 0, "Parameter Id", HFILL }},
1543     { &hf_alcap_param_len, { "Length", "alcap.param.len", FT_UINT8, BASE_DEC, NULL, 0, "Parameter Length", HFILL }},
1544
1545     { &hf_alcap_cau_coding, { "Cause Coding", "alcap.cau.coding", FT_UINT8, BASE_DEC, VALS(cause_coding_vals), 0x03, NULL, HFILL }},
1546     { &hf_alcap_cau_value_itu, { "Cause Value (ITU)", "alcap.cau.value", FT_UINT8, BASE_DEC, VALS(cause_values_itu), 0x7f, NULL, HFILL }},
1547     { &hf_alcap_cau_value_non_itu, { "Cause Value (Other)", "alcap.cau.value", FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1548     { &hf_alcap_cau_diag, { "Diagnostic", "alcap.cau.diag", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1549     { &hf_alcap_cau_diag_len, { "Length", "alcap.cau.diag.len", FT_UINT8, BASE_DEC, NULL, 0, "Diagnostics Length", HFILL }},
1550     { &hf_alcap_cau_diag_msg, { "Message Identifier", "alcap.cau.diag.msg", FT_UINT8, BASE_DEC, VALS(msg_type_strings), 0, NULL, HFILL }},
1551     { &hf_alcap_cau_diag_param_id, { "Parameter Identifier", "alcap.cau.diag.param", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1552     { &hf_alcap_cau_diag_field_num, { "Field Number", "alcap.cau.diag.field_num", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1553
1554     { &hf_alcap_ceid_pathid, { "Path ID", "alcap.ceid.pathid", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
1555     { &hf_alcap_ceid_cid, { "CID", "alcap.ceid.cid", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1556
1557     { &hf_alcap_dnsea, { "Address", "alcap.dnsea.addr", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1558
1559     { &hf_alcap_alc_max_br_fw, { "Maximum Forward Bit Rate", "alcap.alc.bitrate.max.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1560     { &hf_alcap_alc_max_br_bw, { "Maximum Backwards Bit Rate", "alcap.alc.bitrate.max.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1561     { &hf_alcap_alc_avg_br_fw, { "Average Forward Bit Rate", "alcap.alc.bitrate.avg.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1562     { &hf_alcap_alc_avg_br_bw, { "Average Backwards Bit Rate", "alcap.alc.bitrate.avg.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1563     { &hf_alcap_alc_max_sdu_fw, { "Maximum Forward CPS SDU Size", "alcap.alc.sdusize.max.fw", FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1564     { &hf_alcap_alc_max_sdu_bw, { "Maximum Backwards CPS SDU Size", "alcap.alc.sdusize.max.bw", FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1565     { &hf_alcap_alc_avg_sdu_fw, { "Average Forward CPS SDU Size", "alcap.alc.sdusize.avg.fw", FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1566     { &hf_alcap_alc_avg_sdu_bw, { "Average Backwards CPS SDU Size", "alcap.alc.sdusize.avg.bw", FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1567
1568     { &hf_alcap_osaid, { "OSAID", "alcap.osaid", FT_UINT32, BASE_HEX, NULL, 0, "Originating Service Association ID", HFILL }},
1569
1570     { &hf_alcap_sugr, { "SUGR", "alcap.sugr", FT_BYTES, BASE_NONE, NULL, 0, "Served User Generated Reference", HFILL }},
1571
1572     { &hf_alcap_sut_len, { "SUT Length", "alcap.sut.sut_len", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }},
1573     { &hf_alcap_sut, { "SUT", "alcap.sut.transport", FT_BYTES, BASE_NONE, NULL, 0, "Served User Transport", HFILL }},
1574
1575     { &hf_alcap_ssia_pr_type, { "Profile Type", "alcap.ssia.profile.type", FT_UINT8, BASE_DEC, VALS(audio_profile_type), 0xc0, "I.366.2 Profile Type", HFILL }},
1576     { &hf_alcap_ssia_pr_id, { "Profile Id", "alcap.ssia.profile.id", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1577     { &hf_alcap_ssia_frm, { "Frame Mode", "alcap.ssia.frm", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x80, NULL, HFILL }},
1578     { &hf_alcap_ssia_cmd, { "Circuit Mode", "alcap.ssia.cmd", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x40, NULL, HFILL }},
1579     { &hf_alcap_ssia_mfr2, { "Multi-Frequency R2", "alcap.ssia.mfr2", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x20, NULL, HFILL }},
1580     { &hf_alcap_ssia_mfr1, { "Multi-Frequency R1", "alcap.ssia.mfr1", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x10, NULL, HFILL }},
1581     { &hf_alcap_ssia_dtmf, { "DTMF", "alcap.ssia.dtmf", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x08, NULL, HFILL }},
1582     { &hf_alcap_ssia_cas, { "CAS", "alcap.ssia.cas", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x04, "Channel Associated Signalling", HFILL }},
1583     { &hf_alcap_ssia_fax, { "Fax", "alcap.ssia.fax", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x02, "Facsimile", HFILL }},
1584     { &hf_alcap_ssia_pcm, { "PCM Mode", "alcap.ssia.pcm", FT_UINT8, BASE_DEC, VALS(alaw_ulaw), 0x01, NULL, HFILL }},
1585     { &hf_alcap_ssia_max_len, { "Max Len of FM Data", "alcap.ssia.max_fmdata_len", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1586     { &hf_alcap_ssia_oui, { "OUI", "alcap.ssia.oui", FT_BYTES, BASE_NONE, NULL, 0, "Organizational Unique Identifier", HFILL }},
1587
1588     { &hf_alcap_ssim_frm, { "Frame Mode", "alcap.ssim.frm", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x80, NULL, HFILL }},
1589     { &hf_alcap_ssim_mult, { "Multiplier", "alcap.ssim.mult", FT_UINT8, BASE_DEC, NULL, 0x1f, NULL, HFILL }},
1590     { &hf_alcap_ssim_max, { "Max Len", "alcap.ssim.max", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1591
1592     { &hf_alcap_ssisa_max_sssar_fw, { "Maximum Len of SSSAR-SDU Forward", "alcap.ssisa.sssar.max_len.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1593     { &hf_alcap_ssisa_max_sssar_bw, { "Maximum Len of SSSAR-SDU Backwards", "alcap.ssisa.sssar.max_len.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1594     { &hf_alcap_ssisa_max_sscop_sdu_fw, { "Maximum Len of SSSAR-SDU Forward", "alcap.ssisa.sscop.max_sdu_len.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1595     { &hf_alcap_ssisa_max_sscop_sdu_bw, { "Maximum Len of SSSAR-SDU Backwards", "alcap.ssisa.sscop.max_sdu_len.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1596     { &hf_alcap_ssisa_max_sscop_uu_fw, { "Maximum Len of SSSAR-SDU Forward", "alcap.ssisa.sscop.max_uu_len.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1597     { &hf_alcap_ssisa_max_sscop_uu_bw, { "Maximum Len of SSSAR-SDU Backwards", "alcap.ssisa.sscop.max_uu_len.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1598
1599     { &hf_alcap_ssisu_max_sssar_fw, { "Maximum Len of SSSAR-SDU Forward", "alcap.ssisu.sssar.max_len.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1600     { &hf_alcap_ssisu_max_sssar_bw, { "Maximum Len of SSSAR-SDU Backwards", "alcap.ssisu.sssar.max_len.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1601     { &hf_alcap_ssisu_ted, { "Transmission Error Detection", "alcap.ssisu.ted", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x80, NULL, HFILL }},
1602
1603     { &hf_alcap_pt, { "QoS Codepoint", "alcap.pt.codepoint", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1604
1605     { &hf_alcap_plc_max_br_fw, { "Maximum Forward Bit Rate", "alcap.plc.bitrate.max.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1606     { &hf_alcap_plc_max_br_bw, { "Maximum Backwards Bit Rate", "alcap.plc.bitrate.max.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1607     { &hf_alcap_plc_avg_br_fw, { "Average Forward Bit Rate", "alcap.plc.bitrate.avg.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1608     { &hf_alcap_plc_avg_br_bw, { "Average Backwards Bit Rate", "alcap.plc.bitrate.avg.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1609     { &hf_alcap_plc_max_sdu_fw, { "Maximum Forward CPS SDU Size", "alcap.plc.sdusize.max.fw", FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1610     { &hf_alcap_plc_max_sdu_bw, { "Maximum Backwards CPS SDU Size", "alcap.plc.sdusize.max.bw", FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1611     { &hf_alcap_plc_avg_sdu_fw, { "Maximum Forward CPS SDU Size", "alcap.plc.sdusize.max.fw", FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1612     { &hf_alcap_plc_avg_sdu_bw, { "Maximum Backwards CPS SDU Size", "alcap.plc.sdusize.max.bw", FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1613
1614     { &hf_alcap_pssiae_pr_type, { "Profile Type", "alcap.pssiae.profile.type", FT_UINT8, BASE_DEC, VALS(audio_profile_type), 0xc0, "I.366.2 Profile Type", HFILL }},
1615     { &hf_alcap_pssiae_pr_id, { "Profile Id", "alcap.pssiae.profile.id", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1616     { &hf_alcap_pssiae_lb, { "Loopback", "alcap.pssiae.lb", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0xc0, NULL, HFILL }},
1617     { &hf_alcap_pssiae_rc, { "Rate Control", "alcap.pssiae.rc", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0xc0, NULL, HFILL }},
1618     { &hf_alcap_pssiae_syn, { "Synchronization", "alcap.pssiae.syn", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0xc0, "Transport of synchronization of change in SSCS operation", HFILL }},
1619     { &hf_alcap_pssiae_frm, { "Frame Mode", "alcap.pssiae.frm", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x80, NULL, HFILL }},
1620     { &hf_alcap_pssiae_cmd, { "Circuit Mode", "alcap.pssiae.cmd", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x40, NULL, HFILL }},
1621     { &hf_alcap_pssiae_mfr2, { "Multi-Frequency R2", "alcap.pssiae.mfr2", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x20, NULL, HFILL }},
1622     { &hf_alcap_pssiae_mfr1, { "Multi-Frequency R1", "alcap.pssiae.mfr1", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x10, NULL, HFILL }},
1623     { &hf_alcap_pssiae_dtmf, { "DTMF", "alcap.pssiae.dtmf", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x08, NULL, HFILL }},
1624     { &hf_alcap_pssiae_cas, { "CAS", "alcap.pssiae.cas", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x04, "Channel Associated Signalling", HFILL }},
1625     { &hf_alcap_pssiae_fax, { "Fax", "alcap.pssiae.fax", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x02, "Facsimile", HFILL }},
1626     { &hf_alcap_pssiae_pcm, { "PCM Mode", "alcap.pssiae.pcm", FT_UINT8, BASE_DEC, VALS(alaw_ulaw), 0x01, NULL, HFILL }},
1627     { &hf_alcap_pssiae_max_len, { "Max Len of FM Data", "alcap.pssiae.max_fmdata_len", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1628     { &hf_alcap_pssiae_oui, { "OUI", "alcap.pssiae.oui", FT_BYTES, BASE_NONE, NULL, 0, "Organizational Unique Identifier", HFILL }},
1629
1630     { &hf_alcap_pssime_frm, { "Frame Mode", "alcap.pssime.frm", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x80, NULL, HFILL }},
1631     { &hf_alcap_pssime_lb, { "Loopback", "alcap.pssime.lb", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x40, NULL, HFILL }},
1632     { &hf_alcap_pssime_mult, { "Multiplier", "alcap.pssime.mult", FT_UINT8, BASE_DEC, NULL, 0x1f, NULL, HFILL }},
1633     { &hf_alcap_pssime_max, { "Max Len", "alcap.pssime.max", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1634
1635     { &hf_alcap_suci, { "SUCI", "alcap.suci", FT_UINT8, BASE_HEX, NULL, 0, "Served User Correlation Id", HFILL }},
1636
1637     { &hf_alcap_onsea, { "Address", "alcap.onsea.addr", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1638
1639     { &hf_alcap_ssiae_pr_type, { "Profile Type", "alcap.ssiae.profile.type", FT_UINT8, BASE_DEC, VALS(audio_profile_type), 0xc0, "I.366.2 Profile Type", HFILL }},
1640     { &hf_alcap_ssiae_lb, { "Loopback", "alcap.ssiae.lb", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0xc0, NULL, HFILL }},
1641     { &hf_alcap_ssiae_rc, { "Rate Control", "alcap.ssiae.rc", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0xc0, NULL, HFILL }},
1642     { &hf_alcap_ssiae_syn, { "Synchronization", "alcap.ssiae.syn", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0xc0, "Transport of synchronization of change in SSCS operation", HFILL }},
1643     { &hf_alcap_ssiae_pr_id, { "Profile Id", "alcap.ssiae.profile.id", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1644     { &hf_alcap_ssiae_frm, { "Frame Mode", "alcap.ssiae.frm", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x80, NULL, HFILL }},
1645     { &hf_alcap_ssiae_cmd, { "Circuit Mode", "alcap.ssiae.cmd", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x40, NULL, HFILL }},
1646     { &hf_alcap_ssiae_mfr2, { "Multi-Frequency R2", "alcap.ssiae.mfr2", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x20, NULL, HFILL }},
1647     { &hf_alcap_ssiae_mfr1, { "Multi-Frequency R1", "alcap.ssiae.mfr1", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x10, NULL, HFILL }},
1648     { &hf_alcap_ssiae_dtmf, { "DTMF", "alcap.ssiae.dtmf", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x08, NULL, HFILL }},
1649     { &hf_alcap_ssiae_cas, { "CAS", "alcap.ssiae.cas", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x04, "Channel Associated Signalling", HFILL }},
1650     { &hf_alcap_ssiae_fax, { "Fax", "alcap.ssiae.fax", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x02, "Facsimile", HFILL }},
1651     { &hf_alcap_ssiae_pcm, { "PCM Mode", "alcap.ssiae.pcm", FT_UINT8, BASE_DEC, VALS(alaw_ulaw), 0x01, NULL, HFILL }},
1652     { &hf_alcap_ssiae_max_len, { "Max Len of FM Data", "alcap.ssiae.max_fmdata_len", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1653     { &hf_alcap_ssiae_oui, { "OUI", "alcap.ssiae.oui", FT_BYTES, BASE_NONE, NULL, 0, "Organizational Unique Identifier", HFILL }},
1654
1655     { &hf_alcap_ssime_frm, { "Frame Mode", "alcap.ssime.frm", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x80, NULL, HFILL }},
1656     { &hf_alcap_ssime_lb, { "Loopback", "alcap.ssime.lb", FT_UINT8, BASE_DEC, VALS(enabled_disabled), 0x40, NULL, HFILL }},
1657     { &hf_alcap_ssime_mult, { "Multiplier", "alcap.ssime.mult", FT_UINT8, BASE_DEC, NULL, 0x1f, NULL, HFILL }},
1658     { &hf_alcap_ssime_max, { "Max Len", "alcap.ssime.max", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1659
1660     { &hf_alcap_acc_level, { "Congestion Level", "alcap.acc.level", FT_UINT8, BASE_DEC, VALS(congestion_level), 0, NULL, HFILL }},
1661
1662     { &hf_alcap_cp, { "Level", "alcap.cp.level", FT_UINT8, BASE_DEC, VALS(connection_priority), 0x07, NULL, HFILL }},
1663
1664     { &hf_alcap_hc, { "Codepoint", "alcap.hc.codepoint", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1665
1666     { &hf_alcap_pfbw_br_fw, { "CPS Forward Bitrate", "alcap.pfbw.bitrate.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1667     { &hf_alcap_pfbw_br_bw, { "CPS Backwards Bitrate", "alcap.pfbw.bitrate.bw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1668     { &hf_alcap_pfbw_bucket_fw, { "Forward CPS Bucket Size", "alcap.pfbw.bucket_size.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1669     { &hf_alcap_pfbw_bucket_bw, { "Backwards CPS Bucket Size", "alcap.pfbw.bucket_size.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1670     { &hf_alcap_pfbw_size_fw, { "Forward CPS Packet Size", "alcap.pfbw.max_size.fw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1671     { &hf_alcap_pfbw_size_bw, { "Backwards CPS Packet Size", "alcap.pfbw.max_size.bw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1672
1673     { &hf_alcap_pvbws_br_fw, { "Peak CPS Forward Bitrate", "alcap.pvbws.bitrate.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1674     { &hf_alcap_pvbws_br_bw, { "Peak CPS Backwards Bitrate", "alcap.pvbws.bitrate.bw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1675     { &hf_alcap_pvbws_bucket_fw, { "Peak Forward CPS Bucket Size", "alcap.pvbws.bucket_size.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1676     { &hf_alcap_pvbws_bucket_bw, { "Peak Backwards CPS Bucket Size", "alcap.pvbws.bucket_size.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1677     { &hf_alcap_pvbws_size_fw, { "Forward CPS Packet Size", "alcap.pvbws.max_size.fw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1678     { &hf_alcap_pvbws_size_bw, { "Backwards CPS Packet Size", "alcap.pvbws.max_size.bw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1679     { &hf_alcap_pvbws_stt, { "Source Traffic Type", "alcap.pvbws.stt", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1680
1681     { &hf_alcap_pvbwt_peak_br_fw, { "Peak CPS Forward Bitrate", "alcap.pvbwt.bitrate.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1682     { &hf_alcap_pvbwt_peak_br_bw, { "Peak CPS Backwards Bitrate", "alcap.pvbwt.bitrate.bw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1683     { &hf_alcap_pvbwt_peak_bucket_fw, { "Peak Forward CPS Bucket Size", "alcap.pvbwt.bucket_size.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1684     { &hf_alcap_pvbwt_peak_bucket_bw, { "Peak Backwards CPS Bucket Size", "alcap.pvbwt.bucket_size.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1685     { &hf_alcap_pvbwt_sust_br_fw, { "Sustainable CPS Forward Bitrate", "alcap.pvbwt.bitrate.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1686     { &hf_alcap_pvbwt_sust_br_bw, { "Sustainable CPS Backwards Bitrate", "alcap.pvbwt.bitrate.bw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1687     { &hf_alcap_pvbwt_sust_bucket_fw, { "Sustainable Forward CPS Bucket Size", "alcap.pvbwt.bucket_size.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1688     { &hf_alcap_pvbwt_sust_bucket_bw, { "Sustainable Backwards CPS Bucket Size", "alcap.pvbwt.bucket_size.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1689     { &hf_alcap_pvbwt_size_fw, { "Forward CPS Packet Size", "alcap.pvbwt.max_size.fw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1690     { &hf_alcap_pvbwt_size_bw, { "Backwards CPS Packet Size", "alcap.pvbwt.max_size.bw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1691
1692     { &hf_alcap_fbw_br_fw, { "CPS Forward Bitrate", "alcap.fbw.bitrate.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1693     { &hf_alcap_fbw_br_bw, { "CPS Backwards Bitrate", "alcap.fbw.bitrate.bw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1694     { &hf_alcap_fbw_bucket_fw, { "Forward CPS Bucket Size", "alcap.fbw.bucket_size.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1695     { &hf_alcap_fbw_bucket_bw, { "Backwards CPS Bucket Size", "alcap.fbw.bucket_size.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1696     { &hf_alcap_fbw_size_fw, { "Forward CPS Packet Size", "alcap.fbw.max_size.fw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1697     { &hf_alcap_fbw_size_bw, { "Backwards CPS Packet Size", "alcap.fbw.max_size.bw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1698
1699     { &hf_alcap_vbws_br_fw, { "CPS Forward Bitrate", "alcap.vbws.bitrate.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1700     { &hf_alcap_vbws_br_bw, { "CPS Backwards Bitrate", "alcap.vbws.bitrate.bw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1701     { &hf_alcap_vbws_bucket_fw, { "Forward CPS Bucket Size", "alcap.vbws.bucket_size.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1702     { &hf_alcap_vbws_bucket_bw, { "Backwards CPS Bucket Size", "alcap.vbws.bucket_size.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1703     { &hf_alcap_vbws_size_fw, { "Forward CPS Packet Size", "alcap.vbws.max_size.fw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1704     { &hf_alcap_vbws_size_bw, { "Backwards CPS Packet Size", "alcap.vbws.max_size.bw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1705     { &hf_alcap_vbws_stt, { "Source Traffic Type", "alcap.vbws.stt", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1706
1707     { &hf_alcap_vbwt_peak_br_fw, { "Peak CPS Forward Bitrate", "alcap.vbwt.bitrate.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1708     { &hf_alcap_vbwt_peak_br_bw, { "Peak CPS Backwards Bitrate", "alcap.vbwt.bitrate.bw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1709     { &hf_alcap_vbwt_peak_bucket_fw, { "Peak Forward CPS Bucket Size", "alcap.vbwt.bucket_size.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1710     { &hf_alcap_vbwt_peak_bucket_bw, { "Peak Backwards CPS Bucket Size", "alcap.vbwt.bucket_size.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1711     { &hf_alcap_vbwt_sust_br_fw, { "Sustainable CPS Forward Bitrate", "alcap.vbwt.bitrate.fw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1712     { &hf_alcap_vbwt_sust_br_bw, { "Sustainable CPS Backwards Bitrate", "alcap.vbwt.bitrate.bw", FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1713     { &hf_alcap_vbwt_sust_bucket_fw, { "Sustainable Forward CPS Bucket Size", "alcap.vbwt.bucket_size.fw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1714     { &hf_alcap_vbwt_sust_bucket_bw, { "Sustainable Backwards CPS Bucket Size", "alcap.vbwt.bucket_size.bw", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1715     { &hf_alcap_vbwt_size_fw, { "Forward CPS Packet Size", "alcap.vbwt.max_size.fw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1716     { &hf_alcap_vbwt_size_bw, { "Backwards CPS Packet Size", "alcap.vbwt.max_size.bw", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1717
1718     { &hf_alcap_leg_osaid, { "Leg's ERQ OSA id",    "alcap.leg.osaid", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } },
1719     { &hf_alcap_leg_dsaid, { "Leg's ECF OSA id",    "alcap.leg.dsaid", FT_UINT32, BASE_HEX, NULL, 0,NULL, HFILL } },
1720     { &hf_alcap_leg_pathid, { "Leg's path id",    "alcap.leg.pathid", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
1721     { &hf_alcap_leg_cid, { "Leg's channel id",    "alcap.leg.cid", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
1722     { &hf_alcap_leg_sugr, { "Leg's SUGR",    "alcap.leg.sugr", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } },
1723     { &hf_alcap_leg_dnsea, { "Leg's destination NSAP",    "alcap.leg.dnsea", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
1724     { &hf_alcap_leg_onsea, { "Leg's originating NSAP",    "alcap.leg.onsea", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
1725     { &hf_alcap_leg_frame, { "a message of this leg",    "alcap.leg.msg", FT_FRAMENUM, BASE_NONE, NULL, 0, NULL, HFILL } },
1726     { &hf_alcap_leg_release_cause, { "Leg's cause value in REL",    "alcap.leg.cause", FT_UINT8, BASE_DEC, VALS(cause_values_itu), 0, NULL, HFILL }},
1727
1728     };
1729
1730     gint* ett[] = {
1731         &ett_alcap,
1732         &ett_leg,
1733         &ett_compat,
1734         &ett_cau_diag,
1735         &param_infos[0].ett,
1736         &param_infos[1].ett,
1737         &param_infos[2].ett,
1738         &param_infos[3].ett,
1739         &param_infos[4].ett,
1740         &param_infos[5].ett,
1741         &param_infos[6].ett,
1742         &param_infos[7].ett,
1743         &param_infos[8].ett,
1744         &param_infos[9].ett,
1745         &param_infos[10].ett,
1746         &param_infos[11].ett,
1747         &param_infos[12].ett,
1748         &param_infos[13].ett,
1749         &param_infos[14].ett,
1750         &param_infos[15].ett,
1751         &param_infos[16].ett,
1752         &param_infos[17].ett,
1753         &param_infos[18].ett,
1754         &param_infos[19].ett,
1755         &param_infos[20].ett,
1756         &param_infos[21].ett,
1757         &param_infos[22].ett,
1758         &param_infos[23].ett,
1759         &param_infos[24].ett,
1760         &param_infos[25].ett,
1761         &param_infos[26].ett,
1762         &param_infos[27].ett,
1763         &param_infos[28].ett,
1764         &param_infos[29].ett,
1765         &param_infos[30].ett,
1766         &param_infos[31].ett,
1767         &param_infos[32].ett,
1768         &param_infos[33].ett,
1769         &param_infos[34].ett,
1770         &param_infos[35].ett,
1771     };
1772
1773     proto_alcap = proto_register_protocol(alcap_proto_name, alcap_proto_name_short, "alcap");
1774
1775     register_dissector("alcap", dissect_alcap, proto_alcap);
1776
1777     proto_register_field_array(proto_alcap, hf, array_length(hf));
1778     proto_register_subtree_array(ett, array_length(ett));
1779
1780     alcap_module = prefs_register_protocol(proto_alcap, NULL);
1781
1782     prefs_register_bool_preference(alcap_module, "leg_info",
1783                                    "Keep Leg Information",
1784                                    "Whether persistent call leg information is to be kept",
1785                                    &keep_persistent_info);
1786
1787     legs_by_dsaid = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "legs_by_dsaid");
1788     legs_by_osaid = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "legs_by_osaid");
1789     legs_by_bearer = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "legs_by_bearer");
1790 }
1791
1792
1793 void
1794 proto_reg_handoff_alcap(void)
1795 {
1796     dissector_handle_t alcap_handle = create_dissector_handle(dissect_alcap, proto_alcap);
1797
1798     dissector_add_uint("mtp3.service_indicator", MTP_SI_AAL2, alcap_handle);
1799 }