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; |
| 15 | |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 16 | import from General_Types all; |
| 17 | import from Osmocom_Types all; |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 18 | import from Native_Functions all; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 19 | import from NS_Types all; |
| 20 | import from NS_Emulation all; |
| 21 | import from BSSGP_Types all; |
| 22 | import from BSSGP_Emulation all; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 23 | import from Osmocom_Gb_Types all; |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 24 | import from SCCPasp_Types all; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 25 | |
| 26 | import from MobileL3_CommonIE_Types all; |
| 27 | import from MobileL3_GMM_SM_Types all; |
| 28 | import from MobileL3_Types all; |
| 29 | import from L3_Templates all; |
| 30 | import from L3_Common all; |
| 31 | |
| 32 | import from GSUP_Emulation all; |
| 33 | import from GSUP_Types all; |
| 34 | import from IPA_Emulation all; |
| 35 | |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 36 | import from RAN_Adapter all; |
| 37 | import from RAN_Emulation all; |
| 38 | import from RANAP_Templates all; |
| 39 | import from RANAP_PDU_Descriptions all; |
| 40 | import from RANAP_IEs all; |
| 41 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 42 | import from GTP_Emulation all; |
| 43 | import from GTP_Templates all; |
| 44 | import from GTP_CodecPort all; |
| 45 | import from GTPC_Types all; |
| 46 | import from GTPU_Types all; |
| 47 | |
Harald Welte | a2526a8 | 2018-02-18 19:03:36 +0100 | [diff] [blame] | 48 | import from LLC_Types all; |
| 49 | import from LLC_Templates all; |
| 50 | |
| 51 | import from SNDCP_Types all; |
| 52 | |
Harald Welte | bd19472 | 2018-02-16 22:11:08 +0100 | [diff] [blame] | 53 | import from TELNETasp_PortType all; |
| 54 | import from Osmocom_VTY_Functions all; |
| 55 | |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 56 | import from GSM_RR_Types all; |
| 57 | |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 58 | import from MobileL3_MM_Types all; |
| 59 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 60 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 61 | modulepar { |
| 62 | /* IP/port on which we run our internal GSUP/HLR emulation */ |
| 63 | charstring mp_hlr_ip := "127.0.0.1"; |
| 64 | integer mp_hlr_port := 4222; |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 65 | charstring mp_ggsn_ip := "127.0.0.2"; |
Pau Espin Pedrol | fcec914 | 2019-08-28 17:33:46 +0200 | [diff] [blame] | 66 | integer mp_echo_interval := 5; /* in seconds. Only used in test enabling g_use_echo */ |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 67 | |
Alexander Couzens | f3c1b41 | 2018-08-24 00:42:51 +0200 | [diff] [blame] | 68 | NSConfigurations mp_nsconfig := { |
| 69 | { |
| 70 | local_udp_port := 21010, |
| 71 | local_ip := "127.0.0.1", |
| 72 | remote_udp_port := 23000, |
| 73 | remote_ip := "127.0.0.1", |
| 74 | nsvci := 97, |
Harald Welte | 5e514fa | 2018-07-05 00:01:45 +0200 | [diff] [blame] | 75 | nsei := 96, |
| 76 | role_sgsn := false, |
| 77 | handle_sns := false |
Alexander Couzens | f3c1b41 | 2018-08-24 00:42:51 +0200 | [diff] [blame] | 78 | }, |
| 79 | { |
| 80 | local_udp_port := 21011, |
| 81 | local_ip := "127.0.0.1", |
| 82 | remote_udp_port := 23000, |
| 83 | remote_ip := "127.0.0.1", |
| 84 | nsvci := 98, |
Harald Welte | 5e514fa | 2018-07-05 00:01:45 +0200 | [diff] [blame] | 85 | nsei := 97, |
| 86 | role_sgsn := false, |
| 87 | handle_sns := false |
Alexander Couzens | f3c1b41 | 2018-08-24 00:42:51 +0200 | [diff] [blame] | 88 | }, |
| 89 | { |
| 90 | local_udp_port := 21012, |
| 91 | local_ip := "127.0.0.1", |
| 92 | remote_udp_port := 23000, |
| 93 | remote_ip := "127.0.0.1", |
| 94 | nsvci := 99, |
Harald Welte | 5e514fa | 2018-07-05 00:01:45 +0200 | [diff] [blame] | 95 | nsei := 98, |
| 96 | role_sgsn := false, |
| 97 | handle_sns := false |
Alexander Couzens | f3c1b41 | 2018-08-24 00:42:51 +0200 | [diff] [blame] | 98 | } |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 99 | }; |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 100 | |
| 101 | RAN_Configurations mp_ranap_cfg := { |
| 102 | { |
| 103 | transport := RANAP_TRANSPORT_IuCS, |
| 104 | sccp_service_type := "mtp3_itu", |
| 105 | sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" }, |
| 106 | own_pc := 195, |
| 107 | own_ssn := 142, |
| 108 | peer_pc := 188, /* 0.23.4 */ |
| 109 | peer_ssn := 142, |
| 110 | sio := '83'O, |
| 111 | rctx := 2 |
| 112 | } |
| 113 | } |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | type record GbInstance { |
| 117 | NS_CT vc_NS, |
| 118 | BSSGP_CT vc_BSSGP, |
| 119 | BssgpConfig cfg |
| 120 | }; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 121 | |
Harald Welte | 2fa771f | 2019-05-02 20:13:53 +0200 | [diff] [blame] | 122 | const integer NUM_GB := 3; |
| 123 | type record length(NUM_GB) of GbInstance GbInstances; |
| 124 | type record length(NUM_GB) of NSConfiguration NSConfigurations; |
| 125 | type record length(NUM_GB) of BssgpCellId BssgpCellIds; |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 126 | |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 127 | const integer NUM_RNC := 1; |
| 128 | type record of RAN_Configuration RAN_Configurations; |
| 129 | |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 130 | type component test_CT { |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 131 | var GbInstances g_gb; |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 132 | var RAN_Adapter g_ranap[NUM_RNC]; |
Alexander Couzens | 1552e79 | 2019-07-23 20:38:39 +0200 | [diff] [blame] | 133 | var boolean g_ranap_enable := false; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 134 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 135 | var GSUP_Emulation_CT vc_GSUP; |
| 136 | var IPA_Emulation_CT vc_GSUP_IPA; |
| 137 | /* only to get events from IPA underneath GSUP */ |
| 138 | port IPA_CTRL_PT GSUP_IPA_EVENT; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 139 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 140 | var GTP_Emulation_CT vc_GTP; |
| 141 | |
Harald Welte | bd19472 | 2018-02-16 22:11:08 +0100 | [diff] [blame] | 142 | port TELNETasp_PT SGSNVTY; |
| 143 | |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 144 | var boolean g_initialized := false; |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 145 | var boolean g_use_echo := false; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 146 | }; |
| 147 | |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 148 | 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] | 149 | var BSSGP_ConnHdlrPars g_pars; |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 150 | timer g_Tguard; |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 151 | var LLC_Entities llc; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | type record SGSN_ConnHdlrNetworkPars { |
| 155 | boolean expect_ptmsi, |
| 156 | boolean expect_auth, |
| 157 | boolean expect_ciph |
| 158 | }; |
| 159 | |
| 160 | type record BSSGP_ConnHdlrPars { |
| 161 | /* IMEI of the simulated ME */ |
| 162 | hexstring imei, |
Alexander Couzens | 8f0fb00 | 2018-05-02 19:30:55 +0200 | [diff] [blame] | 163 | /* IMSI of the simulated MS */ |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 164 | hexstring imsi, |
| 165 | /* MSISDN of the simulated MS (probably unused) */ |
| 166 | hexstring msisdn, |
| 167 | /* P-TMSI allocated to the simulated MS */ |
| 168 | OCT4 p_tmsi optional, |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 169 | OCT3 p_tmsi_sig optional, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 170 | /* TLLI of the simulated MS */ |
| 171 | OCT4 tlli, |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 172 | OCT4 tlli_old optional, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 173 | RoutingAreaIdentificationV ra optional, |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 174 | BssgpCellIds bssgp_cell_id, |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 175 | /* Tracks the RNC state. If true next L3 message will be sent with InitiualUe */ |
| 176 | boolean rnc_send_initial_ue, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 177 | AuthVector vec optional, |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 178 | SGSN_ConnHdlrNetworkPars net, |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 179 | float t_guard, |
| 180 | /* only in IuPS / RANAP case */ |
Alexander Couzens | 1552e79 | 2019-07-23 20:38:39 +0200 | [diff] [blame] | 181 | SCCP_PAR_Address sccp_addr_local optional, |
| 182 | SCCP_PAR_Address sccp_addr_peer optional |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 183 | }; |
| 184 | |
Alexander Couzens | 8950870 | 2018-07-31 04:16:10 +0200 | [diff] [blame] | 185 | private function f_cellid_to_RAI(in BssgpCellId cell_id) return RoutingAreaIdentificationV { |
Alexander Couzens | c7dddbd | 2019-04-11 19:18:35 +0200 | [diff] [blame] | 186 | /* mcc_mnc is encoded as of 24.008 10.5.5.15 */ |
Alexander Couzens | 8950870 | 2018-07-31 04:16:10 +0200 | [diff] [blame] | 187 | var BcdMccMnc mcc_mnc := cell_id.ra_id.lai.mcc_mnc; |
| 188 | |
| 189 | var RoutingAreaIdentificationV ret := { |
| 190 | mccDigit1 := mcc_mnc[0], |
| 191 | mccDigit2 := mcc_mnc[1], |
| 192 | mccDigit3 := mcc_mnc[2], |
Alexander Couzens | c7dddbd | 2019-04-11 19:18:35 +0200 | [diff] [blame] | 193 | mncDigit3 := mcc_mnc[3], |
| 194 | mncDigit1 := mcc_mnc[4], |
| 195 | mncDigit2 := mcc_mnc[5], |
Alexander Couzens | 8950870 | 2018-07-31 04:16:10 +0200 | [diff] [blame] | 196 | lac := int2oct(cell_id.ra_id.lai.lac, 16), |
| 197 | rac := int2oct(cell_id.ra_id.rac, 8) |
| 198 | } |
| 199 | return ret; |
| 200 | }; |
| 201 | |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 202 | private function f_init_gb(inout GbInstance gb, charstring id, integer offset) runs on test_CT { |
| 203 | gb.vc_NS := NS_CT.create(id & "-NS" & int2str(offset)); |
| 204 | gb.vc_BSSGP := BSSGP_CT.create(id & "-BSSGP" & int2str(offset)); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 205 | /* connect lower end of BSSGP emulation with NS upper port */ |
| 206 | connect(gb.vc_BSSGP:BSCP, gb.vc_NS:NS_SP); |
| 207 | /* connect lower end of NS emulation to NS codec port (on top of IPL4) */ |
| 208 | map(gb.vc_NS:NSCP, system:NS_CODEC_PORT); |
| 209 | |
Alexander Couzens | f3c1b41 | 2018-08-24 00:42:51 +0200 | [diff] [blame] | 210 | gb.vc_NS.start(NSStart(mp_nsconfig[offset])); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 211 | gb.vc_BSSGP.start(BssgpStart(gb.cfg)); |
| 212 | } |
| 213 | |
| 214 | private function f_init_gsup(charstring id) runs on test_CT { |
| 215 | id := id & "-GSUP"; |
| 216 | var GsupOps ops := { |
| 217 | create_cb := refers(GSUP_Emulation.ExpectedCreateCallback) |
| 218 | }; |
| 219 | |
| 220 | vc_GSUP_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 221 | vc_GSUP := GSUP_Emulation_CT.create(id); |
| 222 | |
| 223 | map(vc_GSUP_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 224 | connect(vc_GSUP:GSUP, vc_GSUP_IPA:IPA_GSUP_PORT); |
| 225 | /* we use this hack to get events like ASP_IPA_EVENT_UP */ |
| 226 | connect(vc_GSUP_IPA:IPA_CTRL_PORT, self:GSUP_IPA_EVENT); |
| 227 | |
| 228 | vc_GSUP.start(GSUP_Emulation.main(ops, id)); |
| 229 | vc_GSUP_IPA.start(IPA_Emulation.main_server(mp_hlr_ip, mp_hlr_port)); |
| 230 | |
| 231 | /* wait for incoming connection to GSUP port before proceeding */ |
| 232 | timer T := 10.0; |
| 233 | T.start; |
| 234 | alt { |
| 235 | [] GSUP_IPA_EVENT.receive(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_UP)) { } |
| 236 | [] T.timeout { |
| 237 | setverdict(fail, "No connection to GSUP Port"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 238 | mtc.stop; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 243 | private function f_init_gtp(charstring id) runs on test_CT { |
| 244 | id := id & "-GTP"; |
| 245 | |
| 246 | var GtpEmulationCfg gtp_cfg := { |
| 247 | gtpc_bind_ip := mp_ggsn_ip, |
| 248 | gtpc_bind_port := GTP1C_PORT, |
| 249 | gtpu_bind_ip := mp_ggsn_ip, |
| 250 | gtpu_bind_port := GTP1U_PORT, |
| 251 | sgsn_role := false |
| 252 | }; |
| 253 | |
| 254 | vc_GTP := GTP_Emulation_CT.create(id); |
| 255 | vc_GTP.start(GTP_Emulation.main(gtp_cfg)); |
| 256 | } |
| 257 | |
Harald Welte | bd19472 | 2018-02-16 22:11:08 +0100 | [diff] [blame] | 258 | private function f_init_vty() runs on test_CT { |
| 259 | map(self:SGSNVTY, system:SGSNVTY); |
| 260 | f_vty_set_prompts(SGSNVTY); |
| 261 | f_vty_transceive(SGSNVTY, "enable"); |
Alexander Couzens | 1d1744f | 2018-08-07 11:56:14 +0200 | [diff] [blame] | 262 | f_vty_transceive(SGSNVTY, "reset sgsn state"); |
Harald Welte | bd19472 | 2018-02-16 22:11:08 +0100 | [diff] [blame] | 263 | f_vty_config(SGSNVTY, "sgsn", "auth-policy remote"); |
| 264 | } |
| 265 | |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 266 | private function f_vty_enable_echo_interval(boolean enable) runs on test_CT { |
| 267 | if (enable) { |
Pau Espin Pedrol | fcec914 | 2019-08-28 17:33:46 +0200 | [diff] [blame] | 268 | 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] | 269 | } else { |
| 270 | f_vty_config(SGSNVTY, "sgsn", "ggsn 0 no echo-interval"); |
| 271 | } |
| 272 | } |
| 273 | |
Harald Welte | bd19472 | 2018-02-16 22:11:08 +0100 | [diff] [blame] | 274 | |
Alexander Couzens | c7dddbd | 2019-04-11 19:18:35 +0200 | [diff] [blame] | 275 | /* mcc_mnc is 24.008 10.5.5.15 encoded. 262 42 */ |
| 276 | function f_init(BcdMccMnc mcc_mnc := '262F42'H) runs on test_CT { |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 277 | var integer i; |
| 278 | |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 279 | if (g_initialized == true) { |
| 280 | return; |
| 281 | } |
| 282 | g_initialized := true; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 283 | g_gb[0].cfg := { |
| 284 | nsei := 96, |
| 285 | bvci := 196, |
| 286 | cell_id := { |
| 287 | ra_id := { |
| 288 | lai := { |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 289 | mcc_mnc := mcc_mnc, lac := 13135}, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 290 | rac := 0 |
| 291 | }, |
| 292 | cell_id := 20960 |
| 293 | }, |
Oliver Smith | aac9b9c | 2019-09-02 08:36:36 +0200 | [diff] [blame] | 294 | sgsn_role := false, |
| 295 | depth := BSSGP_DECODE_DEPTH_L3 |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 296 | }; |
Alexander Couzens | 5e2ba75 | 2018-07-03 15:13:07 +0200 | [diff] [blame] | 297 | g_gb[1].cfg := { |
| 298 | nsei := 97, |
| 299 | bvci := 210, |
| 300 | cell_id := { |
| 301 | ra_id := { |
| 302 | lai := { |
| 303 | mcc_mnc := mcc_mnc, lac := 13200}, |
| 304 | rac := 0 |
| 305 | }, |
| 306 | cell_id := 20961 |
| 307 | }, |
Oliver Smith | aac9b9c | 2019-09-02 08:36:36 +0200 | [diff] [blame] | 308 | sgsn_role := false, |
| 309 | depth := BSSGP_DECODE_DEPTH_L3 |
Alexander Couzens | 5e2ba75 | 2018-07-03 15:13:07 +0200 | [diff] [blame] | 310 | }; |
| 311 | g_gb[2].cfg := { |
| 312 | nsei := 98, |
| 313 | bvci := 220, |
| 314 | cell_id := { |
| 315 | ra_id := { |
| 316 | lai := { |
| 317 | mcc_mnc := mcc_mnc, lac := 13300}, |
| 318 | rac := 0 |
| 319 | }, |
| 320 | cell_id := 20962 |
| 321 | }, |
Oliver Smith | aac9b9c | 2019-09-02 08:36:36 +0200 | [diff] [blame] | 322 | sgsn_role := false, |
| 323 | depth := BSSGP_DECODE_DEPTH_L3 |
Alexander Couzens | 5e2ba75 | 2018-07-03 15:13:07 +0200 | [diff] [blame] | 324 | }; |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 325 | |
Alexander Couzens | 1d1744f | 2018-08-07 11:56:14 +0200 | [diff] [blame] | 326 | f_init_vty(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 327 | f_init_gb(g_gb[0], "SGSN_Test-Gb0", 0); |
| 328 | f_init_gb(g_gb[1], "SGSN_Test-Gb1", 1); |
| 329 | f_init_gb(g_gb[2], "SGSN_Test-Gb2", 2); |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 330 | |
Alexander Couzens | 1552e79 | 2019-07-23 20:38:39 +0200 | [diff] [blame] | 331 | if (g_ranap_enable) { |
| 332 | for (i := 0; i < NUM_RNC; i := i+1) { |
| 333 | f_ran_adapter_init(g_ranap[i], mp_ranap_cfg[i], "SGSN_Test_" & int2str(i), RNC_RanOps); |
| 334 | f_ran_adapter_start(g_ranap[i]); |
| 335 | } |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 336 | } |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 337 | f_init_gsup("SGSN_Test"); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 338 | f_init_gtp("SGSN_Test"); |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 339 | f_vty_enable_echo_interval(g_use_echo); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 340 | } |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 341 | |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 342 | function f_cleanup() runs on test_CT { |
| 343 | var integer i; |
Alexander Couzens | 1552e79 | 2019-07-23 20:38:39 +0200 | [diff] [blame] | 344 | if (g_ranap_enable) { |
| 345 | for (i := 0; i < NUM_RNC; i := i+1) { |
| 346 | f_ran_adapter_cleanup(g_ranap[i]); |
| 347 | } |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 348 | } |
| 349 | self.stop; |
| 350 | } |
| 351 | |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 352 | private function RncUnitdataCallback(RANAP_PDU ranap) |
| 353 | runs on RAN_Emulation_CT return template RANAP_PDU { |
| 354 | var template RANAP_PDU resp := omit; |
| 355 | |
| 356 | log ("RANAP_RncUnitDataCallback"); |
| 357 | /* answer all RESET with RESET ACK */ |
| 358 | if (match(ranap, tr_RANAP_Reset)) { |
| 359 | log("RANAP_RncUnitdataCallback: Responding to RESET with RESET-ACK"); |
| 360 | var CN_DomainIndicator dom; |
| 361 | dom := ranap.initiatingMessage.value_.Reset.protocolIEs[1].value_.cN_DomainIndicator; |
| 362 | resp := ts_RANAP_ResetAck(dom); |
| 363 | } |
| 364 | return resp; |
| 365 | } |
| 366 | |
| 367 | const RanOps RNC_RanOps := { |
| 368 | ranap_create_cb := refers(RAN_Emulation.RanapExpectedCreateCallback), |
| 369 | ranap_unitdata_cb := refers(RncUnitdataCallback), |
| 370 | ps_domain := true, |
| 371 | decode_dtap := true, |
| 372 | role_ms := true, |
| 373 | protocol := RAN_PROTOCOL_RANAP, |
| 374 | transport := RANAP_TRANSPORT_IuCS, |
| 375 | use_osmux := false, |
| 376 | sccp_addr_local := omit, |
| 377 | sccp_addr_peer := omit |
| 378 | }; |
| 379 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 380 | type function void_fn(charstring id) runs on BSSGP_ConnHdlr; |
| 381 | |
| 382 | /* helper function to create, connect and start a BSSGP_ConnHdlr component */ |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 383 | function f_start_handler(void_fn fn, charstring id, GbInstances gb, integer imsi_suffix, |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 384 | float t_guard := 30.0) |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 385 | runs on test_CT return BSSGP_ConnHdlr { |
| 386 | var BSSGP_ConnHdlr vc_conn; |
| 387 | var SGSN_ConnHdlrNetworkPars net_pars := { |
| 388 | expect_ptmsi := true, |
| 389 | expect_auth := true, |
| 390 | expect_ciph := false |
| 391 | }; |
| 392 | var BSSGP_ConnHdlrPars pars := { |
| 393 | imei := f_gen_imei(imsi_suffix), |
| 394 | imsi := f_gen_imsi(imsi_suffix), |
| 395 | msisdn := f_gen_msisdn(imsi_suffix), |
| 396 | p_tmsi := omit, |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 397 | p_tmsi_sig := omit, |
Harald Welte | 14a0f94 | 2018-02-16 20:42:23 +0100 | [diff] [blame] | 398 | tlli := f_gprs_tlli_random(), |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 399 | tlli_old := omit, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 400 | ra := omit, |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 401 | bssgp_cell_id := { gb[0].cfg.cell_id, gb[1].cfg.cell_id, gb[2].cfg.cell_id }, |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 402 | rnc_send_initial_ue := true, |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 403 | vec := omit, |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 404 | net := net_pars, |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 405 | t_guard := t_guard, |
Alexander Couzens | 1552e79 | 2019-07-23 20:38:39 +0200 | [diff] [blame] | 406 | sccp_addr_local := omit, |
| 407 | sccp_addr_peer := omit |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 408 | }; |
| 409 | |
Alexander Couzens | 1552e79 | 2019-07-23 20:38:39 +0200 | [diff] [blame] | 410 | if (g_ranap_enable) { |
| 411 | pars.sccp_addr_local := g_ranap[0].sccp_addr_own; |
| 412 | pars.sccp_addr_peer := g_ranap[0].sccp_addr_peer; |
| 413 | } |
| 414 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 415 | vc_conn := BSSGP_ConnHdlr.create(id); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 416 | connect(vc_conn:BSSGP[0], gb[0].vc_BSSGP:BSSGP_SP); |
| 417 | connect(vc_conn:BSSGP_PROC[0], gb[0].vc_BSSGP:BSSGP_PROC); |
| 418 | connect(vc_conn:BSSGP[1], gb[1].vc_BSSGP:BSSGP_SP); |
| 419 | connect(vc_conn:BSSGP_PROC[1], gb[1].vc_BSSGP:BSSGP_PROC); |
| 420 | connect(vc_conn:BSSGP[2], gb[2].vc_BSSGP:BSSGP_SP); |
| 421 | connect(vc_conn:BSSGP_PROC[2], gb[2].vc_BSSGP:BSSGP_PROC); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 422 | |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 423 | /* FIXME: support multiple RNCs */ |
Alexander Couzens | 1552e79 | 2019-07-23 20:38:39 +0200 | [diff] [blame] | 424 | if (g_ranap_enable) { |
| 425 | connect(vc_conn:BSSAP, g_ranap[0].vc_RAN:CLIENT); |
| 426 | connect(vc_conn:BSSAP_PROC, g_ranap[0].vc_RAN:PROC); |
| 427 | } |
Harald Welte | 26fbb6e | 2019-04-14 17:32:46 +0200 | [diff] [blame] | 428 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 429 | connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT); |
| 430 | connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC); |
| 431 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 432 | connect(vc_conn:GTP, vc_GTP:CLIENT); |
| 433 | connect(vc_conn:GTP_PROC, vc_GTP:CLIENT_PROC); |
| 434 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 435 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 436 | return vc_conn; |
| 437 | } |
| 438 | |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 439 | private altstep as_Tguard() runs on BSSGP_ConnHdlr { |
| 440 | [] g_Tguard.timeout { |
| 441 | setverdict(fail, "Tguard timeout"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 442 | mtc.stop; |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 443 | } |
| 444 | } |
| 445 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 446 | /* first function called in every ConnHdlr */ |
| 447 | private function f_handler_init(void_fn fn, charstring id, BSSGP_ConnHdlrPars pars) |
| 448 | runs on BSSGP_ConnHdlr { |
| 449 | /* do some common stuff like setting up g_pars */ |
| 450 | g_pars := pars; |
| 451 | |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 452 | llc := f_llc_create(false); |
| 453 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 454 | /* register with BSSGP core */ |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 455 | f_bssgp_client_register(g_pars.imsi, g_pars.tlli, g_pars.bssgp_cell_id[0]); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 456 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 457 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 458 | /* tell GTP dispatcher to send this IMSI to us */ |
| 459 | f_gtp_register_imsi(g_pars.imsi); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 460 | |
Harald Welte | 62e2958 | 2018-02-16 21:17:11 +0100 | [diff] [blame] | 461 | g_Tguard.start(pars.t_guard); |
| 462 | activate(as_Tguard()); |
| 463 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 464 | /* call the user-supplied test case function */ |
| 465 | fn.apply(id); |
| 466 | f_bssgp_client_unregister(g_pars.imsi); |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | /* TODO: |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 470 | * Detach without Attach |
| 471 | * SM procedures without attach / RAU |
| 472 | * ATTACH / RAU |
| 473 | ** with / without authentication |
| 474 | ** with / without P-TMSI allocation |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 475 | * re-transmissions of LLC frames |
| 476 | * PDP Context activation |
| 477 | ** with different GGSN config in SGSN VTY |
| 478 | ** with different PDP context type (v4/v6/v46) |
| 479 | ** timeout from GGSN |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 480 | ** multiple / secondary PDP context |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 481 | */ |
| 482 | |
| 483 | testcase TC_wait_ns_up() runs on test_CT { |
| 484 | f_init(); |
| 485 | f_sleep(20.0); |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 486 | f_cleanup(); |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 487 | } |
| 488 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 489 | friend function is_gb(integer gb_idx) return boolean { |
| 490 | return gb_idx < NUM_GB; |
| 491 | } |
| 492 | friend function is_iu(integer gb_idx) return boolean { |
| 493 | return gb_idx >= NUM_GB; |
| 494 | } |
| 495 | |
Harald Welte | a05b807 | 2019-04-23 22:35:05 +0200 | [diff] [blame] | 496 | function f_send_llc(template (value) PDU_LLC llc_pdu, integer gb_index := 0) runs on BSSGP_ConnHdlr { |
| 497 | var octetstring llc_enc := enc_PDU_LLC(valueof(llc_pdu)); |
| 498 | BSSGP[gb_index].send(ts_BSSGP_UL_UD(g_pars.tlli, g_pars.bssgp_cell_id[gb_index], llc_enc)); |
| 499 | } |
| 500 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 501 | private function f_send_l3_gmm_llc(template (value) PDU_L3_MS_SGSN l3_mo, integer gb_index := 0) runs on BSSGP_ConnHdlr { |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 502 | var octetstring l3_enc := enc_PDU_L3_MS_SGSN(valueof(l3_mo)); |
| 503 | var BIT4 sapi := f_llc_sapi_by_l3_mo(valueof(l3_mo)); |
| 504 | var integer n_u := f_llc_get_n_u_tx(llc[bit2int(sapi)]); |
Alexander Couzens | ad35222 | 2019-05-11 02:06:04 +0200 | [diff] [blame] | 505 | f_send_llc(ts_LLC_UI(l3_enc, sapi, '0'B, n_u), gb_index); |
Alexander Couzens | cdfb751 | 2018-07-31 15:37:14 +0200 | [diff] [blame] | 506 | } |
| 507 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 508 | /* trigger sending of a RANAP InitialUE and wait for SCCP connection confirmation */ |
| 509 | function f_send_l3_initial_ue(template (value) PDU_L3_MS_SGSN l3_mo) runs on BSSGP_ConnHdlr { |
| 510 | log("Sending InitialUE: ", l3_mo); |
| 511 | var octetstring l3_enc := enc_PDU_L3_MS_SGSN(valueof(l3_mo)); |
| 512 | var RANAP_PDU ranap; |
| 513 | var LAI lai := { |
| 514 | pLMNidentity := '62F224'O, |
| 515 | lAC := '1234'O, |
| 516 | iE_Extensions := omit |
| 517 | }; |
| 518 | var SAI sai := { |
| 519 | pLMNidentity := lai.pLMNidentity, |
| 520 | lAC := lai.lAC, |
| 521 | sAC := '0000'O, /* FIXME */ |
| 522 | iE_Extensions := omit |
| 523 | }; |
| 524 | var IuSignallingConnectionIdentifier sigc_id := int2bit(23, 24); /* FIXME */ |
| 525 | var GlobalRNC_ID grnc_id := { |
| 526 | pLMNidentity := lai.pLMNidentity, |
| 527 | rNC_ID := 2342 /* FIXME */ |
| 528 | }; |
| 529 | |
| 530 | ranap := valueof(ts_RANAP_initialUE_CS(lai, sai, l3_enc, sigc_id, grnc_id)); |
| 531 | BSSAP.send(ts_RANAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_local, ranap)); |
| 532 | alt { |
| 533 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) {} |
| 534 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) { |
| 535 | setverdict(fail, "DISC.ind from SCCP"); |
| 536 | mtc.stop; |
| 537 | } |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | /* send a L3 (GMM/SM) message over whatever is the appropriate lower-layer bearer */ |
| 542 | function f_send_l3(template (value) PDU_L3_MS_SGSN l3_mo, integer gb_index := 0) runs on BSSGP_ConnHdlr { |
| 543 | if (is_iu(gb_index)) { |
| 544 | if (g_pars.rnc_send_initial_ue) { |
| 545 | g_pars.rnc_send_initial_ue := false; |
| 546 | f_send_l3_initial_ue(l3_mo); |
| 547 | } else { |
| 548 | BSSAP.send(ts_PDU_DTAP_PS_MO(l3_mo)); |
| 549 | } |
| 550 | } else { |
| 551 | f_send_l3_gmm_llc(l3_mo, gb_index); |
| 552 | } |
| 553 | } |
| 554 | |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 555 | altstep as_mm_identity(integer gb_idx := 0) runs on BSSGP_ConnHdlr { |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 556 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 557 | [is_gb(gb_idx)] BSSGP[gb_idx].receive(tr_GMM_ID_REQ('001'B)) { |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 558 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 559 | f_send_l3(ts_GMM_ID_RESP(mi), gb_idx); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 560 | repeat; |
| 561 | } |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 562 | [is_iu(gb_idx)] BSSAP.receive(tr_PDU_DTAP_PS_MT(tr_GMM_ID_REQ('001'B))) { |
| 563 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 564 | f_send_l3(ts_GMM_ID_RESP(mi), gb_idx); |
| 565 | repeat; |
| 566 | } |
| 567 | [is_gb(gb_idx)] BSSGP[gb_idx].receive(tr_GMM_ID_REQ('010'B)) { |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 568 | mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 569 | f_send_l3(ts_GMM_ID_RESP(mi), gb_idx); |
| 570 | repeat; |
| 571 | } |
| 572 | [is_iu(gb_idx)] BSSAP.receive(tr_PDU_DTAP_PS_MT(tr_GMM_ID_REQ('010'B))) { |
| 573 | mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
| 574 | f_send_l3(ts_GMM_ID_RESP(mi), gb_idx); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 575 | repeat; |
| 576 | } |
| 577 | } |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 578 | |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 579 | /* receive a L3 (GMM/SM) message over whatever is the appropriate lower-layer bearer */ |
| 580 | function f_receive_l3(template PDU_L3_SGSN_MS rx_tpl := ?, integer gb_idx := 0) |
| 581 | runs on BSSGP_ConnHdlr return PDU_L3_SGSN_MS { |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 582 | var PDU_DTAP_PS_MT mt; |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 583 | var PDU_L3_SGSN_MS l3_mt; |
| 584 | alt { |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 585 | [is_gb(gb_idx)] BSSGP[gb_idx].receive(rx_tpl) -> value l3_mt { } |
| 586 | [is_iu(gb_idx)] BSSAP.receive(tr_PDU_DTAP_PS_MT(rx_tpl)) -> value mt { |
| 587 | l3_mt := mt.dtap; |
| 588 | } |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 589 | } |
| 590 | return l3_mt; |
| 591 | } |
| 592 | |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 593 | /* perform GMM authentication (if expected). |
| 594 | * Note, for umts_aka_challenge to work, the revisionLevelIndicatior needs to |
| 595 | * be 1 to mark R99 capability, in the GMM Attach Request, see f_gmm_attach(). */ |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 596 | function f_gmm_auth (boolean umts_aka_challenge := false, boolean force_gsm_sres := false, integer gb_idx := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 597 | var PDU_L3_MS_SGSN l3_mo; |
| 598 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 599 | var default di := activate(as_mm_identity(gb_idx)); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 600 | if (g_pars.net.expect_auth) { |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 601 | var GSUP_IE auth_tuple; |
| 602 | var template AuthenticationParameterAUTNTLV autn; |
| 603 | |
| 604 | if (umts_aka_challenge) { |
| 605 | g_pars.vec := f_gen_auth_vec_3g(); |
| 606 | autn := { |
| 607 | elementIdentifier := '28'O, |
| 608 | lengthIndicator := lengthof(g_pars.vec.autn), |
| 609 | autnValue := g_pars.vec.autn |
| 610 | }; |
| 611 | |
| 612 | auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 613 | g_pars.vec.sres, |
| 614 | g_pars.vec.kc, |
| 615 | g_pars.vec.ik, |
| 616 | g_pars.vec.ck, |
| 617 | g_pars.vec.autn, |
| 618 | g_pars.vec.res)); |
| 619 | log("GSUP sends 2G and 3G auth tuples", auth_tuple); |
| 620 | } else { |
| 621 | g_pars.vec := f_gen_auth_vec_2g(); |
| 622 | autn := omit; |
| 623 | auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(g_pars.vec.rand, |
| 624 | g_pars.vec.sres, |
| 625 | g_pars.vec.kc)); |
| 626 | log("GSUP sends only 2G auth tuple", auth_tuple); |
| 627 | } |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 628 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 629 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 630 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 631 | |
| 632 | var template PDU_L3_SGSN_MS auth_ciph_req := tr_GMM_AUTH_REQ(g_pars.vec.rand); |
| 633 | auth_ciph_req.msgs.gprs_mm.authenticationAndCipheringRequest.authenticationParameterAUTN := autn; |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 634 | l3_mt := f_receive_l3(auth_ciph_req, gb_idx); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 635 | var BIT4 ac_ref := l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.acReferenceNumber.valueField; |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 636 | var template PDU_L3_MS_SGSN auth_ciph_resp := ts_GMM_AUTH_RESP_2G(ac_ref, g_pars.vec.sres); |
| 637 | |
| 638 | if (umts_aka_challenge and not force_gsm_sres) { |
| 639 | /* set UMTS response instead */ |
| 640 | auth_ciph_resp.msgs.gprs_mm.authenticationAndCipheringResponse.authenticationParResp := { |
| 641 | valueField := substr(g_pars.vec.res, 0, 4) |
| 642 | }; |
| 643 | auth_ciph_resp.msgs.gprs_mm.authenticationAndCipheringResponse.authenticationRespParExt := { |
| 644 | elementIdentifier := '21'O, |
| 645 | lengthIndicator := lengthof(g_pars.vec.res) - 4, |
| 646 | valueField := substr(g_pars.vec.res, 4, lengthof(g_pars.vec.res) - 4) |
| 647 | }; |
| 648 | } |
| 649 | |
| 650 | l3_mo := valueof(auth_ciph_resp); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 651 | if (ispresent(l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.imeisvRequest) and |
| 652 | l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.imeisvRequest.valueField == '001'B) { |
| 653 | l3_mo.msgs.gprs_mm.authenticationAndCipheringResponse.imeisv := |
| 654 | valueof(ts_MI_IMEISV_TLV(g_pars.imei & '0'H)); |
| 655 | } |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 656 | f_send_l3(l3_mo, gb_idx); |
| 657 | |
| 658 | /* Security Mode Command + Complete on Iu case */ |
| 659 | if (is_iu(gb_idx)) { |
| 660 | BSSAP.receive(tr_RANAP_SecurityModeCmd(uia_algs := ?, uia_key := oct2bit(g_pars.vec.ik), |
| 661 | key_sts := ?)) { |
| 662 | var IntegrityProtectionAlgorithm uia_chosen := 0; /* 0 = standard_UMTS_integrity_algorithm_UIA1 */ |
| 663 | BSSAP.send(ts_RANAP_SecurityModeComplete(uia_chosen)); |
| 664 | } |
| 665 | } |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 666 | } else { |
| 667 | /* wait for identity procedure */ |
| 668 | f_sleep(1.0); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 669 | } |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 670 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 671 | deactivate(di); |
| 672 | } |
| 673 | |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 674 | function f_upd_ptmsi_and_tlli(OCT4 p_tmsi, integer bssgp_index := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 675 | g_pars.p_tmsi := p_tmsi; |
| 676 | /* update TLLI */ |
| 677 | g_pars.tlli_old := g_pars.tlli; |
| 678 | g_pars.tlli := g_pars.p_tmsi or4b 'c0000000'O; |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 679 | f_bssgp_client_llgmm_assign(g_pars.tlli_old, g_pars.tlli, BSSGP_PROC[bssgp_index]); |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 680 | } |
| 681 | |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 682 | function f_process_attach_accept(PDU_GMM_AttachAccept aa) runs on BSSGP_ConnHdlr { |
| 683 | /* mandatory IE */ |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 684 | var hexstring aa_plmn := f_RAI_to_plmn_hexstr(aa.routingAreaIdentification); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 685 | 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] | 686 | setverdict(fail, "mismatching PLMN in Attach Accept: " & hex2str(aa_plmn) |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 687 | & "; expected " & hex2str(g_pars.bssgp_cell_id[0].ra_id.lai.mcc_mnc)); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 688 | mtc.stop; |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 689 | } |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 690 | g_pars.ra := aa.routingAreaIdentification; |
| 691 | if (ispresent(aa.allocatedPTMSI)) { |
| 692 | if (not g_pars.net.expect_ptmsi) { |
| 693 | setverdict(fail, "unexpected P-TMSI allocation"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 694 | mtc.stop; |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 695 | } |
Harald Welte | f70997d | 2018-02-17 10:11:19 +0100 | [diff] [blame] | 696 | f_upd_ptmsi_and_tlli(aa.allocatedPTMSI.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi.octets); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 697 | } |
| 698 | if (ispresent(aa.msIdentity)) { |
| 699 | setverdict(fail, "unexpected TMSI allocation in non-combined attach"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 700 | mtc.stop; |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 701 | } |
| 702 | /* P-TMSI.sig */ |
| 703 | if (ispresent(aa.ptmsiSignature)) { |
| 704 | g_pars.p_tmsi_sig := aa.ptmsiSignature.valueField; |
| 705 | } |
| 706 | /* updateTimer */ |
| 707 | // aa.readyTimer |
| 708 | /* T3302, T3319, T3323, T3312_ext, T3324 */ |
| 709 | } |
| 710 | |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 711 | function f_process_rau_accept(PDU_GMM_RoutingAreaUpdateAccept ra, integer bssgp_index := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 712 | /* mandatory IE */ |
| 713 | g_pars.ra := ra.routingAreaId; |
| 714 | if (ispresent(ra.allocatedPTMSI)) { |
| 715 | if (not g_pars.net.expect_ptmsi) { |
| 716 | setverdict(fail, "unexpected P-TMSI allocation"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 717 | mtc.stop; |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 718 | } |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 719 | f_upd_ptmsi_and_tlli(ra.allocatedPTMSI.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi.octets, bssgp_index); |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 720 | } |
| 721 | if (ispresent(ra.msIdentity)) { |
| 722 | setverdict(fail, "unexpected TMSI allocation in non-combined attach"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 723 | mtc.stop; |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 724 | } |
| 725 | /* P-TMSI.sig */ |
| 726 | if (ispresent(ra.ptmsiSignature)) { |
| 727 | g_pars.p_tmsi_sig := ra.ptmsiSignature.valueField; |
| 728 | } |
| 729 | /* updateTimer */ |
| 730 | // aa.readyTimer |
| 731 | /* T3302, T3319, T3323, T3312_ext, T3324 */ |
| 732 | } |
| 733 | |
| 734 | |
Harald Welte | 5a4fa04 | 2018-02-16 20:59:21 +0100 | [diff] [blame] | 735 | function f_random_RAI(HEX0_3n mcc := '262'H, HEX0_3n mnc := '42'H) return RoutingAreaIdentificationV { |
| 736 | return f_RAI(mcc, mnc, f_rnd_octstring(2), f_rnd_octstring(1)); |
| 737 | } |
| 738 | |
Harald Welte | 23178c5 | 2018-02-17 09:36:33 +0100 | [diff] [blame] | 739 | /* return a MobileIdentityLV: P-TMSI if we have one, IMSI otherwise */ |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 740 | private function f_mi_get_lv() runs on BSSGP_ConnHdlr return MobileL3_CommonIE_Types.MobileIdentityLV { |
Harald Welte | 23178c5 | 2018-02-17 09:36:33 +0100 | [diff] [blame] | 741 | if (ispresent(g_pars.p_tmsi)) { |
| 742 | return valueof(ts_MI_TMSI_LV(g_pars.p_tmsi)); |
| 743 | } else { |
| 744 | return valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 745 | } |
| 746 | } |
| 747 | |
Harald Welte | 311ec27 | 2018-02-17 09:40:03 +0100 | [diff] [blame] | 748 | private function f_gmm_gsup_lu_isd() runs on BSSGP_ConnHdlr { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 749 | var GSUP_PDU gsup; |
Harald Welte | 311ec27 | 2018-02-17 09:40:03 +0100 | [diff] [blame] | 750 | /* Expect MSC to perform LU with HLR */ |
| 751 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 752 | gsup := valueof(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 753 | gsup.ies := gsup.ies & { valueof(ts_GSUP_IE_PdpInfo(char2oct("*"), '0121'O, ''O)) }; |
| 754 | GSUP.send(gsup); |
Harald Welte | 311ec27 | 2018-02-17 09:40:03 +0100 | [diff] [blame] | 755 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 756 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 757 | } |
| 758 | |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 759 | friend function f_gmm_attach(boolean umts_aka_challenge, boolean force_gsm_sres, integer gb_idx := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 5a4fa04 | 2018-02-16 20:59:21 +0100 | [diff] [blame] | 760 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 761 | var template PDU_L3_MS_SGSN attach_req := ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit); |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 762 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 763 | |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 764 | /* indicate R99 capability of the MS to enable UMTS AKA in presence of |
| 765 | * 3G auth vectors */ |
| 766 | attach_req.msgs.gprs_mm.attachRequest.msNetworkCapability.msNetworkCapabilityV.revisionLevelIndicatior := '1'B; |
| 767 | /* The thing is, if the solSACapability is 'omit', then the |
| 768 | * revisionLevelIndicatior is at the wrong place! */ |
| 769 | attach_req.msgs.gprs_mm.attachRequest.msNetworkCapability.msNetworkCapabilityV.solSACapability := '0'B; |
| 770 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 771 | f_send_l3(attach_req, gb_idx); |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 772 | f_gmm_auth(umts_aka_challenge, force_gsm_sres, gb_idx); |
Alexander Couzens | 5844d5b | 2018-05-14 06:30:56 +0200 | [diff] [blame] | 773 | /* Expect SGSN to perform LU with HLR */ |
Harald Welte | 311ec27 | 2018-02-17 09:40:03 +0100 | [diff] [blame] | 774 | f_gmm_gsup_lu_isd(); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 775 | |
Harald Welte | ca36246 | 2019-05-02 20:11:21 +0200 | [diff] [blame] | 776 | l3_mt := f_receive_l3(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?), gb_idx); |
| 777 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
| 778 | |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 779 | /* FIXME: Extract P-TMSI, if any. Only send Complete if necessary */ |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 780 | f_send_l3(ts_GMM_ATTACH_COMPL, gb_idx); |
| 781 | |
| 782 | /* IuPS case: Expect Iu Release */ |
| 783 | if (is_iu(gb_idx)) { |
| 784 | as_iu_release_compl_disc(); |
| 785 | } |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | private function f_TC_attach(charstring id) runs on BSSGP_ConnHdlr { |
| 789 | f_gmm_attach(false, false); |
Harald Welte | 5a4fa04 | 2018-02-16 20:59:21 +0100 | [diff] [blame] | 790 | setverdict(pass); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | testcase TC_attach() runs on test_CT { |
| 794 | var BSSGP_ConnHdlr vc_conn; |
| 795 | f_init(); |
| 796 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 797 | 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] | 798 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 799 | f_cleanup(); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 800 | } |
| 801 | |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 802 | testcase TC_attach_mnc3() runs on test_CT { |
| 803 | var BSSGP_ConnHdlr vc_conn; |
| 804 | f_init('023042'H); |
| 805 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 806 | 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] | 807 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 808 | f_cleanup(); |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 809 | } |
| 810 | |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 811 | private function f_TC_attach_umts_aka_umts_res(charstring id) runs on BSSGP_ConnHdlr { |
| 812 | f_gmm_attach(true, false); |
| 813 | setverdict(pass); |
| 814 | } |
| 815 | testcase TC_attach_umts_aka_umts_res() runs on test_CT { |
| 816 | var BSSGP_ConnHdlr vc_conn; |
| 817 | f_init(); |
| 818 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 819 | 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] | 820 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 821 | f_cleanup(); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | private function f_TC_attach_umts_aka_gsm_sres(charstring id) runs on BSSGP_ConnHdlr { |
| 825 | f_gmm_attach(true, true); |
| 826 | setverdict(pass); |
| 827 | } |
| 828 | testcase TC_attach_umts_aka_gsm_sres() runs on test_CT { |
| 829 | var BSSGP_ConnHdlr vc_conn; |
| 830 | f_init(); |
| 831 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 832 | 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] | 833 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 834 | f_cleanup(); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 835 | } |
| 836 | |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 837 | /* MS never responds to ID REQ, expect ATTACH REJECT */ |
| 838 | 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] | 839 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 840 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 841 | 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] | 842 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 843 | [] BSSGP[0].receive(tr_GMM_ID_REQ(?)) { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 844 | /* don't send ID Response */ |
| 845 | repeat; |
| 846 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 847 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT('09'O)) { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 848 | setverdict(pass); |
| 849 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 850 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 851 | setverdict(fail, "Wrong Attach Reject Cause"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 852 | mtc.stop; |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 853 | } |
| 854 | } |
| 855 | } |
| 856 | testcase TC_attach_auth_id_timeout() runs on test_CT { |
| 857 | var BSSGP_ConnHdlr vc_conn; |
| 858 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 859 | 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] | 860 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 861 | f_cleanup(); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 862 | } |
| 863 | |
| 864 | /* HLR never responds to SAI REQ, expect ATTACH REJECT */ |
| 865 | 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] | 866 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 867 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 868 | 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] | 869 | alt { |
| 870 | [] as_mm_identity(); |
| 871 | [] GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); { } |
| 872 | } |
| 873 | /* don't send SAI-response from HLR */ |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 874 | BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 875 | setverdict(pass); |
| 876 | } |
| 877 | testcase TC_attach_auth_sai_timeout() runs on test_CT { |
| 878 | var BSSGP_ConnHdlr vc_conn; |
| 879 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 880 | 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] | 881 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 882 | f_cleanup(); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 883 | } |
| 884 | |
Harald Welte | fe25388 | 2018-02-17 09:25:00 +0100 | [diff] [blame] | 885 | /* HLR rejects SAI, expect ATTACH REJECT */ |
| 886 | 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] | 887 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 888 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 889 | 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] | 890 | alt { |
| 891 | [] as_mm_identity(); |
| 892 | [] GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); { |
| 893 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 23)); |
| 894 | } |
| 895 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 896 | BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)); |
Harald Welte | fe25388 | 2018-02-17 09:25:00 +0100 | [diff] [blame] | 897 | setverdict(pass); |
| 898 | } |
| 899 | testcase TC_attach_auth_sai_reject() runs on test_CT { |
| 900 | var BSSGP_ConnHdlr vc_conn; |
| 901 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 902 | 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] | 903 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 904 | f_cleanup(); |
Harald Welte | fe25388 | 2018-02-17 09:25:00 +0100 | [diff] [blame] | 905 | } |
| 906 | |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 907 | /* HLR never responds to UL REQ, expect ATTACH REJECT */ |
| 908 | 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] | 909 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 910 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 911 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 912 | 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] | 913 | f_gmm_auth(); |
| 914 | /* Expect MSC to perform LU with HLR */ |
| 915 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 916 | /* Never follow-up with ISD_REQ or UL_RES */ |
| 917 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 918 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 919 | setverdict(pass); |
| 920 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 921 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 922 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 923 | setverdict(fail); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 924 | mtc.stop; |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 925 | } |
| 926 | } |
| 927 | } |
| 928 | testcase TC_attach_gsup_lu_timeout() runs on test_CT { |
| 929 | var BSSGP_ConnHdlr vc_conn; |
| 930 | f_init(); |
| 931 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 932 | 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] | 933 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 934 | f_cleanup(); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 935 | } |
| 936 | |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 937 | /* HLR rejects UL REQ, expect ATTACH REJECT */ |
| 938 | 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] | 939 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 940 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 941 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 942 | 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] | 943 | f_gmm_auth(); |
| 944 | /* Expect MSC to perform LU with HLR */ |
| 945 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 946 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 0)); |
| 947 | } |
| 948 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 949 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 950 | setverdict(pass); |
| 951 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 952 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 953 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 954 | setverdict(fail); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 955 | mtc.stop; |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 956 | } |
| 957 | } |
| 958 | } |
| 959 | testcase TC_attach_gsup_lu_reject() runs on test_CT { |
| 960 | var BSSGP_ConnHdlr vc_conn; |
| 961 | f_init(); |
| 962 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 963 | 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] | 964 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 965 | f_cleanup(); |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 969 | /* Attempt of combined GPRS + IMSI attach: network should ACK only GPRS attach */ |
| 970 | private function f_TC_attach_combined(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 971 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 972 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 973 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 974 | 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] | 975 | f_gmm_auth(); |
| 976 | /* Expect MSC to perform LU with HLR */ |
Harald Welte | 311ec27 | 2018-02-17 09:40:03 +0100 | [diff] [blame] | 977 | f_gmm_gsup_lu_isd(); |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 978 | |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 979 | BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 980 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 981 | } |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 982 | f_send_l3(ts_GMM_ATTACH_COMPL); |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 983 | setverdict(pass); |
| 984 | } |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 985 | testcase TC_attach_combined() runs on test_CT { |
| 986 | var BSSGP_ConnHdlr vc_conn; |
| 987 | f_init(); |
| 988 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 989 | vc_conn := f_start_handler(refers(f_TC_attach_combined), testcasename(), g_gb, 7); |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 990 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 991 | f_cleanup(); |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 992 | } |
| 993 | |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 994 | /* Attempt of GPRS ATTACH in 'accept all' mode */ |
| 995 | 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] | 996 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 997 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 998 | |
| 999 | g_pars.net.expect_auth := false; |
| 1000 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 1001 | f_send_l3(ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit)); |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 1002 | f_gmm_auth(); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1003 | BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 1004 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 1005 | } |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 1006 | f_send_l3(ts_GMM_ATTACH_COMPL); |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 1007 | setverdict(pass); |
| 1008 | } |
| 1009 | testcase TC_attach_accept_all() runs on test_CT { |
| 1010 | var BSSGP_ConnHdlr vc_conn; |
| 1011 | f_init(); |
| 1012 | f_sleep(1.0); |
| 1013 | f_vty_config(SGSNVTY, "sgsn", "auth-policy accept-all"); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1014 | 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] | 1015 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1016 | f_cleanup(); |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 1017 | } |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 1018 | |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 1019 | /* Attempt of GPRS ATTACH in 'accept all' mode */ |
| 1020 | 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] | 1021 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 1022 | |
| 1023 | /* Simulate a foreign IMSI */ |
| 1024 | g_pars.imsi := '001010123456789'H; |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1025 | f_bssgp_client_register(g_pars.imsi, g_pars.tlli, g_pars.bssgp_cell_id[0]); |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 1026 | |
| 1027 | g_pars.net.expect_auth := false; |
| 1028 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 1029 | 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] | 1030 | alt { |
| 1031 | [] as_mm_identity(); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1032 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT('07'O)) { |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 1033 | setverdict(pass); |
| 1034 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1035 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 1036 | setverdict(pass); |
| 1037 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1038 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT(*, *, *)) { |
Alexander Couzens | 0ca0d9c | 2018-06-12 14:01:34 +0200 | [diff] [blame] | 1039 | setverdict(fail); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1040 | mtc.stop; |
Alexander Couzens | 0ca0d9c | 2018-06-12 14:01:34 +0200 | [diff] [blame] | 1041 | } |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 1042 | } |
| 1043 | } |
| 1044 | testcase TC_attach_closed() runs on test_CT { |
| 1045 | var BSSGP_ConnHdlr vc_conn; |
| 1046 | f_init(); |
| 1047 | f_sleep(1.0); |
| 1048 | f_vty_config(SGSNVTY, "sgsn", "auth-policy closed"); |
| 1049 | /* test with foreign IMSI: Must Reject */ |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1050 | 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] | 1051 | vc_conn.done; |
| 1052 | /* test with home IMSI: Must Accept */ |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1053 | 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] | 1054 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1055 | f_cleanup(); |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 1056 | } |
| 1057 | |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 1058 | /* Routing Area Update from Unknown TLLI -> REJECT */ |
| 1059 | private function f_TC_rau_unknown(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 1060 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 1061 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 1062 | 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] | 1063 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1064 | [] BSSGP[0].receive(tr_GMM_RAU_REJECT('0a'O)) { |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 1065 | setverdict(pass); |
| 1066 | } |
| 1067 | /* FIXME: Expect XID RESET? */ |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1068 | [] BSSGP[0].receive { repeat; } |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 1069 | } |
| 1070 | } |
| 1071 | testcase TC_rau_unknown() runs on test_CT { |
| 1072 | var BSSGP_ConnHdlr vc_conn; |
| 1073 | f_init(); |
| 1074 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1075 | 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] | 1076 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1077 | f_cleanup(); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 1078 | } |
| 1079 | |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 1080 | private function f_TC_attach_rau(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 1081 | /* first perform regular attach */ |
| 1082 | f_TC_attach(id); |
| 1083 | |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 1084 | f_routing_area_update(g_pars.ra); |
| 1085 | |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 1086 | } |
| 1087 | testcase TC_attach_rau() runs on test_CT { |
| 1088 | var BSSGP_ConnHdlr vc_conn; |
| 1089 | f_init(); |
| 1090 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1091 | 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] | 1092 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1093 | f_cleanup(); |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 1094 | } |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 1095 | |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1096 | /* general GPRS DETACH helper */ |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 1097 | function f_detach_mo(BIT3 detach_type, boolean power_off, boolean expect_purge, integer bssgp_index := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1098 | var PDU_L3_SGSN_MS l3_mt; |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1099 | timer T := 5.0; |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 1100 | f_send_l3(ts_GMM_DET_REQ_MO(detach_type, power_off), bssgp_index); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1101 | if (expect_purge) { |
| 1102 | GSUP.receive(tr_GSUP_PURGE_MS_REQ(g_pars.imsi, OSMO_GSUP_CN_DOMAIN_PS)); |
| 1103 | GSUP.send(ts_GSUP_PURGE_MS_RES(g_pars.imsi)); |
| 1104 | } |
| 1105 | T.start; |
| 1106 | alt { |
| 1107 | [not expect_purge] GSUP.receive(tr_GSUP_PURGE_MS_REQ(?)) { |
| 1108 | setverdict(fail, "Unexpected GSUP PURGE MS for unregistered TLLI"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1109 | mtc.stop; |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1110 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1111 | [power_off] BSSGP[bssgp_index].receive(tr_GMM_DET_ACCEPT_MT) -> value l3_mt { |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1112 | g_pars.ra := omit; |
Alexander Couzens | 8e0fd46 | 2019-05-11 01:20:55 +0200 | [diff] [blame] | 1113 | setverdict(fail, "Unexpected DETACH ACCEPT in power-off DETACH"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1114 | mtc.stop; |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1115 | /* TODO: check if any PDP contexts are deactivated on network side? */ |
| 1116 | } |
| 1117 | [power_off] T.timeout { |
| 1118 | setverdict(pass); |
| 1119 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1120 | [not power_off] BSSGP[bssgp_index].receive(tr_GMM_DET_ACCEPT_MT) -> value l3_mt { |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1121 | g_pars.ra := omit; |
| 1122 | setverdict(pass); |
| 1123 | /* TODO: check if any PDP contexts are deactivated on network side? */ |
| 1124 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1125 | [] BSSGP[bssgp_index].receive(PDU_L3_SGSN_MS:?) -> value l3_mt { |
Alexander Couzens | 4630e74 | 2019-05-11 01:50:10 +0200 | [diff] [blame] | 1126 | if (power_off) { |
| 1127 | setverdict(fail, "Unexpected Layer 3 package received in power-off DETACH"); |
| 1128 | } else { |
| 1129 | setverdict(fail, "Unexpected Layer 3 package received in normal DETACH"); |
| 1130 | } |
| 1131 | mtc.stop; |
| 1132 | } |
Alexander Couzens | 90fe6a2 | 2018-07-31 19:37:32 +0200 | [diff] [blame] | 1133 | [] BSSGP[bssgp_index].receive { repeat; } |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | /* IMSI DETACH (non-power-off) for unknown TLLI */ |
| 1138 | private function f_TC_detach_unknown_nopoweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 1139 | f_detach_mo(c_GMM_DTT_MO_GPRS, false, false); |
| 1140 | } |
| 1141 | testcase TC_detach_unknown_nopoweroff() runs on test_CT { |
| 1142 | var BSSGP_ConnHdlr vc_conn; |
| 1143 | f_init(); |
| 1144 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1145 | 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] | 1146 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1147 | f_cleanup(); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1148 | } |
| 1149 | |
| 1150 | /* IMSI DETACH (power-off) for unknown TLLI */ |
| 1151 | private function f_TC_detach_unknown_poweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 1152 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, false); |
| 1153 | } |
| 1154 | testcase TC_detach_unknown_poweroff() runs on test_CT { |
| 1155 | var BSSGP_ConnHdlr vc_conn; |
| 1156 | f_init(); |
| 1157 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1158 | 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] | 1159 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1160 | f_cleanup(); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1161 | } |
| 1162 | |
| 1163 | /* IMSI DETACH (non-power-off) for known TLLI */ |
| 1164 | private function f_TC_detach_nopoweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 1165 | /* first perform regular attach */ |
| 1166 | f_TC_attach(id); |
| 1167 | |
| 1168 | f_detach_mo(c_GMM_DTT_MO_GPRS, false, true); |
| 1169 | } |
| 1170 | testcase TC_detach_nopoweroff() runs on test_CT { |
| 1171 | var BSSGP_ConnHdlr vc_conn; |
| 1172 | f_init(); |
| 1173 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1174 | vc_conn := f_start_handler(refers(f_TC_detach_nopoweroff), testcasename(), g_gb, 15); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1175 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1176 | f_cleanup(); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | /* IMSI DETACH (power-off) for known TLLI */ |
| 1180 | private function f_TC_detach_poweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 1181 | /* first perform regular attach */ |
| 1182 | f_TC_attach(id); |
| 1183 | |
| 1184 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true); |
| 1185 | } |
| 1186 | testcase TC_detach_poweroff() runs on test_CT { |
| 1187 | var BSSGP_ConnHdlr vc_conn; |
| 1188 | f_init(); |
| 1189 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1190 | 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] | 1191 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1192 | f_cleanup(); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1193 | } |
| 1194 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1195 | type record PdpActPars { |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 1196 | BIT3 tid, /* L3 Transaction ID */ |
| 1197 | BIT4 nsapi, /* SNDCP NSAPI */ |
| 1198 | BIT4 sapi, /* LLC SAPI */ |
| 1199 | QoSV qos, /* QoS parameters */ |
| 1200 | PDPAddressV addr, /* IP address */ |
| 1201 | octetstring apn optional, /* APN name */ |
| 1202 | ProtocolConfigOptionsV pco optional, /* protoco config opts */ |
| 1203 | OCT1 exp_rej_cause optional, /* expected SM reject cause */ |
Harald Welte | 1d6ae93 | 2018-02-18 21:24:44 +0100 | [diff] [blame] | 1204 | OCT1 gtp_resp_cause, /* GTP response cause */ |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 1205 | OCT4 chg_id, /* GTP Charging Identifier */ |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1206 | |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 1207 | OCT4 ggsn_tei_c, /* GGSN TEI Control*/ |
| 1208 | OCT4 ggsn_tei_u, /* GGSN TEI User */ |
| 1209 | octetstring ggsn_ip_c, /* GGSN IP Control */ |
| 1210 | octetstring ggsn_ip_u, /* GGSN IP User */ |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1211 | OCT1 ggsn_restart_ctr, /* GGSN Restart Counter */ |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1212 | |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 1213 | OCT4 sgsn_tei_c optional, /* SGSN TEI Control */ |
| 1214 | OCT4 sgsn_tei_u optional, /* SGSN TEI User */ |
| 1215 | octetstring sgsn_ip_c optional, /* SGSN IP Control */ |
| 1216 | octetstring sgsn_ip_u optional /* SGSN IP USer */ |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1217 | }; |
| 1218 | |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 1219 | |
| 1220 | private function f_process_gtp_ctx_act_req(inout PdpActPars apars, PDU_GTPC gtpc) runs on BSSGP_ConnHdlr { |
| 1221 | var GTPC_PDUs gtpc_rx := gtpc.gtpc_pdu; |
| 1222 | apars.sgsn_tei_c := gtpc_rx.createPDPContextRequest.teidControlPlane.teidControlPlane; |
| 1223 | apars.sgsn_tei_u := gtpc_rx.createPDPContextRequest.teidDataI.teidDataI; |
| 1224 | apars.sgsn_ip_c := gtpc_rx.createPDPContextRequest.sgsn_addr_signalling.addressf; |
| 1225 | apars.sgsn_ip_u := gtpc_rx.createPDPContextRequest.sgsn_addr_traffic.addressf; |
| 1226 | f_gtp_register_teid(apars.ggsn_tei_c); |
| 1227 | f_gtp_register_teid(apars.ggsn_tei_u); |
| 1228 | } |
| 1229 | |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1230 | function f_pdp_ctx_act(inout PdpActPars apars, boolean send_recovery := false, integer gb_idx := 0) |
| 1231 | runs on BSSGP_ConnHdlr { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1232 | var boolean exp_rej := ispresent(apars.exp_rej_cause); |
| 1233 | var Gtp1cUnitdata g_ud; |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1234 | var template Recovery_gtpc recovery := omit; |
| 1235 | |
| 1236 | if (send_recovery) { |
| 1237 | recovery := ts_Recovery(apars.ggsn_restart_ctr); |
| 1238 | } |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1239 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 1240 | f_send_l3(ts_SM_ACT_PDP_REQ(apars.tid, apars.nsapi, apars.sapi, apars.qos, apars.addr, |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1241 | apars.apn, apars.pco), gb_idx); |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 1242 | GTP.receive(tr_GTPC_MsgType(?, createPDPContextRequest, ?)) -> value g_ud { |
| 1243 | f_process_gtp_ctx_act_req(apars, g_ud.gtpc); |
| 1244 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1245 | GTP.send(ts_GTPC_CreatePdpResp(g_ud.peer, seq_nr, |
| 1246 | apars.sgsn_tei_c, apars.gtp_resp_cause, |
| 1247 | apars.ggsn_tei_c, apars.ggsn_tei_u, |
| 1248 | apars.nsapi, |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1249 | apars.ggsn_ip_c, apars.ggsn_ip_u, apars.chg_id, |
| 1250 | omit, recovery)); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1251 | } |
| 1252 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1253 | [exp_rej] BSSGP[gb_idx].receive(tr_SM_ACT_PDP_REJ(apars.tid, apars.exp_rej_cause)) { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1254 | setverdict(pass); |
| 1255 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1256 | [exp_rej] BSSGP[gb_idx].receive(tr_SM_ACT_PDP_ACCEPT) { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1257 | setverdict(fail, "Unexpected PDP CTX ACT ACC"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1258 | mtc.stop; |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1259 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1260 | [not exp_rej] BSSGP[gb_idx].receive(tr_SM_ACT_PDP_REJ(apars.tid, ?)) { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1261 | setverdict(fail, "Unexpected PDP CTX ACT FAIL"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1262 | mtc.stop; |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1263 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1264 | [not exp_rej] BSSGP[gb_idx].receive(tr_SM_ACT_PDP_REJ(apars.tid, ?)) { |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1265 | setverdict(fail, "Unexpected PDP CTX ACT FAIL"); |
| 1266 | mtc.stop; |
| 1267 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1268 | [not exp_rej] BSSGP[gb_idx].receive(tr_SM_ACT_PDP_ACCEPT(apars.tid, apars.sapi)) { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1269 | setverdict(pass); |
| 1270 | } |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1271 | [] as_xid(apars, gb_idx); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1272 | } |
| 1273 | } |
| 1274 | |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1275 | function f_pdp_ctx_deact_mo(inout PdpActPars apars, OCT1 cause, integer gb_idx := 0) |
| 1276 | runs on BSSGP_ConnHdlr { |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1277 | var boolean exp_rej := ispresent(apars.exp_rej_cause); |
| 1278 | var Gtp1cUnitdata g_ud; |
| 1279 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 1280 | f_send_l3(ts_SM_DEACT_PDP_REQ_MO(apars.tid, cause, false, omit), gb_idx); |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1281 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextRequest, apars.ggsn_tei_c)) -> value g_ud { |
| 1282 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1283 | BSSGP[gb_idx].clear; |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1284 | GTP.send(ts_GTPC_DeletePdpResp(g_ud.peer, seq_nr, apars.sgsn_tei_c, '7F'O)); |
| 1285 | } |
| 1286 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1287 | [] BSSGP[gb_idx].receive(tr_SM_DEACT_PDP_ACCEPT_MT(apars.tid)) { |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1288 | setverdict(pass); |
| 1289 | } |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1290 | [] as_xid(apars, gb_idx); |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1291 | } |
| 1292 | } |
| 1293 | |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1294 | function f_pdp_ctx_deact_mt(inout PdpActPars apars, boolean error_ind := false, integer gb_idx := 0) |
| 1295 | runs on BSSGP_ConnHdlr { |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1296 | var Gtp1cUnitdata g_ud; |
| 1297 | var integer seq_nr := 23; |
| 1298 | var GtpPeer peer := valueof(ts_GtpPeerC(apars.sgsn_ip_c)); |
| 1299 | |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1300 | BSSGP[gb_idx].clear; |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1301 | if (error_ind) { |
| 1302 | GTP.send(ts_GTPU_ErrorIndication(peer, 0 /* seq */, apars.ggsn_tei_u, apars.ggsn_ip_u)); |
| 1303 | } else { |
| 1304 | GTP.send(ts_GTPC_DeletePDP(peer, seq_nr, apars.sgsn_tei_c, apars.nsapi, '1'B)); |
| 1305 | } |
Alexander Couzens | 5e71c14 | 2018-08-07 17:21:24 +0200 | [diff] [blame] | 1306 | |
| 1307 | timer T := 5.0; |
| 1308 | T.start; |
| 1309 | |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1310 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1311 | [] BSSGP[gb_idx].receive(tr_SM_DEACT_PDP_REQ_MT(apars.tid, ?, true)) { |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 1312 | f_send_l3(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid), gb_idx); |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1313 | } |
Alexander Couzens | 5e71c14 | 2018-08-07 17:21:24 +0200 | [diff] [blame] | 1314 | [not error_ind] GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, apars.ggsn_tei_c)) { |
| 1315 | repeat; |
| 1316 | } |
| 1317 | [] T.timeout { |
| 1318 | setverdict(fail, "Waiting for SM_DEACT_PDP_REQ_MT"); |
| 1319 | } |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1320 | } |
| 1321 | } |
| 1322 | |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1323 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1324 | /* Table 10.5.156/3GPP TS 24.008 */ |
| 1325 | template (value) QoSV t_QosDefault := { |
| 1326 | reliabilityClass := '011'B, /* unacknowledged GTP+LLC, acknowledged RLC */ |
| 1327 | delayClass := '100'B, /* best effort */ |
| 1328 | spare1 := '00'B, |
| 1329 | precedenceClass := '010'B, /* normal */ |
| 1330 | spare2 := '0'B, |
| 1331 | peakThroughput := '0000'B, /* subscribed */ |
| 1332 | meanThroughput := '00000'B, /* subscribed */ |
| 1333 | spare3 := '000'B, |
| 1334 | deliverErroneusSDU := omit, |
| 1335 | deliveryOrder := omit, |
| 1336 | trafficClass := omit, |
| 1337 | maxSDUSize := omit, |
| 1338 | maxBitrateUplink := omit, |
| 1339 | maxBitrateDownlink := omit, |
| 1340 | sduErrorRatio := omit, |
| 1341 | residualBER := omit, |
| 1342 | trafficHandlingPriority := omit, |
| 1343 | transferDelay := omit, |
| 1344 | guaranteedBitRateUplink := omit, |
| 1345 | guaranteedBitRateDownlink := omit, |
| 1346 | sourceStatisticsDescriptor := omit, |
| 1347 | signallingIndication := omit, |
| 1348 | spare4 := omit, |
| 1349 | maxBitrateDownlinkExt := omit, |
| 1350 | guaranteedBitRateDownlinkExt := omit, |
| 1351 | maxBitrateUplinkExt := omit, |
| 1352 | guaranteedBitRateUplinkExt := omit, |
| 1353 | maxBitrateDownlinkExt2 := omit, |
| 1354 | guaranteedBitRateDownlinkExt2 := omit, |
| 1355 | maxBitrateUplinkExt2 := omit, |
| 1356 | guaranteedBitRateUplinkExt2 := omit |
| 1357 | } |
| 1358 | |
| 1359 | /* 10.5.6.4 / 3GPP TS 24.008 */ |
| 1360 | template (value) PDPAddressV t_AddrIPv4dyn := { |
| 1361 | pdpTypeOrg := '0001'B, /* IETF */ |
| 1362 | spare := '0000'B, |
| 1363 | pdpTypeNum := '21'O, /* IPv4 */ |
| 1364 | addressInfo := omit |
| 1365 | } |
| 1366 | template (value) PDPAddressV t_AddrIPv6dyn := { |
| 1367 | pdpTypeOrg := '0001'B, /* IETF */ |
| 1368 | spare := '0000'B, |
| 1369 | pdpTypeNum := '53'O, /* IPv6 */ |
| 1370 | addressInfo := omit |
| 1371 | } |
| 1372 | |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1373 | template (value) PdpActPars t_PdpActPars(charstring ggsn_ip) := { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1374 | tid := '000'B, |
| 1375 | nsapi := '0101'B, /* < 5 are reserved */ |
| 1376 | sapi := '0011'B, /* 3/5/9/11 */ |
| 1377 | qos := t_QosDefault, |
| 1378 | addr := t_AddrIPv4dyn, |
| 1379 | apn := omit, |
| 1380 | pco := omit, |
| 1381 | exp_rej_cause := omit, |
Harald Welte | 1d6ae93 | 2018-02-18 21:24:44 +0100 | [diff] [blame] | 1382 | gtp_resp_cause := int2oct(128, 1), |
| 1383 | chg_id := f_rnd_octstring(4), |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1384 | |
| 1385 | /* FIXME: make below dynamic !! */ |
Harald Welte | 1d6ae93 | 2018-02-18 21:24:44 +0100 | [diff] [blame] | 1386 | ggsn_tei_c := f_rnd_octstring(4), |
| 1387 | ggsn_tei_u := f_rnd_octstring(4), |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1388 | ggsn_ip_c := f_inet_addr(ggsn_ip), |
| 1389 | ggsn_ip_u := f_inet_addr(ggsn_ip), |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1390 | ggsn_restart_ctr := int2oct(2, 1), |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1391 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1392 | sgsn_tei_c := omit, |
Harald Welte | f8af5d6 | 2018-02-18 15:06:42 +0100 | [diff] [blame] | 1393 | sgsn_tei_u := omit, |
| 1394 | sgsn_ip_c := omit, |
| 1395 | sgsn_ip_u := omit |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1396 | } |
| 1397 | |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1398 | template (value) GtpPeer ts_GtpPeerU(octetstring ip) := { |
| 1399 | connId := 1, |
| 1400 | remName := f_inet_ntoa(ip), |
| 1401 | remPort := GTP1U_PORT |
| 1402 | } |
| 1403 | |
| 1404 | template (value) GtpPeer ts_GtpPeerC(octetstring ip) := { |
| 1405 | connId := 1, |
| 1406 | remName := f_inet_ntoa(ip), |
| 1407 | remPort := GTP1C_PORT |
| 1408 | } |
| 1409 | |
| 1410 | private function f_gtpu_send(inout PdpActPars apars, octetstring payload) runs on BSSGP_ConnHdlr { |
| 1411 | var GtpPeer peer := valueof(ts_GtpPeerU(apars.sgsn_ip_u)); |
| 1412 | GTP.send(ts_GTP1U_GPDU(peer, 0 /*seq*/, apars.sgsn_tei_u, payload)); |
| 1413 | } |
| 1414 | |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1415 | private altstep as_xid(PdpActPars apars, integer gb_idx := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1416 | [] BSSGP[gb_idx].receive(tr_LLC_XID_MT_CMD(?, apars.sapi)) { |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1417 | repeat; |
| 1418 | } |
| 1419 | } |
| 1420 | |
| 1421 | template PDU_SN tr_SN_UD(template BIT4 nsapi, template octetstring payload) := { |
| 1422 | pDU_SN_UNITDATA := { |
| 1423 | nsapi := nsapi, |
| 1424 | moreBit := ?, |
| 1425 | snPduType := '1'B, |
| 1426 | firstSegmentIndicator := ?, |
| 1427 | spareBit := ?, |
| 1428 | pcomp := ?, |
| 1429 | dcomp := ?, |
| 1430 | npduNumber := ?, |
| 1431 | segmentNumber := ?, |
| 1432 | npduNumberContinued := ?, |
| 1433 | dataSegmentSnUnitdataPdu := payload |
| 1434 | } |
| 1435 | } |
| 1436 | |
| 1437 | /* simple case: single segment, no compression */ |
| 1438 | template (value) PDU_SN ts_SN_UD(BIT4 nsapi, octetstring payload) := { |
| 1439 | pDU_SN_UNITDATA := { |
| 1440 | nsapi := nsapi, |
| 1441 | moreBit := '0'B, |
| 1442 | snPduType := '1'B, |
| 1443 | firstSegmentIndicator := '1'B, |
| 1444 | spareBit := '0'B, |
| 1445 | pcomp := '0000'B, |
| 1446 | dcomp := '0000'B, |
| 1447 | npduNumber := '0000'B, |
| 1448 | segmentNumber := '0000'B, |
| 1449 | npduNumberContinued := '00'O, |
| 1450 | dataSegmentSnUnitdataPdu := payload |
| 1451 | } |
| 1452 | } |
| 1453 | |
| 1454 | /* Transceive given 'payload' as MT message from GTP -> OsmoSGSN -> Gb */ |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1455 | private function f_gtpu_xceive_mt(inout PdpActPars apars, octetstring payload, integer gb_idx := 0) |
| 1456 | runs on BSSGP_ConnHdlr { |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1457 | /* Send PDU via GTP from our simulated GGSN to the SGSN */ |
| 1458 | f_gtpu_send(apars, payload); |
| 1459 | /* Expect PDU via BSSGP/LLC on simulated PCU from SGSN */ |
| 1460 | alt { |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1461 | [] as_xid(apars, gb_idx); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1462 | //[] BSSGP[gb_idx].receive(tr_BD_SNDCP(apars.sapi, tr_SN_UD(apars.nsapi, payload))); |
| 1463 | [] BSSGP[gb_idx].receive(tr_SN_UD(apars.nsapi, payload)); |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1464 | } |
| 1465 | } |
| 1466 | |
Pau Espin Pedrol | 8be4d19 | 2018-07-18 13:43:44 +0200 | [diff] [blame] | 1467 | /* Transceive given 'payload' as MT message from Gb -> OsmoSGSN -> GTP */ |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1468 | private function f_gtpu_xceive_mo(inout PdpActPars apars, octetstring payload, integer gb_idx := 0) |
| 1469 | runs on BSSGP_ConnHdlr { |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1470 | /* Send PDU via SNDCP/LLC/BSSGP/NS via simulated MS/PCU to the SGSN */ |
| 1471 | var GtpPeer peer := valueof(ts_GtpPeerU(apars.sgsn_ip_u)); |
| 1472 | var PDU_SN sndcp := valueof(ts_SN_UD(apars.nsapi, payload)); |
Harald Welte | f719167 | 2019-05-02 20:37:23 +0200 | [diff] [blame] | 1473 | BSSGP[gb_idx].send(ts_LLC_UI(enc_PDU_SN(sndcp), apars.sapi, '0'B, 0)); |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1474 | /* Expect PDU via GTP from SGSN on simulated GGSN */ |
| 1475 | alt { |
| 1476 | [] GTP.receive(tr_GTPU_GPDU(peer, apars.ggsn_tei_u, payload)); |
| 1477 | } |
| 1478 | } |
| 1479 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1480 | 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] | 1481 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1482 | |
| 1483 | /* first perform regular attach */ |
| 1484 | f_TC_attach(id); |
| 1485 | |
| 1486 | f_pdp_ctx_act(apars); |
| 1487 | } |
| 1488 | testcase TC_attach_pdp_act() runs on test_CT { |
| 1489 | var BSSGP_ConnHdlr vc_conn; |
| 1490 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1491 | 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] | 1492 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1493 | f_cleanup(); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1494 | } |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 1495 | |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1496 | /* PDP Context activation for not-attached subscriber; expect fail */ |
| 1497 | 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] | 1498 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 1499 | 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] | 1500 | apars.apn, apars.pco)); |
| 1501 | alt { |
| 1502 | /* We might want toalso actually expect a PDPC CTX ACT REJ? */ |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1503 | [] BSSGP[0].receive(tr_GMM_DET_REQ_MT(?, ?)) { |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1504 | setverdict(pass); |
| 1505 | } |
| 1506 | [] GTP.receive(tr_GTPC_MsgType(?, createPDPContextRequest, ?)) { |
| 1507 | setverdict(fail, "Unexpected GTP PDP CTX ACT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1508 | mtc.stop; |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1509 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1510 | [] BSSGP[0].receive(tr_SM_ACT_PDP_ACCEPT(?, ?)) { |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1511 | setverdict(fail, "Unexpected SM PDP CTX ACT ACK"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1512 | mtc.stop; |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1513 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1514 | [] BSSGP[0].receive { repeat; } |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1515 | } |
| 1516 | } |
| 1517 | testcase TC_pdp_act_unattached() runs on test_CT { |
| 1518 | var BSSGP_ConnHdlr vc_conn; |
| 1519 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1520 | 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] | 1521 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1522 | f_cleanup(); |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1523 | } |
| 1524 | |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1525 | /* ATTACH + PDP CTX ACT + user plane traffic */ |
| 1526 | private function f_TC_attach_pdp_act_user(charstring id) runs on BSSGP_ConnHdlr { |
| 1527 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1528 | |
| 1529 | /* first perform regular attach */ |
| 1530 | f_TC_attach(id); |
| 1531 | /* then activate PDP context */ |
| 1532 | f_pdp_ctx_act(apars); |
| 1533 | /* then transceive a downlink PDU */ |
| 1534 | f_gtpu_xceive_mt(apars, f_rnd_octstring(100)); |
| 1535 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 1536 | } |
| 1537 | testcase TC_attach_pdp_act_user() runs on test_CT { |
| 1538 | var BSSGP_ConnHdlr vc_conn; |
| 1539 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1540 | 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] | 1541 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1542 | f_cleanup(); |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1543 | } |
| 1544 | |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 1545 | /* ATTACH + PDP CTX ACT; reject from GGSN */ |
| 1546 | private function f_TC_attach_pdp_act_ggsn_reject(charstring id) runs on BSSGP_ConnHdlr { |
| 1547 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1548 | |
| 1549 | apars.gtp_resp_cause := int2oct(199, 1); /* no resources available */ |
| 1550 | apars.exp_rej_cause := '1a'O; /* insufficient resources */ |
| 1551 | |
| 1552 | /* first perform regular attach */ |
| 1553 | f_TC_attach(id); |
| 1554 | /* then activate PDP context */ |
| 1555 | f_pdp_ctx_act(apars); |
| 1556 | } |
| 1557 | testcase TC_attach_pdp_act_ggsn_reject() runs on test_CT { |
| 1558 | var BSSGP_ConnHdlr vc_conn; |
| 1559 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1560 | 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] | 1561 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1562 | f_cleanup(); |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 1563 | } |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1564 | |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1565 | /* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MO direction */ |
| 1566 | private function f_TC_attach_pdp_act_user_deact_mo(charstring id) runs on BSSGP_ConnHdlr { |
| 1567 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1568 | |
| 1569 | /* first perform regular attach */ |
| 1570 | f_TC_attach(id); |
| 1571 | /* then activate PDP context */ |
| 1572 | f_pdp_ctx_act(apars); |
| 1573 | /* then transceive a downlink PDU */ |
| 1574 | f_gtpu_xceive_mt(apars, f_rnd_octstring(100)); |
| 1575 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 1576 | |
| 1577 | f_pdp_ctx_deact_mo(apars, '00'O); |
| 1578 | } |
| 1579 | testcase TC_attach_pdp_act_user_deact_mo() runs on test_CT { |
| 1580 | var BSSGP_ConnHdlr vc_conn; |
| 1581 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1582 | 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] | 1583 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1584 | f_cleanup(); |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1585 | } |
| 1586 | |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1587 | /* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MT direction */ |
| 1588 | private function f_TC_attach_pdp_act_user_deact_mt(charstring id) runs on BSSGP_ConnHdlr { |
| 1589 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1590 | |
| 1591 | /* first perform regular attach */ |
| 1592 | f_TC_attach(id); |
| 1593 | /* then activate PDP context */ |
| 1594 | f_pdp_ctx_act(apars); |
| 1595 | /* then transceive a downlink PDU */ |
| 1596 | f_gtpu_xceive_mt(apars, f_rnd_octstring(100)); |
| 1597 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 1598 | |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1599 | f_pdp_ctx_deact_mt(apars, false); |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1600 | } |
| 1601 | testcase TC_attach_pdp_act_user_deact_mt() runs on test_CT { |
| 1602 | var BSSGP_ConnHdlr vc_conn; |
| 1603 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1604 | 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] | 1605 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1606 | f_cleanup(); |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1607 | } |
| 1608 | |
Pau Espin Pedrol | 2a3302a | 2019-08-15 16:01:20 +0200 | [diff] [blame] | 1609 | /* Test MS sending a duplicate Deact PDP Ctx (OS#3956). */ |
| 1610 | private function f_TC_attach_pdp_act_deact_dup(charstring id) runs on BSSGP_ConnHdlr { |
| 1611 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1612 | var Gtp1cUnitdata g_ud; |
| 1613 | var integer i; |
| 1614 | var OCT1 cause_regular_deact := '24'O; |
| 1615 | |
| 1616 | /* first perform regular attach + PDP context act */ |
| 1617 | f_TC_attach(id); |
| 1618 | f_pdp_ctx_act(apars); |
| 1619 | |
| 1620 | f_send_l3_gmm_llc(ts_SM_DEACT_PDP_REQ_MO(apars.tid, cause_regular_deact, false, omit), 0); |
| 1621 | f_send_l3_gmm_llc(ts_SM_DEACT_PDP_REQ_MO(apars.tid, cause_regular_deact, false, omit), 0); |
| 1622 | |
| 1623 | for (i := 0; i < 2; i := i+1) { |
| 1624 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextRequest, apars.ggsn_tei_c)) -> value g_ud { |
| 1625 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1626 | log("Received deletePDPContextResponse " & int2str(i) & ", seq_nr=" & int2str(seq_nr)); |
| 1627 | GTP.send(ts_GTPC_DeletePdpResp(g_ud.peer, seq_nr, apars.sgsn_tei_c, '7F'O)); |
| 1628 | } |
| 1629 | } |
| 1630 | |
| 1631 | alt { |
| 1632 | [] BSSGP[0].receive(tr_SM_DEACT_PDP_ACCEPT_MT(apars.tid)) { |
| 1633 | setverdict(pass); |
| 1634 | } |
| 1635 | [] as_xid(apars, 0); |
| 1636 | } |
| 1637 | |
| 1638 | /* Make sure second DeactPdpAccept is sent: */ |
| 1639 | timer T := 2.0; |
| 1640 | T.start; |
| 1641 | alt { |
| 1642 | [] BSSGP[0].receive(tr_SM_DEACT_PDP_ACCEPT_MT(apars.tid)) { |
| 1643 | setverdict(fail, "Second SM_DEACT_PDP_ACCEPT_MT received"); |
| 1644 | } |
| 1645 | [] T.timeout { |
| 1646 | setverdict(pass); |
| 1647 | } |
| 1648 | } |
| 1649 | |
| 1650 | setverdict(pass); |
| 1651 | } |
| 1652 | testcase TC_attach_pdp_act_deact_dup() runs on test_CT { |
| 1653 | var BSSGP_ConnHdlr vc_conn; |
| 1654 | f_init(); |
| 1655 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_deact_dup), testcasename(), g_gb, 46); |
| 1656 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1657 | f_cleanup(); |
Pau Espin Pedrol | 2a3302a | 2019-08-15 16:01:20 +0200 | [diff] [blame] | 1658 | } |
| 1659 | |
Alexander Couzens | 187ad5d | 2018-05-02 19:31:10 +0200 | [diff] [blame] | 1660 | /* ATTACH + ATTACH (2nd) */ |
| 1661 | private function f_TC_attach_forget_tlli_attach(charstring id) runs on BSSGP_ConnHdlr { |
| 1662 | g_pars.t_guard := 5.0; |
| 1663 | |
| 1664 | /* first perform regular attach */ |
| 1665 | f_TC_attach(id); |
| 1666 | |
| 1667 | /* second to perform regular attach */ |
| 1668 | f_TC_attach(id); |
| 1669 | } |
| 1670 | |
| 1671 | |
| 1672 | testcase TC_attach_second_attempt() runs on test_CT { |
| 1673 | var BSSGP_ConnHdlr vc_conn; |
| 1674 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1675 | 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] | 1676 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1677 | f_cleanup(); |
Alexander Couzens | 187ad5d | 2018-05-02 19:31:10 +0200 | [diff] [blame] | 1678 | } |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1679 | |
Pau Espin Pedrol | fcec914 | 2019-08-28 17:33:46 +0200 | [diff] [blame] | 1680 | private function f_TC_attach_echo_timeout(charstring id) runs on BSSGP_ConnHdlr { |
| 1681 | var Gtp1cUnitdata g_ud; |
| 1682 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1683 | var integer seq_nr; |
| 1684 | |
| 1685 | /* first perform regular attach */ |
| 1686 | f_TC_attach(id); |
| 1687 | /* then activate PDP context */ |
| 1688 | f_pdp_ctx_act(apars); |
| 1689 | |
| 1690 | /* Wait to receive first echo request and send initial Restart counter */ |
| 1691 | GTP.receive(tr_GTPC_MsgType(?, echoRequest, ?)) -> value g_ud { |
| 1692 | BSSGP[0].clear; |
| 1693 | seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1694 | GTP.send(ts_GTPC_PONG(g_ud.peer, seq_nr, apars.ggsn_restart_ctr)); |
| 1695 | f_sleep(int2float(mp_echo_interval)); /* wait until around next echo is expected */ |
| 1696 | } |
| 1697 | |
| 1698 | /* At some point next echo request not answered will timeout and SGSN |
| 1699 | should drop the pdp ctx. Around T3 (3secs) * 6 (+ extra, a lot due to OS#4178): */ |
| 1700 | timer T := 3.0 * 6.0 + 16.0; |
| 1701 | T.start; |
| 1702 | alt { |
| 1703 | [] BSSGP[0].receive(tr_SM_DEACT_PDP_REQ_MT(apars.tid, ?, true)) { |
| 1704 | f_send_l3_gmm_llc(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid)); |
| 1705 | setverdict(pass); |
| 1706 | } |
| 1707 | [] GTP.receive(tr_GTPC_MsgType(?, deletePDPContextRequest, apars.ggsn_tei_c)) -> value g_ud { |
| 1708 | /* SGSN currently doesn't send this message because it expects GGSN to be non-reachable anyway */ |
| 1709 | seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1710 | log("Received deletePDPContextRequest seq_nr=" & int2str(seq_nr)); |
| 1711 | GTP.send(ts_GTPC_DeletePdpResp(g_ud.peer, seq_nr, apars.sgsn_tei_c, '7F'O)); |
| 1712 | repeat; |
| 1713 | } |
| 1714 | [] GTP.receive(tr_GTPC_MsgType(?, echoRequest, ?)) -> value g_ud { |
| 1715 | seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1716 | log("Received EchoRequest seq_nr=" & int2str(seq_nr)); |
| 1717 | repeat; |
| 1718 | } |
| 1719 | [] T.timeout { |
| 1720 | setverdict(fail, "BSSGP DeactPdpReq not received"); |
| 1721 | mtc.stop; |
| 1722 | } |
| 1723 | [] as_xid(apars); |
| 1724 | } |
| 1725 | T.stop |
| 1726 | |
| 1727 | setverdict(pass); |
| 1728 | } |
| 1729 | /* ATTACH + trigger Recovery procedure through CreatePdpResp */ |
| 1730 | testcase TC_attach_echo_timeout() runs on test_CT { |
| 1731 | var BSSGP_ConnHdlr vc_conn; |
| 1732 | g_use_echo := true; |
| 1733 | f_init(); |
| 1734 | vc_conn := f_start_handler(refers(f_TC_attach_echo_timeout), testcasename(), g_gb, 67, 50.0); |
| 1735 | vc_conn.done; |
| 1736 | g_use_echo := false; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1737 | f_cleanup(); |
Pau Espin Pedrol | fcec914 | 2019-08-28 17:33:46 +0200 | [diff] [blame] | 1738 | } |
| 1739 | |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1740 | 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] | 1741 | var Gtp1cUnitdata g_ud; |
| 1742 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1743 | |
| 1744 | /* first perform regular attach */ |
| 1745 | f_TC_attach(id); |
| 1746 | /* Activate a pdp context against the GGSN */ |
| 1747 | f_pdp_ctx_act(apars); |
| 1748 | /* Wait to receive first echo request and send initial Restart counter */ |
| 1749 | GTP.receive(tr_GTPC_MsgType(?, echoRequest, ?)) -> value g_ud { |
| 1750 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1751 | GTP.send(ts_GTPC_PONG(g_ud.peer, seq_nr, apars.ggsn_restart_ctr)); |
| 1752 | } |
| 1753 | /* Wait to receive second echo request and send incremented Restart |
| 1754 | counter. This will fake a restarted GGSN, and pdp ctx allocated |
| 1755 | should be released by SGSN */ |
| 1756 | apars.ggsn_restart_ctr := int2oct(oct2int(apars.ggsn_restart_ctr) + 1, 1); |
| 1757 | GTP.receive(tr_GTPC_MsgType(?, echoRequest, ?)) -> value g_ud { |
| 1758 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1759 | GTP.send(ts_GTPC_PONG(g_ud.peer, seq_nr, apars.ggsn_restart_ctr)); |
| 1760 | } |
| 1761 | var OCT1 cause_network_failure := int2oct(38, 1) |
| 1762 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1763 | [] 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] | 1764 | f_send_l3(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid)); |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1765 | setverdict(pass); |
| 1766 | } |
| 1767 | [] as_xid(apars); |
| 1768 | } |
| 1769 | setverdict(pass); |
| 1770 | } |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1771 | /* ATTACH + trigger Recovery procedure through EchoResp */ |
| 1772 | testcase TC_attach_restart_ctr_echo() runs on test_CT { |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1773 | var BSSGP_ConnHdlr vc_conn; |
| 1774 | g_use_echo := true |
| 1775 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1776 | 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] | 1777 | vc_conn.done; |
| 1778 | g_use_echo := false |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1779 | f_cleanup(); |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1780 | } |
| 1781 | |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1782 | private function f_TC_attach_restart_ctr_create(charstring id) runs on BSSGP_ConnHdlr { |
| 1783 | var Gtp1cUnitdata g_ud; |
| 1784 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1785 | var integer seq_nr := 23; |
| 1786 | var GtpPeer peer; |
| 1787 | /* first perform regular attach */ |
| 1788 | f_TC_attach(id); |
| 1789 | |
| 1790 | /* Use this CTX ACT to send initial Restart counter to SGSN. */ |
| 1791 | apars.gtp_resp_cause := int2oct(199, 1); /* no resources available */ |
| 1792 | apars.exp_rej_cause := '1a'O; /* insufficient resources */ |
| 1793 | f_pdp_ctx_act(apars, true); |
| 1794 | |
| 1795 | /* Increment restart_ctr. This will fake a restarted GGSN when CreatePdpResp is |
| 1796 | /* received. */ |
| 1797 | apars.ggsn_restart_ctr := int2oct(oct2int(apars.ggsn_restart_ctr) + 1, 1); |
| 1798 | |
| 1799 | /* FIXME: Once we can easily handle different pdp ctx simultaneously, it |
| 1800 | would be great to have an active pdp context here before triggering |
| 1801 | Recovery, and making sure the the DEACT request is sent by the SGSN. |
| 1802 | */ |
| 1803 | |
| 1804 | /* Activate a pdp context against the GGSN, send incremented Recovery |
| 1805 | IE. This should trigger the recovery path, but still this specific |
| 1806 | CTX activation should work. */ |
| 1807 | apars.exp_rej_cause := omit; /* default value for tests */ |
| 1808 | apars.gtp_resp_cause := int2oct(128, 1); /* default value for tests */ |
| 1809 | f_pdp_ctx_act(apars, true); |
| 1810 | |
| 1811 | setverdict(pass); |
| 1812 | } |
| 1813 | /* ATTACH + trigger Recovery procedure through CreatePdpResp */ |
| 1814 | testcase TC_attach_restart_ctr_create() runs on test_CT { |
| 1815 | var BSSGP_ConnHdlr vc_conn; |
| 1816 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1817 | 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] | 1818 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1819 | f_cleanup(); |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1820 | } |
| 1821 | |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1822 | /* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MT direction + trigger T3395 */ |
| 1823 | private function f_TC_attach_pdp_act_deact_mt_t3395_expire(charstring id) runs on BSSGP_ConnHdlr { |
| 1824 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1825 | var integer seq_nr := 23; |
| 1826 | var GtpPeer peer; |
| 1827 | var integer i; |
| 1828 | |
| 1829 | /* first perform regular attach */ |
| 1830 | f_TC_attach(id); |
| 1831 | /* then activate PDP context */ |
| 1832 | f_pdp_ctx_act(apars); |
| 1833 | |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1834 | BSSGP[0].clear; |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1835 | peer := valueof(ts_GtpPeerC(apars.sgsn_ip_c)); |
| 1836 | GTP.send(ts_GTPC_DeletePDP(peer, seq_nr, apars.sgsn_tei_c, apars.nsapi, '1'B)); |
| 1837 | |
| 1838 | for (i := 0; i < 5; i := i+1) { |
| 1839 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1840 | [] 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] | 1841 | [] as_xid(apars); |
| 1842 | } |
| 1843 | } |
| 1844 | |
| 1845 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, apars.ggsn_tei_c)) {} |
| 1846 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 1847 | f_send_l3(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid)); |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1848 | setverdict(pass); |
| 1849 | } |
| 1850 | testcase TC_attach_pdp_act_deact_mt_t3395_expire() runs on test_CT { |
| 1851 | var BSSGP_ConnHdlr vc_conn; |
| 1852 | f_init(); |
| 1853 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 1854 | 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] | 1855 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1856 | f_cleanup(); |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1857 | } |
| 1858 | |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 1859 | /* ATTACH + PDP CTX ACT dropped + retrans */ |
| 1860 | private function f_TC_attach_pdp_act_deact_gtp_retrans(charstring id) runs on BSSGP_ConnHdlr { |
| 1861 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1862 | var Gtp1cUnitdata g_ud_first, g_ud_second; |
| 1863 | /* first perform regular attach */ |
| 1864 | f_TC_attach(id); |
| 1865 | |
| 1866 | /* then activate PDP context on the Gb side */ |
| 1867 | f_send_l3_gmm_llc(ts_SM_ACT_PDP_REQ(apars.tid, apars.nsapi, apars.sapi, apars.qos, apars.addr, |
| 1868 | apars.apn, apars.pco), 0); |
| 1869 | |
| 1870 | GTP.receive(tr_GTPC_MsgType(?, createPDPContextRequest, ?)) -> value g_ud_first {} |
| 1871 | log("First createPDPContextRequest received, dropping & waiting for retransmission"); |
| 1872 | GTP.receive(tr_GTPC_MsgType(?, createPDPContextRequest, ?)) -> value g_ud_second { |
| 1873 | if (g_ud_first != g_ud_second) { |
| 1874 | setverdict(fail, "Retransmitted GTP message createPDPContextRequest is different from original one!"); |
| 1875 | mtc.stop; |
| 1876 | } |
| 1877 | f_process_gtp_ctx_act_req(apars, g_ud_second.gtpc); |
| 1878 | var integer seq_nr := oct2int(g_ud_second.gtpc.opt_part.sequenceNumber); |
| 1879 | GTP.send(ts_GTPC_CreatePdpResp(g_ud_second.peer, seq_nr, |
| 1880 | apars.sgsn_tei_c, apars.gtp_resp_cause, |
| 1881 | apars.ggsn_tei_c, apars.ggsn_tei_u, |
| 1882 | apars.nsapi, |
| 1883 | apars.ggsn_ip_c, apars.ggsn_ip_u, apars.chg_id, |
| 1884 | omit, omit)); |
| 1885 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1886 | BSSGP[0].receive(tr_SM_ACT_PDP_ACCEPT) {} |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 1887 | |
| 1888 | /* Now the same with Deact */ |
| 1889 | f_send_l3_gmm_llc(ts_SM_DEACT_PDP_REQ_MO(apars.tid, '00'O, false, omit), 0); |
| 1890 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextRequest, apars.ggsn_tei_c)) -> value g_ud_first {} |
| 1891 | log("First deletePDPContextRequest received, dropping & waiting for retransmission"); |
| 1892 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextRequest, apars.ggsn_tei_c)) -> value g_ud_second { |
| 1893 | if (g_ud_first != g_ud_second) { |
| 1894 | setverdict(fail, "Retransmitted GTP message deletePDPContextRequest is different from original one!"); |
| 1895 | mtc.stop; |
| 1896 | } |
| 1897 | var integer seq_nr := oct2int(g_ud_second.gtpc.opt_part.sequenceNumber); |
| 1898 | BSSGP[0].clear; |
| 1899 | GTP.send(ts_GTPC_DeletePdpResp(g_ud_second.peer, seq_nr, apars.sgsn_tei_c, '7F'O)); |
| 1900 | } |
| 1901 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1902 | [] BSSGP[0].receive(tr_SM_DEACT_PDP_ACCEPT_MT(apars.tid)) { |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 1903 | setverdict(pass); |
| 1904 | } |
| 1905 | [] as_xid(apars, 0); |
| 1906 | } |
| 1907 | |
| 1908 | setverdict(pass); |
| 1909 | } |
| 1910 | testcase TC_attach_pdp_act_deact_gtp_retrans() runs on test_CT { |
| 1911 | var BSSGP_ConnHdlr vc_conn; |
| 1912 | f_init(); |
| 1913 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_deact_gtp_retrans), testcasename(), g_gb, 27); |
| 1914 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1915 | f_cleanup(); |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 1916 | } |
| 1917 | |
| 1918 | /* Test that SGSN GTP response retransmit queue works fine */ |
| 1919 | private function f_TC_attach_pdp_act_deact_gtp_retrans_resp(charstring id) runs on BSSGP_ConnHdlr { |
| 1920 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1921 | var integer seq_nr := 23; |
| 1922 | var Gtp1cUnitdata g_ud_first, g_ud_second; |
| 1923 | var template Gtp1cUnitdata g_delete_req; |
| 1924 | /* first perform regular attach + PDP context act */ |
| 1925 | f_TC_attach(id); |
| 1926 | f_pdp_ctx_act(apars); |
| 1927 | |
| 1928 | /* Now perform an MT DeleteCtxReq and emulate GGSN didn't receive response and sends a duplicated DeleteCtxReq */ |
| 1929 | BSSGP[0].clear; |
| 1930 | var GtpPeer peer := valueof(ts_GtpPeerC(apars.sgsn_ip_c)); |
| 1931 | g_delete_req := ts_GTPC_DeletePDP(peer, seq_nr, apars.sgsn_tei_c, apars.nsapi, '1'B); |
| 1932 | GTP.send(g_delete_req); |
| 1933 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1934 | [] BSSGP[0].receive(tr_SM_DEACT_PDP_REQ_MT(apars.tid, ?, true)) { |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 1935 | f_send_l3_gmm_llc(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid), 0); |
| 1936 | } |
| 1937 | [] as_xid(apars, 0); |
| 1938 | } |
| 1939 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, apars.ggsn_tei_c)) -> value g_ud_first { |
| 1940 | if (g_ud_first.gtpc.gtpc_pdu.deletePDPContextResponse.cause.causevalue != '80'O) { |
| 1941 | setverdict(fail, "Received deletePDPContextResponse cause is not 'Request accepted'"); |
| 1942 | mtc.stop; |
| 1943 | } |
| 1944 | }; |
| 1945 | |
| 1946 | /* Send duplicate DeleteCtxReq */ |
| 1947 | log("First deletePDPContextResponse received, dropping & retransmitting retransmission of deletePDPContextRequest"); |
| 1948 | GTP.send(g_delete_req); |
| 1949 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, apars.ggsn_tei_c)) -> value g_ud_second { |
| 1950 | if (g_ud_first != g_ud_second) { |
| 1951 | setverdict(fail, "Retransmitted GTP message deletePDPContextResponse is different from original one!"); |
| 1952 | mtc.stop; |
| 1953 | } |
| 1954 | } |
| 1955 | |
| 1956 | /* Let's send now a new DeleteCtxReq (increased seq_nr) to make sure it |
| 1957 | * is handled differently by SGSN (expect "non-existent" cause) */ |
| 1958 | g_delete_req := ts_GTPC_DeletePDP(peer, seq_nr + 1, apars.sgsn_tei_c, apars.nsapi, '1'B); |
| 1959 | GTP.send(g_delete_req); |
| 1960 | /* Response with cause "non-existent" must be sent with TEID 0 according to specs */ |
| 1961 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, '00000000'O)) -> value g_ud_second { |
| 1962 | if (g_ud_second.gtpc.gtpc_pdu.deletePDPContextResponse.cause.causevalue != 'C0'O) { |
| 1963 | setverdict(fail, "Received deletePDPContextResponse cause is not 'Non-existent'"); |
| 1964 | mtc.stop; |
| 1965 | } |
| 1966 | } |
| 1967 | |
| 1968 | setverdict(pass); |
| 1969 | } |
| 1970 | testcase TC_attach_pdp_act_deact_gtp_retrans_resp() runs on test_CT { |
| 1971 | var BSSGP_ConnHdlr vc_conn; |
| 1972 | f_init(); |
| 1973 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_deact_gtp_retrans_resp), testcasename(), g_gb, 28); |
| 1974 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 1975 | f_cleanup(); |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 1976 | } |
| 1977 | |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1978 | private function f_TC_hlr_location_cancel_request_update(charstring id) runs on BSSGP_ConnHdlr { |
| 1979 | /* MS: perform regular attach */ |
| 1980 | f_TC_attach(id); |
| 1981 | |
| 1982 | /* HLR: cancel the location request */ |
| 1983 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_UPDATE)); |
| 1984 | GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)); |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1985 | |
| 1986 | /* ensure no Detach Request got received */ |
| 1987 | timer T := 5.0; |
| 1988 | T.start; |
| 1989 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 1990 | [] BSSGP[0].receive(tr_GMM_DET_REQ_MT(*, *, *)) { |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1991 | T.stop; |
| 1992 | setverdict(fail, "Unexpected GMM Detach Request"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1993 | mtc.stop; |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1994 | } |
| 1995 | [] T.timeout { |
| 1996 | setverdict(pass); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1997 | mtc.stop; |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1998 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1999 | [] BSSGP[0].receive { |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 2000 | repeat; |
| 2001 | } |
| 2002 | } |
| 2003 | } |
| 2004 | |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 2005 | /* ATTACH + PDP CTX ACT + user plane traffic + ERROR IND in MT direction */ |
| 2006 | private function f_TC_attach_pdp_act_user_error_ind_ggsn(charstring id) runs on BSSGP_ConnHdlr { |
| 2007 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 2008 | |
| 2009 | /* first perform regular attach */ |
| 2010 | f_TC_attach(id); |
| 2011 | /* then activate PDP context */ |
| 2012 | f_pdp_ctx_act(apars); |
| 2013 | /* then transceive a downlink PDU */ |
| 2014 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 2015 | |
| 2016 | /* Send Error indication as response from upload PDU and expect deact towards MS */ |
| 2017 | f_pdp_ctx_deact_mt(apars, true); |
| 2018 | } |
| 2019 | testcase TC_attach_pdp_act_user_error_ind_ggsn() runs on test_CT { |
| 2020 | var BSSGP_ConnHdlr vc_conn; |
| 2021 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2022 | 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] | 2023 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2024 | f_cleanup(); |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 2025 | } |
| 2026 | |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 2027 | testcase TC_hlr_location_cancel_request_update() runs on test_CT { |
| 2028 | /* MS <-> SGSN: GMM Attach |
| 2029 | * HLR -> SGSN: Cancel Location Request |
| 2030 | * HLR <- SGSN: Cancel Location Ack |
| 2031 | */ |
| 2032 | var BSSGP_ConnHdlr vc_conn; |
| 2033 | f_init(); |
| 2034 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2035 | 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] | 2036 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2037 | f_cleanup(); |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 2038 | } |
| 2039 | |
| 2040 | |
Alexander Couzens | c87967a | 2018-05-22 16:09:54 +0200 | [diff] [blame] | 2041 | private function f_TC_hlr_location_cancel_request_withdraw(charstring id) runs on BSSGP_ConnHdlr { |
| 2042 | /* MS: perform regular attach */ |
| 2043 | f_TC_attach(id); |
| 2044 | |
| 2045 | /* HLR: cancel the location request */ |
| 2046 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_WITHDRAW)); |
| 2047 | GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)); |
| 2048 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 2049 | |
| 2050 | /* MS: receive a Detach Request */ |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2051 | 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] | 2052 | f_send_l3(ts_GMM_DET_ACCEPT_MO); |
Alexander Couzens | c87967a | 2018-05-22 16:09:54 +0200 | [diff] [blame] | 2053 | |
| 2054 | setverdict(pass); |
| 2055 | } |
| 2056 | |
| 2057 | testcase TC_hlr_location_cancel_request_withdraw() runs on test_CT { |
| 2058 | /* MS <-> SGSN: GMM Attach |
| 2059 | * HLR -> SGSN: Cancel Location Request |
| 2060 | * HLR <- SGSN: Cancel Location Ack |
| 2061 | * MS <- SGSN: Detach Request |
| 2062 | * SGSN-> MS: Detach Complete |
| 2063 | */ |
| 2064 | var BSSGP_ConnHdlr vc_conn; |
| 2065 | f_init(); |
| 2066 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2067 | 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] | 2068 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2069 | f_cleanup(); |
Alexander Couzens | c87967a | 2018-05-22 16:09:54 +0200 | [diff] [blame] | 2070 | } |
| 2071 | |
| 2072 | |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 2073 | private function f_hlr_location_cancel_request_unknown_subscriber( |
| 2074 | charstring id, |
| 2075 | GSUP_CancelType canceltype) runs on BSSGP_ConnHdlr { |
| 2076 | |
| 2077 | /* HLR: cancel the location request */ |
| 2078 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, canceltype)); |
| 2079 | |
| 2080 | /* cause 2 = IMSI_UNKNOWN */ |
| 2081 | GSUP.receive(tr_GSUP_CL_ERR(g_pars.imsi, 2)); |
| 2082 | |
| 2083 | setverdict(pass); |
| 2084 | } |
| 2085 | |
| 2086 | 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] | 2087 | 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] | 2088 | } |
| 2089 | |
| 2090 | testcase TC_hlr_location_cancel_request_unknown_subscriber_withdraw() runs on test_CT { |
| 2091 | /* HLR -> SGSN: Cancel Location Request |
| 2092 | * HLR <- SGSN: Cancel Location Error |
| 2093 | */ |
| 2094 | |
| 2095 | var BSSGP_ConnHdlr vc_conn; |
| 2096 | f_init(); |
| 2097 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2098 | 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] | 2099 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2100 | f_cleanup(); |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 2101 | } |
| 2102 | |
| 2103 | 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] | 2104 | 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] | 2105 | } |
| 2106 | |
| 2107 | testcase TC_hlr_location_cancel_request_unknown_subscriber_update() runs on test_CT { |
| 2108 | /* HLR -> SGSN: Cancel Location Request |
| 2109 | * HLR <- SGSN: Cancel Location Error |
| 2110 | */ |
| 2111 | |
| 2112 | var BSSGP_ConnHdlr vc_conn; |
| 2113 | f_init(); |
| 2114 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2115 | 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] | 2116 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2117 | f_cleanup(); |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 2118 | } |
| 2119 | |
Alexander Couzens | 49bb4b4 | 2018-06-05 16:28:36 +0200 | [diff] [blame] | 2120 | private function f_TC_attach_detach_check_subscriber_list(charstring id) runs on BSSGP_ConnHdlr { |
| 2121 | f_TC_attach(id); |
| 2122 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true); |
| 2123 | } |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 2124 | |
Alexander Couzens | 49bb4b4 | 2018-06-05 16:28:36 +0200 | [diff] [blame] | 2125 | testcase TC_attach_detach_check_subscriber_list() runs on test_CT { |
| 2126 | /* MS <-> SGSN: Attach |
| 2127 | * MS -> SGSN: Detach Req (Power off) |
| 2128 | * VTY -> SGSN: Check if MS is NOT in subscriber cache |
| 2129 | */ |
| 2130 | var BSSGP_ConnHdlr vc_conn; |
| 2131 | var integer id := 33; |
| 2132 | var charstring imsi := hex2str(f_gen_imsi(id)); |
| 2133 | |
| 2134 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2135 | 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] | 2136 | vc_conn.done; |
| 2137 | |
| 2138 | 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] | 2139 | f_cleanup(); |
Alexander Couzens | 49bb4b4 | 2018-06-05 16:28:36 +0200 | [diff] [blame] | 2140 | } |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 2141 | |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 2142 | /* Attempt an attach, but loose the Identification Request (IMEI) */ |
| 2143 | private function f_TC_attach_no_imei_response(charstring id) runs on BSSGP_ConnHdlr { |
| 2144 | var integer count_req := 0; |
| 2145 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 2146 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2147 | 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] | 2148 | |
| 2149 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2150 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 2151 | /* break */ |
| 2152 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2153 | [] BSSGP[0].receive(tr_GMM_ID_REQ('001'B)) { |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 2154 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2155 | f_send_l3(ts_GMM_ID_RESP(mi)); |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 2156 | repeat; |
| 2157 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2158 | [] BSSGP[0].receive(tr_GMM_ID_REQ('010'B)) { |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 2159 | /* ignore ID REQ IMEI */ |
| 2160 | count_req := count_req + 1; |
| 2161 | repeat; |
| 2162 | } |
| 2163 | } |
| 2164 | if (count_req != 5) { |
| 2165 | setverdict(fail, "Did not received GMM ID Request Type IMEI 5 times!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2166 | mtc.stop; |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 2167 | } |
| 2168 | setverdict(pass); |
| 2169 | } |
| 2170 | |
| 2171 | testcase TC_attach_no_imei_response() runs on test_CT { |
| 2172 | /* MS -> SGSN: Attach Request IMSI |
| 2173 | * MS <- SGSN: Identity Request IMSI (optional) |
| 2174 | * MS -> SGSN: Identity Response IMSI (optional) |
| 2175 | * MS <- SGSN: Identity Request IMEI |
| 2176 | * MS -x SGSN: no response |
| 2177 | * MS <- SGSN: re-send: Identity Request IMEI 4x |
| 2178 | * MS <- SGSN: Attach Reject |
| 2179 | */ |
| 2180 | var BSSGP_ConnHdlr vc_conn; |
| 2181 | f_init(); |
| 2182 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2183 | 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] | 2184 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2185 | f_cleanup(); |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 2186 | } |
| 2187 | |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 2188 | /* Attempt an attach, but loose the Identification Request (IMSI) */ |
| 2189 | private function f_TC_attach_no_imsi_response(charstring id) runs on BSSGP_ConnHdlr { |
| 2190 | var integer count_req := 0; |
| 2191 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 2192 | |
| 2193 | /* set p_tmsi to use it in Attach Req via f_mi_get_lv() */ |
| 2194 | g_pars.p_tmsi := 'c0000035'O; |
| 2195 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2196 | 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] | 2197 | |
| 2198 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2199 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 2200 | /* break */ |
| 2201 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2202 | [] BSSGP[0].receive(tr_GMM_ID_REQ('001'B)) { |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 2203 | /* ignore ID REQ IMSI */ |
| 2204 | count_req := count_req + 1; |
| 2205 | repeat; |
| 2206 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2207 | [] BSSGP[0].receive(tr_GMM_ID_REQ('010'B)) { |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 2208 | mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2209 | f_send_l3(ts_GMM_ID_RESP(mi)); |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 2210 | repeat; |
| 2211 | } |
| 2212 | } |
| 2213 | if (count_req != 5) { |
| 2214 | setverdict(fail, "Did not received GMM ID Request Type IMSI 5 times!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2215 | mtc.stop; |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 2216 | } |
| 2217 | setverdict(pass); |
| 2218 | } |
| 2219 | |
| 2220 | testcase TC_attach_no_imsi_response() runs on test_CT { |
| 2221 | /* MS -> SGSN: Attach Request TMSI (unknown) |
| 2222 | * MS <- SGSN: Identity Request IMEI (optional) |
| 2223 | * MS -> SGSN: Identity Response IMEI (optional) |
| 2224 | * MS <- SGSN: Identity Request IMSI |
| 2225 | * MS -x SGSN: no response |
| 2226 | * MS <- SGSN: re-send: Identity Request IMSI 4x |
| 2227 | * MS <- SGSN: Attach Reject |
| 2228 | */ |
| 2229 | var BSSGP_ConnHdlr vc_conn; |
| 2230 | f_init(); |
| 2231 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2232 | 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] | 2233 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2234 | f_cleanup(); |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 2235 | } |
| 2236 | |
Alexander Couzens | cf81896 | 2018-06-05 18:00:00 +0200 | [diff] [blame] | 2237 | private function f_sgsn_vty_destroy_subscriber_imsi(TELNETasp_PT pt, charstring imsi) { |
| 2238 | f_vty_transceive(pt, "update-subscriber imsi " & imsi & " destroy"); |
| 2239 | } |
| 2240 | |
| 2241 | testcase TC_attach_check_subscriber_list() runs on test_CT { |
| 2242 | /* MS <-> SGSN: Attach |
| 2243 | * VTY -> SGSN: Check if MS is in subscriber cache |
| 2244 | */ |
| 2245 | var BSSGP_ConnHdlr vc_conn; |
| 2246 | var integer id := 34; |
| 2247 | var charstring imsi := hex2str(f_gen_imsi(id)); |
| 2248 | |
| 2249 | f_init(); |
| 2250 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2251 | 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] | 2252 | vc_conn.done; |
| 2253 | |
| 2254 | f_vty_transceive_match(SGSNVTY, "show subscriber cache", pattern "* IMSI: {imsi}*"); |
| 2255 | f_sgsn_vty_destroy_subscriber_imsi(SGSNVTY, imsi); |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2256 | f_cleanup(); |
Alexander Couzens | cf81896 | 2018-06-05 18:00:00 +0200 | [diff] [blame] | 2257 | } |
| 2258 | |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 2259 | private function f_TC_attach_closed_imsi_added(charstring id) runs on BSSGP_ConnHdlr { |
| 2260 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2261 | var PDU_L3_SGSN_MS l3_mt; |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 2262 | |
| 2263 | /* unregister the old IMSI */ |
| 2264 | f_bssgp_client_unregister(g_pars.imsi); |
| 2265 | /* Simulate a foreign IMSI */ |
Alexander Couzens | 03d1224 | 2018-08-07 16:13:52 +0200 | [diff] [blame] | 2266 | g_pars.imsi := '001010123456700'H; |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2267 | f_bssgp_client_register(g_pars.imsi, g_pars.tlli, g_pars.bssgp_cell_id[0]); |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 2268 | |
| 2269 | /* there is no auth */ |
| 2270 | g_pars.net.expect_auth := false; |
| 2271 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2272 | 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] | 2273 | f_gmm_auth(); |
| 2274 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2275 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 2276 | setverdict(fail, "Received unexpected GMM Attach REJECT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2277 | mtc.stop; |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 2278 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2279 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT(*, *, *)) -> value l3_mt { |
| 2280 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2281 | f_send_l3(ts_GMM_ATTACH_COMPL); |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 2282 | setverdict(pass); |
| 2283 | } |
| 2284 | } |
| 2285 | } |
Alexander Couzens | 03d1224 | 2018-08-07 16:13:52 +0200 | [diff] [blame] | 2286 | |
| 2287 | private function f_TC_attach_closed_add_vty(charstring id) runs on BSSGP_ConnHdlr { |
| 2288 | |
| 2289 | f_TC_attach_closed_foreign(id); |
| 2290 | f_TC_attach_closed_imsi_added(id); |
| 2291 | |
| 2292 | } |
| 2293 | |
| 2294 | |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 2295 | testcase TC_attach_closed_add_vty() runs on test_CT { |
| 2296 | /* VTY-> SGSN: policy close |
| 2297 | * MS -> SGSN: Attach Request |
| 2298 | * MS <- SGSN: Identity Request IMSI |
| 2299 | * MS -> SGSN: Identity Response IMSI |
| 2300 | * MS <- SGSN: Attach Reject |
| 2301 | * VTY-> SGSN: policy imsi-acl add IMSI |
| 2302 | * MS -> SGSN: Attach Request |
| 2303 | * MS <- SGSN: Identity Request IMSI |
| 2304 | * MS -> SGSN: Identity Response IMSI |
| 2305 | * MS <- SGSN: Identity Request IMEI |
| 2306 | * MS -> SGSN: Identity Response IMEI |
| 2307 | * MS <- SGSN: Attach Accept |
| 2308 | */ |
| 2309 | var BSSGP_ConnHdlr vc_conn; |
| 2310 | f_init(); |
| 2311 | f_sleep(1.0); |
| 2312 | f_vty_config(SGSNVTY, "sgsn", "auth-policy closed"); |
| 2313 | f_vty_config(SGSNVTY, "sgsn", "imsi-acl del 001010123456789"); |
Alexander Couzens | 03d1224 | 2018-08-07 16:13:52 +0200 | [diff] [blame] | 2314 | f_vty_config(SGSNVTY, "sgsn", "imsi-acl del 001010123456700"); |
| 2315 | f_vty_config(SGSNVTY, "sgsn", "imsi-acl add 001010123456700"); |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 2316 | /* test with foreign IMSI: Must Reject */ |
Alexander Couzens | 03d1224 | 2018-08-07 16:13:52 +0200 | [diff] [blame] | 2317 | 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] | 2318 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2319 | f_cleanup(); |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 2320 | } |
| 2321 | |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2322 | /* Attempt an attach, but never answer a Attach Complete */ |
| 2323 | private function f_TC_attach_check_complete_resend(charstring id) runs on BSSGP_ConnHdlr { |
| 2324 | var integer count_req := 0; |
| 2325 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2326 | 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] | 2327 | f_gmm_auth(); |
| 2328 | |
Alexander Couzens | fa0a75f | 2018-08-07 15:45:04 +0200 | [diff] [blame] | 2329 | timer T := 10.0; |
| 2330 | T.start; |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2331 | alt { |
Alexander Couzens | fa0a75f | 2018-08-07 15:45:04 +0200 | [diff] [blame] | 2332 | [] T.timeout { |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2333 | /* break */ |
| 2334 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2335 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT(*, *, *)) { |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2336 | /* ignore */ |
| 2337 | count_req := count_req + 1; |
Alexander Couzens | fa0a75f | 2018-08-07 15:45:04 +0200 | [diff] [blame] | 2338 | T.start; |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2339 | repeat; |
| 2340 | } |
| 2341 | } |
| 2342 | if (count_req != 5) { |
| 2343 | setverdict(fail, "Did not received GMM Attach Complete."); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2344 | mtc.stop; |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2345 | } |
| 2346 | setverdict(pass); |
| 2347 | } |
| 2348 | |
| 2349 | testcase TC_attach_check_complete_resend() runs on test_CT { |
| 2350 | /* MS -> SGSN: Attach Request IMSI |
| 2351 | * MS <- SGSN: Identity Request * |
| 2352 | * MS -> SGSN: Identity Response * |
| 2353 | * MS <- SGSN: Attach Complete 5x |
| 2354 | */ |
| 2355 | var BSSGP_ConnHdlr vc_conn; |
| 2356 | f_init(); |
| 2357 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame] | 2358 | 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] | 2359 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2360 | f_cleanup(); |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2361 | } |
| 2362 | |
Alexander Couzens | 5d56f52 | 2019-09-03 12:36:18 +0200 | [diff] [blame^] | 2363 | friend function f_routing_area_update(RoutingAreaIdentificationV ra, integer bssgp := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2364 | var PDU_L3_SGSN_MS l3_mt; |
Alexander Couzens | 5d56f52 | 2019-09-03 12:36:18 +0200 | [diff] [blame^] | 2365 | var PDU_DTAP_PS_MT mt; |
| 2366 | var template OCT4 p_tmsi := omit; |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 2367 | |
Alexander Couzens | 5d56f52 | 2019-09-03 12:36:18 +0200 | [diff] [blame^] | 2368 | if (is_iu(bssgp)) { |
| 2369 | p_tmsi := g_pars.p_tmsi; |
| 2370 | } |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 2371 | /* then send RAU */ |
Alexander Couzens | 5d56f52 | 2019-09-03 12:36:18 +0200 | [diff] [blame^] | 2372 | f_send_l3(ts_GMM_RAU_REQ(f_mi_get_lv(), GPRS_UPD_T_RA, g_pars.ra, false, omit, omit, p_tmsi), bssgp); |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 2373 | alt { |
Alexander Couzens | 5d56f52 | 2019-09-03 12:36:18 +0200 | [diff] [blame^] | 2374 | [is_gb(bssgp)] BSSGP[bssgp].receive(tr_GMM_RAU_ACCEPT) -> value l3_mt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2375 | f_process_rau_accept(l3_mt.msgs.gprs_mm.routingAreaUpdateAccept, bssgp); |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2376 | f_send_l3(ts_GMM_RAU_COMPL, bssgp); |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 2377 | setverdict(pass); |
| 2378 | } |
Alexander Couzens | 5d56f52 | 2019-09-03 12:36:18 +0200 | [diff] [blame^] | 2379 | [is_iu(bssgp)] BSSAP.receive(tr_PDU_DTAP_PS_MT(tr_GMM_RAU_ACCEPT)) -> value mt { |
| 2380 | f_process_rau_accept(mt.dtap.msgs.gprs_mm.routingAreaUpdateAccept, bssgp); |
| 2381 | f_send_l3(ts_GMM_RAU_COMPL, bssgp); |
| 2382 | setverdict(pass); |
| 2383 | } |
| 2384 | |
| 2385 | [is_gb(bssgp)] BSSGP[bssgp].receive(tr_GMM_RAU_REJECT) { |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 2386 | setverdict(fail, "Unexpected RAU Reject"); |
| 2387 | mtc.stop; |
| 2388 | } |
Alexander Couzens | 5d56f52 | 2019-09-03 12:36:18 +0200 | [diff] [blame^] | 2389 | [is_iu(bssgp)] BSSAP.receive(tr_PDU_DTAP_PS_MT(tr_GMM_RAU_REJECT)) { |
| 2390 | setverdict(fail, "Unexpected RAU Reject"); |
| 2391 | mtc.stop; |
| 2392 | } |
| 2393 | |
| 2394 | [is_iu(bssgp)] BSSAP.receive(tr_RANAP_SecurityModeCmd(uia_algs := ?, uia_key := oct2bit(g_pars.vec.ik), |
| 2395 | key_sts := ?)) { |
| 2396 | var IntegrityProtectionAlgorithm uia_chosen := 0; /* 0 = standard_UMTS_integrity_algorithm_UIA1 */ |
| 2397 | BSSAP.send(ts_RANAP_SecurityModeComplete(uia_chosen)); |
| 2398 | } |
| 2399 | [is_gb(bssgp)] BSSGP[bssgp].receive { repeat; } |
| 2400 | [is_iu(bssgp)] BSSAP.receive { repeat; } |
Alexander Couzens | 5dce90d | 2018-07-31 03:16:37 +0200 | [diff] [blame] | 2401 | } |
| 2402 | } |
| 2403 | |
Alexander Couzens | bfda921 | 2018-07-31 03:17:33 +0200 | [diff] [blame] | 2404 | 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] | 2405 | /* first perform regular attach */ |
| 2406 | f_TC_attach(id); |
| 2407 | |
| 2408 | /* then send RAU */ |
| 2409 | f_routing_area_update(g_pars.ra); |
| 2410 | |
| 2411 | /* do another RAU */ |
| 2412 | f_routing_area_update(g_pars.ra); |
| 2413 | |
| 2414 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true); |
| 2415 | } |
| 2416 | |
| 2417 | testcase TC_attach_rau_a_a() runs on test_CT { |
| 2418 | /* MS <-> SGSN: Successful Attach |
| 2419 | * MS -> SGSN: Routing Area Update Request |
| 2420 | * MS <- SGSN: Routing Area Update Accept |
| 2421 | * MS -> SGSN: Routing Area Update Request |
| 2422 | * MS <- SGSN: Routing Area Update Accept |
| 2423 | * MS -> SGSN: Detach (PowerOff) |
| 2424 | */ |
| 2425 | var BSSGP_ConnHdlr vc_conn; |
| 2426 | f_init(); |
| 2427 | f_sleep(1.0); |
| 2428 | vc_conn := f_start_handler(refers(f_TC_attach_rau_a_a), testcasename(), g_gb, 37); |
| 2429 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2430 | f_cleanup(); |
Alexander Couzens | bfda921 | 2018-07-31 03:17:33 +0200 | [diff] [blame] | 2431 | } |
| 2432 | |
Alexander Couzens | be837bd | 2018-07-31 04:20:11 +0200 | [diff] [blame] | 2433 | 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] | 2434 | f_TC_attach(id); |
| 2435 | |
| 2436 | log("attach complete sending rau"); |
| 2437 | f_routing_area_update(g_pars.ra, 0); |
| 2438 | |
| 2439 | log("rau complete unregistering"); |
| 2440 | f_bssgp_client_unregister(g_pars.imsi); |
| 2441 | f_bssgp_client_register(g_pars.imsi, g_pars.tlli, g_pars.bssgp_cell_id[1], BSSGP_PROC[1]); |
| 2442 | |
| 2443 | log("sending second RAU via different RA"); |
| 2444 | f_routing_area_update(f_cellid_to_RAI(g_pars.bssgp_cell_id[1]), 1); |
| 2445 | |
| 2446 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true, 1); |
| 2447 | } |
| 2448 | |
| 2449 | testcase TC_attach_rau_a_b() runs on test_CT { |
| 2450 | /* MS <-> SGSN: Successful Attach |
| 2451 | * MS -> SGSN: Routing Area _a_ Update Request |
| 2452 | * MS <- SGSN: Routing Area _a_ Update Accept |
| 2453 | * MS -> SGSN: Routing Area _b_ Update Request |
| 2454 | * MS <- SGSN: Routing Area _b_ Update Accept |
| 2455 | * MS -> SGSN: Detach (PowerOff) |
| 2456 | */ |
| 2457 | var BSSGP_ConnHdlr vc_conn; |
| 2458 | f_init(); |
| 2459 | f_sleep(1.0); |
| 2460 | vc_conn := f_start_handler(refers(f_TC_attach_rau_a_b), testcasename(), g_gb, 38); |
| 2461 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2462 | f_cleanup(); |
Alexander Couzens | be837bd | 2018-07-31 04:20:11 +0200 | [diff] [blame] | 2463 | } |
| 2464 | |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2465 | private function f_TC_attach_gmm_attach_req_while_gmm_attach(charstring id) runs on BSSGP_ConnHdlr { |
| 2466 | var integer count_req := 0; |
| 2467 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 2468 | var RoutingAreaIdentificationV rand_rai := f_random_RAI(); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2469 | var PDU_L3_SGSN_MS l3_mt; |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2470 | |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2471 | 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] | 2472 | |
| 2473 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2474 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2475 | setverdict(fail, "Unexpected GMM ATTACH REJECT"); |
| 2476 | mtc.stop; |
| 2477 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2478 | [] BSSGP[0].receive(tr_GMM_ID_REQ('001'B)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2479 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2480 | f_send_l3(ts_GMM_ID_RESP(mi)); |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2481 | repeat; |
| 2482 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2483 | [] BSSGP[0].receive(tr_GMM_ID_REQ('010'B)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2484 | /* send out a second GMM_Attach Request. |
| 2485 | * If the SGSN follows the rules, this 2nd ATTACH REQ should be ignored, because |
| 2486 | * of the same content */ |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2487 | 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] | 2488 | mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2489 | f_send_l3(ts_GMM_ID_RESP(mi)); |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2490 | } |
| 2491 | } |
| 2492 | f_sleep(1.0); |
| 2493 | |
| 2494 | /* we've sent already a IMEI answer, we should NOT asked again for IMEI */ |
| 2495 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2496 | [] BSSGP[0].receive(tr_GMM_ID_REQ('001'B)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2497 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2498 | f_send_l3(ts_GMM_ID_RESP(mi)); |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2499 | repeat; |
| 2500 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2501 | [] BSSGP[0].receive(tr_GMM_ID_REQ('010'B)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2502 | setverdict(fail, "Unexpected GMM ID REQ (IMEI)."); |
| 2503 | mtc.stop; |
| 2504 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2505 | [] BSSGP[0].receive(tr_GMM_ATTACH_REJECT(?)) { |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2506 | setverdict(fail, "Unexpected GMM ATTACH REJECT"); |
| 2507 | mtc.stop; |
| 2508 | } |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2509 | [] BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 2510 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2511 | f_send_l3(ts_GMM_ATTACH_COMPL); |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2512 | setverdict(pass); |
| 2513 | /* FIXME: Extract P-TMSI, if any. Only send Complete if necessary */ |
| 2514 | } |
| 2515 | } |
| 2516 | } |
| 2517 | |
| 2518 | testcase TC_attach_gmm_attach_req_while_gmm_attach() runs on test_CT { |
| 2519 | /* Testing if the SGSN ignore Attach Request with the exact same content */ |
| 2520 | /* MS -> SGSN: Attach Request IMSI |
| 2521 | * MS <- SGSN: Identity Request IMSI (optional) |
| 2522 | * MS -> SGSN: Identity Response IMSI (optional) |
| 2523 | * MS <- SGSN: Identity Request IMEI |
| 2524 | * MS -> SGSN: Attach Request (2nd) |
| 2525 | * MS <- SGSN: Identity Response IMEI |
| 2526 | * MS <- SGSN: Attach Accept |
| 2527 | * MS -> SGSN: Attach Complete |
| 2528 | */ |
| 2529 | var BSSGP_ConnHdlr vc_conn; |
| 2530 | f_init(); |
| 2531 | f_sleep(1.0); |
| 2532 | f_vty_config(SGSNVTY, "sgsn", "auth-policy accept-all"); |
| 2533 | vc_conn := f_start_handler(refers(f_TC_attach_gmm_attach_req_while_gmm_attach), testcasename(), g_gb, 39); |
| 2534 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2535 | f_cleanup(); |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2536 | } |
| 2537 | |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2538 | 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] | 2539 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 2540 | |
| 2541 | var template PDU_L3_MS_SGSN attach_req := ts_GMM_ATTACH_REQ(f_mi_get_lv(), old_ra, false, false, omit, omit); |
| 2542 | |
| 2543 | /* send Attach Request */ |
| 2544 | /* indicate R99 capability of the MS to enable UMTS AKA in presence of |
| 2545 | * 3G auth vectors */ |
| 2546 | attach_req.msgs.gprs_mm.attachRequest.msNetworkCapability.msNetworkCapabilityV.revisionLevelIndicatior := '1'B; |
| 2547 | /* The thing is, if the solSACapability is 'omit', then the |
| 2548 | * revisionLevelIndicatior is at the wrong place! */ |
| 2549 | attach_req.msgs.gprs_mm.attachRequest.msNetworkCapability.msNetworkCapabilityV.solSACapability := '0'B; |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2550 | f_send_l3(attach_req); |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2551 | |
| 2552 | /* do the auth */ |
| 2553 | var PDU_L3_MS_SGSN l3_mo; |
| 2554 | var PDU_L3_SGSN_MS l3_mt; |
| 2555 | var default di := activate(as_mm_identity()); |
| 2556 | |
| 2557 | var GSUP_IE auth_tuple; |
| 2558 | var template AuthenticationParameterAUTNTLV autn; |
| 2559 | |
| 2560 | g_pars.vec := f_gen_auth_vec_3g(); |
| 2561 | autn := { |
| 2562 | elementIdentifier := '28'O, |
| 2563 | lengthIndicator := lengthof(g_pars.vec.autn), |
| 2564 | autnValue := g_pars.vec.autn |
| 2565 | }; |
| 2566 | auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 2567 | g_pars.vec.sres, |
| 2568 | g_pars.vec.kc, |
| 2569 | g_pars.vec.ik, |
| 2570 | g_pars.vec.ck, |
| 2571 | g_pars.vec.autn, |
| 2572 | g_pars.vec.res)); |
| 2573 | log("GSUP sends 2G and 3G auth tuples", auth_tuple); |
| 2574 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 2575 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 2576 | |
| 2577 | var template PDU_L3_SGSN_MS auth_ciph_req := tr_GMM_AUTH_REQ(g_pars.vec.rand); |
| 2578 | auth_ciph_req.msgs.gprs_mm.authenticationAndCipheringRequest.authenticationParameterAUTN := autn; |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2579 | BSSGP[0].receive(auth_ciph_req) -> value l3_mt; |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2580 | |
| 2581 | /* send the gmm auth failure with resync IE */ |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2582 | 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] | 2583 | |
| 2584 | /* wait for the GSUP resync request */ |
| 2585 | GSUP.receive(tr_GSUP_SAI_REQ_UMTS_AKA_RESYNC( |
| 2586 | g_pars.imsi, |
| 2587 | g_pars.vec.auts, |
| 2588 | g_pars.vec.rand)); |
| 2589 | |
| 2590 | /* generate new key material */ |
| 2591 | g_pars.vec := f_gen_auth_vec_3g(); |
| 2592 | autn := { |
| 2593 | elementIdentifier := '28'O, |
| 2594 | lengthIndicator := lengthof(g_pars.vec.autn), |
| 2595 | autnValue := g_pars.vec.autn |
| 2596 | }; |
| 2597 | |
| 2598 | auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 2599 | g_pars.vec.sres, |
| 2600 | g_pars.vec.kc, |
| 2601 | g_pars.vec.ik, |
| 2602 | g_pars.vec.ck, |
| 2603 | g_pars.vec.autn, |
| 2604 | g_pars.vec.res)); |
| 2605 | /* send new key material */ |
| 2606 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 2607 | |
| 2608 | /* wait for the new Auth Request */ |
| 2609 | auth_ciph_req := tr_GMM_AUTH_REQ(g_pars.vec.rand); |
| 2610 | auth_ciph_req.msgs.gprs_mm.authenticationAndCipheringRequest.authenticationParameterAUTN := autn; |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2611 | BSSGP[0].receive(auth_ciph_req) -> value l3_mt; |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2612 | var BIT4 ac_ref := l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.acReferenceNumber.valueField; |
| 2613 | var template PDU_L3_MS_SGSN auth_ciph_resp := ts_GMM_AUTH_RESP_2G(ac_ref, g_pars.vec.sres); |
| 2614 | auth_ciph_resp := ts_GMM_AUTH_RESP_2G(ac_ref, g_pars.vec.sres); |
| 2615 | auth_ciph_resp.msgs.gprs_mm.authenticationAndCipheringResponse.authenticationParResp := { |
| 2616 | valueField := substr(g_pars.vec.res, 0, 4) |
| 2617 | }; |
| 2618 | auth_ciph_resp.msgs.gprs_mm.authenticationAndCipheringResponse.authenticationRespParExt := { |
| 2619 | elementIdentifier := '21'O, |
| 2620 | lengthIndicator := lengthof(g_pars.vec.res) - 4, |
| 2621 | valueField := substr(g_pars.vec.res, 4, lengthof(g_pars.vec.res) - 4) |
| 2622 | }; |
| 2623 | l3_mo := valueof(auth_ciph_resp); |
| 2624 | if (ispresent(l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.imeisvRequest) and |
| 2625 | l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.imeisvRequest.valueField == '001'B) { |
| 2626 | l3_mo.msgs.gprs_mm.authenticationAndCipheringResponse.imeisv := |
| 2627 | valueof(ts_MI_IMEISV_TLV(g_pars.imei & '0'H)); |
| 2628 | } |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2629 | f_send_l3(l3_mo); |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2630 | deactivate(di); |
| 2631 | |
| 2632 | /* Expect SGSN to perform LU with HLR */ |
| 2633 | f_gmm_gsup_lu_isd(); |
| 2634 | |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2635 | BSSGP[0].receive(tr_GMM_ATTACH_ACCEPT('001'B, ?, ?)) -> value l3_mt { |
| 2636 | f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept); |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2637 | } |
Alexander Couzens | 4444b5a | 2019-08-13 13:25:32 +0200 | [diff] [blame] | 2638 | f_send_l3(ts_GMM_ATTACH_COMPL); |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2639 | setverdict(pass); |
| 2640 | } |
| 2641 | |
| 2642 | testcase TC_attach_usim_resync() runs on test_CT { |
| 2643 | /* MS -> SGSN: Attach Request |
| 2644 | * MS <- SGSN: Identity Request IMSI |
| 2645 | * MS -> SGSN: Identity Response IMSI |
| 2646 | * MS <- SGSN: Identity Request IMEI |
| 2647 | * MS -> SGSN: Identity Response IMEI |
| 2648 | * HLR<- SGSN: SAI Request |
| 2649 | * HLR-> SGSN: SAI Response |
| 2650 | * MS <- SGSN: Auth Request |
| 2651 | * MS -> SGSN: Auth Failure (with AUTS) |
| 2652 | * HLR<- SGSN: SAI Request (with AUTS & RAND) |
| 2653 | * HLR-> SGSN: SAI Response (new key material) |
| 2654 | * MS <- SGSN: Auth Request (new key material) |
| 2655 | * MS -> SGSN: Auth Response |
| 2656 | * MS <- SGSN: Attach Accept |
| 2657 | * MS -> SGSN: Attach Complete |
| 2658 | */ |
| 2659 | var BSSGP_ConnHdlr vc_conn; |
| 2660 | f_init(); |
| 2661 | f_sleep(1.0); |
| 2662 | vc_conn := f_start_handler(refers(f_TC_attach_usim_resync), testcasename(), g_gb, 40); |
| 2663 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2664 | f_cleanup(); |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2665 | } |
| 2666 | |
Harald Welte | a05b807 | 2019-04-23 22:35:05 +0200 | [diff] [blame] | 2667 | |
| 2668 | /* Send LLC NULL to see if the SGSN survives it (OS#3952) */ |
| 2669 | private function f_TC_llc_null(charstring id) runs on BSSGP_ConnHdlr { |
| 2670 | f_gmm_attach(false, false); |
| 2671 | f_sleep(1.0); |
| 2672 | f_send_llc(ts_LLC_NULL('0'B, c_LLC_SAPI_LLGMM, LLC_CR_UL_CMD)); |
| 2673 | /* try to detach to check if SGSN is still alive */ |
| 2674 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true); |
| 2675 | } |
| 2676 | testcase TC_llc_null() runs on test_CT { |
| 2677 | var BSSGP_ConnHdlr vc_conn; |
| 2678 | f_init(); |
| 2679 | f_sleep(1.0); |
| 2680 | vc_conn := f_start_handler(refers(f_TC_llc_null), testcasename(), g_gb, 41); |
| 2681 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2682 | f_cleanup(); |
Harald Welte | a05b807 | 2019-04-23 22:35:05 +0200 | [diff] [blame] | 2683 | } |
| 2684 | |
Harald Welte | 645a151 | 2019-04-23 23:18:23 +0200 | [diff] [blame] | 2685 | /* Send LLC SABM to see if the SGSN rejects it properly with DM */ |
| 2686 | private function f_TC_llc_sabm_dm_llgmm(charstring id) runs on BSSGP_ConnHdlr { |
| 2687 | f_gmm_attach(false, false); |
| 2688 | f_sleep(1.0); |
| 2689 | 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] | 2690 | 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] | 2691 | setverdict(pass); |
| 2692 | } |
| 2693 | testcase TC_llc_sabm_dm_llgmm() runs on test_CT { |
| 2694 | var BSSGP_ConnHdlr vc_conn; |
| 2695 | f_init(); |
| 2696 | f_sleep(1.0); |
| 2697 | vc_conn := f_start_handler(refers(f_TC_llc_sabm_dm_llgmm), testcasename(), g_gb, 42); |
| 2698 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2699 | f_cleanup(); |
Harald Welte | 645a151 | 2019-04-23 23:18:23 +0200 | [diff] [blame] | 2700 | } |
| 2701 | |
| 2702 | /* Send LLC SABM to see if the SGSN rejects it properly with DM */ |
| 2703 | private function f_TC_llc_sabm_dm_ll5(charstring id) runs on BSSGP_ConnHdlr { |
| 2704 | f_gmm_attach(false, false); |
| 2705 | f_sleep(1.0); |
| 2706 | 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] | 2707 | 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] | 2708 | setverdict(pass); |
| 2709 | } |
| 2710 | testcase TC_llc_sabm_dm_ll5() runs on test_CT { |
| 2711 | var BSSGP_ConnHdlr vc_conn; |
| 2712 | f_init(); |
| 2713 | f_sleep(1.0); |
| 2714 | vc_conn := f_start_handler(refers(f_TC_llc_sabm_dm_ll5), testcasename(), g_gb, 43); |
| 2715 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2716 | f_cleanup(); |
Harald Welte | 645a151 | 2019-04-23 23:18:23 +0200 | [diff] [blame] | 2717 | } |
| 2718 | |
Harald Welte | 2aaac1b | 2019-05-02 10:02:53 +0200 | [diff] [blame] | 2719 | /* test XID handshake with empty L3 info: expect empty return (some phones require that, OS#3426 */ |
| 2720 | private function f_TC_xid_empty_l3(charstring id) runs on BSSGP_ConnHdlr { |
| 2721 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 2722 | var template (value) XID_Information xid; |
| 2723 | var template XID_Information xid_rx; |
| 2724 | |
| 2725 | /* first perform regular attach */ |
| 2726 | f_TC_attach(id); |
| 2727 | /* then activate PDP context */ |
| 2728 | f_pdp_ctx_act(apars); |
| 2729 | |
| 2730 | /* start MO XID */ |
| 2731 | xid := { ts_XID_L3(''O) }; |
| 2732 | xid_rx := { tr_XID_L3(''O) }; |
| 2733 | f_send_llc(ts_LLC_XID_MO_CMD(xid, apars.sapi)); |
| 2734 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2735 | [] BSSGP[0].receive(tr_LLC_XID(xid_rx, apars.sapi)); |
Harald Welte | 2aaac1b | 2019-05-02 10:02:53 +0200 | [diff] [blame] | 2736 | [] as_xid(apars); |
| 2737 | } |
| 2738 | setverdict(pass); |
| 2739 | } |
| 2740 | testcase TC_xid_empty_l3() runs on test_CT { |
| 2741 | var BSSGP_ConnHdlr vc_conn; |
| 2742 | f_init(); |
| 2743 | f_sleep(1.0); |
| 2744 | vc_conn := f_start_handler(refers(f_TC_xid_empty_l3), testcasename(), g_gb, 44); |
| 2745 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2746 | f_cleanup(); |
Harald Welte | 2aaac1b | 2019-05-02 10:02:53 +0200 | [diff] [blame] | 2747 | } |
| 2748 | |
| 2749 | private function f_TC_xid_n201u(charstring id) runs on BSSGP_ConnHdlr { |
| 2750 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 2751 | var template (value) XID_Information xid; |
| 2752 | var template XID_Information xid_rx; |
| 2753 | |
| 2754 | /* first perform regular attach */ |
| 2755 | f_TC_attach(id); |
| 2756 | /* then activate PDP context */ |
| 2757 | f_pdp_ctx_act(apars); |
| 2758 | |
| 2759 | /* start MO XID */ |
| 2760 | xid := { ts_XID_N201U(1234) }; |
| 2761 | xid_rx := { tr_XID_N201U(1234) }; |
| 2762 | f_send_llc(ts_LLC_XID_MO_CMD(xid, apars.sapi)); |
| 2763 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 2764 | [] BSSGP[0].receive(tr_LLC_XID_MT_RSP(xid_rx, apars.sapi)); |
Harald Welte | 2aaac1b | 2019-05-02 10:02:53 +0200 | [diff] [blame] | 2765 | [] as_xid(apars); |
| 2766 | } |
| 2767 | setverdict(pass); |
| 2768 | } |
| 2769 | testcase TC_xid_n201u() runs on test_CT { |
| 2770 | var BSSGP_ConnHdlr vc_conn; |
| 2771 | f_init(); |
| 2772 | f_sleep(1.0); |
| 2773 | vc_conn := f_start_handler(refers(f_TC_xid_n201u), testcasename(), g_gb, 45); |
| 2774 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2775 | f_cleanup(); |
Harald Welte | 2aaac1b | 2019-05-02 10:02:53 +0200 | [diff] [blame] | 2776 | } |
| 2777 | |
Alexander Couzens | 6bee087 | 2019-05-11 01:48:50 +0200 | [diff] [blame] | 2778 | private function f_TC_attach_pdp_act_gmm_detach(charstring id) runs on BSSGP_ConnHdlr { |
| 2779 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 2780 | |
| 2781 | /* first perform regular attach */ |
| 2782 | f_TC_attach(id); |
| 2783 | /* then activate PDP context */ |
| 2784 | f_pdp_ctx_act(apars); |
| 2785 | /* do a normal detach */ |
| 2786 | f_detach_mo(c_GMM_DTT_MO_GPRS, false, true); |
| 2787 | } |
| 2788 | |
| 2789 | testcase TC_attach_pdp_act_gmm_detach() runs on test_CT { |
| 2790 | /* MS -> SGSN: Attach Request |
| 2791 | * MS <-> SGSN: [..] |
| 2792 | * MS -> SGSN: Attach Complete |
| 2793 | * MS -> SGSN: PDP Activate Request |
| 2794 | * MS <- SGSN: PDP Activate Accept |
| 2795 | * MS -> SGSN: GMM Detach Request |
| 2796 | * MS <- SGSN: GMM Detach Accept |
| 2797 | */ |
| 2798 | var BSSGP_ConnHdlr vc_conn; |
| 2799 | f_init(); |
| 2800 | vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_gmm_detach), testcasename(), g_gb, 26); |
| 2801 | vc_conn.done; |
Pau Espin Pedrol | ce0d615 | 2019-08-27 19:07:27 +0200 | [diff] [blame] | 2802 | f_cleanup(); |
Alexander Couzens | 6bee087 | 2019-05-11 01:48:50 +0200 | [diff] [blame] | 2803 | } |
Harald Welte | 645a151 | 2019-04-23 23:18:23 +0200 | [diff] [blame] | 2804 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 2805 | control { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 2806 | execute( TC_attach() ); |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 2807 | execute( TC_attach_mnc3() ); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 2808 | execute( TC_attach_umts_aka_umts_res() ); |
| 2809 | execute( TC_attach_umts_aka_gsm_sres() ); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 2810 | execute( TC_attach_auth_id_timeout() ); |
| 2811 | execute( TC_attach_auth_sai_timeout() ); |
Harald Welte | fe25388 | 2018-02-17 09:25:00 +0100 | [diff] [blame] | 2812 | execute( TC_attach_auth_sai_reject() ); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 2813 | execute( TC_attach_gsup_lu_timeout() ); |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 2814 | execute( TC_attach_gsup_lu_reject() ); |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 2815 | execute( TC_attach_combined() ); |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 2816 | execute( TC_attach_accept_all() ); |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 2817 | execute( TC_attach_closed() ); |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 2818 | execute( TC_attach_no_imei_response() ); |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 2819 | execute( TC_attach_no_imsi_response() ); |
Alexander Couzens | d81876a | 2018-08-07 12:43:16 +0200 | [diff] [blame] | 2820 | execute( TC_attach_closed_add_vty(), 20.0 ); |
| 2821 | execute( TC_attach_check_subscriber_list(), 20.0 ); |
| 2822 | execute( TC_attach_detach_check_subscriber_list(), 20.0 ); |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 2823 | execute( TC_attach_check_complete_resend() ); |
Alexander Couzens | d81876a | 2018-08-07 12:43:16 +0200 | [diff] [blame] | 2824 | execute( TC_hlr_location_cancel_request_update(), 20.0 ); |
| 2825 | execute( TC_hlr_location_cancel_request_withdraw(), 20.0 ); |
| 2826 | execute( TC_hlr_location_cancel_request_unknown_subscriber_withdraw(), 20.0 ); |
| 2827 | execute( TC_hlr_location_cancel_request_unknown_subscriber_update(), 20.0 ); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 2828 | execute( TC_rau_unknown() ); |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 2829 | execute( TC_attach_rau() ); |
Alexander Couzens | bfda921 | 2018-07-31 03:17:33 +0200 | [diff] [blame] | 2830 | execute( TC_attach_rau_a_a() ); |
Alexander Couzens | be837bd | 2018-07-31 04:20:11 +0200 | [diff] [blame] | 2831 | execute( TC_attach_rau_a_b() ); |
Alexander Couzens | 0c6324f | 2018-09-14 16:37:04 +0200 | [diff] [blame] | 2832 | execute( TC_attach_usim_resync() ); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 2833 | execute( TC_detach_unknown_nopoweroff() ); |
| 2834 | execute( TC_detach_unknown_poweroff() ); |
| 2835 | execute( TC_detach_nopoweroff() ); |
| 2836 | execute( TC_detach_poweroff() ); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 2837 | execute( TC_attach_pdp_act() ); |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 2838 | execute( TC_pdp_act_unattached() ); |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 2839 | execute( TC_attach_pdp_act_user() ); |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 2840 | execute( TC_attach_pdp_act_ggsn_reject() ); |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 2841 | execute( TC_attach_pdp_act_user_deact_mo() ); |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 2842 | execute( TC_attach_pdp_act_user_deact_mt() ); |
Pau Espin Pedrol | 2a3302a | 2019-08-15 16:01:20 +0200 | [diff] [blame] | 2843 | execute( TC_attach_pdp_act_deact_dup() ); |
Alexander Couzens | 187ad5d | 2018-05-02 19:31:10 +0200 | [diff] [blame] | 2844 | execute( TC_attach_second_attempt() ); |
Pau Espin Pedrol | fcec914 | 2019-08-28 17:33:46 +0200 | [diff] [blame] | 2845 | execute( TC_attach_echo_timeout() ); |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 2846 | execute( TC_attach_restart_ctr_echo() ); |
| 2847 | execute( TC_attach_restart_ctr_create() ); |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 2848 | execute( TC_attach_pdp_act_deact_mt_t3395_expire() ); |
Pau Espin Pedrol | e6f071f | 2019-05-29 13:02:42 +0200 | [diff] [blame] | 2849 | execute( TC_attach_pdp_act_deact_gtp_retrans() ); |
| 2850 | execute( TC_attach_pdp_act_deact_gtp_retrans_resp() ); |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 2851 | execute( TC_attach_pdp_act_user_error_ind_ggsn() ); |
Alexander Couzens | 6bee087 | 2019-05-11 01:48:50 +0200 | [diff] [blame] | 2852 | execute( TC_attach_pdp_act_gmm_detach() ); |
Alexander Couzens | cf3c93d | 2018-08-07 19:48:27 +0200 | [diff] [blame] | 2853 | execute( TC_attach_gmm_attach_req_while_gmm_attach() ); |
Harald Welte | a05b807 | 2019-04-23 22:35:05 +0200 | [diff] [blame] | 2854 | |
Harald Welte | 2aaac1b | 2019-05-02 10:02:53 +0200 | [diff] [blame] | 2855 | execute( TC_xid_empty_l3() ); |
| 2856 | execute( TC_xid_n201u() ); |
| 2857 | |
Harald Welte | a05b807 | 2019-04-23 22:35:05 +0200 | [diff] [blame] | 2858 | execute( TC_llc_null() ); |
Harald Welte | 645a151 | 2019-04-23 23:18:23 +0200 | [diff] [blame] | 2859 | execute( TC_llc_sabm_dm_llgmm() ); |
| 2860 | execute( TC_llc_sabm_dm_ll5() ); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 2861 | } |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 2862 | |
| 2863 | |
| 2864 | |
| 2865 | } |