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