summaryrefslogtreecommitdiffstats
path: root/sgsn
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-02-17 09:36:33 +0100
committerHarald Welte <laforge@gnumonks.org>2018-02-18 10:25:49 +0100
commit23178c590ec1ad931fab36fa177f7135f111a5e8 (patch)
tree986c3c5d8b1f11a1ddc45e5c96b437e9932ab5ac /sgsn
parentb7c14e983cc06f1dd4a658e516a9af353389d1f4 (diff)
sgsn: Reduce code duplication by introducing f_mi_get_lv()
Diffstat (limited to 'sgsn')
-rw-r--r--sgsn/SGSN_Tests.ttcn98
1 files changed, 19 insertions, 79 deletions
diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index 490fbc2..248a9c3 100644
--- a/sgsn/SGSN_Tests.ttcn
+++ b/sgsn/SGSN_Tests.ttcn
@@ -305,18 +305,20 @@ function f_random_RAI(HEX0_3n mcc := '262'H, HEX0_3n mnc := '42'H) return Routin
return f_RAI(mcc, mnc, f_rnd_octstring(2), f_rnd_octstring(1));
}
-private function f_TC_attach(charstring id) runs on BSSGP_ConnHdlr {
- var BssgpDecoded bd;
- var MobileIdentityLV mi;
- var RoutingAreaIdentificationV old_ra := f_random_RAI();
-
+/* return a MobileIdentityLV: P-TMSI if we have one, IMSI otherwise */
+private function f_mi_get_lv() runs on BSSGP_ConnHdlr return MobileIdentityLV {
if (ispresent(g_pars.p_tmsi)) {
- mi := valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
+ return valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
} else {
- mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
+ return valueof(ts_MI_IMSI_LV(g_pars.imsi));
}
+}
+
+private function f_TC_attach(charstring id) runs on BSSGP_ConnHdlr {
+ var BssgpDecoded bd;
+ var RoutingAreaIdentificationV old_ra := f_random_RAI();
- BSSGP.send(ts_GMM_ATTACH_REQ(mi, old_ra, false, false, omit, omit));
+ BSSGP.send(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit));
f_gmm_auth();
/* Expect MSC to perform LU with HLR */
GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi));
@@ -342,16 +344,9 @@ testcase TC_attach() runs on test_CT {
/* MS never responds to ID REQ, expect ATTACH REJECT */
private function f_TC_attach_auth_id_timeout(charstring id) runs on BSSGP_ConnHdlr {
- var MobileIdentityLV mi;
var RoutingAreaIdentificationV old_ra := f_random_RAI();
- if (ispresent(g_pars.p_tmsi)) {
- mi := valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
- } else {
- mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
- }
-
- BSSGP.send(ts_GMM_ATTACH_REQ(mi, old_ra, false, false, omit, omit));
+ BSSGP.send(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit));
alt {
[] BSSGP.receive(tr_BD_L3_MT(tr_GMM_ID_REQ(?))) {
/* don't send ID Response */
@@ -374,16 +369,9 @@ testcase TC_attach_auth_id_timeout() runs on test_CT {
/* HLR never responds to SAI REQ, expect ATTACH REJECT */
private function f_TC_attach_auth_sai_timeout(charstring id) runs on BSSGP_ConnHdlr {
- var MobileIdentityLV mi;
var RoutingAreaIdentificationV old_ra := f_random_RAI();
- if (ispresent(g_pars.p_tmsi)) {
- mi := valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
- } else {
- mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
- }
-
- BSSGP.send(ts_GMM_ATTACH_REQ(mi, old_ra, false, false, omit, omit));
+ BSSGP.send(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit));
alt {
[] as_mm_identity();
[] GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); { }
@@ -401,16 +389,9 @@ testcase TC_attach_auth_sai_timeout() runs on test_CT {
/* HLR rejects SAI, expect ATTACH REJECT */
private function f_TC_attach_auth_sai_reject(charstring id) runs on BSSGP_ConnHdlr {
- var MobileIdentityLV mi;
var RoutingAreaIdentificationV old_ra := f_random_RAI();
- if (ispresent(g_pars.p_tmsi)) {
- mi := valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
- } else {
- mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
- }
-
- BSSGP.send(ts_GMM_ATTACH_REQ(mi, old_ra, false, false, omit, omit));
+ BSSGP.send(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit));
alt {
[] as_mm_identity();
[] GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); {
@@ -430,16 +411,9 @@ testcase TC_attach_auth_sai_reject() runs on test_CT {
/* HLR never responds to UL REQ, expect ATTACH REJECT */
private function f_TC_attach_gsup_lu_timeout(charstring id) runs on BSSGP_ConnHdlr {
var BssgpDecoded bd;
- var MobileIdentityLV mi;
var RoutingAreaIdentificationV old_ra := f_random_RAI();
- if (ispresent(g_pars.p_tmsi)) {
- mi := valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
- } else {
- mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
- }
-
- BSSGP.send(ts_GMM_ATTACH_REQ(mi, old_ra, false, false, omit, omit));
+ BSSGP.send(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit));
f_gmm_auth();
/* Expect MSC to perform LU with HLR */
GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi));
@@ -465,16 +439,9 @@ testcase TC_attach_gsup_lu_timeout() runs on test_CT {
/* HLR rejects UL REQ, expect ATTACH REJECT */
private function f_TC_attach_gsup_lu_reject(charstring id) runs on BSSGP_ConnHdlr {
var BssgpDecoded bd;
- var MobileIdentityLV mi;
var RoutingAreaIdentificationV old_ra := f_random_RAI();
- if (ispresent(g_pars.p_tmsi)) {
- mi := valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
- } else {
- mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
- }
-
- BSSGP.send(ts_GMM_ATTACH_REQ(mi, old_ra, false, false, omit, omit));
+ BSSGP.send(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit));
f_gmm_auth();
/* Expect MSC to perform LU with HLR */
GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) {
@@ -502,16 +469,9 @@ testcase TC_attach_gsup_lu_reject() runs on test_CT {
/* Attempt of combined GPRS + IMSI attach: network should ACK only GPRS attach */
private function f_TC_attach_combined(charstring id) runs on BSSGP_ConnHdlr {
var BssgpDecoded bd;
- var MobileIdentityLV mi;
var RoutingAreaIdentificationV old_ra := f_random_RAI();
- if (ispresent(g_pars.p_tmsi)) {
- mi := valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
- } else {
- mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
- }
-
- BSSGP.send(ts_GMM_ATTACH_REQ(mi, old_ra, true, false, omit, omit));
+ BSSGP.send(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, true, false, omit, omit));
f_gmm_auth();
/* Expect MSC to perform LU with HLR */
GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi));
@@ -536,18 +496,11 @@ testcase TC_attach_combined() runs on test_CT {
/* Attempt of GPRS ATTACH in 'accept all' mode */
private function f_TC_attach_accept_all(charstring id) runs on BSSGP_ConnHdlr {
var BssgpDecoded bd;
- var MobileIdentityLV mi;
var RoutingAreaIdentificationV old_ra := f_random_RAI();
g_pars.net.expect_auth := false;
- if (ispresent(g_pars.p_tmsi)) {
- mi := valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
- } else {
- mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
- }
-
- BSSGP.send(ts_GMM_ATTACH_REQ(mi, old_ra, false, false, omit, omit));
+ BSSGP.send(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit));
f_gmm_auth();
BSSGP.receive(tr_BD_L3_MT(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?))) -> value bd {
f_process_attach_accept(bd.l3_mt.msgs.gprs_mm.attachAccept);
@@ -566,7 +519,6 @@ testcase TC_attach_accept_all() runs on test_CT {
/* Attempt of GPRS ATTACH in 'accept all' mode */
private function f_TC_attach_closed_foreign(charstring id) runs on BSSGP_ConnHdlr {
- var MobileIdentityLV mi;
var RoutingAreaIdentificationV old_ra := f_random_RAI();
/* Simulate a foreign IMSI */
@@ -575,12 +527,7 @@ private function f_TC_attach_closed_foreign(charstring id) runs on BSSGP_ConnHdl
g_pars.net.expect_auth := false;
- if (ispresent(g_pars.p_tmsi)) {
- mi := valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
- } else {
- mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
- }
- BSSGP.send(ts_GMM_ATTACH_REQ(mi, old_ra, false, false, omit, omit));
+ BSSGP.send(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit));
alt {
[] as_mm_identity();
[] BSSGP.receive(tr_BD_L3_MT(tr_GMM_ATTACH_REJECT('07'O))) {
@@ -606,16 +553,9 @@ testcase TC_attach_closed() runs on test_CT {
/* Routing Area Update from Unknown TLLI -> REJECT */
private function f_TC_rau_unknown(charstring id) runs on BSSGP_ConnHdlr {
- var MobileIdentityLV mi;
var RoutingAreaIdentificationV old_ra := f_random_RAI();
- if (ispresent(g_pars.p_tmsi)) {
- mi := valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
- } else {
- mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
- }
-
- BSSGP.send(ts_GMM_RAU_REQ(mi, GPRS_UPD_T_RA, old_ra, false, omit, omit));
+ BSSGP.send(ts_GMM_RAU_REQ(f_mi_get_lv(), GPRS_UPD_T_RA, old_ra, false, omit, omit));
alt {
[] BSSGP.receive(tr_BD_L3_MT(tr_GMM_RAU_REJECT('0a'O))) {
setverdict(pass);