Cleanup related to prefs & proto_reg_handoff
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 3 Sep 2008 16:42:35 +0000 (16:42 +0000)
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 3 Sep 2008 16:42:35 +0000 (16:42 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@26128 f5534014-38df-0310-8fa8-9805f1628bb7

12 files changed:
epan/dissectors/packet-ieee8021ah.c
epan/dissectors/packet-kismet.c
epan/dissectors/packet-llt.c
epan/dissectors/packet-m2pa.c
epan/dissectors/packet-mgcp.c
epan/dissectors/packet-mp4ves.c
epan/dissectors/packet-netsync.c
epan/dissectors/packet-quake.c
epan/dissectors/packet-rtp-events.c
epan/dissectors/packet-sip.c
epan/dissectors/packet-tipc.c
epan/dissectors/packet-vnc.c

index e9c207996b053ee0eab004ff4c27be703066a157..ba1f1a690d0ba335aa44307096042b8ae4a480df 100644 (file)
@@ -45,7 +45,6 @@ void dissect_ieee8021ah_common(tvbuff_t *tvb, packet_info *pinfo,
 
 /* ethertype for 802.1ah tag - encapsulating an Ethernet packet */
 static unsigned int ieee8021ah_ethertype = ETHERTYPE_IEEE_802_1AH;
-static unsigned int old_ieee8021ah_ethertype;
 
 static int proto_ieee8021ah = -1;
 static int proto_ieee8021ad = -1;
@@ -434,6 +433,7 @@ proto_reg_handoff_ieee8021ah(void)
     static gboolean prefs_initialized = FALSE;
     static dissector_handle_t ieee8021ah_handle;
     static dissector_handle_t ieee8021ad_handle;
+    static unsigned int old_ieee8021ah_ethertype;
 
     if (!prefs_initialized){
        ieee8021ah_handle = create_dissector_handle(dissect_ieee8021ah, 
@@ -441,6 +441,7 @@ proto_reg_handoff_ieee8021ah(void)
 
        ieee8021ad_handle = create_dissector_handle(dissect_ieee8021ad,
                                                    proto_ieee8021ad);
+       dissector_add("ethertype", ETHERTYPE_IEEE_802_1AD, ieee8021ad_handle);
 
        prefs_initialized = TRUE;
     }
@@ -451,5 +452,4 @@ proto_reg_handoff_ieee8021ah(void)
     old_ieee8021ah_ethertype = ieee8021ah_ethertype;
     dissector_add("ethertype", ieee8021ah_ethertype, ieee8021ah_handle);
 
-    dissector_add("ethertype", ETHERTYPE_IEEE_802_1AD, ieee8021ad_handle);
 }
index cb5bc262328c1b3894c0ee5ae9d8a60add4d5f44..2402d597a22797beb927d71312bd01644cf7f22f 100644 (file)
@@ -49,7 +49,6 @@ static dissector_handle_t data_handle;
 #define TCP_PORT_KISMET        2501
 
 static guint global_kismet_tcp_port = TCP_PORT_KISMET;
-static guint tcp_port = 0;
 
 static gboolean response_is_continuation(const guchar * data);
 void proto_reg_handoff_kismet(void);
@@ -323,11 +322,13 @@ proto_register_kismet(void)
 void
 proto_reg_handoff_kismet(void)
 {
-       static int kismet_prefs_initialized = FALSE;
+       static gboolean kismet_prefs_initialized = FALSE;
        static dissector_handle_t kismet_handle;
+       static guint tcp_port;
 
        if (!kismet_prefs_initialized) {
                kismet_handle = new_create_dissector_handle(dissect_kismet, proto_kismet);
+               data_handle = find_dissector("data");
                kismet_prefs_initialized = TRUE;
        } else {
                dissector_delete("tcp.port", tcp_port, kismet_handle);
@@ -337,5 +338,4 @@ proto_reg_handoff_kismet(void)
        tcp_port = global_kismet_tcp_port;
 
        dissector_add("tcp.port", global_kismet_tcp_port, kismet_handle);
-       data_handle = find_dissector("data");
 }
index 71780c57a1336fdb7268f76055d4c7f3cb99d363..3b33f7547b977938b4c4207848376fa91c5cb400 100644 (file)
@@ -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);
        }
 }
