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