aboutsummaryrefslogtreecommitdiffstats
path: root/asn1
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-06-27 15:33:42 -0700
committerMichael Mann <mmann78@netscape.net>2015-07-04 00:17:14 +0000
commit3243b6f964c96f0137fc3fffd66a74dd9f7910fd (patch)
treecb4c47ada88b45cd7f6b1835cd412d1d60b746c2 /asn1
parent7b33634cc562ba0ee75536b7dde4268a20d89bee (diff)
asn1: split off cleanup routines
General approach: 1. Split allocation (e.g. g_hash_table_new) from deallocation (g_hash_table_destroy) into functions named "init" and "cleanup". 2. Remove guards that test whether the hash tables are set as init is always called before cleanup. 3. Remove setting hash tables to NULL after destruction. 4. Copy register_init_routine function call and change init to cleanup. 5. Add cleanup function that calls reassembly_table_destroy if there is a reassembly_table_init function. Some templates were modified as follows: - snmp: split renew into init+cleanup, but keep renew for the uat_new callback. - ldap,ros: Rename init to cleanup as there was no initialization. - camel: remove init function from header, make it static. Remove debug print. - tcap: remove unused ssn_range assignment. Files in epan/ were regenerated using cmake && make asn1 Change-Id: Idac16ebf0ec304e0c8becaab5d32904e56eb69b9 Reviewed-on: https://code.wireshark.org/review/9136 Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'asn1')
-rw-r--r--asn1/ansi_map/packet-ansi_map-template.c17
-rw-r--r--asn1/ansi_tcap/packet-ansi_tcap-template.c19
-rw-r--r--asn1/camel/packet-camel-template.c22
-rw-r--r--asn1/camel/packet-camel-template.h6
-rw-r--r--asn1/h225/packet-h225-template.c21
-rw-r--r--asn1/h245/packet-h245-template.c8
-rw-r--r--asn1/idmp/packet-idmp-template.c5
-rw-r--r--asn1/ldap/packet-ldap-template.c4
-rw-r--r--asn1/lte-rrc/packet-lte-rrc-template.c15
-rw-r--r--asn1/nbap/packet-nbap-template.c25
-rw-r--r--asn1/pres/packet-pres-template.c11
-rw-r--r--asn1/ros/packet-ros-template.c4
-rw-r--r--asn1/rrc/packet-rrc-template.c19
-rw-r--r--asn1/rtse/packet-rtse-template.c6
-rw-r--r--asn1/snmp/packet-snmp-template.c41
-rw-r--r--asn1/t38/packet-t38-template.c6
-rw-r--r--asn1/tcap/packet-tcap-template.c14
17 files changed, 135 insertions, 108 deletions
diff --git a/asn1/ansi_map/packet-ansi_map-template.c b/asn1/ansi_map/packet-ansi_map-template.c
index 40ad217995..506a95eb39 100644
--- a/asn1/ansi_map/packet-ansi_map-template.c
+++ b/asn1/ansi_map/packet-ansi_map-template.c
@@ -389,20 +389,16 @@ static void dissect_ansi_map_win_trigger_list(tvbuff_t *tvb, packet_info *pinfo
static GHashTable *TransactionId_table=NULL;
static void
-ansi_map_init_transaction_table(void){
-
- /* Destroy any existing memory chunks / hashes. */
- if (TransactionId_table){
- g_hash_table_destroy(TransactionId_table);
- }
-
+ansi_map_init(void)
+{
TransactionId_table = g_hash_table_new(g_str_hash, g_str_equal);
}
static void
-ansi_map_init_protocol(void)
+ansi_map_cleanup(void)
{
- ansi_map_init_transaction_table();
+ /* Destroy any existing memory chunks / hashes. */
+ g_hash_table_destroy(TransactionId_table);
}
/* Store Invoke information needed for the corresponding reply */
@@ -5492,6 +5488,7 @@ void proto_register_ansi_map(void) {
"Type of matching invoke/response, risk of missmatch if loose matching choosen",
&ansi_map_response_matching_type, ansi_map_response_matching_type_values, FALSE);
- register_init_routine(&ansi_map_init_protocol);
+ register_init_routine(&ansi_map_init);
+ register_cleanup_routine(&ansi_map_cleanup);
register_new_stat_tap_ui(&stat_table);
}
diff --git a/asn1/ansi_tcap/packet-ansi_tcap-template.c b/asn1/ansi_tcap/packet-ansi_tcap-template.c
index 3039d5a1ab..fd170fc82f 100644
--- a/asn1/ansi_tcap/packet-ansi_tcap-template.c
+++ b/asn1/ansi_tcap/packet-ansi_tcap-template.c
@@ -170,22 +170,16 @@ struct ansi_tcap_invokedata_t {
static GHashTable *TransactionId_table=NULL;
static void
-ansi_tcap_init_transaction_table(void){
-
- /* Destroy any existing memory chunks / hashes. */
- if (TransactionId_table){
- g_hash_table_destroy(TransactionId_table);
- TransactionId_table = NULL;
- }
-
+ansi_tcap_init(void)
+{
TransactionId_table = g_hash_table_new(g_str_hash, g_str_equal);
-
}
static void
-ansi_tcap_init_protocol(void)
+ansi_tcap_cleanup(void)
{
- ansi_tcap_init_transaction_table();
+ /* Destroy any existing memory chunks / hashes. */
+ g_hash_table_destroy(TransactionId_table);
}
/* Store Invoke information needed for the corresponding reply */
@@ -533,5 +527,6 @@ proto_register_ansi_tcap(void)
"Type of matching invoke/response, risk of missmatch if loose matching choosen",
&ansi_tcap_response_matching_type, ansi_tcap_response_matching_type_values, FALSE);
- register_init_routine(&ansi_tcap_init_protocol);
+ register_init_routine(&ansi_tcap_init);
+ register_cleanup_routine(&ansi_tcap_cleanup);
}
diff --git a/asn1/camel/packet-camel-template.c b/asn1/camel/packet-camel-template.c
index 2c11b5a219..f0f3e93f0f 100644
--- a/asn1/camel/packet-camel-template.c
+++ b/asn1/camel/packet-camel-template.c
@@ -496,23 +496,11 @@ new_camelsrt_call(struct camelsrt_call_info_key_t *p_camelsrt_call_key)
* Routine called when the TAP is initialized.
* so hash table are (re)created
*/
-void
+static void
camelsrt_init_routine(void)
{
-
- /* free hash-table for SRT */
- if (srt_calls != NULL) {
-#ifdef DEBUG_CAMELSRT
- dbg(16,"Destroy hash ");
-#endif
- g_hash_table_destroy(srt_calls);
- }
-
/* create new hash-table for SRT */
srt_calls = g_hash_table_new(camelsrt_call_hash, camelsrt_call_equal);
-#ifdef DEBUG_CAMELSRT
- dbg(16,"Create hash ");
-#endif
/* Reset the session counter */
camelsrt_global_SessionId=1;
@@ -523,6 +511,13 @@ 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
@@ -1510,6 +1505,7 @@ void proto_register_camel(void) {
/* Routine for statistic */
register_init_routine(&camelsrt_init_routine);
+ register_cleanup_routine(&camelsrt_cleanup_routine);
camel_tap=register_tap(PSNAME);
register_srt_table(proto_camel, "CAMEL", 1, camelstat_packet, camelstat_init, NULL);
diff --git a/asn1/camel/packet-camel-template.h b/asn1/camel/packet-camel-template.h
index d8a4eef3a7..f73e0d4220 100644
--- a/asn1/camel/packet-camel-template.h
+++ b/asn1/camel/packet-camel-template.h
@@ -119,12 +119,6 @@ struct camelsrt_info_t {
};
/**
- * Routine called when the TAP is initialized.
- * so hash table are (re)created
- */
-void camelsrt_init_routine(void);
-
-/**
* Initialize the Message Info used by the main dissector
* Data are linked to a TCAP transaction
*/
diff --git a/asn1/h225/packet-h225-template.c b/asn1/h225/packet-h225-template.c
index 17732081a5..e4de6ada83 100644
--- a/asn1/h225/packet-h225-template.c
+++ b/asn1/h225/packet-h225-template.c
@@ -337,25 +337,27 @@ h225ras_call_t * append_h225ras_call(h225ras_call_t *prev_call, packet_info *pin
is (re-)dissecting a trace file from beginning.
We need to discard and init any state we've saved */
-void
+static void
h225_init_routine(void)
{
int i;
+ /* create new hash-tables for RAS SRT */
- /* free hash-tables for RAS SRT */
for(i=0;i<7;i++) {
- if (ras_calls[i] != NULL) {
- g_hash_table_destroy(ras_calls[i]);
- ras_calls[i] = NULL;
- }
+ ras_calls[i] = g_hash_table_new(h225ras_call_hash, h225ras_call_equal);
}
- /* create new hash-tables for RAS SRT */
+}
+static void
+h225_cleanup_routine(void)
+{
+ int i;
+
+ /* free hash-tables for RAS SRT */
for(i=0;i<7;i++) {
- ras_calls[i] = g_hash_table_new(h225ras_call_hash, h225ras_call_equal);
+ g_hash_table_destroy(ras_calls[i]);
}
-
}
static int
@@ -503,6 +505,7 @@ void proto_register_h225(void) {
gef_content_dissector_table = register_dissector_table("h225.gef.content", "H.225 Generic Extensible Framework", FT_STRING, BASE_NONE);
register_init_routine(&h225_init_routine);
+ register_cleanup_routine(&h225_cleanup_routine);
h225_tap = register_tap("h225");
register_rtd_table(proto_h225_ras, "h225", NUM_RAS_STATS, 1, ras_message_category, h225rassrt_packet, NULL);
diff --git a/asn1/h245/packet-h245-template.c b/asn1/h245/packet-h245-template.c
index a2bc16d616..d4d9ef2dc4 100644
--- a/asn1/h245/packet-h245-template.c
+++ b/asn1/h245/packet-h245-template.c
@@ -308,13 +308,16 @@ static void h223_lc_init( void )
static void h245_init(void)
{
- if ( h245_pending_olc_reqs)
- g_hash_table_destroy(h245_pending_olc_reqs);
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;
@@ -512,6 +515,7 @@ 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);
/* 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/asn1/idmp/packet-idmp-template.c b/asn1/idmp/packet-idmp-template.c
index f0cce14c56..705630afa3 100644
--- a/asn1/idmp/packet-idmp-template.c
+++ b/asn1/idmp/packet-idmp-template.c
@@ -249,7 +249,11 @@ static void idmp_reassemble_init (void)
{
reassembly_table_init (&idmp_reassembly_table,
&addresses_reassembly_table_functions);
+}
+static void idmp_reassemble_cleanup(void)
+{
+ reassembly_table_destroy(&idmp_reassembly_table);
saved_protocolID = NULL;
}
@@ -333,6 +337,7 @@ void proto_register_idmp(void)
new_register_dissector("idmp", dissect_idmp_tcp, proto_idmp);
register_init_routine (&idmp_reassemble_init);
+ register_cleanup_routine (&idmp_reassemble_cleanup);
/* Register our configuration options for IDMP, particularly our port */
diff --git a/asn1/ldap/packet-ldap-template.c b/asn1/ldap/packet-ldap-template.c
index 21bd8cfdcd..7e4b823db9 100644
--- a/asn1/ldap/packet-ldap-template.c
+++ b/asn1/ldap/packet-ldap-template.c
@@ -1894,7 +1894,7 @@ dissect_mscldap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
static void
-ldap_reinit(void)
+ldap_cleanup(void)
{
ldap_conv_info_t *ldap_info;
@@ -2297,7 +2297,7 @@ void proto_register_ldap(void) {
"Connectionless Lightweight Directory Access Protocol",
"CLDAP", "cldap");
- register_init_routine(ldap_reinit);
+ register_cleanup_routine(ldap_cleanup);
ldap_tap=register_tap("ldap");
ldap_name_dissector_table = register_dissector_table("ldap.name", "LDAP Attribute Type Dissectors", FT_STRING, BASE_NONE);
diff --git a/asn1/lte-rrc/packet-lte-rrc-template.c b/asn1/lte-rrc/packet-lte-rrc-template.c
index f9cc583e36..85307c4628 100644
--- a/asn1/lte-rrc/packet-lte-rrc-template.c
+++ b/asn1/lte-rrc/packet-lte-rrc-template.c
@@ -2709,17 +2709,17 @@ dissect_lte_rrc_Handover_Preparation_Info(tvbuff_t *tvb, packet_info *pinfo, pro
static void
lte_rrc_init_protocol(void)
{
- if (lte_rrc_etws_cmas_dcs_hash) {
- g_hash_table_destroy(lte_rrc_etws_cmas_dcs_hash);
- }
- if (lte_rrc_system_info_value_changed_hash) {
- g_hash_table_destroy(lte_rrc_system_info_value_changed_hash);
- }
-
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) {
@@ -3409,6 +3409,7 @@ void proto_register_lte_rrc(void) {
#include "packet-lte-rrc-dis-reg.c"
register_init_routine(&lte_rrc_init_protocol);
+ register_cleanup_routine(&lte_rrc_cleanup_protocol);
}
diff --git a/asn1/nbap/packet-nbap-template.c b/asn1/nbap/packet-nbap-template.c
index b6a0318cd3..8c34e80269 100644
--- a/asn1/nbap/packet-nbap-template.c
+++ b/asn1/nbap/packet-nbap-template.c
@@ -419,16 +419,9 @@ static gint nbap_key_cmp(gconstpointer a_ptr, gconstpointer b_ptr, gpointer igno
}*/
static void nbap_init(void){
- guint8 i;
- /*Cleanup*/
- if(com_context_map){
- g_tree_destroy(com_context_map);
- }
- if(edch_flow_port_map){
- g_tree_destroy(edch_flow_port_map);
- }
- /*Initialize*/
- com_context_map = g_tree_new_full(nbap_key_cmp,
+ guint8 i;
+ /*Initialize*/
+ com_context_map = g_tree_new_full(nbap_key_cmp,
NULL, /* data pointer, optional */
NULL, /* function to free the memory allocated for the key used when removing the entry */
g_free);
@@ -441,9 +434,16 @@ static void nbap_init(void){
g_free);
for (i = 0; i < 15; i++) {
- lchId_type_table[i+1] = *lch_contents[i];
- }
+ lchId_type_table[i+1] = *lch_contents[i];
+ }
}
+
+static void nbap_cleanup(void){
+ /*Cleanup*/
+ g_tree_destroy(com_context_map);
+ g_tree_destroy(edch_flow_port_map);
+}
+
static int
dissect_nbap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
@@ -532,6 +532,7 @@ void proto_register_nbap(void)
nbap_proc_uout_dissector_table = register_dissector_table("nbap.proc.uout", "NBAP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_STRING, BASE_NONE);
register_init_routine(nbap_init);
+ register_cleanup_routine(nbap_cleanup);
}
/*
diff --git a/asn1/pres/packet-pres-template.c b/asn1/pres/packet-pres-template.c
index 02663841f9..5ec32a1fb2 100644
--- a/asn1/pres/packet-pres-template.c
+++ b/asn1/pres/packet-pres-template.c
@@ -117,16 +117,18 @@ pres_ctx_oid_equal(gconstpointer k1, gconstpointer k2)
static void
pres_init(void)
{
- if( pres_ctx_oid_table ){
- g_hash_table_destroy(pres_ctx_oid_table);
- pres_ctx_oid_table = NULL;
- }
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;
@@ -441,6 +443,7 @@ void proto_register_pres(void) {
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_module = prefs_register_protocol(proto_pres, NULL);
diff --git a/asn1/ros/packet-ros-template.c b/asn1/ros/packet-ros-template.c
index b18fc5129f..49cbd9e499 100644
--- a/asn1/ros/packet-ros-template.c
+++ b/asn1/ros/packet-ros-template.c
@@ -437,7 +437,7 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da
}
static void
-ros_reinit(void)
+ros_cleanup(void)
{
ros_conv_info_t *ros_info;
@@ -519,7 +519,7 @@ void proto_register_ros(void) {
ros_handle = find_dissector("ros");
- register_init_routine(ros_reinit);
+ register_cleanup_routine(ros_cleanup);
}
diff --git a/asn1/rrc/packet-rrc-template.c b/asn1/rrc/packet-rrc-template.c
index 10644788f4..86814ab98e 100644
--- a/asn1/rrc/packet-rrc-template.c
+++ b/asn1/rrc/packet-rrc-template.c
@@ -242,14 +242,8 @@ dissect_rrc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
}
-static void rrc_init(void){
- /*Cleanup*/
- if(hsdsch_muxed_flows){
- g_tree_destroy(hsdsch_muxed_flows);
- }
- if(rrc_ciph_inf){
- g_tree_destroy(rrc_ciph_inf);
- }
+static void
+rrc_init(void) {
/*Initialize structure for muxed flow indication*/
hsdsch_muxed_flows = g_tree_new_full(rrc_key_cmp,
NULL, /* data pointer, optional */
@@ -262,6 +256,14 @@ static void rrc_init(void){
NULL,
rrc_free_value);
}
+
+static void
+rrc_cleanup(void) {
+ /*Cleanup*/
+ g_tree_destroy(hsdsch_muxed_flows);
+ g_tree_destroy(rrc_ciph_inf);
+}
+
/*--- proto_register_rrc -------------------------------------------*/
void proto_register_rrc(void) {
@@ -338,6 +340,7 @@ void proto_register_rrc(void) {
register_init_routine(rrc_init);
+ register_cleanup_routine(rrc_cleanup);
}
diff --git a/asn1/rtse/packet-rtse-template.c b/asn1/rtse/packet-rtse-template.c
index 8221459f17..b263d21294 100644
--- a/asn1/rtse/packet-rtse-template.c
+++ b/asn1/rtse/packet-rtse-template.c
@@ -311,6 +311,11 @@ static void rtse_reassemble_init (void)
&addresses_reassembly_table_functions);
}
+static void rtse_reassemble_cleanup(void)
+{
+ reassembly_table_destroy(&rtse_reassembly_table);
+}
+
/*--- proto_register_rtse -------------------------------------------*/
void proto_register_rtse(void) {
@@ -384,6 +389,7 @@ void proto_register_rtse(void) {
expert_rtse = expert_register_protocol(proto_rtse);
expert_register_field_array(expert_rtse, ei, array_length(ei));
register_init_routine (&rtse_reassemble_init);
+ register_cleanup_routine (&rtse_reassemble_cleanup);
rtse_module = prefs_register_protocol_subtree("OSI", proto_rtse, NULL);
prefs_register_bool_preference(rtse_module, "reassemble",
diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c
index e5e6352465..5914dc99d3 100644
--- a/asn1/snmp/packet-snmp-template.c
+++ b/asn1/snmp/packet-snmp-template.c
@@ -1437,28 +1437,38 @@ free_ue_cache(snmp_ue_assoc_t **cache)
#define CACHE_INSERT(c,a) if (c) { snmp_ue_assoc_t* t = c; c = a; c->next = t; } else { c = a; a->next = NULL; }
static void
-renew_ue_cache(void)
+init_ue_cache(void)
{
- free_ue_cache(&localized_ues);
- free_ue_cache(&unlocalized_ues);
-
- if (num_ueas) {
- guint i;
+ guint i;
- for(i = 0; i < num_ueas; i++) {
- snmp_ue_assoc_t* a = ue_dup(&(ueas[i]));
+ for (i = 0; i < num_ueas; i++) {
+ snmp_ue_assoc_t* a = ue_dup(&(ueas[i]));
- if (a->engine.len) {
- CACHE_INSERT(localized_ues,a);
-
- } else {
- CACHE_INSERT(unlocalized_ues,a);
- }
+ if (a->engine.len) {
+ CACHE_INSERT(localized_ues,a);
+ } else {
+ CACHE_INSERT(unlocalized_ues,a);
}
+
}
}
+static void
+cleanup_ue_cache(void)
+{
+ free_ue_cache(&localized_ues);
+ free_ue_cache(&unlocalized_ues);
+}
+
+/* Called when the user applies changes to UAT preferences. */
+static void
+renew_ue_cache(void)
+{
+ cleanup_ue_cache();
+ init_ue_cache();
+}
+
static snmp_ue_assoc_t*
localize_ue( snmp_ue_assoc_t* o, const guint8* engine, guint engine_len )
@@ -2569,7 +2579,8 @@ void proto_register_snmp(void) {
value_sub_dissectors_table = register_dissector_table("snmp.variable_oid","SNMP Variable OID", FT_STRING, BASE_NONE);
- register_init_routine(renew_ue_cache);
+ register_init_routine(init_ue_cache);
+ register_cleanup_routine(cleanup_ue_cache);
register_ber_syntax_dissector("SNMP", proto_snmp, dissect_snmp_tcp);
}
diff --git a/asn1/t38/packet-t38-template.c b/asn1/t38/packet-t38-template.c
index edf59060da..88cc0992d4 100644
--- a/asn1/t38/packet-t38-template.c
+++ b/asn1/t38/packet-t38-template.c
@@ -206,6 +206,11 @@ static void t38_defragment_init(void)
&addresses_reassembly_table_functions);
}
+static void t38_defragment_cleanup(void)
+{
+ reassembly_table_destroy(&data_reassembly_table);
+}
+
/* Set up an T38 conversation */
void t38_add_address(packet_info *pinfo,
@@ -719,6 +724,7 @@ proto_register_t38(void)
/* Init reassemble tables for HDLC */
register_init_routine(t38_defragment_init);
+ register_cleanup_routine(t38_defragment_cleanup);
t38_tap = register_tap("t38");
diff --git a/asn1/tcap/packet-tcap-template.c b/asn1/tcap/packet-tcap-template.c
index b1a7dd7f80..83e5b6a991 100644
--- a/asn1/tcap/packet-tcap-template.c
+++ b/asn1/tcap/packet-tcap-template.c
@@ -2071,6 +2071,7 @@ proto_reg_handoff_tcap(void)
}
static void init_tcap(void);
+static void cleanup_tcap(void);
void
proto_register_tcap(void)
@@ -2187,7 +2188,6 @@ proto_register_tcap(void)
/* Set default SSNs */
range_convert_str(&global_ssn_range, "", MAX_SSN);
- ssn_range = range_empty();
prefs_register_range_preference(tcap_module, "ssn", "SCCP SSNs",
"SCCP (and SUA) SSNs to decode as TCAP",
@@ -2222,6 +2222,7 @@ proto_register_tcap(void)
tcap_handle = create_dissector_handle(dissect_tcap, proto_tcap);
register_init_routine(&init_tcap);
+ register_cleanup_routine(&cleanup_tcap);
}
@@ -2242,16 +2243,17 @@ static void range_add_callback(guint32 ssn)
static void init_tcap(void)
{
- if (ssn_range) {
- range_foreach(ssn_range, range_delete_callback);
- g_free(ssn_range);
- }
-
ssn_range = range_copy(global_ssn_range);
range_foreach(ssn_range, range_add_callback);
tcapsrt_init_routine();
}
+static void cleanup_tcap(void)
+{
+ range_foreach(ssn_range, range_delete_callback);
+ g_free(ssn_range);
+}
+
static int
dissect_tcap_param(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset)
{