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