Call reassembly_table_destroy and move g_hash_table_destroy

This patch moves g_hash_table_destroy calls from the init routine to
the cleanup routine. Besides that, the conditional check for the hash
table has been removed, assuming that init is always paired with a
cleanup call.

If reassembly_table_init is found, a reassembly_table_destroy call is
prepended to the cleanup function as well.

Comments have been removed from the init function as well as these did
not seem to have additional value ("destroy hash table" is clear from
the context).

The changes were automatically generated using
https://git.lekensteyn.nl/peter/wireshark-notes/diff/one-off/cleanup-rewrite.py?id=4d11f07180d9c115eb14bd860e9a47d82d3d1dcd
Manually edited files (for assignment auditing): dvbci, ositp, sccp,
tcp.

Other files that needed special attention due to the use of
register_postseq_cleanup_routine:

 - ipx: keep call, do not add another cleanup routine.
 - ncp: remove empty mncp_postseq_cleanup. mncp_hash_lookup is used
   even if a frame is visited before (see dissect_ncp_common), hence
   the hash table cannot be destroyed here. Do it in cleanup instead.
 - ndps: add cleanup routine to kill reassembly table, but do not
   destroy the hash table as it is already done in ndps_postseq_cleanup.

Change-Id: I95a72b3df2978b2c13fefff6bd6821442193d0ed
Reviewed-on: https://code.wireshark.org/review/9223
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Peter Wu 2015-06-28 16:02:45 -07:00 committed by Michael Mann
parent 80f7ee063d
commit 126e02cd58
36 changed files with 257 additions and 199 deletions

View File

@ -5527,14 +5527,14 @@ dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
return tvb_captured_length(tvb);
}
static void afp_reinit( void)
static void afp_init(void)
{
if (afp_request_hash)
g_hash_table_destroy(afp_request_hash);
afp_request_hash = g_hash_table_new(afp_hash, afp_equal);
}
static void afp_cleanup(void)
{
g_hash_table_destroy(afp_request_hash);
}
void
@ -7263,7 +7263,8 @@ proto_register_afp(void)
expert_afp = expert_register_protocol(proto_afp);
expert_register_field_array(expert_afp, ei, array_length(ei));
register_init_routine(afp_reinit);
register_init_routine(afp_init);
register_cleanup_routine(afp_cleanup);
new_register_dissector("afp", dissect_afp, proto_afp);
new_register_dissector("afp_server_status", dissect_afp_server_status,

View File

@ -1415,17 +1415,18 @@ afs_hash (gconstpointer v)
static void
afs_init_protocol(void)
{
if (afs_request_hash)
g_hash_table_destroy(afs_request_hash);
afs_request_hash = g_hash_table_new(afs_hash, afs_equal);
/* fragment_table_init(&afs_fragment_table); */
/* reassembled_table_init(&afs_reassembled_table); */
reassembly_table_init(&afs_reassembly_table,
&addresses_reassembly_table_functions);
}
static void
afs_cleanup_protocol(void)
{
reassembly_table_destroy(&afs_reassembly_table);
g_hash_table_destroy(afs_request_hash);
}
/*
* Here is a helper routine for adding an AFS acl to the proto tree
* This is to be used with FS packets only
@ -3631,6 +3632,7 @@ proto_register_afs(void)
proto_register_field_array(proto_afs, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_init_routine(&afs_init_protocol);
register_cleanup_routine(&afs_cleanup_protocol);
new_register_dissector("afs", dissect_afs, proto_afs);
}

View File

@ -392,18 +392,15 @@ dissect_aoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
static void
ata_init(void)
{
if(ata_cmd_unmatched){
g_hash_table_destroy(ata_cmd_unmatched);
ata_cmd_unmatched=NULL;
}
ata_cmd_unmatched=g_hash_table_new(ata_cmd_hash_unmatched, ata_cmd_equal_unmatched);
if(ata_cmd_matched){
g_hash_table_destroy(ata_cmd_matched);
ata_cmd_matched=NULL;
}
ata_cmd_matched=g_hash_table_new(ata_cmd_hash_matched, ata_cmd_equal_matched);
}
static void
ata_cleanup(void)
{
g_hash_table_destroy(ata_cmd_unmatched);
g_hash_table_destroy(ata_cmd_matched);
}
void
@ -475,6 +472,7 @@ proto_register_aoe(void)
aoe_handle = register_dissector("aoe", dissect_aoe, proto_aoe);
register_init_routine(ata_init);
register_cleanup_routine(ata_cleanup);
}
void

View File

@ -744,21 +744,18 @@ check_for_duplicate_addresses(packet_info *pinfo, proto_tree *tree,
static void
arp_init_protocol(void)
{
/* Destroy any existing hashes. */
if (address_hash_table) {
g_hash_table_destroy(address_hash_table);
}
if (duplicate_result_hash_table) {
g_hash_table_destroy(duplicate_result_hash_table);
}
/* Now create it over */
address_hash_table = g_hash_table_new(address_hash_func, address_equal_func);
duplicate_result_hash_table = g_hash_table_new(duplicate_result_hash_func,
duplicate_result_equal_func);
}
static void
arp_cleanup_protocol(void)
{
g_hash_table_destroy(address_hash_table);
g_hash_table_destroy(duplicate_result_hash_table);
}
@ -2000,6 +1997,7 @@ proto_register_arp(void)
/* TODO: define a minimum time between sightings that is worth reporting? */
register_init_routine(&arp_init_protocol);
register_cleanup_routine(&arp_cleanup_protocol);
}
void

