Pau Espin Pedrol | 4ff118a | 2022-07-28 17:37:47 +0200 | [diff] [blame] | 1 | /* MME (SBc-AP) Connection Handler of CBC test suite in TTCN-3 |
| 2 | * (C) 2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Author: Pau Espin Pedrol <pespin@sysmocom.de> |
| 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 | |
| 13 | module MME_ConnectionHandler { |
| 14 | |
| 15 | import from SBC_AP_IEs all; |
| 16 | import from SBC_AP_Constants all; |
| 17 | import from SBC_AP_PDU_Contents all; |
| 18 | import from SBC_AP_PDU_Descriptions all; |
| 19 | import from SBC_AP_Types all; |
| 20 | import from SBC_AP_Templates all; |
| 21 | import from SBC_AP_CodecPort all; |
| 22 | import from SBC_AP_Adapter all; |
| 23 | |
| 24 | import from CBS_Message all; |
| 25 | |
| 26 | type function void_fn() runs on MME_ConnHdlr; |
| 27 | |
| 28 | /* this component represents a single subscriber connection */ |
| 29 | type component MME_ConnHdlr extends SBC_AP_Adapter_CT { |
| 30 | var MME_ConnHdlrPars g_pars; |
| 31 | } |
| 32 | |
| 33 | type record MME_ConnHdlrPars { |
| 34 | integer mme_sbcap_port, |
| 35 | charstring cbc_host, |
| 36 | integer cbc_sbcap_port, |
| 37 | void_fn start_fn, |
Pau Espin Pedrol | ae2e515 | 2022-07-29 19:16:23 +0200 | [diff] [blame^] | 38 | CBS_Message exp_cbs_msg optional, |
| 39 | SBC_AP_Cause write_replace_warning_ind_cause optional, |
| 40 | CellId_Broadcast_List bcast_cell_id_list optional |
Pau Espin Pedrol | 4ff118a | 2022-07-28 17:37:47 +0200 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | function f_MME_ConnHdlr_main(charstring id, MME_ConnHdlrPars pars) runs on MME_ConnHdlr { |
| 44 | g_pars := pars; |
| 45 | SBC_AP_Adapter.f_connect(g_pars.cbc_host, g_pars.cbc_sbcap_port, "", g_pars.mme_sbcap_port); |
| 46 | g_pars.start_fn.apply(); |
| 47 | } |
| 48 | |
| 49 | function f_sbcap_tx_write_replace_warn_resp(CBS_Message msg, integer idx := 0) |
| 50 | runs on MME_ConnHdlr { |
| 51 | var template (value) SBC_AP_PDU tx; |
| 52 | /* TODO: pass Unknown Tracking Area List as parameter above (omit by default) */ |
| 53 | tx := ts_SBCAP_WRITE_WARNING_RESP(int2bit(msg.msg_id, 16), |
| 54 | int2bit(msg.ser_nr, 16)); |
| 55 | f_SBC_AP_send(tx, idx); |
| 56 | } |
| 57 | |
Pau Espin Pedrol | ae2e515 | 2022-07-29 19:16:23 +0200 | [diff] [blame^] | 58 | function f_sbcap_tx_write_replace_warn_ind(integer idx := 0, CBS_Message msg, |
| 59 | SBC_AP_Cause cause, |
| 60 | template (value) CellId_Broadcast_List bcast_cell_id_li) |
| 61 | runs on MME_ConnHdlr { |
| 62 | var template (value) SBC_AP_PDU tx; |
| 63 | tx := ts_SBCAP_WRITE_WARNING_IND(int2bit(msg.msg_id, 16), |
| 64 | int2bit(msg.ser_nr, 16), |
| 65 | cause, bcast_cell_id_li); |
| 66 | f_SBC_AP_send(tx, idx); |
| 67 | } |
| 68 | |
Pau Espin Pedrol | 4ff118a | 2022-07-28 17:37:47 +0200 | [diff] [blame] | 69 | function f_sbcap_tx_stop_warn_resp(integer idx := 0, CBS_Message msg) |
| 70 | runs on MME_ConnHdlr { |
| 71 | var template (value) SBC_AP_PDU tx; |
| 72 | tx := ts_SBCAP_STOP_WARNING_RESP(int2bit(msg.msg_id, 16), |
| 73 | int2bit(msg.ser_nr, 16)); |
| 74 | f_SBC_AP_send(tx, idx); |
| 75 | } |
| 76 | |
| 77 | /* handle a SBc-AP Write-Replace Request and respond to it with Response or FAILURE depending on arguments */ |
| 78 | function f_sbcap_handle_write_replace_warn_req(CBS_Message msg, integer idx := 0) |
| 79 | runs on MME_ConnHdlr { |
| 80 | var template (present) SBC_AP_PDU rx_templ; |
| 81 | var SBC_AP_RecvFrom rf; |
| 82 | rx_templ := tr_SBCAP_WRITE_WARNING(int2bit(msg.msg_id, 16), |
| 83 | int2bit(msg.ser_nr, 16), |
| 84 | msg.rep_period, |
| 85 | msg.num_bcast_req); |
| 86 | alt { |
| 87 | [] SBC_AP[idx].receive(tr_SBC_AP_Recv(g_SBC_AP_conn_id[idx], rx_templ)) -> value rf { |
| 88 | log ("received expected req:", rf); |
| 89 | f_sbcap_tx_write_replace_warn_resp(msg, idx); |
| 90 | } |
| 91 | [] SBC_AP[idx].receive { |
| 92 | setverdict(fail, "Received unexpected SBc-AP in index ", idx); |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /* handle a SBc-AP Stop-Warning-Request and respond to it with Response or FAILURE depending on arguments */ |
| 98 | function f_sbcap_handle_stop_warn_req(integer idx := 0, CBS_Message msg) |
| 99 | runs on MME_ConnHdlr { |
| 100 | var template (present) SBC_AP_PDU rx_templ; |
| 101 | var SBC_AP_RecvFrom rf; |
| 102 | |
| 103 | rx_templ := tr_SBCAP_STOP_WARNING(int2bit(msg.msg_id, 16), |
| 104 | int2bit(msg.ser_nr, 16)); |
| 105 | alt { |
| 106 | [] SBC_AP[idx].receive(tr_SBC_AP_Recv(g_SBC_AP_conn_id[idx], rx_templ)) -> value rf { |
| 107 | log ("received expected req:", rf); |
| 108 | f_sbcap_tx_stop_warn_resp(idx, msg); |
| 109 | } |
| 110 | [] SBC_AP[idx].receive { |
| 111 | setverdict(fail, "Received unexpected SBc-AP in index ", idx); |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | } |