prefs_register_protocol not req'd since no prefs; simplify reg_handoff & do minor...
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 25 Aug 2008 19:25:40 +0000 (19:25 +0000)
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 25 Aug 2008 19:25:40 +0000 (19:25 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@26080 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-dplay.c
epan/dissectors/packet-wsmp.c

index 9b5b6daf270dd6ef7d8d652ee044904ff448db16..7183f86c8c7c846bd6cdfb5c7c8561124b08f2eb 100644 (file)
 #endif
 
 #include <epan/packet.h>
 #endif
 
 #include <epan/packet.h>
-#include <epan/prefs.h>
 #include <epan/emem.h>
 #include <epan/aftypes.h>
 #include <string.h>
 
 /* function declarations */
 #include <epan/emem.h>
 #include <epan/aftypes.h>
 #include <string.h>
 
 /* function declarations */
-void proto_reg_handoff_dplay(void);
 static gboolean heur_dissect_dplay(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 static void dissect_dplay(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 static gint dissect_type1a_message(proto_tree *tree, tvbuff_t *tvb, gint offset);
 
 static int proto_dplay = -1;
 static gboolean heur_dissect_dplay(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 static void dissect_dplay(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 static gint dissect_type1a_message(proto_tree *tree, tvbuff_t *tvb, gint offset);
 
 static int proto_dplay = -1;
-static dissector_handle_t dplay_handle;
 
 /* Common data fields */
 static int hf_dplay_size = -1;              /* Size of the whole data */
 
 /* Common data fields */
 static int hf_dplay_size = -1;              /* Size of the whole data */
@@ -1759,7 +1756,6 @@ void proto_register_dplay()
         &ett_dplay_type05_flags,
         &ett_dplay_type29_spp,
     };
         &ett_dplay_type05_flags,
         &ett_dplay_type29_spp,
     };
-    module_t *dplay_module;
 
     if(proto_dplay == -1)
     {
 
     if(proto_dplay == -1)
     {
@@ -1770,20 +1766,12 @@ void proto_register_dplay()
                 );
         proto_register_field_array(proto_dplay, hf, array_length(hf));
         proto_register_subtree_array(ett, array_length(ett));
                 );
         proto_register_field_array(proto_dplay, hf, array_length(hf));
         proto_register_subtree_array(ett, array_length(ett));
-        dplay_module = prefs_register_protocol(proto_dplay, proto_reg_handoff_dplay);
     }
 }
 
 void proto_reg_handoff_dplay(void)
 {
     }
 }
 
 void proto_reg_handoff_dplay(void)
 {
-    static int initialized = FALSE;
-
-    if(!initialized)
-    {
-        initialized = TRUE;
-        heur_dissector_add("udp", heur_dissect_dplay, proto_dplay);
-        heur_dissector_add("tcp", heur_dissect_dplay, proto_dplay);
-        dplay_handle = create_dissector_handle(dissect_dplay, proto_dplay);
-    }
+    heur_dissector_add("udp", heur_dissect_dplay, proto_dplay);
+    heur_dissector_add("tcp", heur_dissect_dplay, proto_dplay);
 }
 
 }
 
index 2faa1bbef8102d13d09ed2f1d411edc71ae302ea..207e503781e3cb0ca080fabe00d51431deb43a5a 100644 (file)
 #include <string.h>
 
 #include <epan/packet.h>
 #include <string.h>
 
 #include <epan/packet.h>
-#include <epan/prefs.h>
 #include <epan/etypes.h>
 
 #include <epan/etypes.h>
 
-/* Forward declaration we need below */
-void proto_reg_handoff_wsmp(void); 
-
 static dissector_handle_t data_handle;
 
 /* Initialize the protocol and registered fields */
 static dissector_handle_t data_handle;
 
 /* Initialize the protocol and registered fields */
@@ -66,7 +62,7 @@ dissect_wsmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
         /* Set up structures needed to add the protocol subtree and manage it */
         proto_item *ti, *wsmdata_item;
         proto_tree *wsmp_tree, *wsmdata_tree;
         /* Set up structures needed to add the protocol subtree and manage it */
         proto_item *ti, *wsmdata_item;
         proto_tree *wsmp_tree, *wsmdata_tree;
-               tvbuff_t *wsmdata_tvb;
+        tvbuff_t *wsmdata_tvb;
         guint16 acmlength, wsmlength, offset;
         char* acm;        
 
         guint16 acmlength, wsmlength, offset;
         char* acm;        
 
@@ -114,7 +110,7 @@ dissect_wsmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                 hf_wsmp_acmlength, tvb, offset, 1, FALSE);
                 offset ++;
                                
                                 hf_wsmp_acmlength, tvb, offset, 1, FALSE);
                 offset ++;
                                
