blob: aef1df50c04142ca7318536306ae94ea4db526d0 [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
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010026static void test_early_stage()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010027{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010028 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010029
30 btw("NULL conn");
31 EXPECT_ACCEPTED(false);
32
33 btw("freshly allocated conn");
Neels Hofmeyr93c74632018-04-02 23:10:28 +020034 g_conn = msc_subscr_conn_alloc(net, RAN_GERAN_A, 123);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010035 EXPECT_ACCEPTED(false);
36
37 btw("conn_fsm present, in state NEW");
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +020038 OSMO_ASSERT(g_conn->fi);
39 OSMO_ASSERT(g_conn->fi->state == SUBSCR_CONN_S_NEW);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010040 EXPECT_ACCEPTED(false);
41
42 thwart_rx_non_initial_requests();
43
44 btw("fake: acceptance");
45 g_conn->vsub = vlr_subscr_alloc(net->vlr);
Philipp Maierfbf66102017-04-09 12:32:51 +020046 g_conn->via_ran = RAN_GERAN_A;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010047 OSMO_ASSERT(g_conn->vsub);
48 /* mark as silent call so it sticks around */
49 g_conn->silent_call = 1;
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +020050 osmo_fsm_inst_state_chg(g_conn->fi, SUBSCR_CONN_S_ACCEPTED, 0, 0);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010051 EXPECT_CONN_COUNT(1);
52 EXPECT_ACCEPTED(true);
53
54 btw("CLOSE event marks conn_fsm as released and frees the conn");
Philipp Maierfbf66102017-04-09 12:32:51 +020055 expect_bssap_clear();
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +020056 osmo_fsm_inst_dispatch(g_conn->fi, SUBSCR_CONN_E_CN_CLOSE, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +020057 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +020058 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010059 EXPECT_CONN_COUNT(0);
60
61 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010062 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010063}
64
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010065static void test_cm_service_without_lu()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010066{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010067 comment_start();
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");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +020075 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010076 EXPECT_CONN_COUNT(0);
77
78 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010079 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010080}
81
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010082static void test_two_lu()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010083{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010084 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010085
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 Maierfbf66102017-04-09 12:32:51 +0200106 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100107 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200108 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100109
110 btw("LU was successful, and the conn has already been closed");
111 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200112 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100113 EXPECT_CONN_COUNT(0);
114
115
116 BTW("verify that the MS can send another LU request");
117 btw("Location Update request causes a GSUP LU request to HLR");
118 lu_result_sent = RES_NONE;
119 gsup_expect_tx("04010809710000004026f0");
120 ms_sends_msg("050802008168000130089910070000006402");
121 OSMO_ASSERT(gsup_tx_confirmed);
122 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
123
124 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
125 gsup_rx("10010809710000004026f00804036470f1",
126 "12010809710000004026f0");
127 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
128
129 btw("having received subscriber data does not mean acceptance");
130 EXPECT_ACCEPTED(false);
131
132 thwart_rx_non_initial_requests();
133
134 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
135
136 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200137 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100138 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200139 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100140
141 btw("LU was successful, and the conn has already been closed");
142 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200143 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100144 EXPECT_CONN_COUNT(0);
145
146 BTW("subscriber detaches");
Philipp Maierfbf66102017-04-09 12:32:51 +0200147 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100148 ms_sends_msg("050130089910070000006402");
Philipp Maierfbf66102017-04-09 12:32:51 +0200149 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100150
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200151 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100152 EXPECT_CONN_COUNT(0);
153 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100154 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100155}
156
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100157static void test_lu_unknown_tmsi()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100158{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100159 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100160
161 btw("Location Update request with unknown TMSI sends ID Request for IMSI");
162 lu_result_sent = RES_NONE;
163 dtap_expect_tx("051801");
164 ms_sends_msg("050802008168000130" "05f4" "23422342");
165 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
166
167 EXPECT_ACCEPTED(false);
168 thwart_rx_non_initial_requests();
169
170 btw("MS tells us the IMSI, causes a GSUP LU request to HLR");
171 gsup_expect_tx("04010809710000004026f0");
172 ms_sends_msg("0559089910070000006402");
173 OSMO_ASSERT(gsup_tx_confirmed);
174 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
175
176 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
177 gsup_rx("10010809710000004026f00804036470f1",
178 "12010809710000004026f0");
179 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
180
181 btw("having received subscriber data does not mean acceptance");
182 EXPECT_ACCEPTED(false);
183 thwart_rx_non_initial_requests();
184 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
185
186 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200187 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100188 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200189 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100190
191 btw("LU was successful, and the conn has already been closed");
192 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200193 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100194 EXPECT_CONN_COUNT(0);
195 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100196 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100197}
198
199msc_vlr_test_func_t msc_vlr_tests[] = {
200 test_early_stage,
201 test_cm_service_without_lu,
202 test_two_lu,
203 test_lu_unknown_tmsi,
204 NULL
205};