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