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