Minor cleanup related to proto_register & proto_reg_handoff
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 26 Sep 2008 20:06:40 +0000 (20:06 +0000)
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 26 Sep 2008 20:06:40 +0000 (20:06 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@26280 f5534014-38df-0310-8fa8-9805f1628bb7

19 files changed:
epan/dissectors/packet-acn.c
epan/dissectors/packet-bat-batman.c
epan/dissectors/packet-bat-gw.c
epan/dissectors/packet-bat-vis.c
epan/dissectors/packet-dcp-etsi.c
epan/dissectors/packet-dplay.c
epan/dissectors/packet-gsm_a_dtap.c
epan/dissectors/packet-h223.c
epan/dissectors/packet-http.c
epan/dissectors/packet-linx.c
epan/dissectors/packet-nhrp.c
epan/dissectors/packet-rsvp.c
epan/dissectors/packet-slimp3.c
epan/dissectors/packet-socks.c
epan/dissectors/packet-srp.c
epan/dissectors/packet-tsp.c
epan/dissectors/packet-user_encap.c
epan/dissectors/packet-winsrepl.c
epan/dissectors/packet-xyplex.c

index 117c16b555f03aac4d90ed3fbb225e59cb60a882..f2f7ef26eb0ebc5c6f564bcc3d5b9aac0bcd60bf 100644 (file)
@@ -3039,14 +3039,12 @@ void proto_register_acn(void)
   };
 
   module_t *acn_module;
