blob: 29639b57d83261329baba3323945bc065d0a35f6 [file] [log] [blame]
Neels Hofmeyra99b4272017-11-21 17:13:23 +01001/* 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"
Harald Welte0df904d2018-12-03 11:00:04 +010025#include "stubs.h"
Neels Hofmeyra99b4272017-11-21 17:13:23 +010026
27#include <osmocom/msc/gsm_04_08.h>
28
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010029static void mncc_sends_to_cc(uint32_t msg_type, struct gsm_mncc *mncc)
Neels Hofmeyra99b4272017-11-21 17:13:23 +010030{
31 mncc->msg_type = msg_type;
32 mncc_tx_to_cc(net, msg_type, mncc);
33}
34
Neels Hofmeyrcbcf89c2018-03-13 17:52:07 +010035static void on_call_release_mncc_sends_to_cc(uint32_t msg_type, struct gsm_mncc *mncc)
36{
37 mncc->msg_type = msg_type;
38 on_call_release_mncc_sends_to_cc_data = mncc;
39}
40
Neels Hofmeyra99b4272017-11-21 17:13:23 +010041#define IMSI "901700000010650"
42
43static void standard_lu()
44{
45 struct vlr_subscr *vsub;
46
47 net->authentication_required = true;
48 net->vlr->cfg.assign_tmsi = true;
Neels Hofmeyr7814a832018-12-26 00:40:18 +010049 rx_from_ran = OSMO_RAT_UTRAN_IU;
Neels Hofmeyra99b4272017-11-21 17:13:23 +010050
51 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
52 lu_result_sent = RES_NONE;
53 gsup_expect_tx("080108" "09710000000156f0");
54 ms_sends_msg("0508" /* MM LU */
55 "7" /* ciph key seq: no key available */
56 "0" /* LU type: normal */
57 "09f107" "0017" /* LAI, LAC */
58 "57" /* classmark 1: R99, early classmark, no power lvl */
59 "089910070000106005" /* IMSI */
60 "3303575886" /* classmark 2 */
61 );
62 OSMO_ASSERT(gsup_tx_confirmed);
63 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
64
65 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
66 /* based on auc_3g:
67 * K = 'EB215756028D60E3275E613320AEC880',
68 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
69 * SQN = 0
70 */
71 auth_request_sent = false;
72 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
73 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
74 gsup_rx("0a"
75 /* imsi */
76 "0108" "09710000000156f0"
77 /* 5 auth vectors... */
78 /* TL TL rand */
79 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
80 /* TL sres TL kc */
81 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
82 /* TL 3G IK */
83 "2310" "27497388b6cb044648f396aa155b95ef"
84 /* TL 3G CK */
85 "2410" "f64735036e5871319c679f4742a75ea1"
86 /* TL AUTN */
87 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
88 /* TL RES */
89 "2708" "e229c19e791f2e41"
90 /* TL TL rand */
91 "0362" "2010" "c187a53a5e6b9d573cac7c74451fd46d"
92 "2104" "85aa3130" "2208" "d3d50a000bf04f6e"
93 "2310" "1159ec926a50e98c034a6b7d7c9f418d"
94 "2410" "df3a03d9ca5335641efc8e36d76cd20b"
95 "2510" "1843a645b98d00005b2d666af46c45d9"
96 "2708" "7db47cf7f81e4dc7"
97 "0362" "2010" "efa9c29a9742148d5c9070348716e1bb"
98 "2104" "69d5f9fb" "2208" "3df176f0c29f1a3d"
99 "2310" "eb50e770ddcc3060101d2f43b6c2b884"
100 "2410" "76542abce5ff9345b0e8947f4c6e019c"
101 "2510" "f9375e6d41e1000096e7fe4ff1c27e39"
102 "2708" "706f996719ba609c"
103 "0362" "2010" "f023d5a3b24726e0631b64b3840f8253"
104 "2104" "d570c03f" "2208" "ec011be8919883d6"
105 "2310" "c4e58af4ba43f3bcd904e16984f086d7"
106 "2410" "0593f65e752e5cb7f473862bda05aa0a"
107 "2510" "541ff1f077270000c5ea00d658bc7e9a"
108 "2708" "3fd26072eaa2a04d"
109 "0362" "2010" "2f8f90c780d6a9c0c53da7ac57b6707e"
110 "2104" "b072446f220823f39f9f425ad6e6"
111 "2310" "65af0527fda95b0dc5ae4aa515cdf32f"
112 "2410" "537c3b35a3b13b08d08eeb28098f45cc"
113 "2510" "4bf4e564f75300009bc796706bc65744"
114 "2708" "0edb0eadbea94ac2",
115 NULL);
116 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
117 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
118
119 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100120 expect_security_mode_ctrl(NULL, "27497388b6cb044648f396aa155b95ef");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100121 ms_sends_msg("0554" "e229c19e" "2104" "791f2e41");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100122 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100123 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
124
125 btw("MS sends SecurityModeControl acceptance, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200126 gsup_expect_tx("04010809710000000156f0280102");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100127 ms_sends_security_mode_complete();
128 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
129 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
130
131 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
132 gsup_rx("10010809710000000156f00804032443f2",
133 "12010809710000000156f0");
134 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
135
136 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
137 gsup_rx("06010809710000000156f0", NULL);
138
139 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
140
141 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
142 EXPECT_CONN_COUNT(1);
143 EXPECT_ACCEPTED(false);
144
145 btw("MS sends TMSI Realloc Complete");
146 iu_release_expected = true;
147 iu_release_sent = false;
148 ms_sends_msg("055b");
149 VERBOSE_ASSERT(iu_release_sent, == true, "%d"); \
150
151 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200152 rnc_sends_release_complete();
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100153 EXPECT_CONN_COUNT(0);
154
155 vsub = vlr_subscr_find_by_imsi(net->vlr, IMSI);
156 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
157 VERBOSE_ASSERT(strcmp(vsub->imsi, IMSI), == 0, "%d");
Max7d41d872018-12-19 11:48:33 +0100158 VAL_ASSERT("LAC", vsub->cgi.lai.lac, == 23, "%u");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100159 vlr_subscr_put(vsub);
160}
161
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100162static void test_call_mo()
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100163{
164 struct gsm_mncc mncc = {
165 .imsi = IMSI,
166 };
167
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100168 comment_start();
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100169
170 fake_time_start();
171
172 standard_lu();
173
174 BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector");
175 auth_request_sent = false;
176 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
177 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
178 cm_service_result_sent = RES_NONE;
179 ms_sends_msg("052478"
180 "03575886" /* classmark 2 */
181 "089910070000106005" /* IMSI */);
182 OSMO_ASSERT(g_conn);
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +0200183 OSMO_ASSERT(g_conn->fi);
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100184 OSMO_ASSERT(g_conn->vsub);
185 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
186 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
187
188 btw("needs auth, not yet accepted");
189 EXPECT_ACCEPTED(false);
190
191 /* On UTRAN */
192 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100193 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100194 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100195 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100196 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
197
198 btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept");
199 ms_sends_security_mode_complete();
200 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
201
202 BTW("a call is initiated");
203
204 btw("SETUP gets forwarded to MNCC");
205 cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_IND);
206 ms_sends_msg("0385" /* CC, seq = 2 -> 0x80 | CC Setup = 0x5 */
207 "0406600402000581" /* Bearer Capability */
208 "5e038121f3" /* Called Number BCD */
209 "15020100" /* CC Capabilities */
210 "4008" /* Supported Codec List */
211 "04026000" /* UMTS: AMR 2 | AMR */
212 "00021f00" /* GSM: HR AMR | FR AMR | GSM EFR | GSM HR | GSM FR */
213 );
214 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
215 mncc.callref = cc_to_mncc_tx_got_callref;
216
217 btw("MNCC says that's fine");
218 dtap_expect_tx("8302" /* CC: Call Proceeding */);
219 mncc_sends_to_cc(MNCC_CALL_PROC_REQ, &mncc);
220 OSMO_ASSERT(dtap_tx_confirmed);
221
222 fake_time_passes(1, 23);
223
224 btw("The other call leg got established (not shown here), MNCC tells us so");
225 dtap_expect_tx("8301" /* CC: Call Alerting */);
226 mncc_sends_to_cc(MNCC_ALERT_REQ, &mncc);
227 OSMO_ASSERT(dtap_tx_confirmed);
228
229 dtap_expect_tx("8307" /* CC: Connect */);
230 mncc_sends_to_cc(MNCC_SETUP_RSP, &mncc);
231 OSMO_ASSERT(dtap_tx_confirmed);
232
233 fake_time_passes(1, 23);
234
235 cc_to_mncc_expect_tx("", MNCC_SETUP_COMPL_IND);
236 ms_sends_msg("03cf" /* CC: Connect Acknowledge */);
237 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
238
239 BTW("RTP stream goes ahead, not shown here.");
240 fake_time_passes(123, 45);
241
242 BTW("Call ends");
243 cc_to_mncc_expect_tx("", MNCC_DISC_IND);
244 ms_sends_msg("032502e090" /* CC: Disconnect, cause: Normal Call Clearing */);
245 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
246
247 dtap_expect_tx("832d" /* CC: Release */);
248 mncc_sends_to_cc(MNCC_REL_REQ, &mncc);
249 OSMO_ASSERT(dtap_tx_confirmed);
250
251 cc_to_mncc_expect_tx("", MNCC_REL_CNF);
252 expect_iu_release();
253 ms_sends_msg("036a" /* CC: Release Complete */);
254 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
255 OSMO_ASSERT(iu_release_sent);
256
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200257 rnc_sends_release_complete();
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100258 EXPECT_CONN_COUNT(0);
259 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100260 comment_end();
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100261}
262
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100263static void test_call_mt()
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100264{
265 struct gsm_mncc mncc = {
266 .imsi = IMSI,
267 .callref = 0x423,
268 };
269
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100270 comment_start();
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100271
272 fake_time_start();
273
274 standard_lu();
275
276 BTW("after a while, MNCC asks us to setup a call, causing Paging");
277
278 paging_expect_imsi(IMSI);
279 paging_sent = false;
280 mncc_sends_to_cc(MNCC_SETUP_REQ, &mncc);
281
282 VERBOSE_ASSERT(paging_sent, == true, "%d");
283 VERBOSE_ASSERT(paging_stopped, == false, "%d");
284
285 btw("MS replies with Paging Response, and VLR sends Auth Request");
286 auth_request_sent = false;
287 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
288 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
289 ms_sends_msg("062707"
290 "03575886" /* classmark 2 */
291 "089910070000106005" /* IMSI */);
292 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
293
294 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100295 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100296 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100297 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100298
299 btw("MS sends SecurityModeControl acceptance, VLR accepts, sends CC Setup");
300 dtap_expect_tx("0305" /* CC: Setup */);
301 ms_sends_security_mode_complete();
302 VERBOSE_ASSERT(paging_stopped, == true, "%d");
303
304 cc_to_mncc_expect_tx(IMSI, MNCC_CALL_CONF_IND);
305 ms_sends_msg("8348" /* CC: Call Confirmed */
306 "0406600402000581" /* Bearer Capability */
307 "15020100" /* Call Control Capabilities */
308 "40080402600400021f00" /* Supported Codec List */);
309
310 fake_time_passes(1, 23);
311
312 cc_to_mncc_expect_tx("", MNCC_ALERT_IND);
313 ms_sends_msg("8381" /* CC: Alerting */);
314
315 fake_time_passes(1, 23);
316
317 cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_CNF);
318 ms_sends_msg("83c7" /* CC: Connect */);
319
320 dtap_expect_tx("030f" /* CC: Connect Acknowledge */);
321 mncc_sends_to_cc(MNCC_SETUP_COMPL_REQ, &mncc);
322
323 BTW("RTP stream goes ahead, not shown here.");
324 fake_time_passes(123, 45);
325
326 BTW("Call ends");
327 cc_to_mncc_expect_tx("", MNCC_DISC_IND);
328 ms_sends_msg("832502e090" /* CC: Disconnect, cause: Normal Call Clearing */);
329 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
330
331 dtap_expect_tx("032d" /* CC: Release */);
332 mncc_sends_to_cc(MNCC_REL_REQ, &mncc);
333 OSMO_ASSERT(dtap_tx_confirmed);
334
335 cc_to_mncc_expect_tx("", MNCC_REL_CNF);
336 expect_iu_release();
337 ms_sends_msg("836a" /* CC: Release Complete */);
338 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
339 OSMO_ASSERT(iu_release_sent);
340
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200341 rnc_sends_release_complete();
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100342 EXPECT_CONN_COUNT(0);
343 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100344 comment_end();
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100345}
346
Neels Hofmeyrcbcf89c2018-03-13 17:52:07 +0100347static void test_call_mt2()
348{
349 struct gsm_mncc mncc = {
350 .imsi = IMSI,
351 .callref = 0x423,
352 };
353
354 comment_start();
355
356 fake_time_start();
357
358 standard_lu();
359
360 BTW("after a while, MNCC asks us to setup a call, causing Paging");
361
362 paging_expect_imsi(IMSI);
363 paging_sent = false;
364 mncc_sends_to_cc(MNCC_SETUP_REQ, &mncc);
365
366 VERBOSE_ASSERT(paging_sent, == true, "%d");
367 VERBOSE_ASSERT(paging_stopped, == false, "%d");
368
369 btw("MS replies with Paging Response, and VLR sends Auth Request");
370 auth_request_sent = false;
371 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
372 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
373 ms_sends_msg("062707"
374 "03575886" /* classmark 2 */
375 "089910070000106005" /* IMSI */);
376 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
377
378 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
379 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
380 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
381 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
382
383 btw("MS sends SecurityModeControl acceptance, VLR accepts, sends CC Setup");
384 dtap_expect_tx("0305" /* CC: Setup */);
385 ms_sends_security_mode_complete();
386 VERBOSE_ASSERT(paging_stopped, == true, "%d");
387
388 cc_to_mncc_expect_tx(IMSI, MNCC_CALL_CONF_IND);
389 ms_sends_msg("8348" /* CC: Call Confirmed */
390 "0406600402000581" /* Bearer Capability */
391 "15020100" /* Call Control Capabilities */
392 "40080402600400021f00" /* Supported Codec List */);
393 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
394
395 fake_time_passes(1, 23);
396
397 cc_to_mncc_expect_tx("", MNCC_ALERT_IND);
398 ms_sends_msg("8381" /* CC: Alerting */);
399 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
400
401 fake_time_passes(15, 23);
402
403 btw("The call failed, the BSC sends a BSSMAP Clear Request");
404 on_call_release_mncc_sends_to_cc(MNCC_REL_REQ, &mncc);
405 cc_to_mncc_expect_tx("", MNCC_REL_CNF);
406 dtap_expect_tx("032d"); /* CC: Release */
407 expect_iu_release();
Neels Hofmeyr3c20a5e2018-11-30 01:08:36 +0100408 ran_conn_clear_request(g_conn, 0);
Neels Hofmeyrcbcf89c2018-03-13 17:52:07 +0100409 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
410 OSMO_ASSERT(iu_release_sent);
411
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200412 rnc_sends_release_complete();
Neels Hofmeyrcbcf89c2018-03-13 17:52:07 +0100413 EXPECT_CONN_COUNT(0);
414
415 /* Make sure a pending release timer doesn't fire later to access freed data */
416 fake_time_passes(15, 23);
417
418 clear_vlr();
419 comment_end();
420}
421
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100422static void test_call_mo_to_unknown()
423{
424 struct gsm_mncc mncc = {
425 .imsi = IMSI,
426 };
427
428 comment_start();
429
430 fake_time_start();
431
432 standard_lu();
433
434 BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector");
435 auth_request_sent = false;
436 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
437 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
438 cm_service_result_sent = RES_NONE;
439 ms_sends_msg("052478"
440 "03575886" /* classmark 2 */
441 "089910070000106005" /* IMSI */);
442 OSMO_ASSERT(g_conn);
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +0200443 OSMO_ASSERT(g_conn->fi);
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100444 OSMO_ASSERT(g_conn->vsub);
445 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
446 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
447
448 btw("needs auth, not yet accepted");
449 EXPECT_ACCEPTED(false);
450
451 /* On UTRAN */
452 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
453 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
454 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
455 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
456 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
457
458 btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept");
459 ms_sends_security_mode_complete();
460 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
461
462 BTW("a call is initiated");
463
464 btw("SETUP gets forwarded to MNCC");
465 cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_IND);
466 ms_sends_msg("0385" /* CC, seq = 2 -> 0x80 | CC Setup = 0x5 */
467 "0406600402000581" /* Bearer Capability */
468 "5e038121f3" /* Called Number BCD */
469 "15020100" /* CC Capabilities */
470 "4008" /* Supported Codec List */
471 "04026000" /* UMTS: AMR 2 | AMR */
472 "00021f00" /* GSM: HR AMR | FR AMR | GSM EFR | GSM HR | GSM FR */
473 );
474 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
475 mncc.callref = cc_to_mncc_tx_got_callref;
476
477 btw("MNCC says that's fine");
478 dtap_expect_tx("8302" /* CC: Call Proceeding */);
479 mncc_sends_to_cc(MNCC_CALL_PROC_REQ, &mncc);
480 OSMO_ASSERT(dtap_tx_confirmed);
481
482 btw("But the other side's MSISDN could not be resolved, MNCC tells us to cancel");
483 dtap_expect_tx("832d" /* CC: Release Request */);
484 mncc_sends_to_cc(MNCC_REL_REQ, &mncc);
485
486 dtap_expect_tx("832d" /* CC: Release Request */);
487 fake_time_passes(10, 23);
488
489 expect_iu_release();
490 cc_to_mncc_expect_tx("", MNCC_REL_CNF);
491 ms_sends_msg("036a" /* CC: Release Complete */);
492 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
493 OSMO_ASSERT(iu_release_sent);
494 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
495
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200496 rnc_sends_release_complete();
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100497 EXPECT_CONN_COUNT(0);
498 clear_vlr();
499 comment_end();
500}
501
502static void test_call_mo_to_unknown_timeout()
503{
504 struct gsm_mncc mncc = {
505 .imsi = IMSI,
506 };
507
508 comment_start();
509
510 fake_time_start();
511
512 standard_lu();
513
514 BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector");
515 auth_request_sent = false;
516 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
517 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
518 cm_service_result_sent = RES_NONE;
519 ms_sends_msg("052478"
520 "03575886" /* classmark 2 */
521 "089910070000106005" /* IMSI */);
522 OSMO_ASSERT(g_conn);
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +0200523 OSMO_ASSERT(g_conn->fi);
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100524 OSMO_ASSERT(g_conn->vsub);
525 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
526 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
527
528 btw("needs auth, not yet accepted");
529 EXPECT_ACCEPTED(false);
530
531 /* On UTRAN */
532 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
533 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
534 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
535 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
536 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
537
538 btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept");
539 ms_sends_security_mode_complete();
540 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
541
542 BTW("a call is initiated");
543
544 btw("SETUP gets forwarded to MNCC");
545 cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_IND);
546 ms_sends_msg("0385" /* CC, seq = 2 -> 0x80 | CC Setup = 0x5 */
547 "0406600402000581" /* Bearer Capability */
548 "5e038121f3" /* Called Number BCD */
549 "15020100" /* CC Capabilities */
550 "4008" /* Supported Codec List */
551 "04026000" /* UMTS: AMR 2 | AMR */
552 "00021f00" /* GSM: HR AMR | FR AMR | GSM EFR | GSM HR | GSM FR */
553 );
554 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
555 mncc.callref = cc_to_mncc_tx_got_callref;
556
557 btw("MNCC says that's fine");
558 dtap_expect_tx("8302" /* CC: Call Proceeding */);
559 mncc_sends_to_cc(MNCC_CALL_PROC_REQ, &mncc);
560 OSMO_ASSERT(dtap_tx_confirmed);
561
562 btw("But the other side's MSISDN could not be resolved, MNCC tells us to cancel");
563 dtap_expect_tx("832d" /* CC: Release Request */);
564 mncc_sends_to_cc(MNCC_REL_REQ, &mncc);
565
566 btw("Despite our repeated CC Release Requests, the MS does not respond anymore");
567 dtap_expect_tx("832d" /* CC: Release Request */);
568 fake_time_passes(10, 23);
569
570 btw("The CC Release times out and we still properly clear the conn");
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100571 cc_to_mncc_expect_tx("", MNCC_REL_CNF);
Neels Hofmeyrd6a769b2018-03-12 23:59:07 +0100572 expect_iu_release();
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100573 fake_time_passes(10, 23);
574 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100575 OSMO_ASSERT(iu_release_sent);
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100576
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200577 rnc_sends_release_complete();
Neels Hofmeyrd6a769b2018-03-12 23:59:07 +0100578 EXPECT_CONN_COUNT(0);
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100579 clear_vlr();
580 comment_end();
581}
582
583
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100584msc_vlr_test_func_t msc_vlr_tests[] = {
585 test_call_mo,
586 test_call_mt,
Neels Hofmeyrcbcf89c2018-03-13 17:52:07 +0100587 test_call_mt2,
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100588 test_call_mo_to_unknown,
589 test_call_mo_to_unknown_timeout,
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100590 NULL
591};