Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 1 | /* BSC Connection Handler of MSC test suite in TTCN-3 |
| 2 | * (C) 2018-2019 Harald Welte <laforge@gnumonks.org> |
| 3 | * (C) 2018-2019 sysmocom - s.f.m.c. GmbH |
| 4 | * (C) 2018 Vadim Yanitskiy <axilirator@gmail.com> |
| 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 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 13 | module BSC_ConnectionHandler { |
| 14 | |
| 15 | import from General_Types all; |
| 16 | import from Osmocom_Types all; |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 17 | import from Native_Functions all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 18 | import from GSM_Types all; |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 19 | import from IPL4asp_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 20 | import from SCCPasp_Types all; |
| 21 | import from BSSAP_Types all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 22 | import from RAN_Emulation all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 23 | import from BSSMAP_Templates all; |
| 24 | |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 25 | import from RANAP_Constants all; |
| 26 | import from RANAP_IEs all; |
| 27 | import from RANAP_PDU_Contents all; |
| 28 | import from RANAP_PDU_Descriptions all; |
| 29 | import from RANAP_Templates all; |
| 30 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 31 | import from GSUP_Types all; |
| 32 | import from GSUP_Emulation all; |
| 33 | |
| 34 | import from MNCC_Types all; |
| 35 | import from MNCC_Emulation all; |
| 36 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 37 | import from MGCP_Types all; |
| 38 | import from MGCP_Emulation all; |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 39 | import from MGCP_Templates all; |
| 40 | import from SDP_Types all; |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 41 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 42 | import from MobileL3_Types all; |
| 43 | import from MobileL3_CommonIE_Types all; |
| 44 | import from MobileL3_MM_Types all; |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 45 | import from MobileL3_CC_Types all; |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 46 | import from MobileL3_SMS_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 47 | import from L3_Templates all; |
Harald Welte | 158a7ca | 2018-02-16 18:11:31 +0100 | [diff] [blame] | 48 | import from L3_Common all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 49 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 50 | import from SMPP_Emulation all; |
| 51 | |
Philipp Maier | aeb29a8 | 2018-11-08 17:40:53 +0100 | [diff] [blame] | 52 | import from IPA_Emulation all; |
| 53 | import from Osmocom_CTRL_Functions all; |
| 54 | import from Osmocom_CTRL_Types all; |
| 55 | import from Osmocom_CTRL_Adapter all; |
| 56 | |
Philipp Maier | c39a9d8 | 2018-11-09 11:21:08 +0100 | [diff] [blame] | 57 | import from TELNETasp_PortType all; |
| 58 | import from Osmocom_VTY_Functions all; |
| 59 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 60 | import from SGsAP_Emulation all; |
| 61 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 62 | import from TCCConversion_Functions { function f_strstr }; |
| 63 | |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 64 | modulepar { |
| 65 | boolean mp_expect_common_id := true; |
| 66 | } |
| 67 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 68 | /* this component represents a single subscriber connection */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 69 | type component BSC_ConnHdlr extends RAN_ConnHdlr, MNCC_ConnHdlr, GSUP_ConnHdlr, MGCP_ConnHdlr, SMPP_ConnHdlr, CTRL_Adapter_CT, SGsAP_ConnHdlr { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 70 | var BSC_ConnHdlrPars g_pars; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 71 | timer g_Tguard := 60.0; |
Philipp Maier | c39a9d8 | 2018-11-09 11:21:08 +0100 | [diff] [blame] | 72 | port TELNETasp_PT MSCVTY; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 73 | } |
| 74 | |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 75 | type record BSC_ConnHdlrNetworkPars { |
| 76 | OCT1 kc_support, |
| 77 | boolean expect_tmsi, |
| 78 | boolean expect_auth, |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 79 | boolean expect_ciph, |
| 80 | boolean expect_imei, |
| 81 | boolean expect_imei_early, |
| 82 | GSUP_IMEIResult check_imei_result, |
| 83 | boolean check_imei_error |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 84 | } |
| 85 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 86 | type record BSC_ConnHdlrPars { |
| 87 | SCCP_PAR_Address sccp_addr_own, |
| 88 | SCCP_PAR_Address sccp_addr_peer, |
| 89 | BSSMAP_IE_CellIdentifier cell_id, |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 90 | hexstring imei, |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 91 | hexstring imsi, |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 92 | hexstring msisdn, |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 93 | OCT4 tmsi optional, |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 94 | MobileStationClassmark1_V cm1, |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 95 | BSSMAP_IE_ClassmarkInformationType2 cm2, |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 96 | BSSMAP_IE_ClassmarkInformationType3 cm3 optional, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 97 | AuthVector vec optional, |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 98 | BSC_ConnHdlrNetworkPars net, |
Philipp Maier | aeb29a8 | 2018-11-08 17:40:53 +0100 | [diff] [blame] | 99 | boolean send_early_cm, |
| 100 | charstring ipa_ctrl_ip, |
| 101 | integer ipa_ctrl_port, |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 102 | boolean ipa_ctrl_enable, |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 103 | boolean mm_info, |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 104 | boolean sgsap_enable, |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 105 | boolean gsup_enable, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 106 | OCT4 gsup_sid, |
Harald Welte | c1f937a | 2019-04-21 21:19:23 +0200 | [diff] [blame] | 107 | integer ran_idx, |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 108 | boolean use_umts_aka, |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 109 | boolean ran_is_geran, |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 110 | boolean use_osmux, |
| 111 | boolean verify_cell_id |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 112 | }; |
| 113 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 114 | /* get a one-octet bitmaks of supported algorithms based on Classmark information */ |
| 115 | function f_alg_mask_from_cm(BSSMAP_IE_ClassmarkInformationType2 cm2) return OCT1 { |
| 116 | var BIT8 res := '00000001'B; /* A5/0 always supported */ |
| 117 | |
| 118 | if (cm2.a5_1 == '0'B) { |
| 119 | res := res or4b '00000010'B; |
| 120 | } |
| 121 | if (cm2.classmarkInformationType2_oct5.a5_2 == '1'B ) { |
| 122 | res := res or4b '00000100'B; |
| 123 | } |
| 124 | if (cm2.classmarkInformationType2_oct5.a5_3 == '1'B) { |
| 125 | res := res or4b '00001000'B; |
| 126 | } |
| 127 | /* TODO: CM3 for A5/4 and beyond */ |
| 128 | return bit2oct(res); |
| 129 | } |
| 130 | |
| 131 | /* determine the best algorithm available within the bit-mask */ |
| 132 | function f_best_alg_from_mask(OCT1 alg_in) return OCT1 { |
| 133 | var BIT8 alg := oct2bit(alg_in); |
| 134 | var BIT8 ordered_algs[8] := { |
| 135 | '10000000'B, '01000000'B, '00100000'B, '00010000'B, |
| 136 | '00001000'B, /* A5/3 */ |
| 137 | '00000010'B, /* A5/1 */ |
| 138 | '00000100'B, /* A5/2 */ |
| 139 | '00000001'B /* A5/0 */ } |
| 140 | for (var integer i := 0; i < sizeof(ordered_algs); i := i+1) { |
| 141 | if (alg and4b ordered_algs[i] != '00000000'B) { |
| 142 | return bit2oct(ordered_algs[i]); |
| 143 | } |
| 144 | } |
| 145 | return '00'O; |
| 146 | } |
| 147 | |
| 148 | /* return an integer like '1' for A5/1 based on a mask (with only one bit set */ |
| 149 | function f_alg_from_mask(OCT1 mask_in) return integer { |
| 150 | var BIT8 mask := oct2bit(mask_in); |
| 151 | for (var integer i := 0; i < 8; i := i+1) { |
| 152 | if (mask and4b ('00000001'B << i) != '00000000'B) { |
| 153 | return i; |
| 154 | } |
| 155 | } |
| 156 | return -1; |
| 157 | } |
| 158 | |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 159 | /* altstep for the global guard timer */ |
| 160 | private altstep as_Tguard() runs on BSC_ConnHdlr { |
| 161 | [] g_Tguard.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 162 | setverdict(fail, "Tguard timeout"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 163 | mtc.stop; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
| 167 | /* init function, called as first function in new BSC_ConnHdlr */ |
Harald Welte | ad2952e | 2018-01-27 14:12:46 +0100 | [diff] [blame] | 168 | function f_init_handler(BSC_ConnHdlrPars pars, float t_guard := 60.0) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 169 | /* make parameters available via component variable */ |
| 170 | g_pars := pars; |
| 171 | /* Start guard timer and activate it as default */ |
Harald Welte | ad2952e | 2018-01-27 14:12:46 +0100 | [diff] [blame] | 172 | g_Tguard.start(t_guard); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 173 | activate(as_Tguard()); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 174 | /* Route all SMPP messages for our MSISDN to us */ |
| 175 | f_create_smpp_expect(hex2str(pars.msisdn)); |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 176 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 177 | /* Route all SGs message for our IMSI to us */ |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 178 | if (g_pars.sgsap_enable == true) { |
| 179 | f_create_sgsap_expect(pars.imsi); |
| 180 | } |
Philipp Maier | aeb29a8 | 2018-11-08 17:40:53 +0100 | [diff] [blame] | 181 | |
| 182 | if (g_pars.ipa_ctrl_enable == true) { |
| 183 | f_ipa_ctrl_start(g_pars.ipa_ctrl_ip, g_pars.ipa_ctrl_port); |
| 184 | } |
Philipp Maier | c39a9d8 | 2018-11-09 11:21:08 +0100 | [diff] [blame] | 185 | |
| 186 | map(self:MSCVTY, system:MSCVTY); |
| 187 | f_vty_set_prompts(MSCVTY); |
| 188 | f_vty_transceive(MSCVTY, "enable"); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 189 | } |
| 190 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 191 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 192 | /* Callback function from general RAN_Emulation whenever a connectionless |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 193 | * BSSMAP message arrives. Canreturn a PDU_BSSAPthat should be sent in return */ |
| 194 | private function BscUnitdataCallback(PDU_BSSAP bssap) |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 195 | runs on RAN_Emulation_CT return template PDU_BSSAP { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 196 | var template PDU_BSSAP resp := omit; |
| 197 | |
| 198 | log("BSSMAP_BscUnitdataCallback"); |
| 199 | /* answer all RESET with RESET ACK */ |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 200 | if (match(bssap, tr_BSSMAP_Reset(g_ran_ops.use_osmux))){ |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 201 | log("BSSMAP_BscUnitdataCallback: Responding to RESET with RESET-ACK"); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 202 | resp := ts_BSSMAP_ResetAck(g_ran_ops.use_osmux); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | /* FIXME: Handle paging, etc. */ |
| 206 | return resp; |
| 207 | } |
| 208 | |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 209 | private function RncUnitdataCallback(RANAP_PDU ranap) |
| 210 | runs on RAN_Emulation_CT return template RANAP_PDU { |
| 211 | var template RANAP_PDU resp := omit; |
| 212 | |
| 213 | log("RANAP_RncUnitdataCallback"); |
| 214 | /* answer all RESET with RESET ACK */ |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 215 | if (match(ranap, tr_RANAP_Reset())) { |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 216 | log("RANAP_RncUnitdataCallback: Responding to RESET with RESET-ACK"); |
| 217 | var CN_DomainIndicator dom; |
| 218 | dom := ranap.initiatingMessage.value_.Reset.protocolIEs[1].value_.cN_DomainIndicator; |
| 219 | resp := ts_RANAP_ResetAck(dom); |
| 220 | } |
| 221 | |
| 222 | /* FIXME: Handle paging, etc. */ |
| 223 | return resp; |
| 224 | } |
| 225 | |
| 226 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 227 | const RanOps BSC_RanOps := { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 228 | /* Create call-back for inbound connections from MSC (hand-over) */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 229 | create_cb := refers(RAN_Emulation.ExpectedCreateCallback), |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 230 | unitdata_cb := refers(BscUnitdataCallback), |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 231 | ranap_create_cb := refers(RAN_Emulation.RanapExpectedCreateCallback), |
| 232 | ranap_unitdata_cb := refers(RncUnitdataCallback), |
| 233 | ps_domain := false, |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 234 | decode_dtap := true, |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 235 | role_ms := true, |
Harald Welte | 2fce788 | 2019-04-15 11:48:05 +0200 | [diff] [blame] | 236 | protocol := RAN_PROTOCOL_BSSAP, |
Pau Espin Pedrol | c6b78ff | 2019-06-06 15:58:17 +0200 | [diff] [blame] | 237 | transport := BSSAP_TRANSPORT_AoIP, |
Pau Espin Pedrol | c6a53db | 2019-05-20 19:31:47 +0200 | [diff] [blame] | 238 | use_osmux := false, |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 239 | sccp_addr_local := omit, |
| 240 | sccp_addr_peer := omit |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | |
| 244 | private function MnccUnitdataCallback(MNCC_PDU mncc) |
| 245 | runs on MNCC_Emulation_CT return template MNCC_PDU { |
| 246 | log("Ignoring MNCC", mncc); |
| 247 | return omit; |
| 248 | } |
| 249 | |
| 250 | const MnccOps BCC_MnccOps := { |
| 251 | create_cb := refers(MNCC_Emulation.ExpectedCreateCallback), |
| 252 | unitdata_cb := refers(MnccUnitdataCallback) |
| 253 | } |
| 254 | |
| 255 | |
| 256 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 257 | /* Encode 'l3' and ask RAN_Emulation to create new connection with COMPL L3 INFO */ |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 258 | function f_bssap_compl_l3(PDU_ML3_MS_NW l3) |
| 259 | runs on BSC_ConnHdlr { |
| 260 | log("Sending COMPL L3: ", l3); |
| 261 | var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3); |
| 262 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 263 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, l3_enc)))); |
Harald Welte | 71b6933 | 2018-01-21 20:43:53 +0100 | [diff] [blame] | 264 | alt { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 265 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) {} |
| 266 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) { |
Harald Welte | 71b6933 | 2018-01-21 20:43:53 +0100 | [diff] [blame] | 267 | setverdict(fail, "DISC.ind from SCCP"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 268 | mtc.stop; |
Harald Welte | 71b6933 | 2018-01-21 20:43:53 +0100 | [diff] [blame] | 269 | } |
| 270 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 271 | } |
| 272 | |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 273 | /* generate Iu LAI from BSSAP CGI */ |
| 274 | private function f_IuLAI_from_BssmapCI(BSSMAP_IE_CellIdentifier ci) return LAI { |
| 275 | var LAI lai; |
| 276 | if (ischosen(ci.cellIdentification.cI_CGI)) { |
| 277 | lai.pLMNidentity := ci.cellIdentification.cI_CGI.mcc_mnc; |
| 278 | lai.lAC := ci.cellIdentification.cI_CGI.lac; |
| 279 | } else if (ischosen(ci.cellIdentification.cI_SAI)) { |
| 280 | lai.pLMNidentity := ci.cellIdentification.cI_SAI.mcc_mnc; |
| 281 | lai.lAC := ci.cellIdentification.cI_SAI.lac; |
| 282 | } else if (ischosen(ci.cellIdentification.ci_LAC_RNC_CI)) { |
| 283 | lai.pLMNidentity := ci.cellIdentification.ci_LAC_RNC_CI.mcc_mnc; |
| 284 | lai.lAC := ci.cellIdentification.ci_LAC_RNC_CI.lac; |
| 285 | } else { |
| 286 | mtc.stop; |
| 287 | } |
| 288 | lai.iE_Extensions := omit; |
| 289 | return lai; |
| 290 | } |
| 291 | |
| 292 | /* like f_bssap_compl_l3() but for 3G */ |
| 293 | function f_ranap_initial_ue(PDU_ML3_MS_NW l3) |
| 294 | runs on BSC_ConnHdlr { |
| 295 | log("Sending InitialUE: ", l3); |
| 296 | var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3); |
| 297 | var RANAP_PDU ranap; |
| 298 | var LAI lai := f_IuLAI_from_BssmapCI(g_pars.cell_id); |
| 299 | var SAI sai := { |
| 300 | pLMNidentity := lai.pLMNidentity, |
| 301 | lAC := lai.lAC, |
| 302 | sAC := '0000'O, /* FIXME */ |
| 303 | iE_Extensions := omit |
| 304 | }; |
| 305 | var IuSignallingConnectionIdentifier sigc_id := int2bit(23, 24); |
| 306 | var GlobalRNC_ID grnc_id := { |
| 307 | pLMNidentity := lai.pLMNidentity, |
| 308 | rNC_ID := 2342 /* FIXME */ |
| 309 | }; |
| 310 | |
| 311 | ranap := valueof(ts_RANAP_initialUE_CS(lai, sai, l3_enc, sigc_id, grnc_id)); |
| 312 | BSSAP.send(ts_RANAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, ranap)); |
| 313 | alt { |
| 314 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) {} |
| 315 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) { |
| 316 | setverdict(fail, "DISC.ind from SCCP"); |
| 317 | mtc.stop; |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 322 | /* Send BSSMAP Complete L3 or RANAP Initial UE depending on 2G/3G RAN type */ |
| 323 | function f_cl3_or_initial_ue(PDU_ML3_MS_NW l3) |
| 324 | runs on BSC_ConnHdlr { |
| 325 | if (g_pars.ran_is_geran) { |
| 326 | f_bssap_compl_l3(l3); |
| 327 | } else { |
| 328 | f_ranap_initial_ue(l3); |
| 329 | } |
| 330 | } |
| 331 | |
Harald Welte | 081b19a | 2018-02-10 09:11:13 +0100 | [diff] [blame] | 332 | type enumerated EstablishType { |
| 333 | EST_TYPE_MO_CALL, |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 334 | EST_TYPE_EMERG_CALL, |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 335 | EST_TYPE_PAG_RESP, |
Vadim Yanitskiy | 20ee5e4 | 2018-05-27 17:54:21 +0700 | [diff] [blame] | 336 | EST_TYPE_MO_SMS, |
| 337 | EST_TYPE_SS_ACT |
Harald Welte | 081b19a | 2018-02-10 09:11:13 +0100 | [diff] [blame] | 338 | }; |
| 339 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 340 | /* helper function to fully establish a dedicated channel */ |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 341 | function f_establish_fully(EstablishType etype := EST_TYPE_MO_CALL) |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 342 | runs on BSC_ConnHdlr { |
Harald Welte | 081b19a | 2018-02-10 09:11:13 +0100 | [diff] [blame] | 343 | var PDU_ML3_MS_NW l3_info; |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 344 | var MobileIdentityLV mi; |
| 345 | |
| 346 | /* If we have a TMSI, use TMSI instead of IMSI */ |
| 347 | if (ispresent(g_pars.tmsi)) { |
| 348 | mi := valueof(ts_MI_TMSI_LV(g_pars.tmsi)); |
| 349 | } else { |
| 350 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 351 | } |
| 352 | |
Harald Welte | 081b19a | 2018-02-10 09:11:13 +0100 | [diff] [blame] | 353 | select (etype) { |
| 354 | case (EST_TYPE_MO_CALL) { |
| 355 | l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); |
| 356 | } |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 357 | case (EST_TYPE_EMERG_CALL) { |
| 358 | l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_EMERG_CALL, mi)); |
| 359 | } |
Harald Welte | 081b19a | 2018-02-10 09:11:13 +0100 | [diff] [blame] | 360 | case (EST_TYPE_PAG_RESP) { |
| 361 | l3_info := valueof(ts_PAG_RESP(mi)); |
| 362 | } |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 363 | case (EST_TYPE_MO_SMS) { |
| 364 | l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, mi)); |
| 365 | } |
Vadim Yanitskiy | 20ee5e4 | 2018-05-27 17:54:21 +0700 | [diff] [blame] | 366 | case (EST_TYPE_SS_ACT) { |
| 367 | l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, mi)); |
| 368 | } |
Harald Welte | 081b19a | 2018-02-10 09:11:13 +0100 | [diff] [blame] | 369 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 370 | |
| 371 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 372 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 373 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 374 | f_verify_vty_lac_ci(verify_vlr := false); |
| 375 | |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 376 | f_mm_common(); |
Pau Espin Pedrol | f803448 | 2019-06-03 13:15:58 +0200 | [diff] [blame] | 377 | if (g_pars.net.expect_ciph or not g_pars.ran_is_geran) { |
Harald Welte | 148a708 | 2018-01-26 18:56:43 +0100 | [diff] [blame] | 378 | /* implicit CM SERVICE ACCEPT? */ |
| 379 | } else { |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 380 | if (etype != EST_TYPE_PAG_RESP) { |
Harald Welte | 081b19a | 2018-02-10 09:11:13 +0100 | [diff] [blame] | 381 | /* explicit CM SERVICE ACCEPT */ |
| 382 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)); |
| 383 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 384 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | /* build a PDU_ML3_MS_NW containing a Location Update by IMSI */ |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 388 | function f_build_lu_imsi(hexstring imsi) runs on BSC_ConnHdlr return PDU_ML3_MS_NW |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 389 | { |
| 390 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(imsi)); |
| 391 | return f_build_lu(mi); |
| 392 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 393 | function f_build_lu_imei(hexstring imei) runs on BSC_ConnHdlr return PDU_ML3_MS_NW |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 394 | { |
| 395 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(imei)); |
| 396 | return f_build_lu(mi); |
| 397 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 398 | function f_build_lu_tmsi(OCT4 tmsi) runs on BSC_ConnHdlr return PDU_ML3_MS_NW |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 399 | { |
| 400 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV(tmsi)); |
| 401 | return f_build_lu(mi); |
| 402 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 403 | private function f_build_lu(MobileIdentityLV mi) runs on BSC_ConnHdlr return PDU_ML3_MS_NW |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 404 | { |
| 405 | var LocationAreaIdentification_V old_lai := { '62F220'O, '9999'O }; |
| 406 | var PDU_ML3_MS_NW l3_info := valueof(ts_ML3_MO_LU_Req(valueof(ts_ML3_IE_LuType_Attach), |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 407 | old_lai, mi, g_pars.cm1)); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 408 | return l3_info; |
| 409 | } |
| 410 | |
Harald Welte | a183a5d | 2019-05-09 13:40:52 +0200 | [diff] [blame] | 411 | altstep as_GSUP_SAI() runs on BSC_ConnHdlr { |
| 412 | var GSUP_IE auth_tuple; |
| 413 | [] GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)) { |
| 414 | if (g_pars.use_umts_aka) { |
| 415 | g_pars.vec := f_gen_auth_vec_3g(); |
| 416 | auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 417 | g_pars.vec.sres, |
| 418 | g_pars.vec.kc, |
| 419 | g_pars.vec.ik, |
| 420 | g_pars.vec.ck, |
| 421 | g_pars.vec.autn, |
| 422 | g_pars.vec.res)); |
| 423 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 424 | } else { |
| 425 | g_pars.vec := f_gen_auth_vec_2g(); |
| 426 | auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(g_pars.vec.rand, |
| 427 | g_pars.vec.sres, |
| 428 | g_pars.vec.kc)); |
| 429 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 434 | function f_mm_auth() runs on BSC_ConnHdlr |
Harald Welte | 148a708 | 2018-01-26 18:56:43 +0100 | [diff] [blame] | 435 | { |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 436 | if (g_pars.net.expect_auth) { |
Harald Welte | a183a5d | 2019-05-09 13:40:52 +0200 | [diff] [blame] | 437 | as_GSUP_SAI(); |
Harald Welte | c1f937a | 2019-04-21 21:19:23 +0200 | [diff] [blame] | 438 | if (g_pars.use_umts_aka) { |
Harald Welte | c1f937a | 2019-04-21 21:19:23 +0200 | [diff] [blame] | 439 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ_3G(g_pars.vec.rand, g_pars.vec.autn))); |
| 440 | var OCT4 res := substr(g_pars.vec.res, 0, 4); |
| 441 | var OCT4 xres := substr(g_pars.vec.res, 4, 4); |
| 442 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_3G(res, xres))); |
| 443 | } else { |
Harald Welte | c1f937a | 2019-04-21 21:19:23 +0200 | [diff] [blame] | 444 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(g_pars.vec.rand))); |
| 445 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G(g_pars.vec.sres))); |
| 446 | } |
Harald Welte | 148a708 | 2018-01-26 18:56:43 +0100 | [diff] [blame] | 447 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 448 | } |
Harald Welte | 148a708 | 2018-01-26 18:56:43 +0100 | [diff] [blame] | 449 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 450 | function f_mm_imei() runs on BSC_ConnHdlr |
| 451 | { |
| 452 | var PDU_DTAP_MT dtap_mt; |
| 453 | var GSUP_PDU gsup_msg; |
Vadim Yanitskiy | 98bb2d5 | 2020-03-28 00:57:21 +0700 | [diff] [blame] | 454 | var MobileIdentityLV mi; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 455 | |
| 456 | if (not g_pars.net.expect_imei) { |
| 457 | return |
| 458 | } |
| 459 | |
| 460 | /* MSC <-> BSC: ID req/rsp for IMEI */ |
| 461 | alt { |
| 462 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMEI))) { |
| 463 | mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
| 464 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp(mi))); |
| 465 | } |
| 466 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) -> value dtap_mt { |
| 467 | setverdict(fail, "Expected ID REQ for IMEI DTAP MT message, but got: ", dtap_mt); |
| 468 | mtc.stop; |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | /* MSC <-> HLR: Check IMEI req/res/err */ |
| 473 | alt { |
| 474 | [g_pars.net.check_imei_error] GSUP.receive(tr_GSUP_CHECK_IMEI_REQ(g_pars.imsi, g_pars.imei)) { |
| 475 | GSUP.send(ts_GSUP_CHECK_IMEI_ERR(g_pars.imsi, 96 /* Invalid Mandatory Information */)); |
| 476 | } |
| 477 | [not g_pars.net.check_imei_error] GSUP.receive(tr_GSUP_CHECK_IMEI_REQ(g_pars.imsi, g_pars.imei)) { |
| 478 | GSUP.send(ts_GSUP_CHECK_IMEI_RES(g_pars.imsi, g_pars.net.check_imei_result)); |
| 479 | } |
| 480 | [] GSUP.receive(?) -> value gsup_msg { |
| 481 | setverdict(fail, "Expected CHECK IMEI REQ GSUP message (with IMEI:", g_pars.imei, " and IMSI: ", |
| 482 | g_pars.imsi, "), but got: ", gsup_msg); |
| 483 | mtc.stop; |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | function f_mm_imei_early() runs on BSC_ConnHdlr |
| 489 | { |
| 490 | var PDU_DTAP_MT dtap_mt; |
| 491 | var GSUP_PDU gsup_msg; |
Vadim Yanitskiy | 98bb2d5 | 2020-03-28 00:57:21 +0700 | [diff] [blame] | 492 | var MobileIdentityLV mi; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 493 | |
| 494 | if (not g_pars.net.expect_imei_early) { |
| 495 | return |
| 496 | } |
| 497 | |
| 498 | /* MSC <-> BSC: ID req/rsp for IMEISV */ |
| 499 | alt { |
| 500 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMEISV))) { |
| 501 | mi := valueof(ts_MI_IMEISV_LV(g_pars.imei)); |
| 502 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp(mi))); |
| 503 | } |
| 504 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) -> value dtap_mt { |
| 505 | setverdict(fail, "Expected ID REQ for IMEISV DTAP MT message, but got: ", dtap_mt); |
| 506 | mtc.stop; |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | /* MSC <-> HLR: Check IMEI req/res/err */ |
| 511 | alt { |
| 512 | [g_pars.net.check_imei_error] GSUP.receive(tr_GSUP_CHECK_IMEI_REQ(g_pars.imsi, g_pars.imei)) { |
| 513 | GSUP.send(ts_GSUP_CHECK_IMEI_ERR(g_pars.imsi, 96 /* Invalid Mandatory Information */)); |
| 514 | } |
| 515 | [not g_pars.net.check_imei_error] GSUP.receive(tr_GSUP_CHECK_IMEI_REQ(g_pars.imsi, g_pars.imei)) { |
| 516 | GSUP.send(ts_GSUP_CHECK_IMEI_RES(g_pars.imsi, g_pars.net.check_imei_result)); |
| 517 | } |
| 518 | [] GSUP.receive(?) -> value gsup_msg { |
| 519 | setverdict(fail, "Expected CHECK IMEI REQ GSUP message (with IMEI:", g_pars.imei, " and IMSI: ", |
| 520 | g_pars.imsi, "), but got: ", gsup_msg); |
| 521 | mtc.stop; |
| 522 | } |
| 523 | } |
| 524 | } |
| 525 | |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 526 | function f_expect_common_id() runs on BSC_ConnHdlr |
| 527 | { |
| 528 | if (g_pars.ran_is_geran) { |
| 529 | if (mp_expect_common_id) { |
| 530 | BSSAP.receive(tr_BSSMAP_CommonId(g_pars.imsi)); |
| 531 | } |
| 532 | } else { |
| 533 | BSSAP.receive(tr_RANAP_CommonId(imsi_hex2oct(g_pars.imsi))); |
| 534 | } |
| 535 | } |
| 536 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 537 | function f_mm_common() runs on BSC_ConnHdlr |
| 538 | { |
| 539 | f_mm_auth(); |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 540 | if (g_pars.ran_is_geran) { |
| 541 | if (g_pars.net.expect_ciph) { |
| 542 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 543 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 544 | alt { |
| 545 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 546 | var OCT1 a5_chosen := f_best_alg_from_mask(a5_intersect); |
| 547 | var integer a5_nr := f_alg_from_mask(a5_chosen); |
| 548 | BSSAP.send(ts_BSSMAP_CipherModeCompl(int2oct(a5_nr+1, 1))); |
| 549 | } |
| 550 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 551 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 552 | mtc.stop; |
| 553 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 554 | } |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 555 | /* FIXME: Send the best available algorithm */ |
| 556 | } |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 557 | f_expect_common_id(); |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 558 | } else { /* UTRAN */ |
| 559 | alt { |
| 560 | [g_pars.net.expect_ciph] BSSAP.receive(tr_RANAP_SecurityModeCmdEnc(uia_algs := ?, |
| 561 | uia_key := oct2bit(g_pars.vec.ik), |
| 562 | key_sts := ?, |
| 563 | uea_algs := ?, |
| 564 | uea_key := oct2bit(g_pars.vec.ck))) { |
| 565 | var IntegrityProtectionAlgorithm uia_chosen := 0; /*standard_UMTS_integrity_algorithm_UIA1*/ |
| 566 | var EncryptionAlgorithm uea_chosen := 1; /*standard_UMTS_encryption_algorith_UEA1*/ |
| 567 | BSSAP.send(ts_RANAP_SecurityModeCompleteEnc(uia_chosen, uea_chosen)); |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 568 | f_expect_common_id(); |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 569 | } |
| 570 | [g_pars.net.expect_ciph] BSSAP.receive(tr_RANAP_SecurityModeCmdEnc(?,?,?,?,?)) { |
| 571 | setverdict(fail, "Invalid SecurityModeCommand (ciphering case)"); |
| 572 | mtc.stop; |
| 573 | } |
| 574 | [not g_pars.net.expect_ciph] BSSAP.receive(tr_RANAP_SecurityModeCmd(uia_algs := ?, |
| 575 | uia_key := oct2bit(g_pars.vec.ik), |
| 576 | key_sts := ?)) { |
| 577 | var IntegrityProtectionAlgorithm uia_chosen := 0; /*standard_UMTS_integrity_algorithm_UIA1;*/ |
| 578 | BSSAP.send(ts_RANAP_SecurityModeComplete(uia_chosen)); |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 579 | f_expect_common_id(); |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 580 | } |
| 581 | [not g_pars.net.expect_ciph] BSSAP.receive(tr_RANAP_SecurityModeCmd(?,?,?)) { |
| 582 | setverdict(fail, "Invalid SecurityModeCommand (non-ciphering case)"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 583 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 584 | } |
| 585 | } |
Harald Welte | 148a708 | 2018-01-26 18:56:43 +0100 | [diff] [blame] | 586 | } |
| 587 | } |
| 588 | |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 589 | function f_expect_mm_info() runs on BSC_ConnHdlr { |
| 590 | if (g_pars.mm_info == true) { |
| 591 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_Info)); |
| 592 | } |
| 593 | } |
| 594 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 595 | private function f_lac_ci_vty_str(BSSMAP_IE_CellIdentifier cell_id) return charstring |
| 596 | { |
| 597 | return "LAC / cell ID: " |
| 598 | & int2str(oct2int(cell_id.cellIdentification.cI_CGI.lac)) & " / " |
| 599 | & int2str(oct2int(cell_id.cellIdentification.cI_CGI.ci)); |
| 600 | } |
| 601 | |
| 602 | /* Get an IMSI's info and verify that the g_pars.cell_id is reflected in the info. |
| 603 | * Verify both the "LAC / cell ID" in the VLR and the "LAC / cell ID" in the "Connection:" part, if any. |
| 604 | * If verify_vlr == false, then only verify the "Connection:" part, and fail if there is no "Connection:"; this is |
| 605 | * useful when a conn has been established, but the subscriber has not been authenticated, so the VLR does not yet |
| 606 | * reflect the new conn's cell ID. |
| 607 | */ |
| 608 | function f_verify_vty_lac_ci(boolean verify_vlr := true) runs on BSC_ConnHdlr { |
| 609 | if (not g_pars.ran_is_geran) { |
| 610 | log("Skipping f_verify_vty_lac_ci(), disabled for Iu"); |
| 611 | setverdict(pass); |
| 612 | return; |
| 613 | } |
| 614 | if (not g_pars.verify_cell_id) { |
| 615 | /* Skip this verification; either the TC expects no cell id to end up being accepted, or this was |
| 616 | * disabled globally to test an older osmo-msc which doesn't store the cell id properly yet. */ |
| 617 | log("Skipping f_verify_vty_lac_ci()"); |
| 618 | setverdict(pass); |
| 619 | return; |
| 620 | } |
| 621 | |
| 622 | var charstring vty_cmd := "show subscriber imsi " & hex2str(g_pars.imsi) & " conn"; |
| 623 | var charstring result := f_vty_transceive_ret(MSCVTY, vty_cmd); |
| 624 | var charstring expect_lac_ci := "LAC / cell ID: " |
| 625 | & int2str(oct2int(g_pars.cell_id.cellIdentification.cI_CGI.lac)) & " / " |
| 626 | & int2str(oct2int(g_pars.cell_id.cellIdentification.cI_CGI.ci)); |
| 627 | |
| 628 | var boolean vlr_matches := false; |
| 629 | var boolean connection_present := false; |
| 630 | var boolean connection_matches := false; |
| 631 | |
| 632 | /* There are two occurences of LAC / cell ID: once for the VLR record, and once for the active connection. The |
| 633 | * active connection part starts with 'Connection:'. If there is no active connection, that part is omitted. |
| 634 | * So, first find out whether there is a 'Connection:' part. Then verify the LAC / cell ID above 'Connection:' |
| 635 | * and below 'Connection:', separately. |
| 636 | */ |
| 637 | var integer connection_start := f_strstr(result, "Connection:"); |
| 638 | connection_present := (connection_start >= 0); |
| 639 | |
| 640 | var integer lac_ci_match := f_strstr(result, expect_lac_ci); |
| 641 | if (connection_present) { |
| 642 | if (lac_ci_match > connection_start) { |
| 643 | /* The first match is below 'Connection:', so the VLR part above it did not match. */ |
| 644 | vlr_matches := false; |
| 645 | connection_matches := true; |
| 646 | } else if (lac_ci_match >= 0) { |
| 647 | /* The first match is above 'Connection:', so the VLR part matches. */ |
| 648 | vlr_matches := true; |
| 649 | |
| 650 | /* Now find a match below 'Connection:' */ |
| 651 | lac_ci_match := f_strstr(result, expect_lac_ci, connection_start); |
| 652 | connection_matches := (lac_ci_match > 0); |
| 653 | } |
| 654 | } else { |
| 655 | /* There is no 'Connection:', so a match, if any, is from the VLR part. */ |
| 656 | vlr_matches := (lac_ci_match >= 0); |
| 657 | } |
| 658 | |
| 659 | if (verify_vlr) { |
| 660 | if (not vlr_matches) { |
| 661 | setverdict(fail, vty_cmd, " shows mismatching LAC / cell ID in the VLR part, expecting: ", |
| 662 | expect_lac_ci, " -- got: ", result); |
| 663 | return; |
| 664 | } else { |
| 665 | log("f_verify_vty_lac_ci(): VLR record matches ", expect_lac_ci); |
| 666 | setverdict(pass); |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | if (connection_present) { |
| 671 | if (not connection_matches) { |
| 672 | setverdict(fail, vty_cmd, " shows mismatching LAC cell ID in the 'Connection' part, expecting: ", |
| 673 | expect_lac_ci, " -- got: ", result); |
| 674 | } else { |
| 675 | log("f_verify_vty_lac_ci(): Active connection matches ", expect_lac_ci); |
| 676 | setverdict(pass); |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | if (not verify_vlr and not connection_present) { |
| 681 | setverdict(fail, "f_verify_vty_lac_ci(verify_vlr := false) called, which requires an active connection, but there is no 'Connection:' part to verify in ", result); |
| 682 | } |
| 683 | } |
| 684 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 685 | function f_perform_lu() |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 686 | runs on BSC_ConnHdlr { |
| 687 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 688 | var PDU_DTAP_MT dtap_mt; |
| 689 | |
| 690 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 691 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 692 | |
| 693 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 694 | if (g_pars.ran_is_geran) { |
| 695 | f_bssap_compl_l3(l3_lu); |
| 696 | if (g_pars.send_early_cm) { |
| 697 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 698 | } |
| 699 | } else { |
| 700 | f_ranap_initial_ue(l3_lu); |
Harald Welte | 8a121b3 | 2018-01-22 03:00:41 +0100 | [diff] [blame] | 701 | } |
Harald Welte | 5c2622c | 2018-01-21 20:45:20 +0100 | [diff] [blame] | 702 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 703 | /* at this point the conn has been established, but the subscriber has not been authenticated, so the VLR does |
| 704 | * not yet reflect this conn's cell ID. */ |
| 705 | f_verify_vty_lac_ci(verify_vlr := false); |
| 706 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 707 | f_mm_imei_early(); |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 708 | f_mm_common(); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 709 | f_msc_lu_hlr(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 710 | f_mm_imei(); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 711 | f_accept_reject_lu(); |
| 712 | /* FIXME: there could be pending SMS or other common procedures by the MSC, let's ignore them */ |
| 713 | f_expect_clear(); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 714 | |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 715 | setverdict(pass); |
| 716 | } |
| 717 | |
| 718 | function f_msc_lu_hlr() runs on BSC_ConnHdlr |
| 719 | { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 720 | /* Expect MSC to perform LU with HLR */ |
| 721 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 722 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 723 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 724 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | function f_accept_reject_lu() runs on BSC_ConnHdlr { |
| 728 | var PDU_DTAP_MT dtap_mt; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 729 | |
| 730 | alt { |
| 731 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) -> value dtap_mt { |
| 732 | var PDU_ML3_LocationUpdateAccept lu_acc := dtap_mt.dtap.msgs.mm.locationUpdateAccept; |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 733 | if (g_pars.net.expect_tmsi) { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 734 | if (not ispresent(lu_acc.mobileIdentityTLV) or |
| 735 | not ischosen(lu_acc.mobileIdentityTLV.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi)) { |
| 736 | setverdict(fail, "Expected TMSI but no TMSI was allocated"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 737 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 738 | } else { |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 739 | g_pars.tmsi := lu_acc.mobileIdentityTLV.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi.octets; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 740 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 741 | } |
| 742 | } else { |
| 743 | if (ispresent(lu_acc.mobileIdentityTLV) and |
| 744 | ischosen(lu_acc.mobileIdentityTLV.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi)) { |
| 745 | setverdict(fail, "Expected no TMSI but TMSI was allocated"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 746 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 747 | } |
| 748 | } |
| 749 | } |
| 750 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 751 | setverdict(fail, "Expected LU ACK, but received LU REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 752 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 753 | } |
| 754 | } |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 755 | |
| 756 | /* Wait for MM-Information (if enabled) */ |
| 757 | f_expect_mm_info(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 758 | setverdict(pass); |
| 759 | } |
| 760 | |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 761 | function f_expect_lu_reject(template OCT1 cause := ?) runs on BSC_ConnHdlr { |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 762 | var PDU_DTAP_MT dtap_mt; |
| 763 | timer T := 5.0; |
| 764 | |
| 765 | T.start; |
| 766 | alt { |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 767 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej(cause))) { |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 768 | setverdict(pass); |
| 769 | } |
| 770 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) -> value dtap_mt { |
| 771 | setverdict(fail, "Expected LU reject BSSAP message, got: ", dtap_mt); |
| 772 | } |
| 773 | [] T.timeout { |
| 774 | setverdict(fail, "Timeout waiting for LU reject"); |
| 775 | } |
| 776 | } |
| 777 | } |
| 778 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 779 | function f_foo() runs on BSC_ConnHdlr{ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 780 | /* SCCP CC handled by RAN_Emulation_CT.main() */ |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 781 | /* Expect auth, if enabled */ |
| 782 | |
| 783 | /* TODO: ISD */ |
| 784 | /* Expect encr, if enabled */ |
| 785 | /* Expect encr, if enabled */ |
| 786 | /* Expect ASS CMD, if chan_type != requested */ |
| 787 | /* Send ASS CMPL in successful case */ |
| 788 | |
| 789 | /* Expect AoIP port/ip information for RTP stream */ |
| 790 | /* Expect MSC-originated MGCP to our simulated MGW */ |
| 791 | /* Verify Counters via CTRL */ |
| 792 | /* re-configure MSC behaviour via VTY */ |
| 793 | } |
| 794 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 795 | type record CrcxResponse { |
| 796 | integer resp, /* 1 = reply with OK, 0 = do not reply, -1 = reply with error */ |
| 797 | HostName mgw_rtp_ip, |
| 798 | PortNumber mgw_rtp_port, |
| 799 | MgcpConnectionId mgcp_connection_id /* MGCP Connection ID BSS Side */ |
| 800 | } |
| 801 | |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 802 | /* parameters related to a (MO?) voice call */ |
| 803 | type record CallParameters { |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 804 | /* CC related parameters */ |
| 805 | hexstring called_party, /* whom are we calling */ |
| 806 | integer transaction_id optional, /* which TS 04.08 CC transaction ID to use */ |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 807 | boolean mo_call, /* For a MO call, the transaction_id was allocated by the MS, |
| 808 | important to set the TI flag properly */ |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 809 | BearerCapability_TLV bearer_cap, /* which bearer capabilities to claim */ |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 810 | boolean emergency, /* is this an emergency call? */ |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 811 | |
| 812 | /* MNCC related parameters */ |
| 813 | uint32_t mncc_callref optional, /* call reference on the MNCC side */ |
| 814 | MNCC_bearer_cap mncc_bearer_cap optional, /* MNCC-side bearer capabilities */ |
| 815 | |
| 816 | /* RTP related parameters */ |
| 817 | HostName bss_rtp_ip optional, /* BSS Side RTP IP */ |
| 818 | PortNumber bss_rtp_port optional, /* BSS Side RTP Port */ |
| 819 | HostName mss_rtp_ip optional, /* MSS Side RTP IP */ |
| 820 | PortNumber mss_rtp_port optional, /* MSS Side RTP Port */ |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 821 | integer got_crcx_count, |
| 822 | CrcxResponse mgw_conn_1, |
| 823 | CrcxResponse mgw_conn_2, |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 824 | uint7_t rtp_payload_type, /* dynamic RTP payload type */ |
| 825 | charstring rtp_sdp_format, /* AMR/8000 or the like */ |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 826 | boolean mgw_drop_dlcx optional, /* Provoke errors by not responding to DLCX |
| 827 | (f_mt_call and f_mt_call) */ |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 828 | boolean stop_after_cc_setup, /* Special case: stop call establish after CC Setup */ |
| 829 | boolean ran_clear_when_alerting, /* Special case: send Clear upon CC Alerting */ |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 830 | boolean expect_release, /* Special case: expect call establish to cause direct CC Rel */ |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 831 | |
Philipp Maier | cd66857 | 2018-03-19 16:11:52 +0100 | [diff] [blame] | 832 | MgcpCallId mgcp_call_id optional, /* MGCP Call ID; CallAgent allocated */ |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 833 | MgcpEndpoint mgcp_ep optional /* MGCP Endpoint, CallAgent or MGW allocated */, |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 834 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 835 | boolean use_osmux, /* MSC is expected to use Osmux for this call */ |
| 836 | integer got_osmux_count |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 837 | } |
| 838 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 839 | template (value) CallParameters t_CallParams(hexstring called := '12345'H, integer tid := 0) := { |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 840 | called_party := called, |
| 841 | transaction_id := tid, |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 842 | mo_call := false, |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 843 | bearer_cap := valueof(ts_Bcap_voice), |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 844 | emergency := false, |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 845 | mncc_callref := omit, |
| 846 | mncc_bearer_cap := valueof(ts_MNCC_bcap_voice), |
Harald Welte | 4017d55 | 2018-01-26 21:40:05 +0100 | [diff] [blame] | 847 | bss_rtp_ip := "9.8.7.6", |
| 848 | bss_rtp_port := 9000, |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 849 | mss_rtp_ip := omit, |
| 850 | mss_rtp_port := omit, |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 851 | got_crcx_count := 0, |
| 852 | mgw_conn_1 := { |
| 853 | resp := 1, |
| 854 | mgw_rtp_ip := "1.1.1.1", |
| 855 | mgw_rtp_port := 10000, |
| 856 | mgcp_connection_id := '11111'H |
| 857 | }, |
| 858 | mgw_conn_2 := { |
| 859 | resp := 1, |
| 860 | mgw_rtp_ip := "1.1.1.1", |
| 861 | mgw_rtp_port := 11000, |
| 862 | mgcp_connection_id := '22222'H |
| 863 | }, |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 864 | rtp_payload_type := 98, |
| 865 | rtp_sdp_format := "AMR/8000", |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 866 | mgw_drop_dlcx := false, |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 867 | stop_after_cc_setup := false, |
| 868 | ran_clear_when_alerting := false, |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 869 | expect_release := false, |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 870 | mgcp_call_id := omit, |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 871 | mgcp_ep := "rtpbridge/1@mgw", |
| 872 | use_osmux := false, |
| 873 | got_osmux_count := 0 |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 874 | }; |
| 875 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 876 | /* Allocate a call reference and send SETUP via MNCC to MSC */ |
| 877 | function f_mt_call_initate(inout CallParameters cpars) |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 878 | runs on BSC_ConnHdlr { |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 879 | cpars.mo_call := false; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 880 | cpars.mncc_callref := f_rnd_int(2147483648); |
| 881 | MNCC.send(ts_MNCC_SETUP_req(cpars.mncc_callref, hex2str(g_pars.msisdn), |
| 882 | hex2str(cpars.called_party), hex2str(g_pars.imsi))); |
| 883 | } |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 884 | |
Harald Welte | 408a7ef | 2019-04-21 17:08:40 +0200 | [diff] [blame] | 885 | private template (value) SDP_Message ts_SDP_CRCX_CN(CallParameters cpars) := |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 886 | ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip, |
Harald Welte | 408a7ef | 2019-04-21 17:08:40 +0200 | [diff] [blame] | 887 | hex2str(cpars.mgcp_call_id), "42", |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 888 | cpars.mgw_conn_2.mgw_rtp_port, |
Harald Welte | 408a7ef | 2019-04-21 17:08:40 +0200 | [diff] [blame] | 889 | { int2str(cpars.rtp_payload_type) }, |
| 890 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 891 | cpars.rtp_sdp_format)), |
| 892 | valueof(ts_SDP_ptime(20)) }); |
| 893 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 894 | /* Complete call, begin with a paging response message via BSSAP */ |
| 895 | function f_mt_call_complete(inout CallParameters cpars) |
| 896 | runs on BSC_ConnHdlr { |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 897 | var MNCC_PDU mncc; |
| 898 | var MgcpCommand mgcp_cmd; |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 899 | var template MgcpResponse mgcp_resp; |
| 900 | var MgcpOsmuxCID osmux_cid; |
| 901 | var PDU_BSSAP bssap; |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 902 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 903 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 904 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 905 | f_establish_fully(EST_TYPE_PAG_RESP); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 906 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 907 | log("f_mt_call_complete 1"); |
| 908 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 909 | cpars.got_osmux_count := 0; |
| 910 | |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 911 | /* MS <- MSC: Expect CC SETUP */ |
| 912 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))); |
| 913 | |
| 914 | /* MS -> MSC: ALERTING */ |
| 915 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_ALERTING(cpars.transaction_id))); |
| 916 | MNCC.receive(tr_MNCC_ALERT_ind(cpars.mncc_callref)); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 917 | log("f_mt_call_complete 2"); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 918 | |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 919 | /* Create MGCP expect */ |
| 920 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 921 | /* Ask MSC via MNCC to create the RTP socket on the MSC/MGW side */ |
| 922 | MNCC.send(ts_MNCC_RTP_CREATE(cpars.mncc_callref)); |
| 923 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 924 | /* First MGCP CRCX */ |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 925 | MGCP.receive(tr_CRCX) -> value mgcp_cmd { |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 926 | log("f_mt_call_complete 3"); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 927 | if (not f_handle_crcx(cpars, mgcp_cmd)) { |
| 928 | return; |
Philipp Maier | 4b2692d | 2018-03-14 16:37:48 +0100 | [diff] [blame] | 929 | } |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 930 | } |
Neels Hofmeyr | 59e0c6f | 2019-03-06 15:21:20 +0100 | [diff] [blame] | 931 | |
Neels Hofmeyr | 59e0c6f | 2019-03-06 15:21:20 +0100 | [diff] [blame] | 932 | |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 933 | if (g_pars.ran_is_geran) { |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 934 | var template BSSMAP_IE_AoIP_TransportLayerAddress tla_ass := |
| 935 | tr_BSSMAP_IE_AoIP_TLA4(f_inet_addr(cpars.mgw_conn_1.mgw_rtp_ip), ?); |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 936 | |
| 937 | interleave { |
| 938 | /* Second MGCP CRCX (this time for MSS/CN side) */ |
| 939 | [] MGCP.receive(tr_CRCX(cpars.mgcp_ep)) -> value mgcp_cmd { |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 940 | log("f_mt_call_complete 4"); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 941 | if (not f_handle_crcx(cpars, mgcp_cmd)) { |
| 942 | break; |
| 943 | } |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 944 | } |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 945 | |
| 946 | /* MSC acknowledges the MNCC_CREATE to the MNCC handler */ |
| 947 | [] MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)) { |
| 948 | log("f_mt_call_complete 5"); |
| 949 | } |
| 950 | |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 951 | /* expect the MSC to trigger a BSSMAP ASSIGNMENT */ |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 952 | [] BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, tla_ass)) -> value bssap { |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 953 | var template BSSMAP_IE_AoIP_TransportLayerAddress tla; |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 954 | var BSSMAP_IE_SpeechCodec codec; |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 955 | var BSSMAP_IE_Osmo_OsmuxCID osmuxCID; |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 956 | log("f_mt_call_complete 6"); |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 957 | |
| 958 | tla := valueof(ts_BSSMAP_IE_AoIP_TLA4(f_inet_addr(cpars.bss_rtp_ip), cpars.bss_rtp_port)); |
| 959 | codec := valueof(ts_BSSMAP_IE_SpeechCodec({ts_CodecFR})); |
| 960 | |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 961 | if (cpars.use_osmux) { |
| 962 | if (not ispresent(bssap.pdu.bssmap.assignmentRequest.osmuxCID)) { |
| 963 | setverdict(fail, "MSC sent AssignReq without expected OsmuxCID IE"); |
| 964 | mtc.stop; |
| 965 | } |
| 966 | osmuxCID := valueof(ts_OsmuxCID(0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 967 | if (not match(bssap.pdu.bssmap.assignmentRequest.osmuxCID, osmuxCID)) { |
| 968 | setverdict(fail, "MSC sent AssignReq without expected OsmuxCID IE. Expected ", osmuxCID, " Got ", bssap.pdu.bssmap.assignmentRequest.osmuxCID); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 969 | mtc.stop; |
| 970 | } |
| 971 | bssap := valueof(ts_BSSMAP_AssignmentComplete(omit, tla, codec, osmuxCID)); |
| 972 | } else { |
| 973 | bssap := valueof(ts_BSSMAP_AssignmentComplete(omit, tla, codec)); |
| 974 | } |
| 975 | BSSAP.send(bssap); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 976 | |
| 977 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CONNECT(cpars.transaction_id))); |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 978 | } |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 979 | |
| 980 | [] MNCC.receive(tr_MNCC_SETUP_cnf(cpars.mncc_callref)) { |
| 981 | log("f_mt_call_complete 7"); |
| 982 | MNCC.send(ts_MNCC_RTP_CONNECT(cpars.mncc_callref, |
| 983 | /* ip 42.23.11.5 */ hex2int('42231105'H), |
| 984 | /* port 423 */ 423, |
| 985 | /* payload type 3 = GSM FR */ 3)); |
| 986 | } |
| 987 | |
| 988 | /* MDCX setting up the RAN side remote RTP address received from Assignment Complete */ |
| 989 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
| 990 | log("f_mt_call_complete 8"); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 991 | var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip, |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 992 | hex2str(cpars.mgcp_call_id), "42", |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 993 | cpars.mgw_conn_2.mgw_rtp_port, |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 994 | { int2str(cpars.rtp_payload_type) }, |
| 995 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 996 | cpars.rtp_sdp_format)), |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 997 | valueof(ts_SDP_ptime(20)) })); |
| 998 | if (cpars.use_osmux) { |
| 999 | osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd); |
| 1000 | if (osmux_cid != 0) { /* we expect MSC to use specific CID here */ |
| 1001 | setverdict(fail, "MSC using unexpected CID " & int2str(osmux_cid) & " != 0"); |
| 1002 | mtc.stop; |
| 1003 | } |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1004 | mgcp_resp := ts_MDCX_ACK_osmux(mgcp_cmd.line.trans_id, cpars.mgw_conn_1.mgcp_connection_id, osmux_cid, sdp); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1005 | } else { |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1006 | mgcp_resp := ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_2.mgcp_connection_id, sdp); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1007 | } |
| 1008 | MGCP.send(mgcp_resp); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1009 | } |
| 1010 | |
| 1011 | /* MDCX setting up the CN side remote RTP address received from MNCC CONNECT */ |
| 1012 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
| 1013 | log("f_mt_call_complete 9"); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1014 | var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip, |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1015 | hex2str(cpars.mgcp_call_id), "42", |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1016 | cpars.mgw_conn_2.mgw_rtp_port, |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1017 | { int2str(cpars.rtp_payload_type) }, |
| 1018 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 1019 | cpars.rtp_sdp_format)), |
| 1020 | valueof(ts_SDP_ptime(20)) })); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1021 | MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_2.mgcp_connection_id, sdp)); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1022 | } |
| 1023 | |
Neels Hofmeyr | 59e0c6f | 2019-03-06 15:21:20 +0100 | [diff] [blame] | 1024 | } |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1025 | } else { |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1026 | interleave { |
| 1027 | [] MGCP.receive(tr_CRCX(cpars.mgcp_ep)) -> value mgcp_cmd { |
Neels Hofmeyr | 8fe8a90 | 2019-11-03 05:51:03 +0100 | [diff] [blame] | 1028 | log("f_mt_call_complete 4.iu"); |
| 1029 | if (not f_handle_crcx(cpars, mgcp_cmd)) { |
| 1030 | break; |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1031 | } |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1032 | } |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1033 | |
Neels Hofmeyr | 8fe8a90 | 2019-11-03 05:51:03 +0100 | [diff] [blame] | 1034 | /* MSC acknowledges the MNCC_CREATE to the MNCC handler */ |
| 1035 | [] MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)) { |
| 1036 | log("f_mt_call_complete 5.iu"); |
| 1037 | } |
| 1038 | |
| 1039 | [] BSSAP.receive(tr_RANAP_RabAssReq(?)) { |
| 1040 | log("f_mt_call_complete 6.iu"); |
| 1041 | var RAB_SetupOrModifiedList l := { |
| 1042 | { |
| 1043 | { |
| 1044 | id := id_RAB_SetupOrModifiedItem, |
| 1045 | criticality := ignore, |
| 1046 | value_ := { |
| 1047 | rAB_SetupOrModifiedItem := { |
| 1048 | rAB_ID := int2bit(23, 8), |
| 1049 | transportLayerAddress := hex2bit( '350001c0a8021500000000000000000000000000'H), |
| 1050 | iuTransportAssociation := { |
| 1051 | bindingID := '040c0000'O |
| 1052 | }, |
| 1053 | dl_dataVolumes := omit, |
| 1054 | iE_Extensions := omit |
| 1055 | } |
| 1056 | } |
| 1057 | } |
| 1058 | } |
| 1059 | }; |
| 1060 | BSSAP.send(ts_RANAP_RabAssResp(l)); |
| 1061 | |
| 1062 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CONNECT(cpars.transaction_id))); |
| 1063 | } |
| 1064 | |
| 1065 | [] MNCC.receive(tr_MNCC_SETUP_cnf(cpars.mncc_callref)) { |
| 1066 | log("f_mt_call_complete 7.iu"); |
| 1067 | MNCC.send(ts_MNCC_RTP_CONNECT(cpars.mncc_callref, |
| 1068 | /* ip 42.23.11.5 */ hex2int('42231105'H), |
| 1069 | /* port 423 */ 423, |
| 1070 | /* payload type 3 = GSM FR */ 3)); |
| 1071 | } |
| 1072 | |
| 1073 | /* MDCX setting up the RAN side remote RTP address received from Assignment Complete */ |
| 1074 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
| 1075 | log("f_mt_call_complete 8.iu"); |
| 1076 | var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip, |
| 1077 | hex2str(cpars.mgcp_call_id), "42", |
| 1078 | cpars.mgw_conn_2.mgw_rtp_port, |
| 1079 | { int2str(cpars.rtp_payload_type) }, |
| 1080 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 1081 | cpars.rtp_sdp_format)), |
| 1082 | valueof(ts_SDP_ptime(20)) })); |
| 1083 | if (cpars.use_osmux) { |
| 1084 | osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd); |
| 1085 | if (osmux_cid != 0) { /* we expect MSC to use specific CID here */ |
| 1086 | setverdict(fail, "MSC using unexpected CID " & int2str(osmux_cid) & " != 0"); |
| 1087 | mtc.stop; |
| 1088 | } |
| 1089 | mgcp_resp := ts_MDCX_ACK_osmux(mgcp_cmd.line.trans_id, cpars.mgw_conn_1.mgcp_connection_id, osmux_cid, sdp); |
| 1090 | } else { |
| 1091 | mgcp_resp := ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_2.mgcp_connection_id, sdp); |
| 1092 | } |
| 1093 | MGCP.send(mgcp_resp); |
| 1094 | } |
| 1095 | |
| 1096 | /* MDCX setting up the CN side remote RTP address received from MNCC CONNECT */ |
| 1097 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
| 1098 | log("f_mt_call_complete 9.iu"); |
| 1099 | var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip, |
| 1100 | hex2str(cpars.mgcp_call_id), "42", |
| 1101 | cpars.mgw_conn_2.mgw_rtp_port, |
| 1102 | { int2str(cpars.rtp_payload_type) }, |
| 1103 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 1104 | cpars.rtp_sdp_format)), |
| 1105 | valueof(ts_SDP_ptime(20)) })); |
| 1106 | MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_2.mgcp_connection_id, sdp)); |
| 1107 | } |
| 1108 | |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1109 | } |
Neels Hofmeyr | 59e0c6f | 2019-03-06 15:21:20 +0100 | [diff] [blame] | 1110 | } |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1111 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1112 | if (cpars.use_osmux == (cpars.got_osmux_count != 0)) { |
| 1113 | log("Osmux ok: use_osmux = ", cpars.use_osmux, " got_osmux_count = ", cpars.got_osmux_count); |
| 1114 | } else { |
| 1115 | setverdict(fail, "Osmux failure: use_osmux = ", cpars.use_osmux, " got_osmux_count = ", cpars.got_osmux_count); |
| 1116 | mtc.stop; |
| 1117 | } |
| 1118 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1119 | log("f_mt_call_complete DONE"); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 1120 | } |
| 1121 | |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 1122 | function f_expect_paging(boolean by_tmsi := true) |
| 1123 | runs on BSC_ConnHdlr { |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1124 | if (g_pars.ran_is_geran) { |
| 1125 | BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); |
| 1126 | } else { |
Harald Welte | 62113fc | 2019-05-09 13:04:02 +0200 | [diff] [blame] | 1127 | BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))); |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1128 | } |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 1129 | } |
| 1130 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 1131 | function f_mt_call_establish(inout CallParameters cpars) |
| 1132 | runs on BSC_ConnHdlr { |
| 1133 | |
| 1134 | /* Initiate the call via MNCC */ |
| 1135 | f_mt_call_initate(cpars); |
| 1136 | |
| 1137 | /* BSC <- MSC: Expect paging. FIXME: By TMSI or not? */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1138 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 1139 | f_expect_paging() |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 1140 | |
| 1141 | /* Complete the call via BSSAP */ |
| 1142 | f_mt_call_complete(cpars); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1143 | |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1144 | setverdict(pass); |
| 1145 | } |
| 1146 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1147 | /* Reply to a received CRCX with an OK (or the reply configured in cpars), using the given parameters. |
| 1148 | * Return true when an OK reply was sent, false otherwise. |
| 1149 | * Count occurence of Osmux, include Osmux parameters in the reply if necessary. */ |
| 1150 | function f_handle_crcx(inout CallParameters cpars, MgcpCommand mgcp_cmd) |
| 1151 | runs on BSC_ConnHdlr |
| 1152 | return boolean { |
| 1153 | var CrcxResponse conn := cpars.mgw_conn_1; |
| 1154 | if (cpars.got_crcx_count > 0) { |
| 1155 | conn := cpars.mgw_conn_2; |
| 1156 | } |
| 1157 | cpars.got_crcx_count := cpars.got_crcx_count + 1; |
| 1158 | |
| 1159 | var MgcpMessage mgcp_msg := { |
| 1160 | command := mgcp_cmd |
| 1161 | } |
| 1162 | var template MgcpResponse mgcp_resp; |
| 1163 | var MgcpOsmuxCID osmux_cid; |
| 1164 | var MgcpCallId call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1165 | if (ispresent(cpars.mgcp_call_id)) { |
| 1166 | if (cpars.mgcp_call_id != call_id) { |
| 1167 | setverdict(fail, "CRCX contained unexpected call id. Expected:", cpars.mgcp_call_id, " got:", call_id); |
| 1168 | mtc.stop; |
| 1169 | } |
| 1170 | } else { |
| 1171 | cpars.mgcp_call_id := call_id; |
| 1172 | } |
| 1173 | |
| 1174 | /* When the endpoint contains a wildcard we keep the endpoint |
| 1175 | * identifier we have set up in cpars. Otherwise we use the |
| 1176 | * endpoint name that the call agent has supplied */ |
| 1177 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard) == false) { |
| 1178 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1179 | } |
| 1180 | |
| 1181 | if (conn.resp == -1) { |
| 1182 | /* Reply with error */ |
| 1183 | var MgcpResponse mgcp_rsp := { |
| 1184 | line := { |
| 1185 | code := "542", |
| 1186 | trans_id := mgcp_cmd.line.trans_id, |
| 1187 | string := "FORCED_FAIL" |
| 1188 | }, |
| 1189 | sdp := omit |
| 1190 | |
| 1191 | } |
| 1192 | var MgcpParameter mgcp_rsp_param := { |
| 1193 | code := "Z", |
| 1194 | val := cpars.mgcp_ep |
| 1195 | }; |
| 1196 | mgcp_rsp.params[0] := mgcp_rsp_param; |
| 1197 | MGCP.send(mgcp_rsp); |
| 1198 | return false; |
| 1199 | } |
| 1200 | |
| 1201 | if (conn.resp == 0) { |
| 1202 | /* Do not reply at all */ |
| 1203 | return false; |
| 1204 | } |
| 1205 | |
| 1206 | if (conn.resp != 1) { |
| 1207 | setverdict(fail, "Unexpected value for cpars.mgw_conn_*.resp, expect -1, 0 or 1"); |
| 1208 | mtc.stop; |
| 1209 | } |
| 1210 | |
| 1211 | var SDP_Message sdp := valueof(ts_SDP(conn.mgw_rtp_ip, conn.mgw_rtp_ip, |
| 1212 | hex2str(cpars.mgcp_call_id), "42", |
| 1213 | conn.mgw_rtp_port, |
| 1214 | { int2str(cpars.rtp_payload_type) }, |
| 1215 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 1216 | cpars.rtp_sdp_format)), |
| 1217 | valueof(ts_SDP_ptime(20)) })); |
| 1218 | |
| 1219 | if (f_mgcp_contains_par(mgcp_msg, "X-OSMUX")) { |
| 1220 | if (not cpars.use_osmux) { |
| 1221 | setverdict(fail, "MSC sent X-Osmux parameter in MGCP, but not expecting any Osmux"); |
| 1222 | mtc.stop; |
| 1223 | } |
| 1224 | cpars.got_osmux_count := cpars.got_osmux_count + 1; |
| 1225 | /* we expect MSC to use wildcard here, i.e. osmux_cid == -1 */ |
| 1226 | osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd); |
| 1227 | log("f_handle_crcx(): got Osmux CID: ", osmux_cid); |
| 1228 | if (osmux_cid != -1) { |
| 1229 | setverdict(fail, "MSC using unexpected CID " & int2str(osmux_cid) & " != -1"); |
| 1230 | mtc.stop; |
| 1231 | } |
| 1232 | |
| 1233 | osmux_cid := 0; |
| 1234 | mgcp_resp := ts_CRCX_ACK_osmux(mgcp_cmd.line.trans_id, conn.mgcp_connection_id, osmux_cid, sdp); |
| 1235 | } else { |
| 1236 | mgcp_resp := ts_CRCX_ACK(mgcp_cmd.line.trans_id, conn.mgcp_connection_id, sdp); |
| 1237 | } |
| 1238 | |
| 1239 | f_mgcp_par_append(mgcp_resp.params, ts_MgcpParSpecEP(cpars.mgcp_ep)); |
| 1240 | MGCP.send(mgcp_resp); |
| 1241 | return true; |
| 1242 | } |
| 1243 | |
| 1244 | |
| 1245 | altstep as_optional_mgcp_crcx(CallParameters cpars) runs on BSC_ConnHdlr { |
| 1246 | var MgcpCommand mgcp_cmd; |
| 1247 | [] MGCP.receive(tr_CRCX) -> value mgcp_cmd { |
| 1248 | log("as_optional_mgcp_crcx: rx CRCX"); |
| 1249 | f_handle_crcx(cpars, mgcp_cmd); |
| 1250 | |
| 1251 | /* Without this 'repeat', the as_optional_mgcp_crcx() exits currently waiting interleaves as soon as an |
| 1252 | * CRCX is handled. */ |
| 1253 | repeat; |
| 1254 | } |
| 1255 | } |
| 1256 | |
| 1257 | private altstep as_optional_mgcp_mdcx(HostName mgw_rtp_ip, PortNumber mgw_rtp_port) runs on BSC_ConnHdlr { |
| 1258 | var MgcpCommand mgcp_cmd; |
| 1259 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
| 1260 | log("as_optional_mgcp_mdcx: rx MDCX"); |
| 1261 | log(mgcp_cmd); |
| 1262 | var charstring conn_id; |
| 1263 | var charstring rtp_payload_type; |
| 1264 | f_mgcp_find_param_entry(mgcp_cmd.params, "I", conn_id); |
| 1265 | rtp_payload_type := mgcp_cmd.sdp.media_list[0].media_field.fmts[0]; |
| 1266 | |
| 1267 | var SDP_Message sdp := valueof(ts_SDP(mgw_rtp_ip, mgw_rtp_ip, |
| 1268 | mgcp_cmd.sdp.origin.session_id, "42", |
| 1269 | mgw_rtp_port, |
| 1270 | { rtp_payload_type }, |
| 1271 | { valueof(ts_SDP_ptime(20)) })); |
| 1272 | MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, str2hex(conn_id), sdp)); |
| 1273 | |
| 1274 | /* Without this 'repeat', currently active other interleave and alt series exit as soon as an MDCX is |
| 1275 | * handled. */ |
| 1276 | repeat; |
| 1277 | } |
| 1278 | } |
| 1279 | |
Neels Hofmeyr | 0b16bf1 | 2019-11-03 05:10:12 +0100 | [diff] [blame] | 1280 | private altstep as_optional_mgcp_dlcx(CallParameters cpars) runs on BSC_ConnHdlr { |
| 1281 | var MgcpCommand mgcp_cmd; |
| 1282 | var boolean respond_to_dlcx := not (isbound(cpars.mgw_drop_dlcx) and valueof(cpars.mgw_drop_dlcx)); |
| 1283 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1284 | log("as_optional_mgcp_dlcx: rx MGCP DLCX"); |
| 1285 | if (respond_to_dlcx) { |
| 1286 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1287 | } |
| 1288 | /* Without this 'repeat', currently active other interleave and alt series exit as soon as a |
| 1289 | * DLCX is handled. */ |
| 1290 | repeat; |
| 1291 | } |
| 1292 | } |
| 1293 | |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1294 | function f_mo_call_establish(inout CallParameters cpars) |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1295 | runs on BSC_ConnHdlr { |
| 1296 | |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1297 | var MNCC_PDU mncc; |
| 1298 | var MgcpCommand mgcp_cmd; |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1299 | var template MgcpResponse mgcp_resp; |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 1300 | var boolean respond_to_dlcx; |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1301 | var PDU_BSSAP bssap; |
Neels Hofmeyr | 0b16bf1 | 2019-11-03 05:10:12 +0100 | [diff] [blame] | 1302 | var RANAP_PDU ranap; |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1303 | var MgcpOsmuxCID osmux_cid; |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1304 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1305 | cpars.mo_call := true; |
| 1306 | |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1307 | if (cpars.emergency) { |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1308 | f_establish_fully(EST_TYPE_EMERG_CALL); |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1309 | } else { |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1310 | f_establish_fully(EST_TYPE_MO_CALL); |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1311 | } |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1312 | |
| 1313 | /* Create MNCC and MGCP expect */ |
| 1314 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1315 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1316 | |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1317 | if (cpars.emergency) { |
| 1318 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_EMERG_SETUP(cpars.transaction_id))); |
| 1319 | } else { |
| 1320 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1321 | } |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1322 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1323 | if (cpars.stop_after_cc_setup) { |
| 1324 | return; |
| 1325 | } |
| 1326 | |
| 1327 | var template BSSMAP_IE_AoIP_TransportLayerAddress tla_ass := |
| 1328 | tr_BSSMAP_IE_AoIP_TLA4(f_inet_addr(cpars.mgw_conn_1.mgw_rtp_ip), ?); |
| 1329 | |
| 1330 | var default mdcx := activate(as_optional_mgcp_mdcx(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_port)); |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 1331 | var boolean got_mncc_setup_compl_ind := false; |
| 1332 | var boolean got_cc_connect := false; |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1333 | |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1334 | interleave { |
| 1335 | [] MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc { |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1336 | log("f_mo_call_establish 1: rx MNCC SETUP ind"); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1337 | cpars.mncc_callref := mncc.u.signal.callref; |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1338 | MNCC.send(ts_MNCC_RTP_CREATE(cpars.mncc_callref)); |
| 1339 | } |
| 1340 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1341 | /* First MGCP CRCX */ |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1342 | [] MGCP.receive(tr_CRCX) -> value mgcp_cmd { |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1343 | log("f_mo_call_establish 2: rx 1st CRCX"); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1344 | if (not f_handle_crcx(cpars, mgcp_cmd)) { |
| 1345 | break; |
| 1346 | } |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1347 | } |
| 1348 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1349 | /* Second MGCP CRCX */ |
| 1350 | [] MGCP.receive(tr_CRCX(cpars.mgcp_ep)) -> value mgcp_cmd { |
| 1351 | log("f_mo_call_establish 6: rx 2nd CRCX"); |
| 1352 | if (not f_handle_crcx(cpars, mgcp_cmd)) { |
| 1353 | break; |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1354 | } |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1355 | } |
Neels Hofmeyr | 59e0c6f | 2019-03-06 15:21:20 +0100 | [diff] [blame] | 1356 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1357 | [] MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)) { |
| 1358 | log("f_mo_call_establish 3: rx RTP CREATE"); |
| 1359 | /* Call Proceeding */ |
| 1360 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 1361 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1362 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1363 | /* Alerting */ |
| 1364 | MNCC.send(ts_MNCC_ALERT_req(cpars.mncc_callref)); |
Neels Hofmeyr | 59e0c6f | 2019-03-06 15:21:20 +0100 | [diff] [blame] | 1365 | } |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1366 | |
Neels Hofmeyr | eccaa99 | 2019-10-15 16:42:21 +0200 | [diff] [blame] | 1367 | //[g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, tla_ass)) -> value bssap |
Neels Hofmeyr | d9d835d | 2019-09-17 18:19:08 +0200 | [diff] [blame] | 1368 | [] BSSAP.receive(tr_BSSMAP_AssignmentReq(omit)) -> value bssap { |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1369 | log("f_mo_call_establish 4: rx Assignment Request"); |
| 1370 | var BSSMAP_IE_AoIP_TransportLayerAddress tla; |
| 1371 | var BSSMAP_IE_SpeechCodec codec; |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1372 | var BSSMAP_IE_Osmo_OsmuxCID osmuxCID; |
| 1373 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1374 | if (not match(bssap.pdu.bssmap.assignmentRequest.aoIPTransportLayer, tla_ass)) { |
Neels Hofmeyr | d9d835d | 2019-09-17 18:19:08 +0200 | [diff] [blame] | 1375 | log("Expected:", tla_ass); |
| 1376 | log("Got:", bssap.pdu.bssmap.assignmentRequest.aoIPTransportLayer); |
| 1377 | setverdict(fail, "MSC sent Assignment Request with unexpected AoIP Transport Layer IE"); |
| 1378 | mtc.stop; |
| 1379 | } |
| 1380 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1381 | tla := valueof(ts_BSSMAP_IE_AoIP_TLA4(f_inet_addr(cpars.bss_rtp_ip), cpars.bss_rtp_port)); |
| 1382 | codec := valueof(ts_BSSMAP_IE_SpeechCodec({ts_CodecFR})); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1383 | if (cpars.use_osmux) { |
| 1384 | if (not ispresent(bssap.pdu.bssmap.assignmentRequest.osmuxCID)) { |
| 1385 | setverdict(fail, "MSC sent AssignReq without expected OsmuxCID IE"); |
| 1386 | mtc.stop; |
| 1387 | } |
| 1388 | osmuxCID := valueof(ts_OsmuxCID(0)); |
| 1389 | if (cpars.use_osmux and not match(bssap.pdu.bssmap.assignmentRequest.osmuxCID, osmuxCID)) { |
| 1390 | setverdict(fail, "MSC sent AssignReq without expected OsmuxCID IE"); |
| 1391 | mtc.stop; |
| 1392 | } |
| 1393 | bssap := valueof(ts_BSSMAP_AssignmentComplete(omit, tla, codec, osmuxCID)); |
| 1394 | } else { |
| 1395 | bssap := valueof(ts_BSSMAP_AssignmentComplete(omit, tla, codec)); |
| 1396 | } |
| 1397 | BSSAP.send(bssap); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1398 | } |
Neels Hofmeyr | 0b16bf1 | 2019-11-03 05:10:12 +0100 | [diff] [blame] | 1399 | [] BSSAP.receive(tr_RANAP_RabAssReq(*)) -> value ranap { |
| 1400 | log("f_mo_call_establish 4.iu: rx RANAP RAB Assignment Request"); |
| 1401 | var RAB_SetupOrModifiedList l := { |
| 1402 | { |
| 1403 | { |
| 1404 | id := id_RAB_SetupOrModifiedItem, |
| 1405 | criticality := ignore, |
| 1406 | value_ := { |
| 1407 | rAB_SetupOrModifiedItem := { |
| 1408 | rAB_ID := int2bit(23, 8), |
| 1409 | transportLayerAddress := hex2bit( '350001c0a8021500000000000000000000000000'H), |
| 1410 | iuTransportAssociation := { |
| 1411 | bindingID := '040c0000'O |
| 1412 | }, |
| 1413 | dl_dataVolumes := omit, |
| 1414 | iE_Extensions := omit |
| 1415 | } |
| 1416 | } |
| 1417 | } |
| 1418 | } |
| 1419 | }; |
| 1420 | BSSAP.send(ts_RANAP_RabAssResp(l)); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1421 | } |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1422 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1423 | /* MDCX setting up the RAN side remote RTP address received from Assignment Complete */ |
| 1424 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
| 1425 | log("f_mo_call_establish 5: rx MDCX for the RAN side"); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1426 | var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip, |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1427 | hex2str(cpars.mgcp_call_id), "42", |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1428 | cpars.mgw_conn_2.mgw_rtp_port, |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1429 | { int2str(cpars.rtp_payload_type) }, |
| 1430 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 1431 | cpars.rtp_sdp_format)), |
| 1432 | valueof(ts_SDP_ptime(20)) })); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1433 | |
| 1434 | if (cpars.use_osmux) { |
| 1435 | osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd); |
| 1436 | if (osmux_cid != 0) { /* we expect MSC to use specific CID here */ |
| 1437 | setverdict(fail, "MSC using unexpected CID " & int2str(osmux_cid) & " != 0"); |
| 1438 | mtc.stop; |
| 1439 | } |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1440 | mgcp_resp := ts_MDCX_ACK_osmux(mgcp_cmd.line.trans_id, cpars.mgw_conn_1.mgcp_connection_id, osmux_cid, sdp); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1441 | } else { |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1442 | mgcp_resp := ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_2.mgcp_connection_id, sdp); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1443 | } |
| 1444 | MGCP.send(mgcp_resp); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1445 | } |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1446 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1447 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_ALERTING(cpars.transaction_id))) { |
| 1448 | log("f_mo_call_establish 7: rx CC Alerting"); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1449 | |
| 1450 | if (cpars.ran_clear_when_alerting) { |
| 1451 | if (g_pars.ran_is_geran) { |
| 1452 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 1453 | } else { |
| 1454 | BSSAP.send(ts_RANAP_IuReleaseRequest(ts_RanapCause_om_intervention)); |
| 1455 | } |
| 1456 | break; |
| 1457 | } |
| 1458 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1459 | cpars.mncc_callref := mncc.u.signal.callref; |
| 1460 | /* Call Proceeding */ |
| 1461 | MNCC.send(ts_MNCC_RTP_CONNECT(cpars.mncc_callref, |
| 1462 | /* ip 42.23.11.5 */ hex2int('42231105'H), |
| 1463 | /* port 423 */ 423, |
| 1464 | /* payload type 3 = GSM FR */ 3)); |
| 1465 | MNCC.send(ts_MNCC_SETUP_rsp(cpars.mncc_callref)); |
| 1466 | } |
| 1467 | |
| 1468 | [] MNCC.receive(tr_MNCC_SETUP_COMPL_ind(?)) -> value mncc { |
| 1469 | log("f_mo_call_establish 8: rx MNCC SETUP COMPLETE ind"); |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 1470 | got_mncc_setup_compl_ind := true; |
| 1471 | if (not cpars.expect_release and got_cc_connect) { |
| 1472 | break; |
| 1473 | } |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1474 | } |
| 1475 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1476 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CONNECT(cpars.transaction_id))) { |
| 1477 | log("f_mo_call_establish 10: rx CC CONNECT"); |
| 1478 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CONNECT_ACK(cpars.transaction_id))); |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 1479 | got_cc_connect := true; |
| 1480 | if (not cpars.expect_release and got_mncc_setup_compl_ind) { |
| 1481 | break; |
| 1482 | } |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1483 | } |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1484 | |
| 1485 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))) { |
| 1486 | log("f_mo_call_establish 11: rx CC RELEASE"); |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 1487 | if (not cpars.expect_release) { |
| 1488 | setverdict(fail, "Got unexpected CC Release"); |
| 1489 | mtc.stop; |
| 1490 | } |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1491 | f_expect_clear(); |
| 1492 | break; |
| 1493 | } |
| 1494 | } |
| 1495 | |
| 1496 | f_sleep(0.5); |
| 1497 | deactivate(mdcx); |
| 1498 | |
| 1499 | if (cpars.use_osmux == (cpars.got_osmux_count != 0)) { |
| 1500 | log("Osmux ok: use_osmux = ", cpars.use_osmux, " got_osmux_count = ", cpars.got_osmux_count); |
| 1501 | } else { |
| 1502 | setverdict(fail, "Osmux failure: use_osmux = ", cpars.use_osmux, " got_osmux_count = ", cpars.got_osmux_count); |
| 1503 | mtc.stop; |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1504 | } |
| 1505 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1506 | log("f_mo_call_establish DONE"); |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1507 | setverdict(pass); |
| 1508 | } |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1509 | |
Harald Welte | 4c422b7 | 2019-02-17 16:27:10 +0100 | [diff] [blame] | 1510 | function f_call_hangup(inout CallParameters cpars, boolean release_by_ms, boolean is_csfb := false) |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1511 | runs on BSC_ConnHdlr { |
| 1512 | |
| 1513 | var MobileIdentityLV mi; |
| 1514 | var MNCC_PDU mncc; |
| 1515 | var MgcpCommand mgcp_cmd; |
| 1516 | var boolean respond_to_dlcx; |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1517 | var boolean dlcx_contained_ci := false; |
| 1518 | var template PDU_BSSAP t_clear := tr_BSSMAP_ClearCommand; |
| 1519 | |
| 1520 | if (is_csfb) { |
| 1521 | t_clear := tr_BSSMAP_ClearCommandCSFB; |
| 1522 | } |
| 1523 | |
Neels Hofmeyr | ba960a1 | 2019-11-02 19:17:38 +0100 | [diff] [blame] | 1524 | log("f_call_hangup 0: tx MNCC_DISC_REQ"); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1525 | MNCC.send(ts_MNCC_DISC_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
| 1526 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id))); |
| 1527 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1528 | log("f_call_hangup 1: rx DTAP CC DISC"); |
| 1529 | |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1530 | if (release_by_ms) { |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1531 | var BIT1 tid_remote := '1'B; |
| 1532 | if (cpars.mo_call) { |
| 1533 | tid_remote := '0'B; |
| 1534 | } |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1535 | /* B-side (MS) Release of call */ |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1536 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_RELEASE(cpars.transaction_id, tid_remote, '0000000'B))); |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1537 | MNCC.receive(tr_MNCC_REL_ind(cpars.mncc_callref)); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1538 | log("f_call_hangup 2: rx MNCC REL ind"); |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1539 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_REL_COMPL(cpars.transaction_id))); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1540 | log("f_call_hangup 3: rx DTAP CC REL COMPL"); |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1541 | } else { |
| 1542 | /* A-side (PLMN) Release of call */ |
| 1543 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(42)))); |
| 1544 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1545 | log("f_call_hangup 4: rx DTAP CC RELEASE"); |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1546 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id))); |
| 1547 | } |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1548 | |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 1549 | respond_to_dlcx := not (isbound(cpars.mgw_drop_dlcx) and valueof(cpars.mgw_drop_dlcx)); |
| 1550 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1551 | var default mdcx := activate(as_optional_mgcp_mdcx(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_port)); |
Neels Hofmeyr | 0b16bf1 | 2019-11-03 05:10:12 +0100 | [diff] [blame] | 1552 | var default dlcx := activate(as_optional_mgcp_dlcx(cpars)); |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1553 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1554 | /* clearing of radio channel */ |
Neels Hofmeyr | 0b16bf1 | 2019-11-03 05:10:12 +0100 | [diff] [blame] | 1555 | alt { |
| 1556 | [g_pars.ran_is_geran] BSSAP.receive(t_clear) { |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1557 | log("f_call_hangup 5: rx BSSAP Clear Command"); |
| 1558 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1559 | BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1560 | log("f_call_hangup 6: rx SCCP DISC"); |
Neels Hofmeyr | 0b16bf1 | 2019-11-03 05:10:12 +0100 | [diff] [blame] | 1561 | setverdict(pass); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 1562 | } |
Neels Hofmeyr | 0b16bf1 | 2019-11-03 05:10:12 +0100 | [diff] [blame] | 1563 | [not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_IuReleaseCommand(?)) { |
| 1564 | log("f_call_hangup 5.iu: rx Iu Release Command"); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1565 | BSSAP.send(ts_RANAP_IuReleaseComplete); |
| 1566 | BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
Neels Hofmeyr | 0b16bf1 | 2019-11-03 05:10:12 +0100 | [diff] [blame] | 1567 | log("f_call_hangup 6.iu: rx SCCP DISC"); |
| 1568 | setverdict(pass); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1569 | } |
| 1570 | } |
| 1571 | |
Neels Hofmeyr | 0b16bf1 | 2019-11-03 05:10:12 +0100 | [diff] [blame] | 1572 | f_sleep(1.0); |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 1573 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1574 | log("f_call_hangup 9: done"); |
| 1575 | |
| 1576 | deactivate(mdcx); |
Neels Hofmeyr | 0b16bf1 | 2019-11-03 05:10:12 +0100 | [diff] [blame] | 1577 | deactivate(dlcx); |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1578 | } |
| 1579 | |
| 1580 | function f_mt_call(inout CallParameters cpars) |
| 1581 | runs on BSC_ConnHdlr { |
| 1582 | |
| 1583 | f_mt_call_establish(cpars); |
| 1584 | |
Neels Hofmeyr | ba960a1 | 2019-11-02 19:17:38 +0100 | [diff] [blame] | 1585 | log("Hold the call for some time"); |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1586 | f_sleep(3.0); |
| 1587 | |
Neels Hofmeyr | ba960a1 | 2019-11-02 19:17:38 +0100 | [diff] [blame] | 1588 | log("Hangup"); |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1589 | f_call_hangup(cpars, true); |
| 1590 | |
| 1591 | setverdict(pass); |
| 1592 | } |
| 1593 | |
| 1594 | function f_mo_call(inout CallParameters cpars) |
| 1595 | runs on BSC_ConnHdlr { |
| 1596 | |
| 1597 | f_mo_call_establish(cpars); |
| 1598 | |
Neels Hofmeyr | ba960a1 | 2019-11-02 19:17:38 +0100 | [diff] [blame] | 1599 | log("Hold the call for some time"); |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1600 | f_sleep(3.0); |
| 1601 | |
Neels Hofmeyr | ba960a1 | 2019-11-02 19:17:38 +0100 | [diff] [blame] | 1602 | log("Hangup"); |
Philipp Maier | 3716a5e | 2018-03-21 15:53:35 +0100 | [diff] [blame] | 1603 | f_call_hangup(cpars, false); |
| 1604 | |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 1605 | setverdict(pass); |
| 1606 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 1607 | |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1608 | function f_mo_seq_dtmf_dup(inout CallParameters cpars) |
| 1609 | runs on BSC_ConnHdlr { |
| 1610 | |
| 1611 | timer T := 1.0; |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1612 | var MNCC_PDU mncc; |
| 1613 | var MgcpCommand mgcp_cmd; |
| 1614 | var template PDU_ML3_MS_NW dtmf_dtap; |
| 1615 | |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1616 | f_mo_call_establish(cpars); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1617 | |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1618 | /* Send DTMF: send the exact same DTAP message twice, the dup should be filtered out by |
| 1619 | * 3GPP TS 24.007 11.2.3.2 Message Type Octet / Duplicate Detection. */ |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1620 | |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1621 | /* Find out the next NSD that will be used, from RAN emulation. */ |
| 1622 | var N_Sd_Array last_n_sd := f_bssmap_last_n_sd(); |
| 1623 | var uint2_t next_n_sd := f_next_n_sd(last_n_sd, 0 /* cc is index 0 */); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1624 | |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1625 | /* Compose DTAP with this correct NSD */ |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1626 | dtmf_dtap := ts_ML3_MO_CC_START_DTMF(cpars.transaction_id, "2"); |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1627 | |
| 1628 | /* Here, pass skip_seq_patching == false so that the RAN Emulation NSD increments after this message. */ |
| 1629 | BSSAP.send(ts_PDU_DTAP_MO(dtmf_dtap, '00'O, false)); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1630 | T.start; |
| 1631 | alt { |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1632 | [] MNCC.receive(tr_MNCC_START_DTMF_ind(cpars.mncc_callref, "2")) { |
| 1633 | log("f_mo_seq_dtmf_dup() 1: got first START_DTMF_ind"); |
| 1634 | } |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1635 | [] T.timeout { |
| 1636 | setverdict(fail, "Timeout waiting for START_DTMF_ind"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1637 | mtc.stop; |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1638 | } |
| 1639 | } |
| 1640 | |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1641 | /* Send the exact same DTAP with above NSD, which is now incorrect (has not incremented), so that this message |
| 1642 | * will get filtered by the duplicate detection. Write NSD into DTAP and pass skip_seq_patching == true. */ |
| 1643 | dtmf_dtap.msgs.cc.startDTMF.nsd := int2bit(next_n_sd, 2); |
Daniel Willmann | 92f6627 | 2018-02-06 15:50:52 +0100 | [diff] [blame] | 1644 | BSSAP.send(ts_PDU_DTAP_MO(dtmf_dtap, '00'O, true)); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1645 | T.start; |
| 1646 | alt { |
| 1647 | [] MNCC.receive(tr_MNCC_START_DTMF_ind(cpars.mncc_callref, "2")) { |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1648 | setverdict(fail, "f_mo_seq_dtmf_dup() 2: Received duplicate START_DTMF_ind"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1649 | mtc.stop; |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1650 | } |
| 1651 | [] T.timeout { } |
| 1652 | } |
| 1653 | |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1654 | /* Here the NSD should be correct again and we see a DTMF. */ |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1655 | dtmf_dtap := ts_ML3_MO_CC_START_DTMF(cpars.transaction_id, "3"); |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1656 | BSSAP.send(ts_PDU_DTAP_MO(dtmf_dtap, '00'O, false)); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1657 | alt { |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1658 | [] MNCC.receive(tr_MNCC_START_DTMF_ind(cpars.mncc_callref, "3")) { |
| 1659 | log("f_mo_seq_dtmf_dup() 3: got second START_DTMF_ind"); |
| 1660 | } |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1661 | [] T.timeout { |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1662 | setverdict(fail, "Timeout waiting for final START_DTMF_ind"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1663 | mtc.stop; |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1664 | } |
| 1665 | } |
| 1666 | |
Neels Hofmeyr | 3d22e4a | 2019-10-03 04:07:47 +0200 | [diff] [blame] | 1667 | f_call_hangup(cpars, true); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1668 | setverdict(pass); |
| 1669 | } |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1670 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1671 | /* expect a clear command */ |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1672 | altstep as_clear_cmd_compl_disc(float t := 5.0) runs on BSC_ConnHdlr { |
Neels Hofmeyr | 6b468a4 | 2019-03-06 15:25:14 +0100 | [diff] [blame] | 1673 | var PDU_BSSAP bssap; |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1674 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1675 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1676 | alt { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1677 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1678 | setverdict(pass); |
| 1679 | } |
| 1680 | [] BSSAP.receive { |
| 1681 | setverdict(fail, "Unexpected BSSMAP while waiting for SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1682 | mtc.stop; |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1683 | } |
| 1684 | } |
| 1685 | } |
Neels Hofmeyr | 6b468a4 | 2019-03-06 15:25:14 +0100 | [diff] [blame] | 1686 | [] BSSAP.receive(tr_BSSAP_BSSMAP) -> value bssap { |
| 1687 | setverdict(fail, "Unexpected BSSMAP while waiting for ClearCommand", bssap); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1688 | mtc.stop; |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1689 | } |
| 1690 | } |
| 1691 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1692 | function f_expect_clear(float t := 5.0, boolean verify_vlr_cell_id := true) runs on BSC_ConnHdlr { |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1693 | timer T := t; |
| 1694 | |
| 1695 | T.start; |
| 1696 | alt { |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 1697 | [g_pars.ran_is_geran] as_clear_cmd_compl_disc(t) { } |
| 1698 | [not g_pars.ran_is_geran] as_iu_release_compl_disc(t) { } |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1699 | [] T.timeout { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1700 | setverdict(fail, "Timeout waiting for ClearCommand/Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1701 | mtc.stop; |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1702 | } |
| 1703 | } |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1704 | |
| 1705 | if (verify_vlr_cell_id) { |
| 1706 | /* Now the conn is gone, but the VLR reflects the cell ID */ |
| 1707 | f_verify_vty_lac_ci(); |
| 1708 | } |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1709 | } |
| 1710 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 1711 | function f_create_bssmap_exp_handoverRequest(integer targetPointCode) runs on BSC_ConnHdlr { |
| 1712 | BSSAP_PROC.call(RAN_register_handoverRequest:{targetPointCode, self}) { |
| 1713 | [] BSSAP_PROC.getreply(RAN_register_handoverRequest:{?, ?}) {}; |
| 1714 | } |
| 1715 | } |
| 1716 | |
| 1717 | function f_bssmap_last_n_sd() runs on BSC_ConnHdlr return N_Sd_Array { |
| 1718 | var N_Sd_Array last_n_sd; |
| 1719 | BSSAP_PROC.call(RAN_last_n_sd:{self, -}) { |
| 1720 | [] BSSAP_PROC.getreply(RAN_last_n_sd:{self, ?}) -> param(last_n_sd) { |
| 1721 | return last_n_sd; |
| 1722 | }; |
| 1723 | } |
| 1724 | } |
| 1725 | |
| 1726 | function f_bssmap_continue_after_n_sd(N_Sd_Array last_n_sd) runs on BSC_ConnHdlr { |
| 1727 | BSSAP_PROC.call(RAN_continue_after_n_sd:{last_n_sd, self}) { |
| 1728 | [] BSSAP_PROC.getreply(RAN_continue_after_n_sd:{last_n_sd, self}); |
| 1729 | } |
| 1730 | } |
| 1731 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1732 | type record SmsParametersTp { |
| 1733 | OCT1 msg_ref, |
| 1734 | TP_DA da, |
| 1735 | OCT1 pid, |
| 1736 | OCT1 dcs, |
| 1737 | integer udl, |
| 1738 | octetstring ud |
| 1739 | } |
| 1740 | type record SmsParametersRp { |
| 1741 | OCT1 msg_ref, |
Vadim Yanitskiy | 437b5a6 | 2019-12-15 14:13:39 +0900 | [diff] [blame] | 1742 | RP_NumberingPlan_and_NumberDigits smsc_addr optional |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1743 | } |
| 1744 | type record SmsParameters { |
| 1745 | SmsParametersTp tp, |
| 1746 | SmsParametersRp rp, |
| 1747 | uint3_t tid, |
| 1748 | OCT1 dlci, |
| 1749 | uint7_t exp_rp_err optional |
| 1750 | } |
| 1751 | |
| 1752 | template (value) TP_DA ts_TP_DA(BIT4 npl, BIT3 ton, hexstring addr) := { |
| 1753 | tP_DA_NoPad := { |
| 1754 | tP_LengthIndicator := 0, /* overwritten */ |
| 1755 | tP_NumberingPlanID := npl, |
| 1756 | tP_TypeOfNumber := ton, |
| 1757 | tp_Spare := '0'B, |
| 1758 | tP_DAValue := addr |
| 1759 | } |
| 1760 | } |
| 1761 | |
Vadim Yanitskiy | 437b5a6 | 2019-12-15 14:13:39 +0900 | [diff] [blame] | 1762 | template RP_NumberingPlan_and_NumberDigits t_RP_Addr(template hexstring addr, |
| 1763 | template BIT4 npi := '0001'B, |
| 1764 | template BIT3 ton := '001'B, |
| 1765 | template BIT1 ext := '1'B) := { |
| 1766 | rP_NumberingPlanIdentification := npi, |
| 1767 | rP_TypeOfNumber := ton, |
| 1768 | rP_Ext := ext, |
| 1769 | rP_NumberDigits := addr |
| 1770 | } |
| 1771 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1772 | template (value) SmsParameters t_SmsPars(hexstring tp_daddr := '12345'H) := { |
| 1773 | tp := { |
| 1774 | msg_ref := '23'O, |
| 1775 | da := ts_TP_DA('0000'B, '000'B, tp_daddr), |
| 1776 | pid := '00'O, |
| 1777 | dcs := '00'O, |
| 1778 | udl := 0, |
| 1779 | ud := ''O |
| 1780 | }, |
| 1781 | rp := { |
| 1782 | msg_ref := '42'O, |
Vadim Yanitskiy | 437b5a6 | 2019-12-15 14:13:39 +0900 | [diff] [blame] | 1783 | /* We don't really need to have both SM-RP-DA/OA here, because only one IE |
Vadim Yanitskiy | afb15a8 | 2020-01-05 14:04:53 +0100 | [diff] [blame] | 1784 | * is included in MO/MT SMS, and in the most cases it's the SMSC address. |
| 1785 | * NOTE: this address is currently hard-coded by OsmoMSC. */ |
| 1786 | smsc_addr := t_RP_Addr('447785016005'H) |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1787 | }, |
| 1788 | tid := 0, |
| 1789 | dlci := '03'O, |
| 1790 | exp_rp_err := omit |
| 1791 | } |
| 1792 | |
| 1793 | private altstep as_other_sms() runs on BSC_ConnHdlr { |
| 1794 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_SMS(?, ?, ?), ?)) { |
| 1795 | setverdict(fail, "Unexpected SMS related PDU from MSC"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1796 | mtc.stop; |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1797 | } |
| 1798 | } |
| 1799 | |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 1800 | /* Submit a MO RP-SMMA over an already existing DTAP connection */ |
| 1801 | function f_mo_smma(inout SmsParameters spars) |
| 1802 | runs on BSC_ConnHdlr { |
| 1803 | var template (value) RPDU_MS_SGSN rp_mo; |
| 1804 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 1805 | |
| 1806 | var default d := activate(as_other_sms()); |
| 1807 | |
| 1808 | /* just in case this is routed to SMPP.. */ |
| 1809 | f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue)); |
| 1810 | |
| 1811 | rp_mo := ts_RP_SMMA_MO(spars.rp.msg_ref); |
| 1812 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo)); |
| 1813 | BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true)); |
| 1814 | /* receive CP-ACK for CP-DATA above */ |
| 1815 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_ACK_MT), spars.dlci)); |
| 1816 | |
| 1817 | deactivate(d); |
| 1818 | setverdict(pass); |
| 1819 | } |
| 1820 | |
Vadim Yanitskiy | d4cc150 | 2018-11-12 01:46:21 +0700 | [diff] [blame] | 1821 | /* Submit a MO-SMS over an already existing DTAP connection */ |
| 1822 | function f_mo_sms_submit(inout SmsParameters spars) |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1823 | runs on BSC_ConnHdlr { |
| 1824 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 1825 | var template (value) RPDU_MS_SGSN rp_mo; |
| 1826 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 1827 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1828 | var default d := activate(as_other_sms()); |
| 1829 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 1830 | /* just in case this is routed to SMPP.. */ |
| 1831 | f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue)); |
| 1832 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1833 | tp_mo := ts_SMS_SUBMIT(spars.tp.msg_ref, spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 1834 | spars.tp.udl, spars.tp.ud); |
Vadim Yanitskiy | 437b5a6 | 2019-12-15 14:13:39 +0900 | [diff] [blame] | 1835 | rp_mo := ts_RP_DATA_MO(spars.rp.msg_ref, omit, spars.rp.smsc_addr, tp_mo); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1836 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo)); |
| 1837 | BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true)); |
| 1838 | /* receive CP-ACK for CP-DATA above */ |
| 1839 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_ACK_MT), spars.dlci)); |
| 1840 | |
Vadim Yanitskiy | d4cc150 | 2018-11-12 01:46:21 +0700 | [diff] [blame] | 1841 | deactivate(d); |
| 1842 | setverdict(pass); |
| 1843 | } |
| 1844 | |
| 1845 | /* Wait RP-ACK for MO-SMS on an already existing DTAP connection */ |
| 1846 | function f_mo_sms_wait_rp_ack(inout SmsParameters spars) |
| 1847 | runs on BSC_ConnHdlr { |
| 1848 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 1849 | |
| 1850 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 1851 | var template RPDU_SGSN_MS rp_mt; |
| 1852 | var template PDU_ML3_NW_MS l3_mt; |
| 1853 | |
| 1854 | var default d := activate(as_other_sms()); |
| 1855 | |
| 1856 | /* just in case this is routed to SMPP.. */ |
| 1857 | f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue)); |
| 1858 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1859 | if (ispresent(spars.exp_rp_err)) { |
| 1860 | /* expect an RP-ERROR message from MSC with given cause */ |
| 1861 | rp_mt := tr_RP_ERROR_MT(spars.rp.msg_ref, spars.exp_rp_err); |
| 1862 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 1863 | BSSAP.receive(tr_PDU_DTAP_MT(l3_mt, spars.dlci)); |
| 1864 | /* send CP-ACK for CP-DATA just received */ |
| 1865 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 1866 | BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true)); |
| 1867 | } else { |
| 1868 | /* expect RP-ACK for RP-DATA */ |
| 1869 | rp_mt := tr_RP_ACK_MT(spars.rp.msg_ref); |
| 1870 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 1871 | BSSAP.receive(tr_PDU_DTAP_MT(l3_mt, spars.dlci)); |
| 1872 | /* send CP-ACO for CP-DATA just received */ |
| 1873 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 1874 | BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true)); |
| 1875 | } |
Vadim Yanitskiy | d4cc150 | 2018-11-12 01:46:21 +0700 | [diff] [blame] | 1876 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1877 | deactivate(d); |
| 1878 | setverdict(pass); |
| 1879 | } |
| 1880 | |
Vadim Yanitskiy | d4cc150 | 2018-11-12 01:46:21 +0700 | [diff] [blame] | 1881 | /* Submit a MO-SMS, and wait for RP-ACK on an existing |
| 1882 | * (and authenticated, ...) DTAP connection */ |
| 1883 | function f_mo_sms(inout SmsParameters spars) |
| 1884 | runs on BSC_ConnHdlr { |
| 1885 | f_mo_sms_submit(spars); |
| 1886 | f_mo_sms_wait_rp_ack(spars); |
| 1887 | } |
| 1888 | |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 1889 | function f_mt_sms_deliver_pdu(in SmsParameters spars) |
| 1890 | runs on BSC_ConnHdlr |
| 1891 | return template PDU_DTAP_MT { |
| 1892 | var template TPDU_RP_DATA_SGSN_MS tp_mt := tr_SMS_DELIVER(?, spars.tp.ud, spars.tp.pid, spars.tp.dcs, ?); |
| 1893 | var template RPDU_SGSN_MS rp_mt := tr_RP_DATA_MT(?, spars.rp.smsc_addr, omit, tp_mt); |
| 1894 | var template PDU_ML3_NW_MS l3_mt := tr_ML3_MT_SMS(?, c_TIF_ORIG, tr_CP_DATA_MT(rp_mt)); |
| 1895 | return tr_PDU_DTAP_MT(l3_mt, spars.dlci); |
| 1896 | } |
| 1897 | |
Vadim Yanitskiy | 2159acb | 2018-11-24 02:50:29 +0700 | [diff] [blame] | 1898 | /* Wait for MT SMS on an already existing DTAP connection */ |
| 1899 | function f_mt_sms_expect(inout SmsParameters spars) |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1900 | runs on BSC_ConnHdlr { |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1901 | var template (value) PDU_ML3_MS_NW l3_mo; |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1902 | var PDU_DTAP_MT dtap_mt; |
| 1903 | |
| 1904 | var default d := activate(as_other_sms()); |
| 1905 | |
| 1906 | /* Expect CP-DATA(RP-DATA(SMS-DELIVER)) */ |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 1907 | BSSAP.receive(f_mt_sms_deliver_pdu(spars)) -> value dtap_mt; |
Vadim Yanitskiy | 2159acb | 2018-11-24 02:50:29 +0700 | [diff] [blame] | 1908 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1909 | /* Extract relevant identifiers */ |
| 1910 | spars.tid := bit2int(dtap_mt.dtap.tiOrSkip.transactionId.tio); |
| 1911 | spars.rp.msg_ref := dtap_mt.dtap.msgs.sms.cP_DATA.cP_User_Data.cP_RPDU.rP_DATA_SGSN_MS.rP_MessageReference; |
| 1912 | |
| 1913 | /* send CP-ACK for CP-DATA just received */ |
| 1914 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_ACK_MO); |
| 1915 | BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true)); |
| 1916 | |
Vadim Yanitskiy | 2159acb | 2018-11-24 02:50:29 +0700 | [diff] [blame] | 1917 | deactivate(d); |
| 1918 | setverdict(pass); |
| 1919 | } |
| 1920 | |
| 1921 | /* Send RP-ACK for MT-SMS over an already existing DTAP connection */ |
| 1922 | function f_mt_sms_send_rp_ack(inout SmsParameters spars) |
| 1923 | runs on BSC_ConnHdlr { |
| 1924 | var template (value) RPDU_MS_SGSN rp_mo; |
| 1925 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 1926 | var template PDU_ML3_NW_MS l3_mt; |
| 1927 | |
| 1928 | var default d := activate(as_other_sms()); |
| 1929 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1930 | /* send RP-ACK for RP-DATA */ |
| 1931 | rp_mo := ts_RP_ACK_MO(spars.rp.msg_ref); |
| 1932 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_DATA_MO(rp_mo)); |
| 1933 | BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true)); |
| 1934 | |
| 1935 | /* expect CP-ACK for CP-DATA(RP-ACK) just sent */ |
Harald Welte | e008eea | 2018-04-14 21:05:48 +0200 | [diff] [blame] | 1936 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_ORIG, tr_CP_ACK_MT); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1937 | BSSAP.receive(tr_PDU_DTAP_MT(l3_mt, spars.dlci)); |
| 1938 | |
| 1939 | deactivate(d); |
| 1940 | setverdict(pass); |
| 1941 | } |
| 1942 | |
Vadim Yanitskiy | 5631852 | 2018-11-24 03:40:47 +0700 | [diff] [blame] | 1943 | /* Send RP-ERROR for MT-SMS over an already existing DTAP connection */ |
| 1944 | function f_mt_sms_send_rp_error(inout SmsParameters spars, uint7_t cause) |
| 1945 | runs on BSC_ConnHdlr { |
| 1946 | var template (value) RPDU_MS_SGSN rp_mo; |
| 1947 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 1948 | var template PDU_ML3_NW_MS l3_mt; |
| 1949 | |
| 1950 | var default d := activate(as_other_sms()); |
| 1951 | |
| 1952 | /* send RP-ACK for RP-DATA */ |
| 1953 | rp_mo := ts_RP_ERROR_MO(spars.rp.msg_ref, cause); |
| 1954 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_DATA_MO(rp_mo)); |
| 1955 | BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true)); |
| 1956 | |
| 1957 | /* expect CP-ACK for CP-DATA(RP-ERROR) just sent */ |
| 1958 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_ORIG, tr_CP_ACK_MT); |
| 1959 | BSSAP.receive(tr_PDU_DTAP_MT(l3_mt, spars.dlci)); |
| 1960 | |
| 1961 | deactivate(d); |
| 1962 | setverdict(pass); |
| 1963 | } |
| 1964 | |
Vadim Yanitskiy | 2159acb | 2018-11-24 02:50:29 +0700 | [diff] [blame] | 1965 | /* Wait for a MT-SMS and send RP-ACK over an already existing |
| 1966 | * (and authenticated, ...) DTAP connection */ |
| 1967 | function f_mt_sms(inout SmsParameters spars) |
| 1968 | runs on BSC_ConnHdlr { |
| 1969 | f_mt_sms_expect(spars); |
| 1970 | f_mt_sms_send_rp_ack(spars); |
| 1971 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 1972 | |
| 1973 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 1974 | } |