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" |
Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 25 | #include "stubs.h" |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 26 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 27 | static void test_reject_2nd_conn() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 28 | { |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 29 | struct msub *conn1; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 30 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 31 | |
| 32 | btw("Location Update Request on one connection"); |
| 33 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 34 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 35 | ms_sends_msg("050802008168000130089910070000006402"); |
| 36 | OSMO_ASSERT(gsup_tx_confirmed); |
| 37 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 38 | EXPECT_CONN_COUNT(1); |
| 39 | |
| 40 | btw("Another Location Update Request from the same subscriber on another connection is rejected"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 41 | conn1 = g_msub; |
| 42 | g_msub = NULL; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 43 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 44 | ms_sends_msg("050802008168000130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 45 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 46 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 47 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 48 | EXPECT_CONN_COUNT(1); |
| 49 | |
| 50 | |
| 51 | BTW("The first connection can still complete its LU"); |
| 52 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 53 | g_msub = conn1; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 54 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 55 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 56 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 57 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 58 | |
| 59 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 60 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 61 | gsup_rx("06010809710000004026f0"HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 62 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 63 | |
| 64 | btw("LU was successful, and the conn has already been closed"); |
| 65 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 66 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 67 | EXPECT_CONN_COUNT(0); |
| 68 | |
| 69 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 70 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 71 | } |
| 72 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 73 | static void _normal_lu_part1() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 74 | { |
| 75 | btw("Location Update Request"); |
| 76 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 77 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 78 | ms_sends_msg("050802008168000130089910070000006402"); |
| 79 | OSMO_ASSERT(gsup_tx_confirmed); |
| 80 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 81 | EXPECT_CONN_COUNT(1); |
| 82 | } |
| 83 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 84 | static void _normal_lu_part2() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 85 | { |
| 86 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 87 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 88 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 89 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 90 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 91 | |
| 92 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 93 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 94 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 95 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 96 | |
| 97 | btw("LU was successful, and the conn has already been closed"); |
| 98 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 99 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 100 | EXPECT_CONN_COUNT(0); |
| 101 | } |
| 102 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 103 | static void _normal_lu() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 104 | { |
| 105 | BTW("Subscriber does a normal LU"); |
| 106 | _normal_lu_part1(); |
| 107 | _normal_lu_part2(); |
| 108 | } |
| 109 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 110 | static void _normal_cm_service_req() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 111 | { |
| 112 | BTW("Subscriber does a normal CM Service Request"); |
| 113 | cm_service_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 114 | ms_sends_msg("05247403305886089910070000006402"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 115 | VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d"); |
| 116 | EXPECT_ACCEPTED(true); |
| 117 | } |
| 118 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 119 | static void _page() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 120 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 121 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 122 | struct vlr_subscr *vsub; |
| 123 | |
| 124 | BTW("an SMS is sent, MS is paged"); |
| 125 | paging_expect_imsi(imsi); |
| 126 | paging_sent = false; |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 127 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 128 | OSMO_ASSERT(vsub); |
| 129 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d"); |
| 130 | |
| 131 | send_sms(vsub, vsub, |
| 132 | "Privacy in residential applications is a desirable" |
| 133 | " marketing option."); |
| 134 | |
| 135 | VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d"); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 136 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 137 | vsub = NULL; |
| 138 | VERBOSE_ASSERT(paging_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 139 | } |
| 140 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 141 | static void _paging_resp_part1() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 142 | { |
| 143 | btw("MS replies with Paging Response, we deliver the SMS"); |
| 144 | dtap_expect_tx("09" /* SMS messages */ |
| 145 | "01" /* CP-DATA */ |
| 146 | "58" /* length */ |
| 147 | "01" /* Network to MS */ |
| 148 | "00" /* reference */ |
| 149 | /* originator (gsm411_send_sms() hardcodes this weird nr) */ |
| 150 | "0791" "447758100650" /* 447785016005 */ |
| 151 | "00" /* dest */ |
| 152 | /* SMS TPDU */ |
| 153 | "4c" /* len */ |
| 154 | "00" /* SMS deliver */ |
| 155 | "05806470f1" /* originating address 46071 */ |
| 156 | "00" /* TP-PID */ |
| 157 | "00" /* GSM default alphabet */ |
| 158 | "071010" /* Y-M-D (from wrapped gsm340_gen_scts())*/ |
| 159 | "000000" /* H-M-S */ |
| 160 | "00" /* GMT+0 */ |
| 161 | "44" /* data length */ |
| 162 | "5079da1e1ee7416937485e9ea7c965373d1d6683c270383b3d0e" |
| 163 | "d3d36ff71c949e83c22072799e9687c5ec32a81d96afcbf4b4fb" |
| 164 | "0c7ac3e9e9b7db05"); |
| 165 | ms_sends_msg("06270703305882089910070000006402"); |
| 166 | VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 167 | |
| 168 | btw("conn is still open to wait for SMS ack dance"); |
| 169 | EXPECT_CONN_COUNT(1); |
| 170 | } |
| 171 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 172 | static void _paging_resp_part2(int expect_conn_count, bool expect_clear) |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 173 | { |
| 174 | btw("MS replies with CP-ACK for received SMS"); |
| 175 | ms_sends_msg("8904"); |
| 176 | EXPECT_CONN_COUNT(1); |
| 177 | |
| 178 | btw("MS also sends RP-ACK, MSC in turn sends CP-ACK for that"); |
| 179 | dtap_expect_tx("0904"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 180 | if (expect_clear) |
| 181 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 182 | ms_sends_msg("890106020041020000"); |
| 183 | VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 184 | if (expect_clear) { |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 185 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 186 | ran_sends_clear_complete(); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 187 | } |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 188 | |
| 189 | btw("SMS is done"); |
| 190 | EXPECT_CONN_COUNT(expect_conn_count); |
| 191 | } |
| 192 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 193 | static void test_reject_lu_during_lu() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 194 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 195 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 196 | |
| 197 | _normal_lu_part1(); |
| 198 | |
| 199 | BTW("Another Location Update Request from the same subscriber on the same conn is dropped silently"); |
| 200 | ms_sends_msg("050802008168000130089910070000006402"); |
| 201 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 202 | EXPECT_CONN_COUNT(1); |
| 203 | |
| 204 | BTW("The first LU can still complete"); |
| 205 | _normal_lu_part2(); |
| 206 | |
| 207 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 208 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 209 | } |
| 210 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 211 | static void test_reject_cm_during_lu() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 212 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 213 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 214 | |
| 215 | _normal_lu_part1(); |
| 216 | |
| 217 | BTW("A CM Service Request in the middle of a LU is rejected"); |
| 218 | cm_service_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 219 | ms_sends_msg("05247403305886089910070000006402"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 220 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 221 | VERBOSE_ASSERT(cm_service_result_sent, == RES_REJECT, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 222 | EXPECT_CONN_COUNT(1); |
| 223 | |
| 224 | BTW("The first LU can still complete"); |
| 225 | _normal_lu_part2(); |
| 226 | |
| 227 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 228 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 229 | } |
| 230 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 231 | static void test_reject_paging_resp_during_lu() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 232 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 233 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 234 | |
| 235 | _normal_lu_part1(); |
| 236 | |
| 237 | BTW("An erratic Paging Response is dropped silently"); |
| 238 | ms_sends_msg("06270703305882089910070000006402"); |
| 239 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 240 | EXPECT_CONN_COUNT(1); |
| 241 | |
| 242 | BTW("The first LU can still complete"); |
| 243 | _normal_lu_part2(); |
| 244 | |
| 245 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 246 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 247 | } |
| 248 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 249 | static void test_reject_lu_during_cm() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 250 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 251 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 252 | |
| 253 | _normal_lu(); |
| 254 | _normal_cm_service_req(); |
| 255 | |
| 256 | btw("A LU request on an open conn is dropped silently"); |
| 257 | /* TODO: accept periodic LU on an already open conn? */ |
| 258 | lu_result_sent = RES_NONE; |
| 259 | ms_sends_msg("050802008168000130089910070000006402"); |
| 260 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 261 | EXPECT_CONN_COUNT(1); |
| 262 | |
| 263 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 264 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 265 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 266 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 267 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 268 | EXPECT_CONN_COUNT(0); |
| 269 | |
| 270 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 271 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 272 | } |
| 273 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 274 | static void test_reject_cm_during_cm() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 275 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 276 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 277 | |
| 278 | _normal_lu(); |
| 279 | _normal_cm_service_req(); |
| 280 | |
| 281 | btw("A second CM Service Request on the same conn is accepted without another auth dance"); |
| 282 | cm_service_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 283 | ms_sends_msg("05247403305886089910070000006402"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 284 | VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d"); |
| 285 | EXPECT_CONN_COUNT(1); |
| 286 | |
| 287 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 288 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 289 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 290 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 291 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 292 | EXPECT_CONN_COUNT(0); |
| 293 | |
| 294 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 295 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 296 | } |
| 297 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 298 | static void test_reject_paging_resp_during_cm() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 299 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 300 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 301 | |
| 302 | _normal_lu(); |
| 303 | _normal_cm_service_req(); |
| 304 | |
| 305 | BTW("An erratic Paging Response on the same conn is dropped silently"); |
| 306 | ms_sends_msg("06270703305882089910070000006402"); |
| 307 | EXPECT_CONN_COUNT(1); |
| 308 | |
| 309 | BTW("The original CM Service Request can conclude"); |
Vadim Yanitskiy | 2760585 | 2018-06-15 23:57:30 +0700 | [diff] [blame] | 310 | |
| 311 | /* Release connection */ |
Neels Hofmeyr | 7814a83 | 2018-12-26 00:40:18 +0100 | [diff] [blame] | 312 | expect_bssap_clear(OSMO_RAT_GERAN_A); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 313 | conn_conclude_cm_service_req(g_msub, MSC_A_USE_CM_SERVICE_SMS); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 314 | |
| 315 | btw("all requests serviced, conn has been released"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 316 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 317 | EXPECT_CONN_COUNT(0); |
| 318 | |
| 319 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 320 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 321 | } |
| 322 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 323 | static void test_reject_paging_resp_during_paging_resp() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 324 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 325 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 326 | |
| 327 | _normal_lu(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 328 | _page(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 329 | _paging_resp_part1(); |
| 330 | |
| 331 | BTW("MS sends another erratic Paging Response which is dropped silently"); |
| 332 | ms_sends_msg("06270703305882089910070000006402"); |
| 333 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 334 | _paging_resp_part2(0, true); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 335 | |
| 336 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 337 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 338 | } |
| 339 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 340 | static void test_reject_lu_during_paging_resp() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 341 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 342 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 343 | |
| 344 | _normal_lu(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 345 | _page(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 346 | _paging_resp_part1(); |
| 347 | |
| 348 | BTW("MS sends erratic LU Request, which is dropped silently"); |
| 349 | lu_result_sent = RES_NONE; |
| 350 | ms_sends_msg("050802008168000130089910070000006402"); |
| 351 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 352 | EXPECT_CONN_COUNT(1); |
| 353 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 354 | _paging_resp_part2(0, true); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 355 | |
| 356 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 357 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 358 | } |
| 359 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 360 | static void test_accept_cm_during_paging_resp() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 361 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 362 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 363 | |
| 364 | _normal_lu(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 365 | _page(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 366 | _paging_resp_part1(); |
| 367 | |
| 368 | BTW("CM Service Request during open connection is accepted"); |
| 369 | cm_service_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 370 | ms_sends_msg("05247403305886089910070000006402"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 371 | VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d"); |
| 372 | EXPECT_CONN_COUNT(1); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 373 | VERBOSE_ASSERT(osmo_use_count_by(&msub_msc_a(g_msub)->use_count, MSC_A_USE_CM_SERVICE_SMS), == 1, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 374 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 375 | _paging_resp_part2(1, false); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 376 | |
| 377 | BTW("subscriber detaches"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 378 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 379 | ms_sends_msg("050130089910070000006402"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 380 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 381 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 382 | EXPECT_CONN_COUNT(0); |
| 383 | |
| 384 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 385 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | msc_vlr_test_func_t msc_vlr_tests[] = { |
| 389 | test_reject_2nd_conn, |
| 390 | test_reject_lu_during_lu, |
| 391 | test_reject_cm_during_lu, |
| 392 | test_reject_paging_resp_during_lu, |
| 393 | test_reject_lu_during_cm, |
| 394 | test_reject_cm_during_cm, |
| 395 | test_reject_paging_resp_during_cm, |
| 396 | test_reject_lu_during_paging_resp, |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 397 | test_accept_cm_during_paging_resp, |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 398 | test_reject_paging_resp_during_paging_resp, |
| 399 | NULL |
| 400 | }; |