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