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