2020-09-07 02:25:05 +00:00
|
|
|
module RAW_NS {
|
|
|
|
|
|
|
|
/* Osmocom NS test suite for NS in TTCN-3
|
|
|
|
* (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Released under the terms of GNU General Public License, Version 2 or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
2021-01-11 01:51:45 +00:00
|
|
|
import from Misc_Helpers all;
|
2020-09-07 02:25:05 +00:00
|
|
|
import from General_Types all;
|
|
|
|
import from Osmocom_Types all;
|
|
|
|
import from Osmocom_Gb_Types all;
|
2021-01-11 01:51:45 +00:00
|
|
|
import from NS_Emulation all;
|
2020-09-07 02:25:05 +00:00
|
|
|
import from NS_Types all;
|
|
|
|
import from BSSGP_Types all;
|
|
|
|
import from NS_Emulation all;
|
|
|
|
import from Native_Functions all;
|
|
|
|
import from IPL4asp_Types all;
|
2021-01-11 01:51:45 +00:00
|
|
|
import from NS_Provider_IPL4 all;
|
|
|
|
#ifdef NS_EMULATION_FR
|
|
|
|
import from NS_Provider_FR all;
|
|
|
|
#endif
|
2020-09-07 02:25:05 +00:00
|
|
|
|
|
|
|
public type component RAW_NS_CT {
|
|
|
|
/* UDP port towards the bottom (IUT) */
|
2021-01-11 01:51:45 +00:00
|
|
|
port NS_PROVIDER_PT NSCP[4];
|
|
|
|
var NS_Provider_IPL4_CT vc_NSP_IP[4];
|
|
|
|
#ifdef NS_EMULATION_FR
|
|
|
|
var NS_Provider_FR_CT vc_NSP_FR[4];
|
|
|
|
#endif
|
|
|
|
var NSConfiguration g_nsconfig;
|
2020-09-07 02:25:05 +00:00
|
|
|
timer g_T_guard;
|
|
|
|
}
|
|
|
|
|
|
|
|
public altstep as_Tguard() runs on RAW_NS_CT {
|
|
|
|
[] g_T_guard.timeout {
|
|
|
|
setverdict(fail, "Timeout of T_guard");
|
|
|
|
mtc.stop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-11 01:51:45 +00:00
|
|
|
function f_init_ns_codec(NSConfiguration ns_config, integer idx := 0, float guard_secs := 60.0, charstring id := testcasename()) runs on RAW_NS_CT {
|
2020-09-07 02:25:05 +00:00
|
|
|
var Result res;
|
|
|
|
|
|
|
|
if (not g_T_guard.running) {
|
|
|
|
g_T_guard.start(guard_secs);
|
|
|
|
activate(as_Tguard());
|
|
|
|
}
|
|
|
|
|
2021-01-11 01:51:45 +00:00
|
|
|
if (not isbound(g_nsconfig)) {
|
|
|
|
g_nsconfig := ns_config;
|
2020-09-07 02:25:05 +00:00
|
|
|
}
|
|
|
|
|
2021-01-11 01:51:45 +00:00
|
|
|
if (ischosen(ns_config.nsvc[idx].provider.ip)) {
|
|
|
|
/* Connect the UDP socket */
|
|
|
|
vc_NSP_IP[idx] := NS_Provider_IPL4_CT.create(id & "-provIP");
|
|
|
|
connect(self:NSCP[idx], vc_NSP_IP[idx]:NSE);
|
|
|
|
vc_NSP_IP[idx].start(NS_Provider_IPL4.main(ns_config.nsvc[idx], ns_config, id));
|
|
|
|
#ifdef NS_EMULATION_FR
|
|
|
|
} else if (ischosen(ns_config.nsvc[idx].provider.fr)) {
|
|
|
|
vc_NSP_FR[idx] := NS_Provider_FR_CT.create(id & "-provFR");
|
|
|
|
connect(self:NSCP[idx], vc_NSP_FR[idx]:NSE);
|
|
|
|
vc_NSP_FR[idx].start(NS_Provider_FR.main(ns_config.nsvc[idx], ns_config, id));
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported NS provider");
|
2020-09-07 02:25:05 +00:00
|
|
|
}
|
|
|
|
|
2021-01-11 01:51:45 +00:00
|
|
|
NSCP[idx].receive(NS_Provider_Evt:{link_status:=NS_PROV_LINK_STATUS_UP});
|
|
|
|
}
|
|
|
|
|
|
|
|
function f_clean_ns_codec() runs on RAW_NS_CT {
|
|
|
|
for (var integer i := 0; i < lengthof(vc_NSP_IP); i := i + 1) {
|
|
|
|
vc_NSP_IP[i].stop;
|
|
|
|
}
|
|
|
|
#ifdef NS_EMULATION_FR
|
|
|
|
for (var integer i := 0; i < lengthof(vc_NSP_FR); i := i + 1) {
|
|
|
|
vc_NSP_FR[i].stop;
|
|
|
|
}
|
|
|
|
#endif NS_EMULATION_FR
|
2020-09-07 02:25:05 +00:00
|
|
|
}
|
|
|
|
|
2020-10-26 22:09:16 +00:00
|
|
|
public altstep ax_rx_fail_on_any_ns(integer idx := 0) runs on RAW_NS_CT {
|
2021-01-11 01:51:45 +00:00
|
|
|
var PDU_NS nrf;
|
|
|
|
[] NSCP[idx].receive(PDU_NS: ?) -> value nrf {
|
2020-09-07 02:25:05 +00:00
|
|
|
setverdict(fail, "Received unexpected NS: ", nrf);
|
|
|
|
mtc.stop;
|
|
|
|
}
|
2020-10-26 22:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function f_ns_exp(template PDU_NS exp_rx, integer idx := 0) runs on RAW_NS_CT return PDU_NS {
|
2021-01-11 01:51:45 +00:00
|
|
|
var PDU_NS nrf;
|
2020-10-26 22:09:16 +00:00
|
|
|
log("f_ns_exp() expecting ", exp_rx);
|
|
|
|
/* last activated altstep has the lowest priority */
|
|
|
|
var default d := activate(ax_rx_fail_on_any_ns());
|
|
|
|
alt {
|
2021-01-11 01:51:45 +00:00
|
|
|
[] NSCP[idx].receive(PDU_NS: exp_rx) -> value nrf { }
|
2020-09-07 02:25:05 +00:00
|
|
|
}
|
2020-10-26 22:09:16 +00:00
|
|
|
deactivate(d);
|
2021-01-11 01:51:45 +00:00
|
|
|
return nrf;
|
2020-09-07 02:25:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* perform outbound NS-ALIVE procedure */
|
|
|
|
function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT {
|
2021-01-11 01:51:45 +00:00
|
|
|
NSCP[idx].send(t_NS_ALIVE);
|
2020-09-07 02:25:05 +00:00
|
|
|
alt {
|
2021-01-11 01:51:45 +00:00
|
|
|
[] NSCP[idx].receive(t_NS_ALIVE_ACK);
|
2020-09-07 02:25:05 +00:00
|
|
|
[] NSCP[idx].receive { repeat; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* perform outbound NS-ALIVE procedure */
|
|
|
|
function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT {
|
|
|
|
timer T := tout;
|
2021-01-11 01:51:45 +00:00
|
|
|
NSCP[idx].send(t_NS_ALIVE);
|
2020-09-07 02:25:05 +00:00
|
|
|
T.start;
|
|
|
|
alt {
|
2021-01-11 01:51:45 +00:00
|
|
|
[] NSCP[idx].receive(t_NS_ALIVE_ACK) {
|
2020-09-07 02:25:05 +00:00
|
|
|
setverdict(fail, "Received unexpected NS-ALIVE ACK");
|
|
|
|
}
|
|
|
|
[] NSCP[idx].receive { repeat; }
|
|
|
|
[] T.timeout {
|
|
|
|
setverdict(pass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-07 03:21:50 +00:00
|
|
|
function f_outgoing_ns_reset(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT {
|
|
|
|
timer T := tout;
|
2021-01-11 01:51:45 +00:00
|
|
|
var template PDU_NS reset := ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[idx].nsvci, g_nsconfig.nsei)
|
|
|
|
NSCP[idx].send(reset);
|
2020-09-07 03:21:50 +00:00
|
|
|
T.start;
|
|
|
|
alt {
|
2021-01-11 01:51:45 +00:00
|
|
|
[] NSCP[idx].receive(ts_NS_RESET_ACK(g_nsconfig.nsvc[idx].nsvci, g_nsconfig.nsei)) {
|
2020-09-07 03:21:50 +00:00
|
|
|
setverdict(pass);
|
|
|
|
}
|
|
|
|
[] NSCP[idx].receive { repeat; }
|
|
|
|
[] T.timeout {
|
|
|
|
setverdict(fail, "Failed to receive a RESET ACK");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-07 02:25:05 +00:00
|
|
|
/* perform outbound NS-BLOCK procedure */
|
|
|
|
function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT {
|
2021-01-11 01:51:45 +00:00
|
|
|
NSCP[idx].send(ts_NS_BLOCK(cause, g_nsconfig.nsvc[idx].nsvci));
|
2020-09-07 02:25:05 +00:00
|
|
|
alt {
|
2021-01-11 01:51:45 +00:00
|
|
|
[] NSCP[idx].receive(tr_NS_BLOCK_ACK(g_nsconfig.nsvc[idx].nsvci));
|
|
|
|
[] NSCP[idx].receive { repeat; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* perform outbound NS-UNBLOCK procedure */
|
|
|
|
function f_outgoing_ns_unblock(integer idx := 0) runs on RAW_NS_CT {
|
|
|
|
NSCP[idx].send(t_NS_UNBLOCK);
|
|
|
|
alt {
|
|
|
|
[] NSCP[idx].receive(t_NS_UNBLOCK_ACK);
|
2020-09-07 02:25:05 +00:00
|
|
|
[] NSCP[idx].receive { repeat; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* receive NS-ALIVE and ACK it */
|
|
|
|
altstep as_rx_alive_tx_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
|
2021-01-11 01:51:45 +00:00
|
|
|
[] NSCP[idx].receive(t_NS_ALIVE) {
|
|
|
|
NSCP[idx].send(t_NS_ALIVE_ACK);
|
2020-09-07 02:25:05 +00:00
|
|
|
if (not oneshot) { repeat; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Transmit BSSGP RESET for given BVCI and expect ACK */
|
2020-10-09 12:56:54 +00:00
|
|
|
function f_tx_bvc_reset_rx_ack(BssgpBvci bvci, template (omit) BssgpCellId tx_cell_id, template BssgpCellId rx_cell_id,
|
|
|
|
integer idx := 0, boolean exp_ack := true)
|
2020-09-07 02:25:05 +00:00
|
|
|
runs on RAW_NS_CT {
|
|
|
|
var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS, bvci,
|
2020-10-09 12:56:54 +00:00
|
|
|
tx_cell_id));
|
2020-09-07 02:25:05 +00:00
|
|
|
timer T := 5.0;
|
2021-01-11 01:51:45 +00:00
|
|
|
NSCP[idx].send(ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)));
|
2020-09-07 02:25:05 +00:00
|
|
|
T.start;
|
|
|
|
alt {
|
2021-01-11 01:51:45 +00:00
|
|
|
[exp_ack] NSCP[idx].receive(tr_NS_UNITDATA(t_SduCtrlB, 0,
|
|
|
|
decmatch tr_BVC_RESET_ACK(bvci, rx_cell_id))) {
|
2020-09-07 02:25:05 +00:00
|
|
|
setverdict(pass);
|
|
|
|
}
|
|
|
|
[exp_ack] T.timeout {
|
|
|
|
setverdict(fail, "No response to BVC-RESET");
|
|
|
|
}
|
|
|
|
[not exp_ack] T.timeout {
|
|
|
|
setverdict(pass);
|
|
|
|
}
|
|
|
|
[] NSCP[idx].receive { repeat; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Receive a BSSGP RESET for given BVCI and ACK it */
|
2020-10-09 12:56:54 +00:00
|
|
|
altstep as_rx_bvc_reset_tx_ack(BssgpBvci bvci, template BssgpCellId rx_cell_id, template (omit) BssgpCellId tx_cell_id,
|
|
|
|
boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
|
2021-01-11 01:51:45 +00:00
|
|
|
var PDU_NS ns_rf;
|
|
|
|
[] NSCP[idx].receive(tr_NS_UNITDATA(t_SduCtrlB, 0,
|
|
|
|
decmatch tr_BVC_RESET(?, bvci, rx_cell_id)))
|
2020-09-07 02:25:05 +00:00
|
|
|
-> value ns_rf {
|
2021-01-11 01:51:45 +00:00
|
|
|
var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.pDU_NS_Unitdata.nS_SDU);
|
2020-10-09 12:56:54 +00:00
|
|
|
var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET_ACK(bvci, tx_cell_id));
|
2021-01-11 01:51:45 +00:00
|
|
|
NSCP[idx].send(ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)));
|
2020-09-07 02:25:05 +00:00
|
|
|
if (not oneshot) { repeat; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Receive a BSSGP UNBLOCK for given BVCI and ACK it */
|
|
|
|
altstep as_rx_bvc_unblock_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
|
2021-01-11 01:51:45 +00:00
|
|
|
var PDU_NS ns_rf;
|
2021-02-05 12:05:06 +00:00
|
|
|
[] NSCP[idx].receive(tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_UNBLOCK(bvci))) -> value ns_rf {
|
2021-01-11 01:51:45 +00:00
|
|
|
var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.pDU_NS_Unitdata.nS_SDU);
|
2021-02-05 12:05:06 +00:00
|
|
|
var PDU_BSSGP bssgp_tx := valueof(ts_BVC_UNBLOCK_ACK(bvci));
|
2021-01-11 01:51:45 +00:00
|
|
|
NSCP[idx].send(ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)));
|
2020-09-07 02:25:05 +00:00
|
|
|
if (not oneshot) { repeat; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Receive a BSSGP FLOW-CONTROL-BVC and ACK it */
|
|
|
|
altstep as_rx_bvc_fc_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
|
2021-01-11 01:51:45 +00:00
|
|
|
var PDU_NS ns_rf;
|
|
|
|
[] NSCP[idx].receive(tr_NS_UNITDATA(t_SduCtrlB, bvci,
|
|
|
|
decmatch tr_BVC_FC_BVC))
|
2020-09-07 02:25:05 +00:00
|
|
|
-> value ns_rf {
|
2021-01-11 01:51:45 +00:00
|
|
|
var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.pDU_NS_Unitdata.nS_SDU);
|
2020-09-07 02:25:05 +00:00
|
|
|
var OCT1 tag := bssgp_rx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value;
|
2021-02-05 12:05:06 +00:00
|
|
|
var PDU_BSSGP bssgp_tx := valueof(ts_BVC_FC_BVC_ACK(tag));
|
2021-01-11 01:51:45 +00:00
|
|
|
NSCP[idx].send(ts_NS_UNITDATA(t_SduCtrlB, bvci, enc_PDU_BSSGP(bssgp_tx)));
|
2020-09-07 02:25:05 +00:00
|
|
|
if (not oneshot) { repeat; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************************
|
|
|
|
* Classic Gb/IP bring-up test cases using NS-{RESET,BLOCK,UNBLOCK} and no IP-SNS *
|
|
|
|
**********************************************************************************/
|
|
|
|
|
|
|
|
/* Receive a NS-RESET and ACK it */
|
|
|
|
public altstep as_rx_ns_reset_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
|
2021-01-11 01:51:45 +00:00
|
|
|
var PDU_NS ns_rf;
|
|
|
|
[] NSCP[idx].receive(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, g_nsconfig.nsvc[idx].nsvci,
|
|
|
|
g_nsconfig.nsei)) -> value ns_rf {
|
|
|
|
NSCP[idx].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[idx].nsvci, g_nsconfig.nsei));
|
2020-09-07 02:25:05 +00:00
|
|
|
if (not oneshot) { repeat; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Receive a NS-UNBLOCK and ACK it */
|
|
|
|
public altstep as_rx_ns_unblock_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
|
2021-01-11 01:51:45 +00:00
|
|
|
var PDU_NS ns_rf;
|
|
|
|
[] NSCP[idx].receive(t_NS_UNBLOCK) -> value ns_rf {
|
|
|
|
NSCP[idx].send(t_NS_UNBLOCK_ACK);
|
2020-09-07 02:25:05 +00:00
|
|
|
if (not oneshot) { repeat; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-11 01:56:03 +00:00
|
|
|
/* Receive a NS-BLOCK and ACK it */
|
|
|
|
public altstep as_rx_ns_block_ack(boolean oneshot := false, integer idx := 0, template NsCause cause := *, template Nsvci nsvci := *) runs on RAW_NS_CT {
|
|
|
|
var PDU_NS ns_rf;
|
|
|
|
[] NSCP[idx].receive(tr_NS_BLOCK(cause, nsvci)) -> value ns_rf {
|
|
|
|
NSCP[idx].send(ts_NS_BLOCK_ACK(oct2int(ns_rf.pDU_NS_Block.nS_VCI.nS_VCI)));
|
|
|
|
if (not oneshot) { repeat; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-07 02:25:05 +00:00
|
|
|
}
|