Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1 | module 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 | |
Vadim Yanitskiy | 5eb06a3 | 2022-06-23 18:39:46 +0700 | [diff] [blame] | 15 | import from BSC_Tests all; |
| 16 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 17 | import from General_Types all; |
| 18 | import from Osmocom_Types all; |
| 19 | import from GSM_Types all; |
| 20 | import from IPL4asp_Types all; |
| 21 | import from BSSAP_Types all; |
| 22 | import from BSSMAP_Templates all; |
| 23 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 24 | import from IPA_Emulation all; |
| 25 | import from IPA_CodecPort all; |
| 26 | import from IPA_Types all; |
| 27 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 28 | import from MobileL3_Types all; |
| 29 | import from MobileL3_RRM_Types all; |
| 30 | import from L3_Templates all; |
| 31 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 32 | import from RSL_Types all; |
| 33 | import from RSL_Emulation all; |
| 34 | |
| 35 | import from CBSP_Types all; |
| 36 | import from CBSP_Templates all; |
| 37 | import from CBSP_Adapter all; |
| 38 | import from CBSP_CodecPort all; |
| 39 | |
Neels Hofmeyr | cec2d80 | 2020-08-26 15:30:16 +0000 | [diff] [blame] | 40 | import from Osmocom_VTY_Functions all; |
| 41 | import from TELNETasp_PortType all; |
| 42 | |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 43 | import from Osmocom_CTRL_Functions all; |
| 44 | import from Osmocom_CTRL_Types all; |
| 45 | import from Osmocom_CTRL_Adapter all; |
| 46 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 47 | modulepar { |
Vadim Yanitskiy | 68d418e | 2021-12-10 19:16:12 +0300 | [diff] [blame] | 48 | charstring mp_cbc_ip := "127.0.0.1"; |
| 49 | charstring mp_cbc_ip6 := "::1"; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 50 | integer mp_cbc_port := 48049; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 51 | charstring mp_bsc_cbsp_ip := "127.0.0.1"; |
| 52 | charstring mp_bsc_cbsp_ip6 := "::1"; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 53 | integer mp_bsc_cbsp_port := 48050; |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 54 | /* port number to which to establish the IPA CTRL connection */ |
| 55 | integer mp_bsc_ctrl_port := 4249; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 56 | |
Harald Welte | 49a61e6 | 2020-03-30 20:13:32 +0200 | [diff] [blame] | 57 | /* BTS 0: 001-01-1-0 with CBCH |
| 58 | * BTS 1: 001-01-1-1 with CBCH |
| 59 | * BTS 2: 001-01-2-1 with CBCH |
| 60 | * BTS 3: 001-01-2-3 without CBCH */ |
| 61 | GsmCgiAbstract mp_cgi_bts0 := { '001'H, '01'H, 1, 0 }; |
| 62 | GsmCgiAbstract mp_cgi_bts1 := { '001'H, '01'H, 1, 1 }; |
| 63 | GsmCgiAbstract mp_cgi_bts2 := { '001'H, '01'H, 2, 1 }; |
| 64 | GsmCgiAbstract mp_cgi_bts3 := { '001'H, '01'H, 2, 3 }; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 65 | } |
| 66 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 67 | type record CBSP_Pars { |
| 68 | boolean tcp_client, |
| 69 | charstring local_ip, |
| 70 | integer local_port, |
| 71 | charstring remote_ip, |
| 72 | integer remote_port, |
| 73 | uint16_t cbsp_msg_id optional, /*server mode only */ |
| 74 | uint16_t cbsp_ser_no optional /*server mode only */ |
| 75 | }; |
| 76 | |
| 77 | private template (value) CBSP_Pars ts_CBSP_Pars_default(boolean tcp_client := true, |
| 78 | template (omit) uint16_t cbsp_msg_id := omit, |
| 79 | template (omit) uint16_t cbsp_ser_no := omit) := { |
| 80 | tcp_client := tcp_client, |
| 81 | local_ip := mp_cbc_ip, |
| 82 | local_port := mp_cbc_port, |
| 83 | remote_ip := mp_bsc_cbsp_ip, |
| 84 | remote_port := mp_bsc_cbsp_port, |
| 85 | cbsp_msg_id := cbsp_msg_id, |
| 86 | cbsp_ser_no := cbsp_ser_no |
| 87 | }; |
| 88 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 89 | private type record GsmCgiAbstract { |
| 90 | GsmMcc mcc, |
| 91 | GsmMnc mnc, |
| 92 | GsmLac lac, |
| 93 | GsmCellId ci |
| 94 | }; |
| 95 | private template (value) BSSMAP_FIELD_CellIdentification_CGI bssmap_cgi(GsmCgiAbstract cgi) := |
| 96 | ts_BSSMAP_CI_CGI(cgi.mcc, cgi.mnc, cgi.lac, cgi.ci); |
| 97 | private template (value) BSSMAP_FIELD_CellIdentification_LAC_CI bssmap_lac_ci(GsmCgiAbstract cgi) := |
| 98 | ts_BSSMAP_CI_LAC_CI(cgi.lac, cgi.ci); |
| 99 | private template (value) BSSMAP_FIELD_CellIdentification_LAI bssmap_lai(GsmCgiAbstract cgi) := |
| 100 | ts_BSSMAP_CI_LAI(cgi.mcc, cgi.mnc, cgi.lac); |
| 101 | private template (value) OCT2 bssmap_lac(GsmCgiAbstract cgi) := ts_BSSMAP_CI_LAC(cgi.lac); |
| 102 | private template (value) OCT2 bssmap_ci(GsmCgiAbstract cgi) := ts_BSSMAP_CI_CI(cgi.ci); |
| 103 | |
| 104 | type component cbsp_test_CT extends test_CT, CBSP_Adapter_CT { |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 105 | var CBSP_Pars g_pars; |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 106 | var uint16_t g_cbsp_msg_id := 0; |
| 107 | var uint16_t g_cbsp_ser_no := 0; |
| 108 | } |
| 109 | |
| 110 | private function f_g_cbsp_next_msg_id_ser_no() runs on cbsp_test_CT |
| 111 | { |
| 112 | g_cbsp_msg_id := g_cbsp_msg_id + 1; |
| 113 | g_cbsp_ser_no := g_cbsp_ser_no + 1; |
| 114 | log("g_cbsp_msg_id=", g_cbsp_msg_id, " g_cbsp_ser_no=", g_cbsp_ser_no); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 115 | } |
| 116 | |
Harald Welte | 38a833b | 2020-08-21 12:12:15 +0200 | [diff] [blame] | 117 | private altstep as_IgnRSL(template (present) RSL_Message tr) runs on cbsp_test_CT { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 118 | [] IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)) { repeat; } |
| 119 | [] IPA_RSL[1][0].receive(tr_ASP_RSL_UD(tr)) { repeat; } |
| 120 | [] IPA_RSL[2][0].receive(tr_ASP_RSL_UD(tr)) { repeat; } |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | private altstep as_FailRSL() runs on cbsp_test_CT { |
Harald Welte | 38a833b | 2020-08-21 12:12:15 +0200 | [diff] [blame] | 124 | var template (present) RSL_Message tr := (tr_RSL_SMSCB_CMD); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 125 | var ASP_RSL_Unitdata rx; |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 126 | [] IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)) -> value rx { |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 127 | setverdict(fail, "Received unexpected RSL ", rx); |
| 128 | mtc.stop; |
| 129 | } |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 130 | [] IPA_RSL[1][0].receive(tr_ASP_RSL_UD(tr)) -> value rx { |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 131 | setverdict(fail, "Received unexpected RSL ", rx); |
| 132 | mtc.stop; |
| 133 | } |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 134 | [] IPA_RSL[2][0].receive(tr_ASP_RSL_UD(tr)) -> value rx { |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 135 | setverdict(fail, "Received unexpected RSL ", rx); |
| 136 | mtc.stop; |
| 137 | } |
| 138 | } |
| 139 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 140 | private function f_vty_configure_cbsp() runs on cbsp_test_CT { |
| 141 | f_vty_enter_config(BSCVTY); |
| 142 | f_vty_transceive(BSCVTY, "cbc"); |
| 143 | /* Move to disabled in order to force socker recreating later */ |
| 144 | f_vty_transceive(BSCVTY, "mode disabled"); |
| 145 | |
| 146 | /* Configure IP addresses */ |
| 147 | |
| 148 | if (g_pars.tcp_client) { |
| 149 | f_vty_transceive(BSCVTY, "server"); |
| 150 | f_vty_transceive(BSCVTY, "local-ip " & g_pars.remote_ip); |
| 151 | f_vty_transceive(BSCVTY, "exit"); |
| 152 | f_vty_transceive(BSCVTY, "mode server"); |
| 153 | } else { |
| 154 | f_vty_transceive(BSCVTY, "client"); |
| 155 | f_vty_transceive(BSCVTY, "local-ip " & g_pars.remote_ip); |
| 156 | f_vty_transceive(BSCVTY, "remote-ip " & g_pars.local_ip); |
| 157 | f_vty_transceive(BSCVTY, "exit"); |
| 158 | f_vty_transceive(BSCVTY, "mode client"); |
| 159 | } |
| 160 | |
| 161 | f_vty_transceive(BSCVTY, "exit"); |
| 162 | f_vty_transceive(BSCVTY, "exit"); |
Neels Hofmeyr | cec2d80 | 2020-08-26 15:30:16 +0000 | [diff] [blame] | 163 | } |
| 164 | |
Neels Hofmeyr | 579bfa8 | 2020-07-29 00:33:59 +0200 | [diff] [blame] | 165 | private function f_init(float guard_timeout := 30.0) runs on cbsp_test_CT { |
| 166 | BSC_Tests.f_init(guard_timeout := guard_timeout); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 167 | activate(as_IgnRSL((tr_RSL_BCCH_INFO, tr_RSL_SACCH_FILL, |
| 168 | tr_RSL_NO_BCCH_INFO, tr_RSL_NO_SACCH_FILL, |
| 169 | tr_RSL_MsgTypeD(?)))); |
| 170 | activate(as_FailRSL()); |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 171 | |
| 172 | f_vty_configure_cbsp(); |
| 173 | |
| 174 | if (g_pars.tcp_client) { |
| 175 | f_cbsp_init_client(); |
| 176 | } else { |
| 177 | f_cbsp_init_server(); |
| 178 | } |
| 179 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 180 | } |
| 181 | private function f_cbsp_init_client() runs on cbsp_test_CT { |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 182 | CBSP_Adapter.f_connect(g_pars.remote_ip, g_pars.remote_port, g_pars.local_ip, 0); |
Neels Hofmeyr | cec2d80 | 2020-08-26 15:30:16 +0000 | [diff] [blame] | 183 | CBSP[0].receive(tr_CBSP_Recv(?, tr_CBSP_RESTART(?, CBSP_BC_MSGT_CBS, ?))); |
Neels Hofmeyr | 289c36a | 2020-07-28 21:19:20 +0200 | [diff] [blame] | 184 | setverdict(pass); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 185 | } |
| 186 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 187 | private function f_cbsp_init_server(float guard_timeout := 30.0) runs on cbsp_test_CT { |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 188 | var ASP_Event asp_evt; |
| 189 | timer T := 10.0; |
| 190 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 191 | CBSP_Adapter.f_bind(g_pars.local_ip, g_pars.local_port); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 192 | |
| 193 | T.start; |
| 194 | alt { |
| 195 | [] CBSP[0].receive(ASP_Event:{connOpened:=?}) -> value asp_evt { |
| 196 | g_cbsp_conn_id[0] := asp_evt.connOpened.connId; |
| 197 | } |
| 198 | [] T.timeout { |
| 199 | setverdict(fail, "Timeout waiting for incoming connection to CBSP Port"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 200 | mtc.stop; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 201 | } |
| 202 | } |
Neels Hofmeyr | 90a0752 | 2020-07-29 01:22:11 +0200 | [diff] [blame] | 203 | f_expect_cbsp_restart(); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 204 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 205 | g_cbsp_msg_id := g_pars.cbsp_msg_id; |
| 206 | g_cbsp_ser_no := g_pars.cbsp_ser_no; |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 207 | log("g_cbsp_msg_id=", g_cbsp_msg_id, " g_cbsp_ser_no=", g_cbsp_ser_no); |
Neels Hofmeyr | ff8a9f2 | 2020-08-13 16:06:11 +0000 | [diff] [blame] | 208 | |
| 209 | f_cbsp_reset_bss(0); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 210 | } |
Neels Hofmeyr | 90a0752 | 2020-07-29 01:22:11 +0200 | [diff] [blame] | 211 | private function f_expect_cbsp_restart() runs on cbsp_test_CT { |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 212 | interleave { |
| 213 | [] CBSP[0].receive(tr_CBSP_Recv(?, tr_CBSP_RESTART(?, CBSP_BC_MSGT_CBS, CBSP_RI_DATA_LOST))); |
| 214 | /* should we also expect a restart for emergency related messages? */ |
| 215 | //[] CBSP[0].receive(tr_CBSP_Recv(?, tr_CBSP_RESTART(?, CBSP_BC_MSGT_EMERG, CBSP_RI_DATA_LOST))); |
| 216 | } |
| 217 | } |
| 218 | |
Neels Hofmeyr | 4c36532 | 2020-07-29 00:36:37 +0200 | [diff] [blame] | 219 | /* Generate a CBSP payload: random size for payload_len == 0, or specific fixed size for payload_len > 0. */ |
| 220 | function f_gen_page(integer payload_len := 0) return CBSP_IE { |
| 221 | if (payload_len < 1) { |
| 222 | /* The maximum CBSP page payload space is 88, but 6 bytes of payload header are added in the first page: |
| 223 | * the maximum length generated here thus is 82. The minimum generated length is 1 (avoiding zero |
| 224 | * length). Note, f_rnd_int(82) returns [0..81], so this results in a len ranging [1..82]: */ |
| 225 | payload_len := 1 + f_rnd_int(82); |
| 226 | } |
| 227 | log("Generating CBSP payload: ", payload_len, " octets"); |
| 228 | var octetstring payload := f_rnd_octstring(payload_len); |
| 229 | return valueof(ts_CbspMsgContent(payload, payload_len)); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 230 | } |
| 231 | |
Neels Hofmeyr | ff8a9f2 | 2020-08-13 16:06:11 +0000 | [diff] [blame] | 232 | function f_cbsp_reset_bss(integer idx) runs on cbsp_test_CT { |
| 233 | /* Make sure no CBSP ETWS commands from a previous CBSP test remain in the RSL queue */ |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 234 | IPA_RSL[0][0].clear; |
| 235 | IPA_RSL[1][0].clear; |
| 236 | IPA_RSL[2][0].clear; |
Neels Hofmeyr | ff8a9f2 | 2020-08-13 16:06:11 +0000 | [diff] [blame] | 237 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 238 | var template (value) CBSP_PDU tx; |
| 239 | timer T := 3.0; |
| 240 | tx := ts_CBSP_RESET(cell_list := ts_BSSMAP_CIL_BSS); |
| 241 | CBSP[idx].clear; |
| 242 | CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx)); |
| 243 | T.start; |
| 244 | alt { |
| 245 | [] CBSP[idx].receive(tr_CBSP_Recv(?, tr_CBSP_RESET_COMPL(cell_list := ts_BSSMAP_CIL_BSS))); |
| 246 | [] CBSP[idx].receive { |
| 247 | setverdict(fail, "received unexpected CBSP"); |
| 248 | mtc.stop; |
| 249 | } |
| 250 | [] T.timeout { |
| 251 | setverdict(fail, "timeout waiting for RESET COMPLETE"); |
| 252 | mtc.stop; |
| 253 | } |
| 254 | } |
Neels Hofmeyr | 161b37e | 2020-08-13 16:18:51 +0000 | [diff] [blame] | 255 | |
| 256 | f_cbsp_expect_disable_etws_pn_broadcast(); |
| 257 | } |
| 258 | |
| 259 | function f_cbsp_expect_disable_etws_pn_broadcast() runs on cbsp_test_CT |
| 260 | { |
| 261 | var template ASP_RSL_Unitdata zero_payload := tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), ''O)); |
| 262 | interleave { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 263 | [] IPA_RSL[0][0].receive(zero_payload) { log("CBSP: disabled ETWS PN broadcast on bts 0"); } |
| 264 | [] IPA_RSL[1][0].receive(zero_payload) { log("CBSP: disabled ETWS PN broadcast on bts 1"); } |
| 265 | [] IPA_RSL[2][0].receive(zero_payload) { log("CBSP: disabled ETWS PN broadcast on bts 2"); } |
Neels Hofmeyr | 161b37e | 2020-08-13 16:18:51 +0000 | [diff] [blame] | 266 | } |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | /* send a WRITE CBS to the BSC; expect either COMPLETE or FAILURE in response*/ |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 270 | function f_cbsp_write_emerg(uint16_t msg_id, uint16_t ser_no, |
| 271 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 272 | template (value) uint8_t emerg_ind := 1, |
| 273 | template (value) uint16_t warn_type := oct2int('0780'O), |
| 274 | template (value) uint16_t warn_per := 5, |
| 275 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 276 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT { |
| 277 | var template (value) CBSP_PDU tx; |
| 278 | var template CBSP_PDU rx; |
| 279 | var CBSP_IEs pages := {f_gen_page()}; |
| 280 | |
| 281 | tx := ts_CBSP_WRITE_EMERG(msg_id, ser_no, cell_list, emerg_ind, warn_type, warn_per); |
| 282 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 283 | if (istemplatekind(fail_list, "omit")) { |
Pau Espin Pedrol | f14e3ec | 2022-08-09 12:51:56 +0200 | [diff] [blame] | 284 | rx := tr_CBSP_WRITE_EMERG_COMPL(msg_id, ser_no, success_list); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 285 | } else { |
Pau Espin Pedrol | f14e3ec | 2022-08-09 12:51:56 +0200 | [diff] [blame] | 286 | rx := tr_CBSP_WRITE_EMERG_FAIL(msg_id, ser_no, fail_list, *, success_list); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 287 | } |
| 288 | alt { |
| 289 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 290 | setverdict(pass); |
| 291 | } |
| 292 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 293 | setverdict(fail, "Received unexpected CBSP"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 294 | mtc.stop; |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | /* send a WRITE CBS to the BSC; expect either COMPLETE or FAILURE in response*/ |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 300 | function f_cbsp_write(uint16_t msg_id, uint16_t ser_no, |
| 301 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 302 | template (value) CBSP_Category category := CBSP_CATEG_NORMAL, |
| 303 | uint16_t rep_period := 10, uint16_t num_bcast_req := 1, |
| 304 | uint8_t dcs := 0, uint8_t channel_ind := 0, CBSP_IEs content, |
| 305 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 306 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT { |
| 307 | var template (value) CBSP_PDU tx; |
| 308 | var template CBSP_PDU rx; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 309 | |
| 310 | tx := ts_CBSP_WRITE_CBS(msg_id, ser_no, cell_list, channel_ind, category, |
| 311 | rep_period, num_bcast_req, dcs, content); |
| 312 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 313 | if (istemplatekind(fail_list, "omit")) { |
| 314 | rx := tr_CBSP_WRITE_CBS_COMPL(msg_id, ser_no, success_list, channel_ind); |
| 315 | } else { |
| 316 | rx := tr_CBSP_WRITE_CBS_FAIL(msg_id, ser_no, fail_list, *, success_list, channel_ind); |
| 317 | } |
| 318 | alt { |
| 319 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 320 | setverdict(pass); |
| 321 | } |
| 322 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 323 | setverdict(fail, "Received unexpected CBSP"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 324 | mtc.stop; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | } |
| 328 | |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 329 | /* send a REPLACE emergency to the BSC; expect either COMPLETE or FAILURE in response*/ |
| 330 | function f_cbsp_replace_emerg(uint16_t msg_id, uint16_t new_ser_no, uint16_t old_ser_no, |
| 331 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 332 | template (value) uint8_t emerg_ind := 1, |
| 333 | template (value) uint16_t warn_type := oct2int('0780'O), |
| 334 | template (value) uint16_t warn_per := 5, |
| 335 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 336 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT { |
| 337 | var template (value) CBSP_PDU tx; |
| 338 | var template CBSP_PDU rx; |
| 339 | var CBSP_IEs pages := {f_gen_page()}; |
| 340 | |
| 341 | tx := ts_CBSP_REPLACE_EMERG(msg_id, new_ser_no, old_ser_no, cell_list, emerg_ind, warn_type, warn_per); |
| 342 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 343 | if (istemplatekind(fail_list, "omit")) { |
Pau Espin Pedrol | f14e3ec | 2022-08-09 12:51:56 +0200 | [diff] [blame] | 344 | rx := tr_CBSP_REPLACE_EMERG_COMPL(msg_id, new_ser_no, old_ser_no, success_list); |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 345 | } else { |
Pau Espin Pedrol | f14e3ec | 2022-08-09 12:51:56 +0200 | [diff] [blame] | 346 | rx := tr_CBSP_REPLACE_EMERG_FAIL(msg_id, new_ser_no, old_ser_no, fail_list, omit, success_list); |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 347 | } |
| 348 | alt { |
| 349 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 350 | setverdict(pass); |
| 351 | } |
| 352 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 353 | setverdict(fail, "Received unexpected CBSP"); |
| 354 | mtc.stop; |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 359 | /* send a REPLACE CBS to the BSC; expect either COMPLETE or FAILURE in response*/ |
| 360 | function f_cbsp_replace(uint16_t msg_id, uint16_t new_ser_no, uint16_t old_ser_no, |
| 361 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 362 | template (value) CBSP_Category category := CBSP_CATEG_NORMAL, |
| 363 | uint16_t rep_period := 10, uint16_t num_bcast_req := 1, |
| 364 | uint8_t dcs := 0, uint8_t channel_ind := 0, CBSP_IEs content, |
| 365 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 366 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT { |
| 367 | var template (value) CBSP_PDU tx; |
| 368 | var template CBSP_PDU rx; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 369 | |
| 370 | tx := ts_CBSP_REPLACE_CBS(msg_id, new_ser_no, old_ser_no, cell_list, channel_ind, category, |
| 371 | rep_period, num_bcast_req, dcs, content); |
| 372 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 373 | if (istemplatekind(fail_list, "omit")) { |
| 374 | rx := tr_CBSP_REPLACE_CBS_COMPL(msg_id, new_ser_no, old_ser_no, ?, success_list, |
| 375 | channel_ind); |
| 376 | } else { |
| 377 | rx := tr_CBSP_REPLACE_CBS_FAIL(msg_id, new_ser_no, old_ser_no, fail_list, *, success_list, |
| 378 | channel_ind); |
| 379 | } |
| 380 | alt { |
| 381 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 382 | setverdict(pass); |
| 383 | } |
| 384 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 385 | setverdict(fail, "Received unexpected CBSP"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 386 | mtc.stop; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 387 | } |
| 388 | } |
| 389 | } |
| 390 | /* send a KILL CBS to the BSC; expect either COMPLETE or FAILURE in response*/ |
| 391 | function f_cbsp_kill(uint16_t msg_id, uint16_t ser_no, template (omit) uint8_t channel_ind := 0, |
| 392 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 393 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
Harald Welte | 3912895 | 2022-04-14 15:33:58 +0200 | [diff] [blame] | 394 | template CBSP_IE_NumBcastComplList compl_list := *, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 395 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT |
| 396 | { |
| 397 | var template (value) CBSP_PDU tx; |
| 398 | var template CBSP_PDU rx; |
| 399 | |
| 400 | tx := ts_CBSP_KILL(msg_id, ser_no, cell_list, channel_ind); |
| 401 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 402 | if (istemplatekind(fail_list, "omit")) { |
Harald Welte | 3912895 | 2022-04-14 15:33:58 +0200 | [diff] [blame] | 403 | rx := tr_CBSP_KILL_COMPL(msg_id, ser_no, compl_list:=compl_list, cell_list:=success_list, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 404 | channel_ind:=channel_ind); |
| 405 | } else { |
Harald Welte | 3912895 | 2022-04-14 15:33:58 +0200 | [diff] [blame] | 406 | rx := tr_CBSP_KILL_FAIL(msg_id, ser_no, fail_list, compl_list:=compl_list, cell_list:=success_list, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 407 | channel_ind:=channel_ind); |
| 408 | } |
| 409 | alt { |
| 410 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 411 | setverdict(pass); |
| 412 | } |
| 413 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 414 | setverdict(fail, "Received unexpected CBSP"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 415 | mtc.stop; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 416 | } |
| 417 | } |
| 418 | } |
| 419 | |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 420 | /* send a KILL CBS to the BSC; expect either COMPLETE or FAILURE in response*/ |
| 421 | function f_cbsp_msg_status_query(uint16_t msg_id, uint16_t ser_no, template (value) uint8_t channel_ind := 0, |
| 422 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 423 | template CBSP_IE_NumBcastComplList compl_list := ?, |
| 424 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT |
| 425 | { |
| 426 | var template (value) CBSP_PDU tx; |
| 427 | var template CBSP_PDU rx; |
| 428 | |
| 429 | tx := ts_CBSP_MSG_STATUS_QUERY(msg_id, ser_no, cell_list, channel_ind); |
| 430 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 431 | if (istemplatekind(fail_list, "omit")) { |
| 432 | rx := tr_CBSP_MSG_STATUS_QUERY_COMPL(msg_id, ser_no, compl_list:=compl_list, channel_ind:=channel_ind); |
| 433 | } else { |
| 434 | rx := tr_CBSP_MSG_STATUS_QUERY_FAIL(msg_id, ser_no, fail_list, channel_ind:=channel_ind, |
| 435 | compl_list:=compl_list); |
| 436 | } |
| 437 | alt { |
| 438 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 439 | setverdict(pass); |
| 440 | } |
| 441 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 442 | setverdict(fail, "Received unexpected CBSP"); |
| 443 | mtc.stop; |
| 444 | } |
| 445 | } |
| 446 | } |
| 447 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 448 | template (present) RSL_IE_CbCommandType |
| 449 | tr_RslCbCmdType(template (present) uint2_t lblock := ?, template (present) RSL_CbCommand cmd := ?) := { |
| 450 | command := cmd, |
| 451 | default_bcast_null := ?, |
| 452 | spare := ?, |
| 453 | last_block := lblock |
| 454 | } |
| 455 | |
Neels Hofmeyr | df65951 | 2020-07-29 00:41:42 +0200 | [diff] [blame] | 456 | /* translate blocks count to RSL_CB_CMD_LASTBLOCK_1..4 values */ |
| 457 | private function f_cbsp_block_count_enc(integer num_blocks) return integer |
| 458 | { |
| 459 | if (num_blocks < 1 or num_blocks > 4) { |
| 460 | setverdict(fail, "Invalid num_blocks: ", num_blocks); |
| 461 | mtc.stop; |
| 462 | } |
| 463 | if (num_blocks == 4) { |
| 464 | return 0; |
| 465 | } |
| 466 | return num_blocks; |
| 467 | } |
| 468 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 469 | /* build a RSL_Message receive template from a CBSP page */ |
Neels Hofmeyr | 63e2e18 | 2020-08-12 11:42:01 +0000 | [diff] [blame] | 470 | private function f_page2rsl(CBSP_IE page, uint16_t msg_id, uint16_t ser_no, boolean ext_cbch := false, |
| 471 | template (present) integer expect_blocks := ?) |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 472 | return template (present) RSL_Message |
| 473 | { |
Harald Welte | 38a833b | 2020-08-21 12:12:15 +0200 | [diff] [blame] | 474 | var template (present) RSL_Message tr; |
Neels Hofmeyr | df65951 | 2020-07-29 00:41:42 +0200 | [diff] [blame] | 475 | var integer len; |
| 476 | var integer num_blocks; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 477 | var octetstring payload; |
Neels Hofmeyr | df65951 | 2020-07-29 00:41:42 +0200 | [diff] [blame] | 478 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 479 | payload := int2oct(ser_no, 2) & int2oct(msg_id, 2) & '0011'O & page.body.msg_content.val; |
Neels Hofmeyr | df65951 | 2020-07-29 00:41:42 +0200 | [diff] [blame] | 480 | len := lengthof(payload); |
| 481 | num_blocks := len / 22; |
| 482 | if (len mod 22 > 0) { |
| 483 | num_blocks := num_blocks + 1; |
| 484 | } |
| 485 | |
Neels Hofmeyr | 63e2e18 | 2020-08-12 11:42:01 +0000 | [diff] [blame] | 486 | if (not istemplatekind(expect_blocks, "omit") and not match(num_blocks, expect_blocks)) { |
| 487 | setverdict(fail, "mismatch: CBSP page expect_blocks == ", expect_blocks, ", but generated num_blocks == ", num_blocks); |
| 488 | mtc.stop; |
| 489 | } |
| 490 | |
Neels Hofmeyr | df65951 | 2020-07-29 00:41:42 +0200 | [diff] [blame] | 491 | var integer lblock := f_cbsp_block_count_enc(num_blocks); |
| 492 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 493 | tr := tr_RSL_SMSCB_CMD(tr_RslCbCmdType(lblock), f_pad_oct(payload, 88, '00'O)); |
| 494 | if (ext_cbch) { |
| 495 | tr.ies[3] := tr_RSL_IE(RSL_IE_Body:{smscb_chan_ind := 1}); |
| 496 | tr.ies[4] := *; |
| 497 | } |
| 498 | return tr; |
| 499 | } |
| 500 | |
| 501 | /*********************************************************************** |
| 502 | * Test Cases |
| 503 | ***********************************************************************/ |
| 504 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 505 | /* Test if BSC (server) accepts connections from CBC (client, IPv4) */ |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 506 | testcase TC_cbsp_bsc_server() runs on cbsp_test_CT { |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 507 | g_pars := valueof(ts_CBSP_Pars_default(tcp_client := true)); |
| 508 | f_init(); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 509 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 510 | } |
| 511 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 512 | /* Test if BSC (server) accepts connections from CBC (client, IPv6) */ |
| 513 | testcase TC_cbsp_bsc_server_ipv6() runs on cbsp_test_CT { |
| 514 | g_pars := valueof(ts_CBSP_Pars_default(tcp_client := true)); |
| 515 | g_pars.local_ip := mp_cbc_ip6; |
| 516 | g_pars.remote_ip := mp_bsc_cbsp_ip6; |
| 517 | f_init(); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 518 | f_shutdown_helper(); |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | /* Test if BSC (client) is connecting to CBC (server, IPv4) */ |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 522 | testcase TC_cbsp_bsc_client() runs on cbsp_test_CT { |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 523 | g_pars := valueof(ts_CBSP_Pars_default(false, 0, 0)); |
| 524 | f_init(); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 525 | f_shutdown_helper(); |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | /* Test if BSC (client) is connecting to CBC (server, IPv6) */ |
| 529 | testcase TC_cbsp_bsc_client_ipv6() runs on cbsp_test_CT { |
| 530 | g_pars := valueof(ts_CBSP_Pars_default(false, 0, 0)); |
| 531 | g_pars.local_ip := mp_cbc_ip6; |
| 532 | g_pars.remote_ip := mp_bsc_cbsp_ip6; |
| 533 | f_init(); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 534 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | /* Test if a BSS-global RESET is executed successfully */ |
| 538 | testcase TC_cbsp_reset_bss() runs on cbsp_test_CT { |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 539 | g_pars := valueof(ts_CBSP_Pars_default(false, 0, 0)); |
| 540 | f_init(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 541 | f_cbsp_reset_bss(0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 542 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 543 | } |
| 544 | |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 545 | /* Test if a LAC_CI FAILURE Ind is sent when TRX holding the CBCH is locked |
| 546 | * (becomes unavailable). LAC_CI RESTART Ind should be sent when the TRX becomes |
| 547 | * unlocked again. */ |
| 548 | testcase TC_cbsp_cell_rflock_failure_restart() runs on cbsp_test_CT { |
Pau Espin Pedrol | 528f5af | 2022-07-14 20:59:53 +0200 | [diff] [blame] | 549 | var template CBSP_PDU rx_cbs; |
| 550 | var template CBSP_PDU rx_emerg; |
| 551 | var boolean received_cbs := false; |
| 552 | var boolean received_emerg := false; |
Pau Espin Pedrol | 696fbe7 | 2022-07-14 20:32:43 +0200 | [diff] [blame] | 553 | var template (present) CBSP_FailureListItem fli_exp; |
| 554 | var template (present) BSSMAP_FIELD_CellIdentificationList cil_exp; |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 555 | |
| 556 | g_pars := valueof(ts_CBSP_Pars_default(false, 0, 0)); |
| 557 | f_init(); |
| 558 | |
| 559 | /* Lock the TRX, CBCH should become unavailable and BSC send FAILURE */ |
| 560 | f_ctrl_set(IPA_CTRL, "bts.0.trx.0.rf_locked", "1"); |
| 561 | |
Pau Espin Pedrol | 696fbe7 | 2022-07-14 20:32:43 +0200 | [diff] [blame] | 562 | /* Expect receiving either CGI or LAC+CI: */ |
| 563 | fli_exp := (CBSP_FailureListItem_CGI(bssmap_cgi(mp_cgi_bts0), |
| 564 | CBSP_CAUSE_CB_NOT_OPERATIONAL), |
| 565 | CBSP_FailureListItem_LAC_CI(bssmap_lac_ci(mp_cgi_bts0), |
| 566 | CBSP_CAUSE_CB_NOT_OPERATIONAL)); |
Pau Espin Pedrol | 528f5af | 2022-07-14 20:59:53 +0200 | [diff] [blame] | 567 | rx_cbs := tr_CBSP_FAILURE({fli_exp}, CBSP_BC_MSGT_CBS); |
| 568 | rx_emerg := tr_CBSP_FAILURE({fli_exp}, CBSP_BC_MSGT_EMERG); |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 569 | alt { |
Pau Espin Pedrol | 528f5af | 2022-07-14 20:59:53 +0200 | [diff] [blame] | 570 | [not received_cbs] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx_cbs)) { |
| 571 | received_cbs := true; |
| 572 | if (not received_cbs or not received_emerg) { |
| 573 | repeat; |
| 574 | } |
| 575 | } |
| 576 | [not received_emerg] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx_emerg)) { |
| 577 | received_emerg := true; |
| 578 | if (not received_cbs or not received_emerg) { |
| 579 | repeat; |
| 580 | } |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 581 | } |
| 582 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 583 | setverdict(fail, "Received unexpected CBSP"); |
| 584 | mtc.stop; |
| 585 | } |
| 586 | } |
Pau Espin Pedrol | 528f5af | 2022-07-14 20:59:53 +0200 | [diff] [blame] | 587 | setverdict(pass); |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 588 | |
| 589 | /* Unlock the TRX, CBCH should become available and BSC send RESTART */ |
| 590 | f_ctrl_set(IPA_CTRL, "bts.0.trx.0.rf_locked", "0"); |
Pau Espin Pedrol | 696fbe7 | 2022-07-14 20:32:43 +0200 | [diff] [blame] | 591 | /* Expect receiving either CGI or LAC+CI: */ |
| 592 | cil_exp := (ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}), |
| 593 | ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)})); |
Pau Espin Pedrol | 528f5af | 2022-07-14 20:59:53 +0200 | [diff] [blame] | 594 | rx_cbs := tr_CBSP_RESTART(cil_exp, CBSP_BC_MSGT_CBS, ?); |
| 595 | rx_emerg := tr_CBSP_RESTART(cil_exp, CBSP_BC_MSGT_EMERG, ?); |
| 596 | received_cbs := false; |
| 597 | received_emerg := false; |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 598 | alt { |
Pau Espin Pedrol | 528f5af | 2022-07-14 20:59:53 +0200 | [diff] [blame] | 599 | [not received_cbs] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx_cbs)) { |
| 600 | received_cbs := true; |
| 601 | if (not received_cbs or not received_emerg) { |
| 602 | repeat; |
| 603 | } |
| 604 | } |
| 605 | [not received_emerg] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx_emerg)) { |
| 606 | received_emerg := true; |
| 607 | if (not received_cbs or not received_emerg) { |
| 608 | repeat; |
| 609 | } |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 610 | } |
| 611 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 612 | setverdict(fail, "Received unexpected CBSP"); |
| 613 | mtc.stop; |
| 614 | } |
| 615 | } |
| 616 | |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 617 | f_shutdown_helper(); |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | /* Test if a LAC_CI FAILURE Ind is sent when conn of TRX holding the CBCH goes down. */ |
| 621 | testcase TC_cbsp_cell_rsl_down_failure() runs on cbsp_test_CT { |
Pau Espin Pedrol | 528f5af | 2022-07-14 20:59:53 +0200 | [diff] [blame] | 622 | var template CBSP_PDU rx_cbs; |
| 623 | var template CBSP_PDU rx_emerg; |
| 624 | var boolean received_cbs := false; |
| 625 | var boolean received_emerg := false; |
Pau Espin Pedrol | 696fbe7 | 2022-07-14 20:32:43 +0200 | [diff] [blame] | 626 | var template (present) CBSP_FailureListItem fli_exp; |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 627 | |
| 628 | g_pars := valueof(ts_CBSP_Pars_default(false, 0, 0)); |
| 629 | f_init(); |
| 630 | |
| 631 | /* Drop RSL link of the TRX holding the CBCH: */ |
| 632 | f_ipa_rsl_stop(bts[0][0].rsl); |
| 633 | |
Pau Espin Pedrol | 696fbe7 | 2022-07-14 20:32:43 +0200 | [diff] [blame] | 634 | /* Expect receiving either CGI or LAC+CI: */ |
| 635 | fli_exp := (CBSP_FailureListItem_CGI(bssmap_cgi(mp_cgi_bts0), |
| 636 | CBSP_CAUSE_CB_NOT_OPERATIONAL), |
| 637 | CBSP_FailureListItem_LAC_CI(bssmap_lac_ci(mp_cgi_bts0), |
| 638 | CBSP_CAUSE_CB_NOT_OPERATIONAL)); |
Pau Espin Pedrol | 528f5af | 2022-07-14 20:59:53 +0200 | [diff] [blame] | 639 | rx_cbs := tr_CBSP_FAILURE({fli_exp}, CBSP_BC_MSGT_CBS); |
| 640 | rx_emerg := tr_CBSP_FAILURE({fli_exp}, CBSP_BC_MSGT_EMERG); |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 641 | alt { |
Pau Espin Pedrol | 528f5af | 2022-07-14 20:59:53 +0200 | [diff] [blame] | 642 | [not received_cbs] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx_cbs)) { |
| 643 | received_cbs := true; |
| 644 | if (not received_cbs or not received_emerg) { |
| 645 | repeat; |
| 646 | } |
| 647 | } |
| 648 | [not received_emerg] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx_emerg)) { |
| 649 | received_emerg := true; |
| 650 | if (not received_cbs or not received_emerg) { |
| 651 | repeat; |
| 652 | } |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 653 | } |
| 654 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 655 | setverdict(fail, "Received unexpected CBSP"); |
| 656 | mtc.stop; |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | /* TODO: call f_init() again to reconnect? */ |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 661 | f_shutdown_helper(); |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 662 | } |
| 663 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 664 | testcase TC_cbsp_write() runs on cbsp_test_CT { |
| 665 | var template (value) CBSP_PDU tx; |
| 666 | var CBSP_IEs pages := {f_gen_page()}; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 667 | g_pars := valueof(ts_CBSP_Pars_default(false, 0, 0)); |
| 668 | f_init(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 669 | |
| 670 | tx := ts_CBSP_WRITE_CBS(msg_id:=23, new_ser_nr:=42, cell_list:=ts_BSSMAP_CIL_BSS, |
| 671 | channel_ind:=0, category:=CBSP_CATEG_NORMAL, |
| 672 | rep_period:=10, num_bcast_req:=1, dcs := 0, |
| 673 | content:=pages); |
| 674 | |
| 675 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 676 | f_sleep(10.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 677 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | /* Write to entire BSS; three cells succeed; one fails (no CBCH) */ |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 681 | function f_tc_cbsp_write_bss(integer payload_len := -1, template (present) integer expect_blocks) runs on cbsp_test_CT { |
| 682 | var CBSP_IEs pages := {f_gen_page(payload_len := payload_len)}; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 683 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 684 | cell_list := ts_BSSMAP_CIL_BSS; |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 685 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 686 | success_list:=tr_BSSMAP_CIL_CGI({?,?,?}), fail_list:={?}); |
| 687 | |
Harald Welte | 38a833b | 2020-08-21 12:12:15 +0200 | [diff] [blame] | 688 | var template (present) RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no, expect_blocks := expect_blocks); |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 689 | log("RSL[0,1,2] EXPECTING ", tr_ASP_RSL_UD(tr)); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 690 | interleave { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 691 | [] IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[0]"); } |
| 692 | [] IPA_RSL[1][0].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[1]"); } |
| 693 | [] IPA_RSL[2][0].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[2]"); } |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 694 | } |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 695 | setverdict(pass); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 696 | |
| 697 | /* Make the next test run (if any) use different msg_id and ser_no */ |
| 698 | f_g_cbsp_next_msg_id_ser_no(); |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 699 | } |
| 700 | testcase TC_cbsp_write_bss() runs on cbsp_test_CT { |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 701 | g_pars := valueof(ts_CBSP_Pars_default(false, 1001, 1501)); |
| 702 | f_init(guard_timeout := 60.0); |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 703 | /* In the SMSCB message, there is a head followed by payload, |
| 704 | * and the resulting data is segmented in blocks of 22 octets (<= 4 blocks). |
| 705 | * |
| 706 | * [head][...payload....]|[....................]|[....................]|[....................] |
| 707 | * 0 |16 |38 |60 |82 |
| 708 | * 0 5 |22 |44 |66 |88 |
| 709 | * |
| 710 | * blocks count: 1 | 2 | 3 | 4 |
| 711 | * payload octets count: 1..16 | 17..38 | 39..60 | 61..82 |
| 712 | */ |
| 713 | f_tc_cbsp_write_bss(payload_len := 1, expect_blocks := 1); |
| 714 | f_tc_cbsp_write_bss(payload_len := 2, expect_blocks := 1); |
| 715 | f_tc_cbsp_write_bss(payload_len := 16, expect_blocks := 1); |
| 716 | f_tc_cbsp_write_bss(payload_len := 17, expect_blocks := 2); |
| 717 | f_tc_cbsp_write_bss(payload_len := 23, expect_blocks := 2); |
| 718 | f_tc_cbsp_write_bss(payload_len := 38, expect_blocks := 2); |
| 719 | f_tc_cbsp_write_bss(payload_len := 39, expect_blocks := 3); |
| 720 | f_tc_cbsp_write_bss(payload_len := 42, expect_blocks := 3); |
| 721 | f_tc_cbsp_write_bss(payload_len := 60, expect_blocks := 3); |
| 722 | f_tc_cbsp_write_bss(payload_len := 61, expect_blocks := 4); |
| 723 | f_tc_cbsp_write_bss(payload_len := 77, expect_blocks := 4); |
| 724 | f_tc_cbsp_write_bss(payload_len := 82, expect_blocks := 4); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 725 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | /* Write to single BTS supporting CBCH: success */ |
| 729 | testcase TC_cbsp_write_bts_cgi() runs on cbsp_test_CT { |
| 730 | var CBSP_IEs pages := {f_gen_page()}; |
| 731 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 732 | g_pars := valueof(ts_CBSP_Pars_default(false, 2001, 2501)); |
| 733 | f_init(); |
| 734 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 735 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 736 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 737 | success_list:=cell_list, fail_list:=omit); |
Harald Welte | 38a833b | 2020-08-21 12:12:15 +0200 | [diff] [blame] | 738 | var template (present) RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no); |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 739 | IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 740 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 741 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | /* Write to single BTS not supporting CBCH: failure */ |
| 745 | testcase TC_cbsp_write_bts_no_cbch() runs on cbsp_test_CT { |
| 746 | var CBSP_IEs pages := {f_gen_page()}; |
| 747 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 748 | g_pars := valueof(ts_CBSP_Pars_default(false, 3001, 3501)); |
| 749 | f_init(); |
| 750 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 751 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts3)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 752 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 753 | success_list:=omit, fail_list:={?}); |
| 754 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 755 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 756 | } |
| 757 | |
| 758 | /* Write to single non-existant BTS */ |
| 759 | testcase TC_cbsp_write_unknown_bts() runs on cbsp_test_CT { |
| 760 | var CBSP_IEs pages := {f_gen_page()}; |
| 761 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 762 | g_pars := valueof(ts_CBSP_Pars_default(false, 4001, 4501)); |
| 763 | f_init(); |
| 764 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 765 | cell_list := ts_BSSMAP_CIL_CGI({ts_BSSMAP_CI_CGI(mp_cgi_bts0.mcc, mp_cgi_bts1.mnc, 22222, 33333)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 766 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 767 | success_list:=omit, fail_list:={?}); |
| 768 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 769 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 770 | } |
| 771 | |
| 772 | /* Write to single BTS using LAC+CI */ |
| 773 | testcase TC_cbsp_write_lac_ci() runs on cbsp_test_CT { |
| 774 | var CBSP_IEs pages := {f_gen_page()}; |
| 775 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 776 | g_pars := valueof(ts_CBSP_Pars_default(false, 5001, 5501)); |
| 777 | f_init(); |
| 778 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 779 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 780 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 781 | success_list:=?, fail_list:=omit); |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 782 | IPA_RSL[0][0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no))); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 783 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 784 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | /* Write to single BTS using CI */ |
| 788 | testcase TC_cbsp_write_ci() runs on cbsp_test_CT { |
| 789 | var CBSP_IEs pages := {f_gen_page()}; |
| 790 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 791 | g_pars := valueof(ts_CBSP_Pars_default(false, 6001, 6501)); |
| 792 | f_init(); |
| 793 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 794 | cell_list := ts_BSSMAP_CIL_CI({bssmap_ci(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 795 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 796 | success_list:=?, fail_list:=omit); |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 797 | IPA_RSL[0][0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no))); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 798 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 799 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 800 | } |
| 801 | |
| 802 | /* Write to single BTS using LAI */ |
| 803 | testcase TC_cbsp_write_lai() runs on cbsp_test_CT { |
| 804 | var CBSP_IEs pages := {f_gen_page()}; |
| 805 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 806 | g_pars := valueof(ts_CBSP_Pars_default(false, 7001, 7501)); |
| 807 | f_init(); |
| 808 | |
Neels Hofmeyr | f514848 | 2020-07-31 16:56:02 +0200 | [diff] [blame] | 809 | /* bts0 and bts1 have the same LAI (only differ in cell identity). |
| 810 | * bts2 and bts3 also have the same LAI, but only bts2 has a CBCH. |
| 811 | * Target only bts2. |
| 812 | */ |
| 813 | cell_list := ts_BSSMAP_CIL_LAI({bssmap_lai(mp_cgi_bts2)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 814 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 815 | success_list:=?, fail_list:=omit); |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 816 | IPA_RSL[2][0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no))); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 817 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 818 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | /* Write to two BTS using LAC */ |
| 822 | testcase TC_cbsp_write_lac() runs on cbsp_test_CT { |
| 823 | var CBSP_IEs pages := {f_gen_page()}; |
| 824 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 825 | g_pars := valueof(ts_CBSP_Pars_default(false, 8001, 8501)); |
| 826 | f_init(); |
| 827 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 828 | cell_list := ts_BSSMAP_CIL_LAC({bssmap_lac(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 829 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 830 | success_list:=?, fail_list:=omit); |
Harald Welte | 38a833b | 2020-08-21 12:12:15 +0200 | [diff] [blame] | 831 | var template (present) RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 832 | interleave { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 833 | [] IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)); |
| 834 | [] IPA_RSL[1][0].receive(tr_ASP_RSL_UD(tr)); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 835 | } |
| 836 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 837 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | /* Write a message, then replace it */ |
| 841 | testcase TC_cbsp_write_then_replace() runs on cbsp_test_CT { |
| 842 | var CBSP_IEs pages := {f_gen_page()}; |
| 843 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 844 | g_pars := valueof(ts_CBSP_Pars_default(false, 9001, 9501)); |
| 845 | f_init(); |
| 846 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 847 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 848 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, num_bcast_req:=10, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 849 | success_list:=?, fail_list:=omit); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 850 | |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 851 | IPA_RSL[0][0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no))); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 852 | |
| 853 | /* Replace: keep the same msg_id, use a new ser_no */ |
| 854 | var uint16_t old_ser_no := g_cbsp_ser_no; |
| 855 | g_cbsp_ser_no := g_cbsp_ser_no + 1; |
| 856 | f_cbsp_replace(g_cbsp_msg_id, g_cbsp_ser_no, old_ser_no, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 857 | success_list:=?, fail_list:=omit); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 858 | |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 859 | IPA_RSL[0][0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no))); |
Neels Hofmeyr | 62d5da3 | 2020-07-31 16:56:14 +0200 | [diff] [blame] | 860 | f_sleep(1.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 861 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 862 | } |
| 863 | |
Vadim Yanitskiy | c2696fa | 2022-03-30 02:15:41 +0300 | [diff] [blame] | 864 | /* Verify handling of the Repetition Period and the Number of Broadcasts */ |
| 865 | testcase TC_cbsp_write_rep_period_num() runs on cbsp_test_CT { |
| 866 | var CBSP_IE page := f_gen_page(); |
| 867 | const integer rep_period := 2; /* units of 1.883s */ |
| 868 | const integer rep_number := 5; |
| 869 | var integer msg_count := 0; |
| 870 | var float last_time := 0.0; |
| 871 | timer T; |
| 872 | |
| 873 | g_pars := valueof(ts_CBSP_Pars_default(false, 9001, 9501)); |
| 874 | f_init(guard_timeout := 60.0); |
| 875 | |
| 876 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, |
| 877 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}), |
| 878 | rep_period := rep_period, num_bcast_req := rep_number, |
| 879 | content := { page }, success_list := ?, fail_list := omit); |
| 880 | |
| 881 | /* Count SMSCB messages during N=rep_number+2 repetition periods */ |
| 882 | T.start(int2float(rep_period * (rep_number + 2)) * 1.883); |
| 883 | alt { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 884 | [] IPA_RSL[0][0].receive(tr_ASP_RSL_UD(f_page2rsl(page, g_cbsp_msg_id, g_cbsp_ser_no))) { |
Vadim Yanitskiy | c2696fa | 2022-03-30 02:15:41 +0300 | [diff] [blame] | 885 | var float exp_period := int2float(rep_period) * 1.883; |
| 886 | var float calc_period := T.read - last_time; |
| 887 | |
| 888 | log("Rx SMSCB message: count := ", msg_count + 1, ", ", |
| 889 | "elapsed := ", T.read, "s, diff := ", calc_period, "s"); |
| 890 | |
| 891 | if (msg_count > 0) { |
| 892 | /* Check the actual repetition period (+/- 0.5s) */ |
| 893 | var template float tr_exp_period := (exp_period - 0.5 .. exp_period + 0.5); |
| 894 | if (not match(calc_period, tr_exp_period)) { |
| 895 | setverdict(fail, "Repetition period mismatch: ", |
| 896 | "calculated := ", calc_period, "s vs ", |
| 897 | "expected := ", tr_exp_period, "s"); |
| 898 | } |
| 899 | } |
| 900 | |
| 901 | msg_count := msg_count + 1; |
| 902 | last_time := T.read; |
| 903 | repeat; |
| 904 | } |
| 905 | [] T.timeout { |
| 906 | log("Received ", msg_count, " messages during ", last_time, "s"); |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | if (msg_count != rep_number) { |
| 911 | setverdict(fail, "Received ", msg_count, " messages, ", |
| 912 | "while we expected ", rep_number); |
| 913 | } |
| 914 | |
| 915 | f_sleep(1.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 916 | f_shutdown_helper(); |
Vadim Yanitskiy | c2696fa | 2022-03-30 02:15:41 +0300 | [diff] [blame] | 917 | } |
| 918 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 919 | /* Replace a message that doesn't exist: failure */ |
| 920 | testcase TC_cbsp_replace_nonexist() runs on cbsp_test_CT { |
| 921 | var CBSP_IEs pages := {f_gen_page()}; |
| 922 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 923 | g_pars := valueof(ts_CBSP_Pars_default(false, 10001, 10501)); |
| 924 | f_init(); |
| 925 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 926 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 927 | f_cbsp_replace(10, 10023, 10042, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 928 | success_list:=omit, fail_list:=?); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 929 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 930 | } |
| 931 | |
| 932 | /* Write more messages than can be scheduled */ |
| 933 | testcase TC_cbsp_write_too_many() runs on cbsp_test_CT { |
| 934 | /* repeating three pages at an interval of 1 is impossible */ |
| 935 | var CBSP_IEs pages := {f_gen_page(), f_gen_page(), f_gen_page()}; |
| 936 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 937 | g_pars := valueof(ts_CBSP_Pars_default(false, 11001, 11501)); |
| 938 | f_init(); |
| 939 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 940 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 941 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, rep_period:=1, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 942 | success_list:=omit, fail_list:=?); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 943 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 944 | } |
| 945 | |
| 946 | /* Kill message that doesn't exist: failure */ |
| 947 | testcase TC_cbsp_kill_nonexist() runs on cbsp_test_CT { |
| 948 | var CBSP_IEs pages := {f_gen_page()}; |
| 949 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 950 | g_pars := valueof(ts_CBSP_Pars_default(false, 12001, 12501)); |
| 951 | f_init(); |
| 952 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 953 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
Harald Welte | 3912895 | 2022-04-14 15:33:58 +0200 | [diff] [blame] | 954 | f_cbsp_kill(g_cbsp_msg_id, g_cbsp_ser_no, 0, cell_list, success_list:=omit, compl_list:=omit, fail_list:=?); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 955 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 956 | } |
| 957 | /* Write a message, then kill it */ |
| 958 | testcase TC_cbsp_write_then_kill() runs on cbsp_test_CT { |
| 959 | var CBSP_IEs pages := {f_gen_page()}; |
| 960 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 961 | g_pars := valueof(ts_CBSP_Pars_default(false, 13001, 13501)); |
| 962 | f_init(); |
| 963 | |
Harald Welte | 3912895 | 2022-04-14 15:33:58 +0200 | [diff] [blame] | 964 | /* write message, request more than one transmission on BTS0 */ |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 965 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
Harald Welte | 3912895 | 2022-04-14 15:33:58 +0200 | [diff] [blame] | 966 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, num_bcast_req := 5, content:=pages, success_list:=?, fail_list:=omit); |
| 967 | /* expect to receive it once on the BTS */ |
| 968 | var template (present) RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no); |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 969 | IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)); |
Harald Welte | 1222f52 | 2022-04-27 17:56:05 +0200 | [diff] [blame] | 970 | /* kill it, expecting non-empty completion list; success must be empty in case of CBS! */ |
| 971 | f_cbsp_kill(g_cbsp_msg_id, g_cbsp_ser_no, 0, cell_list, success_list:=omit, compl_list:=?, fail_list:=omit); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 972 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 973 | } |
| 974 | |
| 975 | /* Write a message, then reset all messages */ |
| 976 | testcase TC_cbsp_write_then_reset() runs on cbsp_test_CT { |
| 977 | var CBSP_IEs pages := {f_gen_page()}; |
| 978 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 979 | g_pars := valueof(ts_CBSP_Pars_default(false, 14001, 14501)); |
| 980 | f_init(); |
| 981 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 982 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 983 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, success_list:=?, fail_list:=omit); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 984 | f_cbsp_reset_bss(0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 985 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 986 | } |
| 987 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 988 | private const octetstring c_ETWS_sec_default := |
| 989 | '00000000000000000000000000000000000000000000000000'O & |
| 990 | '00000000000000000000000000000000000000000000000000'O; |
| 991 | function f_gen_etws_pn(uint16_t ser_nr, uint16_t msg_id, OCT2 msg_type := '0780'O, |
| 992 | octetstring sec_inf := c_ETWS_sec_default) return octetstring { |
| 993 | return int2oct(ser_nr, 2) & int2oct(msg_id, 2) & msg_type & sec_inf; |
| 994 | } |
| 995 | |
| 996 | /* Write ETWS PN to single BTS; verify it arrives on DCHAN */ |
| 997 | testcase TC_cbsp_emerg_write_bts_cgi_dchan() runs on cbsp_test_CT { |
| 998 | var CBSP_IEs pages := {f_gen_page()}; |
| 999 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1000 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 1001 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1002 | g_pars := valueof(ts_CBSP_Pars_default(false, 15001, 15501)); |
| 1003 | f_init(); |
| 1004 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1005 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1006 | |
| 1007 | /* first establish a dedicated channel */ |
Pau Espin Pedrol | 695ada5 | 2023-01-02 17:54:59 +0100 | [diff] [blame] | 1008 | var DchanTuple dt := f_est_dchan('23'O, 23, c_l3_payload); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1009 | |
| 1010 | /* then send ETWS PN */ |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 1011 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list); |
| 1012 | var template (present) octetstring tr_apdu := f_gen_etws_pn(g_cbsp_msg_id, g_cbsp_ser_no); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1013 | timer T := 5.0; |
| 1014 | T.start; |
| 1015 | alt { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 1016 | [] IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(dt.rsl_chan_nr, ?, ?))) -> value rx_rsl_ud { |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1017 | var RSL_IE_Body l3_ie; |
| 1018 | if (f_rsl_find_ie(rx_rsl_ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) { |
| 1019 | setverdict(fail, "RSL DATA REQ without L3?"); |
| 1020 | mtc.stop; |
| 1021 | } |
| 1022 | var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload); |
| 1023 | var template (present) APDU_Flags_V tr_flags := { |
| 1024 | lastSeg := '0'B, |
| 1025 | firstSeg := '0'B, |
| 1026 | cR := '0'B, |
| 1027 | spare := '0'B |
| 1028 | }; |
| 1029 | if (match(l3, tr_RR_APP_INFO('0001'B, tr_apdu, tr_flags))) { |
| 1030 | setverdict(pass); |
| 1031 | } |
| 1032 | } |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 1033 | [] IPA_RSL[0][0].receive { repeat; } |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1034 | [] T.timeout { |
| 1035 | setverdict(fail, "Waiting for APP INFO"); |
| 1036 | } |
| 1037 | } |
Vadim Yanitskiy | 65d879d | 2022-06-23 18:15:39 +0700 | [diff] [blame] | 1038 | |
| 1039 | f_perform_clear_test_ct(dt); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1040 | f_shutdown_helper(); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1041 | } |
| 1042 | |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1043 | private function f_exp_rsl_etws(integer rsl_idx := 0, boolean enabled) runs on cbsp_test_CT { |
| 1044 | var template (present) octetstring tr_apdu; |
Vadim Yanitskiy | 52aee74 | 2022-06-28 23:18:12 +0700 | [diff] [blame] | 1045 | timer T := 5.0 + 0.5; /* +0.5s guard */ |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1046 | |
| 1047 | if (enabled) { |
| 1048 | tr_apdu := f_gen_etws_pn(g_cbsp_ser_no, g_cbsp_msg_id); |
| 1049 | } else { |
| 1050 | tr_apdu := ''O; |
| 1051 | } |
| 1052 | |
Vadim Yanitskiy | d3bef0a | 2022-06-28 23:15:57 +0700 | [diff] [blame] | 1053 | T.start; |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1054 | alt { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 1055 | [] IPA_RSL[rsl_idx][0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), tr_apdu))) { |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1056 | setverdict(pass); |
| 1057 | } |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 1058 | [] IPA_RSL[rsl_idx][0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(?,?))) { |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1059 | setverdict(fail, "Received unexpected OSMO_ETWS_CMD"); |
| 1060 | mtc.stop; |
| 1061 | } |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 1062 | [] IPA_RSL[rsl_idx][0].receive { repeat; } |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1063 | [] T.timeout { |
| 1064 | if (enabled) { |
| 1065 | setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD (enable)"); |
| 1066 | } else { |
| 1067 | setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD (disable)"); |
| 1068 | } |
| 1069 | mtc.stop; |
| 1070 | } |
| 1071 | } |
| 1072 | } |
| 1073 | |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1074 | /* Write ETWS PN to single BTS; verify it arrives on CCHAN */ |
| 1075 | testcase TC_cbsp_emerg_write_bts_cgi_cchan() runs on cbsp_test_CT { |
| 1076 | var CBSP_IEs pages := {f_gen_page()}; |
| 1077 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1078 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 1079 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1080 | g_pars := valueof(ts_CBSP_Pars_default(false, 16001, 16501)); |
| 1081 | f_init(); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1082 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1083 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 1084 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list); |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1085 | |
| 1086 | f_exp_rsl_etws(0, true); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1087 | f_shutdown_helper(); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | /* Write ETWS PN to single BTS; verify it arrives on CCHAN */ |
| 1091 | testcase TC_cbsp_emerg_write_bts_cgi_cchan_disable() runs on cbsp_test_CT { |
| 1092 | var CBSP_IEs pages := {f_gen_page()}; |
| 1093 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1094 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 1095 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1096 | g_pars := valueof(ts_CBSP_Pars_default(false, 17001, 17501)); |
| 1097 | f_init(); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1098 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1099 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 1100 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1101 | |
| 1102 | /* first expect the PN to be enabled */ |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1103 | f_exp_rsl_etws(0, true); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1104 | |
| 1105 | /* then expect it to be disabled after the warning period (5s) */ |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1106 | f_exp_rsl_etws(0, false); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1107 | f_shutdown_helper(); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1108 | } |
| 1109 | |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1110 | /* Write (!replace) ETWS PN to a single BTS which already has an ongoing PN; expect failure (OS#5539) */ |
| 1111 | testcase TC_cbsp_emerg_write_bts_cgi_noreplace() runs on cbsp_test_CT { |
| 1112 | var CBSP_IEs pages := {f_gen_page()}; |
| 1113 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1114 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 1115 | |
| 1116 | g_pars := valueof(ts_CBSP_Pars_default(false, 18001, 18501)); |
| 1117 | f_init(); |
| 1118 | |
| 1119 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 1120 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list); |
| 1121 | |
| 1122 | /* first expect the PN to be enabled */ |
| 1123 | f_exp_rsl_etws(0, true); |
| 1124 | |
| 1125 | /* write another emergency while first one is still ongoing; expect it to fail */ |
| 1126 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no+1, cell_list, success_list:=omit, fail_list:=?); |
| 1127 | |
| 1128 | /* then expect first one to be disabled after the warning period (5s) */ |
| 1129 | f_exp_rsl_etws(0, false); |
| 1130 | |
| 1131 | /* write another emergency after the first one has expired; expect it to succeed */ |
| 1132 | g_cbsp_ser_no := g_cbsp_ser_no + 2; |
| 1133 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, success_list:=?, fail_list:=omit); |
| 1134 | f_exp_rsl_etws(0, true); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1135 | f_shutdown_helper(); |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1136 | } |
| 1137 | |
| 1138 | /* Replace ETWS PN to a single BTS which already has an ongoing PN; expect success */ |
| 1139 | testcase TC_cbsp_emerg_write_bts_cgi_replace() runs on cbsp_test_CT { |
| 1140 | var CBSP_IEs pages := {f_gen_page()}; |
| 1141 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1142 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 1143 | |
| 1144 | g_pars := valueof(ts_CBSP_Pars_default(false, 19001, 19501)); |
| 1145 | f_init(); |
| 1146 | |
| 1147 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 1148 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list); |
| 1149 | |
| 1150 | /* first expect the PN to be enabled */ |
| 1151 | f_exp_rsl_etws(0, true); |
| 1152 | |
| 1153 | /* write another emergency while first one is still ongoing; expect it to fail */ |
| 1154 | f_cbsp_replace_emerg(g_cbsp_msg_id, g_cbsp_ser_no+1, g_cbsp_ser_no, cell_list); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1155 | f_shutdown_helper(); |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1156 | } |
| 1157 | |
| 1158 | /* Write ETWS PN to a single BTS, then kill it during its lifetime (OS#5540) */ |
| 1159 | testcase TC_cbsp_emerg_write_bts_cgi_kill() runs on cbsp_test_CT { |
| 1160 | var CBSP_IEs pages := {f_gen_page()}; |
| 1161 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1162 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 1163 | |
| 1164 | g_pars := valueof(ts_CBSP_Pars_default(false, 20001, 20501)); |
| 1165 | f_init(); |
| 1166 | |
| 1167 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 1168 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, warn_per := 10); |
| 1169 | |
| 1170 | /* first expect the PN to be enabled */ |
| 1171 | f_exp_rsl_etws(0, true); |
| 1172 | |
| 1173 | /* kill it; expect non-zero success list, and no completion or failure lists */ |
| 1174 | f_cbsp_kill(g_cbsp_msg_id, g_cbsp_ser_no, omit, cell_list, success_list:=cell_list, |
| 1175 | compl_list:=omit, fail_list:=omit); |
| 1176 | |
| 1177 | /* then expect it to be disabled */ |
| 1178 | f_exp_rsl_etws(0, false); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1179 | f_shutdown_helper(); |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1180 | } |
| 1181 | |
| 1182 | |
| 1183 | |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1184 | /* Send a MSG STATUS QUERY for an unknown message; expect no completion list and present failure list */ |
| 1185 | testcase TC_cbsp_status_q_empty() runs on cbsp_test_CT { |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1186 | g_pars := valueof(ts_CBSP_Pars_default(false, 21001, 21501)); |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1187 | f_init(); |
| 1188 | |
| 1189 | f_cbsp_msg_status_query(g_cbsp_msg_id, g_cbsp_ser_no, compl_list := omit, fail_list := ?); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1190 | f_shutdown_helper(); |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1191 | } |
| 1192 | |
| 1193 | /* Send a SMSCB to entire BSS followed by MSG_STATUS_QUERY; expect completion list and no failure list */ |
| 1194 | testcase TC_cbsp_status_q_bts_cgi() runs on cbsp_test_CT { |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1195 | g_pars := valueof(ts_CBSP_Pars_default(false, 22001, 22501)); |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1196 | f_init(); |
| 1197 | |
| 1198 | var CBSP_IEs pages := {f_gen_page()}; |
| 1199 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1200 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 1201 | /* request 5 transmissions */ |
| 1202 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, num_bcast_req := 5, content:=pages, |
| 1203 | success_list:=cell_list, fail_list:=omit); |
| 1204 | var template (present) RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no); |
| 1205 | /* wait for first transmission */ |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 1206 | IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)); |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1207 | var template (present) CBSP_IE_NumBcastComplList compl_list := { |
| 1208 | len := ?, |
| 1209 | spare1_4 := ?, |
| 1210 | cell_id_discr := ?, |
| 1211 | list := { |
| 1212 | cI_CGI := { |
| 1213 | ci := bssmap_cgi(mp_cgi_bts0), |
| 1214 | num_bcast_compl := (1 .. 5), |
| 1215 | num_bcast_info := CBSP_NUM_BCAST_INFO_VALID, |
| 1216 | spare1_4 := '0000'B |
| 1217 | } |
| 1218 | } |
| 1219 | }; |
| 1220 | f_cbsp_msg_status_query(g_cbsp_msg_id, g_cbsp_ser_no, cell_list:=cell_list, compl_list := compl_list, fail_list := omit); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1221 | f_shutdown_helper(); |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1222 | } |
| 1223 | |
| 1224 | |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1225 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1226 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1227 | control { |
| 1228 | execute( TC_cbsp_bsc_server() ); |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1229 | execute( TC_cbsp_bsc_server_ipv6() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1230 | execute( TC_cbsp_bsc_client() ); |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1231 | execute( TC_cbsp_bsc_client_ipv6() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1232 | execute( TC_cbsp_reset_bss() ); |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 1233 | execute( TC_cbsp_cell_rflock_failure_restart() ); |
| 1234 | execute( TC_cbsp_cell_rsl_down_failure() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1235 | |
| 1236 | /* test various different types of Cell Identities */ |
| 1237 | execute( TC_cbsp_write_bss() ); |
| 1238 | execute( TC_cbsp_write_bts_cgi() ); |
| 1239 | execute( TC_cbsp_write_bts_no_cbch() ); |
| 1240 | execute( TC_cbsp_write_unknown_bts() ); |
| 1241 | execute( TC_cbsp_write_lac_ci() ); |
| 1242 | execute( TC_cbsp_write_ci() ); |
| 1243 | execute( TC_cbsp_write_lai() ); |
| 1244 | execute( TC_cbsp_write_lac() ); |
| 1245 | |
| 1246 | execute( TC_cbsp_write_then_replace() ); |
Vadim Yanitskiy | c2696fa | 2022-03-30 02:15:41 +0300 | [diff] [blame] | 1247 | execute( TC_cbsp_write_rep_period_num() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1248 | execute( TC_cbsp_replace_nonexist() ); |
| 1249 | execute( TC_cbsp_write_too_many() ); |
| 1250 | execute( TC_cbsp_kill_nonexist() ); |
| 1251 | execute( TC_cbsp_write_then_kill() ); |
| 1252 | execute( TC_cbsp_write_then_reset() ); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1253 | |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1254 | execute( TC_cbsp_status_q_empty() ); |
| 1255 | execute( TC_cbsp_status_q_bts_cgi() ); |
| 1256 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1257 | execute( TC_cbsp_emerg_write_bts_cgi_dchan() ); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1258 | execute( TC_cbsp_emerg_write_bts_cgi_cchan() ); |
| 1259 | execute( TC_cbsp_emerg_write_bts_cgi_cchan_disable() ); |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1260 | execute( TC_cbsp_emerg_write_bts_cgi_noreplace() ); |
| 1261 | execute( TC_cbsp_emerg_write_bts_cgi_replace() ); |
| 1262 | execute( TC_cbsp_emerg_write_bts_cgi_kill() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | |
| 1266 | } |