Have tcap subdissectors registering using functions provided by tcap and tcap manage...
authorLuis Ontanon <luis.ontanon@gmail.com>
Sat, 17 Dec 2005 16:55:45 +0000 (16:55 -0000)
committerLuis Ontanon <luis.ontanon@gmail.com>
Sat, 17 Dec 2005 16:55:45 +0000 (16:55 -0000)
In packet-sccp.c avoid not having a binding.

svn path=/trunk/; revision=16834

13 files changed:
asn1/camel/packet-camel-template.c
asn1/gsmmap/packet-gsm_map-template.c
asn1/inap/packet-inap-template.c
asn1/tcap/packet-tcap-template.c
asn1/tcap/packet-tcap-template.h
epan/dissectors/packet-ansi_map.c
epan/dissectors/packet-camel.c
epan/dissectors/packet-camel.h
epan/dissectors/packet-gsm_map.c
epan/dissectors/packet-inap.c
epan/dissectors/packet-sccp.c
epan/dissectors/packet-tcap.c
epan/dissectors/packet-tcap.h

index 96fbbd3efdfcfea7f3946c17786d11c8d86c4cc5..bee146aef35311c4969bbf7318d2ce04e3785c75 100644 (file)
@@ -51,6 +51,7 @@
 #include "packet-e164.h"
 #include "packet-isup.h"
 #include "packet-gsm_map.h"
+#include "packet-tcap.h"
 
 #define PNAME  "Camel"
 #define PSNAME "CAMEL"
@@ -599,14 +600,14 @@ dissect_camel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
 static void range_delete_callback(guint32 ssn)
 {
   if (ssn) {
-    dissector_delete("tcap.itu_ssn", ssn, camel_handle);
+    delete_itu_tcap_subdissector(ssn, camel_handle);
   }
 }
 
 static void range_add_callback(guint32 ssn)
 {
   if (ssn) {
-    dissector_add("tcap.itu_ssn", ssn, camel_handle);
+    add_itu_tcap_subdissector(ssn, camel_handle);
   }
 }
 
index 03fba0c0f7e85fe1bd53e9d12b65056d7f7e0e48..e45ec760d56c810c5ccb8688b0297816b4dde2ac 100644 (file)
@@ -46,6 +46,7 @@
 #include "packet-q931.h"
 #include "packet-gsm_map.h"
 #include "packet-gsm_a.h"
+#include "packet-tcap.h"
 
 #define PNAME  "GSM Mobile Application"
 #define PSNAME "GSM_MAP"
@@ -1059,7 +1060,7 @@ dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
     }
 
     top_tree = parent_tree;
-    dissector_add("tcap.itu_ssn",pinfo->match_port, map_handle);
+
     /* create display subtree for the protocol */
     if(parent_tree){
         item = proto_tree_add_item(parent_tree, proto_gsm_map, tvb, 0, -1, FALSE);
@@ -1346,14 +1347,14 @@ static const value_string chargingcharacteristics_values[] = {
 static void range_delete_callback(guint32 ssn)
 {
     if (ssn) {
-       dissector_delete("tcap.itu_ssn", ssn, map_handle);
+       delete_itu_tcap_subdissector(ssn, map_handle);
     }
 }
 
 static void range_add_callback(guint32 ssn)
 {
     if (ssn) {
-       dissector_add("tcap.itu_ssn", ssn, map_handle);
+       add_itu_tcap_subdissector(ssn, map_handle);
     }
 }
 
index 808261f80b3f03f23698d632b0446f46b4461ee1..e96cc3aba1b73b3edc673fcc34041090dd0a4590 100644 (file)
@@ -42,6 +42,7 @@
 #include "packet-q931.h"
 #include "packet-e164.h"
 #include "packet-isup.h"
+#include "packet-tcap.h"
 
 #define PNAME  "Intelligent Network Application Protocol"
 #define PSNAME "INAP"
@@ -604,13 +605,13 @@ void proto_reg_handoff_inap(void) {
                inap_prefs_initialized = TRUE;
        }
        else {
-               dissector_delete("tcap.itu_ssn", tcap_itu_ssn, inap_handle);
-               dissector_delete("tcap.itu_ssn", tcap_itu_ssn1, inap_handle);
+               delete_itu_tcap_subdissector(tcap_itu_ssn, inap_handle);
+               delete_itu_tcap_subdissector(tcap_itu_ssn1, inap_handle);
        }
        tcap_itu_ssn = global_tcap_itu_ssn;
        tcap_itu_ssn1 = global_tcap_itu_ssn1;
-    dissector_add("tcap.itu_ssn", global_tcap_itu_ssn, inap_handle);
-    dissector_add("tcap.itu_ssn", global_tcap_itu_ssn1, inap_handle);
+    add_itu_tcap_subdissector(global_tcap_itu_ssn, inap_handle);
+    add_itu_tcap_subdissector(global_tcap_itu_ssn1, inap_handle);
    
 }
 
index 049c976c1555cd75f808e48f9098902564fceff9..44b26b0aa45e13e07120399a55dc7f9ade4b54d9 100644 (file)
@@ -48,10 +48,8 @@ static int hf_tcap_tag = -1;
 static int hf_tcap_length = -1; 
 static int hf_tcap_data = -1;
 static int hf_tcap_tid = -1;
-#include "packet-tcap-hf.c"
-static guint tcap_itu_ssn = 106;
 
-static guint global_tcap_itu_ssn = 1;
+#include "packet-tcap-hf.c"
 
 /* Initialize the subtree pointers */
 static gint ett_tcap = -1;
@@ -67,19 +65,52 @@ static gint ett_dtid = -1;
 static range_t *global_ssn_range;
 static range_t *ssn_range;
 
-dissector_handle_t     tcap_handle;
+dissector_handle_t     tcap_handle = NULL;
 static dissector_table_t ber_oid_dissector_table=NULL;
 static const char * cur_oid;
 static const char * tcapext_oid;
 static proto_tree      *tcap_top_tree=NULL;
 static dissector_handle_t data_handle;
-static dissector_table_t tcap_itu_ssn_dissector_table; /* map use ssn in sccp */
-static dissector_table_t tcap_ansi_ssn_dissector_table; /* map use ssn in sccp */
 
+static dissector_table_t sccp_ssn_table;
 static int dissect_tcap_param(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset);
 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_);
 
 
