aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-selfm.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-selfm.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-selfm.c')
-rw-r--r--epan/dissectors/packet-selfm.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/epan/dissectors/packet-selfm.c b/epan/dissectors/packet-selfm.c
index a977a50586..70dea920cc 100644
--- a/epan/dissectors/packet-selfm.c
+++ b/epan/dissectors/packet-selfm.c
@@ -257,8 +257,6 @@ static expert_field ei_selfm_crc16_incorrect = EI_INIT;
static dissector_handle_t selfm_handle;
-#define PORT_SELFM 0
-
#define CMD_FAST_MSG 0xA546
#define CMD_CLEAR_STATBIT 0xA5B9
#define CMD_RELAY_DEF 0xA5C0
@@ -347,7 +345,6 @@ static dissector_handle_t selfm_handle;
/* Globals for SEL Protocol Preferences */
static gboolean selfm_desegment = TRUE;
static gboolean selfm_telnet_clean = TRUE;
-static guint global_selfm_tcp_port = PORT_SELFM; /* Port 0, by default */
static gboolean selfm_crc16 = FALSE; /* Default CRC16 valdiation to false */
static const char *selfm_ser_list = NULL;
@@ -3092,7 +3089,7 @@ proto_register_selfm(void)
/* Register required preferences for SEL Protocol register decoding */
- selfm_module = prefs_register_protocol(proto_selfm, proto_reg_handoff_selfm);
+ selfm_module = prefs_register_protocol(proto_selfm, NULL);
/* SEL Protocol - Desegmentmentation; defaults to TRUE for TCP desegmentation*/
prefs_register_bool_preference(selfm_module, "desegment",
@@ -3106,11 +3103,6 @@ proto_register_selfm(void)
"Whether the SEL Protocol dissector should automatically pre-process Telnet data to remove duplicate 0xFF IAC bytes",
&selfm_telnet_clean);
- /* SEL Protocol Preference - Default TCP Port, allows for "user" port either than 0. */
- prefs_register_uint_preference(selfm_module, "tcp.port", "SEL Protocol Port",
- "Set the TCP port for SEL FM Protocol packets (if other than the default of 0)",
- 10, &global_selfm_tcp_port);
-
/* SEL Protocol Preference - Disable/Enable CRC verification, */
prefs_register_bool_preference(selfm_module, "crc_verification", "Validate Fast Message CRC16",
"Perform CRC16 validation on Fast Messages",
@@ -3131,20 +3123,7 @@ proto_register_selfm(void)
void
proto_reg_handoff_selfm(void)
{
- static int selfm_prefs_initialized = FALSE;
- static unsigned int selfm_port;
-
- /* Make sure to use SEL FM Protocol Preferences field to determine default TCP port */
- if (! selfm_prefs_initialized) {
- selfm_prefs_initialized = TRUE;
- }
- else {
- dissector_delete_uint("tcp.port", selfm_port, selfm_handle);
- }
-
- selfm_port = global_selfm_tcp_port;
-
- dissector_add_uint("tcp.port", selfm_port, selfm_handle);
+ dissector_add_for_decode_as_with_preference("tcp.port", selfm_handle);
dissector_add_for_decode_as("rtacser.data", selfm_handle);
}