aboutsummaryrefslogtreecommitdiffstats
path: root/epan/prefs.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-09-03 22:22:50 -0400
committerMichael Mann <mmann78@netscape.net>2016-09-16 14:58:24 +0000
commit3120536012bc85361e2e5cd204bd4aa91fb67ff6 (patch)
tree40a44f24258a339540591cfdcd95f7d2b8237c95 /epan/prefs.c
parentd67c1db3f2b16185d7cff250e098f48d94883f0e (diff)
Have TPKT support a TCP port range preference instead of having "subdissectors?" register their own.
There are a number of dissectors who are subdissectors of TPKT (and OSITP) that are not called by TCP dissector directly, yet can possibly register a TCP port "on the behalf" of TPKT. Just allow TPKT to support a range of ports to possibly include these protocols. Remove the preferences from these dissectors, but add backwards compatibility for the preferences by hooking into set_prefs and have the preferences just hook into Decode As functionality directly. Change-Id: Ic1b4959d39607f2b6b20fa6508da8d87d04cf098 Reviewed-on: https://code.wireshark.org/review/17476 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/prefs.c')
-rw-r--r--epan/prefs.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/epan/prefs.c b/epan/prefs.c
index b7a46e3d71..008e59800c 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -41,6 +41,7 @@
#include <epan/proto.h>
#include <epan/strutil.h>
#include <epan/column.h>
+#include <epan/decode_as.h>
#include "print.h"
#include <wsutil/file_util.h>
#include <wsutil/ws_printf.h> /* ws_g_warning */
@@ -4018,6 +4019,61 @@ deprecated_heur_dissector_pref(gchar *pref_name, const gchar *value)
return FALSE;
}
+static gboolean
+deprecated_port_pref(gchar *pref_name, const gchar *value)
+{
+ struct port_pref_name
+ {
+ const char* pref_name;
+ const char* module_name;
+ const char* table_name;
+ guint base;
+ };
+
+ /* These are subdissectors of TPKT/OSITP that used to have a
+ TCP port preference even though they were never
+ directly on TCP. Convert them to use Decode As
+ with the TPKT dissector handle */
+ struct port_pref_name tpkt_subdissector_port_prefs[] = {
+ {"dap.tcp.port", "DAP", "tcp.port", 10},
+ {"disp.tcp.port", "DISP", "tcp.port", 10},
+ {"dop.tcp.port", "DOP", "tcp.port", 10},
+ {"dsp.tcp.port", "DSP", "tcp.port", 10},
+ {"p1.tcp.port", "P1", "tcp.port", 10},
+ {"p7.tcp.port", "P7", "tcp.port", 10},
+ {"rdp.tcp.port", "RDP", "tcp.port", 10},
+ };
+
+ unsigned int i;
+ char *p;
+ guint uval;
+ dissector_handle_t tpkt_handle;
+
+ for (i = 0; i < sizeof(tpkt_subdissector_port_prefs)/sizeof(struct port_pref_name); i++)
+ {
+ if (strcmp(pref_name, tpkt_subdissector_port_prefs[i].pref_name) == 0)
+ {
+ /* XXX - give an error if it doesn't fit in a guint? */
+ uval = (guint)strtoul(value, &p, tpkt_subdissector_port_prefs[i].base);
+ if (p == value || *p != '\0')
+ return FALSE; /* number was bad */
+
+ /* If the value is 0 or 102 (default TPKT port), don't add to the Decode As tables */
+ if ((uval != 0) && (uval != 102))
+ {
+ tpkt_handle = find_dissector("tpkt");
+ if (tpkt_handle != NULL) {
+ dissector_change_uint(tpkt_subdissector_port_prefs[i].table_name, uval, tpkt_handle);
+ }
+ }
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
static prefs_set_pref_e
set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
gboolean return_range_errors)
@@ -4077,6 +4133,8 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
}
} else if (deprecated_heur_dissector_pref(pref_name, value)) {
/* Handled within deprecated_heur_dissector_pref() if found */
+ } else if (deprecated_port_pref(pref_name, value)) {
+ /* Handled within deprecated_port_pref() if found */
} else {
/* Handle deprecated "global" options that don't have a module
* associated with them