aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-cops.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-cops.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-cops.c')
-rw-r--r--epan/dissectors/packet-cops.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/epan/dissectors/packet-cops.c b/epan/dissectors/packet-cops.c
index 68226ef780..280027d796 100644
--- a/epan/dissectors/packet-cops.c
+++ b/epan/dissectors/packet-cops.c
@@ -72,9 +72,6 @@
void proto_register_cops(void);
-/* Preference: Variable to hold the tcp port preference */
-static guint global_cops_tcp_port = TCP_PORT_COPS;
-
/* Preference: desegmentation of COPS */
static gboolean cops_desegment = TRUE;
@@ -2814,8 +2811,7 @@ void proto_register_cops(void)
expert_module_t* expert_cops;
/* Register the protocol name and description */
- proto_cops = proto_register_protocol("Common Open Policy Service",
- "COPS", "cops");
+ proto_cops = proto_register_protocol("Common Open Policy Service", "COPS", "cops");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_cops, hf, array_length(hf));
@@ -2827,11 +2823,7 @@ void proto_register_cops(void)
register_dissector("cops", dissect_cops, proto_cops);
/* Register our configuration options for cops */
- cops_module = prefs_register_protocol(proto_cops, proto_reg_handoff_cops);
- prefs_register_uint_preference(cops_module,"tcp.cops_port",
- "COPS TCP Port",
- "Set the TCP port for COPS messages",
- 10,&global_cops_tcp_port);
+ cops_module = prefs_register_protocol(proto_cops, NULL);
prefs_register_bool_preference(cops_module, "desegment",
"Reassemble COPS messages spanning multiple TCP segments",
"Whether the COPS dissector should reassemble messages spanning multiple TCP segments."
@@ -2853,21 +2845,15 @@ void proto_register_cops(void)
void proto_reg_handoff_cops(void)
{
- static gboolean cops_prefs_initialized = FALSE;
- static dissector_handle_t cops_handle;
- static guint cops_tcp_port;
-
- if (!cops_prefs_initialized) {
- cops_handle = find_dissector("cops");
- dissector_add_uint("tcp.port", TCP_PORT_PKTCABLE_COPS, cops_handle);
- dissector_add_uint("tcp.port", TCP_PORT_PKTCABLE_MM_COPS, cops_handle);
- cops_prefs_initialized = TRUE;
- } else {
- dissector_delete_uint("tcp.port",cops_tcp_port,cops_handle);
- }
- cops_tcp_port = global_cops_tcp_port;
+ dissector_handle_t cops_handle;
+
+ cops_handle = find_dissector("cops");
+ /* These could use a separate "preference name" (to avoid collision),
+ but they are IANA registered and users could still use Decode As */
+ dissector_add_uint("tcp.port", TCP_PORT_PKTCABLE_COPS, cops_handle);
+ dissector_add_uint("tcp.port", TCP_PORT_PKTCABLE_MM_COPS, cops_handle);
- dissector_add_uint("tcp.port", cops_tcp_port, cops_handle);
+ dissector_add_uint_with_preference("tcp.port", TCP_PORT_COPS, cops_handle);
}