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