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