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 | |
| 15 | import from General_Types all; |
| 16 | import from Osmocom_Types all; |
| 17 | import from GSM_Types all; |
| 18 | import from IPL4asp_Types all; |
| 19 | import from BSSAP_Types all; |
| 20 | import from BSSMAP_Templates all; |
| 21 | |
| 22 | import from BSC_Tests all; |
| 23 | |
| 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 | |
| 40 | modulepar { |
| 41 | charstring mp_cbc_ip := "0.0.0.0"; |
| 42 | integer mp_cbc_port := 48049; |
| 43 | integer mp_bsc_cbsp_port := 48050; |
| 44 | |
Harald Welte | 49a61e6 | 2020-03-30 20:13:32 +0200 | [diff] [blame] | 45 | /* BTS 0: 001-01-1-0 with CBCH |
| 46 | * BTS 1: 001-01-1-1 with CBCH |
| 47 | * BTS 2: 001-01-2-1 with CBCH |
| 48 | * BTS 3: 001-01-2-3 without CBCH */ |
| 49 | GsmCgiAbstract mp_cgi_bts0 := { '001'H, '01'H, 1, 0 }; |
| 50 | GsmCgiAbstract mp_cgi_bts1 := { '001'H, '01'H, 1, 1 }; |
| 51 | GsmCgiAbstract mp_cgi_bts2 := { '001'H, '01'H, 2, 1 }; |
| 52 | GsmCgiAbstract mp_cgi_bts3 := { '001'H, '01'H, 2, 3 }; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | private type record GsmCgiAbstract { |
| 56 | GsmMcc mcc, |
| 57 | GsmMnc mnc, |
| 58 | GsmLac lac, |
| 59 | GsmCellId ci |
| 60 | }; |
| 61 | private template (value) BSSMAP_FIELD_CellIdentification_CGI bssmap_cgi(GsmCgiAbstract cgi) := |
| 62 | ts_BSSMAP_CI_CGI(cgi.mcc, cgi.mnc, cgi.lac, cgi.ci); |
| 63 | private template (value) BSSMAP_FIELD_CellIdentification_LAC_CI bssmap_lac_ci(GsmCgiAbstract cgi) := |
| 64 | ts_BSSMAP_CI_LAC_CI(cgi.lac, cgi.ci); |
| 65 | private template (value) BSSMAP_FIELD_CellIdentification_LAI bssmap_lai(GsmCgiAbstract cgi) := |
| 66 | ts_BSSMAP_CI_LAI(cgi.mcc, cgi.mnc, cgi.lac); |
| 67 | private template (value) OCT2 bssmap_lac(GsmCgiAbstract cgi) := ts_BSSMAP_CI_LAC(cgi.lac); |
| 68 | private template (value) OCT2 bssmap_ci(GsmCgiAbstract cgi) := ts_BSSMAP_CI_CI(cgi.ci); |
| 69 | |
| 70 | type component cbsp_test_CT extends test_CT, CBSP_Adapter_CT { |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 71 | var uint16_t g_cbsp_msg_id := 0; |
| 72 | var uint16_t g_cbsp_ser_no := 0; |
| 73 | } |
| 74 | |
| 75 | private function f_g_cbsp_next_msg_id_ser_no() runs on cbsp_test_CT |
| 76 | { |
| 77 | g_cbsp_msg_id := g_cbsp_msg_id + 1; |
| 78 | g_cbsp_ser_no := g_cbsp_ser_no + 1; |
| 79 | log("g_cbsp_msg_id=", g_cbsp_msg_id, " g_cbsp_ser_no=", g_cbsp_ser_no); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | private altstep as_IgnRSL(template RSL_Message tr) runs on cbsp_test_CT { |
Vadim Yanitskiy | ca5c520 | 2020-05-25 22:03:28 +0700 | [diff] [blame] | 83 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr)) { repeat; } |
| 84 | [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr)) { repeat; } |
| 85 | [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr)) { repeat; } |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | private altstep as_FailRSL() runs on cbsp_test_CT { |
| 89 | var template RSL_Message tr := (tr_RSL_SMSCB_CMD); |
| 90 | var ASP_RSL_Unitdata rx; |
Vadim Yanitskiy | ca5c520 | 2020-05-25 22:03:28 +0700 | [diff] [blame] | 91 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr)) -> value rx { |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 92 | setverdict(fail, "Received unexpected RSL ", rx); |
| 93 | mtc.stop; |
| 94 | } |
Vadim Yanitskiy | ca5c520 | 2020-05-25 22:03:28 +0700 | [diff] [blame] | 95 | [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr)) -> value rx { |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 96 | setverdict(fail, "Received unexpected RSL ", rx); |
| 97 | mtc.stop; |
| 98 | } |
Vadim Yanitskiy | ca5c520 | 2020-05-25 22:03:28 +0700 | [diff] [blame] | 99 | [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr)) -> value rx { |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 100 | setverdict(fail, "Received unexpected RSL ", rx); |
| 101 | mtc.stop; |
| 102 | } |
| 103 | } |
| 104 | |
Neels Hofmeyr | 579bfa8 | 2020-07-29 00:33:59 +0200 | [diff] [blame] | 105 | private function f_init(float guard_timeout := 30.0) runs on cbsp_test_CT { |
| 106 | BSC_Tests.f_init(guard_timeout := guard_timeout); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 107 | activate(as_IgnRSL((tr_RSL_BCCH_INFO, tr_RSL_SACCH_FILL, |
| 108 | tr_RSL_NO_BCCH_INFO, tr_RSL_NO_SACCH_FILL, |
| 109 | tr_RSL_MsgTypeD(?)))); |
| 110 | activate(as_FailRSL()); |
| 111 | } |
| 112 | private function f_cbsp_init_client() runs on cbsp_test_CT { |
| 113 | f_init(); |
| 114 | CBSP_Adapter.f_connect(mp_bsc_ip, mp_bsc_cbsp_port, "", -1); |
Neels Hofmeyr | 289c36a | 2020-07-28 21:19:20 +0200 | [diff] [blame] | 115 | /* FIXME: osmo-bsc should probably still send a CBSP RESTART, but to get the current tests running, let's first |
| 116 | * ignore this aspect */ |
| 117 | setverdict(pass); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 118 | } |
| 119 | |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 120 | private function f_cbsp_init_server(uint16_t cbsp_msg_id, uint16_t cbsp_ser_no, float guard_timeout := 30.0) runs on cbsp_test_CT { |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 121 | var ASP_Event asp_evt; |
| 122 | timer T := 10.0; |
| 123 | |
Neels Hofmeyr | 579bfa8 | 2020-07-29 00:33:59 +0200 | [diff] [blame] | 124 | f_init(guard_timeout := guard_timeout); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 125 | CBSP_Adapter.f_bind(mp_cbc_ip, mp_cbc_port); |
| 126 | |
| 127 | T.start; |
| 128 | alt { |
| 129 | [] CBSP[0].receive(ASP_Event:{connOpened:=?}) -> value asp_evt { |
| 130 | g_cbsp_conn_id[0] := asp_evt.connOpened.connId; |
| 131 | } |
| 132 | [] T.timeout { |
| 133 | setverdict(fail, "Timeout waiting for incoming connection to CBSP Port"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 134 | mtc.stop; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 135 | } |
| 136 | } |
Neels Hofmeyr | 90a0752 | 2020-07-29 01:22:11 +0200 | [diff] [blame] | 137 | f_expect_cbsp_restart(); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 138 | |
| 139 | g_cbsp_msg_id := cbsp_msg_id; |
| 140 | g_cbsp_ser_no := cbsp_ser_no; |
| 141 | log("g_cbsp_msg_id=", g_cbsp_msg_id, " g_cbsp_ser_no=", g_cbsp_ser_no); |
Neels Hofmeyr | ff8a9f2 | 2020-08-13 16:06:11 +0000 | [diff] [blame] | 142 | |
| 143 | f_cbsp_reset_bss(0); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 144 | } |
Neels Hofmeyr | 90a0752 | 2020-07-29 01:22:11 +0200 | [diff] [blame] | 145 | private function f_expect_cbsp_restart() runs on cbsp_test_CT { |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 146 | interleave { |
| 147 | [] CBSP[0].receive(tr_CBSP_Recv(?, tr_CBSP_RESTART(?, CBSP_BC_MSGT_CBS, CBSP_RI_DATA_LOST))); |
| 148 | /* should we also expect a restart for emergency related messages? */ |
| 149 | //[] CBSP[0].receive(tr_CBSP_Recv(?, tr_CBSP_RESTART(?, CBSP_BC_MSGT_EMERG, CBSP_RI_DATA_LOST))); |
| 150 | } |
| 151 | } |
| 152 | |
Neels Hofmeyr | 4c36532 | 2020-07-29 00:36:37 +0200 | [diff] [blame] | 153 | /* Generate a CBSP payload: random size for payload_len == 0, or specific fixed size for payload_len > 0. */ |
| 154 | function f_gen_page(integer payload_len := 0) return CBSP_IE { |
| 155 | if (payload_len < 1) { |
| 156 | /* The maximum CBSP page payload space is 88, but 6 bytes of payload header are added in the first page: |
| 157 | * the maximum length generated here thus is 82. The minimum generated length is 1 (avoiding zero |
| 158 | * length). Note, f_rnd_int(82) returns [0..81], so this results in a len ranging [1..82]: */ |
| 159 | payload_len := 1 + f_rnd_int(82); |
| 160 | } |
| 161 | log("Generating CBSP payload: ", payload_len, " octets"); |
| 162 | var octetstring payload := f_rnd_octstring(payload_len); |
| 163 | return valueof(ts_CbspMsgContent(payload, payload_len)); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 164 | } |
| 165 | |
Neels Hofmeyr | ff8a9f2 | 2020-08-13 16:06:11 +0000 | [diff] [blame] | 166 | function f_cbsp_reset_bss(integer idx) runs on cbsp_test_CT { |
| 167 | /* Make sure no CBSP ETWS commands from a previous CBSP test remain in the RSL queue */ |
| 168 | IPA_RSL[0].clear; |
| 169 | IPA_RSL[1].clear; |
| 170 | IPA_RSL[2].clear; |
| 171 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 172 | var template (value) CBSP_PDU tx; |
| 173 | timer T := 3.0; |
| 174 | tx := ts_CBSP_RESET(cell_list := ts_BSSMAP_CIL_BSS); |
| 175 | CBSP[idx].clear; |
| 176 | CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx)); |
| 177 | T.start; |
| 178 | alt { |
| 179 | [] CBSP[idx].receive(tr_CBSP_Recv(?, tr_CBSP_RESET_COMPL(cell_list := ts_BSSMAP_CIL_BSS))); |
| 180 | [] CBSP[idx].receive { |
| 181 | setverdict(fail, "received unexpected CBSP"); |
| 182 | mtc.stop; |
| 183 | } |
| 184 | [] T.timeout { |
| 185 | setverdict(fail, "timeout waiting for RESET COMPLETE"); |
| 186 | mtc.stop; |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | /* 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] | 192 | function f_cbsp_write_emerg(uint16_t msg_id, uint16_t ser_no, |
| 193 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 194 | template (value) uint8_t emerg_ind := 1, |
| 195 | template (value) uint16_t warn_type := oct2int('0780'O), |
| 196 | template (value) uint16_t warn_per := 5, |
| 197 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 198 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT { |
| 199 | var template (value) CBSP_PDU tx; |
| 200 | var template CBSP_PDU rx; |
| 201 | var CBSP_IEs pages := {f_gen_page()}; |
| 202 | |
| 203 | tx := ts_CBSP_WRITE_EMERG(msg_id, ser_no, cell_list, emerg_ind, warn_type, warn_per); |
| 204 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 205 | if (istemplatekind(fail_list, "omit")) { |
| 206 | rx := tr_CBSP_WRITE_CBS_COMPL(msg_id, ser_no, success_list, omit); |
| 207 | } else { |
| 208 | rx := tr_CBSP_WRITE_CBS_FAIL(msg_id, ser_no, fail_list, *, success_list, omit); |
| 209 | } |
| 210 | alt { |
| 211 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 212 | setverdict(pass); |
| 213 | } |
| 214 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 215 | setverdict(fail, "Received unexpected CBSP"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 216 | mtc.stop; |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | /* 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] | 222 | function f_cbsp_write(uint16_t msg_id, uint16_t ser_no, |
| 223 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 224 | template (value) CBSP_Category category := CBSP_CATEG_NORMAL, |
| 225 | uint16_t rep_period := 10, uint16_t num_bcast_req := 1, |
| 226 | uint8_t dcs := 0, uint8_t channel_ind := 0, CBSP_IEs content, |
| 227 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 228 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT { |
| 229 | var template (value) CBSP_PDU tx; |
| 230 | var template CBSP_PDU rx; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 231 | |
| 232 | tx := ts_CBSP_WRITE_CBS(msg_id, ser_no, cell_list, channel_ind, category, |
| 233 | rep_period, num_bcast_req, dcs, content); |
| 234 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 235 | if (istemplatekind(fail_list, "omit")) { |
| 236 | rx := tr_CBSP_WRITE_CBS_COMPL(msg_id, ser_no, success_list, channel_ind); |
| 237 | } else { |
| 238 | rx := tr_CBSP_WRITE_CBS_FAIL(msg_id, ser_no, fail_list, *, success_list, channel_ind); |
| 239 | } |
| 240 | alt { |
| 241 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 242 | setverdict(pass); |
| 243 | } |
| 244 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 245 | setverdict(fail, "Received unexpected CBSP"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 246 | mtc.stop; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 247 | } |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | /* send a REPLACE CBS to the BSC; expect either COMPLETE or FAILURE in response*/ |
| 252 | function f_cbsp_replace(uint16_t msg_id, uint16_t new_ser_no, uint16_t old_ser_no, |
| 253 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 254 | template (value) CBSP_Category category := CBSP_CATEG_NORMAL, |
| 255 | uint16_t rep_period := 10, uint16_t num_bcast_req := 1, |
| 256 | uint8_t dcs := 0, uint8_t channel_ind := 0, CBSP_IEs content, |
| 257 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 258 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT { |
| 259 | var template (value) CBSP_PDU tx; |
| 260 | var template CBSP_PDU rx; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 261 | |
| 262 | tx := ts_CBSP_REPLACE_CBS(msg_id, new_ser_no, old_ser_no, cell_list, channel_ind, category, |
| 263 | rep_period, num_bcast_req, dcs, content); |
| 264 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 265 | if (istemplatekind(fail_list, "omit")) { |
| 266 | rx := tr_CBSP_REPLACE_CBS_COMPL(msg_id, new_ser_no, old_ser_no, ?, success_list, |
| 267 | channel_ind); |
| 268 | } else { |
| 269 | rx := tr_CBSP_REPLACE_CBS_FAIL(msg_id, new_ser_no, old_ser_no, fail_list, *, success_list, |
| 270 | channel_ind); |
| 271 | } |
| 272 | alt { |
| 273 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 274 | setverdict(pass); |
| 275 | } |
| 276 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 277 | setverdict(fail, "Received unexpected CBSP"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 278 | mtc.stop; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 279 | } |
| 280 | } |
| 281 | } |
| 282 | /* send a KILL CBS to the BSC; expect either COMPLETE or FAILURE in response*/ |
| 283 | function f_cbsp_kill(uint16_t msg_id, uint16_t ser_no, template (omit) uint8_t channel_ind := 0, |
| 284 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 285 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 286 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT |
| 287 | { |
| 288 | var template (value) CBSP_PDU tx; |
| 289 | var template CBSP_PDU rx; |
| 290 | |
| 291 | tx := ts_CBSP_KILL(msg_id, ser_no, cell_list, channel_ind); |
| 292 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 293 | if (istemplatekind(fail_list, "omit")) { |
| 294 | rx := tr_CBSP_KILL_COMPL(msg_id, ser_no, compl_list:=*, cell_list:=success_list, |
| 295 | channel_ind:=channel_ind); |
| 296 | } else { |
| 297 | rx := tr_CBSP_KILL_FAIL(msg_id, ser_no, fail_list, compl_list:=*, cell_list:=success_list, |
| 298 | channel_ind:=channel_ind); |
| 299 | } |
| 300 | alt { |
| 301 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 302 | setverdict(pass); |
| 303 | } |
| 304 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 305 | setverdict(fail, "Received unexpected CBSP"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 306 | mtc.stop; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 307 | } |
| 308 | } |
| 309 | } |
| 310 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 311 | template (present) RSL_IE_CbCommandType |
| 312 | tr_RslCbCmdType(template (present) uint2_t lblock := ?, template (present) RSL_CbCommand cmd := ?) := { |
| 313 | command := cmd, |
| 314 | default_bcast_null := ?, |
| 315 | spare := ?, |
| 316 | last_block := lblock |
| 317 | } |
| 318 | |
Neels Hofmeyr | df65951 | 2020-07-29 00:41:42 +0200 | [diff] [blame] | 319 | /* translate blocks count to RSL_CB_CMD_LASTBLOCK_1..4 values */ |
| 320 | private function f_cbsp_block_count_enc(integer num_blocks) return integer |
| 321 | { |
| 322 | if (num_blocks < 1 or num_blocks > 4) { |
| 323 | setverdict(fail, "Invalid num_blocks: ", num_blocks); |
| 324 | mtc.stop; |
| 325 | } |
| 326 | if (num_blocks == 4) { |
| 327 | return 0; |
| 328 | } |
| 329 | return num_blocks; |
| 330 | } |
| 331 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 332 | /* build a RSL_Message receive template from a CBSP page */ |
Neels Hofmeyr | 63e2e18 | 2020-08-12 11:42:01 +0000 | [diff] [blame] | 333 | private function f_page2rsl(CBSP_IE page, uint16_t msg_id, uint16_t ser_no, boolean ext_cbch := false, |
| 334 | template (present) integer expect_blocks := ?) |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 335 | return template (present) RSL_Message |
| 336 | { |
| 337 | var template RSL_Message tr; |
Neels Hofmeyr | df65951 | 2020-07-29 00:41:42 +0200 | [diff] [blame] | 338 | var integer len; |
| 339 | var integer num_blocks; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 340 | var octetstring payload; |
Neels Hofmeyr | df65951 | 2020-07-29 00:41:42 +0200 | [diff] [blame] | 341 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 342 | 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] | 343 | len := lengthof(payload); |
| 344 | num_blocks := len / 22; |
| 345 | if (len mod 22 > 0) { |
| 346 | num_blocks := num_blocks + 1; |
| 347 | } |
| 348 | |
Neels Hofmeyr | 63e2e18 | 2020-08-12 11:42:01 +0000 | [diff] [blame] | 349 | if (not istemplatekind(expect_blocks, "omit") and not match(num_blocks, expect_blocks)) { |
| 350 | setverdict(fail, "mismatch: CBSP page expect_blocks == ", expect_blocks, ", but generated num_blocks == ", num_blocks); |
| 351 | mtc.stop; |
| 352 | } |
| 353 | |
Neels Hofmeyr | df65951 | 2020-07-29 00:41:42 +0200 | [diff] [blame] | 354 | var integer lblock := f_cbsp_block_count_enc(num_blocks); |
| 355 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 356 | tr := tr_RSL_SMSCB_CMD(tr_RslCbCmdType(lblock), f_pad_oct(payload, 88, '00'O)); |
| 357 | if (ext_cbch) { |
| 358 | tr.ies[3] := tr_RSL_IE(RSL_IE_Body:{smscb_chan_ind := 1}); |
| 359 | tr.ies[4] := *; |
| 360 | } |
| 361 | return tr; |
| 362 | } |
| 363 | |
| 364 | /*********************************************************************** |
| 365 | * Test Cases |
| 366 | ***********************************************************************/ |
| 367 | |
| 368 | /* Test if BSC (server) accepts connections from CBC (client) */ |
| 369 | testcase TC_cbsp_bsc_server() runs on cbsp_test_CT { |
| 370 | f_cbsp_init_client(); |
| 371 | setverdict(pass); |
| 372 | } |
| 373 | |
| 374 | /* Test if BSC (client) is connecting to CBC (server) */ |
| 375 | testcase TC_cbsp_bsc_client() runs on cbsp_test_CT { |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 376 | f_cbsp_init_server(0, 0); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 377 | setverdict(pass); |
| 378 | } |
| 379 | |
| 380 | /* Test if a BSS-global RESET is executed successfully */ |
| 381 | testcase TC_cbsp_reset_bss() runs on cbsp_test_CT { |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 382 | f_cbsp_init_server(0, 0); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 383 | |
| 384 | f_cbsp_reset_bss(0); |
| 385 | setverdict(pass); |
| 386 | } |
| 387 | |
| 388 | testcase TC_cbsp_write() runs on cbsp_test_CT { |
| 389 | var template (value) CBSP_PDU tx; |
| 390 | var CBSP_IEs pages := {f_gen_page()}; |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 391 | f_cbsp_init_server(0, 0); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 392 | |
| 393 | tx := ts_CBSP_WRITE_CBS(msg_id:=23, new_ser_nr:=42, cell_list:=ts_BSSMAP_CIL_BSS, |
| 394 | channel_ind:=0, category:=CBSP_CATEG_NORMAL, |
| 395 | rep_period:=10, num_bcast_req:=1, dcs := 0, |
| 396 | content:=pages); |
| 397 | |
| 398 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 399 | f_sleep(10.0); |
| 400 | } |
| 401 | |
| 402 | /* Write to entire BSS; three cells succeed; one fails (no CBCH) */ |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 403 | function f_tc_cbsp_write_bss(integer payload_len := -1, template (present) integer expect_blocks) runs on cbsp_test_CT { |
| 404 | var CBSP_IEs pages := {f_gen_page(payload_len := payload_len)}; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 405 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 406 | cell_list := ts_BSSMAP_CIL_BSS; |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 407 | 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] | 408 | success_list:=tr_BSSMAP_CIL_CGI({?,?,?}), fail_list:={?}); |
| 409 | |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 410 | var template 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] | 411 | log("RSL[0,1,2] EXPECTING ", tr_ASP_RSL_UD(tr)); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 412 | interleave { |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 413 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[0]"); } |
| 414 | [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[1]"); } |
| 415 | [] IPA_RSL[2].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] | 416 | } |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 417 | setverdict(pass); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 418 | |
| 419 | /* Make the next test run (if any) use different msg_id and ser_no */ |
| 420 | f_g_cbsp_next_msg_id_ser_no(); |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 421 | } |
| 422 | testcase TC_cbsp_write_bss() runs on cbsp_test_CT { |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 423 | f_cbsp_init_server(1001, 1501, guard_timeout := 60.0); |
Neels Hofmeyr | a16afdc | 2020-07-29 00:57:27 +0200 | [diff] [blame] | 424 | /* In the SMSCB message, there is a head followed by payload, |
| 425 | * and the resulting data is segmented in blocks of 22 octets (<= 4 blocks). |
| 426 | * |
| 427 | * [head][...payload....]|[....................]|[....................]|[....................] |
| 428 | * 0 |16 |38 |60 |82 |
| 429 | * 0 5 |22 |44 |66 |88 |
| 430 | * |
| 431 | * blocks count: 1 | 2 | 3 | 4 |
| 432 | * payload octets count: 1..16 | 17..38 | 39..60 | 61..82 |
| 433 | */ |
| 434 | f_tc_cbsp_write_bss(payload_len := 1, expect_blocks := 1); |
| 435 | f_tc_cbsp_write_bss(payload_len := 2, expect_blocks := 1); |
| 436 | f_tc_cbsp_write_bss(payload_len := 16, expect_blocks := 1); |
| 437 | f_tc_cbsp_write_bss(payload_len := 17, expect_blocks := 2); |
| 438 | f_tc_cbsp_write_bss(payload_len := 23, expect_blocks := 2); |
| 439 | f_tc_cbsp_write_bss(payload_len := 38, expect_blocks := 2); |
| 440 | f_tc_cbsp_write_bss(payload_len := 39, expect_blocks := 3); |
| 441 | f_tc_cbsp_write_bss(payload_len := 42, expect_blocks := 3); |
| 442 | f_tc_cbsp_write_bss(payload_len := 60, expect_blocks := 3); |
| 443 | f_tc_cbsp_write_bss(payload_len := 61, expect_blocks := 4); |
| 444 | f_tc_cbsp_write_bss(payload_len := 77, expect_blocks := 4); |
| 445 | f_tc_cbsp_write_bss(payload_len := 82, expect_blocks := 4); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | /* Write to single BTS supporting CBCH: success */ |
| 449 | testcase TC_cbsp_write_bts_cgi() runs on cbsp_test_CT { |
| 450 | var CBSP_IEs pages := {f_gen_page()}; |
| 451 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 452 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 453 | f_cbsp_init_server(2001, 2501); |
| 454 | 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] | 455 | success_list:=cell_list, fail_list:=omit); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 456 | var template RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no); |
Vadim Yanitskiy | ca5c520 | 2020-05-25 22:03:28 +0700 | [diff] [blame] | 457 | IPA_RSL[0].receive(tr_ASP_RSL_UD(tr)); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 458 | f_sleep(5.0); |
| 459 | } |
| 460 | |
| 461 | /* Write to single BTS not supporting CBCH: failure */ |
| 462 | testcase TC_cbsp_write_bts_no_cbch() runs on cbsp_test_CT { |
| 463 | var CBSP_IEs pages := {f_gen_page()}; |
| 464 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 465 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts3)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 466 | f_cbsp_init_server(3001, 3501); |
| 467 | 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] | 468 | success_list:=omit, fail_list:={?}); |
| 469 | f_sleep(5.0); |
| 470 | } |
| 471 | |
| 472 | /* Write to single non-existant BTS */ |
| 473 | testcase TC_cbsp_write_unknown_bts() runs on cbsp_test_CT { |
| 474 | var CBSP_IEs pages := {f_gen_page()}; |
| 475 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 476 | 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] | 477 | f_cbsp_init_server(4001, 4501); |
| 478 | 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] | 479 | success_list:=omit, fail_list:={?}); |
| 480 | f_sleep(5.0); |
| 481 | } |
| 482 | |
| 483 | /* Write to single BTS using LAC+CI */ |
| 484 | testcase TC_cbsp_write_lac_ci() runs on cbsp_test_CT { |
| 485 | var CBSP_IEs pages := {f_gen_page()}; |
| 486 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 487 | 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] | 488 | f_cbsp_init_server(5001, 5501); |
| 489 | 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] | 490 | success_list:=?, fail_list:=omit); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 491 | IPA_RSL[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] | 492 | f_sleep(5.0); |
| 493 | } |
| 494 | |
| 495 | /* Write to single BTS using CI */ |
| 496 | testcase TC_cbsp_write_ci() runs on cbsp_test_CT { |
| 497 | var CBSP_IEs pages := {f_gen_page()}; |
| 498 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 499 | cell_list := ts_BSSMAP_CIL_CI({bssmap_ci(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 500 | f_cbsp_init_server(6001, 6501); |
| 501 | 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] | 502 | success_list:=?, fail_list:=omit); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 503 | IPA_RSL[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] | 504 | f_sleep(5.0); |
| 505 | } |
| 506 | |
| 507 | /* Write to single BTS using LAI */ |
| 508 | testcase TC_cbsp_write_lai() runs on cbsp_test_CT { |
| 509 | var CBSP_IEs pages := {f_gen_page()}; |
| 510 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
Neels Hofmeyr | f514848 | 2020-07-31 16:56:02 +0200 | [diff] [blame] | 511 | /* bts0 and bts1 have the same LAI (only differ in cell identity). |
| 512 | * bts2 and bts3 also have the same LAI, but only bts2 has a CBCH. |
| 513 | * Target only bts2. |
| 514 | */ |
| 515 | cell_list := ts_BSSMAP_CIL_LAI({bssmap_lai(mp_cgi_bts2)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 516 | f_cbsp_init_server(7001, 7501); |
| 517 | 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] | 518 | success_list:=?, fail_list:=omit); |
Neels Hofmeyr | f514848 | 2020-07-31 16:56:02 +0200 | [diff] [blame] | 519 | IPA_RSL[2].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] | 520 | f_sleep(5.0); |
| 521 | } |
| 522 | |
| 523 | /* Write to two BTS using LAC */ |
| 524 | testcase TC_cbsp_write_lac() runs on cbsp_test_CT { |
| 525 | var CBSP_IEs pages := {f_gen_page()}; |
| 526 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 527 | cell_list := ts_BSSMAP_CIL_LAC({bssmap_lac(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 528 | f_cbsp_init_server(8001, 8501); |
| 529 | 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] | 530 | success_list:=?, fail_list:=omit); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 531 | var template 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] | 532 | interleave { |
Vadim Yanitskiy | ca5c520 | 2020-05-25 22:03:28 +0700 | [diff] [blame] | 533 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr)); |
| 534 | [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr)); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 535 | } |
| 536 | f_sleep(5.0); |
| 537 | } |
| 538 | |
| 539 | /* Write a message, then replace it */ |
| 540 | testcase TC_cbsp_write_then_replace() runs on cbsp_test_CT { |
| 541 | var CBSP_IEs pages := {f_gen_page()}; |
| 542 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 543 | 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] | 544 | f_cbsp_init_server(9001, 9501); |
| 545 | 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] | 546 | success_list:=?, fail_list:=omit); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 547 | |
Neels Hofmeyr | 62d5da3 | 2020-07-31 16:56:14 +0200 | [diff] [blame] | 548 | IPA_RSL[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] | 549 | |
| 550 | /* Replace: keep the same msg_id, use a new ser_no */ |
| 551 | var uint16_t old_ser_no := g_cbsp_ser_no; |
| 552 | g_cbsp_ser_no := g_cbsp_ser_no + 1; |
| 553 | 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] | 554 | success_list:=?, fail_list:=omit); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 555 | |
Neels Hofmeyr | 62d5da3 | 2020-07-31 16:56:14 +0200 | [diff] [blame] | 556 | IPA_RSL[0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no))); |
| 557 | f_sleep(1.0); |
| 558 | setverdict(pass); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | /* Replace a message that doesn't exist: failure */ |
| 562 | testcase TC_cbsp_replace_nonexist() runs on cbsp_test_CT { |
| 563 | var CBSP_IEs pages := {f_gen_page()}; |
| 564 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 565 | 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] | 566 | f_cbsp_init_server(10001, 10501); |
| 567 | f_cbsp_replace(10, 10023, 10042, cell_list, content:=pages, |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 568 | success_list:=omit, fail_list:=?); |
| 569 | } |
| 570 | |
| 571 | /* Write more messages than can be scheduled */ |
| 572 | testcase TC_cbsp_write_too_many() runs on cbsp_test_CT { |
| 573 | /* repeating three pages at an interval of 1 is impossible */ |
| 574 | var CBSP_IEs pages := {f_gen_page(), f_gen_page(), f_gen_page()}; |
| 575 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 576 | 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] | 577 | f_cbsp_init_server(11001, 11501); |
| 578 | 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] | 579 | success_list:=omit, fail_list:=?); |
| 580 | } |
| 581 | |
| 582 | /* Kill message that doesn't exist: failure */ |
| 583 | testcase TC_cbsp_kill_nonexist() runs on cbsp_test_CT { |
| 584 | var CBSP_IEs pages := {f_gen_page()}; |
| 585 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 586 | 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] | 587 | f_cbsp_init_server(12001, 12501); |
| 588 | f_cbsp_kill(g_cbsp_msg_id, g_cbsp_ser_no, 0, cell_list, success_list:=omit, fail_list:=?); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 589 | } |
| 590 | /* Write a message, then kill it */ |
| 591 | testcase TC_cbsp_write_then_kill() runs on cbsp_test_CT { |
| 592 | var CBSP_IEs pages := {f_gen_page()}; |
| 593 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 594 | 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] | 595 | f_cbsp_init_server(13001, 13501); |
| 596 | f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, success_list:=?, fail_list:=omit); |
| 597 | f_cbsp_kill(g_cbsp_msg_id, g_cbsp_ser_no, 0, cell_list, success_list:=?, fail_list:=omit); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | /* Write a message, then reset all messages */ |
| 601 | testcase TC_cbsp_write_then_reset() runs on cbsp_test_CT { |
| 602 | var CBSP_IEs pages := {f_gen_page()}; |
| 603 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 604 | 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] | 605 | f_cbsp_init_server(14001, 14501); |
| 606 | 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] | 607 | f_cbsp_reset_bss(0); |
| 608 | } |
| 609 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 610 | private const octetstring c_ETWS_sec_default := |
| 611 | '00000000000000000000000000000000000000000000000000'O & |
| 612 | '00000000000000000000000000000000000000000000000000'O; |
| 613 | function f_gen_etws_pn(uint16_t ser_nr, uint16_t msg_id, OCT2 msg_type := '0780'O, |
| 614 | octetstring sec_inf := c_ETWS_sec_default) return octetstring { |
| 615 | return int2oct(ser_nr, 2) & int2oct(msg_id, 2) & msg_type & sec_inf; |
| 616 | } |
| 617 | |
| 618 | /* Write ETWS PN to single BTS; verify it arrives on DCHAN */ |
| 619 | testcase TC_cbsp_emerg_write_bts_cgi_dchan() runs on cbsp_test_CT { |
| 620 | var CBSP_IEs pages := {f_gen_page()}; |
| 621 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 622 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 623 | |
| 624 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 625 | f_cbsp_init_server(15001, 15501); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 626 | |
| 627 | /* first establish a dedicated channel */ |
| 628 | var DchanTuple dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 629 | |
| 630 | /* then send ETWS PN */ |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 631 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list); |
| 632 | 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] | 633 | timer T := 5.0; |
| 634 | T.start; |
| 635 | alt { |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame] | 636 | [] IPA_RSL[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] | 637 | var RSL_IE_Body l3_ie; |
| 638 | if (f_rsl_find_ie(rx_rsl_ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) { |
| 639 | setverdict(fail, "RSL DATA REQ without L3?"); |
| 640 | mtc.stop; |
| 641 | } |
| 642 | var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload); |
| 643 | var template (present) APDU_Flags_V tr_flags := { |
| 644 | lastSeg := '0'B, |
| 645 | firstSeg := '0'B, |
| 646 | cR := '0'B, |
| 647 | spare := '0'B |
| 648 | }; |
| 649 | if (match(l3, tr_RR_APP_INFO('0001'B, tr_apdu, tr_flags))) { |
| 650 | setverdict(pass); |
| 651 | } |
| 652 | } |
| 653 | [] IPA_RSL[0].receive { repeat; } |
| 654 | [] T.timeout { |
| 655 | setverdict(fail, "Waiting for APP INFO"); |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 660 | /* Write ETWS PN to single BTS; verify it arrives on CCHAN */ |
| 661 | testcase TC_cbsp_emerg_write_bts_cgi_cchan() runs on cbsp_test_CT { |
| 662 | var CBSP_IEs pages := {f_gen_page()}; |
| 663 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 664 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 665 | |
| 666 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 667 | f_cbsp_init_server(16001, 16501); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 668 | |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 669 | f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list); |
Neels Hofmeyr | fbaca3f | 2020-08-13 13:57:43 +0000 | [diff] [blame] | 670 | var template (present) octetstring tr_apdu := f_gen_etws_pn(g_cbsp_ser_no, g_cbsp_msg_id); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 671 | timer T := 5.0; |
| 672 | T.start; |
| 673 | alt { |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame] | 674 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), tr_apdu))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 675 | setverdict(pass); |
| 676 | } |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame] | 677 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(?,?))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 678 | setverdict(fail, "Received unexpected OSMO_ETWS_CMD"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 679 | mtc.stop; |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 680 | } |
| 681 | [] IPA_RSL[0].receive { repeat; } |
| 682 | [] T.timeout { |
| 683 | setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 684 | mtc.stop; |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 685 | } |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | /* Write ETWS PN to single BTS; verify it arrives on CCHAN */ |
| 690 | testcase TC_cbsp_emerg_write_bts_cgi_cchan_disable() runs on cbsp_test_CT { |
| 691 | var CBSP_IEs pages := {f_gen_page()}; |
| 692 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 693 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 694 | |
| 695 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 696 | f_cbsp_init_server(17001, 17501); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 697 | |
Neels Hofmeyr | 4e63a01 | 2020-07-31 14:29:43 +0200 | [diff] [blame] | 698 | 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] | 699 | |
| 700 | /* first expect the PN to be enabled */ |
Neels Hofmeyr | fbaca3f | 2020-08-13 13:57:43 +0000 | [diff] [blame] | 701 | var template (present) octetstring tr_apdu := f_gen_etws_pn(g_cbsp_ser_no, g_cbsp_msg_id); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 702 | timer T := 5.0; |
| 703 | T.start; |
| 704 | alt { |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame] | 705 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), tr_apdu))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 706 | setverdict(pass); |
| 707 | } |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame] | 708 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(?,?))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 709 | setverdict(fail, "Received unexpected OSMO_ETWS_CMD"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 710 | mtc.stop; |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 711 | } |
| 712 | [] IPA_RSL[0].receive { repeat; } |
| 713 | [] T.timeout { |
| 714 | setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD (enable)"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 715 | mtc.stop; |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 716 | } |
| 717 | } |
| 718 | |
| 719 | /* then expect it to be disabled after the warning period (5s) */ |
| 720 | T.start; |
| 721 | alt { |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame] | 722 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), ''O))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 723 | setverdict(pass); |
| 724 | } |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame] | 725 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(?,?))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 726 | setverdict(fail, "Received unexpected OSMO_ETWS_CMD"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 727 | mtc.stop; |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 728 | } |
| 729 | [] IPA_RSL[0].receive { repeat; } |
| 730 | [] T.timeout { |
| 731 | setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD (disable)"); |
Neels Hofmeyr | ee3b927 | 2020-07-28 21:20:15 +0200 | [diff] [blame] | 732 | mtc.stop; |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 733 | } |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 738 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 739 | control { |
| 740 | execute( TC_cbsp_bsc_server() ); |
| 741 | execute( TC_cbsp_bsc_client() ); |
| 742 | execute( TC_cbsp_reset_bss() ); |
| 743 | |
| 744 | /* test various different types of Cell Identities */ |
| 745 | execute( TC_cbsp_write_bss() ); |
| 746 | execute( TC_cbsp_write_bts_cgi() ); |
| 747 | execute( TC_cbsp_write_bts_no_cbch() ); |
| 748 | execute( TC_cbsp_write_unknown_bts() ); |
| 749 | execute( TC_cbsp_write_lac_ci() ); |
| 750 | execute( TC_cbsp_write_ci() ); |
| 751 | execute( TC_cbsp_write_lai() ); |
| 752 | execute( TC_cbsp_write_lac() ); |
| 753 | |
| 754 | execute( TC_cbsp_write_then_replace() ); |
| 755 | execute( TC_cbsp_replace_nonexist() ); |
| 756 | execute( TC_cbsp_write_too_many() ); |
| 757 | execute( TC_cbsp_kill_nonexist() ); |
| 758 | execute( TC_cbsp_write_then_kill() ); |
| 759 | execute( TC_cbsp_write_then_reset() ); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 760 | |
| 761 | execute( TC_cbsp_emerg_write_bts_cgi_dchan() ); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 762 | execute( TC_cbsp_emerg_write_bts_cgi_cchan() ); |
| 763 | execute( TC_cbsp_emerg_write_bts_cgi_cchan_disable() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | |
| 767 | } |