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