+static GHashTable* ansi_sub_dissectors = NULL;
+static GHashTable* itu_sub_dissectors = NULL;
+
+static void dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree);
+
+extern void add_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector) {
+    g_hash_table_insert(ansi_sub_dissectors,GUINT_TO_POINTER(ssn),dissector);
+    dissector_add("sccp.ssn",ssn,tcap_handle);
+}
+
+extern void add_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector) {
+    g_hash_table_insert(itu_sub_dissectors,GUINT_TO_POINTER(ssn),dissector);
+    dissector_add("sccp.ssn",ssn,tcap_handle);
+}
+
+extern void delete_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector _U_) {
+    g_hash_table_remove(ansi_sub_dissectors,GUINT_TO_POINTER(ssn));
+    dissector_delete("sccp.ssn",ssn,tcap_handle);
+}
+extern void delete_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector _U_) {
+    g_hash_table_remove(itu_sub_dissectors,GUINT_TO_POINTER(ssn));
+       dissector_delete("sccp.ssn", ssn,tcap_handle);
+}
+
+static dissector_handle_t get_ansi_tcap_subdissector(guint32 ssn) {
+    return g_hash_table_lookup(ansi_sub_dissectors,GUINT_TO_POINTER(ssn));
+}
+
+static dissector_handle_t get_itu_tcap_subdissector(guint32 ssn) {
+    return g_hash_table_lookup(itu_sub_dissectors,GUINT_TO_POINTER(ssn));
+}
+
+
+
 #include "packet-tcap-fn.c"
 
 
@@ -119,15 +150,23 @@ dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
 }
 
 
+void
+proto_reg_handoff_tcap(void)
+{
+    
+    static gboolean prefs_initialized = FALSE;
+    
+    if (! prefs_initialized) {
+        sccp_ssn_table = find_dissector_table("sccp.ssn");
+        prefs_initialized = TRUE;
+    }
+    
+    register_ber_oid_name("0.0.17.773.1.1.1",
+                          "itu-t(0) recommendation(0) q(17) 773 as(1) dialogue-as(1) version1(1)");
+    
+}
 
-/* Register the protocol with Ethereal */
-
-void proto_reg_handoff_tcap(void);
-
-/* this format is require because a script is used to build the C function
-   that calls all the protocol registration.
-*/
-
+static void init_tcap(void);
 
 void
 proto_register_tcap(void)
@@ -201,72 +240,51 @@ proto_register_tcap(void)
 #endif
 
     /* Set default SSNs */
-    range_convert_str(&global_ssn_range, "2,4-141,143-251,253,255", MAX_SSN);
+    range_convert_str(&global_ssn_range, "", MAX_SSN);
     ssn_range = range_empty();
 
     prefs_register_range_preference(tcap_module, "ssn", "SCCP SSNs",
        "SCCP (and SUA) SSNs to decode as TCAP",
        &global_ssn_range, MAX_SSN);
-
-    /* we will fake a ssn subfield which has the same value obtained from sccp */
-    tcap_itu_ssn_dissector_table = register_dissector_table("tcap.itu_ssn", "ITU TCAP SSN", FT_UINT8, BASE_DEC);
-    tcap_ansi_ssn_dissector_table = register_dissector_table("tcap.ansi_ssn", "ANSI TCAP SSN", FT_UINT8, BASE_DEC);
+    
+    ansi_sub_dissectors = g_hash_table_new(g_direct_hash,g_direct_equal);
+    itu_sub_dissectors = g_hash_table_new(g_direct_hash,g_direct_equal);
 
     /* 'globally' register dissector */
     register_dissector("tcap", dissect_tcap, proto_tcap);
 
-}
-
-
+    tcap_handle = create_dissector_handle(dissect_tcap, proto_tcap);
 
+    register_init_routine(&init_tcap);
+}
 
