blob: 498f48436ac5bc59f1495da1c39562880cfee25b [file] [log] [blame]
Harald Welte09538f82019-08-01 09:50:25 +02001module BSC_Tests_CBSP {
2
3/* CBSP Integration Tests for OsmoBSC
4 * (C) 2019 by 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 * This test suite tests OsmoBSC while emulating the CBC (Cell Broadcast Centre)
13 */
14
15import from General_Types all;
16import from Osmocom_Types all;
17import from GSM_Types all;
18import from IPL4asp_Types all;
19import from BSSAP_Types all;
20import from BSSMAP_Templates all;
21
22import from BSC_Tests all;
23
24import from IPA_Emulation all;
25import from IPA_CodecPort all;
26import from IPA_Types all;
27
Harald Welte187f7a92019-09-05 11:15:20 +020028import from MobileL3_Types all;
29import from MobileL3_RRM_Types all;
30import from L3_Templates all;
31
Harald Welte09538f82019-08-01 09:50:25 +020032import from RSL_Types all;
33import from RSL_Emulation all;
34
35import from CBSP_Types all;
36import from CBSP_Templates all;
37import from CBSP_Adapter all;
38import from CBSP_CodecPort all;
39
40modulepar {
41 charstring mp_cbc_ip := "0.0.0.0";
42 integer mp_cbc_port := 48049;
43 integer mp_bsc_cbsp_port := 48050;
44
Harald Welte49a61e62020-03-30 20:13:32 +020045 /* BTS 0: 001-01-1-0 with CBCH
46 * BTS 1: 001-01-1-1 with CBCH
47 * BTS 2: 001-01-2-1 with CBCH
48 * BTS 3: 001-01-2-3 without CBCH */
49 GsmCgiAbstract mp_cgi_bts0 := { '001'H, '01'H, 1, 0 };
50 GsmCgiAbstract mp_cgi_bts1 := { '001'H, '01'H, 1, 1 };
51 GsmCgiAbstract mp_cgi_bts2 := { '001'H, '01'H, 2, 1 };
52 GsmCgiAbstract mp_cgi_bts3 := { '001'H, '01'H, 2, 3 };
Harald Welte09538f82019-08-01 09:50:25 +020053}
54
55private type record GsmCgiAbstract {
56 GsmMcc mcc,
57 GsmMnc mnc,
58 GsmLac lac,
59 GsmCellId ci
60};
61private template (value) BSSMAP_FIELD_CellIdentification_CGI bssmap_cgi(GsmCgiAbstract cgi) :=
62 ts_BSSMAP_CI_CGI(cgi.mcc, cgi.mnc, cgi.lac, cgi.ci);
63private template (value) BSSMAP_FIELD_CellIdentification_LAC_CI bssmap_lac_ci(GsmCgiAbstract cgi) :=
64 ts_BSSMAP_CI_LAC_CI(cgi.lac, cgi.ci);
65private template (value) BSSMAP_FIELD_CellIdentification_LAI bssmap_lai(GsmCgiAbstract cgi) :=
66 ts_BSSMAP_CI_LAI(cgi.mcc, cgi.mnc, cgi.lac);
67private template (value) OCT2 bssmap_lac(GsmCgiAbstract cgi) := ts_BSSMAP_CI_LAC(cgi.lac);
68private template (value) OCT2 bssmap_ci(GsmCgiAbstract cgi) := ts_BSSMAP_CI_CI(cgi.ci);
69
70type component cbsp_test_CT extends test_CT, CBSP_Adapter_CT {
Neels Hofmeyr4e63a012020-07-31 14:29:43 +020071 var uint16_t g_cbsp_msg_id := 0;
72 var uint16_t g_cbsp_ser_no := 0;
73}
74
75private function f_g_cbsp_next_msg_id_ser_no() runs on cbsp_test_CT
76{
77 g_cbsp_msg_id := g_cbsp_msg_id + 1;
78 g_cbsp_ser_no := g_cbsp_ser_no + 1;
79 log("g_cbsp_msg_id=", g_cbsp_msg_id, " g_cbsp_ser_no=", g_cbsp_ser_no);
Harald Welte09538f82019-08-01 09:50:25 +020080}
81
Harald Welte38a833b2020-08-21 12:12:15 +020082private altstep as_IgnRSL(template (present) RSL_Message tr) runs on cbsp_test_CT {
Vadim Yanitskiyca5c5202020-05-25 22:03:28 +070083[] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr)) { repeat; }
84[] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr)) { repeat; }
85[] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr)) { repeat; }
Harald Welte09538f82019-08-01 09:50:25 +020086}
87
88private altstep as_FailRSL() runs on cbsp_test_CT {
Harald Welte38a833b2020-08-21 12:12:15 +020089var template (present) RSL_Message tr := (tr_RSL_SMSCB_CMD);
Harald Welte09538f82019-08-01 09:50:25 +020090var ASP_RSL_Unitdata rx;
Vadim Yanitskiyca5c5202020-05-25 22:03:28 +070091[] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr)) -> value rx {
Harald Welte09538f82019-08-01 09:50:25 +020092 setverdict(fail, "Received unexpected RSL ", rx);
93 mtc.stop;
94 }
Vadim Yanitskiyca5c5202020-05-25 22:03:28 +070095[] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr)) -> value rx {
Harald Welte09538f82019-08-01 09:50:25 +020096 setverdict(fail, "Received unexpected RSL ", rx);
97 mtc.stop;
98 }
Vadim Yanitskiyca5c5202020-05-25 22:03:28 +070099[] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr)) -> value rx {
Harald Welte09538f82019-08-01 09:50:25 +0200100 setverdict(fail, "Received unexpected RSL ", rx);
101 mtc.stop;
102 }
103}
104
Neels Hofmeyr579bfa82020-07-29 00:33:59 +0200105private function f_init(float guard_timeout := 30.0) runs on cbsp_test_CT {
106 BSC_Tests.f_init(guard_timeout := guard_timeout);
Harald Welte09538f82019-08-01 09:50:25 +0200107 activate(as_IgnRSL((tr_RSL_BCCH_INFO, tr_RSL_SACCH_FILL,
108 tr_RSL_NO_BCCH_INFO, tr_RSL_NO_SACCH_FILL,
109 tr_RSL_MsgTypeD(?))));
110 activate(as_FailRSL());
111}
112private function f_cbsp_init_client() runs on cbsp_test_CT {
113 f_init();
114 CBSP_Adapter.f_connect(mp_bsc_ip, mp_bsc_cbsp_port, "", -1);
Neels Hofmeyr289c36a2020-07-28 21:19:20 +0200115 /* FIXME: osmo-bsc should probably still send a CBSP RESTART, but to get the current tests running, let's first
116 * ignore this aspect */
117 setverdict(pass);
Harald Welte09538f82019-08-01 09:50:25 +0200118}
119
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200120private function f_cbsp_init_server(uint16_t cbsp_msg_id, uint16_t cbsp_ser_no, float guard_timeout := 30.0) runs on cbsp_test_CT {
Harald Welte09538f82019-08-01 09:50:25 +0200121 var ASP_Event asp_evt;
122 timer T := 10.0;
123
Neels Hofmeyr579bfa82020-07-29 00:33:59 +0200124 f_init(guard_timeout := guard_timeout);
Harald Welte09538f82019-08-01 09:50:25 +0200125 CBSP_Adapter.f_bind(mp_cbc_ip, mp_cbc_port);
126
127 T.start;
128 alt {
129 [] CBSP[0].receive(ASP_Event:{connOpened:=?}) -> value asp_evt {
130 g_cbsp_conn_id[0] := asp_evt.connOpened.connId;
131 }
132 [] T.timeout {
133 setverdict(fail, "Timeout waiting for incoming connection to CBSP Port");
Neels Hofmeyree3b9272020-07-28 21:20:15 +0200134 mtc.stop;
Harald Welte09538f82019-08-01 09:50:25 +0200135 }
136 }
Neels Hofmeyr90a07522020-07-29 01:22:11 +0200137 f_expect_cbsp_restart();
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200138
139 g_cbsp_msg_id := cbsp_msg_id;
140 g_cbsp_ser_no := cbsp_ser_no;
141 log("g_cbsp_msg_id=", g_cbsp_msg_id, " g_cbsp_ser_no=", g_cbsp_ser_no);
Neels Hofmeyrff8a9f22020-08-13 16:06:11 +0000142
143 f_cbsp_reset_bss(0);
Harald Welte09538f82019-08-01 09:50:25 +0200144}
Neels Hofmeyr90a07522020-07-29 01:22:11 +0200145private function f_expect_cbsp_restart() runs on cbsp_test_CT {
Harald Welte09538f82019-08-01 09:50:25 +0200146 interleave {
147 [] CBSP[0].receive(tr_CBSP_Recv(?, tr_CBSP_RESTART(?, CBSP_BC_MSGT_CBS, CBSP_RI_DATA_LOST)));
148 /* should we also expect a restart for emergency related messages? */
149 //[] CBSP[0].receive(tr_CBSP_Recv(?, tr_CBSP_RESTART(?, CBSP_BC_MSGT_EMERG, CBSP_RI_DATA_LOST)));
150 }
151}
152
Neels Hofmeyr4c365322020-07-29 00:36:37 +0200153/* Generate a CBSP payload: random size for payload_len == 0, or specific fixed size for payload_len > 0. */
154function f_gen_page(integer payload_len := 0) return CBSP_IE {
155 if (payload_len < 1) {
156 /* The maximum CBSP page payload space is 88, but 6 bytes of payload header are added in the first page:
157 * the maximum length generated here thus is 82. The minimum generated length is 1 (avoiding zero
158 * length). Note, f_rnd_int(82) returns [0..81], so this results in a len ranging [1..82]: */
159 payload_len := 1 + f_rnd_int(82);
160 }
161 log("Generating CBSP payload: ", payload_len, " octets");
162 var octetstring payload := f_rnd_octstring(payload_len);
163 return valueof(ts_CbspMsgContent(payload, payload_len));
Harald Welte09538f82019-08-01 09:50:25 +0200164}
165
Neels Hofmeyrff8a9f22020-08-13 16:06:11 +0000166function f_cbsp_reset_bss(integer idx) runs on cbsp_test_CT {
167 /* Make sure no CBSP ETWS commands from a previous CBSP test remain in the RSL queue */
168 IPA_RSL[0].clear;
169 IPA_RSL[1].clear;
170 IPA_RSL[2].clear;
171
Harald Welte09538f82019-08-01 09:50:25 +0200172 var template (value) CBSP_PDU tx;
173 timer T := 3.0;
174 tx := ts_CBSP_RESET(cell_list := ts_BSSMAP_CIL_BSS);
175 CBSP[idx].clear;
176 CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx));
177 T.start;
178 alt {
179 [] CBSP[idx].receive(tr_CBSP_Recv(?, tr_CBSP_RESET_COMPL(cell_list := ts_BSSMAP_CIL_BSS)));
180 [] CBSP[idx].receive {
181 setverdict(fail, "received unexpected CBSP");
182 mtc.stop;
183 }
184 [] T.timeout {
185 setverdict(fail, "timeout waiting for RESET COMPLETE");
186 mtc.stop;
187 }
188 }
Neels Hofmeyr161b37e2020-08-13 16:18:51 +0000189
190 f_cbsp_expect_disable_etws_pn_broadcast();
191}
192
193function f_cbsp_expect_disable_etws_pn_broadcast() runs on cbsp_test_CT
194{
195 var template ASP_RSL_Unitdata zero_payload := tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), ''O));
196 interleave {
197 [] IPA_RSL[0].receive(zero_payload) { log("CBSP: disabled ETWS PN broadcast on bts 0"); }
198 [] IPA_RSL[1].receive(zero_payload) { log("CBSP: disabled ETWS PN broadcast on bts 1"); }
199 [] IPA_RSL[2].receive(zero_payload) { log("CBSP: disabled ETWS PN broadcast on bts 2"); }
200 }
Harald Welte09538f82019-08-01 09:50:25 +0200201}
202
203/* send a WRITE CBS to the BSC; expect either COMPLETE or FAILURE in response*/
Harald Welte187f7a92019-09-05 11:15:20 +0200204function f_cbsp_write_emerg(uint16_t msg_id, uint16_t ser_no,
205 template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS,
206 template (value) uint8_t emerg_ind := 1,
207 template (value) uint16_t warn_type := oct2int('0780'O),
208 template (value) uint16_t warn_per := 5,
209 template BSSMAP_FIELD_CellIdentificationList success_list := ?,
210 template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT {
211 var template (value) CBSP_PDU tx;
212 var template CBSP_PDU rx;
213 var CBSP_IEs pages := {f_gen_page()};
214
215 tx := ts_CBSP_WRITE_EMERG(msg_id, ser_no, cell_list, emerg_ind, warn_type, warn_per);
216 CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx));
217 if (istemplatekind(fail_list, "omit")) {
218 rx := tr_CBSP_WRITE_CBS_COMPL(msg_id, ser_no, success_list, omit);
219 } else {
220 rx := tr_CBSP_WRITE_CBS_FAIL(msg_id, ser_no, fail_list, *, success_list, omit);
221 }
222 alt {
223 [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) {
224 setverdict(pass);
225 }
226 [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) {
227 setverdict(fail, "Received unexpected CBSP");
Neels Hofmeyree3b9272020-07-28 21:20:15 +0200228 mtc.stop;
Harald Welte187f7a92019-09-05 11:15:20 +0200229 }
230 }
231}
232
233/* send a WRITE CBS to the BSC; expect either COMPLETE or FAILURE in response*/
Harald Welte09538f82019-08-01 09:50:25 +0200234function f_cbsp_write(uint16_t msg_id, uint16_t ser_no,
235 template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS,
236 template (value) CBSP_Category category := CBSP_CATEG_NORMAL,
237 uint16_t rep_period := 10, uint16_t num_bcast_req := 1,
238 uint8_t dcs := 0, uint8_t channel_ind := 0, CBSP_IEs content,
239 template BSSMAP_FIELD_CellIdentificationList success_list := ?,
240 template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT {
241 var template (value) CBSP_PDU tx;
242 var template CBSP_PDU rx;
Harald Welte09538f82019-08-01 09:50:25 +0200243
244 tx := ts_CBSP_WRITE_CBS(msg_id, ser_no, cell_list, channel_ind, category,
245 rep_period, num_bcast_req, dcs, content);
246 CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx));
247 if (istemplatekind(fail_list, "omit")) {
248 rx := tr_CBSP_WRITE_CBS_COMPL(msg_id, ser_no, success_list, channel_ind);
249 } else {
250 rx := tr_CBSP_WRITE_CBS_FAIL(msg_id, ser_no, fail_list, *, success_list, channel_ind);
251 }
252 alt {
253 [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) {
254 setverdict(pass);
255 }
256 [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) {
257 setverdict(fail, "Received unexpected CBSP");
Neels Hofmeyree3b9272020-07-28 21:20:15 +0200258 mtc.stop;
Harald Welte09538f82019-08-01 09:50:25 +0200259 }
260 }
261}
262
263/* send a REPLACE CBS to the BSC; expect either COMPLETE or FAILURE in response*/
264function f_cbsp_replace(uint16_t msg_id, uint16_t new_ser_no, uint16_t old_ser_no,
265 template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS,
266 template (value) CBSP_Category category := CBSP_CATEG_NORMAL,
267 uint16_t rep_period := 10, uint16_t num_bcast_req := 1,
268 uint8_t dcs := 0, uint8_t channel_ind := 0, CBSP_IEs content,
269 template BSSMAP_FIELD_CellIdentificationList success_list := ?,
270 template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT {
271 var template (value) CBSP_PDU tx;
272 var template CBSP_PDU rx;
Harald Welte09538f82019-08-01 09:50:25 +0200273
274 tx := ts_CBSP_REPLACE_CBS(msg_id, new_ser_no, old_ser_no, cell_list, channel_ind, category,
275 rep_period, num_bcast_req, dcs, content);
276 CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx));
277 if (istemplatekind(fail_list, "omit")) {
278 rx := tr_CBSP_REPLACE_CBS_COMPL(msg_id, new_ser_no, old_ser_no, ?, success_list,
279 channel_ind);
280 } else {
281 rx := tr_CBSP_REPLACE_CBS_FAIL(msg_id, new_ser_no, old_ser_no, fail_list, *, success_list,
282 channel_ind);
283 }
284 alt {
285 [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) {
286 setverdict(pass);
287 }
288 [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) {
289 setverdict(fail, "Received unexpected CBSP");
Neels Hofmeyree3b9272020-07-28 21:20:15 +0200290 mtc.stop;
Harald Welte09538f82019-08-01 09:50:25 +0200291 }
292 }
293}
294/* send a KILL CBS to the BSC; expect either COMPLETE or FAILURE in response*/
295function f_cbsp_kill(uint16_t msg_id, uint16_t ser_no, template (omit) uint8_t channel_ind := 0,
296 template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS,
297 template BSSMAP_FIELD_CellIdentificationList success_list := ?,
298 template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT
299{
300 var template (value) CBSP_PDU tx;
301 var template CBSP_PDU rx;
302
303 tx := ts_CBSP_KILL(msg_id, ser_no, cell_list, channel_ind);
304 CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx));
305 if (istemplatekind(fail_list, "omit")) {
306 rx := tr_CBSP_KILL_COMPL(msg_id, ser_no, compl_list:=*, cell_list:=success_list,
307 channel_ind:=channel_ind);
308 } else {
309 rx := tr_CBSP_KILL_FAIL(msg_id, ser_no, fail_list, compl_list:=*, cell_list:=success_list,
310 channel_ind:=channel_ind);
311 }
312 alt {
313 [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) {
314 setverdict(pass);
315 }
316 [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) {
317 setverdict(fail, "Received unexpected CBSP");
Neels Hofmeyree3b9272020-07-28 21:20:15 +0200318 mtc.stop;
Harald Welte09538f82019-08-01 09:50:25 +0200319 }
320 }
321}
322
Harald Welte09538f82019-08-01 09:50:25 +0200323template (present) RSL_IE_CbCommandType
324tr_RslCbCmdType(template (present) uint2_t lblock := ?, template (present) RSL_CbCommand cmd := ?) := {
325 command := cmd,
326 default_bcast_null := ?,
327 spare := ?,
328 last_block := lblock
329}
330
Neels Hofmeyrdf659512020-07-29 00:41:42 +0200331/* translate blocks count to RSL_CB_CMD_LASTBLOCK_1..4 values */
332private function f_cbsp_block_count_enc(integer num_blocks) return integer
333{
334 if (num_blocks < 1 or num_blocks > 4) {
335 setverdict(fail, "Invalid num_blocks: ", num_blocks);
336 mtc.stop;
337 }
338 if (num_blocks == 4) {
339 return 0;
340 }
341 return num_blocks;
342}
343
Harald Welte09538f82019-08-01 09:50:25 +0200344/* build a RSL_Message receive template from a CBSP page */
Neels Hofmeyr63e2e182020-08-12 11:42:01 +0000345private function f_page2rsl(CBSP_IE page, uint16_t msg_id, uint16_t ser_no, boolean ext_cbch := false,
346 template (present) integer expect_blocks := ?)
Harald Welte09538f82019-08-01 09:50:25 +0200347return template (present) RSL_Message
348{
Harald Welte38a833b2020-08-21 12:12:15 +0200349 var template (present) RSL_Message tr;
Neels Hofmeyrdf659512020-07-29 00:41:42 +0200350 var integer len;
351 var integer num_blocks;
Harald Welte09538f82019-08-01 09:50:25 +0200352 var octetstring payload;
Neels Hofmeyrdf659512020-07-29 00:41:42 +0200353
Harald Welte09538f82019-08-01 09:50:25 +0200354 payload := int2oct(ser_no, 2) & int2oct(msg_id, 2) & '0011'O & page.body.msg_content.val;
Neels Hofmeyrdf659512020-07-29 00:41:42 +0200355 len := lengthof(payload);
356 num_blocks := len / 22;
357 if (len mod 22 > 0) {
358 num_blocks := num_blocks + 1;
359 }
360
Neels Hofmeyr63e2e182020-08-12 11:42:01 +0000361 if (not istemplatekind(expect_blocks, "omit") and not match(num_blocks, expect_blocks)) {
362 setverdict(fail, "mismatch: CBSP page expect_blocks == ", expect_blocks, ", but generated num_blocks == ", num_blocks);
363 mtc.stop;
364 }
365
Neels Hofmeyrdf659512020-07-29 00:41:42 +0200366 var integer lblock := f_cbsp_block_count_enc(num_blocks);
367
Harald Welte09538f82019-08-01 09:50:25 +0200368 tr := tr_RSL_SMSCB_CMD(tr_RslCbCmdType(lblock), f_pad_oct(payload, 88, '00'O));
369 if (ext_cbch) {
370 tr.ies[3] := tr_RSL_IE(RSL_IE_Body:{smscb_chan_ind := 1});
371 tr.ies[4] := *;
372 }
373 return tr;
374}
375
376/***********************************************************************
377 * Test Cases
378 ***********************************************************************/
379
380/* Test if BSC (server) accepts connections from CBC (client) */
381testcase TC_cbsp_bsc_server() runs on cbsp_test_CT {
382 f_cbsp_init_client();
383 setverdict(pass);
384}
385
386/* Test if BSC (client) is connecting to CBC (server) */
387testcase TC_cbsp_bsc_client() runs on cbsp_test_CT {
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200388 f_cbsp_init_server(0, 0);
Harald Welte09538f82019-08-01 09:50:25 +0200389 setverdict(pass);
390}
391
392/* Test if a BSS-global RESET is executed successfully */
393testcase TC_cbsp_reset_bss() runs on cbsp_test_CT {
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200394 f_cbsp_init_server(0, 0);
Harald Welte09538f82019-08-01 09:50:25 +0200395
396 f_cbsp_reset_bss(0);
397 setverdict(pass);
398}
399
400testcase TC_cbsp_write() runs on cbsp_test_CT {
401 var template (value) CBSP_PDU tx;
402 var CBSP_IEs pages := {f_gen_page()};
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200403 f_cbsp_init_server(0, 0);
Harald Welte09538f82019-08-01 09:50:25 +0200404
405 tx := ts_CBSP_WRITE_CBS(msg_id:=23, new_ser_nr:=42, cell_list:=ts_BSSMAP_CIL_BSS,
406 channel_ind:=0, category:=CBSP_CATEG_NORMAL,
407 rep_period:=10, num_bcast_req:=1, dcs := 0,
408 content:=pages);
409
410 CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx));
411 f_sleep(10.0);
412}
413
414/* Write to entire BSS; three cells succeed; one fails (no CBCH) */
Neels Hofmeyra16afdc2020-07-29 00:57:27 +0200415function f_tc_cbsp_write_bss(integer payload_len := -1, template (present) integer expect_blocks) runs on cbsp_test_CT {
416 var CBSP_IEs pages := {f_gen_page(payload_len := payload_len)};
Harald Welte09538f82019-08-01 09:50:25 +0200417 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
418 cell_list := ts_BSSMAP_CIL_BSS;
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200419 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200420 success_list:=tr_BSSMAP_CIL_CGI({?,?,?}), fail_list:={?});
421
Harald Welte38a833b2020-08-21 12:12:15 +0200422 var template (present) RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no, expect_blocks := expect_blocks);
Neels Hofmeyra16afdc2020-07-29 00:57:27 +0200423 log("RSL[0,1,2] EXPECTING ", tr_ASP_RSL_UD(tr));
Harald Welte09538f82019-08-01 09:50:25 +0200424 interleave {
Neels Hofmeyra16afdc2020-07-29 00:57:27 +0200425 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[0]"); }
426 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[1]"); }
427 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[2]"); }
Harald Welte09538f82019-08-01 09:50:25 +0200428 }
Neels Hofmeyra16afdc2020-07-29 00:57:27 +0200429 setverdict(pass);
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200430
431 /* Make the next test run (if any) use different msg_id and ser_no */
432 f_g_cbsp_next_msg_id_ser_no();
Neels Hofmeyra16afdc2020-07-29 00:57:27 +0200433}
434testcase TC_cbsp_write_bss() runs on cbsp_test_CT {
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200435 f_cbsp_init_server(1001, 1501, guard_timeout := 60.0);
Neels Hofmeyra16afdc2020-07-29 00:57:27 +0200436 /* In the SMSCB message, there is a head followed by payload,
437 * and the resulting data is segmented in blocks of 22 octets (<= 4 blocks).
438 *
439 * [head][...payload....]|[....................]|[....................]|[....................]
440 * 0 |16 |38 |60 |82
441 * 0 5 |22 |44 |66 |88
442 *
443 * blocks count: 1 | 2 | 3 | 4
444 * payload octets count: 1..16 | 17..38 | 39..60 | 61..82
445 */
446 f_tc_cbsp_write_bss(payload_len := 1, expect_blocks := 1);
447 f_tc_cbsp_write_bss(payload_len := 2, expect_blocks := 1);
448 f_tc_cbsp_write_bss(payload_len := 16, expect_blocks := 1);
449 f_tc_cbsp_write_bss(payload_len := 17, expect_blocks := 2);
450 f_tc_cbsp_write_bss(payload_len := 23, expect_blocks := 2);
451 f_tc_cbsp_write_bss(payload_len := 38, expect_blocks := 2);
452 f_tc_cbsp_write_bss(payload_len := 39, expect_blocks := 3);
453 f_tc_cbsp_write_bss(payload_len := 42, expect_blocks := 3);
454 f_tc_cbsp_write_bss(payload_len := 60, expect_blocks := 3);
455 f_tc_cbsp_write_bss(payload_len := 61, expect_blocks := 4);
456 f_tc_cbsp_write_bss(payload_len := 77, expect_blocks := 4);
457 f_tc_cbsp_write_bss(payload_len := 82, expect_blocks := 4);
Harald Welte09538f82019-08-01 09:50:25 +0200458}
459
460/* Write to single BTS supporting CBCH: success */
461testcase TC_cbsp_write_bts_cgi() runs on cbsp_test_CT {
462 var CBSP_IEs pages := {f_gen_page()};
463 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
464 cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200465 f_cbsp_init_server(2001, 2501);
466 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200467 success_list:=cell_list, fail_list:=omit);
Harald Welte38a833b2020-08-21 12:12:15 +0200468 var template (present) RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no);
Vadim Yanitskiyca5c5202020-05-25 22:03:28 +0700469 IPA_RSL[0].receive(tr_ASP_RSL_UD(tr));
Harald Welte09538f82019-08-01 09:50:25 +0200470 f_sleep(5.0);
471}
472
473/* Write to single BTS not supporting CBCH: failure */
474testcase TC_cbsp_write_bts_no_cbch() runs on cbsp_test_CT {
475 var CBSP_IEs pages := {f_gen_page()};
476 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
477 cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts3)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200478 f_cbsp_init_server(3001, 3501);
479 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200480 success_list:=omit, fail_list:={?});
481 f_sleep(5.0);
482}
483
484/* Write to single non-existant BTS */
485testcase TC_cbsp_write_unknown_bts() runs on cbsp_test_CT {
486 var CBSP_IEs pages := {f_gen_page()};
487 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
488 cell_list := ts_BSSMAP_CIL_CGI({ts_BSSMAP_CI_CGI(mp_cgi_bts0.mcc, mp_cgi_bts1.mnc, 22222, 33333)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200489 f_cbsp_init_server(4001, 4501);
490 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200491 success_list:=omit, fail_list:={?});
492 f_sleep(5.0);
493}
494
495/* Write to single BTS using LAC+CI */
496testcase TC_cbsp_write_lac_ci() runs on cbsp_test_CT {
497 var CBSP_IEs pages := {f_gen_page()};
498 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
499 cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200500 f_cbsp_init_server(5001, 5501);
501 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200502 success_list:=?, fail_list:=omit);
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200503 IPA_RSL[0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no)));
Harald Welte09538f82019-08-01 09:50:25 +0200504 f_sleep(5.0);
505}
506
507/* Write to single BTS using CI */
508testcase TC_cbsp_write_ci() runs on cbsp_test_CT {
509 var CBSP_IEs pages := {f_gen_page()};
510 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
511 cell_list := ts_BSSMAP_CIL_CI({bssmap_ci(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200512 f_cbsp_init_server(6001, 6501);
513 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200514 success_list:=?, fail_list:=omit);
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200515 IPA_RSL[0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no)));
Harald Welte09538f82019-08-01 09:50:25 +0200516 f_sleep(5.0);
517}
518
519/* Write to single BTS using LAI */
520testcase TC_cbsp_write_lai() runs on cbsp_test_CT {
521 var CBSP_IEs pages := {f_gen_page()};
522 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
Neels Hofmeyrf5148482020-07-31 16:56:02 +0200523 /* bts0 and bts1 have the same LAI (only differ in cell identity).
524 * bts2 and bts3 also have the same LAI, but only bts2 has a CBCH.
525 * Target only bts2.
526 */
527 cell_list := ts_BSSMAP_CIL_LAI({bssmap_lai(mp_cgi_bts2)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200528 f_cbsp_init_server(7001, 7501);
529 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200530 success_list:=?, fail_list:=omit);
Neels Hofmeyrf5148482020-07-31 16:56:02 +0200531 IPA_RSL[2].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no)));
Harald Welte09538f82019-08-01 09:50:25 +0200532 f_sleep(5.0);
533}
534
535/* Write to two BTS using LAC */
536testcase TC_cbsp_write_lac() runs on cbsp_test_CT {
537 var CBSP_IEs pages := {f_gen_page()};
538 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
539 cell_list := ts_BSSMAP_CIL_LAC({bssmap_lac(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200540 f_cbsp_init_server(8001, 8501);
541 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200542 success_list:=?, fail_list:=omit);
Harald Welte38a833b2020-08-21 12:12:15 +0200543 var template (present) RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no);
Harald Welte09538f82019-08-01 09:50:25 +0200544 interleave {
Vadim Yanitskiyca5c5202020-05-25 22:03:28 +0700545 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr));
546 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr));
Harald Welte09538f82019-08-01 09:50:25 +0200547 }
548 f_sleep(5.0);
549}
550
551/* Write a message, then replace it */
552testcase TC_cbsp_write_then_replace() runs on cbsp_test_CT {
553 var CBSP_IEs pages := {f_gen_page()};
554 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
555 cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200556 f_cbsp_init_server(9001, 9501);
557 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, num_bcast_req:=10, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200558 success_list:=?, fail_list:=omit);
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200559
Neels Hofmeyr62d5da32020-07-31 16:56:14 +0200560 IPA_RSL[0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no)));
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200561
562 /* Replace: keep the same msg_id, use a new ser_no */
563 var uint16_t old_ser_no := g_cbsp_ser_no;
564 g_cbsp_ser_no := g_cbsp_ser_no + 1;
565 f_cbsp_replace(g_cbsp_msg_id, g_cbsp_ser_no, old_ser_no, cell_list, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200566 success_list:=?, fail_list:=omit);
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200567
Neels Hofmeyr62d5da32020-07-31 16:56:14 +0200568 IPA_RSL[0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no)));
569 f_sleep(1.0);
570 setverdict(pass);
Harald Welte09538f82019-08-01 09:50:25 +0200571}
572
573/* Replace a message that doesn't exist: failure */
574testcase TC_cbsp_replace_nonexist() runs on cbsp_test_CT {
575 var CBSP_IEs pages := {f_gen_page()};
576 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
577 cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200578 f_cbsp_init_server(10001, 10501);
579 f_cbsp_replace(10, 10023, 10042, cell_list, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200580 success_list:=omit, fail_list:=?);
581}
582
583/* Write more messages than can be scheduled */
584testcase TC_cbsp_write_too_many() runs on cbsp_test_CT {
585 /* repeating three pages at an interval of 1 is impossible */
586 var CBSP_IEs pages := {f_gen_page(), f_gen_page(), f_gen_page()};
587 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
588 cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200589 f_cbsp_init_server(11001, 11501);
590 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, rep_period:=1, content:=pages,
Harald Welte09538f82019-08-01 09:50:25 +0200591 success_list:=omit, fail_list:=?);
592}
593
594/* Kill message that doesn't exist: failure */
595testcase TC_cbsp_kill_nonexist() runs on cbsp_test_CT {
596 var CBSP_IEs pages := {f_gen_page()};
597 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
598 cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200599 f_cbsp_init_server(12001, 12501);
600 f_cbsp_kill(g_cbsp_msg_id, g_cbsp_ser_no, 0, cell_list, success_list:=omit, fail_list:=?);
Harald Welte09538f82019-08-01 09:50:25 +0200601}
602/* Write a message, then kill it */
603testcase TC_cbsp_write_then_kill() runs on cbsp_test_CT {
604 var CBSP_IEs pages := {f_gen_page()};
605 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
606 cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200607 f_cbsp_init_server(13001, 13501);
608 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, success_list:=?, fail_list:=omit);
609 f_cbsp_kill(g_cbsp_msg_id, g_cbsp_ser_no, 0, cell_list, success_list:=?, fail_list:=omit);
Harald Welte09538f82019-08-01 09:50:25 +0200610}
611
612/* Write a message, then reset all messages */
613testcase TC_cbsp_write_then_reset() runs on cbsp_test_CT {
614 var CBSP_IEs pages := {f_gen_page()};
615 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
616 cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200617 f_cbsp_init_server(14001, 14501);
618 f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, success_list:=?, fail_list:=omit);
Harald Welte09538f82019-08-01 09:50:25 +0200619 f_cbsp_reset_bss(0);
620}
621
Harald Welte187f7a92019-09-05 11:15:20 +0200622private const octetstring c_ETWS_sec_default :=
623 '00000000000000000000000000000000000000000000000000'O &
624 '00000000000000000000000000000000000000000000000000'O;
625function f_gen_etws_pn(uint16_t ser_nr, uint16_t msg_id, OCT2 msg_type := '0780'O,
626 octetstring sec_inf := c_ETWS_sec_default) return octetstring {
627 return int2oct(ser_nr, 2) & int2oct(msg_id, 2) & msg_type & sec_inf;
628}
629
630/* Write ETWS PN to single BTS; verify it arrives on DCHAN */
631testcase TC_cbsp_emerg_write_bts_cgi_dchan() runs on cbsp_test_CT {
632 var CBSP_IEs pages := {f_gen_page()};
633 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
634 var ASP_RSL_Unitdata rx_rsl_ud;
635
636 cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200637 f_cbsp_init_server(15001, 15501);
Harald Welte187f7a92019-09-05 11:15:20 +0200638
639 /* first establish a dedicated channel */
640 var DchanTuple dt := f_est_dchan('23'O, 23, '00010203040506'O);
641
642 /* then send ETWS PN */
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200643 f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list);
644 var template (present) octetstring tr_apdu := f_gen_etws_pn(g_cbsp_msg_id, g_cbsp_ser_no);
Harald Welte187f7a92019-09-05 11:15:20 +0200645 timer T := 5.0;
646 T.start;
647 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700648 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(dt.rsl_chan_nr, ?, ?))) -> value rx_rsl_ud {
Harald Welte187f7a92019-09-05 11:15:20 +0200649 var RSL_IE_Body l3_ie;
650 if (f_rsl_find_ie(rx_rsl_ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
651 setverdict(fail, "RSL DATA REQ without L3?");
652 mtc.stop;
653 }
654 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
655 var template (present) APDU_Flags_V tr_flags := {
656 lastSeg := '0'B,
657 firstSeg := '0'B,
658 cR := '0'B,
659 spare := '0'B
660 };
661 if (match(l3, tr_RR_APP_INFO('0001'B, tr_apdu, tr_flags))) {
662 setverdict(pass);
663 }
664 }
665 [] IPA_RSL[0].receive { repeat; }
666 [] T.timeout {
667 setverdict(fail, "Waiting for APP INFO");
668 }
669 }
670}
671
Harald Welte0b5e0f92019-09-07 08:30:25 +0200672/* Write ETWS PN to single BTS; verify it arrives on CCHAN */
673testcase TC_cbsp_emerg_write_bts_cgi_cchan() runs on cbsp_test_CT {
674 var CBSP_IEs pages := {f_gen_page()};
675 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
676 var ASP_RSL_Unitdata rx_rsl_ud;
677
678 cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200679 f_cbsp_init_server(16001, 16501);
Harald Welte0b5e0f92019-09-07 08:30:25 +0200680
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200681 f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list);
Neels Hofmeyrfbaca3f2020-08-13 13:57:43 +0000682 var template (present) octetstring tr_apdu := f_gen_etws_pn(g_cbsp_ser_no, g_cbsp_msg_id);
Harald Welte0b5e0f92019-09-07 08:30:25 +0200683 timer T := 5.0;
684 T.start;
685 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700686 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), tr_apdu))) {
Harald Welte0b5e0f92019-09-07 08:30:25 +0200687 setverdict(pass);
688 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700689 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(?,?))) {
Harald Welte0b5e0f92019-09-07 08:30:25 +0200690 setverdict(fail, "Received unexpected OSMO_ETWS_CMD");
Neels Hofmeyree3b9272020-07-28 21:20:15 +0200691 mtc.stop;
Harald Welte0b5e0f92019-09-07 08:30:25 +0200692 }
693 [] IPA_RSL[0].receive { repeat; }
694 [] T.timeout {
695 setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD");
Neels Hofmeyree3b9272020-07-28 21:20:15 +0200696 mtc.stop;
Harald Welte0b5e0f92019-09-07 08:30:25 +0200697 }
698 }
699}
700
701/* Write ETWS PN to single BTS; verify it arrives on CCHAN */
702testcase TC_cbsp_emerg_write_bts_cgi_cchan_disable() runs on cbsp_test_CT {
703 var CBSP_IEs pages := {f_gen_page()};
704 var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
705 var ASP_RSL_Unitdata rx_rsl_ud;
706
707 cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)});
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200708 f_cbsp_init_server(17001, 17501);
Harald Welte0b5e0f92019-09-07 08:30:25 +0200709
Neels Hofmeyr4e63a012020-07-31 14:29:43 +0200710 f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list);
Harald Welte0b5e0f92019-09-07 08:30:25 +0200711
712 /* first expect the PN to be enabled */
Neels Hofmeyrfbaca3f2020-08-13 13:57:43 +0000713 var template (present) octetstring tr_apdu := f_gen_etws_pn(g_cbsp_ser_no, g_cbsp_msg_id);
Harald Welte0b5e0f92019-09-07 08:30:25 +0200714 timer T := 5.0;
715 T.start;
716 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700717 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), tr_apdu))) {
Harald Welte0b5e0f92019-09-07 08:30:25 +0200718 setverdict(pass);
719 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700720 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(?,?))) {
Harald Welte0b5e0f92019-09-07 08:30:25 +0200721 setverdict(fail, "Received unexpected OSMO_ETWS_CMD");
Neels Hofmeyree3b9272020-07-28 21:20:15 +0200722 mtc.stop;
Harald Welte0b5e0f92019-09-07 08:30:25 +0200723 }
724 [] IPA_RSL[0].receive { repeat; }
725 [] T.timeout {
726 setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD (enable)");
Neels Hofmeyree3b9272020-07-28 21:20:15 +0200727 mtc.stop;
Harald Welte0b5e0f92019-09-07 08:30:25 +0200728 }
729 }
730
731 /* then expect it to be disabled after the warning period (5s) */
732 T.start;
733 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700734 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), ''O))) {
Harald Welte0b5e0f92019-09-07 08:30:25 +0200735 setverdict(pass);
736 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700737 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(?,?))) {
Harald Welte0b5e0f92019-09-07 08:30:25 +0200738 setverdict(fail, "Received unexpected OSMO_ETWS_CMD");
Neels Hofmeyree3b9272020-07-28 21:20:15 +0200739 mtc.stop;
Harald Welte0b5e0f92019-09-07 08:30:25 +0200740 }
741 [] IPA_RSL[0].receive { repeat; }
742 [] T.timeout {
743 setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD (disable)");
Neels Hofmeyree3b9272020-07-28 21:20:15 +0200744 mtc.stop;
Harald Welte0b5e0f92019-09-07 08:30:25 +0200745 }
746 }
747}
748
749
Harald Welte187f7a92019-09-05 11:15:20 +0200750
Harald Welte09538f82019-08-01 09:50:25 +0200751control {
752 execute( TC_cbsp_bsc_server() );
753 execute( TC_cbsp_bsc_client() );
754 execute( TC_cbsp_reset_bss() );
755
756 /* test various different types of Cell Identities */
757 execute( TC_cbsp_write_bss() );
758 execute( TC_cbsp_write_bts_cgi() );
759 execute( TC_cbsp_write_bts_no_cbch() );
760 execute( TC_cbsp_write_unknown_bts() );
761 execute( TC_cbsp_write_lac_ci() );
762 execute( TC_cbsp_write_ci() );
763 execute( TC_cbsp_write_lai() );
764 execute( TC_cbsp_write_lac() );
765
766 execute( TC_cbsp_write_then_replace() );
767 execute( TC_cbsp_replace_nonexist() );
768 execute( TC_cbsp_write_too_many() );
769 execute( TC_cbsp_kill_nonexist() );
770 execute( TC_cbsp_write_then_kill() );
771 execute( TC_cbsp_write_then_reset() );
Harald Welte187f7a92019-09-05 11:15:20 +0200772
773 execute( TC_cbsp_emerg_write_bts_cgi_dchan() );
Harald Welte0b5e0f92019-09-07 08:30:25 +0200774 execute( TC_cbsp_emerg_write_bts_cgi_cchan() );
775 execute( TC_cbsp_emerg_write_bts_cgi_cchan_disable() );
Harald Welte09538f82019-08-01 09:50:25 +0200776}
777
778
779}