From Harald Welte:
authoretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 8 Feb 2012 19:31:23 +0000 (19:31 +0000)
committeretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 8 Feb 2012 19:31:23 +0000 (19:31 +0000)
GSMTAP dissector: introduce a dissector table.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6810

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

epan/dissectors/packet-gsm_sim.c
epan/dissectors/packet-gsmtap.c

index 17c0491..83c90f7 100644 (file)
@@ -1668,6 +1668,10 @@ proto_reg_handoff_gsm_sim(void)
        static gboolean initialized = FALSE;
 
        if (!initialized) {
+               dissector_handle_t dtap_handle;
+               dtap_handle = find_dissector("gsm_sim");
+               dissector_add_uint("gsmtap.type", 4, dtap_handle);
+
                sub_handle_cap = find_dissector("etsi_cat");
        } else {
                /* preferences have been changed */
index 869fcd5..2c98489 100644 (file)
@@ -225,6 +225,8 @@ enum {
 
 static dissector_handle_t sub_handles[GSMTAP_SUB_MAX];
 
+static dissector_table_t gsmtap_dissector_table;
+
 static const value_string gsmtap_bursts[] = {
        { GSMTAP_BURST_UNKNOWN,         "UNKNOWN" },
        { GSMTAP_BURST_FCCH,            "FCCH" },
@@ -420,11 +422,9 @@ dissect_gsmtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        col_set_str(pinfo->cinfo, COL_PROTOCOL, "GSMTAP");
 
        /* Some GSMTAP types are completely unrelated to the Um air interface */
-       switch (type) {
-       case GSMTAP_TYPE_SIM:
-               call_dissector(sub_handles[GSMTAP_SUB_SIM], payload_tvb, pinfo, tree);
+       if (dissector_try_uint(gsmtap_dissector_table, type, payload_tvb,
+                              pinfo, tree))
                return;
-       }
 
        if (arfcn & GSMTAP_ARFCN_F_UPLINK) {
                col_append_str(pinfo->cinfo, COL_RES_NET_SRC, "MS");
@@ -663,6 +663,9 @@ proto_register_gsmtap(void)
        proto_gsmtap = proto_register_protocol("GSM Radiotap", "GSMTAP", "gsmtap");
        proto_register_field_array(proto_gsmtap, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
+
+       gsmtap_dissector_table = register_dissector_table("gsmtap.type",
+                                               "GSMTAP type", FT_UINT8, BASE_HEX);
 }
 
 void
@@ -678,7 +681,6 @@ proto_reg_handoff_gsmtap(void)
        sub_handles[GSMTAP_SUB_LLC] = find_dissector("llcgprs");
        sub_handles[GSMTAP_SUB_SNDCP] = find_dissector("sndcp");
        sub_handles[GSMTAP_SUB_ABIS] = find_dissector("gsm_a_dtap");
-       sub_handles[GSMTAP_SUB_SIM] = find_dissector("gsm_sim");
        sub_handles[GSMTAP_SUB_CDMA_CODE] = find_dissector("wimax_cdma_code_burst_handler");
        sub_handles[GSMTAP_SUB_FCH] = find_dissector("wimax_fch_burst_handler");
        sub_handles[GSMTAP_SUB_FFB] = find_dissector("wimax_ffb_burst_handler");