-/* If this dissector uses sub-dissector registration add a registration routine.
-   This format is required because a script is used to find these routines and
-   create the code that calls these routines.
-*/
 
 static void range_delete_callback(guint32 ssn)
 {
-    if (ssn) {
-       dissector_delete("sccp.ssn", ssn, tcap_handle);
+    if ( ssn && !get_ansi_tcap_subdissector(ssn) && !get_itu_tcap_subdissector(ssn) ) {
+        dissector_delete("sccp.ssn", ssn, tcap_handle);
     }
 }
 
 static void range_add_callback(guint32 ssn)
 {
-    if (ssn) {
-       dissector_add("sccp.ssn", ssn, tcap_handle);
+    if (ssn && !get_ansi_tcap_subdissector(ssn) && !get_itu_tcap_subdissector(ssn) ) {
+        dissector_add("sccp.ssn", ssn, tcap_handle);
     }
 }
 
-void
-proto_reg_handoff_tcap(void)
-{
-    static gboolean prefs_initialized = FALSE;
-
-    if (!prefs_initialized) {
-
-       tcap_handle = create_dissector_handle(dissect_tcap, proto_tcap);
-       
-       prefs_initialized = TRUE;
-
-    } else {
 
-       range_foreach(ssn_range, range_delete_callback);
+static void init_tcap(void) {
+    if (ssn_range) {
+        range_foreach(ssn_range, range_delete_callback);
+        g_free(ssn_range);
     }
-
-    g_free(ssn_range);
+    
     ssn_range = range_copy(global_ssn_range);
-
     range_foreach(ssn_range, range_add_callback);
-    register_ber_oid_name("0.0.17.773.1.1.1",
-               "itu-t(0) recommendation(0) q(17) 773 as(1) dialogue-as(1) version1(1)");
-
+    
 }
 
-
-
-
 static int
 dissect_tcap_param(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset)
 {
index 491392af7d7dec1476a3368d8a23aa5d3a0c2868..a426690d125c77f9100a7df8f9f3b0179603b84b 100644 (file)
@@ -57,5 +57,10 @@ extern gint tcap_standard;
 
 extern const value_string tcap_component_type_str[];
 
+extern void add_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector);
+extern void add_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector);
+
+extern void delete_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector);
+extern void delete_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector);
 
 #endif  /* PACKET_INAP_H */
index 5b4cd60101c5a800103db77f5745c4ade7cd8915..c42c2c6940921e27b96fed559ec023e65133f59c 100644 (file)
 
 #include "packet-ansi_a.h"
 #include "packet-ansi_map.h"
-
+#include "packet-tcap.h"
 
 /* PROTOTYPES/FORWARDS */
 
@@ -13149,16 +13149,16 @@ proto_reg_handoff_ansi_map(void)
 
     ansi_map_handle = create_dissector_handle(dissect_ansi_map, proto_ansi_map);
 
-    dissector_add("tcap.ansi_ssn", 5, ansi_map_handle);
-    dissector_add("tcap.ansi_ssn", 6, ansi_map_handle);
-    dissector_add("tcap.ansi_ssn", 7, ansi_map_handle);
-    dissector_add("tcap.ansi_ssn", 8, ansi_map_handle);
-    dissector_add("tcap.ansi_ssn", 9 , ansi_map_handle);
-    dissector_add("tcap.ansi_ssn", 10 , ansi_map_handle);
-    dissector_add("tcap.ansi_ssn", 11 , ansi_map_handle);
-    dissector_add("tcap.ansi_ssn", 12 , ansi_map_handle);
-    dissector_add("tcap.ansi_ssn", 13 , ansi_map_handle);
-    dissector_add("tcap.ansi_ssn", 14 , ansi_map_handle);
+    add_ansi_tcap_subdissector(5, ansi_map_handle);
+    add_ansi_tcap_subdissector(6, ansi_map_handle);
+    add_ansi_tcap_subdissector(7, ansi_map_handle);
+    add_ansi_tcap_subdissector(8, ansi_map_handle);
+    add_ansi_tcap_subdissector(9 , ansi_map_handle);
+    add_ansi_tcap_subdissector(10 , ansi_map_handle);
+    add_ansi_tcap_subdissector(11 , ansi_map_handle);
+    add_ansi_tcap_subdissector(12 , ansi_map_handle);
+    add_ansi_tcap_subdissector(13 , ansi_map_handle);
+    add_ansi_tcap_subdissector(14 , ansi_map_handle);
 
     data_handle = find_dissector("data");
 }
index de8e87604b9c5d7d07273878d8ab7621c1df6462..32c6a5a69ce55a45329c271dbe63200f9372230a 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Ethereal dissector compiler    */
-/* .\packet-camel.c                                                           */
+/* ./packet-camel.c                                                           */
 /* ../../tools/asn2eth.py -X -b -e -p camel -c camel.cnf -s packet-camel-template camel.asn */
 
 /* Input file: packet-camel-template.c */
@@ -59,6 +59,7 @@
 #include "packet-e164.h"
 #include "packet-isup.h"
 #include "packet-gsm_map.h"
+#include "packet-tcap.h"
 
 #define PNAME  "Camel"
 #define PSNAME "CAMEL"
@@ -570,7 +571,7 @@ static int hf_camel_OfferedCamel4Functionalities_criteriaForChangeOfPositionDP =
 static int hf_camel_OfferedCamel4Functionalities_serviceChangeDP = -1;
 
 /*--- End of included file: packet-camel-hf.c ---*/
-#line 83 "packet-camel-template.c"
+#line 84 "packet-camel-template.c"
 static guint global_tcap_itu_ssn = 0;
 
 /* Initialize the subtree pointers */
@@ -792,7 +793,7 @@ static gint ett_camel_ResetTimerGPRSArg = -1;
 static gint ett_camel_CancelFailedPARAM = -1;
 
 /*--- End of included file: packet-camel-ett.c ---*/
-#line 95 "packet-camel-template.c"
+#line 96 "packet-camel-template.c"
 
 
 /* Preference settings default */
@@ -7796,7 +7797,7 @@ dissect_camel_TaskRefusedPARAM(gboolean implicit_tag _U_, tvbuff_t *tvb, int off
 
 
 /*--- End of included file: packet-camel-fn.c ---*/
-#line 170 "packet-camel-template.c"
+#line 171 "packet-camel-template.c"
 
 const value_string camel_opr_code_strings[] = {
 
@@ -8229,14 +8230,14 @@ dissect_camel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
 static void range_delete_callback(guint32 ssn)
 {
   if (ssn) {
-    dissector_delete("tcap.itu_ssn", ssn, camel_handle);
+    delete_itu_tcap_subdissector(ssn, camel_handle);
   }
 }
 
 static void range_add_callback(guint32 ssn)
 {
   if (ssn) {
-    dissector_add("tcap.itu_ssn", ssn, camel_handle);
+    add_itu_tcap_subdissector(ssn, camel_handle);
   }
 }
 
@@ -10235,7 +10236,7 @@ void proto_register_camel(void) {
         "", HFILL }},
 
 /*--- End of included file: packet-camel-hfarr.c ---*/
-#line 696 "packet-camel-template.c"
+#line 697 "packet-camel-template.c"
   };
 
   /* List of subtrees */
@@ -10458,7 +10459,7 @@ void proto_register_camel(void) {
     &ett_camel_CancelFailedPARAM,
 
 /*--- End of included file: packet-camel-ettarr.c ---*/
-#line 709 "packet-camel-template.c"
+#line 710 "packet-camel-template.c"
   };
 
   /* Register protocol */
index be8dddd309049a5aee3df0b547ae0a3e333a6889..8494b09e217db4f83cbfe5a75ef9b37fed37de43 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Ethereal dissector compiler    */
-/* .\packet-camel.h                                                           */
+/* ./packet-camel.h                                                           */
 /* ../../tools/asn2eth.py -X -b -e -p camel -c camel.cnf -s packet-camel-template camel.asn */
 
 /* Input file: packet-camel-template.h */
