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