Review at  https://gerrit.osmocom.org/7316

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
---
M sgsn/SGSN_Tests.ttcn
1 file changed, 26 insertions(+), 4 deletions(-)


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

diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index a853c6d..1b986f7 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,17 @@
 
 function f_process_attach_accept(PDU_GMM_AttachAccept aa) runs on 
BSSGP_ConnHdlr {
        /* mandatory IE */
+       var hexstring aa_plmn := aa.routingAreaIdentification.mccDigit1
+                                & aa.routingAreaIdentification.mccDigit2
+                                & aa.routingAreaIdentification.mccDigit3
+                                & aa.routingAreaIdentification.mncDigit1
+                                & aa.routingAreaIdentification.mncDigit2
+                                & aa.routingAreaIdentification.mncDigit3;
+       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 +388,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 {
@@ -416,6 +429,14 @@
        f_init();
        f_sleep(1.0);
        vc_conn := f_start_handler(refers(f_TC_attach), testcasename(), 
g_gb[0], 1);
+       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;
 }
 
@@ -1136,6 +1157,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() );

-- 
To view, visit https://gerrit.osmocom.org/7316
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8901ec0b090e342ebb04a04f9d759fc46c7d9cab
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <[email protected]>

Reply via email to