index cb2e302c06b91549359b8a5eb968c554818dcf27..4b747c2a02d5efdf4786016e601fb220b3437607 100644 (file)
@@ -54,6 +54,7 @@
 #include "packet-q931.h"
 #include "packet-gsm_map.h"
 #include "packet-gsm_a.h"
+#include "packet-tcap.h"
 
 #define PNAME  "GSM Mobile Application"
 #define PSNAME "GSM_MAP"
@@ -897,7 +898,7 @@ static int hf_gsm_map_SupportedGADShapes_ellipsoidPointWithAltitudeAndUncertaint
 static int hf_gsm_map_SupportedGADShapes_ellipsoidArc = -1;
 
 /*--- End of included file: packet-gsm_map-hf.c ---*/
-#line 94 "packet-gsm_map-template.c"
+#line 95 "packet-gsm_map-template.c"
 
 /* Initialize the subtree pointers */
 static gint ett_gsm_map = -1;
@@ -1289,7 +1290,7 @@ static gint ett_gsm_map_UnknownOrUnreachableLCSClient_Param = -1;
 static gint ett_gsm_map_ExtensionContainer = -1;
 
 /*--- End of included file: packet-gsm_map-ett.c ---*/
-#line 106 "packet-gsm_map-template.c"
+#line 107 "packet-gsm_map-template.c"
 
 static dissector_table_t       sms_dissector_table;    /* SMS TPDU */
 static dissector_handle_t data_handle;
@@ -13425,7 +13426,7 @@ dissect_gsm_map_UnknownOrUnreachableLCSClient_Param(gboolean implicit_tag _U_, t
 
 
 /*--- End of included file: packet-gsm_map-fn.c ---*/
-#line 163 "packet-gsm_map-template.c"
+#line 164 "packet-gsm_map-template.c"
 
 const value_string gsm_map_opr_code_strings[] = {
   {   2, "updateLocation" },
@@ -14325,7 +14326,7 @@ dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
     }
 
     top_tree = parent_tree;
-    dissector_add("tcap.itu_ssn",pinfo->match_port, map_handle);
+
     /* create display subtree for the protocol */
     if(parent_tree){
         item = proto_tree_add_item(parent_tree, proto_gsm_map, tvb, 0, -1, FALSE);
@@ -14612,14 +14613,14 @@ static const value_string chargingcharacteristics_values[] = {
 static void range_delete_callback(guint32 ssn)
 {
     if (ssn) {
-       dissector_delete("tcap.itu_ssn", ssn, map_handle);
+       delete_itu_tcap_subdissector(ssn, map_handle);
     }
 }
 
 static void range_add_callback(guint32 ssn)
 {
     if (ssn) {
-       dissector_add("tcap.itu_ssn", ssn, map_handle);
+       add_itu_tcap_subdissector(ssn, map_handle);
     }
 }
 
@@ -18034,7 +18035,7 @@ void proto_register_gsm_map(void) {
         "", HFILL }},
 
 /*--- End of included file: packet-gsm_map-hfarr.c ---*/
-#line 1595 "packet-gsm_map-template.c"
+#line 1596 "packet-gsm_map-template.c"
   };
 
   /* List of subtrees */
@@ -18427,7 +18428,7 @@ void proto_register_gsm_map(void) {
     &ett_gsm_map_ExtensionContainer,
 
 /*--- End of included file: packet-gsm_map-ettarr.c ---*/
-#line 1608 "packet-gsm_map-template.c"
+#line 1609 "packet-gsm_map-template.c"
   };
 
   /* Register protocol */
index 9ec870c0ae593f8e5500dc92cfa3f992cababf27..2e4bde5f72795c4cb617d3771ce138c2c9fcb4b4 100644 (file)
@@ -50,6 +50,7 @@
 #include "packet-q931.h"
 #include "packet-e164.h"
 #include "packet-isup.h"
+#include "packet-tcap.h"
 
 #define PNAME  "Intelligent Network Application Protocol"
 #define PSNAME "INAP"
@@ -348,7 +349,7 @@ static int hf_inap_rrp = -1;                      /* ReturnResultProblem */
 static int hf_inap_rep = -1;                      /* ReturnErrorProblem */
 
 /*--- End of included file: packet-inap-hf.c ---*/
-#line 65 "packet-inap-template.c"
+#line 66 "packet-inap-template.c"
 
 static guint tcap_itu_ssn = 106;
 static guint tcap_itu_ssn1 = 241;
@@ -493,7 +494,7 @@ static gint ett_inap_T_rinvokeID = -1;
 static gint ett_inap_T_rproblem = -1;
 
 /*--- End of included file: packet-inap-ett.c ---*/
-#line 83 "packet-inap-template.c"
+#line 84 "packet-inap-template.c"
 
 static int  dissect_invokeCmd(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset);
 
@@ -4985,7 +4986,7 @@ static void dissect_TNoAnswerArg_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tr
 
 
 /*--- End of included file: packet-inap-fn.c ---*/
-#line 87 "packet-inap-template.c"
+#line 88 "packet-inap-template.c"
 
 
 const value_string inap_opr_code_strings[] = {
@@ -5506,13 +5507,13 @@ void proto_reg_handoff_inap(void) {
                inap_prefs_initialized = TRUE;
        }
        else {
-               dissector_delete("tcap.itu_ssn", tcap_itu_ssn, inap_handle);
-               dissector_delete("tcap.itu_ssn", tcap_itu_ssn1, inap_handle);
+               delete_itu_tcap_subdissector(tcap_itu_ssn, inap_handle);
+               delete_itu_tcap_subdissector(tcap_itu_ssn1, inap_handle);
        }
        tcap_itu_ssn = global_tcap_itu_ssn;
        tcap_itu_ssn1 = global_tcap_itu_ssn1;
-    dissector_add("tcap.itu_ssn", global_tcap_itu_ssn, inap_handle);
-    dissector_add("tcap.itu_ssn", global_tcap_itu_ssn1, inap_handle);
+    add_itu_tcap_subdissector(global_tcap_itu_ssn, inap_handle);
+    add_itu_tcap_subdissector(global_tcap_itu_ssn1, inap_handle);
    
 }
 
@@ -6657,7 +6658,7 @@ void proto_register_inap(void) {
         "RejectPDU/rproblem/rep", HFILL }},
 
 /*--- End of included file: packet-inap-hfarr.c ---*/
