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