summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-rsync.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-rsync.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-rsync.c')
-rw-r--r--epan/dissectors/packet-rsync.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/epan/dissectors/packet-rsync.c b/epan/dissectors/packet-rsync.c
index a849ed88f7..9ca13d66c6 100644
--- a/epan/dissectors/packet-rsync.c
+++ b/epan/dissectors/packet-rsync.c
@@ -30,9 +30,11 @@
#include <epan/packet.h>
#include <epan/conversation.h>
#include <epan/prefs.h>
+#include <epan/prefs-int.h>
#include <epan/proto_data.h>
void proto_register_rsync(void);
+void proto_reg_handoff_rsync(void);
#define RSYNCD_MAGIC_HEADER "@RSYNCD:"
#define RSYNCD_MAGIC_HEADER_LEN 8
@@ -306,10 +308,15 @@ dissect_rsync(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U
return dissect_rsync_encap(tvb, pinfo, tree, rsync_desegment);
}
-/* Register protocol with Wireshark. */
-
-void proto_reg_handoff_rsync(void);
+static void
+apply_rsync_prefs(void)
+{
+ /* Rsync uses the port preference to determine client/server */
+ pref_t *rsync_port = prefs_find_preference(prefs_find_module("rsync"), "tcp.port");
+ glb_rsync_tcp_port = *rsync_port->varp.uint;
+}
+/* Register protocol with Wireshark. */
void
proto_register_rsync(void)
{
@@ -334,14 +341,13 @@ proto_register_rsync(void)
int proto_rsync;
- proto_rsync = proto_register_protocol("RSYNC File Synchroniser",
- "RSYNC", "rsync");
+ proto_rsync = proto_register_protocol("RSYNC File Synchroniser", "RSYNC", "rsync");
hfi_rsync = proto_registrar_get_nth(proto_rsync);
proto_register_fields(proto_rsync, hfi, array_length(hfi));
proto_register_subtree_array(ett, array_length(ett));
- rsync_module = prefs_register_protocol(proto_rsync, proto_reg_handoff_rsync);
+ rsync_module = prefs_register_protocol(proto_rsync, apply_rsync_prefs);
prefs_register_uint_preference(rsync_module, "tcp_port",
"rsync TCP Port",
"Set the TCP port for RSYNC messages",
@@ -359,17 +365,7 @@ proto_register_rsync(void)
void
proto_reg_handoff_rsync(void)
{
- static gboolean initialized = FALSE;
- static guint saved_rsync_tcp_port;
-
- if (!initialized) {
- initialized = TRUE;
- } else {
- dissector_delete_uint("tcp.port", saved_rsync_tcp_port, rsync_handle);
- }
-
- dissector_add_uint("tcp.port", glb_rsync_tcp_port, rsync_handle);
- saved_rsync_tcp_port = glb_rsync_tcp_port;
+ dissector_add_uint_with_preference("tcp.port", TCP_PORT_RSYNC, rsync_handle);
}
/*