index 92a0c9243138f36998a6df1f69caf643f0266e3b..0373299188d996c71f4157b3e47b30dcf780f4df 100644 (file)
@@ -44,7 +44,6 @@
 #define SCTP_PORT_M2PA              3565
 
 static guint global_sctp_port       = SCTP_PORT_M2PA;
-static guint sctp_port              = 0;
 
 void proto_reg_handoff_m2pa(void);
 
@@ -76,7 +75,6 @@ static int hf_pri_spare    = -1;
 static gint ett_m2pa       = -1;
 static gint ett_m2pa_li    = -1;
 
-static int mtp3_proto_id;
 static dissector_handle_t mtp3_handle;
 
 typedef enum {
@@ -596,14 +594,14 @@ proto_register_m2pa(void)
 void
 proto_reg_handoff_m2pa(void)
 {
-  static int prefs_initialized = FALSE;
+  static gboolean prefs_initialized = FALSE;
   static dissector_handle_t m2pa_handle;
+  static guint sctp_port;
 
   /* Port preferences code shamelessly copied from packet-beep.c */
   if (!prefs_initialized) {
+    m2pa_handle   = find_dissector("m2pa");
     mtp3_handle   = find_dissector("mtp3");
-    mtp3_proto_id = proto_get_id_by_filter_name("mtp3");
-    m2pa_handle   = create_dissector_handle(dissect_m2pa, proto_m2pa);
 
     dissector_add("sctp.ppi", M2PA_PAYLOAD_PROTOCOL_ID, m2pa_handle);
 
index 8c564c92466d30d31ce82d033fdbb1403682cac4..5cde55eb60d1e665b29df0bdc91b332e73d5c5f2 100644 (file)
@@ -254,15 +254,6 @@ static guint global_mgcp_callagent_udp_port = UDP_PORT_MGCP_CALLAGENT;
 static gboolean global_mgcp_raw_text = FALSE;
 static gboolean global_mgcp_message_count = FALSE;
 
-/*
- * Variables to allow for proper deletion of dissector registration when
- * the user changes port from the gui.
- */
-static int gateway_tcp_port = 0;
-static int gateway_udp_port = 0;
-static int callagent_tcp_port = 0;
-static int callagent_udp_port = 0;
-
 /* Some basic utility functions that are specific to this dissector */
 static gboolean is_mgcp_verb(tvbuff_t *tvb, gint offset, gint maxlength, const gchar **verb_name);
 static gboolean is_mgcp_rspcode(tvbuff_t *tvb, gint offset, gint maxlength);
@@ -949,13 +940,21 @@ void proto_register_mgcp(void)
 /* The registration hand-off routine */
 void proto_reg_handoff_mgcp(void)
 {
-       static int mgcp_prefs_initialized = FALSE;
+       static gboolean mgcp_prefs_initialized = FALSE;
        static dissector_handle_t mgcp_tpkt_handle;
-       /* Get a handle for the SDP dissector. */
-       sdp_handle = find_dissector("sdp");
+       /*
+        * Variables to allow for proper deletion of dissector registration when
+        * the user changes port from the gui.
+        */
+       static int gateway_tcp_port;
+       static int gateway_udp_port;
+       static int callagent_tcp_port;
+       static int callagent_udp_port;
 
        if (!mgcp_prefs_initialized)
        {
+               /* Get a handle for the SDP dissector. */
+               sdp_handle = find_dissector("sdp");
                mgcp_handle = new_create_dissector_handle(dissect_mgcp, proto_mgcp);
                mgcp_tpkt_handle = new_create_dissector_handle(dissect_tpkt_mgcp, proto_mgcp);
                mgcp_prefs_initialized = TRUE;
index 063f1ad050a8379b61c465cef1c6a98f61ac855a..96c045c23d526f6698c0879c438164230061546a 100644 (file)
@@ -56,8 +56,7 @@ static int ett_mp4ves_config = -1;
 
 /* The dynamic payload type which will be dissected as MP4V-ES */
 
-static guint dynamic_payload_type = 0;
-static guint temp_dynamic_payload_type = 0;
+static guint global_dynamic_payload_type = 0;
 
 
 static const range_string mp4ves_startcode_vals[] = {
@@ -220,25 +219,23 @@ dissect_mp4ves(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 void
 proto_reg_handoff_mp4ves(void)
 {
-       dissector_handle_t mp4ves_handle;
-       static int mp4ves_prefs_initialized = FALSE;
-
-       mp4ves_handle = create_dissector_handle(dissect_mp4ves, proto_mp4ves);
+       static dissector_handle_t mp4ves_handle;
+       static guint dynamic_payload_type;
+       static gboolean mp4ves_prefs_initialized = FALSE;
 
        if (!mp4ves_prefs_initialized) {
+               mp4ves_handle = find_dissector("mp4ves");
+               dissector_add_string("rtp_dyn_payload_type","MP4V-ES", mp4ves_handle);
                mp4ves_prefs_initialized = TRUE;
        }else{
                if ( dynamic_payload_type > 95 )
                        dissector_delete("rtp.pt", dynamic_payload_type, mp4ves_handle);
        }
-       dynamic_payload_type = temp_dynamic_payload_type;
+       dynamic_payload_type = global_dynamic_payload_type;
 
        if ( dynamic_payload_type > 95 ){
                dissector_add("rtp.pt", dynamic_payload_type, mp4ves_handle);
        }
-
-       dissector_add_string("rtp_dyn_payload_type","MP4V-ES", mp4ves_handle);
-
 }
 
 void
@@ -295,6 +292,6 @@ proto_register_mp4ves(void)
                                                                   "MP4V-ES dynamic payload type",
                                                                   "The dynamic payload type which will be interpreted as MP4V-ES",
                                                                   10,
-                                                                  &temp_dynamic_payload_type);
+                                                                  &global_dynamic_payload_type);
 
 }
index 79420be680ba9e27429654ff3c4270ecb2d2b92c..6da713d2b1777d696a9ec60cfeb00bf4127e3021 100644 (file)
@@ -161,10 +161,7 @@ static int ett_netsync = -1;
  * for monotone netsync
  */
 
-static dissector_handle_t netsync_handle;
-
 static guint global_tcp_port_netsync = TCP_PORT_NETSYNC;
-static guint tcp_port_netsync = TCP_PORT_NETSYNC;
 static gboolean netsync_desegment = TRUE;
 
 static gint dissect_uleb128( tvbuff_t *tvb, gint offset, guint* size)
@@ -757,8 +754,6 @@ proto_register_netsync(void)
        proto_register_field_array(proto_netsync, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
 
-       netsync_handle = create_dissector_handle(dissect_netsync, proto_netsync);
-
        netsync_module = prefs_register_protocol(proto_netsync,
                                                proto_reg_handoff_netsync);
 
@@ -779,12 +774,15 @@ proto_register_netsync(void)
 void
 proto_reg_handoff_netsync(void)
 {
-       static gint initialized = 0;
+       static dissector_handle_t netsync_handle;
+       static guint tcp_port_netsync;
+       static gboolean initialized = FALSE;
 
-       if (initialized) {
-               dissector_delete("tcp.port", tcp_port_netsync, netsync_handle);
+       if (!initialized) {
+               netsync_handle = create_dissector_handle(dissect_netsync, proto_netsync);
+               initialized = TRUE;
        } else {
-               initialized = 1;
+               dissector_delete("tcp.port", tcp_port_netsync, netsync_handle);
        }
 
        tcp_port_netsync = global_tcp_port_netsync;
index 9bec019ddc546600d2a5a6ffd1aae1857e9b71d0..506e2bae763a021e607981c162e2f0ac1409aaa3 100644 (file)
@@ -516,20 +516,21 @@ dissect_quake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 void
 proto_reg_handoff_quake(void)
 {
-       static int Initialized=FALSE;
-       static int ServerPort=0;
+       static gboolean Initialized=FALSE;
+       static int ServerPort;
 
-       if (Initialized) {
-               dissector_delete("udp.port", ServerPort, quake_handle);
-       } else {
+       if (!Initialized) {
+               quake_handle = create_dissector_handle(dissect_quake, proto_quake);
+               data_handle = find_dissector("data");
                Initialized=TRUE;
+       } else {
+               dissector_delete("udp.port", ServerPort, quake_handle);
        }
 
        /* set port for future deletes */
        ServerPort=gbl_quakeServerPort;
 
        dissector_add("udp.port", gbl_quakeServerPort, quake_handle);
-       data_handle = find_dissector("data");
 }
 
 
@@ -655,8 +656,6 @@ proto_register_quake(void)
        proto_register_field_array(proto_quake, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
 
-       quake_handle = create_dissector_handle(dissect_quake, proto_quake);
-
        /* Register a configuration option for port */
        quake_module = prefs_register_protocol(proto_quake,
                proto_reg_handoff_quake);
index 8e3411d3ec791a6878f0481890c697050a8b42ec..d634d6b8dd87beb88e8aebed96e79ecacc4fd331 100644 (file)
 
 /*  rtp_event_payload_type_value is the value used globally
        to set the appropriate payload type
-    saved_pt_value is a temporary place to save the value
-       so we can properly reinitialize when the settings
-       get changed
 */
 static guint rtp_event_payload_type_value = 101;
-static guint saved_payload_type_value;
 
 
 /* RTP Event Fields */
@@ -87,9 +83,9 @@ dissect_rtp_events( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
        guint8      octet;
 
        if ( check_col( pinfo->cinfo, COL_PROTOCOL ) )
-         {
+       {
            col_set_str( pinfo->cinfo, COL_PROTOCOL, "RTP EVENT" );
-         }
+       }
        if (check_col(pinfo->cinfo, COL_INFO))
                col_clear(pinfo->cinfo, COL_INFO);
 
@@ -109,23 +105,23 @@ dissect_rtp_events( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
 
 
        if ( check_col( pinfo->cinfo, COL_INFO) )
-         {
+       {
                col_add_fstr( pinfo->cinfo, COL_INFO,
                    "Payload type=RTP Event, %s",
                    val_to_str( rtp_evt, rtp_event_type_values, "Unknown (%u)" ));
-         }
+       }
 
-    ti = proto_tree_add_item( tree, proto_rtp_events, tvb, offset, -1, FALSE );
-    rtp_events_tree = proto_item_add_subtree( ti, ett_rtp_events );
+       ti = proto_tree_add_item( tree, proto_rtp_events, tvb, offset, -1, FALSE );
+       rtp_events_tree = proto_item_add_subtree( ti, ett_rtp_events );
 
-    proto_tree_add_uint ( rtp_events_tree, hf_rtp_events_event, tvb, offset, 1, rtp_evt);
+       proto_tree_add_uint ( rtp_events_tree, hf_rtp_events_event, tvb, offset, 1, rtp_evt);
 
-    octet = tvb_get_guint8(tvb, offset +1 );
-    proto_tree_add_boolean (rtp_events_tree, hf_rtp_events_end, tvb, offset+1, 1, octet);
-    proto_tree_add_boolean (rtp_events_tree, hf_rtp_events_reserved, tvb, offset+1, 1, octet);
-    proto_tree_add_uint ( rtp_events_tree, hf_rtp_events_volume, tvb, offset+1, 1, octet);
+       octet = tvb_get_guint8(tvb, offset +1 );
+       proto_tree_add_boolean (rtp_events_tree, hf_rtp_events_end, tvb, offset+1, 1, octet);
+       proto_tree_add_boolean (rtp_events_tree, hf_rtp_events_reserved, tvb, offset+1, 1, octet);
+       proto_tree_add_uint ( rtp_events_tree, hf_rtp_events_volume, tvb, offset+1, 1, octet);
 
-    proto_tree_add_item ( rtp_events_tree, hf_rtp_events_duration, tvb, offset+2, 2, FALSE);
+       proto_tree_add_item ( rtp_events_tree, hf_rtp_events_duration, tvb, offset+2, 2, FALSE);
 
        /* set the end info for the tap */
        if (octet & 0x80)
@@ -136,11 +132,11 @@ dissect_rtp_events( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
                rtp_event_info.info_end = FALSE;
        }
 
-    /* Make end-of-event packets obvious in the info column */
-    if ((octet & 0x80) && check_col(pinfo->cinfo, COL_INFO))
-    {
-           col_append_str(pinfo->cinfo, COL_INFO, " (end)");
-    }
+       /* Make end-of-event packets obvious in the info column */
+       if ((octet & 0x80) && check_col(pinfo->cinfo, COL_INFO))
+       {
+               col_append_str(pinfo->cinfo, COL_INFO, " (end)");
+       }
 
        tap_queue_packet(rtp_event_tap, pinfo, &rtp_event_info);
 }
@@ -229,9 +225,9 @@ proto_register_rtp_events(void)
        proto_register_subtree_array(ett, array_length(ett));
 
 
-    /* Register preferences */
-    rtp_events_module = prefs_register_protocol (proto_rtp_events, proto_reg_handoff_rtp_events);
-    prefs_register_uint_preference (rtp_events_module,
+       /* Register preferences */
+       rtp_events_module = prefs_register_protocol (proto_rtp_events, proto_reg_handoff_rtp_events);
+       prefs_register_uint_preference (rtp_events_module,
                                     "event_payload_type_value", "Payload Type for RFC2833 RTP Events",
                                     "This is the value of the Payload Type field"
                                     "that specifies RTP Events", 10,
@@ -246,10 +242,15 @@ void
 proto_reg_handoff_rtp_events(void)
 {
        static dissector_handle_t rtp_events_handle;
-       static int rtp_events_prefs_initialized = FALSE;
+       /* saved_payload_type_value is a temporary place to save */
+       /* the value so we can properly reinitialize when the    */
+       /* settings get changed.                                 */
+       static guint saved_payload_type_value;
+       static gboolean rtp_events_prefs_initialized = FALSE;
 
        if (!rtp_events_prefs_initialized) {
-               rtp_events_handle = create_dissector_handle(dissect_rtp_events, proto_rtp_events);
+               rtp_events_handle = find_dissector("rtpevent");
+               dissector_add_string("rtp_dyn_payload_type", "telephone-event", rtp_events_handle);
                rtp_events_prefs_initialized = TRUE;
        }
        else {
@@ -259,6 +260,5 @@ proto_reg_handoff_rtp_events(void)
        saved_payload_type_value = rtp_event_payload_type_value;
        /* rtp_event_payload_type_value is set from preferences */
 
-    dissector_add("rtp.pt", saved_payload_type_value, rtp_events_handle);
-       dissector_add_string("rtp_dyn_payload_type", "telephone-event", rtp_events_handle);
+       dissector_add("rtp.pt", saved_payload_type_value, rtp_events_handle);
 }
index 3c707b7c8e999302ad493860e48562ad1c5f9243..770f97f23214c0b2f9368fa223e8cc84ec77f530 100644 (file)
 static gint sip_tap = -1;
 static dissector_handle_t sigcomp_handle;
 
-/* Dissectors */
-static dissector_handle_t sip_handle = NULL;
-static dissector_handle_t sip_tcp_handle = NULL;
-
 /* Initialize the protocol and registered fields */
 static gint proto_sip                          = -1;
 static gint proto_raw_sip                      = -1;
@@ -552,10 +548,6 @@ static gboolean sip_desegment_headers = TRUE;
  */
 static gboolean sip_desegment_body = TRUE;
 
-/* Gloabl variables */
-static guint saved_sip_tcp_port;
-static guint saved_sip_tls_port;
-
 /* Forward declaration we need below */
 void proto_reg_handoff_sip(void);
 static gboolean dissect_sip_common(tvbuff_t *tvb, int offset, packet_info *pinfo,
@@ -2751,28 +2743,28 @@ static gint sip_is_known_sip_header(tvbuff_t *tvb, int offset, guint header_len)
 static void
 tvb_raw_text_add(tvbuff_t *tvb, int offset, int length, proto_tree *tree)
 {
-    proto_tree *raw_tree = NULL;
-    proto_item *ti = NULL;
-    int next_offset, linelen, end_offset;
-
-    if (tree) {
-        ti = proto_tree_add_item(tree, proto_raw_sip, tvb, offset, length, FALSE);
-        raw_tree = proto_item_add_subtree(ti, ett_raw_text);
-    }
-
-    end_offset = offset + length;
-
-    while (offset < end_offset) {
-        tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
-        linelen = next_offset - offset;
-        if (raw_tree) {
-            proto_tree_add_string_format(raw_tree, hf_raw_sip_line, tvb, offset, linelen,
-                                         tvb_format_text(tvb, offset, linelen),
-                                         "%s",
-                                         tvb_format_text(tvb, offset, linelen));
-        }
-        offset = next_offset;
-    }
+       proto_tree *raw_tree = NULL;
+       proto_item *ti = NULL;
+       int next_offset, linelen, end_offset;
+
+       if (tree) {
+               ti = proto_tree_add_item(tree, proto_raw_sip, tvb, offset, length, FALSE);
+               raw_tree = proto_item_add_subtree(ti, ett_raw_text);
+       }
+
+       end_offset = offset + length;
+
+       while (offset < end_offset) {
+               tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
+               linelen = next_offset - offset;
+               if (raw_tree) {
+                       proto_tree_add_string_format(raw_tree, hf_raw_sip_line, tvb, offset, linelen,
+                                                    tvb_format_text(tvb, offset, linelen),
+                                                    "%s",
+                                                    tvb_format_text(tvb, offset, linelen));
+               }
+               offset = next_offset;
+       }
 }
 
 /* Check to see if this packet is a resent request.  Return value is the frame number
@@ -3418,7 +3410,7 @@ void proto_register_sip(void)
                           "RFC 3327: Path Header", HFILL }
                },
 
-        { &hf_header_array[POS_PRIORITY],
+               { &hf_header_array[POS_PRIORITY],
                       { "Priority",            "sip.Priority",
                       FT_STRING, BASE_NONE,NULL,0x0,
                        "RFC 3261: Priority Header", HFILL }
@@ -3429,7 +3421,7 @@ void proto_register_sip(void)
                        "Privacy Header", HFILL }
                },
 
-        { &hf_header_array[POS_PROXY_AUTHENTICATE],
+               { &hf_header_array[POS_PROXY_AUTHENTICATE],
                       { "Proxy-Authenticate",          "sip.Proxy-Authenticate",
                       FT_STRING, BASE_NONE,NULL,0x0,
                        "RFC 3261: Proxy-Authenticate Header", HFILL }
@@ -3440,7 +3432,7 @@ void proto_register_sip(void)
                        "RFC 3261: Proxy-Authorization Header", HFILL }
                },
 
-        { &hf_header_array[POS_PROXY_REQUIRE],
+               { &hf_header_array[POS_PROXY_REQUIRE],
                       { "Proxy-Require",               "sip.Proxy-Require",
                       FT_STRING, BASE_NONE,NULL,0x0,
                        "RFC 3261: Proxy-Require Header", HFILL }
@@ -3510,7 +3502,7 @@ void proto_register_sip(void)
                       FT_STRING, BASE_NONE,NULL,0x0,
                        "RFC 3261: Route Header", HFILL }
                },
-        { &hf_header_array[POS_RSEQ],
+               { &hf_header_array[POS_RSEQ],
                       { "RSeq",                "sip.RSeq",
                       FT_UINT32, BASE_DEC,NULL,0x0,
                        "RFC 3262: RSeq Header", HFILL }
@@ -3865,9 +3857,7 @@ void proto_register_sip(void)
        proto_raw_sip = proto_register_protocol("Session Initiation Protocol (SIP as raw text)",
                                                "Raw_SIP", "raw_sip");
        new_register_dissector("sip", dissect_sip, proto_sip);
-       sip_handle = find_dissector("sip");
        register_dissector("sip.tcp", dissect_sip_tcp, proto_sip);
-       sip_tcp_handle = find_dissector("sip.tcp");
 
        /* Required function calls to register the header fields and subtrees used */
        proto_register_field_array(proto_sip, hf, array_length(hf));
@@ -3877,16 +3867,13 @@ void proto_register_sip(void)
        /* Register raw_sip field(s) */
        proto_register_field_array(proto_raw_sip, raw_hf, array_length(raw_hf));
 
-       /* SIP content type and internet media type used by other dissectors are the same */
-       media_type_dissector_table = find_dissector_table("media_type");
-
        sip_module = prefs_register_protocol(proto_sip, proto_reg_handoff_sip);
 
-  prefs_register_uint_preference(sip_module, "tcp.port",
+       prefs_register_uint_preference(sip_module, "tcp.port",
                                  "SIP TCP Port",
                                  "SIP Server TCP Port",
                                  10, &sip_tcp_port);
-  prefs_register_uint_preference(sip_module, "tls.port",
+       prefs_register_uint_preference(sip_module, "tls.port",
                                  "SIP TLS Port",
                                  "SIP Server TLS Port",
                                  10, &sip_tls_port);
@@ -3921,7 +3908,7 @@ void proto_register_sip(void)
            &sip_desegment_body);
 
        register_init_routine(&sip_init_protocol);
-    register_heur_dissector_list("sip", &heur_subdissector_list);
+       register_heur_dissector_list("sip", &heur_subdissector_list);
        /* Register for tapping */
        sip_tap = register_tap("sip");
 }
@@ -3929,26 +3916,35 @@ void proto_register_sip(void)
 void
 proto_reg_handoff_sip(void)
 {
-  static gboolean sip_prefs_initialized = FALSE;
-
-  if (sip_prefs_initialized) {
-    dissector_delete("tcp.port", saved_sip_tcp_port, sip_tcp_handle);
-    ssl_dissector_delete(saved_sip_tls_port, "sip.tcp", TRUE);
-  } else {
-    sip_prefs_initialized = TRUE;
-  }
-  /* Set our port number for future use */
-  saved_sip_tcp_port = sip_tcp_port;
-  dissector_add("tcp.port", saved_sip_tcp_port, sip_tcp_handle);
-  saved_sip_tls_port = sip_tls_port;
-  ssl_dissector_add(saved_sip_tls_port, "sip.tcp", TRUE);
-
-       dissector_add("udp.port", UDP_PORT_SIP, sip_handle);
-       dissector_add_string("media_type", "message/sip", sip_handle);
-       sigcomp_handle = find_dissector("sigcomp");
-
-       heur_dissector_add("udp", dissect_sip_heur, proto_sip);
-       heur_dissector_add("tcp", dissect_sip_tcp_heur, proto_sip);
-       heur_dissector_add("sctp", dissect_sip_heur, proto_sip);
-       heur_dissector_add("stun2", dissect_sip_heur, proto_sip);
+       static dissector_handle_t sip_handle;
+       static dissector_handle_t sip_tcp_handle;
+       static guint saved_sip_tcp_port;
+       static guint saved_sip_tls_port;
+       static gboolean sip_prefs_initialized = FALSE;
+
+       if (!sip_prefs_initialized) {
+               sip_handle = find_dissector("sip");
+               sip_tcp_handle = find_dissector("sip.tcp");
+               sigcomp_handle = find_dissector("sigcomp");
+               /* SIP content type and internet media type used by other dissectors are the same */
+               media_type_dissector_table = find_dissector_table("media_type");
+
+               dissector_add("udp.port", UDP_PORT_SIP, sip_handle);
+               dissector_add_string("media_type", "message/sip", sip_handle);
+
+               heur_dissector_add("udp", dissect_sip_heur, proto_sip);
+               heur_dissector_add("tcp", dissect_sip_tcp_heur, proto_sip);
+               heur_dissector_add("sctp", dissect_sip_heur, proto_sip);
+               heur_dissector_add("stun2", dissect_sip_heur, proto_sip);
+               sip_prefs_initialized = TRUE;
+       } else {
+               dissector_delete("tcp.port", saved_sip_tcp_port, sip_tcp_handle);
+               ssl_dissector_delete(saved_sip_tls_port, "sip.tcp", TRUE);
+       }
+       /* Set our port number for future use */
+       saved_sip_tcp_port = sip_tcp_port;
+       saved_sip_tls_port = sip_tls_port;
+       dissector_add("tcp.port", saved_sip_tcp_port, sip_tcp_handle);
+       ssl_dissector_add(saved_sip_tls_port, "sip.tcp", TRUE);
+
 }
index ebfd70d663a352b5b76829289e968890b562f3ee..1f88c1ea0210b035686e985bf1cc6561904715b1 100644 (file)
@@ -52,8 +52,6 @@
 static int proto_tipc = -1;
 
 /* dissector handles */
-static dissector_handle_t tipc_handle;
-static dissector_handle_t tipc_tcp_handle;
 static dissector_handle_t data_handle;
 static dissector_handle_t ip_handle;
 
@@ -186,7 +184,6 @@ static gint ett_tipc = -1;
 static gint ett_tipc_data = -1;
 
 /* protocol preferences */
-static gboolean inited = FALSE;
 static gboolean tipc_defragment = TRUE;
 static gboolean dissect_tipc_data = TRUE;
 static gboolean try_heuristic_first = FALSE;
@@ -195,7 +192,6 @@ static gboolean try_heuristic_first = FALSE;
 #define V2_AS_1_7  0x4
 static gint     handle_v2_as = V2_AS_ALL;
 static guint tipc_alternate_tcp_port = 0;
-static guint tipc_alternate_tcp_port_prev = 0;
 static gboolean tipc_tcp_desegment = TRUE;
 
 /* this is used to find encapsulated protocols */
@@ -2969,6 +2965,11 @@ proto_register_tipc(void)
 void
 proto_reg_handoff_tipc(void)
 {
+       static gboolean inited = FALSE;
+       static dissector_handle_t tipc_handle;
+       static dissector_handle_t tipc_tcp_handle;
+       static guint tipc_alternate_tcp_port_prev = 0;
+
        if (!inited) {
                tipc_handle = create_dissector_handle(dissect_tipc, proto_tipc);
                tipc_tcp_handle = new_create_dissector_handle(dissect_tipc_tcp, proto_tipc);
index 8bce57cf9e5908ff001c476245aaaa4b6bc5e459..1a2ced273fa484c4d77048c76eda3c326defb31a 100644 (file)
@@ -238,12 +238,6 @@ static guint8 vnc_get_bytes_per_pixel(packet_info *pinfo);
 /* Variables for our preferences */
 static guint vnc_preference_alternate_port = 0;
 
-/* This is a behind the scenes variable that is not changed by the user.
- * This stores last setting of the vnc_preference_alternate_port.  Used to keep
- * track of when the user has changed the setting so that we can delete
- * and re-register with the new port number. */
-static guint vnc_preference_alternate_port_last = 0;
-
 /* Initialize the protocol and registered fields */
 static int proto_vnc = -1; /* Protocol subtree */
 static int hf_vnc_padding = -1;
@@ -411,8 +405,6 @@ static gint ett_vnc_zrle_subencoding = -1;
 static gint ett_vnc_colormap_num_groups = -1;
 static gint ett_vnc_colormap_color_group = -1;
 
-static dissector_handle_t vnc_handle;
-
 guint8 vnc_bytes_per_pixel; /* Global so it keeps its value between packets */
 
 
@@ -2397,11 +2389,16 @@ proto_register_vnc(void)
 void
 proto_reg_handoff_vnc(void)
 {
-        static gboolean inited = FALSE;
+       static gboolean inited = FALSE;
+       static dissector_handle_t vnc_handle;
+       /* This is a behind the scenes variable that is not changed by the user.
+        * This stores last setting of the vnc_preference_alternate_port.  Used to keep
+        * track of when the user has changed the setting so that we can delete
+        * and re-register with the new port number. */
+       static guint vnc_preference_alternate_port_last = 0;
 
-        if(!inited) {
-               vnc_handle = create_dissector_handle(dissect_vnc,
-                                                    proto_vnc);
+       if(!inited) {
+               vnc_handle = create_dissector_handle(dissect_vnc, proto_vnc);
 
                dissector_add("tcp.port", 5500, vnc_handle);
                dissector_add("tcp.port", 5501, vnc_handle);
@@ -2414,26 +2411,27 @@ proto_reg_handoff_vnc(void)
                 * VNC port. */
 
                inited = TRUE;
+       } else {  /* only after preferences have been read/changed */
+               if(vnc_preference_alternate_port != vnc_preference_alternate_port_last &&
+                  vnc_preference_alternate_port != 5500 &&
+                  vnc_preference_alternate_port != 5501 &&
+                  vnc_preference_alternate_port != 5900 &&
+                  vnc_preference_alternate_port != 5901) {
+                       if (vnc_preference_alternate_port_last != 0) {
+                               dissector_delete("tcp.port",
+                                                vnc_preference_alternate_port_last,
+                                                vnc_handle);
+                       }
+                       /* Save this setting to see if has changed later */
+                       vnc_preference_alternate_port_last =
+                               vnc_preference_alternate_port;
+
+                       /* Register the new port setting */
+                       if (vnc_preference_alternate_port != 0) {
+                               dissector_add("tcp.port", 
+                                             vnc_preference_alternate_port,
+                                             vnc_handle);
+                       }
+               }
        }
-
-       if(vnc_preference_alternate_port != 5500 &&
-          vnc_preference_alternate_port != 5501 &&
-          vnc_preference_alternate_port != 5900 &&
-          vnc_preference_alternate_port != 5901 &&
-          vnc_preference_alternate_port != 0) {
-
-               dissector_delete("tcp.port",
-                                vnc_preference_alternate_port_last,
-                                vnc_handle);
-
-               /* Save this setting to see if has changed later */
-               vnc_preference_alternate_port_last =
-                       vnc_preference_alternate_port;
-
-               /* Register the new port setting */
-                       dissector_add("tcp.port", vnc_preference_alternate_port,
-                             vnc_handle);
-               
-       }
-
 }