Implement a proposal from Elefterios Gabriel for SCCP:
authorlego <lego@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 3 Apr 2007 19:08:00 +0000 (19:08 +0000)
committerlego <lego@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 3 Apr 2007 19:08:00 +0000 (19:08 +0000)
Add a table of DPCs and SSNs that allow to override the protocol that would be choosen
so that the same SSN can use two different protocols in two different DPCs.

I did not believe it someone could have done it, then I saw the captures...

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@21321 f5534014-38df-0310-8fa8-9805f1628bb7

16 files changed:
asn1/camel/Makefile.nmake
asn1/camel/packet-camel-template.c
asn1/gsmmap/packet-gsm_map-template.c
asn1/tcap/packet-tcap-template.c
asn1/tcap/packet-tcap-template.h
epan/dfilter/grammar.lemon
epan/dissectors/packet-bssap.c
epan/dissectors/packet-camel.c
epan/dissectors/packet-camel.h
epan/dissectors/packet-gsm_map.c
epan/dissectors/packet-gsm_map.h
epan/dissectors/packet-sccp.c
epan/dissectors/packet-tcap.c
epan/dissectors/packet-tcap.h
epan/uat.c
epan/uat.h

index 8022a1e68c0872ad391c2867d84d1499345e0a3f..f327d6d5e5d548e404a16d3159374302bb968d5b 100644 (file)
@@ -40,6 +40,6 @@ fix_eol: generate_dissector
        $(UNIX2DOS) < packet-$(PROTOCOL_NAME).h.tmp > packet-$(PROTOCOL_NAME).h
        del /f packet-$(PROTOCOL_NAME).c.tmp packet-$(PROTOCOL_NAME).h.tmp
 
-copy_files: generate_dissector fix_eol
+copy_files: generate_dissector
        xcopy packet-$(PROTOCOL_NAME).c ..\..\epan\dissectors /d /y
        xcopy packet-$(PROTOCOL_NAME).h ..\..\epan\dissectors /d /y
