aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-10-05 16:33:54 -0400
committerMichael Mann <mmann78@netscape.net>2016-10-13 02:51:18 +0000
commit2eb7b05b8c9c6408268f0d1e81f0a18a02610f1c (patch)
treebd0a909e3d506ea2e61c446aa8a809b6f728af3b /plugins
parent4d8581d7e15fe4a80a53496b83a853271fc674b6 (diff)
Convert most UDP dissectors to use "auto" preferences.
Similar to the "tcp.port" changes in I99604f95d426ad345f4b494598d94178b886eb67, convert dissectors that use "udp.port". More cleanup done on dissectors that use both TCP and UDP dissector tables, so that less preference callbacks exist. Change-Id: If07be9b9e850c244336a7069599cd554ce312dd3 Reviewed-on: https://code.wireshark.org/review/18120 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ethercat/packet-ethercat-frame.c5
-rw-r--r--plugins/profinet/packet-pn-rt.c4
-rw-r--r--plugins/unistim/packet-unistim.c34
-rw-r--r--plugins/wimaxasncp/packet-wimaxasncp.c43
-rw-r--r--plugins/wimaxmacphy/packet-wimaxmacphy.c41
5 files changed, 17 insertions, 110 deletions
diff --git a/plugins/ethercat/packet-ethercat-frame.c b/plugins/ethercat/packet-ethercat-frame.c
index e9c7c92c59..53b60b7112 100644
--- a/plugins/ethercat/packet-ethercat-frame.c
+++ b/plugins/ethercat/packet-ethercat-frame.c
@@ -129,8 +129,7 @@ void proto_register_ethercat_frame(void)
&ett_ethercat_frame
};
- proto_ethercat_frame = proto_register_protocol("EtherCAT frame header",
- "ETHERCAT","ecatf");
+ proto_ethercat_frame = proto_register_protocol("EtherCAT frame header", "ETHERCAT", "ecatf");
proto_register_field_array(proto_ethercat_frame,hf,array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@@ -148,7 +147,7 @@ void proto_reg_handoff_ethercat_frame(void)
ethercat_frame_handle = find_dissector("ecatf");
dissector_add_uint("ethertype", ETHERTYPE_ECATF, ethercat_frame_handle);
- dissector_add_uint("udp.port", ETHERTYPE_ECATF, ethercat_frame_handle);
+ dissector_add_uint_with_preference("udp.port", ETHERTYPE_ECATF, ethercat_frame_handle);
dissector_add_uint_with_preference("tcp.port", ETHERTYPE_ECATF, ethercat_frame_handle);
}
diff --git a/plugins/profinet/packet-pn-rt.c b/plugins/profinet/packet-pn-rt.c
index 885cd9fc68..6ee55eb67c 100644
--- a/plugins/profinet/packet-pn-rt.c
+++ b/plugins/profinet/packet-pn-rt.c
@@ -39,6 +39,8 @@
void proto_register_pn_rt(void);
void proto_reg_handoff_pn_rt(void);
+#define PROFINET_UDP_PORT 0x8892
+
/* Define the pn-rt proto */
static int proto_pn_rt = -1;
static gboolean pnio_desegment = TRUE;
@@ -1001,7 +1003,7 @@ proto_reg_handoff_pn_rt(void)
pn_rt_handle = create_dissector_handle(dissect_pn_rt, proto_pn_rt);
dissector_add_uint("ethertype", ETHERTYPE_PROFINET, pn_rt_handle);
- dissector_add_uint("udp.port", 0x8892, pn_rt_handle);
+ dissector_add_uint_with_preference("udp.port", PROFINET_UDP_PORT, pn_rt_handle);
heur_dissector_add("pn_rt", dissect_CSF_SDU_heur, "PROFINET CSF_SDU IO", "pn_csf_sdu_pn_rt", proto_pn_rt, HEURISTIC_ENABLE);
heur_dissector_add("pn_rt", dissect_FRAG_PDU_heur, "PROFINET Frag PDU IO", "pn_frag_pn_rt", proto_pn_rt, HEURISTIC_ENABLE);
diff --git a/plugins/unistim/packet-unistim.c b/plugins/unistim/packet-unistim.c
index de74ec2837..1db183f081 100644
--- a/plugins/unistim/packet-unistim.c
+++ b/plugins/unistim/packet-unistim.c
@@ -29,7 +29,6 @@
#include <epan/packet.h>
#include <epan/tap.h>
#include <epan/expert.h>
-#include <epan/prefs.h>
#include <epan/dissectors/packet-rtp.h>
#include <epan/dissectors/packet-rtcp.h>
#include "packet-unistim.h"
@@ -45,11 +44,6 @@
void proto_register_unistim(void);
-/* Don't set this to 5000 until this dissector is made a heuristic one!
- It collides (at least) with tapa.
- static guint global_unistim_port = 5000; */
-static guint global_unistim_port = 0;
-
static unistim_info_t *uinfo;
static int unistim_tap = -1;
@@ -2692,8 +2686,6 @@ dissect_audio_phone(proto_tree *msg_tree,
void
proto_register_unistim(void){
- module_t* unistim_module;
-
static hf_register_info hf[] = {
{ &hf_unistim_seq_nu,
{ "RUDP Seq Num","unistim.num",FT_UINT32,
@@ -4041,33 +4033,15 @@ proto_register_unistim(void){
expert_register_field_array(expert_unistim, ei, array_length(ei));
unistim_tap = register_tap("unistim");
-
- unistim_module = prefs_register_protocol(proto_unistim, proto_reg_handoff_unistim);
-
- prefs_register_uint_preference(unistim_module, "udp.port", "UNISTIM UDP port",
- "UNISTIM port (default 5000)", 10, &global_unistim_port);
}
void
proto_reg_handoff_unistim(void) {
- static gboolean initialized = FALSE;
- static dissector_handle_t unistim_handle;
- static guint unistim_port;
-
- if (!initialized) {
- unistim_handle=create_dissector_handle(dissect_unistim,proto_unistim);
- dissector_add_for_decode_as("udp.port", unistim_handle);
- initialized=TRUE;
- } else {
- if (unistim_port != 0) {
- dissector_delete_uint("udp.port",unistim_port,unistim_handle);
- }
- }
- if (global_unistim_port != 0) {
- dissector_add_uint("udp.port",global_unistim_port,unistim_handle);
- }
- unistim_port = global_unistim_port;
+ dissector_handle_t unistim_handle;
+
+ unistim_handle=create_dissector_handle(dissect_unistim,proto_unistim);
+ dissector_add_for_decode_as_with_preference("udp.port", unistim_handle);
}
/*
diff --git a/plugins/wimaxasncp/packet-wimaxasncp.c b/plugins/wimaxasncp/packet-wimaxasncp.c
index 1c829f3c4c..27d06c81e8 100644
--- a/plugins/wimaxasncp/packet-wimaxasncp.c
+++ b/plugins/wimaxasncp/packet-wimaxasncp.c
@@ -87,7 +87,6 @@ static gboolean debug_enabled = FALSE;
/* Default WiMAX ASN control protocol port */
#define WIMAXASNCP_DEF_UDP_PORT 2231
-static guint global_wimaxasncp_udp_port = WIMAXASNCP_DEF_UDP_PORT;
/* Initialize the subtree pointers */
@@ -3396,20 +3395,12 @@ proto_register_wimaxasncp(void)
*/
/* Register the protocol name and description */
- proto_wimaxasncp = proto_register_protocol(
- "WiMAX ASN Control Plane Protocol",
- "WiMAX ASN CP",
- "wimaxasncp");
-
+ proto_wimaxasncp = proto_register_protocol("WiMAX ASN Control Plane Protocol", "WiMAX ASN CP", "wimaxasncp");
/* Register this dissector by name */
wimaxasncp_handle = register_dissector("wimaxasncp", dissect_wimaxasncp, proto_wimaxasncp);
- /* Register preferences module (See Section 2.6 for more on
- * preferences) */
- wimaxasncp_module = prefs_register_protocol(
- proto_wimaxasncp,
- proto_reg_handoff_wimaxasncp);
+ wimaxasncp_module = prefs_register_protocol(proto_wimaxasncp, NULL);
/* Register preferences */
prefs_register_bool_preference(
@@ -3427,13 +3418,6 @@ proto_register_wimaxasncp(void)
"Print debug output to the console.",
&debug_enabled);
- prefs_register_uint_preference(
- wimaxasncp_module,
- "udp.wimax_port",
- "UDP Port for WiMAX ASN Control Plane Protocol",
- "Set UDP port for WiMAX ASN Control Plane Protocol",
- 10, &global_wimaxasncp_udp_port);
-
prefs_register_enum_preference(
wimaxasncp_module,
"nwg_version",
@@ -3458,27 +3442,10 @@ proto_register_wimaxasncp(void)
void
proto_reg_handoff_wimaxasncp(void)
{
- static gboolean inited = FALSE;
- static int currentPort = -1;
-
- if (!inited)
- {
-
- /* Find the EAP dissector */
- eap_handle = find_dissector_add_dependency("eap", proto_wimaxasncp);
-
- inited = TRUE;
- }
-
- if (currentPort != -1)
- {
- /* Remove any previous registered port */
- dissector_delete_uint("udp.port", currentPort, wimaxasncp_handle);
- }
+ /* Find the EAP dissector */
+ eap_handle = find_dissector_add_dependency("eap", proto_wimaxasncp);
- /* Add the new one from preferences */
- currentPort = global_wimaxasncp_udp_port;
- dissector_add_uint("udp.port", currentPort, wimaxasncp_handle);
+ dissector_add_uint_with_preference("udp.port", WIMAXASNCP_DEF_UDP_PORT, wimaxasncp_handle);
}
diff --git a/plugins/wimaxmacphy/packet-wimaxmacphy.c b/plugins/wimaxmacphy/packet-wimaxmacphy.c
index cc7e80c24b..d872453bee 100644
--- a/plugins/wimaxmacphy/packet-wimaxmacphy.c
+++ b/plugins/wimaxmacphy/packet-wimaxmacphy.c
@@ -25,7 +25,6 @@
#include "config.h"
#include <epan/packet.h>
-#include <epan/prefs.h>
#include <epan/expert.h>
/* IF PROTO exposes code to other dissectors, then it must be exported
@@ -303,10 +302,6 @@ static gint ett_wimaxmacphy_ul_sub_burst_sub_allocation_specific = -1;
static expert_field ei_wimaxmacphy_unknown = EI_INIT;
-/* Preferences */
-static guint wimaxmacphy_udp_port = 0;
-
-
/* PHY SAP message header size */
#define WIMAXMACPHY_HEADER_SIZE 2
@@ -2459,8 +2454,6 @@ dissect_wimaxmacphy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d
void
proto_register_wimaxmacphy(void)
{
- module_t *wimaxmacphy_module;
-
static hf_register_info hf[] = {
{
&hf_wimaxmacphy_hdr_phy_entity_id,
@@ -5441,43 +5434,15 @@ proto_register_wimaxmacphy(void)
proto_register_subtree_array(ett, array_length(ett));
expert_wimaxmacphy = expert_register_protocol(proto_wimaxmacphy);
expert_register_field_array(expert_wimaxmacphy, ei, array_length(ei));
-
- /* Register preferences module (See Section 2.6 for more on
- * preferences) */
- wimaxmacphy_module = prefs_register_protocol(
- proto_wimaxmacphy,
- proto_reg_handoff_wimaxmacphy);
-
- prefs_register_uint_preference(
- wimaxmacphy_module, "udp.port",
- "WiMAX MAX PHY UDP Port",
- "WiMAX MAX PHY UDP port",
- 10,
- &wimaxmacphy_udp_port);
-
}
void
proto_reg_handoff_wimaxmacphy(void)
{
- static guint old_wimaxmacphy_udp_port = 0;
- static gboolean inited = FALSE;
- static dissector_handle_t wimaxmacphy_handle;
-
- if (!inited) {
- wimaxmacphy_handle = create_dissector_handle(dissect_wimaxmacphy, proto_wimaxmacphy);
- dissector_add_for_decode_as("udp.port", wimaxmacphy_handle);
- inited = TRUE;
- }
+ dissector_handle_t wimaxmacphy_handle;
- /* Register UDP port for dissection */
- if (old_wimaxmacphy_udp_port != 0 && old_wimaxmacphy_udp_port != wimaxmacphy_udp_port) {
- dissector_delete_uint("udp.port", old_wimaxmacphy_udp_port, wimaxmacphy_handle);
- }
-
- if (wimaxmacphy_udp_port != 0 && old_wimaxmacphy_udp_port != wimaxmacphy_udp_port) {
- dissector_add_uint("udp.port", wimaxmacphy_udp_port, wimaxmacphy_handle);
- }
+ wimaxmacphy_handle = create_dissector_handle(dissect_wimaxmacphy, proto_wimaxmacphy);
+ dissector_add_for_decode_as_with_preference("udp.port", wimaxmacphy_handle);
}
/*