aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-knet.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-knet.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-knet.c')
-rw-r--r--epan/dissectors/packet-knet.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/epan/dissectors/packet-knet.c b/epan/dissectors/packet-knet.c
index 25bd5bb004..ecaa151fa2 100644
--- a/epan/dissectors/packet-knet.c
+++ b/epan/dissectors/packet-knet.c
@@ -32,7 +32,7 @@ void proto_register_knet(void);
void proto_reg_handoff_knet(void);
#define PROTO_TAG_KNET "KNET" /*!< Definition of kNet Protocol */
-#define PORT 2345
+#define PORT 2345 /* Not IANA registered */
#define KNET_SCTP_PACKET 1000
#define KNET_TCP_PACKET 1001
@@ -119,7 +119,6 @@ static dissector_handle_t knet_handle_udp;
/* Ports used by the dissectors */
static guint32 knet_sctp_port = PORT; /*!< Port used by kNet SCTP */
-static guint32 knet_tcp_port = PORT; /*!< Port used by kNet TCP */
static guint32 knet_udp_port = PORT; /*!< Port used by kNet UDP */
static const value_string packettypenames[] = { /*!< Messageid List */
@@ -758,10 +757,6 @@ proto_register_knet(void)
"Set the SCTP port for kNet messages",
10, &knet_sctp_port);
- prefs_register_uint_preference(knet_module, "tcp.port", "kNet TCP Port",
- "Set the TCP port for kNet messages",
- 10, &knet_tcp_port);
-
prefs_register_uint_preference(knet_module, "udp.port", "kNet UDP Port",
"Set the UDP port for kNet messages",
10, &knet_udp_port);
@@ -777,26 +772,22 @@ proto_reg_handoff_knet(void)
static gboolean initialized = FALSE;
static guint current_sctp_port;
- static guint current_tcp_port;
static guint current_udp_port;
if(!initialized)
{
+ dissector_add_uint_with_preference("tcp.port", PORT, knet_handle_tcp);
initialized = TRUE;
}
else
{
dissector_delete_uint("sctp.port", current_sctp_port, knet_handle_sctp);
- dissector_delete_uint("tcp.port", current_tcp_port, knet_handle_tcp);
dissector_delete_uint("udp.port", current_udp_port, knet_handle_udp);
}
current_sctp_port = knet_sctp_port;
dissector_add_uint("sctp.port", current_sctp_port, knet_handle_sctp);
- current_tcp_port = knet_tcp_port;
- dissector_add_uint("tcp.port", current_tcp_port, knet_handle_tcp);
-
current_udp_port = knet_udp_port;
dissector_add_uint("udp.port", current_udp_port, knet_handle_udp);
}