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