sgsn: test GMM Attach with 3-digit leading-zero MNC
Add general infrastructure to
- pass an MCC-MNC for BSSGP to use into f_init();
- verify that the Attach Accept PLMN matches the BSSGP one.
Add TC_attach_mnc3() to feed an MNC with three digits and a leading zero, to
verify the recent mnc3 patches. When testing against a libosmocore and
osmo-sgsn before mnc3, this results in:
Test case TC_attach_mnc3 finished. Verdict: fail reason: "mismatching PLMN in Attach Accept: 02342F; expected 023042"
With the current master branches the proper 3-digit MNC with leading zero is
fed back into the Attach Accept message.
Change-Id: I8901ec0b090e342ebb04a04f9d759fc46c7d9cab
diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index a853c6d..79aa166 100644
--- a/sgsn/SGSN_Tests.ttcn
+++ b/sgsn/SGSN_Tests.ttcn
@@ -33,6 +33,8 @@
import from TELNETasp_PortType all;
import from Osmocom_VTY_Functions all;
+import from GSM_RR_Types all;
+
modulepar {
/* IP/port on which we run our internal GSUP/HLR emulation */
@@ -157,7 +159,7 @@
}
-function f_init() runs on test_CT {
+function f_init(BcdMccMnc mcc_mnc := '26242F'H) runs on test_CT {
if (g_initialized == true) {
return;
}
@@ -168,7 +170,7 @@
cell_id := {
ra_id := {
lai := {
- mcc_mnc := '26242F'H, lac := 13135},
+ mcc_mnc := mcc_mnc, lac := 13135},
rac := 0
},
cell_id := 20960
@@ -271,7 +273,7 @@
}
altstep as_mm_identity() runs on BSSGP_ConnHdlr {
- var MobileIdentityLV mi;
+ var MobileL3_CommonIE_Types.MobileIdentityLV mi;
[] BSSGP.receive(tr_BD_L3_MT(tr_GMM_ID_REQ('001'B))) {
mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
BSSGP.send(ts_GMM_ID_RESP(mi));
@@ -325,6 +327,12 @@
function f_process_attach_accept(PDU_GMM_AttachAccept aa) runs on BSSGP_ConnHdlr {
/* mandatory IE */
+ var hexstring aa_plmn := f_RAI_to_plmn_hexstr(aa.routingAreaIdentification);
+ if (not (g_pars.bssgp_cell_id.ra_id.lai.mcc_mnc == aa_plmn)) {
+ setverdict(fail, "mismatching PLMN in Attach Accept: " & hex2str(aa_plmn)
+ & "; expected " & hex2str(g_pars.bssgp_cell_id.ra_id.lai.mcc_mnc));
+ self.stop;
+ }
g_pars.ra := aa.routingAreaIdentification;
if (ispresent(aa.allocatedPTMSI)) {
if (not g_pars.net.expect_ptmsi) {
@@ -375,7 +383,7 @@
}
/* return a MobileIdentityLV: P-TMSI if we have one, IMSI otherwise */
-private function f_mi_get_lv() runs on BSSGP_ConnHdlr return MobileIdentityLV {
+private function f_mi_get_lv() runs on BSSGP_ConnHdlr return MobileL3_CommonIE_Types.MobileIdentityLV {
if (ispresent(g_pars.p_tmsi)) {
return valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
} else {
@@ -419,6 +427,14 @@
vc_conn.done;
}
+testcase TC_attach_mnc3() runs on test_CT {
+ var BSSGP_ConnHdlr vc_conn;
+ f_init('023042'H);
+ f_sleep(1.0);
+ vc_conn := f_start_handler(refers(f_TC_attach), testcasename(), g_gb[0], 1001);
+ vc_conn.done;
+}
+
/* MS never responds to ID REQ, expect ATTACH REJECT */
private function f_TC_attach_auth_id_timeout(charstring id) runs on BSSGP_ConnHdlr {
var RoutingAreaIdentificationV old_ra := f_random_RAI();
@@ -1136,6 +1152,7 @@
control {
execute( TC_attach() );
+ execute( TC_attach_mnc3() );
execute( TC_attach_auth_id_timeout() );
execute( TC_attach_auth_sai_timeout() );
execute( TC_attach_auth_sai_reject() );