diff options
author | Michael Mann <mmann78@netscape.net> | 2017-01-28 22:29:32 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-01-30 02:25:24 +0000 |
commit | 9365fd3d3a4cdac07d70bd77f7a42f3260b33b5e (patch) | |
tree | 934046830769d5f32b51cabd240e3ed40e07a217 /epan/dissectors/asn1 | |
parent | 984d78da13608b7cba3cd8144d1285b33277b0d3 (diff) |
Convert GHashTable -> wmem_map_t for ASN.1 disseectors
Change-Id: Id749c41947c6300f2c82ed947352c336f9e45b72
Reviewed-on: https://code.wireshark.org/review/19838
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/asn1')
-rw-r--r-- | epan/dissectors/asn1/acse/packet-acse-template.c | 27 | ||||
-rw-r--r-- | epan/dissectors/asn1/ansi_map/packet-ansi_map-template.c | 24 | ||||
-rw-r--r-- | epan/dissectors/asn1/ansi_tcap/packet-ansi_tcap-template.c | 24 | ||||
-rw-r--r-- | epan/dissectors/asn1/camel/packet-camel-template.c | 24 | ||||
-rw-r--r-- | epan/dissectors/asn1/h225/packet-h225-template.c | 44 | ||||
-rw-r--r-- | epan/dissectors/asn1/h245/h245.cnf | 10 | ||||
-rw-r--r-- | epan/dissectors/asn1/h245/packet-h245-template.c | 32 | ||||
-rw-r--r-- | epan/dissectors/asn1/lte-rrc/lte-rrc.cnf | 12 | ||||
-rw-r--r-- | epan/dissectors/asn1/lte-rrc/packet-lte-rrc-template.c | 22 | ||||
-rw-r--r-- | epan/dissectors/asn1/pres/packet-pres-template.c | 27 | ||||
-rw-r--r-- | epan/dissectors/asn1/ros/packet-ros-template.c | 79 | ||||
-rw-r--r-- | epan/dissectors/asn1/rtse/packet-rtse-template.c | 7 |
12 files changed, 92 insertions, 240 deletions
diff --git a/epan/dissectors/asn1/acse/packet-acse-template.c b/epan/dissectors/asn1/acse/packet-acse-template.c index f783b87061..02adb4e98e 100644 --- a/epan/dissectors/asn1/acse/packet-acse-template.c +++ b/epan/dissectors/asn1/acse/packet-acse-template.c @@ -90,7 +90,7 @@ typedef struct _acse_ctx_oid_t { guint32 ctx_id; char *oid; } acse_ctx_oid_t; -static GHashTable *acse_ctx_oid_table = NULL; +static wmem_map_t *acse_ctx_oid_table = NULL; static guint acse_ctx_oid_hash(gconstpointer k) @@ -108,18 +108,6 @@ acse_ctx_oid_equal(gconstpointer k1, gconstpointer k2) } static void -acse_init(void) -{ - if (acse_ctx_oid_table) { - g_hash_table_destroy(acse_ctx_oid_table); - acse_ctx_oid_table = NULL; - } - acse_ctx_oid_table = g_hash_table_new(acse_ctx_oid_hash, - acse_ctx_oid_equal); - -} - -static void register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, char *oid) { acse_ctx_oid_t *aco, *tmpaco; @@ -128,18 +116,18 @@ register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, char *oid) aco->oid=wmem_strdup(wmem_file_scope(), oid); /* if this ctx already exists, remove the old one first */ - tmpaco=(acse_ctx_oid_t *)g_hash_table_lookup(acse_ctx_oid_table, aco); + tmpaco=(acse_ctx_oid_t *)wmem_map_lookup(acse_ctx_oid_table, aco); if (tmpaco) { - g_hash_table_remove(acse_ctx_oid_table, tmpaco); + wmem_map_remove(acse_ctx_oid_table, tmpaco); } - g_hash_table_insert(acse_ctx_oid_table, aco, aco); + wmem_map_insert(acse_ctx_oid_table, aco, aco); } static char * find_oid_by_ctx_id(packet_info *pinfo _U_, guint32 idx) { acse_ctx_oid_t aco, *tmpaco; aco.ctx_id=idx; - tmpaco=(acse_ctx_oid_t *)g_hash_table_lookup(acse_ctx_oid_table, &aco); + tmpaco=(acse_ctx_oid_t *)wmem_map_lookup(acse_ctx_oid_table, &aco); if (tmpaco) { return tmpaco->oid; } @@ -294,6 +282,11 @@ void proto_register_acse(void) { proto_register_subtree_array(ett, array_length(ett)); expert_acse = expert_register_protocol(proto_acse); expert_register_field_array(expert_acse, ei, array_length(ei)); + +#if NOT_NEEDED + acse_ctx_oid_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), acse_ctx_oid_hash, + acse_ctx_oid_equal); +#endif } diff --git a/epan/dissectors/asn1/ansi_map/packet-ansi_map-template.c b/epan/dissectors/asn1/ansi_map/packet-ansi_map-template.c index 09947f8c31..67f43eae93 100644 --- a/epan/dissectors/asn1/ansi_map/packet-ansi_map-template.c +++ b/epan/dissectors/asn1/ansi_map/packet-ansi_map-template.c @@ -387,20 +387,7 @@ static void dissect_ansi_map_win_trigger_list(tvbuff_t *tvb, packet_info *pinfo /* Transaction table */ -static GHashTable *TransactionId_table=NULL; - -static void -ansi_map_init(void) -{ - TransactionId_table = g_hash_table_new(g_str_hash, g_str_equal); -} - -static void -ansi_map_cleanup(void) -{ - /* Destroy any existing memory chunks / hashes. */ - g_hash_table_destroy(TransactionId_table); -} +static wmem_map_t *TransactionId_table=NULL; /* Store Invoke information needed for the corresponding reply */ static void @@ -432,7 +419,7 @@ update_saved_invokedata(packet_info *pinfo, struct ansi_tcap_private_t *p_privat break; } /* If the entry allready exists don't owervrite it */ - ansi_map_saved_invokedata = (struct ansi_map_invokedata_t *)g_hash_table_lookup(TransactionId_table,buf); + ansi_map_saved_invokedata = (struct ansi_map_invokedata_t *)wmem_map_lookup(TransactionId_table,buf); if(ansi_map_saved_invokedata) return; @@ -440,7 +427,7 @@ update_saved_invokedata(packet_info *pinfo, struct ansi_tcap_private_t *p_privat ansi_map_saved_invokedata->opcode = p_private_tcap->d.OperationCode_private; ansi_map_saved_invokedata->ServiceIndicator = ServiceIndicator; - g_hash_table_insert(TransactionId_table, + wmem_map_insert(TransactionId_table, wmem_strdup(wmem_file_scope(), buf), ansi_map_saved_invokedata); @@ -4363,7 +4350,7 @@ find_saved_invokedata(asn1_ctx_t *actx, struct ansi_tcap_private_t *p_private_tc } /*g_warning("Find Hash string %s pkt: %u",buf,actx->pinfo->num);*/ - ansi_map_saved_invokedata = (struct ansi_map_invokedata_t *)g_hash_table_lookup(TransactionId_table, buf); + ansi_map_saved_invokedata = (struct ansi_map_invokedata_t *)wmem_map_lookup(TransactionId_table, buf); if(ansi_map_saved_invokedata){ OperationCode = ansi_map_saved_invokedata->opcode & 0xff; ServiceIndicator = ansi_map_saved_invokedata->ServiceIndicator; @@ -5499,8 +5486,7 @@ void proto_register_ansi_map(void) { "Type of matching invoke/response, risk of mismatch if loose matching chosen", &ansi_map_response_matching_type, ansi_map_response_matching_type_values, FALSE); - register_init_routine(&ansi_map_init); - register_cleanup_routine(&ansi_map_cleanup); + TransactionId_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), wmem_str_hash, g_str_equal); register_stat_tap_table_ui(&stat_table); } diff --git a/epan/dissectors/asn1/ansi_tcap/packet-ansi_tcap-template.c b/epan/dissectors/asn1/ansi_tcap/packet-ansi_tcap-template.c index 7721b91305..4d65674aa4 100644 --- a/epan/dissectors/asn1/ansi_tcap/packet-ansi_tcap-template.c +++ b/epan/dissectors/asn1/ansi_tcap/packet-ansi_tcap-template.c @@ -146,20 +146,7 @@ struct ansi_tcap_invokedata_t { gint32 OperationCode_national; }; -static GHashTable *TransactionId_table=NULL; - -static void -ansi_tcap_init(void) -{ - TransactionId_table = g_hash_table_new(g_str_hash, g_str_equal); -} - -static void -ansi_tcap_cleanup(void) -{ - /* Destroy any existing memory chunks / hashes. */ - g_hash_table_destroy(TransactionId_table); -} +static wmem_map_t *TransactionId_table=NULL; /* Store Invoke information needed for the corresponding reply */ static void @@ -189,7 +176,7 @@ save_invoke_data(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U_){ } /* If the entry allready exists don't owervrite it */ - ansi_tcap_saved_invokedata = (struct ansi_tcap_invokedata_t *)g_hash_table_lookup(TransactionId_table,buf); + ansi_tcap_saved_invokedata = (struct ansi_tcap_invokedata_t *)wmem_map_lookup(TransactionId_table,buf); if(ansi_tcap_saved_invokedata) return; @@ -198,7 +185,7 @@ save_invoke_data(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U_){ ansi_tcap_saved_invokedata->OperationCode_national = ansi_tcap_private.d.OperationCode_national; ansi_tcap_saved_invokedata->OperationCode_private = ansi_tcap_private.d.OperationCode_private; - g_hash_table_insert(TransactionId_table, + wmem_map_insert(TransactionId_table, wmem_strdup(wmem_file_scope(), buf), ansi_tcap_saved_invokedata); /* @@ -237,7 +224,7 @@ find_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U break; } - ansi_tcap_saved_invokedata = (struct ansi_tcap_invokedata_t *)g_hash_table_lookup(TransactionId_table, buf); + ansi_tcap_saved_invokedata = (struct ansi_tcap_invokedata_t *)wmem_map_lookup(TransactionId_table, buf); if(ansi_tcap_saved_invokedata){ ansi_tcap_private.d.OperationCode = ansi_tcap_saved_invokedata->OperationCode; ansi_tcap_private.d.OperationCode_national = ansi_tcap_saved_invokedata->OperationCode_national; @@ -508,6 +495,5 @@ proto_register_ansi_tcap(void) "Type of matching invoke/response, risk of mismatch if loose matching chosen", &ansi_tcap_response_matching_type, ansi_tcap_response_matching_type_values, FALSE); - register_init_routine(&ansi_tcap_init); - register_cleanup_routine(&ansi_tcap_cleanup); + TransactionId_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), wmem_str_hash, g_str_equal); } diff --git a/epan/dissectors/asn1/camel/packet-camel-template.c b/epan/dissectors/asn1/camel/packet-camel-template.c index 78df8f9bc3..bc463d59e7 100644 --- a/epan/dissectors/asn1/camel/packet-camel-template.c +++ b/epan/dissectors/asn1/camel/packet-camel-template.c @@ -165,7 +165,7 @@ const char *camel_obj_id = NULL; gboolean is_ExtensionField =FALSE; /* Global hash tables*/ -static GHashTable *srt_calls = NULL; +static wmem_map_t *srt_calls = NULL; static guint32 camelsrt_global_SessionId=1; static int camel_opcode_type; @@ -441,7 +441,7 @@ static struct camelsrt_call_t * find_camelsrt_call(struct camelsrt_call_info_key_t *p_camelsrt_call_key) { struct camelsrt_call_t *p_camelsrt_call = NULL; - p_camelsrt_call = (struct camelsrt_call_t *)g_hash_table_lookup(srt_calls, p_camelsrt_call_key); + p_camelsrt_call = (struct camelsrt_call_t *)wmem_map_lookup(srt_calls, p_camelsrt_call_key); #ifdef DEBUG_CAMELSRT if(p_camelsrt_call) { @@ -486,7 +486,7 @@ new_camelsrt_call(struct camelsrt_call_info_key_t *p_camelsrt_call_key) dbg(10,"D%d ", p_new_camelsrt_call->session_id); #endif /* store it */ - g_hash_table_insert(srt_calls, p_new_camelsrt_call_key, p_new_camelsrt_call); + wmem_map_insert(srt_calls, p_new_camelsrt_call_key, p_new_camelsrt_call); return p_new_camelsrt_call; } @@ -497,8 +497,6 @@ new_camelsrt_call(struct camelsrt_call_info_key_t *p_camelsrt_call_key) static void camelsrt_init_routine(void) { - /* create new hash-table for SRT */ - srt_calls = g_hash_table_new(camelsrt_call_hash, camelsrt_call_equal); /* Reset the session counter */ camelsrt_global_SessionId=1; @@ -509,13 +507,6 @@ camelsrt_init_routine(void) gcamel_DisplaySRT=gcamel_PersistentSRT || gcamel_HandleSRT&gcamel_StatSRT; } -static void -camelsrt_cleanup_routine(void) -{ - /* free hash-table for SRT */ - g_hash_table_destroy(srt_calls); -} - /* * Update a record with the data of the Request @@ -566,7 +557,7 @@ camelsrt_close_call_matching(packet_info *pinfo, p_camelsrt_info->msginfo[CAMELSRT_SESSION].req_time = p_camelsrt_call->category[CAMELSRT_SESSION].req_time; if ( !gcamel_PersistentSRT ) { - g_hash_table_remove(srt_calls, &camelsrt_call_key); + wmem_map_remove(srt_calls, &camelsrt_call_key); #ifdef DEBUG_CAMELSRT dbg(20,"remove hash "); #endif @@ -629,7 +620,7 @@ camelsrt_begin_call_matching(packet_info *pinfo, dbg(10,"\n Session begin #%u\n", pinfo->num); dbg(11,"Search key %lu ",camelsrt_call_key.SessionIdKey); #endif - p_camelsrt_call = (struct camelsrt_call_t *)g_hash_table_lookup(srt_calls, &camelsrt_call_key); + p_camelsrt_call = (struct camelsrt_call_t *)wmem_map_lookup(srt_calls, &camelsrt_call_key); if (p_camelsrt_call) { /* We have seen this request before -> do nothing */ #ifdef DEBUG_CAMELSRT @@ -1598,7 +1589,10 @@ void proto_register_camel(void) { /* Routine for statistic */ register_init_routine(&camelsrt_init_routine); - register_cleanup_routine(&camelsrt_cleanup_routine); + + /* create new hash-table for SRT */ + srt_calls = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), camelsrt_call_hash, camelsrt_call_equal); + camel_tap=register_tap(PSNAME); register_srt_table(proto_camel, PSNAME, 1, camelstat_packet, camelstat_init, NULL); diff --git a/epan/dissectors/asn1/h225/packet-h225-template.c b/epan/dissectors/asn1/h225/packet-h225-template.c index c037ed3d5c..8b859e3f6c 100644 --- a/epan/dissectors/asn1/h225/packet-h225-template.c +++ b/epan/dissectors/asn1/h225/packet-h225-template.c @@ -63,7 +63,6 @@ void proto_register_h225(void); static h225_packet_info* create_h225_packet_info(packet_info *pinfo); -static void h225_init_routine(void); static void ras_call_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, h225_packet_info *pi); /* Item of ras request list*/ @@ -86,7 +85,7 @@ typedef struct _h225ras_call_info_key { /* Global Memory Chunks for lists and Global hash tables*/ -static GHashTable *ras_calls[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +static wmem_map_t *ras_calls[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; /* functions, needed using ras-request and halfcall matching*/ static h225ras_call_t * find_h225ras_call(h225ras_call_info_key *h225ras_call_key ,int category); @@ -275,8 +274,7 @@ static guint h225ras_call_hash(gconstpointer k) h225ras_call_t * find_h225ras_call(h225ras_call_info_key *h225ras_call_key ,int category) { - h225ras_call_t *h225ras_call = NULL; - h225ras_call = (h225ras_call_t *)g_hash_table_lookup(ras_calls[category], h225ras_call_key); + h225ras_call_t *h225ras_call = (h225ras_call_t *)wmem_map_lookup(ras_calls[category], h225ras_call_key); return h225ras_call; } @@ -304,7 +302,7 @@ h225ras_call_t * new_h225ras_call(h225ras_call_info_key *h225ras_call_key, packe h225ras_call->req_time=pinfo->abs_ts; h225ras_call->guid=*guid; /* store it */ - g_hash_table_insert(ras_calls[category], new_h225ras_call_key, h225ras_call); + wmem_map_insert(ras_calls[category], new_h225ras_call_key, h225ras_call); return h225ras_call; } @@ -331,34 +329,6 @@ h225ras_call_t * append_h225ras_call(h225ras_call_t *prev_call, packet_info *pin return h225ras_call; } -/* Init routine for hash tables and delay calculation - This routine will be called by Wireshark, before it - is (re-)dissecting a trace file from beginning. - We need to discard and init any state we've saved */ - -static void -h225_init_routine(void) -{ - int i; - /* create new hash-tables for RAS SRT */ - - for(i=0;i<7;i++) { - ras_calls[i] = g_hash_table_new(h225ras_call_hash, h225ras_call_equal); - } - -} - -static void -h225_cleanup_routine(void) -{ - int i; - - /* free hash-tables for RAS SRT */ - for(i=0;i<7;i++) { - g_hash_table_destroy(ras_calls[i]); - } -} - static int dissect_h225_H323UserInformation(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { @@ -868,7 +838,7 @@ void proto_register_h225(void) { }; module_t *h225_module; - int proto_h225_ras; + int i, proto_h225_ras; /* Register protocol */ proto_h225 = proto_register_protocol(PNAME, PSNAME, PFNAME); @@ -909,8 +879,10 @@ void proto_register_h225(void) { gef_name_dissector_table = register_dissector_table("h225.gef.name", "H.225 Generic Extensible Framework (names)", proto_h225, FT_STRING, BASE_NONE); gef_content_dissector_table = register_dissector_table("h225.gef.content", "H.225 Generic Extensible Framework", proto_h225, FT_STRING, BASE_NONE); - register_init_routine(&h225_init_routine); - register_cleanup_routine(&h225_cleanup_routine); + for(i=0;i<7;i++) { + ras_calls[i] = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), h225ras_call_hash, h225ras_call_equal); + } + h225_tap = register_tap(PFNAME); register_rtd_table(proto_h225_ras, PFNAME, NUM_RAS_STATS, 1, ras_message_category, h225rassrt_packet, NULL); diff --git a/epan/dissectors/asn1/h245/h245.cnf b/epan/dissectors/asn1/h245/h245.cnf index 1d8f3e4595..24b870734b 100644 --- a/epan/dissectors/asn1/h245/h245.cnf +++ b/epan/dissectors/asn1/h245/h245.cnf @@ -141,14 +141,14 @@ Rfc2733Format FECCapability/rfc2733Format FECMode/rfc2733Format pending->rev_channel_params = h223_rev_lc_params; temp = h223_fw_lc_num; if (%(ACTX)s->pinfo->p2p_dir > -1) - g_hash_table_insert(h223_pending_olc_reqs[%(ACTX)s->pinfo->p2p_dir], GINT_TO_POINTER(temp), pending); + wmem_map_insert(h223_pending_olc_reqs[%(ACTX)s->pinfo->p2p_dir], GINT_TO_POINTER(temp), pending); } if (upcoming_olc) { if (fast_start) { h245_setup_channels(actx->pinfo, &upcoming_olc->rev_lc); } else { - g_hash_table_insert(h245_pending_olc_reqs, + wmem_map_insert(h245_pending_olc_reqs, wmem_strdup(wmem_file_scope(), gen_olc_key(upcoming_olc->fwd_lc_num, &%(ACTX)s->pinfo->dst, &%(ACTX)s->pinfo->src)), upcoming_olc); } @@ -235,7 +235,7 @@ Rfc2733Format FECCapability/rfc2733Format FECMode/rfc2733Format %(ACTX)s->pinfo->p2p_dir = P2P_DIR_RECV; else %(ACTX)s->pinfo->p2p_dir = P2P_DIR_SENT; - pend = (h223_pending_olc *)g_hash_table_lookup( h223_pending_olc_reqs[%(ACTX)s->pinfo->p2p_dir], GINT_TO_POINTER(temp) ); + pend = (h223_pending_olc *)wmem_map_lookup( h223_pending_olc_reqs[%(ACTX)s->pinfo->p2p_dir], GINT_TO_POINTER(temp) ); if (pend) { DISSECTOR_ASSERT( ( h223_rev_lc_num && pend->rev_channel_params) || (!h223_rev_lc_num && !pend->rev_channel_params) ); @@ -251,7 +251,7 @@ Rfc2733Format FECCapability/rfc2733Format FECMode/rfc2733Format if (upcoming_olc) { olc_key = gen_olc_key(upcoming_olc->fwd_lc_num, &%(ACTX)s->pinfo->src, &%(ACTX)s->pinfo->dst); - olc_req = (olc_info_t *)g_hash_table_lookup(h245_pending_olc_reqs, olc_key); + olc_req = (olc_info_t *)wmem_map_lookup(h245_pending_olc_reqs, olc_key); if (olc_req) { update_unicast_addr(&olc_req->fwd_lc.media_addr, &upcoming_olc->fwd_lc.media_addr); update_unicast_addr(&olc_req->fwd_lc.media_control_addr, &upcoming_olc->fwd_lc.media_control_addr); @@ -259,7 +259,7 @@ Rfc2733Format FECCapability/rfc2733Format FECMode/rfc2733Format update_unicast_addr(&olc_req->rev_lc.media_control_addr, &upcoming_olc->rev_lc.media_control_addr); h245_setup_channels(actx->pinfo, &olc_req->fwd_lc); h245_setup_channels(actx->pinfo, &olc_req->rev_lc); - g_hash_table_remove(h245_pending_olc_reqs, olc_key); + wmem_map_remove(h245_pending_olc_reqs, olc_key); } else { h245_setup_channels(actx->pinfo, &upcoming_olc->fwd_lc); } diff --git a/epan/dissectors/asn1/h245/packet-h245-template.c b/epan/dissectors/asn1/h245/packet-h245-template.c index 801b9d1126..573ff89b7b 100644 --- a/epan/dissectors/asn1/h245/packet-h245-template.c +++ b/epan/dissectors/asn1/h245/packet-h245-template.c @@ -232,7 +232,7 @@ typedef struct _olc_info_t { channel_info_t rev_lc; } olc_info_t; -static GHashTable* h245_pending_olc_reqs = NULL; +static wmem_map_t* h245_pending_olc_reqs = NULL; static gboolean fast_start = FALSE; static olc_info_t *upcoming_olc = NULL; static channel_info_t *upcoming_channel = NULL; @@ -281,7 +281,7 @@ typedef struct { h223_lc_params *rev_channel_params; } h223_pending_olc; -static GHashTable* h223_pending_olc_reqs[] = { NULL, NULL }; +static wmem_map_t* h223_pending_olc_reqs[] = { NULL, NULL }; static dissector_handle_t h245_lc_dissector; static guint16 h245_lc_temp; static guint16 h223_fw_lc_num; @@ -291,34 +291,13 @@ static h223_lc_params *h223_fw_lc_params; static h223_lc_params *h223_rev_lc_params; static h223_add_lc_handle_t h223_add_lc_handle = NULL; -static void h223_lc_init_dir( int dir ) -{ - if ( h223_pending_olc_reqs[dir] ) - g_hash_table_destroy( h223_pending_olc_reqs[dir] ); - h223_pending_olc_reqs[dir] = g_hash_table_new( g_direct_hash, g_direct_equal ); -} - static void h223_lc_init( void ) { - h223_lc_init_dir( P2P_DIR_SENT ); - h223_lc_init_dir( P2P_DIR_RECV ); h223_lc_params_temp = NULL; h245_lc_dissector = NULL; h223_fw_lc_num = 0; } -static void h245_init(void) -{ - h245_pending_olc_reqs = g_hash_table_new(g_str_hash, g_str_equal); - - h223_lc_init(); -} - -static void h245_cleanup(void) -{ - g_hash_table_destroy(h245_pending_olc_reqs); -} - void h245_set_h223_add_lc_handle( h223_add_lc_handle_t handle ) { h223_add_lc_handle = handle; @@ -517,8 +496,11 @@ void proto_register_h245(void) { /* Register protocol */ proto_h245 = proto_register_protocol(PNAME, PSNAME, PFNAME); - register_init_routine(h245_init); - register_cleanup_routine(h245_cleanup); + h223_pending_olc_reqs[P2P_DIR_SENT] = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal ); + h223_pending_olc_reqs[P2P_DIR_RECV] = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal ); + h245_pending_olc_reqs = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), wmem_str_hash, g_str_equal); + + register_init_routine(h223_lc_init); /* Register fields and subtrees */ proto_register_field_array(proto_h245, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); diff --git a/epan/dissectors/asn1/lte-rrc/lte-rrc.cnf b/epan/dissectors/asn1/lte-rrc/lte-rrc.cnf index b666535e6c..fd23e33bbd 100644 --- a/epan/dissectors/asn1/lte-rrc/lte-rrc.cnf +++ b/epan/dissectors/asn1/lte-rrc/lte-rrc.cnf @@ -748,7 +748,7 @@ SystemInformationBlockType11/messageIdentifier TYPE=FT_UINT16 DISPLAY=BASE_DEC|B guint32 dataCodingScheme; subtree = proto_item_add_subtree(actx->created_item, ett_lte_rrc_dataCodingScheme); dataCodingScheme = dissect_cbs_data_coding_scheme(data_coding_scheme_tvb, actx->pinfo, subtree, 0); - g_hash_table_insert(lte_rrc_etws_cmas_dcs_hash, GUINT_TO_POINTER((guint)private_data_get_message_identifier(actx)), + wmem_map_insert(lte_rrc_etws_cmas_dcs_hash, GUINT_TO_POINTER((guint)private_data_get_message_identifier(actx)), GUINT_TO_POINTER(dataCodingScheme)); } @@ -769,7 +769,7 @@ SystemInformationBlockType11/messageIdentifier TYPE=FT_UINT16 DISPLAY=BASE_DEC|B subtree = proto_item_add_subtree(actx->created_item, ett_lte_rrc_warningMessageSegment); frag_tvb = process_reassembled_data(warning_msg_seg_tvb, 0, actx->pinfo, "Reassembled SIB11 warning message", frag_data, <e_rrc_sib11_frag_items, NULL, subtree); - p_dcs = g_hash_table_lookup(lte_rrc_etws_cmas_dcs_hash, GUINT_TO_POINTER((guint)private_data_get_message_identifier(actx))); + p_dcs = wmem_map_lookup(lte_rrc_etws_cmas_dcs_hash, GUINT_TO_POINTER((guint)private_data_get_message_identifier(actx))); if (frag_tvb && p_dcs) { dissect_lte_rrc_warningMessageSegment(frag_tvb, subtree, actx->pinfo, GPOINTER_TO_UINT(p_dcs)); } @@ -823,7 +823,7 @@ SystemInformationBlockType12-r9/messageIdentifier-r9 TYPE=FT_UINT16 DISPLAY=BASE guint32 dataCodingScheme; subtree = proto_item_add_subtree(actx->created_item, ett_lte_rrc_dataCodingScheme); dataCodingScheme = dissect_cbs_data_coding_scheme(data_coding_scheme_tvb, actx->pinfo, subtree, 0); - g_hash_table_insert(lte_rrc_etws_cmas_dcs_hash, GUINT_TO_POINTER((guint)private_data_get_message_identifier(actx)), + wmem_map_insert(lte_rrc_etws_cmas_dcs_hash, GUINT_TO_POINTER((guint)private_data_get_message_identifier(actx)), GUINT_TO_POINTER(dataCodingScheme)); } @@ -844,7 +844,7 @@ SystemInformationBlockType12-r9/messageIdentifier-r9 TYPE=FT_UINT16 DISPLAY=BASE subtree = proto_item_add_subtree(actx->created_item, ett_lte_rrc_warningMessageSegment); frag_tvb = process_reassembled_data(warning_msg_seg_tvb, 0, actx->pinfo, "Reassembled SIB12 warning message", frag_data, <e_rrc_sib12_frag_items, NULL, subtree); - p_dcs = g_hash_table_lookup(lte_rrc_etws_cmas_dcs_hash, GUINT_TO_POINTER((guint)private_data_get_message_identifier(actx))); + p_dcs = wmem_map_lookup(lte_rrc_etws_cmas_dcs_hash, GUINT_TO_POINTER((guint)private_data_get_message_identifier(actx))); if (frag_tvb && p_dcs) { dissect_lte_rrc_warningMessageSegment(frag_tvb, subtree, actx->pinfo, GPOINTER_TO_UINT(p_dcs)); } @@ -1598,7 +1598,7 @@ SoundingRS-UL-ConfigDedicated/setup/duration STRINGS=TFS(<e_rrc_duration_val) if (!actx->pinfo->fd->flags.visited) { if (system_info_value_current_set && (value != system_info_value_current)) { /* Add entry to the hash table. Offset by one to distinguish 0 from lookup failure */ - g_hash_table_insert(lte_rrc_system_info_value_changed_hash, GUINT_TO_POINTER(actx->pinfo->num), + wmem_map_insert(lte_rrc_system_info_value_changed_hash, GUINT_TO_POINTER(actx->pinfo->num), GUINT_TO_POINTER(system_info_value_current+1)); } system_info_value_current_set = TRUE; @@ -1606,7 +1606,7 @@ SoundingRS-UL-ConfigDedicated/setup/duration STRINGS=TFS(<e_rrc_duration_val) } else { /* Look up indication of changed info value from hash table */ - gpointer p_previous = g_hash_table_lookup(lte_rrc_system_info_value_changed_hash, GUINT_TO_POINTER(actx->pinfo->num)); + gpointer p_previous = wmem_map_lookup(lte_rrc_system_info_value_changed_hash, GUINT_TO_POINTER(actx->pinfo->num)); if (p_previous != NULL) { /* Subtract one from stored result to get previous value */ guint32 previous = GPOINTER_TO_UINT(p_previous) - 1; diff --git a/epan/dissectors/asn1/lte-rrc/packet-lte-rrc-template.c b/epan/dissectors/asn1/lte-rrc/packet-lte-rrc-template.c index cac4e6bcf2..62c101fc3e 100644 --- a/epan/dissectors/asn1/lte-rrc/packet-lte-rrc-template.c +++ b/epan/dissectors/asn1/lte-rrc/packet-lte-rrc-template.c @@ -65,10 +65,10 @@ static dissector_handle_t gsm_a_dtap_handle = NULL; static dissector_handle_t gsm_rlcmac_dl_handle = NULL; static dissector_handle_t lte_rrc_dl_ccch_handle; -static GHashTable *lte_rrc_etws_cmas_dcs_hash = NULL; +static wmem_map_t *lte_rrc_etws_cmas_dcs_hash = NULL; /* Keep track of where/how the System Info value has changed */ -static GHashTable *lte_rrc_system_info_value_changed_hash = NULL; +static wmem_map_t *lte_rrc_system_info_value_changed_hash = NULL; static guint8 system_info_value_current; static gboolean system_info_value_current_set; @@ -3186,20 +3186,6 @@ dissect_lte_rrc_PCCH_NB(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi return tvb_captured_length(tvb); } -static void -lte_rrc_init_protocol(void) -{ - lte_rrc_etws_cmas_dcs_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - lte_rrc_system_info_value_changed_hash = g_hash_table_new(g_direct_hash, g_direct_equal); -} - -static void -lte_rrc_cleanup_protocol(void) -{ - g_hash_table_destroy(lte_rrc_etws_cmas_dcs_hash); - g_hash_table_destroy(lte_rrc_system_info_value_changed_hash); -} - /*--- proto_register_rrc -------------------------------------------*/ void proto_register_lte_rrc(void) { @@ -4009,8 +3995,8 @@ void proto_register_lte_rrc(void) { /* Register the dissectors defined in lte-rrc.conf */ #include "packet-lte-rrc-dis-reg.c" - register_init_routine(<e_rrc_init_protocol); - register_cleanup_routine(<e_rrc_cleanup_protocol); + lte_rrc_etws_cmas_dcs_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal); + lte_rrc_system_info_value_changed_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal); reassembly_table_register(<e_rrc_sib11_reassembly_table, &addresses_reassembly_table_functions); diff --git a/epan/dissectors/asn1/pres/packet-pres-template.c b/epan/dissectors/asn1/pres/packet-pres-template.c index 54ac9ae26f..7ca8de50ae 100644 --- a/epan/dissectors/asn1/pres/packet-pres-template.c +++ b/epan/dissectors/asn1/pres/packet-pres-template.c @@ -69,7 +69,7 @@ typedef struct _pres_ctx_oid_t { char *oid; guint32 idx; } pres_ctx_oid_t; -static GHashTable *pres_ctx_oid_table = NULL; +static wmem_map_t *pres_ctx_oid_table = NULL; typedef struct _pres_user_t { guint ctx_id; @@ -115,20 +115,6 @@ pres_ctx_oid_equal(gconstpointer k1, gconstpointer k2) } static void -pres_init(void) -{ - pres_ctx_oid_table = g_hash_table_new(pres_ctx_oid_hash, - pres_ctx_oid_equal); - -} - -static void -pres_cleanup(void) -{ - g_hash_table_destroy(pres_ctx_oid_table); -} - -static void register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, const char *oid) { pres_ctx_oid_t *pco, *tmppco; @@ -151,11 +137,11 @@ register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, const char *oid) } /* if this ctx already exists, remove the old one first */ - tmppco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, pco); + tmppco=(pres_ctx_oid_t *)wmem_map_lookup(pres_ctx_oid_table, pco); if (tmppco) { - g_hash_table_remove(pres_ctx_oid_table, tmppco); + wmem_map_remove(pres_ctx_oid_table, tmppco); } - g_hash_table_insert(pres_ctx_oid_table, pco, pco); + wmem_map_insert(pres_ctx_oid_table, pco, pco); } static char * @@ -191,7 +177,7 @@ find_oid_by_pres_ctx_id(packet_info *pinfo, guint32 idx) pco.idx = 0; } - tmppco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, &pco); + tmppco=(pres_ctx_oid_t *)wmem_map_lookup(pres_ctx_oid_table, &pco); if (tmppco) { return tmppco->oid; } @@ -440,8 +426,7 @@ void proto_register_pres(void) { proto_register_subtree_array(ett, array_length(ett)); expert_pres = expert_register_protocol(proto_pres); expert_register_field_array(expert_pres, ei, array_length(ei)); - register_init_routine(pres_init); - register_cleanup_routine(pres_cleanup); + pres_ctx_oid_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pres_ctx_oid_hash, pres_ctx_oid_equal); pres_module = prefs_register_protocol(proto_pres, NULL); diff --git a/epan/dissectors/asn1/ros/packet-ros-template.c b/epan/dissectors/asn1/ros/packet-ros-template.c index 4364de44af..eabe705df6 100644 --- a/epan/dissectors/asn1/ros/packet-ros-template.c +++ b/epan/dissectors/asn1/ros/packet-ros-template.c @@ -49,13 +49,10 @@ static guint32 invokeid; static dissector_handle_t ros_handle = NULL; typedef struct ros_conv_info_t { - struct ros_conv_info_t *next; - GHashTable *unmatched; /* unmatched operations */ - GHashTable *matched; /* matched operations */ + wmem_map_t *unmatched; /* unmatched operations */ + wmem_map_t *matched; /* matched operations */ } ros_conv_info_t; -static ros_conv_info_t *ros_info_items = NULL; - typedef struct ros_call_response { gboolean is_request; guint32 req_frame; @@ -89,14 +86,12 @@ static expert_field ei_ros_unknown_ros_pdu = EI_INIT; static dissector_table_t ros_oid_dissector_table=NULL; -static GHashTable *oid_table=NULL; -static GHashTable *protocol_table=NULL; +static wmem_map_t *protocol_table=NULL; void register_ros_oid_dissector_handle(const char *oid, dissector_handle_t dissector, int proto _U_, const char *name, gboolean uses_rtse) { dissector_add_string("ros.oid", oid, dissector); - g_hash_table_insert(oid_table, (gpointer)oid, (gpointer)name); if(!uses_rtse) /* if we are not using RTSE, then we must register ROS with BER (ACSE) */ @@ -106,8 +101,7 @@ register_ros_oid_dissector_handle(const char *oid, dissector_handle_t dissector, void register_ros_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name, gboolean uses_rtse) { - g_hash_table_insert(protocol_table, (gpointer)oid, (gpointer)rinfo); - g_hash_table_insert(oid_table, (gpointer)oid, (gpointer)name); + wmem_map_insert(protocol_table, (gpointer)oid, (gpointer)rinfo); if(!uses_rtse) /* if we are not using RTSE, then we must register ROS with BER (ACSE) */ @@ -151,7 +145,7 @@ ros_try_string(const char *oid, tvbuff_t *tvb, packet_info *pinfo, proto_tree *t proto_item *item=NULL; proto_tree *ros_tree=NULL; - if((session != NULL) && ((rinfo = (ros_info_t*)g_hash_table_lookup(protocol_table, oid)) != NULL)) { + if((session != NULL) && ((rinfo = (ros_info_t*)wmem_map_lookup(protocol_table, oid)) != NULL)) { if(tree){ item = proto_tree_add_item(tree, *(rinfo->proto), tvb, 0, -1, ENC_NA); @@ -280,9 +274,19 @@ static ros_call_response_t * ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint invokeId, gboolean isInvoke) { ros_call_response_t rcr, *rcrp=NULL; - ros_conv_info_t *ros_info = ros_info_items; + ros_conv_info_t *ros_info; + conversation_t *conversation; /* first see if we have already matched this */ + conversation = find_conversation(pinfo->num, &pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->srcport, + pinfo->destport, 0); + if (conversation == NULL) + return NULL; + + ros_info = (ros_conv_info_t *)conversation_get_proto_data(conversation, proto_ros); + if (ros_info == NULL) + return NULL; rcr.invokeId=invokeId; rcr.is_request = isInvoke; @@ -295,7 +299,7 @@ ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui rcr.rep_frame=pinfo->num; } - rcrp=(ros_call_response_t *)g_hash_table_lookup(ros_info->matched, &rcr); + rcrp=(ros_call_response_t *)wmem_map_lookup(ros_info->matched, &rcr); if(rcrp) { /* we have found a match */ @@ -313,10 +317,10 @@ ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui rcr.invokeId=invokeId; - rcrp=(ros_call_response_t *)g_hash_table_lookup(ros_info->unmatched, &rcr); + rcrp=(ros_call_response_t *)wmem_map_lookup(ros_info->unmatched, &rcr); if(rcrp){ - g_hash_table_remove(ros_info->unmatched, rcrp); + wmem_map_remove(ros_info->unmatched, rcrp); } /* if we can't reuse the old one, grab a new chunk */ @@ -328,7 +332,7 @@ ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui rcrp->req_time=pinfo->abs_ts; rcrp->rep_frame=0; rcrp->is_request=TRUE; - g_hash_table_insert(ros_info->unmatched, rcrp, rcrp); + wmem_map_insert(ros_info->unmatched, rcrp, rcrp); return NULL; } else { @@ -336,15 +340,15 @@ ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui /* this is a result - it should be in our unmatched list */ rcr.invokeId=invokeId; - rcrp=(ros_call_response_t *)g_hash_table_lookup(ros_info->unmatched, &rcr); + rcrp=(ros_call_response_t *)wmem_map_lookup(ros_info->unmatched, &rcr); if(rcrp){ if(!rcrp->rep_frame){ - g_hash_table_remove(ros_info->unmatched, rcrp); + wmem_map_remove(ros_info->unmatched, rcrp); rcrp->rep_frame=pinfo->num; rcrp->is_request=FALSE; - g_hash_table_insert(ros_info->matched, rcrp, rcrp); + wmem_map_insert(ros_info->matched, rcrp, rcrp); } } } @@ -405,14 +409,11 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da /* No. Attach that information to the conversation. */ - ros_info = (ros_conv_info_t *)g_malloc(sizeof(ros_conv_info_t)); - ros_info->matched=g_hash_table_new(ros_info_hash_matched, ros_info_equal_matched); - ros_info->unmatched=g_hash_table_new(ros_info_hash_unmatched, ros_info_equal_unmatched); + ros_info = (ros_conv_info_t *)wmem_new0(wmem_file_scope(), ros_conv_info_t); + ros_info->matched=wmem_map_new(wmem_file_scope(), ros_info_hash_matched, ros_info_equal_matched); + ros_info->unmatched=wmem_map_new(wmem_file_scope(), ros_info_hash_unmatched, ros_info_equal_unmatched); conversation_add_proto_data(conversation, proto_ros, ros_info); - - ros_info->next = ros_info_items; - ros_info_items = ros_info; } item = proto_tree_add_item(parent_tree, proto_ros, tvb, 0, -1, ENC_NA); @@ -436,29 +437,6 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da return tvb_captured_length(tvb); } -static void -ros_cleanup(void) -{ - ros_conv_info_t *ros_info; - - /* Free up state attached to the ros_info structures */ - for (ros_info = ros_info_items; ros_info != NULL; ) { - ros_conv_info_t *last; - - g_hash_table_destroy(ros_info->matched); - ros_info->matched=NULL; - g_hash_table_destroy(ros_info->unmatched); - ros_info->unmatched=NULL; - - last = ros_info; - ros_info = ros_info->next; - g_free(last); - } - - ros_info_items = NULL; - -} - /*--- proto_register_ros -------------------------------------------*/ void proto_register_ros(void) { @@ -514,10 +492,7 @@ void proto_register_ros(void) { expert_register_field_array(expert_ros, ei, array_length(ei)); ros_oid_dissector_table = register_dissector_table("ros.oid", "ROS OID Dissectors", proto_ros, FT_STRING, BASE_NONE); - oid_table=g_hash_table_new(g_str_hash, g_str_equal); - protocol_table=g_hash_table_new(g_str_hash, g_str_equal); - - register_cleanup_routine(ros_cleanup); + protocol_table = wmem_map_new(wmem_epan_scope(), wmem_str_hash, g_str_equal); } diff --git a/epan/dissectors/asn1/rtse/packet-rtse-template.c b/epan/dissectors/asn1/rtse/packet-rtse-template.c index 56d59838aa..b2c3c956a0 100644 --- a/epan/dissectors/asn1/rtse/packet-rtse-template.c +++ b/epan/dissectors/asn1/rtse/packet-rtse-template.c @@ -68,7 +68,6 @@ static expert_field ei_rtse_abstract_syntax = EI_INIT; static dissector_table_t rtse_oid_dissector_table=NULL; static dissector_handle_t rtse_handle = NULL; -static GHashTable *oid_table=NULL; static gint ett_rtse_unknown = -1; static reassembly_table rtse_reassembly_table; @@ -121,9 +120,6 @@ register_rtse_oid_dissector_handle(const char *oid, dissector_handle_t dissector if (ros_handle == NULL) ros_handle = find_dissector("ros"); - /* save the name - but not used */ - g_hash_table_insert(oid_table, (gpointer)oid, (gpointer)name); - /* register RTSE with the BER (ACSE) */ register_ber_oid_dissector_handle(oid, rtse_handle, proto, name); @@ -392,9 +388,6 @@ void proto_register_rtse(void) { " in the TCP protocol settings.", &rtse_reassemble); rtse_oid_dissector_table = register_dissector_table("rtse.oid", "RTSE OID Dissectors", proto_rtse, FT_STRING, BASE_NONE); - oid_table=g_hash_table_new(g_str_hash, g_str_equal); - - } |