summaryrefslogtreecommitdiffstats
path: root/stp
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2019-11-05 16:55:30 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2019-11-12 13:05:46 +0100
commit829dac4358bb691e288ba9e8a3ede0d717ea3a17 (patch)
tree9cbfbd1bc67d281fb69edef0495f0700c8b04986 /stp
parentdc9b6919aa25c3c2419cea3d5be4cf4ca558a5ad (diff)
stp: Add tests for running STP in M3UA ASP role
Diffstat (limited to 'stp')
-rw-r--r--stp/STP_Tests_M3UA.ttcn143
-rw-r--r--stp/osmo-stp.cfg9
2 files changed, 149 insertions, 3 deletions
diff --git a/stp/STP_Tests_M3UA.ttcn b/stp/STP_Tests_M3UA.ttcn
index 3415e525..5c15c6f0 100644
--- a/stp/STP_Tests_M3UA.ttcn
+++ b/stp/STP_Tests_M3UA.ttcn
@@ -36,14 +36,20 @@ import from STP_Tests_Common all;
modulepar {
integer mp_stp_m3ua_port := 2905;
+ integer mp_stp_m3ua_clnt_port := 2906;
integer mp_local_m3ua_port := 9999;
}
-private const integer NR_M3UA := 3;
+private const integer NR_M3UA := 3; /* number of M3UA clients in ATS */
+private const integer NR_M3UA_SRV := 1; /* number of M3UA servres in ATS */
+
+private function M3UA_SRV(integer idx) return integer {
+ return NR_M3UA+idx;
+}
type component RAW_M3UA_CT extends Test_CT {
- port M3UA_CODEC_PT M3UA[NR_M3UA];
- var integer g_m3ua_conn_id[NR_M3UA];
+ port M3UA_CODEC_PT M3UA[NR_M3UA+NR_M3UA_SRV];
+ var integer g_m3ua_conn_id[NR_M3UA+NR_M3UA_SRV];
}
private template PortEvent tr_SctpAssocChange := {
@@ -56,6 +62,10 @@ private template PortEvent tr_SctpPeerAddrChange := {
sctpPeerAddrChange := ?
}
}
+private template PortEvent tr_SctpConnOpened := {
+ connOpened := ?
+}
+
private altstep as_m3ua_sctp() runs on RAW_M3UA_CT {
[] any from M3UA.receive(tr_SctpAssocChange) { repeat; }
@@ -93,6 +103,16 @@ friend function f_M3UA_connect(integer i) runs on RAW_M3UA_CT {
g_m3ua_conn_id[i] := res.connId;
}
+friend function f_M3UA_listen(integer i) runs on RAW_M3UA_CT {
+ var Result res;
+ res := M3UA_CodecPort_CtrlFunct.f_IPL4_listen(M3UA[i], mp_local_ip, mp_local_m3ua_port+i,
+ {sctp:=valueof(ts_SCTP)});
+ if (not ispresent(res.connId)) {
+ setverdict(fail, "Could not bind M3UA socket, check your configuration");
+ mtc.stop;
+ }
+}
+
friend function f_init_m3ua() runs on RAW_M3UA_CT {
var integer i;
@@ -106,6 +126,26 @@ friend function f_init_m3ua() runs on RAW_M3UA_CT {
}
}
+friend function f_init_m3ua_srv() runs on RAW_M3UA_CT {
+ var integer i;
+ var PortEvent sctp_evt;
+
+ for (i := NR_M3UA; i < NR_M3UA+NR_M3UA_SRV; i:=i+1) {
+ map(self:M3UA[i], system:M3UA_CODEC_PT);
+ /* bind+ listen */
+ f_M3UA_listen(i);
+ /* wait for accept() */
+ M3UA[i].receive(tr_SctpConnOpened) -> value sctp_evt {
+ g_m3ua_conn_id[i] := sctp_evt.connOpened.connId;
+ }
+ }
+}
+
+
+/***********************************************************************
+ * Test the STP in M3UA SG role (we are ASP)
+ ***********************************************************************/
+
/* perform an outbound ASP-UP procedure */
friend function f_M3UA_asp_up(integer idx, template (omit) OCT4 aspid := omit) runs on RAW_M3UA_CT {
f_M3UA_send(idx, ts_M3UA_ASPUP(aspid));
@@ -417,6 +457,97 @@ testcase TC_rkm_unreg_active() runs on RAW_M3UA_CT {
/* FIXME: we now may have changed the state on the STP side! */
}
+/***********************************************************************
+ * Test the STP in M3UA ASP role (we are SG)
+ ***********************************************************************/
+
+/* expect/perform an inbound ASP-UP procedure */
+friend function f_M3UA_CLNT_asp_up(integer idx, template OCT4 aspid := omit) runs on RAW_M3UA_CT {
+ f_M3UA_exp(idx, tr_M3UA_ASPUP(aspid));
+ f_M3UA_send(idx, ts_M3UA_ASPUP_ACK);
+}
+
+/* expect/perform an inbound ASP-ACTIVATE procedure */
+friend function f_M3UA_CLNT_asp_act(integer idx, template M3UA_Traffic_Mode_Type tmt := omit,
+ template (omit) OCT4 rctx := omit) runs on RAW_M3UA_CT {
+ f_M3UA_exp(idx, tr_M3UA_ASPAC(tmt, rctx));
+ f_M3UA_send(idx, ts_M3UA_ASPAC_ACK(tmt, rctx));
+}
+
+/* expect/perform inbound ASP-UP and ASP-ACT, optionally send interemittent NOTIFY */
+friend function f_M3UA_CLNT_asp_up_act(integer idx, template M3UA_Traffic_Mode_Type tmt := omit,
+ template OCT4 rctx := omit,
+ template (omit) OCT2 ntfy_after_up := c_M3UA_ST_I_AS_INACTIVE,
+ template (omit) OCT2 ntfy_after_act := c_M3UA_ST_I_AS_ACTIVE)
+runs on RAW_M3UA_CT {
+ f_M3UA_CLNT_asp_up(idx, omit);
+ if (not istemplatekind(ntfy_after_up, "omit")) {
+ f_M3UA_send(idx, ts_M3UA_NOTIFY(c_M3UA_ST_T_STATE_CHG, ntfy_after_up, rctx));
+ }
+ f_M3UA_CLNT_asp_act(idx, tmt, rctx);
+ if (not istemplatekind(ntfy_after_act, "omit")) {
+ f_M3UA_send(idx, ts_M3UA_NOTIFY(c_M3UA_ST_T_STATE_CHG, ntfy_after_act, rctx));
+ }
+}
+
+
+/* Expect inbound connection from ASP/SCTP-client, followed by ASP-UP */
+testcase TC_clnt_connect_asp_up() runs on RAW_M3UA_CT {
+ f_init_m3ua();
+ f_init_m3ua_srv();
+
+ f_M3UA_CLNT_asp_up(M3UA_SRV(0));
+}
+
+/* Expect inbound connection from ASP/SCTP-client, followed by ASP-UP + ASP-ACT */
+testcase TC_clnt_asp_act() runs on RAW_M3UA_CT {
+ f_init_m3ua();
+ f_init_m3ua_srv();
+
+ f_M3UA_CLNT_asp_up_act(M3UA_SRV(0));
+}
+
+/* Test traffic being routed through "server" side STP (M3UA SG), coming back in "client"
+ * side STP (M3UA ASP) */
+testcase TC_clnt_sg_to_asp() runs on RAW_M3UA_CT {
+ var OCT4 rctx_sender := int2oct(1023, 4);
+ var OCT4 pc_sender := int2oct(23, 4);
+ var OCT4 rctx_receiver := int2oct(1055, 4);
+ var OCT4 pc_receiver := int2oct(55, 4);
+
+ f_init_m3ua();
+ f_M3UA_asp_up_act(0);
+
+ f_init_m3ua_srv();
+ f_M3UA_CLNT_asp_up_act(M3UA_SRV(0));
+
+ f_sleep(1.0);
+
+ /* verify traffic is routed from sender to [sole] receiver */
+ f_test_traffic(0, rctx_sender, pc_sender, M3UA_SRV(0), rctx_receiver, pc_receiver);
+}
+
+/* Test traffic being routed through "client" side STP (M3UA ASP), coming back in "server"
+ * side STP (M3UA SG) */
+testcase TC_clnt_asp_to_sg() runs on RAW_M3UA_CT {
+ var OCT4 rctx_sender := int2oct(1055, 4);
+ var OCT4 pc_sender := int2oct(55, 4);
+ var OCT4 rctx_receiver := int2oct(1023, 4);
+ var OCT4 pc_receiver := int2oct(23, 4);
+
+ f_init_m3ua();
+ f_M3UA_asp_up_act(0);
+
+ f_init_m3ua_srv();
+ f_M3UA_CLNT_asp_up_act(M3UA_SRV(0));
+
+ f_sleep(1.0);
+
+ /* verify traffic is routed from sender to [sole] receiver */
+ f_test_traffic(M3UA_SRV(0), rctx_sender, pc_sender, 0, rctx_receiver, pc_receiver);
+}
+
+
control {
/* M3UA Tests */
@@ -442,6 +573,12 @@ control {
/* TODO: test RKM with unsupported routing keys: NA, SI, OPC */
/* TODO: register/unregister multiple routing contexts in one message; including mixed
success/failure situations */
+
+ /* Test STP as SCTP client + M3UA ASP role */
+ execute( TC_clnt_connect_asp_up() );
+ execute( TC_clnt_asp_act() );
+ execute( TC_clnt_sg_to_asp() );
+ execute( TC_clnt_asp_to_sg() );
}
diff --git a/stp/osmo-stp.cfg b/stp/osmo-stp.cfg
index d5eccbab..d8630d21 100644
--- a/stp/osmo-stp.cfg
+++ b/stp/osmo-stp.cfg
@@ -45,6 +45,11 @@ cs7 instance 0
asp asp-receiver1 10001 2905 m3ua
local-ip 127.0.0.1
remote-ip 127.0.0.1
+ asp asp-client0 10002 2906 m3ua
+ local-ip 127.0.0.1
+ remote-ip 127.0.0.1
+ sctp-role client
+ role asp
as as-sender m3ua
asp asp-sender
routing-key 1023 23
@@ -54,9 +59,13 @@ cs7 instance 0
as mahlzeit ipa
routing-key 0 5
point-code override dpc 23
+ as as-client m3ua
+ routing-key 1055 55
+ asp asp-client0
route-table system
update route 23 16777215 linkset as-sender
update route 42 16777215 linkset as-receiver
+ update route 55 16777215 linkset as-client
listen m3ua 2905
accept-asp-connections dynamic-permitted
listen ipa 5000