bts: Factor out mobile-originated LAPDm establishment

which avoids us to have to copy+pate this between several test cases.

Change-Id: I8da753bb3d809ec09f9380bb4bac666ceaf61f00
This commit is contained in:
Harald Welte 2019-06-02 22:58:58 +02:00
parent b2a3034826
commit 76771f1cc2
1 changed files with 29 additions and 24 deletions

View File

@ -290,6 +290,31 @@ private function fp_common_fini() runs on ConnHdlr
f_lapdm_exit();
}
/* Mobile-Originated LAPDm establishment on given Link ID */
private function f_establish_mo(RslLinkId link_id) runs on ConnHdlr
{
var integer sapi := link_id.sapi;
var boolean is_sacch := false;
if (link_id.c == SACCH) {
is_sacch := true;
}
var octetstring l3_mo := f_rnd_octstring(5);
/* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */
if (is_sacch) {
/* no payload permitted, as this is not contention resolution */
l3_mo := ''O;
LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
} else {
LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo));
}
/* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */
LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo)));
}
/* Verify that the BTS is re-transmitting SABM messages after T200 timeout, inspired
by 3GPP TS 51.010-1 25.2.1.1.2.1 + 25.2.1.2.4 */
private function f_TC_sabm_retransmit_bts(charstring id) runs on ConnHdlr {
@ -547,11 +572,7 @@ private function f_TC_iframe_seq_and_ack(charstring id) runs on ConnHdlr {
RSL.clear;
LAPDM.clear;
/* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */
LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3)));
RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
/* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */
LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3)));
f_establish_mo(link_id);
var integer last_ns_rx := 0;
@ -804,22 +825,9 @@ private function f_TC_segm_concat(charstring id, RslLinkId link_id) runs on Conn
RSL.clear;
LAPDM.clear;
var octetstring l3_mo := f_rnd_octstring(5);
f_establish_mo(link_id);
/* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */
if (is_sacch) {
/* no payload permitted, as this is not contention resolution */
l3_mo := ''O;
LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
} else {
LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo));
}
/* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */
LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo)));
l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS);
var octetstring l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS);
deactivate(d);
@ -882,10 +890,7 @@ private function f_TC_t200_n200(charstring id) runs on ConnHdlr {
RSL.clear;
LAPDM.clear;
var octetstring l3_mo := f_rnd_octstring(20);
LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo));
LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo)));
f_establish_mo(link_id);
var octetstring l3_mt := f_rnd_octstring(20);
RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt));