From f8a9df558f869781624d2d41eb9d9cf28a86ae4f Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Sat, 12 Mar 2022 13:29:26 +0300 Subject: [PATCH] BTS_Tests: add a hierarchy of L1CTL/LAPDm/DCCH altsteps In TTCN-3 it's possible to call one altstep from another. This allows us to build complex hierarchies of simple altsteps, where one is built on top of the others. I call this altstep-oriented programming. This change adds the following hierarchy: * as_l1ctl_dl_msg() - triggers on receipt of a L1CTL DATA.ind matching the given RSL chan_nr/link_id and data templates; * as_dl_lapdm_dummy() - triggers on receipt of dummy LAPDm func=UI frames with empty payload (repeats by default); * as_dl_dcch_lapdm_ab() - triggers on receipt of a Downlink DCCH containing a L2 payload that matches the given LAPDm frame; * as_dl_dcch_pdu() - triggers on receipt of a LAPDm AB frame with a L3 payload matching the given template. All of these altsteps (except as_dl_lapdm_dummy()) expect an 'out' parameter, which will hold the matched (and possibly decoded) data. Example: var PDU_ML3_NW_MS pdu; alt { [] as_dl_lapdm_dummy(); /* Ignore empty LAPDm func=UI frames */ [] as_dl_dcch_pdu(pdu, tr_CM_SERV_ACC) { setverdict(pass); } [] as_dl_dcch_pdu(pdu, tr_CM_SERV_REJ) { setverdict(fail); } [] as_dl_dcch_pdu(pdu, ?) { setverdict(inconc, "Unexpected PDU"); } } Change-Id: Ia4d502488cbb6bccc4d2656206ae6649bfa71007 Related: SYS#5838 --- bts/BTS_Tests.ttcn | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn index b95648a70..39dca7acd 100644 --- a/bts/BTS_Tests.ttcn +++ b/bts/BTS_Tests.ttcn @@ -873,6 +873,62 @@ friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, } } +/* This altstep triggers on receipt of a L1CTL DATA.ind matching the given + * RSL chan_nr/link_id and data templates. Used as a base for other altsteps. */ +private altstep as_l1ctl_dl_msg(out L1ctlDlMessage msg, + template (present) octetstring tr_data := ?, + template (present) RslChannelNr chan_nr := ?, + template (present) RslLinkId link_id := ?) +runs on ConnHdlr { + [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr, link_id, tr_data)) -> value msg; +} + +/* This altstep is built on top of as_l1ctl_dl_msg(), and triggers on receipt + * of dummy LAPDm func=UI frames with empty payload. Repeats by default. */ +private altstep as_dl_lapdm_dummy(template (present) RslChannelNr chan_nr := ?, + template (present) RslLinkId link_id := ?, + template (present) LapdmSapi sapi := ?, + boolean do_repeat := true) +runs on ConnHdlr { + template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, ''O); + var L1ctlDlMessage dl_msg; + + [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, chan_nr, link_id) { + if (do_repeat) { + repeat; + } + } +} + +/* This altstep triggers on receipt of a Downlink DCCH containing a L2 payload + * that matches the given LAPDm frame. The L2 is treated as LapdmFrameAB. */ +private altstep as_dl_dcch_lapdm_ab(out LapdmFrameAB frame, + template (present) LapdmFrameAB tr_frame := ?, + template (present) RslLinkId link_id := ?) +runs on ConnHdlr { + var L1ctlDlMessage dl_msg; + + [] as_l1ctl_dl_msg(dl_msg, decmatch tr_frame, g_chan_nr, link_id) { + frame := dec_LapdmFrameAB(dl_msg.payload.data_ind.payload); + } +} + +/* This altstep is built on top of as_dl_dcch_lapdm_ab(), and triggers on receipt + * of a LAPDm AB frame with a L3 payload matching the given template. The L3 + * payload is treated as PDU_ML3_NW_MS. */ +private altstep as_dl_dcch_pdu(out PDU_ML3_NW_MS pdu, + template (present) PDU_ML3_NW_MS tr_pdu := ?, + template (present) GsmSapi sapi := 0) +runs on ConnHdlr { + template (present) LapdmFrame tr_frame := tr_LAPDm_UI(sapi, true, decmatch tr_pdu); + template (present) RslLinkId link_id := tr_RslLinkID_DCCH(sapi); + var LapdmFrameAB lapdm_frame; + + [] as_dl_dcch_lapdm_ab(lapdm_frame, tr_frame.ab, link_id) { + pdu := dec_PDU_ML3_NW_MS(lapdm_frame.payload); + } +} + /*********************************************************************** * Channel Activation / Deactivation ***********************************************************************/