Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 1 | /* Osmocom MSC+VLR end-to-end tests */ |
| 2 | |
| 3 | /* (C) 2017 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
| 4 | * |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * Author: Neels Hofmeyr <nhofmeyr@sysmocom.de> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU Affero General Public License as published by |
| 11 | * the Free Software Foundation; either version 3 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU Affero General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Affero General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include "msc_vlr_tests.h" |
| 25 | |
| 26 | #include <osmocom/msc/gsm_04_08.h> |
| 27 | |
Neels Hofmeyr | 07351d8 | 2019-10-21 05:53:58 +0200 | [diff] [blame] | 28 | #define mncc_sends_to_cc(MSG_TYPE, MNCC) do { \ |
| 29 | (MNCC)->msg_type = MSG_TYPE; \ |
| 30 | log("MSC <-- MNCC: callref 0x%x: %s\n%s", (MNCC)->callref, \ |
| 31 | get_mncc_name((MNCC)->msg_type), \ |
| 32 | (MNCC)->sdp); \ |
| 33 | mncc_tx_to_cc(net, MNCC); \ |
| 34 | } while(0) |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 35 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 36 | /* |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 37 | static void on_call_release_mncc_sends_to_cc(uint32_t msg_type, struct gsm_mncc *mncc) |
| 38 | { |
| 39 | mncc->msg_type = msg_type; |
| 40 | on_call_release_mncc_sends_to_cc_data = mncc; |
| 41 | } |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 42 | */ |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 43 | |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 44 | #define IMSI "901700000010650" |
| 45 | |
Neels Hofmeyr | 11bf0bc | 2019-10-21 05:55:49 +0200 | [diff] [blame] | 46 | static void lu_utran_tmsi() |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 47 | { |
| 48 | struct vlr_subscr *vsub; |
| 49 | |
| 50 | net->authentication_required = true; |
| 51 | net->vlr->cfg.assign_tmsi = true; |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 52 | rx_from_ran = OSMO_RAT_UTRAN_IU; |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 53 | |
| 54 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 55 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | 63b2464 | 2019-12-12 01:31:04 +0100 | [diff] [blame] | 56 | gsup_expect_tx("080108" "09710000000156f0" CN_DOMAIN VLR_TO_HLR); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 57 | ms_sends_msg("0508" /* MM LU */ |
| 58 | "7" /* ciph key seq: no key available */ |
| 59 | "0" /* LU type: normal */ |
| 60 | "09f107" "0017" /* LAI, LAC */ |
| 61 | "57" /* classmark 1: R99, early classmark, no power lvl */ |
| 62 | "089910070000106005" /* IMSI */ |
| 63 | "3303575886" /* classmark 2 */ |
| 64 | ); |
| 65 | OSMO_ASSERT(gsup_tx_confirmed); |
| 66 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 67 | |
| 68 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 69 | /* based on auc_3g: |
| 70 | * K = 'EB215756028D60E3275E613320AEC880', |
| 71 | * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308' |
| 72 | * SQN = 0 |
| 73 | */ |
| 74 | auth_request_sent = false; |
| 75 | auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d"; |
| 76 | auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919"; |
| 77 | gsup_rx("0a" |
| 78 | /* imsi */ |
| 79 | "0108" "09710000000156f0" |
| 80 | /* 5 auth vectors... */ |
| 81 | /* TL TL rand */ |
| 82 | "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d" |
| 83 | /* TL sres TL kc */ |
| 84 | "2104" "9b36efdf" "2208" "059a4f668f6fbe39" |
| 85 | /* TL 3G IK */ |
| 86 | "2310" "27497388b6cb044648f396aa155b95ef" |
| 87 | /* TL 3G CK */ |
| 88 | "2410" "f64735036e5871319c679f4742a75ea1" |
| 89 | /* TL AUTN */ |
| 90 | "2510" "8704f5ba55f30000d2ee44b22c8ea919" |
| 91 | /* TL RES */ |
| 92 | "2708" "e229c19e791f2e41" |
| 93 | /* TL TL rand */ |
| 94 | "0362" "2010" "c187a53a5e6b9d573cac7c74451fd46d" |
| 95 | "2104" "85aa3130" "2208" "d3d50a000bf04f6e" |
| 96 | "2310" "1159ec926a50e98c034a6b7d7c9f418d" |
| 97 | "2410" "df3a03d9ca5335641efc8e36d76cd20b" |
| 98 | "2510" "1843a645b98d00005b2d666af46c45d9" |
| 99 | "2708" "7db47cf7f81e4dc7" |
| 100 | "0362" "2010" "efa9c29a9742148d5c9070348716e1bb" |
| 101 | "2104" "69d5f9fb" "2208" "3df176f0c29f1a3d" |
| 102 | "2310" "eb50e770ddcc3060101d2f43b6c2b884" |
| 103 | "2410" "76542abce5ff9345b0e8947f4c6e019c" |
| 104 | "2510" "f9375e6d41e1000096e7fe4ff1c27e39" |
| 105 | "2708" "706f996719ba609c" |
| 106 | "0362" "2010" "f023d5a3b24726e0631b64b3840f8253" |
| 107 | "2104" "d570c03f" "2208" "ec011be8919883d6" |
| 108 | "2310" "c4e58af4ba43f3bcd904e16984f086d7" |
| 109 | "2410" "0593f65e752e5cb7f473862bda05aa0a" |
| 110 | "2510" "541ff1f077270000c5ea00d658bc7e9a" |
| 111 | "2708" "3fd26072eaa2a04d" |
| 112 | "0362" "2010" "2f8f90c780d6a9c0c53da7ac57b6707e" |
| 113 | "2104" "b072446f220823f39f9f425ad6e6" |
| 114 | "2310" "65af0527fda95b0dc5ae4aa515cdf32f" |
| 115 | "2410" "537c3b35a3b13b08d08eeb28098f45cc" |
| 116 | "2510" "4bf4e564f75300009bc796706bc65744" |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 117 | "2708" "0edb0eadbea94ac2" |
| 118 | HLR_TO_VLR, |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 119 | NULL); |
| 120 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 121 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 122 | |
| 123 | btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl"); |
Neels Hofmeyr | dbabfd3 | 2018-03-10 02:06:47 +0100 | [diff] [blame] | 124 | expect_security_mode_ctrl(NULL, "27497388b6cb044648f396aa155b95ef"); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 125 | ms_sends_msg("0554" "e229c19e" "2104" "791f2e41"); |
Neels Hofmeyr | dbabfd3 | 2018-03-10 02:06:47 +0100 | [diff] [blame] | 126 | VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d"); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 127 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 128 | |
| 129 | btw("MS sends SecurityModeControl acceptance, VLR accepts and sends GSUP LU Req to HLR"); |
Neels Hofmeyr | 63b2464 | 2019-12-12 01:31:04 +0100 | [diff] [blame] | 130 | gsup_expect_tx("04010809710000000156f0" CN_DOMAIN VLR_TO_HLR); |
Alexander Couzens | 2aaff75 | 2021-10-19 17:09:11 +0200 | [diff] [blame] | 131 | ms_sends_security_mode_complete(1); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 132 | VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d"); |
| 133 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 134 | |
| 135 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 136 | gsup_rx("10010809710000000156f00804032443f2" HLR_TO_VLR, |
| 137 | "12010809710000000156f0" VLR_TO_HLR); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 138 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 139 | |
| 140 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 141 | gsup_rx("06010809710000000156f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 142 | |
| 143 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 144 | |
| 145 | btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl"); |
| 146 | EXPECT_CONN_COUNT(1); |
| 147 | EXPECT_ACCEPTED(false); |
| 148 | |
| 149 | btw("MS sends TMSI Realloc Complete"); |
| 150 | iu_release_expected = true; |
| 151 | iu_release_sent = false; |
| 152 | ms_sends_msg("055b"); |
| 153 | VERBOSE_ASSERT(iu_release_sent, == true, "%d"); \ |
| 154 | |
| 155 | btw("LU was successful, and the conn has already been closed"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 156 | ran_sends_clear_complete(); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 157 | EXPECT_CONN_COUNT(0); |
| 158 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 159 | vsub = vlr_subscr_find_by_imsi(net->vlr, IMSI, __func__); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 160 | VERBOSE_ASSERT(vsub != NULL, == true, "%d"); |
| 161 | VERBOSE_ASSERT(strcmp(vsub->imsi, IMSI), == 0, "%d"); |
Max | 7d41d87 | 2018-12-19 11:48:33 +0100 | [diff] [blame] | 162 | VAL_ASSERT("LAC", vsub->cgi.lai.lac, == 23, "%u"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 163 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 164 | } |
| 165 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 166 | static void test_call_mo() |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 167 | { |
| 168 | struct gsm_mncc mncc = { |
| 169 | .imsi = IMSI, |
| 170 | }; |
| 171 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 172 | comment_start(); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 173 | |
| 174 | fake_time_start(); |
| 175 | |
Neels Hofmeyr | 11bf0bc | 2019-10-21 05:55:49 +0200 | [diff] [blame] | 176 | lu_utran_tmsi(); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 177 | |
| 178 | BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector"); |
| 179 | auth_request_sent = false; |
| 180 | auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d"; |
| 181 | auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9"; |
| 182 | cm_service_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 183 | ms_sends_msg("052471" |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 184 | "03575886" /* classmark 2 */ |
| 185 | "089910070000106005" /* IMSI */); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 186 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 187 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 188 | |
| 189 | btw("needs auth, not yet accepted"); |
| 190 | EXPECT_ACCEPTED(false); |
| 191 | |
| 192 | /* On UTRAN */ |
| 193 | btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl"); |
Neels Hofmeyr | dbabfd3 | 2018-03-10 02:06:47 +0100 | [diff] [blame] | 194 | expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d"); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 195 | ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */ |
Neels Hofmeyr | dbabfd3 | 2018-03-10 02:06:47 +0100 | [diff] [blame] | 196 | VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d"); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 197 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 198 | |
| 199 | btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept"); |
Alexander Couzens | 2aaff75 | 2021-10-19 17:09:11 +0200 | [diff] [blame] | 200 | ms_sends_security_mode_complete(1); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 201 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 202 | |
| 203 | BTW("a call is initiated"); |
| 204 | |
| 205 | btw("SETUP gets forwarded to MNCC"); |
| 206 | cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_IND); |
| 207 | ms_sends_msg("0385" /* CC, seq = 2 -> 0x80 | CC Setup = 0x5 */ |
| 208 | "0406600402000581" /* Bearer Capability */ |
| 209 | "5e038121f3" /* Called Number BCD */ |
| 210 | "15020100" /* CC Capabilities */ |
| 211 | "4008" /* Supported Codec List */ |
| 212 | "04026000" /* UMTS: AMR 2 | AMR */ |
| 213 | "00021f00" /* GSM: HR AMR | FR AMR | GSM EFR | GSM HR | GSM FR */ |
| 214 | ); |
| 215 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 216 | mncc.callref = cc_to_mncc_tx_got_callref; |
| 217 | |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 218 | btw("MNCC replies with MNCC_RTP_CREATE, causing MGW endpoint CRCX to RAN"); |
| 219 | expect_crcx(RTP_TO_RAN); |
| 220 | mncc_sends_to_cc(MNCC_RTP_CREATE, &mncc); |
Neels Hofmeyr | 81938fd | 2022-01-14 03:39:58 +0100 | [diff] [blame^] | 221 | OSMO_ASSERT(crcx_scheduled(RTP_TO_RAN)); |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 222 | |
| 223 | btw("MGW acknowledges the CRCX, triggering Assignment"); |
| 224 | expect_iu_rab_assignment(); |
| 225 | crcx_ok(RTP_TO_RAN); |
| 226 | OSMO_ASSERT(iu_rab_assignment_sent); |
| 227 | |
| 228 | btw("Assignment succeeds, triggering CRCX to CN"); |
| 229 | expect_crcx(RTP_TO_CN); |
Neels Hofmeyr | cec51b3 | 2023-03-01 03:47:45 +0100 | [diff] [blame] | 230 | ms_sends_assignment_complete("AMR"); |
Neels Hofmeyr | 81938fd | 2022-01-14 03:39:58 +0100 | [diff] [blame^] | 231 | OSMO_ASSERT(crcx_scheduled(RTP_TO_CN)); |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 232 | |
| 233 | btw("CN RTP address is available, trigger MNCC_RTP_CREATE"); |
| 234 | cc_to_mncc_expect_tx("", MNCC_RTP_CREATE); |
| 235 | crcx_ok(RTP_TO_CN); |
| 236 | |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 237 | btw("MNCC says that's fine"); |
| 238 | dtap_expect_tx("8302" /* CC: Call Proceeding */); |
| 239 | mncc_sends_to_cc(MNCC_CALL_PROC_REQ, &mncc); |
| 240 | OSMO_ASSERT(dtap_tx_confirmed); |
| 241 | |
| 242 | fake_time_passes(1, 23); |
| 243 | |
| 244 | btw("The other call leg got established (not shown here), MNCC tells us so"); |
| 245 | dtap_expect_tx("8301" /* CC: Call Alerting */); |
| 246 | mncc_sends_to_cc(MNCC_ALERT_REQ, &mncc); |
| 247 | OSMO_ASSERT(dtap_tx_confirmed); |
| 248 | |
| 249 | dtap_expect_tx("8307" /* CC: Connect */); |
| 250 | mncc_sends_to_cc(MNCC_SETUP_RSP, &mncc); |
| 251 | OSMO_ASSERT(dtap_tx_confirmed); |
| 252 | |
| 253 | fake_time_passes(1, 23); |
| 254 | |
| 255 | cc_to_mncc_expect_tx("", MNCC_SETUP_COMPL_IND); |
| 256 | ms_sends_msg("03cf" /* CC: Connect Acknowledge */); |
| 257 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 258 | |
| 259 | BTW("RTP stream goes ahead, not shown here."); |
| 260 | fake_time_passes(123, 45); |
| 261 | |
| 262 | BTW("Call ends"); |
| 263 | cc_to_mncc_expect_tx("", MNCC_DISC_IND); |
| 264 | ms_sends_msg("032502e090" /* CC: Disconnect, cause: Normal Call Clearing */); |
| 265 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 266 | |
| 267 | dtap_expect_tx("832d" /* CC: Release */); |
| 268 | mncc_sends_to_cc(MNCC_REL_REQ, &mncc); |
| 269 | OSMO_ASSERT(dtap_tx_confirmed); |
| 270 | |
| 271 | cc_to_mncc_expect_tx("", MNCC_REL_CNF); |
| 272 | expect_iu_release(); |
| 273 | ms_sends_msg("036a" /* CC: Release Complete */); |
| 274 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 275 | OSMO_ASSERT(iu_release_sent); |
| 276 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 277 | ran_sends_clear_complete(); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 278 | EXPECT_CONN_COUNT(0); |
| 279 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 280 | comment_end(); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 281 | } |
| 282 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 283 | static void test_call_mt() |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 284 | { |
| 285 | struct gsm_mncc mncc = { |
| 286 | .imsi = IMSI, |
| 287 | .callref = 0x423, |
Neels Hofmeyr | 8dd1646 | 2022-01-13 20:06:53 +0100 | [diff] [blame] | 288 | .fields = MNCC_F_BEARER_CAP, |
| 289 | .bearer_cap = { |
| 290 | .speech_ver = { |
| 291 | GSM48_BCAP_SV_AMR_F, |
| 292 | GSM48_BCAP_SV_EFR, |
| 293 | GSM48_BCAP_SV_FR, |
| 294 | GSM48_BCAP_SV_AMR_H, |
| 295 | GSM48_BCAP_SV_HR, |
| 296 | -1 }, |
| 297 | }, |
| 298 | /* NOTE: below SDP includes only AMR, above bearer_cap includes more codecs. Ideally, these would match, |
| 299 | * but in reality the bearer cap in MNCC was never implemented properly. This test shows that above |
| 300 | * bearer_cap is ignored when SDP is present: In the CC Setup below, the Bearer Capability is only |
| 301 | * "04 04 60 04 05 8b" with speech versions '04' == GSM48_BCAP_SV_AMR_F and '05' == GSM48_BCAP_SV_AMR_H. |
| 302 | */ |
| 303 | .sdp = "v=0\r\n" |
| 304 | "o=OsmoMSC 0 0 IN IP4 10.23.23.1\r\n" |
| 305 | "s=GSM Call\r\n" |
| 306 | "c=IN IP4 10.23.23.1\r\n" |
| 307 | "t=0 0\r\n" |
| 308 | "m=audio 23 RTP/AVP 112\r\n" |
| 309 | "a=rtpmap:112 AMR/8000\r\n" |
| 310 | "a=fmtp:112 octet-align=1\r\n" |
| 311 | "a=ptime:20\r\n", |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 312 | }; |
| 313 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 314 | comment_start(); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 315 | |
| 316 | fake_time_start(); |
| 317 | |
Neels Hofmeyr | 11bf0bc | 2019-10-21 05:55:49 +0200 | [diff] [blame] | 318 | lu_utran_tmsi(); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 319 | |
| 320 | BTW("after a while, MNCC asks us to setup a call, causing Paging"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 321 | |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 322 | paging_expect_imsi(IMSI); |
| 323 | paging_sent = false; |
| 324 | mncc_sends_to_cc(MNCC_SETUP_REQ, &mncc); |
Neels Hofmeyr | 8dd1646 | 2022-01-13 20:06:53 +0100 | [diff] [blame] | 325 | mncc.sdp[0] = '\0'; |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 326 | |
| 327 | VERBOSE_ASSERT(paging_sent, == true, "%d"); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 328 | |
| 329 | btw("MS replies with Paging Response, and VLR sends Auth Request"); |
| 330 | auth_request_sent = false; |
| 331 | auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d"; |
| 332 | auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9"; |
| 333 | ms_sends_msg("062707" |
| 334 | "03575886" /* classmark 2 */ |
| 335 | "089910070000106005" /* IMSI */); |
| 336 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 337 | |
| 338 | btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl"); |
Neels Hofmeyr | dbabfd3 | 2018-03-10 02:06:47 +0100 | [diff] [blame] | 339 | expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d"); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 340 | ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */ |
Neels Hofmeyr | dbabfd3 | 2018-03-10 02:06:47 +0100 | [diff] [blame] | 341 | VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d"); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 342 | |
| 343 | btw("MS sends SecurityModeControl acceptance, VLR accepts, sends CC Setup"); |
Neels Hofmeyr | 8dd1646 | 2022-01-13 20:06:53 +0100 | [diff] [blame] | 344 | dtap_expect_tx("0305" /* CC: Setup */ "04 04 60 04 05 8b" /* Bearer Cap, speech ver of AMR-FR and AMR-HR */); |
Alexander Couzens | 2aaff75 | 2021-10-19 17:09:11 +0200 | [diff] [blame] | 345 | ms_sends_security_mode_complete(1); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 346 | |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 347 | btw("MS confirms call, we create a RAN-side RTP and forward MNCC_CALL_CONF_IND"); |
| 348 | expect_crcx(RTP_TO_RAN); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 349 | cc_to_mncc_expect_tx(IMSI, MNCC_CALL_CONF_IND); |
| 350 | ms_sends_msg("8348" /* CC: Call Confirmed */ |
| 351 | "0406600402000581" /* Bearer Capability */ |
| 352 | "15020100" /* Call Control Capabilities */ |
| 353 | "40080402600400021f00" /* Supported Codec List */); |
Neels Hofmeyr | 81938fd | 2022-01-14 03:39:58 +0100 | [diff] [blame^] | 354 | OSMO_ASSERT(crcx_scheduled(RTP_TO_RAN)); |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 355 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 356 | |
| 357 | btw("MNCC sends MNCC_RTP_CREATE"); |
| 358 | mncc_sends_to_cc(MNCC_RTP_CREATE, &mncc); |
| 359 | |
| 360 | btw("MGW acknowledges the CRCX to RAN, triggering Assignment"); |
| 361 | expect_iu_rab_assignment(); |
| 362 | crcx_ok(RTP_TO_RAN); |
| 363 | OSMO_ASSERT(iu_rab_assignment_sent); |
| 364 | |
| 365 | btw("Assignment completes, triggering CRCX to CN"); |
| 366 | expect_crcx(RTP_TO_CN); |
Neels Hofmeyr | cec51b3 | 2023-03-01 03:47:45 +0100 | [diff] [blame] | 367 | ms_sends_assignment_complete("AMR"); |
Neels Hofmeyr | 81938fd | 2022-01-14 03:39:58 +0100 | [diff] [blame^] | 368 | OSMO_ASSERT(crcx_scheduled(RTP_TO_CN)); |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 369 | |
| 370 | btw("When the CN side RTP address is known, send MNCC_RTP_CREATE"); |
| 371 | cc_to_mncc_expect_tx("", MNCC_RTP_CREATE); |
| 372 | crcx_ok(RTP_TO_CN); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 373 | |
| 374 | fake_time_passes(1, 23); |
| 375 | |
| 376 | cc_to_mncc_expect_tx("", MNCC_ALERT_IND); |
| 377 | ms_sends_msg("8381" /* CC: Alerting */); |
| 378 | |
| 379 | fake_time_passes(1, 23); |
| 380 | |
| 381 | cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_CNF); |
| 382 | ms_sends_msg("83c7" /* CC: Connect */); |
| 383 | |
| 384 | dtap_expect_tx("030f" /* CC: Connect Acknowledge */); |
| 385 | mncc_sends_to_cc(MNCC_SETUP_COMPL_REQ, &mncc); |
| 386 | |
| 387 | BTW("RTP stream goes ahead, not shown here."); |
| 388 | fake_time_passes(123, 45); |
| 389 | |
| 390 | BTW("Call ends"); |
| 391 | cc_to_mncc_expect_tx("", MNCC_DISC_IND); |
| 392 | ms_sends_msg("832502e090" /* CC: Disconnect, cause: Normal Call Clearing */); |
| 393 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 394 | |
| 395 | dtap_expect_tx("032d" /* CC: Release */); |
| 396 | mncc_sends_to_cc(MNCC_REL_REQ, &mncc); |
| 397 | OSMO_ASSERT(dtap_tx_confirmed); |
| 398 | |
| 399 | cc_to_mncc_expect_tx("", MNCC_REL_CNF); |
| 400 | expect_iu_release(); |
| 401 | ms_sends_msg("836a" /* CC: Release Complete */); |
| 402 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 403 | OSMO_ASSERT(iu_release_sent); |
| 404 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 405 | ran_sends_clear_complete(); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 406 | EXPECT_CONN_COUNT(0); |
| 407 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 408 | comment_end(); |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 409 | } |
| 410 | |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 411 | static void test_call_mt2() |
| 412 | { |
| 413 | struct gsm_mncc mncc = { |
| 414 | .imsi = IMSI, |
| 415 | .callref = 0x423, |
Neels Hofmeyr | 8dd1646 | 2022-01-13 20:06:53 +0100 | [diff] [blame] | 416 | .fields = MNCC_F_BEARER_CAP, |
| 417 | .bearer_cap = { |
| 418 | .speech_ver = { GSM48_BCAP_SV_FR, -1, }, |
| 419 | }, |
| 420 | /* NOTE: below SDP includes only AMR, above bearer_cap includes only GSM-FR. Ideally, these would match, |
| 421 | * but in reality the bearer cap in MNCC was never implemented properly. This test shows that above |
| 422 | * bearer_cap is ignored when SDP is present: In the CC Setup below, the Bearer Capability is only |
| 423 | * "04 04 60 04 05 8b" with speech versions '04' == GSM48_BCAP_SV_AMR_F and '05' == GSM48_BCAP_SV_AMR_H. |
| 424 | */ |
| 425 | .sdp = "v=0\r\n" |
| 426 | "o=OsmoMSC 0 0 IN IP4 10.23.23.1\r\n" |
| 427 | "s=GSM Call\r\n" |
| 428 | "c=IN IP4 10.23.23.1\r\n" |
| 429 | "t=0 0\r\n" |
| 430 | "m=audio 23 RTP/AVP 112\r\n" |
| 431 | "a=rtpmap:112 AMR/8000\r\n" |
| 432 | "a=fmtp:112 octet-align=1\r\n" |
| 433 | "a=ptime:20\r\n", |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 434 | }; |
| 435 | |
| 436 | comment_start(); |
| 437 | |
| 438 | fake_time_start(); |
| 439 | |
Neels Hofmeyr | 11bf0bc | 2019-10-21 05:55:49 +0200 | [diff] [blame] | 440 | lu_utran_tmsi(); |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 441 | |
| 442 | BTW("after a while, MNCC asks us to setup a call, causing Paging"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 443 | |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 444 | paging_expect_imsi(IMSI); |
| 445 | paging_sent = false; |
| 446 | mncc_sends_to_cc(MNCC_SETUP_REQ, &mncc); |
| 447 | |
| 448 | VERBOSE_ASSERT(paging_sent, == true, "%d"); |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 449 | |
| 450 | btw("MS replies with Paging Response, and VLR sends Auth Request"); |
| 451 | auth_request_sent = false; |
| 452 | auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d"; |
| 453 | auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9"; |
| 454 | ms_sends_msg("062707" |
| 455 | "03575886" /* classmark 2 */ |
| 456 | "089910070000106005" /* IMSI */); |
| 457 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 458 | |
| 459 | btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl"); |
| 460 | expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d"); |
| 461 | ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */ |
| 462 | VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d"); |
| 463 | |
| 464 | btw("MS sends SecurityModeControl acceptance, VLR accepts, sends CC Setup"); |
Neels Hofmeyr | 8dd1646 | 2022-01-13 20:06:53 +0100 | [diff] [blame] | 465 | dtap_expect_tx("0305" /* CC: Setup */ "04 04 60 04 05 8b" /* Bearer Cap, speech ver of AMR-FR and AMR-HR */); |
Alexander Couzens | 2aaff75 | 2021-10-19 17:09:11 +0200 | [diff] [blame] | 466 | ms_sends_security_mode_complete(1); |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 467 | |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 468 | btw("MS confirms call, we create a RAN-side RTP and forward MNCC_CALL_CONF_IND"); |
| 469 | expect_crcx(RTP_TO_RAN); |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 470 | cc_to_mncc_expect_tx(IMSI, MNCC_CALL_CONF_IND); |
| 471 | ms_sends_msg("8348" /* CC: Call Confirmed */ |
| 472 | "0406600402000581" /* Bearer Capability */ |
| 473 | "15020100" /* Call Control Capabilities */ |
| 474 | "40080402600400021f00" /* Supported Codec List */); |
Neels Hofmeyr | 81938fd | 2022-01-14 03:39:58 +0100 | [diff] [blame^] | 475 | OSMO_ASSERT(crcx_scheduled(RTP_TO_RAN)); |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 476 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 477 | |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 478 | btw("MNCC sends MNCC_RTP_CREATE"); |
| 479 | mncc_sends_to_cc(MNCC_RTP_CREATE, &mncc); |
| 480 | |
| 481 | btw("MGW acknowledges the CRCX to RAN, triggering Assignment"); |
| 482 | expect_iu_rab_assignment(); |
| 483 | crcx_ok(RTP_TO_RAN); |
| 484 | OSMO_ASSERT(iu_rab_assignment_sent); |
| 485 | |
| 486 | btw("Assignment completes, triggering CRCX to CN"); |
| 487 | expect_crcx(RTP_TO_CN); |
Neels Hofmeyr | cec51b3 | 2023-03-01 03:47:45 +0100 | [diff] [blame] | 488 | ms_sends_assignment_complete("AMR"); |
Neels Hofmeyr | 81938fd | 2022-01-14 03:39:58 +0100 | [diff] [blame^] | 489 | OSMO_ASSERT(crcx_scheduled(RTP_TO_CN)); |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 490 | |
| 491 | btw("When the CN side RTP address is known, send MNCC_RTP_CREATE"); |
| 492 | cc_to_mncc_expect_tx("", MNCC_RTP_CREATE); |
| 493 | crcx_ok(RTP_TO_CN); |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 494 | fake_time_passes(1, 23); |
| 495 | |
| 496 | cc_to_mncc_expect_tx("", MNCC_ALERT_IND); |
| 497 | ms_sends_msg("8381" /* CC: Alerting */); |
| 498 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 499 | |
| 500 | fake_time_passes(15, 23); |
| 501 | |
| 502 | btw("The call failed, the BSC sends a BSSMAP Clear Request"); |
Vadim Yanitskiy | dd466cf | 2021-02-05 19:17:31 +0100 | [diff] [blame] | 503 | cc_to_mncc_expect_tx("", MNCC_REL_IND); |
Keith Whyte | ff17f8f | 2019-08-01 12:20:25 +0200 | [diff] [blame] | 504 | dtap_expect_tx("032d0802e1af"); /* CC: Release */ |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 505 | expect_iu_release(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 506 | msc_a_release_cn(msub_msc_a(g_msub)); |
| 507 | OSMO_ASSERT(dtap_tx_confirmed); |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 508 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 509 | OSMO_ASSERT(iu_release_sent); |
| 510 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 511 | ran_sends_clear_complete(); |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 512 | EXPECT_CONN_COUNT(0); |
| 513 | |
| 514 | /* Make sure a pending release timer doesn't fire later to access freed data */ |
| 515 | fake_time_passes(15, 23); |
| 516 | |
| 517 | clear_vlr(); |
| 518 | comment_end(); |
| 519 | } |
| 520 | |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 521 | static void test_call_mo_to_unknown() |
| 522 | { |
| 523 | struct gsm_mncc mncc = { |
| 524 | .imsi = IMSI, |
| 525 | }; |
| 526 | |
| 527 | comment_start(); |
| 528 | |
| 529 | fake_time_start(); |
| 530 | |
Neels Hofmeyr | 11bf0bc | 2019-10-21 05:55:49 +0200 | [diff] [blame] | 531 | lu_utran_tmsi(); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 532 | |
| 533 | BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector"); |
| 534 | auth_request_sent = false; |
| 535 | auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d"; |
| 536 | auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9"; |
| 537 | cm_service_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 538 | ms_sends_msg("052471" |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 539 | "03575886" /* classmark 2 */ |
| 540 | "089910070000106005" /* IMSI */); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 541 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 542 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 543 | |
| 544 | btw("needs auth, not yet accepted"); |
| 545 | EXPECT_ACCEPTED(false); |
| 546 | |
| 547 | /* On UTRAN */ |
| 548 | btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl"); |
| 549 | expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d"); |
| 550 | ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */ |
| 551 | VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d"); |
| 552 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 553 | |
| 554 | btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept"); |
Alexander Couzens | 2aaff75 | 2021-10-19 17:09:11 +0200 | [diff] [blame] | 555 | ms_sends_security_mode_complete(1); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 556 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 557 | |
| 558 | BTW("a call is initiated"); |
| 559 | |
| 560 | btw("SETUP gets forwarded to MNCC"); |
| 561 | cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_IND); |
| 562 | ms_sends_msg("0385" /* CC, seq = 2 -> 0x80 | CC Setup = 0x5 */ |
| 563 | "0406600402000581" /* Bearer Capability */ |
| 564 | "5e038121f3" /* Called Number BCD */ |
| 565 | "15020100" /* CC Capabilities */ |
| 566 | "4008" /* Supported Codec List */ |
| 567 | "04026000" /* UMTS: AMR 2 | AMR */ |
| 568 | "00021f00" /* GSM: HR AMR | FR AMR | GSM EFR | GSM HR | GSM FR */ |
| 569 | ); |
| 570 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 571 | mncc.callref = cc_to_mncc_tx_got_callref; |
| 572 | |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 573 | btw("MNCC replies with MNCC_RTP_CREATE, causing MGW endpoint CRCX to RAN"); |
| 574 | expect_crcx(RTP_TO_RAN); |
| 575 | mncc_sends_to_cc(MNCC_RTP_CREATE, &mncc); |
Neels Hofmeyr | 81938fd | 2022-01-14 03:39:58 +0100 | [diff] [blame^] | 576 | OSMO_ASSERT(crcx_scheduled(RTP_TO_RAN)); |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 577 | |
| 578 | btw("MGW acknowledges the CRCX, triggering Assignment"); |
| 579 | expect_iu_rab_assignment(); |
| 580 | crcx_ok(RTP_TO_RAN); |
| 581 | OSMO_ASSERT(iu_rab_assignment_sent); |
| 582 | |
| 583 | btw("Assignment succeeds, triggering CRCX to CN"); |
| 584 | expect_crcx(RTP_TO_CN); |
Neels Hofmeyr | cec51b3 | 2023-03-01 03:47:45 +0100 | [diff] [blame] | 585 | ms_sends_assignment_complete("AMR"); |
Neels Hofmeyr | 81938fd | 2022-01-14 03:39:58 +0100 | [diff] [blame^] | 586 | OSMO_ASSERT(crcx_scheduled(RTP_TO_CN)); |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 587 | |
| 588 | btw("CN RTP address is available, trigger MNCC_RTP_CREATE"); |
| 589 | cc_to_mncc_expect_tx("", MNCC_RTP_CREATE); |
| 590 | crcx_ok(RTP_TO_CN); |
| 591 | |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 592 | btw("MNCC says that's fine"); |
| 593 | dtap_expect_tx("8302" /* CC: Call Proceeding */); |
| 594 | mncc_sends_to_cc(MNCC_CALL_PROC_REQ, &mncc); |
| 595 | OSMO_ASSERT(dtap_tx_confirmed); |
| 596 | |
| 597 | btw("But the other side's MSISDN could not be resolved, MNCC tells us to cancel"); |
| 598 | dtap_expect_tx("832d" /* CC: Release Request */); |
| 599 | mncc_sends_to_cc(MNCC_REL_REQ, &mncc); |
| 600 | |
| 601 | dtap_expect_tx("832d" /* CC: Release Request */); |
| 602 | fake_time_passes(10, 23); |
| 603 | |
| 604 | expect_iu_release(); |
| 605 | cc_to_mncc_expect_tx("", MNCC_REL_CNF); |
| 606 | ms_sends_msg("036a" /* CC: Release Complete */); |
| 607 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 608 | OSMO_ASSERT(iu_release_sent); |
| 609 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 610 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 611 | ran_sends_clear_complete(); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 612 | EXPECT_CONN_COUNT(0); |
| 613 | clear_vlr(); |
| 614 | comment_end(); |
| 615 | } |
| 616 | |
| 617 | static void test_call_mo_to_unknown_timeout() |
| 618 | { |
| 619 | struct gsm_mncc mncc = { |
| 620 | .imsi = IMSI, |
| 621 | }; |
| 622 | |
| 623 | comment_start(); |
| 624 | |
| 625 | fake_time_start(); |
| 626 | |
Neels Hofmeyr | 11bf0bc | 2019-10-21 05:55:49 +0200 | [diff] [blame] | 627 | lu_utran_tmsi(); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 628 | |
| 629 | BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector"); |
| 630 | auth_request_sent = false; |
| 631 | auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d"; |
| 632 | auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9"; |
| 633 | cm_service_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 634 | ms_sends_msg("052471" |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 635 | "03575886" /* classmark 2 */ |
| 636 | "089910070000106005" /* IMSI */); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 637 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 638 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 639 | |
| 640 | btw("needs auth, not yet accepted"); |
| 641 | EXPECT_ACCEPTED(false); |
| 642 | |
| 643 | /* On UTRAN */ |
| 644 | btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl"); |
| 645 | expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d"); |
| 646 | ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */ |
| 647 | VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d"); |
| 648 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 649 | |
| 650 | btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept"); |
Alexander Couzens | 2aaff75 | 2021-10-19 17:09:11 +0200 | [diff] [blame] | 651 | ms_sends_security_mode_complete(1); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 652 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 653 | |
| 654 | BTW("a call is initiated"); |
| 655 | |
| 656 | btw("SETUP gets forwarded to MNCC"); |
| 657 | cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_IND); |
| 658 | ms_sends_msg("0385" /* CC, seq = 2 -> 0x80 | CC Setup = 0x5 */ |
| 659 | "0406600402000581" /* Bearer Capability */ |
| 660 | "5e038121f3" /* Called Number BCD */ |
| 661 | "15020100" /* CC Capabilities */ |
| 662 | "4008" /* Supported Codec List */ |
| 663 | "04026000" /* UMTS: AMR 2 | AMR */ |
| 664 | "00021f00" /* GSM: HR AMR | FR AMR | GSM EFR | GSM HR | GSM FR */ |
| 665 | ); |
| 666 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
| 667 | mncc.callref = cc_to_mncc_tx_got_callref; |
| 668 | |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 669 | btw("MNCC replies with MNCC_RTP_CREATE, causing MGW endpoint CRCX to RAN"); |
| 670 | expect_crcx(RTP_TO_RAN); |
| 671 | mncc_sends_to_cc(MNCC_RTP_CREATE, &mncc); |
Neels Hofmeyr | 81938fd | 2022-01-14 03:39:58 +0100 | [diff] [blame^] | 672 | OSMO_ASSERT(crcx_scheduled(RTP_TO_RAN)); |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 673 | |
| 674 | btw("MGW acknowledges the CRCX, triggering Assignment"); |
| 675 | expect_iu_rab_assignment(); |
| 676 | crcx_ok(RTP_TO_RAN); |
| 677 | OSMO_ASSERT(iu_rab_assignment_sent); |
| 678 | |
| 679 | btw("Assignment succeeds, triggering CRCX to CN"); |
| 680 | expect_crcx(RTP_TO_CN); |
Neels Hofmeyr | cec51b3 | 2023-03-01 03:47:45 +0100 | [diff] [blame] | 681 | ms_sends_assignment_complete("AMR"); |
Neels Hofmeyr | 81938fd | 2022-01-14 03:39:58 +0100 | [diff] [blame^] | 682 | OSMO_ASSERT(crcx_scheduled(RTP_TO_CN)); |
Neels Hofmeyr | 3f391dd | 2019-08-29 03:53:11 +0200 | [diff] [blame] | 683 | |
| 684 | btw("CN RTP address is available, trigger MNCC_RTP_CREATE"); |
| 685 | cc_to_mncc_expect_tx("", MNCC_RTP_CREATE); |
| 686 | crcx_ok(RTP_TO_CN); |
| 687 | |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 688 | btw("MNCC says that's fine"); |
| 689 | dtap_expect_tx("8302" /* CC: Call Proceeding */); |
| 690 | mncc_sends_to_cc(MNCC_CALL_PROC_REQ, &mncc); |
| 691 | OSMO_ASSERT(dtap_tx_confirmed); |
| 692 | |
| 693 | btw("But the other side's MSISDN could not be resolved, MNCC tells us to cancel"); |
| 694 | dtap_expect_tx("832d" /* CC: Release Request */); |
| 695 | mncc_sends_to_cc(MNCC_REL_REQ, &mncc); |
| 696 | |
| 697 | btw("Despite our repeated CC Release Requests, the MS does not respond anymore"); |
| 698 | dtap_expect_tx("832d" /* CC: Release Request */); |
| 699 | fake_time_passes(10, 23); |
| 700 | |
| 701 | btw("The CC Release times out and we still properly clear the conn"); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 702 | cc_to_mncc_expect_tx("", MNCC_REL_CNF); |
Neels Hofmeyr | d6a769b | 2018-03-12 23:59:07 +0100 | [diff] [blame] | 703 | expect_iu_release(); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 704 | fake_time_passes(10, 23); |
| 705 | OSMO_ASSERT(cc_to_mncc_tx_confirmed); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 706 | OSMO_ASSERT(iu_release_sent); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 707 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 708 | ran_sends_clear_complete(); |
Neels Hofmeyr | d6a769b | 2018-03-12 23:59:07 +0100 | [diff] [blame] | 709 | EXPECT_CONN_COUNT(0); |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 710 | clear_vlr(); |
| 711 | comment_end(); |
| 712 | } |
| 713 | |
| 714 | |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 715 | msc_vlr_test_func_t msc_vlr_tests[] = { |
| 716 | test_call_mo, |
| 717 | test_call_mt, |
Neels Hofmeyr | cbcf89c | 2018-03-13 17:52:07 +0100 | [diff] [blame] | 718 | test_call_mt2, |
Neels Hofmeyr | eb1cfdb | 2018-03-15 13:42:10 +0100 | [diff] [blame] | 719 | test_call_mo_to_unknown, |
| 720 | test_call_mo_to_unknown_timeout, |
Neels Hofmeyr | a99b427 | 2017-11-21 17:13:23 +0100 | [diff] [blame] | 721 | NULL |
| 722 | }; |