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