aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ipsec-tcp.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-ipsec-tcp.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-ipsec-tcp.c')
-rw-r--r--epan/dissectors/packet-ipsec-tcp.c38
1 files changed, 7 insertions, 31 deletions
diff --git a/epan/dissectors/packet-ipsec-tcp.c b/epan/dissectors/packet-ipsec-tcp.c
index 9941c269a7..fd4e333cb4 100644
--- a/epan/dissectors/packet-ipsec-tcp.c
+++ b/epan/dissectors/packet-ipsec-tcp.c
@@ -32,7 +32,6 @@
#include "config.h"
#include <epan/packet.h>
-#include <epan/prefs.h>
#include "packet-ndmp.h"
void proto_register_tcpencap(void);
@@ -67,11 +66,6 @@ static const value_string tcpencap_proto_vals[] = {
#define TRAILERLENGTH 16
#define TCP_CISCO_IPSEC 10000
-/* Another case of several companies creating protocols and
- choosing an easy-to-remember port. Playing tonight: Cisco vs NDMP.
- Since NDMP has officially registered port 10000 with IANA, it should be the default
-*/
-static guint global_tcpencap_tcp_port = 0;
static dissector_handle_t esp_handle;
static dissector_handle_t udp_handle;
@@ -224,43 +218,25 @@ proto_register_tcpencap(void)
&ett_tcpencap_unknown,
};
- module_t *tcpencap_module;
+ proto_tcpencap = proto_register_protocol("TCP Encapsulation of IPsec Packets", "TCPENCAP", "tcpencap");
- proto_tcpencap = proto_register_protocol(
- "TCP Encapsulation of IPsec Packets", "TCPENCAP", "tcpencap");
proto_register_field_array(proto_tcpencap, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- tcpencap_module = prefs_register_protocol(proto_tcpencap, proto_reg_handoff_tcpencap);
- prefs_register_uint_preference(tcpencap_module, "tcp.port", "IPSEC TCP Port",
- "Set the port for IPSEC/ISAKMP messages (typically 10000)",
- 10, &global_tcpencap_tcp_port);
}
void
proto_reg_handoff_tcpencap(void)
{
- static dissector_handle_t tcpencap_handle;
- static gboolean initialized = FALSE;
- static guint tcpencap_tcp_port = 0;
+ dissector_handle_t tcpencap_handle;
- if (!initialized) {
- tcpencap_handle = create_dissector_handle(dissect_tcpencap, proto_tcpencap);
- esp_handle = find_dissector_add_dependency("esp", proto_tcpencap);
- udp_handle = find_dissector_add_dependency("udp", proto_tcpencap);
+ tcpencap_handle = create_dissector_handle(dissect_tcpencap, proto_tcpencap);
+ esp_handle = find_dissector_add_dependency("esp", proto_tcpencap);
+ udp_handle = find_dissector_add_dependency("udp", proto_tcpencap);
- heur_dissector_add("tcp", dissect_tcpencap_heur, "TCP Encapsulation of IPsec Packets", "ipsec_tcp", proto_tcpencap, HEURISTIC_ENABLE);
-
- initialized = TRUE;
- }
+ heur_dissector_add("tcp", dissect_tcpencap_heur, "TCP Encapsulation of IPsec Packets", "ipsec_tcp", proto_tcpencap, HEURISTIC_ENABLE);
/* Register TCP port for dissection */
- if(tcpencap_tcp_port != 0 && tcpencap_tcp_port != global_tcpencap_tcp_port){
- dissector_delete_uint("tcp.port", tcpencap_tcp_port, tcpencap_handle);
- }
-
- if(global_tcpencap_tcp_port != 0 && tcpencap_tcp_port != global_tcpencap_tcp_port) {
- dissector_add_uint("tcp.port", global_tcpencap_tcp_port, tcpencap_handle);
- }
+ dissector_add_for_decode_as_with_preference("tcp.port", tcpencap_handle);
}
/*