343a77ad1696e29dba3163753d1663b1a3fa6106
[obnox/wireshark/wip.git] / asn1 / tcap / packet-tcap-template.c
1 /* packet-tcap-template.c
2  * Routines for  TCAP
3  * Copyright 2004 - 2005, Tim Endean <endeant@hotmail.com>
4  * Built from the gsm-map dissector Copyright 2004 - 2005, Anders Broman <anders.broman@ericsson.com>
5  *
6  * $Id$
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  * References: ETSI 300 374
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <glib.h>
32 #include <epan/packet.h>
33 #include <epan/prefs.h>
34 #include <epan/conversation.h>
35 #include <epan/oid_resolv.h>
36 #include <epan/emem.h>
37
38 #include <stdio.h>
39 #include <string.h>
40 #include "packet-ber.h"
41 #include "packet-tcap.h"
42 #include "epan/tcap-persistentdata.h"
43
44 #define PNAME  "Transaction Capabilities Application Part"
45 #define PSNAME "TCAP"
46 #define PFNAME "tcap"
47
48 /* Initialize the protocol and registered fields */
49 int proto_tcap = -1;
50 static int hf_tcap_tag = -1; 
51 static int hf_tcap_length = -1; 
52 static int hf_tcap_data = -1;
53 static int hf_tcap_tid = -1;
54
55 int hf_tcapsrt_SessionId=-1;
56 int hf_tcapsrt_Duplicate=-1;
57 int hf_tcapsrt_BeginSession=-1;
58 int hf_tcapsrt_EndSession=-1;
59 int hf_tcapsrt_SessionTime=-1;
60
61 #include "packet-tcap-hf.c"
62
63 /* Initialize the subtree pointers */
64 static gint ett_tcap = -1;
65 static gint ett_param = -1;
66
67 static gint ett_otid = -1;
68 static gint ett_dtid = -1;
69 gint ett_tcap_stat = -1;
70
71 static struct tcapsrt_info_t * gp_tcapsrt_info;
72 static gboolean tcap_subdissector_used=FALSE;
73 static struct tcaphash_context_t * gp_tcap_context=NULL;
74
75 #include "packet-tcap-ett.c"
76
77 #define MAX_SSN 254
78 static range_t *global_ssn_range;
79 static range_t *ssn_range;
80 struct tcap_private_t tcap_private;
81
82 gboolean gtcap_HandleSRT=FALSE;
83 extern gboolean gtcap_PersistentSRT;
84 extern gboolean gtcap_DisplaySRT;
85 extern guint gtcap_RepetitionTimeout;
86 extern guint gtcap_LostTimeout;
87
88 static dissector_handle_t       tcap_handle = NULL;
89 static dissector_table_t ber_oid_dissector_table=NULL;
90 static const char * cur_oid;
91 static const char * tcapext_oid;
92 static proto_tree * tcap_top_tree=NULL;
93 static proto_tree * tcap_stat_tree=NULL;
94 static proto_item * tcap_stat_item=NULL;
95
96 static dissector_handle_t data_handle;
97
98 static dissector_table_t sccp_ssn_table;
99
100 static void raz_tcap_private(struct tcap_private_t * p_tcap_private);
101 static int dissect_tcap_param(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset);
102 static int dissect_tcap_UserInformation(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_);
103 static int dissect_tcap_TheComponent(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_);
104 static int dissect_tcap_TheExternUserInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_);
105
106 static GHashTable* ansi_sub_dissectors = NULL;
107 static GHashTable* itu_sub_dissectors = NULL;
108
109 static void dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree);
110
111 extern void add_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector) {
112     g_hash_table_insert(ansi_sub_dissectors,GUINT_TO_POINTER(ssn),dissector);
113     dissector_add("sccp.ssn",ssn,tcap_handle);
114 }
115
116 extern void add_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector) {
117     g_hash_table_insert(itu_sub_dissectors,GUINT_TO_POINTER(ssn),dissector);
118     dissector_add("sccp.ssn",ssn,tcap_handle);
119 }
120
121 extern void delete_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector _U_) {
122     g_hash_table_remove(ansi_sub_dissectors,GUINT_TO_POINTER(ssn));
123     dissector_delete("sccp.ssn",ssn,tcap_handle);
124 }
125 extern void delete_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector _U_) {
126     g_hash_table_remove(itu_sub_dissectors,GUINT_TO_POINTER(ssn));
127         dissector_delete("sccp.ssn", ssn,tcap_handle);
128 }
129
130 dissector_handle_t get_ansi_tcap_subdissector(guint32 ssn) {
131     return g_hash_table_lookup(ansi_sub_dissectors,GUINT_TO_POINTER(ssn));
132 }
133
134 dissector_handle_t get_itu_tcap_subdissector(guint32 ssn) {
135     return g_hash_table_lookup(itu_sub_dissectors,GUINT_TO_POINTER(ssn));
136 }
137
138
139
140 #include "packet-tcap-fn.c"
141
142
143
144 const value_string tcap_component_type_str[] = {
145     { TCAP_COMP_INVOKE,         "Invoke" },
146     { TCAP_COMP_RRL,            "Return Result(L)" },
147     { TCAP_COMP_RE,                     "Return Error" },
148     { TCAP_COMP_REJECT,         "Reject" },
149     { TCAP_COMP_RRN,            "Return Result(NL)" },
150     { 0,                        NULL } };
151
152
153 static void
154 dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
155 {
156     proto_item          *item=NULL;
157     proto_tree          *tree=NULL;
158     proto_item  *stat_item=NULL;
159     proto_tree  *stat_tree=NULL;
160     struct tcaphash_context_t * p_tcap_context;
161     dissector_handle_t subdissector_handle;
162
163     tcap_top_tree = parent_tree;
164     if (check_col(pinfo->cinfo, COL_PROTOCOL))
165     {
166                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCAP");
167     }
168
169     /* create display subtree for the protocol */
170     if(parent_tree){
171       item = proto_tree_add_item(parent_tree, proto_tcap, tvb, 0, -1, FALSE);
172       tree = proto_item_add_subtree(item, ett_tcap);
173       tcap_stat_item=item;
174       tcap_stat_tree=tree;
175     }
176     cur_oid = NULL;
177     tcapext_oid = NULL;
178     raz_tcap_private(&tcap_private);
179
180     pinfo->private_data = &tcap_private;
181     gp_tcapsrt_info=tcapsrt_razinfo();
182     tcap_subdissector_used=FALSE;
183     gp_tcap_context=NULL;
184     dissect_tcap_MessageType(FALSE, tvb, 0, pinfo, tree, -1);  
185
186     if (gtcap_HandleSRT &&
187         !tcap_subdissector_used ) {
188       if (gtcap_DisplaySRT && tree) {
189         stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat");
190         stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat);
191       }
192       p_tcap_context=tcapsrt_call_matching(tvb, pinfo, stat_tree, gp_tcapsrt_info);
193       tcap_private.context=p_tcap_context;
194
195       /* If the current message is TCAP only, 
196          save the Application contexte name for the next messages */
197       if ( p_tcap_context &&
198            cur_oid &&
199            !p_tcap_context->oid_present ) {
200         /* Save the application context and the sub dissector */
201         ber_oid_dissector_table = find_dissector_table("ber.oid");
202         strncpy(p_tcap_context->oid,cur_oid, LENGTH_OID);
203         if ( (subdissector_handle 
204               = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) {
205           p_tcap_context->subdissector_handle=subdissector_handle;
206           p_tcap_context->oid_present=TRUE;
207         }
208       } 
209       
210       if (gtcap_HandleSRT &&
211           p_tcap_context &&
212           p_tcap_context->callback) {
213         /* Callback fonction for the upper layer */
214         (p_tcap_context->callback)(tvb, pinfo, stat_tree, p_tcap_context);
215       }
216     }
217 }
218
219
220 void
221 proto_reg_handoff_tcap(void)
222 {
223     
224     static gboolean prefs_initialized = FALSE;
225     
226     if (! prefs_initialized) {
227         sccp_ssn_table = find_dissector_table("sccp.ssn");
228         prefs_initialized = TRUE;
229     }
230     
231     add_oid_str_name("0.0.17.773.1.1.1",
232                           "itu-t(0) recommendation(0) q(17) 773 as(1) dialogue-as(1) version1(1)");
233
234     data_handle = find_dissector("data");    
235 }
236
237 static void init_tcap(void);
238
239 void
240 proto_register_tcap(void)
241 {
242
243 /* Setup list of header fields  See Section 1.6.1 for details*/
244     static hf_register_info hf[] = {
245         { &hf_tcap_tag,
246                 { "Tag",           "tcap.msgtype",
247                 FT_UINT8, BASE_HEX, NULL, 0,
248                 "", HFILL }
249         },
250         { &hf_tcap_length,
251                 { "Length", "tcap.len",
252                 FT_UINT8, BASE_HEX, NULL, 0,
253                 "", HFILL }
254         },
255         { &hf_tcap_data,
256                 { "Data", "tcap.data",
257                 FT_BYTES, BASE_HEX, NULL, 0,
258                 "", HFILL }
259         },
260                 { &hf_tcap_tid,
261                 { "Transaction Id", "tcap.tid",
262                 FT_BYTES, BASE_HEX, NULL, 0,
263                 "", HFILL }
264         }, 
265         /* Tcap Service Response Time */
266         { &hf_tcapsrt_SessionId,
267           { "Session Id",
268             "tcap.srt.session_id",
269             FT_UINT32, BASE_DEC, NULL, 0x0,
270             "", HFILL }
271         },
272         { &hf_tcapsrt_BeginSession,
273           { "Begin Session",
274             "tcap.srt.begin",
275             FT_FRAMENUM, BASE_NONE, NULL, 0x0,
276             "SRT Begin of Session", HFILL }
277         },
278         { &hf_tcapsrt_EndSession,
279           { "End Session",
280             "tcap.srt.end",
281             FT_FRAMENUM, BASE_NONE, NULL, 0x0,
282             "SRT End of Session", HFILL }
283         },
284         { &hf_tcapsrt_SessionTime,
285           { "Session duration",
286             "tcap.srt.sessiontime",
287             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
288             "Duration of the TCAP session", HFILL }
289         },
290         { &hf_tcapsrt_Duplicate,
291           { "Request Duplicate",
292             "tcap.srt.duplicate",
293             FT_UINT32, BASE_DEC, NULL, 0x0,
294             "", HFILL }
295         },
296 #include "packet-tcap-hfarr.c"  
297     };
298
299 /* Setup protocol subtree array */
300     static gint *ett[] = {
301         &ett_tcap,
302         &ett_param,
303         &ett_otid,
304         &ett_dtid,
305         &ett_tcap_stat,
306         #include "packet-tcap-ettarr.c"
307     };
308
309     /*static enum_val_t tcap_options[] = {
310         { "itu", "ITU",  ITU_TCAP_STANDARD },
311         { "ansi", "ANSI", ANSI_TCAP_STANDARD },
312         { NULL, NULL, 0 }
313     };*/
314
315     module_t *tcap_module;
316
317 /* Register the protocol name and description */
318     proto_tcap = proto_register_protocol(PNAME, PSNAME, PFNAME);
319
320 /* Required function calls to register the header fields and subtrees used */
321     proto_register_field_array(proto_tcap, hf, array_length(hf));
322     proto_register_subtree_array(ett, array_length(ett));
323
324     tcap_module = prefs_register_protocol(proto_tcap, proto_reg_handoff_tcap);
325
326 #if 0
327     prefs_register_enum_preference(tcap_module, "standard", "ITU TCAP standard",
328         "The SS7 standard used in ITU TCAP packets",
329         &tcap_standard, tcap_options, FALSE);
330 #else
331     prefs_register_obsolete_preference(tcap_module, "standard");
332 #endif
333
334 #if 0
335     prefs_register_bool_preference(tcap_module, "lock_info_col", "Lock Info column",
336         "Always show TCAP in Info column",
337         &lock_info_col);
338 #else
339     prefs_register_obsolete_preference(tcap_module, "lock_info_col");
340 #endif
341
342     /* Set default SSNs */
343     range_convert_str(&global_ssn_range, "", MAX_SSN);
344     ssn_range = range_empty();
345
346     prefs_register_range_preference(tcap_module, "ssn", "SCCP SSNs",
347         "SCCP (and SUA) SSNs to decode as TCAP",
348         &global_ssn_range, MAX_SSN);
349
350     prefs_register_bool_preference(tcap_module, "srt",
351                                    "Service Response Time Analyse",
352                                    "Activate the analyse for Response Time",
353                                    &gtcap_HandleSRT);
354
355     prefs_register_bool_preference(tcap_module, "persistentsrt",
356                                    "Persistent stats for SRT",
357                                    "Statistics for Response Time",
358                                    &gtcap_PersistentSRT);
359   
360     prefs_register_uint_preference(tcap_module, "repetitiontimeout",
361                                    "Repetition timeout",
362                                    "Maximal delay for message repetion",
363                                    10, &gtcap_RepetitionTimeout);
364
365     prefs_register_uint_preference(tcap_module, "losttimeout",
366                                    "lost timeout",
367                                    "Maximal delay for message lost",
368                                    10, &gtcap_LostTimeout);
369     
370     ansi_sub_dissectors = g_hash_table_new(g_direct_hash,g_direct_equal);
371     itu_sub_dissectors = g_hash_table_new(g_direct_hash,g_direct_equal);
372
373     /* 'globally' register dissector */
374     register_dissector("tcap", dissect_tcap, proto_tcap);
375
376     tcap_handle = create_dissector_handle(dissect_tcap, proto_tcap);
377
378     register_init_routine(&init_tcap);
379 }
380
381
382 static void range_delete_callback(guint32 ssn)
383 {
384     if ( ssn && !get_ansi_tcap_subdissector(ssn) && !get_itu_tcap_subdissector(ssn) ) {
385         dissector_delete("sccp.ssn", ssn, tcap_handle);
386     }
387 }
388
389 static void range_add_callback(guint32 ssn)
390 {
391     if (ssn && !get_ansi_tcap_subdissector(ssn) && !get_itu_tcap_subdissector(ssn) ) {
392         dissector_add("sccp.ssn", ssn, tcap_handle);
393     }
394 }
395
396
397 static void init_tcap(void) {
398     if (ssn_range) {
399         range_foreach(ssn_range, range_delete_callback);
400         g_free(ssn_range);
401     }
402     
403     ssn_range = range_copy(global_ssn_range);
404     range_foreach(ssn_range, range_add_callback);
405     tcapsrt_init_routine();
406 }
407
408 static int
409 dissect_tcap_param(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset)
410 {
411     gint tag_offset, saved_offset, len_offset;
412     tvbuff_t    *next_tvb;
413     proto_tree *subtree;
414     proto_item *pi;
415     gint8 class;
416     gboolean pc;
417     gint32 tag;
418     guint32 len;
419     gboolean ind_field;
420     
421     while (tvb_reported_length_remaining(tvb, offset) > 0)
422     {
423         saved_offset = offset;
424     
425         offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
426         tag_offset = offset;
427         offset = get_ber_length(tree, tvb, offset, &len, &ind_field);
428         len_offset = offset;
429
430         if (pc)
431         {
432             pi =
433                 proto_tree_add_text(tree, tvb, saved_offset, len + (len_offset - saved_offset), "CONSTRUCTOR");
434             subtree = proto_item_add_subtree(pi, ett_param);
435             proto_tree_add_uint_format(subtree, hf_tcap_tag, tvb,
436                 saved_offset, tag_offset-saved_offset, tag, "CONSTRUCTOR Tag");
437             proto_tree_add_uint(subtree, hf_tcap_tag, tvb,
438                 saved_offset, tag_offset-saved_offset, class);
439
440             proto_tree_add_uint(subtree, hf_tcap_length, tvb,
441                 tag_offset, len_offset-tag_offset, len);
442                 if (len-(2*ind_field)) /*should always be positive unless we get an empty contructor pointless? */
443                 {
444                 next_tvb = tvb_new_subset(tvb, offset, len-(2*ind_field), len-(2*ind_field));           
445                         dissect_tcap_param(pinfo, subtree,next_tvb,0);
446             }           
447                 if (ind_field)
448                         proto_tree_add_text(subtree, tvb, offset+len-2, 2, "CONSTRUCTOR EOC");
449             offset += len;
450         }
451         else
452         {
453             pi = proto_tree_add_text(tree, tvb,
454                 saved_offset, len + (len_offset - saved_offset), "Parameter (0x%.2x)", tag);
455
456             subtree = proto_item_add_subtree(pi, ett_param);
457
458             proto_tree_add_uint(subtree, hf_tcap_tag, tvb,
459                 saved_offset, 1, tag);
460
461             proto_tree_add_uint(subtree, hf_tcap_length, tvb,
462                 saved_offset+1, 1, len);
463                 if (len) /* check for NULLS */
464                         {
465                 next_tvb = tvb_new_subset(tvb, offset, len, len);               
466                 dissect_ber_octet_string(TRUE, pinfo, tree, next_tvb, 0, hf_tcap_data,
467                                         NULL);
468                 }
469             offset += len;
470         }
471     }
472     return offset;
473 }
474
475 static void raz_tcap_private(struct tcap_private_t * p_tcap_private)
476 {  
477   memset(p_tcap_private,0,sizeof(struct tcap_private_t) );
478 }
479
480
481 static int
482 dissect_tcap_TheComponent(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_)
483 {
484   tvbuff_t * next_tvb;
485   dissector_handle_t subdissector_handle;
486   gboolean is_subdissector=FALSE;
487   struct tcaphash_context_t * p_tcap_context=NULL;
488
489   gint8 class;
490   gboolean pc;
491   gint tag;
492   guint32 len, s_offset;
493   gint ind_field;
494   proto_tree * stat_tree=NULL;
495   proto_item * stat_item=NULL;
496   /* 
497    * ok lets look at the oid and ssn and try and find a dissector, otherwise lets decode it.
498    */
499   ber_oid_dissector_table = find_dissector_table("ber.oid");
500   s_offset = offset;
501   offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
502   offset = get_ber_length(tree, tvb, offset, &len, &ind_field);
503   /* we can believe the length now */
504   next_tvb = tvb_new_subset(tvb, s_offset, len+(offset-s_offset), len+(offset-s_offset));
505   if (!next_tvb)
506     return offset+len;
507   
508   dissect_ber_choice(pinfo, tree, next_tvb, 0,
509                      Component_choice, hf_index, ett_tcap_Component,NULL);
510   
511
512   /*
513    * Handle The TCAP Service Response Time
514    */
515   if ( gtcap_HandleSRT ) {
516     if (!tcap_subdissector_used) {
517       /* Create TCAP context and tree for display */
518       if (gtcap_DisplaySRT && tree) {
519         stat_item = proto_tree_add_text(tcap_stat_tree, tvb, offset, -1, "Stat");
520         stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat);
521       }
522       p_tcap_context=tcapsrt_call_matching(tvb, pinfo, stat_tree, gp_tcapsrt_info);
523       tcap_subdissector_used=TRUE;
524       gp_tcap_context=p_tcap_context;
525       tcap_private.context=p_tcap_context;
526     } else {
527       /* Take the last TCAP context */
528       p_tcap_context = gp_tcap_context;
529       tcap_private.context=p_tcap_context;
530     }
531   }
532
533   if (p_tcap_context) {
534     if (cur_oid) {
535       if (p_tcap_context->oid_present) {
536         /* We have already an Application Context, check if we have
537            to fallback to a lower version */
538         if ( strncmp(p_tcap_context->oid,cur_oid, LENGTH_OID)!=0) {
539           /* ACN, changed, Fallback to lower version */
540           /* and update the subdissector (purely formal) */
541           strncpy(p_tcap_context->oid,cur_oid, LENGTH_OID);
542           if ( (subdissector_handle 
543                 = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) {
544             p_tcap_context->subdissector_handle=subdissector_handle;
545           }
546         }
547       } else {
548         /* We do not have the OID in the TCAP context, so store it */
549         strncpy(p_tcap_context->oid,cur_oid, LENGTH_OID);
550         if ( (subdissector_handle 
551               = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) {
552           p_tcap_context->subdissector_handle=subdissector_handle;
553           p_tcap_context->oid_present=TRUE;
554         }
555       } /* context OID */
556     } else {
557       /* Copy the OID from the TCAP context to the current oid */
558       if (p_tcap_context->oid_present) {
559         tcap_private.oid= (void*) p_tcap_context->oid;
560         tcap_private.acv=TRUE;
561       }
562     } /* no OID */
563   } /* no TCAP context */
564   
565   if ( p_tcap_context 
566        && p_tcap_context->oid_present) {
567     /* Take the subdissector from the context */
568     subdissector_handle=p_tcap_context->subdissector_handle;
569     is_subdissector=TRUE;
570   }
571   
572   if (!is_subdissector) {
573     /*
574      * If we do not currently know the subdissector, we have to find it
575      * - first, according to the OID
576      * - then according to the SSN
577      * - and at least, take the default Data handler 
578      */
579     if (ber_oid_dissector_table && cur_oid) {
580       /* Search if we can find the sub protocol according to the A.C.N */
581       if ( (subdissector_handle 
582             = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) {
583         /* found */
584         is_subdissector=TRUE;
585       } else {
586         /* Search if we can found the sub protocol according to the SSN table */
587         if ( (subdissector_handle 
588               = get_itu_tcap_subdissector(pinfo->match_port))) {
589           /* Found according to SSN */
590           is_subdissector=TRUE;
591         } else {
592           /* Nothing found, take the Data handler */
593           subdissector_handle = data_handle;
594           is_subdissector=TRUE;
595         } /* SSN */
596       } /* ACN */
597     } else {
598       /* There is no A.C.N for this transaction, so search in the SSN table */
599       if ( (subdissector_handle = get_itu_tcap_subdissector(pinfo->match_port))) {
600         /* Found according to SSN */
601         is_subdissector=TRUE;
602       } else {
603         subdissector_handle = data_handle;
604         is_subdissector=TRUE;
605       }
606     } /* OID */
607   } else {
608     /* We have it already */
609   }
610   /* Call the sub dissector if present, and not already called */
611   if (is_subdissector)
612     call_dissector(subdissector_handle, next_tvb, pinfo, tcap_top_tree);
613   
614   return offset+len;
615 }
616
617
618 static int
619 dissect_tcap_TheExternUserInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_)
620 {
621   tvbuff_t *next_tvb;
622   gint8 class;
623   gboolean pc;
624   gint tag;
625   guint32 len, start_offset;
626   gint ind_field;
627
628   /* 
629    * ok lets look at the oid and ssn and try and find a dissector, otherwise lets decode it.
630    */
631   ber_oid_dissector_table = find_dissector_table("ber.oid");
632   start_offset = offset;
633   offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
634   offset = get_ber_length(tree, tvb, offset, &len, &ind_field);
635
636   next_tvb = tvb_new_subset(tvb, start_offset, len +(offset - start_offset), len+(offset - start_offset));              
637   if (!next_tvb)
638     return offset+len;
639
640   if (ber_oid_dissector_table && tcapext_oid){
641     if(!dissector_try_string(ber_oid_dissector_table, tcapext_oid, next_tvb, pinfo, tcap_top_tree))     
642       {
643       }
644   }
645   dissect_tcap_param(pinfo,tree,next_tvb,0);
646   offset+=len;
647
648   return offset;
649 }