index e200f446f5996300d58c667d6467773b49133b61..3d6b3a5e753b1297ff5cbecdf658c27c63b11418 100644 (file)
@@ -888,6 +888,8 @@ void proto_register_camel(void) {
   /* Register protocol */
   proto_camel = proto_register_protocol(PNAME, PSNAME, PFNAME);
 
+  register_dissector("camel", dissect_camel, proto_camel);
+
   proto_register_field_array(proto_camel, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
 
index eec4e30a206c37d9754b20dbc836337f8814636d..3ae2b276e614cc68fd8e22b84f3067dcf7fb86ec 100644 (file)
@@ -2270,7 +2270,9 @@ void proto_register_gsm_map(void) {
 
   /* Register protocol */
   proto_gsm_map = proto_register_protocol(PNAME, PSNAME, PFNAME);
-/*XXX  register_dissector("gsm_map", dissect_gsm_map, proto_gsm_map);*/
+
+  register_dissector("gsm_map", dissect_gsm_map, proto_gsm_map);
+  
   /* Register fields and subtrees */
   proto_register_field_array(proto_gsm_map, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
index 343a77ad1696e29dba3163753d1663b1a3fa6106..f2acd890171c19db6f04d4ed99cc5ac5533da374 100644 (file)
@@ -70,6 +70,8 @@ gint ett_tcap_stat = -1;
 
 static struct tcapsrt_info_t * gp_tcapsrt_info;
 static gboolean tcap_subdissector_used=FALSE;
+static dissector_handle_t requested_subdissector_handle = NULL;
+
 static struct tcaphash_context_t * gp_tcap_context=NULL;
 
 #include "packet-tcap-ett.c"
@@ -568,7 +570,13 @@ dissect_tcap_TheComponent(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
     subdissector_handle=p_tcap_context->subdissector_handle;
     is_subdissector=TRUE;
   }
-  
+
+  /* Have SccpUsersTable protocol taking precedence over sccp.ssn table */
+  if (!is_subdissector && requested_subdissector_handle) {
+         is_subdissector = TRUE;
+         subdissector_handle = requested_subdissector_handle;
+  }
+
   if (!is_subdissector) {
     /*
      * If we do not currently know the subdissector, we have to find it
@@ -607,6 +615,7 @@ dissect_tcap_TheComponent(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
   } else {
     /* We have it already */
   }
+    
   /* Call the sub dissector if present, and not already called */
   if (is_subdissector)
     call_dissector(subdissector_handle, next_tvb, pinfo, tcap_top_tree);
@@ -647,3 +656,21 @@ dissect_tcap_TheExternUserInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int off
 
   return offset;
 }
+
+
+void call_tcap_dissector(dissector_handle_t handle, tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
+
+       requested_subdissector_handle = handle;
+
+       TRY {
+               dissect_tcap(tvb, pinfo, tree);
+       } CATCH_ALL {
+               requested_subdissector_handle = NULL;
+               RETHROW;
+       } ENDTRY;
+       
+       requested_subdissector_handle = NULL;
+
+}
+
+
index 430cab67d27a88ff6fdb01db3db30b4961b56f09..060c64ddca1eca8e75793c91bad2185864c0dcb9 100644 (file)
@@ -41,6 +41,7 @@
 #define ANSI_TC_INVOKE_N       0xed
 #define ANSI_TC_RRN            0xee
 
+
 #define        TCAP_SEQ_TAG            0x30
 #define        TCAP_SET_TAG            0x31
 
@@ -76,4 +77,6 @@ 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);
 
+extern void call_tcap_dissector(dissector_handle_t, tvbuff_t*, packet_info*, proto_tree*);
+
 #endif  /* PACKET_tcap_H */
index 7798dd5c1b49bf1d6842d9579da053b06e1ba575..2797e6a473dac5b436abddd70ea220505e2d6a4e 100644 (file)
 
 #include "grammar.h"
 
+#ifdef _WIN32
+#pragma warning(disable:4671)
+#endif
+       
 /* End of C code */
 }
 
index ab39c598985cdaf7cca4490d7c9c647940c133f3..52c05b90f37225164302b60da70d31244596ae08 100644 (file)
@@ -2491,6 +2491,8 @@ proto_register_bssap(void)
     proto_bssap = proto_register_protocol("BSSAP/BSAP", "BSSAP", "bssap");
        /*proto_bssap_plus = proto_register_protocol("BSSAP2", "BSSAP2", "bssap2");*/
 
+    register_dissector("bssap", dissect_bssap, proto_bssap);
+
     /* Required function calls to register the header fields and subtrees used */
     proto_register_field_array(proto_bssap, hf, array_length(hf));
     proto_register_subtree_array(ett, array_length(ett));
index d89c1fba83f1ef736201e9633498d3dc067c1c1e..4aba308a2caf57e3c1de8587cfff846c6f457e06 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
-/* ./packet-camel.c                                                           */
+/* .\packet-camel.c                                                           */
 /* ../../tools/asn2wrs.py -b -e -p camel -c camel.cnf -s packet-camel-template camel.asn */
 
 /* Input file: packet-camel-template.c */
@@ -10599,6 +10599,8 @@ void proto_register_camel(void) {
   /* Register protocol */
   proto_camel = proto_register_protocol(PNAME, PSNAME, PFNAME);
 
+  register_dissector("camel", dissect_camel, proto_camel);
+
   proto_register_field_array(proto_camel, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
 
index 2b424bcbe3da47455b3e666005ac42682f7449f8..ff3465d4293e9a6cb888a7faf17f39ad49037e09 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
-/* ./packet-camel.h                                                           */
+/* .\packet-camel.h                                                           */
 /* ../../tools/asn2wrs.py -b -e -p camel -c camel.cnf -s packet-camel-template camel.asn */
 
 /* Input file: packet-camel-template.h */
index b48085e93f6e528ddf1203b0b653759554aba067..d423612e0c06ac3330dd716a6019a7fc50674673 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
-/* ./packet-gsm_map.c                                                         */
+/* .\packet-gsm_map.c                                                         */
 /* ../../tools/asn2wrs.py -b -e -p gsm_map -c gsmmap.cnf -s packet-gsm_map-template GSMMAP.asn */
 
 /* Input file: packet-gsm_map-template.c */
@@ -16619,7 +16619,7 @@ static guint8 gsmmap_pdu_type = 0;
 static guint8 gsm_map_pdu_size = 0;
 
 static int
-dissect_gsm_map_GSMMAPPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo , proto_tree *tree, int hf_index) {
+dissect_gsm_map_GSMMAPPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo , proto_tree *tree, int hf_index _U_) {
 
   char *version_ptr;
   struct tcap_private_t * p_private_tcap;
@@ -21548,7 +21548,9 @@ void proto_register_gsm_map(void) {
 
   /* Register protocol */
   proto_gsm_map = proto_register_protocol(PNAME, PSNAME, PFNAME);
-/*XXX  register_dissector("gsm_map", dissect_gsm_map, proto_gsm_map);*/
+
+  register_dissector("gsm_map", dissect_gsm_map, proto_gsm_map);
+  
   /* Register fields and subtrees */
   proto_register_field_array(proto_gsm_map, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
index b30f287af45153f2d791429056cde269e1ad2036..6f493f30c68824540370a574c4c609bd47f05160 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
-/* ./packet-gsm_map.h                                                         */
+/* .\packet-gsm_map.h                                                         */
 /* ../../tools/asn2wrs.py -b -e -p gsm_map -c gsmmap.cnf -s packet-gsm_map-template GSMMAP.asn */
 
 /* Input file: packet-gsm_map-template.h */
index 67665d8116a6ac1e702bf013341afcdaeac55081..3737fdf2e4604c56ef5203649a51b4eaa755b231 100644 (file)
@@ -53,6 +53,7 @@
 #include "packet-tcap.h"
 #include "packet-sccp.h"
 #include "tap.h"
+#include <epan/uat.h>
 
 static Standard_Type decode_mtp3_standard;
 #define SCCP_SI 3
@@ -62,6 +63,7 @@ static Standard_Type decode_mtp3_standard;
 #define POINTER_LENGTH      1
 #define POINTER_LENGTH_LONG 2
 
+
 /* Same as below but with names typed out */
 static const value_string sccp_message_type_values[] = {
   { SCCP_MSG_TYPE_CR,     "Connection Request" },
@@ -699,6 +701,44 @@ static GHashTable *sccp_xudt_msg_fragment_table = NULL;
 static GHashTable *sccp_xudt_msg_reassembled_table = NULL;
 
 
+#define SCCP_USER_DATA 0
+#define SCCP_USER_TCAP 1
+#define SCCP_USER_RANAP 2
+#define SCCP_USER_BSSAP 3
+#define SCCP_USER_GSMMAP 4
+#define SCCP_USER_CAMEL 5
+#define SCCP_USER_INAP 6
+
+typedef struct _sccp_user_t {
+       guint ni;
+       range_t* called_pc;
+       range_t* called_ssn;
+       guint user;
+       gboolean uses_tcap;
+       dissector_handle_t* handlep;
+} sccp_user_t;
+
+static sccp_user_t* sccp_users;
+static guint num_sccp_users;
+
+static dissector_handle_t data_handle;
+static dissector_handle_t tcap_handle;
+static dissector_handle_t ranap_handle;
+static dissector_handle_t bssap_handle;
+static dissector_handle_t gsmmap_handle;
+static dissector_handle_t camel_handle;
+static dissector_handle_t inap_handle;
+
+static value_string sccp_users_vals[] = {
+       { SCCP_USER_DATA, "Data"},
+       { SCCP_USER_TCAP, "TCAP"},
+       { SCCP_USER_RANAP, "RANAP"},
+       { SCCP_USER_BSSAP, "BSSAP"},
+       { SCCP_USER_GSMMAP, "GSM MAP"},
+       { SCCP_USER_CAMEL, "CAMEL"},
+       { SCCP_USER_INAP, "INAP"},
+       { 0, NULL }
+};
 
 /*
  * Here are the global variables associated with
@@ -719,7 +759,6 @@ static guint8 message_type = 0;
 static guint dlr = 0;
 static guint slr = 0;
 
-static dissector_handle_t data_handle;
 static dissector_table_t sccp_ssn_dissector_table;
 
 static emem_tree_t* assocs = NULL;
@@ -778,12 +817,15 @@ sccp_assoc_info_t* get_sccp_assoc(packet_info* pinfo, guint offset, guint32 src_
                        emem_tree_key_t bw_key[] = {
                                {1, &dpck}, {1, &opck}, {1, &src_lr}, {0, NULL}
                        };
-
+                       
                        if (! ( assoc = se_tree_lookup32_array(assocs,bw_key) ) && ! pinfo->fd->flags.visited ) {
                                assoc = new_assoc(opck,dpck);
                                se_tree_insert32_array(assocs,bw_key,assoc);
                                assoc->has_bw_key = TRUE;
                        }
+                       
+                       pinfo->p2p_dir = P2P_DIR_SENT;
+                       
                        break;
                }
                case SCCP_MSG_TYPE_CC:
@@ -794,7 +836,7 @@ sccp_assoc_info_t* get_sccp_assoc(packet_info* pinfo, guint offset, guint32 src_
                        emem_tree_key_t bw_key[] = {
                                {1, &opck}, {1, &dpck}, {1, &dst_lr}, {0, NULL}
                        };
-
+                       
                        if ( ( assoc = se_tree_lookup32_array(assocs,bw_key) ) ) {
                                goto got_assoc;
                        }
@@ -803,9 +845,12 @@ sccp_assoc_info_t* get_sccp_assoc(packet_info* pinfo, guint offset, guint32 src_
                                goto got_assoc;
                        }
 
-                       assoc = new_assoc(opck,dpck);
+                       assoc = new_assoc(dpck,opck);
 
         got_assoc:
+                       
+                       pinfo->p2p_dir = P2P_DIR_RECV;
+                       
                        if ( ! pinfo->fd->flags.visited && ! assoc->has_bw_key ) {
                                se_tree_insert32_array(assocs,bw_key,assoc);
                                assoc->has_bw_key = TRUE;
@@ -823,9 +868,17 @@ sccp_assoc_info_t* get_sccp_assoc(packet_info* pinfo, guint offset, guint32 src_
                        emem_tree_key_t key[] = {
                                {1, &opck}, {1, &dpck}, {1, &dst_lr}, {0, NULL}
                        };
-
+                       
                        assoc = se_tree_lookup32_array(assocs,key);
-
+                       
+                       if (assoc) {
+                               if (assoc->calling_dpc == dpck) {
+                                       pinfo->p2p_dir = P2P_DIR_RECV;
+                               } else {
+                                       pinfo->p2p_dir = P2P_DIR_SENT;
+                               }                       
+                       }
+                       
                        break;
                }
     }
@@ -1446,40 +1499,74 @@ dissect_sccp_refusal_cause_param(tvbuff_t *tvb, proto_tree *tree, guint length,
     col_append_fstr(pinfo->cinfo, COL_INFO, "Cause=%d ", cause);
 }
 
+
 /* This function is used for both data and long data (ITU only) parameters */
 static void
 dissect_sccp_data_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
     guint8 ssn = INVALID_SSN;
     guint8 other_ssn = INVALID_SSN;
-
+    const mtp3_addr_pc_t* dpc;
+    const mtp3_addr_pc_t* opc;
+       
        if (trace_sccp && assoc && assoc != &no_assoc) {
                pinfo->sccp_info = assoc->curr_msg;
        } else {
                pinfo->sccp_info = NULL;
        }
 
-    if ( assoc ) {
-               other_ssn = INVALID_SSN;
-
-               switch (pinfo->p2p_dir) {
-                       case P2P_DIR_SENT:
-                               ssn = assoc->calling_ssn;
-                               break;
-                       case P2P_DIR_RECV:
-                               ssn = assoc->called_ssn;
-                               break;
-                       default:
-                               ssn = assoc->called_ssn;
-                               other_ssn = assoc->calling_ssn;
-                               break;
+       switch (pinfo->p2p_dir) {
+               case P2P_DIR_SENT:
+                       ssn = assoc->calling_ssn;
+                       dpc = (mtp3_addr_pc_t*)pinfo->dst.data;
+                       opc = (mtp3_addr_pc_t*)pinfo->src.data;
+                       break;
+               case P2P_DIR_RECV:
+                       ssn = assoc->called_ssn;
+                       dpc = (mtp3_addr_pc_t*)pinfo->src.data;
+                       opc = (mtp3_addr_pc_t*)pinfo->dst.data;
+                       break;
+               default:
+                       ssn = assoc->called_ssn;
+                       other_ssn = assoc->calling_ssn;
+                       dpc = (mtp3_addr_pc_t*)pinfo->dst.data;
+                       opc = (mtp3_addr_pc_t*)pinfo->src.data;
+                       break;
+       }
+
+    
+    if (num_sccp_users && pinfo->src.type == AT_SS7PC) {
+       guint i;
+       dissector_handle_t handle = NULL;
+        gboolean uses_tcap = FALSE;
+       
+       for (i=0; i < num_sccp_users; i++) {
+               sccp_user_t* u = &(sccp_users[i]);
+               
+               if (dpc->ni != u->ni) continue;
+                       
+                if (value_is_in_range(u->called_ssn, ssn)  && value_is_in_range(u->called_pc, dpc->pc) ) { 
+                       handle = *(u->handlep);
+                       uses_tcap = u->uses_tcap;
+                       break;
+               } else if (value_is_in_range(u->called_ssn, other_ssn) && value_is_in_range(u->called_pc, opc->pc) ) { 
+                       handle = *(u->handlep);
+                       uses_tcap = u->uses_tcap;
+                       break;
                }
+       }
 
-    } else {
-               ssn = assoc->called_ssn;
-               other_ssn = assoc->calling_ssn;
-    }
+       if (handle) {
+               if (uses_tcap) {
+                       call_tcap_dissector(handle, tvb, pinfo, tree);
+               } else {
+                       call_dissector(handle, tvb, pinfo, tree);
+               }
+               return;
+       }
 
+   }
+    
     if (ssn != INVALID_SSN && dissector_try_port(sccp_ssn_dissector_table, ssn, tvb, pinfo, tree)) {
                return;
     }
@@ -2502,6 +2589,68 @@ dissect_sccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
 }
 
+/*** SccpUsers Table **/
+
+static struct _sccp_ul {
+       guint id;
+       gboolean uses_tcap;
+       dissector_handle_t* handlep;
+       } user_list[] = {
+       {SCCP_USER_DATA,FALSE,&data_handle},
+       {SCCP_USER_TCAP,FALSE,&tcap_handle},
+       {SCCP_USER_RANAP,FALSE,&ranap_handle},
+       {SCCP_USER_BSSAP,FALSE,&bssap_handle},
+       {SCCP_USER_GSMMAP,TRUE,&gsmmap_handle},
+       {SCCP_USER_CAMEL,TRUE,&camel_handle},
+       {SCCP_USER_INAP,TRUE,&inap_handle},
+       {0,FALSE,NULL}
+};
+
+static void sccp_users_update_cb(void* r, char** err _U_) {
+       sccp_user_t* u = r;
+       struct _sccp_ul* c;
+               
+       for (c=user_list; c->handlep; c++) {
+               if (c->id == u->user) {
+                       u->uses_tcap = c->uses_tcap;
+                       u->handlep = c->handlep;
+                       return;
+               }
+       }
+       
+       u->uses_tcap = FALSE;
+       u->handlep = &data_handle;
+}
+
+static void* sccp_users_copy_cb(void* n, const void* o, unsigned siz) {
+       const sccp_user_t* u = o;
+       sccp_user_t* un = n;
+       
+       un->ni = u->ni;
+       un->user = u->user;
+       un->uses_tcap = u->uses_tcap;
+       un->handlep = u->handlep;
+       if (u->called_pc) un->called_pc = range_copy(u->called_pc);
+       if (u->called_ssn) un->called_ssn= range_copy(u->called_ssn);
+       
+       return n;
+}
+
+static void sccp_users_free_cb(void*r) {
+       sccp_user_t* u = r;
+       if (u->called_pc) g_free(u->called_pc);
+       if (u->called_ssn) g_free(u->called_ssn);
+}
+
+
+UAT_DEC_CB_DEF(sccp_users, ni, sccp_user_t)
+UAT_RANGE_CB_DEF(sccp_users,called_pc,sccp_user_t)
+UAT_RANGE_CB_DEF(sccp_users,called_ssn,sccp_user_t)
+UAT_VS_DEF(sccp_users, user, sccp_user_t, SCCP_USER_DATA, "Data")
+
+/** End SccpUsersTable **/
+
+
 static void init_sccp(void) {
     next_assoc_id = 1;
     fragment_table_init (&sccp_xudt_msg_fragment_table);
@@ -2908,7 +3057,29 @@ proto_register_sccp(void)
     &ett_sccp_assoc
   };
 
-  /* Register the protocol name and description */
+  static uat_field_t users_flds[] = {
+               UAT_FLD_DEC(sccp_users,ni,"Network Indicator"),
+               UAT_FLD_RANGE(sccp_users,called_pc,65535,"DPCs for which this protocol is to be used"),
+               UAT_FLD_RANGE(sccp_users,called_ssn,65535,"Called SSNs for which this protocol is to be used"),
+               UAT_FLD_VS(sccp_users,user,sccp_users_vals,"The User Protocol"),
+               UAT_END_FIELDS
+  };
+
+
+  uat_t* users_uat = uat_new("SCCP Users Table",
+       sizeof(sccp_user_t),
+       "sccp_users",
+       (void**) &sccp_users,
+       &num_sccp_users,
+       UAT_CAT_PORTS,
+       "ChSccpUsers",
+       sccp_users_copy_cb,
+       sccp_users_update_cb,
+       sccp_users_free_cb,
+       users_flds );
+  
+ /* Register the protocol name and description */
   proto_sccp = proto_register_protocol("Signalling Connection Control Part",
                                       "SCCP", "sccp");
 
@@ -2918,6 +3089,7 @@ proto_register_sccp(void)
   proto_register_field_array(proto_sccp, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
 
+
   sccp_ssn_dissector_table = register_dissector_table("sccp.ssn", "SCCP SSN", FT_UINT8, BASE_DEC);
 
   register_heur_dissector_list("sccp", &heur_subdissector_list);
@@ -2950,6 +3122,9 @@ proto_register_sccp(void)
                                                                 &show_key_params);
 
 
+  prefs_register_uat_preference(sccp_module, "users_table", "Users Table",
+                                                                 "A table that enumerates user protocols to be used against specific PCs and SSNs",
+                                                                 users_uat);
 
   register_init_routine(&init_sccp);
 
@@ -2970,5 +3145,11 @@ proto_reg_handoff_sccp(void)
   dissector_add_string("tali.opcode", "sccp", sccp_handle);
 
   data_handle = find_dissector("data");
+  tcap_handle = find_dissector("tcap");
+  ranap_handle = find_dissector("ranap");
+  bssap_handle = find_dissector("bssap");
+  gsmmap_handle = find_dissector("gsm_map");
+  camel_handle = find_dissector("camel");
+  inap_handle = find_dissector("inap");
 }
 
index d7ebc824be691a58ada0d4f72a773dad61712714..3d1227fa6499dc8bcdac8896d29aa8199e0dd120 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
-/* ./packet-tcap.c                                                            */
+/* .\packet-tcap.c                                                            */
 /* ../../tools/asn2wrs.py -b -e -p tcap -c tcap.cnf -s packet-tcap-template tcap.asn */
 
 /* Input file: packet-tcap-template.c */
@@ -206,6 +206,8 @@ gint ett_tcap_stat = -1;
 
 static struct tcapsrt_info_t * gp_tcapsrt_info;
 static gboolean tcap_subdissector_used=FALSE;
+static dissector_handle_t requested_subdissector_handle = NULL;
+
 static struct tcaphash_context_t * gp_tcap_context=NULL;
 
 
@@ -263,7 +265,7 @@ static gint ett_tcap_OperationCode = -1;
 static gint ett_tcap_ErrorCode = -1;
 
 /*--- End of included file: packet-tcap-ett.c ---*/
-#line 76 "packet-tcap-template.c"
+#line 78 "packet-tcap-template.c"
 
 #define MAX_SSN 254
 static range_t *global_ssn_range;
@@ -2322,7 +2324,7 @@ dissect_tcap_ERROR(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_,
 
 
 /*--- End of included file: packet-tcap-fn.c ---*/
-#line 141 "packet-tcap-template.c"
+#line 143 "packet-tcap-template.c"
 
 
 
@@ -2971,7 +2973,7 @@ proto_register_tcap(void)
         "", HFILL }},
 
 /*--- End of included file: packet-tcap-hfarr.c ---*/
-#line 297 "packet-tcap-template.c"
+#line 299 "packet-tcap-template.c"
     };
 
 /* Setup protocol subtree array */
@@ -3036,7 +3038,7 @@ proto_register_tcap(void)
     &ett_tcap_ErrorCode,
 
 /*--- End of included file: packet-tcap-ettarr.c ---*/
-#line 307 "packet-tcap-template.c"
+#line 309 "packet-tcap-template.c"
     };
 
     /*static enum_val_t tcap_options[] = {
@@ -3301,7 +3303,13 @@ dissect_tcap_TheComponent(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
     subdissector_handle=p_tcap_context->subdissector_handle;
     is_subdissector=TRUE;
   }
-  
+
+  /* Have SccpUsersTable protocol taking precedence over sccp.ssn table */
+  if (!is_subdissector && requested_subdissector_handle) {
+         is_subdissector = TRUE;
+         subdissector_handle = requested_subdissector_handle;
+  }
+
   if (!is_subdissector) {
     /*
      * If we do not currently know the subdissector, we have to find it
@@ -3340,6 +3348,7 @@ dissect_tcap_TheComponent(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
   } else {
     /* We have it already */
   }
+    
   /* Call the sub dissector if present, and not already called */
   if (is_subdissector)
     call_dissector(subdissector_handle, next_tvb, pinfo, tcap_top_tree);
@@ -3380,3 +3389,21 @@ dissect_tcap_TheExternUserInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int off
 
   return offset;
 }
+
+
+void call_tcap_dissector(dissector_handle_t handle, tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
+
+       requested_subdissector_handle = handle;
+
+       TRY {
+               dissect_tcap(tvb, pinfo, tree);
+       } CATCH_ALL {
+               requested_subdissector_handle = NULL;
+               RETHROW;
+       } ENDTRY;
+       
+       requested_subdissector_handle = NULL;
+
+}
+
+
index e96d482a1969d5afaada4a2ed130300834e21f70..d15cd47b391b2c19bd833bd638a36a9b4e405489 100644 (file)
@@ -1,6 +1,6 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
-/* ./packet-tcap.h                                                            */
+/* .\packet-tcap.h                                                            */
 /* ../../tools/asn2wrs.py -b -e -p tcap -c tcap.cnf -s packet-tcap-template tcap.asn */
 
 /* Input file: packet-tcap-template.h */
@@ -49,6 +49,7 @@
 #define ANSI_TC_INVOKE_N       0xed
 #define ANSI_TC_RRN            0xee
 
+
 #define        TCAP_SEQ_TAG            0x30
 #define        TCAP_SET_TAG            0x31
 
@@ -84,4 +85,6 @@ 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);
 