View File

@ -1618,15 +1618,16 @@ dissect_llap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
static void
atp_init(void)
{
/* fragment */
reassembly_table_init(&atp_reassembly_table,
&addresses_reassembly_table_functions);
/* bitmap */
if (atp_request_hash)
g_hash_table_destroy(atp_request_hash);
atp_request_hash = g_hash_table_new(asp_hash, asp_equal);
}
static void
atp_cleanup(void)
{
reassembly_table_destroy(&atp_reassembly_table);
g_hash_table_destroy(atp_request_hash);
}
static void
@ -2110,6 +2111,7 @@ proto_reg_handoff_atalk(void)
dissector_add_uint("wtap_encap", WTAP_ENCAP_LOCALTALK, llap_handle);
register_init_routine( atp_init);
register_cleanup_routine( atp_cleanup);
register_init_routine( &asp_reinit);
afp_handle = find_dissector("afp");

View File

@ -7845,15 +7845,15 @@ static const value_string sec_chan_type_vals[] = {
static void
netlogon_reassemble_init(void)
{
if (netlogon_auths){
g_hash_table_destroy (netlogon_auths);
}
netlogon_auths = g_hash_table_new (netlogon_auth_hash, netlogon_auth_equal);
if (schannel_auths){
g_hash_table_destroy (schannel_auths);
}
schannel_auths = g_hash_table_new (netlogon_auth_hash, netlogon_auth_equal);
}
static void
netlogon_reassemble_cleanup(void)
{
g_hash_table_destroy(netlogon_auths);
g_hash_table_destroy(schannel_auths);
}
void
@ -9265,6 +9265,7 @@ proto_register_dcerpc_netlogon(void)
array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_init_routine(netlogon_reassemble_init);
register_cleanup_routine(netlogon_reassemble_cleanup);
}

View File

