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_ms_timeout_lu_auth_resp() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 27 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 28 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 29 | |
| 30 | net->authentication_required = true; |
| 31 | |
| 32 | fake_time_start(); |
| 33 | |
| 34 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 35 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | 63b2464 | 2019-12-12 01:31:04 +0100 | [diff] [blame] | 36 | gsup_expect_tx("08010809710000004026f0" CN_DOMAIN VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 37 | ms_sends_msg("050802008168000130089910070000006402"); |
| 38 | OSMO_ASSERT(gsup_tx_confirmed); |
| 39 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 40 | |
| 41 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 42 | auth_request_sent = false; |
| 43 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 44 | auth_request_expect_autn = NULL; |
| 45 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 46 | gsup_rx("0a" |
| 47 | /* imsi */ |
| 48 | "0108" "09710000004026f0" |
| 49 | /* auth vectors... */ |
| 50 | /* TL TL rand */ |
| 51 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 52 | /* TL sres TL kc */ |
| 53 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 54 | HLR_TO_VLR,NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 55 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 56 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 57 | |
| 58 | BTW("MS fails to send an Authentication Response"); |
| 59 | |
| 60 | btw("At first, we're still waiting"); |
| 61 | fake_time_passes(0, 423); |
| 62 | EXPECT_CONN_COUNT(1); |
| 63 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 64 | fake_time_passes(1, 235); |
| 65 | EXPECT_CONN_COUNT(1); |
| 66 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 67 | fake_time_passes(1, 235); |
| 68 | EXPECT_CONN_COUNT(1); |
| 69 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 70 | fake_time_passes(1, 235); |
| 71 | EXPECT_CONN_COUNT(1); |
| 72 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 73 | fake_time_passes(1, 235); |
| 74 | EXPECT_CONN_COUNT(1); |
| 75 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 76 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 77 | fake_time_passes(1, 235); |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 78 | btw("RAN_CONN_TIMEOUT has passed, conn is gone."); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 79 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 80 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 81 | EXPECT_CONN_COUNT(0); |
| 82 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
| 83 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 84 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 85 | } |
| 86 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 87 | static void test_ms_timeout_cm_auth_resp() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 88 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 89 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 90 | |
| 91 | net->authentication_required = true; |
| 92 | |
| 93 | fake_time_start(); |
| 94 | |
| 95 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 96 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | 63b2464 | 2019-12-12 01:31:04 +0100 | [diff] [blame] | 97 | gsup_expect_tx("08010809710000004026f0" CN_DOMAIN VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 98 | ms_sends_msg("050802008168000130089910070000006402"); |
| 99 | OSMO_ASSERT(gsup_tx_confirmed); |
| 100 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 101 | |
| 102 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 103 | auth_request_sent = false; |
| 104 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 105 | auth_request_expect_autn = NULL; |
| 106 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 107 | gsup_rx("0a" |
| 108 | /* imsi */ |
| 109 | "0108" "09710000004026f0" |
| 110 | /* 5 auth vectors... */ |
| 111 | /* TL TL rand */ |
| 112 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 113 | /* TL sres TL kc */ |
| 114 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" |
| 115 | "0322" "2010" "12aca96fb4ffdea5c985cbafa9b6e18b" |
| 116 | "2104" "20bde240" "2208" "07fa7502e07e1c00" |
| 117 | "0322" "2010" "e7c03ba7cf0e2fde82b2dc4d63077d42" |
| 118 | "2104" "a29514ae" "2208" "e2b234f807886400" |
| 119 | "0322" "2010" "fa8f20b781b5881329d4fea26b1a3c51" |
| 120 | "2104" "5afc8d72" "2208" "2392f14f709ae000" |
| 121 | "0322" "2010" "0fd4cc8dbe8715d1f439e304edfd68dc" |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 122 | "2104" "bc8d1c5b" "2208" "da7cdd6bfe2d7000" HLR_TO_VLR, |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 123 | NULL); |
| 124 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 125 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 126 | |
| 127 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
Neels Hofmeyr | 63b2464 | 2019-12-12 01:31:04 +0100 | [diff] [blame] | 128 | gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 129 | ms_sends_msg("05542d8b2c3e"); |
| 130 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 131 | |
| 132 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 133 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 134 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 135 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 136 | |
| 137 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 138 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 139 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 140 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 141 | |
| 142 | btw("LU was successful, and the conn has already been closed"); |
| 143 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 144 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 145 | EXPECT_CONN_COUNT(0); |
| 146 | |
| 147 | BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector"); |
| 148 | auth_request_sent = false; |
| 149 | auth_request_expect_rand = "12aca96fb4ffdea5c985cbafa9b6e18b"; |
| 150 | cm_service_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 151 | ms_sends_msg("05247403305886089910070000006402"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 152 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 153 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 154 | |
| 155 | BTW("MS fails to send an Authentication Response"); |
| 156 | |
| 157 | btw("At first, we're still waiting"); |
| 158 | fake_time_passes(0, 423); |
| 159 | EXPECT_CONN_COUNT(1); |
| 160 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 161 | fake_time_passes(1, 235); |
| 162 | EXPECT_CONN_COUNT(1); |
| 163 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 164 | fake_time_passes(1, 235); |
| 165 | EXPECT_CONN_COUNT(1); |
| 166 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 167 | fake_time_passes(1, 235); |
| 168 | EXPECT_CONN_COUNT(1); |
| 169 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
| 170 | fake_time_passes(1, 235); |
| 171 | EXPECT_CONN_COUNT(1); |
| 172 | VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 173 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 174 | fake_time_passes(1, 235); |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 175 | btw("RAN_CONN_TIMEOUT has passed, conn is gone."); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 176 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 177 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 178 | EXPECT_CONN_COUNT(0); |
| 179 | VERBOSE_ASSERT(cm_service_result_sent, == RES_REJECT, "%d"); |
| 180 | |
| 181 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 182 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 183 | } |
| 184 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 185 | static void test_ms_timeout_paging() |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 186 | { |
| 187 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 188 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 189 | |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 190 | rx_from_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 191 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 192 | comment_start(); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 193 | |
| 194 | fake_time_start(); |
| 195 | |
| 196 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 197 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | 63b2464 | 2019-12-12 01:31:04 +0100 | [diff] [blame] | 198 | gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 199 | ms_sends_msg("050802008168000130089910070000006402"); |
| 200 | OSMO_ASSERT(gsup_tx_confirmed); |
| 201 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 202 | |
| 203 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 204 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 205 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 206 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 207 | |
| 208 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 209 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 210 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 211 | |
| 212 | btw("LU was successful, and the conn has already been closed"); |
| 213 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 214 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 215 | ran_sends_clear_complete(); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 216 | EXPECT_CONN_COUNT(0); |
| 217 | |
| 218 | BTW("an SMS is sent, MS is paged"); |
| 219 | paging_expect_imsi(imsi); |
| 220 | paging_sent = false; |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 221 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 222 | OSMO_ASSERT(vsub); |
| 223 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d"); |
| 224 | |
| 225 | send_sms(vsub, vsub, |
| 226 | "Privacy in residential applications is a desirable" |
| 227 | " marketing option."); |
| 228 | |
| 229 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 230 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 231 | vsub = NULL; |
| 232 | VERBOSE_ASSERT(paging_sent, == true, "%d"); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 233 | |
| 234 | btw("time passes and no paging result is received"); |
| 235 | |
| 236 | fake_time_passes(MSC_PAGING_RESPONSE_TIMER_DEFAULT - 1, 0); |
| 237 | |
| 238 | btw("the paging timeout has not yet expired"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 239 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 240 | OSMO_ASSERT(vsub); |
| 241 | VERBOSE_ASSERT(vsub->cs.is_paging, == true, "%d"); |
| 242 | btw("another request is added to the list but does not cause another paging"); |
| 243 | paging_sent = false; |
| 244 | paging_expect_imsi(NULL); |
| 245 | send_sms(vsub, vsub, |
| 246 | "One paging ought to be enough for anyone."); |
| 247 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 2, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 248 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 249 | vsub = NULL; |
| 250 | VERBOSE_ASSERT(paging_sent, == false, "%d"); |
| 251 | |
| 252 | btw("the paging timeout expires, the paging as well as the requests are canceled"); |
| 253 | fake_time_passes(2, 0); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 254 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 255 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 256 | OSMO_ASSERT(vsub); |
| 257 | VERBOSE_ASSERT(vsub->cs.is_paging, == false, "%d"); |
| 258 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d"); |
Neels Hofmeyr | facd57a | 2017-12-15 03:48:48 +0100 | [diff] [blame] | 259 | |
| 260 | BTW("Now that the timeout has expired, another Paging is sent on request"); |
| 261 | paging_expect_imsi(imsi); |
| 262 | paging_sent = false; |
| 263 | |
| 264 | send_sms(vsub, vsub, |
| 265 | "Privacy in residential applications is a desirable" |
| 266 | " marketing option."); |
| 267 | |
| 268 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 269 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 270 | vsub = NULL; |
Neels Hofmeyr | facd57a | 2017-12-15 03:48:48 +0100 | [diff] [blame] | 271 | VERBOSE_ASSERT(paging_sent, == true, "%d"); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 272 | |
Neels Hofmeyr | facd57a | 2017-12-15 03:48:48 +0100 | [diff] [blame] | 273 | BTW("subscriber detaches, pagings are canceled"); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 274 | expect_bssap_clear(); |
| 275 | ms_sends_msg("050130089910070000006402"); |
| 276 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 277 | |
| 278 | ran_sends_clear_complete(); |
| 279 | EXPECT_CONN_COUNT(0); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 280 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 281 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 282 | OSMO_ASSERT(!vsub); |
| 283 | |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 284 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 285 | comment_end(); |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 286 | } |
| 287 | |
Neels Hofmeyr | 3117b70 | 2018-09-13 03:23:07 +0200 | [diff] [blame] | 288 | static void test_classmark_update_timeout() |
| 289 | { |
| 290 | comment_start(); |
| 291 | |
| 292 | fake_time_start(); |
| 293 | |
| 294 | /* implicit: net->authentication_required = true; */ |
| 295 | net->a5_encryption_mask = (1 << 3); /* A5/3 */ |
| 296 | |
| 297 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 298 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | 63b2464 | 2019-12-12 01:31:04 +0100 | [diff] [blame] | 299 | gsup_expect_tx("08010809710000004026f0" CN_DOMAIN VLR_TO_HLR); |
Neels Hofmeyr | 3117b70 | 2018-09-13 03:23:07 +0200 | [diff] [blame] | 300 | ms_sends_msg("050802008168000130089910070000006402"); |
| 301 | OSMO_ASSERT(gsup_tx_confirmed); |
| 302 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 303 | |
| 304 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 305 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 306 | auth_request_sent = false; |
| 307 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 308 | auth_request_expect_autn = NULL; |
| 309 | gsup_rx("0a" |
| 310 | /* imsi */ |
| 311 | "0108" "09710000004026f0" |
| 312 | /* TL TL rand */ |
| 313 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 314 | /* TL sres TL kc */ |
| 315 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 316 | HLR_TO_VLR, |
Neels Hofmeyr | 3117b70 | 2018-09-13 03:23:07 +0200 | [diff] [blame] | 317 | NULL); |
| 318 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 319 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 320 | |
| 321 | BTW("MS sends Authen Response, VLR accepts and wants to send Ciphering Mode Command to MS" |
| 322 | " -- but needs Classmark 2 to determine whether A5/3 is supported"); |
| 323 | cipher_mode_cmd_sent = false; |
| 324 | ms_sends_msg("05542d8b2c3e"); |
| 325 | OSMO_ASSERT(!cipher_mode_cmd_sent); |
| 326 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 327 | |
| 328 | BTW("But the BSSMAP Classmark Update never arrives"); |
| 329 | btw("At first, we're still waiting"); |
| 330 | fake_time_passes(0, 423); |
| 331 | EXPECT_CONN_COUNT(1); |
| 332 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 333 | fake_time_passes(1, 235); |
| 334 | EXPECT_CONN_COUNT(1); |
| 335 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 336 | fake_time_passes(1, 235); |
| 337 | EXPECT_CONN_COUNT(1); |
| 338 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 339 | fake_time_passes(1, 235); |
| 340 | EXPECT_CONN_COUNT(1); |
| 341 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 342 | fake_time_passes(1, 235); |
| 343 | EXPECT_CONN_COUNT(1); |
| 344 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 345 | expect_bssap_clear(); |
| 346 | fake_time_passes(1, 235); |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 347 | btw("RAN_CONN_TIMEOUT has passed, conn is gone."); |
Neels Hofmeyr | 3117b70 | 2018-09-13 03:23:07 +0200 | [diff] [blame] | 348 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 349 | ran_sends_clear_complete(); |
Neels Hofmeyr | 3117b70 | 2018-09-13 03:23:07 +0200 | [diff] [blame] | 350 | EXPECT_CONN_COUNT(0); |
| 351 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
| 352 | |
| 353 | comment_end(); |
| 354 | } |
| 355 | |
| 356 | |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 357 | msc_vlr_test_func_t msc_vlr_tests[] = { |
| 358 | test_ms_timeout_lu_auth_resp, |
| 359 | test_ms_timeout_cm_auth_resp, |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 360 | test_ms_timeout_paging, |
Neels Hofmeyr | 3117b70 | 2018-09-13 03:23:07 +0200 | [diff] [blame] | 361 | test_classmark_update_timeout, |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 362 | NULL |
| 363 | }; |