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