+extern void call_tcap_dissector(dissector_handle_t, tvbuff_t*, packet_info*, proto_tree*);
+
 #endif  /* PACKET_tcap_H */
index 0dbdedb09299e1b2b3b1c94d179dff9284ed91ed..6cf507666c2ff776b6c1f6667f14caa3c68698d5 100644 (file)
@@ -42,6 +42,7 @@
 #include <epan/report_err.h>
 #include <epan/filesystem.h>
 #include <epan/packet.h>
+#include <epan/range.h>
 
 #include "uat-int.h"
 
@@ -388,6 +389,27 @@ gboolean uat_fld_chk_enum(void* u1 _U_, const char* strptr, unsigned len, void*
        return FALSE;
 }
 
+gboolean uat_fld_chk_range(void* u1 _U_, const char* strptr, unsigned len, void* v, void* u3, char** err) {
+       char* str = ep_strndup(strptr,len);
+       range_t* r = NULL;
+       convert_ret_t ret = range_convert_str(&r, str,GPOINTER_TO_UINT(u3));
+       
+       switch (  ret ) {
+               case CVT_NO_ERROR:
+                       *err = NULL;
+                       return TRUE;
+               case CVT_SYNTAX_ERROR:
+                       *err = ep_strdup_printf("syntax error in range: %s",str);
+                       return FALSE;
+               case CVT_NUMBER_TOO_BIG:
+                       *err = ep_strdup_printf("value too large in range: '%s' (max = %u)",str,GPOINTER_TO_UINT(u3));
+                       return FALSE;
+               default:
+                       *err = "This should not happen, it is a bug in wireshark! please report to wireshark-dev@wireshark.org";
+                       return FALSE;
+       }
+}
+
 static int xton(char d) {
        switch(d) {
                case '0': return 0;
index 946d930682ebcce1470b63f1c888b8435980fb2d..8f81f70db4914953dfbfbfe04dd3bde9398b0924 100644 (file)
@@ -203,6 +203,7 @@ typedef struct _uat_field_t {
 
 
 #define UAT_CAT_GENERAL "General"
+#define UAT_CAT_PORTS "Port Assignments"
 #define UAT_CAT_CRYPTO "Decryption"
 #define UAT_CAT_FFMT "File Formats"
 
@@ -260,6 +261,7 @@ gboolean uat_fld_chk_proto(void*, const char*, unsigned, void*,void*, char** err
 gboolean uat_fld_chk_num_dec(void*, const char*, unsigned, void*, void*, char** err);
 gboolean uat_fld_chk_num_hex(void*, const char*, unsigned, void*, void*, char** err);
 gboolean uat_fld_chk_enum(void*, const char*, unsigned, void*, void*, char**);
+gboolean uat_fld_chk_range(void*, const char*, unsigned, void*, void*, char**);
 
 #define CHK_STR_IS_DECL(what) \
 gboolean uat_fld_chk_str_ ## what (void*, const char*, unsigned, void*, void*, char**)
@@ -433,6 +435,28 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr,
 #define UAT_FLD_PROTO(basename,field_name,desc) \
        {#field_name, PT_TXTMOD_STRING,{uat_fld_chk_proto,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL}
 
+/*
+ * RANGE macros
+ */
+
+#define UAT_RANGE_CB_DEF(basename,field_name,rec_t) \
+static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, void* u1 _U_, void* u2) {\
+       char* rng = ep_strndup(buf,len);\
+               range_convert_str(&(((rec_t*)rec)->field_name), rng,GPOINTER_TO_UINT(u2)); \
+       } \
+static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, void* u1 _U_, void* u2 _U_) {\
+       if ( ((rec_t*)rec)->field_name ) { \
+               *out_ptr = range_convert_range(((rec_t*)rec)->field_name);  *out_len = strlen(*out_ptr); \
+       } else { \
+               *out_ptr = ""; *out_len = 0; } } 
+
+
+#define UAT_FLD_RANGE(basename,field_name,max,desc) \
+       {#field_name, PT_TXTMOD_STRING,{uat_fld_chk_range,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},\
+         {GUINT_TO_POINTER(max),GUINT_TO_POINTER(max),GUINT_TO_POINTER(max)},0,desc,FLDFILL}
+
+
+
 
 
 #endif