Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 1 | module SGSN_Tests { |
| 2 | |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 3 | /* Osmocom SGSN test suite in TTCN-3 |
| 4 | * (C) 2018-2019 Harald Welte <laforge@gnumonks.org> |
| 5 | * (C) 2018-2019 sysmocom - s.f.m.c. GmbH |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Released under the terms of GNU General Public License, Version 2 or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | */ |
| 13 | |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 14 | import from General_Types all; |
| 15 | import from Osmocom_Types all; |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 16 | import from Native_Functions all; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 17 | import from NS_Types all; |
| 18 | import from NS_Emulation all; |
| 19 | import from BSSGP_Types all; |
| 20 | import from BSSGP_Emulation all; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 21 | import from Osmocom_Gb_Types all; |
| 22 | |
| 23 | import from MobileL3_CommonIE_Types all; |
| 24 | import from MobileL3_GMM_SM_Types all; |
| 25 | import from MobileL3_Types all; |
| 26 | import from L3_Templates all; |
| 27 | import from L3_Common all; |
| 28 | |
| 29 | import from GSUP_Emulation all; |
| 30 | import from GSUP_Types all; |
| 31 | import from IPA_Emulation all; |
| 32 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 33 | import from GTP_Emulation all; |
| 34 | import from GTP_Templates all; |
| 35 | import from GTP_CodecPort all; |
| 36 | import from GTPC_Types all; |
| 37 | import from GTPU_Types all; |
| 38 | |
Harald Welte | a2526a8 | 2018-02-18 19:03:36 +0100 | [diff] [blame] | 39 | import from LLC_Types all; |
| 40 | import from LLC_Templates all; |
| 41 | |
| 42 | import from SNDCP_Types all; |
| 43 | |
Harald Welte | bd19472 | 2018-02-16 22:11:08 +0100 | [diff] [blame] | 44 | import from TELNETasp_PortType all; |
| 45 | import from Osmocom_VTY_Functions all; |
| 46 | |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 47 | import from GSM_RR_Types all; |
| 48 | |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 49 | import from MobileL3_MM_Types all; |
| 50 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 51 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 52 | modulepar { |
| 53 | /* IP/port on which we run our internal GSUP/HLR emulation */ |
| 54 | charstring mp_hlr_ip := "127.0.0.1"; |
| 55 | integer mp_hlr_port := 4222; |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 56 | charstring mp_ggsn_ip := "127.0.0.2"; |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 57 | |
Alexander Couzens | f3c1b41 | 2018-08-24 00:42:51 +0200 | [diff] [blame] | 58 | NSConfigurations mp_nsconfig := { |
| 59 | { |
| 60 | local_udp_port := 21010, |
| 61 | local_ip := "127.0.0.1", |
| 62 | remote_udp_port := 23000, |
| 63 | remote_ip := "127.0.0.1", |
| 64 | nsvci := 97, |
Harald Welte | 5e514fa | 2018-07-05 00:01:45 +0200 | [diff] [blame] | 65 | nsei := 96, |
| 66 | role_sgsn := false, |
| 67 | handle_sns := false |
Alexander Couzens | f3c1b41 | 2018-08-24 00:42:51 +0200 | [diff] [blame] | 68 | }, |
| 69 | { |
| 70 | local_udp_port := 21011, |
| 71 | local_ip := "127.0.0.1", |
| 72 | remote_udp_port := 23000, |
| 73 | remote_ip := "127.0.0.1", |
| 74 | nsvci := 98, |
Harald Welte | 5e514fa | 2018-07-05 00:01:45 +0200 | [diff] [blame] | 75 | nsei := 97, |
| 76 | role_sgsn := false, |
| 77 | handle_sns := false |
Alexander Couzens | f3c1b41 | 2018-08-24 00:42:51 +0200 | [diff] [blame] | 78 | }, |
| 79 | { |
| 80 | local_udp_port := 21012, |
| 81 | local_ip := "127.0.0.1", |
| 82 | remote_udp_port := 23000, |
| 83 | remote_ip := "127.0.0.1", |
| 84 | nsvci := 99, |
Harald Welte | 5e514fa | 2018-07-05 00:01:45 +0200 | [diff] [blame] | 85 | nsei := 98, |
| 86 | role_sgsn := false, |
| 87 | handle_sns := false |
Alexander Couzens | f3c1b41 | 2018-08-24 00:42:51 +0200 | [diff] [blame] | 88 | } |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 89 | }; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | type record GbInstance { |
| 93 | NS_CT vc_NS, |
| 94 | BSSGP_CT vc_BSSGP, |
| 95 | BssgpConfig cfg |
| 96 | }; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 97 | |
Harald Welte | 2fa771f | 2019-05-02 20:13:53 +0200 | [diff] [blame] | 98 | const integer NUM_GB := 3; |
| 99 | type record length(NUM_GB) of GbInstance GbInstances; |
| 100 | type record length(NUM_GB) of NSConfiguration NSConfigurations; |
| 101 | type record length(NUM_GB) of BssgpCellId BssgpCellIds; |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 102 | |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 103 | type component test_CT { |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 104 | var GbInstances g_gb; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 105 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 106 | var GSUP_Emulation_CT vc_GSUP; |
| 107 | var IPA_Emulation_CT vc_GSUP_IPA; |
| 108 | /* only to get events from IPA underneath GSUP */ |
| 109 | port IPA_CTRL_PT GSUP_IPA_EVENT; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 110 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 111 | var GTP_Emulation_CT vc_GTP; |
| 112 | |
Harald Welte | bd19472 | 2018-02-16 22:11:08 +0100 | [diff] [blame] | 113 | port TELNETasp_PT SGSNVTY; |
| 114 | |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 115 | var boolean g_initialized := false; |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 116 | var boolean g_use_echo := false; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 117 | }; |
| 118 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 119 | type component BSSGP_ConnHdlr extends BSSGP_Client_CT, GSUP_ConnHdlr, GTP_ConnHdlr { |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 120 | var BSSGP_ConnHdlrPars g_pars; |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 121 | timer g_Tguard; |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 122 | var LLC_Entities llc; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | type record SGSN_ConnHdlrNetworkPars { |
| 126 | boolean expect_ptmsi, |
| 127 | boolean expect_auth, |
| 128 | boolean expect_ciph |
| 129 | }; |
| 130 | |
| 131 | type record BSSGP_ConnHdlrPars { |
| 132 | /* IMEI of the simulated ME */ |
| 133 | hexstring imei, |
Alexander Couzens | 8f0fb00 | 2018-05-02 19:30:55 +0200 | [diff] [blame] | 134 | /* IMSI of the simulated MS */ |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 135 | hexstring imsi, |
| 136 | /* MSISDN of the simulated MS (probably unused) */ |
| 137 | hexstring msisdn, |
| 138 | /* P-TMSI allocated to the simulated MS */ |
| 139 | OCT4 p_tmsi optional, |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 140 | OCT3 p_tmsi_sig optional, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 141 | /* TLLI of the simulated MS */ |
| 142 | OCT4 tlli, |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 143 | OCT4 tlli_old optional, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 144 | RoutingAreaIdentificationV ra optional, |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 145 | BssgpCellIds bssgp_cell_id, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 146 | AuthVector vec optional, |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 147 | SGSN_ConnHdlrNetworkPars net, |
| 148 | float t_guard |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 149 | }; |
| 150 | |
Alexander Couzens | 8950870 | 2018-07-31 04:16:10 +0200 | [diff] [blame] | 151 | private function f_cellid_to_RAI(in BssgpCellId cell_id) return RoutingAreaIdentificationV { |
Alexander Couzens | c7dddbd | 2019-04-11 19:18:35 +0200 | [diff] [blame] | 152 | /* mcc_mnc is encoded as of 24.008 10.5.5.15 */ |
Alexander Couzens | 8950870 | 2018-07-31 04:16:10 +0200 | [diff] [blame] | 153 | var BcdMccMnc mcc_mnc := cell_id.ra_id.lai.mcc_mnc; |
| 154 | |
| 155 | var RoutingAreaIdentificationV ret := { |
| 156 | mccDigit1 := mcc_mnc[0], |
| 157 | mccDigit2 := mcc_mnc[1], |
| 158 | mccDigit3 := mcc_mnc[2], |
Alexander Couzens | c7dddbd | 2019-04-11 19:18:35 +0200 | [diff] [blame] | 159 | mncDigit3 := mcc_mnc[3], |
| 160 | mncDigit1 := mcc_mnc[4], |
| 161 | mncDigit2 := mcc_mnc[5], |
Alexander Couzens | 8950870 | 2018-07-31 04:16:10 +0200 | [diff] [blame] | 162 | lac := int2oct(cell_id.ra_id.lai.lac, 16), |
| 163 | rac := int2oct(cell_id.ra_id.rac, 8) |
| 164 | } |
| 165 | return ret; |
| 166 | }; |
| 167 | |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 168 | private function f_init_gb(inout GbInstance gb, charstring id, integer offset) runs on test_CT { |
| 169 | gb.vc_NS := NS_CT.create(id & "-NS" & int2str(offset)); |
| 170 | gb.vc_BSSGP := BSSGP_CT.create(id & "-BSSGP" & int2str(offset)); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 171 | /* connect lower end of BSSGP emulation with NS upper port */ |
| 172 | connect(gb.vc_BSSGP:BSCP, gb.vc_NS:NS_SP); |
| 173 | /* connect lower end of NS emulation to NS codec port (on top of IPL4) */ |
| 174 | map(gb.vc_NS:NSCP, system:NS_CODEC_PORT); |
| 175 | |
Alexander Couzens | f3c1b41 | 2018-08-24 00:42:51 +0200 | [diff] [blame] | 176 | gb.vc_NS.start(NSStart(mp_nsconfig[offset])); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 177 | gb.vc_BSSGP.start(BssgpStart(gb.cfg)); |
| 178 | } |
| 179 | |
| 180 | private function f_init_gsup(charstring id) runs on test_CT { |
| 181 | id := id & "-GSUP"; |
| 182 | var GsupOps ops := { |
| 183 | create_cb := refers(GSUP_Emulation.ExpectedCreateCallback) |
| 184 | }; |
| 185 | |
| 186 | vc_GSUP_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 187 | vc_GSUP := GSUP_Emulation_CT.create(id); |
| 188 | |
| 189 | map(vc_GSUP_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 190 | connect(vc_GSUP:GSUP, vc_GSUP_IPA:IPA_GSUP_PORT); |
| 191 | /* we use this hack to get events like ASP_IPA_EVENT_UP */ |
| 192 | connect(vc_GSUP_IPA:IPA_CTRL_PORT, self:GSUP_IPA_EVENT); |
| 193 | |
| 194 | vc_GSUP.start(GSUP_Emulation.main(ops, id)); |
| 195 | vc_GSUP_IPA.start(IPA_Emulation.main_server(mp_hlr_ip, mp_hlr_port)); |
| 196 | |
| 197 | /* wait for incoming connection to GSUP port before proceeding */ |
| 198 | timer T := 10.0; |
| 199 | T.start; |
| 200 | alt { |
| 201 | [] GSUP_IPA_EVENT.receive(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_UP)) { } |
| 202 | [] T.timeout { |
| 203 | setverdict(fail, "No connection to GSUP Port"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 204 | mtc.stop; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | } |
| 208 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 209 | private function f_init_gtp(charstring id) runs on test_CT { |
| 210 | id := id & "-GTP"; |
| 211 | |
| 212 | var GtpEmulationCfg gtp_cfg := { |
| 213 | gtpc_bind_ip := mp_ggsn_ip, |
| 214 | gtpc_bind_port := GTP1C_PORT, |
| 215 | gtpu_bind_ip := mp_ggsn_ip, |
| 216 | gtpu_bind_port := GTP1U_PORT, |
| 217 | sgsn_role := false |
| 218 | }; |
| 219 | |
| 220 | vc_GTP := GTP_Emulation_CT.create(id); |
| 221 | vc_GTP.start(GTP_Emulation.main(gtp_cfg)); |
| 222 | } |
| 223 | |
Harald Welte | bd19472 | 2018-02-16 22:11:08 +0100 | [diff] [blame] | 224 | private function f_init_vty() runs on test_CT { |
| 225 | map(self:SGSNVTY, system:SGSNVTY); |
| 226 | f_vty_set_prompts(SGSNVTY); |
| 227 | f_vty_transceive(SGSNVTY, "enable"); |
Alexander Couzens | 1d1744f | 2018-08-07 11:56:14 +0200 | [diff] [blame] | 228 | f_vty_transceive(SGSNVTY, "reset sgsn state"); |
Harald Welte | bd19472 | 2018-02-16 22:11:08 +0100 | [diff] [blame] | 229 | f_vty_config(SGSNVTY, "sgsn", "auth-policy remote"); |
| 230 | } |
| 231 | |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 232 | private function f_vty_enable_echo_interval(boolean enable) runs on test_CT { |
| 233 | if (enable) { |
| 234 | f_vty_config(SGSNVTY, "sgsn", "ggsn 0 echo-interval 5"); |
| 235 | } else { |
| 236 | f_vty_config(SGSNVTY, "sgsn", "ggsn 0 no echo-interval"); |
| 237 | } |
| 238 | } |
| 239 | |
Harald Welte | bd19472 | 2018-02-16 22:11:08 +0100 | [diff] [blame] | 240 | |
Alexander Couzens | c7dddbd | 2019-04-11 19:18:35 +0200 | [diff] [blame] | 241 | /* mcc_mnc is 24.008 10.5.5.15 encoded. 262 42 */ |
| 242 | function f_init(BcdMccMnc mcc_mnc := '262F42'H) runs on test_CT { |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 243 | if (g_initialized == true) { |
| 244 | return; |
| 245 | } |
| 246 | g_initialized := true; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 247 | g_gb[0].cfg := { |
| 248 | nsei := 96, |
| 249 | bvci := 196, |
| 250 | cell_id := { |
| 251 | ra_id := { |
| 252 | lai := { |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 253 | mcc_mnc := mcc_mnc, lac := 13135}, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 254 | rac := 0 |
| 255 | }, |
| 256 | cell_id := 20960 |
| 257 | }, |
| 258 | sgsn_role := false |
| 259 | }; |
Alexander Couzens | 5e2ba75 | 2018-07-03 15:13:07 +0200 | [diff] [blame] | 260 | g_gb[1].cfg := { |
| 261 | nsei := 97, |
| 262 | bvci := 210, |
| 263 | cell_id := { |
| 264 | ra_id := { |
| 265 | lai := { |
| 266 | mcc_mnc := mcc_mnc, lac := 13200}, |
| 267 | rac := 0 |
| 268 | }, |
| 269 | cell_id := 20961 |
| 270 | }, |
| 271 | sgsn_role := false |
| 272 | }; |
| 273 | g_gb[2].cfg := { |
| 274 | nsei := 98, |
| 275 | bvci := 220, |
| 276 | cell_id := { |
| 277 | ra_id := { |
| 278 | lai := { |
| 279 | mcc_mnc := mcc_mnc, lac := 13300}, |
| 280 | rac := 0 |
| 281 | }, |
| 282 | cell_id := 20962 |
| 283 | }, |
| 284 | sgsn_role := false |
| 285 | }; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 286 | |
Alexander Couzens | 1d1744f | 2018-08-07 11:56:14 +0200 | [diff] [blame] | 287 | f_init_vty(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 288 | f_init_gb(g_gb[0], "SGSN_Test-Gb0", 0); |
| 289 | f_init_gb(g_gb[1], "SGSN_Test-Gb1", 1); |
| 290 | f_init_gb(g_gb[2], "SGSN_Test-Gb2", 2); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 291 | f_init_gsup("SGSN_Test"); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 292 | f_init_gtp("SGSN_Test"); |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 293 | f_vty_enable_echo_interval(g_use_echo); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 294 | } |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 295 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 296 | type function void_fn(charstring id) runs on BSSGP_ConnHdlr; |
| 297 | |
| 298 | /* helper function to create, connect and start a BSSGP_ConnHdlr component */ |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 299 | function f_start_handler(void_fn fn, charstring id, GbInstances gb, integer imsi_suffix, |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 300 | float t_guard := 30.0) |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 301 | runs on test_CT return BSSGP_ConnHdlr { |
| 302 | var BSSGP_ConnHdlr vc_conn; |
| 303 | var SGSN_ConnHdlrNetworkPars net_pars := { |
| 304 | expect_ptmsi := true, |
| 305 | expect_auth := true, |
| 306 | expect_ciph := false |
| 307 | }; |
| 308 | var BSSGP_ConnHdlrPars pars := { |
| 309 | imei := f_gen_imei(imsi_suffix), |
| 310 | imsi := f_gen_imsi(imsi_suffix), |
| 311 | msisdn := f_gen_msisdn(imsi_suffix), |
| 312 | p_tmsi := omit, |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 313 | p_tmsi_sig := omit, |
Harald Welte | 14a0f94 | 2018-02-16 20:42:23 +0100 | [diff] [blame] | 314 | tlli := f_gprs_tlli_random(), |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 315 | tlli_old := omit, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 316 | ra := omit, |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 317 | bssgp_cell_id := { gb[0].cfg.cell_id, gb[1].cfg.cell_id, gb[2].cfg.cell_id }, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 318 | vec := omit, |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 319 | net := net_pars, |
| 320 | t_guard := t_guard |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 321 | }; |
| 322 | |
| 323 | vc_conn := BSSGP_ConnHdlr.create(id); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 324 | connect(vc_conn:BSSGP[0], gb[0].vc_BSSGP:BSSGP_SP); |
| 325 | connect(vc_conn:BSSGP_PROC[0], gb[0].vc_BSSGP:BSSGP_PROC); |
| 326 | connect(vc_conn:BSSGP[1], gb[1].vc_BSSGP:BSSGP_SP); |
| 327 | connect(vc_conn:BSSGP_PROC[1], gb[1].vc_BSSGP:BSSGP_PROC); |
| 328 | connect(vc_conn:BSSGP[2], gb[2].vc_BSSGP:BSSGP_SP); |
| 329 | connect(vc_conn:BSSGP_PROC[2], gb[2].vc_BSSGP:BSSGP_PROC); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 330 | |
| 331 | connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT); |
| 332 | connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC); |
| 333 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 334 | connect(vc_conn:GTP, vc_GTP:CLIENT); |
| 335 | connect(vc_conn:GTP_PROC, vc_GTP:CLIENT_PROC); |
| 336 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 337 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 338 | return vc_conn; |
| 339 | } |
| 340 | |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 341 | private altstep as_Tguard() runs on BSSGP_ConnHdlr { |
| 342 | [] g_Tguard.timeout { |
| 343 | setverdict(fail, "Tguard timeout"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 344 | mtc.stop; |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 345 | } |
| 346 | } |
| 347 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 348 | /* first function called in every ConnHdlr */ |
| 349 | private function f_handler_init(void_fn fn, charstring id, BSSGP_ConnHdlrPars pars) |
| 350 | runs on BSSGP_ConnHdlr { |
| 351 | /* do some common stuff like setting up g_pars */ |
| 352 | g_pars := pars; |
| 353 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 354 | llc := f_llc_create(false); |
| 355 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 356 | /* register with BSSGP core */ |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 357 | f_bssgp_client_register(g_pars.imsi, g_pars.tlli, g_pars.bssgp_cell_id[0]); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 358 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 359 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 360 | /* tell GTP dispatcher to send this IMSI to us */ |
| 361 | f_gtp_register_imsi(g_pars.imsi); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 362 | |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 363 | g_Tguard.start(pars.t_guard); |
| 364 | activate(as_Tguard()); |
| 365 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 366 | /* call the user-supplied test case function */ |
| 367 | fn.apply(id); |
| 368 | f_bssgp_client_unregister(g_pars.imsi); |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | /* TODO: |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 372 | * Detach without Attach |
| 373 | * SM procedures without attach / RAU |
| 374 | * ATTACH / RAU |
| 375 | ** with / without authentication |
| 376 | ** with / without P-TMSI allocation |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 377 | * re-transmissions of LLC frames |
| 378 | * PDP Context activation |
| 379 | ** with different GGSN config in SGSN VTY |
| 380 | ** with different PDP context type (v4/v6/v46) |
| 381 | ** timeout from GGSN |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 382 | ** multiple / secondary PDP context |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 383 | */ |
| 384 | |
| 385 | testcase TC_wait_ns_up() runs on test_CT { |
| 386 | f_init(); |
| 387 | f_sleep(20.0); |
| 388 | } |
| 389 | |
Harald Welte | a05b807 | 2019-04-23 22:35:05 +0200 | [diff] [blame] | 390 | function f_send_llc(template (value) PDU_LLC llc_pdu, integer gb_index := 0) runs on BSSGP_ConnHdlr { |
| 391 | var octetstring llc_enc := enc_PDU_LLC(valueof(llc_pdu)); |
| 392 | BSSGP[gb_index].send(ts_BSSGP_UL_UD(g_pars.tlli, g_pars.bssgp_cell_id[gb_index], llc_enc)); |
| 393 | } |
| 394 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 395 | function f_send_l3_gmm_llc(template PDU_L3_MS_SGSN l3_mo, integer gb_index := 0) runs on BSSGP_ConnHdlr { |
| 396 | var octetstring l3_enc := enc_PDU_L3_MS_SGSN(valueof(l3_mo)); |
| 397 | var BIT4 sapi := f_llc_sapi_by_l3_mo(valueof(l3_mo)); |
| 398 | var integer n_u := f_llc_get_n_u_tx(llc[bit2int(sapi)]); |
Alexander Couzens | ad35222 | 2019-05-11 02:06:04 +0200 | [diff] [blame] | 399 | f_send_llc(ts_LLC_UI(l3_enc, sapi, '0'B, n_u), gb_index); |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 400 | } |
| 401 | |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 402 | altstep as_mm_identity(integer gb_idx := 0) runs on BSSGP_ConnHdlr { |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 403 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 404 | [] BSSGP[gb_idx].receive(tr_GMM_ID_REQ('001'B)) { |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 405 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 406 | f_send_l3_gmm_llc(ts_GMM_ID_RESP(mi), gb_idx); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 407 | repeat; |
| 408 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 409 | [] BSSGP[gb_idx].receive(tr_GMM_ID_REQ('010'B)) { |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 410 | mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 411 | f_send_l3_gmm_llc(ts_GMM_ID_RESP(mi), gb_idx); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 412 | repeat; |
| 413 | } |
| 414 | } |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 415 | |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 416 | /* receive a L3 (GMM/SM) message over whatever is the appropriate lower-layer bearer */ |
| 417 | function f_receive_l3(template PDU_L3_SGSN_MS rx_tpl := ?, integer gb_idx := 0) |
| 418 | runs on BSSGP_ConnHdlr return PDU_L3_SGSN_MS { |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 419 | var PDU_L3_SGSN_MS l3_mt; |
| 420 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 421 | [] BSSGP[gb_idx].receive(rx_tpl) -> value l3_mt { } |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 422 | } |
| 423 | return l3_mt; |
| 424 | } |
| 425 | |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 426 | /* perform GMM authentication (if expected). |
| 427 | * Note, for umts_aka_challenge to work, the revisionLevelIndicatior needs to |
| 428 | * be 1 to mark R99 capability, in the GMM Attach Request, see f_gmm_attach(). */ |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 429 | function f_gmm_auth (boolean umts_aka_challenge := false, boolean force_gsm_sres := false, integer gb_idx := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 430 | var PDU_L3_MS_SGSN l3_mo; |
| 431 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 432 | var default di := activate(as_mm_identity(gb_idx)); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 433 | if (g_pars.net.expect_auth) { |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 434 | var GSUP_IE auth_tuple; |
| 435 | var template AuthenticationParameterAUTNTLV autn; |
| 436 | |
| 437 | if (umts_aka_challenge) { |
| 438 | g_pars.vec := f_gen_auth_vec_3g(); |
| 439 | autn := { |
| 440 | elementIdentifier := '28'O, |
| 441 | lengthIndicator := lengthof(g_pars.vec.autn), |
| 442 | autnValue := g_pars.vec.autn |
| 443 | }; |
| 444 | |
| 445 | auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 446 | g_pars.vec.sres, |
| 447 | g_pars.vec.kc, |
| 448 | g_pars.vec.ik, |
| 449 | g_pars.vec.ck, |
| 450 | g_pars.vec.autn, |
| 451 | g_pars.vec.res)); |
| 452 | log("GSUP sends 2G and 3G auth tuples", auth_tuple); |
| 453 | } else { |
| 454 | g_pars.vec := f_gen_auth_vec_2g(); |
| 455 | autn := omit; |
| 456 | auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(g_pars.vec.rand, |
| 457 | g_pars.vec.sres, |
| 458 | g_pars.vec.kc)); |
| 459 | log("GSUP sends only 2G auth tuple", auth_tuple); |
| 460 | } |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 461 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 462 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 463 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 464 | |
| 465 | var template PDU_L3_SGSN_MS auth_ciph_req := tr_GMM_AUTH_REQ(g_pars.vec.rand); |
| 466 | auth_ciph_req.msgs.gprs_mm.authenticationAndCipheringRequest.authenticationParameterAUTN := autn; |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 467 | l3_mt := f_receive_l3(auth_ciph_req, gb_idx); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 468 | var BIT4 ac_ref := l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.acReferenceNumber.valueField; |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 469 | var template PDU_L3_MS_SGSN auth_ciph_resp := ts_GMM_AUTH_RESP_2G(ac_ref, g_pars.vec.sres); |
| 470 | |
| 471 | if (umts_aka_challenge and not force_gsm_sres) { |
| 472 | /* set UMTS response instead */ |
| 473 | auth_ciph_resp.msgs.gprs_mm.authenticationAndCipheringResponse.authenticationParResp := { |
| 474 | valueField := substr(g_pars.vec.res, 0, 4) |
| 475 | }; |
| 476 | auth_ciph_resp.msgs.gprs_mm.authenticationAndCipheringResponse.authenticationRespParExt := { |
| 477 | elementIdentifier := '21'O, |
| 478 | lengthIndicator := lengthof(g_pars.vec.res) - 4, |
| 479 | valueField := substr(g_pars.vec.res, 4, lengthof(g_pars.vec.res) - 4) |
| 480 | }; |
| 481 | } |
| 482 | |
| 483 | l3_mo := valueof(auth_ciph_resp); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 484 | if (ispresent(l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.imeisvRequest) and |
| 485 | l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.imeisvRequest.valueField == '001'B) { |
| 486 | l3_mo.msgs.gprs_mm.authenticationAndCipheringResponse.imeisv := |
| 487 | valueof(ts_MI_IMEISV_TLV(g_pars.imei & '0'H)); |
| 488 | } |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 489 | f_send_l3_gmm_llc(l3_mo, gb_idx); |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 490 | } else { |
| 491 | /* wait for identity procedure */ |
| 492 | f_sleep(1.0); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 493 | } |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 494 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 495 | deactivate(di); |
| 496 | } |
| 497 | |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 498 | function f_upd_ptmsi_and_tlli(OCT4 p_tmsi, integer bssgp_index := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 499 | g_pars.p_tmsi := p_tmsi; |
| 500 | /* update TLLI */ |
| 501 | g_pars.tlli_old := g_pars.tlli; |
| 502 | g_pars.tlli := g_pars.p_tmsi or4b 'c0000000'O; |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 503 | f_bssgp_client_llgmm_assign(g_pars.tlli_old, g_pars.tlli, BSSGP_PROC[bssgp_index]); |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 504 | } |
| 505 | |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 506 | function f_process_attach_accept(PDU_GMM_AttachAccept aa) runs on BSSGP_ConnHdlr { |
| 507 | /* mandatory IE */ |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 508 | var hexstring aa_plmn := f_RAI_to_plmn_hexstr(aa.routingAreaIdentification); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 509 | if (not (g_pars.bssgp_cell_id[0].ra_id.lai.mcc_mnc == aa_plmn)) { |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 510 | setverdict(fail, "mismatching PLMN in Attach Accept: " & hex2str(aa_plmn) |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 511 | & "; expected " & hex2str(g_pars.bssgp_cell_id[0].ra_id.lai.mcc_mnc)); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 512 | mtc.stop; |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 513 | } |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 514 | g_pars.ra := aa.routingAreaIdentification; |
| 515 | if (ispresent(aa.allocatedPTMSI)) { |
| 516 | if (not g_pars.net.expect_ptmsi) { |
| 517 | setverdict(fail, "unexpected P-TMSI allocation"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 518 | mtc.stop; |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 519 | } |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 520 | f_upd_ptmsi_and_tlli(aa.allocatedPTMSI.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi.octets); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 521 | } |
| 522 | if (ispresent(aa.msIdentity)) { |
| 523 | setverdict(fail, "unexpected TMSI allocation in non-combined attach"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 524 | mtc.stop; |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 525 | } |
| 526 | /* P-TMSI.sig */ |
| 527 | if (ispresent(aa.ptmsiSignature)) { |
| 528 | g_pars.p_tmsi_sig := aa.ptmsiSignature.valueField; |
| 529 | } |
| 530 | /* updateTimer */ |
| 531 | // aa.readyTimer |
| 532 | /* T3302, T3319, T3323, T3312_ext, T3324 */ |
| 533 | } |
| 534 | |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 535 | function f_process_rau_accept(PDU_GMM_RoutingAreaUpdateAccept ra, integer bssgp_index := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 536 | /* mandatory IE */ |
| 537 | g_pars.ra := ra.routingAreaId; |
| 538 | if (ispresent(ra.allocatedPTMSI)) { |
| 539 | if (not g_pars.net.expect_ptmsi) { |
| 540 | setverdict(fail, "unexpected P-TMSI allocation"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 541 | mtc.stop; |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 542 | } |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 543 | f_upd_ptmsi_and_tlli(ra.allocatedPTMSI.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi.octets, bssgp_index); |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 544 | } |
| 545 | if (ispresent(ra.msIdentity)) { |
| 546 | setverdict(fail, "unexpected TMSI allocation in non-combined attach"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 547 | mtc.stop; |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 548 | } |
| 549 | /* P-TMSI.sig */ |
| 550 | if (ispresent(ra.ptmsiSignature)) { |
| 551 | g_pars.p_tmsi_sig := ra.ptmsiSignature.valueField; |
| 552 | } |
| 553 | /* updateTimer */ |
| 554 | // aa.readyTimer |
| 555 | /* T3302, T3319, T3323, T3312_ext, T3324 */ |
| 556 | } |
| 557 | |
| 558 | |
Harald Welte | 5a4fa04 | 2018-02-16 20:59:21 +0100 | [diff] [blame] | 559 | function f_random_RAI(HEX0_3n mcc := '262'H, HEX0_3n mnc := '42'H) return RoutingAreaIdentificationV { |
| 560 | return f_RAI(mcc, mnc, f_rnd_octstring(2), f_rnd_octstring(1)); |
| 561 | } |
| 562 | |
Harald Welte | 23178c5 | 2018-02-17 09:36:33 +0100 | [diff] [blame] | 563 | /* return a MobileIdentityLV: P-TMSI if we have one, IMSI otherwise */ |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 564 | private function f_mi_get_lv() runs on BSSGP_ConnHdlr return MobileL3_CommonIE_Types.MobileIdentityLV { |
Harald Welte | 23178c5 | 2018-02-17 09:36:33 +0100 | [diff] [blame] | 565 | if (ispresent(g_pars.p_tmsi)) { |
| 566 | return valueof(ts_MI_TMSI_LV(g_pars.p_tmsi)); |
| 567 | } else { |
| 568 | return valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 569 | } |
| 570 | } |
| 571 | |
Harald Welte | 311ec27 | 2018-02-17 09:40:03 +0100 | [diff] [blame] | 572 | private function f_gmm_gsup_lu_isd() runs on BSSGP_ConnHdlr { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 573 | var GSUP_PDU gsup; |
Harald Welte | 311ec27 | 2018-02-17 09:40:03 +0100 | [diff] [blame] | 574 | /* Expect MSC to perform LU with HLR */ |
| 575 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 576 | gsup := valueof(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 577 | gsup.ies := gsup.ies & { valueof(ts_GSUP_IE_PdpInfo(char2oct("*"), '0121'O, ''O)) }; |
| 578 | GSUP.send(gsup); |
Harald Welte | 311ec27 | 2018-02-17 09:40:03 +0100 | [diff] [blame] | 579 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 580 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 581 | } |
| 582 | |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 583 | friend function f_gmm_attach(boolean umts_aka_challenge, boolean force_gsm_sres, integer gb_idx := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 5a4fa04 | 2018-02-16 20:59:21 +0100 | [diff] [blame] | 584 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 585 | var template PDU_L3_MS_SGSN attach_req := ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit); |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 586 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 587 | |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 588 | /* indicate R99 capability of the MS to enable UMTS AKA in presence of |
| 589 | * 3G auth vectors */ |
| 590 | attach_req.msgs.gprs_mm.attachRequest.msNetworkCapability.msNetworkCapabilityV.revisionLevelIndicatior := '1'B; |
| 591 | /* The thing is, if the solSACapability is 'omit', then the |
| 592 | * revisionLevelIndicatior is at the wrong place! */ |
| 593 | attach_req.msgs.gprs_mm.attachRequest.msNetworkCapability.msNetworkCapabilityV.solSACapability := '0'B; |
| 594 | |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 595 | f_send_l3_gmm_llc(attach_req, gb_idx); |
| 596 | f_gmm_auth(umts_aka_challenge, force_gsm_sres, gb_idx); |
Alexander Couzens | 5844d5b | 2018-05-14 06:30:56 +0200 | [diff] [blame] | 597 | /* Expect SGSN to perform LU with HLR */ |
Harald Welte | 311ec27 | 2018-02-17 09:40:03 +0100 | [diff] [blame] | 598 | f_gmm_gsup_lu_isd(); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 599 | |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 600 | l3_mt := f_receive_l3(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?), gb_idx); |
| 601 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
| 602 | |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 603 | /* FIXME: Extract P-TMSI, if any. Only send Complete if necessary */ |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 604 | f_send_l3_gmm_llc(ts_GMM_ATTACH_COMPL, gb_idx); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | private function f_TC_attach(charstring id) runs on BSSGP_ConnHdlr { |
| 608 | f_gmm_attach(false, false); |
Harald Welte | 5a4fa04 | 2018-02-16 20:59:21 +0100 | [diff] [blame] | 609 | setverdict(pass); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | testcase TC_attach() runs on test_CT { |
| 613 | var BSSGP_ConnHdlr vc_conn; |
| 614 | f_init(); |
| 615 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 616 | vc_conn := f_start_handler(refers(f_TC_attach), testcasename(), g_gb, 1); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 617 | vc_conn.done; |
| 618 | } |
| 619 | |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 620 | testcase TC_attach_mnc3() runs on test_CT { |
| 621 | var BSSGP_ConnHdlr vc_conn; |
| 622 | f_init('023042'H); |
| 623 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 624 | vc_conn := f_start_handler(refers(f_TC_attach), testcasename(), g_gb, 1001); |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 625 | vc_conn.done; |
| 626 | } |
| 627 | |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 628 | private function f_TC_attach_umts_aka_umts_res(charstring id) runs on BSSGP_ConnHdlr { |
| 629 | f_gmm_attach(true, false); |
| 630 | setverdict(pass); |
| 631 | } |
| 632 | testcase TC_attach_umts_aka_umts_res() runs on test_CT { |
| 633 | var BSSGP_ConnHdlr vc_conn; |
| 634 | f_init(); |
| 635 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 636 | vc_conn := f_start_handler(refers(f_TC_attach_umts_aka_umts_res), testcasename(), g_gb, 1002); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 637 | vc_conn.done; |
| 638 | } |
| 639 | |
| 640 | private function f_TC_attach_umts_aka_gsm_sres(charstring id) runs on BSSGP_ConnHdlr { |
| 641 | f_gmm_attach(true, true); |
| 642 | setverdict(pass); |
| 643 | } |
| 644 | testcase TC_attach_umts_aka_gsm_sres() runs on test_CT { |
| 645 | var BSSGP_ConnHdlr vc_conn; |
| 646 | f_init(); |
| 647 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 648 | vc_conn := f_start_handler(refers(f_TC_attach_umts_aka_gsm_sres), testcasename(), g_gb, 1003); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 649 | vc_conn.done; |
| 650 | } |
| 651 | |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 652 | /* MS never responds to ID REQ, expect ATTACH REJECT */ |
| 653 | private function f_TC_attach_auth_id_timeout(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 654 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 655 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 656 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit)); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 657 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 658 | [] BSSGP[0].receive(tr_GMM_ID_REQ(?)) { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 659 | /* don't send ID Response */ |
| 660 | repeat; |
| 661 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 662 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT('09'O)) { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 663 | setverdict(pass); |
| 664 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 665 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 666 | setverdict(fail, "Wrong Attach Reject Cause"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 667 | mtc.stop; |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 668 | } |
| 669 | } |
| 670 | } |
| 671 | testcase TC_attach_auth_id_timeout() runs on test_CT { |
| 672 | var BSSGP_ConnHdlr vc_conn; |
| 673 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 674 | vc_conn := f_start_handler(refers(f_TC_attach_auth_id_timeout), testcasename(), g_gb, 2, 40.0); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 675 | vc_conn.done; |
| 676 | } |
| 677 | |
| 678 | /* HLR never responds to SAI REQ, expect ATTACH REJECT */ |
| 679 | private function f_TC_attach_auth_sai_timeout(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 680 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 681 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 682 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit)); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 683 | alt { |
| 684 | [] as_mm_identity(); |
| 685 | [] GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); { } |
| 686 | } |
| 687 | /* don't send SAI-response from HLR */ |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 688 | BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 689 | setverdict(pass); |
| 690 | } |
| 691 | testcase TC_attach_auth_sai_timeout() runs on test_CT { |
| 692 | var BSSGP_ConnHdlr vc_conn; |
| 693 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 694 | vc_conn := f_start_handler(refers(f_TC_attach_auth_sai_timeout), testcasename(), g_gb, 3); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 695 | vc_conn.done; |
| 696 | } |
| 697 | |
Harald Welte | fe25388 | 2018-02-17 09:25:00 +0100 | [diff] [blame] | 698 | /* HLR rejects SAI, expect ATTACH REJECT */ |
| 699 | private function f_TC_attach_auth_sai_reject(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | fe25388 | 2018-02-17 09:25:00 +0100 | [diff] [blame] | 700 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 701 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 702 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit)); |
Harald Welte | fe25388 | 2018-02-17 09:25:00 +0100 | [diff] [blame] | 703 | alt { |
| 704 | [] as_mm_identity(); |
| 705 | [] GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); { |
| 706 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 23)); |
| 707 | } |
| 708 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 709 | BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)); |
Harald Welte | fe25388 | 2018-02-17 09:25:00 +0100 | [diff] [blame] | 710 | setverdict(pass); |
| 711 | } |
| 712 | testcase TC_attach_auth_sai_reject() runs on test_CT { |
| 713 | var BSSGP_ConnHdlr vc_conn; |
| 714 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 715 | vc_conn := f_start_handler(refers(f_TC_attach_auth_sai_reject), testcasename(), g_gb, 4); |
Harald Welte | fe25388 | 2018-02-17 09:25:00 +0100 | [diff] [blame] | 716 | vc_conn.done; |
| 717 | } |
| 718 | |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 719 | /* HLR never responds to UL REQ, expect ATTACH REJECT */ |
| 720 | private function f_TC_attach_gsup_lu_timeout(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 721 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 722 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 723 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 724 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit)); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 725 | f_gmm_auth(); |
| 726 | /* Expect MSC to perform LU with HLR */ |
| 727 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 728 | /* Never follow-up with ISD_REQ or UL_RES */ |
| 729 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 730 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 731 | setverdict(pass); |
| 732 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 733 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 734 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 735 | setverdict(fail); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 736 | mtc.stop; |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 737 | } |
| 738 | } |
| 739 | } |
| 740 | testcase TC_attach_gsup_lu_timeout() runs on test_CT { |
| 741 | var BSSGP_ConnHdlr vc_conn; |
| 742 | f_init(); |
| 743 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 744 | vc_conn := f_start_handler(refers(f_TC_attach_gsup_lu_timeout), testcasename(), g_gb, 5); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 745 | vc_conn.done; |
| 746 | } |
| 747 | |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 748 | /* HLR rejects UL REQ, expect ATTACH REJECT */ |
| 749 | private function f_TC_attach_gsup_lu_reject(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 750 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 751 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 752 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 753 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit)); |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 754 | f_gmm_auth(); |
| 755 | /* Expect MSC to perform LU with HLR */ |
| 756 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 757 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 0)); |
| 758 | } |
| 759 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 760 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 761 | setverdict(pass); |
| 762 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 763 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 764 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 765 | setverdict(fail); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 766 | mtc.stop; |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 767 | } |
| 768 | } |
| 769 | } |
| 770 | testcase TC_attach_gsup_lu_reject() runs on test_CT { |
| 771 | var BSSGP_ConnHdlr vc_conn; |
| 772 | f_init(); |
| 773 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 774 | vc_conn := f_start_handler(refers(f_TC_attach_gsup_lu_reject), testcasename(), g_gb, 6); |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 775 | vc_conn.done; |
| 776 | } |
| 777 | |
| 778 | |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 779 | /* Attempt of combined GPRS + IMSI attach: network should ACK only GPRS attach */ |
| 780 | private function f_TC_attach_combined(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 781 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 782 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 783 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 784 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, true, false, omit, omit)); |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 785 | f_gmm_auth(); |
| 786 | /* Expect MSC to perform LU with HLR */ |
Harald Welte | 311ec27 | 2018-02-17 09:40:03 +0100 | [diff] [blame] | 787 | f_gmm_gsup_lu_isd(); |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 788 | |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 789 | BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 790 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 791 | } |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 792 | f_send_l3_gmm_llc(ts_GMM_ATTACH_COMPL); |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 793 | setverdict(pass); |
| 794 | } |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 795 | testcase TC_attach_combined() runs on test_CT { |
| 796 | var BSSGP_ConnHdlr vc_conn; |
| 797 | f_init(); |
| 798 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 799 | vc_conn := f_start_handler(refers(f_TC_attach_combined), testcasename(), g_gb, 7); |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 800 | vc_conn.done; |
| 801 | } |
| 802 | |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 803 | /* Attempt of GPRS ATTACH in 'accept all' mode */ |
| 804 | private function f_TC_attach_accept_all(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 805 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 806 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 807 | |
| 808 | g_pars.net.expect_auth := false; |
| 809 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 810 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit)); |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 811 | f_gmm_auth(); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 812 | BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 813 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 814 | } |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 815 | f_send_l3_gmm_llc(ts_GMM_ATTACH_COMPL); |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 816 | setverdict(pass); |
| 817 | } |
| 818 | testcase TC_attach_accept_all() runs on test_CT { |
| 819 | var BSSGP_ConnHdlr vc_conn; |
| 820 | f_init(); |
| 821 | f_sleep(1.0); |
| 822 | f_vty_config(SGSNVTY, "sgsn", "auth-policy accept-all"); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 823 | vc_conn := f_start_handler(refers(f_TC_attach_accept_all), testcasename(), g_gb, 8); |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 824 | vc_conn.done; |
| 825 | } |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 826 | |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 827 | /* Attempt of GPRS ATTACH in 'accept all' mode */ |
| 828 | private function f_TC_attach_closed_foreign(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 829 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 830 | |
| 831 | /* Simulate a foreign IMSI */ |
| 832 | g_pars.imsi := '001010123456789'H; |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 833 | f_bssgp_client_register(g_pars.imsi, g_pars.tlli, g_pars.bssgp_cell_id[0]); |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 834 | |
| 835 | g_pars.net.expect_auth := false; |
| 836 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 837 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit)); |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 838 | alt { |
| 839 | [] as_mm_identity(); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 840 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT('07'O)) { |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 841 | setverdict(pass); |
| 842 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 843 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 844 | setverdict(pass); |
| 845 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 846 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT(*, *, *)) { |
Alexander Couzens | 0ca0d9c | 2018-06-12 14:01:34 +0200 | [diff] [blame] | 847 | setverdict(fail); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 848 | mtc.stop; |
Alexander Couzens | 0ca0d9c | 2018-06-12 14:01:34 +0200 | [diff] [blame] | 849 | } |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 850 | } |
| 851 | } |
| 852 | testcase TC_attach_closed() runs on test_CT { |
| 853 | var BSSGP_ConnHdlr vc_conn; |
| 854 | f_init(); |
| 855 | f_sleep(1.0); |
| 856 | f_vty_config(SGSNVTY, "sgsn", "auth-policy closed"); |
| 857 | /* test with foreign IMSI: Must Reject */ |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 858 | vc_conn := f_start_handler(refers(f_TC_attach_closed_foreign), testcasename(), g_gb, 9); |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 859 | vc_conn.done; |
| 860 | /* test with home IMSI: Must Accept */ |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 861 | vc_conn := f_start_handler(refers(f_TC_attach_accept_all), testcasename(), g_gb, 10); |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 862 | vc_conn.done; |
| 863 | } |
| 864 | |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 865 | /* Routing Area Update from Unknown TLLI -> REJECT */ |
| 866 | private function f_TC_rau_unknown(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 867 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 868 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 869 | f_send_l3_gmm_llc(ts_GMM_RAU_REQ(f_mi_get_lv(), GPRS_UPD_T_RA, old_ra, false, omit, omit)); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 870 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 871 | [] BSSGP[0].receive(tr_GMM_RAU_REJECT('0a'O)) { |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 872 | setverdict(pass); |
| 873 | } |
| 874 | /* FIXME: Expect XID RESET? */ |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 875 | [] BSSGP[0].receive { repeat; } |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 876 | } |
| 877 | } |
| 878 | testcase TC_rau_unknown() runs on test_CT { |
| 879 | var BSSGP_ConnHdlr vc_conn; |
| 880 | f_init(); |
| 881 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 882 | vc_conn := f_start_handler(refers(f_TC_rau_unknown), testcasename(), g_gb, 11); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 883 | vc_conn.done; |
| 884 | } |
| 885 | |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 886 | private function f_TC_attach_rau(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 887 | /* first perform regular attach */ |
| 888 | f_TC_attach(id); |
| 889 | |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 890 | f_routing_area_update(g_pars.ra); |
| 891 | |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 892 | } |
| 893 | testcase TC_attach_rau() runs on test_CT { |
| 894 | var BSSGP_ConnHdlr vc_conn; |
| 895 | f_init(); |
| 896 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 897 | vc_conn := f_start_handler(refers(f_TC_attach_rau), testcasename(), g_gb, 12); |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 898 | vc_conn.done; |
| 899 | } |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 900 | |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 901 | /* general GPRS DETACH helper */ |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 902 | function f_detach_mo(BIT3 detach_type, boolean power_off, boolean expect_purge, integer bssgp_index := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 903 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 904 | timer T := 5.0; |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 905 | f_send_l3_gmm_llc(ts_GMM_DET_REQ_MO(detach_type, power_off), bssgp_index); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 906 | if (expect_purge) { |
| 907 | GSUP.receive(tr_GSUP_PURGE_MS_REQ(g_pars.imsi, OSMO_GSUP_CN_DOMAIN_PS)); |
| 908 | GSUP.send(ts_GSUP_PURGE_MS_RES(g_pars.imsi)); |
| 909 | } |
| 910 | T.start; |
| 911 | alt { |
| 912 | [not expect_purge] GSUP.receive(tr_GSUP_PURGE_MS_REQ(?)) { |
| 913 | setverdict(fail, "Unexpected GSUP PURGE MS for unregistered TLLI"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 914 | mtc.stop; |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 915 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 916 | [power_off] BSSGP[bssgp_index].receive(tr_GMM_DET_ACCEPT_MT) -> value l3_mt { |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 917 | g_pars.ra := omit; |
Alexander Couzens | 8e0fd46 | 2019-05-11 01:20:55 +0200 | [diff] [blame] | 918 | setverdict(fail, "Unexpected DETACH ACCEPT in power-off DETACH"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 919 | mtc.stop; |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 920 | /* TODO: check if any PDP contexts are deactivated on network side? */ |
| 921 | } |
| 922 | [power_off] T.timeout { |
| 923 | setverdict(pass); |
| 924 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 925 | [not power_off] BSSGP[bssgp_index].receive(tr_GMM_DET_ACCEPT_MT) -> value l3_mt { |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 926 | g_pars.ra := omit; |
| 927 | setverdict(pass); |
| 928 | /* TODO: check if any PDP contexts are deactivated on network side? */ |
| 929 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 930 | [] BSSGP[bssgp_index].receive(PDU_L3_SGSN_MS:?) -> value l3_mt { |
Alexander Couzens | 4630e74 | 2019-05-11 01:50:10 +0200 | [diff] [blame] | 931 | if (power_off) { |
| 932 | setverdict(fail, "Unexpected Layer 3 package received in power-off DETACH"); |
| 933 | } else { |
| 934 | setverdict(fail, "Unexpected Layer 3 package received in normal DETACH"); |
| 935 | } |
| 936 | mtc.stop; |
| 937 | } |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 938 | [] BSSGP[bssgp_index].receive { repeat; } |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 939 | } |
| 940 | } |
| 941 | |
| 942 | /* IMSI DETACH (non-power-off) for unknown TLLI */ |
| 943 | private function f_TC_detach_unknown_nopoweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 944 | f_detach_mo(c_GMM_DTT_MO_GPRS, false, false); |
| 945 | } |
| 946 | testcase TC_detach_unknown_nopoweroff() runs on test_CT { |
| 947 | var BSSGP_ConnHdlr vc_conn; |
| 948 | f_init(); |
| 949 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 950 | vc_conn := f_start_handler(refers(f_TC_detach_unknown_nopoweroff), testcasename(), g_gb, 13); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 951 | vc_conn.done; |
| 952 | } |
| 953 | |
| 954 | /* IMSI DETACH (power-off) for unknown TLLI */ |
| 955 | private function f_TC_detach_unknown_poweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 956 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, false); |
| 957 | } |
| 958 | testcase TC_detach_unknown_poweroff() runs on test_CT { |
| 959 | var BSSGP_ConnHdlr vc_conn; |
| 960 | f_init(); |
| 961 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 962 | vc_conn := f_start_handler(refers(f_TC_detach_unknown_poweroff), testcasename(), g_gb, 14); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 963 | vc_conn.done; |
| 964 | } |
| 965 | |
| 966 | /* IMSI DETACH (non-power-off) for known TLLI */ |
| 967 | private function f_TC_detach_nopoweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 968 | /* first perform regular attach */ |
| 969 | f_TC_attach(id); |
| 970 | |
| 971 | f_detach_mo(c_GMM_DTT_MO_GPRS, false, true); |
| 972 | } |
| 973 | testcase TC_detach_nopoweroff() runs on test_CT { |
| 974 | var BSSGP_ConnHdlr vc_conn; |
| 975 | f_init(); |
| 976 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 977 | vc_conn := f_start_handler(refers(f_TC_detach_nopoweroff), testcasename(), g_gb, 15); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 978 | vc_conn.done; |
| 979 | } |
| 980 | |
| 981 | /* IMSI DETACH (power-off) for known TLLI */ |
| 982 | private function f_TC_detach_poweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 983 | /* first perform regular attach */ |
| 984 | f_TC_attach(id); |
| 985 | |
| 986 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true); |
| 987 | } |
| 988 | testcase TC_detach_poweroff() runs on test_CT { |
| 989 | var BSSGP_ConnHdlr vc_conn; |
| 990 | f_init(); |
| 991 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 992 | vc_conn := f_start_handler(refers(f_TC_detach_poweroff), testcasename(), g_gb, 16); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 993 | vc_conn.done; |
| 994 | } |
| 995 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 996 | type record PdpActPars { |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 997 | BIT3 tid, /* L3 Transaction ID */ |
| 998 | BIT4 nsapi, /* SNDCP NSAPI */ |
| 999 | BIT4 sapi, /* LLC SAPI */ |
| 1000 | QoSV qos, /* QoS parameters */ |
| 1001 | PDPAddressV addr, /* IP address */ |
| 1002 | octetstring apn optional, /* APN name */ |
| 1003 | ProtocolConfigOptionsV pco optional, /* protoco config opts */ |
| 1004 | OCT1 exp_rej_cause optional, /* expected SM reject cause */ |
Harald Welte | 1d6ae93 | 2018-02-18 21:24:44 +0100 | [diff] [blame] | 1005 | OCT1 gtp_resp_cause, /* GTP response cause */ |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 1006 | OCT4 chg_id, /* GTP Charging Identifier */ |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1007 | |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 1008 | OCT4 ggsn_tei_c, /* GGSN TEI Control*/ |
| 1009 | OCT4 ggsn_tei_u, /* GGSN TEI User */ |
| 1010 | octetstring ggsn_ip_c, /* GGSN IP Control */ |
| 1011 | octetstring ggsn_ip_u, /* GGSN IP User */ |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1012 | OCT1 ggsn_restart_ctr, /* GGSN Restart Counter */ |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1013 | |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 1014 | OCT4 sgsn_tei_c optional, /* SGSN TEI Control */ |
| 1015 | OCT4 sgsn_tei_u optional, /* SGSN TEI User */ |
| 1016 | octetstring sgsn_ip_c optional, /* SGSN IP Control */ |
| 1017 | octetstring sgsn_ip_u optional /* SGSN IP USer */ |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1018 | }; |
| 1019 | |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 1020 | |
| 1021 | private function f_process_gtp_ctx_act_req(inout PdpActPars apars, PDU_GTPC gtpc) runs on BSSGP_ConnHdlr { |
| 1022 | var GTPC_PDUs gtpc_rx := gtpc.gtpc_pdu; |
| 1023 | apars.sgsn_tei_c := gtpc_rx.createPDPContextRequest.teidControlPlane.teidControlPlane; |
| 1024 | apars.sgsn_tei_u := gtpc_rx.createPDPContextRequest.teidDataI.teidDataI; |
| 1025 | apars.sgsn_ip_c := gtpc_rx.createPDPContextRequest.sgsn_addr_signalling.addressf; |
| 1026 | apars.sgsn_ip_u := gtpc_rx.createPDPContextRequest.sgsn_addr_traffic.addressf; |
| 1027 | f_gtp_register_teid(apars.ggsn_tei_c); |
| 1028 | f_gtp_register_teid(apars.ggsn_tei_u); |
| 1029 | } |
| 1030 | |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1031 | function f_pdp_ctx_act(inout PdpActPars apars, boolean send_recovery := false, integer gb_idx := 0) |
| 1032 | runs on BSSGP_ConnHdlr { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1033 | var boolean exp_rej := ispresent(apars.exp_rej_cause); |
| 1034 | var Gtp1cUnitdata g_ud; |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1035 | var template Recovery_gtpc recovery := omit; |
| 1036 | |
| 1037 | if (send_recovery) { |
| 1038 | recovery := ts_Recovery(apars.ggsn_restart_ctr); |
| 1039 | } |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1040 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1041 | f_send_l3_gmm_llc(ts_SM_ACT_PDP_REQ(apars.tid, apars.nsapi, apars.sapi, apars.qos, apars.addr, |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1042 | apars.apn, apars.pco), gb_idx); |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 1043 | GTP.receive(tr_GTPC_MsgType(?, createPDPContextRequest, ?)) -> value g_ud { |
| 1044 | f_process_gtp_ctx_act_req(apars, g_ud.gtpc); |
| 1045 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1046 | GTP.send(ts_GTPC_CreatePdpResp(g_ud.peer, seq_nr, |
| 1047 | apars.sgsn_tei_c, apars.gtp_resp_cause, |
| 1048 | apars.ggsn_tei_c, apars.ggsn_tei_u, |
| 1049 | apars.nsapi, |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1050 | apars.ggsn_ip_c, apars.ggsn_ip_u, apars.chg_id, |
| 1051 | omit, recovery)); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1052 | } |
| 1053 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1054 | [exp_rej] BSSGP[gb_idx].receive(tr_SM_ACT_PDP_REJ(apars.tid, apars.exp_rej_cause)) { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1055 | setverdict(pass); |
| 1056 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1057 | [exp_rej] BSSGP[gb_idx].receive(tr_SM_ACT_PDP_ACCEPT) { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1058 | setverdict(fail, "Unexpected PDP CTX ACT ACC"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1059 | mtc.stop; |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1060 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1061 | [not exp_rej] BSSGP[gb_idx].receive(tr_SM_ACT_PDP_REJ(apars.tid, ?)) { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1062 | setverdict(fail, "Unexpected PDP CTX ACT FAIL"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1063 | mtc.stop; |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1064 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1065 | [not exp_rej] BSSGP[gb_idx].receive(tr_SM_ACT_PDP_REJ(apars.tid, ?)) { |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1066 | setverdict(fail, "Unexpected PDP CTX ACT FAIL"); |
| 1067 | mtc.stop; |
| 1068 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1069 | [not exp_rej] BSSGP[gb_idx].receive(tr_SM_ACT_PDP_ACCEPT(apars.tid, apars.sapi)) { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1070 | setverdict(pass); |
| 1071 | } |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1072 | [] as_xid(apars, gb_idx); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1073 | } |
| 1074 | } |
| 1075 | |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1076 | function f_pdp_ctx_deact_mo(inout PdpActPars apars, OCT1 cause, integer gb_idx := 0) |
| 1077 | runs on BSSGP_ConnHdlr { |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1078 | var boolean exp_rej := ispresent(apars.exp_rej_cause); |
| 1079 | var Gtp1cUnitdata g_ud; |
| 1080 | |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1081 | f_send_l3_gmm_llc(ts_SM_DEACT_PDP_REQ_MO(apars.tid, cause, false, omit), gb_idx); |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1082 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextRequest, apars.ggsn_tei_c)) -> value g_ud { |
| 1083 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1084 | BSSGP[gb_idx].clear; |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1085 | GTP.send(ts_GTPC_DeletePdpResp(g_ud.peer, seq_nr, apars.sgsn_tei_c, '7F'O)); |
| 1086 | } |
| 1087 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1088 | [] BSSGP[gb_idx].receive(tr_SM_DEACT_PDP_ACCEPT_MT(apars.tid)) { |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1089 | setverdict(pass); |
| 1090 | } |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1091 | [] as_xid(apars, gb_idx); |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1092 | } |
| 1093 | } |
| 1094 | |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1095 | function f_pdp_ctx_deact_mt(inout PdpActPars apars, boolean error_ind := false, integer gb_idx := 0) |
| 1096 | runs on BSSGP_ConnHdlr { |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1097 | var Gtp1cUnitdata g_ud; |
| 1098 | var integer seq_nr := 23; |
| 1099 | var GtpPeer peer := valueof(ts_GtpPeerC(apars.sgsn_ip_c)); |
| 1100 | |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1101 | BSSGP[gb_idx].clear; |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1102 | if (error_ind) { |
| 1103 | GTP.send(ts_GTPU_ErrorIndication(peer, 0 /* seq */, apars.ggsn_tei_u, apars.ggsn_ip_u)); |
| 1104 | } else { |
| 1105 | GTP.send(ts_GTPC_DeletePDP(peer, seq_nr, apars.sgsn_tei_c, apars.nsapi, '1'B)); |
| 1106 | } |
Alexander Couzens | 5e71c14 | 2018-08-07 17:21:24 +0200 | [diff] [blame] | 1107 | |
| 1108 | timer T := 5.0; |
| 1109 | T.start; |
| 1110 | |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1111 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1112 | [] BSSGP[gb_idx].receive(tr_SM_DEACT_PDP_REQ_MT(apars.tid, ?, true)) { |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1113 | f_send_l3_gmm_llc(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid), gb_idx); |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1114 | } |
Alexander Couzens | 5e71c14 | 2018-08-07 17:21:24 +0200 | [diff] [blame] | 1115 | [not error_ind] GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, apars.ggsn_tei_c)) { |
| 1116 | repeat; |
| 1117 | } |
| 1118 | [] T.timeout { |
| 1119 | setverdict(fail, "Waiting for SM_DEACT_PDP_REQ_MT"); |
| 1120 | } |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1121 | } |
| 1122 | } |
| 1123 | |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1124 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1125 | /* Table 10.5.156/3GPP TS 24.008 */ |
| 1126 | template (value) QoSV t_QosDefault := { |
| 1127 | reliabilityClass := '011'B, /* unacknowledged GTP+LLC, acknowledged RLC */ |
| 1128 | delayClass := '100'B, /* best effort */ |
| 1129 | spare1 := '00'B, |
| 1130 | precedenceClass := '010'B, /* normal */ |
| 1131 | spare2 := '0'B, |
| 1132 | peakThroughput := '0000'B, /* subscribed */ |
| 1133 | meanThroughput := '00000'B, /* subscribed */ |
| 1134 | spare3 := '000'B, |
| 1135 | deliverErroneusSDU := omit, |
| 1136 | deliveryOrder := omit, |
| 1137 | trafficClass := omit, |
| 1138 | maxSDUSize := omit, |
| 1139 | maxBitrateUplink := omit, |
| 1140 | maxBitrateDownlink := omit, |
| 1141 | sduErrorRatio := omit, |
| 1142 | residualBER := omit, |
| 1143 | trafficHandlingPriority := omit, |
| 1144 | transferDelay := omit, |
| 1145 | guaranteedBitRateUplink := omit, |
| 1146 | guaranteedBitRateDownlink := omit, |
| 1147 | sourceStatisticsDescriptor := omit, |
| 1148 | signallingIndication := omit, |
| 1149 | spare4 := omit, |
| 1150 | maxBitrateDownlinkExt := omit, |
| 1151 | guaranteedBitRateDownlinkExt := omit, |
| 1152 | maxBitrateUplinkExt := omit, |
| 1153 | guaranteedBitRateUplinkExt := omit, |
| 1154 | maxBitrateDownlinkExt2 := omit, |
| 1155 | guaranteedBitRateDownlinkExt2 := omit, |
| 1156 | maxBitrateUplinkExt2 := omit, |
| 1157 | guaranteedBitRateUplinkExt2 := omit |
| 1158 | } |
| 1159 | |
| 1160 | /* 10.5.6.4 / 3GPP TS 24.008 */ |
| 1161 | template (value) PDPAddressV t_AddrIPv4dyn := { |
| 1162 | pdpTypeOrg := '0001'B, /* IETF */ |
| 1163 | spare := '0000'B, |
| 1164 | pdpTypeNum := '21'O, /* IPv4 */ |
| 1165 | addressInfo := omit |
| 1166 | } |
| 1167 | template (value) PDPAddressV t_AddrIPv6dyn := { |
| 1168 | pdpTypeOrg := '0001'B, /* IETF */ |
| 1169 | spare := '0000'B, |
| 1170 | pdpTypeNum := '53'O, /* IPv6 */ |
| 1171 | addressInfo := omit |
| 1172 | } |
| 1173 | |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1174 | template (value) PdpActPars t_PdpActPars(charstring ggsn_ip) := { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1175 | tid := '000'B, |
| 1176 | nsapi := '0101'B, /* < 5 are reserved */ |
| 1177 | sapi := '0011'B, /* 3/5/9/11 */ |
| 1178 | qos := t_QosDefault, |
| 1179 | addr := t_AddrIPv4dyn, |
| 1180 | apn := omit, |
| 1181 | pco := omit, |
| 1182 | exp_rej_cause := omit, |
Harald Welte | 1d6ae93 | 2018-02-18 21:24:44 +0100 | [diff] [blame] | 1183 | gtp_resp_cause := int2oct(128, 1), |
| 1184 | chg_id := f_rnd_octstring(4), |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1185 | |
| 1186 | /* FIXME: make below dynamic !! */ |
Harald Welte | 1d6ae93 | 2018-02-18 21:24:44 +0100 | [diff] [blame] | 1187 | ggsn_tei_c := f_rnd_octstring(4), |
| 1188 | ggsn_tei_u := f_rnd_octstring(4), |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1189 | ggsn_ip_c := f_inet_addr(ggsn_ip), |
| 1190 | ggsn_ip_u := f_inet_addr(ggsn_ip), |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1191 | ggsn_restart_ctr := int2oct(2, 1), |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1192 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1193 | sgsn_tei_c := omit, |
Harald Welte | f8af5d6 | 2018-02-18 15:06:42 +0100 | [diff] [blame] | 1194 | sgsn_tei_u := omit, |
| 1195 | sgsn_ip_c := omit, |
| 1196 | sgsn_ip_u := omit |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1197 | } |
| 1198 | |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1199 | template (value) GtpPeer ts_GtpPeerU(octetstring ip) := { |
| 1200 | connId := 1, |
| 1201 | remName := f_inet_ntoa(ip), |
| 1202 | remPort := GTP1U_PORT |
| 1203 | } |
| 1204 | |
| 1205 | template (value) GtpPeer ts_GtpPeerC(octetstring ip) := { |
| 1206 | connId := 1, |
| 1207 | remName := f_inet_ntoa(ip), |
| 1208 | remPort := GTP1C_PORT |
| 1209 | } |
| 1210 | |
| 1211 | private function f_gtpu_send(inout PdpActPars apars, octetstring payload) runs on BSSGP_ConnHdlr { |
| 1212 | var GtpPeer peer := valueof(ts_GtpPeerU(apars.sgsn_ip_u)); |
| 1213 | GTP.send(ts_GTP1U_GPDU(peer, 0 /*seq*/, apars.sgsn_tei_u, payload)); |
| 1214 | } |
| 1215 | |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1216 | private altstep as_xid(PdpActPars apars, integer gb_idx := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1217 | [] BSSGP[gb_idx].receive(tr_LLC_XID_MT_CMD(?, apars.sapi)) { |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1218 | repeat; |
| 1219 | } |
| 1220 | } |
| 1221 | |
| 1222 | template PDU_SN tr_SN_UD(template BIT4 nsapi, template octetstring payload) := { |
| 1223 | pDU_SN_UNITDATA := { |
| 1224 | nsapi := nsapi, |
| 1225 | moreBit := ?, |
| 1226 | snPduType := '1'B, |
| 1227 | firstSegmentIndicator := ?, |
| 1228 | spareBit := ?, |
| 1229 | pcomp := ?, |
| 1230 | dcomp := ?, |
| 1231 | npduNumber := ?, |
| 1232 | segmentNumber := ?, |
| 1233 | npduNumberContinued := ?, |
| 1234 | dataSegmentSnUnitdataPdu := payload |
| 1235 | } |
| 1236 | } |
| 1237 | |
| 1238 | /* simple case: single segment, no compression */ |
| 1239 | template (value) PDU_SN ts_SN_UD(BIT4 nsapi, octetstring payload) := { |
| 1240 | pDU_SN_UNITDATA := { |
| 1241 | nsapi := nsapi, |
| 1242 | moreBit := '0'B, |
| 1243 | snPduType := '1'B, |
| 1244 | firstSegmentIndicator := '1'B, |
| 1245 | spareBit := '0'B, |
| 1246 | pcomp := '0000'B, |
| 1247 | dcomp := '0000'B, |
| 1248 | npduNumber := '0000'B, |
| 1249 | segmentNumber := '0000'B, |
| 1250 | npduNumberContinued := '00'O, |
| 1251 | dataSegmentSnUnitdataPdu := payload |
| 1252 | } |
| 1253 | } |
| 1254 | |
| 1255 | /* Transceive given 'payload' as MT message from GTP -> OsmoSGSN -> Gb */ |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1256 | private function f_gtpu_xceive_mt(inout PdpActPars apars, octetstring payload, integer gb_idx := 0) |
| 1257 | runs on BSSGP_ConnHdlr { |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1258 | /* Send PDU via GTP from our simulated GGSN to the SGSN */ |
| 1259 | f_gtpu_send(apars, payload); |
| 1260 | /* Expect PDU via BSSGP/LLC on simulated PCU from SGSN */ |
| 1261 | alt { |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1262 | [] as_xid(apars, gb_idx); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1263 | //[] BSSGP[gb_idx].receive(tr_BD_SNDCP(apars.sapi, tr_SN_UD(apars.nsapi, payload))); |
| 1264 | [] BSSGP[gb_idx].receive(tr_SN_UD(apars.nsapi, payload)); |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1265 | } |
| 1266 | } |
| 1267 | |
Pau Espin Pedrol | 8be4d19 | 2018-07-18 13:43:44 +0200 | [diff] [blame] | 1268 | /* Transceive given 'payload' as MT message from Gb -> OsmoSGSN -> GTP */ |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1269 | private function f_gtpu_xceive_mo(inout PdpActPars apars, octetstring payload, integer gb_idx := 0) |
| 1270 | runs on BSSGP_ConnHdlr { |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1271 | /* Send PDU via SNDCP/LLC/BSSGP/NS via simulated MS/PCU to the SGSN */ |
| 1272 | var GtpPeer peer := valueof(ts_GtpPeerU(apars.sgsn_ip_u)); |
| 1273 | var PDU_SN sndcp := valueof(ts_SN_UD(apars.nsapi, payload)); |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1274 | BSSGP[gb_idx].send(ts_LLC_UI(enc_PDU_SN(sndcp), apars.sapi, '0'B, 0)); |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1275 | /* Expect PDU via GTP from SGSN on simulated GGSN */ |
| 1276 | alt { |
| 1277 | [] GTP.receive(tr_GTPU_GPDU(peer, apars.ggsn_tei_u, payload)); |
| 1278 | } |
| 1279 | } |
| 1280 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1281 | private function f_TC_attach_pdp_act(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1282 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1283 | |
| 1284 | /* first perform regular attach */ |
| 1285 | f_TC_attach(id); |
| 1286 | |
| 1287 | f_pdp_ctx_act(apars); |
| 1288 | } |
| 1289 | testcase TC_attach_pdp_act() runs on test_CT { |
| 1290 | var BSSGP_ConnHdlr vc_conn; |
| 1291 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1292 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act), testcasename(), g_gb, 17); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1293 | vc_conn.done; |
| 1294 | } |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 1295 | |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1296 | /* PDP Context activation for not-attached subscriber; expect fail */ |
| 1297 | private function f_TC_pdp_act_unattached(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1298 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1299 | f_send_l3_gmm_llc(ts_SM_ACT_PDP_REQ(apars.tid, apars.nsapi, apars.sapi, apars.qos, apars.addr, |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1300 | apars.apn, apars.pco)); |
| 1301 | alt { |
| 1302 | /* We might want toalso actually expect a PDPC CTX ACT REJ? */ |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1303 | [] BSSGP[0].receive(tr_GMM_DET_REQ_MT(?, ?)) { |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1304 | setverdict(pass); |
| 1305 | } |
| 1306 | [] GTP.receive(tr_GTPC_MsgType(?, createPDPContextRequest, ?)) { |
| 1307 | setverdict(fail, "Unexpected GTP PDP CTX ACT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1308 | mtc.stop; |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1309 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1310 | [] BSSGP[0].receive(tr_SM_ACT_PDP_ACCEPT(?, ?)) { |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1311 | setverdict(fail, "Unexpected SM PDP CTX ACT ACK"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1312 | mtc.stop; |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1313 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1314 | [] BSSGP[0].receive { repeat; } |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1315 | } |
| 1316 | } |
| 1317 | testcase TC_pdp_act_unattached() runs on test_CT { |
| 1318 | var BSSGP_ConnHdlr vc_conn; |
| 1319 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1320 | vc_conn := f_start_handler(refers(f_TC_pdp_act_unattached), testcasename(), g_gb, 18); |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1321 | vc_conn.done; |
| 1322 | } |
| 1323 | |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1324 | /* ATTACH + PDP CTX ACT + user plane traffic */ |
| 1325 | private function f_TC_attach_pdp_act_user(charstring id) runs on BSSGP_ConnHdlr { |
| 1326 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1327 | |
| 1328 | /* first perform regular attach */ |
| 1329 | f_TC_attach(id); |
| 1330 | /* then activate PDP context */ |
| 1331 | f_pdp_ctx_act(apars); |
| 1332 | /* then transceive a downlink PDU */ |
| 1333 | f_gtpu_xceive_mt(apars, f_rnd_octstring(100)); |
| 1334 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 1335 | } |
| 1336 | testcase TC_attach_pdp_act_user() runs on test_CT { |
| 1337 | var BSSGP_ConnHdlr vc_conn; |
| 1338 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1339 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_user), testcasename(), g_gb, 19); |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1340 | vc_conn.done; |
| 1341 | } |
| 1342 | |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 1343 | /* ATTACH + PDP CTX ACT; reject from GGSN */ |
| 1344 | private function f_TC_attach_pdp_act_ggsn_reject(charstring id) runs on BSSGP_ConnHdlr { |
| 1345 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1346 | |
| 1347 | apars.gtp_resp_cause := int2oct(199, 1); /* no resources available */ |
| 1348 | apars.exp_rej_cause := '1a'O; /* insufficient resources */ |
| 1349 | |
| 1350 | /* first perform regular attach */ |
| 1351 | f_TC_attach(id); |
| 1352 | /* then activate PDP context */ |
| 1353 | f_pdp_ctx_act(apars); |
| 1354 | } |
| 1355 | testcase TC_attach_pdp_act_ggsn_reject() runs on test_CT { |
| 1356 | var BSSGP_ConnHdlr vc_conn; |
| 1357 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1358 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_ggsn_reject), testcasename(), g_gb, 20); |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 1359 | vc_conn.done; |
| 1360 | } |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1361 | |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1362 | /* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MO direction */ |
| 1363 | private function f_TC_attach_pdp_act_user_deact_mo(charstring id) runs on BSSGP_ConnHdlr { |
| 1364 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1365 | |
| 1366 | /* first perform regular attach */ |
| 1367 | f_TC_attach(id); |
| 1368 | /* then activate PDP context */ |
| 1369 | f_pdp_ctx_act(apars); |
| 1370 | /* then transceive a downlink PDU */ |
| 1371 | f_gtpu_xceive_mt(apars, f_rnd_octstring(100)); |
| 1372 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 1373 | |
| 1374 | f_pdp_ctx_deact_mo(apars, '00'O); |
| 1375 | } |
| 1376 | testcase TC_attach_pdp_act_user_deact_mo() runs on test_CT { |
| 1377 | var BSSGP_ConnHdlr vc_conn; |
| 1378 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1379 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_user_deact_mo), testcasename(), g_gb, 21); |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1380 | vc_conn.done; |
| 1381 | } |
| 1382 | |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1383 | /* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MT direction */ |
| 1384 | private function f_TC_attach_pdp_act_user_deact_mt(charstring id) runs on BSSGP_ConnHdlr { |
| 1385 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1386 | |
| 1387 | /* first perform regular attach */ |
| 1388 | f_TC_attach(id); |
| 1389 | /* then activate PDP context */ |
| 1390 | f_pdp_ctx_act(apars); |
| 1391 | /* then transceive a downlink PDU */ |
| 1392 | f_gtpu_xceive_mt(apars, f_rnd_octstring(100)); |
| 1393 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 1394 | |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1395 | f_pdp_ctx_deact_mt(apars, false); |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1396 | } |
| 1397 | testcase TC_attach_pdp_act_user_deact_mt() runs on test_CT { |
| 1398 | var BSSGP_ConnHdlr vc_conn; |
| 1399 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1400 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_user_deact_mt), testcasename(), g_gb, 22); |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1401 | vc_conn.done; |
| 1402 | } |
| 1403 | |
Alexander Couzens | 187ad5d | 2018-05-02 19:31:10 +0200 | [diff] [blame] | 1404 | /* ATTACH + ATTACH (2nd) */ |
| 1405 | private function f_TC_attach_forget_tlli_attach(charstring id) runs on BSSGP_ConnHdlr { |
| 1406 | g_pars.t_guard := 5.0; |
| 1407 | |
| 1408 | /* first perform regular attach */ |
| 1409 | f_TC_attach(id); |
| 1410 | |
| 1411 | /* second to perform regular attach */ |
| 1412 | f_TC_attach(id); |
| 1413 | } |
| 1414 | |
| 1415 | |
| 1416 | testcase TC_attach_second_attempt() runs on test_CT { |
| 1417 | var BSSGP_ConnHdlr vc_conn; |
| 1418 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1419 | vc_conn := f_start_handler(refers(f_TC_attach_forget_tlli_attach), testcasename(), g_gb, 22); |
Alexander Couzens | 187ad5d | 2018-05-02 19:31:10 +0200 | [diff] [blame] | 1420 | vc_conn.done; |
| 1421 | } |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1422 | |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1423 | private function f_TC_attach_restart_ctr_echo(charstring id) runs on BSSGP_ConnHdlr { |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1424 | var Gtp1cUnitdata g_ud; |
| 1425 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1426 | |
| 1427 | /* first perform regular attach */ |
| 1428 | f_TC_attach(id); |
| 1429 | /* Activate a pdp context against the GGSN */ |
| 1430 | f_pdp_ctx_act(apars); |
| 1431 | /* Wait to receive first echo request and send initial Restart counter */ |
| 1432 | GTP.receive(tr_GTPC_MsgType(?, echoRequest, ?)) -> value g_ud { |
| 1433 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1434 | GTP.send(ts_GTPC_PONG(g_ud.peer, seq_nr, apars.ggsn_restart_ctr)); |
| 1435 | } |
| 1436 | /* Wait to receive second echo request and send incremented Restart |
| 1437 | counter. This will fake a restarted GGSN, and pdp ctx allocated |
| 1438 | should be released by SGSN */ |
| 1439 | apars.ggsn_restart_ctr := int2oct(oct2int(apars.ggsn_restart_ctr) + 1, 1); |
| 1440 | GTP.receive(tr_GTPC_MsgType(?, echoRequest, ?)) -> value g_ud { |
| 1441 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1442 | GTP.send(ts_GTPC_PONG(g_ud.peer, seq_nr, apars.ggsn_restart_ctr)); |
| 1443 | } |
| 1444 | var OCT1 cause_network_failure := int2oct(38, 1) |
| 1445 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1446 | [] BSSGP[0].receive(tr_SM_DEACT_PDP_REQ_MT(apars.tid, cause_network_failure, true)) { |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1447 | f_send_l3_gmm_llc(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid)); |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1448 | setverdict(pass); |
| 1449 | } |
| 1450 | [] as_xid(apars); |
| 1451 | } |
| 1452 | setverdict(pass); |
| 1453 | } |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1454 | /* ATTACH + trigger Recovery procedure through EchoResp */ |
| 1455 | testcase TC_attach_restart_ctr_echo() runs on test_CT { |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1456 | var BSSGP_ConnHdlr vc_conn; |
| 1457 | g_use_echo := true |
| 1458 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1459 | vc_conn := f_start_handler(refers(f_TC_attach_restart_ctr_echo), testcasename(), g_gb, 23, 30.0); |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1460 | vc_conn.done; |
| 1461 | g_use_echo := false |
| 1462 | } |
| 1463 | |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1464 | private function f_TC_attach_restart_ctr_create(charstring id) runs on BSSGP_ConnHdlr { |
| 1465 | var Gtp1cUnitdata g_ud; |
| 1466 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1467 | var integer seq_nr := 23; |
| 1468 | var GtpPeer peer; |
| 1469 | /* first perform regular attach */ |
| 1470 | f_TC_attach(id); |
| 1471 | |
| 1472 | /* Use this CTX ACT to send initial Restart counter to SGSN. */ |
| 1473 | apars.gtp_resp_cause := int2oct(199, 1); /* no resources available */ |
| 1474 | apars.exp_rej_cause := '1a'O; /* insufficient resources */ |
| 1475 | f_pdp_ctx_act(apars, true); |
| 1476 | |
| 1477 | /* Increment restart_ctr. This will fake a restarted GGSN when CreatePdpResp is |
| 1478 | /* received. */ |
| 1479 | apars.ggsn_restart_ctr := int2oct(oct2int(apars.ggsn_restart_ctr) + 1, 1); |
| 1480 | |
| 1481 | /* FIXME: Once we can easily handle different pdp ctx simultaneously, it |
| 1482 | would be great to have an active pdp context here before triggering |
| 1483 | Recovery, and making sure the the DEACT request is sent by the SGSN. |
| 1484 | */ |
| 1485 | |
| 1486 | /* Activate a pdp context against the GGSN, send incremented Recovery |
| 1487 | IE. This should trigger the recovery path, but still this specific |
| 1488 | CTX activation should work. */ |
| 1489 | apars.exp_rej_cause := omit; /* default value for tests */ |
| 1490 | apars.gtp_resp_cause := int2oct(128, 1); /* default value for tests */ |
| 1491 | f_pdp_ctx_act(apars, true); |
| 1492 | |
| 1493 | setverdict(pass); |
| 1494 | } |
| 1495 | /* ATTACH + trigger Recovery procedure through CreatePdpResp */ |
| 1496 | testcase TC_attach_restart_ctr_create() runs on test_CT { |
| 1497 | var BSSGP_ConnHdlr vc_conn; |
| 1498 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1499 | vc_conn := f_start_handler(refers(f_TC_attach_restart_ctr_create), testcasename(), g_gb, 24, 30.0); |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1500 | vc_conn.done; |
| 1501 | } |
| 1502 | |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1503 | /* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MT direction + trigger T3395 */ |
| 1504 | private function f_TC_attach_pdp_act_deact_mt_t3395_expire(charstring id) runs on BSSGP_ConnHdlr { |
| 1505 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1506 | var integer seq_nr := 23; |
| 1507 | var GtpPeer peer; |
| 1508 | var integer i; |
| 1509 | |
| 1510 | /* first perform regular attach */ |
| 1511 | f_TC_attach(id); |
| 1512 | /* then activate PDP context */ |
| 1513 | f_pdp_ctx_act(apars); |
| 1514 | |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1515 | BSSGP[0].clear; |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1516 | peer := valueof(ts_GtpPeerC(apars.sgsn_ip_c)); |
| 1517 | GTP.send(ts_GTPC_DeletePDP(peer, seq_nr, apars.sgsn_tei_c, apars.nsapi, '1'B)); |
| 1518 | |
| 1519 | for (i := 0; i < 5; i := i+1) { |
| 1520 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1521 | [] BSSGP[0].receive(tr_SM_DEACT_PDP_REQ_MT(apars.tid, ?, true)) {} |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1522 | [] as_xid(apars); |
| 1523 | } |
| 1524 | } |
| 1525 | |
| 1526 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, apars.ggsn_tei_c)) {} |
| 1527 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1528 | f_send_l3_gmm_llc(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid)); |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1529 | setverdict(pass); |
| 1530 | } |
| 1531 | testcase TC_attach_pdp_act_deact_mt_t3395_expire() runs on test_CT { |
| 1532 | var BSSGP_ConnHdlr vc_conn; |
| 1533 | f_init(); |
| 1534 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1535 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_deact_mt_t3395_expire), testcasename(), g_gb, 25, 60.0); |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1536 | vc_conn.done; |
| 1537 | } |
| 1538 | |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 1539 | /* ATTACH + PDP CTX ACT dropped + retrans */ |
| 1540 | private function f_TC_attach_pdp_act_deact_gtp_retrans(charstring id) runs on BSSGP_ConnHdlr { |
| 1541 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1542 | var Gtp1cUnitdata g_ud_first, g_ud_second; |
| 1543 | /* first perform regular attach */ |
| 1544 | f_TC_attach(id); |
| 1545 | |
| 1546 | /* then activate PDP context on the Gb side */ |
| 1547 | f_send_l3_gmm_llc(ts_SM_ACT_PDP_REQ(apars.tid, apars.nsapi, apars.sapi, apars.qos, apars.addr, |
| 1548 | apars.apn, apars.pco), 0); |
| 1549 | |
| 1550 | GTP.receive(tr_GTPC_MsgType(?, createPDPContextRequest, ?)) -> value g_ud_first {} |
| 1551 | log("First createPDPContextRequest received, dropping & waiting for retransmission"); |
| 1552 | GTP.receive(tr_GTPC_MsgType(?, createPDPContextRequest, ?)) -> value g_ud_second { |
| 1553 | if (g_ud_first != g_ud_second) { |
| 1554 | setverdict(fail, "Retransmitted GTP message createPDPContextRequest is different from original one!"); |
| 1555 | mtc.stop; |
| 1556 | } |
| 1557 | f_process_gtp_ctx_act_req(apars, g_ud_second.gtpc); |
| 1558 | var integer seq_nr := oct2int(g_ud_second.gtpc.opt_part.sequenceNumber); |
| 1559 | GTP.send(ts_GTPC_CreatePdpResp(g_ud_second.peer, seq_nr, |
| 1560 | apars.sgsn_tei_c, apars.gtp_resp_cause, |
| 1561 | apars.ggsn_tei_c, apars.ggsn_tei_u, |
| 1562 | apars.nsapi, |
| 1563 | apars.ggsn_ip_c, apars.ggsn_ip_u, apars.chg_id, |
| 1564 | omit, omit)); |
| 1565 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1566 | BSSGP[0].receive(tr_SM_ACT_PDP_ACCEPT) {} |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 1567 | |
| 1568 | /* Now the same with Deact */ |
| 1569 | f_send_l3_gmm_llc(ts_SM_DEACT_PDP_REQ_MO(apars.tid, '00'O, false, omit), 0); |
| 1570 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextRequest, apars.ggsn_tei_c)) -> value g_ud_first {} |
| 1571 | log("First deletePDPContextRequest received, dropping & waiting for retransmission"); |
| 1572 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextRequest, apars.ggsn_tei_c)) -> value g_ud_second { |
| 1573 | if (g_ud_first != g_ud_second) { |
| 1574 | setverdict(fail, "Retransmitted GTP message deletePDPContextRequest is different from original one!"); |
| 1575 | mtc.stop; |
| 1576 | } |
| 1577 | var integer seq_nr := oct2int(g_ud_second.gtpc.opt_part.sequenceNumber); |
| 1578 | BSSGP[0].clear; |
| 1579 | GTP.send(ts_GTPC_DeletePdpResp(g_ud_second.peer, seq_nr, apars.sgsn_tei_c, '7F'O)); |
| 1580 | } |
| 1581 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1582 | [] BSSGP[0].receive(tr_SM_DEACT_PDP_ACCEPT_MT(apars.tid)) { |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 1583 | setverdict(pass); |
| 1584 | } |
| 1585 | [] as_xid(apars, 0); |
| 1586 | } |
| 1587 | |
| 1588 | setverdict(pass); |
| 1589 | } |
| 1590 | testcase TC_attach_pdp_act_deact_gtp_retrans() runs on test_CT { |
| 1591 | var BSSGP_ConnHdlr vc_conn; |
| 1592 | f_init(); |
| 1593 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_deact_gtp_retrans), testcasename(), g_gb, 27); |
| 1594 | vc_conn.done; |
| 1595 | } |
| 1596 | |
| 1597 | /* Test that SGSN GTP response retransmit queue works fine */ |
| 1598 | private function f_TC_attach_pdp_act_deact_gtp_retrans_resp(charstring id) runs on BSSGP_ConnHdlr { |
| 1599 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1600 | var integer seq_nr := 23; |
| 1601 | var Gtp1cUnitdata g_ud_first, g_ud_second; |
| 1602 | var template Gtp1cUnitdata g_delete_req; |
| 1603 | /* first perform regular attach + PDP context act */ |
| 1604 | f_TC_attach(id); |
| 1605 | f_pdp_ctx_act(apars); |
| 1606 | |
| 1607 | /* Now perform an MT DeleteCtxReq and emulate GGSN didn't receive response and sends a duplicated DeleteCtxReq */ |
| 1608 | BSSGP[0].clear; |
| 1609 | var GtpPeer peer := valueof(ts_GtpPeerC(apars.sgsn_ip_c)); |
| 1610 | g_delete_req := ts_GTPC_DeletePDP(peer, seq_nr, apars.sgsn_tei_c, apars.nsapi, '1'B); |
| 1611 | GTP.send(g_delete_req); |
| 1612 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1613 | [] BSSGP[0].receive(tr_SM_DEACT_PDP_REQ_MT(apars.tid, ?, true)) { |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 1614 | f_send_l3_gmm_llc(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid), 0); |
| 1615 | } |
| 1616 | [] as_xid(apars, 0); |
| 1617 | } |
| 1618 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, apars.ggsn_tei_c)) -> value g_ud_first { |
| 1619 | if (g_ud_first.gtpc.gtpc_pdu.deletePDPContextResponse.cause.causevalue != '80'O) { |
| 1620 | setverdict(fail, "Received deletePDPContextResponse cause is not 'Request accepted'"); |
| 1621 | mtc.stop; |
| 1622 | } |
| 1623 | }; |
| 1624 | |
| 1625 | /* Send duplicate DeleteCtxReq */ |
| 1626 | log("First deletePDPContextResponse received, dropping & retransmitting retransmission of deletePDPContextRequest"); |
| 1627 | GTP.send(g_delete_req); |
| 1628 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, apars.ggsn_tei_c)) -> value g_ud_second { |
| 1629 | if (g_ud_first != g_ud_second) { |
| 1630 | setverdict(fail, "Retransmitted GTP message deletePDPContextResponse is different from original one!"); |
| 1631 | mtc.stop; |
| 1632 | } |
| 1633 | } |
| 1634 | |
| 1635 | /* Let's send now a new DeleteCtxReq (increased seq_nr) to make sure it |
| 1636 | * is handled differently by SGSN (expect "non-existent" cause) */ |
| 1637 | g_delete_req := ts_GTPC_DeletePDP(peer, seq_nr + 1, apars.sgsn_tei_c, apars.nsapi, '1'B); |
| 1638 | GTP.send(g_delete_req); |
| 1639 | /* Response with cause "non-existent" must be sent with TEID 0 according to specs */ |
| 1640 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, '00000000'O)) -> value g_ud_second { |
| 1641 | if (g_ud_second.gtpc.gtpc_pdu.deletePDPContextResponse.cause.causevalue != 'C0'O) { |
| 1642 | setverdict(fail, "Received deletePDPContextResponse cause is not 'Non-existent'"); |
| 1643 | mtc.stop; |
| 1644 | } |
| 1645 | } |
| 1646 | |
| 1647 | setverdict(pass); |
| 1648 | } |
| 1649 | testcase TC_attach_pdp_act_deact_gtp_retrans_resp() runs on test_CT { |
| 1650 | var BSSGP_ConnHdlr vc_conn; |
| 1651 | f_init(); |
| 1652 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_deact_gtp_retrans_resp), testcasename(), g_gb, 28); |
| 1653 | vc_conn.done; |
| 1654 | } |
| 1655 | |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1656 | private function f_TC_hlr_location_cancel_request_update(charstring id) runs on BSSGP_ConnHdlr { |
| 1657 | /* MS: perform regular attach */ |
| 1658 | f_TC_attach(id); |
| 1659 | |
| 1660 | /* HLR: cancel the location request */ |
| 1661 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_UPDATE)); |
| 1662 | GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)); |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1663 | |
| 1664 | /* ensure no Detach Request got received */ |
| 1665 | timer T := 5.0; |
| 1666 | T.start; |
| 1667 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1668 | [] BSSGP[0].receive(tr_GMM_DET_REQ_MT(*, *, *)) { |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1669 | T.stop; |
| 1670 | setverdict(fail, "Unexpected GMM Detach Request"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1671 | mtc.stop; |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1672 | } |
| 1673 | [] T.timeout { |
| 1674 | setverdict(pass); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1675 | mtc.stop; |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1676 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1677 | [] BSSGP[0].receive { |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1678 | repeat; |
| 1679 | } |
| 1680 | } |
| 1681 | } |
| 1682 | |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1683 | /* ATTACH + PDP CTX ACT + user plane traffic + ERROR IND in MT direction */ |
| 1684 | private function f_TC_attach_pdp_act_user_error_ind_ggsn(charstring id) runs on BSSGP_ConnHdlr { |
| 1685 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1686 | |
| 1687 | /* first perform regular attach */ |
| 1688 | f_TC_attach(id); |
| 1689 | /* then activate PDP context */ |
| 1690 | f_pdp_ctx_act(apars); |
| 1691 | /* then transceive a downlink PDU */ |
| 1692 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 1693 | |
| 1694 | /* Send Error indication as response from upload PDU and expect deact towards MS */ |
| 1695 | f_pdp_ctx_deact_mt(apars, true); |
| 1696 | } |
| 1697 | testcase TC_attach_pdp_act_user_error_ind_ggsn() runs on test_CT { |
| 1698 | var BSSGP_ConnHdlr vc_conn; |
| 1699 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1700 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_user_error_ind_ggsn), testcasename(), g_gb, 26); |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1701 | vc_conn.done; |
| 1702 | } |
| 1703 | |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1704 | testcase TC_hlr_location_cancel_request_update() runs on test_CT { |
| 1705 | /* MS <-> SGSN: GMM Attach |
| 1706 | * HLR -> SGSN: Cancel Location Request |
| 1707 | * HLR <- SGSN: Cancel Location Ack |
| 1708 | */ |
| 1709 | var BSSGP_ConnHdlr vc_conn; |
| 1710 | f_init(); |
| 1711 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1712 | vc_conn := f_start_handler(refers(f_TC_hlr_location_cancel_request_update), testcasename(), g_gb, 31); |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1713 | vc_conn.done; |
| 1714 | } |
| 1715 | |
| 1716 | |
Alexander Couzens | c87967a | 2018-05-22 16:09:54 +0200 | [diff] [blame] | 1717 | private function f_TC_hlr_location_cancel_request_withdraw(charstring id) runs on BSSGP_ConnHdlr { |
| 1718 | /* MS: perform regular attach */ |
| 1719 | f_TC_attach(id); |
| 1720 | |
| 1721 | /* HLR: cancel the location request */ |
| 1722 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_WITHDRAW)); |
| 1723 | GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)); |
| 1724 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1725 | |
| 1726 | /* MS: receive a Detach Request */ |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1727 | BSSGP[0].receive(tr_GMM_DET_REQ_MT(c_GMM_DTT_MT_IMSI_DETACH, ?, ?)); |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1728 | f_send_l3_gmm_llc(ts_GMM_DET_ACCEPT_MO); |
Alexander Couzens | c87967a | 2018-05-22 16:09:54 +0200 | [diff] [blame] | 1729 | |
| 1730 | setverdict(pass); |
| 1731 | } |
| 1732 | |
| 1733 | testcase TC_hlr_location_cancel_request_withdraw() runs on test_CT { |
| 1734 | /* MS <-> SGSN: GMM Attach |
| 1735 | * HLR -> SGSN: Cancel Location Request |
| 1736 | * HLR <- SGSN: Cancel Location Ack |
| 1737 | * MS <- SGSN: Detach Request |
| 1738 | * SGSN-> MS: Detach Complete |
| 1739 | */ |
| 1740 | var BSSGP_ConnHdlr vc_conn; |
| 1741 | f_init(); |
| 1742 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1743 | vc_conn := f_start_handler(refers(f_TC_hlr_location_cancel_request_withdraw), testcasename(), g_gb, 29); |
Alexander Couzens | c87967a | 2018-05-22 16:09:54 +0200 | [diff] [blame] | 1744 | vc_conn.done; |
| 1745 | } |
| 1746 | |
| 1747 | |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 1748 | private function f_hlr_location_cancel_request_unknown_subscriber( |
| 1749 | charstring id, |
| 1750 | GSUP_CancelType canceltype) runs on BSSGP_ConnHdlr { |
| 1751 | |
| 1752 | /* HLR: cancel the location request */ |
| 1753 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, canceltype)); |
| 1754 | |
| 1755 | /* cause 2 = IMSI_UNKNOWN */ |
| 1756 | GSUP.receive(tr_GSUP_CL_ERR(g_pars.imsi, 2)); |
| 1757 | |
| 1758 | setverdict(pass); |
| 1759 | } |
| 1760 | |
| 1761 | private function f_TC_hlr_location_cancel_request_unknown_subscriber_withdraw(charstring id) runs on BSSGP_ConnHdlr { |
Alexander Couzens | ace6fc6 | 2018-06-05 16:29:02 +0200 | [diff] [blame] | 1762 | f_hlr_location_cancel_request_unknown_subscriber(id, OSMO_GSUP_CANCEL_TYPE_WITHDRAW); |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 1763 | } |
| 1764 | |
| 1765 | testcase TC_hlr_location_cancel_request_unknown_subscriber_withdraw() runs on test_CT { |
| 1766 | /* HLR -> SGSN: Cancel Location Request |
| 1767 | * HLR <- SGSN: Cancel Location Error |
| 1768 | */ |
| 1769 | |
| 1770 | var BSSGP_ConnHdlr vc_conn; |
| 1771 | f_init(); |
| 1772 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1773 | vc_conn := f_start_handler(refers(f_TC_hlr_location_cancel_request_unknown_subscriber_withdraw), testcasename(), g_gb, 30); |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 1774 | vc_conn.done; |
| 1775 | } |
| 1776 | |
| 1777 | private function f_TC_hlr_location_cancel_request_unknown_subscriber_update(charstring id) runs on BSSGP_ConnHdlr { |
Alexander Couzens | ace6fc6 | 2018-06-05 16:29:02 +0200 | [diff] [blame] | 1778 | f_hlr_location_cancel_request_unknown_subscriber(id, OSMO_GSUP_CANCEL_TYPE_WITHDRAW); |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 1779 | } |
| 1780 | |
| 1781 | testcase TC_hlr_location_cancel_request_unknown_subscriber_update() runs on test_CT { |
| 1782 | /* HLR -> SGSN: Cancel Location Request |
| 1783 | * HLR <- SGSN: Cancel Location Error |
| 1784 | */ |
| 1785 | |
| 1786 | var BSSGP_ConnHdlr vc_conn; |
| 1787 | f_init(); |
| 1788 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1789 | vc_conn := f_start_handler(refers(f_TC_hlr_location_cancel_request_unknown_subscriber_update), testcasename(), g_gb, 30); |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 1790 | vc_conn.done; |
| 1791 | } |
| 1792 | |
Alexander Couzens | 49bb4b4 | 2018-06-05 16:28:36 +0200 | [diff] [blame] | 1793 | private function f_TC_attach_detach_check_subscriber_list(charstring id) runs on BSSGP_ConnHdlr { |
| 1794 | f_TC_attach(id); |
| 1795 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true); |
| 1796 | } |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 1797 | |
Alexander Couzens | 49bb4b4 | 2018-06-05 16:28:36 +0200 | [diff] [blame] | 1798 | testcase TC_attach_detach_check_subscriber_list() runs on test_CT { |
| 1799 | /* MS <-> SGSN: Attach |
| 1800 | * MS -> SGSN: Detach Req (Power off) |
| 1801 | * VTY -> SGSN: Check if MS is NOT in subscriber cache |
| 1802 | */ |
| 1803 | var BSSGP_ConnHdlr vc_conn; |
| 1804 | var integer id := 33; |
| 1805 | var charstring imsi := hex2str(f_gen_imsi(id)); |
| 1806 | |
| 1807 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1808 | vc_conn := f_start_handler(refers(f_TC_attach_detach_check_subscriber_list), testcasename(), g_gb, id); |
Alexander Couzens | 49bb4b4 | 2018-06-05 16:28:36 +0200 | [diff] [blame] | 1809 | vc_conn.done; |
| 1810 | |
| 1811 | f_vty_transceive_not_match(SGSNVTY, "show subscriber cache", pattern "* IMSI: {imsi}*"); |
| 1812 | } |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 1813 | |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1814 | /* Attempt an attach, but loose the Identification Request (IMEI) */ |
| 1815 | private function f_TC_attach_no_imei_response(charstring id) runs on BSSGP_ConnHdlr { |
| 1816 | var integer count_req := 0; |
| 1817 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 1818 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1819 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), f_random_RAI(), true, false, omit, omit)); |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1820 | |
| 1821 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1822 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1823 | /* break */ |
| 1824 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1825 | [] BSSGP[0].receive(tr_GMM_ID_REQ('001'B)) { |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1826 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1827 | f_send_l3_gmm_llc(ts_GMM_ID_RESP(mi)); |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1828 | repeat; |
| 1829 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1830 | [] BSSGP[0].receive(tr_GMM_ID_REQ('010'B)) { |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1831 | /* ignore ID REQ IMEI */ |
| 1832 | count_req := count_req + 1; |
| 1833 | repeat; |
| 1834 | } |
| 1835 | } |
| 1836 | if (count_req != 5) { |
| 1837 | setverdict(fail, "Did not received GMM ID Request Type IMEI 5 times!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1838 | mtc.stop; |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1839 | } |
| 1840 | setverdict(pass); |
| 1841 | } |
| 1842 | |
| 1843 | testcase TC_attach_no_imei_response() runs on test_CT { |
| 1844 | /* MS -> SGSN: Attach Request IMSI |
| 1845 | * MS <- SGSN: Identity Request IMSI (optional) |
| 1846 | * MS -> SGSN: Identity Response IMSI (optional) |
| 1847 | * MS <- SGSN: Identity Request IMEI |
| 1848 | * MS -x SGSN: no response |
| 1849 | * MS <- SGSN: re-send: Identity Request IMEI 4x |
| 1850 | * MS <- SGSN: Attach Reject |
| 1851 | */ |
| 1852 | var BSSGP_ConnHdlr vc_conn; |
| 1853 | f_init(); |
| 1854 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1855 | vc_conn := f_start_handler(refers(f_TC_attach_no_imei_response), testcasename(), g_gb, 32, 60.0); |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1856 | vc_conn.done; |
| 1857 | } |
| 1858 | |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1859 | /* Attempt an attach, but loose the Identification Request (IMSI) */ |
| 1860 | private function f_TC_attach_no_imsi_response(charstring id) runs on BSSGP_ConnHdlr { |
| 1861 | var integer count_req := 0; |
| 1862 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 1863 | |
| 1864 | /* set p_tmsi to use it in Attach Req via f_mi_get_lv() */ |
| 1865 | g_pars.p_tmsi := 'c0000035'O; |
| 1866 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1867 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), f_random_RAI(), true, false, omit, omit)); |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1868 | |
| 1869 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1870 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1871 | /* break */ |
| 1872 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1873 | [] BSSGP[0].receive(tr_GMM_ID_REQ('001'B)) { |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1874 | /* ignore ID REQ IMSI */ |
| 1875 | count_req := count_req + 1; |
| 1876 | repeat; |
| 1877 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1878 | [] BSSGP[0].receive(tr_GMM_ID_REQ('010'B)) { |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1879 | mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1880 | f_send_l3_gmm_llc(ts_GMM_ID_RESP(mi)); |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1881 | repeat; |
| 1882 | } |
| 1883 | } |
| 1884 | if (count_req != 5) { |
| 1885 | setverdict(fail, "Did not received GMM ID Request Type IMSI 5 times!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1886 | mtc.stop; |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1887 | } |
| 1888 | setverdict(pass); |
| 1889 | } |
| 1890 | |
| 1891 | testcase TC_attach_no_imsi_response() runs on test_CT { |
| 1892 | /* MS -> SGSN: Attach Request TMSI (unknown) |
| 1893 | * MS <- SGSN: Identity Request IMEI (optional) |
| 1894 | * MS -> SGSN: Identity Response IMEI (optional) |
| 1895 | * MS <- SGSN: Identity Request IMSI |
| 1896 | * MS -x SGSN: no response |
| 1897 | * MS <- SGSN: re-send: Identity Request IMSI 4x |
| 1898 | * MS <- SGSN: Attach Reject |
| 1899 | */ |
| 1900 | var BSSGP_ConnHdlr vc_conn; |
| 1901 | f_init(); |
| 1902 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1903 | vc_conn := f_start_handler(refers(f_TC_attach_no_imsi_response), testcasename(), g_gb, 35, 60.0); |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1904 | vc_conn.done; |
| 1905 | } |
| 1906 | |
Alexander Couzens | cf81896 | 2018-06-05 18:00:00 +0200 | [diff] [blame] | 1907 | private function f_sgsn_vty_destroy_subscriber_imsi(TELNETasp_PT pt, charstring imsi) { |
| 1908 | f_vty_transceive(pt, "update-subscriber imsi " & imsi & " destroy"); |
| 1909 | } |
| 1910 | |
| 1911 | testcase TC_attach_check_subscriber_list() runs on test_CT { |
| 1912 | /* MS <-> SGSN: Attach |
| 1913 | * VTY -> SGSN: Check if MS is in subscriber cache |
| 1914 | */ |
| 1915 | var BSSGP_ConnHdlr vc_conn; |
| 1916 | var integer id := 34; |
| 1917 | var charstring imsi := hex2str(f_gen_imsi(id)); |
| 1918 | |
| 1919 | f_init(); |
| 1920 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1921 | vc_conn := f_start_handler(refers(f_TC_attach), testcasename(), g_gb, id); |
Alexander Couzens | cf81896 | 2018-06-05 18:00:00 +0200 | [diff] [blame] | 1922 | vc_conn.done; |
| 1923 | |
| 1924 | f_vty_transceive_match(SGSNVTY, "show subscriber cache", pattern "* IMSI: {imsi}*"); |
| 1925 | f_sgsn_vty_destroy_subscriber_imsi(SGSNVTY, imsi); |
| 1926 | } |
| 1927 | |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1928 | private function f_TC_attach_closed_imsi_added(charstring id) runs on BSSGP_ConnHdlr { |
| 1929 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1930 | var PDU_L3_SGSN_MS l3_mt; |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1931 | |
| 1932 | /* unregister the old IMSI */ |
| 1933 | f_bssgp_client_unregister(g_pars.imsi); |
| 1934 | /* Simulate a foreign IMSI */ |
Alexander Couzens | 03d1224 | 2018-08-07 16:13:52 +0200 | [diff] [blame] | 1935 | g_pars.imsi := '001010123456700'H; |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1936 | f_bssgp_client_register(g_pars.imsi, g_pars.tlli, g_pars.bssgp_cell_id[0]); |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1937 | |
| 1938 | /* there is no auth */ |
| 1939 | g_pars.net.expect_auth := false; |
| 1940 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1941 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit)); |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1942 | f_gmm_auth(); |
| 1943 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1944 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1945 | setverdict(fail, "Received unexpected GMM Attach REJECT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1946 | mtc.stop; |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1947 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 1948 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT(*, *, *)) -> value l3_mt { |
| 1949 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1950 | f_send_l3_gmm_llc(ts_GMM_ATTACH_COMPL); |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1951 | setverdict(pass); |
| 1952 | } |
| 1953 | } |
| 1954 | } |
Alexander Couzens | 03d1224 | 2018-08-07 16:13:52 +0200 | [diff] [blame] | 1955 | |
| 1956 | private function f_TC_attach_closed_add_vty(charstring id) runs on BSSGP_ConnHdlr { |
| 1957 | |
| 1958 | f_TC_attach_closed_foreign(id); |
| 1959 | f_TC_attach_closed_imsi_added(id); |
| 1960 | |
| 1961 | } |
| 1962 | |
| 1963 | |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1964 | testcase TC_attach_closed_add_vty() runs on test_CT { |
| 1965 | /* VTY-> SGSN: policy close |
| 1966 | * MS -> SGSN: Attach Request |
| 1967 | * MS <- SGSN: Identity Request IMSI |
| 1968 | * MS -> SGSN: Identity Response IMSI |
| 1969 | * MS <- SGSN: Attach Reject |
| 1970 | * VTY-> SGSN: policy imsi-acl add IMSI |
| 1971 | * MS -> SGSN: Attach Request |
| 1972 | * MS <- SGSN: Identity Request IMSI |
| 1973 | * MS -> SGSN: Identity Response IMSI |
| 1974 | * MS <- SGSN: Identity Request IMEI |
| 1975 | * MS -> SGSN: Identity Response IMEI |
| 1976 | * MS <- SGSN: Attach Accept |
| 1977 | */ |
| 1978 | var BSSGP_ConnHdlr vc_conn; |
| 1979 | f_init(); |
| 1980 | f_sleep(1.0); |
| 1981 | f_vty_config(SGSNVTY, "sgsn", "auth-policy closed"); |
| 1982 | f_vty_config(SGSNVTY, "sgsn", "imsi-acl del 001010123456789"); |
Alexander Couzens | 03d1224 | 2018-08-07 16:13:52 +0200 | [diff] [blame] | 1983 | f_vty_config(SGSNVTY, "sgsn", "imsi-acl del 001010123456700"); |
| 1984 | f_vty_config(SGSNVTY, "sgsn", "imsi-acl add 001010123456700"); |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1985 | /* test with foreign IMSI: Must Reject */ |
Alexander Couzens | 03d1224 | 2018-08-07 16:13:52 +0200 | [diff] [blame] | 1986 | vc_conn := f_start_handler(refers(f_TC_attach_closed_add_vty), testcasename(), g_gb, 9); |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1987 | vc_conn.done; |
| 1988 | } |
| 1989 | |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 1990 | /* Attempt an attach, but never answer a Attach Complete */ |
| 1991 | private function f_TC_attach_check_complete_resend(charstring id) runs on BSSGP_ConnHdlr { |
| 1992 | var integer count_req := 0; |
| 1993 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 1994 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), f_random_RAI(), true, false, omit, omit)); |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 1995 | f_gmm_auth(); |
| 1996 | |
Alexander Couzens | fa0a75f | 2018-08-07 15:45:04 +0200 | [diff] [blame] | 1997 | timer T := 10.0; |
| 1998 | T.start; |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 1999 | alt { |
Alexander Couzens | fa0a75f | 2018-08-07 15:45:04 +0200 | [diff] [blame] | 2000 | [] T.timeout { |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2001 | /* break */ |
| 2002 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2003 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT(*, *, *)) { |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2004 | /* ignore */ |
| 2005 | count_req := count_req + 1; |
Alexander Couzens | fa0a75f | 2018-08-07 15:45:04 +0200 | [diff] [blame] | 2006 | T.start; |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2007 | repeat; |
| 2008 | } |
| 2009 | } |
| 2010 | if (count_req != 5) { |
| 2011 | setverdict(fail, "Did not received GMM Attach Complete."); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2012 | mtc.stop; |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2013 | } |
| 2014 | setverdict(pass); |
| 2015 | } |
| 2016 | |
| 2017 | testcase TC_attach_check_complete_resend() runs on test_CT { |
| 2018 | /* MS -> SGSN: Attach Request IMSI |
| 2019 | * MS <- SGSN: Identity Request * |
| 2020 | * MS -> SGSN: Identity Response * |
| 2021 | * MS <- SGSN: Attach Complete 5x |
| 2022 | */ |
| 2023 | var BSSGP_ConnHdlr vc_conn; |
| 2024 | f_init(); |
| 2025 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2026 | vc_conn := f_start_handler(refers(f_TC_attach_check_complete_resend), testcasename(), g_gb, 36, 60.0); |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2027 | vc_conn.done; |
| 2028 | } |
| 2029 | |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 2030 | private function f_routing_area_update(RoutingAreaIdentificationV ra, integer bssgp := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2031 | var PDU_L3_SGSN_MS l3_mt; |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 2032 | |
| 2033 | /* then send RAU */ |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 2034 | f_send_l3_gmm_llc(ts_GMM_RAU_REQ(f_mi_get_lv(), GPRS_UPD_T_RA, g_pars.ra, false, omit, omit), bssgp); |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 2035 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2036 | [] BSSGP[bssgp].receive(tr_GMM_RAU_ACCEPT) -> value l3_mt { |
| 2037 | f_process_rau_accept(l3_mt.msgs.gprs_mm.routingAreaUpdateAccept, bssgp); |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 2038 | f_send_l3_gmm_llc(ts_GMM_RAU_COMPL, bssgp); |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 2039 | setverdict(pass); |
| 2040 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2041 | [] BSSGP[bssgp].receive(tr_GMM_RAU_REJECT) { |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 2042 | setverdict(fail, "Unexpected RAU Reject"); |
| 2043 | mtc.stop; |
| 2044 | } |
| 2045 | [] BSSGP[bssgp].receive { repeat; } |
| 2046 | } |
| 2047 | } |
| 2048 | |
Alexander Couzens | bfda921 | 2018-07-31 03:17:33 +0200 | [diff] [blame] | 2049 | private function f_TC_attach_rau_a_a(charstring id) runs on BSSGP_ConnHdlr { |
Alexander Couzens | bfda921 | 2018-07-31 03:17:33 +0200 | [diff] [blame] | 2050 | /* first perform regular attach */ |
| 2051 | f_TC_attach(id); |
| 2052 | |
| 2053 | /* then send RAU */ |
| 2054 | f_routing_area_update(g_pars.ra); |
| 2055 | |
| 2056 | /* do another RAU */ |
| 2057 | f_routing_area_update(g_pars.ra); |
| 2058 | |
| 2059 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true); |
| 2060 | } |
| 2061 | |
| 2062 | testcase TC_attach_rau_a_a() runs on test_CT { |
| 2063 | /* MS <-> SGSN: Successful Attach |
| 2064 | * MS -> SGSN: Routing Area Update Request |
| 2065 | * MS <- SGSN: Routing Area Update Accept |
| 2066 | * MS -> SGSN: Routing Area Update Request |
| 2067 | * MS <- SGSN: Routing Area Update Accept |
| 2068 | * MS -> SGSN: Detach (PowerOff) |
| 2069 | */ |
| 2070 | var BSSGP_ConnHdlr vc_conn; |
| 2071 | f_init(); |
| 2072 | f_sleep(1.0); |
| 2073 | vc_conn := f_start_handler(refers(f_TC_attach_rau_a_a), testcasename(), g_gb, 37); |
| 2074 | vc_conn.done; |
| 2075 | } |
| 2076 | |
Alexander Couzens | be837bd | 2018-07-31 04:20:11 +0200 | [diff] [blame] | 2077 | private function f_TC_attach_rau_a_b(charstring id) runs on BSSGP_ConnHdlr { |
Alexander Couzens | be837bd | 2018-07-31 04:20:11 +0200 | [diff] [blame] | 2078 | f_TC_attach(id); |
| 2079 | |
| 2080 | log("attach complete sending rau"); |
| 2081 | f_routing_area_update(g_pars.ra, 0); |
| 2082 | |
| 2083 | log("rau complete unregistering"); |
| 2084 | f_bssgp_client_unregister(g_pars.imsi); |
| 2085 | f_bssgp_client_register(g_pars.imsi, g_pars.tlli, g_pars.bssgp_cell_id[1], BSSGP_PROC[1]); |
| 2086 | |
| 2087 | log("sending second RAU via different RA"); |
| 2088 | f_routing_area_update(f_cellid_to_RAI(g_pars.bssgp_cell_id[1]), 1); |
| 2089 | |
| 2090 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true, 1); |
| 2091 | } |
| 2092 | |
| 2093 | testcase TC_attach_rau_a_b() runs on test_CT { |
| 2094 | /* MS <-> SGSN: Successful Attach |
| 2095 | * MS -> SGSN: Routing Area _a_ Update Request |
| 2096 | * MS <- SGSN: Routing Area _a_ Update Accept |
| 2097 | * MS -> SGSN: Routing Area _b_ Update Request |
| 2098 | * MS <- SGSN: Routing Area _b_ Update Accept |
| 2099 | * MS -> SGSN: Detach (PowerOff) |
| 2100 | */ |
| 2101 | var BSSGP_ConnHdlr vc_conn; |
| 2102 | f_init(); |
| 2103 | f_sleep(1.0); |
| 2104 | vc_conn := f_start_handler(refers(f_TC_attach_rau_a_b), testcasename(), g_gb, 38); |
| 2105 | vc_conn.done; |
| 2106 | } |
| 2107 | |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2108 | private function f_TC_attach_gmm_attach_req_while_gmm_attach(charstring id) runs on BSSGP_ConnHdlr { |
| 2109 | var integer count_req := 0; |
| 2110 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 2111 | var RoutingAreaIdentificationV rand_rai := f_random_RAI(); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2112 | var PDU_L3_SGSN_MS l3_mt; |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2113 | |
| 2114 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), rand_rai, true, false, omit, omit)); |
| 2115 | |
| 2116 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2117 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2118 | setverdict(fail, "Unexpected GMM ATTACH REJECT"); |
| 2119 | mtc.stop; |
| 2120 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2121 | [] BSSGP[0].receive(tr_GMM_ID_REQ('001'B)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2122 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 2123 | f_send_l3_gmm_llc(ts_GMM_ID_RESP(mi)); |
| 2124 | repeat; |
| 2125 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2126 | [] BSSGP[0].receive(tr_GMM_ID_REQ('010'B)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2127 | /* send out a second GMM_Attach Request. |
| 2128 | * If the SGSN follows the rules, this 2nd ATTACH REQ should be ignored, because |
| 2129 | * of the same content */ |
| 2130 | f_send_l3_gmm_llc(ts_GMM_ATTACH_REQ(f_mi_get_lv(), rand_rai, true, false, omit, omit)); |
| 2131 | mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
| 2132 | f_send_l3_gmm_llc(ts_GMM_ID_RESP(mi)); |
| 2133 | } |
| 2134 | } |
| 2135 | f_sleep(1.0); |
| 2136 | |
| 2137 | /* we've sent already a IMEI answer, we should NOT asked again for IMEI */ |
| 2138 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2139 | [] BSSGP[0].receive(tr_GMM_ID_REQ('001'B)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2140 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 2141 | f_send_l3_gmm_llc(ts_GMM_ID_RESP(mi)); |
| 2142 | repeat; |
| 2143 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2144 | [] BSSGP[0].receive(tr_GMM_ID_REQ('010'B)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2145 | setverdict(fail, "Unexpected GMM ID REQ (IMEI)."); |
| 2146 | mtc.stop; |
| 2147 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2148 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2149 | setverdict(fail, "Unexpected GMM ATTACH REJECT"); |
| 2150 | mtc.stop; |
| 2151 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2152 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 2153 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2154 | f_send_l3_gmm_llc(ts_GMM_ATTACH_COMPL); |
| 2155 | setverdict(pass); |
| 2156 | /* FIXME: Extract P-TMSI, if any. Only send Complete if necessary */ |
| 2157 | } |
| 2158 | } |
| 2159 | } |
| 2160 | |
| 2161 | testcase TC_attach_gmm_attach_req_while_gmm_attach() runs on test_CT { |
| 2162 | /* Testing if the SGSN ignore Attach Request with the exact same content */ |
| 2163 | /* MS -> SGSN: Attach Request IMSI |
| 2164 | * MS <- SGSN: Identity Request IMSI (optional) |
| 2165 | * MS -> SGSN: Identity Response IMSI (optional) |
| 2166 | * MS <- SGSN: Identity Request IMEI |
| 2167 | * MS -> SGSN: Attach Request (2nd) |
| 2168 | * MS <- SGSN: Identity Response IMEI |
| 2169 | * MS <- SGSN: Attach Accept |
| 2170 | * MS -> SGSN: Attach Complete |
| 2171 | */ |
| 2172 | var BSSGP_ConnHdlr vc_conn; |
| 2173 | f_init(); |
| 2174 | f_sleep(1.0); |
| 2175 | f_vty_config(SGSNVTY, "sgsn", "auth-policy accept-all"); |
| 2176 | vc_conn := f_start_handler(refers(f_TC_attach_gmm_attach_req_while_gmm_attach), testcasename(), g_gb, 39); |
| 2177 | vc_conn.done; |
| 2178 | } |
| 2179 | |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2180 | private function f_TC_attach_usim_resync(charstring id) runs on BSSGP_ConnHdlr { |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2181 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 2182 | |
| 2183 | var template PDU_L3_MS_SGSN attach_req := ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit); |
| 2184 | |
| 2185 | /* send Attach Request */ |
| 2186 | /* indicate R99 capability of the MS to enable UMTS AKA in presence of |
| 2187 | * 3G auth vectors */ |
| 2188 | attach_req.msgs.gprs_mm.attachRequest.msNetworkCapability.msNetworkCapabilityV.revisionLevelIndicatior := '1'B; |
| 2189 | /* The thing is, if the solSACapability is 'omit', then the |
| 2190 | * revisionLevelIndicatior is at the wrong place! */ |
| 2191 | attach_req.msgs.gprs_mm.attachRequest.msNetworkCapability.msNetworkCapabilityV.solSACapability := '0'B; |
| 2192 | f_send_l3_gmm_llc(attach_req); |
| 2193 | |
| 2194 | /* do the auth */ |
| 2195 | var PDU_L3_MS_SGSN l3_mo; |
| 2196 | var PDU_L3_SGSN_MS l3_mt; |
| 2197 | var default di := activate(as_mm_identity()); |
| 2198 | |
| 2199 | var GSUP_IE auth_tuple; |
| 2200 | var template AuthenticationParameterAUTNTLV autn; |
| 2201 | |
| 2202 | g_pars.vec := f_gen_auth_vec_3g(); |
| 2203 | autn := { |
| 2204 | elementIdentifier := '28'O, |
| 2205 | lengthIndicator := lengthof(g_pars.vec.autn), |
| 2206 | autnValue := g_pars.vec.autn |
| 2207 | }; |
| 2208 | auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 2209 | g_pars.vec.sres, |
| 2210 | g_pars.vec.kc, |
| 2211 | g_pars.vec.ik, |
| 2212 | g_pars.vec.ck, |
| 2213 | g_pars.vec.autn, |
| 2214 | g_pars.vec.res)); |
| 2215 | log("GSUP sends 2G and 3G auth tuples", auth_tuple); |
| 2216 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 2217 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 2218 | |
| 2219 | var template PDU_L3_SGSN_MS auth_ciph_req := tr_GMM_AUTH_REQ(g_pars.vec.rand); |
| 2220 | auth_ciph_req.msgs.gprs_mm.authenticationAndCipheringRequest.authenticationParameterAUTN := autn; |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2221 | BSSGP[0].receive(auth_ciph_req) -> value l3_mt; |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2222 | |
| 2223 | /* send the gmm auth failure with resync IE */ |
| 2224 | f_send_l3_gmm_llc(ts_GMM_AUTH_FAIL_UMTS_AKA_RESYNC(g_pars.vec.auts)); |
| 2225 | |
| 2226 | /* wait for the GSUP resync request */ |
| 2227 | GSUP.receive(tr_GSUP_SAI_REQ_UMTS_AKA_RESYNC( |
| 2228 | g_pars.imsi, |
| 2229 | g_pars.vec.auts, |
| 2230 | g_pars.vec.rand)); |
| 2231 | |
| 2232 | /* generate new key material */ |
| 2233 | g_pars.vec := f_gen_auth_vec_3g(); |
| 2234 | autn := { |
| 2235 | elementIdentifier := '28'O, |
| 2236 | lengthIndicator := lengthof(g_pars.vec.autn), |
| 2237 | autnValue := g_pars.vec.autn |
| 2238 | }; |
| 2239 | |
| 2240 | auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 2241 | g_pars.vec.sres, |
| 2242 | g_pars.vec.kc, |
| 2243 | g_pars.vec.ik, |
| 2244 | g_pars.vec.ck, |
| 2245 | g_pars.vec.autn, |
| 2246 | g_pars.vec.res)); |
| 2247 | /* send new key material */ |
| 2248 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 2249 | |
| 2250 | /* wait for the new Auth Request */ |
| 2251 | auth_ciph_req := tr_GMM_AUTH_REQ(g_pars.vec.rand); |
| 2252 | auth_ciph_req.msgs.gprs_mm.authenticationAndCipheringRequest.authenticationParameterAUTN := autn; |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2253 | BSSGP[0].receive(auth_ciph_req) -> value l3_mt; |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2254 | var BIT4 ac_ref := l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.acReferenceNumber.valueField; |
| 2255 | var template PDU_L3_MS_SGSN auth_ciph_resp := ts_GMM_AUTH_RESP_2G(ac_ref, g_pars.vec.sres); |
| 2256 | auth_ciph_resp := ts_GMM_AUTH_RESP_2G(ac_ref, g_pars.vec.sres); |
| 2257 | auth_ciph_resp.msgs.gprs_mm.authenticationAndCipheringResponse.authenticationParResp := { |
| 2258 | valueField := substr(g_pars.vec.res, 0, 4) |
| 2259 | }; |
| 2260 | auth_ciph_resp.msgs.gprs_mm.authenticationAndCipheringResponse.authenticationRespParExt := { |
| 2261 | elementIdentifier := '21'O, |
| 2262 | lengthIndicator := lengthof(g_pars.vec.res) - 4, |
| 2263 | valueField := substr(g_pars.vec.res, 4, lengthof(g_pars.vec.res) - 4) |
| 2264 | }; |
| 2265 | l3_mo := valueof(auth_ciph_resp); |
| 2266 | if (ispresent(l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.imeisvRequest) and |
| 2267 | l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.imeisvRequest.valueField == '001'B) { |
| 2268 | l3_mo.msgs.gprs_mm.authenticationAndCipheringResponse.imeisv := |
| 2269 | valueof(ts_MI_IMEISV_TLV(g_pars.imei & '0'H)); |
| 2270 | } |
| 2271 | f_send_l3_gmm_llc(l3_mo); |
| 2272 | deactivate(di); |
| 2273 | |
| 2274 | /* Expect SGSN to perform LU with HLR */ |
| 2275 | f_gmm_gsup_lu_isd(); |
| 2276 | |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2277 | BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 2278 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2279 | } |
| 2280 | f_send_l3_gmm_llc(ts_GMM_ATTACH_COMPL); |
| 2281 | setverdict(pass); |
| 2282 | } |
| 2283 | |
| 2284 | testcase TC_attach_usim_resync() runs on test_CT { |
| 2285 | /* MS -> SGSN: Attach Request |
| 2286 | * MS <- SGSN: Identity Request IMSI |
| 2287 | * MS -> SGSN: Identity Response IMSI |
| 2288 | * MS <- SGSN: Identity Request IMEI |
| 2289 | * MS -> SGSN: Identity Response IMEI |
| 2290 | * HLR<- SGSN: SAI Request |
| 2291 | * HLR-> SGSN: SAI Response |
| 2292 | * MS <- SGSN: Auth Request |
| 2293 | * MS -> SGSN: Auth Failure (with AUTS) |
| 2294 | * HLR<- SGSN: SAI Request (with AUTS & RAND) |
| 2295 | * HLR-> SGSN: SAI Response (new key material) |
| 2296 | * MS <- SGSN: Auth Request (new key material) |
| 2297 | * MS -> SGSN: Auth Response |
| 2298 | * MS <- SGSN: Attach Accept |
| 2299 | * MS -> SGSN: Attach Complete |
| 2300 | */ |
| 2301 | var BSSGP_ConnHdlr vc_conn; |
| 2302 | f_init(); |
| 2303 | f_sleep(1.0); |
| 2304 | vc_conn := f_start_handler(refers(f_TC_attach_usim_resync), testcasename(), g_gb, 40); |
| 2305 | vc_conn.done; |
| 2306 | } |
| 2307 | |
Harald Welte | a05b807 | 2019-04-23 22:35:05 +0200 | [diff] [blame] | 2308 | |
| 2309 | /* Send LLC NULL to see if the SGSN survives it (OS#3952) */ |
| 2310 | private function f_TC_llc_null(charstring id) runs on BSSGP_ConnHdlr { |
| 2311 | f_gmm_attach(false, false); |
| 2312 | f_sleep(1.0); |
| 2313 | f_send_llc(ts_LLC_NULL('0'B, c_LLC_SAPI_LLGMM, LLC_CR_UL_CMD)); |
| 2314 | /* try to detach to check if SGSN is still alive */ |
| 2315 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true); |
| 2316 | } |
| 2317 | testcase TC_llc_null() runs on test_CT { |
| 2318 | var BSSGP_ConnHdlr vc_conn; |
| 2319 | f_init(); |
| 2320 | f_sleep(1.0); |
| 2321 | vc_conn := f_start_handler(refers(f_TC_llc_null), testcasename(), g_gb, 41); |
| 2322 | vc_conn.done; |
| 2323 | } |
| 2324 | |
Harald Welte | 645a151 | 2019-04-23 23:18:23 +0200 | [diff] [blame] | 2325 | /* Send LLC SABM to see if the SGSN rejects it properly with DM */ |
| 2326 | private function f_TC_llc_sabm_dm_llgmm(charstring id) runs on BSSGP_ConnHdlr { |
| 2327 | f_gmm_attach(false, false); |
| 2328 | f_sleep(1.0); |
| 2329 | f_send_llc(ts_LLC_SABM({}, '1'B, c_LLC_SAPI_LLGMM, LLC_CR_UL_CMD)); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2330 | BSSGP[0].receive(tr_LLC_DM(?, c_LLC_SAPI_LLGMM, LLC_CR_DL_RSP)); |
Harald Welte | 645a151 | 2019-04-23 23:18:23 +0200 | [diff] [blame] | 2331 | setverdict(pass); |
| 2332 | } |
| 2333 | testcase TC_llc_sabm_dm_llgmm() runs on test_CT { |
| 2334 | var BSSGP_ConnHdlr vc_conn; |
| 2335 | f_init(); |
| 2336 | f_sleep(1.0); |
| 2337 | vc_conn := f_start_handler(refers(f_TC_llc_sabm_dm_llgmm), testcasename(), g_gb, 42); |
| 2338 | vc_conn.done; |
| 2339 | } |
| 2340 | |
| 2341 | /* Send LLC SABM to see if the SGSN rejects it properly with DM */ |
| 2342 | private function f_TC_llc_sabm_dm_ll5(charstring id) runs on BSSGP_ConnHdlr { |
| 2343 | f_gmm_attach(false, false); |
| 2344 | f_sleep(1.0); |
| 2345 | f_send_llc(ts_LLC_SABM({}, '1'B, c_LLC_SAPI_LL5, LLC_CR_UL_CMD)); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2346 | BSSGP[0].receive(tr_LLC_DM(?, c_LLC_SAPI_LL5, LLC_CR_DL_RSP)); |
Harald Welte | 645a151 | 2019-04-23 23:18:23 +0200 | [diff] [blame] | 2347 | setverdict(pass); |
| 2348 | } |
| 2349 | testcase TC_llc_sabm_dm_ll5() runs on test_CT { |
| 2350 | var BSSGP_ConnHdlr vc_conn; |
| 2351 | f_init(); |
| 2352 | f_sleep(1.0); |
| 2353 | vc_conn := f_start_handler(refers(f_TC_llc_sabm_dm_ll5), testcasename(), g_gb, 43); |
| 2354 | vc_conn.done; |
| 2355 | } |
| 2356 | |
Harald Welte | 2aaac1b | 2019-05-02 10:02:53 +0200 | [diff] [blame] | 2357 | /* test XID handshake with empty L3 info: expect empty return (some phones require that, OS#3426 */ |
| 2358 | private function f_TC_xid_empty_l3(charstring id) runs on BSSGP_ConnHdlr { |
| 2359 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 2360 | var template (value) XID_Information xid; |
| 2361 | var template XID_Information xid_rx; |
| 2362 | |
| 2363 | /* first perform regular attach */ |
| 2364 | f_TC_attach(id); |
| 2365 | /* then activate PDP context */ |
| 2366 | f_pdp_ctx_act(apars); |
| 2367 | |
| 2368 | /* start MO XID */ |
| 2369 | xid := { ts_XID_L3(''O) }; |
| 2370 | xid_rx := { tr_XID_L3(''O) }; |
| 2371 | f_send_llc(ts_LLC_XID_MO_CMD(xid, apars.sapi)); |
| 2372 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2373 | [] BSSGP[0].receive(tr_LLC_XID(xid_rx, apars.sapi)); |
Harald Welte | 2aaac1b | 2019-05-02 10:02:53 +0200 | [diff] [blame] | 2374 | [] as_xid(apars); |
| 2375 | } |
| 2376 | setverdict(pass); |
| 2377 | } |
| 2378 | testcase TC_xid_empty_l3() runs on test_CT { |
| 2379 | var BSSGP_ConnHdlr vc_conn; |
| 2380 | f_init(); |
| 2381 | f_sleep(1.0); |
| 2382 | vc_conn := f_start_handler(refers(f_TC_xid_empty_l3), testcasename(), g_gb, 44); |
| 2383 | vc_conn.done; |
| 2384 | } |
| 2385 | |
| 2386 | private function f_TC_xid_n201u(charstring id) runs on BSSGP_ConnHdlr { |
| 2387 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 2388 | var template (value) XID_Information xid; |
| 2389 | var template XID_Information xid_rx; |
| 2390 | |
| 2391 | /* first perform regular attach */ |
| 2392 | f_TC_attach(id); |
| 2393 | /* then activate PDP context */ |
| 2394 | f_pdp_ctx_act(apars); |
| 2395 | |
| 2396 | /* start MO XID */ |
| 2397 | xid := { ts_XID_N201U(1234) }; |
| 2398 | xid_rx := { tr_XID_N201U(1234) }; |
| 2399 | f_send_llc(ts_LLC_XID_MO_CMD(xid, apars.sapi)); |
| 2400 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame^] | 2401 | [] BSSGP[0].receive(tr_LLC_XID_MT_RSP(xid_rx, apars.sapi)); |
Harald Welte | 2aaac1b | 2019-05-02 10:02:53 +0200 | [diff] [blame] | 2402 | [] as_xid(apars); |
| 2403 | } |
| 2404 | setverdict(pass); |
| 2405 | } |
| 2406 | testcase TC_xid_n201u() runs on test_CT { |
| 2407 | var BSSGP_ConnHdlr vc_conn; |
| 2408 | f_init(); |
| 2409 | f_sleep(1.0); |
| 2410 | vc_conn := f_start_handler(refers(f_TC_xid_n201u), testcasename(), g_gb, 45); |
| 2411 | vc_conn.done; |
| 2412 | } |
| 2413 | |
Alexander Couzens | 6bee087 | 2019-05-11 01:48:50 +0200 | [diff] [blame] | 2414 | private function f_TC_attach_pdp_act_gmm_detach(charstring id) runs on BSSGP_ConnHdlr { |
| 2415 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 2416 | |
| 2417 | /* first perform regular attach */ |
| 2418 | f_TC_attach(id); |
| 2419 | /* then activate PDP context */ |
| 2420 | f_pdp_ctx_act(apars); |
| 2421 | /* do a normal detach */ |
| 2422 | f_detach_mo(c_GMM_DTT_MO_GPRS, false, true); |
| 2423 | } |
| 2424 | |
| 2425 | testcase TC_attach_pdp_act_gmm_detach() runs on test_CT { |
| 2426 | /* MS -> SGSN: Attach Request |
| 2427 | * MS <-> SGSN: [..] |
| 2428 | * MS -> SGSN: Attach Complete |
| 2429 | * MS -> SGSN: PDP Activate Request |
| 2430 | * MS <- SGSN: PDP Activate Accept |
| 2431 | * MS -> SGSN: GMM Detach Request |
| 2432 | * MS <- SGSN: GMM Detach Accept |
| 2433 | */ |
| 2434 | var BSSGP_ConnHdlr vc_conn; |
| 2435 | f_init(); |
| 2436 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_gmm_detach), testcasename(), g_gb, 26); |
| 2437 | vc_conn.done; |
| 2438 | } |
Harald Welte | 645a151 | 2019-04-23 23:18:23 +0200 | [diff] [blame] | 2439 | |
| 2440 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 2441 | control { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 2442 | execute( TC_attach() ); |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 2443 | execute( TC_attach_mnc3() ); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 2444 | execute( TC_attach_umts_aka_umts_res() ); |
| 2445 | execute( TC_attach_umts_aka_gsm_sres() ); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 2446 | execute( TC_attach_auth_id_timeout() ); |
| 2447 | execute( TC_attach_auth_sai_timeout() ); |
Harald Welte | fe25388 | 2018-02-17 09:25:00 +0100 | [diff] [blame] | 2448 | execute( TC_attach_auth_sai_reject() ); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 2449 | execute( TC_attach_gsup_lu_timeout() ); |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 2450 | execute( TC_attach_gsup_lu_reject() ); |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 2451 | execute( TC_attach_combined() ); |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 2452 | execute( TC_attach_accept_all() ); |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 2453 | execute( TC_attach_closed() ); |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 2454 | execute( TC_attach_no_imei_response() ); |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 2455 | execute( TC_attach_no_imsi_response() ); |
Alexander Couzens | d81876a | 2018-08-07 12:43:16 +0200 | [diff] [blame] | 2456 | execute( TC_attach_closed_add_vty(), 20.0 ); |
| 2457 | execute( TC_attach_check_subscriber_list(), 20.0 ); |
| 2458 | execute( TC_attach_detach_check_subscriber_list(), 20.0 ); |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2459 | execute( TC_attach_check_complete_resend() ); |
Alexander Couzens | d81876a | 2018-08-07 12:43:16 +0200 | [diff] [blame] | 2460 | execute( TC_hlr_location_cancel_request_update(), 20.0 ); |
| 2461 | execute( TC_hlr_location_cancel_request_withdraw(), 20.0 ); |
| 2462 | execute( TC_hlr_location_cancel_request_unknown_subscriber_withdraw(), 20.0 ); |
| 2463 | execute( TC_hlr_location_cancel_request_unknown_subscriber_update(), 20.0 ); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 2464 | execute( TC_rau_unknown() ); |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 2465 | execute( TC_attach_rau() ); |
Alexander Couzens | bfda921 | 2018-07-31 03:17:33 +0200 | [diff] [blame] | 2466 | execute( TC_attach_rau_a_a() ); |
Alexander Couzens | be837bd | 2018-07-31 04:20:11 +0200 | [diff] [blame] | 2467 | execute( TC_attach_rau_a_b() ); |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2468 | execute( TC_attach_usim_resync() ); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 2469 | execute( TC_detach_unknown_nopoweroff() ); |
| 2470 | execute( TC_detach_unknown_poweroff() ); |
| 2471 | execute( TC_detach_nopoweroff() ); |
| 2472 | execute( TC_detach_poweroff() ); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 2473 | execute( TC_attach_pdp_act() ); |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 2474 | execute( TC_pdp_act_unattached() ); |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 2475 | execute( TC_attach_pdp_act_user() ); |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 2476 | execute( TC_attach_pdp_act_ggsn_reject() ); |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 2477 | execute( TC_attach_pdp_act_user_deact_mo() ); |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 2478 | execute( TC_attach_pdp_act_user_deact_mt() ); |
Alexander Couzens | 187ad5d | 2018-05-02 19:31:10 +0200 | [diff] [blame] | 2479 | execute( TC_attach_second_attempt() ); |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 2480 | execute( TC_attach_restart_ctr_echo() ); |
| 2481 | execute( TC_attach_restart_ctr_create() ); |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 2482 | execute( TC_attach_pdp_act_deact_mt_t3395_expire() ); |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 2483 | execute( TC_attach_pdp_act_deact_gtp_retrans() ); |
| 2484 | execute( TC_attach_pdp_act_deact_gtp_retrans_resp() ); |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 2485 | execute( TC_attach_pdp_act_user_error_ind_ggsn() ); |
Alexander Couzens | 6bee087 | 2019-05-11 01:48:50 +0200 | [diff] [blame] | 2486 | execute( TC_attach_pdp_act_gmm_detach() ); |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2487 | execute( TC_attach_gmm_attach_req_while_gmm_attach() ); |
Harald Welte | a05b807 | 2019-04-23 22:35:05 +0200 | [diff] [blame] | 2488 | |
Harald Welte | 2aaac1b | 2019-05-02 10:02:53 +0200 | [diff] [blame] | 2489 | execute( TC_xid_empty_l3() ); |
| 2490 | execute( TC_xid_n201u() ); |
| 2491 | |
Harald Welte | a05b807 | 2019-04-23 22:35:05 +0200 | [diff] [blame] | 2492 | execute( TC_llc_null() ); |
Harald Welte | 645a151 | 2019-04-23 23:18:23 +0200 | [diff] [blame] | 2493 | execute( TC_llc_sabm_dm_llgmm() ); |
| 2494 | execute( TC_llc_sabm_dm_ll5() ); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 2495 | } |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 2496 | |
| 2497 | |
| 2498 | |
| 2499 | } |