aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-sml.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-10-07 16:25:01 -0400
committerMichael Mann <mmann78@netscape.net>2016-10-08 02:44:53 +0000
commit268841f3e00b7cf0f16c81dd2b3b952172130b8b (patch)
tree359e01cf5eba83308760531888713fe0ff0bc10b /epan/dissectors/packet-sml.c
parent11d3224142c0531879fb8e415daf9639a4eace66 (diff)
Combine Decode As and port preferences for tcp.port dissector table.
This patch introduces new APIs to allow dissectors to have a preference for a (TCP) port, but the underlying data is actually part of Decode As functionality. For now the APIs are intentionally separate from the regular APIs that register a dissector within a dissector table. It may be possible to eventually combine the two so that all dissectors that register with a dissector table have an opportunity to "automatically" have a preference to adjust the "table value" through the preferences dialog. The tcp.port dissector table was used as the guinea pig. This will eventually be expanded to other dissector tables as well (most notably UDP ports). Some dissectors that "shared" a TCP/UDP port preference were also converted. It also removed the need for some preference callback functions (mostly when the callback function was the proto_reg_handoff function) so there is cleanup around that. Dissectors that has a port preference whose default was 0 were switched to using the dissector_add_for_decode_as_with_preference API rather than dissector_add_uint_with_preference Also added comments for TCP ports used that aren't IANA registered. Change-Id: I99604f95d426ad345f4b494598d94178b886eb67 Reviewed-on: https://code.wireshark.org/review/17724 Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-sml.c')
-rw-r--r--epan/dissectors/packet-sml.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/epan/dissectors/packet-sml.c b/epan/dissectors/packet-sml.c
index 6f4916e24f..75b66f4e38 100644
--- a/epan/dissectors/packet-sml.c
+++ b/epan/dissectors/packet-sml.c
@@ -37,7 +37,6 @@ Short description of the SML protocol on the SML Wireshark Wiki page: https://w
#include <wsutil/str_util.h>
-#define TCP_PORT_SML 0
#define UDP_PORT_SML 0
#define ESC_SEQ_END G_GUINT64_CONSTANT(0x1b1b1b1b1a)
@@ -74,7 +73,6 @@ Short description of the SML protocol on the SML Wireshark Wiki page: https://w
#define LIST_6_ELEMENTS 0x76
#define MSB 0x80
-static guint tcp_port_pref = TCP_PORT_SML;
static guint udp_port_pref = UDP_PORT_SML;
/* Forward declaration we need below (if using proto_reg_handoff as a prefs callback)*/
@@ -2796,7 +2794,6 @@ void proto_register_sml (void) {
prefs_register_bool_preference (sml_module, "reassemble", "Enable reassemble", "Enable reassembling (default is enabled)", &sml_reassemble);
prefs_register_bool_preference (sml_module, "crc", "Enable crc calculation", "Enable crc (default is disabled)", &sml_crc_enabled);
- prefs_register_uint_preference(sml_module, "tcp.port", "SML TCP Port", "Set the TCP port for SML (Default is 0), recommended port is 7259", 10, &tcp_port_pref);
prefs_register_uint_preference(sml_module, "udp.port", "SML UDP Port", "Set the UDP port for SML (Default is 0), recommended port is 7259", 10, &udp_port_pref);
proto_register_field_array(proto_sml, hf, array_length(hf));
@@ -2807,21 +2804,18 @@ void proto_register_sml (void) {
void proto_reg_handoff_sml(void) {
static gboolean initialized = FALSE;
- static int old_tcp_port;
static int old_udp_port;
static dissector_handle_t sml_handle;
if (!initialized) {
sml_handle = create_dissector_handle(dissect_sml, proto_sml);
+ dissector_add_for_decode_as_with_preference("tcp.port", sml_handle);
initialized = TRUE;
} else {
- dissector_delete_uint("tcp.port", old_tcp_port, sml_handle);
dissector_delete_uint("udp.port", old_udp_port, sml_handle);
}
- old_tcp_port = tcp_port_pref;
old_udp_port = udp_port_pref;
- dissector_add_uint("tcp.port", tcp_port_pref, sml_handle);
dissector_add_uint("udp.port", udp_port_pref, sml_handle);
}