-                               acm = tvb_get_ephemeral_string(tvb, offset, acmlength);
+                acm = tvb_get_ephemeral_string(tvb, offset, acmlength);
                 proto_tree_add_item(wsmp_tree, hf_wsmp_acm, tvb, offset, acmlength, FALSE);
                 offset +=acmlength;
 
                 proto_tree_add_item(wsmp_tree, hf_wsmp_acm, tvb, offset, acmlength, FALSE);
                 offset +=acmlength;
 
@@ -122,16 +118,16 @@ dissect_wsmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 proto_tree_add_item(wsmp_tree,
                                 hf_wsmp_wsmlength, tvb, offset, 2, TRUE);
                 offset += 2; 
                 proto_tree_add_item(wsmp_tree,
                                 hf_wsmp_wsmlength, tvb, offset, 2, TRUE);
                 offset += 2; 
-
-                               wsmdata_item = proto_tree_add_text (wsmp_tree, tvb, offset, wsmlength,
-                                       "Wave Short Message");
-                               wsmdata_tree = proto_item_add_subtree(wsmdata_item, ett_wsmdata);
-
-                               /* TODO: Branch on the application context and display accordingly 
-                                * Default call the data dissector
-                                */
-                               wsmdata_tvb = tvb_new_subset(tvb, offset,wsmlength, wsmlength);
-                               call_dissector(data_handle, wsmdata_tvb, pinfo, wsmdata_tree);
+                
+                wsmdata_item = proto_tree_add_text (wsmp_tree, tvb, offset, wsmlength,
+                                                    "Wave Short Message");
+                wsmdata_tree = proto_item_add_subtree(wsmdata_item, ett_wsmdata);
+
+                /* TODO: Branch on the application context and display accordingly 
+                 * Default call the data dissector
+                 */
+                wsmdata_tvb = tvb_new_subset(tvb, offset,wsmlength, wsmlength);
+                call_dissector(data_handle, wsmdata_tvb, pinfo, wsmdata_tree);
         }
 
 }
         }
 
 }
@@ -143,11 +139,9 @@ dissect_wsmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
    that calls all the protocol registration.
  */
 
    that calls all the protocol registration.
  */
 
-        void
+void
 proto_register_wsmp(void)
 {                 
 proto_register_wsmp(void)
 {                 
-        module_t *wsmp_module;
-
         /* Setup list of header fields  See Section 1.6.1 for details*/
         static hf_register_info hf[] = {
                 { &hf_wsmp_version,
         /* Setup list of header fields  See Section 1.6.1 for details*/
         static hf_register_info hf[] = {
                 { &hf_wsmp_version,
@@ -200,33 +194,20 @@ proto_register_wsmp(void)
         proto_register_field_array(proto_wsmp, hf, array_length(hf));
         proto_register_subtree_array(ett, array_length(ett));
 
         proto_register_field_array(proto_wsmp, hf, array_length(hf));
         proto_register_subtree_array(ett, array_length(ett));
 
-        /* Register preferences module (See Section 2.6 for more on preferences) */       
-        wsmp_module = prefs_register_protocol(proto_wsmp, proto_reg_handoff_wsmp);
-
 }
 
 /* If this dissector uses sub-dissector registration add a registration routine.
    This exact format is required because a script is used to find these routines 
    and create the code that calls these routines.
 }
 
 /* If this dissector uses sub-dissector registration add a registration routine.
    This exact format is required because a script is used to find these routines 
    and create the code that calls these routines.
-
-   This function is also called by preferences whenever "Apply" is pressed 
-   (see prefs_register_protocol above) so it should accommodate being called 
-   more than once.
  */
  */
-        void
+
+void
 proto_reg_handoff_wsmp(void)
 {
 proto_reg_handoff_wsmp(void)
 {
-        static gboolean inited = FALSE;
-        if( !inited ) {
-
-                dissector_handle_t wsmp_handle;
+        dissector_handle_t wsmp_handle;
 
 
-                wsmp_handle = create_dissector_handle(dissect_wsmp,
-                                proto_wsmp);
-                dissector_add("ethertype", ETHERTYPE_WSMP, wsmp_handle);
-                               data_handle = find_dissector("data");
-                inited = TRUE;
-        }
+        wsmp_handle = create_dissector_handle(dissect_wsmp, proto_wsmp);
+        dissector_add("ethertype", ETHERTYPE_WSMP, wsmp_handle);
+        data_handle = find_dissector("data");
         return;
         return;
-
 }
 }