Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 1 | /* 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 Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 25 | #include "stubs.h" |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 26 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 27 | static void test_no_authen() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 28 | { |
| 29 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 30 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 31 | /* No auth only works on GERAN */ |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 32 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 33 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 34 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 35 | |
| 36 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 37 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 38 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 39 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 44 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 45 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 46 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 56 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 57 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 58 | |
| 59 | btw("LU was successful, and the conn has already been closed"); |
| 60 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 61 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 62 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 63 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 64 | EXPECT_CONN_COUNT(0); |
| 65 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 66 | BTW("after a while, a new conn sends a CM Service Request (MO SMS)"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 67 | cm_service_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 68 | ms_sends_msg("05 24 74 03 30 58 86 08 99 10 07 00 00 00 64 02"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 69 | VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d"); |
| 70 | EXPECT_ACCEPTED(true); |
| 71 | |
Vadim Yanitskiy | 2760585 | 2018-06-15 23:57:30 +0700 | [diff] [blame] | 72 | /* Release connection */ |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 73 | expect_bssap_clear(OSMO_RAT_GERAN_A); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 74 | conn_conclude_cm_service_req(g_msub, MSC_A_USE_CM_SERVICE_SMS); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 75 | |
| 76 | btw("all requests serviced, conn has been released"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 77 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 78 | EXPECT_CONN_COUNT(0); |
| 79 | |
| 80 | BTW("an SMS is sent, MS is paged"); |
| 81 | paging_expect_imsi(imsi); |
| 82 | paging_sent = false; |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 83 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 84 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 92 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 93 | vsub = NULL; |
| 94 | VERBOSE_ASSERT(paging_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 95 | |
| 96 | btw("the subscriber and its pending request should remain"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 97 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 98 | OSMO_ASSERT(vsub); |
| 99 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 100 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 101 | |
| 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 Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 126 | |
| 127 | btw("SMS was delivered, no requests pending for subscr"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 128 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 129 | OSMO_ASSERT(vsub); |
| 130 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 131 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 132 | |
| 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 142 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 143 | ms_sends_msg("890106020041020000"); |
| 144 | VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 145 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 146 | |
| 147 | btw("SMS is done, conn is gone"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 148 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 149 | EXPECT_CONN_COUNT(0); |
| 150 | |
| 151 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 152 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 153 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 154 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 155 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 156 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 157 | EXPECT_CONN_COUNT(0); |
| 158 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 159 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 160 | } |
| 161 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 162 | static void test_no_authen_tmsi() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 163 | { |
| 164 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 165 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 166 | |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 167 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 168 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 169 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 170 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 175 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 176 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 181 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 182 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 183 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 191 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 192 | |
| 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 200 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 201 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 205 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 206 | |
| 207 | btw("MS sends TMSI Realloc Complete"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 208 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 209 | ms_sends_msg("055b"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 210 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 211 | |
| 212 | btw("LU was successful, and the conn has already been closed"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 213 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 214 | EXPECT_CONN_COUNT(0); |
| 215 | |
| 216 | btw("Subscriber has the new TMSI"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 217 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 218 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 222 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 223 | |
| 224 | BTW("after a while, a new conn sends a CM Service Request using above TMSI"); |
| 225 | cm_service_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 226 | ms_sends_msg("05247403305886" "05f4" "03020100"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 227 | VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d"); |
| 228 | EXPECT_ACCEPTED(true); |
| 229 | |
Vadim Yanitskiy | 2760585 | 2018-06-15 23:57:30 +0700 | [diff] [blame] | 230 | /* Release connection */ |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 231 | expect_bssap_clear(OSMO_RAT_GERAN_A); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 232 | conn_conclude_cm_service_req(g_msub, MSC_A_USE_CM_SERVICE_SMS); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 233 | |
| 234 | btw("all requests serviced, conn has been released"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 235 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 236 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 241 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 242 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 250 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 251 | vsub = NULL; |
| 252 | VERBOSE_ASSERT(paging_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 253 | |
| 254 | btw("the subscriber and its pending request should remain"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 255 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 256 | OSMO_ASSERT(vsub); |
| 257 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 258 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 259 | |
| 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 Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 284 | |
| 285 | btw("SMS was delivered, no requests pending for subscr"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 286 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 287 | OSMO_ASSERT(vsub); |
| 288 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 289 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 290 | |
| 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 300 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 301 | ms_sends_msg("890106020041020000"); |
| 302 | VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 303 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 304 | |
| 305 | btw("SMS is done, conn is gone"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 306 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 307 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 320 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 321 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 326 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 327 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 328 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 336 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 337 | |
| 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 345 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 346 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 350 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 351 | |
| 352 | btw("MS sends TMSI Realloc Complete"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 353 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 354 | ms_sends_msg("055b"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 355 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 356 | |
| 357 | btw("LU was successful, and the conn has already been closed"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 358 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 359 | EXPECT_CONN_COUNT(0); |
| 360 | |
| 361 | btw("subscriber has the new TMSI"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 362 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 363 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 367 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 368 | |
| 369 | BTW("subscriber detaches, using new TMSI"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 370 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 371 | ms_sends_msg("050130" "05f4" "07060504"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 372 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 373 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 374 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 375 | EXPECT_CONN_COUNT(0); |
| 376 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 377 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 378 | } |
| 379 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 380 | static void test_no_authen_imei() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 381 | { |
| 382 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 383 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 384 | |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 385 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 386 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 387 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 388 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 393 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 394 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 399 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 400 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 401 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 410 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 411 | |
| 412 | btw("We will only do business when the IMEI is known"); |
| 413 | EXPECT_CONN_COUNT(1); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 414 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 415 | OSMO_ASSERT(vsub); |
| 416 | VERBOSE_ASSERT(vsub->imei[0], == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 417 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 418 | EXPECT_ACCEPTED(false); |
| 419 | thwart_rx_non_initial_requests(); |
| 420 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame] | 421 | btw("MS replies with an Identity Response, VLR sends the IMEI to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 422 | gsup_expect_tx("30010809710000004026f050090824433224433224f0" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 423 | /* 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 Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame] | 426 | |
| 427 | btw("HLR accepts the IMEI"); |
| 428 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 429 | gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 430 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 431 | |
| 432 | btw("LU was successful, and the conn has already been closed"); |
| 433 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 434 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 435 | EXPECT_CONN_COUNT(0); |
| 436 | |
| 437 | btw("Subscriber has the IMEI"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 438 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 439 | OSMO_ASSERT(vsub); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 440 | VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 441 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 442 | |
| 443 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 444 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 445 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 446 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 447 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 448 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 449 | EXPECT_CONN_COUNT(0); |
| 450 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 451 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 452 | } |
| 453 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 454 | static void test_no_authen_tmsi_imei() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 455 | { |
| 456 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 457 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 458 | |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 459 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 460 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 461 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 462 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 468 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 469 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 474 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 475 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 476 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 485 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 486 | |
| 487 | btw("We will only do business when the IMEI is known"); |
| 488 | EXPECT_CONN_COUNT(1); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 489 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 490 | OSMO_ASSERT(vsub); |
| 491 | VERBOSE_ASSERT(vsub->imei[0], == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 492 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 493 | EXPECT_ACCEPTED(false); |
| 494 | thwart_rx_non_initial_requests(); |
| 495 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame] | 496 | btw("MS replies with an Identity Response, VLR sends the IMEI to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 497 | gsup_expect_tx("30010809710000004026f050090824433224433224f0" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 498 | ms_sends_msg("0559084a32244332244302"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 499 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame] | 500 | btw("HLR accepts the IMEI"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 501 | gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL); |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame] | 502 | |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 503 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 510 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 511 | ms_sends_msg("055b"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 512 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 513 | |
| 514 | btw("LU was successful, and the conn has already been closed"); |
| 515 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 516 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 517 | EXPECT_CONN_COUNT(0); |
| 518 | |
| 519 | btw("Subscriber has the IMEI and TMSI"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 520 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 521 | OSMO_ASSERT(vsub); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 522 | VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 523 | VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 524 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 525 | |
| 526 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 527 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 528 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 529 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 530 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 531 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 532 | EXPECT_CONN_COUNT(0); |
| 533 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 534 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 535 | } |
| 536 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 537 | static void test_no_authen_imeisv() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 538 | { |
| 539 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 540 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 541 | |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 542 | /* No auth only works on GERAN */ |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 543 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 544 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 545 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 546 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 556 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 557 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 562 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 563 | OSMO_ASSERT(vsub); |
| 564 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 565 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 566 | |
| 567 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 568 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 569 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 570 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 581 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 582 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 586 | ran_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 587 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 594 | ran_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 595 | EXPECT_CONN_COUNT(0); |
| 596 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 597 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 598 | } |
| 599 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 600 | static void test_no_authen_imeisv_imei() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 601 | { |
| 602 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 603 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 604 | |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 605 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 606 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 607 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 608 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 619 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 620 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 625 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 626 | OSMO_ASSERT(vsub); |
| 627 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 628 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 629 | |
| 630 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 631 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 632 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 633 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 642 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 643 | |
| 644 | btw("We will only do business when the IMEI is known"); |
| 645 | EXPECT_CONN_COUNT(1); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 646 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 647 | OSMO_ASSERT(vsub); |
| 648 | VERBOSE_ASSERT(vsub->imei[0], == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 649 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 650 | EXPECT_ACCEPTED(false); |
| 651 | thwart_rx_non_initial_requests(); |
| 652 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame] | 653 | btw("MS replies with an Identity Response, VLR sends the IMEI to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 654 | gsup_expect_tx("30010809710000004026f050090824433224433224f0" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 655 | ms_sends_msg("0559084a32244332244302"); |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame] | 656 | |
| 657 | btw("HLR accepts the IMEI"); |
| 658 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 659 | gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 660 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 664 | ran_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 665 | EXPECT_CONN_COUNT(0); |
| 666 | |
| 667 | btw("Subscriber has the IMEI"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 668 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 669 | OSMO_ASSERT(vsub); |
| 670 | VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 671 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 672 | |
| 673 | BTW("subscriber detaches"); |
| 674 | expect_bssap_clear(); |
| 675 | ms_sends_msg("050130089910070000006402"); |
| 676 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 677 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 678 | ran_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 679 | EXPECT_CONN_COUNT(0); |
| 680 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 681 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 682 | } |
| 683 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 684 | static void test_no_authen_imeisv_tmsi() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 685 | { |
| 686 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 687 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 688 | |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 689 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 690 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 691 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 692 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 703 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 704 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 709 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 710 | OSMO_ASSERT(vsub); |
| 711 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 712 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 713 | |
| 714 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 715 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 716 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 717 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 725 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 726 | |
| 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 734 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 735 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 739 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 740 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 747 | ran_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 748 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 759 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 760 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 765 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 766 | OSMO_ASSERT(vsub); |
| 767 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "5234234234234276"), == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 768 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 769 | |
| 770 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 771 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 772 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 773 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 781 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 782 | |
| 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 790 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 791 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 795 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 796 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 803 | ran_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 804 | EXPECT_CONN_COUNT(0); |
| 805 | |
| 806 | btw("subscriber has the new TMSI"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 807 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 808 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 812 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 813 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 819 | ran_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 820 | EXPECT_CONN_COUNT(0); |
| 821 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 822 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 823 | } |
| 824 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 825 | static void test_no_authen_imeisv_tmsi_imei() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 826 | { |
| 827 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 828 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 829 | |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 830 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 831 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 832 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 833 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 845 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 846 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 851 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 852 | OSMO_ASSERT(vsub); |
| 853 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 854 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 855 | |
| 856 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 857 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 858 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 859 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 868 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 869 | |
| 870 | btw("We will only do business when the IMEI is known"); |
| 871 | EXPECT_CONN_COUNT(1); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 872 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 873 | OSMO_ASSERT(vsub); |
| 874 | VERBOSE_ASSERT(vsub->imei[0], == 0, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 875 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 876 | EXPECT_ACCEPTED(false); |
| 877 | thwart_rx_non_initial_requests(); |
| 878 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame] | 879 | btw("MS replies with an Identity Response, VLR sends the IMEI to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 880 | gsup_expect_tx("30010809710000004026f050090824433224433224f0" VLR_TO_HLR); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 881 | ms_sends_msg("0559084a32244332244302"); |
| 882 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame] | 883 | btw("HLR accepts the IMEI"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 884 | gsup_rx("32010809710000004026f0510100" HLR_TO_VLR, NULL); |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame] | 885 | |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 886 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 899 | ran_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 900 | EXPECT_CONN_COUNT(0); |
| 901 | |
| 902 | btw("Subscriber has the IMEISV, IMEI and TMSI"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 903 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 904 | 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 908 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 909 | |
| 910 | BTW("subscriber detaches"); |
| 911 | expect_bssap_clear(); |
| 912 | ms_sends_msg("050130089910070000006402"); |
| 913 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 914 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 915 | ran_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 916 | EXPECT_CONN_COUNT(0); |
| 917 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 918 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 919 | } |
| 920 | |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 921 | static 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 Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 927 | rx_from_ran = OSMO_RAT_GERAN_A; |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 928 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 943 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 944 | 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 949 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 950 | "12010809710000004026f0" VLR_TO_HLR); |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 951 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 952 | |
| 953 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 954 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 955 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 956 | |
| 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 Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame^] | 961 | ran_sends_clear_complete(); |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 962 | EXPECT_CONN_COUNT(0); |
| 963 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 964 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 965 | OSMO_ASSERT(vsub); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 966 | vlr_subscr_put(vsub, __func__); |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 967 | |
| 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 Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 972 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 973 | OSMO_ASSERT(vsub == NULL); |
| 974 | |
| 975 | EXPECT_CONN_COUNT(0); |
| 976 | clear_vlr(); |
| 977 | comment_end(); |
| 978 | } |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 979 | |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 980 | msc_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 Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 985 | test_no_authen_imeisv, |
| 986 | test_no_authen_imeisv_imei, |
| 987 | test_no_authen_imeisv_tmsi, |
| 988 | test_no_authen_imeisv_tmsi_imei, |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 989 | test_no_authen_subscr_expire, |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 990 | NULL |
| 991 | }; |