@ -870,18 +870,14 @@ gboolean dcerpc_fetch_polhnd_data(e_ctx_hnd *policy_hnd,
static void init_pol_hash(void)
{
/* Initialise hash table */
if (pol_hash) {
/* Everything in the table is allocated with wmem file
* scope so there's no need to go through and free it all.
*/
g_hash_table_destroy(pol_hash);
}
pol_hash = g_hash_table_new(pol_hash_fn, pol_hash_compare);
}
static void cleanup_pol_hash(void)
{
g_hash_table_destroy(pol_hash);
}
/* Dissect a NT status code */
int
@ -2025,6 +2021,7 @@ void dcerpc_smb_init(int proto_dcerpc)
expert_dcerpc_nt = expert_register_protocol(proto_dcerpc);
expert_register_field_array(expert_dcerpc_nt, ei, array_length(ei));
register_init_routine(&init_pol_hash);
register_cleanup_routine(&cleanup_pol_hash);
}
/*

View File

@ -4087,17 +4087,16 @@ static int dissect_dmp (tvbuff_t *tvb, packet_info *pinfo,
static void dmp_init_routine (void)
{
if (dmp_id_hash_table) {
g_hash_table_destroy (dmp_id_hash_table);
}
if (dmp_long_id_hash_table) {
g_hash_table_destroy (dmp_long_id_hash_table);
}
dmp_id_hash_table = g_hash_table_new (dmp_id_hash, dmp_id_hash_equal);
dmp_long_id_hash_table = g_hash_table_new (g_str_hash, g_str_equal);
}
static void dmp_cleanup_routine (void)
{
g_hash_table_destroy(dmp_id_hash_table);
g_hash_table_destroy(dmp_long_id_hash_table);
}
void proto_register_dmp (void)
{
static hf_register_info hf[] = {
@ -4989,6 +4988,7 @@ void proto_register_dmp (void)
expert_dmp = expert_register_protocol(proto_dmp);
expert_register_field_array(expert_dmp, ei, array_length(ei));
register_init_routine (&dmp_init_routine);
register_cleanup_routine (&dmp_cleanup_routine);
/* Set default UDP ports */
range_convert_str (&global_dmp_port_range, DEFAULT_DMP_PORT_RANGE,

View File

@ -3521,16 +3521,18 @@ dissect_dnp3_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
static void
dnp3_init(void)
{
if (dl_conversation_table)
{
g_hash_table_destroy(dl_conversation_table);
}
dl_conversation_table = g_hash_table_new(dl_conversation_hash, dl_conversation_equal);
reassembly_table_init(&al_reassembly_table,
&addresses_reassembly_table_functions);
}
static void
dnp3_cleanup(void)
{
reassembly_table_destroy(&al_reassembly_table);
g_hash_table_destroy(dl_conversation_table);
}
/* Register the protocol with Wireshark */
void
@ -4526,6 +4528,7 @@ proto_register_dnp3(void)
/* Register protocol init routine */
register_init_routine(&dnp3_init);
register_cleanup_routine(&dnp3_cleanup);
/* Register the protocol name and description */
proto_dnp3 = proto_register_protocol("Distributed Network Protocol 3.0",

View File

@ -1700,13 +1700,19 @@ dvbci_init(void)
{
buf_size_cam = 0;
buf_size_host = 0;
reassembly_table_init(&tpdu_reassembly_table,
&addresses_reassembly_table_functions);
reassembly_table_init(&spdu_reassembly_table,
&addresses_reassembly_table_functions);
}
static void
dvbci_cleanup(void)
{
reassembly_table_destroy(&tpdu_reassembly_table);
reassembly_table_destroy(&spdu_reassembly_table);
}
/* dissect a delivery system descriptor loop
and the preceding length field
@ -6328,6 +6334,7 @@ proto_register_dvbci(void)
"SAS application id", FT_STRING, STR_ASCII);
register_init_routine(dvbci_init);
register_cleanup_routine(dvbci_cleanup);
/* the dissector for decrypted CI+ SAC messages which we can export */
new_register_dissector(EXPORTED_SAC_MSG_PROTO,

View File

@ -1753,15 +1753,17 @@ attribute_info_t enip_attribute_vals[45] = {
static void
enip_init_protocol(void)
{
if (enip_request_hashtable)
g_hash_table_destroy(enip_request_hashtable);
enip_request_hashtable = g_hash_table_new(enip_request_hash, enip_request_equal);
if (enip_conn_hashtable)
g_hash_table_destroy(enip_conn_hashtable);
enip_conn_hashtable = g_hash_table_new(enip_conn_hash, enip_conn_equal);
}
static void
enip_cleanup_protocol(void)
{
g_hash_table_destroy(enip_request_hashtable);
g_hash_table_destroy(enip_conn_hashtable);
}
/* Disssect Common Packet Format */
static void
dissect_cpf(enip_request_key_t *request_key, int command, tvbuff_t *tvb,
@ -3726,6 +3728,7 @@ proto_register_enip(void)
subdissector_io_table = register_dissector_table("enip.io", "ENIP IO dissector", FT_UINT32, BASE_DEC);
register_init_routine(&enip_init_protocol);
register_cleanup_routine(&enip_cleanup_protocol);
/* Register the protocol name and description */
proto_dlr = proto_register_protocol("Device Level Ring", "DLR", "dlr");

View File

@ -195,13 +195,16 @@ fc_exchange_init_protocol(void)
{
reassembly_table_init(&fc_reassembly_table,
&addresses_reassembly_table_functions);
if (fcseq_req_hash)
g_hash_table_destroy(fcseq_req_hash);
fcseq_req_hash = g_hash_table_new(fcseq_hash, fcseq_equal);
}
static void
fc_exchange_cleanup_protocol(void)
{
reassembly_table_destroy(&fc_reassembly_table);
g_hash_table_destroy(fcseq_req_hash);
}
static const char* fc_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter)
{
if ((filter == CONV_FT_SRC_ADDRESS) && (conv->src_address.type == AT_FC))
@ -1575,6 +1578,7 @@ proto_register_fc(void)
&fc_max_frame_size);
register_init_routine (fc_exchange_init_protocol);
register_cleanup_routine (fc_exchange_cleanup_protocol);
/* Register FC SOF/EOF */

View File

@ -383,12 +383,15 @@ fcdns_hash (gconstpointer v)
static void
fcdns_init_protocol(void)
{
if (fcdns_req_hash)
g_hash_table_destroy(fcdns_req_hash);
fcdns_req_hash = g_hash_table_new(fcdns_hash, fcdns_equal);
}
static void
fcdns_cleanup_protocol(void)
{
g_hash_table_destroy(fcdns_req_hash);
}
static void
dissect_cos_flags (proto_tree *parent_tree, tvbuff_t *tvb, int offset, const header_field_info *hfinfo)
@ -1854,6 +1857,7 @@ proto_register_fcdns (void)
expert_fcdns = expert_register_protocol(proto_fcdns);
expert_register_field_array(expert_fcdns, ei, array_length(ei));
register_init_routine (&fcdns_init_protocol);
register_cleanup_routine (&fcdns_cleanup_protocol);
dns_handle = new_create_dissector_handle (dissect_fcdns, proto_fcdns);
}

View File

@ -652,12 +652,15 @@ fcels_hash (gconstpointer v)
static void
fcels_init_protocol(void)
{
if (fcels_req_hash)
g_hash_table_destroy(fcels_req_hash);
fcels_req_hash = g_hash_table_new(fcels_hash, fcels_equal);
}
static void
fcels_cleanup_protocol(void)
{
g_hash_table_destroy(fcels_req_hash);
}
static const true_false_string tfs_fc_fcels_cmn_b2b = {
"Alt B2B Credit Mgmt",
"Normal B2B Credit Mgmt"
@ -2613,6 +2616,7 @@ proto_register_fcels (void)
expert_fcels = expert_register_protocol(proto_fcels);
expert_register_field_array(expert_fcels, ei, array_length(ei));
register_init_routine (&fcels_init_protocol);
register_cleanup_routine (&fcels_cleanup_protocol);
}
void

View File

@ -130,12 +130,15 @@ fcfcs_hash (gconstpointer v)
static void
fcfcs_init_protocol(void)
{
if (fcfcs_req_hash)
g_hash_table_destroy (fcfcs_req_hash);
fcfcs_req_hash = g_hash_table_new(fcfcs_hash, fcfcs_equal);
}
static void
fcfcs_cleanup_protocol(void)
{
g_hash_table_destroy(fcfcs_req_hash);
}
/* Code to actually dissect the packets */
static void
dissect_fcfcs_giel (tvbuff_t *tvb, proto_tree *tree, gboolean isreq)
@ -1042,6 +1045,7 @@ proto_register_fcfcs (void)
expert_register_field_array(expert_fcfcs, ei, array_length(ei));
register_init_routine (&fcfcs_init_protocol);
register_cleanup_routine (&fcfcs_cleanup_protocol);
}
void

View File

@ -114,12 +114,15 @@ fcfzs_hash(gconstpointer v)
static void
fcfzs_init_protocol(void)
{
if (fcfzs_req_hash)
g_hash_table_destroy(fcfzs_req_hash);
fcfzs_req_hash = g_hash_table_new(fcfzs_hash, fcfzs_equal);
}
static void
fcfzs_cleanup_protocol(void)
{
g_hash_table_destroy(fcfzs_req_hash);
}
/* Code to actually dissect the packets */
static void
dissect_fcfzs_zoneset(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset)
@ -867,6 +870,7 @@ proto_register_fcfzs(void)
expert_fcfzs = expert_register_protocol(proto_fcfzs);
expert_register_field_array(expert_fcfzs, ei, array_length(ei));
register_init_routine(&fcfzs_init_protocol);
register_cleanup_routine(&fcfzs_cleanup_protocol);
}

View File

@ -486,11 +486,13 @@ fcswils_hash(gconstpointer v)
static void
fcswils_init_protocol(void)
{
if (fcswils_req_hash)
g_hash_table_destroy(fcswils_req_hash);
fcswils_req_hash = g_hash_table_new(fcswils_hash, fcswils_equal);
}
static void
fcswils_cleanup_protocol(void)
{
g_hash_table_destroy(fcswils_req_hash);
}
static guint8 *
@ -2531,6 +2533,7 @@ proto_register_fcswils(void)
expert_fcswils = expert_register_protocol(proto_fcswils);
expert_register_field_array(expert_fcswils, ei, array_length(ei));
register_init_routine(&fcswils_init_protocol);
register_cleanup_routine(&fcswils_cleanup_protocol);
}
void

