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