-  if (proto_acn == -1) {
-    proto_acn = proto_register_protocol (
-      "Architecture for Control Networks", /* name */
-      "ACN",                               /* short name */
-      "acn"                                /* abbrev */
-      );
-  }
-
+  proto_acn = proto_register_protocol (
+    "Architecture for Control Networks", /* name */
+    "ACN",                               /* short name */
+    "acn"                                /* abbrev */
+    );
+  
   proto_register_field_array(proto_acn, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
 
index 4a5dc528b236718a3986a0770e2a3999aa801406..2a28e6d37815fe4e283daa0284175f233d0608a4 100644 (file)
@@ -54,7 +54,6 @@ static int hf_bat_batman_flags_directlink = -1;
 /* unknown */
 
 static guint global_bat_batman_udp_port = BAT_BATMAN_PORT;
-static guint udp_port = 0;
 
 static void dissect_bat_batman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 static void dissect_bat_hna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
@@ -158,6 +157,7 @@ void reg_handoff_bat_batman(void)
 {
        static gboolean inited = FALSE;
        static dissector_handle_t batman_handle;
+       static guint udp_port;
 
        if (!inited) {
                batman_handle = create_dissector_handle(dissect_bat_batman, proto_bat_plugin);
index e8ef43c4a05e312256dfc32b1b2d9726451ca22b..bd98bdcebe13128a7e9cf3d83bedff61e337e713 100644 (file)
@@ -35,7 +35,6 @@ static int hf_bat_gw_type = -1;
 static int hf_bat_gw_ip = -1;
 
 static guint global_bat_gw_udp_port = BAT_GW_PORT;
-static guint udp_port = 0;
 
 static void dissect_bat_gw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 
@@ -81,6 +80,7 @@ void reg_handoff_bat_gw(void)
 {
        static gboolean inited = FALSE;
        static dissector_handle_t gw_handle;
+       static guint udp_port;
 
        if (!inited) {
                gw_handle = create_dissector_handle(dissect_bat_gw, proto_bat_plugin);
index a927e1f95c31c5eaf8e3e862e1093a52324a6373..dcf957612b8b7791b79e9e1ecbc6923ae4aee1e3 100644 (file)
@@ -43,7 +43,6 @@ static int hf_bat_vis_tq_v23 = -1;
 static int hf_bat_vis_data_ip = -1;
 
 static guint global_bat_vis_udp_port = BAT_VIS_PORT;
-static guint udp_port = 0;
 
 static void dissect_vis_entry_v22(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
 static void dissect_bat_vis_v22(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
@@ -132,6 +131,7 @@ void reg_handoff_bat_vis(void)
 {
        static gboolean inited = FALSE;
        static dissector_handle_t vis_handle;
+       static guint udp_port;
 
        if (!inited) {
                vis_handle = create_dissector_handle(dissect_bat_vis, proto_bat_plugin);
index 26516caa499b014929271254bf846c064da6fca2..d2b6c8fac03a34379cc9c21422aefc4e9885137c 100644 (file)
@@ -850,17 +850,14 @@ proto_register_dcp_etsi (void)
     &ett_edcp_fragments
   };
 
-  if (proto_dcp_etsi == -1) {
-    proto_dcp_etsi = proto_register_protocol ("ETSI Distribution & Communication Protocol (for DRM)",  /* name */
-                                        "DCP (ETSI)",  /* short name */
-                                        "dcp-etsi"     /* abbrev */
-      );
-    proto_af = proto_register_protocol ("DCP Application Framing Layer", "DCP-AF", "dcp-af");
-    proto_pft = proto_register_protocol ("DCP Protection, Fragmentation & Transport Layer", "DCP-PFT", "dcp-pft");
-    proto_tpl = proto_register_protocol ("DCP Tag Packet Layer", "DCP-TPL", "dcp-tpl");
-
+  proto_dcp_etsi = proto_register_protocol ("ETSI Distribution & Communication Protocol (for DRM)",    /* name */
+                                            "DCP (ETSI)",      /* short name */
+                                            "dcp-etsi" /* abbrev */
+    );
+  proto_af = proto_register_protocol ("DCP Application Framing Layer", "DCP-AF", "dcp-af");
+  proto_pft = proto_register_protocol ("DCP Protection, Fragmentation & Transport Layer", "DCP-PFT", "dcp-pft");
+  proto_tpl = proto_register_protocol ("DCP Tag Packet Layer", "DCP-TPL", "dcp-tpl");
 
-  }
   proto_register_field_array (proto_dcp_etsi, hf_edcp, array_length (hf_edcp));
   proto_register_field_array (proto_af, hf_af, array_length (hf_af));
   proto_register_field_array (proto_pft, hf_pft, array_length (hf_pft));
index 7183f86c8c7c846bd6cdfb5c7c8561124b08f2eb..f39fab21ae60d631905df62ce0751b9779ae7cbc 100644 (file)
@@ -1757,16 +1757,13 @@ void proto_register_dplay()
         &ett_dplay_type29_spp,
     };
 
-    if(proto_dplay == -1)
-    {
-        proto_dplay = proto_register_protocol (
-                "DirectPlay Protocol",
-                "DPLAY",
-                "dplay"
-                );
-        proto_register_field_array(proto_dplay, hf, array_length(hf));
-        proto_register_subtree_array(ett, array_length(ett));
-    }
+    proto_dplay = proto_register_protocol (
+        "DirectPlay Protocol",
+        "DPLAY",
+        "dplay"
+        );
+    proto_register_field_array(proto_dplay, hf, array_length(hf));
+    proto_register_subtree_array(ett, array_length(ett));
 }
 
 void proto_reg_handoff_dplay(void)
index 4dedd821210f6d300233e621748eb54bb868975a..2124e4d69c567067583f938bb91259b1f321c07c 100644 (file)
@@ -411,8 +411,6 @@ static char a_bigbuf[1024];
 
 static dissector_handle_t data_handle;
 static dissector_handle_t gsm_map_handle;
-static dissector_handle_t gsm_bsslap_handle = NULL;
-static dissector_handle_t dtap_handle;
 static dissector_handle_t rp_handle;
 
 packet_info *gsm_a_dtap_pinfo;
@@ -5724,15 +5722,15 @@ proto_register_gsm_a_dtap(void)
 void
 proto_reg_handoff_gsm_a_dtap(void)
 {
+       dissector_handle_t dtap_handle;
 
        dtap_handle = find_dissector("gsm_a_dtap");
-       rp_handle = find_dissector("gsm_a_rp");
-
        dissector_add("bssap.pdu_type", BSSAP_PDU_TYPE_DTAP, dtap_handle);
        dissector_add("ranap.nas_pdu", BSSAP_PDU_TYPE_DTAP, dtap_handle);
        dissector_add("llcgprs.sapi", 1 , dtap_handle); /* GPRS Mobility Management */
        dissector_add("llcgprs.sapi", 7 , dtap_handle); /* SMS */
+
        data_handle = find_dissector("data");
        gsm_map_handle = find_dissector("gsm_map");
-       gsm_bsslap_handle = find_dissector("gsm_bsslap");
+       rp_handle = find_dissector("gsm_a_rp");
 }
index 7c93902d0987d5d0808336607148bfbbf4ea0aef..552a3ac4c46ac9319322ec9d3b35c0ac9c2b546d 100644 (file)
@@ -122,9 +122,8 @@ static gint ett_h223_al2 = -1;
 static gint ett_h223_al_payload = -1;
 
 /* These are the handles of our subdissectors */
-static dissector_handle_t data_handle=NULL;
-static dissector_handle_t srp_handle=NULL;
-static dissector_handle_t h245dg_handle=NULL;
+static dissector_handle_t data_handle;
+static dissector_handle_t srp_handle;
 
 static const fragment_items h223_mux_frag_items _U_ = {
        &ett_h223_mux_fragment,
@@ -1549,7 +1548,6 @@ void proto_register_h223 (void)
        &ett_h223_al_payload
     };
 
-    if (proto_h223 == -1) { /* execute protocol initialization only once */
     proto_h223 =
        proto_register_protocol ("ITU-T Recommendation H.223", "H.223", "h223");
     proto_h223_bitswapped =
@@ -1563,7 +1561,6 @@ void proto_register_h223 (void)
     /* register our init routine to be called at the start of a capture,
        to clear out our hash tables etc */
     register_init_routine(&h223_init_protocol);
-    }
 
     h245_set_h223_set_mc_handle( &h223_set_mc );
     h245_set_h223_add_lc_handle( &h223_add_lc );
@@ -1574,7 +1571,6 @@ void proto_reg_handoff_h223(void)
     dissector_handle_t h223_bitswapped = find_dissector("h223_bitswapped");
     dissector_handle_t h223 = find_dissector("h223");
     data_handle = find_dissector("data");
-    h245dg_handle = find_dissector("h245dg");
     srp_handle = find_dissector("srp");
 
     dissector_add_handle("tcp.port", h223);
index 41ebb969331ec46e730d9f01aef4f40db4a1551e..0c0a8b780000e6b5fd4e076351bd59444e27d730 100644 (file)
@@ -203,8 +203,8 @@ static dissector_table_t port_subdissector_table;
 static dissector_table_t media_type_subdissector_table;
 static heur_dissector_list_t heur_subdissector_list;
 
-static dissector_handle_t ntlmssp_handle=NULL;
-static dissector_handle_t gssapi_handle=NULL;
+static dissector_handle_t ntlmssp_handle;
+static dissector_handle_t gssapi_handle;
 
 static const value_string vals_status_code[] = {
        { 100, "Continue" },
@@ -2364,7 +2364,6 @@ proto_reg_handoff_http(void)
 
 static gint proto_message_http = -1;
 static gint ett_message_http = -1;
-static dissector_handle_t message_http_handle;
 
 static void
 dissect_message_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@@ -2411,6 +2410,8 @@ proto_register_message_http(void)
 void
 proto_reg_handoff_message_http(void)
 {
+       dissector_handle_t message_http_handle;
+
        message_http_handle = create_dissector_handle(dissect_message_http,
                        proto_message_http);
 
index 49ec80ddb4dea6fccfd1b01549b14c8c37eb3a3a..a65136f3baa2b3e8dd17d3c7e185b21983552bd3 100644 (file)
@@ -730,13 +730,11 @@ proto_register_linx(void)
                &ett_linx_ack
        };
 
-       if (proto_linx == -1) {
-               proto_linx = proto_register_protocol (
-                       "ENEA LINX",    /* name */
-                       "LINX",         /* short name */
-                       "linx"          /* abbrev */
-                       );
-       }
+       proto_linx = proto_register_protocol (
+               "ENEA LINX",    /* name */
+               "LINX",         /* short name */
+               "linx"          /* abbrev */
+               );
 
        /* Protocol Registering data structures. */
        proto_register_field_array(proto_linx, hf, array_length(hf));
index 8526dabbd615763795f9903d7791183fc696b64f..69dfca849b348172f389352cb27339ef818a52a1 100644 (file)
@@ -770,14 +770,12 @@ proto_register_nhrp(void)
                &ett_nhrp_indication
        };
        
-       if (proto_nhrp == -1) {
-               proto_nhrp = proto_register_protocol(
-                       "NBMA Next Hop Resolution Protocol",
-                       "NHRP",
-                       "nhrp");
-               proto_register_field_array(proto_nhrp, hf, array_length(hf));
-               proto_register_subtree_array(ett, array_length(ett));
-       }
+       proto_nhrp = proto_register_protocol(
+               "NBMA Next Hop Resolution Protocol",
+               "NHRP",
+               "nhrp");
+       proto_register_field_array(proto_nhrp, hf, array_length(hf));
+       proto_register_subtree_array(ett, array_length(ett));
 }
 
 void
index 02f5e8e761cff9ff88a544811c3d6f96b664880a..5798319d333669f41ac1ce93cb2a149f98ac8068 100644 (file)
 static int proto_rsvp = -1;
 
 static dissector_table_t rsvp_dissector_table;
-static dissector_handle_t data_handle;
 
 static int rsvp_tap = -1;
 
@@ -5946,6 +5945,5 @@ proto_reg_handoff_rsvp(void)
        dissector_add("ip.proto", IP_PROTO_RSVP, rsvp_handle);
        dissector_add("ip.proto", IP_PROTO_RSVPE2EI, rsvp_handle);
        dissector_add("udp.port", UDP_PORT_PRSVP, rsvp_handle);
-       data_handle = find_dissector("data");
        rsvp_tap = register_tap("rsvp");
 }
index a23da863e592e5ff9364563a439ffccc59972b81..c4608a5a52540bfc8dde57731c923f19267f8dec 100644 (file)
@@ -53,8 +53,6 @@ static int hf_slimp3_data_ack = -1;
 
 static gint ett_slimp3 = -1;
 
-static dissector_handle_t slimp3_handle;
-
 #define UDP_PORT_SLIMP3_V1    1069
 #define UDP_PORT_SLIMP3_V2    3483
 
@@ -746,13 +744,14 @@ proto_register_slimp3(void)
                                       "SliMP3", "slimp3");
   proto_register_field_array(proto_slimp3, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
-
-  slimp3_handle = new_create_dissector_handle(dissect_slimp3, proto_slimp3);
 }
 
 void
 proto_reg_handoff_slimp3(void)
 {
+  dissector_handle_t slimp3_handle;
+
+  slimp3_handle = new_create_dissector_handle(dissect_slimp3, proto_slimp3);
   dissector_add("udp.port", UDP_PORT_SLIMP3_V1, slimp3_handle);
   dissector_add("udp.port", UDP_PORT_SLIMP3_V2, slimp3_handle);
 }
index 28cfef788312700c61411e456cbe150cc7a99e57..cf64d516e01f25107ec1074d04293fd081bd9e78 100644 (file)
@@ -1194,10 +1194,6 @@ proto_register_socks( void){
 
        proto_register_field_array(proto_socks, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
-
-       socks_udp_handle = create_dissector_handle(socks_udp_dissector,
-           proto_socks);
-       socks_handle = create_dissector_handle(dissect_socks, proto_socks);
 }
 
 
@@ -1205,6 +1201,8 @@ void
 proto_reg_handoff_socks(void) {
 
        /* dissector install routine */
+       socks_udp_handle = create_dissector_handle(socks_udp_dissector, proto_socks);
+       socks_handle = create_dissector_handle(dissect_socks, proto_socks);
 
        dissector_add("tcp.port", TCP_PORT_SOCKS, socks_handle);
 }
index 298882c7b3a01d3f4b244c744e4825dc4fdd0b7a..580585586c2d49cc873bdfc783952370d5fe1254 100644 (file)
@@ -54,9 +54,8 @@ static int hf_ccsrl_ls = -1;
 static gint ett_srp = -1;
 static gint ett_ccsrl = -1;
 
-static dissector_handle_t data_handle=NULL;
-static dissector_handle_t ccsrl_handle=NULL;
-static dissector_handle_t h245dg_handle=NULL;
+static dissector_handle_t ccsrl_handle;
+static dissector_handle_t h245dg_handle;
 
 /*****************************************************************************/
 #define SRP_SRP_COMMAND 249
@@ -188,14 +187,10 @@ void proto_register_ccsrl (void)
        &ett_ccsrl,
     };
 
-    if (proto_ccsrl == -1) { /* execute protocol initialization only once */
-       proto_ccsrl =
-           proto_register_protocol ("H.324/CCSRL", "CCSRL", "ccsrl");
-
-       proto_register_field_array (proto_ccsrl, hf, array_length (hf));
-       proto_register_subtree_array (ett, array_length (ett));
-       register_dissector("ccsrl", dissect_ccsrl, proto_ccsrl);
-    }
+    proto_ccsrl = proto_register_protocol ("H.324/CCSRL", "CCSRL", "ccsrl");
+    proto_register_field_array (proto_ccsrl, hf, array_length (hf));
+    proto_register_subtree_array (ett, array_length (ett));
+    register_dissector("ccsrl", dissect_ccsrl, proto_ccsrl);
 }
 
 void proto_register_srp (void)
@@ -219,24 +214,19 @@ void proto_register_srp (void)
        &ett_srp,
     };
 
-    if (proto_srp == -1) { /* execute protocol initialization only once */
-       proto_srp =
-           proto_register_protocol ("H.324/SRP", "SRP", "srp");
+    proto_srp = proto_register_protocol ("H.324/SRP", "SRP", "srp");
+    proto_register_field_array (proto_srp, hf, array_length (hf));
+    proto_register_subtree_array (ett, array_length (ett));
+    register_dissector("srp", dissect_srp, proto_srp);
 
-       proto_register_field_array (proto_srp, hf, array_length (hf));
-       proto_register_subtree_array (ett, array_length (ett));
-       register_dissector("srp", dissect_srp, proto_srp);
+    /* register our init routine to be called at the start of a capture,
+       to clear out our hash tables etc */
+    /* register_init_routine(&srp_init_protocol); */
 
-       /* register our init routine to be called at the start of a capture,
-          to clear out our hash tables etc */
-       /* register_init_routine(&srp_init_protocol); */
-
-    }
 }
 
 
 void proto_reg_handoff_srp(void) {
-    data_handle = find_dissector("data");
     ccsrl_handle = find_dissector("ccsrl");
     h245dg_handle = find_dissector("h245dg");
 }
