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