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_hlr_rej_auth_info_unknown_imsi() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 28 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 29 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 30 | |
| 31 | net->authentication_required = true; |
| 32 | |
| 33 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 34 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 35 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 36 | ms_sends_msg("050802008168000130089910070000006402"); |
| 37 | OSMO_ASSERT(gsup_tx_confirmed); |
| 38 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 39 | |
| 40 | btw("HLR sends _SEND_AUTH_INFO_ERROR = unknown IMSI"); |
| 41 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 42 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 43 | gsup_rx("09" "010809710000004026f0" "020102" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 44 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 45 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 46 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 47 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 48 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 49 | EXPECT_CONN_COUNT(0); |
| 50 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 51 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 52 | } |
| 53 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 54 | static void test_hlr_rej_auth_info_net_fail() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 55 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 56 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 57 | |
| 58 | net->authentication_required = true; |
| 59 | |
| 60 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 61 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 62 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 63 | ms_sends_msg("050802008168000130089910070000006402"); |
| 64 | OSMO_ASSERT(gsup_tx_confirmed); |
| 65 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 66 | |
| 67 | btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail"); |
| 68 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 69 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 70 | gsup_rx("09" "010809710000004026f0" "020111" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 71 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 72 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 73 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 74 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 75 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 76 | EXPECT_CONN_COUNT(0); |
| 77 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 78 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 79 | } |
| 80 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 81 | static void test_hlr_rej_auth_info_net_fail_no_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 82 | { |
| 83 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 84 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 85 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 86 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 87 | |
| 88 | net->authentication_required = true; |
| 89 | net->vlr->cfg.auth_reuse_old_sets_on_error = false; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 90 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 91 | |
| 92 | BTW("Submit a used auth tuple in the VLR"); |
| 93 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 94 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 95 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 96 | ms_sends_msg("050802008168000130089910070000006402"); |
| 97 | OSMO_ASSERT(gsup_tx_confirmed); |
| 98 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 99 | |
| 100 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 101 | auth_request_sent = false; |
| 102 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 103 | auth_request_expect_autn = NULL; |
| 104 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 105 | gsup_rx("0a" |
| 106 | /* imsi */ |
| 107 | "0108" "09710000004026f0" |
| 108 | /* auth vectors... */ |
| 109 | /* TL TL rand */ |
| 110 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 111 | /* TL sres TL kc */ |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 112 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" HLR_TO_VLR, |
| 113 | NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 114 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 115 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 116 | |
| 117 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 118 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 119 | ms_sends_msg("05542d8b2c3e"); |
| 120 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 121 | |
| 122 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 123 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 124 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 125 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 126 | |
| 127 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 128 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 129 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 130 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 131 | |
| 132 | btw("LU was successful, and the conn has already been closed"); |
| 133 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 134 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 135 | EXPECT_CONN_COUNT(0); |
| 136 | |
| 137 | |
| 138 | BTW("Now one auth tuple is available, but used."); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 139 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 140 | OSMO_ASSERT(vsub); |
| 141 | OSMO_ASSERT(vsub->last_tuple); |
| 142 | VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d"); |
| 143 | /* no need to look at all auth tuples, the ongoing test would take an |
| 144 | * unexpected course if there were more. */ |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 145 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 146 | |
| 147 | BTW("Another LU wants to get new tuples; HLR sends Network Failure, we reject."); |
| 148 | |
| 149 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 150 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 151 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 152 | ms_sends_msg("050802008168000130089910070000006402"); |
| 153 | OSMO_ASSERT(gsup_tx_confirmed); |
| 154 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 155 | |
| 156 | btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail"); |
| 157 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 158 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 159 | gsup_rx("09" "010809710000004026f0" "020111" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 160 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 161 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 162 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 163 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 164 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 165 | EXPECT_CONN_COUNT(0); |
| 166 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 167 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 168 | } |
| 169 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 170 | static void test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 171 | { |
| 172 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 173 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [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->authentication_required = true; |
| 178 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 179 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 180 | |
| 181 | BTW("Submit a used auth tuple in the VLR"); |
| 182 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 183 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 184 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 185 | ms_sends_msg("050802008168000130089910070000006402"); |
| 186 | OSMO_ASSERT(gsup_tx_confirmed); |
| 187 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 188 | |
| 189 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 190 | auth_request_sent = false; |
| 191 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 192 | auth_request_expect_autn = NULL; |
| 193 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 194 | gsup_rx("0a" |
| 195 | /* imsi */ |
| 196 | "0108" "09710000004026f0" |
| 197 | /* auth vectors... */ |
| 198 | /* TL TL rand */ |
| 199 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 200 | /* TL sres TL kc */ |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 201 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" HLR_TO_VLR, |
| 202 | NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 203 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 204 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 205 | |
| 206 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 207 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 208 | ms_sends_msg("05542d8b2c3e"); |
| 209 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 210 | |
| 211 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 212 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 213 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 214 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 215 | |
| 216 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 217 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 218 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 219 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 220 | |
| 221 | btw("LU was successful, and the conn has already been closed"); |
| 222 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 223 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 224 | EXPECT_CONN_COUNT(0); |
| 225 | |
| 226 | |
| 227 | BTW("Now one auth tuple is available, but used."); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 228 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 229 | OSMO_ASSERT(vsub); |
| 230 | OSMO_ASSERT(vsub->last_tuple); |
| 231 | VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d"); |
| 232 | /* no need to look at all auth tuples, the ongoing test would take an |
| 233 | * unexpected course if there were more. */ |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 234 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 235 | |
| 236 | BTW("Another LU wants to get new tuples; HLR sends IMSI Unknown. Even though we would re-use an old tuple, reject the unknown IMSI."); |
| 237 | VERBOSE_ASSERT(net->vlr->cfg.auth_reuse_old_sets_on_error, == true, "%d"); |
| 238 | |
| 239 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 240 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 241 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 242 | ms_sends_msg("050802008168000130089910070000006402"); |
| 243 | OSMO_ASSERT(gsup_tx_confirmed); |
| 244 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 245 | |
| 246 | btw("HLR sends _SEND_AUTH_INFO_ERROR = unknown IMSI"); |
| 247 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 248 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 249 | gsup_rx("09" "010809710000004026f0" "020102" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 250 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 251 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 252 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 253 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 254 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 255 | EXPECT_CONN_COUNT(0); |
| 256 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 257 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 258 | } |
| 259 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 260 | static void test_hlr_acc_but_no_auth_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 261 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 262 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 263 | |
| 264 | net->authentication_required = true; |
| 265 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 266 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 267 | |
| 268 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 269 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 270 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 271 | ms_sends_msg("050802008168000130089910070000006402"); |
| 272 | OSMO_ASSERT(gsup_tx_confirmed); |
| 273 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 274 | |
| 275 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT but it lacks auth tuples"); |
| 276 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 277 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 278 | gsup_rx("0a" |
| 279 | /* imsi */ |
| 280 | "0108" "09710000004026f0" |
| 281 | /* NO auth vectors */ |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 282 | HLR_TO_VLR, |
| 283 | NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 284 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 285 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 286 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 287 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 288 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 289 | EXPECT_CONN_COUNT(0); |
| 290 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 291 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 292 | } |
| 293 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 294 | static void test_hlr_rej_auth_info_net_fail_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 295 | { |
| 296 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 297 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 298 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 299 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 300 | |
| 301 | net->authentication_required = true; |
| 302 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 303 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 304 | |
| 305 | BTW("Submit a used auth tuple in the VLR"); |
| 306 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 307 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 308 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 309 | ms_sends_msg("050802008168000130089910070000006402"); |
| 310 | OSMO_ASSERT(gsup_tx_confirmed); |
| 311 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 312 | |
| 313 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 314 | auth_request_sent = false; |
| 315 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 316 | auth_request_expect_autn = NULL; |
| 317 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 318 | gsup_rx("0a" |
| 319 | /* imsi */ |
| 320 | "0108" "09710000004026f0" |
| 321 | /* auth vectors... */ |
| 322 | /* TL TL rand */ |
| 323 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 324 | /* TL sres TL kc */ |
| 325 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 326 | HLR_TO_VLR, |
| 327 | NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 328 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 329 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 330 | |
| 331 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 332 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 333 | ms_sends_msg("05542d8b2c3e"); |
| 334 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 335 | |
| 336 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 337 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 338 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 339 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 340 | |
| 341 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 342 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 343 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 344 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 345 | |
| 346 | btw("LU was successful, and the conn has already been closed"); |
| 347 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 348 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 349 | EXPECT_CONN_COUNT(0); |
| 350 | |
| 351 | |
| 352 | BTW("Now one auth tuple is available, but used."); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 353 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 354 | OSMO_ASSERT(vsub); |
| 355 | OSMO_ASSERT(vsub->last_tuple); |
| 356 | VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d"); |
| 357 | /* no need to look at all auth tuples, the ongoing test would take an |
| 358 | * unexpected course if there were more. */ |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 359 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 360 | |
| 361 | BTW("Another LU wants to get new tuples; even though HLR sends Network Failure, we are reusing the old tuples."); |
| 362 | |
| 363 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 364 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 365 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 366 | ms_sends_msg("050802008168000130089910070000006402"); |
| 367 | OSMO_ASSERT(gsup_tx_confirmed); |
| 368 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 369 | |
| 370 | btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail"); |
| 371 | auth_request_sent = false; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 372 | gsup_rx("09" "010809710000004026f0" "020111" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 373 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 374 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 375 | |
| 376 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 377 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 378 | ms_sends_msg("05542d8b2c3e"); |
| 379 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 380 | |
| 381 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 382 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 383 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 384 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 385 | |
| 386 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 387 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 388 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 389 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 390 | |
| 391 | btw("LU was successful, and the conn has already been closed"); |
| 392 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 393 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 394 | EXPECT_CONN_COUNT(0); |
| 395 | |
| 396 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 397 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 398 | } |
| 399 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 400 | static void test_hlr_rej_lu() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 401 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 402 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 403 | |
| 404 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 405 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 406 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 407 | ms_sends_msg("050802008168000130089910070000006402"); |
| 408 | OSMO_ASSERT(gsup_tx_confirmed); |
| 409 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 410 | |
| 411 | btw("HLR sends UPDATE_LOCATION_ERROR"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 412 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 413 | gsup_rx("05" "010809710000004026f0" "020102" HLR_TO_VLR, |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 414 | NULL); |
| 415 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 416 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 417 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 418 | EXPECT_CONN_COUNT(0); |
| 419 | |
| 420 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 421 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 422 | } |
| 423 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 424 | static void test_hlr_no_insert_data() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 425 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 426 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 427 | |
| 428 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 429 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 430 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 431 | ms_sends_msg("050802008168000130089910070000006402"); |
| 432 | OSMO_ASSERT(gsup_tx_confirmed); |
| 433 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 434 | |
| 435 | btw("HLR sends only _UPDATE_LOCATION_RESULT, no INSERT DATA"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 436 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 437 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 438 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 439 | |
| 440 | /* TODO should we wait for OSMO_GSUP_MSGT_INSERT_DATA_REQUEST? */ |
| 441 | |
| 442 | btw("LU was successful, and the conn has already been closed"); |
| 443 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 444 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 445 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 446 | EXPECT_CONN_COUNT(0); |
| 447 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 448 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | msc_vlr_test_func_t msc_vlr_tests[] = { |
| 452 | test_hlr_rej_auth_info_unknown_imsi, |
| 453 | test_hlr_rej_auth_info_net_fail, |
| 454 | test_hlr_rej_auth_info_net_fail_reuse_tuples, |
| 455 | test_hlr_rej_auth_info_net_fail_no_reuse_tuples, |
| 456 | test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples, |
| 457 | test_hlr_acc_but_no_auth_tuples, |
| 458 | test_hlr_rej_lu, |
| 459 | test_hlr_no_insert_data, |
| 460 | NULL |
| 461 | }; |