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