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")) { |
| 284 | rx := tr_CBSP_WRITE_CBS_COMPL(msg_id, ser_no, success_list, omit); |
| 285 | } else { |
| 286 | rx := tr_CBSP_WRITE_CBS_FAIL(msg_id, ser_no, fail_list, *, success_list, omit); |
| 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")) { |
| 344 | rx := tr_CBSP_REPLACE_CBS_COMPL(msg_id, new_ser_no, old_ser_no, omit, success_list, omit); |
| 345 | } else { |
| 346 | rx := tr_CBSP_REPLACE_CBS_FAIL(msg_id, new_ser_no, old_ser_no, fail_list, omit, success_list, omit); |
| 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 { |
| 549 | var template CBSP_PDU rx; |
| 550 | |
| 551 | g_pars := valueof(ts_CBSP_Pars_default(false, 0, 0)); |
| 552 | f_init(); |
| 553 | |
| 554 | /* Lock the TRX, CBCH should become unavailable and BSC send FAILURE */ |
| 555 | f_ctrl_set(IPA_CTRL, "bts.0.trx.0.rf_locked", "1"); |
| 556 | |
| 557 | rx := tr_CBSP_FAILURE({CBSP_FailureListItem_LAC_CI(bssmap_lac_ci(mp_cgi_bts0), |
| 558 | CBSP_CAUSE_CB_NOT_OPERATIONAL)}, |
| 559 | CBSP_BC_MSGT_CBS); |
| 560 | alt { |
| 561 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 562 | setverdict(pass); |
| 563 | } |
| 564 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 565 | setverdict(fail, "Received unexpected CBSP"); |
| 566 | mtc.stop; |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | /* Unlock the TRX, CBCH should become available and BSC send RESTART */ |
| 571 | f_ctrl_set(IPA_CTRL, "bts.0.trx.0.rf_locked", "0"); |
| 572 | rx := tr_CBSP_RESTART(ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}), |
| 573 | CBSP_BC_MSGT_CBS, ?); |
| 574 | alt { |
| 575 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 576 | setverdict(pass); |
| 577 | } |
| 578 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 579 | setverdict(fail, "Received unexpected CBSP"); |
| 580 | mtc.stop; |
| 581 | } |
| 582 | } |
| 583 | |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 584 | f_shutdown_helper(); |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | /* Test if a LAC_CI FAILURE Ind is sent when conn of TRX holding the CBCH goes down. */ |
| 588 | testcase TC_cbsp_cell_rsl_down_failure() runs on cbsp_test_CT { |
| 589 | var template CBSP_PDU rx; |
| 590 | |
| 591 | g_pars := valueof(ts_CBSP_Pars_default(false, 0, 0)); |
| 592 | f_init(); |
| 593 | |
| 594 | /* Drop RSL link of the TRX holding the CBCH: */ |
| 595 | f_ipa_rsl_stop(bts[0][0].rsl); |
| 596 | |
| 597 | rx := tr_CBSP_FAILURE({CBSP_FailureListItem_LAC_CI(bssmap_lac_ci(mp_cgi_bts0), |
| 598 | CBSP_CAUSE_CB_NOT_OPERATIONAL)}, |
| 599 | CBSP_BC_MSGT_CBS); |
| 600 | alt { |
| 601 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 602 | setverdict(pass); |
| 603 | } |
| 604 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 605 | setverdict(fail, "Received unexpected CBSP"); |
| 606 | mtc.stop; |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | /* TODO: call f_init() again to reconnect? */ |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 611 | f_shutdown_helper(); |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 612 | } |
| 613 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 614 | testcase TC_cbsp_write() runs on cbsp_test_CT { |
| 615 | var template (value) CBSP_PDU tx; |
| 616 | var CBSP_IEs pages := {f_gen_page()}; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 617 | g_pars := valueof(ts_CBSP_Pars_default(false, 0, 0)); |
| 618 | f_init(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 619 | |
| 620 | tx := ts_CBSP_WRITE_CBS(msg_id:=23, new_ser_nr:=42, cell_list:=ts_BSSMAP_CIL_BSS, |
| 621 | channel_ind:=0, category:=CBSP_CATEG_NORMAL, |
| 622 | rep_period:=10, num_bcast_req:=1, dcs := 0, |
| 623 | content:=pages); |
| 624 | |
| 625 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 626 | f_sleep(10.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 627 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | /* Write to entire BSS; three cells succeed; one fails (no CBCH) */ |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 631 | function f_tc_cbsp_write_bss(integer payload_len := -1, template (present) integer expect_blocks) runs on cbsp_test_CT { |
| 632 | var CBSP_IEs pages := {f_gen_page(payload_len := payload_len)}; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 633 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 634 | cell_list := ts_BSSMAP_CIL_BSS; |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 635 | 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] | 636 | success_list:=tr_BSSMAP_CIL_CGI({?,?,?}), fail_list:={?}); |
| 637 | |
Harald Welte | 38a833b | 2020-08-21 12:12:15 +0200 | [diff] [blame] | 638 | 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] | 639 | log("RSL[0,1,2] EXPECTING ", tr_ASP_RSL_UD(tr)); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 640 | interleave { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 641 | [] IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[0]"); } |
| 642 | [] IPA_RSL[1][0].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[1]"); } |
| 643 | [] 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] | 644 | } |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 645 | setverdict(pass); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 646 | |
| 647 | /* Make the next test run (if any) use different msg_id and ser_no */ |
| 648 | f_g_cbsp_next_msg_id_ser_no(); |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 649 | } |
| 650 | testcase TC_cbsp_write_bss() runs on cbsp_test_CT { |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 651 | g_pars := valueof(ts_CBSP_Pars_default(false, 1001, 1501)); |
| 652 | f_init(guard_timeout := 60.0); |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 653 | /* In the SMSCB message, there is a head followed by payload, |
| 654 | * and the resulting data is segmented in blocks of 22 octets (<= 4 blocks). |
| 655 | * |
| 656 | * [head][...payload....]|[....................]|[....................]|[....................] |
| 657 | * 0 |16 |38 |60 |82 |
| 658 | * 0 5 |22 |44 |66 |88 |
| 659 | * |
| 660 | * blocks count: 1 | 2 | 3 | 4 |
| 661 | * payload octets count: 1..16 | 17..38 | 39..60 | 61..82 |
| 662 | */ |
| 663 | f_tc_cbsp_write_bss(payload_len := 1, expect_blocks := 1); |
| 664 | f_tc_cbsp_write_bss(payload_len := 2, expect_blocks := 1); |
| 665 | f_tc_cbsp_write_bss(payload_len := 16, expect_blocks := 1); |
| 666 | f_tc_cbsp_write_bss(payload_len := 17, expect_blocks := 2); |
| 667 | f_tc_cbsp_write_bss(payload_len := 23, expect_blocks := 2); |
| 668 | f_tc_cbsp_write_bss(payload_len := 38, expect_blocks := 2); |
| 669 | f_tc_cbsp_write_bss(payload_len := 39, expect_blocks := 3); |
| 670 | f_tc_cbsp_write_bss(payload_len := 42, expect_blocks := 3); |
| 671 | f_tc_cbsp_write_bss(payload_len := 60, expect_blocks := 3); |
| 672 | f_tc_cbsp_write_bss(payload_len := 61, expect_blocks := 4); |
| 673 | f_tc_cbsp_write_bss(payload_len := 77, expect_blocks := 4); |
| 674 | f_tc_cbsp_write_bss(payload_len := 82, expect_blocks := 4); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 675 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | /* Write to single BTS supporting CBCH: success */ |
| 679 | testcase TC_cbsp_write_bts_cgi() runs on cbsp_test_CT { |
| 680 | var CBSP_IEs pages := {f_gen_page()}; |
| 681 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 682 | g_pars := valueof(ts_CBSP_Pars_default(false, 2001, 2501)); |
| 683 | f_init(); |
| 684 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 685 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 686 | 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] | 687 | success_list:=cell_list, fail_list:=omit); |
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); |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 689 | IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 690 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 691 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 692 | } |
| 693 | |
| 694 | /* Write to single BTS not supporting CBCH: failure */ |
| 695 | testcase TC_cbsp_write_bts_no_cbch() runs on cbsp_test_CT { |
| 696 | var CBSP_IEs pages := {f_gen_page()}; |
| 697 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 698 | g_pars := valueof(ts_CBSP_Pars_default(false, 3001, 3501)); |
| 699 | f_init(); |
| 700 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 701 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts3)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 702 | 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] | 703 | success_list:=omit, fail_list:={?}); |
| 704 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 705 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 706 | } |
| 707 | |
| 708 | /* Write to single non-existant BTS */ |
| 709 | testcase TC_cbsp_write_unknown_bts() runs on cbsp_test_CT { |
| 710 | var CBSP_IEs pages := {f_gen_page()}; |
| 711 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 712 | g_pars := valueof(ts_CBSP_Pars_default(false, 4001, 4501)); |
| 713 | f_init(); |
| 714 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 715 | 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] | 716 | 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] | 717 | success_list:=omit, fail_list:={?}); |
| 718 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 719 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | /* Write to single BTS using LAC+CI */ |
| 723 | testcase TC_cbsp_write_lac_ci() runs on cbsp_test_CT { |
| 724 | var CBSP_IEs pages := {f_gen_page()}; |
| 725 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 726 | g_pars := valueof(ts_CBSP_Pars_default(false, 5001, 5501)); |
| 727 | f_init(); |
| 728 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 729 | 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] | 730 | 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] | 731 | success_list:=?, fail_list:=omit); |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 732 | 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] | 733 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 734 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | /* Write to single BTS using CI */ |
| 738 | testcase TC_cbsp_write_ci() runs on cbsp_test_CT { |
| 739 | var CBSP_IEs pages := {f_gen_page()}; |
| 740 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 741 | g_pars := valueof(ts_CBSP_Pars_default(false, 6001, 6501)); |
| 742 | f_init(); |
| 743 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 744 | cell_list := ts_BSSMAP_CIL_CI({bssmap_ci(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 745 | 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] | 746 | success_list:=?, fail_list:=omit); |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 747 | 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] | 748 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 749 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | /* Write to single BTS using LAI */ |
| 753 | testcase TC_cbsp_write_lai() runs on cbsp_test_CT { |
| 754 | var CBSP_IEs pages := {f_gen_page()}; |
| 755 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 756 | g_pars := valueof(ts_CBSP_Pars_default(false, 7001, 7501)); |
| 757 | f_init(); |
| 758 | |
Neels Hofmeyr | f514848 | 2020-07-31 16:56:02 +0200 | [diff] [blame] | 759 | /* bts0 and bts1 have the same LAI (only differ in cell identity). |
| 760 | * bts2 and bts3 also have the same LAI, but only bts2 has a CBCH. |
| 761 | * Target only bts2. |
| 762 | */ |
| 763 | cell_list := ts_BSSMAP_CIL_LAI({bssmap_lai(mp_cgi_bts2)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 764 | 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] | 765 | success_list:=?, fail_list:=omit); |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 766 | 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] | 767 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 768 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | /* Write to two BTS using LAC */ |
| 772 | testcase TC_cbsp_write_lac() runs on cbsp_test_CT { |
| 773 | var CBSP_IEs pages := {f_gen_page()}; |
| 774 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 775 | g_pars := valueof(ts_CBSP_Pars_default(false, 8001, 8501)); |
| 776 | f_init(); |
| 777 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 778 | cell_list := ts_BSSMAP_CIL_LAC({bssmap_lac(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 779 | 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] | 780 | success_list:=?, fail_list:=omit); |
Harald Welte | 38a833b | 2020-08-21 12:12:15 +0200 | [diff] [blame] | 781 | 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] | 782 | interleave { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 783 | [] IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)); |
| 784 | [] IPA_RSL[1][0].receive(tr_ASP_RSL_UD(tr)); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 785 | } |
| 786 | f_sleep(5.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 787 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | /* Write a message, then replace it */ |
| 791 | testcase TC_cbsp_write_then_replace() runs on cbsp_test_CT { |
| 792 | var CBSP_IEs pages := {f_gen_page()}; |
| 793 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 794 | g_pars := valueof(ts_CBSP_Pars_default(false, 9001, 9501)); |
| 795 | f_init(); |
| 796 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 797 | 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] | 798 | 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] | 799 | success_list:=?, fail_list:=omit); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 800 | |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 801 | 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] | 802 | |
| 803 | /* Replace: keep the same msg_id, use a new ser_no */ |
| 804 | var uint16_t old_ser_no := g_cbsp_ser_no; |
| 805 | g_cbsp_ser_no := g_cbsp_ser_no + 1; |
| 806 | 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] | 807 | success_list:=?, fail_list:=omit); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 808 | |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 809 | 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] | 810 | f_sleep(1.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 811 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 812 | } |
| 813 | |
Vadim Yanitskiy | c2696fa | 2022-03-30 02:15:41 +0300 | [diff] [blame] | 814 | /* Verify handling of the Repetition Period and the Number of Broadcasts */ |
| 815 | testcase TC_cbsp_write_rep_period_num() runs on cbsp_test_CT { |
| 816 | var CBSP_IE page := f_gen_page(); |
| 817 | const integer rep_period := 2; /* units of 1.883s */ |
| 818 | const integer rep_number := 5; |
| 819 | var integer msg_count := 0; |
| 820 | var float last_time := 0.0; |
| 821 | timer T; |
| 822 | |
| 823 | g_pars := valueof(ts_CBSP_Pars_default(false, 9001, 9501)); |
| 824 | f_init(guard_timeout := 60.0); |
| 825 | |
| 826 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, |
| 827 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}), |
| 828 | rep_period := rep_period, num_bcast_req := rep_number, |
| 829 | content := { page }, success_list := ?, fail_list := omit); |
| 830 | |
| 831 | /* Count SMSCB messages during N=rep_number+2 repetition periods */ |
| 832 | T.start(int2float(rep_period * (rep_number + 2)) * 1.883); |
| 833 | alt { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 834 | [] 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] | 835 | var float exp_period := int2float(rep_period) * 1.883; |
| 836 | var float calc_period := T.read - last_time; |
| 837 | |
| 838 | log("Rx SMSCB message: count := ", msg_count + 1, ", ", |
| 839 | "elapsed := ", T.read, "s, diff := ", calc_period, "s"); |
| 840 | |
| 841 | if (msg_count > 0) { |
| 842 | /* Check the actual repetition period (+/- 0.5s) */ |
| 843 | var template float tr_exp_period := (exp_period - 0.5 .. exp_period + 0.5); |
| 844 | if (not match(calc_period, tr_exp_period)) { |
| 845 | setverdict(fail, "Repetition period mismatch: ", |
| 846 | "calculated := ", calc_period, "s vs ", |
| 847 | "expected := ", tr_exp_period, "s"); |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | msg_count := msg_count + 1; |
| 852 | last_time := T.read; |
| 853 | repeat; |
| 854 | } |
| 855 | [] T.timeout { |
| 856 | log("Received ", msg_count, " messages during ", last_time, "s"); |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | if (msg_count != rep_number) { |
| 861 | setverdict(fail, "Received ", msg_count, " messages, ", |
| 862 | "while we expected ", rep_number); |
| 863 | } |
| 864 | |
| 865 | f_sleep(1.0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 866 | f_shutdown_helper(); |
Vadim Yanitskiy | c2696fa | 2022-03-30 02:15:41 +0300 | [diff] [blame] | 867 | } |
| 868 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 869 | /* Replace a message that doesn't exist: failure */ |
| 870 | testcase TC_cbsp_replace_nonexist() runs on cbsp_test_CT { |
| 871 | var CBSP_IEs pages := {f_gen_page()}; |
| 872 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 873 | g_pars := valueof(ts_CBSP_Pars_default(false, 10001, 10501)); |
| 874 | f_init(); |
| 875 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 876 | 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] | 877 | f_cbsp_replace(10, 10023, 10042, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 878 | success_list:=omit, fail_list:=?); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 879 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | /* Write more messages than can be scheduled */ |
| 883 | testcase TC_cbsp_write_too_many() runs on cbsp_test_CT { |
| 884 | /* repeating three pages at an interval of 1 is impossible */ |
| 885 | var CBSP_IEs pages := {f_gen_page(), f_gen_page(), f_gen_page()}; |
| 886 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 887 | g_pars := valueof(ts_CBSP_Pars_default(false, 11001, 11501)); |
| 888 | f_init(); |
| 889 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 890 | 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] | 891 | 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] | 892 | success_list:=omit, fail_list:=?); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 893 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 894 | } |
| 895 | |
| 896 | /* Kill message that doesn't exist: failure */ |
| 897 | testcase TC_cbsp_kill_nonexist() runs on cbsp_test_CT { |
| 898 | var CBSP_IEs pages := {f_gen_page()}; |
| 899 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 900 | g_pars := valueof(ts_CBSP_Pars_default(false, 12001, 12501)); |
| 901 | f_init(); |
| 902 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 903 | 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] | 904 | 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] | 905 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 906 | } |
| 907 | /* Write a message, then kill it */ |
| 908 | testcase TC_cbsp_write_then_kill() runs on cbsp_test_CT { |
| 909 | var CBSP_IEs pages := {f_gen_page()}; |
| 910 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 911 | g_pars := valueof(ts_CBSP_Pars_default(false, 13001, 13501)); |
| 912 | f_init(); |
| 913 | |
Harald Welte | 3912895 | 2022-04-14 15:33:58 +0200 | [diff] [blame] | 914 | /* write message, request more than one transmission on BTS0 */ |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 915 | 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] | 916 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, num_bcast_req := 5, content:=pages, success_list:=?, fail_list:=omit); |
| 917 | /* expect to receive it once on the BTS */ |
| 918 | 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] | 919 | IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)); |
Harald Welte | 1222f52 | 2022-04-27 17:56:05 +0200 | [diff] [blame] | 920 | /* kill it, expecting non-empty completion list; success must be empty in case of CBS! */ |
| 921 | 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] | 922 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | /* Write a message, then reset all messages */ |
| 926 | testcase TC_cbsp_write_then_reset() runs on cbsp_test_CT { |
| 927 | var CBSP_IEs pages := {f_gen_page()}; |
| 928 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 929 | g_pars := valueof(ts_CBSP_Pars_default(false, 14001, 14501)); |
| 930 | f_init(); |
| 931 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 932 | 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] | 933 | 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] | 934 | f_cbsp_reset_bss(0); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 935 | f_shutdown_helper(); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 936 | } |
| 937 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 938 | private const octetstring c_ETWS_sec_default := |
| 939 | '00000000000000000000000000000000000000000000000000'O & |
| 940 | '00000000000000000000000000000000000000000000000000'O; |
| 941 | function f_gen_etws_pn(uint16_t ser_nr, uint16_t msg_id, OCT2 msg_type := '0780'O, |
| 942 | octetstring sec_inf := c_ETWS_sec_default) return octetstring { |
| 943 | return int2oct(ser_nr, 2) & int2oct(msg_id, 2) & msg_type & sec_inf; |
| 944 | } |
| 945 | |
| 946 | /* Write ETWS PN to single BTS; verify it arrives on DCHAN */ |
| 947 | testcase TC_cbsp_emerg_write_bts_cgi_dchan() runs on cbsp_test_CT { |
| 948 | var CBSP_IEs pages := {f_gen_page()}; |
| 949 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 950 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 951 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 952 | g_pars := valueof(ts_CBSP_Pars_default(false, 15001, 15501)); |
| 953 | f_init(); |
| 954 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 955 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 956 | |
| 957 | /* first establish a dedicated channel */ |
| 958 | var DchanTuple dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 959 | |
| 960 | /* then send ETWS PN */ |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 961 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list); |
| 962 | 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] | 963 | timer T := 5.0; |
| 964 | T.start; |
| 965 | alt { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 966 | [] 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] | 967 | var RSL_IE_Body l3_ie; |
| 968 | if (f_rsl_find_ie(rx_rsl_ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) { |
| 969 | setverdict(fail, "RSL DATA REQ without L3?"); |
| 970 | mtc.stop; |
| 971 | } |
| 972 | var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload); |
| 973 | var template (present) APDU_Flags_V tr_flags := { |
| 974 | lastSeg := '0'B, |
| 975 | firstSeg := '0'B, |
| 976 | cR := '0'B, |
| 977 | spare := '0'B |
| 978 | }; |
| 979 | if (match(l3, tr_RR_APP_INFO('0001'B, tr_apdu, tr_flags))) { |
| 980 | setverdict(pass); |
| 981 | } |
| 982 | } |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 983 | [] IPA_RSL[0][0].receive { repeat; } |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 984 | [] T.timeout { |
| 985 | setverdict(fail, "Waiting for APP INFO"); |
| 986 | } |
| 987 | } |
Vadim Yanitskiy | 65d879d | 2022-06-23 18:15:39 +0700 | [diff] [blame] | 988 | |
| 989 | f_perform_clear_test_ct(dt); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 990 | f_shutdown_helper(); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 991 | } |
| 992 | |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 993 | private function f_exp_rsl_etws(integer rsl_idx := 0, boolean enabled) runs on cbsp_test_CT { |
| 994 | var template (present) octetstring tr_apdu; |
| 995 | timer T := 5.0; |
| 996 | T.start; |
| 997 | |
| 998 | if (enabled) { |
| 999 | tr_apdu := f_gen_etws_pn(g_cbsp_ser_no, g_cbsp_msg_id); |
| 1000 | } else { |
| 1001 | tr_apdu := ''O; |
| 1002 | } |
| 1003 | |
| 1004 | alt { |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 1005 | [] 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] | 1006 | setverdict(pass); |
| 1007 | } |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 1008 | [] 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] | 1009 | setverdict(fail, "Received unexpected OSMO_ETWS_CMD"); |
| 1010 | mtc.stop; |
| 1011 | } |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 1012 | [] IPA_RSL[rsl_idx][0].receive { repeat; } |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1013 | [] T.timeout { |
| 1014 | if (enabled) { |
| 1015 | setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD (enable)"); |
| 1016 | } else { |
| 1017 | setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD (disable)"); |
| 1018 | } |
| 1019 | mtc.stop; |
| 1020 | } |
| 1021 | } |
| 1022 | } |
| 1023 | |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1024 | /* Write ETWS PN to single BTS; verify it arrives on CCHAN */ |
| 1025 | testcase TC_cbsp_emerg_write_bts_cgi_cchan() runs on cbsp_test_CT { |
| 1026 | var CBSP_IEs pages := {f_gen_page()}; |
| 1027 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1028 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 1029 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1030 | g_pars := valueof(ts_CBSP_Pars_default(false, 16001, 16501)); |
| 1031 | f_init(); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1032 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1033 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 1034 | 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] | 1035 | |
| 1036 | f_exp_rsl_etws(0, true); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1037 | f_shutdown_helper(); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1038 | } |
| 1039 | |
| 1040 | /* Write ETWS PN to single BTS; verify it arrives on CCHAN */ |
| 1041 | testcase TC_cbsp_emerg_write_bts_cgi_cchan_disable() runs on cbsp_test_CT { |
| 1042 | var CBSP_IEs pages := {f_gen_page()}; |
| 1043 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1044 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 1045 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1046 | g_pars := valueof(ts_CBSP_Pars_default(false, 17001, 17501)); |
| 1047 | f_init(); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1048 | |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1049 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 1050 | 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] | 1051 | |
| 1052 | /* first expect the PN to be enabled */ |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1053 | f_exp_rsl_etws(0, true); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1054 | |
| 1055 | /* then expect it to be disabled after the warning period (5s) */ |
Harald Welte | 8bb2944 | 2022-04-25 13:26:41 +0200 | [diff] [blame] | 1056 | f_exp_rsl_etws(0, false); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1057 | f_shutdown_helper(); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1058 | } |
| 1059 | |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1060 | /* Write (!replace) ETWS PN to a single BTS which already has an ongoing PN; expect failure (OS#5539) */ |
| 1061 | testcase TC_cbsp_emerg_write_bts_cgi_noreplace() runs on cbsp_test_CT { |
| 1062 | var CBSP_IEs pages := {f_gen_page()}; |
| 1063 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1064 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 1065 | |
| 1066 | g_pars := valueof(ts_CBSP_Pars_default(false, 18001, 18501)); |
| 1067 | f_init(); |
| 1068 | |
| 1069 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 1070 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list); |
| 1071 | |
| 1072 | /* first expect the PN to be enabled */ |
| 1073 | f_exp_rsl_etws(0, true); |
| 1074 | |
| 1075 | /* write another emergency while first one is still ongoing; expect it to fail */ |
| 1076 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no+1, cell_list, success_list:=omit, fail_list:=?); |
| 1077 | |
| 1078 | /* then expect first one to be disabled after the warning period (5s) */ |
| 1079 | f_exp_rsl_etws(0, false); |
| 1080 | |
| 1081 | /* write another emergency after the first one has expired; expect it to succeed */ |
| 1082 | g_cbsp_ser_no := g_cbsp_ser_no + 2; |
| 1083 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, success_list:=?, fail_list:=omit); |
| 1084 | f_exp_rsl_etws(0, true); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1085 | f_shutdown_helper(); |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1086 | } |
| 1087 | |
| 1088 | /* Replace ETWS PN to a single BTS which already has an ongoing PN; expect success */ |
| 1089 | testcase TC_cbsp_emerg_write_bts_cgi_replace() runs on cbsp_test_CT { |
| 1090 | var CBSP_IEs pages := {f_gen_page()}; |
| 1091 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1092 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 1093 | |
| 1094 | g_pars := valueof(ts_CBSP_Pars_default(false, 19001, 19501)); |
| 1095 | f_init(); |
| 1096 | |
| 1097 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 1098 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list); |
| 1099 | |
| 1100 | /* first expect the PN to be enabled */ |
| 1101 | f_exp_rsl_etws(0, true); |
| 1102 | |
| 1103 | /* write another emergency while first one is still ongoing; expect it to fail */ |
| 1104 | 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] | 1105 | f_shutdown_helper(); |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1106 | } |
| 1107 | |
| 1108 | /* Write ETWS PN to a single BTS, then kill it during its lifetime (OS#5540) */ |
| 1109 | testcase TC_cbsp_emerg_write_bts_cgi_kill() runs on cbsp_test_CT { |
| 1110 | var CBSP_IEs pages := {f_gen_page()}; |
| 1111 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1112 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 1113 | |
| 1114 | g_pars := valueof(ts_CBSP_Pars_default(false, 20001, 20501)); |
| 1115 | f_init(); |
| 1116 | |
| 1117 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 1118 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, warn_per := 10); |
| 1119 | |
| 1120 | /* first expect the PN to be enabled */ |
| 1121 | f_exp_rsl_etws(0, true); |
| 1122 | |
| 1123 | /* kill it; expect non-zero success list, and no completion or failure lists */ |
| 1124 | f_cbsp_kill(g_cbsp_msg_id, g_cbsp_ser_no, omit, cell_list, success_list:=cell_list, |
| 1125 | compl_list:=omit, fail_list:=omit); |
| 1126 | |
| 1127 | /* then expect it to be disabled */ |
| 1128 | f_exp_rsl_etws(0, false); |
Pau Espin Pedrol | d5496ad | 2022-06-23 12:12:25 +0200 | [diff] [blame] | 1129 | f_shutdown_helper(); |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | |
| 1133 | |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1134 | /* Send a MSG STATUS QUERY for an unknown message; expect no completion list and present failure list */ |
| 1135 | testcase TC_cbsp_status_q_empty() runs on cbsp_test_CT { |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1136 | g_pars := valueof(ts_CBSP_Pars_default(false, 21001, 21501)); |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1137 | f_init(); |
| 1138 | |
| 1139 | 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] | 1140 | f_shutdown_helper(); |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | /* Send a SMSCB to entire BSS followed by MSG_STATUS_QUERY; expect completion list and no failure list */ |
| 1144 | testcase TC_cbsp_status_q_bts_cgi() runs on cbsp_test_CT { |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1145 | g_pars := valueof(ts_CBSP_Pars_default(false, 22001, 22501)); |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1146 | f_init(); |
| 1147 | |
| 1148 | var CBSP_IEs pages := {f_gen_page()}; |
| 1149 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 1150 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 1151 | /* request 5 transmissions */ |
| 1152 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, num_bcast_req := 5, content:=pages, |
| 1153 | success_list:=cell_list, fail_list:=omit); |
| 1154 | var template (present) RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no); |
| 1155 | /* wait for first transmission */ |
Vadim Yanitskiy | e5d393c | 2022-05-29 16:55:42 +0600 | [diff] [blame] | 1156 | IPA_RSL[0][0].receive(tr_ASP_RSL_UD(tr)); |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1157 | var template (present) CBSP_IE_NumBcastComplList compl_list := { |
| 1158 | len := ?, |
| 1159 | spare1_4 := ?, |
| 1160 | cell_id_discr := ?, |
| 1161 | list := { |
| 1162 | cI_CGI := { |
| 1163 | ci := bssmap_cgi(mp_cgi_bts0), |
| 1164 | num_bcast_compl := (1 .. 5), |
| 1165 | num_bcast_info := CBSP_NUM_BCAST_INFO_VALID, |
| 1166 | spare1_4 := '0000'B |
| 1167 | } |
| 1168 | } |
| 1169 | }; |
| 1170 | 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] | 1171 | f_shutdown_helper(); |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1172 | } |
| 1173 | |
| 1174 | |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1175 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1176 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1177 | control { |
| 1178 | execute( TC_cbsp_bsc_server() ); |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1179 | execute( TC_cbsp_bsc_server_ipv6() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1180 | execute( TC_cbsp_bsc_client() ); |
Pau Espin Pedrol | 62adaaf | 2020-09-15 18:05:46 +0200 | [diff] [blame] | 1181 | execute( TC_cbsp_bsc_client_ipv6() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1182 | execute( TC_cbsp_reset_bss() ); |
Pau Espin Pedrol | 2b33d4e | 2022-06-10 17:00:30 +0200 | [diff] [blame] | 1183 | execute( TC_cbsp_cell_rflock_failure_restart() ); |
| 1184 | execute( TC_cbsp_cell_rsl_down_failure() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1185 | |
| 1186 | /* test various different types of Cell Identities */ |
| 1187 | execute( TC_cbsp_write_bss() ); |
| 1188 | execute( TC_cbsp_write_bts_cgi() ); |
| 1189 | execute( TC_cbsp_write_bts_no_cbch() ); |
| 1190 | execute( TC_cbsp_write_unknown_bts() ); |
| 1191 | execute( TC_cbsp_write_lac_ci() ); |
| 1192 | execute( TC_cbsp_write_ci() ); |
| 1193 | execute( TC_cbsp_write_lai() ); |
| 1194 | execute( TC_cbsp_write_lac() ); |
| 1195 | |
| 1196 | execute( TC_cbsp_write_then_replace() ); |
Vadim Yanitskiy | c2696fa | 2022-03-30 02:15:41 +0300 | [diff] [blame] | 1197 | execute( TC_cbsp_write_rep_period_num() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1198 | execute( TC_cbsp_replace_nonexist() ); |
| 1199 | execute( TC_cbsp_write_too_many() ); |
| 1200 | execute( TC_cbsp_kill_nonexist() ); |
| 1201 | execute( TC_cbsp_write_then_kill() ); |
| 1202 | execute( TC_cbsp_write_then_reset() ); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1203 | |
Harald Welte | 562d28e | 2022-03-28 21:29:04 +0200 | [diff] [blame] | 1204 | execute( TC_cbsp_status_q_empty() ); |
| 1205 | execute( TC_cbsp_status_q_bts_cgi() ); |
| 1206 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 1207 | execute( TC_cbsp_emerg_write_bts_cgi_dchan() ); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 1208 | execute( TC_cbsp_emerg_write_bts_cgi_cchan() ); |
| 1209 | execute( TC_cbsp_emerg_write_bts_cgi_cchan_disable() ); |
Harald Welte | 4a788a0 | 2022-04-27 16:57:24 +0200 | [diff] [blame] | 1210 | execute( TC_cbsp_emerg_write_bts_cgi_noreplace() ); |
| 1211 | execute( TC_cbsp_emerg_write_bts_cgi_replace() ); |
| 1212 | execute( TC_cbsp_emerg_write_bts_cgi_kill() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1213 | } |
| 1214 | |
| 1215 | |
| 1216 | } |