laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/28141 )


Change subject: RAN_Emulation: f_ran_unregister_imsi complement for 
f_ran_register_imsi
......................................................................

RAN_Emulation: f_ran_unregister_imsi complement for f_ran_register_imsi

We have a function to register an IMSI but we're missing a function
to unregister it from RAN_Emulation.  This will cause resource leaks
and eventually an overflow of the ImsiTable.  We don't notice this yet
as we don't have long enough running tests in the test suite yet.

Change-Id: I1f5d86c999d4495d661166f98183dfbc48f05f47
---
M library/RAN_Emulation.ttcnpp
1 file changed, 28 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/41/28141/1

diff --git a/library/RAN_Emulation.ttcnpp b/library/RAN_Emulation.ttcnpp
index e6d36e6..3198ee1 100644
--- a/library/RAN_Emulation.ttcnpp
+++ b/library/RAN_Emulation.ttcnpp
@@ -1254,7 +1254,10 @@
                        f_create_imsi(imsi, tmsi, vc_hdlr);
                        PROC.reply(RAN_register_imsi:{imsi, tmsi, vc_hdlr}) to 
vc_hdlr;
                        }
-
+               [] PROC.getcall(RAN_unregister_imsi:{?,?}) -> param(imsi, 
vc_hdlr) {
+                       f_destroy_imsi(imsi, vc_hdlr);
+                       PROC.reply(RAN_unregister_imsi:{imsi, vc_hdlr}) to 
vc_hdlr;
+                       }

                }
        }
@@ -1287,6 +1290,7 @@

 /* procedure based port to register for incoming IMSI/TMSI */
 signature RAN_register_imsi(in hexstring imsi, in OCT4 tmsi, in RAN_ConnHdlr 
hdlr);
+signature RAN_unregister_imsi(in hexstring imsi, in RAN_ConnHdlr hdlr);

 /* If DTAP happens across other channels (e.g. GSUP), provide manual advancing 
of the n_sd sequence number */
 signature RAN_last_n_sd(in RAN_ConnHdlr hdlr, out N_Sd_Array last_n_sd);
@@ -1295,7 +1299,7 @@
 signature RAN_continue_after_n_sd(N_Sd_Array last_n_sd, in RAN_ConnHdlr hdlr);

 type port RAN_PROC_PT procedure {
-       inout RAN_register, RAN_register_imsi, RAN_register_handoverRequest, 
RAN_last_n_sd, RAN_continue_after_n_sd;
+       inout RAN_register, RAN_register_imsi, RAN_unregister_imsi, 
RAN_register_handoverRequest, RAN_last_n_sd, RAN_continue_after_n_sd;
 } with { extension "internal" };

 #ifdef RAN_EMULATION_BSSAP
@@ -1425,6 +1429,19 @@
        testcase.stop("No space left in ImsiTable");
 }

+private function f_destroy_imsi(hexstring imsi, RAN_ConnHdlr hdlr)
+runs on RAN_Emulation_CT {
+       for (var integer i := 0; i < sizeof(ImsiTable); i := i+1) {
+               if (ImsiTable[i].imsi == imsi and ImsiTable[i].comp_ref == 
hdlr) {
+                       ImsiTable[i].comp_ref := null;
+                       ImsiTable[i].imsi := omit;
+                       ImsiTable[i].tmsi := 'FFFFFFFF'O;
+                       log("Removed IMSI[", i, "] for ", imsi, " to be handled 
at ", hdlr);
+                       return;
+               }
+       }
+       testcase.stop("Unable to find to-be-destroyed IMSI in ImsiTable");
+}

 private function f_expect_table_init()
 runs on RAN_Emulation_CT {
@@ -1451,6 +1468,15 @@
        }
 }

+/* helper function for clients to register their IMSI/TMSI */
+function f_ran_unregister_imsi(hexstring imsi)
+runs on RAN_ConnHdlr {
+
+       BSSAP_PROC.call(RAN_unregister_imsi:{imsi, self}) {
+               [] BSSAP_PROC.getreply(RAN_unregister_imsi:{?,?}) {};
+       }
+}
+
 /* register an expect with the BSSMAP core */
 function f_ran_register_exp(octetstring l3_enc) runs on RAN_ConnHdlr {
        BSSAP_PROC.call(RAN_register:{l3_enc, self}) {

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/28141
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I1f5d86c999d4495d661166f98183dfbc48f05f47
Gerrit-Change-Number: 28141
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <lafo...@osmocom.org>
Gerrit-MessageType: newchange

Reply via email to