-#line 658 "packet-inap-template.c"
+#line 659 "packet-inap-template.c"
   };
 
 
@@ -6802,7 +6803,7 @@ void proto_register_inap(void) {
     &ett_inap_T_rproblem,
 
 /*--- End of included file: packet-inap-ettarr.c ---*/
-#line 676 "packet-inap-template.c"
+#line 677 "packet-inap-template.c"
   };
 
   /* Register protocol */
index d190c39d637c86ee05b954e36152d2acac8a2252..02b39cef7abfe711bc124282bbaaaebc0b6c85fc 100644 (file)
@@ -676,15 +676,13 @@ static heur_dissector_list_t heur_subdissector_list;
 static guint8 message_type = 0;
 static guint dlr = 0;
 static guint slr = 0;
-/* Put back old code(before binding) to be able to dissect data messages wher no setup info seen */
-static guint8 called_ssn = INVALID_SSN;
-static guint8 calling_ssn = INVALID_SSN;
 
 static dissector_handle_t data_handle;
 static dissector_table_t sccp_ssn_dissector_table;
 
 static GHashTable* bindings = NULL;
 sccp_binding_info_t* binding;
+sccp_binding_info_t no_binding = {NULL,NULL,0,0};
 
 static sccp_binding_info_t* sccp_binding(address* opc, address* dpc, guint src_lr, guint dst_lr) {
     
@@ -692,7 +690,7 @@ static sccp_binding_info_t* sccp_binding(address* opc, address* dpc, guint src_l
         return binding;
     
     if (!src_lr && !dst_lr)
-        return NULL;
+        return &no_binding;
     
     switch (message_type) {
         case MESSAGE_TYPE_CR:
@@ -749,7 +747,7 @@ static sccp_binding_info_t* sccp_binding(address* opc, address* dpc, guint src_l
         }
     }
     
-    return binding;
+    return binding ? binding : &no_binding;
 }
 
 
@@ -1071,13 +1069,11 @@ dissect_sccp_called_calling_param(tvbuff_t *tvb, proto_tree *tree,
     if (ssni) {
       ssn = tvb_get_guint8(tvb, offset);
       if (called) {
-                 called_ssn = ssn;
              if (binding) binding->called_ssn = ssn;
       }
       else {
              if (binding) binding->calling_ssn = ssn;
-                 calling_ssn = ssn;
-      }
+    }
 
       proto_tree_add_uint(call_tree, called ? hf_sccp_called_ssn
                                            : hf_sccp_calling_ssn,
@@ -1290,16 +1286,24 @@ dissect_sccp_data_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     guint8 ssn;
     
     if (binding) {
-        if (pinfo->p2p_dir == P2P_DIR_SENT) {
-            ssn = binding->calling_ssn;
-        } else {
-            ssn = binding->called_ssn;
+        switch (pinfo->p2p_dir) {
+            case P2P_DIR_SENT:
+                ssn = binding->calling_ssn;
+                break;
+            case P2P_DIR_RECV:
+                ssn = binding->called_ssn;
+                break;
+            default:
+                ssn = binding->called_ssn;
+                if (ssn == INVALID_SSN) ssn = binding->calling_ssn;
+                break;
         }
     } else {
-        ssn = called_ssn;
+        ssn = binding->called_ssn;
     }
     
-    if ((ssn != INVALID_SSN && dissector_try_port(sccp_ssn_dissector_table, ssn, tvb, pinfo, tree))) {
+
+    if (ssn != INVALID_SSN && dissector_try_port(sccp_ssn_dissector_table, ssn, tvb, pinfo, tree) ) {
         return;
     }
     
@@ -2133,7 +2137,7 @@ dissect_sccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   dissect_sccp_message(tvb, pinfo, sccp_tree, tree);
 }
 
-void init_sccp(void) {
+static void init_sccp(void) {
     
     if (bindings) {
         g_hash_table_destroy(bindings);
index 22bce30bda62e279bd20a12614bc22135122e165..679161c8a57161a8bcb2fb6908d6a814f56af21a 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Ethereal dissector compiler    */
-/* .\packet-tcap.c                                                            */
+/* ./packet-tcap.c                                                            */
 /* ../../tools/asn2eth.py -X -b -e -p tcap -c tcap.cnf -s packet-tcap-template tcap.asn */
 
 /* Input file: packet-tcap-template.c */
@@ -57,6 +57,7 @@ static int hf_tcap_length = -1;
 static int hf_tcap_data = -1;
 static int hf_tcap_tid = -1;
 
+
 /*--- Included file: packet-tcap-hf.c ---*/
 #line 1 "packet-tcap-hf.c"
 static int hf_tcap_dialogueRequest = -1;          /* AARQ_apdu */
@@ -184,10 +185,7 @@ static int hf_tcap_T_protocol_versionre_version1 = -1;
 static int hf_tcap_T_protocol_version3_version1 = -1;
 
 /*--- End of included file: packet-tcap-hf.c ---*/
-#line 52 "packet-tcap-template.c"
-static guint tcap_itu_ssn = 106;
-
-static guint global_tcap_itu_ssn = 1;
+#line 53 "packet-tcap-template.c"
 
 /* Initialize the subtree pointers */
 static gint ett_tcap = -1;
@@ -252,25 +250,61 @@ static gint ett_tcap_OperationCode = -1;
 static gint ett_tcap_ErrorCode = -1;
 
 /*--- End of included file: packet-tcap-ett.c ---*/
-#line 65 "packet-tcap-template.c"
+#line 63 "packet-tcap-template.c"
 
 #define MAX_SSN 254
 static range_t *global_ssn_range;
 static range_t *ssn_range;
 
-dissector_handle_t     tcap_handle;
+dissector_handle_t     tcap_handle = NULL;
 static dissector_table_t ber_oid_dissector_table=NULL;
 static const char * cur_oid;
 static const char * tcapext_oid;
 static proto_tree      *tcap_top_tree=NULL;
 static dissector_handle_t data_handle;
-static dissector_table_t tcap_itu_ssn_dissector_table; /* map use ssn in sccp */
-static dissector_table_t tcap_ansi_ssn_dissector_table; /* map use ssn in sccp */
 
+//static dissector_table_t tcap_itu_ssn_dissector_table; /* map use ssn in sccp */
+//static dissector_table_t tcap_ansi_ssn_dissector_table; /* map use ssn in sccp */
+
+static dissector_table_t sccp_ssn_table;
 static int dissect_tcap_param(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset);
 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_);
 
 
+static GHashTable* ansi_sub_dissectors = NULL;
+static GHashTable* itu_sub_dissectors = NULL;
+
+static void dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree);
+
+extern void add_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector) {
+    g_hash_table_insert(ansi_sub_dissectors,GUINT_TO_POINTER(ssn),dissector);
+    dissector_add("sccp.ssn",ssn,tcap_handle);
+}
+
+extern void add_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector) {
+    g_hash_table_insert(itu_sub_dissectors,GUINT_TO_POINTER(ssn),dissector);
+    dissector_add("sccp.ssn",ssn,tcap_handle);
+}
+
+extern void delete_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector _U_) {
+    g_hash_table_remove(ansi_sub_dissectors,GUINT_TO_POINTER(ssn));
+    dissector_delete("sccp.ssn",ssn,tcap_handle);
+}
+extern void delete_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector _U_) {
+    g_hash_table_remove(itu_sub_dissectors,GUINT_TO_POINTER(ssn));
+       dissector_delete("sccp.ssn", ssn,tcap_handle);
+}
+
+static dissector_handle_t get_ansi_tcap_subdissector(guint32 ssn) {
+    return g_hash_table_lookup(ansi_sub_dissectors,GUINT_TO_POINTER(ssn));
+}
+
+static dissector_handle_t get_itu_tcap_subdissector(guint32 ssn) {
+    return g_hash_table_lookup(itu_sub_dissectors,GUINT_TO_POINTER(ssn));
+}
+
+
+
 
 /*--- Included file: packet-tcap-fn.c ---*/
 #line 1 "packet-tcap-fn.c"
@@ -299,10 +333,10 @@ static int dissect_protocol_versionrq_impl(packet_info *pinfo, proto_tree *tree,
 
 static int
 dissect_tcap_Applicationcontext(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 128 "tcap.cnf"
+#line 142 "tcap.cnf"
   offset = dissect_ber_object_identifier_str(implicit_tag, pinfo, tree, tvb, offset, hf_index, &cur_oid);
 
-       pinfo->private_data = cur_oid;
+       pinfo->private_data = (void*)cur_oid;
 
 
 
@@ -318,11 +352,11 @@ static int
 dissect_tcap_User_information(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
 #line 77 "tcap.cnf"
 tvbuff_t       *next_tvb;
-guint8 class;
+gint8 class;
        gboolean pc;
-       guint32 tag;
+       gint tag;
        guint32 len;
-       guint32 ind_field;
+       gint ind_field;
 
 
 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
@@ -571,11 +605,11 @@ static int dissect_objectConfidentialityId_impl(packet_info *pinfo, proto_tree *
 static int
 dissect_tcap_Dialog1(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
 #line 43 "tcap.cnf"
-guint8 class;
+gint8 class;
        gboolean pc;
-       guint32 tag;
+       gint tag;
        guint32 len;
-       guint32 ind_field;
+       gint ind_field;
        
 
 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
@@ -611,10 +645,10 @@ dissect_tcap_ExternalPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, p
 
 static int
 dissect_tcap_UserInfoOID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 132 "tcap.cnf"
+#line 146 "tcap.cnf"
   offset = dissect_ber_object_identifier_str(implicit_tag, pinfo, tree, tvb, offset, hf_index, &tcapext_oid);
 
-       pinfo->private_data = tcapext_oid;
+       pinfo->private_data = (void*)tcapext_oid;
 
 
 
@@ -628,13 +662,13 @@ static int dissect_useroid(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb,
 
 static int
 dissect_tcap_ExternUserInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 136 "tcap.cnf"
+#line 150 "tcap.cnf"
 tvbuff_t       *next_tvb;
-guint8 class;
+gint8 class;
        gboolean pc;
-       guint32 tag;
+       gint tag;
        guint32 len, start_offset;
-       guint32 ind_field;
+       gint ind_field;
 /* 
  * ok lets look at the oid and ssn and try and find a dissector, otherwise lets decode it.
  */
@@ -814,11 +848,11 @@ static int
 dissect_tcap_DialogueOC(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
 #line 21 "tcap.cnf"
 tvbuff_t       *next_tvb;
-guint8 class;
+gint8 class;
        gboolean pc;
-       guint32 tag;
+       gint tag;
        guint32 len;
-       guint32 ind_field;
+       gint ind_field;
        
 
 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
@@ -929,11 +963,11 @@ static int
 dissect_tcap_Parameter(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
 #line 57 "tcap.cnf"
 tvbuff_t       *next_tvb;
-guint8 class;
+gint8 class;
        gboolean pc;
-       guint32 tag;
+       gint tag;
        guint32 len;
-       guint32 ind_field;
+       gint ind_field;
 
 
  offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
@@ -1268,16 +1302,15 @@ static int
 dissect_tcap_Component(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
 #line 95 "tcap.cnf"
 tvbuff_t       *next_tvb;
-guint8 class;
+gint8 class;
        gboolean pc;
-       guint32 tag;
+       gint tag;
        guint32 len, s_offset;
-       guint32 ind_field;
+       gint ind_field;
 /* 
  * ok lets look at the oid and ssn and try and find a dissector, otherwise lets decode it.
  */
 ber_oid_dissector_table = find_dissector_table("ber.oid");
-tcap_itu_ssn_dissector_table = find_dissector_table("tcap.itu_ssn");
 s_offset = offset;
 offset = get_ber_identifier(tvb, offset, &class, &pc, &tag);
 offset = get_ber_length(tree, tvb, offset, &len, &ind_field);
@@ -1292,11 +1325,26 @@ dissect_ber_choice(pinfo, tree, next_tvb, 0,
 if (ber_oid_dissector_table && cur_oid){
 if(!dissector_try_string(ber_oid_dissector_table, cur_oid, next_tvb, pinfo, tcap_top_tree))    
        {
-       dissector_try_port(tcap_itu_ssn_dissector_table, pinfo->match_port, next_tvb,pinfo, tcap_top_tree);
+       dissector_handle_t subdissector_handle;
+
+    if (! (subdissector_handle = get_itu_tcap_subdissector(pinfo->match_port))) {
+        subdissector_handle = data_handle;
+    } 
+
+    call_dissector(subdissector_handle, next_tvb, pinfo, tcap_top_tree);
+
        }
 }
-else
-        dissector_try_port(tcap_itu_ssn_dissector_table, pinfo->match_port, next_tvb, pinfo, tcap_top_tree);
+else {
+    dissector_handle_t subdissector_handle;
+
+    if (! (subdissector_handle = get_itu_tcap_subdissector(pinfo->match_port))) {
+        subdissector_handle = data_handle;
+    } 
+
+    call_dissector(subdissector_handle, next_tvb, pinfo, tcap_top_tree);
+}
+     
 return offset+len;
 
 
@@ -1345,7 +1393,7 @@ static int dissect_unidirectional_impl(packet_info *pinfo, proto_tree *tree, tvb
 
 static int
 dissect_tcap_OrigTransactionID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 184 "tcap.cnf"
+#line 203 "tcap.cnf"
 tvbuff_t *parameter_tvb;
 guint8 len, i;
 proto_item *tid_item;
@@ -1385,7 +1433,7 @@ static const ber_sequence_t Begin_sequence[] = {
 
 static int
 dissect_tcap_Begin(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 225 "tcap.cnf"
+#line 244 "tcap.cnf"
 if (check_col(pinfo->cinfo, COL_INFO))
                col_append_fstr(pinfo->cinfo, COL_INFO, " Begin ");
   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
@@ -1402,7 +1450,7 @@ static int dissect_begin_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tv
 
 static int
 dissect_tcap_DestTransactionID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 206 "tcap.cnf"
+#line 225 "tcap.cnf"
 tvbuff_t *parameter_tvb;
 guint8 len , i;
 proto_item *tid_item;
@@ -1439,7 +1487,7 @@ static const ber_sequence_t End_sequence[] = {
 
 static int
 dissect_tcap_End(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 230 "tcap.cnf"
+#line 249 "tcap.cnf"
 if (check_col(pinfo->cinfo, COL_INFO))
                col_append_fstr(pinfo->cinfo, COL_INFO, " End ");
 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
@@ -1463,7 +1511,7 @@ static const ber_sequence_t Continue_sequence[] = {
 
 static int
 dissect_tcap_Continue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 235 "tcap.cnf"
+#line 254 "tcap.cnf"
 if (check_col(pinfo->cinfo, COL_INFO))
                col_append_fstr(pinfo->cinfo, COL_INFO, " Continue ");
 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
@@ -1532,7 +1580,7 @@ static const ber_sequence_t Abort_sequence[] = {
 
 static int
 dissect_tcap_Abort(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 240 "tcap.cnf"
+#line 259 "tcap.cnf"
 if (check_col(pinfo->cinfo, COL_INFO))
                col_append_fstr(pinfo->cinfo, COL_INFO, " Abort ");
  offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
@@ -1751,7 +1799,7 @@ static int dissect_operationCode(packet_info *pinfo, proto_tree *tree, tvbuff_t
 
 static int
 dissect_tcap_ANSIParameters(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 163 "tcap.cnf"
+#line 177 "tcap.cnf"
 /* we are doing the ParamSet here so need to look at the tags*/
        guint32 len;
 len = tvb_length_remaining(tvb, offset);
@@ -2017,13 +2065,18 @@ static const ber_choice_t ComponentPDU_choice[] = {
 
 static int
 dissect_tcap_ComponentPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 174 "tcap.cnf"
+#line 188 "tcap.cnf"
 tvbuff_t *next_tvb;
+dissector_handle_t subdissector_handle;
 
 next_tvb = tvb_new_subset(tvb, offset, tvb_length_remaining(tvb, offset), tvb_length_remaining(tvb, offset));          
 
-dissector_try_port(tcap_ansi_ssn_dissector_table, pinfo->match_port, next_tvb, pinfo, tcap_top_tree);
+if (! (subdissector_handle = get_ansi_tcap_subdissector(pinfo->match_port))) {
+    subdissector_handle = data_handle;
+} 
 
+call_dissector(subdissector_handle, next_tvb, pinfo, tcap_top_tree);
+    
 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
                               ComponentPDU_choice, hf_index, ett_tcap_ComponentPDU,NULL);
        
@@ -2080,7 +2133,7 @@ static const ber_sequence_t TransactionPDU_sequence[] = {
 
 static int
 dissect_tcap_TransactionPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 250 "tcap.cnf"
+#line 269 "tcap.cnf"
 if ((hf_index == hf_tcap_ansiqueryWithPerm)&&(check_col(pinfo->cinfo, COL_INFO)))
                                col_append_fstr(pinfo->cinfo, COL_INFO, " QueryWithPerm");              
                                
@@ -2181,7 +2234,7 @@ static const ber_sequence_t AbortPDU_sequence[] = {
 
 static int
 dissect_tcap_AbortPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
-#line 245 "tcap.cnf"
+#line 264 "tcap.cnf"
 if (check_col(pinfo->cinfo, COL_INFO))
                col_append_fstr(pinfo->cinfo, COL_INFO, " Abort ");
    offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
@@ -2260,7 +2313,7 @@ dissect_tcap_ERROR(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_
 
 
 /*--- End of included file: packet-tcap-fn.c ---*/
-#line 84 "packet-tcap-template.c"
+#line 118 "packet-tcap-template.c"
 
 
 
@@ -2299,15 +2352,23 @@ dissect_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
 }
 
 
+void
+proto_reg_handoff_tcap(void)
+{
+    
+    static gboolean prefs_initialized = FALSE;
+    
+    if (! prefs_initialized) {
+        sccp_ssn_table = find_dissector_table("sccp.ssn");
+        prefs_initialized = TRUE;
+    }
+    
+    register_ber_oid_name("0.0.17.773.1.1.1",
+                          "itu-t(0) recommendation(0) q(17) 773 as(1) dialogue-as(1) version1(1)");
+    
+}
 
-/* Register the protocol with Ethereal */
-
-void proto_reg_handoff_tcap(void);
-
-/* this format is require because a script is used to build the C function
-   that calls all the protocol registration.
-*/
-
+static void init_tcap(void);
 
 void
 proto_register_tcap(void)
@@ -2828,7 +2889,7 @@ proto_register_tcap(void)
         "", HFILL }},
 
 /*--- End of included file: packet-tcap-hfarr.c ---*/
-#line 159 "packet-tcap-template.c"
+#line 201 "packet-tcap-template.c"
     };
 
 /* Setup protocol subtree array */
@@ -2892,7 +2953,7 @@ proto_register_tcap(void)
     &ett_tcap_ErrorCode,
 
 /*--- End of included file: packet-tcap-ettarr.c ---*/
-#line 168 "packet-tcap-template.c"
+#line 210 "packet-tcap-template.c"
     };
 
     /*static enum_val_t tcap_options[] = {
@@ -2929,72 +2990,52 @@ proto_register_tcap(void)
 #endif
 
     /* Set default SSNs */
-    range_convert_str(&global_ssn_range, "2,4-141,143-251,253,255", MAX_SSN);
+    range_convert_str(&global_ssn_range, "", MAX_SSN);
     ssn_range = range_empty();
 
     prefs_register_range_preference(tcap_module, "ssn", "SCCP SSNs",
        "SCCP (and SUA) SSNs to decode as TCAP",
        &global_ssn_range, MAX_SSN);
-
-    /* we will fake a ssn subfield which has the same value obtained from sccp */
-    tcap_itu_ssn_dissector_table = register_dissector_table("tcap.itu_ssn", "ITU TCAP SSN", FT_UINT8, BASE_DEC);
-    tcap_ansi_ssn_dissector_table = register_dissector_table("tcap.ansi_ssn", "ANSI TCAP SSN", FT_UINT8, BASE_DEC);
+    
+    ansi_sub_dissectors = g_hash_table_new(g_direct_hash,g_direct_equal);
+    itu_sub_dissectors = g_hash_table_new(g_direct_hash,g_direct_equal);
 
     /* 'globally' register dissector */
     register_dissector("tcap", dissect_tcap, proto_tcap);
 
-}
-
-
+    tcap_handle = create_dissector_handle(dissect_tcap, proto_tcap);
 
+    register_init_routine(&init_tcap);
+}
 
-/* If this dissector uses sub-dissector registration add a registration routine.
-   This format is required because a script is used to find these routines and
-   create the code that calls these routines.
-*/
 
 static void range_delete_callback(guint32 ssn)
 {
-    if (ssn) {
-       dissector_delete("sccp.ssn", ssn, tcap_handle);
+    if ( ssn && !get_ansi_tcap_subdissector(ssn) && !get_itu_tcap_subdissector(ssn) ) {
+        dissector_delete("sccp.ssn", ssn, tcap_handle);
     }
 }
 
 static void range_add_callback(guint32 ssn)
 {
-    if (ssn) {
-       dissector_add("sccp.ssn", ssn, tcap_handle);
+    if (ssn && !get_ansi_tcap_subdissector(ssn) && !get_itu_tcap_subdissector(ssn) ) {
+        dissector_add("sccp.ssn", ssn, tcap_handle);
     }
 }
 
-void
-proto_reg_handoff_tcap(void)
-{
-    static gboolean prefs_initialized = FALSE;
-
-    if (!prefs_initialized) {
 
-       tcap_handle = create_dissector_handle(dissect_tcap, proto_tcap);
-       
-       prefs_initialized = TRUE;
-
-    } else {
-
-       range_foreach(ssn_range, range_delete_callback);
+static void init_tcap(void) {
+    if (ssn_range) {
+        range_foreach(ssn_range, range_delete_callback);
+        g_free(ssn_range);
+        ssn_range = NULL;
     }
-
-    g_free(ssn_range);
+    
     ssn_range = range_copy(global_ssn_range);
-
     range_foreach(ssn_range, range_add_callback);
-    register_ber_oid_name("0.0.17.773.1.1.1",
-               "itu-t(0) recommendation(0) q(17) 773 as(1) dialogue-as(1) version1(1)");
-
+    
 }
 
-
-
-
 static int
 dissect_tcap_param(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset)
 {
index 0663e66a57c38665c95d56084539e9b79732723c..6a481d6bb32e05ed730cef1cb3a1c48b26ad5ead 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Ethereal dissector compiler    */
-/* .\packet-tcap.h                                                            */
+/* ./packet-tcap.h                                                            */
 /* ../../tools/asn2eth.py -X -b -e -p tcap -c tcap.cnf -s packet-tcap-template tcap.asn */
 
 /* Input file: packet-tcap-template.h */
@@ -65,5 +65,10 @@ extern gint tcap_standard;
 
 extern const value_string tcap_component_type_str[];
 
+extern void add_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector);
+extern void add_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector);
+
+extern void delete_ansi_tcap_subdissector(guint32 ssn, dissector_handle_t dissector);
+extern void delete_itu_tcap_subdissector(guint32 ssn, dissector_handle_t dissector);
 
 #endif  /* PACKET_INAP_H */