blob: 5d3db69aecd77e65c52fc00537c04be235cdc74a [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"
25
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010026static void test_no_authen()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010027{
28 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010029 const char *imsi = "901700000004620";
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020030 /* No auth only works on GERAN */
Neels Hofmeyr7814a832018-12-26 00:40:18 +010031 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010032
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010033 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010034
35 btw("Location Update request causes a GSUP LU request to HLR");
36 lu_result_sent = RES_NONE;
Neels Hofmeyr63b24642019-12-12 01:31:04 +010037 gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010038 ms_sends_msg("050802008168000130089910070000006402");
39 OSMO_ASSERT(gsup_tx_confirmed);
40 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
41
42 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010043 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
44 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010045 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
46
47 btw("having received subscriber data does not mean acceptance");
48 EXPECT_ACCEPTED(false);
49
50 thwart_rx_non_initial_requests();
51
52 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
53
54 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +020055 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010056 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010057
58 btw("LU was successful, and the conn has already been closed");
59 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +020060 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +020061
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010062 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010063 EXPECT_CONN_COUNT(0);
64
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010065 BTW("after a while, a new conn sends a CM Service Request (MO SMS)");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010066 cm_service_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010067 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 +010068 VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d");
69 EXPECT_ACCEPTED(true);
70
Vadim Yanitskiy27605852018-06-15 23:57:30 +070071 /* Release connection */
Vadim Yanitskiy188dd5f2019-06-19 02:05:08 +070072 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010073 conn_conclude_cm_service_req(g_msub, MSC_A_USE_CM_SERVICE_SMS);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010074
75 btw("all requests serviced, conn has been released");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010076 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010077 EXPECT_CONN_COUNT(0);
78
79 BTW("an SMS is sent, MS is paged");
80 paging_expect_imsi(imsi);
81 paging_sent = false;
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +010082 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010083 OSMO_ASSERT(vsub);
84 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
85
86 send_sms(vsub, vsub,
87 "Privacy in residential applications is a desirable"
88 " marketing option.");
89
90 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +010091 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010092 vsub = NULL;
93 VERBOSE_ASSERT(paging_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010094
95 btw("the subscriber and its pending request should remain");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +010096 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010097 OSMO_ASSERT(vsub);
98 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +010099 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100100
101 btw("MS replies with Paging Response, we deliver the SMS");
102 dtap_expect_tx("09" /* SMS messages */
103 "01" /* CP-DATA */
104 "58" /* length */
105 "01" /* Network to MS */
106 "00" /* reference */
107 /* originator (gsm411_send_sms() hardcodes this weird nr) */
108 "0791" "447758100650" /* 447785016005 */
109 "00" /* dest */
110 /* SMS TPDU */
111 "4c" /* len */
112 "00" /* SMS deliver */
113 "05806470f1" /* originating address 46071 */
114 "00" /* TP-PID */
115 "00" /* GSM default alphabet */
116 "071010" /* Y-M-D (from wrapped gsm340_gen_scts())*/
117 "000000" /* H-M-S */
118 "00" /* GMT+0 */
119 "44" /* data length */
120 "5079da1e1ee7416937485e9ea7c965373d1d6683c270383b3d0e"
121 "d3d36ff71c949e83c22072799e9687c5ec32a81d96afcbf4b4fb"
122 "0c7ac3e9e9b7db05");
123 ms_sends_msg("06270703305882089910070000006402");
124 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100125
126 btw("SMS was delivered, no requests pending for subscr");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100127 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100128 OSMO_ASSERT(vsub);
129 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100130 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100131
132 btw("conn is still open to wait for SMS ack dance");
133 EXPECT_CONN_COUNT(1);
134
135 btw("MS replies with CP-ACK for received SMS");
136 ms_sends_msg("8904");
137 EXPECT_CONN_COUNT(1);
138
139 btw("MS also sends RP-ACK, MSC in turn sends CP-ACK for that");
140 dtap_expect_tx("0904");
Philipp Maierfbf66102017-04-09 12:32:51 +0200141 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100142 ms_sends_msg("890106020041020000");
143 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200144 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100145
146 btw("SMS is done, conn is gone");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100147 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100148 EXPECT_CONN_COUNT(0);
149
150 BTW("subscriber detaches");
Philipp Maierfbf66102017-04-09 12:32:51 +0200151 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100152 ms_sends_msg("050130089910070000006402");
Philipp Maierfbf66102017-04-09 12:32:51 +0200153 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100154
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100155 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100156 EXPECT_CONN_COUNT(0);
157 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100158 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100159}
160
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100161static void test_no_authen_tmsi()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100162{
163 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100164 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100165
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100166 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200167
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100168 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100169
170 net->vlr->cfg.assign_tmsi = true;
171
172 btw("Location Update request causes a GSUP LU request to HLR");
173 lu_result_sent = RES_NONE;
Neels Hofmeyr63b24642019-12-12 01:31:04 +0100174 gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100175 ms_sends_msg("050802008168000130089910070000006402");
176 OSMO_ASSERT(gsup_tx_confirmed);
177 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
178
179 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100180 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
181 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100182 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
183
184 btw("having received subscriber data does not mean acceptance");
185 EXPECT_ACCEPTED(false);
186 thwart_rx_non_initial_requests();
187 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
188
189 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100190 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100191
192 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
193 EXPECT_CONN_COUNT(1);
194 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
195 EXPECT_ACCEPTED(false);
196 thwart_rx_non_initial_requests();
197
198 btw("even though the TMSI is not acked, we can already find the subscr with it");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100199 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100200 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
201 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
202 VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x");
203 VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100204 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100205
206 btw("MS sends TMSI Realloc Complete");
Philipp Maierfbf66102017-04-09 12:32:51 +0200207 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100208 ms_sends_msg("055b");
Philipp Maierfbf66102017-04-09 12:32:51 +0200209 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100210
211 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100212 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100213 EXPECT_CONN_COUNT(0);
214
215 btw("Subscriber has the new TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100216 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100217 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
218 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
219 VERBOSE_ASSERT(vsub->tmsi_new, == GSM_RESERVED_TMSI, "0x%08x");
220 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100221 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100222
223 BTW("after a while, a new conn sends a CM Service Request using above TMSI");
224 cm_service_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100225 ms_sends_msg("05247403305886" "05f4" "03020100");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100226 VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d");
227 EXPECT_ACCEPTED(true);
228
Vadim Yanitskiy27605852018-06-15 23:57:30 +0700229 /* Release connection */
Vadim Yanitskiy188dd5f2019-06-19 02:05:08 +0700230 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100231 conn_conclude_cm_service_req(g_msub, MSC_A_USE_CM_SERVICE_SMS);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100232
233 btw("all requests serviced, conn has been released");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100234 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100235 EXPECT_CONN_COUNT(0);
236
237 BTW("an SMS is sent, MS is paged using above TMSI");
238 paging_expect_tmsi(0x03020100);
239 paging_sent = false;
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100240 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100241 OSMO_ASSERT(vsub);
242 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
243
244 send_sms(vsub, vsub,
245 "Privacy in residential applications is a desirable"
246 " marketing option.");
247
248 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100249 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100250 vsub = NULL;
251 VERBOSE_ASSERT(paging_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100252
253 btw("the subscriber and its pending request should remain");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100254 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100255 OSMO_ASSERT(vsub);
256 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100257 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100258
259 btw("MS replies with Paging Response using TMSI, we deliver the SMS");
260 dtap_expect_tx("09" /* SMS messages */
261 "01" /* CP-DATA */
262 "58" /* length */
263 "01" /* Network to MS */
264 "00" /* reference */
265 /* originator (gsm411_send_sms() hardcodes this weird nr) */
266 "0791" "447758100650" /* 447785016005 */
267 "00" /* dest */
268 /* SMS TPDU */
269 "4c" /* len */
270 "00" /* SMS deliver */
271 "05806470f1" /* originating address 46071 */
272 "00" /* TP-PID */
273 "00" /* GSM default alphabet */
274 "071010" /* Y-M-D (from wrapped gsm340_gen_scts())*/
275 "000000" /* H-M-S */
276 "00" /* GMT+0 */
277 "44" /* data length */
278 "5079da1e1ee7416937485e9ea7c965373d1d6683c270383b3d0e"
279 "d3d36ff71c949e83c22072799e9687c5ec32a81d96afcbf4b4fb"
280 "0c7ac3e9e9b7db05");
281 ms_sends_msg("06270703305882" "05f4" "03020100");
282 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100283
284 btw("SMS was delivered, no requests pending for subscr");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100285 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100286 OSMO_ASSERT(vsub);
287 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100288 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100289
290 btw("conn is still open to wait for SMS ack dance");
291 EXPECT_CONN_COUNT(1);
292
293 btw("MS replies with CP-ACK for received SMS");
294 ms_sends_msg("8904");
295 EXPECT_CONN_COUNT(1);
296
297 btw("MS also sends RP-ACK, MSC in turn sends CP-ACK for that");
298 dtap_expect_tx("0904");
Philipp Maierfbf66102017-04-09 12:32:51 +0200299 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100300 ms_sends_msg("890106020041020000");
301 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200302 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100303
304 btw("SMS is done, conn is gone");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100305 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100306 EXPECT_CONN_COUNT(0);
307
308 /* TODO: when the subscriber detaches, the vlr_subscr gets
309 * deallocated and we no longer know the TMSI. This case is covered by
310 * test_lu_unknown_tmsi(), so here I'd like to still have the TMSI.
311 BTW("subscriber detaches, using TMSI");
312 ms_sends_msg("050130" "05f4" "03020100");
313 EXPECT_CONN_COUNT(0);
314 */
315
316 BTW("subscriber sends LU Request, this time with the TMSI");
317 btw("Location Update request causes a GSUP LU request to HLR");
318 lu_result_sent = RES_NONE;
Neels Hofmeyr63b24642019-12-12 01:31:04 +0100319 gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100320 ms_sends_msg("050802008168000130" "05f4" "03020100");
321 OSMO_ASSERT(gsup_tx_confirmed);
322 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
323
324 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100325 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
326 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100327 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
328
329 btw("having received subscriber data does not mean acceptance");
330 EXPECT_ACCEPTED(false);
331 thwart_rx_non_initial_requests();
332 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
333
334 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100335 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100336
337 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
338 EXPECT_CONN_COUNT(1);
339 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
340 EXPECT_ACCEPTED(false);
341 thwart_rx_non_initial_requests();
342
343 btw("even though the TMSI is not acked, we can already find the subscr with it");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100344 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100345 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
346 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
347 VERBOSE_ASSERT(vsub->tmsi_new, == 0x07060504, "0x%08x");
348 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100349 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100350
351 btw("MS sends TMSI Realloc Complete");
Philipp Maierfbf66102017-04-09 12:32:51 +0200352 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100353 ms_sends_msg("055b");
Philipp Maierfbf66102017-04-09 12:32:51 +0200354 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100355
356 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100357 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100358 EXPECT_CONN_COUNT(0);
359
360 btw("subscriber has the new TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100361 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100362 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
363 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
364 VERBOSE_ASSERT(vsub->tmsi_new, == GSM_RESERVED_TMSI, "0x%08x");
365 VERBOSE_ASSERT(vsub->tmsi, == 0x07060504, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100366 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100367
368 BTW("subscriber detaches, using new TMSI");
Philipp Maierfbf66102017-04-09 12:32:51 +0200369 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100370 ms_sends_msg("050130" "05f4" "07060504");
Philipp Maierfbf66102017-04-09 12:32:51 +0200371 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100372
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100373 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100374 EXPECT_CONN_COUNT(0);
375 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100376 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100377}
378
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100379static void test_no_authen_imei()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100380{
381 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100382 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100383
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100384 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200385
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100386 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100387
388 net->vlr->cfg.check_imei_rqd = true;
389
390 btw("Location Update request causes a GSUP LU request to HLR");
391 lu_result_sent = RES_NONE;
Neels Hofmeyr63b24642019-12-12 01:31:04 +0100392 gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100393 ms_sends_msg("050802008168000130089910070000006402");
394 OSMO_ASSERT(gsup_tx_confirmed);
395 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
396
397 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100398 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
399 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100400 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
401
402 btw("having received subscriber data does not mean acceptance");
403 EXPECT_ACCEPTED(false);
404 thwart_rx_non_initial_requests();
405 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
406
407 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS");
408 dtap_expect_tx("051802");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100409 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100410
411 btw("We will only do business when the IMEI is known");
412 EXPECT_CONN_COUNT(1);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100413 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100414 OSMO_ASSERT(vsub);
415 VERBOSE_ASSERT(vsub->imei[0], == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100416 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100417 EXPECT_ACCEPTED(false);
418 thwart_rx_non_initial_requests();
419
Oliver Smith7d053092018-12-14 17:37:38 +0100420 btw("MS replies with an Identity Response, VLR sends the IMEI to HLR");
Oliver Smithd1037052019-05-02 13:39:26 +0200421 gsup_expect_tx("30010809710000004026f050080724433224433224" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200422 /* 3GPP TS 23.003: 6.2.1 Composition of IMEI: the IMEI ends with a
423 * spare digit that shall be sent as zero by the MS. */
424 ms_sends_msg("0559084a32244332244302");
Oliver Smith7d053092018-12-14 17:37:38 +0100425
426 btw("HLR accepts the IMEI");
427 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100428 gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200429 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100430
431 btw("LU was successful, and the conn has already been closed");
432 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100433 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100434 EXPECT_CONN_COUNT(0);
435
436 btw("Subscriber has the IMEI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100437 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100438 OSMO_ASSERT(vsub);
Oliver Smithd1037052019-05-02 13:39:26 +0200439 VERBOSE_ASSERT(strcmp(vsub->imei, "42342342342342"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100440 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100441
442 BTW("subscriber detaches");
Philipp Maierfbf66102017-04-09 12:32:51 +0200443 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100444 ms_sends_msg("050130089910070000006402");
Philipp Maierfbf66102017-04-09 12:32:51 +0200445 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100446
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100447 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100448 EXPECT_CONN_COUNT(0);
449 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100450 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100451}
452
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100453static void test_no_authen_tmsi_imei()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100454{
455 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100456 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100457
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100458 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200459
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100460 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100461
462 net->vlr->cfg.assign_tmsi = true;
463 net->vlr->cfg.check_imei_rqd = true;
464
465 btw("Location Update request causes a GSUP LU request to HLR");
466 lu_result_sent = RES_NONE;
Neels Hofmeyr63b24642019-12-12 01:31:04 +0100467 gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100468 ms_sends_msg("050802008168000130089910070000006402");
469 OSMO_ASSERT(gsup_tx_confirmed);
470 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
471
472 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100473 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
474 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100475 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
476
477 btw("having received subscriber data does not mean acceptance");
478 EXPECT_ACCEPTED(false);
479 thwart_rx_non_initial_requests();
480 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
481
482 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS");
483 dtap_expect_tx("051802");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100484 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100485
486 btw("We will only do business when the IMEI is known");
487 EXPECT_CONN_COUNT(1);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100488 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100489 OSMO_ASSERT(vsub);
490 VERBOSE_ASSERT(vsub->imei[0], == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100491 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100492 EXPECT_ACCEPTED(false);
493 thwart_rx_non_initial_requests();
494
Oliver Smith7d053092018-12-14 17:37:38 +0100495 btw("MS replies with an Identity Response, VLR sends the IMEI to HLR");
Oliver Smithd1037052019-05-02 13:39:26 +0200496 gsup_expect_tx("30010809710000004026f050080724433224433224" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200497 ms_sends_msg("0559084a32244332244302");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100498
Oliver Smith7d053092018-12-14 17:37:38 +0100499 btw("HLR accepts the IMEI");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100500 gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL);
Oliver Smith7d053092018-12-14 17:37:38 +0100501
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100502 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
503 EXPECT_CONN_COUNT(1);
504 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
505 EXPECT_ACCEPTED(false);
506 thwart_rx_non_initial_requests();
507
508 btw("MS sends TMSI Realloc Complete");
Philipp Maierfbf66102017-04-09 12:32:51 +0200509 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100510 ms_sends_msg("055b");
Philipp Maierfbf66102017-04-09 12:32:51 +0200511 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100512
513 btw("LU was successful, and the conn has already been closed");
514 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100515 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100516 EXPECT_CONN_COUNT(0);
517
518 btw("Subscriber has the IMEI and TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100519 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100520 OSMO_ASSERT(vsub);
Oliver Smithd1037052019-05-02 13:39:26 +0200521 VERBOSE_ASSERT(strcmp(vsub->imei, "42342342342342"), == 0, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100522 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100523 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100524
525 BTW("subscriber detaches");
Philipp Maierfbf66102017-04-09 12:32:51 +0200526 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100527 ms_sends_msg("050130089910070000006402");
Philipp Maierfbf66102017-04-09 12:32:51 +0200528 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100529
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100530 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100531 EXPECT_CONN_COUNT(0);
532 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100533 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100534}
535
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100536static void test_no_authen_imeisv()
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200537{
538 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100539 const char *imsi = "901700000004620";
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100540
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200541 /* No auth only works on GERAN */
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100542 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200543
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100544 comment_start();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200545
546 net->vlr->cfg.retrieve_imeisv_early = true;
547
548 btw("Location Update request causes an IMEISV ID request back to the MS");
549 lu_result_sent = RES_NONE;
550 dtap_expect_tx("051803");
551 ms_sends_msg("050802008168000130089910070000006402");
552 OSMO_ASSERT(dtap_tx_confirmed);
553
554 btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR");
Neels Hofmeyr63b24642019-12-12 01:31:04 +0100555 gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200556 ms_sends_msg("0559094332244332244372f5");
557 OSMO_ASSERT(gsup_tx_confirmed);
558 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
559
560 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100561 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200562 OSMO_ASSERT(vsub);
563 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100564 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200565
566 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100567 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
568 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200569 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
570
571 btw("having received subscriber data does not mean acceptance");
572 EXPECT_ACCEPTED(false);
573
574 thwart_rx_non_initial_requests();
575
576 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
577
578 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
579 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100580 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200581
582 btw("LU was successful, and the conn has already been closed");
583 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
584 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100585 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200586 EXPECT_CONN_COUNT(0);
587
588 BTW("subscriber detaches");
589 expect_bssap_clear();
590 ms_sends_msg("050130089910070000006402");
591 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
592
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100593 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200594 EXPECT_CONN_COUNT(0);
595 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100596 comment_end();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200597}
598
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100599static void test_no_authen_imeisv_imei()
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200600{
601 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100602 const char *imsi = "901700000004620";
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200603
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100604 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200605
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100606 comment_start();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200607
608 net->vlr->cfg.retrieve_imeisv_early = true;
609 net->vlr->cfg.check_imei_rqd = true;
610
611 btw("Location Update request causes an IMEISV ID request back to the MS");
612 lu_result_sent = RES_NONE;
613 dtap_expect_tx("051803");
614 ms_sends_msg("050802008168000130089910070000006402");
615 OSMO_ASSERT(dtap_tx_confirmed);
616
Oliver Smithcbf2c932019-05-06 13:09:55 +0200617 btw("MS replies with an Identity Response, causes an early GSUP Check IMEI request to HLR");
618 gsup_expect_tx("30010809710000004026f050080724433224433224" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200619 ms_sends_msg("0559094332244332244372f5");
620 OSMO_ASSERT(gsup_tx_confirmed);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200621
622 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100623 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200624 OSMO_ASSERT(vsub);
625 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100626 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200627
Oliver Smithcbf2c932019-05-06 13:09:55 +0200628 btw("HLR accepts the IMEI, VLR responds with LU Request");
629 expect_bssap_clear();
630 gsup_rx("32010809710000004026f0510100" HLR_TO_VLR,
Neels Hofmeyr63b24642019-12-12 01:31:04 +0100631 "04010809710000004026f0" CN_DOMAIN VLR_TO_HLR);
Oliver Smithcbf2c932019-05-06 13:09:55 +0200632 OSMO_ASSERT(gsup_tx_confirmed);
633 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
634
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200635 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100636 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
637 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200638 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
639
640 btw("having received subscriber data does not mean acceptance");
641 EXPECT_ACCEPTED(false);
642 thwart_rx_non_initial_requests();
643 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
644
Oliver Smithcbf2c932019-05-06 13:09:55 +0200645 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100646 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200647
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200648 btw("LU was successful, and the conn has already been closed");
649 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100650 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200651 EXPECT_CONN_COUNT(0);
652
653 btw("Subscriber has the IMEI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100654 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200655 OSMO_ASSERT(vsub);
Oliver Smithd1037052019-05-02 13:39:26 +0200656 VERBOSE_ASSERT(strcmp(vsub->imei, "42342342342342"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100657 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200658
659 BTW("subscriber detaches");
660 expect_bssap_clear();
661 ms_sends_msg("050130089910070000006402");
662 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
663
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 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100667 comment_end();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200668}
669
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100670static void test_no_authen_imeisv_tmsi()
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200671{
672 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100673 const char *imsi = "901700000004620";
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200674
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100675 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200676
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100677 comment_start();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200678
679 net->vlr->cfg.retrieve_imeisv_early = true;
680 net->vlr->cfg.assign_tmsi = true;
681
682 btw("Location Update request causes an IMEISV ID request back to the MS");
683 lu_result_sent = RES_NONE;
684 dtap_expect_tx("051803");
685 ms_sends_msg("050802008168000130089910070000006402");
686 OSMO_ASSERT(dtap_tx_confirmed);
687
688 btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR");
Neels Hofmeyr63b24642019-12-12 01:31:04 +0100689 gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200690 ms_sends_msg("0559094332244332244372f5");
691 OSMO_ASSERT(gsup_tx_confirmed);
692 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
693
694 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100695 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200696 OSMO_ASSERT(vsub);
697 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100698 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200699
700 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100701 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
702 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200703 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
704
705 btw("having received subscriber data does not mean acceptance");
706 EXPECT_ACCEPTED(false);
707 thwart_rx_non_initial_requests();
708 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
709
710 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100711 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200712
713 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
714 EXPECT_CONN_COUNT(1);
715 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
716 EXPECT_ACCEPTED(false);
717 thwart_rx_non_initial_requests();
718
719 btw("even though the TMSI is not acked, we can already find the subscr with it");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100720 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200721 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
722 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
723 VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x");
724 VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100725 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200726
727 btw("MS sends TMSI Realloc Complete");
728 expect_bssap_clear();
729 ms_sends_msg("055b");
730 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
731
732 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100733 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200734 EXPECT_CONN_COUNT(0);
735
736
737 BTW("subscriber sends LU Request, this time with the TMSI");
738 btw("Location Update request causes an IMEISV ID request back to the MS");
739 lu_result_sent = RES_NONE;
740 dtap_expect_tx("051803");
741 ms_sends_msg("050802008168000130089910070000006402");
742 OSMO_ASSERT(dtap_tx_confirmed);
743
744 btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR");
Neels Hofmeyr63b24642019-12-12 01:31:04 +0100745 gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200746 ms_sends_msg("0559095332244332244372f6");
747 OSMO_ASSERT(gsup_tx_confirmed);
748 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
749
750 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100751 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200752 OSMO_ASSERT(vsub);
753 VERBOSE_ASSERT(strcmp(vsub->imeisv, "5234234234234276"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100754 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200755
756 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100757 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
758 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200759 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
760
761 btw("having received subscriber data does not mean acceptance");
762 EXPECT_ACCEPTED(false);
763 thwart_rx_non_initial_requests();
764 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
765
766 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100767 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200768
769 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
770 EXPECT_CONN_COUNT(1);
771 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
772 EXPECT_ACCEPTED(false);
773 thwart_rx_non_initial_requests();
774
775 btw("even though the TMSI is not acked, we can already find the subscr with it");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100776 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200777 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
778 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
779 VERBOSE_ASSERT(vsub->tmsi_new, == 0x07060504, "0x%08x");
780 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100781 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200782
783 btw("MS sends TMSI Realloc Complete");
784 expect_bssap_clear();
785 ms_sends_msg("055b");
786 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
787
788 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100789 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200790 EXPECT_CONN_COUNT(0);
791
792 btw("subscriber has the new TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100793 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200794 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
795 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
796 VERBOSE_ASSERT(vsub->tmsi_new, == GSM_RESERVED_TMSI, "0x%08x");
797 VERBOSE_ASSERT(vsub->tmsi, == 0x07060504, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100798 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200799
800 BTW("subscriber detaches, using new TMSI");
801 expect_bssap_clear();
802 ms_sends_msg("050130" "05f4" "07060504");
803 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
804
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100805 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200806 EXPECT_CONN_COUNT(0);
807 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100808 comment_end();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200809}
810
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100811static void test_no_authen_imeisv_tmsi_imei()
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200812{
813 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100814 const char *imsi = "901700000004620";
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200815
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100816 rx_from_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200817
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100818 comment_start();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200819
820 net->vlr->cfg.retrieve_imeisv_early = true;
821 net->vlr->cfg.assign_tmsi = true;
822 net->vlr->cfg.check_imei_rqd = true;
823
824 btw("Location Update request causes an IMEISV ID request back to the MS");
825 lu_result_sent = RES_NONE;
826 dtap_expect_tx("051803");
827 ms_sends_msg("050802008168000130089910070000006402");
828 OSMO_ASSERT(dtap_tx_confirmed);
829
Oliver Smithcbf2c932019-05-06 13:09:55 +0200830 btw("MS replies with an Identity Response, causes an early GSUP Check IMEI request to HLR");
831 gsup_expect_tx("30010809710000004026f050080724433224433224" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200832 ms_sends_msg("0559094332244332244372f5");
833 OSMO_ASSERT(gsup_tx_confirmed);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200834
835 btw("Subscriber has the IMEISV from the ID Response");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100836 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200837 OSMO_ASSERT(vsub);
838 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100839 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200840
Oliver Smithcbf2c932019-05-06 13:09:55 +0200841 btw("HLR accepts the IMEI, VLR responds with LU Request");
842 expect_bssap_clear();
843 gsup_rx("32010809710000004026f0510100" HLR_TO_VLR,
Neels Hofmeyr63b24642019-12-12 01:31:04 +0100844 "04010809710000004026f0" CN_DOMAIN VLR_TO_HLR);
Oliver Smithcbf2c932019-05-06 13:09:55 +0200845 OSMO_ASSERT(gsup_tx_confirmed);
846 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
847
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200848 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100849 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
850 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200851 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
852
853 btw("having received subscriber data does not mean acceptance");
854 EXPECT_ACCEPTED(false);
855 thwart_rx_non_initial_requests();
856 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
857
Oliver Smithcbf2c932019-05-06 13:09:55 +0200858 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100859 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200860
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200861 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
862 EXPECT_CONN_COUNT(1);
863 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
864 EXPECT_ACCEPTED(false);
865 thwart_rx_non_initial_requests();
866
867 btw("MS sends TMSI Realloc Complete");
868 expect_bssap_clear();
869 ms_sends_msg("055b");
870 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
871
872 btw("LU was successful, and the conn has already been closed");
873 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100874 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200875 EXPECT_CONN_COUNT(0);
876
877 btw("Subscriber has the IMEISV, IMEI and TMSI");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100878 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200879 OSMO_ASSERT(vsub);
880 VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d");
Oliver Smithd1037052019-05-02 13:39:26 +0200881 VERBOSE_ASSERT(strcmp(vsub->imei, "42342342342342"), == 0, "%d");
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200882 VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100883 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200884
885 BTW("subscriber detaches");
886 expect_bssap_clear();
887 ms_sends_msg("050130089910070000006402");
888 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
889
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100890 ran_sends_clear_complete();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200891 EXPECT_CONN_COUNT(0);
892 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100893 comment_end();
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200894}
895
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200896static void test_no_authen_subscr_expire()
897{
898 struct vlr_subscr *vsub;
899 const char *imsi = "901700000004620";
900
901 /* No auth only works on GERAN */
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100902 rx_from_ran = OSMO_RAT_GERAN_A;
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200903
904 comment_start();
905
906 fake_time_start();
907
908 /* The test framework has already started the VLR before fake time was active.
909 * Manually schedule this timeout in fake time. */
910 osmo_timer_del(&net->vlr->lu_expire_timer);
911 osmo_timer_schedule(&net->vlr->lu_expire_timer, VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL, 0);
912
913 /* Let the LU expiration timer tick once */
914 fake_time_passes(VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL + 1, 0);
915
916 btw("Location Update request causes a GSUP LU request to HLR");
917 lu_result_sent = RES_NONE;
Neels Hofmeyr63b24642019-12-12 01:31:04 +0100918 gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200919 ms_sends_msg("050802008168000130089910070000006402");
920 OSMO_ASSERT(gsup_tx_confirmed);
921 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
922
923 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100924 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
925 "12010809710000004026f0" VLR_TO_HLR);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200926 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
927
928 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
929 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100930 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200931
932 btw("LU was successful, and the conn has already been closed");
933 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
934 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
935
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100936 ran_sends_clear_complete();
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200937 EXPECT_CONN_COUNT(0);
938
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100939 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200940 OSMO_ASSERT(vsub);
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100941 vlr_subscr_put(vsub, __func__);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200942
943 /* Let T3212 (periodic Location update timer) expire */
Vadim Yanitskiyfc2b0192020-01-18 07:20:14 +0700944 fake_time_passes(vlr_timer(net->vlr, 3212) + 60 * 4, 0);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200945
946 /* The subscriber should now be gone. */
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100947 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200948 OSMO_ASSERT(vsub == NULL);
949
950 EXPECT_CONN_COUNT(0);
951 clear_vlr();
952 comment_end();
953}
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200954
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100955msc_vlr_test_func_t msc_vlr_tests[] = {
956 test_no_authen,
957 test_no_authen_tmsi,
958 test_no_authen_imei,
959 test_no_authen_tmsi_imei,
Neels Hofmeyr34d33bd2017-07-20 02:56:21 +0200960 test_no_authen_imeisv,
961 test_no_authen_imeisv_imei,
962 test_no_authen_imeisv_tmsi,
963 test_no_authen_imeisv_tmsi_imei,
Stefan Sperlingdefc3c82018-05-15 14:48:04 +0200964 test_no_authen_subscr_expire,
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100965 NULL
966};