View File

@ -334,12 +334,16 @@ gsm_sms_defragment_init (void)
{
reassembly_table_init(&g_sm_reassembly_table,
&addresses_reassembly_table_functions);
if (g_sm_fragment_params_table) {
g_hash_table_destroy(g_sm_fragment_params_table);
}
g_sm_fragment_params_table = g_hash_table_new(g_direct_hash, g_direct_equal);
}
static void
gsm_sms_defragment_cleanup (void)
{
reassembly_table_destroy(&g_sm_reassembly_table);
g_hash_table_destroy(g_sm_fragment_params_table);
}
/*
* this is the GSM 03.40 definition with the bit 2
* set to 1 for uplink messages
@ -3285,6 +3289,7 @@ proto_register_gsm_sms(void)
/* GSM SMS UD dissector initialization routines */
register_init_routine (gsm_sms_defragment_init);
register_cleanup_routine (gsm_sms_defragment_cleanup);
}
/*

View File

@ -510,10 +510,8 @@ spx_hash_func(gconstpointer v)
static void
spx_init_protocol(void)
{
if (spx_hash)
g_hash_table_destroy(spx_hash);
/* no need for register_cleanup_routine that destroys spx_hash,
* spx_postseq_cleanup should clear this. */
spx_hash = g_hash_table_new(spx_hash_func, spx_equal);
}

View File

