aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-prp.c
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2008-02-27 23:24:40 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2008-02-27 23:24:40 +0000
commit6e0297dc86c3cf0905e361aa9baf3b586bf9b367 (patch)
tree355f453e34882717994d83e30f50672824cd9ffa /epan/dissectors/packet-prp.c
parent31d705e32f6e8b92f7df6c0c9951bef1c87958a4 (diff)
Rather than always disabling the protocol at startup, just add a preference that decides if the dissector should be enabled or not. Still not perfect but it makes it more usable.
svn path=/trunk/; revision=24494
Diffstat (limited to 'epan/dissectors/packet-prp.c')
-rw-r--r--epan/dissectors/packet-prp.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/epan/dissectors/packet-prp.c b/epan/dissectors/packet-prp.c
index 649fcdaf8b..bdbed25a74 100644
--- a/epan/dissectors/packet-prp.c
+++ b/epan/dissectors/packet-prp.c
@@ -38,6 +38,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/etypes.h>
+#include <epan/prefs.h>
/**********************************************************/
/* Offsets of fields within a PRP packet. */
@@ -81,7 +82,9 @@ static const value_string prp_lan_vals[] = {
/* Initialize the protocol and registered fields */
/**********************************************************/
+void proto_reg_handoff_prp(void);
static int proto_prp = -1;
+static module_t *prp_module;
/* Initialize supervision frame fields */
static int hf_prp_supervision_frame_version = -1;
@@ -100,6 +103,18 @@ static int hf_prp_redundancy_control_trailer_size = -1;
static gint ett_prp_supervision_frame = -1;
static gint ett_prp_redundancy_control_trailer = -1;
+
+/* Post dissectors (such as the trailer dissector for this protocol)
+ * get called for every single frame anyone loads into Wireshark.
+ * Since this protocol is not of general interest we disable this
+ * protocol by default.
+ *
+ * This is done separately from the disabled protocols list mainly so
+ * we can disable it by default. XXX Maybe there's a better way.
+ */
+static gboolean prp_enable_dissector = FALSE;
+
+
/* Code to actually dissect the packets */
static void
dissect_prp_supervision_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@@ -274,16 +289,11 @@ void proto_register_prp(void)
/* Register the protocol name and description */
proto_prp = proto_register_protocol("Parallel Redundancy Protocol (IEC62439 Chapter 6)",
"PRP", "prp");
+ prp_module = prefs_register_protocol(proto_prp, proto_reg_handoff_prp);
- /* Post dissectors (such as the trailer dissector for this protocol)
- * get called for every single frame anyone loads into Wireshark.
- * Since this protocol is not of general interest we disable this
- * protocol by default (really every time Wireshark starts).
- *
- * XXX This should be improved to only disable the protocol by
- * default.
- */
- proto_set_decoding(proto_prp, FALSE);
+ prefs_register_bool_preference(prp_module, "enable", "Enable dissector",
+ "Enable this dissector (default is false)",
+ &prp_enable_dissector);
/* Required function calls to register the header fields and subtree used */
proto_register_field_array(proto_prp, hf, array_length(hf));
@@ -293,12 +303,20 @@ void proto_register_prp(void)
void proto_reg_handoff_prp(void)
{
- dissector_handle_t prp_supervision_frame_handle;
- dissector_handle_t prp_redundancy_control_trailer_handle;
+ static int prefs_initialized = FALSE;
- prp_supervision_frame_handle = create_dissector_handle(dissect_prp_supervision_frame, proto_prp);
- dissector_add("ethertype", ETHERTYPE_PRP, prp_supervision_frame_handle);
+ if (!prefs_initialized) {
+ dissector_handle_t prp_supervision_frame_handle;
+ dissector_handle_t prp_redundancy_control_trailer_handle;
+
+ prp_supervision_frame_handle = create_dissector_handle(dissect_prp_supervision_frame, proto_prp);
+ dissector_add("ethertype", ETHERTYPE_PRP, prp_supervision_frame_handle);
+
+ prp_redundancy_control_trailer_handle = create_dissector_handle(dissect_prp_redundancy_control_trailer, proto_prp);
+ register_postdissector(prp_redundancy_control_trailer_handle);
+
+ prefs_initialized = TRUE;
+ }
- prp_redundancy_control_trailer_handle = create_dissector_handle(dissect_prp_redundancy_control_trailer, proto_prp);
- register_postdissector(prp_redundancy_control_trailer_handle);
+ proto_set_decoding(proto_prp, prp_enable_dissector);
}