#include <stdio.h> not needed.
[obnox/wireshark/wip.git] / epan / dissectors / packet-tcap.c
1 /* Do not modify this file.                                                   */
2 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
3 /* packet-tcap.c                                                              */
4 /* ../../tools/asn2wrs.py -b -p tcap -c ./tcap.cnf -s ./packet-tcap-template -D . tcap.asn UnidialoguePDUs.asn DialoguePDUs.asn */
5
6 /* Input file: packet-tcap-template.c */
7
8 #line 1 "packet-tcap-template.c"
9 /* packet-tcap-template.c
10  * Routines for  TCAP
11  * Copyright 2004 - 2005, Tim Endean <endeant@hotmail.com>
12  * Built from the gsm-map dissector Copyright 2004 - 2005, Anders Broman <anders.broman@ericsson.com>
13  *
14  * $Id$
15  *
16  * Wireshark - Network traffic analyzer
17  * By Gerald Combs <gerald@wireshark.org>
18  * Copyright 1998 Gerald Combs
19  *
20  * This program is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU General Public License
22  * as published by the Free Software Foundation; either version 2
23  * of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program; if not, write to the Free Software
32  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
33  * References: ETSI 300 374
34  */
35
36 #ifdef HAVE_CONFIG_H
37 # include "config.h"
38 #endif
39
40 #include <glib.h>
41 #include <epan/packet.h>
42 #include <epan/prefs.h>
43 #include <epan/oids.h>
44 #include <epan/asn1.h>
45 #include <epan/strutil.h>
46
47 #include <string.h>
48 #include "packet-ber.h"
49 #include "packet-tcap.h"
50 #include <epan/tcap-persistentdata.h>
51
52 #define PNAME  "Transaction Capabilities Application Part"
53 #define PSNAME "TCAP"
54 #define PFNAME "tcap"
55
56 /* Initialize the protocol and registered fields */
57 static int proto_tcap = -1;
58 static int hf_tcap_tag = -1;
59 static int hf_tcap_length = -1;
60 static int hf_tcap_data = -1;
61 static int hf_tcap_tid = -1;
62
63 int hf_tcapsrt_SessionId=-1;
64 int hf_tcapsrt_Duplicate=-1;
65 int hf_tcapsrt_BeginSession=-1;
66 int hf_tcapsrt_EndSession=-1;
67 int hf_tcapsrt_SessionTime=-1;
68
69
70 /*--- Included file: packet-tcap-hf.c ---*/
71 #line 1 "packet-tcap-hf.c"
72 static int hf_tcap_UniDialoguePDU_PDU = -1;       /* UniDialoguePDU */
73 static int hf_tcap_DialoguePDU_PDU = -1;          /* DialoguePDU */
74 static int hf_tcap_oid = -1;                      /* OBJECT_IDENTIFIER */
75 static int hf_tcap_dialog = -1;                   /* Dialog1 */
76 static int hf_tcap_unidirectional = -1;           /* Unidirectional */
77 static int hf_tcap_begin = -1;                    /* Begin */
78 static int hf_tcap_end = -1;                      /* End */
79 static int hf_tcap_continue = -1;                 /* Continue */
80 static int hf_tcap_abort = -1;                    /* Abort */
81 static int hf_tcap_dialoguePortion = -1;          /* DialoguePortion */
82 static int hf_tcap_components = -1;               /* ComponentPortion */
83 static int hf_tcap_otid = -1;                     /* OrigTransactionID */
84 static int hf_tcap_dtid = -1;                     /* DestTransactionID */
85 static int hf_tcap_reason = -1;                   /* Reason */
86 static int hf_tcap_p_abortCause = -1;             /* P_AbortCause */
87 static int hf_tcap_u_abortCause = -1;             /* DialoguePortion */
88 static int hf_tcap__untag_item = -1;              /* Component */
89 static int hf_tcap_invoke = -1;                   /* Invoke */
90 static int hf_tcap_returnResultLast = -1;         /* ReturnResult */
91 static int hf_tcap_returnError = -1;              /* ReturnError */
92 static int hf_tcap_reject = -1;                   /* Reject */
93 static int hf_tcap_returnResultNotLast = -1;      /* ReturnResult */
94 static int hf_tcap_invokeID = -1;                 /* InvokeIdType */
95 static int hf_tcap_linkedID = -1;                 /* InvokeIdType */
96 static int hf_tcap_opCode = -1;                   /* OPERATION */
97 static int hf_tcap_parameter = -1;                /* Parameter */
98 static int hf_tcap_resultretres = -1;             /* T_resultretres */
99 static int hf_tcap_errorCode = -1;                /* ErrorCode */
100 static int hf_tcap_invokeIDRej = -1;              /* T_invokeIDRej */
101 static int hf_tcap_derivable = -1;                /* InvokeIdType */
102 static int hf_tcap_not_derivable = -1;            /* NULL */
103 static int hf_tcap_problem = -1;                  /* T_problem */
104 static int hf_tcap_generalProblem = -1;           /* GeneralProblem */
105 static int hf_tcap_invokeProblem = -1;            /* InvokeProblem */
106 static int hf_tcap_returnResultProblem = -1;      /* ReturnResultProblem */
107 static int hf_tcap_returnErrorProblem = -1;       /* ReturnErrorProblem */
108 static int hf_tcap_localValue = -1;               /* INTEGER */
109 static int hf_tcap_globalValue = -1;              /* OBJECT_IDENTIFIER */
110 static int hf_tcap_nationaler = -1;               /* INTEGER_M32768_32767 */
111 static int hf_tcap_privateer = -1;                /* INTEGER */
112 static int hf_tcap_unidialoguePDU = -1;           /* AUDT_apdu */
113 static int hf_tcap_audt_protocol_version = -1;    /* AUDT_protocol_version */
114 static int hf_tcap_audt_application_context_name = -1;  /* AUDT_application_context_name */
115 static int hf_tcap_audt_user_information = -1;    /* AUDT_user_information */
116 static int hf_tcap_audt_user_information_item = -1;  /* EXTERNAL */
117 static int hf_tcap_dialogueRequest = -1;          /* AARQ_apdu */
118 static int hf_tcap_dialogueResponse = -1;         /* AARE_apdu */
119 static int hf_tcap_dialogueAbort = -1;            /* ABRT_apdu */
120 static int hf_tcap_aarq_protocol_version = -1;    /* AARQ_protocol_version */
121 static int hf_tcap_aarq_application_context_name = -1;  /* AARQ_application_context_name */
122 static int hf_tcap_aarq_user_information = -1;    /* AARQ_user_information */
123 static int hf_tcap_aarq_user_information_item = -1;  /* EXTERNAL */
124 static int hf_tcap_aare_protocol_version = -1;    /* AARE_protocol_version */
125 static int hf_tcap_aare_application_context_name = -1;  /* AARE_application_context_name */
126 static int hf_tcap_result = -1;                   /* Associate_result */
127 static int hf_tcap_result_source_diagnostic = -1;  /* Associate_source_diagnostic */
128 static int hf_tcap_aare_user_information = -1;    /* AARE_user_information */
129 static int hf_tcap_aare_user_information_item = -1;  /* EXTERNAL */
130 static int hf_tcap_abort_source = -1;             /* ABRT_source */
131 static int hf_tcap_abrt_user_information = -1;    /* ABRT_user_information */
132 static int hf_tcap_abrt_user_information_item = -1;  /* EXTERNAL */
133 static int hf_tcap_dialogue_service_user = -1;    /* T_dialogue_service_user */
134 static int hf_tcap_dialogue_service_provider = -1;  /* T_dialogue_service_provider */
135 /* named bits */
136 static int hf_tcap_AUDT_protocol_version_version1 = -1;
137 static int hf_tcap_AARQ_protocol_version_version1 = -1;
138 static int hf_tcap_AARE_protocol_version_version1 = -1;
139
140 /*--- End of included file: packet-tcap-hf.c ---*/
141 #line 62 "packet-tcap-template.c"
142
143 /* Initialize the subtree pointers */
144 static gint ett_tcap = -1;
145 static gint ett_param = -1;
146
147 static gint ett_otid = -1;
148 static gint ett_dtid = -1;
149 gint ett_tcap_stat = -1;
150
151 static struct tcapsrt_info_t * gp_tcapsrt_info;
152 static gboolean tcap_subdissector_used=FALSE;
153 static dissector_handle_t requested_subdissector_handle = NULL;
154
155 static struct tcaphash_context_t * gp_tcap_context=NULL;
156
157
158 /*--- Included file: packet-tcap-ett.c ---*/
159 #line 1 "packet-tcap-ett.c"
160 static gint ett_tcap_ExternalPDU_U = -1;
161 static gint ett_tcap_TCMessage = -1;
162 static gint ett_tcap_Unidirectional = -1;
163 static gint ett_tcap_Begin = -1;
164 static gint ett_tcap_End = -1;
165 static gint ett_tcap_Continue = -1;
166 static gint ett_tcap_Abort = -1;
167 static gint ett_tcap_Reason = -1;
168 static gint ett_tcap_SEQUENCE_SIZE_1_MAX_OF_Component = -1;
169 static gint ett_tcap_Component = -1;
170 static gint ett_tcap_Invoke = -1;
171 static gint ett_tcap_ReturnResult = -1;
172 static gint ett_tcap_T_resultretres = -1;
173 static gint ett_tcap_ReturnError = -1;
174 static gint ett_tcap_Reject = -1;
175 static gint ett_tcap_T_invokeIDRej = -1;
176 static gint ett_tcap_T_problem = -1;
177 static gint ett_tcap_OPERATION = -1;
178 static gint ett_tcap_ERROR = -1;
179 static gint ett_tcap_ErrorCode = -1;
180 static gint ett_tcap_UniDialoguePDU = -1;
181 static gint ett_tcap_AUDT_apdu_U = -1;
182 static gint ett_tcap_AUDT_protocol_version = -1;
183 static gint ett_tcap_AUDT_user_information = -1;
184 static gint ett_tcap_DialoguePDU = -1;
185 static gint ett_tcap_AARQ_apdu_U = -1;
186 static gint ett_tcap_AARQ_protocol_version = -1;
187 static gint ett_tcap_AARQ_user_information = -1;
188 static gint ett_tcap_AARE_apdu_U = -1;
189 static gint ett_tcap_AARE_protocol_version = -1;
190 static gint ett_tcap_AARE_user_information = -1;
191 static gint ett_tcap_ABRT_apdu_U = -1;
192 static gint ett_tcap_ABRT_user_information = -1;
193 static gint ett_tcap_Associate_source_diagnostic = -1;
194
195 /*--- End of included file: packet-tcap-ett.c ---*/
196 #line 78 "packet-tcap-template.c"
197
198 #define MAX_SSN 254
199 static range_t *global_ssn_range;
200 static range_t *ssn_range;
201 struct tcap_private_t tcap_private;
202
203 gboolean gtcap_HandleSRT=FALSE;
204 extern gboolean gtcap_PersistentSRT;
205 extern gboolean gtcap_DisplaySRT;
206 extern guint gtcap_RepetitionTimeout;
207 extern guint gtcap_LostTimeout;
208
209 static dissector_handle_t       tcap_handle = NULL;
210 static dissector_table_t ber_oid_dissector_table;
211 static const char * cur_oid;
212 static const char * tcapext_oid;
213 static proto_tree * tcap_top_tree=NULL;
214 static proto_tree * tcap_stat_tree=NULL;
215
216 static dissector_handle_t data_handle;
217 static dissector_handle_t ansi_tcap_handle;
218
219 static void raz_tcap_private(struct tcap_private_t * p_tcap_private);
220 static int dissect_tcap_param(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset);
221 static int dissect_tcap_ITU_ComponentPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_);
222
223 static GHashTable* ansi_sub_dissectors = NULL;
224 static GHashTable* itu_sub_dissectors = NULL;
225
226 static void dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree);
227
228 extern void add_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector) {
229     g_hash_table_insert(ansi_sub_dissectors,GUINT_TO_POINTER(ssn),dissector);
230     dissector_add("sccp.ssn",ssn,tcap_handle);
231 }
232
233 extern void add_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector) {
234     g_hash_table_insert(itu_sub_dissectors,GUINT_TO_POINTER(ssn),dissector);
235     dissector_add("sccp.ssn",ssn,tcap_handle);
236 }
237
238 extern void delete_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector _U_) {
239     g_hash_table_remove(ansi_sub_dissectors,GUINT_TO_POINTER(ssn));
240     if (!get_itu_tcap_subdissector(ssn))
241       dissector_delete("sccp.ssn",ssn,tcap_handle);
242 }
243 extern void delete_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector _U_) {
244     g_hash_table_remove(itu_sub_dissectors,GUINT_TO_POINTER(ssn));
245     if (!get_ansi_tcap_subdissector(ssn))
246       dissector_delete("sccp.ssn", ssn,tcap_handle);
247 }
248
249 dissector_handle_t get_ansi_tcap_subdissector(guint32 ssn) {
250     return g_hash_table_lookup(ansi_sub_dissectors,GUINT_TO_POINTER(ssn));
251 }
252
253 dissector_handle_t get_itu_tcap_subdissector(guint32 ssn) {
254     return g_hash_table_lookup(itu_sub_dissectors,GUINT_TO_POINTER(ssn));
255 }
256
257
258
259
260 /*--- Included file: packet-tcap-fn.c ---*/
261 #line 1 "packet-tcap-fn.c"
262
263
264 static int
265 dissect_tcap_OBJECT_IDENTIFIER(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
266   offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
267
268   return offset;
269 }
270
271
272
273 static int
274 dissect_tcap_Dialog1(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
275 #line 69 "tcap.cnf"
276
277   offset = dissect_tcap_DialoguePDU(TRUE, tvb, offset, actx, tree, -1);
278
279
280
281   return offset;
282 }
283
284
285 static const ber_sequence_t ExternalPDU_U_sequence[] = {
286   { &hf_tcap_oid            , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_tcap_OBJECT_IDENTIFIER },
287   { &hf_tcap_dialog         , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_tcap_Dialog1 },
288   { NULL, 0, 0, 0, NULL }
289 };
290
291 static int
292 dissect_tcap_ExternalPDU_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
293   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
294                                    ExternalPDU_U_sequence, hf_index, ett_tcap_ExternalPDU_U);
295
296   return offset;
297 }
298
299
300
301 static int
302 dissect_tcap_ExternalPDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
303 #line 64 "tcap.cnf"
304
305   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
306                                       hf_index, BER_CLASS_UNI, 8, TRUE, dissect_tcap_ExternalPDU_U);
307
308
309
310
311   return offset;
312 }
313
314
315
316 static int
317 dissect_tcap_DialogueOC(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
318 #line 59 "tcap.cnf"
319
320   offset = dissect_tcap_ExternalPDU(FALSE /*implicit_tag*/, tvb, offset, actx, tree, -1);
321
322
323
324   return offset;
325 }
326
327
328
329 static int
330 dissect_tcap_DialoguePortion(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
331   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
332                                       hf_index, BER_CLASS_APP, 11, TRUE, dissect_tcap_DialogueOC);
333
334   return offset;
335 }
336
337
338
339 static int
340 dissect_tcap_InvokeIdType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
341   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
342                                                 NULL);
343
344   return offset;
345 }
346
347
348
349 static int
350 dissect_tcap_INTEGER(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
351   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
352                                                 NULL);
353
354   return offset;
355 }
356
357
358 static const value_string tcap_OPERATION_vals[] = {
359   {   0, "localValue" },
360   {   1, "globalValue" },
361   { 0, NULL }
362 };
363
364 static const ber_choice_t OPERATION_choice[] = {
365   {   0, &hf_tcap_localValue     , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_tcap_INTEGER },
366   {   1, &hf_tcap_globalValue    , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_tcap_OBJECT_IDENTIFIER },
367   { 0, NULL, 0, 0, 0, NULL }
368 };
369
370 static int
371 dissect_tcap_OPERATION(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
372   offset = dissect_ber_choice(actx, tree, tvb, offset,
373                                  OPERATION_choice, hf_index, ett_tcap_OPERATION,
374                                  NULL);
375
376   return offset;
377 }
378
379
380
381 static int
382 dissect_tcap_Parameter(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
383 #line 74 "tcap.cnf"
384
385   offset = dissect_tcap_param(actx,tree,tvb,offset);
386
387
388
389   return offset;
390 }
391
392
393 static const ber_sequence_t Invoke_sequence[] = {
394   { &hf_tcap_invokeID       , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_tcap_InvokeIdType },
395   { &hf_tcap_linkedID       , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_tcap_InvokeIdType },
396   { &hf_tcap_opCode         , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_tcap_OPERATION },
397   { &hf_tcap_parameter      , BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_tcap_Parameter },
398   { NULL, 0, 0, 0, NULL }
399 };
400
401 static int
402 dissect_tcap_Invoke(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
403   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
404                                    Invoke_sequence, hf_index, ett_tcap_Invoke);
405
406   return offset;
407 }
408
409
410 static const ber_sequence_t T_resultretres_sequence[] = {
411   { &hf_tcap_opCode         , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_tcap_OPERATION },
412   { &hf_tcap_parameter      , BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_tcap_Parameter },
413   { NULL, 0, 0, 0, NULL }
414 };
415
416 static int
417 dissect_tcap_T_resultretres(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
418   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
419                                    T_resultretres_sequence, hf_index, ett_tcap_T_resultretres);
420
421   return offset;
422 }
423
424
425 static const ber_sequence_t ReturnResult_sequence[] = {
426   { &hf_tcap_invokeID       , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_tcap_InvokeIdType },
427   { &hf_tcap_resultretres   , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_tcap_T_resultretres },
428   { NULL, 0, 0, 0, NULL }
429 };
430
431 static int
432 dissect_tcap_ReturnResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
433   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
434                                    ReturnResult_sequence, hf_index, ett_tcap_ReturnResult);
435
436   return offset;
437 }
438
439
440
441 static int
442 dissect_tcap_INTEGER_M32768_32767(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
443   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
444                                                 NULL);
445
446   return offset;
447 }
448
449
450 static const value_string tcap_ErrorCode_vals[] = {
451   {  19, "nationaler" },
452   {  20, "privateer" },
453   { 0, NULL }
454 };
455
456 static const ber_choice_t ErrorCode_choice[] = {
457   {  19, &hf_tcap_nationaler     , BER_CLASS_PRI, 19, BER_FLAGS_IMPLTAG, dissect_tcap_INTEGER_M32768_32767 },
458   {  20, &hf_tcap_privateer      , BER_CLASS_PRI, 20, BER_FLAGS_IMPLTAG, dissect_tcap_INTEGER },
459   { 0, NULL, 0, 0, 0, NULL }
460 };
461
462 static int
463 dissect_tcap_ErrorCode(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
464   offset = dissect_ber_choice(actx, tree, tvb, offset,
465                                  ErrorCode_choice, hf_index, ett_tcap_ErrorCode,
466                                  NULL);
467
468   return offset;
469 }
470
471
472 static const ber_sequence_t ReturnError_sequence[] = {
473   { &hf_tcap_invokeID       , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_tcap_InvokeIdType },
474   { &hf_tcap_errorCode      , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_tcap_ErrorCode },
475   { &hf_tcap_parameter      , BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_tcap_Parameter },
476   { NULL, 0, 0, 0, NULL }
477 };
478
479 static int
480 dissect_tcap_ReturnError(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
481   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
482                                    ReturnError_sequence, hf_index, ett_tcap_ReturnError);
483
484   return offset;
485 }
486
487
488
489 static int
490 dissect_tcap_NULL(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
491   offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
492
493   return offset;
494 }
495
496
497 static const value_string tcap_T_invokeIDRej_vals[] = {
498   {   0, "derivable" },
499   {   1, "not-derivable" },
500   { 0, NULL }
501 };
502
503 static const ber_choice_t T_invokeIDRej_choice[] = {
504   {   0, &hf_tcap_derivable      , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_tcap_InvokeIdType },
505   {   1, &hf_tcap_not_derivable  , BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_tcap_NULL },
506   { 0, NULL, 0, 0, 0, NULL }
507 };
508
509 static int
510 dissect_tcap_T_invokeIDRej(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
511   offset = dissect_ber_choice(actx, tree, tvb, offset,
512                                  T_invokeIDRej_choice, hf_index, ett_tcap_T_invokeIDRej,
513                                  NULL);
514
515   return offset;
516 }
517
518
519 static const value_string tcap_GeneralProblem_vals[] = {
520   {   0, "unrecognizedComponent" },
521   {   1, "mistypedComponent" },
522   {   2, "badlyStructuredComponent" },
523   { 0, NULL }
524 };
525
526
527 static int
528 dissect_tcap_GeneralProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
529   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
530                                                 NULL);
531
532   return offset;
533 }
534
535
536 static const value_string tcap_InvokeProblem_vals[] = {
537   {   0, "duplicateInvokeID" },
538   {   1, "unrecognizedOperation" },
539   {   2, "mistypedParameter" },
540   {   3, "resourceLimitation" },
541   {   4, "initiatingRelease" },
542   {   5, "unrecognizedLinkedID" },
543   {   6, "linkedResponseUnexpected" },
544   {   7, "unexpectedLinkedOperation" },
545   { 0, NULL }
546 };
547
548
549 static int
550 dissect_tcap_InvokeProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
551   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
552                                                 NULL);
553
554   return offset;
555 }
556
557
558 static const value_string tcap_ReturnResultProblem_vals[] = {
559   {   0, "unrecognizedInvokeID" },
560   {   1, "returnResultUnexpected" },
561   {   2, "mistypedParameter" },
562   { 0, NULL }
563 };
564
565
566 static int
567 dissect_tcap_ReturnResultProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
568   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
569                                                 NULL);
570
571   return offset;
572 }
573
574
575 static const value_string tcap_ReturnErrorProblem_vals[] = {
576   {   0, "unrecognizedInvokeID" },
577   {   1, "returnErrorUnexpected" },
578   {   2, "unrecognizedError" },
579   {   3, "unexpectedError" },
580   {   4, "mistypedParameter" },
581   { 0, NULL }
582 };
583
584
585 static int
586 dissect_tcap_ReturnErrorProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
587   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
588                                                 NULL);
589
590   return offset;
591 }
592
593
594 static const value_string tcap_T_problem_vals[] = {
595   {   0, "generalProblem" },
596   {   1, "invokeProblem" },
597   {   2, "returnResultProblem" },
598   {   3, "returnErrorProblem" },
599   { 0, NULL }
600 };
601
602 static const ber_choice_t T_problem_choice[] = {
603   {   0, &hf_tcap_generalProblem , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_tcap_GeneralProblem },
604   {   1, &hf_tcap_invokeProblem  , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_tcap_InvokeProblem },
605   {   2, &hf_tcap_returnResultProblem, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_tcap_ReturnResultProblem },
606   {   3, &hf_tcap_returnErrorProblem, BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_tcap_ReturnErrorProblem },
607   { 0, NULL, 0, 0, 0, NULL }
608 };
609
610 static int
611 dissect_tcap_T_problem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
612   offset = dissect_ber_choice(actx, tree, tvb, offset,
613                                  T_problem_choice, hf_index, ett_tcap_T_problem,
614                                  NULL);
615
616   return offset;
617 }
618
619
620 static const ber_sequence_t Reject_sequence[] = {
621   { &hf_tcap_invokeIDRej    , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_tcap_T_invokeIDRej },
622   { &hf_tcap_problem        , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_tcap_T_problem },
623   { NULL, 0, 0, 0, NULL }
624 };
625
626 static int
627 dissect_tcap_Reject(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
628   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
629                                    Reject_sequence, hf_index, ett_tcap_Reject);
630
631   return offset;
632 }
633
634
635 static const value_string tcap_Component_vals[] = {
636   {   1, "invoke" },
637   {   2, "returnResultLast" },
638   {   3, "returnError" },
639   {   4, "reject" },
640   {   7, "returnResultNotLast" },
641   { 0, NULL }
642 };
643
644 static const ber_choice_t Component_choice[] = {
645   {   1, &hf_tcap_invoke         , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_tcap_Invoke },
646   {   2, &hf_tcap_returnResultLast, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_tcap_ReturnResult },
647   {   3, &hf_tcap_returnError    , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_tcap_ReturnError },
648   {   4, &hf_tcap_reject         , BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_tcap_Reject },
649   {   7, &hf_tcap_returnResultNotLast, BER_CLASS_CON, 7, BER_FLAGS_IMPLTAG, dissect_tcap_ReturnResult },
650   { 0, NULL, 0, 0, 0, NULL }
651 };
652
653 static int
654 dissect_tcap_Component(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
655 #line 79 "tcap.cnf"
656 tvbuff_t        *next_tvb;
657 gint8 class;
658 gboolean pc;
659 gint tag;
660 guint32 len, comp_offset;
661 gint ind_field;
662
663 comp_offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &class, &pc, &tag);
664 comp_offset = dissect_ber_length(actx->pinfo, tree, tvb, comp_offset, &len, &ind_field);
665 /* we can believe the length now */
666 next_tvb = tvb_new_subset(tvb, offset, len+comp_offset-offset, len+comp_offset-offset);
667
668 if (!next_tvb)
669   return comp_offset;
670
671   offset = dissect_ber_choice(actx, tree, tvb, offset,
672                                  Component_choice, hf_index, ett_tcap_Component,
673                                  NULL);
674
675
676  dissect_tcap_ITU_ComponentPDU(implicit_tag, next_tvb, 0, actx, tcap_top_tree, hf_index);
677
678 /* return comp_offset+len; or return offset (will be automatically added) */
679
680
681
682   return offset;
683 }
684
685
686 static const ber_sequence_t SEQUENCE_SIZE_1_MAX_OF_Component_sequence_of[1] = {
687   { &hf_tcap__untag_item    , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_tcap_Component },
688 };
689
690 static int
691 dissect_tcap_SEQUENCE_SIZE_1_MAX_OF_Component(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
692   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
693                                       SEQUENCE_SIZE_1_MAX_OF_Component_sequence_of, hf_index, ett_tcap_SEQUENCE_SIZE_1_MAX_OF_Component);
694
695   return offset;
696 }
697
698
699
700 static int
701 dissect_tcap_ComponentPortion(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
702   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
703                                       hf_index, BER_CLASS_APP, 12, TRUE, dissect_tcap_SEQUENCE_SIZE_1_MAX_OF_Component);
704
705   return offset;
706 }
707
708
709 static const ber_sequence_t Unidirectional_sequence[] = {
710   { &hf_tcap_dialoguePortion, BER_CLASS_APP, 11, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_tcap_DialoguePortion },
711   { &hf_tcap_components     , BER_CLASS_APP, 12, BER_FLAGS_NOOWNTAG, dissect_tcap_ComponentPortion },
712   { NULL, 0, 0, 0, NULL }
713 };
714
715 static int
716 dissect_tcap_Unidirectional(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
717   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
718                                    Unidirectional_sequence, hf_index, ett_tcap_Unidirectional);
719
720   return offset;
721 }
722
723
724
725 static int
726 dissect_tcap_OCTET_STRING_SIZE_1_4(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
727   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
728                                        NULL);
729
730   return offset;
731 }
732
733
734
735 static int
736 dissect_tcap_OrigTransactionID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
737 #line 117 "tcap.cnf"
738 tvbuff_t *parameter_tvb;
739 guint8 len, i;
740 proto_item *tid_item;
741 proto_tree *subtree;
742 tid_item = proto_tree_add_text(tree, tvb, offset, -1, "Source Transaction ID");
743 subtree = proto_item_add_subtree(tid_item, ett_otid);
744
745 offset = dissect_ber_octet_string(implicit_tag, actx, subtree, tvb, offset, hf_tcap_tid,
746                                     &parameter_tvb);
747
748 if (parameter_tvb){
749         len = tvb_length_remaining(parameter_tvb, 0);
750         switch(len) {
751         case 1:
752                 gp_tcapsrt_info->src_tid=tvb_get_guint8(parameter_tvb, 0);
753                 break;
754         case 2:
755                 gp_tcapsrt_info->src_tid=tvb_get_ntohs(parameter_tvb, 0);
756                 break;
757         case 4:
758                 gp_tcapsrt_info->src_tid=tvb_get_ntohl(parameter_tvb, 0);
759                 break;
760         default:
761                 gp_tcapsrt_info->src_tid=0;
762                 break;
763         }
764
765         if ((len)&&(check_col(actx->pinfo->cinfo, COL_INFO))){
766                 col_append_str(actx->pinfo->cinfo, COL_INFO, "otid(");
767                 for(i=0;i<len;i++)
768                           col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%02x",tvb_get_guint8(parameter_tvb,i));
769                 col_append_str(actx->pinfo->cinfo, COL_INFO, ") ");
770         }
771
772 }
773
774
775
776
777   return offset;
778 }
779
780
781 static const ber_sequence_t Begin_sequence[] = {
782   { &hf_tcap_otid           , BER_CLASS_APP, 8, BER_FLAGS_NOOWNTAG, dissect_tcap_OrigTransactionID },
783   { &hf_tcap_dialoguePortion, BER_CLASS_APP, 11, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_tcap_DialoguePortion },
784   { &hf_tcap_components     , BER_CLASS_APP, 12, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_tcap_ComponentPortion },
785   { NULL, 0, 0, 0, NULL }
786 };
787
788 static int
789 dissect_tcap_Begin(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
790 #line 191 "tcap.cnf"
791 gp_tcapsrt_info->ope=TC_BEGIN;
792
793 /*  Do not change col_add_str() to col_append_str() here: we _want_ this call
794  *  to overwrite whatever's currently in the INFO column (e.g., "UDT" from
795  *  the SCCP dissector).
796  *
797  *  If there's something there that should not be overwritten, whoever
798  *  put that info there should call col_set_fence() to protect it.
799  */
800 if (check_col(actx->pinfo->cinfo, COL_INFO))
801                 col_set_str(actx->pinfo->cinfo, COL_INFO, "Begin ");
802
803   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
804                                    Begin_sequence, hf_index, ett_tcap_Begin);
805
806   return offset;
807 }
808
809
810
811 static int
812 dissect_tcap_DestTransactionID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
813 #line 156 "tcap.cnf"
814 tvbuff_t *parameter_tvb;
815 guint8 len , i;
816 proto_item *tid_item;
817 proto_tree *subtree;
818 tid_item = proto_tree_add_text(tree, tvb, offset, -1, "Destination Transaction ID");
819 subtree = proto_item_add_subtree(tid_item, ett_otid);
820
821 offset = dissect_ber_octet_string(implicit_tag, actx, subtree, tvb, offset, hf_tcap_tid,
822                                     &parameter_tvb);
823
824 if (parameter_tvb){
825         len = tvb_length_remaining(parameter_tvb, 0);
826         switch(len) {
827         case 1:
828                 gp_tcapsrt_info->dst_tid=tvb_get_guint8(parameter_tvb, 0);
829                 break;
830         case 2:
831                 gp_tcapsrt_info->dst_tid=tvb_get_ntohs(parameter_tvb, 0);
832                 break;
833         case 4:
834                 gp_tcapsrt_info->dst_tid=tvb_get_ntohl(parameter_tvb, 0);
835                 break;
836         default:
837                 gp_tcapsrt_info->dst_tid=0;
838                 break;
839         }
840
841         if ((len)&&(check_col(actx->pinfo->cinfo, COL_INFO))){
842                 col_append_str(actx->pinfo->cinfo, COL_INFO, "dtid(");
843                 for(i=0;i<len;i++)
844                         col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%02x",tvb_get_guint8(parameter_tvb,i));
845                 col_append_str(actx->pinfo->cinfo, COL_INFO, ") ");
846            }
847 }
848
849
850   return offset;
851 }
852
853
854 static const ber_sequence_t End_sequence[] = {
855   { &hf_tcap_dtid           , BER_CLASS_APP, 9, BER_FLAGS_NOOWNTAG, dissect_tcap_DestTransactionID },
856   { &hf_tcap_dialoguePortion, BER_CLASS_APP, 11, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_tcap_DialoguePortion },
857   { &hf_tcap_components     , BER_CLASS_APP, 12, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_tcap_ComponentPortion },
858   { NULL, 0, 0, 0, NULL }
859 };
860
861 static int
862 dissect_tcap_End(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
863 #line 206 "tcap.cnf"
864 gp_tcapsrt_info->ope=TC_END;
865
866 if (check_col(actx->pinfo->cinfo, COL_INFO))
867                 col_set_str(actx->pinfo->cinfo, COL_INFO, "End ");
868
869   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
870                                    End_sequence, hf_index, ett_tcap_End);
871
872   return offset;
873 }
874
875
876 static const ber_sequence_t Continue_sequence[] = {
877   { &hf_tcap_otid           , BER_CLASS_APP, 8, BER_FLAGS_NOOWNTAG, dissect_tcap_OrigTransactionID },
878   { &hf_tcap_dtid           , BER_CLASS_APP, 9, BER_FLAGS_NOOWNTAG, dissect_tcap_DestTransactionID },
879   { &hf_tcap_dialoguePortion, BER_CLASS_APP, 11, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_tcap_DialoguePortion },
880   { &hf_tcap_components     , BER_CLASS_APP, 12, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_tcap_ComponentPortion },
881   { NULL, 0, 0, 0, NULL }
882 };
883
884 static int
885 dissect_tcap_Continue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
886 #line 214 "tcap.cnf"
887 gp_tcapsrt_info->ope=TC_CONT;
888
889 if (check_col(actx->pinfo->cinfo, COL_INFO))
890                 col_set_str(actx->pinfo->cinfo, COL_INFO, "Continue ");
891
892   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
893                                    Continue_sequence, hf_index, ett_tcap_Continue);
894
895   return offset;
896 }
897
898
899 static const value_string tcap_P_AbortCause_U_vals[] = {
900   {   0, "unrecognizedMessageType" },
901   {   1, "unrecognizedTransactionID" },
902   {   2, "badlyFormattedTransactionPortion" },
903   {   3, "incorrectTransactionPortion" },
904   {   4, "resourceLimitation" },
905   { 0, NULL }
906 };
907
908
909 static int
910 dissect_tcap_P_AbortCause_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
911   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
912                                                 NULL);
913
914   return offset;
915 }
916
917
918
919 static int
920 dissect_tcap_P_AbortCause(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
921   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
922                                       hf_index, BER_CLASS_APP, 10, TRUE, dissect_tcap_P_AbortCause_U);
923
924   return offset;
925 }
926
927
928 static const value_string tcap_Reason_vals[] = {
929   {  10, "p-abortCause" },
930   {  11, "u-abortCause" },
931   { 0, NULL }
932 };
933
934 static const ber_choice_t Reason_choice[] = {
935   {  10, &hf_tcap_p_abortCause   , BER_CLASS_APP, 10, BER_FLAGS_NOOWNTAG, dissect_tcap_P_AbortCause },
936   {  11, &hf_tcap_u_abortCause   , BER_CLASS_APP, 11, BER_FLAGS_NOOWNTAG, dissect_tcap_DialoguePortion },
937   { 0, NULL, 0, 0, 0, NULL }
938 };
939
940 static int
941 dissect_tcap_Reason(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
942   offset = dissect_ber_choice(actx, tree, tvb, offset,
943                                  Reason_choice, hf_index, ett_tcap_Reason,
944                                  NULL);
945
946   return offset;
947 }
948
949
950 static const ber_sequence_t Abort_sequence[] = {
951   { &hf_tcap_dtid           , BER_CLASS_APP, 9, BER_FLAGS_NOOWNTAG, dissect_tcap_DestTransactionID },
952   { &hf_tcap_reason         , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_tcap_Reason },
953   { NULL, 0, 0, 0, NULL }
954 };
955
956 static int
957 dissect_tcap_Abort(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
958 #line 222 "tcap.cnf"
959 gp_tcapsrt_info->ope=TC_ABORT;
960
961 if (check_col(actx->pinfo->cinfo, COL_INFO))
962                 col_set_str(actx->pinfo->cinfo, COL_INFO, "Abort ");
963
964   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
965                                    Abort_sequence, hf_index, ett_tcap_Abort);
966
967   return offset;
968 }
969
970
971 static const value_string tcap_TCMessage_vals[] = {
972   {   1, "unidirectional" },
973   {   2, "begin" },
974   {   4, "end" },
975   {   5, "continue" },
976   {   7, "abort" },
977   { 0, NULL }
978 };
979
980 static const ber_choice_t TCMessage_choice[] = {
981   {   1, &hf_tcap_unidirectional , BER_CLASS_APP, 1, BER_FLAGS_IMPLTAG, dissect_tcap_Unidirectional },
982   {   2, &hf_tcap_begin          , BER_CLASS_APP, 2, BER_FLAGS_IMPLTAG, dissect_tcap_Begin },
983   {   4, &hf_tcap_end            , BER_CLASS_APP, 4, BER_FLAGS_IMPLTAG, dissect_tcap_End },
984   {   5, &hf_tcap_continue       , BER_CLASS_APP, 5, BER_FLAGS_IMPLTAG, dissect_tcap_Continue },
985   {   7, &hf_tcap_abort          , BER_CLASS_APP, 7, BER_FLAGS_IMPLTAG, dissect_tcap_Abort },
986   { 0, NULL, 0, 0, 0, NULL }
987 };
988
989 static int
990 dissect_tcap_TCMessage(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
991   offset = dissect_ber_choice(actx, tree, tvb, offset,
992                                  TCMessage_choice, hf_index, ett_tcap_TCMessage,
993                                  NULL);
994
995   return offset;
996 }
997
998
999 static const value_string tcap_ERROR_vals[] = {
1000   {   0, "localValue" },
1001   {   1, "globalValue" },
1002   { 0, NULL }
1003 };
1004
1005 static const ber_choice_t ERROR_choice[] = {
1006   {   0, &hf_tcap_localValue     , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_tcap_INTEGER },
1007   {   1, &hf_tcap_globalValue    , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_tcap_OBJECT_IDENTIFIER },
1008   { 0, NULL, 0, 0, 0, NULL }
1009 };
1010
1011 static int
1012 dissect_tcap_ERROR(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1013   offset = dissect_ber_choice(actx, tree, tvb, offset,
1014                                  ERROR_choice, hf_index, ett_tcap_ERROR,
1015                                  NULL);
1016
1017   return offset;
1018 }
1019
1020
1021 static const asn_namedbit AUDT_protocol_version_bits[] = {
1022   {  0, &hf_tcap_AUDT_protocol_version_version1, -1, -1, "version1", NULL },
1023   { 0, NULL, 0, 0, NULL, NULL }
1024 };
1025
1026 static int
1027 dissect_tcap_AUDT_protocol_version(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1028   offset = dissect_ber_bitstring(implicit_tag, actx, tree, tvb, offset,
1029                                     AUDT_protocol_version_bits, hf_index, ett_tcap_AUDT_protocol_version,
1030                                     NULL);
1031
1032   return offset;
1033 }
1034
1035
1036
1037 static int
1038 dissect_tcap_AUDT_application_context_name(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1039 #line 102 "tcap.cnf"
1040   offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &cur_oid);
1041
1042         tcap_private.oid= (void*) cur_oid;
1043         tcap_private.acv=TRUE;
1044
1045
1046   return offset;
1047 }
1048
1049
1050
1051 static int
1052 dissect_tcap_EXTERNAL(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1053   offset = dissect_ber_external_type(implicit_tag, tree, tvb, offset, actx, hf_index, NULL);
1054
1055   return offset;
1056 }
1057
1058
1059 static const ber_sequence_t AUDT_user_information_sequence_of[1] = {
1060   { &hf_tcap_audt_user_information_item, BER_CLASS_UNI, BER_UNI_TAG_EXTERNAL, BER_FLAGS_NOOWNTAG, dissect_tcap_EXTERNAL },
1061 };
1062
1063 static int
1064 dissect_tcap_AUDT_user_information(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1065   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
1066                                       AUDT_user_information_sequence_of, hf_index, ett_tcap_AUDT_user_information);
1067
1068   return offset;
1069 }
1070
1071
1072 static const ber_sequence_t AUDT_apdu_U_sequence[] = {
1073   { &hf_tcap_audt_protocol_version, BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_tcap_AUDT_protocol_version },
1074   { &hf_tcap_audt_application_context_name, BER_CLASS_CON, 1, 0, dissect_tcap_AUDT_application_context_name },
1075   { &hf_tcap_audt_user_information, BER_CLASS_CON, 30, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_tcap_AUDT_user_information },
1076   { NULL, 0, 0, 0, NULL }
1077 };
1078
1079 static int
1080 dissect_tcap_AUDT_apdu_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1081   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1082                                    AUDT_apdu_U_sequence, hf_index, ett_tcap_AUDT_apdu_U);
1083
1084   return offset;
1085 }
1086
1087
1088
1089 static int
1090 dissect_tcap_AUDT_apdu(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1091   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
1092                                       hf_index, BER_CLASS_APP, 0, TRUE, dissect_tcap_AUDT_apdu_U);
1093
1094   return offset;
1095 }
1096
1097
1098 const value_string tcap_UniDialoguePDU_vals[] = {
1099   {   0, "unidialoguePDU" },
1100   { 0, NULL }
1101 };
1102
1103 static const ber_choice_t UniDialoguePDU_choice[] = {
1104   {   0, &hf_tcap_unidialoguePDU , BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_tcap_AUDT_apdu },
1105   { 0, NULL, 0, 0, 0, NULL }
1106 };
1107
1108 int
1109 dissect_tcap_UniDialoguePDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1110   offset = dissect_ber_choice(actx, tree, tvb, offset,
1111                                  UniDialoguePDU_choice, hf_index, ett_tcap_UniDialoguePDU,
1112                                  NULL);
1113
1114   return offset;
1115 }
1116
1117
1118 static const asn_namedbit AARQ_protocol_version_bits[] = {
1119   {  0, &hf_tcap_AARQ_protocol_version_version1, -1, -1, "version1", NULL },
1120   { 0, NULL, 0, 0, NULL, NULL }
1121 };
1122
1123 static int
1124 dissect_tcap_AARQ_protocol_version(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1125   offset = dissect_ber_bitstring(implicit_tag, actx, tree, tvb, offset,
1126                                     AARQ_protocol_version_bits, hf_index, ett_tcap_AARQ_protocol_version,
1127                                     NULL);
1128
1129   return offset;
1130 }
1131
1132
1133
1134 static int
1135 dissect_tcap_AARQ_application_context_name(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1136 #line 107 "tcap.cnf"
1137   offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &cur_oid);
1138
1139         tcap_private.oid= (void*) cur_oid;
1140         tcap_private.acv=TRUE;
1141
1142
1143   return offset;
1144 }
1145
1146
1147 static const ber_sequence_t AARQ_user_information_sequence_of[1] = {
1148   { &hf_tcap_aarq_user_information_item, BER_CLASS_UNI, BER_UNI_TAG_EXTERNAL, BER_FLAGS_NOOWNTAG, dissect_tcap_EXTERNAL },
1149 };
1150
1151 static int
1152 dissect_tcap_AARQ_user_information(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1153   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
1154                                       AARQ_user_information_sequence_of, hf_index, ett_tcap_AARQ_user_information);
1155
1156   return offset;
1157 }
1158
1159
1160 static const ber_sequence_t AARQ_apdu_U_sequence[] = {
1161   { &hf_tcap_aarq_protocol_version, BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_tcap_AARQ_protocol_version },
1162   { &hf_tcap_aarq_application_context_name, BER_CLASS_CON, 1, 0, dissect_tcap_AARQ_application_context_name },
1163   { &hf_tcap_aarq_user_information, BER_CLASS_CON, 30, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_tcap_AARQ_user_information },
1164   { NULL, 0, 0, 0, NULL }
1165 };
1166
1167 static int
1168 dissect_tcap_AARQ_apdu_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1169   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1170                                    AARQ_apdu_U_sequence, hf_index, ett_tcap_AARQ_apdu_U);
1171
1172   return offset;
1173 }
1174
1175
1176
1177 static int
1178 dissect_tcap_AARQ_apdu(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1179   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
1180                                       hf_index, BER_CLASS_APP, 0, TRUE, dissect_tcap_AARQ_apdu_U);
1181
1182   return offset;
1183 }
1184
1185
1186 static const asn_namedbit AARE_protocol_version_bits[] = {
1187   {  0, &hf_tcap_AARE_protocol_version_version1, -1, -1, "version1", NULL },
1188   { 0, NULL, 0, 0, NULL, NULL }
1189 };
1190
1191 static int
1192 dissect_tcap_AARE_protocol_version(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1193   offset = dissect_ber_bitstring(implicit_tag, actx, tree, tvb, offset,
1194                                     AARE_protocol_version_bits, hf_index, ett_tcap_AARE_protocol_version,
1195                                     NULL);
1196
1197   return offset;
1198 }
1199
1200
1201
1202 static int
1203 dissect_tcap_AARE_application_context_name(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1204 #line 112 "tcap.cnf"
1205   offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &cur_oid);
1206
1207         tcap_private.oid= (void*) cur_oid;
1208         tcap_private.acv=TRUE;
1209
1210
1211   return offset;
1212 }
1213
1214
1215 static const value_string tcap_Associate_result_vals[] = {
1216   {   0, "accepted" },
1217   {   1, "reject-permanent" },
1218   { 0, NULL }
1219 };
1220
1221
1222 static int
1223 dissect_tcap_Associate_result(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1224   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1225                                                 NULL);
1226
1227   return offset;
1228 }
1229
1230
1231 static const value_string tcap_T_dialogue_service_user_vals[] = {
1232   {   0, "null" },
1233   {   1, "no-reason-given" },
1234   {   2, "application-context-name-not-supported" },
1235   { 0, NULL }
1236 };
1237
1238
1239 static int
1240 dissect_tcap_T_dialogue_service_user(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1241   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1242                                                 NULL);
1243
1244   return offset;
1245 }
1246
1247
1248 static const value_string tcap_T_dialogue_service_provider_vals[] = {
1249   {   0, "null" },
1250   {   1, "no-reason-given" },
1251   {   2, "no-common-dialogue-portion" },
1252   { 0, NULL }
1253 };
1254
1255
1256 static int
1257 dissect_tcap_T_dialogue_service_provider(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1258   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1259                                                 NULL);
1260
1261   return offset;
1262 }
1263
1264
1265 static const value_string tcap_Associate_source_diagnostic_vals[] = {
1266   {   1, "dialogue-service-user" },
1267   {   2, "dialogue-service-provider" },
1268   { 0, NULL }
1269 };
1270
1271 static const ber_choice_t Associate_source_diagnostic_choice[] = {
1272   {   1, &hf_tcap_dialogue_service_user, BER_CLASS_CON, 1, 0, dissect_tcap_T_dialogue_service_user },
1273   {   2, &hf_tcap_dialogue_service_provider, BER_CLASS_CON, 2, 0, dissect_tcap_T_dialogue_service_provider },
1274   { 0, NULL, 0, 0, 0, NULL }
1275 };
1276
1277 static int
1278 dissect_tcap_Associate_source_diagnostic(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1279   offset = dissect_ber_choice(actx, tree, tvb, offset,
1280                                  Associate_source_diagnostic_choice, hf_index, ett_tcap_Associate_source_diagnostic,
1281                                  NULL);
1282
1283   return offset;
1284 }
1285
1286
1287 static const ber_sequence_t AARE_user_information_sequence_of[1] = {
1288   { &hf_tcap_aare_user_information_item, BER_CLASS_UNI, BER_UNI_TAG_EXTERNAL, BER_FLAGS_NOOWNTAG, dissect_tcap_EXTERNAL },
1289 };
1290
1291 static int
1292 dissect_tcap_AARE_user_information(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1293   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
1294                                       AARE_user_information_sequence_of, hf_index, ett_tcap_AARE_user_information);
1295
1296   return offset;
1297 }
1298
1299
1300 static const ber_sequence_t AARE_apdu_U_sequence[] = {
1301   { &hf_tcap_aare_protocol_version, BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_tcap_AARE_protocol_version },
1302   { &hf_tcap_aare_application_context_name, BER_CLASS_CON, 1, 0, dissect_tcap_AARE_application_context_name },
1303   { &hf_tcap_result         , BER_CLASS_CON, 2, 0, dissect_tcap_Associate_result },
1304   { &hf_tcap_result_source_diagnostic, BER_CLASS_CON, 3, BER_FLAGS_NOTCHKTAG, dissect_tcap_Associate_source_diagnostic },
1305   { &hf_tcap_aare_user_information, BER_CLASS_CON, 30, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_tcap_AARE_user_information },
1306   { NULL, 0, 0, 0, NULL }
1307 };
1308
1309 static int
1310 dissect_tcap_AARE_apdu_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1311   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1312                                    AARE_apdu_U_sequence, hf_index, ett_tcap_AARE_apdu_U);
1313
1314   return offset;
1315 }
1316
1317
1318
1319 static int
1320 dissect_tcap_AARE_apdu(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1321   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
1322                                       hf_index, BER_CLASS_APP, 1, TRUE, dissect_tcap_AARE_apdu_U);
1323
1324   return offset;
1325 }
1326
1327
1328 static const value_string tcap_ABRT_source_vals[] = {
1329   {   0, "dialogue-service-user" },
1330   {   1, "dialogue-service-provider" },
1331   { 0, NULL }
1332 };
1333
1334
1335 static int
1336 dissect_tcap_ABRT_source(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1337   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1338                                                 NULL);
1339
1340   return offset;
1341 }
1342
1343
1344 static const ber_sequence_t ABRT_user_information_sequence_of[1] = {
1345   { &hf_tcap_abrt_user_information_item, BER_CLASS_UNI, BER_UNI_TAG_EXTERNAL, BER_FLAGS_NOOWNTAG, dissect_tcap_EXTERNAL },
1346 };
1347
1348 static int
1349 dissect_tcap_ABRT_user_information(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1350   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
1351                                       ABRT_user_information_sequence_of, hf_index, ett_tcap_ABRT_user_information);
1352
1353   return offset;
1354 }
1355
1356
1357 static const ber_sequence_t ABRT_apdu_U_sequence[] = {
1358   { &hf_tcap_abort_source   , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_tcap_ABRT_source },
1359   { &hf_tcap_abrt_user_information, BER_CLASS_CON, 30, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_tcap_ABRT_user_information },
1360   { NULL, 0, 0, 0, NULL }
1361 };
1362
1363 static int
1364 dissect_tcap_ABRT_apdu_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1365   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1366                                    ABRT_apdu_U_sequence, hf_index, ett_tcap_ABRT_apdu_U);
1367
1368   return offset;
1369 }
1370
1371
1372
1373 static int
1374 dissect_tcap_ABRT_apdu(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1375   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
1376                                       hf_index, BER_CLASS_APP, 4, TRUE, dissect_tcap_ABRT_apdu_U);
1377
1378   return offset;
1379 }
1380
1381
1382 const value_string tcap_DialoguePDU_vals[] = {
1383   {   0, "dialogueRequest" },
1384   {   1, "dialogueResponse" },
1385   {   4, "dialogueAbort" },
1386   { 0, NULL }
1387 };
1388
1389 static const ber_choice_t DialoguePDU_choice[] = {
1390   {   0, &hf_tcap_dialogueRequest, BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_tcap_AARQ_apdu },
1391   {   1, &hf_tcap_dialogueResponse, BER_CLASS_APP, 1, BER_FLAGS_NOOWNTAG, dissect_tcap_AARE_apdu },
1392   {   4, &hf_tcap_dialogueAbort  , BER_CLASS_APP, 4, BER_FLAGS_NOOWNTAG, dissect_tcap_ABRT_apdu },
1393   { 0, NULL, 0, 0, 0, NULL }
1394 };
1395
1396 int
1397 dissect_tcap_DialoguePDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1398   offset = dissect_ber_choice(actx, tree, tvb, offset,
1399                                  DialoguePDU_choice, hf_index, ett_tcap_DialoguePDU,
1400                                  NULL);
1401
1402   return offset;
1403 }
1404
1405 /*--- PDUs ---*/
1406
1407 static void dissect_UniDialoguePDU_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1408   asn1_ctx_t asn1_ctx;
1409   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1410   dissect_tcap_UniDialoguePDU(FALSE, tvb, 0, &asn1_ctx, tree, hf_tcap_UniDialoguePDU_PDU);
1411 }
1412 static void dissect_DialoguePDU_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1413   asn1_ctx_t asn1_ctx;
1414   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1415   dissect_tcap_DialoguePDU(FALSE, tvb, 0, &asn1_ctx, tree, hf_tcap_DialoguePDU_PDU);
1416 }
1417
1418
1419 /*--- End of included file: packet-tcap-fn.c ---*/
1420 #line 141 "packet-tcap-template.c"
1421
1422
1423
1424 const value_string tcap_component_type_str[] = {
1425     { TCAP_COMP_INVOKE,         "Invoke" },
1426     { TCAP_COMP_RRL,            "Return Result(L)" },
1427     { TCAP_COMP_RE,                     "Return Error" },
1428     { TCAP_COMP_REJECT,         "Reject" },
1429     { TCAP_COMP_RRN,            "Return Result(NL)" },
1430     { 0,                        NULL } };
1431
1432
1433 static void
1434 dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
1435 {
1436     proto_item          *item=NULL;
1437     proto_tree          *tree=NULL;
1438
1439     struct tcaphash_context_t * p_tcap_context;
1440     dissector_handle_t subdissector_handle;
1441         asn1_ctx_t asn1_ctx;
1442         gint8 class;
1443         gboolean pc;
1444         gint tag;
1445
1446         /* Check if ANSI TCAP and call the ANSI TCAP dissector if that's the case 
1447          * PackageType ::= CHOICE { unidirectional                      [PRIVATE 1] IMPLICIT UniTransactionPDU,
1448          *                                               queryWithPerm                          [PRIVATE 2] IMPLICIT TransactionPDU,
1449          *                                               queryWithoutPerm                       [PRIVATE 3] IMPLICIT TransactionPDU,
1450          *                                               response                                       [PRIVATE 4] IMPLICIT TransactionPDU,
1451          *                                               conversationWithPerm           [PRIVATE 5] IMPLICIT TransactionPDU,
1452          *                                               conversationWithoutPerm        [PRIVATE 6] IMPLICIT TransactionPDU,
1453          *                                               abort                                          [PRIVATE 22] IMPLICIT Abort 
1454          *                                               }
1455          *      
1456          * 
1457          */
1458         get_ber_identifier(tvb, 0, &class, &pc, &tag);
1459
1460         if(class == BER_CLASS_PRI){
1461                 switch(tag){
1462                 case 1:
1463                 case 2:
1464                 case 3:
1465                 case 4:
1466                 case 5:
1467                 case 6:
1468                 case 22:
1469                         call_dissector(ansi_tcap_handle, tvb, pinfo, parent_tree);
1470                         return;
1471                         break;
1472                 default:
1473                         return;
1474                 }
1475         }
1476
1477         /* ITU TCAP */
1478         asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1479
1480     tcap_top_tree = parent_tree;
1481     tcap_stat_tree = NULL;
1482
1483     col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCAP");
1484
1485     /* create display subtree for the protocol */
1486     if(parent_tree){
1487       item = proto_tree_add_item(parent_tree, proto_tcap, tvb, 0, -1, FALSE);
1488       tree = proto_item_add_subtree(item, ett_tcap);
1489       tcap_stat_tree=tree;
1490     }
1491     cur_oid = NULL;
1492     tcapext_oid = NULL;
1493     raz_tcap_private(&tcap_private);
1494
1495     pinfo->private_data = &tcap_private;
1496     gp_tcapsrt_info=tcapsrt_razinfo();
1497     tcap_subdissector_used=FALSE;
1498     gp_tcap_context=NULL;
1499     dissect_tcap_TCMessage(FALSE, tvb, 0, &asn1_ctx, tree, -1);
1500
1501     if (gtcap_HandleSRT && !tcap_subdissector_used ) {
1502       p_tcap_context=tcapsrt_call_matching(tvb, pinfo, tcap_stat_tree, gp_tcapsrt_info);
1503       tcap_private.context=p_tcap_context;
1504
1505                 /* If the current message is TCAP only,
1506                  * save the Application Context Name for the next messages
1507                  */
1508                 if ( p_tcap_context && cur_oid && !p_tcap_context->oid_present ) {
1509                         /* Save the application context and the sub dissector */
1510                         g_strlcpy(p_tcap_context->oid,cur_oid, LENGTH_OID);
1511                         p_tcap_context->oid_present=TRUE;
1512                         if ( (subdissector_handle = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) {
1513                                 p_tcap_context->subdissector_handle=subdissector_handle;
1514                                 p_tcap_context->subdissector_present=TRUE;
1515                         }
1516                 }
1517                 if (gtcap_HandleSRT && p_tcap_context && p_tcap_context->callback) {
1518                         /* Callback fonction for the upper layer */
1519                         (p_tcap_context->callback)(tvb, pinfo, tcap_stat_tree, p_tcap_context);
1520                 }
1521         }
1522 }
1523
1524 void
1525 proto_reg_handoff_tcap(void)
1526 {
1527
1528     data_handle = find_dissector("data");
1529     ansi_tcap_handle = find_dissector("ansi_tcap");
1530     ber_oid_dissector_table = find_dissector_table("ber.oid");
1531
1532
1533 /*--- Included file: packet-tcap-dis-tab.c ---*/
1534 #line 1 "packet-tcap-dis-tab.c"
1535   register_ber_oid_dissector("0.0.17.773.1.1.1", dissect_DialoguePDU_PDU, proto_tcap, "id-as-dialogue");
1536   register_ber_oid_dissector("0.0.17.773.1.2.1", dissect_UniDialoguePDU_PDU, proto_tcap, "id-as-uniDialogue");
1537
1538
1539 /*--- End of included file: packet-tcap-dis-tab.c ---*/
1540 #line 253 "packet-tcap-template.c"
1541 }
1542
1543 static void init_tcap(void);
1544
1545 void
1546 proto_register_tcap(void)
1547 {
1548
1549 /* Setup list of header fields  See Section 1.6.1 for details*/
1550     static hf_register_info hf[] = {
1551         { &hf_tcap_tag,
1552                 { "Tag",           "tcap.msgtype",
1553                 FT_UINT8, BASE_HEX, NULL, 0,
1554                 NULL, HFILL }
1555         },
1556         { &hf_tcap_length,
1557                 { "Length", "tcap.len",
1558                 FT_UINT8, BASE_DEC, NULL, 0,
1559                 NULL, HFILL }
1560         },
1561         { &hf_tcap_data,
1562                 { "Data", "tcap.data",
1563                 FT_BYTES, BASE_NONE, NULL, 0,
1564                 NULL, HFILL }
1565         },
1566                 { &hf_tcap_tid,
1567                 { "Transaction Id", "tcap.tid",
1568                 FT_BYTES, BASE_NONE, NULL, 0,
1569                 NULL, HFILL }
1570         },
1571         /* Tcap Service Response Time */
1572         { &hf_tcapsrt_SessionId,
1573           { "Session Id",
1574             "tcap.srt.session_id",
1575             FT_UINT32, BASE_DEC, NULL, 0x0,
1576             NULL, HFILL }
1577         },
1578         { &hf_tcapsrt_BeginSession,
1579           { "Begin Session",
1580             "tcap.srt.begin",
1581             FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1582             "SRT Begin of Session", HFILL }
1583         },
1584         { &hf_tcapsrt_EndSession,
1585           { "End Session",
1586             "tcap.srt.end",
1587             FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1588             "SRT End of Session", HFILL }
1589         },
1590         { &hf_tcapsrt_SessionTime,
1591           { "Session duration",
1592             "tcap.srt.sessiontime",
1593             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
1594             "Duration of the TCAP session", HFILL }
1595         },
1596         { &hf_tcapsrt_Duplicate,
1597           { "Session Duplicate",
1598             "tcap.srt.duplicate",
1599             FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1600             "SRT Duplicated with Session", HFILL }
1601         },
1602
1603 /*--- Included file: packet-tcap-hfarr.c ---*/
1604 #line 1 "packet-tcap-hfarr.c"
1605     { &hf_tcap_UniDialoguePDU_PDU,
1606       { "UniDialoguePDU", "tcap.UniDialoguePDU",
1607         FT_UINT32, BASE_DEC, VALS(tcap_UniDialoguePDU_vals), 0,
1608         "tcap.UniDialoguePDU", HFILL }},
1609     { &hf_tcap_DialoguePDU_PDU,
1610       { "DialoguePDU", "tcap.DialoguePDU",
1611         FT_UINT32, BASE_DEC, VALS(tcap_DialoguePDU_vals), 0,
1612         "tcap.DialoguePDU", HFILL }},
1613     { &hf_tcap_oid,
1614       { "oid", "tcap.oid",
1615         FT_OID, BASE_NONE, NULL, 0,
1616         "tcap.OBJECT_IDENTIFIER", HFILL }},
1617     { &hf_tcap_dialog,
1618       { "dialog", "tcap.dialog",
1619         FT_BYTES, BASE_NONE, NULL, 0,
1620         "tcap.Dialog1", HFILL }},
1621     { &hf_tcap_unidirectional,
1622       { "unidirectional", "tcap.unidirectional",
1623         FT_NONE, BASE_NONE, NULL, 0,
1624         "tcap.Unidirectional", HFILL }},
1625     { &hf_tcap_begin,
1626       { "begin", "tcap.begin",
1627         FT_NONE, BASE_NONE, NULL, 0,
1628         "tcap.Begin", HFILL }},
1629     { &hf_tcap_end,
1630       { "end", "tcap.end",
1631         FT_NONE, BASE_NONE, NULL, 0,
1632         "tcap.End", HFILL }},
1633     { &hf_tcap_continue,
1634       { "continue", "tcap.continue",
1635         FT_NONE, BASE_NONE, NULL, 0,
1636         "tcap.Continue", HFILL }},
1637     { &hf_tcap_abort,
1638       { "abort", "tcap.abort",
1639         FT_NONE, BASE_NONE, NULL, 0,
1640         "tcap.Abort", HFILL }},
1641     { &hf_tcap_dialoguePortion,
1642       { "dialoguePortion", "tcap.dialoguePortion",
1643         FT_BYTES, BASE_NONE, NULL, 0,
1644         "tcap.DialoguePortion", HFILL }},
1645     { &hf_tcap_components,
1646       { "components", "tcap.components",
1647         FT_UINT32, BASE_DEC, NULL, 0,
1648         "tcap.ComponentPortion", HFILL }},
1649     { &hf_tcap_otid,
1650       { "otid", "tcap.otid",
1651         FT_BYTES, BASE_NONE, NULL, 0,
1652         "tcap.OrigTransactionID", HFILL }},
1653     { &hf_tcap_dtid,
1654       { "dtid", "tcap.dtid",
1655         FT_BYTES, BASE_NONE, NULL, 0,
1656         "tcap.DestTransactionID", HFILL }},
1657     { &hf_tcap_reason,
1658       { "reason", "tcap.reason",
1659         FT_UINT32, BASE_DEC, VALS(tcap_Reason_vals), 0,
1660         "tcap.Reason", HFILL }},
1661     { &hf_tcap_p_abortCause,
1662       { "p-abortCause", "tcap.p_abortCause",
1663         FT_UINT32, BASE_DEC, VALS(tcap_P_AbortCause_U_vals), 0,
1664         "tcap.P_AbortCause", HFILL }},
1665     { &hf_tcap_u_abortCause,
1666       { "u-abortCause", "tcap.u_abortCause",
1667         FT_BYTES, BASE_NONE, NULL, 0,
1668         "tcap.DialoguePortion", HFILL }},
1669     { &hf_tcap__untag_item,
1670       { "Component", "tcap.Component",
1671         FT_UINT32, BASE_DEC, VALS(tcap_Component_vals), 0,
1672         "tcap.Component", HFILL }},
1673     { &hf_tcap_invoke,
1674       { "invoke", "tcap.invoke",
1675         FT_NONE, BASE_NONE, NULL, 0,
1676         "tcap.Invoke", HFILL }},
1677     { &hf_tcap_returnResultLast,
1678       { "returnResultLast", "tcap.returnResultLast",
1679         FT_NONE, BASE_NONE, NULL, 0,
1680         "tcap.ReturnResult", HFILL }},
1681     { &hf_tcap_returnError,
1682       { "returnError", "tcap.returnError",
1683         FT_NONE, BASE_NONE, NULL, 0,
1684         "tcap.ReturnError", HFILL }},
1685     { &hf_tcap_reject,
1686       { "reject", "tcap.reject",
1687         FT_NONE, BASE_NONE, NULL, 0,
1688         "tcap.Reject", HFILL }},
1689     { &hf_tcap_returnResultNotLast,
1690       { "returnResultNotLast", "tcap.returnResultNotLast",
1691         FT_NONE, BASE_NONE, NULL, 0,
1692         "tcap.ReturnResult", HFILL }},
1693     { &hf_tcap_invokeID,
1694       { "invokeID", "tcap.invokeID",
1695         FT_INT32, BASE_DEC, NULL, 0,
1696         "tcap.InvokeIdType", HFILL }},
1697     { &hf_tcap_linkedID,
1698       { "linkedID", "tcap.linkedID",
1699         FT_INT32, BASE_DEC, NULL, 0,
1700         "tcap.InvokeIdType", HFILL }},
1701     { &hf_tcap_opCode,
1702       { "opCode", "tcap.opCode",
1703         FT_UINT32, BASE_DEC, VALS(tcap_OPERATION_vals), 0,
1704         "tcap.OPERATION", HFILL }},
1705     { &hf_tcap_parameter,
1706       { "parameter", "tcap.parameter",
1707         FT_NONE, BASE_NONE, NULL, 0,
1708         "tcap.Parameter", HFILL }},
1709     { &hf_tcap_resultretres,
1710       { "resultretres", "tcap.resultretres",
1711         FT_NONE, BASE_NONE, NULL, 0,
1712         "tcap.T_resultretres", HFILL }},
1713     { &hf_tcap_errorCode,
1714       { "errorCode", "tcap.errorCode",
1715         FT_UINT32, BASE_DEC, VALS(tcap_ErrorCode_vals), 0,
1716         "tcap.ErrorCode", HFILL }},
1717     { &hf_tcap_invokeIDRej,
1718       { "invokeIDRej", "tcap.invokeIDRej",
1719         FT_UINT32, BASE_DEC, VALS(tcap_T_invokeIDRej_vals), 0,
1720         "tcap.T_invokeIDRej", HFILL }},
1721     { &hf_tcap_derivable,
1722       { "derivable", "tcap.derivable",
1723         FT_INT32, BASE_DEC, NULL, 0,
1724         "tcap.InvokeIdType", HFILL }},
1725     { &hf_tcap_not_derivable,
1726       { "not-derivable", "tcap.not_derivable",
1727         FT_NONE, BASE_NONE, NULL, 0,
1728         "tcap.NULL", HFILL }},
1729     { &hf_tcap_problem,
1730       { "problem", "tcap.problem",
1731         FT_UINT32, BASE_DEC, VALS(tcap_T_problem_vals), 0,
1732         "tcap.T_problem", HFILL }},
1733     { &hf_tcap_generalProblem,
1734       { "generalProblem", "tcap.generalProblem",
1735         FT_INT32, BASE_DEC, VALS(tcap_GeneralProblem_vals), 0,
1736         "tcap.GeneralProblem", HFILL }},
1737     { &hf_tcap_invokeProblem,
1738       { "invokeProblem", "tcap.invokeProblem",
1739         FT_INT32, BASE_DEC, VALS(tcap_InvokeProblem_vals), 0,
1740         "tcap.InvokeProblem", HFILL }},
1741     { &hf_tcap_returnResultProblem,
1742       { "returnResultProblem", "tcap.returnResultProblem",
1743         FT_INT32, BASE_DEC, VALS(tcap_ReturnResultProblem_vals), 0,
1744         "tcap.ReturnResultProblem", HFILL }},
1745     { &hf_tcap_returnErrorProblem,
1746       { "returnErrorProblem", "tcap.returnErrorProblem",
1747         FT_INT32, BASE_DEC, VALS(tcap_ReturnErrorProblem_vals), 0,
1748         "tcap.ReturnErrorProblem", HFILL }},
1749     { &hf_tcap_localValue,
1750       { "localValue", "tcap.localValue",
1751         FT_INT32, BASE_DEC, NULL, 0,
1752         "tcap.INTEGER", HFILL }},
1753     { &hf_tcap_globalValue,
1754       { "globalValue", "tcap.globalValue",
1755         FT_OID, BASE_NONE, NULL, 0,
1756         "tcap.OBJECT_IDENTIFIER", HFILL }},
1757     { &hf_tcap_nationaler,
1758       { "nationaler", "tcap.nationaler",
1759         FT_INT32, BASE_DEC, NULL, 0,
1760         "tcap.INTEGER_M32768_32767", HFILL }},
1761     { &hf_tcap_privateer,
1762       { "privateer", "tcap.privateer",
1763         FT_INT32, BASE_DEC, NULL, 0,
1764         "tcap.INTEGER", HFILL }},
1765     { &hf_tcap_unidialoguePDU,
1766       { "unidialoguePDU", "tcap.unidialoguePDU",
1767         FT_NONE, BASE_NONE, NULL, 0,
1768         "tcap.AUDT_apdu", HFILL }},
1769     { &hf_tcap_audt_protocol_version,
1770       { "protocol-version", "tcap.protocol_version",
1771         FT_BYTES, BASE_NONE, NULL, 0,
1772         "tcap.AUDT_protocol_version", HFILL }},
1773     { &hf_tcap_audt_application_context_name,
1774       { "application-context-name", "tcap.application_context_name",
1775         FT_OID, BASE_NONE, NULL, 0,
1776         "tcap.AUDT_application_context_name", HFILL }},
1777     { &hf_tcap_audt_user_information,
1778       { "user-information", "tcap.user_information",
1779         FT_UINT32, BASE_DEC, NULL, 0,
1780         "tcap.AUDT_user_information", HFILL }},
1781     { &hf_tcap_audt_user_information_item,
1782       { "user-information item", "tcap.user_information_item",
1783         FT_NONE, BASE_NONE, NULL, 0,
1784         "tcap.EXTERNAL", HFILL }},
1785     { &hf_tcap_dialogueRequest,
1786       { "dialogueRequest", "tcap.dialogueRequest",
1787         FT_NONE, BASE_NONE, NULL, 0,
1788         "tcap.AARQ_apdu", HFILL }},
1789     { &hf_tcap_dialogueResponse,
1790       { "dialogueResponse", "tcap.dialogueResponse",
1791         FT_NONE, BASE_NONE, NULL, 0,
1792         "tcap.AARE_apdu", HFILL }},
1793     { &hf_tcap_dialogueAbort,
1794       { "dialogueAbort", "tcap.dialogueAbort",
1795         FT_NONE, BASE_NONE, NULL, 0,
1796         "tcap.ABRT_apdu", HFILL }},
1797     { &hf_tcap_aarq_protocol_version,
1798       { "protocol-version", "tcap.protocol_version",
1799         FT_BYTES, BASE_NONE, NULL, 0,
1800         "tcap.AARQ_protocol_version", HFILL }},
1801     { &hf_tcap_aarq_application_context_name,
1802       { "application-context-name", "tcap.application_context_name",
1803         FT_OID, BASE_NONE, NULL, 0,
1804         "tcap.AARQ_application_context_name", HFILL }},
1805     { &hf_tcap_aarq_user_information,
1806       { "user-information", "tcap.user_information",
1807         FT_UINT32, BASE_DEC, NULL, 0,
1808         "tcap.AARQ_user_information", HFILL }},
1809     { &hf_tcap_aarq_user_information_item,
1810       { "user-information item", "tcap.user_information_item",
1811         FT_NONE, BASE_NONE, NULL, 0,
1812         "tcap.EXTERNAL", HFILL }},
1813     { &hf_tcap_aare_protocol_version,
1814       { "protocol-version", "tcap.protocol_version",
1815         FT_BYTES, BASE_NONE, NULL, 0,
1816         "tcap.AARE_protocol_version", HFILL }},
1817     { &hf_tcap_aare_application_context_name,
1818       { "application-context-name", "tcap.application_context_name",
1819         FT_OID, BASE_NONE, NULL, 0,
1820         "tcap.AARE_application_context_name", HFILL }},
1821     { &hf_tcap_result,
1822       { "result", "tcap.result",
1823         FT_INT32, BASE_DEC, VALS(tcap_Associate_result_vals), 0,
1824         "tcap.Associate_result", HFILL }},
1825     { &hf_tcap_result_source_diagnostic,
1826       { "result-source-diagnostic", "tcap.result_source_diagnostic",
1827         FT_UINT32, BASE_DEC, VALS(tcap_Associate_source_diagnostic_vals), 0,
1828         "tcap.Associate_source_diagnostic", HFILL }},
1829     { &hf_tcap_aare_user_information,
1830       { "user-information", "tcap.user_information",
1831         FT_UINT32, BASE_DEC, NULL, 0,
1832         "tcap.AARE_user_information", HFILL }},
1833     { &hf_tcap_aare_user_information_item,
1834       { "user-information item", "tcap.user_information_item",
1835         FT_NONE, BASE_NONE, NULL, 0,
1836         "tcap.EXTERNAL", HFILL }},
1837     { &hf_tcap_abort_source,
1838       { "abort-source", "tcap.abort_source",
1839         FT_INT32, BASE_DEC, VALS(tcap_ABRT_source_vals), 0,
1840         "tcap.ABRT_source", HFILL }},
1841     { &hf_tcap_abrt_user_information,
1842       { "user-information", "tcap.user_information",
1843         FT_UINT32, BASE_DEC, NULL, 0,
1844         "tcap.ABRT_user_information", HFILL }},
1845     { &hf_tcap_abrt_user_information_item,
1846       { "user-information item", "tcap.user_information_item",
1847         FT_NONE, BASE_NONE, NULL, 0,
1848         "tcap.EXTERNAL", HFILL }},
1849     { &hf_tcap_dialogue_service_user,
1850       { "dialogue-service-user", "tcap.dialogue_service_user",
1851         FT_INT32, BASE_DEC, VALS(tcap_T_dialogue_service_user_vals), 0,
1852         "tcap.T_dialogue_service_user", HFILL }},
1853     { &hf_tcap_dialogue_service_provider,
1854       { "dialogue-service-provider", "tcap.dialogue_service_provider",
1855         FT_INT32, BASE_DEC, VALS(tcap_T_dialogue_service_provider_vals), 0,
1856         "tcap.T_dialogue_service_provider", HFILL }},
1857     { &hf_tcap_AUDT_protocol_version_version1,
1858       { "version1", "tcap.version1",
1859         FT_BOOLEAN, 8, NULL, 0x80,
1860         NULL, HFILL }},
1861     { &hf_tcap_AARQ_protocol_version_version1,
1862       { "version1", "tcap.version1",
1863         FT_BOOLEAN, 8, NULL, 0x80,
1864         NULL, HFILL }},
1865     { &hf_tcap_AARE_protocol_version_version1,
1866       { "version1", "tcap.version1",
1867         FT_BOOLEAN, 8, NULL, 0x80,
1868         NULL, HFILL }},
1869
1870 /*--- End of included file: packet-tcap-hfarr.c ---*/
1871 #line 315 "packet-tcap-template.c"
1872     };
1873
1874 /* Setup protocol subtree array */
1875     static gint *ett[] = {
1876         &ett_tcap,
1877         &ett_param,
1878         &ett_otid,
1879         &ett_dtid,
1880         &ett_tcap_stat,
1881
1882 /*--- Included file: packet-tcap-ettarr.c ---*/
1883 #line 1 "packet-tcap-ettarr.c"
1884     &ett_tcap_ExternalPDU_U,
1885     &ett_tcap_TCMessage,
1886     &ett_tcap_Unidirectional,
1887     &ett_tcap_Begin,
1888     &ett_tcap_End,
1889     &ett_tcap_Continue,
1890     &ett_tcap_Abort,
1891     &ett_tcap_Reason,
1892     &ett_tcap_SEQUENCE_SIZE_1_MAX_OF_Component,
1893     &ett_tcap_Component,
1894     &ett_tcap_Invoke,
1895     &ett_tcap_ReturnResult,
1896     &ett_tcap_T_resultretres,
1897     &ett_tcap_ReturnError,
1898     &ett_tcap_Reject,
1899     &ett_tcap_T_invokeIDRej,
1900     &ett_tcap_T_problem,
1901     &ett_tcap_OPERATION,
1902     &ett_tcap_ERROR,
1903     &ett_tcap_ErrorCode,
1904     &ett_tcap_UniDialoguePDU,
1905     &ett_tcap_AUDT_apdu_U,
1906     &ett_tcap_AUDT_protocol_version,
1907     &ett_tcap_AUDT_user_information,
1908     &ett_tcap_DialoguePDU,
1909     &ett_tcap_AARQ_apdu_U,
1910     &ett_tcap_AARQ_protocol_version,
1911     &ett_tcap_AARQ_user_information,
1912     &ett_tcap_AARE_apdu_U,
1913     &ett_tcap_AARE_protocol_version,
1914     &ett_tcap_AARE_user_information,
1915     &ett_tcap_ABRT_apdu_U,
1916     &ett_tcap_ABRT_user_information,
1917     &ett_tcap_Associate_source_diagnostic,
1918
1919 /*--- End of included file: packet-tcap-ettarr.c ---*/
1920 #line 325 "packet-tcap-template.c"
1921     };
1922
1923     /*static enum_val_t tcap_options[] = {
1924         { "itu", "ITU",  ITU_TCAP_STANDARD },
1925         { "ansi", "ANSI", ANSI_TCAP_STANDARD },
1926         { NULL, NULL, 0 }
1927     };*/
1928
1929     module_t *tcap_module;
1930
1931 /* Register the protocol name and description */
1932     proto_tcap = proto_register_protocol(PNAME, PSNAME, PFNAME);
1933
1934 /* Required function calls to register the header fields and subtrees used */
1935     proto_register_field_array(proto_tcap, hf, array_length(hf));
1936     proto_register_subtree_array(ett, array_length(ett));
1937
1938     tcap_module = prefs_register_protocol(proto_tcap, NULL);
1939
1940 #if 0
1941     prefs_register_enum_preference(tcap_module, "standard", "ITU TCAP standard",
1942         "The SS7 standard used in ITU TCAP packets",
1943         &tcap_standard, tcap_options, FALSE);
1944 #else
1945     prefs_register_obsolete_preference(tcap_module, "standard");
1946 #endif
1947
1948 #if 0
1949     prefs_register_bool_preference(tcap_module, "lock_info_col", "Lock Info column",
1950         "Always show TCAP in Info column",
1951         &lock_info_col);
1952 #else
1953     prefs_register_obsolete_preference(tcap_module, "lock_info_col");
1954 #endif
1955
1956     /* Set default SSNs */
1957     range_convert_str(&global_ssn_range, "", MAX_SSN);
1958     ssn_range = range_empty();
1959
1960     prefs_register_range_preference(tcap_module, "ssn", "SCCP SSNs",
1961         "SCCP (and SUA) SSNs to decode as TCAP",
1962         &global_ssn_range, MAX_SSN);
1963
1964     prefs_register_bool_preference(tcap_module, "srt",
1965                                    "Service Response Time Analyse",
1966                                    "Activate the analyse for Response Time",
1967                                    &gtcap_HandleSRT);
1968
1969     prefs_register_bool_preference(tcap_module, "persistentsrt",
1970                                    "Persistent stats for SRT",
1971                                    "Statistics for Response Time",
1972                                    &gtcap_PersistentSRT);
1973
1974     prefs_register_uint_preference(tcap_module, "repetitiontimeout",
1975                                    "Repetition timeout",
1976                                    "Maximal delay for message repetion",
1977                                    10, &gtcap_RepetitionTimeout);
1978
1979     prefs_register_uint_preference(tcap_module, "losttimeout",
1980                                    "lost timeout",
1981                                    "Maximal delay for message lost",
1982                                    10, &gtcap_LostTimeout);
1983
1984     ansi_sub_dissectors = g_hash_table_new(g_direct_hash,g_direct_equal);
1985     itu_sub_dissectors = g_hash_table_new(g_direct_hash,g_direct_equal);
1986
1987     /* 'globally' register dissector */
1988     register_dissector("tcap", dissect_tcap, proto_tcap);
1989
1990     tcap_handle = create_dissector_handle(dissect_tcap, proto_tcap);
1991
1992     register_init_routine(&init_tcap);
1993 }
1994
1995
1996 static void range_delete_callback(guint32 ssn)
1997 {
1998     if ( ssn && !get_ansi_tcap_subdissector(ssn) && !get_itu_tcap_subdissector(ssn) ) {
1999         dissector_delete("sccp.ssn", ssn, tcap_handle);
2000     }
2001 }
2002
2003 static void range_add_callback(guint32 ssn)
2004 {
2005     if (ssn && !get_ansi_tcap_subdissector(ssn) && !get_itu_tcap_subdissector(ssn) ) {
2006         dissector_add("sccp.ssn", ssn, tcap_handle);
2007     }
2008 }
2009
2010
2011 static void init_tcap(void) {
2012     if (ssn_range) {
2013         range_foreach(ssn_range, range_delete_callback);
2014         g_free(ssn_range);
2015     }
2016
2017     ssn_range = range_copy(global_ssn_range);
2018     range_foreach(ssn_range, range_add_callback);
2019     tcapsrt_init_routine();
2020 }
2021
2022 static int
2023 dissect_tcap_param(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset)
2024 {
2025     gint tag_offset, saved_offset, len_offset;
2026     tvbuff_t    *next_tvb;
2027     proto_tree *subtree;
2028     proto_item *pi;
2029     gint8 class;
2030     gboolean pc;
2031     gint32 tag;
2032     guint32 len;
2033     guint32 tag_length;
2034     guint32 len_length;
2035     gboolean ind_field;
2036
2037     while (tvb_reported_length_remaining(tvb, offset) > 0)
2038     {
2039         saved_offset = offset;
2040
2041         offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
2042         tag_offset = offset;
2043         offset = get_ber_length(tvb, offset, &len, &ind_field);
2044         len_offset = offset;
2045
2046         tag_length = tag_offset - saved_offset;
2047         len_length = len_offset - tag_offset;
2048
2049         if (pc)
2050         {
2051             pi = proto_tree_add_text(tree, tvb, saved_offset,
2052                                      len + (len_offset - saved_offset),
2053                                      "CONSTRUCTOR");
2054             subtree = proto_item_add_subtree(pi, ett_param);
2055             proto_tree_add_uint_format(subtree, hf_tcap_tag, tvb,
2056                                        saved_offset, tag_length, tag,
2057                                        "CONSTRUCTOR Tag");
2058             proto_tree_add_uint(subtree, hf_tcap_tag, tvb, saved_offset,
2059                                 tag_length, class);
2060
2061             proto_tree_add_uint(subtree, hf_tcap_length, tvb, tag_offset,
2062                                 len_length, len);
2063
2064             if (len-(2*ind_field)) /*should always be positive unless we get an empty contructor pointless? */
2065             {
2066                 next_tvb = tvb_new_subset(tvb, offset, len-(2*ind_field),
2067                                           len-(2*ind_field));
2068                 dissect_tcap_param(actx, subtree,next_tvb,0);
2069             }
2070
2071             if (ind_field)
2072                     proto_tree_add_text(subtree, tvb, offset+len-2, 2, "CONSTRUCTOR EOC");
2073
2074             offset += len;
2075         }
2076         else
2077         {
2078             pi = proto_tree_add_text(tree, tvb, saved_offset,
2079                                      len + (len_offset - saved_offset),
2080                                      "Parameter (0x%.2x)", tag);
2081
2082             subtree = proto_item_add_subtree(pi, ett_param);
2083
2084             proto_tree_add_uint(subtree, hf_tcap_tag, tvb, saved_offset,
2085                                 tag_length, tag);
2086
2087             proto_tree_add_uint(subtree, hf_tcap_length, tvb,
2088                                 saved_offset+tag_length, len_length, len);
2089
2090             if (len) /* check for NULLS */
2091             {
2092                 next_tvb = tvb_new_subset(tvb, offset, len, len);
2093                 dissect_ber_octet_string(TRUE, actx, tree, next_tvb, 0,
2094                                          hf_tcap_data, NULL);
2095             }
2096
2097             offset += len;
2098         }
2099     }
2100     return offset;
2101 }
2102
2103 static void raz_tcap_private(struct tcap_private_t * p_tcap_private)
2104 {
2105   memset(p_tcap_private,0,sizeof(struct tcap_private_t) );
2106 }
2107
2108 /*
2109  * Call ITU Subdissector to decode the Tcap Component
2110  */
2111 static int
2112 dissect_tcap_ITU_ComponentPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_)
2113 {
2114   dissector_handle_t subdissector_handle=NULL;
2115   gboolean is_subdissector=FALSE;
2116   struct tcaphash_context_t * p_tcap_context=NULL;
2117
2118   /*
2119    * ok lets look at the oid and ssn and try and find a dissector, otherwise lets decode it.
2120    */
2121
2122   /*
2123    * Handle The TCAP Service Response Time
2124    */
2125   if ( gtcap_HandleSRT ) {
2126           if (!tcap_subdissector_used) {
2127             p_tcap_context=tcapsrt_call_matching(tvb, actx->pinfo, tcap_stat_tree, gp_tcapsrt_info);
2128             tcap_subdissector_used=TRUE;
2129             gp_tcap_context=p_tcap_context;
2130             tcap_private.context=p_tcap_context;
2131           }else{
2132                   /* Take the last TCAP context */
2133                   p_tcap_context = gp_tcap_context;
2134                   tcap_private.context=p_tcap_context;
2135           }
2136   }
2137   if (p_tcap_context) {
2138           if (cur_oid) {
2139                   if (p_tcap_context->oid_present) {
2140                           /* We have already an Application Context, check if we have
2141                              to fallback to a lower version */
2142                           if ( strncmp(p_tcap_context->oid,cur_oid, LENGTH_OID)!=0) {
2143                                   /* ACN, changed, Fallback to lower version
2144                                    * and update the subdissector (purely formal)
2145                                    */
2146                                   g_strlcpy(p_tcap_context->oid,cur_oid, LENGTH_OID);
2147                                   if ( (subdissector_handle = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) {
2148                                           p_tcap_context->subdissector_handle=subdissector_handle;
2149                                           p_tcap_context->subdissector_present=TRUE;
2150                                   }
2151                           }
2152                   } else {
2153                           /* We do not have the OID in the TCAP context, so store it */
2154                           g_strlcpy(p_tcap_context->oid,cur_oid, LENGTH_OID);
2155                           p_tcap_context->oid_present=TRUE;
2156                           /* Try to find a subdissector according to OID */
2157                           if ( (subdissector_handle
2158                                   = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) {
2159                                   p_tcap_context->subdissector_handle=subdissector_handle;
2160                                   p_tcap_context->subdissector_present=TRUE;
2161                           } else {
2162                             /* Not found, so try to find a subdissector according to SSN */
2163                             if ( (subdissector_handle = get_itu_tcap_subdissector(actx->pinfo->match_port))) {
2164                               /* Found according to SSN */
2165                               p_tcap_context->subdissector_handle=subdissector_handle;
2166                               p_tcap_context->subdissector_present=TRUE;
2167                             }
2168                           }
2169                   } /* context OID */
2170           } else {
2171                   /* Copy the OID from the TCAP context to the current oid */
2172                   if (p_tcap_context->oid_present) {
2173                           tcap_private.oid= (void*) p_tcap_context->oid;
2174                           tcap_private.acv=TRUE;
2175                   }
2176           } /* no OID */
2177   } /* no TCAP context */
2178
2179
2180   if ( p_tcap_context
2181        && p_tcap_context->subdissector_present) {
2182     /* Take the subdissector from the context */
2183     subdissector_handle=p_tcap_context->subdissector_handle;
2184     is_subdissector=TRUE;
2185   }
2186
2187   /* Have SccpUsersTable protocol taking precedence over sccp.ssn table */
2188   if (!is_subdissector && requested_subdissector_handle) {
2189           is_subdissector = TRUE;
2190           subdissector_handle = requested_subdissector_handle;
2191   }
2192
2193   if (!is_subdissector) {
2194     /*
2195      * If we do not currently know the subdissector, we have to find it
2196      * - first, according to the OID
2197      * - then according to the SSN
2198      * - and at least, take the default Data handler
2199      */
2200     if (ber_oid_dissector_table && cur_oid) {
2201       /* Search if we can find the sub protocol according to the A.C.N */
2202       if ( (subdissector_handle
2203             = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) {
2204                   /* found */
2205                   is_subdissector=TRUE;
2206       } else {
2207                   /* Search if we can found the sub protocol according to the SSN table */
2208                   if ( (subdissector_handle
2209                           = get_itu_tcap_subdissector(actx->pinfo->match_port))) {
2210                           /* Found according to SSN */
2211                           is_subdissector=TRUE;
2212                   } else {
2213                           /* Nothing found, take the Data handler */
2214                           subdissector_handle = data_handle;
2215                           is_subdissector=TRUE;
2216                   } /* SSN */
2217           } /* ACN */
2218         } else {
2219                 /* There is no A.C.N for this transaction, so search in the SSN table */
2220                 if ( (subdissector_handle = get_itu_tcap_subdissector(actx->pinfo->match_port))) {
2221                         /* Found according to SSN */
2222                         is_subdissector=TRUE;
2223                 } else {
2224                         subdissector_handle = data_handle;
2225                         is_subdissector=TRUE;
2226                 }
2227         } /* OID */
2228   } else {
2229           /* We have it already */
2230   }
2231
2232   /* Call the sub dissector if present, and not already called */
2233   if (is_subdissector)
2234     call_dissector(subdissector_handle, tvb, actx->pinfo, tree);
2235
2236   return offset;
2237 }
2238
2239 void call_tcap_dissector(dissector_handle_t handle, tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
2240
2241         requested_subdissector_handle = handle;
2242
2243         TRY {
2244                 dissect_tcap(tvb, pinfo, tree);
2245         } CATCH_ALL {
2246                 requested_subdissector_handle = NULL;
2247                 RETHROW;
2248         } ENDTRY;
2249
2250         requested_subdissector_handle = NULL;
2251
2252 }
2253
2254