Add f_gen_tmsi() to generate a TMSI similar to f_gen_{imsi,imei}()
... and start to use it from BSC_Tests.ttcn
Related: OS#4472, SYS#5002
Change-Id: Iacba62bb740374c28cbcf50d54ba1814c5b4e1c2
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index 2c02e36..52b4906 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -6383,14 +6383,8 @@
* MSC Pooling
***********************************************************************/
-function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
-{
- return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
- 4);
-}
-
template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
- ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
+ ts_MI_TMSI_LV(tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v, nri_bitlen := nri_bitlen));
private function f_expect_lchan_rel(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
interleave {
@@ -6949,7 +6943,7 @@
var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
var integer nri_v := 300; /* <-- second MSC's NRI */
- var octetstring tmsi := f_tmsi_nri(nri_v);
+ var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
var BSSAP_N_UNITDATA_req paging;
f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index 862509b..1cba168 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -267,6 +267,21 @@
return f_concat_pad(12, '49123'H, suffix);
}
+function f_gen_tmsi(integer suffix, integer nri_v := 0, integer nri_bitlen := 10,
+ OCT4 base_tmsi := '42000023'O) return OCT4 {
+ var integer tmsi_int := oct2int(base_tmsi) + suffix;
+ var bitstring base_tmsi_bits := int2bit(tmsi_int, 32);
+ var bitstring prefix_bits := substr(base_tmsi_bits, 0, 8);
+ var bitstring suffix_bits := substr(base_tmsi_bits, 8 + nri_bitlen, 24 - nri_bitlen);
+ var bitstring total_bits := prefix_bits & int2bit(nri_v, nri_bitlen) & suffix_bits;
+ var OCT4 tmsi := bit2oct(total_bits);
+
+ log("f_gen_tmsi(suffix:=", suffix, ", nri_v:=", nri_v, ", nri_bitlen:=", nri_bitlen,
+ ", base_tmsi:=", base_tmsi, ") -> prefix:=", prefix_bits, ", suffix:=", suffix_bits,
+ "total_bits:=", total_bits, " == ", tmsi);
+
+ return tmsi;
+}
} with { encode "RAW"; variant "FIELDORDER(msb)" }