summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-dhcp-failover.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-dhcp-failover.c
parent11d3224142c0531879fb8e415daf9639a4eace66 (diff)
downloadwireshark-268841f3e00b7cf0f16c81dd2b3b952172130b8b.tar.gz
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-dhcp-failover.c')
-rw-r--r--epan/dissectors/packet-dhcp-failover.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/epan/dissectors/packet-dhcp-failover.c b/epan/dissectors/packet-dhcp-failover.c
index 1146df9c59..7321dd92fa 100644
--- a/epan/dissectors/packet-dhcp-failover.c
+++ b/epan/dissectors/packet-dhcp-failover.c
@@ -44,13 +44,11 @@
#include "packet-arp.h"
#include "packet-tcp.h"
-#define TCP_PORT_DHCPFO 519
+#define TCP_PORT_DHCPFO 519 /* Not IANA registered */
void proto_register_dhcpfo(void);
void proto_reg_handoff_dhcpfo(void);
-static guint tcp_port_pref = TCP_PORT_DHCPFO;
-
/* desegmentation of DHCP failover over TCP */
static gboolean dhcpfo_desegment = TRUE;
@@ -1132,8 +1130,7 @@ proto_register_dhcpfo(void)
expert_module_t* expert_dhcpfo;
/* Register the protocol name and description */
- proto_dhcpfo = proto_register_protocol("DHCP Failover", "DHCPFO",
- "dhcpfo");
+ proto_dhcpfo = proto_register_protocol("DHCP Failover", "DHCPFO", "dhcpfo");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_dhcpfo, hf, array_length(hf));
@@ -1141,10 +1138,8 @@ proto_register_dhcpfo(void)
expert_dhcpfo = expert_register_protocol(proto_dhcpfo);
expert_register_field_array(expert_dhcpfo, ei, array_length(ei));
- dhcpfo_module = prefs_register_protocol(proto_dhcpfo, proto_reg_handoff_dhcpfo);
- prefs_register_uint_preference(dhcpfo_module, "tcp_port",
- "DHCP failover TCP Port", "Set the port for DHCP failover communications",
- 10, &tcp_port_pref);
+ dhcpfo_module = prefs_register_protocol(proto_dhcpfo, NULL);
+
prefs_register_bool_preference(dhcpfo_module, "desegment",
"Reassemble DHCP failover messages spanning multiple TCP segments",
"Whether the DHCP failover dissector should reassemble messages spanning multiple TCP segments."
@@ -1155,18 +1150,10 @@ proto_register_dhcpfo(void)
void
proto_reg_handoff_dhcpfo(void)
{
- static gboolean initialized = FALSE;
- static dissector_handle_t dhcpfo_handle;
- static guint saved_tcp_port;
+ dissector_handle_t dhcpfo_handle;
- if (!initialized) {
- dhcpfo_handle = create_dissector_handle(dissect_dhcpfo, proto_dhcpfo);
- initialized = TRUE;
- } else {
- dissector_delete_uint("tcp.port", saved_tcp_port, dhcpfo_handle);
- }
- dissector_add_uint("tcp.port", tcp_port_pref, dhcpfo_handle);
- saved_tcp_port = tcp_port_pref;
+ dhcpfo_handle = create_dissector_handle(dissect_dhcpfo, proto_dhcpfo);
+ dissector_add_uint_with_preference("tcp.port", TCP_PORT_DHCPFO, dhcpfo_handle);
}
/*