blob: 9d4126e407e3c4472ebef023d1382593ccbab5f3 [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");
125 gsup_expect_tx("04010809710000000156f0");
126 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");
151 EXPECT_CONN_COUNT(0);
152
153 vsub = vlr_subscr_find_by_imsi(net->vlr, IMSI);
154 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
155 VERBOSE_ASSERT(strcmp(vsub->imsi, IMSI), == 0, "%d");
156 VERBOSE_ASSERT(vsub->lac, == 23, "%u");
157 vlr_subscr_put(vsub);
158}
159
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100160static void test_call_mo()
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100161{
162 struct gsm_mncc mncc = {
163 .imsi = IMSI,
164 };
165
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100166 comment_start();
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100167
168 fake_time_start();
169
170 standard_lu();
171
172 BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector");
173 auth_request_sent = false;
174 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
175 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
176 cm_service_result_sent = RES_NONE;
177 ms_sends_msg("052478"
178 "03575886" /* classmark 2 */
179 "089910070000106005" /* IMSI */);
180 OSMO_ASSERT(g_conn);
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +0200181 OSMO_ASSERT(g_conn->fi);
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100182 OSMO_ASSERT(g_conn->vsub);
183 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
184 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
185
186 btw("needs auth, not yet accepted");
187 EXPECT_ACCEPTED(false);
188
189 /* On UTRAN */
190 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100191 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100192 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100193 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100194 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
195
196 btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept");
197 ms_sends_security_mode_complete();
198 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
199
200 BTW("a call is initiated");
201
202 btw("SETUP gets forwarded to MNCC");
203 cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_IND);
204 ms_sends_msg("0385" /* CC, seq = 2 -> 0x80 | CC Setup = 0x5 */
205 "0406600402000581" /* Bearer Capability */
206 "5e038121f3" /* Called Number BCD */
207 "15020100" /* CC Capabilities */
208 "4008" /* Supported Codec List */
209 "04026000" /* UMTS: AMR 2 | AMR */
210 "00021f00" /* GSM: HR AMR | FR AMR | GSM EFR | GSM HR | GSM FR */
211 );
212 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
213 mncc.callref = cc_to_mncc_tx_got_callref;
214
215 btw("MNCC says that's fine");
216 dtap_expect_tx("8302" /* CC: Call Proceeding */);
217 mncc_sends_to_cc(MNCC_CALL_PROC_REQ, &mncc);
218 OSMO_ASSERT(dtap_tx_confirmed);
219
220 fake_time_passes(1, 23);
221
222 btw("The other call leg got established (not shown here), MNCC tells us so");
223 dtap_expect_tx("8301" /* CC: Call Alerting */);
224 mncc_sends_to_cc(MNCC_ALERT_REQ, &mncc);
225 OSMO_ASSERT(dtap_tx_confirmed);
226
227 dtap_expect_tx("8307" /* CC: Connect */);
228 mncc_sends_to_cc(MNCC_SETUP_RSP, &mncc);
229 OSMO_ASSERT(dtap_tx_confirmed);
230
231 fake_time_passes(1, 23);
232
233 cc_to_mncc_expect_tx("", MNCC_SETUP_COMPL_IND);
234 ms_sends_msg("03cf" /* CC: Connect Acknowledge */);
235 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
236
237 BTW("RTP stream goes ahead, not shown here.");
238 fake_time_passes(123, 45);
239
240 BTW("Call ends");
241 cc_to_mncc_expect_tx("", MNCC_DISC_IND);
242 ms_sends_msg("032502e090" /* CC: Disconnect, cause: Normal Call Clearing */);
243 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
244
245 dtap_expect_tx("832d" /* CC: Release */);
246 mncc_sends_to_cc(MNCC_REL_REQ, &mncc);
247 OSMO_ASSERT(dtap_tx_confirmed);
248
249 cc_to_mncc_expect_tx("", MNCC_REL_CNF);
250 expect_iu_release();
251 ms_sends_msg("036a" /* CC: Release Complete */);
252 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
253 OSMO_ASSERT(iu_release_sent);
254
255 EXPECT_CONN_COUNT(0);
256 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100257 comment_end();
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100258}
259
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100260static void test_call_mt()
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100261{
262 struct gsm_mncc mncc = {
263 .imsi = IMSI,
264 .callref = 0x423,
265 };
266
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100267 comment_start();
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100268
269 fake_time_start();
270
271 standard_lu();
272
273 BTW("after a while, MNCC asks us to setup a call, causing Paging");
274
275 paging_expect_imsi(IMSI);
276 paging_sent = false;
277 mncc_sends_to_cc(MNCC_SETUP_REQ, &mncc);
278
279 VERBOSE_ASSERT(paging_sent, == true, "%d");
280 VERBOSE_ASSERT(paging_stopped, == false, "%d");
281
282 btw("MS replies with Paging Response, and VLR sends Auth Request");
283 auth_request_sent = false;
284 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
285 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
286 ms_sends_msg("062707"
287 "03575886" /* classmark 2 */
288 "089910070000106005" /* IMSI */);
289 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
290
291 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100292 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100293 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100294 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100295
296 btw("MS sends SecurityModeControl acceptance, VLR accepts, sends CC Setup");
297 dtap_expect_tx("0305" /* CC: Setup */);
298 ms_sends_security_mode_complete();
299 VERBOSE_ASSERT(paging_stopped, == true, "%d");
300
301 cc_to_mncc_expect_tx(IMSI, MNCC_CALL_CONF_IND);
302 ms_sends_msg("8348" /* CC: Call Confirmed */
303 "0406600402000581" /* Bearer Capability */
304 "15020100" /* Call Control Capabilities */
305 "40080402600400021f00" /* Supported Codec List */);
306
307 fake_time_passes(1, 23);
308
309 cc_to_mncc_expect_tx("", MNCC_ALERT_IND);
310 ms_sends_msg("8381" /* CC: Alerting */);
311
312 fake_time_passes(1, 23);
313
314 cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_CNF);
315 ms_sends_msg("83c7" /* CC: Connect */);
316
317 dtap_expect_tx("030f" /* CC: Connect Acknowledge */);
318 mncc_sends_to_cc(MNCC_SETUP_COMPL_REQ, &mncc);
319
320 BTW("RTP stream goes ahead, not shown here.");
321 fake_time_passes(123, 45);
322
323 BTW("Call ends");
324 cc_to_mncc_expect_tx("", MNCC_DISC_IND);
325 ms_sends_msg("832502e090" /* CC: Disconnect, cause: Normal Call Clearing */);
326 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
327
328 dtap_expect_tx("032d" /* CC: Release */);
329 mncc_sends_to_cc(MNCC_REL_REQ, &mncc);
330 OSMO_ASSERT(dtap_tx_confirmed);
331
332 cc_to_mncc_expect_tx("", MNCC_REL_CNF);
333 expect_iu_release();
334 ms_sends_msg("836a" /* CC: Release Complete */);
335 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
336 OSMO_ASSERT(iu_release_sent);
337
338 EXPECT_CONN_COUNT(0);
339 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100340 comment_end();
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100341}
342
Neels Hofmeyrcbcf89c2018-03-13 17:52:07 +0100343static void test_call_mt2()
344{
345 struct gsm_mncc mncc = {
346 .imsi = IMSI,
347 .callref = 0x423,
348 };
349
350 comment_start();
351
352 fake_time_start();
353
354 standard_lu();
355
356 BTW("after a while, MNCC asks us to setup a call, causing Paging");
357
358 paging_expect_imsi(IMSI);
359 paging_sent = false;
360 mncc_sends_to_cc(MNCC_SETUP_REQ, &mncc);
361
362 VERBOSE_ASSERT(paging_sent, == true, "%d");
363 VERBOSE_ASSERT(paging_stopped, == false, "%d");
364
365 btw("MS replies with Paging Response, and VLR sends Auth Request");
366 auth_request_sent = false;
367 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
368 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
369 ms_sends_msg("062707"
370 "03575886" /* classmark 2 */
371 "089910070000106005" /* IMSI */);
372 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
373
374 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
375 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
376 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
377 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
378
379 btw("MS sends SecurityModeControl acceptance, VLR accepts, sends CC Setup");
380 dtap_expect_tx("0305" /* CC: Setup */);
381 ms_sends_security_mode_complete();
382 VERBOSE_ASSERT(paging_stopped, == true, "%d");
383
384 cc_to_mncc_expect_tx(IMSI, MNCC_CALL_CONF_IND);
385 ms_sends_msg("8348" /* CC: Call Confirmed */
386 "0406600402000581" /* Bearer Capability */
387 "15020100" /* Call Control Capabilities */
388 "40080402600400021f00" /* Supported Codec List */);
389 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
390
391 fake_time_passes(1, 23);
392
393 cc_to_mncc_expect_tx("", MNCC_ALERT_IND);
394 ms_sends_msg("8381" /* CC: Alerting */);
395 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
396
397 fake_time_passes(15, 23);
398
399 btw("The call failed, the BSC sends a BSSMAP Clear Request");
400 on_call_release_mncc_sends_to_cc(MNCC_REL_REQ, &mncc);
401 cc_to_mncc_expect_tx("", MNCC_REL_CNF);
402 dtap_expect_tx("032d"); /* CC: Release */
403 expect_iu_release();
404 msc_clear_request(g_conn, 0);
405 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
406 OSMO_ASSERT(iu_release_sent);
407
408 EXPECT_CONN_COUNT(0);
409
410 /* Make sure a pending release timer doesn't fire later to access freed data */
411 fake_time_passes(15, 23);
412
413 clear_vlr();
414 comment_end();
415}
416
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100417static void test_call_mo_to_unknown()
418{
419 struct gsm_mncc mncc = {
420 .imsi = IMSI,
421 };
422
423 comment_start();
424
425 fake_time_start();
426
427 standard_lu();
428
429 BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector");
430 auth_request_sent = false;
431 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
432 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
433 cm_service_result_sent = RES_NONE;
434 ms_sends_msg("052478"
435 "03575886" /* classmark 2 */
436 "089910070000106005" /* IMSI */);
437 OSMO_ASSERT(g_conn);
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +0200438 OSMO_ASSERT(g_conn->fi);
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100439 OSMO_ASSERT(g_conn->vsub);
440 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
441 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
442
443 btw("needs auth, not yet accepted");
444 EXPECT_ACCEPTED(false);
445
446 /* On UTRAN */
447 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
448 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
449 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
450 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
451 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
452
453 btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept");
454 ms_sends_security_mode_complete();
455 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
456
457 BTW("a call is initiated");
458
459 btw("SETUP gets forwarded to MNCC");
460 cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_IND);
461 ms_sends_msg("0385" /* CC, seq = 2 -> 0x80 | CC Setup = 0x5 */
462 "0406600402000581" /* Bearer Capability */
463 "5e038121f3" /* Called Number BCD */
464 "15020100" /* CC Capabilities */
465 "4008" /* Supported Codec List */
466 "04026000" /* UMTS: AMR 2 | AMR */
467 "00021f00" /* GSM: HR AMR | FR AMR | GSM EFR | GSM HR | GSM FR */
468 );
469 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
470 mncc.callref = cc_to_mncc_tx_got_callref;
471
472 btw("MNCC says that's fine");
473 dtap_expect_tx("8302" /* CC: Call Proceeding */);
474 mncc_sends_to_cc(MNCC_CALL_PROC_REQ, &mncc);
475 OSMO_ASSERT(dtap_tx_confirmed);
476
477 btw("But the other side's MSISDN could not be resolved, MNCC tells us to cancel");
478 dtap_expect_tx("832d" /* CC: Release Request */);
479 mncc_sends_to_cc(MNCC_REL_REQ, &mncc);
480
481 dtap_expect_tx("832d" /* CC: Release Request */);
482 fake_time_passes(10, 23);
483
484 expect_iu_release();
485 cc_to_mncc_expect_tx("", MNCC_REL_CNF);
486 ms_sends_msg("036a" /* CC: Release Complete */);
487 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
488 OSMO_ASSERT(iu_release_sent);
489 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
490
491 EXPECT_CONN_COUNT(0);
492 clear_vlr();
493 comment_end();
494}
495
496static void test_call_mo_to_unknown_timeout()
497{
498 struct gsm_mncc mncc = {
499 .imsi = IMSI,
500 };
501
502 comment_start();
503
504 fake_time_start();
505
506 standard_lu();
507
508 BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector");
509 auth_request_sent = false;
510 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
511 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
512 cm_service_result_sent = RES_NONE;
513 ms_sends_msg("052478"
514 "03575886" /* classmark 2 */
515 "089910070000106005" /* IMSI */);
516 OSMO_ASSERT(g_conn);
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +0200517 OSMO_ASSERT(g_conn->fi);
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100518 OSMO_ASSERT(g_conn->vsub);
519 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
520 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
521
522 btw("needs auth, not yet accepted");
523 EXPECT_ACCEPTED(false);
524
525 /* On UTRAN */
526 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
527 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
528 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
529 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
530 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
531
532 btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept");
533 ms_sends_security_mode_complete();
534 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
535
536 BTW("a call is initiated");
537
538 btw("SETUP gets forwarded to MNCC");
539 cc_to_mncc_expect_tx(IMSI, MNCC_SETUP_IND);
540 ms_sends_msg("0385" /* CC, seq = 2 -> 0x80 | CC Setup = 0x5 */
541 "0406600402000581" /* Bearer Capability */
542 "5e038121f3" /* Called Number BCD */
543 "15020100" /* CC Capabilities */
544 "4008" /* Supported Codec List */
545 "04026000" /* UMTS: AMR 2 | AMR */
546 "00021f00" /* GSM: HR AMR | FR AMR | GSM EFR | GSM HR | GSM FR */
547 );
548 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
549 mncc.callref = cc_to_mncc_tx_got_callref;
550
551 btw("MNCC says that's fine");
552 dtap_expect_tx("8302" /* CC: Call Proceeding */);
553 mncc_sends_to_cc(MNCC_CALL_PROC_REQ, &mncc);
554 OSMO_ASSERT(dtap_tx_confirmed);
555
556 btw("But the other side's MSISDN could not be resolved, MNCC tells us to cancel");
557 dtap_expect_tx("832d" /* CC: Release Request */);
558 mncc_sends_to_cc(MNCC_REL_REQ, &mncc);
559
560 btw("Despite our repeated CC Release Requests, the MS does not respond anymore");
561 dtap_expect_tx("832d" /* CC: Release Request */);
562 fake_time_passes(10, 23);
563
564 btw("The CC Release times out and we still properly clear the conn");
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100565 cc_to_mncc_expect_tx("", MNCC_REL_CNF);
Neels Hofmeyrd6a769b2018-03-12 23:59:07 +0100566 expect_iu_release();
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100567 fake_time_passes(10, 23);
568 OSMO_ASSERT(cc_to_mncc_tx_confirmed);
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100569 OSMO_ASSERT(iu_release_sent);
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100570
Neels Hofmeyrd6a769b2018-03-12 23:59:07 +0100571 EXPECT_CONN_COUNT(0);
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100572 clear_vlr();
573 comment_end();
574}
575
576
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100577msc_vlr_test_func_t msc_vlr_tests[] = {
578 test_call_mo,
579 test_call_mt,
Neels Hofmeyrcbcf89c2018-03-13 17:52:07 +0100580 test_call_mt2,
Neels Hofmeyreb1cfdb2018-03-15 13:42:10 +0100581 test_call_mo_to_unknown,
582 test_call_mo_to_unknown_timeout,
Neels Hofmeyra99b4272017-11-21 17:13:23 +0100583 NULL
584};