aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-pdc.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-pdc.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-pdc.c')
-rw-r--r--epan/dissectors/packet-pdc.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/epan/dissectors/packet-pdc.c b/epan/dissectors/packet-pdc.c
index eba89fab7a..e1c8d23949 100644
--- a/epan/dissectors/packet-pdc.c
+++ b/epan/dissectors/packet-pdc.c
@@ -24,7 +24,6 @@
#include "config.h"
#include <epan/packet.h>
-#include <epan/prefs.h>
#include "packet-tcp.h"
void proto_register_pdc(void);
@@ -57,7 +56,6 @@ void proto_reg_handoff_pdc(void);
static dissector_handle_t asterix_handle;
static int proto_pdc = -1;
-static guint gPREF_PORT_NUM_TCP = 0;
/*HF Declarations*/
static gint hf_pdc_len = -1;
@@ -475,8 +473,6 @@ static int tcp_dissect_pdc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void proto_register_pdc(void)
{
- module_t *pdc_pref_module;
-
static hf_register_info hf[] =
{
{ &hf_pdc_len,
@@ -579,37 +575,17 @@ void proto_register_pdc(void)
/*Required Function Calls to register the header fields and subtrees used*/
proto_register_field_array(proto_pdc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
-
- /*Register Preferences Module*/
- pdc_pref_module = prefs_register_protocol(proto_pdc, proto_reg_handoff_pdc);
-
- /*Register Preferences*/
- prefs_register_uint_preference(pdc_pref_module, "tcp.port", "PDC Port", "PDC Port if other then the default", 10, &gPREF_PORT_NUM_TCP);
}
/* Function to add pdc dissector to tcp.port dissector table and to get handle for asterix dissector */
void proto_reg_handoff_pdc(void)
{
- static dissector_handle_t pdc_tcp_handle;
- static int pdc_tcp_port;
- static gboolean initialized = FALSE;
+ dissector_handle_t pdc_tcp_handle;
- if (! initialized)
- {
- asterix_handle = find_dissector_add_dependency("asterix", proto_pdc);
- pdc_tcp_handle = create_dissector_handle(tcp_dissect_pdc, proto_pdc);
- dissector_add_for_decode_as("tcp.port", pdc_tcp_handle);
- initialized = TRUE;
- }
- else
- {
- if (pdc_tcp_port != 0)
- dissector_delete_uint("tcp.port", pdc_tcp_port, pdc_tcp_handle);
- }
+ asterix_handle = find_dissector_add_dependency("asterix", proto_pdc);
+ pdc_tcp_handle = create_dissector_handle(tcp_dissect_pdc, proto_pdc);
- pdc_tcp_port = gPREF_PORT_NUM_TCP;
- if (pdc_tcp_port != 0)
- dissector_add_uint("tcp.port", pdc_tcp_port, pdc_tcp_handle);
+ dissector_add_for_decode_as_with_preference("tcp.port", pdc_tcp_handle);
}
/*