Skip to content

Commit

Permalink
Minor cleanup mostly related to proto_reg_handoff
Browse files Browse the repository at this point in the history
 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
  • Loading branch information
Bill Meier committed Nov 4, 2008
1 parent a3d5cbf commit f35324d
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 103 deletions.
6 changes: 3 additions & 3 deletions asn1/h235/packet-h235-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand Down Expand Up @@ -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);
Expand All @@ -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");

Expand Down
7 changes: 4 additions & 3 deletions asn1/h245/packet-h245-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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);
}

Expand Down
12 changes: 5 additions & 7 deletions asn1/h283/packet-h283-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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");
Expand Down
5 changes: 2 additions & 3 deletions asn1/h323/packet-h323-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 */
Expand Down
5 changes: 0 additions & 5 deletions asn1/h450/packet-h450-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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++) {
Expand Down
27 changes: 12 additions & 15 deletions asn1/h501/packet-h501-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -149,12 +139,19 @@ void proto_register_h501(void) {
void proto_reg_handoff_h501(void)
{
static gboolean h501_prefs_initialized = FALSE;

if (h501_prefs_initialized) {
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) {
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 */
Expand Down
5 changes: 2 additions & 3 deletions asn1/mpeg-pes/packet-mpeg-pes-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
5 changes: 2 additions & 3 deletions asn1/nbap/packet-nbap-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down
5 changes: 0 additions & 5 deletions asn1/pres/packet-pres-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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");

}
7 changes: 1 addition & 6 deletions asn1/q932/packet-q932-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
}

/*---------------------------------------------------------------------------*/
8 changes: 2 additions & 6 deletions asn1/qsig/packet-qsig-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions asn1/rnsap/packet-rnsap-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions asn1/rrc/packet-rrc-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -154,7 +152,6 @@ void
proto_reg_handoff_rrc(void)
{

rrc_handle = find_dissector("rrc");
gsm_a_dtap_handle = find_dissector("gsm_a_dtap");

}
Expand Down
5 changes: 0 additions & 5 deletions asn1/rrlp/packet-rrlp-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -106,9 +104,6 @@ void
proto_reg_handoff_rrlp(void)
{

rrlp_handle = create_dissector_handle(dissect_PDU_PDU, proto_rrlp);


}


Loading

0 comments on commit f35324d

Please sign in to comment.