aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-dcerpc.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-02-01 23:13:42 -0500
committerMichael Mann <mmann78@netscape.net>2017-02-02 13:46:03 +0000
commit577d21e35c1ca19e245014ea2b65d09709c9cca3 (patch)
tree91d63807f33f05a4970b9fe769dbec7040b904e0 /epan/dissectors/packet-dcerpc.c
parent36892d8a4ca2f6019dc00b0f2540097499da2e11 (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/dissectors/packet-dcerpc.c')
-rw-r--r--epan/dissectors/packet-dcerpc.c92
1 files changed, 39 insertions, 53 deletions
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",