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