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" |
| 25 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 26 | static void test_no_authen() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 27 | { |
| 28 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 29 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 30 | |
| 31 | /* No auth only works on GERAN */ |
| 32 | rx_from_ran = RAN_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 | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 38 | gsup_expect_tx("04010809710000004026f0280102"); |
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"); |
| 44 | gsup_rx("10010809710000004026f00804036470f1", |
| 45 | "12010809710000004026f0"); |
| 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 | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 57 | gsup_rx("06010809710000004026f0", NULL); |
| 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 | |
| 63 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 64 | EXPECT_CONN_COUNT(0); |
| 65 | |
| 66 | BTW("after a while, a new conn sends a CM Service Request"); |
| 67 | cm_service_result_sent = RES_NONE; |
| 68 | ms_sends_msg("05247803305886089910070000006402"); |
| 69 | OSMO_ASSERT(g_conn); |
Neels Hofmeyr | 4d3a66b | 2018-03-31 18:45:59 +0200 | [diff] [blame] | 70 | OSMO_ASSERT(g_conn->fi); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 71 | OSMO_ASSERT(g_conn->vsub); |
| 72 | VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d"); |
| 73 | EXPECT_ACCEPTED(true); |
| 74 | |
Vadim Yanitskiy | 2760585 | 2018-06-15 23:57:30 +0700 | [diff] [blame] | 75 | /* Release connection */ |
| 76 | expect_bssap_clear(RAN_GERAN_A); |
| 77 | conn_conclude_cm_service_req(g_conn, RAN_GERAN_A); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 78 | |
| 79 | btw("all requests serviced, conn has been released"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 80 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 81 | EXPECT_CONN_COUNT(0); |
| 82 | |
| 83 | BTW("an SMS is sent, MS is paged"); |
| 84 | paging_expect_imsi(imsi); |
| 85 | paging_sent = false; |
| 86 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 87 | OSMO_ASSERT(vsub); |
| 88 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d"); |
| 89 | |
| 90 | send_sms(vsub, vsub, |
| 91 | "Privacy in residential applications is a desirable" |
| 92 | " marketing option."); |
| 93 | |
| 94 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d"); |
| 95 | vlr_subscr_put(vsub); |
| 96 | vsub = NULL; |
| 97 | VERBOSE_ASSERT(paging_sent, == true, "%d"); |
| 98 | VERBOSE_ASSERT(paging_stopped, == false, "%d"); |
| 99 | |
| 100 | btw("the subscriber and its pending request should remain"); |
| 101 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 102 | OSMO_ASSERT(vsub); |
| 103 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d"); |
| 104 | vlr_subscr_put(vsub); |
| 105 | |
| 106 | btw("MS replies with Paging Response, we deliver the SMS"); |
| 107 | dtap_expect_tx("09" /* SMS messages */ |
| 108 | "01" /* CP-DATA */ |
| 109 | "58" /* length */ |
| 110 | "01" /* Network to MS */ |
| 111 | "00" /* reference */ |
| 112 | /* originator (gsm411_send_sms() hardcodes this weird nr) */ |
| 113 | "0791" "447758100650" /* 447785016005 */ |
| 114 | "00" /* dest */ |
| 115 | /* SMS TPDU */ |
| 116 | "4c" /* len */ |
| 117 | "00" /* SMS deliver */ |
| 118 | "05806470f1" /* originating address 46071 */ |
| 119 | "00" /* TP-PID */ |
| 120 | "00" /* GSM default alphabet */ |
| 121 | "071010" /* Y-M-D (from wrapped gsm340_gen_scts())*/ |
| 122 | "000000" /* H-M-S */ |
| 123 | "00" /* GMT+0 */ |
| 124 | "44" /* data length */ |
| 125 | "5079da1e1ee7416937485e9ea7c965373d1d6683c270383b3d0e" |
| 126 | "d3d36ff71c949e83c22072799e9687c5ec32a81d96afcbf4b4fb" |
| 127 | "0c7ac3e9e9b7db05"); |
| 128 | ms_sends_msg("06270703305882089910070000006402"); |
| 129 | VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d"); |
| 130 | VERBOSE_ASSERT(paging_stopped, == true, "%d"); |
| 131 | |
| 132 | btw("SMS was delivered, no requests pending for subscr"); |
| 133 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 134 | OSMO_ASSERT(vsub); |
| 135 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d"); |
| 136 | vlr_subscr_put(vsub); |
| 137 | |
| 138 | btw("conn is still open to wait for SMS ack dance"); |
| 139 | EXPECT_CONN_COUNT(1); |
| 140 | |
| 141 | btw("MS replies with CP-ACK for received SMS"); |
| 142 | ms_sends_msg("8904"); |
| 143 | EXPECT_CONN_COUNT(1); |
| 144 | |
| 145 | btw("MS also sends RP-ACK, MSC in turn sends CP-ACK for that"); |
| 146 | dtap_expect_tx("0904"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 147 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 148 | ms_sends_msg("890106020041020000"); |
| 149 | VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 150 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 151 | |
| 152 | btw("SMS is done, conn is gone"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 153 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 154 | EXPECT_CONN_COUNT(0); |
| 155 | |
| 156 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 157 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 158 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 159 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 160 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 161 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 162 | EXPECT_CONN_COUNT(0); |
| 163 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 164 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 165 | } |
| 166 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 167 | static void test_no_authen_tmsi() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 168 | { |
| 169 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 170 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 171 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 172 | rx_from_ran = RAN_GERAN_A; |
| 173 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 174 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 175 | |
| 176 | net->vlr->cfg.assign_tmsi = true; |
| 177 | |
| 178 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 179 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 180 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 181 | ms_sends_msg("050802008168000130089910070000006402"); |
| 182 | OSMO_ASSERT(gsup_tx_confirmed); |
| 183 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 184 | |
| 185 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 186 | gsup_rx("10010809710000004026f00804036470f1", |
| 187 | "12010809710000004026f0"); |
| 188 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 189 | |
| 190 | btw("having received subscriber data does not mean acceptance"); |
| 191 | EXPECT_ACCEPTED(false); |
| 192 | thwart_rx_non_initial_requests(); |
| 193 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 194 | |
| 195 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 196 | gsup_rx("06010809710000004026f0", NULL); |
| 197 | |
| 198 | btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl"); |
| 199 | EXPECT_CONN_COUNT(1); |
| 200 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 201 | EXPECT_ACCEPTED(false); |
| 202 | thwart_rx_non_initial_requests(); |
| 203 | |
| 204 | btw("even though the TMSI is not acked, we can already find the subscr with it"); |
| 205 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100); |
| 206 | VERBOSE_ASSERT(vsub != NULL, == true, "%d"); |
| 207 | VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d"); |
| 208 | VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x"); |
| 209 | VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x"); |
| 210 | vlr_subscr_put(vsub); |
| 211 | |
| 212 | btw("MS sends TMSI Realloc Complete"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 213 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 214 | ms_sends_msg("055b"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 215 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 216 | |
| 217 | btw("LU was successful, and the conn has already been closed"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 218 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 219 | EXPECT_CONN_COUNT(0); |
| 220 | |
| 221 | btw("Subscriber has the new TMSI"); |
| 222 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 223 | VERBOSE_ASSERT(vsub != NULL, == true, "%d"); |
| 224 | VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d"); |
| 225 | VERBOSE_ASSERT(vsub->tmsi_new, == GSM_RESERVED_TMSI, "0x%08x"); |
| 226 | VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x"); |
| 227 | vlr_subscr_put(vsub); |
| 228 | |
| 229 | BTW("after a while, a new conn sends a CM Service Request using above TMSI"); |
| 230 | cm_service_result_sent = RES_NONE; |
| 231 | ms_sends_msg("05247803305886" "05f4" "03020100"); |
| 232 | OSMO_ASSERT(g_conn); |
Neels Hofmeyr | 4d3a66b | 2018-03-31 18:45:59 +0200 | [diff] [blame] | 233 | OSMO_ASSERT(g_conn->fi); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 234 | OSMO_ASSERT(g_conn->vsub); |
| 235 | VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d"); |
| 236 | EXPECT_ACCEPTED(true); |
| 237 | |
Vadim Yanitskiy | 2760585 | 2018-06-15 23:57:30 +0700 | [diff] [blame] | 238 | /* Release connection */ |
| 239 | expect_bssap_clear(RAN_GERAN_A); |
| 240 | conn_conclude_cm_service_req(g_conn, RAN_GERAN_A); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 241 | |
| 242 | btw("all requests serviced, conn has been released"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 243 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 244 | EXPECT_CONN_COUNT(0); |
| 245 | |
| 246 | BTW("an SMS is sent, MS is paged using above TMSI"); |
| 247 | paging_expect_tmsi(0x03020100); |
| 248 | paging_sent = false; |
| 249 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100); |
| 250 | OSMO_ASSERT(vsub); |
| 251 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d"); |
| 252 | |
| 253 | send_sms(vsub, vsub, |
| 254 | "Privacy in residential applications is a desirable" |
| 255 | " marketing option."); |
| 256 | |
| 257 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d"); |
| 258 | vlr_subscr_put(vsub); |
| 259 | vsub = NULL; |
| 260 | VERBOSE_ASSERT(paging_sent, == true, "%d"); |
| 261 | VERBOSE_ASSERT(paging_stopped, == false, "%d"); |
| 262 | |
| 263 | btw("the subscriber and its pending request should remain"); |
| 264 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 265 | OSMO_ASSERT(vsub); |
| 266 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d"); |
| 267 | vlr_subscr_put(vsub); |
| 268 | |
| 269 | btw("MS replies with Paging Response using TMSI, we deliver the SMS"); |
| 270 | dtap_expect_tx("09" /* SMS messages */ |
| 271 | "01" /* CP-DATA */ |
| 272 | "58" /* length */ |
| 273 | "01" /* Network to MS */ |
| 274 | "00" /* reference */ |
| 275 | /* originator (gsm411_send_sms() hardcodes this weird nr) */ |
| 276 | "0791" "447758100650" /* 447785016005 */ |
| 277 | "00" /* dest */ |
| 278 | /* SMS TPDU */ |
| 279 | "4c" /* len */ |
| 280 | "00" /* SMS deliver */ |
| 281 | "05806470f1" /* originating address 46071 */ |
| 282 | "00" /* TP-PID */ |
| 283 | "00" /* GSM default alphabet */ |
| 284 | "071010" /* Y-M-D (from wrapped gsm340_gen_scts())*/ |
| 285 | "000000" /* H-M-S */ |
| 286 | "00" /* GMT+0 */ |
| 287 | "44" /* data length */ |
| 288 | "5079da1e1ee7416937485e9ea7c965373d1d6683c270383b3d0e" |
| 289 | "d3d36ff71c949e83c22072799e9687c5ec32a81d96afcbf4b4fb" |
| 290 | "0c7ac3e9e9b7db05"); |
| 291 | ms_sends_msg("06270703305882" "05f4" "03020100"); |
| 292 | VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d"); |
| 293 | VERBOSE_ASSERT(paging_stopped, == true, "%d"); |
| 294 | |
| 295 | btw("SMS was delivered, no requests pending for subscr"); |
| 296 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 297 | OSMO_ASSERT(vsub); |
| 298 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d"); |
| 299 | vlr_subscr_put(vsub); |
| 300 | |
| 301 | btw("conn is still open to wait for SMS ack dance"); |
| 302 | EXPECT_CONN_COUNT(1); |
| 303 | |
| 304 | btw("MS replies with CP-ACK for received SMS"); |
| 305 | ms_sends_msg("8904"); |
| 306 | EXPECT_CONN_COUNT(1); |
| 307 | |
| 308 | btw("MS also sends RP-ACK, MSC in turn sends CP-ACK for that"); |
| 309 | dtap_expect_tx("0904"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 310 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 311 | ms_sends_msg("890106020041020000"); |
| 312 | VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 313 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 314 | |
| 315 | btw("SMS is done, conn is gone"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 316 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 317 | EXPECT_CONN_COUNT(0); |
| 318 | |
| 319 | /* TODO: when the subscriber detaches, the vlr_subscr gets |
| 320 | * deallocated and we no longer know the TMSI. This case is covered by |
| 321 | * test_lu_unknown_tmsi(), so here I'd like to still have the TMSI. |
| 322 | BTW("subscriber detaches, using TMSI"); |
| 323 | ms_sends_msg("050130" "05f4" "03020100"); |
| 324 | EXPECT_CONN_COUNT(0); |
| 325 | */ |
| 326 | |
| 327 | BTW("subscriber sends LU Request, this time with the TMSI"); |
| 328 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 329 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 330 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 331 | ms_sends_msg("050802008168000130" "05f4" "03020100"); |
| 332 | OSMO_ASSERT(gsup_tx_confirmed); |
| 333 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 334 | |
| 335 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 336 | gsup_rx("10010809710000004026f00804036470f1", |
| 337 | "12010809710000004026f0"); |
| 338 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 339 | |
| 340 | btw("having received subscriber data does not mean acceptance"); |
| 341 | EXPECT_ACCEPTED(false); |
| 342 | thwart_rx_non_initial_requests(); |
| 343 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 344 | |
| 345 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 346 | gsup_rx("06010809710000004026f0", NULL); |
| 347 | |
| 348 | btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl"); |
| 349 | EXPECT_CONN_COUNT(1); |
| 350 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 351 | EXPECT_ACCEPTED(false); |
| 352 | thwart_rx_non_initial_requests(); |
| 353 | |
| 354 | btw("even though the TMSI is not acked, we can already find the subscr with it"); |
| 355 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504); |
| 356 | VERBOSE_ASSERT(vsub != NULL, == true, "%d"); |
| 357 | VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d"); |
| 358 | VERBOSE_ASSERT(vsub->tmsi_new, == 0x07060504, "0x%08x"); |
| 359 | VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x"); |
| 360 | vlr_subscr_put(vsub); |
| 361 | |
| 362 | btw("MS sends TMSI Realloc Complete"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 363 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 364 | ms_sends_msg("055b"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 365 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 366 | |
| 367 | btw("LU was successful, and the conn has already been closed"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 368 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 369 | EXPECT_CONN_COUNT(0); |
| 370 | |
| 371 | btw("subscriber has the new TMSI"); |
| 372 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504); |
| 373 | VERBOSE_ASSERT(vsub != NULL, == true, "%d"); |
| 374 | VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d"); |
| 375 | VERBOSE_ASSERT(vsub->tmsi_new, == GSM_RESERVED_TMSI, "0x%08x"); |
| 376 | VERBOSE_ASSERT(vsub->tmsi, == 0x07060504, "0x%08x"); |
| 377 | vlr_subscr_put(vsub); |
| 378 | |
| 379 | BTW("subscriber detaches, using new TMSI"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 380 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 381 | ms_sends_msg("050130" "05f4" "07060504"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 382 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 383 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 384 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 385 | EXPECT_CONN_COUNT(0); |
| 386 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 387 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 388 | } |
| 389 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 390 | static void test_no_authen_imei() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 391 | { |
| 392 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 393 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 394 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 395 | rx_from_ran = RAN_GERAN_A; |
| 396 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 397 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 398 | |
| 399 | net->vlr->cfg.check_imei_rqd = true; |
| 400 | |
| 401 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 402 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 403 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 404 | ms_sends_msg("050802008168000130089910070000006402"); |
| 405 | OSMO_ASSERT(gsup_tx_confirmed); |
| 406 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 407 | |
| 408 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 409 | gsup_rx("10010809710000004026f00804036470f1", |
| 410 | "12010809710000004026f0"); |
| 411 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 412 | |
| 413 | btw("having received subscriber data does not mean acceptance"); |
| 414 | EXPECT_ACCEPTED(false); |
| 415 | thwart_rx_non_initial_requests(); |
| 416 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 417 | |
| 418 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS"); |
| 419 | dtap_expect_tx("051802"); |
| 420 | gsup_rx("06010809710000004026f0", NULL); |
| 421 | |
| 422 | btw("We will only do business when the IMEI is known"); |
| 423 | EXPECT_CONN_COUNT(1); |
| 424 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 425 | OSMO_ASSERT(vsub); |
| 426 | VERBOSE_ASSERT(vsub->imei[0], == 0, "%d"); |
| 427 | vlr_subscr_put(vsub); |
| 428 | EXPECT_ACCEPTED(false); |
| 429 | thwart_rx_non_initial_requests(); |
| 430 | |
| 431 | btw("MS replies with an Identity Response"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 432 | expect_bssap_clear(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 433 | /* 3GPP TS 23.003: 6.2.1 Composition of IMEI: the IMEI ends with a |
| 434 | * spare digit that shall be sent as zero by the MS. */ |
| 435 | ms_sends_msg("0559084a32244332244302"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 436 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 437 | |
| 438 | btw("LU was successful, and the conn has already been closed"); |
| 439 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 440 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 441 | EXPECT_CONN_COUNT(0); |
| 442 | |
| 443 | btw("Subscriber has the IMEI"); |
| 444 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 445 | OSMO_ASSERT(vsub); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 446 | VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 447 | vlr_subscr_put(vsub); |
| 448 | |
| 449 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 450 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 451 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 452 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 453 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 454 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 455 | EXPECT_CONN_COUNT(0); |
| 456 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 457 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 458 | } |
| 459 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 460 | static void test_no_authen_tmsi_imei() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 461 | { |
| 462 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 463 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 464 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 465 | rx_from_ran = RAN_GERAN_A; |
| 466 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 467 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 468 | |
| 469 | net->vlr->cfg.assign_tmsi = true; |
| 470 | net->vlr->cfg.check_imei_rqd = true; |
| 471 | |
| 472 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 473 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 474 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 475 | ms_sends_msg("050802008168000130089910070000006402"); |
| 476 | OSMO_ASSERT(gsup_tx_confirmed); |
| 477 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 478 | |
| 479 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 480 | gsup_rx("10010809710000004026f00804036470f1", |
| 481 | "12010809710000004026f0"); |
| 482 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 483 | |
| 484 | btw("having received subscriber data does not mean acceptance"); |
| 485 | EXPECT_ACCEPTED(false); |
| 486 | thwart_rx_non_initial_requests(); |
| 487 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 488 | |
| 489 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS"); |
| 490 | dtap_expect_tx("051802"); |
| 491 | gsup_rx("06010809710000004026f0", NULL); |
| 492 | |
| 493 | btw("We will only do business when the IMEI is known"); |
| 494 | EXPECT_CONN_COUNT(1); |
| 495 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 496 | OSMO_ASSERT(vsub); |
| 497 | VERBOSE_ASSERT(vsub->imei[0], == 0, "%d"); |
| 498 | vlr_subscr_put(vsub); |
| 499 | EXPECT_ACCEPTED(false); |
| 500 | thwart_rx_non_initial_requests(); |
| 501 | |
| 502 | btw("MS replies with an Identity Response"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 503 | ms_sends_msg("0559084a32244332244302"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 504 | |
| 505 | btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl"); |
| 506 | EXPECT_CONN_COUNT(1); |
| 507 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 508 | EXPECT_ACCEPTED(false); |
| 509 | thwart_rx_non_initial_requests(); |
| 510 | |
| 511 | btw("MS sends TMSI Realloc Complete"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 512 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 513 | ms_sends_msg("055b"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 514 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 515 | |
| 516 | btw("LU was successful, and the conn has already been closed"); |
| 517 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 518 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 519 | EXPECT_CONN_COUNT(0); |
| 520 | |
| 521 | btw("Subscriber has the IMEI and TMSI"); |
| 522 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 523 | OSMO_ASSERT(vsub); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 524 | VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 525 | VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x"); |
| 526 | vlr_subscr_put(vsub); |
| 527 | |
| 528 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 529 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 530 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 531 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 532 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 533 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 534 | EXPECT_CONN_COUNT(0); |
| 535 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 536 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 537 | } |
| 538 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 539 | static void test_no_authen_imeisv() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 540 | { |
| 541 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 542 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 543 | |
| 544 | /* No auth only works on GERAN */ |
| 545 | rx_from_ran = RAN_GERAN_A; |
| 546 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 547 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 548 | |
| 549 | net->vlr->cfg.retrieve_imeisv_early = true; |
| 550 | |
| 551 | btw("Location Update request causes an IMEISV ID request back to the MS"); |
| 552 | lu_result_sent = RES_NONE; |
| 553 | dtap_expect_tx("051803"); |
| 554 | ms_sends_msg("050802008168000130089910070000006402"); |
| 555 | OSMO_ASSERT(dtap_tx_confirmed); |
| 556 | |
| 557 | btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR"); |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 558 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 559 | ms_sends_msg("0559094332244332244372f5"); |
| 560 | OSMO_ASSERT(gsup_tx_confirmed); |
| 561 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 562 | |
| 563 | btw("Subscriber has the IMEISV from the ID Response"); |
| 564 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 565 | OSMO_ASSERT(vsub); |
| 566 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
| 567 | vlr_subscr_put(vsub); |
| 568 | |
| 569 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 570 | gsup_rx("10010809710000004026f00804036470f1", |
| 571 | "12010809710000004026f0"); |
| 572 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 573 | |
| 574 | btw("having received subscriber data does not mean acceptance"); |
| 575 | EXPECT_ACCEPTED(false); |
| 576 | |
| 577 | thwart_rx_non_initial_requests(); |
| 578 | |
| 579 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 580 | |
| 581 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 582 | expect_bssap_clear(); |
| 583 | gsup_rx("06010809710000004026f0", NULL); |
| 584 | |
| 585 | btw("LU was successful, and the conn has already been closed"); |
| 586 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 587 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 588 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 589 | EXPECT_CONN_COUNT(0); |
| 590 | |
| 591 | BTW("subscriber detaches"); |
| 592 | expect_bssap_clear(); |
| 593 | ms_sends_msg("050130089910070000006402"); |
| 594 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 595 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 596 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 597 | EXPECT_CONN_COUNT(0); |
| 598 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 599 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 600 | } |
| 601 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 602 | static void test_no_authen_imeisv_imei() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 603 | { |
| 604 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 605 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 606 | |
| 607 | rx_from_ran = RAN_GERAN_A; |
| 608 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 609 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 610 | |
| 611 | net->vlr->cfg.retrieve_imeisv_early = true; |
| 612 | net->vlr->cfg.check_imei_rqd = true; |
| 613 | |
| 614 | btw("Location Update request causes an IMEISV ID request back to the MS"); |
| 615 | lu_result_sent = RES_NONE; |
| 616 | dtap_expect_tx("051803"); |
| 617 | ms_sends_msg("050802008168000130089910070000006402"); |
| 618 | OSMO_ASSERT(dtap_tx_confirmed); |
| 619 | |
| 620 | btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR"); |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 621 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 622 | ms_sends_msg("0559094332244332244372f5"); |
| 623 | OSMO_ASSERT(gsup_tx_confirmed); |
| 624 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 625 | |
| 626 | btw("Subscriber has the IMEISV from the ID Response"); |
| 627 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 628 | OSMO_ASSERT(vsub); |
| 629 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
| 630 | vlr_subscr_put(vsub); |
| 631 | |
| 632 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 633 | gsup_rx("10010809710000004026f00804036470f1", |
| 634 | "12010809710000004026f0"); |
| 635 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 636 | |
| 637 | btw("having received subscriber data does not mean acceptance"); |
| 638 | EXPECT_ACCEPTED(false); |
| 639 | thwart_rx_non_initial_requests(); |
| 640 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 641 | |
| 642 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS"); |
| 643 | dtap_expect_tx("051802"); |
| 644 | gsup_rx("06010809710000004026f0", NULL); |
| 645 | |
| 646 | btw("We will only do business when the IMEI is known"); |
| 647 | EXPECT_CONN_COUNT(1); |
| 648 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 649 | OSMO_ASSERT(vsub); |
| 650 | VERBOSE_ASSERT(vsub->imei[0], == 0, "%d"); |
| 651 | vlr_subscr_put(vsub); |
| 652 | EXPECT_ACCEPTED(false); |
| 653 | thwart_rx_non_initial_requests(); |
| 654 | |
| 655 | btw("MS replies with an Identity Response"); |
| 656 | expect_bssap_clear(); |
| 657 | ms_sends_msg("0559084a32244332244302"); |
| 658 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 659 | |
| 660 | btw("LU was successful, and the conn has already been closed"); |
| 661 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 662 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 663 | EXPECT_CONN_COUNT(0); |
| 664 | |
| 665 | btw("Subscriber has the IMEI"); |
| 666 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 667 | OSMO_ASSERT(vsub); |
| 668 | VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d"); |
| 669 | vlr_subscr_put(vsub); |
| 670 | |
| 671 | BTW("subscriber detaches"); |
| 672 | expect_bssap_clear(); |
| 673 | ms_sends_msg("050130089910070000006402"); |
| 674 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 675 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 676 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 677 | EXPECT_CONN_COUNT(0); |
| 678 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 679 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 680 | } |
| 681 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 682 | static void test_no_authen_imeisv_tmsi() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 683 | { |
| 684 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 685 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 686 | |
| 687 | rx_from_ran = RAN_GERAN_A; |
| 688 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 689 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 690 | |
| 691 | net->vlr->cfg.retrieve_imeisv_early = true; |
| 692 | net->vlr->cfg.assign_tmsi = true; |
| 693 | |
| 694 | btw("Location Update request causes an IMEISV ID request back to the MS"); |
| 695 | lu_result_sent = RES_NONE; |
| 696 | dtap_expect_tx("051803"); |
| 697 | ms_sends_msg("050802008168000130089910070000006402"); |
| 698 | OSMO_ASSERT(dtap_tx_confirmed); |
| 699 | |
| 700 | btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR"); |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 701 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 702 | ms_sends_msg("0559094332244332244372f5"); |
| 703 | OSMO_ASSERT(gsup_tx_confirmed); |
| 704 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 705 | |
| 706 | btw("Subscriber has the IMEISV from the ID Response"); |
| 707 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 708 | OSMO_ASSERT(vsub); |
| 709 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
| 710 | vlr_subscr_put(vsub); |
| 711 | |
| 712 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 713 | gsup_rx("10010809710000004026f00804036470f1", |
| 714 | "12010809710000004026f0"); |
| 715 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 716 | |
| 717 | btw("having received subscriber data does not mean acceptance"); |
| 718 | EXPECT_ACCEPTED(false); |
| 719 | thwart_rx_non_initial_requests(); |
| 720 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 721 | |
| 722 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 723 | gsup_rx("06010809710000004026f0", NULL); |
| 724 | |
| 725 | btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl"); |
| 726 | EXPECT_CONN_COUNT(1); |
| 727 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 728 | EXPECT_ACCEPTED(false); |
| 729 | thwart_rx_non_initial_requests(); |
| 730 | |
| 731 | btw("even though the TMSI is not acked, we can already find the subscr with it"); |
| 732 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100); |
| 733 | VERBOSE_ASSERT(vsub != NULL, == true, "%d"); |
| 734 | VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d"); |
| 735 | VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x"); |
| 736 | VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x"); |
| 737 | vlr_subscr_put(vsub); |
| 738 | |
| 739 | btw("MS sends TMSI Realloc Complete"); |
| 740 | expect_bssap_clear(); |
| 741 | ms_sends_msg("055b"); |
| 742 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 743 | |
| 744 | btw("LU was successful, and the conn has already been closed"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 745 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 746 | EXPECT_CONN_COUNT(0); |
| 747 | |
| 748 | |
| 749 | BTW("subscriber sends LU Request, this time with the TMSI"); |
| 750 | btw("Location Update request causes an IMEISV ID request back to the MS"); |
| 751 | lu_result_sent = RES_NONE; |
| 752 | dtap_expect_tx("051803"); |
| 753 | ms_sends_msg("050802008168000130089910070000006402"); |
| 754 | OSMO_ASSERT(dtap_tx_confirmed); |
| 755 | |
| 756 | btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR"); |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 757 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 758 | ms_sends_msg("0559095332244332244372f6"); |
| 759 | OSMO_ASSERT(gsup_tx_confirmed); |
| 760 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 761 | |
| 762 | btw("Subscriber has the IMEISV from the ID Response"); |
| 763 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 764 | OSMO_ASSERT(vsub); |
| 765 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "5234234234234276"), == 0, "%d"); |
| 766 | vlr_subscr_put(vsub); |
| 767 | |
| 768 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 769 | gsup_rx("10010809710000004026f00804036470f1", |
| 770 | "12010809710000004026f0"); |
| 771 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 772 | |
| 773 | btw("having received subscriber data does not mean acceptance"); |
| 774 | EXPECT_ACCEPTED(false); |
| 775 | thwart_rx_non_initial_requests(); |
| 776 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 777 | |
| 778 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 779 | gsup_rx("06010809710000004026f0", NULL); |
| 780 | |
| 781 | btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl"); |
| 782 | EXPECT_CONN_COUNT(1); |
| 783 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 784 | EXPECT_ACCEPTED(false); |
| 785 | thwart_rx_non_initial_requests(); |
| 786 | |
| 787 | btw("even though the TMSI is not acked, we can already find the subscr with it"); |
| 788 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504); |
| 789 | VERBOSE_ASSERT(vsub != NULL, == true, "%d"); |
| 790 | VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d"); |
| 791 | VERBOSE_ASSERT(vsub->tmsi_new, == 0x07060504, "0x%08x"); |
| 792 | VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x"); |
| 793 | vlr_subscr_put(vsub); |
| 794 | |
| 795 | btw("MS sends TMSI Realloc Complete"); |
| 796 | expect_bssap_clear(); |
| 797 | ms_sends_msg("055b"); |
| 798 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 799 | |
| 800 | btw("LU was successful, and the conn has already been closed"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 801 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 802 | EXPECT_CONN_COUNT(0); |
| 803 | |
| 804 | btw("subscriber has the new TMSI"); |
| 805 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504); |
| 806 | VERBOSE_ASSERT(vsub != NULL, == true, "%d"); |
| 807 | VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d"); |
| 808 | VERBOSE_ASSERT(vsub->tmsi_new, == GSM_RESERVED_TMSI, "0x%08x"); |
| 809 | VERBOSE_ASSERT(vsub->tmsi, == 0x07060504, "0x%08x"); |
| 810 | vlr_subscr_put(vsub); |
| 811 | |
| 812 | BTW("subscriber detaches, using new TMSI"); |
| 813 | expect_bssap_clear(); |
| 814 | ms_sends_msg("050130" "05f4" "07060504"); |
| 815 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 816 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 817 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 818 | EXPECT_CONN_COUNT(0); |
| 819 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 820 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 821 | } |
| 822 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 823 | static void test_no_authen_imeisv_tmsi_imei() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 824 | { |
| 825 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 826 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 827 | |
| 828 | rx_from_ran = RAN_GERAN_A; |
| 829 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 830 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 831 | |
| 832 | net->vlr->cfg.retrieve_imeisv_early = true; |
| 833 | net->vlr->cfg.assign_tmsi = true; |
| 834 | net->vlr->cfg.check_imei_rqd = true; |
| 835 | |
| 836 | btw("Location Update request causes an IMEISV ID request back to the MS"); |
| 837 | lu_result_sent = RES_NONE; |
| 838 | dtap_expect_tx("051803"); |
| 839 | ms_sends_msg("050802008168000130089910070000006402"); |
| 840 | OSMO_ASSERT(dtap_tx_confirmed); |
| 841 | |
| 842 | btw("MS replies with an Identity Response, causes LU to commence with a GSUP LU request to HLR"); |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 843 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 844 | ms_sends_msg("0559094332244332244372f5"); |
| 845 | OSMO_ASSERT(gsup_tx_confirmed); |
| 846 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 847 | |
| 848 | btw("Subscriber has the IMEISV from the ID Response"); |
| 849 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 850 | OSMO_ASSERT(vsub); |
| 851 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
| 852 | vlr_subscr_put(vsub); |
| 853 | |
| 854 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 855 | gsup_rx("10010809710000004026f00804036470f1", |
| 856 | "12010809710000004026f0"); |
| 857 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 858 | |
| 859 | btw("having received subscriber data does not mean acceptance"); |
| 860 | EXPECT_ACCEPTED(false); |
| 861 | thwart_rx_non_initial_requests(); |
| 862 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 863 | |
| 864 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS"); |
| 865 | dtap_expect_tx("051802"); |
| 866 | gsup_rx("06010809710000004026f0", NULL); |
| 867 | |
| 868 | btw("We will only do business when the IMEI is known"); |
| 869 | EXPECT_CONN_COUNT(1); |
| 870 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 871 | OSMO_ASSERT(vsub); |
| 872 | VERBOSE_ASSERT(vsub->imei[0], == 0, "%d"); |
| 873 | vlr_subscr_put(vsub); |
| 874 | EXPECT_ACCEPTED(false); |
| 875 | thwart_rx_non_initial_requests(); |
| 876 | |
| 877 | btw("MS replies with an Identity Response"); |
| 878 | ms_sends_msg("0559084a32244332244302"); |
| 879 | |
| 880 | btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl"); |
| 881 | EXPECT_CONN_COUNT(1); |
| 882 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 883 | EXPECT_ACCEPTED(false); |
| 884 | thwart_rx_non_initial_requests(); |
| 885 | |
| 886 | btw("MS sends TMSI Realloc Complete"); |
| 887 | expect_bssap_clear(); |
| 888 | ms_sends_msg("055b"); |
| 889 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 890 | |
| 891 | btw("LU was successful, and the conn has already been closed"); |
| 892 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 893 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 894 | EXPECT_CONN_COUNT(0); |
| 895 | |
| 896 | btw("Subscriber has the IMEISV, IMEI and TMSI"); |
| 897 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 898 | OSMO_ASSERT(vsub); |
| 899 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
| 900 | VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d"); |
| 901 | VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x"); |
| 902 | vlr_subscr_put(vsub); |
| 903 | |
| 904 | BTW("subscriber detaches"); |
| 905 | expect_bssap_clear(); |
| 906 | ms_sends_msg("050130089910070000006402"); |
| 907 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 908 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 909 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 910 | EXPECT_CONN_COUNT(0); |
| 911 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 912 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 913 | } |
| 914 | |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 915 | static void test_no_authen_subscr_expire() |
| 916 | { |
| 917 | struct vlr_subscr *vsub; |
| 918 | const char *imsi = "901700000004620"; |
| 919 | |
| 920 | /* No auth only works on GERAN */ |
| 921 | rx_from_ran = RAN_GERAN_A; |
| 922 | |
| 923 | comment_start(); |
| 924 | |
| 925 | fake_time_start(); |
| 926 | |
| 927 | /* The test framework has already started the VLR before fake time was active. |
| 928 | * Manually schedule this timeout in fake time. */ |
| 929 | osmo_timer_del(&net->vlr->lu_expire_timer); |
| 930 | osmo_timer_schedule(&net->vlr->lu_expire_timer, VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL, 0); |
| 931 | |
| 932 | /* Let the LU expiration timer tick once */ |
| 933 | fake_time_passes(VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL + 1, 0); |
| 934 | |
| 935 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 936 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 937 | gsup_expect_tx("04010809710000004026f0280102"); |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 938 | ms_sends_msg("050802008168000130089910070000006402"); |
| 939 | OSMO_ASSERT(gsup_tx_confirmed); |
| 940 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 941 | |
| 942 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 943 | gsup_rx("10010809710000004026f00804036470f1", |
| 944 | "12010809710000004026f0"); |
| 945 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 946 | |
| 947 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 948 | expect_bssap_clear(); |
| 949 | gsup_rx("06010809710000004026f0", NULL); |
| 950 | |
| 951 | btw("LU was successful, and the conn has already been closed"); |
| 952 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 953 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 954 | |
| 955 | bss_sends_clear_complete(); |
| 956 | EXPECT_CONN_COUNT(0); |
| 957 | |
| 958 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 959 | OSMO_ASSERT(vsub); |
| 960 | vlr_subscr_put(vsub); |
| 961 | |
| 962 | /* Let T3212 (periodic Location update timer) expire */ |
| 963 | fake_time_passes((net->t3212 * 60 * 6 * 2) + 60*4, 0); |
| 964 | |
| 965 | /* The subscriber should now be gone. */ |
| 966 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 967 | OSMO_ASSERT(vsub == NULL); |
| 968 | |
| 969 | EXPECT_CONN_COUNT(0); |
| 970 | clear_vlr(); |
| 971 | comment_end(); |
| 972 | } |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 973 | |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 974 | msc_vlr_test_func_t msc_vlr_tests[] = { |
| 975 | test_no_authen, |
| 976 | test_no_authen_tmsi, |
| 977 | test_no_authen_imei, |
| 978 | test_no_authen_tmsi_imei, |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 979 | test_no_authen_imeisv, |
| 980 | test_no_authen_imeisv_imei, |
| 981 | test_no_authen_imeisv_tmsi, |
| 982 | test_no_authen_imeisv_tmsi_imei, |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 983 | test_no_authen_subscr_expire, |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 984 | NULL |
| 985 | }; |