blob: cb5e24f4222a8039edf7b59ef67f27e0e9ad3016 [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"
25
Maxb0a43142018-02-06 19:19:52 +010026void test_early_stage(uint8_t nr, const char *imsi)
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010027{
Maxb0a43142018-02-06 19:19:52 +010028 comment_start(nr, imsi);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010029
30 btw("NULL conn");
31 EXPECT_ACCEPTED(false);
32
33 btw("freshly allocated conn");
34 g_conn = msc_subscr_con_allocate(net);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010035 EXPECT_ACCEPTED(false);
36
37 btw("conn_fsm present, in state NEW");
38 OSMO_ASSERT(msc_create_conn_fsm(g_conn, "test") == 0);
39 OSMO_ASSERT(g_conn->conn_fsm);
40 OSMO_ASSERT(g_conn->conn_fsm->state == SUBSCR_CONN_S_NEW);
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 Maierfbf66102017-04-09 12:32:51 +020047 g_conn->via_ran = RAN_GERAN_A;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010048 OSMO_ASSERT(g_conn->vsub);
49 /* mark as silent call so it sticks around */
50 g_conn->silent_call = 1;
51 osmo_fsm_inst_state_chg(g_conn->conn_fsm, SUBSCR_CONN_S_ACCEPTED, 0, 0);
52 EXPECT_CONN_COUNT(1);
53 EXPECT_ACCEPTED(true);
54
55 btw("CLOSE event marks conn_fsm as released and frees the conn");
Philipp Maierfbf66102017-04-09 12:32:51 +020056 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010057 osmo_fsm_inst_dispatch(g_conn->conn_fsm, SUBSCR_CONN_E_CN_CLOSE, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +020058 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010059 EXPECT_CONN_COUNT(0);
60
61 clear_vlr();
Maxb0a43142018-02-06 19:19:52 +010062 comment_end(nr, imsi);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010063}
64
Maxb0a43142018-02-06 19:19:52 +010065void test_cm_service_without_lu(uint8_t nr, const char *imsi)
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010066{
Maxb0a43142018-02-06 19:19:52 +010067 comment_start(nr, imsi);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010068
69 btw("CM Service Request without a prior Location Updating");
Philipp Maierfbf66102017-04-09 12:32:51 +020070 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010071 ms_sends_msg("05247803305886089910070000006402");
Philipp Maierfbf66102017-04-09 12:32:51 +020072 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010073
74 btw("conn was released");
75 EXPECT_CONN_COUNT(0);
76
77 clear_vlr();
Maxb0a43142018-02-06 19:19:52 +010078 comment_end(nr, imsi);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010079}
80
Maxb0a43142018-02-06 19:19:52 +010081void test_two_lu(uint8_t nr, const char *imsi)
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010082{
Maxb0a43142018-02-06 19:19:52 +010083 comment_start(nr, imsi);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010084
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 Maierfbf66102017-04-09 12:32:51 +0200105 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100106 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200107 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100108
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 Maierfbf66102017-04-09 12:32:51 +0200135 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100136 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200137 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100138
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 Maierfbf66102017-04-09 12:32:51 +0200144 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100145 ms_sends_msg("050130089910070000006402");
Philipp Maierfbf66102017-04-09 12:32:51 +0200146 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100147
148 EXPECT_CONN_COUNT(0);
149 clear_vlr();
Maxb0a43142018-02-06 19:19:52 +0100150 comment_end(nr, imsi);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100151}
152
Maxb0a43142018-02-06 19:19:52 +0100153void test_lu_unknown_tmsi(uint8_t nr, const char *imsi)
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100154{
Maxb0a43142018-02-06 19:19:52 +0100155 comment_start(nr, imsi);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100156
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 Maierfbf66102017-04-09 12:32:51 +0200183 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100184 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200185 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100186
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();
Maxb0a43142018-02-06 19:19:52 +0100191 comment_end(nr, imsi);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100192}
193
194msc_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};