Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 1 | module CBC_Tests { |
| 2 | |
| 3 | import from Osmocom_Types all; |
| 4 | |
| 5 | import from BSSAP_Types all; |
| 6 | import from BSSMAP_Templates all; |
| 7 | import from CBSP_Types all; |
| 8 | import from CBSP_Templates all; |
| 9 | import from CBSP_Adapter all; |
| 10 | import from CBSP_CodecPort all; |
| 11 | import from Socket_API_Definitions all; |
| 12 | |
| 13 | import from HTTP_Adapter all; |
| 14 | import from HTTPmsg_Types all; |
| 15 | import from ECBE_Types all; |
| 16 | |
| 17 | modulepar { |
| 18 | charstring mp_cbc_host := "127.0.0.1"; |
Pau Espin Pedrol | 07746ad | 2022-06-16 19:02:04 +0200 | [diff] [blame] | 19 | integer mp_cbc_cbsp_port := 48049; |
| 20 | integer mp_cbc_ecbe_port := 12345; |
| 21 | integer mp_local_cbsp_port := 9999; |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 22 | }; |
| 23 | |
| 24 | type component test_CT extends CBSP_Adapter_CT, http_CT { |
| 25 | }; |
| 26 | |
| 27 | /********************************************************************************* |
| 28 | * ECBE (REST) interface |
| 29 | *********************************************************************************/ |
| 30 | |
| 31 | function f_ecbe_tx_post_cbs(EcbeCbcMessage cbc) |
| 32 | runs on http_CT { |
| 33 | var charstring body := oct2char(enc_EcbeCbcMessage(cbc)); |
| 34 | log("TX POST CBS: ", body); |
| 35 | var HTTPMessage http_resp; |
| 36 | f_http_tx_request(url := "/api/ecbe/v1/message", method := "POST", body := body); |
| 37 | } |
| 38 | |
| 39 | function f_ecbe_rx_resp(template integer exp_sts := (200..299)) |
| 40 | runs on http_CT return HTTPResponse { |
| 41 | var HTTPMessage http_resp := f_http_rx_response(tr_HTTP_Resp(exp_sts), tout := 20.0); |
| 42 | return http_resp.response; |
| 43 | } |
| 44 | |
| 45 | /* run a HTTP POST to add a new CBC message */ |
| 46 | function f_ecbe_post_cbs(EcbeCbcMessage cbc, template integer exp_sts := 201) |
| 47 | runs on http_CT return HTTPResponse { |
| 48 | f_ecbe_tx_post_cbs(cbc); |
| 49 | return f_ecbe_rx_resp(exp_sts) |
| 50 | } |
| 51 | |
| 52 | function f_ecbe_tx_delete_cbs(integer msg_id) |
| 53 | runs on http_CT { |
| 54 | f_http_tx_request("/api/ecbe/v1/message/" & int2str(msg_id), method := "DELETE"); |
| 55 | } |
| 56 | |
| 57 | /* run a HTTP GET on specified URL expecting json in RSRES format as response */ |
| 58 | function f_ecbe_delete_cbs(integer msg_id, template integer exp_sts := 200) |
| 59 | runs on http_CT return HTTPResponse { |
| 60 | f_ecbe_tx_delete_cbs(msg_id); |
| 61 | return f_ecbe_rx_resp(exp_sts); |
| 62 | } |
| 63 | |
| 64 | |
| 65 | altstep as_cbsp_reset(integer idx) runs on CBSP_Adapter_CT { |
| 66 | var CBSP_RecvFrom rf; |
| 67 | [] CBSP[idx].receive(tr_CBSP_Recv(g_cbsp_conn_id[idx], tr_CBSP_RESET)) -> value rf { |
| 68 | var CBSP_IE ie; |
| 69 | f_cbsp_find_ie(rf.msg, CBSP_IEI_CELL_LIST, ie); |
| 70 | CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], |
| 71 | ts_CBSP_RESET_COMPL(ie.body.cell_list.cell_id))); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | private function f_cbs2ecbe_category(CBSP_Category cat_in) return EcbeCategory |
| 76 | { |
| 77 | select (cat_in) { |
| 78 | case (CBSP_CATEG_HIGH_PRIO) { return high_priority; } |
| 79 | case (CBSP_CATEG_BACKGROUND) { return background; } |
| 80 | case (CBSP_CATEG_NORMAL) { return normal; } |
| 81 | case else { mtc.stop } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | private function f_cbs2ecbe_page(CBS_MessageContent inp) return EcbePage |
| 86 | { |
| 87 | return hex2str(oct2hex(inp.payload)); |
| 88 | } |
| 89 | |
| 90 | /* convert from CBS_Message to EcbeCbcMessage */ |
| 91 | function f_cbs2ecbe(CBS_Message inp, charstring cbe_name) return EcbeCbcMessage |
| 92 | { |
| 93 | var EcbeCbcMessage ret := { |
| 94 | cbe_name := cbe_name, |
| 95 | category := f_cbs2ecbe_category(inp.category), |
| 96 | repetition_period := inp.rep_period, |
| 97 | num_of_bcast := inp.num_bcast_req, |
| 98 | scope := { scope_plmn := {} }, |
| 99 | smscb_message := { |
| 100 | serial_nr := { |
| 101 | serial_nr_encoded := inp.ser_nr |
| 102 | }, |
| 103 | message_id := inp.msg_id, |
| 104 | payload := { |
| 105 | payload_encoded := { |
| 106 | dcs := inp.dcs, |
| 107 | pages := { } /* appended below */ |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | }; |
| 112 | for (var integer i := 0; i < lengthof(inp.content); i := i+1) { |
Pau Espin Pedrol | f2c701d | 2022-06-16 19:00:47 +0200 | [diff] [blame] | 113 | ret.smscb_message.payload.payload_encoded.pages := |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 114 | ret.smscb_message.payload.payload_encoded.pages & { f_cbs2ecbe_page(inp.content[i]) }; |
| 115 | } |
| 116 | return ret; |
| 117 | } |
| 118 | |
| 119 | /********************************************************************************* |
| 120 | * CBSP interface |
| 121 | *********************************************************************************/ |
| 122 | |
| 123 | /* receive + acknowledge KEEP-ALIVE */ |
| 124 | altstep as_cbsp_keepalive_ack(integer idx) runs on CBSP_Adapter_CT { |
| 125 | [] CBSP[idx].receive(tr_CBSP_Recv(g_cbsp_conn_id[idx], tr_CBSP_KEEP_ALIVE)) { |
| 126 | CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], ts_CBSP_KEEP_ALIVE_COMPL)); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /* receive + ignore RESTART */ |
| 131 | altstep as_cbsp_restart(integer idx) runs on CBSP_Adapter_CT { |
| 132 | [] CBSP[idx].receive(tr_CBSP_Recv(g_cbsp_conn_id[idx], tr_CBSP_RESTART)); |
| 133 | } |
| 134 | |
Pau Espin Pedrol | 9d8b6bf | 2022-06-23 12:19:47 +0200 | [diff] [blame] | 135 | private function f_shutdown_helper() runs on test_CT { |
| 136 | all component.stop; |
| 137 | setverdict(pass); |
| 138 | mtc.stop; |
| 139 | } |
| 140 | |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 141 | private function f_init(boolean raw := false) runs on test_CT { |
Pau Espin Pedrol | 07746ad | 2022-06-16 19:02:04 +0200 | [diff] [blame] | 142 | f_http_init(mp_cbc_host, mp_cbc_ecbe_port); |
| 143 | CBSP_Adapter.f_connect(mp_cbc_host, mp_cbc_cbsp_port, "", mp_local_cbsp_port); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 144 | |
| 145 | if (not raw) { |
| 146 | var BSSMAP_FIELD_CellIdentificationList cell_list := { |
| 147 | cIl_allInBSS := ''O |
| 148 | }; |
| 149 | activate(as_cbsp_keepalive_ack(0)); |
| 150 | activate(as_cbsp_restart(0)); |
| 151 | f_cbsp_send(ts_CBSP_RESTART(cell_list, CBSP_BC_MSGT_CBS, CBSP_RI_DATA_LOST)); |
| 152 | f_cbsp_send(ts_CBSP_RESTART(cell_list, CBSP_BC_MSGT_EMERG, CBSP_RI_DATA_LOST)); |
| 153 | as_cbsp_reset(0); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | /* test whether or not we receive a valid KEEP-ALIVE from the CBC */ |
| 158 | testcase TC_rx_keepalive() runs on test_CT { |
| 159 | var CBSP_PDU rx; |
| 160 | var CBSP_IE ie; |
| 161 | |
| 162 | f_init(); |
| 163 | rx := f_cbsp_exp(tr_CBSP_KEEP_ALIVE(?)); |
| 164 | f_cbsp_find_ie(rx, CBSP_IEI_KEEP_ALIVE_REP_PERIOD, ie); |
| 165 | |
Pau Espin Pedrol | 9d8b6bf | 2022-06-23 12:19:47 +0200 | [diff] [blame] | 166 | f_shutdown_helper(); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | /* test whether CBC terminates connection if KEEP-ALIVE is not answered by BSC */ |
| 170 | testcase TC_rx_keepalive_timeout() runs on test_CT { |
| 171 | var CBSP_PDU rx; |
| 172 | var CBSP_IE ie; |
| 173 | var integer ka_rep_per_s; |
| 174 | |
| 175 | f_init(); |
| 176 | rx := f_cbsp_exp(tr_CBSP_KEEP_ALIVE(?)); |
| 177 | f_cbsp_find_ie(rx, CBSP_IEI_KEEP_ALIVE_REP_PERIOD, ie); |
| 178 | |
| 179 | /* sleep for longer than the keep-alive period */ |
| 180 | ka_rep_per_s := f_cbsp_period2s(ie.body.keep_alive_rep_period); |
| 181 | f_sleep(int2float(ka_rep_per_s + 5)); |
| 182 | |
| 183 | /* expect the CBSP connection to be closed */ |
| 184 | CBSP[0].receive(PortEvent:{connClosed:=?}) |
| 185 | |
Pau Espin Pedrol | 9d8b6bf | 2022-06-23 12:19:47 +0200 | [diff] [blame] | 186 | f_shutdown_helper(); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | type record CBS_Message { |
| 190 | uint16_t msg_id, |
| 191 | uint16_t ser_nr, |
| 192 | uint16_t old_ser_nr optional, |
| 193 | BSSMAP_FIELD_CellIdentificationList cell_list, |
| 194 | uint8_t channel_ind, |
| 195 | CBSP_Category category, |
| 196 | uint16_t rep_period, |
| 197 | uint16_t num_bcast_req, |
| 198 | uint8_t dcs, |
| 199 | CBS_MessageContents content |
| 200 | }; |
| 201 | type record CBS_MessageContent { |
| 202 | octetstring payload, |
| 203 | uint8_t user_len |
| 204 | }; |
| 205 | type record of CBS_MessageContent CBS_MessageContents; |
| 206 | |
Pau Espin Pedrol | ac71dbb | 2022-07-08 17:14:45 +0200 | [diff] [blame] | 207 | private function f_cbsp_tx_write_compl(CBS_Message msg, integer idx := 0, |
| 208 | template (omit) BSSMAP_FIELD_CellIdentificationList tx_cell_list := omit, |
| 209 | template (omit) CBSP_IE_NumBcastComplList tx_compl_list := omit) |
| 210 | runs on test_CT { |
| 211 | var template (value) CBSP_PDU tx; |
| 212 | var template (value) BSSMAP_FIELD_CellIdentificationList tx_list; |
| 213 | if (istemplatekind(tx_cell_list, "omit")) { |
| 214 | /* use the "expected list" when confirming the write-replace */ |
| 215 | tx_list := msg.cell_list; |
| 216 | } else { |
| 217 | /* use an user-provided different list of cells */ |
| 218 | tx_list := valueof(tx_cell_list); |
| 219 | } |
| 220 | if (istemplatekind(tx_compl_list, "omit")) { |
| 221 | tx := ts_CBSP_WRITE_CBS_COMPL(msg.msg_id, msg.ser_nr, tx_list, msg.channel_ind); |
| 222 | } else { |
| 223 | tx := ts_CBSP_REPLACE_CBS_COMPL(msg.msg_id, msg.ser_nr, msg.old_ser_nr, |
| 224 | valueof(tx_compl_list), tx_list, |
| 225 | msg.channel_ind); |
| 226 | } |
| 227 | CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx)); |
| 228 | } |
| 229 | |
| 230 | private function f_cbsp_tx_write_fail(CBS_Message msg, integer idx := 0, |
| 231 | template (omit) BSSMAP_FIELD_CellIdentificationList tx_cell_list := omit, |
| 232 | template (omit) CBSP_FailureListItems tx_fail_list := omit) |
| 233 | runs on test_CT { |
| 234 | var template (value) CBSP_PDU tx; |
| 235 | tx := ts_CBSP_WRITE_CBS_FAIL(msg.msg_id, msg.ser_nr, valueof(tx_fail_list), |
| 236 | omit, tx_cell_list, msg.channel_ind); |
| 237 | CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx)); |
| 238 | } |
| 239 | |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 240 | /* handle a CBSP-WRITE-REPLACE and respond to it with COMPLETE or FAILURE depending on arguments */ |
Pau Espin Pedrol | ac71dbb | 2022-07-08 17:14:45 +0200 | [diff] [blame] | 241 | private function f_cbsp_handle_write(CBS_Message msg, integer idx := 0, |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 242 | template (omit) BSSMAP_FIELD_CellIdentificationList tx_cell_list := omit, |
| 243 | template (omit) CBSP_FailureListItems tx_fail_list := omit, |
| 244 | template (omit) CBSP_IE_NumBcastComplList tx_compl_list := omit) |
| 245 | runs on test_CT { |
| 246 | var template CBSP_IEs content_ies := {}; |
| 247 | var template (present) CBSP_PDU rx_templ; |
| 248 | var CBSP_RecvFrom rf; |
| 249 | for (var integer i := 0; i < lengthof(msg.content); i := i+1) { |
| 250 | //content_ies[i] := tr_CbspMsgContent(msg.content[i].payload, msg.content[i].user_len); |
| 251 | content_ies[i] := tr_CbspMsgContent(?, ?); |
| 252 | } |
| 253 | rx_templ := tr_CBSP_WRITE_CBS(msg.msg_id, msg.ser_nr, msg.cell_list, msg.channel_ind, |
| 254 | msg.category, msg.rep_period, msg.num_bcast_req, msg.dcs, |
| 255 | content_ies); |
| 256 | alt { |
| 257 | [] CBSP[idx].receive(tr_CBSP_Recv(g_cbsp_conn_id[idx], rx_templ)) -> value rf { |
| 258 | var template (value) CBSP_PDU tx; |
| 259 | if (istemplatekind(tx_fail_list, "omit")) { |
Pau Espin Pedrol | ac71dbb | 2022-07-08 17:14:45 +0200 | [diff] [blame] | 260 | f_cbsp_tx_write_compl(msg, idx, tx_cell_list, tx_compl_list); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 261 | } else { |
Pau Espin Pedrol | ac71dbb | 2022-07-08 17:14:45 +0200 | [diff] [blame] | 262 | f_cbsp_tx_write_fail(msg, idx, tx_cell_list, tx_fail_list); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 263 | } |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 264 | } |
| 265 | [] as_cbsp_keepalive_ack(idx) { repeat; } |
| 266 | [] CBSP[idx].receive { |
| 267 | setverdict(fail, "Received unexpected CBSP in index ", idx); |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | /* handle a CBSP-KILL and respond to it with COMPLETE or FAILURE depending on arguments */ |
| 273 | private function f_cbsp_handle_kill(integer idx, uint16_t msg_id, uint16_t ser_nr, |
| 274 | template BSSMAP_FIELD_CellIdentificationList exp_list, |
| 275 | template (omit) BSSMAP_FIELD_CellIdentificationList tx_list, |
| 276 | template (omit) CBSP_FailureListItems tx_fail_list := omit, |
| 277 | template (omit) CBSP_IE_NumBcastComplList tx_compl_list := omit, |
| 278 | template (omit) uint8_t channel_ind := omit) |
| 279 | runs on test_CT { |
| 280 | var template (present) CBSP_PDU rx_templ; |
| 281 | var CBSP_RecvFrom rf; |
| 282 | |
| 283 | rx_templ := tr_CBSP_KILL(msg_id, ser_nr, exp_list, channel_ind); |
| 284 | alt { |
| 285 | [] CBSP[idx].receive(tr_CBSP_Recv(g_cbsp_conn_id[idx], rx_templ)) -> value rf { |
| 286 | var template (value) CBSP_PDU tx; |
| 287 | if (istemplatekind(tx_fail_list, "omit")) { |
| 288 | tx := ts_CBSP_KILL_COMPL(msg_id, ser_nr, tx_compl_list, tx_list, channel_ind); |
| 289 | } else { |
| 290 | tx := ts_CBSP_KILL_FAIL(msg_id, ser_nr, valueof(tx_fail_list), tx_compl_list, |
| 291 | tx_list, channel_ind); |
| 292 | } |
| 293 | CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx)); |
| 294 | } |
| 295 | [] as_cbsp_keepalive_ack(idx) { repeat; } |
| 296 | [] CBSP[idx].receive { |
| 297 | setverdict(fail, "Received unexpected CBSP in index ", idx); |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | private const BSSMAP_FIELD_CellIdentificationList cil_BSS := { |
| 303 | cIl_allInBSS := ''O |
| 304 | }; |
| 305 | |
| 306 | testcase TC_write_replace() runs on test_CT { |
| 307 | f_init(); |
| 308 | var CBS_Message msg := { |
| 309 | msg_id := 42, |
| 310 | ser_nr := 16752, |
| 311 | old_ser_nr := omit, |
| 312 | cell_list := cil_BSS, |
| 313 | channel_ind := 0, |
| 314 | category := CBSP_CATEG_NORMAL, |
| 315 | rep_period := 5, |
| 316 | num_bcast_req := 3, |
| 317 | dcs := 1, |
| 318 | content := { |
| 319 | { '00'O, 1 } |
| 320 | } |
| 321 | }; |
Pau Espin Pedrol | ac71dbb | 2022-07-08 17:14:45 +0200 | [diff] [blame] | 322 | f_cbsp_handle_write(msg); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 323 | f_sleep(100.0); |
Pau Espin Pedrol | 9d8b6bf | 2022-06-23 12:19:47 +0200 | [diff] [blame] | 324 | f_shutdown_helper(); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | testcase TC_selftest() runs on test_CT { |
| 328 | const octetstring c_load_q := '0700000d0400080000f110012345671200'O; |
| 329 | const octetstring c_load_q_compl := '0800000f0a000a0000f1100123456700001200'O; |
| 330 | const octetstring c_reset := '1000000b0400080000f11001234567'O; |
| 331 | const octetstring c_reset_compl := '1100000b0400080000f11001234567'O; |
| 332 | const octetstring c_msg_sts_q := '0a0000130e022b0200000400080000f110012345671200'O; |
| 333 | const octetstring c_msg_sts_q_fail := '0c0000140e022b0200000900090000f11001234567021200'O; |
| 334 | const octetstring c_kill := '040000110e00000200000400080000f11001234567'O; |
| 335 | const octetstring c_kill_fail := '060000120e00000200000900090000f1100123456702'O; |
| 336 | const octetstring c_write_repl := '010000c70e022b0300300400080000f110012345671200050006000407000613020c400107f4f29c9e769f5de337b90c921d1b8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d100'O; |
| 337 | const octetstring c_write_repl_compl := '020000130e022b0300300400080000f110012345671200'O; |
| 338 | const octetstring c_write_repl_fail := '030000140e022b0300300900090000f110012345670d1200'O; |
| 339 | const octetstring c_msg_s_q := '0a0000130e022b0200900400080000f110012345671200'O; |
| 340 | const octetstring c_msg_s_q_compl := '0b0000160e022b02009008000b0000f110012345670008001200'O; |
| 341 | const octetstring c_kill_compl := '050000160e022b02008008000b0000f110012345670006001200'O; |
| 342 | |
| 343 | log(dec_CBSP_PDU(c_load_q)); |
| 344 | log(dec_CBSP_PDU(c_load_q_compl)); |
| 345 | log(dec_CBSP_PDU(c_reset)); |
| 346 | log(dec_CBSP_PDU(c_reset_compl)); |
| 347 | log(dec_CBSP_PDU(c_msg_sts_q)); |
| 348 | log(dec_CBSP_PDU(c_msg_sts_q_fail)); |
| 349 | log(dec_CBSP_PDU(c_kill)); |
| 350 | log(dec_CBSP_PDU(c_kill_fail)); |
| 351 | log(dec_CBSP_PDU(c_write_repl)); |
| 352 | log(dec_CBSP_PDU(c_write_repl_compl)); |
| 353 | log(dec_CBSP_PDU(c_write_repl_fail)); |
| 354 | log(dec_CBSP_PDU(c_msg_s_q)); |
| 355 | log(dec_CBSP_PDU(c_msg_s_q_compl)); |
| 356 | log(dec_CBSP_PDU(c_kill_compl)); |
| 357 | } |
| 358 | |
| 359 | import from SABP_Types all; |
| 360 | import from SABP_Templates all; |
| 361 | import from SABP_IEs all; |
| 362 | import from SABP_PDU_Descriptions all; |
| 363 | |
| 364 | testcase TC_selftest_sabp() runs on test_CT { |
| 365 | const octetstring c_write := '00000080930000080006000211120007000240c0000f0010000113f0030282ec0613f0030282ec070001400100000d0002012a000900020000000400010100000056029f01b4d90d064297d9ec37e8fe96b3c9a0303bdd68341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d10012'O; |
| 366 | |
| 367 | log(dec_SABP_PDU(c_write)); |
| 368 | log(enc_SABP_PDU(dec_SABP_PDU(c_write))); |
| 369 | |
| 370 | var template (value) Service_Areas_List sa_list := { |
| 371 | ts_SabpSai('62F224'O, '0023'O, '0042'O) |
| 372 | }; |
| 373 | var template (value) SABP_PDU tx; |
| 374 | |
| 375 | tx := ts_SABP_Write(int2bit(1, 16), int2bit(1, 16), sa_list, 23, 42, '00000000'B, '01011010'B); |
| 376 | log("Write: ", enc_SABP_PDU(valueof(tx))) |
| 377 | |
| 378 | var Service_Areas_List sa_list2 := { valueof(ts_SabpSai('62F224'O, '1000'O, '0042'O)) }; |
| 379 | for (var integer i := 0; i < 2500; i := i+1) { |
| 380 | sa_list2 := sa_list2 & {valueof(ts_SabpSai('62F224'O, '2000'O, int2oct(i,2))) }; |
| 381 | } |
| 382 | tx := ts_SABP_Write(int2bit(2, 16), int2bit(2, 16), sa_list2, 23, 42, '00000000'B, '01011010'B); |
| 383 | log("Write: ", enc_SABP_PDU(valueof(tx))) |
| 384 | |
| 385 | tx := ts_SABP_Restart(sa_list); |
| 386 | log("Restart: ", enc_SABP_PDU(valueof(tx))); |
| 387 | } |
| 388 | |
| 389 | /********************************************************************************* |
| 390 | * ECBE interface (verifying expected procedures on CBSP) |
| 391 | *********************************************************************************/ |
| 392 | |
| 393 | function f_create_and_delete(CBS_Message msg, |
| 394 | template (omit) BSSMAP_FIELD_CellIdentificationList cell_list_success) |
| 395 | runs on test_CT { |
| 396 | var EcbeCbcMessage ecbe := f_cbs2ecbe(msg, "TTCN-3"); |
| 397 | f_ecbe_tx_post_cbs(ecbe); |
Pau Espin Pedrol | ac71dbb | 2022-07-08 17:14:45 +0200 | [diff] [blame] | 398 | f_cbsp_handle_write(msg, 0, cell_list_success); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 399 | f_ecbe_rx_resp(201); |
| 400 | |
| 401 | f_sleep(2.0); |
| 402 | |
| 403 | f_ecbe_tx_delete_cbs(msg.msg_id); |
| 404 | /* FIXME: cbc segfaults if we terminate here (if we don't wait for Connect_result? */ |
Harald Welte | c81236c | 2022-04-29 13:23:07 +0200 | [diff] [blame] | 405 | f_cbsp_handle_kill(0, msg.msg_id, msg.ser_nr, exp_list:=cell_list_success, tx_list:=cell_list_success, |
| 406 | tx_fail_list:=omit, tx_compl_list:=omit, channel_ind:=msg.channel_ind); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 407 | f_ecbe_rx_resp(200); |
| 408 | } |
| 409 | |
| 410 | private template (value) CBS_Message t_CBSmsg(uint16_t msg_id, uint16_t ser_nr) := { |
| 411 | msg_id := msg_id, |
| 412 | ser_nr := ser_nr, |
| 413 | old_ser_nr := omit, |
| 414 | cell_list := cil_BSS, |
| 415 | channel_ind := 0, |
| 416 | category := CBSP_CATEG_NORMAL, |
| 417 | rep_period := 5, |
| 418 | num_bcast_req := 3, |
| 419 | dcs := 1, |
| 420 | content := { |
| 421 | { '00'O, 1 } |
| 422 | } |
| 423 | }; |
| 424 | |
| 425 | /* specify a variety of different Cell Identifier formats to extend test coverage */ |
| 426 | testcase TC_ecbe_create_delete_cgi() runs on test_CT { |
| 427 | f_init(); |
| 428 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list_success; |
| 429 | var template (value) CBS_Message msg := t_CBSmsg(43, 16752); |
| 430 | |
| 431 | cell_list_success := ts_BSSMAP_CIL_CGI({ |
| 432 | ts_BSSMAP_CI_CGI('901'H, '70'H, 23, 42), |
| 433 | ts_BSSMAP_CI_CGI('901'H, '70'H, 24, 42), |
| 434 | ts_BSSMAP_CI_CGI('901'H, '70'H, 24, 43) |
| 435 | }); |
| 436 | f_create_and_delete(valueof(msg), cell_list_success); |
Pau Espin Pedrol | 9d8b6bf | 2022-06-23 12:19:47 +0200 | [diff] [blame] | 437 | f_shutdown_helper(); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 438 | } |
| 439 | testcase TC_ecbe_create_delete_lac_ci() runs on test_CT { |
| 440 | f_init(); |
| 441 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list_success; |
| 442 | var template (value) CBS_Message msg := t_CBSmsg(44, 16752); |
| 443 | cell_list_success := ts_BSSMAP_CIL_LAC_CI({ |
| 444 | ts_BSSMAP_CI_LAC_CI(10001, 50001), |
| 445 | ts_BSSMAP_CI_LAC_CI(10002, 50002), |
| 446 | ts_BSSMAP_CI_LAC_CI(10003, 50003) |
| 447 | }); |
| 448 | f_create_and_delete(valueof(msg), cell_list_success); |
Pau Espin Pedrol | 9d8b6bf | 2022-06-23 12:19:47 +0200 | [diff] [blame] | 449 | f_shutdown_helper(); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 450 | } |
| 451 | testcase TC_ecbe_create_delete_lac() runs on test_CT { |
| 452 | f_init(); |
| 453 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list_success; |
| 454 | var template (value) CBS_Message msg := t_CBSmsg(45, 16752); |
| 455 | cell_list_success := ts_BSSMAP_CIL_LAC({ |
| 456 | ts_BSSMAP_CI_LAC(10001), |
| 457 | ts_BSSMAP_CI_LAC(10002), |
| 458 | ts_BSSMAP_CI_LAC(10003) |
| 459 | }); |
| 460 | f_create_and_delete(valueof(msg), cell_list_success); |
Pau Espin Pedrol | 9d8b6bf | 2022-06-23 12:19:47 +0200 | [diff] [blame] | 461 | f_shutdown_helper(); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 462 | } |
| 463 | testcase TC_ecbe_create_delete_ci() runs on test_CT { |
| 464 | f_init(); |
| 465 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list_success; |
| 466 | var template (value) CBS_Message msg := t_CBSmsg(46, 16752); |
| 467 | cell_list_success := ts_BSSMAP_CIL_CI({ |
| 468 | ts_BSSMAP_CI_CI(50001), |
| 469 | ts_BSSMAP_CI_CI(50002), |
| 470 | ts_BSSMAP_CI_CI(50003) |
| 471 | }); |
| 472 | f_create_and_delete(valueof(msg), cell_list_success); |
Pau Espin Pedrol | 9d8b6bf | 2022-06-23 12:19:47 +0200 | [diff] [blame] | 473 | f_shutdown_helper(); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 474 | } |
| 475 | testcase TC_ecbe_create_delete_lai() runs on test_CT { |
| 476 | f_init(); |
| 477 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list_success; |
| 478 | var template (value) CBS_Message msg := t_CBSmsg(47, 16752); |
| 479 | cell_list_success := ts_BSSMAP_CIL_LAI({ |
| 480 | ts_BSSMAP_CI_LAI('901'H, '70'H, 25), |
| 481 | ts_BSSMAP_CI_LAI('901'H, '70'H, 26), |
| 482 | ts_BSSMAP_CI_LAI('901'H, '70'H, 27) |
| 483 | }); |
| 484 | f_create_and_delete(valueof(msg), cell_list_success); |
Pau Espin Pedrol | 9d8b6bf | 2022-06-23 12:19:47 +0200 | [diff] [blame] | 485 | f_shutdown_helper(); |
Harald Welte | 0833230 | 2019-08-01 09:54:40 +0200 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | control { |
| 489 | execute( TC_rx_keepalive() ); |
| 490 | execute( TC_rx_keepalive_timeout() ); |
| 491 | execute( TC_ecbe_create_delete_cgi() ); |
| 492 | execute( TC_ecbe_create_delete_lac_ci() ); |
| 493 | execute( TC_ecbe_create_delete_lac() ); |
| 494 | execute( TC_ecbe_create_delete_ci() ); |
| 495 | execute( TC_ecbe_create_delete_lai() ); |
| 496 | } |
| 497 | |
| 498 | } |