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" |
Vadim Yanitskiy | 98f0675 | 2019-06-03 15:39:13 +0700 | [diff] [blame] | 25 | |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 26 | #include <osmocom/msc/vlr.h> |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 27 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 28 | #if 0 |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 29 | static void test_early_stage() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 30 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 31 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 32 | |
| 33 | btw("NULL conn"); |
| 34 | EXPECT_ACCEPTED(false); |
| 35 | |
| 36 | btw("freshly allocated conn"); |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 37 | g_conn = ran_conn_alloc(net, OSMO_RAT_GERAN_A, 123); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 38 | EXPECT_ACCEPTED(false); |
| 39 | |
| 40 | btw("conn_fsm present, in state NEW"); |
Neels Hofmeyr | 4d3a66b | 2018-03-31 18:45:59 +0200 | [diff] [blame] | 41 | OSMO_ASSERT(g_conn->fi); |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 42 | OSMO_ASSERT(g_conn->fi->state == RAN_CONN_S_NEW); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 43 | EXPECT_ACCEPTED(false); |
| 44 | |
| 45 | thwart_rx_non_initial_requests(); |
| 46 | |
| 47 | btw("fake: acceptance"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 48 | g_conn->vsub = vlr_subscr_find_or_create_by_imsi(net->vlr, "135111", VSUB_USE_CONN, NULL); |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 49 | g_conn->via_ran = OSMO_RAT_GERAN_A; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 50 | OSMO_ASSERT(g_conn->vsub); |
| 51 | /* mark as silent call so it sticks around */ |
| 52 | g_conn->silent_call = 1; |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 53 | osmo_fsm_inst_state_chg(g_conn->fi, RAN_CONN_S_ACCEPTED, 0, 0); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 54 | EXPECT_CONN_COUNT(1); |
| 55 | EXPECT_ACCEPTED(true); |
| 56 | |
| 57 | btw("CLOSE event marks conn_fsm as released and frees the conn"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 58 | expect_bssap_clear(); |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 59 | osmo_fsm_inst_dispatch(g_conn->fi, RAN_CONN_E_CN_CLOSE, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 60 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 61 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 62 | EXPECT_CONN_COUNT(0); |
| 63 | |
| 64 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 65 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 66 | } |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 67 | #endif |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 68 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 69 | static void test_cm_service_without_lu() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 70 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 71 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 72 | |
| 73 | btw("CM Service Request without a prior Location Updating"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 74 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 75 | ms_sends_msg("05247403305886089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 76 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 77 | |
| 78 | btw("conn was released"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 79 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 80 | EXPECT_CONN_COUNT(0); |
| 81 | |
| 82 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 83 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 84 | } |
| 85 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 86 | static void test_two_lu() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 87 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 88 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 89 | |
| 90 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 91 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | 63b2464 | 2019-12-12 01:31:04 +0100 | [diff] [blame] | 92 | gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 93 | ms_sends_msg("050802008168000130089910070000006402"); |
| 94 | OSMO_ASSERT(gsup_tx_confirmed); |
| 95 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 96 | |
| 97 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 98 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 99 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 100 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 101 | |
| 102 | btw("having received subscriber data does not mean acceptance"); |
| 103 | EXPECT_ACCEPTED(false); |
| 104 | |
| 105 | thwart_rx_non_initial_requests(); |
| 106 | |
| 107 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 108 | |
| 109 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 110 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 111 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 112 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 113 | |
| 114 | btw("LU was successful, and the conn has already been closed"); |
| 115 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 116 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 117 | EXPECT_CONN_COUNT(0); |
| 118 | |
| 119 | |
| 120 | BTW("verify that the MS can send another LU request"); |
| 121 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 122 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | 63b2464 | 2019-12-12 01:31:04 +0100 | [diff] [blame] | 123 | gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 124 | ms_sends_msg("050802008168000130089910070000006402"); |
| 125 | OSMO_ASSERT(gsup_tx_confirmed); |
| 126 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 127 | |
| 128 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 129 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 130 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 131 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 132 | |
| 133 | btw("having received subscriber data does not mean acceptance"); |
| 134 | EXPECT_ACCEPTED(false); |
| 135 | |
| 136 | thwart_rx_non_initial_requests(); |
| 137 | |
| 138 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 139 | |
| 140 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 141 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 142 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 143 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 144 | |
| 145 | btw("LU was successful, and the conn has already been closed"); |
| 146 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 147 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 148 | EXPECT_CONN_COUNT(0); |
| 149 | |
| 150 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 151 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 152 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 153 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 154 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 155 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 156 | EXPECT_CONN_COUNT(0); |
| 157 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 158 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 159 | } |
| 160 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 161 | static void test_lu_unknown_tmsi() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 162 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 163 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 164 | |
| 165 | btw("Location Update request with unknown TMSI sends ID Request for IMSI"); |
| 166 | lu_result_sent = RES_NONE; |
| 167 | dtap_expect_tx("051801"); |
| 168 | ms_sends_msg("050802008168000130" "05f4" "23422342"); |
| 169 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 170 | |
| 171 | EXPECT_ACCEPTED(false); |
| 172 | thwart_rx_non_initial_requests(); |
| 173 | |
| 174 | btw("MS tells us the IMSI, causes a GSUP LU request to HLR"); |
Neels Hofmeyr | 63b2464 | 2019-12-12 01:31:04 +0100 | [diff] [blame] | 175 | gsup_expect_tx("04010809710000004026f0" CN_DOMAIN VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 176 | ms_sends_msg("0559089910070000006402"); |
| 177 | OSMO_ASSERT(gsup_tx_confirmed); |
| 178 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 179 | |
| 180 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 181 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 182 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 183 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 184 | |
| 185 | btw("having received subscriber data does not mean acceptance"); |
| 186 | EXPECT_ACCEPTED(false); |
| 187 | thwart_rx_non_initial_requests(); |
| 188 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 189 | |
| 190 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 191 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 192 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 193 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 194 | |
| 195 | btw("LU was successful, and the conn has already been closed"); |
| 196 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 197 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 198 | EXPECT_CONN_COUNT(0); |
| 199 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 200 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | msc_vlr_test_func_t msc_vlr_tests[] = { |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 204 | //test_early_stage, |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 205 | test_cm_service_without_lu, |
| 206 | test_two_lu, |
| 207 | test_lu_unknown_tmsi, |
| 208 | NULL |
| 209 | }; |