diff options
author | Michael Mann <mmann78@netscape.net> | 2017-02-01 23:13:42 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-02-02 13:46:03 +0000 |
commit | 577d21e35c1ca19e245014ea2b65d09709c9cca3 (patch) | |
tree | 91d63807f33f05a4970b9fe769dbec7040b904e0 /epan | |
parent | 36892d8a4ca2f6019dc00b0f2540097499da2e11 (diff) |
GHashtable -> wmem_map conversions
Many of the register_init_routine/register_cleanup_routine functions
are for initializing and cleaning up a GHashtable.
wmem_map_new_autoreset can do that automatically, so convert many
of the simple cases.
Change-Id: I93e1f435845fd5a5e5286487e9f0092fae052f3e
Reviewed-on: https://code.wireshark.org/review/19912
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan')
30 files changed, 289 insertions, 721 deletions
diff --git a/epan/dissectors/packet-aeron.c b/epan/dissectors/packet-aeron.c index ffb7417d90..ee77e10f3b 100644 --- a/epan/dissectors/packet-aeron.c +++ b/epan/dissectors/packet-aeron.c @@ -2861,11 +2861,6 @@ static gboolean test_aeron_packet(tvbuff_t * tvb, packet_info * pinfo, proto_tre return (TRUE); } -static void aeron_init(void) -{ - aeron_channel_id_init(); -} - /* Register all the bits needed with the filtering engine */ void proto_register_aeron(void) { @@ -3124,7 +3119,7 @@ void proto_register_aeron(void) "Use heuristic sub-dissectors", "Use a registered heuristic sub-dissector to decode the payload data. Requires \"Analyze transport sequencing\", \"Analyze stream sequencing\", and \"Reassemble fragmented data\".", &aeron_use_heuristic_subdissectors); - register_init_routine(aeron_init); + register_init_routine(aeron_channel_id_init); aeron_frame_info_tree = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); } diff --git a/epan/dissectors/packet-afp.c b/epan/dissectors/packet-afp.c index 062fe75edd..1c3a22fab9 100644 --- a/epan/dissectors/packet-afp.c +++ b/epan/dissectors/packet-afp.c @@ -1146,7 +1146,7 @@ typedef struct { guint16 seq; } afp_request_key; -static GHashTable *afp_request_hash = NULL; +static wmem_map_t *afp_request_hash = NULL; static guint Vol; /* volume */ static guint Did; /* parent directory ID */ @@ -5124,7 +5124,7 @@ dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) request_key.conversation = conversation->conv_index; request_key.seq = aspinfo->seq; - request_val = (afp_request_val *) g_hash_table_lookup( + request_val = (afp_request_val *) wmem_map_lookup( afp_request_hash, &request_key); if (!request_val && !aspinfo->reply) { @@ -5144,7 +5144,7 @@ dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) request_val->frame_res = 0; request_val->req_time=pinfo->abs_ts; - g_hash_table_insert(afp_request_hash, new_request_key, + wmem_map_insert(afp_request_hash, new_request_key, request_val); } @@ -5526,16 +5526,6 @@ dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) return tvb_captured_length(tvb); } -static void afp_init(void) -{ - afp_request_hash = g_hash_table_new(afp_hash, afp_equal); -} - -static void afp_cleanup(void) -{ - g_hash_table_destroy(afp_request_hash); -} - void proto_register_afp(void) { @@ -7262,8 +7252,7 @@ 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_init); - register_cleanup_routine(afp_cleanup); + afp_request_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), afp_hash, afp_equal); register_dissector("afp", dissect_afp, proto_afp); register_dissector("afp_server_status", dissect_afp_server_status, diff --git a/epan/dissectors/packet-afs.c b/epan/dissectors/packet-afs.c index 8044661c9c..32c6a8bb5c 100644 --- a/epan/dissectors/packet-afs.c +++ b/epan/dissectors/packet-afs.c @@ -1372,7 +1372,7 @@ struct afs_request_val { nstime_t req_time; }; -static GHashTable *afs_request_hash = NULL; +static wmem_map_t *afs_request_hash = NULL; /*static GHashTable *afs_fragment_table = NULL; */ /*static GHashTable *afs_reassembled_table = NULL; */ @@ -1410,21 +1410,6 @@ afs_hash (gconstpointer v) } /* - * Protocol initialization - */ -static void -afs_init_protocol(void) -{ - afs_request_hash = g_hash_table_new(afs_hash, afs_equal); -} - -static void -afs_cleanup_protocol(void) -{ - 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 * @@ -2769,7 +2754,7 @@ dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) request_key.cid = rxinfo->cid; request_key.callnumber = rxinfo->callnumber; - request_val = (struct afs_request_val *) g_hash_table_lookup( + request_val = (struct afs_request_val *) wmem_map_lookup( afs_request_hash, &request_key); /* only allocate a new hash element when it's a request */ @@ -2785,7 +2770,7 @@ dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) request_val -> rep_num = 0; request_val -> req_time = pinfo->abs_ts; - g_hash_table_insert(afs_request_hash, new_request_key, + wmem_map_insert(afs_request_hash, new_request_key, request_val); } if( request_val && reply ) { @@ -3633,8 +3618,7 @@ proto_register_afs(void) reassembly_table_register(&afs_reassembly_table, &addresses_reassembly_table_functions); - register_init_routine(&afs_init_protocol); - register_cleanup_routine(&afs_cleanup_protocol); + afs_request_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), afs_hash, afs_equal); register_dissector("afs", dissect_afs, proto_afs); } diff --git a/epan/dissectors/packet-aoe.c b/epan/dissectors/packet-aoe.c index a9d38cb75d..d3b6d92d68 100644 --- a/epan/dissectors/packet-aoe.c +++ b/epan/dissectors/packet-aoe.c @@ -175,8 +175,8 @@ typedef struct ata_info_t { nstime_t req_time; guint8 cmd; } ata_info_t; -static GHashTable *ata_cmd_unmatched = NULL; -static GHashTable *ata_cmd_matched = NULL; +static wmem_map_t *ata_cmd_unmatched = NULL; +static wmem_map_t *ata_cmd_matched = NULL; static guint ata_cmd_hash_matched(gconstpointer k) @@ -232,29 +232,29 @@ dissect_ata_pdu(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, ata_info->cmd=tvb_get_guint8(tvb, offset+3); ata_info->req_time=pinfo->abs_ts; - tmp_ata_info=(ata_info_t *)g_hash_table_lookup(ata_cmd_unmatched, ata_info); + tmp_ata_info=(ata_info_t *)wmem_map_lookup(ata_cmd_unmatched, ata_info); if(tmp_ata_info){ - g_hash_table_remove(ata_cmd_unmatched, tmp_ata_info); + wmem_map_remove(ata_cmd_unmatched, tmp_ata_info); } - g_hash_table_insert(ata_cmd_unmatched, ata_info, ata_info); + wmem_map_insert(ata_cmd_unmatched, ata_info, ata_info); } else { ata_info_t tmp_ata_info; /* first time we see this response so see if we can match it with a request */ tmp_ata_info.tag=tag; tmp_ata_info.conversation=conversation; - ata_info=(ata_info_t *)g_hash_table_lookup(ata_cmd_unmatched, &tmp_ata_info); + ata_info=(ata_info_t *)wmem_map_lookup(ata_cmd_unmatched, &tmp_ata_info); /* woo hoo we could, so no need to store this in unmatched any more, move both request and response to the matched table */ if(ata_info){ ata_info->response_frame=pinfo->num; - g_hash_table_remove(ata_cmd_unmatched, ata_info); - g_hash_table_insert(ata_cmd_matched, GUINT_TO_POINTER(ata_info->request_frame), ata_info); - g_hash_table_insert(ata_cmd_matched, GUINT_TO_POINTER(ata_info->response_frame), ata_info); + wmem_map_remove(ata_cmd_unmatched, ata_info); + wmem_map_insert(ata_cmd_matched, GUINT_TO_POINTER(ata_info->request_frame), ata_info); + wmem_map_insert(ata_cmd_matched, GUINT_TO_POINTER(ata_info->response_frame), ata_info); } } } else { - ata_info=(ata_info_t *)g_hash_table_lookup(ata_cmd_matched, GUINT_TO_POINTER(pinfo->num)); + ata_info=(ata_info_t *)wmem_map_lookup(ata_cmd_matched, GUINT_TO_POINTER(pinfo->num)); } if(ata_info){ @@ -394,20 +394,6 @@ dissect_aoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da return tvb_captured_length(tvb); } -static void -ata_init(void) -{ - ata_cmd_unmatched=g_hash_table_new(ata_cmd_hash_unmatched, ata_cmd_equal_unmatched); - 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 proto_register_aoe(void) { @@ -476,8 +462,8 @@ proto_register_aoe(void) aoe_handle = register_dissector("aoe", dissect_aoe, proto_aoe); - register_init_routine(ata_init); - register_cleanup_routine(ata_cleanup); + ata_cmd_unmatched=wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), ata_cmd_hash_unmatched, ata_cmd_equal_unmatched); + ata_cmd_matched=wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), ata_cmd_hash_matched, ata_cmd_equal_matched); } void diff --git a/epan/dissectors/packet-arp.c b/epan/dissectors/packet-arp.c index 789aee2a7d..1efa3df028 100644 --- a/epan/dissectors/packet-arp.c +++ b/epan/dissectors/packet-arp.c @@ -125,7 +125,7 @@ static nstime_t time_at_start_of_count; /* Map of (IP address -> MAC address) to detect duplicate IP addresses Key is unsigned32 */ -static GHashTable *address_hash_table = NULL; +static wmem_map_t *address_hash_table = NULL; typedef struct address_hash_value { guint8 mac[6]; @@ -134,7 +134,7 @@ typedef struct address_hash_value { } address_hash_value; /* Map of ((frame Num, IP address) -> MAC address) */ -static GHashTable *duplicate_result_hash_table = NULL; +static wmem_map_t *duplicate_result_hash_table = NULL; typedef struct duplicate_result_key { guint32 frame_number; @@ -653,7 +653,7 @@ check_for_duplicate_addresses(packet_info *pinfo, proto_tree *tree, /* Look up existing result */ if (pinfo->fd->flags.visited) { - result = (address_hash_value *)g_hash_table_lookup(duplicate_result_hash_table, + result = (address_hash_value *)wmem_map_lookup(duplicate_result_hash_table, &result_key); } else { @@ -661,7 +661,7 @@ check_for_duplicate_addresses(packet_info *pinfo, proto_tree *tree, store result */ /* Look up current assignment of IP address */ - value = (address_hash_value *)g_hash_table_lookup(address_hash_table, GUINT_TO_POINTER(ip)); + value = (address_hash_value *)wmem_map_lookup(address_hash_table, GUINT_TO_POINTER(ip)); /* If MAC matches table, just update details */ if (value != NULL) @@ -683,7 +683,7 @@ check_for_duplicate_addresses(packet_info *pinfo, proto_tree *tree, result = wmem_new(wmem_file_scope(), address_hash_value); memcpy(result, value, sizeof(address_hash_value)); - g_hash_table_insert(duplicate_result_hash_table, persistent_key, result); + wmem_map_insert(duplicate_result_hash_table, persistent_key, result); } } } @@ -696,7 +696,7 @@ check_for_duplicate_addresses(packet_info *pinfo, proto_tree *tree, value->time_of_entry = pinfo->abs_ts.secs; /* Add it */ - g_hash_table_insert(address_hash_table, GUINT_TO_POINTER(ip), value); + wmem_map_insert(address_hash_table, GUINT_TO_POINTER(ip), value); } } @@ -744,26 +744,6 @@ check_for_duplicate_addresses(packet_info *pinfo, proto_tree *tree, -/* Initializes the hash table each time a new - * file is loaded or re-loaded in wireshark */ -static void -arp_init_protocol(void) -{ - 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); -} - - - - /* Take note that a request has been seen */ static void request_seen(packet_info *pinfo) @@ -2023,8 +2003,9 @@ 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); + address_hash_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), address_hash_func, address_equal_func); + duplicate_result_hash_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), duplicate_result_hash_func, + duplicate_result_equal_func); arp_cap_handle = register_capture_dissector("arp", capture_arp, proto_arp); } diff --git a/epan/dissectors/packet-atalk.c b/epan/dissectors/packet-atalk.c index ac07e237f3..03278d0fd0 100644 --- a/epan/dissectors/packet-atalk.c +++ b/epan/dissectors/packet-atalk.c @@ -232,7 +232,7 @@ typedef struct { guint8 value; /* command for asp, bitmap for atp */ } asp_request_val; -static GHashTable *asp_request_hash = NULL; +static wmem_map_t *asp_request_hash = NULL; /* Hash Functions */ static gint asp_equal (gconstpointer v, gconstpointer v2) @@ -255,7 +255,7 @@ static guint asp_hash (gconstpointer v) } /* ------------------------------------ */ -static GHashTable *atp_request_hash = NULL; +static wmem_map_t *atp_request_hash = NULL; /* ------------------------------------ */ @@ -733,7 +733,7 @@ dissect_atp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) memcpy(request_key.src, (!aspinfo.reply)?pinfo->src.data:pinfo->dst.data, 4); request_key.seq = aspinfo.seq; - request_val = (asp_request_val *) g_hash_table_lookup(atp_request_hash, &request_key); + request_val = (asp_request_val *) wmem_map_lookup(atp_request_hash, &request_key); if (!request_val && query && nbe > 1) { asp_request_key *new_request_key; @@ -749,7 +749,7 @@ dissect_atp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) request_val = wmem_new(wmem_file_scope(), asp_request_val); request_val->value = nbe; - g_hash_table_insert(atp_request_hash, new_request_key,request_val); + wmem_map_insert(atp_request_hash, new_request_key,request_val); } } @@ -981,7 +981,7 @@ get_transaction(tvbuff_t *tvb, packet_info *pinfo, struct aspinfo *aspinfo) memcpy(request_key.src, (!aspinfo->reply)?pinfo->src.data:pinfo->dst.data, 4); request_key.seq = aspinfo->seq; - request_val = (asp_request_val *) g_hash_table_lookup(asp_request_hash, &request_key); + request_val = (asp_request_val *) wmem_map_lookup(asp_request_hash, &request_key); if (!request_val && !aspinfo->reply ) { fn = tvb_get_guint8(tvb, 0); new_request_key = wmem_new(wmem_file_scope(), asp_request_key); @@ -990,7 +990,7 @@ get_transaction(tvbuff_t *tvb, packet_info *pinfo, struct aspinfo *aspinfo) request_val = wmem_new(wmem_file_scope(), asp_request_val); request_val->value = fn; - g_hash_table_insert(asp_request_hash, new_request_key, request_val); + wmem_map_insert(asp_request_hash, new_request_key, request_val); } if (!request_val) @@ -1583,36 +1583,6 @@ dissect_llap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ return tvb_captured_length(tvb); } -static void -atp_init(void) -{ - atp_request_hash = g_hash_table_new(asp_hash, asp_equal); -} - -static void -atp_cleanup(void) -{ - g_hash_table_destroy(atp_request_hash); -} - -static void -asp_reinit( void) -{ - - if (asp_request_hash) - g_hash_table_destroy(asp_request_hash); - - asp_request_hash = g_hash_table_new(asp_hash, asp_equal); - -} - -static void -asp_shutdown(void) -{ - if (asp_request_hash) - g_hash_table_destroy(asp_request_hash); -} - void proto_register_atalk(void) { @@ -2042,8 +2012,6 @@ proto_register_atalk(void) FT_UINT8, BASE_HEX); atalk_address_type = address_type_dissector_register("AT_ATALK", "Appletalk DDP", atalk_to_str, atalk_str_len, NULL, atalk_col_filter_str, atalk_len, NULL, NULL); - - register_shutdown_routine(asp_shutdown); } void @@ -2091,9 +2059,8 @@ proto_reg_handoff_atalk(void) reassembly_table_register(&atp_reassembly_table, &addresses_reassembly_table_functions); - register_init_routine( atp_init); - register_cleanup_routine( atp_cleanup); - register_init_routine( &asp_reinit); + atp_request_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), asp_hash, asp_equal); + asp_request_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), asp_hash, asp_equal); afp_handle = find_dissector_add_dependency("afp", proto_asp); afp_server_status_handle = find_dissector_add_dependency("afp_server_status", proto_asp); diff --git a/epan/dissectors/packet-beep.c b/epan/dissectors/packet-beep.c index 51cff81c1f..9c870e1da2 100644 --- a/epan/dissectors/packet-beep.c +++ b/epan/dissectors/packet-beep.c @@ -158,7 +158,7 @@ struct beep_request_val { int c_mime_hdr, s_mime_hdr; }; -static GHashTable *beep_request_hash = NULL; +static wmem_map_t *beep_request_hash = NULL; /* Hash Functions */ static gint @@ -195,18 +195,6 @@ beep_hash(gconstpointer v) } -static void -beep_init_protocol(void) -{ - beep_request_hash = g_hash_table_new(beep_hash, beep_equal); -} - -static void -beep_cleanup_protocol(void) -{ - g_hash_table_destroy(beep_request_hash); -} - /* dissect the more flag, and return a value of: * 1 -> more @@ -777,7 +765,7 @@ dissect_beep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ */ request_key.conversation = conversation->conv_index; - request_val = (struct beep_request_val *)g_hash_table_lookup(beep_request_hash, &request_key); + request_val = (struct beep_request_val *)wmem_map_lookup(beep_request_hash, &request_key); if (!request_val) { /* Create one */ @@ -788,7 +776,7 @@ dissect_beep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ request_val->processed = 0; request_val->size = 0; - g_hash_table_insert(beep_request_hash, new_request_key, request_val); + wmem_map_insert(beep_request_hash, new_request_key, request_val); } } @@ -989,8 +977,8 @@ proto_register_beep(void) proto_register_subtree_array(ett, array_length(ett)); expert_beep = expert_register_protocol(proto_beep); expert_register_field_array(expert_beep, ei, array_length(ei)); - register_init_routine(&beep_init_protocol); - register_cleanup_routine(&beep_cleanup_protocol); + + beep_request_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), beep_hash, beep_equal); /* Register our configuration options for BEEP, particularly our port */ diff --git a/epan/dissectors/packet-dcerpc-netlogon.c b/epan/dissectors/packet-dcerpc-netlogon.c index aeae7a1c74..a4b1541867 100644 --- a/epan/dissectors/packet-dcerpc-netlogon.c +++ b/epan/dissectors/packet-dcerpc-netlogon.c @@ -101,8 +101,10 @@ static void printnbyte(const guint8* tab _U_,int nb _U_,const char* txt _U_,cons #define NETLOGON_FLAG_2 0x2 #define NETLOGON_FLAG_1 0x1 -static GHashTable *netlogon_auths=NULL; -static GHashTable *schannel_auths; +static wmem_map_t *netlogon_auths=NULL; +#if 0 +static wmem_map_t *schannel_auths; +#endif static gint hf_netlogon_TrustedDomainName_string = -1; static gint hf_netlogon_UserName_string = -1; static gint DomainInfo_sid = -1; @@ -2452,10 +2454,10 @@ netlogon_dissect_netrserverreqchallenge_rqst(tvbuff_t *tvb, int offset, key = wmem_new(wmem_file_scope(), netlogon_auth_key); generate_hash_key(pinfo,0,key,NULL); - existing_vars = (netlogon_auth_vars *)g_hash_table_lookup(netlogon_auths, key); + existing_vars = (netlogon_auth_vars *)wmem_map_lookup(netlogon_auths, key); if (!existing_vars) { debugprintf("Adding initial vars with this start packet = %d\n",vars->start); - g_hash_table_insert(netlogon_auths, key, vars); + wmem_map_insert(netlogon_auths, key, vars); } else { while(existing_vars->next != NULL && existing_vars->start < vars->start) { @@ -2476,10 +2478,10 @@ netlogon_dissect_netrserverreqchallenge_rqst(tvbuff_t *tvb, int offset, #if 0 generate_hash_key(pinfo,0,key,vars->client_name); existing_vars = NULL; - existing_vars = g_hash_table_lookup(schannel_auths, key); + existing_vars = wmem_map_lookup(schannel_auths, key); if (!existing_vars) { - g_hash_table_insert(schannel_auths, key, vars); + wmem_map_insert(schannel_auths, key, vars); } else { @@ -2506,7 +2508,7 @@ netlogon_dissect_netrserverreqchallenge_reply(tvbuff_t *tvb, int offset, guint64 server_challenge; generate_hash_key(pinfo,1,&key,NULL); - vars = (netlogon_auth_vars *)g_hash_table_lookup(netlogon_auths,(gconstpointer*) &key); + vars = (netlogon_auth_vars *)wmem_map_lookup(netlogon_auths,(gconstpointer*) &key); offset = dissect_dcerpc_8bytes(tvb, offset, pinfo, tree, drep, hf_server_challenge, &server_challenge); @@ -6636,7 +6638,7 @@ netlogon_dissect_netrserverauthenticate23_reply(tvbuff_t *tvb, int offset, generate_hash_key(pinfo, 1 , &key, NULL); - vars = (netlogon_auth_vars *)g_hash_table_lookup(netlogon_auths, &key); + vars = (netlogon_auth_vars *)wmem_map_lookup(netlogon_auths, &key); if(vars != NULL) { debugprintf("Found some vars (ie. server/client challenges), let's see if I can get a session key\n"); while(vars != NULL && vars->next_start != -1 && vars->next_start < (int) pinfo->num ) { @@ -7696,14 +7698,14 @@ dissect_packet_data(tvbuff_t *tvb ,tvbuff_t *auth_tvb _U_, /*debugprintf("Dissection of request data offset %d len=%d on packet %d\n",offset,tvb_length_remaining(tvb,offset),pinfo->num);*/ generate_hash_key(pinfo,is_server,&key,NULL); - vars = (netlogon_auth_vars *)g_hash_table_lookup(netlogon_auths, &key); + vars = (netlogon_auth_vars *)wmem_map_lookup(netlogon_auths, &key); if(vars != NULL ) { while(vars != NULL && vars->next_start != -1 && vars->next_start < (int) pinfo->num ) { vars = vars->next; } if(vars == NULL ) { - debugprintf("Vars not found %d (packet_data)\n",g_hash_table_size(netlogon_auths)); + debugprintf("Vars not found %d (packet_data)\n",wmem_map_size(netlogon_auths)); return(buf); } else { @@ -7729,7 +7731,7 @@ dissect_packet_data(tvbuff_t *tvb ,tvbuff_t *auth_tvb _U_, } } } else { - debugprintf("Vars not found %d (packet_data)\n",g_hash_table_size(netlogon_auths)); + debugprintf("Vars not found %d (packet_data)\n",wmem_map_size(netlogon_auths)); return(buf); } @@ -7762,7 +7764,7 @@ dissect_secchan_verf(tvbuff_t *tvb, int offset, packet_info *pinfo, int update_vars = 0; generate_hash_key(pinfo,is_server,&key,NULL); - vars = (netlogon_auth_vars *)g_hash_table_lookup(netlogon_auths,(gconstpointer*) &key); + vars = (netlogon_auth_vars *)wmem_map_lookup(netlogon_auths,(gconstpointer*) &key); if( ! (seen.isseen && seen.num == pinfo->num) ) { /* * Create a new tree, and split into x components ... @@ -7799,7 +7801,7 @@ dissect_secchan_verf(tvbuff_t *tvb, int offset, packet_info *pinfo, vars = vars->next; } if(vars == NULL ) { - debugprintf("Vars not found %d (packet_data)\n",g_hash_table_size(netlogon_auths)); + debugprintf("Vars not found %d (packet_data)\n",wmem_map_size(netlogon_auths)); return(offset); } else { @@ -7820,7 +7822,7 @@ dissect_secchan_verf(tvbuff_t *tvb, int offset, packet_info *pinfo, } else { - debugprintf("Vars not found (is null %d) %d (dissect_verf)\n",vars==NULL,g_hash_table_size(netlogon_auths)); + debugprintf("Vars not found (is null %d) %d (dissect_verf)\n",vars==NULL,wmem_map_size(netlogon_auths)); } /*debugprintf("Setting isseen to true, old packet %d new %d\n",seen.num,pinfo->num);*/ seen.isseen = TRUE; @@ -7849,19 +7851,6 @@ static const value_string sec_chan_type_vals[] = { { SEC_CHAN_BDC, "Backup domain controller" }, { 0, NULL } }; -static void -netlogon_reassemble_init(void) -{ - netlogon_auths = g_hash_table_new (netlogon_auth_hash, netlogon_auth_equal); - 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 proto_register_dcerpc_netlogon(void) @@ -9265,15 +9254,15 @@ proto_register_dcerpc_netlogon(void) &ett_user_account_control }; - proto_dcerpc_netlogon = proto_register_protocol( - "Microsoft Network Logon", "RPC_NETLOGON", "rpc_netlogon"); + proto_dcerpc_netlogon = proto_register_protocol("Microsoft Network Logon", "RPC_NETLOGON", "rpc_netlogon"); - proto_register_field_array(proto_dcerpc_netlogon, hf, - array_length(hf)); + proto_register_field_array(proto_dcerpc_netlogon, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - register_init_routine(netlogon_reassemble_init); - register_cleanup_routine(netlogon_reassemble_cleanup); + netlogon_auths = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), netlogon_auth_hash, netlogon_auth_equal); +#if 0 + schannel_auths = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), netlogon_auth_hash, netlogon_auth_equal); +#endif } static dcerpc_auth_subdissector_fns secchan_auth_fns = { diff --git a/epan/dissectors/packet-dcerpc-nt.c b/epan/dissectors/packet-dcerpc-nt.c index d1a060b0a8..6726204b9a 100644 --- a/epan/dissectors/packet-dcerpc-nt.c +++ b/epan/dissectors/packet-dcerpc-nt.c @@ -526,7 +526,7 @@ typedef struct { pol_value *list; /* List of policy handle entries */ } pol_hash_value; -static GHashTable *pol_hash = NULL; +static wmem_map_t *pol_hash = NULL; /* Hash function */ @@ -572,7 +572,7 @@ static pol_value *find_pol_handle(e_ctx_hnd *policy_hnd, guint32 frame, pol_value *pol; memcpy(&key.policy_hnd, policy_hnd, sizeof(key.policy_hnd)); - if ((*valuep = (pol_hash_value *)g_hash_table_lookup(pol_hash, &key))) { + if ((*valuep = (pol_hash_value *)wmem_map_lookup(pol_hash, &key))) { /* * Look for the first value such that both: * @@ -625,7 +625,7 @@ static void add_pol_handle(e_ctx_hnd *policy_hnd, guint32 frame, pol->next = NULL; key = (pol_hash_key *)wmem_alloc(wmem_file_scope(), sizeof(pol_hash_key)); memcpy(&key->policy_hnd, policy_hnd, sizeof(key->policy_hnd)); - g_hash_table_insert(pol_hash, key, value); + wmem_map_insert(pol_hash, key, value); } else { /* * Put the new value in the hash value's policy handle @@ -867,18 +867,6 @@ gboolean dcerpc_fetch_polhnd_data(e_ctx_hnd *policy_hnd, return pol != NULL; } -/* Initialise policy handle hash */ - -static void init_pol_hash(void) -{ - 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 @@ -2021,8 +2009,8 @@ void dcerpc_smb_init(int proto_dcerpc) /* Initialise policy handle hash */ 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); + + pol_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pol_hash_fn, pol_hash_compare); } /* diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c index bec5616ec0..cd6060d82c 100644 --- a/epan/dissectors/packet-dcerpc.c +++ b/epan/dissectors/packet-dcerpc.c @@ -692,7 +692,7 @@ static GSList *decode_dcerpc_bindings = NULL; * Note that we always specify a SMB FID. For non-SMB transports this * value is 0. */ -static GHashTable *dcerpc_binds = NULL; +static wmem_map_t *dcerpc_binds = NULL; typedef struct _dcerpc_bind_key { conversation_t *conv; @@ -780,7 +780,7 @@ dcerpc_add_conv_to_bind_table(decode_dcerpc_bind_values_t *binding) key->transport_salt = binding->transport_salt; /* add this entry to the bind table */ - g_hash_table_insert(dcerpc_binds, key, bind_value); + wmem_map_insert(dcerpc_binds, key, bind_value); return bind_value; @@ -1800,8 +1800,8 @@ dcerpc_bind_hash(gconstpointer k) * To keep track of callid mappings. Should really use some generic * conversation support instead. */ -static GHashTable *dcerpc_cn_calls = NULL; -static GHashTable *dcerpc_dg_calls = NULL; +static wmem_map_t *dcerpc_cn_calls = NULL; +static wmem_map_t *dcerpc_dg_calls = NULL; typedef struct _dcerpc_cn_call_key { conversation_t *conv; @@ -1870,7 +1870,7 @@ dcerpc_dg_call_hash(gconstpointer k) XXX - why not just use the same keys as are used for calls? */ -static GHashTable *dcerpc_matched = NULL; +static wmem_map_t *dcerpc_matched = NULL; typedef struct _dcerpc_matched_key { guint32 frame; @@ -3992,7 +3992,7 @@ dissect_dcerpc_cn_bind(tvbuff_t *tvb, gint offset, packet_info *pinfo, value->transport = trans_id; /* add this entry to the bind table */ - g_hash_table_insert(dcerpc_binds, key, value); + wmem_map_insert(dcerpc_binds, key, value); } if (i > 0) @@ -4441,7 +4441,7 @@ dissect_dcerpc_cn_rqst(tvbuff_t *tvb, gint offset, packet_info *pinfo, */ matched_key.frame = pinfo->num; matched_key.call_id = hdr->call_id; - value = (dcerpc_call_value *)g_hash_table_lookup(dcerpc_matched, &matched_key); + value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_matched, &matched_key); if (!value) { dcerpc_bind_key bind_key; dcerpc_bind_value *bind_value; @@ -4450,7 +4450,7 @@ dissect_dcerpc_cn_rqst(tvbuff_t *tvb, gint offset, packet_info *pinfo, bind_key.ctx_id = ctx_id; bind_key.transport_salt = dcerpc_get_transport_salt(pinfo); - if ((bind_value = (dcerpc_bind_value *)g_hash_table_lookup(dcerpc_binds, &bind_key)) ) { + if ((bind_value = (dcerpc_bind_value *)wmem_map_lookup(dcerpc_binds, &bind_key)) ) { if (!(hdr->flags&PFC_FIRST_FRAG)) { dcerpc_cn_call_key call_key; dcerpc_call_value *call_value; @@ -4458,10 +4458,10 @@ dissect_dcerpc_cn_rqst(tvbuff_t *tvb, gint offset, packet_info *pinfo, call_key.conv = conv; call_key.call_id = hdr->call_id; call_key.transport_salt = dcerpc_get_transport_salt(pinfo); - if ((call_value = (dcerpc_call_value *)g_hash_table_lookup(dcerpc_cn_calls, &call_key))) { + if ((call_value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_cn_calls, &call_key))) { new_matched_key = (dcerpc_matched_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_matched_key)); *new_matched_key = matched_key; - g_hash_table_insert(dcerpc_matched, new_matched_key, call_value); + wmem_map_insert(dcerpc_matched, new_matched_key, call_value); value = call_value; } } else { @@ -4480,8 +4480,8 @@ dissect_dcerpc_cn_rqst(tvbuff_t *tvb, gint offset, packet_info *pinfo, /* if there is already a matching call in the table remove it so it is replaced with the new one */ - if (g_hash_table_lookup(dcerpc_cn_calls, call_key)) { - g_hash_table_remove(dcerpc_cn_calls, call_key); + if (wmem_map_lookup(dcerpc_cn_calls, call_key)) { + wmem_map_remove(dcerpc_cn_calls, call_key); } call_value = (dcerpc_call_value *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_call_value)); @@ -4501,11 +4501,11 @@ dissect_dcerpc_cn_rqst(tvbuff_t *tvb, gint offset, packet_info *pinfo, call_value->flags |= DCERPC_IS_NDR64; } - g_hash_table_insert(dcerpc_cn_calls, call_key, call_value); + wmem_map_insert(dcerpc_cn_calls, call_key, call_value); new_matched_key = (dcerpc_matched_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_matched_key)); *new_matched_key = matched_key; - g_hash_table_insert(dcerpc_matched, new_matched_key, call_value); + wmem_map_insert(dcerpc_matched, new_matched_key, call_value); value = call_value; } } @@ -4601,7 +4601,7 @@ dissect_dcerpc_cn_resp(tvbuff_t *tvb, gint offset, packet_info *pinfo, */ matched_key.frame = pinfo->num; matched_key.call_id = hdr->call_id; - value = (dcerpc_call_value *)g_hash_table_lookup(dcerpc_matched, &matched_key); + value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_matched, &matched_key); if (!value) { dcerpc_cn_call_key call_key; dcerpc_call_value *call_value; @@ -4610,13 +4610,13 @@ dissect_dcerpc_cn_resp(tvbuff_t *tvb, gint offset, packet_info *pinfo, call_key.call_id = hdr->call_id; call_key.transport_salt = dcerpc_get_transport_salt(pinfo); - if ((call_value = (dcerpc_call_value *)g_hash_table_lookup(dcerpc_cn_calls, &call_key))) { + if ((call_value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_cn_calls, &call_key))) { /* extra sanity check, only match them if the reply came after the request */ if (call_value->req_frame<pinfo->num) { new_matched_key = (dcerpc_matched_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_matched_key)); *new_matched_key = matched_key; - g_hash_table_insert(dcerpc_matched, new_matched_key, call_value); + wmem_map_insert(dcerpc_matched, new_matched_key, call_value); value = call_value; if (call_value->rep_frame == 0) { call_value->rep_frame = pinfo->num; @@ -4743,7 +4743,7 @@ dissect_dcerpc_cn_fault(tvbuff_t *tvb, gint offset, packet_info *pinfo, */ matched_key.frame = pinfo->num; matched_key.call_id = hdr->call_id; - value = (dcerpc_call_value *)g_hash_table_lookup(dcerpc_matched, &matched_key); + value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_matched, &matched_key); if (!value) { dcerpc_cn_call_key call_key; dcerpc_call_value *call_value; @@ -4752,10 +4752,10 @@ dissect_dcerpc_cn_fault(tvbuff_t *tvb, gint offset, packet_info *pinfo, call_key.call_id = hdr->call_id; call_key.transport_salt = dcerpc_get_transport_salt(pinfo); - if ((call_value = (dcerpc_call_value *)g_hash_table_lookup(dcerpc_cn_calls, &call_key))) { + if ((call_value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_cn_calls, &call_key))) { new_matched_key = (dcerpc_matched_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_matched_key)); *new_matched_key = matched_key; - g_hash_table_insert(dcerpc_matched, new_matched_key, call_value); + wmem_map_insert(dcerpc_matched, new_matched_key, call_value); value = call_value; if (call_value->rep_frame == 0) { @@ -5988,17 +5988,17 @@ dissect_dcerpc_dg_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, /* NDR64 is not available on dg transports ?*/ call_value->flags = 0; - g_hash_table_insert(dcerpc_dg_calls, call_key, call_value); + wmem_map_insert(dcerpc_dg_calls, call_key, call_value); new_matched_key = (dcerpc_matched_key *)wmem_alloc(wmem_file_scope(), sizeof(dcerpc_matched_key)); new_matched_key->frame = pinfo->num; new_matched_key->call_id = hdr->seqnum; - g_hash_table_insert(dcerpc_matched, new_matched_key, call_value); + wmem_map_insert(dcerpc_matched, new_matched_key, call_value); } matched_key.frame = pinfo->num; matched_key.call_id = hdr->seqnum; - value = (dcerpc_call_value *)g_hash_table_lookup(dcerpc_matched, &matched_key); + value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_matched, &matched_key); if (!value) { value = wmem_new(wmem_packet_scope(), dcerpc_call_value); value->uuid = hdr->if_id; @@ -6051,11 +6051,11 @@ dissect_dcerpc_dg_resp(tvbuff_t *tvb, int offset, packet_info *pinfo, call_key.seqnum = hdr->seqnum; call_key.act_id = hdr->act_id; - if ((call_value = (dcerpc_call_value *)g_hash_table_lookup(dcerpc_dg_calls, &call_key))) { + if ((call_value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_dg_calls, &call_key))) { new_matched_key = (dcerpc_matched_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_matched_key)); new_matched_key->frame = pinfo->num; new_matched_key->call_id = hdr->seqnum; - g_hash_table_insert(dcerpc_matched, new_matched_key, call_value); + wmem_map_insert(dcerpc_matched, new_matched_key, call_value); if (call_value->rep_frame == 0) { call_value->rep_frame = pinfo->num; } @@ -6064,7 +6064,7 @@ dissect_dcerpc_dg_resp(tvbuff_t *tvb, int offset, packet_info *pinfo, matched_key.frame = pinfo->num; matched_key.call_id = hdr->seqnum; - value = (dcerpc_call_value *)g_hash_table_lookup(dcerpc_matched, &matched_key); + value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_matched, &matched_key); if (!value) { value = wmem_new0(wmem_packet_scope(), dcerpc_call_value); value->uuid = hdr->if_id; @@ -6113,7 +6113,7 @@ dissect_dcerpc_dg_ping_ack(tvbuff_t *tvb, int offset, packet_info *pinfo, call_key.seqnum = hdr->seqnum; call_key.act_id = hdr->act_id; - if ((call_value = (dcerpc_call_value *)g_hash_table_lookup(dcerpc_dg_calls, &call_key))) { + if ((call_value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_dg_calls, &call_key))) { proto_item *pi; nstime_t delta_ts; @@ -6451,30 +6451,6 @@ dissect_dcerpc_dg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat } static void -dcerpc_init_protocol(void) -{ - /* structures and data for BIND */ - dcerpc_binds = g_hash_table_new(dcerpc_bind_hash, dcerpc_bind_equal); - - /* structures and data for CALL */ - dcerpc_cn_calls = g_hash_table_new(dcerpc_cn_call_hash, dcerpc_cn_call_equal); - dcerpc_dg_calls = g_hash_table_new(dcerpc_dg_call_hash, dcerpc_dg_call_equal); - - /* structure and data for MATCHED */ - dcerpc_matched = g_hash_table_new(dcerpc_matched_hash, dcerpc_matched_equal); - decode_dcerpc_inject_bindings(); -} - -static void -dcerpc_cleanup_protocol(void) -{ - g_hash_table_destroy(dcerpc_binds); - g_hash_table_destroy(dcerpc_cn_calls); - g_hash_table_destroy(dcerpc_dg_calls); - g_hash_table_destroy(dcerpc_matched); -} - -static void dcerpc_auth_subdissector_list_free(gpointer p, gpointer user_data _U_) { g_free(p); @@ -6938,8 +6914,18 @@ proto_register_dcerpc(void) uuid_dissector_table = register_dissector_table("dcerpc.uuid", "DCE/RPC UUIDs", proto_dcerpc, FT_GUID, BASE_HEX); - register_init_routine(dcerpc_init_protocol); - register_cleanup_routine(dcerpc_cleanup_protocol); + /* structures and data for BIND */ + dcerpc_binds = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), dcerpc_bind_hash, dcerpc_bind_equal); + + /* structures and data for CALL */ + dcerpc_cn_calls = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), dcerpc_cn_call_hash, dcerpc_cn_call_equal); + dcerpc_dg_calls = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), dcerpc_dg_call_hash, dcerpc_dg_call_equal); + + /* structure and data for MATCHED */ + dcerpc_matched = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), dcerpc_matched_hash, dcerpc_matched_equal); + + register_init_routine(decode_dcerpc_inject_bindings); + dcerpc_module = prefs_register_protocol(proto_dcerpc, NULL); prefs_register_bool_preference(dcerpc_module, "desegment_dcerpc", diff --git a/epan/dissectors/packet-dmp.c b/epan/dissectors/packet-dmp.c index 035e43afd7..7644726b05 100644 --- a/epan/dissectors/packet-dmp.c +++ b/epan/dissectors/packet-dmp.c @@ -502,8 +502,8 @@ typedef struct _dmp_id_val { guint32 ack_resend_count; /* Acknowledgement resend counter */ } dmp_id_val; -static GHashTable *dmp_id_hash_table = NULL; -static GHashTable *dmp_long_id_hash_table = NULL; +static wmem_map_t *dmp_id_hash_table = NULL; +static wmem_map_t *dmp_long_id_hash_table = NULL; /* Global values used in several functions */ static struct dmp_data { @@ -1377,7 +1377,7 @@ static void register_dmp_id (packet_info *pinfo, guint8 reason) copy_address_wmem(wmem_file_scope(), &dmp_key->src, &(pinfo->dst)); copy_address_wmem(wmem_file_scope(), &dmp_key->dst, &(pinfo->src)); - dmp_data = (dmp_id_val *) g_hash_table_lookup (dmp_id_hash_table, dmp_key); + dmp_data = (dmp_id_val *) wmem_map_lookup (dmp_id_hash_table, dmp_key); if (dmp_data) { /* Found message */ @@ -1400,7 +1400,7 @@ static void register_dmp_id (packet_info *pinfo, guint8 reason) copy_address_wmem(wmem_file_scope(), &dmp_key->dst, &(pinfo->dst)); } - dmp_data = (dmp_id_val *) g_hash_table_lookup (dmp_id_hash_table, dmp_key); + dmp_data = (dmp_id_val *) wmem_map_lookup (dmp_id_hash_table, dmp_key); if (!pinfo->fd->flags.visited) { if (dmp_data) { @@ -1446,7 +1446,7 @@ static void register_dmp_id (packet_info *pinfo, guint8 reason) dmp_data->msg_id = pinfo->num; } - g_hash_table_insert (dmp_id_hash_table, dmp_key, dmp_data); + wmem_map_insert (dmp_id_hash_table, dmp_key, dmp_data); } } @@ -2671,12 +2671,12 @@ static gint dissect_mts_identifier (tvbuff_t *tvb, packet_info *pinfo, proto_tre ti = proto_tree_add_string (tree, hf_message_subj_mts_id, tvb, offset, dmp.mts_id_length, mts_id); hidden_item = proto_tree_add_string (tree, hf_mts_id, tvb, offset, dmp.mts_id_length, mts_id); /* Read from hash, for analysis */ - dmp.subj_id = GPOINTER_TO_UINT (g_hash_table_lookup (dmp_long_id_hash_table, mts_id)); + dmp.subj_id = GPOINTER_TO_UINT (wmem_map_lookup (dmp_long_id_hash_table, mts_id)); } else { ti = proto_tree_add_string (tree, hf_envelope_mts_id, tvb, offset, dmp.mts_id_length, mts_id); hidden_item = proto_tree_add_string (tree, hf_mts_id, tvb, offset, dmp.mts_id_length, mts_id); /* Insert into hash, for analysis */ - g_hash_table_insert (dmp_long_id_hash_table, g_strdup (mts_id), GUINT_TO_POINTER ((guint)dmp.msg_id)); + wmem_map_insert (dmp_long_id_hash_table, g_strdup (mts_id), GUINT_TO_POINTER ((guint)dmp.msg_id)); } PROTO_ITEM_SET_HIDDEN (hidden_item); offset += dmp.mts_id_length; @@ -2727,12 +2727,12 @@ static gint dissect_ipm_identifier (tvbuff_t *tvb, packet_info *pinfo, proto_tre ti = proto_tree_add_string (tree, hf_message_subj_ipm_id, tvb, offset, ipm_id_length, ipm_id); hidden_item = proto_tree_add_string (tree, hf_ipm_id, tvb, offset, ipm_id_length, ipm_id); /* Read from hash, for analysis */ - dmp.subj_id = GPOINTER_TO_UINT (g_hash_table_lookup (dmp_long_id_hash_table, ipm_id)); + dmp.subj_id = GPOINTER_TO_UINT (wmem_map_lookup (dmp_long_id_hash_table, ipm_id)); } else { ti = proto_tree_add_string (tree, hf_envelope_ipm_id, tvb, offset, ipm_id_length, ipm_id); hidden_item = proto_tree_add_string (tree, hf_ipm_id, tvb, offset, ipm_id_length, ipm_id); /* Insert into hash, for analysis */ - g_hash_table_insert (dmp_long_id_hash_table, g_strdup (ipm_id), GUINT_TO_POINTER ((guint)dmp.msg_id)); + wmem_map_insert (dmp_long_id_hash_table, g_strdup (ipm_id), GUINT_TO_POINTER ((guint)dmp.msg_id)); } PROTO_ITEM_SET_HIDDEN (hidden_item); offset += ipm_id_length; @@ -3995,18 +3995,6 @@ static int dissect_dmp (tvbuff_t *tvb, packet_info *pinfo, return offset; } -static void dmp_init_routine (void) -{ - 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[] = { @@ -4919,8 +4907,9 @@ void proto_register_dmp (void) proto_register_subtree_array (ett, array_length (ett)); 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); + + dmp_id_hash_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), dmp_id_hash, dmp_id_hash_equal); + dmp_long_id_hash_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), wmem_str_hash, g_str_equal); /* Build national values */ build_national_strings (); diff --git a/epan/dissectors/packet-dnp.c b/epan/dissectors/packet-dnp.c index 48df1f3f40..1705caa9e7 100644 --- a/epan/dissectors/packet-dnp.c +++ b/epan/dissectors/packet-dnp.c @@ -1301,7 +1301,7 @@ static expert_field ei_dnp3_buffering_user_data_until_final_frame_is_received = /* Tables for reassembly of fragments. */ static reassembly_table al_reassembly_table; -static GHashTable *dl_conversation_table = NULL; +static wmem_map_t *dl_conversation_table = NULL; /* Data-Link-Layer Conversation Key Structure */ typedef struct _dl_conversation_key @@ -3326,7 +3326,7 @@ dissect_dnp3_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dl_conversation_key.src = dl_src; dl_conversation_key.dst = dl_dst; - conv_data_ptr = (dnp3_conv_t*)g_hash_table_lookup(dl_conversation_table, &dl_conversation_key); + conv_data_ptr = (dnp3_conv_t*)wmem_map_lookup(dl_conversation_table, &dl_conversation_key); if (!pinfo->fd->flags.visited && conv_data_ptr == NULL) { @@ -3339,7 +3339,7 @@ dissect_dnp3_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* /*** Increment static global fragment reassembly id ***/ conv_data_ptr->conv_seq_number = seq_number++; - g_hash_table_insert(dl_conversation_table, new_dl_conversation_key, conv_data_ptr); + wmem_map_insert(dl_conversation_table, new_dl_conversation_key, conv_data_ptr); } conv_seq_number = conv_data_ptr->conv_seq_number; @@ -3518,18 +3518,6 @@ dissect_dnp3_udp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void } -static void -dnp3_init(void) -{ - dl_conversation_table = g_hash_table_new(dl_conversation_hash, dl_conversation_equal); -} - -static void -dnp3_cleanup(void) -{ - g_hash_table_destroy(dl_conversation_table); -} - /* Register the protocol with Wireshark */ void @@ -4551,16 +4539,12 @@ proto_register_dnp3(void) module_t *dnp3_module; expert_module_t* expert_dnp3; -/* Register protocol init routine */ - register_init_routine(&dnp3_init); - register_cleanup_routine(&dnp3_cleanup); + dl_conversation_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), dl_conversation_hash, dl_conversation_equal); reassembly_table_register(&al_reassembly_table, &addresses_reassembly_table_functions); - /* Register the protocol name and description */ - proto_dnp3 = proto_register_protocol("Distributed Network Protocol 3.0", - "DNP 3.0", "dnp3"); + proto_dnp3 = proto_register_protocol("Distributed Network Protocol 3.0", "DNP 3.0", "dnp3"); /* Register the dissector so it may be used as a User DLT payload protocol */ register_dissector("dnp3.udp", dissect_dnp3_udp, proto_dnp3); diff --git a/epan/dissectors/packet-enip.c b/epan/dissectors/packet-enip.c index 47f03d2ecf..7359c91f87 100644 --- a/epan/dissectors/packet-enip.c +++ b/epan/dissectors/packet-enip.c @@ -730,7 +730,7 @@ static gpointer enip_value(packet_info *pinfo _U_) return 0; } -static GHashTable *enip_request_hashtable = NULL; +static wmem_map_t *enip_request_hashtable = NULL; /* Return codes of function classifying packets as query/response */ enum enip_packet_type {ENIP_REQUEST_PACKET, ENIP_RESPONSE_PACKET, ENIP_CANNOT_CLASSIFY}; @@ -815,7 +815,7 @@ enip_match_request( packet_info *pinfo, proto_tree *tree, enip_request_key_t *pr enip_request_info_t *request_info; request_info = NULL; - request_val = (enip_request_val_t *)g_hash_table_lookup( enip_request_hashtable, prequest_key ); + request_val = (enip_request_val_t *)wmem_map_lookup( enip_request_hashtable, prequest_key ); if (!pinfo->fd->flags.visited) { if ( prequest_key && prequest_key->requesttype == ENIP_REQUEST_PACKET ) @@ -827,7 +827,7 @@ enip_match_request( packet_info *pinfo, proto_tree *tree, enip_request_key_t *pr request_val = wmem_new(wmem_file_scope(), enip_request_val_t); request_val->frames = wmem_tree_new(wmem_file_scope()); - g_hash_table_insert(enip_request_hashtable, new_request_key, request_val ); + wmem_map_insert(enip_request_hashtable, new_request_key, request_val ); } request_info = wmem_new(wmem_file_scope(), enip_request_info_t); @@ -1017,7 +1017,7 @@ enip_exp_conv_filter(packet_info *pinfo) /* * Connection management */ -static GHashTable *enip_conn_hashtable = NULL; +static wmem_map_t *enip_conn_hashtable = NULL; static guint32 enip_unique_connid = 1; static gint @@ -1067,7 +1067,7 @@ enip_open_cip_connection( packet_info *pinfo, cip_conn_info_t* connInfo) conn_key->O2TConnID = connInfo->O2T.connID; conn_key->T2OConnID = connInfo->T2O.connID; - conn_val = (enip_conn_val_t *)g_hash_table_lookup( enip_conn_hashtable, conn_key ); + conn_val = (enip_conn_val_t *)wmem_map_lookup( enip_conn_hashtable, conn_key ); if ( conn_val == NULL ) { conn_val = wmem_new(wmem_file_scope(), enip_conn_val_t); @@ -1086,7 +1086,7 @@ enip_open_cip_connection( packet_info *pinfo, cip_conn_info_t* connInfo) conn_val->close_frame = 0; conn_val->connid = enip_unique_connid++; - g_hash_table_insert(enip_conn_hashtable, conn_key, conn_val ); + wmem_map_insert(enip_conn_hashtable, conn_key, conn_val ); /* I/O connection */ if (((connInfo->TransportClass_trigger & CI_TRANSPORT_CLASS_MASK) == 0) || @@ -1210,7 +1210,7 @@ enip_close_cip_connection(packet_info *pinfo, guint16 ConnSerialNumber, conn_key.O2TConnID = 0; conn_key.T2OConnID = 0; - conn_val = (enip_conn_val_t *)g_hash_table_lookup( enip_conn_hashtable, &conn_key ); + conn_val = (enip_conn_val_t *)wmem_map_lookup( enip_conn_hashtable, &conn_key ); if ( conn_val ) { conn_val->close_frame = pinfo->num; @@ -1233,7 +1233,7 @@ void enip_mark_connection_triad( packet_info *pinfo, guint16 ConnSerialNumber, g conn_key.O2TConnID = 0; conn_key.T2OConnID = 0; - conn_val = (enip_conn_val_t *)g_hash_table_lookup( enip_conn_hashtable, &conn_key ); + conn_val = (enip_conn_val_t *)wmem_map_lookup( enip_conn_hashtable, &conn_key ); if ( conn_val ) { p_add_proto_data(wmem_file_scope(), pinfo, proto_enip, ENIP_CONNECTION_INFO, conn_val); @@ -2180,24 +2180,6 @@ attribute_info_t enip_attribute_vals[99] = { {0x5F, FALSE, 4, 3, "CA Certificate", cip_dissector_func, NULL, dissect_eip_cert_ca_cert}, }; - -/* - * Protocol initialization - */ -static void -enip_init_protocol(void) -{ - enip_request_hashtable = g_hash_table_new(enip_request_hash, enip_request_equal); - 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); -} - /* Dissect Common Packet Format */ static void dissect_cpf(enip_request_key_t *request_key, int command, tvbuff_t *tvb, @@ -4417,8 +4399,8 @@ proto_register_enip(void) subdissector_io_table = register_dissector_table("enip.io", "ENIP IO dissector", proto_enip, FT_UINT32, BASE_DEC); - register_init_routine(&enip_init_protocol); - register_cleanup_routine(&enip_cleanup_protocol); + enip_request_hashtable = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), enip_request_hash, enip_request_equal); + enip_conn_hashtable = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), enip_conn_hash, enip_conn_equal); /* Register the protocol name and description */ proto_dlr = proto_register_protocol("Device Level Ring", "DLR", "dlr"); diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c index f11fc5475b..04725916bc 100644 --- a/epan/dissectors/packet-fc.c +++ b/epan/dissectors/packet-fc.c @@ -166,7 +166,7 @@ typedef struct _fcseq_conv_data { guint32 seq_cnt; } fcseq_conv_data_t; -static GHashTable *fcseq_req_hash = NULL; +static wmem_map_t *fcseq_req_hash = NULL; /* * Hash Functions @@ -191,18 +191,6 @@ fcseq_hash (gconstpointer v) return val; } -static void -fc_exchange_init_protocol(void) -{ - fcseq_req_hash = g_hash_table_new(fcseq_hash, fcseq_equal); -} - -static void -fc_exchange_cleanup_protocol(void) -{ - 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)) @@ -1073,7 +1061,7 @@ dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean */ ckey.conv_idx = conversation->conv_index; - cdata = (fcseq_conv_data_t *)g_hash_table_lookup (fcseq_req_hash, + cdata = (fcseq_conv_data_t *)wmem_map_lookup (fcseq_req_hash, &ckey); if (is_1frame_inseq) { @@ -1091,7 +1079,7 @@ dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean cdata = wmem_new(wmem_file_scope(), fcseq_conv_data_t); cdata->seq_cnt = fchdr->seqcnt; - g_hash_table_insert (fcseq_req_hash, req_key, cdata); + wmem_map_insert (fcseq_req_hash, req_key, cdata); } real_seqcnt = 0; } @@ -1572,8 +1560,8 @@ proto_register_fc(void) "multi-frame sequence", 10, &fc_max_frame_size); - register_init_routine (fc_exchange_init_protocol); - register_cleanup_routine (fc_exchange_cleanup_protocol); + fcseq_req_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), fcseq_hash, fcseq_equal); + reassembly_table_register(&fc_reassembly_table, &addresses_reassembly_table_functions); diff --git a/epan/dissectors/packet-fcdns.c b/epan/dissectors/packet-fcdns.c index 3fac1d16c3..3364d2f23c 100644 --- a/epan/dissectors/packet-fcdns.c +++ b/epan/dissectors/packet-fcdns.c @@ -555,7 +555,7 @@ typedef struct _fcdns_conv_data { guint32 opcode; } fcdns_conv_data_t; -static GHashTable *fcdns_req_hash = NULL; +static wmem_map_t *fcdns_req_hash = NULL; /* * Hash Functions @@ -580,22 +580,6 @@ fcdns_hash (gconstpointer v) return val; } -/* - * Protocol initialization - */ -static void -fcdns_init_protocol(void) -{ - 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) { @@ -1739,7 +1723,7 @@ dissect_fcdns (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) ckey.conv_idx = conversation->conv_index; - cdata = (fcdns_conv_data_t *)g_hash_table_lookup (fcdns_req_hash, + cdata = (fcdns_conv_data_t *)wmem_map_lookup (fcdns_req_hash, &ckey); if (cdata) { /* Since we never free the memory used by an exchange, this maybe a @@ -1755,7 +1739,7 @@ dissect_fcdns (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) cdata = wmem_new(wmem_file_scope(), fcdns_conv_data_t); cdata->opcode = opcode; - g_hash_table_insert (fcdns_req_hash, req_key, cdata); + wmem_map_insert (fcdns_req_hash, req_key, cdata); } col_add_str (pinfo->cinfo, COL_INFO, val_to_str (opcode, fc_dns_opcode_val, "0x%x")); @@ -1779,7 +1763,7 @@ dissect_fcdns (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) else { ckey.conv_idx = conversation->conv_index; - cdata = (fcdns_conv_data_t *)g_hash_table_lookup (fcdns_req_hash, &ckey); + cdata = (fcdns_conv_data_t *)wmem_map_lookup (fcdns_req_hash, &ckey); if (cdata != NULL) { if (opcode == FCCT_MSG_ACC) { @@ -2059,8 +2043,8 @@ proto_register_fcdns (void) proto_register_subtree_array(ett, array_length(ett)); 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); + + fcdns_req_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), fcdns_hash, fcdns_equal); dns_handle = create_dissector_handle (dissect_fcdns, proto_fcdns); } diff --git a/epan/dissectors/packet-fcels.c b/epan/dissectors/packet-fcels.c index 656839b193..a0514ce5ad 100644 --- a/epan/dissectors/packet-fcels.c +++ b/epan/dissectors/packet-fcels.c @@ -619,7 +619,7 @@ typedef struct _fcels_conv_data { guint32 opcode; } fcels_conv_data_t; -static GHashTable *fcels_req_hash = NULL; +static wmem_map_t *fcels_req_hash = NULL; static dissector_handle_t fcsp_handle; @@ -646,21 +646,6 @@ fcels_hash (gconstpointer v) return val; } -/* - * Protocol initialization - */ -static void -fcels_init_protocol(void) -{ - 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" @@ -1894,7 +1879,7 @@ dissect_fcels (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) ckey.conv_idx = conversation->conv_index; - cdata = (fcels_conv_data_t *)g_hash_table_lookup (fcels_req_hash, + cdata = (fcels_conv_data_t *)wmem_map_lookup (fcels_req_hash, &ckey); if (cdata) { /* Since we never free the memory used by an exchange, this maybe a @@ -1910,7 +1895,7 @@ dissect_fcels (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) cdata = wmem_new(wmem_file_scope(), fcels_conv_data_t); cdata->opcode = opcode; - g_hash_table_insert (fcels_req_hash, req_key, cdata); + wmem_map_insert (fcels_req_hash, req_key, cdata); } } else { @@ -1964,7 +1949,7 @@ dissect_fcels (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) if (conversation) { ckey.conv_idx = conversation->conv_index; - cdata = (fcels_conv_data_t *)g_hash_table_lookup (fcels_req_hash, &ckey); + cdata = (fcels_conv_data_t *)wmem_map_lookup (fcels_req_hash, &ckey); if (cdata != NULL) { if ((options & NO_ADDR2) && (cdata->opcode != FC_ELS_FLOGI)) { @@ -2615,8 +2600,7 @@ proto_register_fcels (void) proto_register_subtree_array(ett, array_length(ett)); 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); + fcels_req_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), fcels_hash, fcels_equal); } void diff --git a/epan/dissectors/packet-fcfcs.c b/epan/dissectors/packet-fcfcs.c index 68d2292694..53b6620dff 100644 --- a/epan/dissectors/packet-fcfcs.c +++ b/epan/dissectors/packet-fcfcs.c @@ -97,7 +97,7 @@ typedef struct _fcfcs_conv_data { guint32 opcode; } fcfcs_conv_data_t; -static GHashTable *fcfcs_req_hash = NULL; +static wmem_map_t *fcfcs_req_hash = NULL; /* * Hash Functions @@ -122,21 +122,6 @@ fcfcs_hash (gconstpointer v) return val; } -/* - * Protocol initialization - */ -static void -fcfcs_init_protocol(void) -{ - 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) @@ -738,7 +723,7 @@ dissect_fcfcs (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) ckey.conv_idx = conversation->conv_index; - cdata = (fcfcs_conv_data_t *)g_hash_table_lookup (fcfcs_req_hash, + cdata = (fcfcs_conv_data_t *)wmem_map_lookup (fcfcs_req_hash, &ckey); if (cdata) { /* Since we never free the memory used by an exchange, this maybe a @@ -754,7 +739,7 @@ dissect_fcfcs (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) cdata = wmem_new(wmem_file_scope(), fcfcs_conv_data_t); cdata->opcode = opcode; - g_hash_table_insert (fcfcs_req_hash, req_key, cdata); + wmem_map_insert (fcfcs_req_hash, req_key, cdata); } col_add_str (pinfo->cinfo, COL_INFO, val_to_str (opcode, fc_fcs_opcode_abbrev_val, "0x%x")); @@ -778,7 +763,7 @@ dissect_fcfcs (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) else { ckey.conv_idx = conversation->conv_index; - cdata = (fcfcs_conv_data_t *)g_hash_table_lookup (fcfcs_req_hash, + cdata = (fcfcs_conv_data_t *)wmem_map_lookup (fcfcs_req_hash, &ckey); if (cdata != NULL) { @@ -1042,8 +1027,7 @@ proto_register_fcfcs (void) expert_fcfcs = expert_register_protocol(proto_fcfcs); expert_register_field_array(expert_fcfcs, ei, array_length(ei)); - register_init_routine (&fcfcs_init_protocol); - register_cleanup_routine (&fcfcs_cleanup_protocol); + fcfcs_req_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), fcfcs_hash, fcfcs_equal); } void diff --git a/epan/dissectors/packet-fcfzs.c b/epan/dissectors/packet-fcfzs.c index 6dba52aeb6..3e518769e1 100644 --- a/epan/dissectors/packet-fcfzs.c +++ b/epan/dissectors/packet-fcfzs.c @@ -81,7 +81,7 @@ typedef struct _fcfzs_conv_data { guint32 opcode; } fcfzs_conv_data_t; -static GHashTable *fcfzs_req_hash = NULL; +static wmem_map_t *fcfzs_req_hash = NULL; /* * Hash Functions @@ -106,21 +106,6 @@ fcfzs_hash(gconstpointer v) return val; } -/* - * Protocol initialization - */ -static void -fcfzs_init_protocol(void) -{ - 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) @@ -561,7 +546,7 @@ dissect_fcfzs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) ckey.conv_idx = conversation->conv_index; - cdata = (fcfzs_conv_data_t *)g_hash_table_lookup(fcfzs_req_hash, + cdata = (fcfzs_conv_data_t *)wmem_map_lookup(fcfzs_req_hash, &ckey); if (cdata) { /* Since we never free the memory used by an exchange, this maybe a @@ -577,7 +562,7 @@ dissect_fcfzs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) cdata = wmem_new(wmem_file_scope(), fcfzs_conv_data_t); cdata->opcode = opcode; - g_hash_table_insert(fcfzs_req_hash, req_key, cdata); + wmem_map_insert(fcfzs_req_hash, req_key, cdata); } col_add_str(pinfo->cinfo, COL_INFO, val_to_str(opcode, fc_fzs_opcode_val, @@ -603,7 +588,7 @@ dissect_fcfzs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) else { ckey.conv_idx = conversation->conv_index; - cdata = (fcfzs_conv_data_t *)g_hash_table_lookup(fcfzs_req_hash, &ckey); + cdata = (fcfzs_conv_data_t *)wmem_map_lookup(fcfzs_req_hash, &ckey); if (cdata != NULL) { if (opcode == FCCT_MSG_ACC) @@ -867,9 +852,8 @@ proto_register_fcfzs(void) proto_register_subtree_array(ett, array_length(ett)); 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); + fcfzs_req_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), fcfzs_hash, fcfzs_equal); } void diff --git a/epan/dissectors/packet-fcswils.c b/epan/dissectors/packet-fcswils.c index 22212d2117..3b9256bbc1 100644 --- a/epan/dissectors/packet-fcswils.c +++ b/epan/dissectors/packet-fcswils.c @@ -444,7 +444,7 @@ typedef struct _fcswils_conv_data { guint32 opcode; } fcswils_conv_data_t; -static GHashTable *fcswils_req_hash = NULL; +static wmem_map_t *fcswils_req_hash = NULL; /* list of commands for each commandset */ typedef void (*fcswils_dissector_t)(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, guint8 isreq); @@ -480,21 +480,6 @@ fcswils_hash(gconstpointer v) return val; } -/* - * Protocol initialization - */ -static void -fcswils_init_protocol(void) -{ - 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 * zonenm_to_str(tvbuff_t *tvb, gint offset) { @@ -1717,7 +1702,7 @@ dissect_fcswils(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) ckey.conv_idx = conversation->conv_index; - cdata = (fcswils_conv_data_t *)g_hash_table_lookup(fcswils_req_hash, + cdata = (fcswils_conv_data_t *)wmem_map_lookup(fcswils_req_hash, &ckey); if (cdata) { /* Since we never free the memory used by an exchange, this maybe a @@ -1733,7 +1718,7 @@ dissect_fcswils(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) cdata = wmem_new(wmem_file_scope(), fcswils_conv_data_t); cdata->opcode = opcode; - g_hash_table_insert(fcswils_req_hash, req_key, cdata); + wmem_map_insert(fcswils_req_hash, req_key, cdata); } } else { @@ -1752,7 +1737,7 @@ dissect_fcswils(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) else { ckey.conv_idx = conversation->conv_index; - cdata = (fcswils_conv_data_t *)g_hash_table_lookup(fcswils_req_hash, &ckey); + cdata = (fcswils_conv_data_t *)wmem_map_lookup(fcswils_req_hash, &ckey); if (cdata != NULL) { if (opcode == FC_SWILS_SWACC) @@ -2525,8 +2510,8 @@ proto_register_fcswils(void) proto_register_subtree_array(ett, array_length(ett)); 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); + + fcswils_req_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), fcswils_hash, fcswils_equal); } void diff --git a/epan/dissectors/packet-gsm_sms.c b/epan/dissectors/packet-gsm_sms.c index 57cb6c5212..0298fa2431 100644 --- a/epan/dissectors/packet-gsm_sms.c +++ b/epan/dissectors/packet-gsm_sms.c @@ -289,7 +289,7 @@ static value_string_ext gsm_sms_coding_group_bits_vals_ext = VALUE_STRING_EXT_IN static dissector_table_t gsm_sms_dissector_tbl; /* Short Message reassembly */ static reassembly_table g_sm_reassembly_table; -static GHashTable *g_sm_fragment_params_table = NULL; +static wmem_map_t *g_sm_fragment_params_table = NULL; static gint ett_gsm_sms_ud_fragment = -1; static gint ett_gsm_sms_ud_fragments = -1; /* @@ -335,18 +335,6 @@ typedef struct { guint8 fill_bits; } sm_fragment_params; -static void -gsm_sms_defragment_init (void) -{ - g_sm_fragment_params_table = g_hash_table_new(g_direct_hash, g_direct_equal); -} - -static void -gsm_sms_defragment_cleanup (void) -{ - 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 @@ -1906,7 +1894,7 @@ dis_field_ud(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset p_frag_params->udl = udl; p_frag_params->fill_bits = fill_bits; p_frag_params->length = length; - g_hash_table_insert(g_sm_fragment_params_table, + wmem_map_insert(g_sm_fragment_params_table, GUINT_TO_POINTER((guint)((udh_fields.sm_id<<16)|(udh_fields.frag-1))), p_frag_params); } /* Else: not fragmented */ @@ -1950,7 +1938,7 @@ dis_field_ud(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset total_sms_len = 0; for(i = 0 ; i < udh_fields.frags; i++) { - p_frag_params = (sm_fragment_params*)g_hash_table_lookup(g_sm_fragment_params_table, + p_frag_params = (sm_fragment_params*)wmem_map_lookup(g_sm_fragment_params_table, GUINT_TO_POINTER((guint)((udh_fields.sm_id<<16)|i))); if (p_frag_params) { @@ -1978,7 +1966,7 @@ dis_field_ud(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset total_sms_len = 0; for(i = 0 ; i < udh_fields.frags; i++) { - p_frag_params = (sm_fragment_params*)g_hash_table_lookup(g_sm_fragment_params_table, + p_frag_params = (sm_fragment_params*)wmem_map_lookup(g_sm_fragment_params_table, GUINT_TO_POINTER((guint)((udh_fields.sm_id<<16)|i))); if (p_frag_params) { @@ -2023,7 +2011,7 @@ dis_field_ud(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset total_sms_len = 0; for(i = 0 ; i < udh_fields.frags; i++) { - p_frag_params = (sm_fragment_params*)g_hash_table_lookup(g_sm_fragment_params_table, + p_frag_params = (sm_fragment_params*)wmem_map_lookup(g_sm_fragment_params_table, GUINT_TO_POINTER((guint)((udh_fields.sm_id<<16)|i))); if (p_frag_params) { @@ -3357,9 +3345,7 @@ proto_register_gsm_sms(void) register_dissector("gsm_sms", dissect_gsm_sms, proto_gsm_sms); - /* GSM SMS UD dissector initialization routines */ - register_init_routine (gsm_sms_defragment_init); - register_cleanup_routine (gsm_sms_defragment_cleanup); + g_sm_fragment_params_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal); reassembly_table_register(&g_sm_reassembly_table, &addresses_reassembly_table_functions); diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c index 35da543de9..3d72158857 100644 --- a/epan/dissectors/packet-ipsec.c +++ b/epan/dissectors/packet-ipsec.c @@ -470,19 +470,19 @@ typedef struct /* The sequence analysis SPI hash table. Maps SPI -> spi_status */ -static GHashTable *esp_sequence_analysis_hash = NULL; +static wmem_map_t *esp_sequence_analysis_hash = NULL; /* Results are stored here: framenum -> spi_status */ /* N.B. only store entries for out-of-order frames, if there is no entry for a given frame, it was found to be in-order */ -static GHashTable *esp_sequence_analysis_report_hash = NULL; +static wmem_map_t *esp_sequence_analysis_report_hash = NULL; /* During the first pass, update the SPI state. If the sequence numbers are out of order, add an entry to the report table */ static void check_esp_sequence_info(guint32 spi, guint32 sequence_number, packet_info *pinfo) { /* Do the table lookup */ - spi_status *status = (spi_status*)g_hash_table_lookup(esp_sequence_analysis_hash, + spi_status *status = (spi_status*)wmem_map_lookup(esp_sequence_analysis_hash, GUINT_TO_POINTER((guint)spi)); if (status == NULL) { /* Create an entry for this SPI */ @@ -491,7 +491,7 @@ static void check_esp_sequence_info(guint32 spi, guint32 sequence_number, packet status->previousFrameNum = pinfo->num; /* And add it to the table */ - g_hash_table_insert(esp_sequence_analysis_hash, GUINT_TO_POINTER((guint)spi), status); + wmem_map_insert(esp_sequence_analysis_hash, GUINT_TO_POINTER((guint)spi), status); } else { spi_status *frame_status; @@ -503,7 +503,7 @@ static void check_esp_sequence_info(guint32 spi, guint32 sequence_number, packet /* Copy what was expected */ *frame_status = *status; /* And add it into the report table */ - g_hash_table_insert(esp_sequence_analysis_report_hash, GUINT_TO_POINTER(pinfo->num), frame_status); + wmem_map_insert(esp_sequence_analysis_report_hash, GUINT_TO_POINTER(pinfo->num), frame_status); } /* Adopt this setting as 'current' regardless of whether expected */ status->previousSequenceNumber = sequence_number; @@ -517,7 +517,7 @@ static void show_esp_sequence_info(guint32 spi, guint32 sequence_number, tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo) { /* Look up this frame in the report table. */ - spi_status *status = (spi_status*)g_hash_table_lookup(esp_sequence_analysis_report_hash, + spi_status *status = (spi_status*)wmem_map_lookup(esp_sequence_analysis_report_hash, GUINT_TO_POINTER(pinfo->num)); if (status != NULL) { proto_item *sn_ti, *frame_ti; @@ -2235,15 +2235,9 @@ dissect_ipcomp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dissec return tvb_captured_length(tvb); } -static void ipsec_init_protocol(void) -{ - esp_sequence_analysis_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - esp_sequence_analysis_report_hash = g_hash_table_new(g_direct_hash, g_direct_equal); -} - +#ifdef HAVE_LIBGCRYPT static void ipsec_cleanup_protocol(void) { -#ifdef HAVE_LIBGCRYPT /* Free any SA records added by other dissectors */ guint n; for (n=0; n < extra_esp_sa_records.num_records; n++) { @@ -2254,11 +2248,8 @@ static void ipsec_cleanup_protocol(void) g_free(extra_esp_sa_records.records); extra_esp_sa_records.records = NULL; extra_esp_sa_records.num_records = 0; -#endif - - g_hash_table_destroy(esp_sequence_analysis_hash); - g_hash_table_destroy(esp_sequence_analysis_report_hash); } +#endif void proto_register_ipsec(void) @@ -2473,8 +2464,11 @@ proto_register_ipsec(void) esp_uat); #endif - register_init_routine(&ipsec_init_protocol); + esp_sequence_analysis_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal); + esp_sequence_analysis_report_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal); +#ifdef HAVE_LIBGCRYPT register_cleanup_routine(&ipsec_cleanup_protocol); +#endif register_dissector("esp", dissect_esp, proto_esp); register_dissector("ah", dissect_ah, proto_ah); diff --git a/epan/dissectors/packet-iuup.c b/epan/dissectors/packet-iuup.c index 370be8afbc..348f2b8f4a 100644 --- a/epan/dissectors/packet-iuup.c +++ b/epan/dissectors/packet-iuup.c @@ -155,7 +155,7 @@ static expert_field ei_iuup_time_align = EI_INIT; static expert_field ei_iuup_procedure_indicator = EI_INIT; static expert_field ei_iuup_pdu_type = EI_INIT; -static GHashTable* circuits = NULL; +static wmem_map_t* circuits = NULL; static dissector_handle_t iuup_handle; @@ -364,7 +364,7 @@ static void dissect_iuup_payload(tvbuff_t* tvb, packet_info* pinfo, proto_tree* if ( ! dissect_fields ) { return; } else if ( ! circuit_id - || ! ( iuup_circuit = (iuup_circuit_t *)g_hash_table_lookup(circuits,GUINT_TO_POINTER(circuit_id)) ) ) { + || ! ( iuup_circuit = (iuup_circuit_t *)wmem_map_lookup(circuits,GUINT_TO_POINTER(circuit_id)) ) ) { expert_add_info(pinfo, pi, &ei_iuup_payload_undecoded); return; } @@ -482,10 +482,10 @@ static void dissect_iuup_init(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tre iuup_circuit_t* iuup_circuit = NULL; if (circuit_id) { - iuup_circuit = (iuup_circuit_t *)g_hash_table_lookup(circuits,GUINT_TO_POINTER(circuit_id)); + iuup_circuit = (iuup_circuit_t *)wmem_map_lookup(circuits,GUINT_TO_POINTER(circuit_id)); if (iuup_circuit) { - g_hash_table_remove(circuits,GUINT_TO_POINTER(circuit_id)); + wmem_map_remove(circuits,GUINT_TO_POINTER(circuit_id)); } iuup_circuit = wmem_new0(wmem_file_scope(), iuup_circuit_t); @@ -499,7 +499,7 @@ static void dissect_iuup_init(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tre iuup_circuit->last_rfci = NULL; if (circuit_id) { - g_hash_table_insert(circuits,GUINT_TO_POINTER(iuup_circuit->id),iuup_circuit); + wmem_map_insert(circuits,GUINT_TO_POINTER(iuup_circuit->id),iuup_circuit); } if (tree) { @@ -834,14 +834,6 @@ static int find_iuup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* return tvb_captured_length(tvb); } -static void init_iuup(void) { - 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; @@ -997,8 +989,7 @@ void proto_register_iuup(void) { iuup_handle = register_dissector("iuup", dissect_iuup, proto_iuup); register_dissector("find_iuup", find_iuup, proto_iuup); - register_init_routine(&init_iuup); - register_cleanup_routine(&cleanup_iuup); + circuits = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal); iuup_module = prefs_register_protocol(proto_iuup, proto_reg_handoff_iuup); diff --git a/epan/dissectors/packet-mgcp.c b/epan/dissectors/packet-mgcp.c index 87d877f111..6e4eb27f6f 100644 --- a/epan/dissectors/packet-mgcp.c +++ b/epan/dissectors/packet-mgcp.c @@ -405,7 +405,7 @@ typedef struct _mgcp_call_info_key conversation_t *conversation; } mgcp_call_info_key; -static GHashTable *mgcp_calls; +static wmem_map_t *mgcp_calls; /* Compare 2 keys */ static gint mgcp_call_equal(gconstpointer k1, gconstpointer k2) @@ -637,18 +637,6 @@ static void mgcp_raw_text_add(tvbuff_t *tvb, proto_tree *tree) } while (tvb_offset_exists(tvb, tvb_lineend)); } -/* Discard and init any state we've saved */ -static void mgcp_init_protocol(void) -{ - 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 * MGCP verb at offset in tvb @@ -1280,7 +1268,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree matching conversation is available. */ mgcp_call_key.transid = mi->transid; mgcp_call_key.conversation = conversation; - mgcp_call = (mgcp_call_t *)g_hash_table_lookup(mgcp_calls, &mgcp_call_key); + mgcp_call = (mgcp_call_t *)wmem_map_lookup(mgcp_calls, &mgcp_call_key); if (mgcp_call) { /* Indicate the frame to which this is a reply. */ @@ -1399,7 +1387,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree mgcp_call_key.conversation = conversation; /* Look up the request */ - mgcp_call = (mgcp_call_t *)g_hash_table_lookup(mgcp_calls, &mgcp_call_key); + mgcp_call = (mgcp_call_t *)wmem_map_lookup(mgcp_calls, &mgcp_call_key); if (mgcp_call != NULL) { /* We've seen a request with this TRANSID, with the same @@ -1443,7 +1431,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree g_strlcpy(mgcp_call->code, mi->code, 5); /* Store it */ - g_hash_table_insert(mgcp_calls, new_mgcp_call_key, mgcp_call); + wmem_map_insert(mgcp_calls, new_mgcp_call_key, mgcp_call); } if (mgcp_call->rsp_num) { @@ -2285,8 +2273,8 @@ void proto_register_mgcp(void) proto_mgcp = proto_register_protocol("Media Gateway Control Protocol", "MGCP", "mgcp"); 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); + + mgcp_calls = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), mgcp_call_hash, mgcp_call_equal); mgcp_handle = register_dissector("mgcp", dissect_mgcp, proto_mgcp); diff --git a/epan/dissectors/packet-netflow.c b/epan/dissectors/packet-netflow.c index bee1d70cc7..d868c82dec 100644 --- a/epan/dissectors/packet-netflow.c +++ b/epan/dissectors/packet-netflow.c @@ -324,7 +324,7 @@ typedef struct _v9_v10_tmplt { /* Map from (converstion+obs-domain-id+flowset-id) -> v9_v10_tmplt_entry_t* */ /* Confusingly, for key, fill in only relevant parts of v9_v10_tmplt_entry_t... */ -GHashTable *v9_v10_tmplt_table = NULL; +wmem_map_t *v9_v10_tmplt_table = NULL; static const value_string v9_v10_template_types[] = { @@ -2341,10 +2341,10 @@ typedef struct netflow_domain_state_t { guint32 current_frame_number; } netflow_domain_state_t; -static GHashTable *netflow_sequence_analysis_domain_hash = NULL; +static wmem_map_t *netflow_sequence_analysis_domain_hash = NULL; /* Frame number -> domain state */ -static GHashTable *netflow_sequence_analysis_result_hash = NULL; +static wmem_map_t *netflow_sequence_analysis_result_hash = NULL; /* On first pass, check ongoing sequence of observation domain, and only store a result if the sequence number is not as expected */ @@ -2352,7 +2352,7 @@ static void store_sequence_analysis_info(guint32 domain_id, guint32 seqnum, unsi packet_info *pinfo) { /* Find current domain info */ - netflow_domain_state_t *domain_state = (netflow_domain_state_t *)g_hash_table_lookup(netflow_sequence_analysis_domain_hash, + netflow_domain_state_t *domain_state = (netflow_domain_state_t *)wmem_map_lookup(netflow_sequence_analysis_domain_hash, GUINT_TO_POINTER(domain_id)); if (domain_state == NULL) { /* Give up if we haven't seen a template for this domain id yet */ @@ -2370,7 +2370,7 @@ static void store_sequence_analysis_info(guint32 domain_id, guint32 seqnum, unsi *result_state = *domain_state; /* Add into result table for current frame number */ - g_hash_table_insert(netflow_sequence_analysis_result_hash, GUINT_TO_POINTER(pinfo->num), result_state); + wmem_map_insert(netflow_sequence_analysis_result_hash, GUINT_TO_POINTER(pinfo->num), result_state); } /* Update domain info for the next frame to consult. @@ -2386,7 +2386,7 @@ static void show_sequence_analysis_info(guint32 domain_id, guint32 seqnum, proto_item *flow_sequence_ti, proto_tree *tree) { /* Look for info stored for this frame */ - netflow_domain_state_t *state = (netflow_domain_state_t *)g_hash_table_lookup(netflow_sequence_analysis_result_hash, + netflow_domain_state_t *state = (netflow_domain_state_t *)wmem_map_lookup(netflow_sequence_analysis_result_hash, GUINT_TO_POINTER(pinfo->num)); if (state != NULL) { proto_item *ti; @@ -3103,7 +3103,7 @@ dissect_v9_v10_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pdutree, int /* Look up template */ v9_v10_tmplt_build_key(&tmplt_key, pinfo, hdrinfo_p->src_id, id); - tmplt_p = (v9_v10_tmplt_t *)g_hash_table_lookup(v9_v10_tmplt_table, &tmplt_key); + tmplt_p = (v9_v10_tmplt_t *)wmem_map_lookup(v9_v10_tmplt_table, &tmplt_key); if ((tmplt_p != NULL) && (tmplt_p->length != 0)) { int count = 1; proto_item *ti; @@ -7395,7 +7395,7 @@ dissect_v9_v10_options_template(tvbuff_t *tvb, packet_info *pinfo, proto_tree *p /* ToDo: expert warning if replacement (changed) and new template ignored. */ /* XXX: Is an Options template with only scope fields allowed for V9 ?? */ - tmplt_p = (v9_v10_tmplt_t *)g_hash_table_lookup(v9_v10_tmplt_table, &tmplt); + tmplt_p = (v9_v10_tmplt_t *)wmem_map_lookup(v9_v10_tmplt_table, &tmplt); if (!pinfo->fd->flags.visited) { /* cache template info only during first pass */ do { if (v9_tmplt_max_fields && @@ -7428,7 +7428,7 @@ dissect_v9_v10_options_template(tvbuff_t *tvb, packet_info *pinfo, proto_tree *p /* Remember when we saw this template */ tmplt_p->template_frame_number = pinfo->num; /* Add completed entry into table */ - g_hash_table_insert(v9_v10_tmplt_table, tmplt_p, tmplt_p); + wmem_map_insert(v9_v10_tmplt_table, tmplt_p, tmplt_p); } remaining -= offset - orig_offset; @@ -7499,7 +7499,7 @@ dissect_v9_v10_data_template(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pdut /* been allocated) and thus this template will not be cached after dissection. */ /* ToDo: expert warning if replacement (changed) and new template ignored. */ - tmplt_p = (v9_v10_tmplt_t *)g_hash_table_lookup(v9_v10_tmplt_table, &tmplt); + tmplt_p = (v9_v10_tmplt_t *)wmem_map_lookup(v9_v10_tmplt_table, &tmplt); if (!pinfo->fd->flags.visited) { /* cache template info only during first pass */ do { if ((count == 0) || @@ -7527,15 +7527,15 @@ dissect_v9_v10_data_template(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pdut copy_address_wmem(wmem_file_scope(), &tmplt_p->dst_addr, &pinfo->net_dst); /* Remember when we saw this template */ tmplt_p->template_frame_number = pinfo->num; - g_hash_table_insert(v9_v10_tmplt_table, tmplt_p, tmplt_p); + wmem_map_insert(v9_v10_tmplt_table, tmplt_p, tmplt_p); /* Create if necessary observation domain entry (for use with sequence analysis) */ - domain_state = (netflow_domain_state_t *)g_hash_table_lookup(netflow_sequence_analysis_domain_hash, + domain_state = (netflow_domain_state_t *)wmem_map_lookup(netflow_sequence_analysis_domain_hash, GUINT_TO_POINTER(hdrinfo_p->src_id)); if (domain_state == NULL) { domain_state = wmem_new0(wmem_file_scope(), netflow_domain_state_t); /* Store new domain in table */ - g_hash_table_insert(netflow_sequence_analysis_domain_hash, GUINT_TO_POINTER(hdrinfo_p->src_id), domain_state); + wmem_map_insert(netflow_sequence_analysis_domain_hash, GUINT_TO_POINTER(hdrinfo_p->src_id), domain_state); } } remaining -= offset - orig_offset; @@ -7696,23 +7696,6 @@ getprefix(const guint32 *addr, int prefix) return address_to_str(wmem_packet_scope(), &prefix_addr); } -/* Called whenever a new capture is loaded, a complete redissection is done, a pref is changed, & etc */ -static void -netflow_init(void) -{ - v9_v10_tmplt_table = g_hash_table_new(v9_v10_tmplt_table_hash, v9_v10_tmplt_table_equal); - netflow_sequence_analysis_domain_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - 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) { @@ -12035,8 +12018,9 @@ proto_register_netflow(void) " (default: " G_STRINGIFY(V9_TMPLT_MAX_FIELDS_DEF) ")", 10, &v9_tmplt_max_fields); - register_init_routine(&netflow_init); - register_cleanup_routine(&netflow_cleanup); + v9_v10_tmplt_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), v9_v10_tmplt_table_hash, v9_v10_tmplt_table_equal); + netflow_sequence_analysis_domain_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal); + netflow_sequence_analysis_result_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal); } diff --git a/epan/dissectors/packet-pdcp-lte.c b/epan/dissectors/packet-pdcp-lte.c index c3b6acf198..5e483324b7 100644 --- a/epan/dissectors/packet-pdcp-lte.c +++ b/epan/dissectors/packet-pdcp-lte.c @@ -294,19 +294,19 @@ UAT_CSTRING_CB_DEF(uat_ue_keys_records, rrcIntegrityKeyString, uat_ue_keys_reco /* Also supporting a hash table with entries from these functions */ /* Table from ueid -> uat_ue_keys_record_t* */ -static GHashTable *pdcp_security_key_hash = NULL; +static wmem_map_t *pdcp_security_key_hash = NULL; void set_pdcp_lte_rrc_ciphering_key(guint16 ueid, const char *key) { /* Get or create struct for this UE */ - uat_ue_keys_record_t *key_record = (uat_ue_keys_record_t*)g_hash_table_lookup(pdcp_security_key_hash, + uat_ue_keys_record_t *key_record = (uat_ue_keys_record_t*)wmem_map_lookup(pdcp_security_key_hash, GUINT_TO_POINTER((guint)ueid)); if (key_record == NULL) { /* Create and add to table */ key_record = wmem_new0(wmem_file_scope(), uat_ue_keys_record_t); key_record->ueid = ueid; - g_hash_table_insert(pdcp_security_key_hash, GUINT_TO_POINTER((guint)ueid), key_record); + wmem_map_insert(pdcp_security_key_hash, GUINT_TO_POINTER((guint)ueid), key_record); } /* Check and convert RRC key */ @@ -316,13 +316,13 @@ void set_pdcp_lte_rrc_ciphering_key(guint16 ueid, const char *key) void set_pdcp_lte_rrc_integrity_key(guint16 ueid, const char *key) { /* Get or create struct for this UE */ - uat_ue_keys_record_t *key_record = (uat_ue_keys_record_t*)g_hash_table_lookup(pdcp_security_key_hash, + uat_ue_keys_record_t *key_record = (uat_ue_keys_record_t*)wmem_map_lookup(pdcp_security_key_hash, GUINT_TO_POINTER((guint)ueid)); if (key_record == NULL) { /* Create and add to table */ key_record = wmem_new0(wmem_file_scope(), uat_ue_keys_record_t); key_record->ueid = ueid; - g_hash_table_insert(pdcp_security_key_hash, GUINT_TO_POINTER((guint)ueid), key_record); + wmem_map_insert(pdcp_security_key_hash, GUINT_TO_POINTER((guint)ueid), key_record); } /* Check and convert RRC integrity key */ @@ -333,13 +333,13 @@ void set_pdcp_lte_rrc_integrity_key(guint16 ueid, const char *key) void set_pdcp_lte_up_ciphering_key(guint16 ueid, const char *key) { /* Get or create struct for this UE */ - uat_ue_keys_record_t *key_record = (uat_ue_keys_record_t*)g_hash_table_lookup(pdcp_security_key_hash, + uat_ue_keys_record_t *key_record = (uat_ue_keys_record_t*)wmem_map_lookup(pdcp_security_key_hash, GUINT_TO_POINTER((guint)ueid)); if (key_record == NULL) { /* Create and add to table */ key_record = wmem_new0(wmem_file_scope(), uat_ue_keys_record_t); key_record->ueid = ueid; - g_hash_table_insert(pdcp_security_key_hash, GUINT_TO_POINTER((guint)ueid), key_record); + wmem_map_insert(pdcp_security_key_hash, GUINT_TO_POINTER((guint)ueid), key_record); } /* Check and convert UP key */ @@ -502,7 +502,7 @@ typedef struct /* The sequence analysis channel hash table. Maps key -> status */ -static GHashTable *pdcp_sequence_analysis_channel_hash = NULL; +static wmem_map_t *pdcp_sequence_analysis_channel_hash = NULL; /* Hash table types & functions for frame reports */ @@ -597,7 +597,7 @@ typedef struct /* The sequence analysis frame report hash table. Maps pdcp_result_hash_key* -> pdcp_sequence_report_in_frame* */ -static GHashTable *pdcp_lte_sequence_analysis_report_hash = NULL; +static wmem_map_t *pdcp_lte_sequence_analysis_report_hash = NULL; /* Gather together security settings in order to be able to do deciphering */ typedef struct pdu_security_settings_t @@ -618,7 +618,7 @@ static uat_ue_keys_record_t* look_up_keys_record(guint16 ueid) { unsigned int record_id; /* Try hash table first */ - uat_ue_keys_record_t* key_record = (uat_ue_keys_record_t*)g_hash_table_lookup(pdcp_security_key_hash, + uat_ue_keys_record_t* key_record = (uat_ue_keys_record_t*)wmem_map_lookup(pdcp_security_key_hash, GUINT_TO_POINTER((guint)ueid)); if (key_record != NULL) { return key_record; @@ -867,7 +867,7 @@ static void checkChannelSequenceInfo(packet_info *pinfo, tvbuff_t *tvb, /* If find stat_report_in_frame already, use that and get out */ if (pinfo->fd->flags.visited) { p_report_in_frame = - (pdcp_sequence_report_in_frame*)g_hash_table_lookup(pdcp_lte_sequence_analysis_report_hash, + (pdcp_sequence_report_in_frame*)wmem_map_lookup(pdcp_lte_sequence_analysis_report_hash, get_report_hash_key(sequenceNumber, pinfo->num, p_pdcp_lte_info, FALSE)); @@ -893,7 +893,7 @@ static void checkChannelSequenceInfo(packet_info *pinfo, tvbuff_t *tvb, channel_key.notUsed = 0; /* Do the table lookup */ - p_channel_status = (pdcp_channel_status*)g_hash_table_lookup(pdcp_sequence_analysis_channel_hash, + p_channel_status = (pdcp_channel_status*)wmem_map_lookup(pdcp_sequence_analysis_channel_hash, get_channel_hash_key(&channel_key)); /* Create table entry if necessary */ @@ -904,7 +904,7 @@ static void checkChannelSequenceInfo(packet_info *pinfo, tvbuff_t *tvb, p_channel_status = wmem_new0(wmem_file_scope(), pdcp_channel_status); /* Add entry */ - g_hash_table_insert(pdcp_sequence_analysis_channel_hash, + wmem_map_insert(pdcp_sequence_analysis_channel_hash, get_channel_hash_key(&channel_key), p_channel_status); } @@ -990,7 +990,7 @@ static void checkChannelSequenceInfo(packet_info *pinfo, tvbuff_t *tvb, if (p_report_in_frame->previousFrameNum != 0) { /* Get report for previous frame */ pdcp_sequence_report_in_frame *p_previous_report; - p_previous_report = (pdcp_sequence_report_in_frame*)g_hash_table_lookup(pdcp_lte_sequence_analysis_report_hash, + p_previous_report = (pdcp_sequence_report_in_frame*)wmem_map_lookup(pdcp_lte_sequence_analysis_report_hash, get_report_hash_key((sequenceNumber+262144) % 262144, p_report_in_frame->previousFrameNum, p_pdcp_lte_info, @@ -1004,7 +1004,7 @@ static void checkChannelSequenceInfo(packet_info *pinfo, tvbuff_t *tvb, } /* Associate with this frame number */ - g_hash_table_insert(pdcp_lte_sequence_analysis_report_hash, + wmem_map_insert(pdcp_lte_sequence_analysis_report_hash, get_report_hash_key(sequenceNumber, pinfo->num, p_pdcp_lte_info, TRUE), p_report_in_frame); @@ -1026,7 +1026,7 @@ static guint pdcp_lte_ueid_hash_func(gconstpointer v) { return GPOINTER_TO_UINT(v); } -static GHashTable *pdcp_security_hash = NULL; +static wmem_map_t *pdcp_security_hash = NULL; /* Result is (ueid, framenum) -> pdcp_security_info_t* */ typedef struct ueid_frame_t { @@ -1068,7 +1068,7 @@ static guint pdcp_lte_ueid_frame_hash_func(gconstpointer v) const ueid_frame_t *ueid_frame = (const ueid_frame_t *)v; return ueid_frame->framenum + 100*ueid_frame->ueid; } -static GHashTable *pdcp_security_result_hash = NULL; +static wmem_map_t *pdcp_security_result_hash = NULL; @@ -1440,7 +1440,7 @@ void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_security_info_t *securi /* Create or update current settings, by UEID */ pdcp_security_info_t* ue_security = - (pdcp_security_info_t*)g_hash_table_lookup(pdcp_security_hash, + (pdcp_security_info_t*)wmem_map_lookup(pdcp_security_hash, GUINT_TO_POINTER((guint)ueid)); if (ue_security == NULL) { /* Copy whole security struct */ @@ -1448,7 +1448,7 @@ void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_security_info_t *securi *ue_security = *security_info; /* And add into security table */ - g_hash_table_insert(pdcp_security_hash, GUINT_TO_POINTER((guint)ueid), ue_security); + wmem_map_insert(pdcp_security_hash, GUINT_TO_POINTER((guint)ueid), ue_security); } else { /* Just update existing entry already in table */ @@ -1466,7 +1466,7 @@ void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_security_info_t *securi when we query it on the first pass. */ p_frame_security = wmem_new(wmem_file_scope(), pdcp_security_info_t); *p_frame_security = *ue_security; - g_hash_table_insert(pdcp_security_result_hash, + wmem_map_insert(pdcp_security_result_hash, get_ueid_frame_hash_key(ueid, ue_security->configuration_frame, TRUE), p_frame_security); } @@ -1476,7 +1476,7 @@ void set_pdcp_lte_security_algorithms_failed(guint16 ueid) { /* Look up current state by UEID */ pdcp_security_info_t* ue_security = - (pdcp_security_info_t*)g_hash_table_lookup(pdcp_security_hash, + (pdcp_security_info_t*)wmem_map_lookup(pdcp_security_hash, GUINT_TO_POINTER((guint)ueid)); if (ue_security != NULL) { /* TODO: could remove from table if previous_configuration_frame is 0 */ @@ -1806,14 +1806,14 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, /* UE security algorithms */ if (!pinfo->fd->flags.visited) { /* Look up current state by UEID */ - current_security = (pdcp_security_info_t*)g_hash_table_lookup(pdcp_security_hash, + current_security = (pdcp_security_info_t*)wmem_map_lookup(pdcp_security_hash, GUINT_TO_POINTER((guint)p_pdcp_info->ueid)); if (current_security != NULL) { /* Store any result for this frame in the result table */ pdcp_security_info_t *security_to_store = wmem_new(wmem_file_scope(), pdcp_security_info_t); /* Take a deep copy of the settings */ *security_to_store = *current_security; - g_hash_table_insert(pdcp_security_result_hash, + wmem_map_insert(pdcp_security_result_hash, get_ueid_frame_hash_key(p_pdcp_info->ueid, pinfo->num, TRUE), security_to_store); } @@ -1826,7 +1826,7 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, security_to_store->ciphering = global_default_ciphering_algorithm; security_to_store->integrity = global_default_integrity_algorithm; security_to_store->seen_next_ul_pdu = TRUE; - g_hash_table_insert(pdcp_security_result_hash, + wmem_map_insert(pdcp_security_result_hash, get_ueid_frame_hash_key(p_pdcp_info->ueid, pinfo->num, TRUE), security_to_store); } @@ -1834,7 +1834,7 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } /* Show security settings for this PDU */ - pdu_security = (pdcp_security_info_t*)g_hash_table_lookup(pdcp_security_result_hash, get_ueid_frame_hash_key(p_pdcp_info->ueid, pinfo->num, FALSE)); + pdu_security = (pdcp_security_info_t*)wmem_map_lookup(pdcp_security_result_hash, get_ueid_frame_hash_key(p_pdcp_info->ueid, pinfo->num, FALSE)); if (pdu_security != NULL) { proto_item *ti; @@ -2433,27 +2433,6 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, return tvb_captured_length(tvb); } -/* Initializes the hash tables each time a new - * file is loaded or re-loaded in wireshark */ -static void pdcp_lte_init_protocol(void) -{ - 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); - pdcp_security_result_hash = g_hash_table_new(pdcp_lte_ueid_frame_hash_func, pdcp_lte_ueid_frame_hash_equal); - 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) { @@ -2976,8 +2955,11 @@ void proto_register_pdcp(void) "N.B. only possible if build with algorithm support, and have key available and configured", &global_pdcp_check_integrity); - register_init_routine(&pdcp_lte_init_protocol); - register_cleanup_routine(&pdcp_lte_cleanup_protocol); + pdcp_sequence_analysis_channel_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal); + pdcp_lte_sequence_analysis_report_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pdcp_result_hash_func, pdcp_result_hash_equal); + pdcp_security_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pdcp_lte_ueid_hash_func, pdcp_lte_ueid_hash_equal); + pdcp_security_result_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pdcp_lte_ueid_frame_hash_func, pdcp_lte_ueid_frame_hash_equal); + pdcp_security_key_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pdcp_lte_ueid_hash_func, pdcp_lte_ueid_hash_equal); } void proto_reg_handoff_pdcp_lte(void) diff --git a/epan/dissectors/packet-pvfs2.c b/epan/dissectors/packet-pvfs2.c index e5b23ece35..ce327e0949 100644 --- a/epan/dissectors/packet-pvfs2.c +++ b/epan/dissectors/packet-pvfs2.c @@ -2874,7 +2874,7 @@ dissect_pvfs2_response(tvbuff_t *tvb, proto_tree *tree, int offset, return offset; } -static GHashTable *pvfs2_io_tracking_value_table = NULL; +static wmem_map_t *pvfs2_io_tracking_value_table = NULL; typedef struct pvfs2_io_tracking_key { @@ -2906,19 +2906,6 @@ pvfs2_io_tracking_hash(gconstpointer k) return (guint) ((key->tag >> 32) ^ ((guint32) key->tag)); } -static void -pvfs2_io_tracking_init(void) -{ - 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) { @@ -2930,7 +2917,7 @@ pvfs2_io_tracking_new_with_tag(guint64 tag, guint32 num) value = wmem_new0(wmem_file_scope(), pvfs2_io_tracking_value_t); - g_hash_table_insert(pvfs2_io_tracking_value_table, newkey, value); + wmem_map_insert(pvfs2_io_tracking_value_table, newkey, value); value->request_frame_num = num; @@ -2993,7 +2980,7 @@ dissect_pvfs_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, memset(&key, 0, sizeof(key)); key.tag = tag; - val = (pvfs2_io_tracking_value_t *)g_hash_table_lookup(pvfs2_io_tracking_value_table, &key); + val = (pvfs2_io_tracking_value_t *)wmem_map_lookup(pvfs2_io_tracking_value_table, &key); /* If this frame contains a known PVFS_SERV_IO tag, track it */ if (val && !pinfo->fd->flags.visited) @@ -3606,8 +3593,7 @@ proto_register_pvfs(void) expert_pvfs = expert_register_protocol(proto_pvfs); expert_register_field_array(expert_pvfs, ei, array_length(ei)); - register_init_routine(pvfs2_io_tracking_init); - register_cleanup_routine(pvfs2_io_tracking_cleanup); + pvfs2_io_tracking_value_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pvfs2_io_tracking_hash, pvfs2_io_tracking_equal); pvfs_module = prefs_register_protocol(proto_pvfs, NULL); prefs_register_bool_preference(pvfs_module, "desegment", diff --git a/epan/dissectors/packet-rlc-lte.c b/epan/dissectors/packet-rlc-lte.c index 296a081c67..3322eef328 100644 --- a/epan/dissectors/packet-rlc-lte.c +++ b/epan/dissectors/packet-rlc-lte.c @@ -415,7 +415,7 @@ typedef struct } channel_sequence_analysis_status; /* The sequence analysis channel hash table */ -static GHashTable *sequence_analysis_channel_hash = NULL; +static wmem_map_t *sequence_analysis_channel_hash = NULL; /* Types for sequence analysis frame report hash table */ @@ -446,7 +446,7 @@ typedef struct /* The sequence analysis frame report hash table instance itself */ -static GHashTable *sequence_analysis_report_hash = NULL; +static wmem_map_t *sequence_analysis_report_hash = NULL; static gpointer get_report_hash_key(guint16 SN, guint32 frameNumber, @@ -457,7 +457,7 @@ static gpointer get_report_hash_key(guint16 SN, guint32 frameNumber, /* The reassembly result hash table */ -static GHashTable *reassembly_report_hash = NULL; +static wmem_map_t *reassembly_report_hash = NULL; /* Create a new struct for reassembly */ @@ -505,7 +505,7 @@ static void reassembly_record(channel_sequence_analysis_status *status, packet_i guint16 SN, rlc_lte_info *p_rlc_lte_info) { /* Just store existing info in hash table */ - g_hash_table_insert(reassembly_report_hash, + wmem_map_insert(reassembly_report_hash, get_report_hash_key(SN, pinfo->num, p_rlc_lte_info, TRUE), status->reassembly_info); } @@ -621,7 +621,7 @@ typedef struct guint32 frameNum; } channel_repeated_nack_status; -static GHashTable *repeated_nack_channel_hash = NULL; +static wmem_map_t *repeated_nack_channel_hash = NULL; typedef struct { guint16 noOfNACKsRepeated; @@ -629,7 +629,7 @@ typedef struct { guint32 previousFrameNum; } channel_repeated_nack_report; -static GHashTable *repeated_nack_report_hash = NULL; +static wmem_map_t *repeated_nack_report_hash = NULL; @@ -1413,7 +1413,7 @@ static sequence_analysis_state checkChannelSequenceInfo(packet_info *pinfo, tvbu /* If find stat_report_in_frame already, use that and get out */ if (pinfo->fd->flags.visited) { - p_report_in_frame = (sequence_analysis_report*)g_hash_table_lookup(sequence_analysis_report_hash, + p_report_in_frame = (sequence_analysis_report*)wmem_map_lookup(sequence_analysis_report_hash, get_report_hash_key(sequenceNumber, pinfo->num, p_rlc_lte_info, @@ -1437,7 +1437,7 @@ static sequence_analysis_state checkChannelSequenceInfo(packet_info *pinfo, tvbu channel_key.direction = p_rlc_lte_info->direction; /* Do the table lookup */ - p_channel_status = (channel_sequence_analysis_status*)g_hash_table_lookup(sequence_analysis_channel_hash, &channel_key); + p_channel_status = (channel_sequence_analysis_status*)wmem_map_lookup(sequence_analysis_channel_hash, &channel_key); /* Create table entry if necessary */ if (p_channel_status == NULL) { @@ -1451,7 +1451,7 @@ static sequence_analysis_state checkChannelSequenceInfo(packet_info *pinfo, tvbu p_channel_status->rlcMode = p_rlc_lte_info->rlcMode; /* Add entry */ - g_hash_table_insert(sequence_analysis_channel_hash, p_channel_key, p_channel_status); + wmem_map_insert(sequence_analysis_channel_hash, p_channel_key, p_channel_status); } /* Create space for frame state_report */ @@ -1580,7 +1580,7 @@ static sequence_analysis_state checkChannelSequenceInfo(packet_info *pinfo, tvbu } /* Look up report for previous SN */ - p_previous_report = (sequence_analysis_report*)g_hash_table_lookup(sequence_analysis_report_hash, + p_previous_report = (sequence_analysis_report*)wmem_map_lookup(sequence_analysis_report_hash, get_report_hash_key((sequenceNumber+snLimit-1) % snLimit, p_report_in_frame->previousFrameNum, p_rlc_lte_info, @@ -1683,7 +1683,7 @@ static sequence_analysis_state checkChannelSequenceInfo(packet_info *pinfo, tvbu if (p_report_in_frame->previousFrameNum != 0) { /* Get report for previous frame */ sequence_analysis_report *p_previous_report; - p_previous_report = (sequence_analysis_report*)g_hash_table_lookup(sequence_analysis_report_hash, + p_previous_report = (sequence_analysis_report*)wmem_map_lookup(sequence_analysis_report_hash, get_report_hash_key((sequenceNumber+snLimit-1) % snLimit, p_report_in_frame->previousFrameNum, p_rlc_lte_info, @@ -1750,7 +1750,7 @@ static sequence_analysis_state checkChannelSequenceInfo(packet_info *pinfo, tvbu } /* Associate with this frame number */ - g_hash_table_insert(sequence_analysis_report_hash, + wmem_map_insert(sequence_analysis_report_hash, get_report_hash_key(sequenceNumber, pinfo->num, p_rlc_lte_info, TRUE), p_report_in_frame); @@ -1830,7 +1830,7 @@ static void checkChannelRepeatedNACKInfo(packet_info *pinfo, /* If find state_report_in_frame already, use that and get out */ if (pinfo->fd->flags.visited) { - p_report_in_frame = (channel_repeated_nack_report*)g_hash_table_lookup(repeated_nack_report_hash, + p_report_in_frame = (channel_repeated_nack_report*)wmem_map_lookup(repeated_nack_report_hash, get_report_hash_key(0, pinfo->num, p_rlc_lte_info, FALSE)); if (p_report_in_frame != NULL) { @@ -1854,7 +1854,7 @@ static void checkChannelRepeatedNACKInfo(packet_info *pinfo, memset(repeatedNACKs, 0, sizeof(repeatedNACKs)); /* Do the table lookup */ - p_channel_status = (channel_repeated_nack_status*)g_hash_table_lookup(repeated_nack_channel_hash, &channel_key); + p_channel_status = (channel_repeated_nack_status*)wmem_map_lookup(repeated_nack_channel_hash, &channel_key); /* Create table entry if necessary */ if (p_channel_status == NULL) { @@ -1867,7 +1867,7 @@ static void checkChannelRepeatedNACKInfo(packet_info *pinfo, memcpy(p_channel_key, &channel_key, sizeof(channel_hash_key)); /* Add entry to table */ - g_hash_table_insert(repeated_nack_channel_hash, p_channel_key, p_channel_status); + wmem_map_insert(repeated_nack_channel_hash, p_channel_key, p_channel_status); } /* Compare NACKs in channel status with NACKs in tap_info. @@ -1904,7 +1904,7 @@ static void checkChannelRepeatedNACKInfo(packet_info *pinfo, p_report_in_frame->previousFrameNum = p_channel_status->frameNum; /* Associate with this frame number */ - g_hash_table_insert(repeated_nack_report_hash, + wmem_map_insert(repeated_nack_report_hash, get_report_hash_key(0, pinfo->num, p_rlc_lte_info, TRUE), p_report_in_frame); @@ -1934,7 +1934,7 @@ static void checkChannelACKWindow(guint16 ack_sn, /* If find stat_report_in_frame already, use that and get out */ if (pinfo->fd->flags.visited) { - p_report_in_frame = (sequence_analysis_report*)g_hash_table_lookup(sequence_analysis_report_hash, + p_report_in_frame = (sequence_analysis_report*)wmem_map_lookup(sequence_analysis_report_hash, get_report_hash_key(0, pinfo->num, p_rlc_lte_info, FALSE)); @@ -1960,7 +1960,7 @@ static void checkChannelACKWindow(guint16 ack_sn, (p_rlc_lte_info->direction == DIRECTION_UPLINK) ? DIRECTION_DOWNLINK : DIRECTION_UPLINK; /* Do the table lookup */ - p_channel_status = (channel_sequence_analysis_status*)g_hash_table_lookup(sequence_analysis_channel_hash, &channel_key); + p_channel_status = (channel_sequence_analysis_status*)wmem_map_lookup(sequence_analysis_channel_hash, &channel_key); /* Create table entry if necessary */ if (p_channel_status == NULL) { @@ -1980,7 +1980,7 @@ static void checkChannelACKWindow(guint16 ack_sn, p_report_in_frame->firstSN = ack_sn; /* Associate with this frame number */ - g_hash_table_insert(sequence_analysis_report_hash, + wmem_map_insert(sequence_analysis_report_hash, get_report_hash_key(0, pinfo->num, p_rlc_lte_info, TRUE), p_report_in_frame); @@ -2247,7 +2247,7 @@ static void dissect_rlc_lte_um(tvbuff_t *tvb, packet_info *pinfo, /*************************************/ /* Data */ - reassembly_info = (rlc_channel_reassembly_info *)g_hash_table_lookup(reassembly_report_hash, + reassembly_info = (rlc_channel_reassembly_info *)wmem_map_lookup(reassembly_report_hash, get_report_hash_key((guint16)sn, pinfo->num, p_rlc_lte_info, FALSE)); @@ -2700,7 +2700,7 @@ static void dissect_rlc_lte_am(tvbuff_t *tvb, packet_info *pinfo, /* Data */ if (!first_includes_start) { - reassembly_info = (rlc_channel_reassembly_info *)g_hash_table_lookup(reassembly_report_hash, + reassembly_info = (rlc_channel_reassembly_info *)wmem_map_lookup(reassembly_report_hash, get_report_hash_key((guint16)sn, pinfo->num, p_rlc_lte_info, @@ -3043,26 +3043,6 @@ static void dissect_rlc_lte_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree -/* Initializes the hash tables each time a new - * file is loaded or re-loaded in wireshark */ -static void rlc_lte_init_protocol(void) -{ - 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) @@ -3695,8 +3675,11 @@ 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); + sequence_analysis_channel_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), rlc_channel_hash_func, rlc_channel_equal); + sequence_analysis_report_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), rlc_result_hash_func, rlc_result_hash_equal); + repeated_nack_channel_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), rlc_channel_hash_func, rlc_channel_equal); + repeated_nack_report_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), rlc_result_hash_func, rlc_result_hash_equal); + reassembly_report_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), rlc_result_hash_func, rlc_result_hash_equal); } void proto_reg_handoff_rlc_lte(void) diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c index 5b64237e69..bbda7d561b 100644 --- a/epan/dissectors/packet-rpc.c +++ b/epan/dissectors/packet-rpc.c @@ -3072,7 +3072,7 @@ static reassembly_table rpc_fragment_table; * so that they don't try to combine fragments from different TCP * connections.) */ -static GHashTable *rpc_reassembly_table = NULL; +static wmem_map_t *rpc_reassembly_table = NULL; typedef struct _rpc_fragment_key { guint32 conv_id; @@ -3408,7 +3408,7 @@ dissect_rpc_fragment(tvbuff_t *tvb, int offset, packet_info *pinfo, old_rfk.conv_id = conversation->conv_index; old_rfk.seq = seq; old_rfk.port = pinfo->srcport; - rfk = (rpc_fragment_key *)g_hash_table_lookup(rpc_reassembly_table, &old_rfk); + rfk = (rpc_fragment_key *)wmem_map_lookup(rpc_reassembly_table, &old_rfk); if (rfk == NULL) { /* @@ -3451,7 +3451,7 @@ dissect_rpc_fragment(tvbuff_t *tvb, int offset, packet_info *pinfo, rfk->port = pinfo->srcport; rfk->offset = 0; rfk->start_seq = seq; - g_hash_table_insert(rpc_reassembly_table, rfk, rfk); + wmem_map_insert(rpc_reassembly_table, rfk, rfk); /* * Start defragmentation. @@ -3474,7 +3474,7 @@ dissect_rpc_fragment(tvbuff_t *tvb, int offset, packet_info *pinfo, new_rfk->port = pinfo->srcport; new_rfk->offset = rfk->offset + len - 4; new_rfk->start_seq = rfk->start_seq; - g_hash_table_insert(rpc_reassembly_table, new_rfk, + wmem_map_insert(rpc_reassembly_table, new_rfk, new_rfk); /* @@ -3542,7 +3542,7 @@ dissect_rpc_fragment(tvbuff_t *tvb, int offset, packet_info *pinfo, new_rfk->port = pinfo->srcport; new_rfk->offset = rfk->offset + len - 4; new_rfk->start_seq = rfk->start_seq; - g_hash_table_insert(rpc_reassembly_table, new_rfk, + wmem_map_insert(rpc_reassembly_table, new_rfk, new_rfk); /* @@ -3911,20 +3911,6 @@ dissect_rpc_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) return tvb_reported_length(tvb); } -/* Discard any state we've saved. */ -static void -rpc_init_protocol(void) -{ - rpc_reassembly_table = g_hash_table_new(rpc_fragment_hash, - rpc_fragment_equal); -} - -static void -rpc_cleanup_protocol(void) -{ - g_hash_table_destroy(rpc_reassembly_table); -} - /* Tap statistics */ typedef enum { @@ -4370,8 +4356,8 @@ proto_register_rpc(void) proto_register_subtree_array(ett, array_length(ett)); 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_reassembly_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), rpc_fragment_hash, rpc_fragment_equal); reassembly_table_register(&rpc_fragment_table, &addresses_ports_reassembly_table_functions); diff --git a/epan/dissectors/packet-rsvp.c b/epan/dissectors/packet-rsvp.c index 1bfc58a09c..e459facee0 100644 --- a/epan/dissectors/packet-rsvp.c +++ b/epan/dissectors/packet-rsvp.c @@ -669,7 +669,7 @@ struct rsvp_request_val { /* * Initialize the conversation related data structures. */ -static GHashTable *rsvp_request_hash = NULL; +static wmem_map_t *rsvp_request_hash = NULL; /* * The list of tree types @@ -1975,23 +1975,6 @@ rsvp_hash(gconstpointer k) return key->conversation; } -/* - * Conversation specific initialization code that deletes any unused memory that - * might need to be freed, and allocates the memory for the various conversation - * hash tables. - */ -static void -rsvp_init_protocol(void) -{ - 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)) @@ -7495,7 +7478,7 @@ dissect_rsvp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolea /* See if a request with this key already exists */ request_val = - (struct rsvp_request_val *) g_hash_table_lookup(rsvp_request_hash, + (struct rsvp_request_val *) wmem_map_lookup(rsvp_request_hash, &request_key); /* If not, insert the new request key into the hash table */ @@ -7531,7 +7514,7 @@ dissect_rsvp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolea request_val = wmem_new(wmem_file_scope(), struct rsvp_request_val); request_val->value = conversation->conv_index; - g_hash_table_insert(rsvp_request_hash, new_request_key, request_val); + wmem_map_insert(rsvp_request_hash, new_request_key, request_val); } tap_queue_packet(rsvp_tap, pinfo, rsvph); @@ -9535,9 +9518,7 @@ proto_register_rsvp(void) expert_register_field_array(expert_rsvp, ei, array_length(ei)); register_rsvp_prefs(); - /* Initialization routine for RSVP conversations */ - register_init_routine(&rsvp_init_protocol); - register_cleanup_routine(&rsvp_cleanup_protocol); + rsvp_request_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), rsvp_hash, rsvp_equal); register_conversation_table(proto_rsvp, TRUE, rsvp_conversation_packet, rsvp_hostlist_packet); } diff --git a/epan/dissectors/packet-sbus.c b/epan/dissectors/packet-sbus.c index a81abd7f45..305aa5f5f3 100644 --- a/epan/dissectors/packet-sbus.c +++ b/epan/dissectors/packet-sbus.c @@ -558,7 +558,7 @@ typedef struct { } sbus_request_val; /* The hash structure (for conversations)*/ -static GHashTable *sbus_request_hash = NULL; +static wmem_map_t *sbus_request_hash = NULL; static guint crc_calc (guint crc, guint val) { @@ -593,15 +593,6 @@ static guint sbus_hash(gconstpointer v) return val; } -/*Protocol initialisation*/ -static void sbus_init_protocol(void){ - 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) @@ -703,7 +694,7 @@ dissect_sbus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ request_key.conversation = conversation->conv_index; request_key.sequence = tvb_get_ntohs(tvb,6); - request_val = (sbus_request_val *) g_hash_table_lookup(sbus_request_hash, + request_val = (sbus_request_val *) wmem_map_lookup(sbus_request_hash, &request_key); /*Get type of telegram for finding retries *As we are storing the info in a hash table we need to update the info @@ -756,7 +747,7 @@ dissect_sbus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ request_val->block_tlg = 0x0; } - g_hash_table_insert(sbus_request_hash, new_request_key, request_val); + wmem_map_insert(sbus_request_hash, new_request_key, request_val); } /* End of attaching data to hash table*/ @@ -2306,8 +2297,7 @@ proto_register_sbus(void) proto_register_subtree_array(ett, array_length(ett)); 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); + sbus_request_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), sbus_hash, sbus_equal); } void |