index 579949155c8e909a86e5c64a1aabcc8c9a8315fb..028c4a47debdbb38b655ddc95f928c743be55f9c 100644 (file)
@@ -49,9 +49,6 @@ static int hf_tsp_name = -1;
 
 static gint ett_tsp = -1;
 
-static dissector_handle_t      tsp_handle;
-
-
 /* timed port from /etc/services */
 #define UDP_PORT_TIMED 525
 
@@ -176,6 +173,9 @@ dissect_tsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 void
 proto_reg_handoff_tsp(void)
 {
+       dissector_handle_t      tsp_handle;
+
+       tsp_handle = create_dissector_handle(dissect_tsp, proto_tsp);
        dissector_add("udp.port", UDP_PORT_TIMED, tsp_handle);
 }
 
@@ -221,7 +221,5 @@ proto_register_tsp(void)
                                        "TSP", "tsp");
        proto_register_field_array(proto_tsp, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
-
-       tsp_handle = create_dissector_handle(dissect_tsp, proto_tsp);
 }
 
index 160d2e14dc9cd5a4b724f2661b54faf33cc37108..0d14adf738d271accba365e80036c5404273367d 100644 (file)
@@ -136,10 +136,9 @@ UAT_DEC_CB_DEF(user_encap, trailer_size, user_encap_t)
 UAT_PROTO_DEF(user_encap, header_proto, header_proto, header_proto_name, user_encap_t)
 UAT_PROTO_DEF(user_encap, trailer_proto, trailer_proto, trailer_proto_name, user_encap_t)
 
