blob: 0a3692163b8827991997bd0c82c81218af12c02e [file] [log] [blame]
Harald Welte0db44132019-10-17 11:09:05 +02001module STP_Tests_IPA {
2
3/* Osmocom STP test suite in in TTCN-3
4 * (C) 2019 Harald Welte <laforge@gnumonks.org>
5 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13friend module STP_Tests;
14
15import from General_Types all;
16import from Osmocom_Types all;
17import from IPL4asp_Types all;
18
19import from TELNETasp_PortType all;
20import from Osmocom_VTY_Functions all;
21
22import from SCCP_Types all;
23import from SCCP_Templates all;
24import from SCCPasp_Types all;
25import from SCCP_Emulation all;
26
27import from IPA_Emulation all;
28
29import from M3UA_Emulation all;
30import from M3UA_CodecPort all;
31import from MTP3asp_Types all;
32import from MTP3asp_PortType all;
33
34import from STP_Tests_Common all;
35
36private const integer NR_IPA := 1;
37
38modulepar {
39 integer mp_stp_ipa_port := 5000;
40 integer mp_local_ipa_port := 20000;
41}
42
43type component IPA_CT extends Test_CT {
44 /* for IPA we use the IPA_Emulation and not directly IPA_CodecPort to avoid
45 * having to re-invent IPA CCM handling here */
46 port MTP3asp_PT IPA[NR_IPA];
47 var IPA_Emulation_CT vc_IPA[NR_IPA];
48}
49
50friend function f_IPA_send(integer idx, octetstring data) runs on IPA_CT {
51 var MTP3_Field_sio sio := { ni := '00'B, prio := '00'B, si := '0011'B };
52 IPA[idx].send(t_ASP_MTP3_TRANSFERreq(sio, 0, 0, 0, data));
53}
54
55friend function f_IPA_exp(integer idx, template (present) octetstring data) runs on IPA_CT {
56 var M3UA_RecvFrom rx;
57 alt {
58 [] IPA[idx].receive(t_ASP_MTP3_TRANSFERind(?, ?, ?, ?, data)) {
59 setverdict(pass);
60 }
61 [] IPA[idx].receive {
62 setverdict(fail, "Received unexpected data on IPA port while waiting for ", data);
63 mtc.stop;
64 }
65 }
66}
67
68friend function f_init_ipa() runs on IPA_CT {
69 var integer i;
70
71 f_init_common();
72
73 for (i := 0; i < NR_IPA; i:=i+1) {
74 vc_IPA[i] := IPA_Emulation_CT.create("IPA" & int2str(i));
75 map(vc_IPA[i]:IPA_PORT, system:IPA_CODEC_PT);
76 connect(self:IPA[i], vc_IPA[i]:MTP3_SP_PORT);
77 vc_IPA[i].start(IPA_Emulation.main_client(mp_stp_ip, mp_stp_ipa_port, mp_local_ip,
78 mp_local_ipa_port+i));
79 }
80}
81
82
83
84/* "accept-asp-connections pre-configured" and client from unknown source */
85testcase TC_unknown_client_nodynamic() runs on IPA_CT {
86 f_init_common();
87 f_vty_config2(VTY, {"cs7 instance 0", "listen ipa 5000"},
88 "accept-asp-connections pre-configured");
89 f_init_ipa();
90 f_sleep(1.0);
91 if (IPA[0].checkstate("Connected")) {
92 setverdict(fail, "Expected IPA port to be disconnected");
93 } else {
94 setverdict(pass);
95 }
96 /* switch back to default */
97 f_vty_config2(VTY, {"cs7 instance 0", "listen ipa 5000"},
98 "accept-asp-connections dynamic-permitted");
99}
100
101/* "accept-asp-connections pre-configured" and client from known source */
102testcase TC_known_client_nodynamic() runs on IPA_CT {
103 f_init_common();
104 f_vty_config2(VTY, {"cs7 instance 0", "listen ipa 5000"},
105 "accept-asp-connections pre-configured");
106 f_vty_config2(VTY, {"cs7 instance 0"}, "asp ipa-mahlzeit0 20000 5000 ipa");
107 f_vty_config2(VTY, {"cs7 instance 0", "as mahlzeit ipa"}, "asp ipa-mahlzeit0");
108 f_init_ipa();
109 f_sleep(1.0);
110 if (not IPA[0].checkstate("Connected")) {
111 setverdict(fail, "Expected IPA port to be connected");
112 } else {
113 setverdict(pass);
114 }
115 /* switch back to default */
116 f_vty_config2(VTY, {"cs7 instance 0", "listen ipa 5000"},
117 "accept-asp-connections dynamic-permitted");
118 f_vty_config2(VTY, {"cs7 instance 0"}, "no asp ipa-mahlzeit0");
119}
120
121
122/* "accept-asp-connections dynamic-permitted" and client from unknown source */
123testcase TC_unknown_client_dynamic() runs on IPA_CT {
124 f_init_common();
125 f_init_ipa();
126 f_sleep(1.0);
127 if (not IPA[0].checkstate("Connected")) {
128 setverdict(fail, "Expected IPA port to be connected");
129 } else {
130 setverdict(pass);
131 }
132}
133
134
135control {
136 execute( TC_unknown_client_nodynamic() );
137 execute( TC_known_client_nodynamic() );
138 execute( TC_unknown_client_dynamic() );
139}
140
141
142}