@ -838,11 +838,13 @@ static void find_iuup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
}
static void init_iuup(void) {
if (circuits)
g_hash_table_destroy(circuits);
circuits = g_hash_table_new(g_direct_hash,g_direct_equal);
}
static void cleanup_iuup(void) {
g_hash_table_destroy(circuits);
}
void proto_reg_handoff_iuup(void) {
static gboolean iuup_prefs_initialized = FALSE;
@ -1002,6 +1004,7 @@ void proto_register_iuup(void) {
register_dissector("find_iuup", find_iuup, proto_iuup);
register_init_routine(&init_iuup);
register_cleanup_routine(&cleanup_iuup);
iuup_module = prefs_register_protocol(proto_iuup, proto_reg_handoff_iuup);

View File

@ -670,15 +670,14 @@ static void mgcp_raw_text_add(tvbuff_t *tvb, proto_tree *tree)
/* Discard and init any state we've saved */
static void mgcp_init_protocol(void)
{
if (mgcp_calls != NULL)
{
g_hash_table_destroy(mgcp_calls);
mgcp_calls = NULL;
}
mgcp_calls = g_hash_table_new(mgcp_call_hash, mgcp_call_equal);
}
static void mgcp_cleanup_protocol(void)
{
g_hash_table_destroy(mgcp_calls);
}
/*
* is_mgcp_verb - A function for determining whether there is a
@ -2307,6 +2306,7 @@ void proto_register_mgcp(void)
proto_register_field_array(proto_mgcp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_init_routine(&mgcp_init_protocol);
register_cleanup_routine(&mgcp_cleanup_protocol);
new_register_dissector("mgcp", dissect_mgcp, proto_mgcp);

View File

@ -484,18 +484,13 @@ mncp_hash(gconstpointer v)
static void
mncp_init_protocol(void)
{
if (mncp_rhash)
g_hash_table_destroy(mncp_rhash);
mncp_rhash = g_hash_table_new(mncp_hash, mncp_equal);
}
/* After the sequential run, we don't need the ncp_request hash and keys
* anymore; the lookups have already been done and the vital info
* saved in the reply-packets' private_data in the frame_data struct. */
static void
mncp_postseq_cleanup(void)
mncp_cleanup_protocol(void)
{
g_hash_table_destroy(mncp_rhash);
}
static mncp_rhash_value*
@ -1381,9 +1376,9 @@ proto_register_ncp(void)
"Whether the NCP dissector should echo file open/close/oplock information to the expert table.",
&ncp_echo_file);
register_init_routine(&mncp_init_protocol);
register_cleanup_routine(&mncp_cleanup_protocol);
ncp_tap.stat=register_tap("ncp_srt");
ncp_tap.hdr=register_tap("ncp");
register_postseq_cleanup_routine(&mncp_postseq_cleanup);
register_conversation_table(proto_ncp, FALSE, ncp_conversation_packet, ncp_hostlist_packet);
register_srt_table(proto_ncp, "ncp_srt", 24, ncpstat_packet, ncpstat_init, NULL);

View File

@ -4079,16 +4079,18 @@ ndps_hash(gconstpointer v)
static void
ndps_init_protocol(void)
{
/* fragment */
reassembly_table_init(&ndps_reassembly_table,
&addresses_reassembly_table_functions);
if (ndps_req_hash)
g_hash_table_destroy(ndps_req_hash);
ndps_req_hash = g_hash_table_new(ndps_hash, ndps_equal);
}
static void
ndps_cleanup_protocol(void)
{
reassembly_table_destroy(&ndps_reassembly_table);
/* ndps_req_hash is already destroyed by ndps_postseq_cleanup */
}
/* After the sequential run, we don't need the ncp_request hash and keys
* anymore; the lookups have already been done and the vital info
* saved in the reply-packets' private_data in the frame_data struct. */
@ -4100,7 +4102,7 @@ ndps_postseq_cleanup(void)
g_hash_table_destroy(ndps_req_hash);
ndps_req_hash = NULL;
}
/* Don't free the ncp_req_hash_values, as they're
/* Don't free the ndps_req_hash_value values of ndps_req_hash, as they're
* needed during random-access processing of the proto_tree.*/
}
@ -9513,6 +9515,7 @@ proto_register_ndps(void)
&ndps_show_oids);
register_init_routine(&ndps_init_protocol);
register_cleanup_routine(&ndps_cleanup_protocol);
register_postseq_cleanup_routine(&ndps_postseq_cleanup);
}

View File

@ -7442,23 +7442,19 @@ getprefix(const guint32 *addr, int prefix)
static void
netflow_init(void)
{
/* keys & values are allocated using 'wmem_file_scope()' as thus freed as part of the init sequence */
if (v9_v10_tmplt_table != NULL) {
g_hash_table_destroy(v9_v10_tmplt_table);
}
v9_v10_tmplt_table = g_hash_table_new(v9_v10_tmplt_table_hash, v9_v10_tmplt_table_equal);
if (netflow_sequence_analysis_domain_hash != NULL) {
g_hash_table_destroy(netflow_sequence_analysis_domain_hash);
}
netflow_sequence_analysis_domain_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
if (netflow_sequence_analysis_result_hash != NULL) {
g_hash_table_destroy(netflow_sequence_analysis_result_hash);
}
netflow_sequence_analysis_result_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
}
static void
netflow_cleanup(void)
{
g_hash_table_destroy(v9_v10_tmplt_table);
g_hash_table_destroy(netflow_sequence_analysis_domain_hash);
g_hash_table_destroy(netflow_sequence_analysis_result_hash);
}
void
proto_register_netflow(void)
{
@ -11531,6 +11527,7 @@ proto_register_netflow(void)
10, &v9_tmplt_max_fields);
register_init_routine(&netflow_init);
register_cleanup_routine(&netflow_cleanup);
}

