143 lines
3.8 KiB
Plaintext
143 lines
3.8 KiB
Plaintext
|
module STP_Tests_IPA {
|
||
|
|
||
|
/* Osmocom STP test suite in in TTCN-3
|
||
|
* (C) 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
|
||
|
*/
|
||
|
|
||
|
friend module STP_Tests;
|
||
|
|
||
|
import from General_Types all;
|
||
|
import from Osmocom_Types all;
|
||
|
import from IPL4asp_Types all;
|
||
|
|
||
|
import from TELNETasp_PortType all;
|
||
|
import from Osmocom_VTY_Functions all;
|
||
|
|
||
|
import from SCCP_Types all;
|
||
|
import from SCCP_Templates all;
|
||
|
import from SCCPasp_Types all;
|
||
|
import from SCCP_Emulation all;
|
||
|
|
||
|
import from IPA_Emulation all;
|
||
|
|
||
|
import from M3UA_Emulation all;
|
||
|
import from M3UA_CodecPort all;
|
||
|
import from MTP3asp_Types all;
|
||
|
import from MTP3asp_PortType all;
|
||
|
|
||
|
import from STP_Tests_Common all;
|
||
|
|
||
|
private const integer NR_IPA := 1;
|
||
|
|
||
|
modulepar {
|
||
|
integer mp_stp_ipa_port := 5000;
|
||
|
integer mp_local_ipa_port := 20000;
|
||
|
}
|
||
|
|
||
|
type component IPA_CT extends Test_CT {
|
||
|
/* for IPA we use the IPA_Emulation and not directly IPA_CodecPort to avoid
|
||
|
* having to re-invent IPA CCM handling here */
|
||
|
port MTP3asp_PT IPA[NR_IPA];
|
||
|
var IPA_Emulation_CT vc_IPA[NR_IPA];
|
||
|
}
|
||
|
|
||
|
friend function f_IPA_send(integer idx, octetstring data) runs on IPA_CT {
|
||
|
var MTP3_Field_sio sio := { ni := '00'B, prio := '00'B, si := '0011'B };
|
||
|
IPA[idx].send(t_ASP_MTP3_TRANSFERreq(sio, 0, 0, 0, data));
|
||
|
}
|
||
|
|
||
|
friend function f_IPA_exp(integer idx, template (present) octetstring data) runs on IPA_CT {
|
||
|
var M3UA_RecvFrom rx;
|
||
|
alt {
|
||
|
[] IPA[idx].receive(t_ASP_MTP3_TRANSFERind(?, ?, ?, ?, data)) {
|
||
|
setverdict(pass);
|
||
|
}
|
||
|
[] IPA[idx].receive {
|
||
|
setverdict(fail, "Received unexpected data on IPA port while waiting for ", data);
|
||
|
mtc.stop;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
friend function f_init_ipa() runs on IPA_CT {
|
||
|
var integer i;
|
||
|
|
||
|
f_init_common();
|
||
|
|
||
|
for (i := 0; i < NR_IPA; i:=i+1) {
|
||
|
vc_IPA[i] := IPA_Emulation_CT.create("IPA" & int2str(i));
|
||
|
map(vc_IPA[i]:IPA_PORT, system:IPA_CODEC_PT);
|
||
|
connect(self:IPA[i], vc_IPA[i]:MTP3_SP_PORT);
|
||
|
vc_IPA[i].start(IPA_Emulation.main_client(mp_stp_ip, mp_stp_ipa_port, mp_local_ip,
|
||
|
mp_local_ipa_port+i));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/* "accept-asp-connections pre-configured" and client from unknown source */
|
||
|
testcase TC_unknown_client_nodynamic() runs on IPA_CT {
|
||
|
f_init_common();
|
||
|
f_vty_config2(VTY, {"cs7 instance 0", "listen ipa 5000"},
|
||
|
"accept-asp-connections pre-configured");
|
||
|
f_init_ipa();
|
||
|
f_sleep(1.0);
|
||
|
if (IPA[0].checkstate("Connected")) {
|
||
|
setverdict(fail, "Expected IPA port to be disconnected");
|
||
|
} else {
|
||
|
setverdict(pass);
|
||
|
}
|
||
|
/* switch back to default */
|
||
|
f_vty_config2(VTY, {"cs7 instance 0", "listen ipa 5000"},
|
||
|
"accept-asp-connections dynamic-permitted");
|
||
|
}
|
||
|
|
||
|
/* "accept-asp-connections pre-configured" and client from known source */
|
||
|
testcase TC_known_client_nodynamic() runs on IPA_CT {
|
||
|
f_init_common();
|
||
|
f_vty_config2(VTY, {"cs7 instance 0", "listen ipa 5000"},
|
||
|
"accept-asp-connections pre-configured");
|
||
|
f_vty_config2(VTY, {"cs7 instance 0"}, "asp ipa-mahlzeit0 20000 5000 ipa");
|
||
|
f_vty_config2(VTY, {"cs7 instance 0", "as mahlzeit ipa"}, "asp ipa-mahlzeit0");
|
||
|
f_init_ipa();
|
||
|
f_sleep(1.0);
|
||
|
if (not IPA[0].checkstate("Connected")) {
|
||
|
setverdict(fail, "Expected IPA port to be connected");
|
||
|
} else {
|
||
|
setverdict(pass);
|
||
|
}
|
||
|
/* switch back to default */
|
||
|
f_vty_config2(VTY, {"cs7 instance 0", "listen ipa 5000"},
|
||
|
"accept-asp-connections dynamic-permitted");
|
||
|
f_vty_config2(VTY, {"cs7 instance 0"}, "no asp ipa-mahlzeit0");
|
||
|
}
|
||
|
|
||
|
|
||
|
/* "accept-asp-connections dynamic-permitted" and client from unknown source */
|
||
|
testcase TC_unknown_client_dynamic() runs on IPA_CT {
|
||
|
f_init_common();
|
||
|
f_init_ipa();
|
||
|
f_sleep(1.0);
|
||
|
if (not IPA[0].checkstate("Connected")) {
|
||
|
setverdict(fail, "Expected IPA port to be connected");
|
||
|
} else {
|
||
|
setverdict(pass);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
control {
|
||
|
execute( TC_unknown_client_nodynamic() );
|
||
|
execute( TC_known_client_nodynamic() );
|
||
|
execute( TC_unknown_client_dynamic() );
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|