msc: Introduce BSC_ConnHdlrNetworkPars

This record collects information about the network configuration,
such as whether or not authentication, tmsi allocation and/or
encryption are enabled.  The individual helper functions can then
react according to this information, without having to pass long
argument lists along the call chain.

Change-Id: I01a931f1cbbca4593fff2fd12689f040ceaa79b6
This commit is contained in:
Harald Welte 2018-01-27 23:44:41 +01:00
parent d95da56490
commit de37149345
2 changed files with 55 additions and 41 deletions

View File

@ -40,6 +40,13 @@ type record AuthVector {
/* FIXME: 3G elements */
}
type record BSC_ConnHdlrNetworkPars {
OCT1 kc_support,
boolean expect_tmsi,
boolean expect_auth,
boolean expect_ciph
}
type record BSC_ConnHdlrPars {
SCCP_PAR_Address sccp_addr_own,
SCCP_PAR_Address sccp_addr_peer,
@ -50,7 +57,8 @@ type record BSC_ConnHdlrPars {
OCT4 tmsi optional,
BSSMAP_IE_ClassmarkInformationType2 cm2,
BSSMAP_IE_ClassmarkInformationType3 cm3 optional,
AuthVector vec optional
AuthVector vec optional,
BSC_ConnHdlrNetworkPars net
};
/* altstep for the global guard timer */
@ -133,7 +141,7 @@ runs on BSC_ConnHdlr {
}
/* helper function to fully establish a dedicated channel */
function f_establish_fully(MobileIdentityLV mi, boolean expect_auth, boolean expect_ciph)
function f_establish_fully(MobileIdentityLV mi)
runs on BSC_ConnHdlr {
var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
var PDU_DTAP_MT dtap_mt;
@ -141,8 +149,8 @@ runs on BSC_ConnHdlr {
/* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
f_bssap_compl_l3(l3_info);
f_mm_common(expect_auth, expect_ciph);
if (expect_ciph) {
f_mm_common();
if (g_pars.net.expect_ciph) {
/* implicit CM SERVICE ACCEPT? */
} else {
/* explicit CM SERVICE ACCEPT */
@ -151,7 +159,7 @@ runs on BSC_ConnHdlr {
}
/* helper function to fully establish a dedicated channel */
function f_establish_fully_pag(MobileIdentityLV mi, boolean expect_auth, boolean expect_ciph)
function f_establish_fully_pag(MobileIdentityLV mi)
runs on BSC_ConnHdlr {
var PDU_ML3_MS_NW l3_info := valueof(ts_PAG_RESP(mi));
var PDU_DTAP_MT dtap_mt;
@ -159,7 +167,7 @@ runs on BSC_ConnHdlr {
/* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
f_bssap_compl_l3(l3_info);
f_mm_common(expect_auth, expect_ciph);
f_mm_common();
}
@ -205,9 +213,9 @@ function f_gen_auth_vec_2g() return AuthVector {
}
function f_mm_common(boolean expect_auth, boolean expect_ciph) runs on BSC_ConnHdlr
function f_mm_common() runs on BSC_ConnHdlr
{
if (expect_auth) {
if (g_pars.net.expect_auth) {
g_pars.vec := f_gen_auth_vec_2g();
var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(g_pars.vec.rand,
g_pars.vec.sres,
@ -219,14 +227,13 @@ function f_mm_common(boolean expect_auth, boolean expect_ciph) runs on BSC_ConnH
BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G(g_pars.vec.sres)));
}
if (expect_ciph) {
if (g_pars.net.expect_ciph) {
BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc));
BSSAP.send(ts_BSSMAP_CipherModeCompl('02'O));
}
}
function f_perform_lu(boolean expect_auth, boolean expect_tmsi, boolean send_early_cm,
boolean expect_ciph := false)
function f_perform_lu(boolean send_early_cm)
runs on BSC_ConnHdlr {
var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi)
var PDU_DTAP_MT dtap_mt;
@ -241,7 +248,7 @@ runs on BSC_ConnHdlr {
BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3));
}
f_mm_common(expect_auth, expect_ciph);
f_mm_common();
/* Expect MSC to perform LU with HLR */
GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi));
@ -252,7 +259,7 @@ runs on BSC_ConnHdlr {
alt {
[] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) -> value dtap_mt {
var PDU_ML3_LocationUpdateAccept lu_acc := dtap_mt.dtap.msgs.mm.locationUpdateAccept;
if (expect_tmsi) {
if (g_pars.net.expect_tmsi) {
if (not ispresent(lu_acc.mobileIdentityTLV) or
not ischosen(lu_acc.mobileIdentityTLV.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi)) {
setverdict(fail, "Expected TMSI but no TMSI was allocated");
@ -299,9 +306,6 @@ function f_foo() runs on BSC_ConnHdlr{
/* parameters related to a (MO?) voice call */
type record CallParameters {
boolean expect_auth, /* do we expect AUTHENTICATE from network */
boolean expect_ciph, /* do we expect CIPHER MODE from network */
/* CC related parameters */
hexstring called_party, /* whom are we calling */
integer transaction_id optional, /* which TS 04.08 CC transaction ID to use */
@ -330,8 +334,6 @@ type record CallParameters {
}
template (value) CallParameters t_CallParams(hexstring called, integer tid) := {
expect_auth := false,
expect_ciph := false,
called_party := called,
transaction_id := tid,
bearer_cap := valueof(ts_Bcap_voice),
@ -367,7 +369,7 @@ runs on BSC_ConnHdlr {
} else {
mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
}
f_establish_fully(mi, cpars.expect_auth, cpars.expect_ciph);
f_establish_fully(mi);
/* Create MNCC and MGCP expect */
f_create_mncc_expect(hex2str(cpars.called_party));

View File

@ -354,6 +354,12 @@ function f_gen_msisdn(integer suffix) return hexstring {
/* FIXME: move into BSC_ConnectionHandler? */
function f_start_handler(void_fn fn, charstring id, integer imsi_suffix) runs on MTC_CT return BSC_ConnHdlr {
var BSC_ConnHdlr vc_conn;
var BSC_ConnHdlrNetworkPars net_pars := {
kc_support := '0A'O, /* A5/1 and A5/3 enabled */
expect_tmsi := true,
expect_auth := false,
expect_ciph := false
};
var BSC_ConnHdlrPars pars := {
sccp_addr_own := g_sccp_addr_own,
sccp_addr_peer := g_sccp_addr_peer,
@ -364,7 +370,8 @@ function f_start_handler(void_fn fn, charstring id, integer imsi_suffix) runs on
tmsi := omit,
cm2 := valueof(ts_CM2_default),
cm3 := omit,
vec := omit
vec := omit,
net := net_pars
};
vc_conn := BSC_ConnHdlr.create(id);
@ -400,7 +407,7 @@ function f_vty_config(TELNETasp_PT pt, charstring config_node, charstring cmd)
private function f_tc_lu_imsi_noauth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
f_init_handler(pars);
f_perform_lu(false, true, true);
f_perform_lu(true);
}
testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT {
var BSC_ConnHdlr vc_conn;
@ -411,8 +418,9 @@ testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT {
}
private function f_tc_lu_imsi_noauth_notmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
pars.net.expect_tmsi := false;
f_init_handler(pars);
f_perform_lu(false, false, true);
f_perform_lu(true);
}
testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT {
var BSC_ConnHdlr vc_conn;
@ -477,8 +485,9 @@ testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT {
}
private function f_tc_lu_imsi_auth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
pars.net.expect_auth := true;
f_init_handler(pars);
f_perform_lu(true, true, true);
f_perform_lu(true);
}
testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT {
var BSC_ConnHdlr vc_conn;
@ -532,7 +541,7 @@ private function f_tc_lu_and_mo_call(charstring id, BSC_ConnHdlrPars pars) runs
cpars.mgcp_connection_id_bss := '22222'H;
cpars.mgcp_connection_id_mss := '33333'H;
f_perform_lu(cpars.expect_auth, true, true);
f_perform_lu(true);
f_mo_call(cpars);
}
testcase TC_lu_and_mo_call() runs on MTC_CT {
@ -883,7 +892,7 @@ testcase TC_emerg_call_imei_reject() runs on MTC_CT {
private function f_tc_emerg_call_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
f_init_handler(pars);
/* First perform location update to ensure subscriber is known */
f_perform_lu(false, true, true);
f_perform_lu(true);
/* Then issue emergency call identified by IMSI */
f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
}
@ -900,7 +909,7 @@ private function f_tc_cm_serv_req_vgcs_reject(charstring id, BSC_ConnHdlrPars pa
f_init_handler(pars);
/* First perform location update to ensure subscriber is known */
f_perform_lu(false, true, true);
f_perform_lu(true);
var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VGCS, mi));
@ -921,7 +930,7 @@ private function f_tc_cm_serv_req_vbs_reject(charstring id, BSC_ConnHdlrPars par
f_init_handler(pars);
/* First perform location update to ensure subscriber is known */
f_perform_lu(false, true, true);
f_perform_lu(true);
var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VBS, mi));
@ -942,7 +951,7 @@ private function f_tc_cm_serv_req_lcs_reject(charstring id, BSC_ConnHdlrPars par
f_init_handler(pars);
/* First perform location update to ensure subscriber is known */
f_perform_lu(false, true, true);
f_perform_lu(true);
var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_LCS, mi));
@ -963,7 +972,7 @@ private function f_tc_cm_reest_req_reject(charstring id, BSC_ConnHdlrPars pars)
f_init_handler(pars);
/* First perform location update to ensure subscriber is known */
f_perform_lu(false, true, true);
f_perform_lu(true);
var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REEST_REQ(0, mi));
@ -1019,9 +1028,12 @@ testcase TC_lu_auth_2G_fail() runs on MTC_CT {
vc_conn.done;
}
/* A5/1 + A5/3 permitted on network side, and MS capable to do it */
private function f_tc_lu_imsi_auth_tmsi_encr_13_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
pars.net.expect_auth := true;
pars.net.expect_ciph := true;
f_init_handler(pars);
f_perform_lu(true, true, true, true);
f_perform_lu(true);
}
testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT {
var BSC_ConnHdlr vc_conn;
@ -1106,9 +1118,9 @@ testcase TC_cl3_rnd_payload() runs on MTC_CT {
private function f_tc_establish_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
f_init_handler(pars);
f_perform_lu(false, true, true, false);
f_perform_lu(true);
f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false);
f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
f_expect_clear();
}
testcase TC_establish_and_nothing() runs on MTC_CT {
@ -1125,9 +1137,9 @@ private function f_tc_mo_setup_and_nothing(charstring id, BSC_ConnHdlrPars pars)
var CallParameters cpars := valueof(t_CallParams('12345'H, 0));
f_perform_lu(false, true, true, false);
f_perform_lu(true);
f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false);
f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
f_create_mncc_expect(hex2str(cpars.called_party));
f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
@ -1150,9 +1162,9 @@ private function f_tc_mo_crcx_ran_timeout(charstring id, BSC_ConnHdlrPars pars)
var MNCC_PDU mncc;
var MgcpCommand mgcp_cmd;
f_perform_lu(false, true, true, false);
f_perform_lu(true);
f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false);
f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
f_create_mncc_expect(hex2str(cpars.called_party));
f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
@ -1184,9 +1196,9 @@ private function f_tc_mo_crcx_ran_reject(charstring id, BSC_ConnHdlrPars pars) r
var MNCC_PDU mncc;
var MgcpCommand mgcp_cmd;
f_perform_lu(false, true, true, false);
f_perform_lu(true);
f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false);
f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
f_create_mncc_expect(hex2str(cpars.called_party));
f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
@ -1246,7 +1258,7 @@ private function f_mt_call_start(inout CallParameters cpars) runs on BSC_ConnHdl
var MgcpCommand mgcp_cmd;
var OCT4 tmsi;
f_perform_lu(false, true, true, false);
f_perform_lu(true);
if (isvalue(g_pars.tmsi)) {
tmsi := g_pars.tmsi;
} else {
@ -1262,7 +1274,7 @@ private function f_mt_call_start(inout CallParameters cpars) runs on BSC_ConnHdl
/* MSC->BSC: expect PAGING from MSC */
BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi));
/* MS -> MSC: PAGING RESPONSE */
f_establish_fully_pag(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false);
f_establish_fully_pag(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
@ -1390,7 +1402,7 @@ private function f_tc_gsup_cancel(charstring id, BSC_ConnHdlrPars pars) runs on
cpars.mgcp_connection_id_mss := '33333'H;
/* Location Update to make subscriber known */
f_perform_lu(cpars.expect_auth, true, true);
f_perform_lu(true);
/* First MO call should succeed */
f_mo_call(cpars);