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