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