blob: 5849dad3c915116b98580641fbb4c4e2860ed6fb [file] [log] [blame]
Harald Welte9adf57b2020-01-10 12:33:44 +01001/* (C) 2019 by Harald Welte <laforge@gnumonks.org>
2 * All Rights Reserved
3 *
4 * The idea is that these tests are executed against sccp_demo_user from
5 * libosmo-sccp.git in server mode.
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
13module SCCP_Tests_RAW {
14
15import from General_Types all;
16import from Osmocom_Types all;
17
18import from M3UA_Emulation all;
19
20import from SCCP_Types all;
21import from SCCPasp_Types all;
22import from SCCP_Templates all;
23import from SCCP_Emulation all;
24import from SCCP_CodecPort all;
25
26import from TELNETasp_PortType all;
27import from Osmocom_VTY_Functions all;
28
29import from SCCP_Tests all;
30
31type component SCCP_Test_RAW_CT {
32 /* VTY to sccp_demo_user (not used yet) */
33 port TELNETasp_PT SCCP_DEMO_USER_VTY;
34
35 /* SCCP raw port runs on top of M3UA Emulation.
36 * "System Under Test" is libosmo-sccp's sccp_demo_user example program. */
37 var M3UA_CT vc_M3UA;
38 port SCCP_CODEC_PT MTP3;
39
40 var MSC_SCCP_MTP3_parameters g_param;
Pau Espin Pedrola2473da2020-01-20 13:20:58 +010041
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +010042 var OCT3 g_own_lref := '000001'O
43
Pau Espin Pedrola2473da2020-01-20 13:20:58 +010044 /*Configure T(tias) over VTY, seconds */
45 var integer g_demo_sccp_timer_ias := 7 * 60;
46 /*Configure T(tiar) over VTY, seconds */
47 var integer g_demo_sccp_timer_iar := 15 * 60;
48}
49
50type record of charstring Commands;
51private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
52{
53 f_vty_enter_cfg_cs7_inst(pt, 0);
54 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
55 f_vty_transceive(pt, cmds[i]);
56 }
57 f_vty_transceive(pt, "end");
58}
59
60function f_init_vty() runs on SCCP_Test_RAW_CT {
61 if (SCCP_DEMO_USER_VTY.checkstate("Mapped")) {
62 /* skip initialization if already executed once */
63 return;
64 }
65 map(self:SCCP_DEMO_USER_VTY, system:SCCP_DEMO_USER_VTY);
66 f_vty_set_prompts(SCCP_DEMO_USER_VTY);
67 f_vty_transceive(SCCP_DEMO_USER_VTY, "enable");
68 f_cs7_inst_0_cfg(SCCP_DEMO_USER_VTY, {"sccp-timer ias " & int2str(g_demo_sccp_timer_ias),
69 "sccp-timer iar " & int2str(g_demo_sccp_timer_iar)});
Harald Welte9adf57b2020-01-10 12:33:44 +010070}
71
Pau Espin Pedrol27486792023-10-30 18:13:20 +010072function f_vty_cmd_connect_req(integer conn_id) runs on SCCP_Test_RAW_CT {
73 f_vty_transceive(SCCP_DEMO_USER_VTY, "sccp-user");
74 f_vty_transceive(SCCP_DEMO_USER_VTY, "connect-req " & int2str(conn_id));
75 f_vty_transceive(SCCP_DEMO_USER_VTY, "end");
76}
77
78function f_vty_cmd_disconnect_req(integer conn_id) runs on SCCP_Test_RAW_CT {
79 f_vty_transceive(SCCP_DEMO_USER_VTY, "sccp-user");
80 f_vty_transceive(SCCP_DEMO_USER_VTY, "disconnect-req " & int2str(conn_id));
81 f_vty_transceive(SCCP_DEMO_USER_VTY, "end");
82}
83
Harald Welte9adf57b2020-01-10 12:33:44 +010084private function f_init_raw(SCCP_Configuration cfg) runs on SCCP_Test_RAW_CT {
85 g_param := {
86 sio := {
87 ni := substr(oct2bit(cfg.sio),0,2),
88 prio := substr(oct2bit(cfg.sio),2,2),
89 si := substr(oct2bit(cfg.sio),4,4)
90 },
91 opc := cfg.own_pc,
92 dpc := cfg.peer_pc,
93 sls := 0,
94 sccp_serviceType := cfg.sccp_service_type,
95 ssn := cfg.own_ssn
96 };
97
Pau Espin Pedrola2473da2020-01-20 13:20:58 +010098 f_init_vty();
Harald Welte9adf57b2020-01-10 12:33:44 +010099
100 /* Create and connect test components */
101 vc_M3UA := M3UA_CT.create;
102 connect(self:MTP3, vc_M3UA:MTP3_SP_PORT);
103 map(vc_M3UA:SCTP_PORT, system:sctp);
104
105 vc_M3UA.start(f_M3UA_Emulation(cfg.sctp_addr));
106}
107
108private function f_cleanup() runs on SCCP_Test_RAW_CT {
109 all component.stop;
110 unmap(vc_M3UA:SCTP_PORT, system:sctp);
111 disconnect(vc_M3UA:MTP3_SP_PORT, self:MTP3);
112 self.stop
113}
114
Harald Welte9adf57b2020-01-10 12:33:44 +0100115private function f_send_sccp(template PDU_SCCP sccp) runs on SCCP_Test_RAW_CT {
116 var SCCP_MTP3_TRANSFERreq tx := {
117 sio := g_param.sio,
118 opc := g_param.opc,
119 dpc := g_param.dpc,
120 sls := g_param.sls,
121 data := valueof(sccp)
122 };
123 MTP3.send(tx);
124}
125
Pau Espin Pedrole30d5432020-01-21 13:47:32 +0100126private function tr_SCCP_MTP3_TRANSFERind(template PDU_SCCP sccp)
127runs on SCCP_Test_RAW_CT return template SCCP_MTP3_TRANSFERind {
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100128
Harald Welte9adf57b2020-01-10 12:33:44 +0100129 var template SCCP_MTP3_TRANSFERind exp := {
130 sio := g_param.sio,
131 opc := g_param.dpc,
132 dpc := g_param.opc,
133 sls := g_param.sls,
134 data := sccp
135 };
Pau Espin Pedrole30d5432020-01-21 13:47:32 +0100136 return exp;
137}
138
139private function f_exp_sccp(template PDU_SCCP sccp)
140runs on SCCP_Test_RAW_CT return SCCP_MTP3_TRANSFERind {
141 var template SCCP_MTP3_TRANSFERind exp := tr_SCCP_MTP3_TRANSFERind(sccp);
142 var SCCP_MTP3_TRANSFERind rx;
Harald Welte9adf57b2020-01-10 12:33:44 +0100143 timer T := 10.0;
144 T.start;
145 alt {
146 [] MTP3.receive(exp) -> value rx {
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100147 return rx;
Harald Welte9adf57b2020-01-10 12:33:44 +0100148 }
149 [] MTP3.receive {
150 setverdict(fail, "Unexpected MTP/SCCP received");
Pau Espin Pedrol94b7a682020-01-20 19:30:07 +0100151 self.stop
Harald Welte9adf57b2020-01-10 12:33:44 +0100152 }
153 [] T.timeout {
154 setverdict(fail, "Timeout waiting for ", exp);
Pau Espin Pedrol94b7a682020-01-20 19:30:07 +0100155 self.stop
Harald Welte9adf57b2020-01-10 12:33:44 +0100156 }
157 }
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100158 return rx;
Harald Welte9adf57b2020-01-10 12:33:44 +0100159}
160
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100161private function f_establish_conn(SCCP_PAR_Address calling, SCCP_PAR_Address called)
162runs on SCCP_Test_RAW_CT return OCT3 {
163 var SCCP_MTP3_TRANSFERind mtp3_rx;
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100164
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100165 f_send_sccp(ts_SCCP_CR(g_own_lref, calling, called));
166 mtp3_rx := f_exp_sccp(tr_SCCP_CC(?, g_own_lref));
167
168 return mtp3_rx.data.connconfirm.sourceLocRef;
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100169}
170
171private function f_tx_udt_exp(SCCP_PAR_Address calling, SCCP_PAR_Address called, octetstring data) runs on SCCP_Test_RAW_CT {
172
173 f_send_sccp(ts_SCCP_UDT(calling, called, data));
174 f_exp_sccp(tr_SCCP_UDT(called, calling, data));
175}
176
Harald Welte9adf57b2020-01-10 12:33:44 +0100177/* Verify sccp_demo_user answers a CR with a CC for PC and SSN set up to echo back */
178testcase TC_cr_cc() runs on SCCP_Test_RAW_CT {
179 var SCCP_PAR_Address calling, called;
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100180
181 f_init_raw(mp_sccp_cfg[0]);
182 f_sleep(1.0);
183
Pau Espin Pedrole1870912020-01-17 17:30:19 +0100184 called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, mp_sccp_cfg[0].peer_ssn,
185 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
186 calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, mp_sccp_cfg[0].own_ssn,
187 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100188 f_establish_conn(calling, called);
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100189 setverdict(pass);
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100190}
191
Pau Espin Pedrol1269b1b2020-01-21 12:58:48 +0100192/* Verify sccp_demo_user inactivty timers are not armed upon dealing with
Alexander Couzens3b2b32e2022-11-22 12:55:05 +0000193 * connectionless data-unit messages. Since no connection exists. */
Pau Espin Pedrolf7ba2342020-01-20 20:19:47 +0100194testcase TC_udt_without_cr_cc() runs on SCCP_Test_RAW_CT {
195 var SCCP_PAR_Address calling, called;
Pau Espin Pedrol1269b1b2020-01-21 12:58:48 +0100196 var SCCP_MTP3_TRANSFERind rx;
Harald Welte67881ae2022-04-12 22:52:47 +0200197 var octetstring data := f_rnd_octstring_rnd_len(100);
Pau Espin Pedrolf7ba2342020-01-20 20:19:47 +0100198
Pau Espin Pedrol1269b1b2020-01-21 12:58:48 +0100199 /* Keep recommended ratio of T(iar) >= T(ias)*2, but anyway no IT
200 should be received in this case. */
201 g_demo_sccp_timer_ias := 1;
202 g_demo_sccp_timer_iar := 3;
Pau Espin Pedrolf7ba2342020-01-20 20:19:47 +0100203 f_init_raw(mp_sccp_cfg[0]);
204 f_sleep(1.0);
205
206 called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, mp_sccp_cfg[0].peer_ssn,
207 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
208 calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, mp_sccp_cfg[0].own_ssn,
209 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
210
211 f_tx_udt_exp(calling, called, data);
Pau Espin Pedrol1269b1b2020-01-21 12:58:48 +0100212
213 /* Make sure no SCCP message is received at all, since no connection is active. */
214 timer T := int2float(g_demo_sccp_timer_iar + 1);
215 T.start;
216 alt {
217 [] MTP3.receive {
218 setverdict(fail, "Unexpected MTP/SCCP received");
219 self.stop;
220 }
221 [] T.timeout {}
222 }
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100223 setverdict(pass);
Pau Espin Pedrolf7ba2342020-01-20 20:19:47 +0100224}
225
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100226/* Verify T(iar) triggers and releases the channel */
227testcase TC_tiar_timeout() runs on SCCP_Test_RAW_CT {
228 var SCCP_PAR_Address calling, called;
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100229 var OCT3 remote_lref;
Harald Welte67881ae2022-04-12 22:52:47 +0200230 var octetstring data := f_rnd_octstring_rnd_len(100);
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100231
232 /* Set T(iar) in sccp_demo_user low enough that it will trigger before other side
233 has time to keep alive with a T(ias). Keep recommended ratio of
234 T(iar) >= T(ias)*2 */
235 g_demo_sccp_timer_ias := 2;
236 g_demo_sccp_timer_iar := 5;
Pau Espin Pedrole1870912020-01-17 17:30:19 +0100237 f_init_raw(mp_sccp_cfg[0]);
Harald Welte9adf57b2020-01-10 12:33:44 +0100238 f_sleep(1.0);
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100239
240 called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, mp_sccp_cfg[0].peer_ssn,
241 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
242 calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, mp_sccp_cfg[0].own_ssn,
243 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100244 remote_lref := f_establish_conn(calling, called);
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100245 f_tx_udt_exp(calling, called, data);
246
247 log("Waiting for first IT");
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100248 f_exp_sccp(tr_SCCP_IT(remote_lref, g_own_lref));
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100249 log("Waiting for second IT");
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100250 f_exp_sccp(tr_SCCP_IT(remote_lref, g_own_lref));
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100251
252 log("Waiting for RLSD");
Pau Espin Pedrol392eaf32020-01-21 12:21:05 +0100253 f_exp_sccp(tr_SCCP_RLSD(remote_lref, g_own_lref, hex2int('0D'H))); /* Cause: Expiration of Rx Inactivity Timer */
254 f_send_sccp(ts_SCCP_RLC(g_own_lref, remote_lref));
255 setverdict(pass);
Harald Welte9adf57b2020-01-10 12:33:44 +0100256}
257
Pau Espin Pedrole30d5432020-01-21 13:47:32 +0100258/* Verify T(iar) triggers and releases the channel */
259testcase TC_it_avoids_tiar() runs on SCCP_Test_RAW_CT {
260 var SCCP_PAR_Address calling, called;
261 var OCT3 remote_lref;
262 var boolean it_received := false;
Alexander Couzens9e8e96f2022-11-22 15:52:18 +0000263 var SCCP_MTP3_TRANSFERind rx;
Pau Espin Pedrole30d5432020-01-21 13:47:32 +0100264
265 g_demo_sccp_timer_ias := 1;
266 g_demo_sccp_timer_iar := 3;
267 f_init_raw(mp_sccp_cfg[0]);
268 f_sleep(1.0);
269
270 called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, mp_sccp_cfg[0].peer_ssn,
271 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
272 calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, mp_sccp_cfg[0].own_ssn,
273 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
274 remote_lref := f_establish_conn(calling, called);
275
276 timer T_total := 7.0; /* Higher than g_demo_sccp_timer_iar */
277 timer T_tias := 1.0; /* Lower than g_demo_sccp_timer_iar */
278 T_total.start;
279 T_tias.start;
280 alt {
281 [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_IT(remote_lref, g_own_lref))) {
282 it_received := true;
283 repeat;
284 }
285 [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_RLSD(remote_lref, g_own_lref, hex2int('0D'H)))) {
286 setverdict(fail, "Unexpected SCCP RLSD received");
287 self.stop;
288 }
Alexander Couzens9e8e96f2022-11-22 15:52:18 +0000289 [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(*)) -> value rx {
290 setverdict(fail, "Unexpected MTP/SCCP TRANSFERind received: ", rx);
291 self.stop;
292 }
Pau Espin Pedrole30d5432020-01-21 13:47:32 +0100293 [] MTP3.receive {
294 setverdict(fail, "Unexpected MTP/SCCP received");
295 self.stop;
296 }
297 [] T_tias.timeout {
298 f_send_sccp(ts_SCCP_IT(g_own_lref, remote_lref));
299 T_tias.start;
300 repeat;
301 }
302 [] T_total.timeout {
303 /* We kept the connection alive only with IT messages for a while, cool! */
304 T_tias.stop;
305 setverdict(pass);
306 }
307 }
308
309 if (not it_received) {
310 setverdict(fail, "Didn't receive any IT (Tias) from peer");
311 }
312
313 /* After we stop sending IT, we should be receiving an RLSD triggered from T(iar) */
314 log("Waiting for RLSD");
315 alt {
316 [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_IT(remote_lref, g_own_lref))) {
317 repeat;
318 }
319 [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_RLSD(remote_lref, g_own_lref, hex2int('0D'H)))) {
320 f_send_sccp(ts_SCCP_RLC(g_own_lref, remote_lref));
321 setverdict(pass);
322 }
323 [] MTP3.receive {
324 setverdict(fail, "Unexpected MTP/SCCP received");
325 self.stop;
326 }
327 }
328}
329
Harald Welte4038d4c2021-10-26 14:37:54 +0200330private function f_tx_xudt_exp(SCCP_PAR_Address calling, SCCP_PAR_Address called, octetstring data) runs on SCCP_Test_RAW_CT {
331 var template PDU_SCCP exp_rx;
332 f_send_sccp(ts_SCCP_XUDT(calling, called, data));
333 exp_rx := (tr_SCCP_UDT(called, calling, data), tr_SCCP_XUDT(called, calling, data));
334 f_exp_sccp(exp_rx);
335}
336
337/* Test if the IUT SCCP code processes an XUDT [treat it like UDT] and answers back. */
338testcase TC_process_rx_xudt() runs on SCCP_Test_RAW_CT {
339 var SCCP_PAR_Address calling, called;
Harald Welte67881ae2022-04-12 22:52:47 +0200340 var octetstring data := f_rnd_octstring_rnd_len(100);
Harald Welte4038d4c2021-10-26 14:37:54 +0200341
342 f_init_raw(mp_sccp_cfg[0]);
343 f_sleep(1.0);
344
345 called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, mp_sccp_cfg[0].peer_ssn,
346 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
347 calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, mp_sccp_cfg[0].own_ssn,
348 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
349
350 /* Make sure an XUDT is echoed back just like an UDT */
351 f_tx_xudt_exp(calling, called, data);
352 setverdict(pass);
353}
354
Pau Espin Pedrol0c613ab2023-09-19 14:39:34 +0200355private function f_tx_ludt_exp(SCCP_PAR_Address calling, SCCP_PAR_Address called, octetstring data) runs on SCCP_Test_RAW_CT {
356 var template PDU_SCCP exp_rx;
357 f_send_sccp(ts_SCCP_LUDT(calling, called, data));
358 exp_rx := tr_SCCP_LUDT(called, calling, data);
359 f_exp_sccp(exp_rx);
360}
361
362/* Test if the IUT SCCP code processes a LUDT [treat it like UDT] and answers back. */
363testcase TC_process_rx_ludt() runs on SCCP_Test_RAW_CT {
364 var SCCP_PAR_Address calling, called;
365 var octetstring data := f_rnd_octstring(1000);
366
367 f_init_raw(mp_sccp_cfg[0]);
368 f_sleep(1.0);
369
370 called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, mp_sccp_cfg[0].peer_ssn,
371 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
372 calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, mp_sccp_cfg[0].own_ssn,
373 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
374
375 /* Make sure an LUDT is echoed back just like an UDT */
376 f_tx_ludt_exp(calling, called, data);
377 setverdict(pass);
378}
379
Harald Welte24f921b2021-02-10 19:37:45 +0100380function f_scmg_xceive(SCCP_PAR_Address calling, SCCP_PAR_Address called,
381 template (value) PDU_SCMG_message tx,
Harald Welteaed9f942021-05-13 21:54:58 +0200382 template (omit) PDU_SCMG_message rx_exp,
383 boolean accept_other_called_resp := false) runs on SCCP_Test_RAW_CT
Harald Welte24f921b2021-02-10 19:37:45 +0100384{
385 var boolean exp_something := true;
Alexander Couzens9e8e96f2022-11-22 15:52:18 +0000386 var SCCP_MTP3_TRANSFERind rx;
Harald Welte24f921b2021-02-10 19:37:45 +0100387 timer T := 5.0;
388
389 if (istemplatekind(rx_exp, "omit")) {
390 exp_something := false;
391 }
392
393 MTP3.clear;
394 f_send_sccp(ts_SCCP_UDT(calling, called, enc_PDU_SCMG_message(valueof(tx))));
395 T.start;
396 alt {
397 [exp_something] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_UDT(called, calling, decmatch rx_exp))) {
398 setverdict(pass);
399 }
Harald Welteaed9f942021-05-13 21:54:58 +0200400 [exp_something and accept_other_called_resp] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_UDT(called, ?, decmatch rx_exp))) {
401 setverdict(pass);
402 }
Alexander Couzens9e8e96f2022-11-22 15:52:18 +0000403 [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_UDT(called, calling, ?))) -> value rx {
404 setverdict(fail, "Received unexpected SCCP/MTP3 TRANSFERind (specific): ", rx, " but waiting for (specific) ", rx_exp);
405 }
406 [] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(*)) -> value rx {
407 setverdict(fail, "Received unexpected SCCP/MTP3 TRANSFERind (*): ", rx, " but waiting for ", rx_exp);
Harald Welte24f921b2021-02-10 19:37:45 +0100408 }
409 [] MTP3.receive {
410 setverdict(fail, "Received unexpected waiting for ", rx_exp);
411 }
412 [exp_something] T.timeout {
413 setverdict(fail, "Timeout waiting for ", rx_exp);
414 }
415 [not exp_something] T.timeout {
416 setverdict(pass);
417 }
418 }
419
420}
421
422/* Test is SST(SSN=1) returns SSA */
423testcase TC_scmg_sst_ssn1() runs on SCCP_Test_RAW_CT {
424 var SCCP_PAR_Address calling, called;
425 var template (value) PDU_SCMG_message tx;
426 var template (present) PDU_SCMG_message rx_exp;
427
428 f_init_raw(mp_sccp_cfg[0]);
429 f_sleep(1.0);
430
431 called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, 1,
432 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
433 calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, 1,
434 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
435
436 tx := ts_SCMG_SST(1, mp_sccp_cfg[0].peer_pc);
437 rx_exp := ts_SCMG_SSA(1, mp_sccp_cfg[0].peer_pc);
438 f_scmg_xceive(calling, called, tx, rx_exp);
439}
440
441/* Test is SST(SSN=valid) returns SSA */
442testcase TC_scmg_sst_ssn_valid() runs on SCCP_Test_RAW_CT {
443 var SCCP_PAR_Address calling, called;
444 var template (value) PDU_SCMG_message tx;
445 var template (present) PDU_SCMG_message rx_exp;
446
447 f_init_raw(mp_sccp_cfg[0]);
448 f_sleep(1.0);
449
450 called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, 1,
451 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
452 calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, 1,
453 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
454
455 tx := ts_SCMG_SST(mp_sccp_cfg[0].peer_ssn, mp_sccp_cfg[0].peer_pc);
456 rx_exp := ts_SCMG_SSA(mp_sccp_cfg[0].peer_ssn, mp_sccp_cfg[0].peer_pc);
457 f_scmg_xceive(calling, called, tx, rx_exp);
458}
459
460
461/* Test is SST(SSN=invalid) returns nothing */
462testcase TC_scmg_sst_ssn_invalid() runs on SCCP_Test_RAW_CT {
463 var SCCP_PAR_Address calling, called;
464 var template (value) PDU_SCMG_message tx;
465 var template (omit) PDU_SCMG_message rx_exp;
466
467 f_init_raw(mp_sccp_cfg[0]);
468 f_sleep(1.0);
469
470 called := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].peer_pc, 1,
471 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
472 calling := valueof(ts_SccpAddr_PC_SSN(mp_sccp_cfg[0].own_pc, 1,
473 mp_sccp_cfg[0].sio, mp_sccp_cfg[0].sccp_service_type));
474
475 tx := ts_SCMG_SST(123, mp_sccp_cfg[0].peer_pc);
476 rx_exp := omit;
477 f_scmg_xceive(calling, called, tx, rx_exp);
478}
479
Harald Welteaed9f942021-05-13 21:54:58 +0200480/* Test CallingParty(only SSN) solicits response (OS#5146) */
481testcase TC_callingparty_ssn_only() runs on SCCP_Test_RAW_CT {
482 var SCCP_PAR_Address calling, called;
483 var template (value) PDU_SCMG_message tx;
484 var template (present) PDU_SCMG_message rx_exp;
485
486 f_init_raw(mp_sccp_cfg[0]);
487 f_sleep(1.0);
488
489 called := valueof(ts_SccpAddr_SSN(1));
490 calling := valueof(ts_SccpAddr_SSN(1));
491
492 tx := ts_SCMG_SST(1, mp_sccp_cfg[0].peer_pc);
493 rx_exp := ts_SCMG_SSA(1, mp_sccp_cfg[0].peer_pc);
494 f_scmg_xceive(calling, called, tx, rx_exp, accept_other_called_resp:=true);
495}
Harald Welte24f921b2021-02-10 19:37:45 +0100496
497
Pau Espin Pedrol27486792023-10-30 18:13:20 +0100498/* Test user initiating a conn (eg RUA), which triggers SCCP CR. While waiting
499 * for CC, user decides it timed out (eg. RUA side timeout) which makes it move to
500 * WAIT_CONN_CONF state. In that state, wait for CC and then submit an RLSD and
501 * wait for ack. */
502testcase TC_cr_timeout_cc_too_late() runs on SCCP_Test_RAW_CT {
503 var SCCP_MTP3_TRANSFERind mtp3_rx;
504 var integer conn_id := 1234;
505 var OCT3 remote_lref;
506
507 f_init_raw(mp_sccp_cfg[0]);
508 f_sleep(1.0);
509
510 f_vty_cmd_connect_req(conn_id);
511 mtp3_rx := f_exp_sccp(tr_SCCP_CR(?, ?, ?));
512
513 /* Emulate disconnection from the user: */
514 f_vty_cmd_disconnect_req(conn_id);
515 remote_lref := mtp3_rx.data.connrequest.sourceLocRef;
516
517 /* Now send CC, user should send RLSD to us: */
518 f_send_sccp(ts_SCCP_CC(g_own_lref, remote_lref));
519 log("Waiting for RLSD");
520 /* Cause set hardcoded by osmo_sccp_demo_user VTY code, nothing to test here: */
521 var template (present) integer cause := ?;
522 f_exp_sccp(tr_SCCP_RLSD(remote_lref, g_own_lref, cause));
523 f_send_sccp(ts_SCCP_RLC(g_own_lref, remote_lref));
524
525 setverdict(pass);
526}
527
528
Harald Welte9adf57b2020-01-10 12:33:44 +0100529control {
530 execute( TC_cr_cc() );
Pau Espin Pedrolf7ba2342020-01-20 20:19:47 +0100531 execute( TC_udt_without_cr_cc() );
Pau Espin Pedrola2473da2020-01-20 13:20:58 +0100532 execute( TC_tiar_timeout() );
Pau Espin Pedrole30d5432020-01-21 13:47:32 +0100533 execute( TC_it_avoids_tiar() );
Harald Welte4038d4c2021-10-26 14:37:54 +0200534 execute( TC_process_rx_xudt() );
Pau Espin Pedrol0c613ab2023-09-19 14:39:34 +0200535 execute( TC_process_rx_ludt() );
Harald Welte24f921b2021-02-10 19:37:45 +0100536
537 execute( TC_scmg_sst_ssn1() );
538 execute( TC_scmg_sst_ssn_valid() );
539 execute( TC_scmg_sst_ssn_invalid() );
Harald Welteaed9f942021-05-13 21:54:58 +0200540
541 execute( TC_callingparty_ssn_only() );
Pau Espin Pedrol27486792023-10-30 18:13:20 +0100542 execute( TC_cr_timeout_cc_too_late() );
Harald Welte9adf57b2020-01-10 12:33:44 +0100543}
544
545
546}