aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/ethercat
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2009-07-07 17:03:11 +0000
committerBill Meier <wmeier@newsguy.com>2009-07-07 17:03:11 +0000
commit4a3f4208435d6bd5c58bbd498229fd42d496bd12 (patch)
tree3abb013a42c9a2013f3113acfe9d43edf3cc64fc /plugins/ethercat
parent2f66bac84deec416ba78083aa95cce943ea3e090 (diff)
Fix the esl protocol enable/disable handling issue introduced in SVN #28986:
Use the standard "if (!initialized)..." logic in proto_reg_handoff(). Also: use "true_false_string flags_yes_no" as in the original patch. svn path=/trunk/; revision=28994
Diffstat (limited to 'plugins/ethercat')
-rw-r--r--plugins/ethercat/packet-esl.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/plugins/ethercat/packet-esl.c b/plugins/ethercat/packet-esl.c
index 3de4b84837..8ae0dfc1f6 100644
--- a/plugins/ethercat/packet-esl.c
+++ b/plugins/ethercat/packet-esl.c
@@ -37,7 +37,7 @@
#include "packet-esl.h"
-static dissector_handle_t eth_withoutfcs_handle = NULL;
+static dissector_handle_t eth_withoutfcs_handle;
static int esl_enable_dissector = FALSE;
void proto_reg_handoff_esl(void);
@@ -52,6 +52,11 @@ static int hf_esl_port = -1;
static int hf_esl_crcerror = -1;
static int hf_esl_alignerror = -1;
+static const true_false_string flags_yes_no = {
+ "yes",
+ "no"
+};
+
static guint16 flags_to_port(guint16 flagsValue) {
EslFlagsUnion flagsUnion;
flagsUnion.flags = flagsValue;
@@ -224,12 +229,6 @@ dissect_esl_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
return result;
}
-static void esl_enable_dissector_cb(void) {
- proto_set_decoding(proto_esl, esl_enable_dissector);
-}
-
-static const true_false_string tfs_esl_yes_no = { "Yes", "No" };
-
void
proto_register_esl(void) {
static hf_register_info hf[] = {
@@ -240,12 +239,12 @@ proto_register_esl(void) {
},
{ &hf_esl_crcerror,
{ "Crc Error", "esl.crcerror",
- FT_BOOLEAN, 16, TFS(&tfs_esl_yes_no), 0x1000,
+ FT_BOOLEAN, 16, TFS(&flags_yes_no), 0x1000,
NULL, HFILL }
},
{ &hf_esl_alignerror,
{ "Alignment Error", "esl.alignerror",
- FT_BOOLEAN, 16, TFS(&tfs_esl_yes_no), 0x0800,
+ FT_BOOLEAN, 16, TFS(&flags_yes_no), 0x0800,
NULL, HFILL }
},
{ &hf_esl_timestamp,
@@ -263,7 +262,7 @@ proto_register_esl(void) {
proto_esl = proto_register_protocol("EtherCAT Switch Link",
"ESL","esl");
- esl_module = prefs_register_protocol(proto_esl, esl_enable_dissector_cb);
+ esl_module = prefs_register_protocol(proto_esl, proto_reg_handoff_esl);
prefs_register_bool_preference(esl_module, "enable", "Enable dissector",
"Enable this dissector (default is false)",
@@ -278,8 +277,12 @@ proto_register_esl(void) {
void
proto_reg_handoff_esl(void) {
-
- eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
-
- heur_dissector_add("eth", dissect_esl_heur, proto_esl);
+ static gboolean initialized = FALSE;
+
+ if (!initialized) {
+ eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
+ heur_dissector_add("eth", dissect_esl_heur, proto_esl);
+ initialized = TRUE;
+ }
+ proto_set_decoding(proto_esl, esl_enable_dissector);
}