blob: 72647a3bc2001152b2a5cbbb5da500da94369101 [file] [log] [blame]
Neels Hofmeyr6a29d322017-01-25 15:04:16 +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 Hofmeyr6a29d322017-01-25 15:04:16 +010026
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010027static void test_no_authen()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010028{
29 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010030 const char *imsi = "901700000004620";
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020031 /* No auth only works on GERAN */
Neels Hofmeyr7814a832018-12-26 00:40:18 +010032 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010033
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010034 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010035
36 btw("Location Update request causes a GSUP LU request to HLR");
37 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010038 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010039 ms_sends_msg("050802008168000130089910070000006402");
40 OSMO_ASSERT(gsup_tx_confirmed);
41 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
42
43 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010044 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
45 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010046 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
47
48 btw("having received subscriber data does not mean acceptance");
49 EXPECT_ACCEPTED(false);
50
51 thwart_rx_non_initial_requests();
52
53 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
54
55 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +020056 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010057 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010058
59 btw("LU was successful, and the conn has already been closed");
60 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +020061 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +020062
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010063 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010064 EXPECT_CONN_COUNT(0);
65
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010066 BTW("after a while, a new conn sends a CM Service Request (MO SMS)");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010067 cm_service_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010068 ms_sends_msg("05 24 74 03 30 58 86 08 99 10 07 00 00 00 64 02");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010069 VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d");
70 EXPECT_ACCEPTED(true);
71
Vadim Yanitskiy27605852018-06-15 23:57:30 +070072 /* Release connection */
Neels Hofmeyr7814a832018-12-26 00:40:18 +010073 expect_bssap_clear(OSMO_RAT_GERAN_A);
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010074 conn_conclude_cm_service_req(g_msub, MSC_A_USE_CM_SERVICE_SMS);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010075
76 btw("all requests serviced, conn has been released");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010077 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010078 EXPECT_CONN_COUNT(0);
79
80 BTW("an SMS is sent, MS is paged");
81 paging_expect_imsi(imsi);
82 paging_sent = false;
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +010083 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010084 OSMO_ASSERT(vsub);
85 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
86
87 send_sms(vsub, vsub,
88 "Privacy in residential applications is a desirable"
89 " marketing option.");
90
91 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +010092 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010093 vsub = NULL;
94 VERBOSE_ASSERT(paging_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010095
96 btw("the subscriber and its pending request should remain");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +010097 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010098 OSMO_ASSERT(vsub);
99 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100100 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100101
102 btw("MS replies with Paging Response, we deliver the SMS");
103 dtap_expect_tx("09" /* SMS messages */
104 "01" /* CP-DATA */
105 "58" /* length */
106 "01" /* Network to MS */
107 "00" /* reference */
108 /* originator (gsm411_send_sms() hardcodes this weird nr) */
109 "0791" "447758100650" /* 447785016005 */
110 "00" /* dest */
111 /* SMS TPDU */
112 "4c" /* len */
113 "00" /* SMS deliver */
114 "05806470f1" /* originating address 46071 */
115 "00" /* TP-PID */
116 "00" /* GSM default alphabet */
117 "071010" /* Y-M-D (from wrapped gsm340_gen_scts())*/
118 "000000" /* H-M-S */
119 "00" /* GMT+0 */
120 "44" /* data length */
121 "5079da1e1ee7416937485e9ea7c965373d1d6683c270383b3d0e"
122 "d3d36ff71c949e83c22072799e9687c5ec32a81d96afcbf4b4fb"
123 "0c7ac3e9e9b7db05");
124 ms_sends_msg("06270703305882089910070000006402");
125 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100126
127 btw("SMS was delivered, no requests pending for subscr");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100128 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100129 OSMO_ASSERT(vsub);
130 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100131 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100132
133 btw("conn is still open to wait for SMS ack dance");
134 EXPECT_CONN_COUNT(1);
135
136 btw("MS replies with CP-ACK for received SMS");
137 ms_sends_msg("8904");
138 EXPECT_CONN_COUNT(1);
139
140 btw("MS also sends RP-ACK, MSC in turn sends CP-ACK for that");
141 dtap_expect_tx("0904");
Philipp Maierfbf66102017-04-09 12:32:51 +0200142 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100143 ms_sends_msg("890106020041020000");
144 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200145 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100146
147 btw("SMS is done, conn is gone");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100148 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100149 EXPECT_CONN_COUNT(0);
150
151 BTW("subscriber detaches");
Philipp Maierfbf66102017-04-09 12:32:51 +0200152 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100153 ms_sends_msg("050130089910070000006402");
Philipp Maierfbf66102017-04-09 12:32:51 +0200154 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100155
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100156 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100157 EXPECT_CONN_COUNT(0);
158 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100159 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100160}
161
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100162static void test_no_authen_tmsi()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100163{
164 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100165 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100166
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100167 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200168
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100169 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100170
171 net->vlr->cfg.assign_tmsi = true;
172
173 btw("Location Update request causes a GSUP LU request to HLR");
174 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100175 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100176 ms_sends_msg("050802008168000130089910070000006402");
177 OSMO_ASSERT(gsup_tx_confirmed);
178 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
179
180 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100181 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
182 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100183 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
184
185 btw("having received subscriber data does not mean acceptance");
186 EXPECT_ACCEPTED(false);
187 thwart_rx_non_initial_requests();
188 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
189
190 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100191 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100192
193 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
194 EXPECT_CONN_COUNT(1);
195 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
196 EXPECT_ACCEPTED(false);
197 thwart_rx_non_initial_requests();
198
199 btw("even though the TMSI is not acked, we can already find the subscr with it");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100200 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100201 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
202 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
203 VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x");
204 VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100205 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100206
207 btw("MS sends TMSI Realloc Complete");
Philipp Maierfbf66102017-04-09 12:32:51 +0200208 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100209 ms_sends_msg("055b");
Philipp Maierfbf66102017-04-09 12:32:51 +0200210 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100211
212 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100213 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100214 EXPECT_CONN_COUNT(0);
215
216 btw("Subscriber has the new TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100217 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100218 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
219 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
220 VERBOSE_ASSERT(vsub->tmsi_new, == GSM_RESERVED_TMSI, "0x%08x");
221 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100222 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100223
224 BTW("after a while, a new conn sends a CM Service Request using above TMSI");
225 cm_service_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100226 ms_sends_msg("05247403305886" "05f4" "03020100");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100227 VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d");
228 EXPECT_ACCEPTED(true);
229
Vadim Yanitskiy27605852018-06-15 23:57:30 +0700230 /* Release connection */
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100231 expect_bssap_clear(OSMO_RAT_GERAN_A);
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100232 conn_conclude_cm_service_req(g_msub, MSC_A_USE_CM_SERVICE_SMS);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100233
234 btw("all requests serviced, conn has been released");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100235 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100236 EXPECT_CONN_COUNT(0);
237
238 BTW("an SMS is sent, MS is paged using above TMSI");
239 paging_expect_tmsi(0x03020100);
240 paging_sent = false;
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100241 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100242 OSMO_ASSERT(vsub);
243 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
244
245 send_sms(vsub, vsub,
246 "Privacy in residential applications is a desirable"
247 " marketing option.");
248
249 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100250 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100251 vsub = NULL;
252 VERBOSE_ASSERT(paging_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100253
254 btw("the subscriber and its pending request should remain");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100255 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100256 OSMO_ASSERT(vsub);
257 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100258 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100259
260 btw("MS replies with Paging Response using TMSI, we deliver the SMS");
261 dtap_expect_tx("09" /* SMS messages */
262 "01" /* CP-DATA */
263 "58" /* length */
264 "01" /* Network to MS */
265 "00" /* reference */
266 /* originator (gsm411_send_sms() hardcodes this weird nr) */
267 "0791" "447758100650" /* 447785016005 */
268 "00" /* dest */
269 /* SMS TPDU */
270 "4c" /* len */
271 "00" /* SMS deliver */
272 "05806470f1" /* originating address 46071 */
273 "00" /* TP-PID */
274 "00" /* GSM default alphabet */
275 "071010" /* Y-M-D (from wrapped gsm340_gen_scts())*/
276 "000000" /* H-M-S */
277 "00" /* GMT+0 */
278 "44" /* data length */
279 "5079da1e1ee7416937485e9ea7c965373d1d6683c270383b3d0e"
280 "d3d36ff71c949e83c22072799e9687c5ec32a81d96afcbf4b4fb"
281 "0c7ac3e9e9b7db05");
282 ms_sends_msg("06270703305882" "05f4" "03020100");
283 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100284
285 btw("SMS was delivered, no requests pending for subscr");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100286 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100287 OSMO_ASSERT(vsub);
288 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100289 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100290
291 btw("conn is still open to wait for SMS ack dance");
292 EXPECT_CONN_COUNT(1);
293
294 btw("MS replies with CP-ACK for received SMS");
295 ms_sends_msg("8904");
296 EXPECT_CONN_COUNT(1);
297
298 btw("MS also sends RP-ACK, MSC in turn sends CP-ACK for that");
299 dtap_expect_tx("0904");
Philipp Maierfbf66102017-04-09 12:32:51 +0200300 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100301 ms_sends_msg("890106020041020000");
302 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200303 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100304
305 btw("SMS is done, conn is gone");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100306 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100307 EXPECT_CONN_COUNT(0);
308
309 /* TODO: when the subscriber detaches, the vlr_subscr gets
310 * deallocated and we no longer know the TMSI. This case is covered by
311 * test_lu_unknown_tmsi(), so here I'd like to still have the TMSI.
312 BTW("subscriber detaches, using TMSI");
313 ms_sends_msg("050130" "05f4" "03020100");
314 EXPECT_CONN_COUNT(0);
315 */
316
317 BTW("subscriber sends LU Request, this time with the TMSI");
318 btw("Location Update request causes a GSUP LU request to HLR");
319 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100320 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100321 ms_sends_msg("050802008168000130" "05f4" "03020100");
322 OSMO_ASSERT(gsup_tx_confirmed);
323 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
324
325 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100326 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
327 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100328 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
329
330 btw("having received subscriber data does not mean acceptance");
331 EXPECT_ACCEPTED(false);
332 thwart_rx_non_initial_requests();
333 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
334
335 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100336 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100337
338 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
339 EXPECT_CONN_COUNT(1);
340 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
341 EXPECT_ACCEPTED(false);
342 thwart_rx_non_initial_requests();
343
344 btw("even though the TMSI is not acked, we can already find the subscr with it");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100345 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100346 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
347 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
348 VERBOSE_ASSERT(vsub->tmsi_new, == 0x07060504, "0x%08x");
349 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100350 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100351
352 btw("MS sends TMSI Realloc Complete");
Philipp Maierfbf66102017-04-09 12:32:51 +0200353 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100354 ms_sends_msg("055b");
Philipp Maierfbf66102017-04-09 12:32:51 +0200355 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100356
357 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100358 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100359 EXPECT_CONN_COUNT(0);
360
361 btw("subscriber has the new TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100362 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100363 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
364 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
365 VERBOSE_ASSERT(vsub->tmsi_new, == GSM_RESERVED_TMSI, "0x%08x");
366 VERBOSE_ASSERT(vsub->tmsi, == 0x07060504, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100367 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100368
369 BTW("subscriber detaches, using new TMSI");
Philipp Maierfbf66102017-04-09 12:32:51 +0200370 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100371 ms_sends_msg("050130" "05f4" "07060504");
Philipp Maierfbf66102017-04-09 12:32:51 +0200372 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100373
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100374 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100375 EXPECT_CONN_COUNT(0);
376 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100377 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100378}
379
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100380static void test_no_authen_imei()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100381{
382 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100383 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100384
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100385 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200386
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100387 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100388
389 net->vlr->cfg.check_imei_rqd = true;
390
391 btw("Location Update request causes a GSUP LU request to HLR");
392 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100393 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100394 ms_sends_msg("050802008168000130089910070000006402");
395 OSMO_ASSERT(gsup_tx_confirmed);
396 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
397
398 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100399 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
400 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100401 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
402
403 btw("having received subscriber data does not mean acceptance");
404 EXPECT_ACCEPTED(false);
405 thwart_rx_non_initial_requests();
406 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
407
408 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS");
409 dtap_expect_tx("051802");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100410 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100411
412 btw("We will only do business when the IMEI is known");
413 EXPECT_CONN_COUNT(1);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100414 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100415 OSMO_ASSERT(vsub);
416 VERBOSE_ASSERT(vsub->imei[0], == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100417 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100418 EXPECT_ACCEPTED(false);
419 thwart_rx_non_initial_requests();
420
Oliver Smith7d053092018-12-14 17:37:38 +0100421 btw("MS replies with an Identity Response, VLR sends the IMEI to HLR");
Oliver Smithd1037052019-05-02 13:39:26 +0200422 gsup_expect_tx("30010809710000004026f050080724433224433224" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200423 /* 3GPP TS 23.003: 6.2.1 Composition of IMEI: the IMEI ends with a
424 * spare digit that shall be sent as zero by the MS. */
425 ms_sends_msg("0559084a32244332244302");
Oliver Smith7d053092018-12-14 17:37:38 +0100426
427 btw("HLR accepts the IMEI");
428 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100429 gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200430 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100431
432 btw("LU was successful, and the conn has already been closed");
433 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100434 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100435 EXPECT_CONN_COUNT(0);
436
437 btw("Subscriber has the IMEI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100438 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100439 OSMO_ASSERT(vsub);
Oliver Smithd1037052019-05-02 13:39:26 +0200440 VERBOSE_ASSERT(strcmp(vsub->imei, "42342342342342"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100441 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100442
443 BTW("subscriber detaches");
Philipp Maierfbf66102017-04-09 12:32:51 +0200444 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100445 ms_sends_msg("050130089910070000006402");
Philipp Maierfbf66102017-04-09 12:32:51 +0200446 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100447
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100448 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100449 EXPECT_CONN_COUNT(0);
450 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100451 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100452}
453
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100454static void test_no_authen_tmsi_imei()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100455{
456 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100457 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100458
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100459 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200460
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100461 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100462
463 net->vlr->cfg.assign_tmsi = true;
464 net->vlr->cfg.check_imei_rqd = true;
465
466 btw("Location Update request causes a GSUP LU request to HLR");
467 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100468 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100469 ms_sends_msg("050802008168000130089910070000006402");
470 OSMO_ASSERT(gsup_tx_confirmed);
471 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
472
473 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100474 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
475 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100476 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
477
478 btw("having received subscriber data does not mean acceptance");
479 EXPECT_ACCEPTED(false);
480 thwart_rx_non_initial_requests();
481 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
482
483 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS");
484 dtap_expect_tx("051802");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100485 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100486
487 btw("We will only do business when the IMEI is known");
488 EXPECT_CONN_COUNT(1);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100489 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100490 OSMO_ASSERT(vsub);
491 VERBOSE_ASSERT(vsub->imei[0], == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100492 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100493 EXPECT_ACCEPTED(false);
494 thwart_rx_non_initial_requests();
495
Oliver Smith7d053092018-12-14 17:37:38 +0100496 btw("MS replies with an Identity Response, VLR sends the IMEI to HLR");
Oliver Smithd1037052019-05-02 13:39:26 +0200497 gsup_expect_tx("30010809710000004026f050080724433224433224" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200498 ms_sends_msg("0559084a32244332244302");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100499
Oliver Smith7d053092018-12-14 17:37:38 +0100500 btw("HLR accepts the IMEI");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100501 gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL);
Oliver Smith7d053092018-12-14 17:37:38 +0100502
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100503 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
504 EXPECT_CONN_COUNT(1);
505 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
506 EXPECT_ACCEPTED(false);
507 thwart_rx_non_initial_requests();
508
509 btw("MS sends TMSI Realloc Complete");
Philipp Maierfbf66102017-04-09 12:32:51 +0200510 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100511 ms_sends_msg("055b");
Philipp Maierfbf66102017-04-09 12:32:51 +0200512 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100513
514 btw("LU was successful, and the conn has already been closed");
515 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100516 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100517 EXPECT_CONN_COUNT(0);
518
519 btw("Subscriber has the IMEI and TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100520 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100521 OSMO_ASSERT(vsub);
Oliver Smithd1037052019-05-02 13:39:26 +0200522 VERBOSE_ASSERT(strcmp(vsub->imei, "42342342342342"), == 0, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100523 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100524 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100525
526 BTW("subscriber detaches");
Philipp Maierfbf66102017-04-09 12:32:51 +0200527 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100528 ms_sends_msg("050130089910070000006402");
Philipp Maierfbf66102017-04-09 12:32:51 +0200529 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100530
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100531 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100532 EXPECT_CONN_COUNT(0);
533 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100534 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100535}
536
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100537static void test_no_authen_imeisv()
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200538{
539 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100540 const char *imsi = "901700000004620";
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100541
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200542 /* No auth only works on GERAN */
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100543 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200544
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100545 comment_start();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200546
547 net->vlr->cfg.retrieve_imeisv_early = true;
548
549 btw("Location Update request causes an IMEISV ID request back to the MS");
550 lu_result_sent = RES_NONE;
551 dtap_expect_tx("051803");
552 ms_sends_msg("050802008168000130089910070000006402");
553 OSMO_ASSERT(dtap_tx_confirmed);
554
555 btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100556 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200557 ms_sends_msg("0559094332244332244372f5");
558 OSMO_ASSERT(gsup_tx_confirmed);
559 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
560
561 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100562 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200563 OSMO_ASSERT(vsub);
564 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100565 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200566
567 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100568 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
569 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200570 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
571
572 btw("having received subscriber data does not mean acceptance");
573 EXPECT_ACCEPTED(false);
574
575 thwart_rx_non_initial_requests();
576
577 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
578
579 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
580 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100581 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200582
583 btw("LU was successful, and the conn has already been closed");
584 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
585 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100586 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200587 EXPECT_CONN_COUNT(0);
588
589 BTW("subscriber detaches");
590 expect_bssap_clear();
591 ms_sends_msg("050130089910070000006402");
592 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
593
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100594 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200595 EXPECT_CONN_COUNT(0);
596 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100597 comment_end();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200598}
599
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100600static void test_no_authen_imeisv_imei()
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200601{
602 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100603 const char *imsi = "901700000004620";
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200604
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100605 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200606
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100607 comment_start();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200608
609 net->vlr->cfg.retrieve_imeisv_early = true;
610 net->vlr->cfg.check_imei_rqd = true;
611
612 btw("Location Update request causes an IMEISV ID request back to the MS");
613 lu_result_sent = RES_NONE;
614 dtap_expect_tx("051803");
615 ms_sends_msg("050802008168000130089910070000006402");
616 OSMO_ASSERT(dtap_tx_confirmed);
617
618 btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100619 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200620 ms_sends_msg("0559094332244332244372f5");
621 OSMO_ASSERT(gsup_tx_confirmed);
622 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
623
624 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100625 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200626 OSMO_ASSERT(vsub);
627 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100628 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200629
630 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100631 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
632 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200633 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
634
635 btw("having received subscriber data does not mean acceptance");
636 EXPECT_ACCEPTED(false);
637 thwart_rx_non_initial_requests();
638 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
639
640 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS");
641 dtap_expect_tx("051802");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100642 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200643
644 btw("We will only do business when the IMEI is known");
645 EXPECT_CONN_COUNT(1);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100646 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200647 OSMO_ASSERT(vsub);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100648 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200649 EXPECT_ACCEPTED(false);
650 thwart_rx_non_initial_requests();
651
Oliver Smith7d053092018-12-14 17:37:38 +0100652 btw("MS replies with an Identity Response, VLR sends the IMEI to HLR");
Oliver Smithd1037052019-05-02 13:39:26 +0200653 gsup_expect_tx("30010809710000004026f050080724433224433224" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200654 ms_sends_msg("0559084a32244332244302");
Oliver Smith7d053092018-12-14 17:37:38 +0100655
656 btw("HLR accepts the IMEI");
657 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100658 gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200659 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
660
661 btw("LU was successful, and the conn has already been closed");
662 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100663 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200664 EXPECT_CONN_COUNT(0);
665
666 btw("Subscriber has the IMEI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100667 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200668 OSMO_ASSERT(vsub);
Oliver Smithd1037052019-05-02 13:39:26 +0200669 VERBOSE_ASSERT(strcmp(vsub->imei, "42342342342342"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100670 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200671
672 BTW("subscriber detaches");
673 expect_bssap_clear();
674 ms_sends_msg("050130089910070000006402");
675 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
676
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100677 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200678 EXPECT_CONN_COUNT(0);
679 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100680 comment_end();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200681}
682
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100683static void test_no_authen_imeisv_tmsi()
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200684{
685 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100686 const char *imsi = "901700000004620";
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200687
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100688 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200689
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100690 comment_start();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200691
692 net->vlr->cfg.retrieve_imeisv_early = true;
693 net->vlr->cfg.assign_tmsi = true;
694
695 btw("Location Update request causes an IMEISV ID request back to the MS");
696 lu_result_sent = RES_NONE;
697 dtap_expect_tx("051803");
698 ms_sends_msg("050802008168000130089910070000006402");
699 OSMO_ASSERT(dtap_tx_confirmed);
700
701 btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100702 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200703 ms_sends_msg("0559094332244332244372f5");
704 OSMO_ASSERT(gsup_tx_confirmed);
705 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
706
707 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100708 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200709 OSMO_ASSERT(vsub);
710 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100711 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200712
713 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100714 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
715 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200716 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
717
718 btw("having received subscriber data does not mean acceptance");
719 EXPECT_ACCEPTED(false);
720 thwart_rx_non_initial_requests();
721 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
722
723 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100724 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200725
726 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
727 EXPECT_CONN_COUNT(1);
728 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
729 EXPECT_ACCEPTED(false);
730 thwart_rx_non_initial_requests();
731
732 btw("even though the TMSI is not acked, we can already find the subscr with it");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100733 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200734 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
735 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
736 VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x");
737 VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100738 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200739
740 btw("MS sends TMSI Realloc Complete");
741 expect_bssap_clear();
742 ms_sends_msg("055b");
743 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
744
745 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100746 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200747 EXPECT_CONN_COUNT(0);
748
749
750 BTW("subscriber sends LU Request, this time with the TMSI");
751 btw("Location Update request causes an IMEISV ID request back to the MS");
752 lu_result_sent = RES_NONE;
753 dtap_expect_tx("051803");
754 ms_sends_msg("050802008168000130089910070000006402");
755 OSMO_ASSERT(dtap_tx_confirmed);
756
757 btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100758 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200759 ms_sends_msg("0559095332244332244372f6");
760 OSMO_ASSERT(gsup_tx_confirmed);
761 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
762
763 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100764 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200765 OSMO_ASSERT(vsub);
766 VERBOSE_ASSERT(strcmp(vsub->imeisv, "5234234234234276"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100767 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200768
769 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100770 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
771 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200772 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
773
774 btw("having received subscriber data does not mean acceptance");
775 EXPECT_ACCEPTED(false);
776 thwart_rx_non_initial_requests();
777 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
778
779 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100780 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200781
782 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
783 EXPECT_CONN_COUNT(1);
784 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
785 EXPECT_ACCEPTED(false);
786 thwart_rx_non_initial_requests();
787
788 btw("even though the TMSI is not acked, we can already find the subscr with it");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100789 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200790 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
791 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
792 VERBOSE_ASSERT(vsub->tmsi_new, == 0x07060504, "0x%08x");
793 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100794 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200795
796 btw("MS sends TMSI Realloc Complete");
797 expect_bssap_clear();
798 ms_sends_msg("055b");
799 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
800
801 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100802 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200803 EXPECT_CONN_COUNT(0);
804
805 btw("subscriber has the new TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100806 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200807 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
808 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
809 VERBOSE_ASSERT(vsub->tmsi_new, == GSM_RESERVED_TMSI, "0x%08x");
810 VERBOSE_ASSERT(vsub->tmsi, == 0x07060504, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100811 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200812
813 BTW("subscriber detaches, using new TMSI");
814 expect_bssap_clear();
815 ms_sends_msg("050130" "05f4" "07060504");
816 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
817
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100818 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200819 EXPECT_CONN_COUNT(0);
820 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100821 comment_end();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200822}
823
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100824static void test_no_authen_imeisv_tmsi_imei()
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200825{
826 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100827 const char *imsi = "901700000004620";
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200828
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100829 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200830
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100831 comment_start();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200832
833 net->vlr->cfg.retrieve_imeisv_early = true;
834 net->vlr->cfg.assign_tmsi = true;
835 net->vlr->cfg.check_imei_rqd = true;
836
837 btw("Location Update request causes an IMEISV ID request back to the MS");
838 lu_result_sent = RES_NONE;
839 dtap_expect_tx("051803");
840 ms_sends_msg("050802008168000130089910070000006402");
841 OSMO_ASSERT(dtap_tx_confirmed);
842
843 btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100844 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200845 ms_sends_msg("0559094332244332244372f5");
846 OSMO_ASSERT(gsup_tx_confirmed);
847 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
848
849 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100850 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200851 OSMO_ASSERT(vsub);
852 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100853 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200854
855 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100856 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
857 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200858 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
859
860 btw("having received subscriber data does not mean acceptance");
861 EXPECT_ACCEPTED(false);
862 thwart_rx_non_initial_requests();
863 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
864
865 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS");
866 dtap_expect_tx("051802");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100867 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200868
869 btw("We will only do business when the IMEI is known");
870 EXPECT_CONN_COUNT(1);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100871 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200872 OSMO_ASSERT(vsub);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100873 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200874 EXPECT_ACCEPTED(false);
875 thwart_rx_non_initial_requests();
876
Oliver Smith7d053092018-12-14 17:37:38 +0100877 btw("MS replies with an Identity Response, VLR sends the IMEI to HLR");
Oliver Smithd1037052019-05-02 13:39:26 +0200878 gsup_expect_tx("30010809710000004026f050080724433224433224" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200879 ms_sends_msg("0559084a32244332244302");
880
Oliver Smith7d053092018-12-14 17:37:38 +0100881 btw("HLR accepts the IMEI");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100882 gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL);
Oliver Smith7d053092018-12-14 17:37:38 +0100883
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200884 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
885 EXPECT_CONN_COUNT(1);
886 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
887 EXPECT_ACCEPTED(false);
888 thwart_rx_non_initial_requests();
889
890 btw("MS sends TMSI Realloc Complete");
891 expect_bssap_clear();
892 ms_sends_msg("055b");
893 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
894
895 btw("LU was successful, and the conn has already been closed");
896 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100897 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200898 EXPECT_CONN_COUNT(0);
899
900 btw("Subscriber has the IMEISV, IMEI and TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100901 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200902 OSMO_ASSERT(vsub);
903 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Oliver Smithd1037052019-05-02 13:39:26 +0200904 VERBOSE_ASSERT(strcmp(vsub->imei, "42342342342342"), == 0, "%d");
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200905 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100906 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200907
908 BTW("subscriber detaches");
909 expect_bssap_clear();
910 ms_sends_msg("050130089910070000006402");
911 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
912
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100913 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200914 EXPECT_CONN_COUNT(0);
915 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100916 comment_end();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200917}
918
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200919static void test_no_authen_subscr_expire()
920{
921 struct vlr_subscr *vsub;
922 const char *imsi = "901700000004620";
923
924 /* No auth only works on GERAN */
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100925 rx_from_ran = OSMO_RAT_GERAN_A;
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200926
927 comment_start();
928
929 fake_time_start();
930
931 /* The test framework has already started the VLR before fake time was active.
932 * Manually schedule this timeout in fake time. */
933 osmo_timer_del(&net->vlr->lu_expire_timer);
934 osmo_timer_schedule(&net->vlr->lu_expire_timer, VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL, 0);
935
936 /* Let the LU expiration timer tick once */
937 fake_time_passes(VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL + 1, 0);
938
939 btw("Location Update request causes a GSUP LU request to HLR");
940 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100941 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200942 ms_sends_msg("050802008168000130089910070000006402");
943 OSMO_ASSERT(gsup_tx_confirmed);
944 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
945
946 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100947 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
948 "12010809710000004026f0" VLR_TO_HLR);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200949 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
950
951 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
952 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100953 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200954
955 btw("LU was successful, and the conn has already been closed");
956 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
957 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
958
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100959 ran_sends_clear_complete();
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200960 EXPECT_CONN_COUNT(0);
961
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100962 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200963 OSMO_ASSERT(vsub);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100964 vlr_subscr_put(vsub, __func__);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200965
966 /* Let T3212 (periodic Location update timer) expire */
967 fake_time_passes((net->t3212 * 60 * 6 * 2) + 60*4, 0);
968
969 /* The subscriber should now be gone. */
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100970 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200971 OSMO_ASSERT(vsub == NULL);
972
973 EXPECT_CONN_COUNT(0);
974 clear_vlr();
975 comment_end();
976}
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200977
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100978msc_vlr_test_func_t msc_vlr_tests[] = {
979 test_no_authen,
980 test_no_authen_tmsi,
981 test_no_authen_imei,
982 test_no_authen_tmsi_imei,
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200983 test_no_authen_imeisv,
984 test_no_authen_imeisv_imei,
985 test_no_authen_imeisv_tmsi,
986 test_no_authen_imeisv_tmsi_imei,
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200987 test_no_authen_subscr_expire,
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100988 NULL
989};