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