media_type: Default decode application/octet-stream as data
authorStig Bjørlykke <stig@bjorlykke.org>
Thu, 24 May 2018 19:02:26 +0000 (21:02 +0200)
committerGuy Harris <guy@alum.mit.edu>
Fri, 25 May 2018 02:41:29 +0000 (02:41 +0000)
Remove registering media_type application/octet-stream from both
thread and uasip because the settings will interfere each other.

Enable decoding as for media_type instead.

Bug: 14729
Change-Id: I58c527977fe4713418219fc3126ce7a93c4bb641
Reviewed-on: https://code.wireshark.org/review/27789
Reviewed-by: Guy Harris <guy@alum.mit.edu>
epan/dissectors/packet-data.c
epan/dissectors/packet-thread.c
epan/dissectors/packet-uasip.c

index a26144f3f12b0af98e7e3fe7053d269a78a42d8d..459b4a44495ffdcf04c97ad8c6fba52b442eac85 100644 (file)
@@ -23,6 +23,7 @@
  * print routines
  */
 void proto_register_data(void);
+void proto_reg_handoff_data(void);
 
 int proto_data = -1;
 
@@ -53,6 +54,8 @@ static gboolean generate_md5_hash = FALSE;
 
 static gint ett_data = -1;
 
+static dissector_handle_t data_handle;
+
 static int
 dissect_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
 {
@@ -147,7 +150,7 @@ proto_register_data(void)
                "data"          /* abbrev */
                );
 
-       register_dissector("data", dissect_data, proto_data);
+       data_handle = register_dissector("data", dissect_data, proto_data);
 
        proto_register_fields(proto_data, hfi, array_length(hfi));
        proto_register_subtree_array(ett, array_length(ett));
@@ -183,6 +186,12 @@ proto_register_data(void)
        proto_set_cant_toggle(proto_data);
 }
 
+void
+proto_reg_handoff_data(void)
+{
+       dissector_add_string("media_type", "application/octet-stream", data_handle);
+}
+
 /*
  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
  *
index a944a4e808eec611ef8bc873031b37f45a4b09ea..bbdf65ad6612c0f8ddfe0ac71e5d92c45bde8c87 100644 (file)
@@ -1,5 +1,5 @@
 /* packet-thread.c
- * Routines for Thread CoAP and beacon packet dissection
+ * Routines for Thread over CoAP and beacon packet dissection
  *
  * Robert Cragie <robert.cragie@arm.com>
  *
@@ -681,7 +681,6 @@ static const value_string thread_bcn_tlv_vals[] = {
 };
 
 /* Preferences */
-static gboolean thread_coap_decode = FALSE;
 static gboolean thread_use_pan_id_in_key = FALSE;
 static const gchar *thread_seq_ctr_str = NULL;
 static gboolean thread_auto_acq_seq_ctr = TRUE;
@@ -3362,11 +3361,7 @@ proto_register_thread(void)
     proto_thread = proto_register_protocol("Thread", "Thread", "thread");
 
     thread_module = prefs_register_protocol(proto_thread, proto_reg_handoff_thread);
-    prefs_register_bool_preference(thread_module, "thr_coap_decode",
-                                   "Decode CoAP for Thread",
-                                   "Try to decode CoAP for Thread",
-                                   &thread_coap_decode);
-
+    prefs_register_obsolete_preference(thread_module, "thr_coap_decode");
     prefs_register_string_preference(thread_module, "thr_seq_ctr",
                                      "Thread sequence counter",
                                      "32-bit sequence counter for hash",
@@ -3429,11 +3424,8 @@ void
 proto_reg_handoff_thread(void)
 {
     /* Thread Content-Format is opaque byte string, i.e. application/octet-stream */
-    if (thread_coap_decode) {
-        dissector_add_string("media_type", "application/octet-stream", thread_coap_handle);
-    } else {
-        dissector_delete_string("media_type", "application/octet-stream", thread_coap_handle);
-    }
+    /* Enable decoding "Internet media type" as Thread over CoAP */
+    dissector_add_for_decode_as("media_type", thread_coap_handle);
 
     proto_coap = proto_get_id_by_filter_name("coap");
 }
index 3a8333047d192b5d0d2ddef4897750a5dd7adc0a..03bb4f8ca2c01ca8156a61de455c49e2eaded91a 100644 (file)
@@ -54,7 +54,6 @@ static expert_field ei_uasip_tlv_length = EI_INIT;
 static guint8      proxy_ipaddr[4];
 static const char *pref_proxy_ipaddr_s = NULL;
 
-static gboolean uasip_enabled = FALSE;
 static gboolean use_proxy_ipaddr = FALSE;
 static gboolean noesip_enabled   = FALSE;
 
@@ -519,7 +518,7 @@ void proto_register_uasip(void)
     expert_register_field_array(expert_uasip, ei, array_length(ei));
 
     uasip_module = prefs_register_protocol(proto_uasip, proto_reg_handoff_uasip);
-    prefs_register_bool_preference(uasip_module, "aplication_octet_stream", "Try to decode application/octet-stream as UASIP", "UA SIP Protocol enabled", &uasip_enabled);
+    prefs_register_obsolete_preference(uasip_module, "aplication_octet_stream");
     prefs_register_bool_preference(uasip_module, "noesip", "Try to decode SIP NOE", "NOE SIP Protocol", &noesip_enabled);
     prefs_register_string_preference(uasip_module, "proxy_ipaddr", "Proxy IP Address",
                                      "IPv4 address of the proxy (Invalid values will be ignored)",
@@ -543,11 +542,8 @@ void proto_reg_handoff_uasip(void)
     use_proxy_ipaddr = FALSE;
     memset(proxy_ipaddr, 0, sizeof(proxy_ipaddr));
 
-    if(uasip_enabled){
-        dissector_add_string("media_type", "application/octet-stream", uasip_handle);
-    }else{
-        dissector_delete_string("media_type", "application/octet-stream", uasip_handle);
-    }
+    /* Enable decoding "Internet media type" as UASIP */
+    dissector_add_for_decode_as("media_type", uasip_handle);
 
     if (strcmp(pref_proxy_ipaddr_s, "") != 0) {
         if (str_to_ip(pref_proxy_ipaddr_s, proxy_ipaddr)) {