aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-lg8979.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-lg8979.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-lg8979.c')
-rw-r--r--epan/dissectors/packet-lg8979.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/epan/dissectors/packet-lg8979.c b/epan/dissectors/packet-lg8979.c
index 910339270f..0a0d2573ee 100644
--- a/epan/dissectors/packet-lg8979.c
+++ b/epan/dissectors/packet-lg8979.c
@@ -152,11 +152,8 @@ static gint ett_lg8979_funccode = -1;
static gint ett_lg8979_point = -1;
static gint ett_lg8979_ts = -1;
-#define PORT_LG8979 0
-
/* Globals for L&G 8979 Protocol Preferences */
static gboolean lg8979_desegment = TRUE;
-static guint global_lg8979_tcp_port = PORT_LG8979; /* Port 0, by default */
#define LG8979_HEADER 0xFF
@@ -1543,46 +1540,25 @@ proto_register_lg8979(void)
/* Register required preferences for L&G 8979 register decoding */
- lg8979_module = prefs_register_protocol(proto_lg8979, proto_reg_handoff_lg8979);
+ lg8979_module = prefs_register_protocol(proto_lg8979, NULL);
/* L&G 8979 - Desegmentmentation; defaults to TRUE for TCP desegmentation*/
prefs_register_bool_preference(lg8979_module, "desegment",
"Desegment all L&G 8979 Protocol packets spanning multiple TCP segments",
"Whether the L&G 8979 dissector should desegment all messages spanning multiple TCP segments",
&lg8979_desegment);
-
-
- /* L&G 8979 Preference - Default TCP Port, allows for "user" port either than 0. */
- prefs_register_uint_preference(lg8979_module, "tcp.port",
- "L&G 8979 Protocol Port",
- "Set the TCP port for L&G 8979 Protocol packets (if other than the default of 0)",
- 10, &global_lg8979_tcp_port);
}
/******************************************************************************************************/
void
proto_reg_handoff_lg8979(void)
{
- static int lg8979_prefs_initialized = FALSE;
- static dissector_handle_t lg8979_handle;
- static unsigned int lg8979_port;
+ dissector_handle_t lg8979_handle;
/* Make sure to use L&G 8979 Protocol Preferences field to determine default TCP port */
- if (! lg8979_prefs_initialized) {
- lg8979_handle = create_dissector_handle(dissect_lg8979_tcp, proto_lg8979);
- lg8979_prefs_initialized = TRUE;
- }
-
- if(lg8979_port != 0 && lg8979_port != global_lg8979_tcp_port){
- dissector_delete_uint("tcp.port", lg8979_port, lg8979_handle);
- }
-
- if(global_lg8979_tcp_port != 0 && lg8979_port != global_lg8979_tcp_port) {
- dissector_add_uint("tcp.port", global_lg8979_tcp_port, lg8979_handle);
- }
-
- lg8979_port = global_lg8979_tcp_port;
+ lg8979_handle = create_dissector_handle(dissect_lg8979_tcp, proto_lg8979);
+ dissector_add_for_decode_as_with_preference("tcp.port", lg8979_handle);
dissector_add_for_decode_as("rtacser.data", lg8979_handle);
}