View File

@ -2231,6 +2231,12 @@ cotp_reassemble_init(void)
cotp_dst_ref = 0;
}
static void
cotp_reassemble_cleanup(void)
{
reassembly_table_destroy(&cotp_reassembly_table);
}
void proto_register_cotp(void)
{
static hf_register_info hf[] = {
@ -2428,6 +2434,7 @@ void proto_register_cotp(void)
new_register_dissector("ositp_inactive", dissect_ositp_inactive, proto_cotp);
register_init_routine(cotp_reassemble_init);
register_cleanup_routine(cotp_reassemble_cleanup);
}
void proto_register_cltp(void)

View File

@ -2227,25 +2227,6 @@ static void dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
* file is loaded or re-loaded in wireshark */
static void pdcp_lte_init_protocol(void)
{
/* Destroy any existing hashes. */
if (pdcp_sequence_analysis_channel_hash) {
g_hash_table_destroy(pdcp_sequence_analysis_channel_hash);
}
if (pdcp_lte_sequence_analysis_report_hash) {
g_hash_table_destroy(pdcp_lte_sequence_analysis_report_hash);
}
if (pdcp_security_hash) {
g_hash_table_destroy(pdcp_security_hash);
}
if (pdcp_security_result_hash) {
g_hash_table_destroy(pdcp_security_result_hash);
}
if (pdcp_security_key_hash) {
g_hash_table_destroy(pdcp_security_key_hash);
}
/* Now create them over */
pdcp_sequence_analysis_channel_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
pdcp_lte_sequence_analysis_report_hash = g_hash_table_new(pdcp_result_hash_func, pdcp_result_hash_equal);
pdcp_security_hash = g_hash_table_new(pdcp_lte_ueid_hash_func, pdcp_lte_ueid_hash_equal);
@ -2253,6 +2234,15 @@ static void pdcp_lte_init_protocol(void)
pdcp_security_key_hash = g_hash_table_new(pdcp_lte_ueid_hash_func, pdcp_lte_ueid_hash_equal);
}
static void pdcp_lte_cleanup_protocol(void)
{
g_hash_table_destroy(pdcp_sequence_analysis_channel_hash);
g_hash_table_destroy(pdcp_lte_sequence_analysis_report_hash);
g_hash_table_destroy(pdcp_security_hash);
g_hash_table_destroy(pdcp_security_result_hash);
g_hash_table_destroy(pdcp_security_key_hash);
}
void proto_register_pdcp(void)
@ -2703,6 +2693,7 @@ void proto_register_pdcp(void)
&global_pdcp_check_integrity);
register_init_routine(&pdcp_lte_init_protocol);
register_cleanup_routine(&pdcp_lte_cleanup_protocol);
}
void proto_reg_handoff_pdcp_lte(void)

View File

