Minor cleanup mostly related to proto_reg_handoff

Remove code for unused handles;
 Localize handles (in proto_reg_handoff) which need not be global;
 Localize (in proto_reg_handoff) "saved prefs";
 Use find_dissector instead of create_dissector_handle as appropriate;
 Use gboolean for "initialized" flag in proto_reg_handoff.

svn path=/trunk/; revision=26693
This commit is contained in:
Bill Meier 2008-11-04 21:42:02 +00:00
parent a3d5cbf5d8
commit f35324d0fd
17 changed files with 50 additions and 102 deletions

View File

@ -59,7 +59,6 @@ int proto_h235 = -1;
/* Initialize the subtree pointers */
#include "packet-h235-ett.c"
static dissector_handle_t mikey_handle=NULL;
static int
dissect_xxx_ToBeSigned(tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) {
@ -102,8 +101,8 @@ void proto_register_h235(void) {
oid_add_from_string("HMAC-SHA1-96","0.0.8.235.0.1.6");
oid_add_from_string("HMAC-SHA1-96","0.0.8.235.0.2.6");
/* H.235.7, Chapter 5, Table 1 */
oid_add_from_string("MIKEY", OID_MIKEY);
oid_add_from_string("MIKEY-PS", OID_MIKEY_PS);
oid_add_from_string("MIKEY", OID_MIKEY);
oid_add_from_string("MIKEY-PS", OID_MIKEY_PS);
oid_add_from_string("MIKEY-DHHMAC", OID_MIKEY_DHHMAC);
oid_add_from_string("MIKEY-PK-SIGN", OID_MIKEY_PK_SIGN);
oid_add_from_string("MIKEY-DH-SIGN", OID_MIKEY_DH_SIGN);
@ -120,6 +119,7 @@ void proto_register_h235(void) {
/*--- proto_reg_handoff_h235 -------------------------------------------*/
void proto_reg_handoff_h235(void) {
dissector_handle_t mikey_handle;
mikey_handle = find_dissector("mikey");

View File

@ -71,7 +71,6 @@ static dissector_table_t gef_name_dissector_table;
static dissector_table_t gef_content_dissector_table;
static dissector_handle_t nsp_handle;
static dissector_handle_t data_handle;
static dissector_handle_t h245_handle;
static dissector_handle_t MultimediaSystemControlMessage_handle;
static dissector_handle_t h263_handle = NULL;
static dissector_handle_t amr_handle = NULL;
@ -554,6 +553,8 @@ void proto_register_h245(void) {
/*--- proto_reg_handoff_h245 ---------------------------------------*/
void proto_reg_handoff_h245(void) {
dissector_handle_t h245_handle;
rtp_handle = find_dissector("rtp");
rtcp_handle = find_dissector("rtcp");
t38_handle = find_dissector("t38");
@ -562,9 +563,9 @@ void proto_reg_handoff_h245(void) {
amr_handle = find_dissector("amr_if2_nb");
h245_handle=create_dissector_handle(dissect_h245, proto_h245);
h245_handle = find_dissector("h245");
dissector_add_handle("tcp.port", h245_handle);
MultimediaSystemControlMessage_handle=create_dissector_handle(dissect_h245_h245, proto_h245);
MultimediaSystemControlMessage_handle = find_dissector("h245dg");
dissector_add_handle("udp.port", MultimediaSystemControlMessage_handle);
}

View File

@ -51,13 +51,10 @@ int proto_h283 = -1;
static int ett_h283 = -1;
#include "packet-h283-ett.c"
/* Dissectors */
static dissector_handle_t h283_udp_handle = NULL;
/* Subdissectors */
static dissector_handle_t rdc_pdu_handle = NULL;
static dissector_handle_t rdc_device_list_handle = NULL;
static dissector_handle_t data_handle = NULL;
static dissector_handle_t rdc_pdu_handle;
static dissector_handle_t rdc_device_list_handle;
static dissector_handle_t data_handle;
static gboolean info_is_set;
@ -102,14 +99,15 @@ void proto_register_h283(void) {
proto_register_subtree_array(ett, array_length(ett));
new_register_dissector(PFNAME, dissect_h283_udp, proto_h283);
h283_udp_handle = find_dissector(PFNAME);
}
/*--- proto_reg_handoff_h283 -------------------------------------------*/
void proto_reg_handoff_h283(void)
{
dissector_handle_t h283_udp_handle;
h283_udp_handle = find_dissector(PFNAME);
dissector_add_handle("udp.port", h283_udp_handle);
rdc_pdu_handle = find_dissector("rdc");

View File

@ -91,9 +91,6 @@ void gef_ctx_update_key(gef_ctx_t *gefx) {
);
}
/* Subdissectors */
static dissector_handle_t q931_handle = NULL;
/* Initialize the protocol and registered fields */
int proto_h323 = -1;
#include "packet-h323-hf.c"
@ -129,6 +126,8 @@ void proto_register_h323(void) {
/*--- proto_reg_handoff_h323 -------------------------------------------*/
void proto_reg_handoff_h323(void)
{
dissector_handle_t q931_handle;
q931_handle = find_dissector("q931");
/* H.323, Annex M1, Tunnelling of signalling protocols (QSIG) in H.323 */

View File

@ -71,9 +71,6 @@ static const value_string h450_str_error[] = {
/* ROSE context */
static rose_ctx_t h450_rose_ctx;
/* Subdissectors */
static dissector_handle_t data_handle = NULL;
/* Global variables */
#include "packet-h450-fn.c"
@ -292,8 +289,6 @@ proto_reg_handoff_h450(void)
dissector_handle_t h450_res_handle;
dissector_handle_t h450_err_handle;
data_handle = find_dissector("data");
h450_arg_handle = new_create_dissector_handle(dissect_h450_arg, proto_h450);
h450_res_handle = new_create_dissector_handle(dissect_h450_res, proto_h450);
for (i=0; i<(int)array_length(h450_op_tab); i++) {

View File

@ -55,19 +55,13 @@ static int ett_h501 = -1;
#include "packet-h501-ett.c"
/* Dissectors */
static dissector_handle_t h501_pdu_handle = NULL;
static dissector_handle_t h501_udp_handle = NULL;
static dissector_handle_t h501_tcp_handle = NULL;
static dissector_handle_t h501_pdu_handle;
/* Preferences */
static guint h501_udp_port = 2099;
static guint h501_tcp_port = 2099;
static gboolean h501_desegment_tcp = TRUE;
/* Gloabl variables */
static guint saved_h501_udp_port;
static guint saved_h501_tcp_port;
void proto_reg_handoff_h501(void);
#include "packet-h501-fn.c"
@ -124,10 +118,6 @@ void proto_register_h501(void) {
proto_register_subtree_array(ett, array_length(ett));
new_register_dissector(PFNAME, dissect_h501_pdu, proto_h501);
h501_pdu_handle = find_dissector(PFNAME);
h501_udp_handle = new_create_dissector_handle(dissect_h501_udp, proto_h501);
h501_tcp_handle = new_create_dissector_handle(dissect_h501_tcp, proto_h501);
h501_module = prefs_register_protocol(proto_h501, proto_reg_handoff_h501);
prefs_register_uint_preference(h501_module, "udp.port",
@ -149,12 +139,19 @@ void proto_register_h501(void) {
void proto_reg_handoff_h501(void)
{
static gboolean h501_prefs_initialized = FALSE;
static dissector_handle_t h501_udp_handle;
static dissector_handle_t h501_tcp_handle;
static guint saved_h501_udp_port;
static guint saved_h501_tcp_port;
if (h501_prefs_initialized) {
if (!h501_prefs_initialized) {
h501_pdu_handle = find_dissector(PFNAME);
h501_udp_handle = new_create_dissector_handle(dissect_h501_udp, proto_h501);
h501_tcp_handle = new_create_dissector_handle(dissect_h501_tcp, proto_h501);
h501_prefs_initialized = TRUE;
} else {
dissector_delete("udp.port", saved_h501_udp_port, h501_udp_handle);
dissector_delete("tcp.port", saved_h501_tcp_port, h501_tcp_handle);
} else {
h501_prefs_initialized = TRUE;
}
/* Set our port number for future use */

View File

@ -568,9 +568,8 @@ proto_register_mpeg_pes(void)
void
proto_reg_handoff_mpeg_pes(void)
{
dissector_handle_t mpeg_handle = create_dissector_handle(
dissect_mpeg, proto_mpeg);
dissector_add("wtap_encap", WTAP_ENCAP_MPEG, mpeg_handle);
dissector_handle_t mpeg_handle = find_dissector("mpeg");
dissector_add("wtap_encap", WTAP_ENCAP_MPEG, mpeg_handle);
heur_dissector_add("mpeg", dissect_mpeg_pes, proto_mpeg_pes);
}

View File

@ -51,8 +51,6 @@
#include "packet-nbap-val.h"
static dissector_handle_t nbap_handle = NULL;
/* Initialize the protocol and registered fields */
static int proto_nbap = -1;
@ -153,7 +151,6 @@ void proto_register_nbap(void) {
/* Register dissector */
register_dissector("nbap", dissect_nbap, proto_nbap);
nbap_handle = find_dissector("nbap");
/* Register dissector tables */
nbap_ies_dissector_table = register_dissector_table("nbap.ies", "NBAP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
@ -169,7 +166,9 @@ void proto_register_nbap(void) {
void
proto_reg_handoff_nbap(void)
{
dissector_handle_t nbap_handle;
nbap_handle = find_dissector("nbap");
/*dissector_add("sctp.ppi", Add ppid here, nbap_handle); */
dissector_add("sctp.port", 0, nbap_handle);

View File

@ -57,9 +57,6 @@ static struct SESSION_DATA_STRUCTURE* session = NULL;
proto_tree *global_tree = NULL;
packet_info *global_pinfo = NULL;
/* dissector for data */
static dissector_handle_t data_handle;
static const char *abstract_syntax_name_oid;
static guint32 presentation_context_identifier;
@ -345,6 +342,4 @@ void proto_reg_handoff_pres(void) {
/* register_ber_oid_dissector("0.4.0.0.1.1.1.1", dissect_pres, proto_pres,
"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) abstractSyntax(1) pres(1) version1(1)"); */
data_handle = find_dissector("data");
}

View File

@ -60,11 +60,7 @@ static gint ett_q932_ie = -1;
static rose_ctx_t q932_rose_ctx;
/* Subdissectors */
static dissector_handle_t data_handle = NULL;
static dissector_handle_t q932_ros_handle = NULL;
/* Gloabl variables */
static dissector_handle_t q932_ros_handle;
#define Q932_IE_EXTENDED_FACILITY 0x0D
#define Q932_IE_FACILITY 0x1C
@ -335,7 +331,6 @@ void proto_reg_handoff_q932(void) {
dissector_add("q931.ie", (0x00 << 8) | Q932_IE_NOTIFICATION_INDICATOR, q932_ie_handle);
q932_ros_handle = find_dissector("q932.ros");
data_handle = find_dissector("data");
}
/*---------------------------------------------------------------------------*/

View File

@ -312,11 +312,7 @@ static gint ett_qsig_unknown_extension = -1;
/* Preferences */
/* Subdissectors */
static dissector_handle_t q931_handle = NULL;
static dissector_handle_t data_handle = NULL;
/* Gloabl variables */
/* Global variables */
static const char *extension_oid = NULL;
/* Dissector tables */
@ -643,13 +639,13 @@ void proto_register_qsig(void) {
/*--- proto_reg_handoff_qsig ------------------------------------------------*/
void proto_reg_handoff_qsig(void) {
int i;
dissector_handle_t q931_handle;
dissector_handle_t qsig_arg_handle;
dissector_handle_t qsig_res_handle;
dissector_handle_t qsig_err_handle;
dissector_handle_t qsig_ie_handle;
q931_handle = find_dissector("q931");
data_handle = find_dissector("data");
qsig_arg_handle = new_create_dissector_handle(dissect_qsig_arg, proto_qsig);
qsig_res_handle = new_create_dissector_handle(dissect_qsig_res, proto_qsig);

View File

@ -56,8 +56,6 @@
#include "packet-rnsap-val.h"
static dissector_handle_t rnsap_handle = NULL;
static dissector_handle_t rrc_dl_dcch_handle = NULL;
/* Initialize the protocol and registered fields */
@ -160,7 +158,6 @@ void proto_register_rnsap(void) {
/* Register dissector */
register_dissector("rnsap", dissect_rnsap, proto_rnsap);
rnsap_handle = find_dissector("rnsap");
/* Register dissector tables */
rnsap_ies_dissector_table = register_dissector_table("rnsap.ies", "RNSAP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
@ -176,7 +173,9 @@ void proto_register_rnsap(void) {
void
proto_reg_handoff_rnsap(void)
{
dissector_handle_t rnsap_handle;
rnsap_handle = find_dissector("rnsap");
rrc_dl_dcch_handle = find_dissector("rrc.dl.dcch");
dissector_add("sccp.ssn", SCCP_SSN_RNSAP, rnsap_handle);

View File

@ -53,8 +53,7 @@
#define PSNAME "RRC"
#define PFNAME "rrc"
static dissector_handle_t rrc_handle=NULL;
static dissector_handle_t gsm_a_dtap_handle=NULL;
static dissector_handle_t gsm_a_dtap_handle;
/* Include constants */
#include "packet-rrc-val.h"
@ -141,7 +140,6 @@ void proto_register_rrc(void) {
proto_register_field_array(proto_rrc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("rrc", dissect_rrc, proto_rrc);
#include "packet-rrc-dis-reg.c"
@ -154,7 +152,6 @@ void
proto_reg_handoff_rrc(void)
{
rrc_handle = find_dissector("rrc");
gsm_a_dtap_handle = find_dissector("gsm_a_dtap");
}

View File

@ -53,8 +53,6 @@
#pragma warning(disable:4146)
#endif
static dissector_handle_t rrlp_handle=NULL;
/* Initialize the protocol and registered fields */
static int proto_rrlp = -1;
@ -106,9 +104,6 @@ void
proto_reg_handoff_rrlp(void)
{
rrlp_handle = create_dissector_handle(dissect_PDU_PDU, proto_rrlp);
}

View File

@ -96,8 +96,6 @@ static gint ett_spnego_krb5_cfx_flags = -1;
#include "packet-spnego-ett.c"
static dissector_handle_t data_handle;
/*
* Unfortunately, we have to have a forward declaration of this,
* as the code generated by asn2wrs includes a call before the
@ -1414,9 +1412,8 @@ void proto_reg_handoff_spnego(void) {
/* Register protocol with GSS-API module */
spnego_handle = create_dissector_handle(dissect_spnego, proto_spnego);
spnego_wrap_handle = new_create_dissector_handle(dissect_spnego_wrap,
proto_spnego);
spnego_handle = find_dissector("spnego");
spnego_wrap_handle = new_create_dissector_handle(dissect_spnego_wrap, proto_spnego);
gssapi_init_oid("1.3.6.1.5.5.2", proto_spnego, ett_spnego,
spnego_handle, spnego_wrap_handle,
"SPNEGO - Simple Protected Negotiation");
@ -1430,10 +1427,8 @@ void proto_reg_handoff_spnego(void) {
* See the archive of <ietf-krb-wg@anl.gov> for the thread topic
* SPNEGO implementation issues. 3-Dec-2002.
*/
spnego_krb5_handle = create_dissector_handle(dissect_spnego_krb5,
proto_spnego_krb5);
spnego_krb5_wrap_handle = new_create_dissector_handle(dissect_spnego_krb5_wrap,
proto_spnego_krb5);
spnego_krb5_handle = find_dissector("spnego-krb5");
spnego_krb5_wrap_handle = find_dissector("spnego-krb5-wrap");
gssapi_init_oid("1.2.840.48018.1.2.2", proto_spnego_krb5, ett_spnego_krb5,
spnego_krb5_handle, spnego_krb5_wrap_handle,
"MS KRB5 - Microsoft Kerberos 5");
@ -1444,8 +1439,4 @@ void proto_reg_handoff_spnego(void) {
spnego_krb5_handle, spnego_krb5_wrap_handle,
"KRB5 - Kerberos 5 - User to User");
/*
* Find the data handle for some calls
*/
data_handle = find_dissector("data");
}

View File

@ -73,13 +73,6 @@ static guint global_t38_udp_port = PORT_T38;
static int t38_tap = -1;
/*
* Variables to allow for proper deletion of dissector registration when
* the user changes port from the gui.
*/
static guint tcp_port = 0;
static guint udp_port = 0;
/* dissect using the Pre Corrigendum T.38 ASN.1 specification (1998) */
static gboolean use_pre_corrigendum_asn1_specification = TRUE;
@ -745,7 +738,7 @@ proto_register_t38(void)
register_dissector("t38", dissect_t38, proto_t38);
/* Init reassemble tables for HDLC */
register_init_routine(t38_defragment_init);
register_init_routine(t38_defragment_init);
t38_tap = register_tap("t38");
@ -773,7 +766,8 @@ proto_register_t38(void)
"Reassemble T.38 PDUs over TPKT over TCP",
"Whether the dissector should reassemble T.38 PDUs spanning multiple TCP segments "
"when TPKT is used over TCP. "
"To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
"To use this option, you must also enable \"Allow subdissectors to reassemble "
"TCP streams\" in the TCP protocol settings.",
&t38_tpkt_reassembly);
prefs_register_enum_preference(t38_module, "tpkt_usage",
"TPKT used over TCP",
@ -791,12 +785,17 @@ proto_register_t38(void)
void
proto_reg_handoff_t38(void)
{
static int t38_prefs_initialized = FALSE;
static gboolean t38_prefs_initialized = FALSE;
static guint tcp_port;
static guint udp_port;
if (!t38_prefs_initialized) {
t38_udp_handle=create_dissector_handle(dissect_t38_udp, proto_t38);
t38_tcp_handle=create_dissector_handle(dissect_t38_tcp, proto_t38);
t38_tcp_pdu_handle=create_dissector_handle(dissect_t38_tcp_pdu, proto_t38);
rtp_handle = find_dissector("rtp");
t30_hdlc_handle = find_dissector("t30.hdlc");
data_handle = find_dissector("data");
t38_prefs_initialized = TRUE;
}
else {
@ -809,11 +808,5 @@ proto_reg_handoff_t38(void)
dissector_add("tcp.port", tcp_port, t38_tcp_handle);
dissector_add("udp.port", udp_port, t38_udp_handle);
rtp_handle = find_dissector("rtp");
t30_hdlc_handle = find_dissector("t30.hdlc");
data_handle = find_dissector("data");
}

View File

@ -56,8 +56,6 @@
#include "packet-x2ap-val.h"
static dissector_handle_t x2ap_handle = NULL;
/* Initialize the protocol and registered fields */
static int proto_x2ap = -1;
@ -157,7 +155,6 @@ void proto_register_x2ap(void) {
/* Register dissector */
register_dissector("x2ap", dissect_x2ap, proto_x2ap);
x2ap_handle = find_dissector("x2ap");
/* Register dissector tables */
x2ap_ies_dissector_table = register_dissector_table("x2ap.ies", "X2AP-PROTOCOL-IES", FT_UINT32, BASE_DEC);
@ -173,7 +170,9 @@ void proto_register_x2ap(void) {
void
proto_reg_handoff_x2ap(void)
{
dissector_handle_t x2ap_handle;
x2ap_handle = find_dissector("x2ap");
dissector_add("sctp.port", 0, x2ap_handle);
#include "packet-x2ap-dis-tab.c"