blob: d9ec091ac529a1d6c69ae690048e5a9f6ae6e713 [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");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100422 gsup_expect_tx("30010809710000004026f050090824433224433224f0" 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);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200440 VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 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");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100497 gsup_expect_tx("30010809710000004026f050090824433224433224f0" 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);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200522 VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 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);
648 VERBOSE_ASSERT(vsub->imei[0], == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100649 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200650 EXPECT_ACCEPTED(false);
651 thwart_rx_non_initial_requests();
652
Oliver Smith7d053092018-12-14 17:37:38 +0100653 btw("MS replies with an Identity Response, VLR sends the IMEI to HLR");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100654 gsup_expect_tx("30010809710000004026f050090824433224433224f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200655 ms_sends_msg("0559084a32244332244302");
Oliver Smith7d053092018-12-14 17:37:38 +0100656
657 btw("HLR accepts the IMEI");
658 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100659 gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200660 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
661
662 btw("LU was successful, and the conn has already been closed");
663 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100664 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200665 EXPECT_CONN_COUNT(0);
666
667 btw("Subscriber has the IMEI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100668 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200669 OSMO_ASSERT(vsub);
670 VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100671 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200672
673 BTW("subscriber detaches");
674 expect_bssap_clear();
675 ms_sends_msg("050130089910070000006402");
676 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
677
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100678 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200679 EXPECT_CONN_COUNT(0);
680 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100681 comment_end();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200682}
683
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100684static void test_no_authen_imeisv_tmsi()
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200685{
686 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100687 const char *imsi = "901700000004620";
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200688
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100689 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200690
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100691 comment_start();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200692
693 net->vlr->cfg.retrieve_imeisv_early = true;
694 net->vlr->cfg.assign_tmsi = true;
695
696 btw("Location Update request causes an IMEISV ID request back to the MS");
697 lu_result_sent = RES_NONE;
698 dtap_expect_tx("051803");
699 ms_sends_msg("050802008168000130089910070000006402");
700 OSMO_ASSERT(dtap_tx_confirmed);
701
702 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 +0100703 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200704 ms_sends_msg("0559094332244332244372f5");
705 OSMO_ASSERT(gsup_tx_confirmed);
706 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
707
708 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100709 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200710 OSMO_ASSERT(vsub);
711 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100712 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200713
714 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100715 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
716 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200717 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
718
719 btw("having received subscriber data does not mean acceptance");
720 EXPECT_ACCEPTED(false);
721 thwart_rx_non_initial_requests();
722 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
723
724 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100725 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200726
727 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
728 EXPECT_CONN_COUNT(1);
729 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
730 EXPECT_ACCEPTED(false);
731 thwart_rx_non_initial_requests();
732
733 btw("even though the TMSI is not acked, we can already find the subscr with it");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100734 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200735 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
736 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
737 VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x");
738 VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100739 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200740
741 btw("MS sends TMSI Realloc Complete");
742 expect_bssap_clear();
743 ms_sends_msg("055b");
744 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
745
746 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100747 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200748 EXPECT_CONN_COUNT(0);
749
750
751 BTW("subscriber sends LU Request, this time with the TMSI");
752 btw("Location Update request causes an IMEISV ID request back to the MS");
753 lu_result_sent = RES_NONE;
754 dtap_expect_tx("051803");
755 ms_sends_msg("050802008168000130089910070000006402");
756 OSMO_ASSERT(dtap_tx_confirmed);
757
758 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 +0100759 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200760 ms_sends_msg("0559095332244332244372f6");
761 OSMO_ASSERT(gsup_tx_confirmed);
762 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
763
764 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100765 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200766 OSMO_ASSERT(vsub);
767 VERBOSE_ASSERT(strcmp(vsub->imeisv, "5234234234234276"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100768 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200769
770 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100771 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
772 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200773 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
774
775 btw("having received subscriber data does not mean acceptance");
776 EXPECT_ACCEPTED(false);
777 thwart_rx_non_initial_requests();
778 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
779
780 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100781 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200782
783 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
784 EXPECT_CONN_COUNT(1);
785 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
786 EXPECT_ACCEPTED(false);
787 thwart_rx_non_initial_requests();
788
789 btw("even though the TMSI is not acked, we can already find the subscr with it");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100790 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200791 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
792 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
793 VERBOSE_ASSERT(vsub->tmsi_new, == 0x07060504, "0x%08x");
794 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100795 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200796
797 btw("MS sends TMSI Realloc Complete");
798 expect_bssap_clear();
799 ms_sends_msg("055b");
800 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
801
802 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100803 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200804 EXPECT_CONN_COUNT(0);
805
806 btw("subscriber has the new TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100807 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200808 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
809 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
810 VERBOSE_ASSERT(vsub->tmsi_new, == GSM_RESERVED_TMSI, "0x%08x");
811 VERBOSE_ASSERT(vsub->tmsi, == 0x07060504, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100812 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200813
814 BTW("subscriber detaches, using new TMSI");
815 expect_bssap_clear();
816 ms_sends_msg("050130" "05f4" "07060504");
817 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
818
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100819 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200820 EXPECT_CONN_COUNT(0);
821 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100822 comment_end();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200823}
824
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100825static void test_no_authen_imeisv_tmsi_imei()
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200826{
827 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100828 const char *imsi = "901700000004620";
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200829
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100830 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200831
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100832 comment_start();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200833
834 net->vlr->cfg.retrieve_imeisv_early = true;
835 net->vlr->cfg.assign_tmsi = true;
836 net->vlr->cfg.check_imei_rqd = true;
837
838 btw("Location Update request causes an IMEISV ID request back to the MS");
839 lu_result_sent = RES_NONE;
840 dtap_expect_tx("051803");
841 ms_sends_msg("050802008168000130089910070000006402");
842 OSMO_ASSERT(dtap_tx_confirmed);
843
844 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 +0100845 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200846 ms_sends_msg("0559094332244332244372f5");
847 OSMO_ASSERT(gsup_tx_confirmed);
848 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
849
850 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100851 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200852 OSMO_ASSERT(vsub);
853 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100854 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200855
856 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100857 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
858 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200859 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
860
861 btw("having received subscriber data does not mean acceptance");
862 EXPECT_ACCEPTED(false);
863 thwart_rx_non_initial_requests();
864 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
865
866 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS");
867 dtap_expect_tx("051802");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100868 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200869
870 btw("We will only do business when the IMEI is known");
871 EXPECT_CONN_COUNT(1);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100872 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200873 OSMO_ASSERT(vsub);
874 VERBOSE_ASSERT(vsub->imei[0], == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100875 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200876 EXPECT_ACCEPTED(false);
877 thwart_rx_non_initial_requests();
878
Oliver Smith7d053092018-12-14 17:37:38 +0100879 btw("MS replies with an Identity Response, VLR sends the IMEI to HLR");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100880 gsup_expect_tx("30010809710000004026f050090824433224433224f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200881 ms_sends_msg("0559084a32244332244302");
882
Oliver Smith7d053092018-12-14 17:37:38 +0100883 btw("HLR accepts the IMEI");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100884 gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL);
Oliver Smith7d053092018-12-14 17:37:38 +0100885
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200886 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
887 EXPECT_CONN_COUNT(1);
888 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
889 EXPECT_ACCEPTED(false);
890 thwart_rx_non_initial_requests();
891
892 btw("MS sends TMSI Realloc Complete");
893 expect_bssap_clear();
894 ms_sends_msg("055b");
895 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
896
897 btw("LU was successful, and the conn has already been closed");
898 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100899 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200900 EXPECT_CONN_COUNT(0);
901
902 btw("Subscriber has the IMEISV, IMEI and TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100903 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200904 OSMO_ASSERT(vsub);
905 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
906 VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d");
907 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100908 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200909
910 BTW("subscriber detaches");
911 expect_bssap_clear();
912 ms_sends_msg("050130089910070000006402");
913 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
914
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100915 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200916 EXPECT_CONN_COUNT(0);
917 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100918 comment_end();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200919}
920
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200921static void test_no_authen_subscr_expire()
922{
923 struct vlr_subscr *vsub;
924 const char *imsi = "901700000004620";
925
926 /* No auth only works on GERAN */
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100927 rx_from_ran = OSMO_RAT_GERAN_A;
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200928
929 comment_start();
930
931 fake_time_start();
932
933 /* The test framework has already started the VLR before fake time was active.
934 * Manually schedule this timeout in fake time. */
935 osmo_timer_del(&net->vlr->lu_expire_timer);
936 osmo_timer_schedule(&net->vlr->lu_expire_timer, VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL, 0);
937
938 /* Let the LU expiration timer tick once */
939 fake_time_passes(VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL + 1, 0);
940
941 btw("Location Update request causes a GSUP LU request to HLR");
942 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100943 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200944 ms_sends_msg("050802008168000130089910070000006402");
945 OSMO_ASSERT(gsup_tx_confirmed);
946 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
947
948 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100949 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
950 "12010809710000004026f0" VLR_TO_HLR);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200951 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
952
953 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
954 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100955 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200956
957 btw("LU was successful, and the conn has already been closed");
958 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
959 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
960
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100961 ran_sends_clear_complete();
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200962 EXPECT_CONN_COUNT(0);
963
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100964 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200965 OSMO_ASSERT(vsub);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100966 vlr_subscr_put(vsub, __func__);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200967
968 /* Let T3212 (periodic Location update timer) expire */
969 fake_time_passes((net->t3212 * 60 * 6 * 2) + 60*4, 0);
970
971 /* The subscriber should now be gone. */
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100972 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200973 OSMO_ASSERT(vsub == NULL);
974
975 EXPECT_CONN_COUNT(0);
976 clear_vlr();
977 comment_end();
978}
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200979
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100980msc_vlr_test_func_t msc_vlr_tests[] = {
981 test_no_authen,
982 test_no_authen_tmsi,
983 test_no_authen_imei,
984 test_no_authen_tmsi_imei,
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200985 test_no_authen_imeisv,
986 test_no_authen_imeisv_imei,
987 test_no_authen_imeisv_tmsi,
988 test_no_authen_imeisv_tmsi_imei,
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200989 test_no_authen_subscr_expire,
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100990 NULL
991};