@ -2916,13 +2916,16 @@ pvfs2_io_tracking_hash(gconstpointer k)
static void
pvfs2_io_tracking_init(void)
{
if (pvfs2_io_tracking_value_table != NULL)
g_hash_table_destroy(pvfs2_io_tracking_value_table);
pvfs2_io_tracking_value_table = g_hash_table_new(pvfs2_io_tracking_hash,
pvfs2_io_tracking_equal);
}
static void
pvfs2_io_tracking_cleanup(void)
{
g_hash_table_destroy(pvfs2_io_tracking_value_table);
}
static pvfs2_io_tracking_value_t *
pvfs2_io_tracking_new_with_tag(guint64 tag, guint32 num)
{
@ -3611,6 +3614,7 @@ proto_register_pvfs(void)
expert_register_field_array(expert_pvfs, ei, array_length(ei));
register_init_routine(pvfs2_io_tracking_init);
register_cleanup_routine(pvfs2_io_tracking_cleanup);
pvfs_module = prefs_register_protocol(proto_pvfs, NULL);
prefs_register_bool_preference(pvfs_module, "desegment",

View File

@ -2066,15 +2066,15 @@ extern void radius_register_avp_dissector(guint32 vendor_id, guint32 attribute_i
static void
radius_init_protocol(void)
{
if (radius_calls != NULL)
{
g_hash_table_destroy(radius_calls);
radius_calls = NULL;
}
radius_calls = g_hash_table_new(radius_call_hash, radius_call_equal);
}
static void
radius_cleanup_protocol(void)
{
g_hash_table_destroy(radius_calls);
}
static void register_radius_fields(const char* unused _U_) {
hf_register_info base_hf[] = {
{ &hf_radius_req,
@ -2255,6 +2255,7 @@ proto_register_radius(void)
proto_radius = proto_register_protocol("Radius Protocol", "RADIUS", "radius");
new_register_dissector("radius", dissect_radius, proto_radius);
register_init_routine(&radius_init_protocol);
register_cleanup_routine(&radius_cleanup_protocol);
radius_module = prefs_register_protocol(proto_radius, proto_reg_handoff_radius);
prefs_register_string_preference(radius_module,"shared_secret","Shared Secret",
"Shared secret used to decode User Passwords",

View File

@ -2983,32 +2983,22 @@ static void dissect_rlc_lte_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree
* file is loaded or re-loaded in wireshark */
static void rlc_lte_init_protocol(void)
{
/* Destroy any existing hashes. */
if (sequence_analysis_channel_hash) {
g_hash_table_destroy(sequence_analysis_channel_hash);
}
if (sequence_analysis_report_hash) {
g_hash_table_destroy(sequence_analysis_report_hash);
}
if (repeated_nack_channel_hash) {
g_hash_table_destroy(repeated_nack_channel_hash);
}
if (repeated_nack_report_hash) {
g_hash_table_destroy(repeated_nack_report_hash);
}
if (reassembly_report_hash) {
g_hash_table_destroy(reassembly_report_hash);
}
/* Now create them over */
sequence_analysis_channel_hash = g_hash_table_new(rlc_channel_hash_func, rlc_channel_equal);
sequence_analysis_report_hash = g_hash_table_new(rlc_result_hash_func, rlc_result_hash_equal);
repeated_nack_channel_hash = g_hash_table_new(rlc_channel_hash_func, rlc_channel_equal);
repeated_nack_report_hash = g_hash_table_new(rlc_result_hash_func, rlc_result_hash_equal);
reassembly_report_hash = g_hash_table_new(rlc_result_hash_func, rlc_result_hash_equal);
}
static void rlc_lte_cleanup_protocol(void)
{
g_hash_table_destroy(sequence_analysis_channel_hash);
g_hash_table_destroy(sequence_analysis_report_hash);
g_hash_table_destroy(repeated_nack_channel_hash);
g_hash_table_destroy(repeated_nack_report_hash);
g_hash_table_destroy(reassembly_report_hash);
}
/* Configure number of PDCP SN bits to use for DRB channels */
void set_rlc_lte_drb_pdcp_seqnum_length(packet_info *pinfo, guint16 ueid, guint8 drbid,
guint8 userplane_seqnum_length)
@ -3610,6 +3600,7 @@ void proto_register_rlc_lte(void)
ue_parameters_tree = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
register_init_routine(&rlc_lte_init_protocol);
register_cleanup_routine(&rlc_lte_cleanup_protocol);
}
void proto_reg_handoff_rlc_lte(void)

View File

@ -2364,14 +2364,15 @@ static guint cid_hash_func(gconstpointer v)
static void
rohc_init_protocol(void)
{
/* Destroy any existing hashes. */
if (rohc_cid_hash)
g_hash_table_destroy(rohc_cid_hash);
/* Now create them again */
rohc_cid_hash = g_hash_table_new(cid_hash_func, cid_hash_equal);
}
static void
rohc_cleanup_protocol(void)
{
g_hash_table_destroy(rohc_cid_hash);
}
void
proto_register_rohc(void)
{
@ -2979,6 +2980,7 @@ proto_register_rohc(void)
rohc_handle = new_register_dissector("rohc", dissect_rohc, proto_rohc);
register_init_routine(&rohc_init_protocol);
register_cleanup_routine(&rohc_cleanup_protocol);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_rohc, hf, array_length(hf));

View File

@ -3797,18 +3797,19 @@ dissect_rpc_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
static void
rpc_init_protocol(void)
{
if (rpc_reassembly_table != NULL) {
g_hash_table_destroy(rpc_reassembly_table);
rpc_reassembly_table = NULL;
}
rpc_reassembly_table = g_hash_table_new(rpc_fragment_hash,
rpc_fragment_equal);
reassembly_table_init(&rpc_fragment_table,
&addresses_ports_reassembly_table_functions);
}
static void
rpc_cleanup_protocol(void)
{
reassembly_table_destroy(&rpc_fragment_table);
g_hash_table_destroy(rpc_reassembly_table);
}
/* will be called once from register.c at startup time */
void
proto_register_rpc(void)
@ -4083,6 +4084,7 @@ proto_register_rpc(void)
expert_rpc = expert_register_protocol(proto_rpc);
expert_register_field_array(expert_rpc, ei, array_length(ei));
register_init_routine(&rpc_init_protocol);
register_cleanup_routine(&rpc_cleanup_protocol);
rpc_module = prefs_register_protocol(proto_rpc, NULL);
prefs_register_bool_preference(rpc_module, "desegment_rpc_over_tcp",

View File

@ -1945,12 +1945,15 @@ rsvp_hash(gconstpointer k)
static void
rsvp_init_protocol(void)
{
if (rsvp_request_hash)
g_hash_table_destroy(rsvp_request_hash);
rsvp_request_hash = g_hash_table_new(rsvp_hash, rsvp_equal);
}
static void
rsvp_cleanup_protocol(void)
{
g_hash_table_destroy(rsvp_request_hash);
}
static const char* rsvp_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter _U_)
{
if ((filter == CONV_FT_SRC_ADDRESS) && (conv->src_address.type == AT_IPv4))
@ -9577,6 +9580,7 @@ proto_register_rsvp(void)
/* Initialization routine for RSVP conversations */
register_init_routine(&rsvp_init_protocol);
register_cleanup_routine(&rsvp_cleanup_protocol);
register_conversation_table(proto_rsvp, TRUE, rsvp_conversation_packet, rsvp_hostlist_packet);
}

View File

@ -593,12 +593,13 @@ static guint sbus_hash(gconstpointer v)
/*Protocol initialisation*/
static void sbus_init_protocol(void){
if (sbus_request_hash){
g_hash_table_destroy(sbus_request_hash);
}
sbus_request_hash = g_hash_table_new(sbus_hash, sbus_equal);
}
static void sbus_cleanup_protocol(void){
g_hash_table_destroy(sbus_request_hash);
}
/* check whether the packet looks like SBUS or not */
static gboolean
is_sbus_pdu(tvbuff_t *tvb)
@ -2321,6 +2322,7 @@ proto_register_sbus(void)
expert_sbus = expert_register_protocol(proto_sbus);
expert_register_field_array(expert_sbus, ei, array_length(ei));
register_init_routine(&sbus_init_protocol);
register_cleanup_routine(&sbus_cleanup_protocol);
}
void

View File

@ -3495,6 +3495,12 @@ init_sccp(void)
&addresses_reassembly_table_functions);
}
static void
cleanup_sccp(void)
{
reassembly_table_destroy(&sccp_xudt_msg_reassembly_table);
}
/* Register the protocol with Wireshark */
void
proto_register_sccp(void)
@ -4123,6 +4129,7 @@ proto_register_sccp(void)
&default_payload);
register_init_routine(&init_sccp);
register_cleanup_routine(&cleanup_sccp);
assocs = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());

View File

@ -5114,6 +5114,12 @@ tcp_init(void)
&addresses_ports_reassembly_table_functions);
}
static void
tcp_cleanup(void)
{
reassembly_table_destroy(&tcp_reassembly_table);
}
void
proto_register_tcp(void)
{
@ -6070,6 +6076,7 @@ proto_register_tcp(void)
&tcp_exp_options_with_magic);
register_init_routine(tcp_init);
register_cleanup_routine(tcp_cleanup);
register_decode_as(&tcp_da);

