aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-kdsp.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-kdsp.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-kdsp.c')
-rw-r--r--epan/dissectors/packet-kdsp.c50
1 files changed, 12 insertions, 38 deletions
diff --git a/epan/dissectors/packet-kdsp.c b/epan/dissectors/packet-kdsp.c
index 8f429098c4..e26586b42d 100644
--- a/epan/dissectors/packet-kdsp.c
+++ b/epan/dissectors/packet-kdsp.c
@@ -25,14 +25,13 @@
#include "config.h"
#include <epan/packet.h>
-#include <epan/prefs.h>
#include <epan/expert.h>
#include "packet-tcp.h"
void proto_register_kdsp(void);
void proto_reg_handoff_kdsp(void);
-#define KDSP_PORT 2502
+#define KDSP_PORT 2502 /* Not IANA registered */
#define FRAME_HEADER_LEN 12
#define HELLO 1
@@ -100,7 +99,6 @@ void proto_reg_handoff_kdsp(void);
static int proto_kdsp = -1;
static dissector_table_t subdissector_dlt_table;
-static guint global_kdsp_tcp_port = KDSP_PORT;
static const value_string packettypenames[] = {
{0, "NULL"},
@@ -552,8 +550,6 @@ dissect_kdsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
void
proto_register_kdsp(void)
{
- module_t *kdsp_module;
-
static hf_register_info hf[] = {
{ &hf_kdsp_sentinel,
{ "Sentinel", "kdsp.sentinel",
@@ -1132,57 +1128,35 @@ proto_register_kdsp(void)
};
expert_module_t* expert_kdsp;
- proto_kdsp = proto_register_protocol(
- "Kismet Drone/Server Protocol",
- "KDSP",
- "kdsp"
- );
+ proto_kdsp = proto_register_protocol("Kismet Drone/Server Protocol", "KDSP", "kdsp");
proto_register_field_array(proto_kdsp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- kdsp_module = prefs_register_protocol(proto_kdsp, proto_reg_handoff_kdsp);
expert_kdsp = expert_register_protocol(proto_kdsp);
expert_register_field_array(expert_kdsp, ei, array_length(ei));
subdissector_dlt_table = register_dissector_table("kdsp.cpt.dlt", "KDSP DLT Type", proto_kdsp, FT_UINT32, BASE_DEC);
-
- prefs_register_uint_preference(kdsp_module, "tcp.port",
- "Kismet Drone TCP Port",
- "Set the port for Kismet Drone/Server messages (if other"
- " than the default of 2502)", 10,
- &global_kdsp_tcp_port);
-
}
void
proto_reg_handoff_kdsp(void)
{
- static gboolean initialized = FALSE;
- static guint tcp_port;
- static dissector_handle_t kdsp_handle;
+ dissector_handle_t kdsp_handle;
dissector_handle_t dlt_handle;
+ /* XXX - Should be done in respective dissectors? */
+ kdsp_handle = create_dissector_handle(dissect_kdsp, proto_kdsp);
+ dlt_handle = find_dissector("radiotap");
+ if (dlt_handle)
+ dissector_add_uint( "kdsp.cpt.dlt", DATALINK_RADIOTAP, dlt_handle);
- if (!initialized) {
- kdsp_handle = create_dissector_handle(dissect_kdsp, proto_kdsp);
- dlt_handle = find_dissector("radiotap");
- if (dlt_handle)
- dissector_add_uint( "kdsp.cpt.dlt", DATALINK_RADIOTAP, dlt_handle);
-
- dlt_handle = find_dissector("wlan");
- if (dlt_handle)
- dissector_add_uint( "kdsp.cpt.dlt", DATALINK_WLAN, dlt_handle);
-
- } else {
- dissector_delete_uint("tcp.port", tcp_port, kdsp_handle);
- }
-
- tcp_port = global_kdsp_tcp_port;
-
- dissector_add_uint("tcp.port", global_kdsp_tcp_port, kdsp_handle);
+ dlt_handle = find_dissector("wlan");
+ if (dlt_handle)
+ dissector_add_uint( "kdsp.cpt.dlt", DATALINK_WLAN, dlt_handle);
+ dissector_add_uint_with_preference("tcp.port", KDSP_PORT, kdsp_handle);
}
/*