-static dissector_handle_t user_encap_handle;
-
 void proto_reg_handoff_user_encap(void)
 {
+       dissector_handle_t user_encap_handle;
        guint i;
        
        user_encap_handle = find_dissector("user_dlt");
@@ -184,10 +183,10 @@ void proto_register_user_encap(void)
                                                 user_flds );
        
        prefs_register_uat_preference(module,
-                                                                 "encaps_table",
-                                                                 "Encapsulations Table",
-                                                                 "A table that enumerates the various protocols to be used against a cartain user DLT",
-                                                                 encaps_uat);
+                                     "encaps_table",
+                                     "Encapsulations Table",
+                                     "A table that enumerates the various protocols to be used against a cartain user DLT",
+                                     encaps_uat);
        
        
        register_dissector("user_dlt",dissect_user,proto_user_encap);
index bb6cd241464533bb4569fe2dfe42405dad8c7c65..be138df5aa61324a86d53984e092ac37558eb19b 100644 (file)
@@ -106,8 +106,6 @@ static gint ett_winsrepl_send_reply = -1;
 
 static gint ett_winsrepl_flags = -1;
 
-static dissector_handle_t winsrepl_handle;
-
 #define WINS_REPLICATION_PORT  ( 42 )
 #define WREPL_OPCODE_BITS      ( 0x7800 )
 
@@ -916,6 +914,8 @@ proto_register_winsrepl(void)
 void
 proto_reg_handoff_winsrepl(void)
 {
+       dissector_handle_t winsrepl_handle;
+
        winsrepl_handle = create_dissector_handle(dissect_winsrepl, proto_winsrepl);
        dissector_add("tcp.port", glb_winsrepl_tcp_port, winsrepl_handle);
 }
index b63704594e50b39b137a0768502005cb2ce89fce..46ddfbdff8642238996c24673298ff78821ac1a5 100644 (file)
@@ -203,13 +203,12 @@ proto_register_xyplex(void)
   proto_xyplex = proto_register_protocol("Xyplex", "XYPLEX", "xyplex");
   proto_register_field_array(proto_xyplex, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
-
-  xyplex_handle = create_dissector_handle(dissect_xyplex, proto_xyplex);
 }
 
 void
 proto_reg_handoff_xyplex(void)
 {
+  xyplex_handle = create_dissector_handle(dissect_xyplex, proto_xyplex);
   dissector_add("udp.port", UDP_PORT_XYPLEX, xyplex_handle);
 }