View File

@ -60,6 +60,7 @@ static guint dissect_zbee_nwk_link_status(tvbuff_t *tvb, proto_tree *tree,
static guint dissect_zbee_nwk_report (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
static guint dissect_zbee_nwk_update (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
static void proto_init_zbee_nwk (void);
static void proto_cleanup_zbee_nwk(void);
void proto_register_zbee_nwk(void);
void proto_reg_handoff_zbee_nwk(void);
@ -1942,6 +1943,7 @@ void proto_register_zbee_nwk(void)
expert_register_field_array(expert_zbee_nwk, ei, array_length(ei));
register_init_routine(proto_init_zbee_nwk);
register_cleanup_routine(proto_cleanup_zbee_nwk);
/* Register the protocol with Wireshark. */
proto_zbee_nwk = proto_register_protocol("ZigBee Network Layer", "ZigBee", ZBEE_PROTOABBREV_NWK);
@ -2011,17 +2013,19 @@ static void free_keyring_val(gpointer a)
static void
proto_init_zbee_nwk(void)
{
/* Destroy the hash tables, if they exist. */
if (zbee_nwk_map.short_table) g_hash_table_destroy(zbee_nwk_map.short_table);
if (zbee_nwk_map.long_table) g_hash_table_destroy(zbee_nwk_map.long_table);
if (zbee_table_nwk_keyring) g_hash_table_destroy(zbee_table_nwk_keyring);
/* (Re)create the hash tables. */
zbee_nwk_map.short_table = g_hash_table_new(ieee802154_short_addr_hash, ieee802154_short_addr_equal);
zbee_nwk_map.long_table = g_hash_table_new(ieee802154_long_addr_hash, ieee802154_long_addr_equal);
zbee_table_nwk_keyring = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, free_keyring_val);
} /* proto_init_zbee_nwk */
static void
proto_cleanup_zbee_nwk(void)
{
g_hash_table_destroy(zbee_nwk_map.short_table);
g_hash_table_destroy(zbee_nwk_map.long_table);
g_hash_table_destroy(zbee_table_nwk_keyring);
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*