blob: 620652c9577c168d3d302588d0ec4f10125693d6 [file] [log] [blame]
Neels Hofmeyr6a29d322017-01-25 15:04:16 +01001/* 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 Welte0df904d2018-12-03 11:00:04 +010025#include "stubs.h"
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +010026#include <osmocom/msc/vlr.h>
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010027
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010028#if 0
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010029static void test_early_stage()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010030{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010031 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010032
33 btw("NULL conn");
34 EXPECT_ACCEPTED(false);
35
36 btw("freshly allocated conn");
Neels Hofmeyr7814a832018-12-26 00:40:18 +010037 g_conn = ran_conn_alloc(net, OSMO_RAT_GERAN_A, 123);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010038 EXPECT_ACCEPTED(false);
39
40 btw("conn_fsm present, in state NEW");
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +020041 OSMO_ASSERT(g_conn->fi);
Neels Hofmeyrc036b792018-11-29 22:37:51 +010042 OSMO_ASSERT(g_conn->fi->state == RAN_CONN_S_NEW);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010043 EXPECT_ACCEPTED(false);
44
45 thwart_rx_non_initial_requests();
46
47 btw("fake: acceptance");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +010048 g_conn->vsub = vlr_subscr_find_or_create_by_imsi(net->vlr, "135111", VSUB_USE_CONN, NULL);
Neels Hofmeyr7814a832018-12-26 00:40:18 +010049 g_conn->via_ran = OSMO_RAT_GERAN_A;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010050 OSMO_ASSERT(g_conn->vsub);
51 /* mark as silent call so it sticks around */
52 g_conn->silent_call = 1;
Neels Hofmeyrc036b792018-11-29 22:37:51 +010053 osmo_fsm_inst_state_chg(g_conn->fi, RAN_CONN_S_ACCEPTED, 0, 0);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010054 EXPECT_CONN_COUNT(1);
55 EXPECT_ACCEPTED(true);
56
57 btw("CLOSE event marks conn_fsm as released and frees the conn");
Philipp Maierfbf66102017-04-09 12:32:51 +020058 expect_bssap_clear();
Neels Hofmeyrc036b792018-11-29 22:37:51 +010059 osmo_fsm_inst_dispatch(g_conn->fi, RAN_CONN_E_CN_CLOSE, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +020060 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010061 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010062 EXPECT_CONN_COUNT(0);
63
64 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010065 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010066}
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010067#endif
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010068
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010069static void test_cm_service_without_lu()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010070{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010071 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010072
73 btw("CM Service Request without a prior Location Updating");
Philipp Maierfbf66102017-04-09 12:32:51 +020074 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010075 ms_sends_msg("05247403305886089910070000006402");
Philipp Maierfbf66102017-04-09 12:32:51 +020076 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010077
78 btw("conn was released");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010079 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010080 EXPECT_CONN_COUNT(0);
81
82 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010083 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010084}
85
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010086static void test_two_lu()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010087{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010088 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010089
90 btw("Location Update request causes a GSUP LU request to HLR");
91 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010092 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010093 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 Hofmeyrc4628a32018-12-07 14:47:34 +010098 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
99 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100100 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 Maierfbf66102017-04-09 12:32:51 +0200110 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100111 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200112 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100113
114 btw("LU was successful, and the conn has already been closed");
115 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100116 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100117 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 Hofmeyrc4628a32018-12-07 14:47:34 +0100123 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100124 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 Hofmeyrc4628a32018-12-07 14:47:34 +0100129 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
130 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100131 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 Maierfbf66102017-04-09 12:32:51 +0200141 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100142 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200143 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100144
145 btw("LU was successful, and the conn has already been closed");
146 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100147 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100148 EXPECT_CONN_COUNT(0);
149
150 BTW("subscriber detaches");
Philipp Maierfbf66102017-04-09 12:32:51 +0200151 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100152 ms_sends_msg("050130089910070000006402");
Philipp Maierfbf66102017-04-09 12:32:51 +0200153 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100154
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100155 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100156 EXPECT_CONN_COUNT(0);
157 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100158 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100159}
160
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100161static void test_lu_unknown_tmsi()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100162{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100163 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100164
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 Hofmeyrc4628a32018-12-07 14:47:34 +0100175 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100176 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 Hofmeyrc4628a32018-12-07 14:47:34 +0100181 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
182 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100183 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 Maierfbf66102017-04-09 12:32:51 +0200191 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100192 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200193 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100194
195 btw("LU was successful, and the conn has already been closed");
196 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100197 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100198 EXPECT_CONN_COUNT(0);
199 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100200 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100201}
202
203msc_vlr_test_func_t msc_vlr_tests[] = {
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100204 //test_early_stage,
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100205 test_cm_service_without_lu,
206 test_two_lu,
207 test_lu_unknown_tmsi,
208 NULL
209};