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 */ |
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 | 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 */ |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 76 | expect_bssap_clear(OSMO_RAT_GERAN_A); |
| 77 | conn_conclude_cm_service_req(g_conn, OSMO_RAT_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 | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 172 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 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 */ |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 239 | expect_bssap_clear(OSMO_RAT_GERAN_A); |
| 240 | conn_conclude_cm_service_req(g_conn, OSMO_RAT_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 | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 395 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 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 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame^] | 431 | btw("MS replies with an Identity Response, VLR sends the IMEI to HLR"); |
| 432 | gsup_expect_tx("30010809710000004026f050090824433224433224f0"); |
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"); |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame^] | 436 | |
| 437 | btw("HLR accepts the IMEI"); |
| 438 | expect_bssap_clear(); |
| 439 | gsup_rx("32010809710000004026f0510100", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 440 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 441 | |
| 442 | btw("LU was successful, and the conn has already been closed"); |
| 443 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 444 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 445 | EXPECT_CONN_COUNT(0); |
| 446 | |
| 447 | btw("Subscriber has the IMEI"); |
| 448 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 449 | OSMO_ASSERT(vsub); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 450 | VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 451 | vlr_subscr_put(vsub); |
| 452 | |
| 453 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 454 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 455 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 456 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 457 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 458 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 459 | EXPECT_CONN_COUNT(0); |
| 460 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 461 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 462 | } |
| 463 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 464 | static void test_no_authen_tmsi_imei() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 465 | { |
| 466 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 467 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 468 | |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 469 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 470 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 471 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 472 | |
| 473 | net->vlr->cfg.assign_tmsi = true; |
| 474 | net->vlr->cfg.check_imei_rqd = true; |
| 475 | |
| 476 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 477 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 478 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 479 | ms_sends_msg("050802008168000130089910070000006402"); |
| 480 | OSMO_ASSERT(gsup_tx_confirmed); |
| 481 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 482 | |
| 483 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 484 | gsup_rx("10010809710000004026f00804036470f1", |
| 485 | "12010809710000004026f0"); |
| 486 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 487 | |
| 488 | btw("having received subscriber data does not mean acceptance"); |
| 489 | EXPECT_ACCEPTED(false); |
| 490 | thwart_rx_non_initial_requests(); |
| 491 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 492 | |
| 493 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS"); |
| 494 | dtap_expect_tx("051802"); |
| 495 | gsup_rx("06010809710000004026f0", NULL); |
| 496 | |
| 497 | btw("We will only do business when the IMEI is known"); |
| 498 | EXPECT_CONN_COUNT(1); |
| 499 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 500 | OSMO_ASSERT(vsub); |
| 501 | VERBOSE_ASSERT(vsub->imei[0], == 0, "%d"); |
| 502 | vlr_subscr_put(vsub); |
| 503 | EXPECT_ACCEPTED(false); |
| 504 | thwart_rx_non_initial_requests(); |
| 505 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame^] | 506 | btw("MS replies with an Identity Response, VLR sends the IMEI to HLR"); |
| 507 | gsup_expect_tx("30010809710000004026f050090824433224433224f0"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 508 | ms_sends_msg("0559084a32244332244302"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 509 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame^] | 510 | btw("HLR accepts the IMEI"); |
| 511 | gsup_rx("32010809710000004026f0510100", NULL); |
| 512 | |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 513 | btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl"); |
| 514 | EXPECT_CONN_COUNT(1); |
| 515 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 516 | EXPECT_ACCEPTED(false); |
| 517 | thwart_rx_non_initial_requests(); |
| 518 | |
| 519 | btw("MS sends TMSI Realloc Complete"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 520 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 521 | ms_sends_msg("055b"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 522 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 523 | |
| 524 | btw("LU was successful, and the conn has already been closed"); |
| 525 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 526 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 527 | EXPECT_CONN_COUNT(0); |
| 528 | |
| 529 | btw("Subscriber has the IMEI and TMSI"); |
| 530 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 531 | OSMO_ASSERT(vsub); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 532 | VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 533 | VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x"); |
| 534 | vlr_subscr_put(vsub); |
| 535 | |
| 536 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 537 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 538 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 539 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 540 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 541 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 542 | EXPECT_CONN_COUNT(0); |
| 543 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 544 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 545 | } |
| 546 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 547 | static void test_no_authen_imeisv() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 548 | { |
| 549 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 550 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 551 | |
| 552 | /* No auth only works on GERAN */ |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 553 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 554 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 555 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 556 | |
| 557 | net->vlr->cfg.retrieve_imeisv_early = true; |
| 558 | |
| 559 | btw("Location Update request causes an IMEISV ID request back to the MS"); |
| 560 | lu_result_sent = RES_NONE; |
| 561 | dtap_expect_tx("051803"); |
| 562 | ms_sends_msg("050802008168000130089910070000006402"); |
| 563 | OSMO_ASSERT(dtap_tx_confirmed); |
| 564 | |
| 565 | 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] | 566 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 567 | ms_sends_msg("0559094332244332244372f5"); |
| 568 | OSMO_ASSERT(gsup_tx_confirmed); |
| 569 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 570 | |
| 571 | btw("Subscriber has the IMEISV from the ID Response"); |
| 572 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 573 | OSMO_ASSERT(vsub); |
| 574 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
| 575 | vlr_subscr_put(vsub); |
| 576 | |
| 577 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 578 | gsup_rx("10010809710000004026f00804036470f1", |
| 579 | "12010809710000004026f0"); |
| 580 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 581 | |
| 582 | btw("having received subscriber data does not mean acceptance"); |
| 583 | EXPECT_ACCEPTED(false); |
| 584 | |
| 585 | thwart_rx_non_initial_requests(); |
| 586 | |
| 587 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 588 | |
| 589 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 590 | expect_bssap_clear(); |
| 591 | gsup_rx("06010809710000004026f0", NULL); |
| 592 | |
| 593 | btw("LU was successful, and the conn has already been closed"); |
| 594 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 595 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
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 | |
| 599 | BTW("subscriber detaches"); |
| 600 | expect_bssap_clear(); |
| 601 | ms_sends_msg("050130089910070000006402"); |
| 602 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 603 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 604 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 605 | EXPECT_CONN_COUNT(0); |
| 606 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 607 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 608 | } |
| 609 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 610 | static void test_no_authen_imeisv_imei() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 611 | { |
| 612 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 613 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 614 | |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 615 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 616 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 617 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 618 | |
| 619 | net->vlr->cfg.retrieve_imeisv_early = true; |
| 620 | net->vlr->cfg.check_imei_rqd = true; |
| 621 | |
| 622 | btw("Location Update request causes an IMEISV ID request back to the MS"); |
| 623 | lu_result_sent = RES_NONE; |
| 624 | dtap_expect_tx("051803"); |
| 625 | ms_sends_msg("050802008168000130089910070000006402"); |
| 626 | OSMO_ASSERT(dtap_tx_confirmed); |
| 627 | |
| 628 | 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] | 629 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 630 | ms_sends_msg("0559094332244332244372f5"); |
| 631 | OSMO_ASSERT(gsup_tx_confirmed); |
| 632 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 633 | |
| 634 | btw("Subscriber has the IMEISV from the ID Response"); |
| 635 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 636 | OSMO_ASSERT(vsub); |
| 637 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
| 638 | vlr_subscr_put(vsub); |
| 639 | |
| 640 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 641 | gsup_rx("10010809710000004026f00804036470f1", |
| 642 | "12010809710000004026f0"); |
| 643 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 644 | |
| 645 | btw("having received subscriber data does not mean acceptance"); |
| 646 | EXPECT_ACCEPTED(false); |
| 647 | thwart_rx_non_initial_requests(); |
| 648 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 649 | |
| 650 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS"); |
| 651 | dtap_expect_tx("051802"); |
| 652 | gsup_rx("06010809710000004026f0", NULL); |
| 653 | |
| 654 | btw("We will only do business when the IMEI is known"); |
| 655 | EXPECT_CONN_COUNT(1); |
| 656 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 657 | OSMO_ASSERT(vsub); |
| 658 | VERBOSE_ASSERT(vsub->imei[0], == 0, "%d"); |
| 659 | vlr_subscr_put(vsub); |
| 660 | EXPECT_ACCEPTED(false); |
| 661 | thwart_rx_non_initial_requests(); |
| 662 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame^] | 663 | btw("MS replies with an Identity Response, VLR sends the IMEI to HLR"); |
| 664 | gsup_expect_tx("30010809710000004026f050090824433224433224f0"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 665 | ms_sends_msg("0559084a32244332244302"); |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame^] | 666 | |
| 667 | btw("HLR accepts the IMEI"); |
| 668 | expect_bssap_clear(); |
| 669 | gsup_rx("32010809710000004026f0510100", NULL); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 670 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 671 | |
| 672 | btw("LU was successful, and the conn has already been closed"); |
| 673 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 674 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 675 | EXPECT_CONN_COUNT(0); |
| 676 | |
| 677 | btw("Subscriber has the IMEI"); |
| 678 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 679 | OSMO_ASSERT(vsub); |
| 680 | VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d"); |
| 681 | vlr_subscr_put(vsub); |
| 682 | |
| 683 | BTW("subscriber detaches"); |
| 684 | expect_bssap_clear(); |
| 685 | ms_sends_msg("050130089910070000006402"); |
| 686 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 687 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 688 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 689 | EXPECT_CONN_COUNT(0); |
| 690 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 691 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 692 | } |
| 693 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 694 | static void test_no_authen_imeisv_tmsi() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 695 | { |
| 696 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 697 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 698 | |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 699 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 700 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 701 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 702 | |
| 703 | net->vlr->cfg.retrieve_imeisv_early = true; |
| 704 | net->vlr->cfg.assign_tmsi = true; |
| 705 | |
| 706 | btw("Location Update request causes an IMEISV ID request back to the MS"); |
| 707 | lu_result_sent = RES_NONE; |
| 708 | dtap_expect_tx("051803"); |
| 709 | ms_sends_msg("050802008168000130089910070000006402"); |
| 710 | OSMO_ASSERT(dtap_tx_confirmed); |
| 711 | |
| 712 | 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] | 713 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 714 | ms_sends_msg("0559094332244332244372f5"); |
| 715 | OSMO_ASSERT(gsup_tx_confirmed); |
| 716 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 717 | |
| 718 | btw("Subscriber has the IMEISV from the ID Response"); |
| 719 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 720 | OSMO_ASSERT(vsub); |
| 721 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
| 722 | vlr_subscr_put(vsub); |
| 723 | |
| 724 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 725 | gsup_rx("10010809710000004026f00804036470f1", |
| 726 | "12010809710000004026f0"); |
| 727 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 728 | |
| 729 | btw("having received subscriber data does not mean acceptance"); |
| 730 | EXPECT_ACCEPTED(false); |
| 731 | thwart_rx_non_initial_requests(); |
| 732 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 733 | |
| 734 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 735 | gsup_rx("06010809710000004026f0", NULL); |
| 736 | |
| 737 | btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl"); |
| 738 | EXPECT_CONN_COUNT(1); |
| 739 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 740 | EXPECT_ACCEPTED(false); |
| 741 | thwart_rx_non_initial_requests(); |
| 742 | |
| 743 | btw("even though the TMSI is not acked, we can already find the subscr with it"); |
| 744 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100); |
| 745 | VERBOSE_ASSERT(vsub != NULL, == true, "%d"); |
| 746 | VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d"); |
| 747 | VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x"); |
| 748 | VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x"); |
| 749 | vlr_subscr_put(vsub); |
| 750 | |
| 751 | btw("MS sends TMSI Realloc Complete"); |
| 752 | expect_bssap_clear(); |
| 753 | ms_sends_msg("055b"); |
| 754 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 755 | |
| 756 | btw("LU was successful, and the conn has already been closed"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 757 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 758 | EXPECT_CONN_COUNT(0); |
| 759 | |
| 760 | |
| 761 | BTW("subscriber sends LU Request, this time with the TMSI"); |
| 762 | btw("Location Update request causes an IMEISV ID request back to the MS"); |
| 763 | lu_result_sent = RES_NONE; |
| 764 | dtap_expect_tx("051803"); |
| 765 | ms_sends_msg("050802008168000130089910070000006402"); |
| 766 | OSMO_ASSERT(dtap_tx_confirmed); |
| 767 | |
| 768 | 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] | 769 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 770 | ms_sends_msg("0559095332244332244372f6"); |
| 771 | OSMO_ASSERT(gsup_tx_confirmed); |
| 772 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 773 | |
| 774 | btw("Subscriber has the IMEISV from the ID Response"); |
| 775 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 776 | OSMO_ASSERT(vsub); |
| 777 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "5234234234234276"), == 0, "%d"); |
| 778 | vlr_subscr_put(vsub); |
| 779 | |
| 780 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 781 | gsup_rx("10010809710000004026f00804036470f1", |
| 782 | "12010809710000004026f0"); |
| 783 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 784 | |
| 785 | btw("having received subscriber data does not mean acceptance"); |
| 786 | EXPECT_ACCEPTED(false); |
| 787 | thwart_rx_non_initial_requests(); |
| 788 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 789 | |
| 790 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 791 | gsup_rx("06010809710000004026f0", NULL); |
| 792 | |
| 793 | btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl"); |
| 794 | EXPECT_CONN_COUNT(1); |
| 795 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 796 | EXPECT_ACCEPTED(false); |
| 797 | thwart_rx_non_initial_requests(); |
| 798 | |
| 799 | btw("even though the TMSI is not acked, we can already find the subscr with it"); |
| 800 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504); |
| 801 | VERBOSE_ASSERT(vsub != NULL, == true, "%d"); |
| 802 | VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d"); |
| 803 | VERBOSE_ASSERT(vsub->tmsi_new, == 0x07060504, "0x%08x"); |
| 804 | VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x"); |
| 805 | vlr_subscr_put(vsub); |
| 806 | |
| 807 | btw("MS sends TMSI Realloc Complete"); |
| 808 | expect_bssap_clear(); |
| 809 | ms_sends_msg("055b"); |
| 810 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 811 | |
| 812 | btw("LU was successful, and the conn has already been closed"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 813 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 814 | EXPECT_CONN_COUNT(0); |
| 815 | |
| 816 | btw("subscriber has the new TMSI"); |
| 817 | vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x07060504); |
| 818 | VERBOSE_ASSERT(vsub != NULL, == true, "%d"); |
| 819 | VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d"); |
| 820 | VERBOSE_ASSERT(vsub->tmsi_new, == GSM_RESERVED_TMSI, "0x%08x"); |
| 821 | VERBOSE_ASSERT(vsub->tmsi, == 0x07060504, "0x%08x"); |
| 822 | vlr_subscr_put(vsub); |
| 823 | |
| 824 | BTW("subscriber detaches, using new TMSI"); |
| 825 | expect_bssap_clear(); |
| 826 | ms_sends_msg("050130" "05f4" "07060504"); |
| 827 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 828 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 829 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 830 | EXPECT_CONN_COUNT(0); |
| 831 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 832 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 833 | } |
| 834 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 835 | static void test_no_authen_imeisv_tmsi_imei() |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 836 | { |
| 837 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 838 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 839 | |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 840 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 841 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 842 | comment_start(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 843 | |
| 844 | net->vlr->cfg.retrieve_imeisv_early = true; |
| 845 | net->vlr->cfg.assign_tmsi = true; |
| 846 | net->vlr->cfg.check_imei_rqd = true; |
| 847 | |
| 848 | btw("Location Update request causes an IMEISV ID request back to the MS"); |
| 849 | lu_result_sent = RES_NONE; |
| 850 | dtap_expect_tx("051803"); |
| 851 | ms_sends_msg("050802008168000130089910070000006402"); |
| 852 | OSMO_ASSERT(dtap_tx_confirmed); |
| 853 | |
| 854 | 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] | 855 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 856 | ms_sends_msg("0559094332244332244372f5"); |
| 857 | OSMO_ASSERT(gsup_tx_confirmed); |
| 858 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 859 | |
| 860 | btw("Subscriber has the IMEISV from the ID Response"); |
| 861 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 862 | OSMO_ASSERT(vsub); |
| 863 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
| 864 | vlr_subscr_put(vsub); |
| 865 | |
| 866 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 867 | gsup_rx("10010809710000004026f00804036470f1", |
| 868 | "12010809710000004026f0"); |
| 869 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 870 | |
| 871 | btw("having received subscriber data does not mean acceptance"); |
| 872 | EXPECT_ACCEPTED(false); |
| 873 | thwart_rx_non_initial_requests(); |
| 874 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 875 | |
| 876 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT, and we send an ID Request for the IMEI to the MS"); |
| 877 | dtap_expect_tx("051802"); |
| 878 | gsup_rx("06010809710000004026f0", NULL); |
| 879 | |
| 880 | btw("We will only do business when the IMEI is known"); |
| 881 | EXPECT_CONN_COUNT(1); |
| 882 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 883 | OSMO_ASSERT(vsub); |
| 884 | VERBOSE_ASSERT(vsub->imei[0], == 0, "%d"); |
| 885 | vlr_subscr_put(vsub); |
| 886 | EXPECT_ACCEPTED(false); |
| 887 | thwart_rx_non_initial_requests(); |
| 888 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame^] | 889 | btw("MS replies with an Identity Response, VLR sends the IMEI to HLR"); |
| 890 | gsup_expect_tx("30010809710000004026f050090824433224433224f0"); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 891 | ms_sends_msg("0559084a32244332244302"); |
| 892 | |
Oliver Smith | 7d05309 | 2018-12-14 17:37:38 +0100 | [diff] [blame^] | 893 | btw("HLR accepts the IMEI"); |
| 894 | gsup_rx("32010809710000004026f0510100", NULL); |
| 895 | |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 896 | btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl"); |
| 897 | EXPECT_CONN_COUNT(1); |
| 898 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 899 | EXPECT_ACCEPTED(false); |
| 900 | thwart_rx_non_initial_requests(); |
| 901 | |
| 902 | btw("MS sends TMSI Realloc Complete"); |
| 903 | expect_bssap_clear(); |
| 904 | ms_sends_msg("055b"); |
| 905 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 906 | |
| 907 | btw("LU was successful, and the conn has already been closed"); |
| 908 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
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 | |
| 912 | btw("Subscriber has the IMEISV, IMEI and TMSI"); |
| 913 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 914 | OSMO_ASSERT(vsub); |
| 915 | VERBOSE_ASSERT(strcmp(vsub->imeisv, "4234234234234275"), == 0, "%d"); |
| 916 | VERBOSE_ASSERT(strcmp(vsub->imei, "423423423423420"), == 0, "%d"); |
| 917 | VERBOSE_ASSERT(vsub->tmsi, == 0x03020100, "0x%08x"); |
| 918 | vlr_subscr_put(vsub); |
| 919 | |
| 920 | BTW("subscriber detaches"); |
| 921 | expect_bssap_clear(); |
| 922 | ms_sends_msg("050130089910070000006402"); |
| 923 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 924 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 925 | bss_sends_clear_complete(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 926 | EXPECT_CONN_COUNT(0); |
| 927 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 928 | comment_end(); |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 929 | } |
| 930 | |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 931 | static void test_no_authen_subscr_expire() |
| 932 | { |
| 933 | struct vlr_subscr *vsub; |
| 934 | const char *imsi = "901700000004620"; |
| 935 | |
| 936 | /* No auth only works on GERAN */ |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 937 | rx_from_ran = OSMO_RAT_GERAN_A; |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 938 | |
| 939 | comment_start(); |
| 940 | |
| 941 | fake_time_start(); |
| 942 | |
| 943 | /* The test framework has already started the VLR before fake time was active. |
| 944 | * Manually schedule this timeout in fake time. */ |
| 945 | osmo_timer_del(&net->vlr->lu_expire_timer); |
| 946 | osmo_timer_schedule(&net->vlr->lu_expire_timer, VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL, 0); |
| 947 | |
| 948 | /* Let the LU expiration timer tick once */ |
| 949 | fake_time_passes(VLR_SUBSCRIBER_LU_EXPIRATION_INTERVAL + 1, 0); |
| 950 | |
| 951 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 952 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 953 | gsup_expect_tx("04010809710000004026f0280102"); |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 954 | ms_sends_msg("050802008168000130089910070000006402"); |
| 955 | OSMO_ASSERT(gsup_tx_confirmed); |
| 956 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 957 | |
| 958 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 959 | gsup_rx("10010809710000004026f00804036470f1", |
| 960 | "12010809710000004026f0"); |
| 961 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 962 | |
| 963 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 964 | expect_bssap_clear(); |
| 965 | gsup_rx("06010809710000004026f0", NULL); |
| 966 | |
| 967 | btw("LU was successful, and the conn has already been closed"); |
| 968 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 969 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
| 970 | |
| 971 | bss_sends_clear_complete(); |
| 972 | EXPECT_CONN_COUNT(0); |
| 973 | |
| 974 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 975 | OSMO_ASSERT(vsub); |
| 976 | vlr_subscr_put(vsub); |
| 977 | |
| 978 | /* Let T3212 (periodic Location update timer) expire */ |
| 979 | fake_time_passes((net->t3212 * 60 * 6 * 2) + 60*4, 0); |
| 980 | |
| 981 | /* The subscriber should now be gone. */ |
| 982 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 983 | OSMO_ASSERT(vsub == NULL); |
| 984 | |
| 985 | EXPECT_CONN_COUNT(0); |
| 986 | clear_vlr(); |
| 987 | comment_end(); |
| 988 | } |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 989 | |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 990 | msc_vlr_test_func_t msc_vlr_tests[] = { |
| 991 | test_no_authen, |
| 992 | test_no_authen_tmsi, |
| 993 | test_no_authen_imei, |
| 994 | test_no_authen_tmsi_imei, |
Neels Hofmeyr | 34d33bd | 2017-07-20 02:56:21 +0200 | [diff] [blame] | 995 | test_no_authen_imeisv, |
| 996 | test_no_authen_imeisv_imei, |
| 997 | test_no_authen_imeisv_tmsi, |
| 998 | test_no_authen_imeisv_tmsi_imei, |
Stefan Sperling | defc3c8 | 2018-05-15 14:48:04 +0200 | [diff] [blame] | 999 | test_no_authen_subscr_expire, |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 1000 | NULL |
| 1001 | }; |