aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-llt.c
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2008-09-03 16:42:35 +0000
committerBill Meier <wmeier@newsguy.com>2008-09-03 16:42:35 +0000
commit419e3a47f6a9c887edc949235dc0755a98d4c4ee (patch)
tree0cba41be21c97f7851f13844ce71399d7be20e97 /epan/dissectors/packet-llt.c
parentaf49f0161686d18f45b749d96eaf431ce45625d0 (diff)
Cleanup related to prefs & proto_reg_handoff
svn path=/trunk/; revision=26128
Diffstat (limited to 'epan/dissectors/packet-llt.c')
-rw-r--r--epan/dissectors/packet-llt.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/epan/dissectors/packet-llt.c b/epan/dissectors/packet-llt.c
index 71780c57a1..3b33f7547b 100644
--- a/epan/dissectors/packet-llt.c
+++ b/epan/dissectors/packet-llt.c
@@ -48,9 +48,6 @@ void proto_reg_handoff_llt(void);
/* Variables for our preferences */
static guint preference_alternate_ethertype = 0x0;
-/* Behind the scenes variable to keep track of the last preference setting */
-static guint preference_alternate_ethertype_last;
-
/* Initialize the protocol and registered fields */
static int proto_llt = -1;
@@ -63,8 +60,6 @@ static int hf_llt_message_time = -1;
/* Initialize the subtree pointers */
static gint ett_llt = -1;
-static dissector_handle_t llt_handle; /* Declaring this here allows us to use it for re-registration throughout the handoff function */
-
/* Code to actually dissect the packets */
static void
dissect_llt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@@ -153,13 +148,25 @@ proto_register_llt(void)
void
proto_reg_handoff_llt(void)
{
- llt_handle = create_dissector_handle(dissect_llt, proto_llt);
- dissector_add("ethertype", ETHERTYPE_LLT, llt_handle);
-
- if((preference_alternate_ethertype != ETHERTYPE_LLT)
- && (preference_alternate_ethertype != 0x0)){
- dissector_delete("ethertype", preference_alternate_ethertype_last, llt_handle);
- preference_alternate_ethertype_last = preference_alternate_ethertype; /* Save the setting to see if it has changed later */
- dissector_add("ethertype", preference_alternate_ethertype, llt_handle); /* Register the new ethertype setting */
+ static gboolean initialized = FALSE;
+ static dissector_handle_t llt_handle;
+ static guint preference_alternate_ethertype_last = 0x0;
+
+ if (!initialized) {
+ llt_handle = create_dissector_handle(dissect_llt, proto_llt);
+ dissector_add("ethertype", ETHERTYPE_LLT, llt_handle);
+ initialized = TRUE;
+ } else {
+ if (preference_alternate_ethertype_last != 0x0) {
+ dissector_delete("ethertype", preference_alternate_ethertype_last, llt_handle);
+ }
+ }
+
+ /* Save the setting to see if it has changed later */
+ preference_alternate_ethertype_last = preference_alternate_ethertype;
+
+ if (preference_alternate_ethertype != 0x0) {
+ /* Register the new ethertype setting */
+ dissector_add("ethertype", preference_alternate_ethertype, llt_handle);
}
}