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 | |
| 812 | /* then send RAU */ |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 813 | BSSGP[0].send(ts_GMM_RAU_REQ(f_mi_get_lv(), GPRS_UPD_T_RA, g_pars.ra, false, omit, omit)); |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 814 | alt { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 815 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_GMM_RAU_ACCEPT)) -> value bd { |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 816 | f_process_rau_accept(bd.l3_mt.msgs.gprs_mm.routingAreaUpdateAccept); |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 817 | BSSGP[0].send(ts_GMM_RAU_COMPL); |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 818 | setverdict(pass); |
| 819 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 820 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_GMM_RAU_REJECT)) { |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 821 | setverdict(fail, "Unexpected RAU Reject"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 822 | mtc.stop; |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 823 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 824 | [] BSSGP[0].receive { repeat; } |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 825 | } |
| 826 | } |
| 827 | testcase TC_attach_rau() runs on test_CT { |
| 828 | var BSSGP_ConnHdlr vc_conn; |
| 829 | f_init(); |
| 830 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 831 | 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] | 832 | vc_conn.done; |
| 833 | } |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 834 | |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 835 | /* general GPRS DETACH helper */ |
| 836 | function f_detach_mo(BIT3 detach_type, boolean power_off, boolean expect_purge) runs on BSSGP_ConnHdlr { |
| 837 | var BssgpDecoded bd; |
| 838 | timer T := 5.0; |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 839 | BSSGP[0].send(ts_GMM_DET_REQ_MO(detach_type, power_off)); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 840 | if (expect_purge) { |
| 841 | GSUP.receive(tr_GSUP_PURGE_MS_REQ(g_pars.imsi, OSMO_GSUP_CN_DOMAIN_PS)); |
| 842 | GSUP.send(ts_GSUP_PURGE_MS_RES(g_pars.imsi)); |
| 843 | } |
| 844 | T.start; |
| 845 | alt { |
| 846 | [not expect_purge] GSUP.receive(tr_GSUP_PURGE_MS_REQ(?)) { |
| 847 | setverdict(fail, "Unexpected GSUP PURGE MS for unregistered TLLI"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 848 | mtc.stop; |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 849 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 850 | [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] | 851 | g_pars.ra := omit; |
| 852 | setverdict(fail, "Unexpected ATTACH ACCEPT in no-power-off DETACH"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 853 | mtc.stop; |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 854 | /* TODO: check if any PDP contexts are deactivated on network side? */ |
| 855 | } |
| 856 | [power_off] T.timeout { |
| 857 | setverdict(pass); |
| 858 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 859 | [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] | 860 | g_pars.ra := omit; |
| 861 | setverdict(pass); |
| 862 | /* TODO: check if any PDP contexts are deactivated on network side? */ |
| 863 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 864 | [] BSSGP[0].receive { repeat; } |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 865 | } |
| 866 | } |
| 867 | |
| 868 | /* IMSI DETACH (non-power-off) for unknown TLLI */ |
| 869 | private function f_TC_detach_unknown_nopoweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 870 | f_detach_mo(c_GMM_DTT_MO_GPRS, false, false); |
| 871 | } |
| 872 | testcase TC_detach_unknown_nopoweroff() 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_nopoweroff), testcasename(), g_gb, 13); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 877 | vc_conn.done; |
| 878 | } |
| 879 | |
| 880 | /* IMSI DETACH (power-off) for unknown TLLI */ |
| 881 | private function f_TC_detach_unknown_poweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 882 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, false); |
| 883 | } |
| 884 | testcase TC_detach_unknown_poweroff() runs on test_CT { |
| 885 | var BSSGP_ConnHdlr vc_conn; |
| 886 | f_init(); |
| 887 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 888 | 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] | 889 | vc_conn.done; |
| 890 | } |
| 891 | |
| 892 | /* IMSI DETACH (non-power-off) for known TLLI */ |
| 893 | private function f_TC_detach_nopoweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 894 | /* first perform regular attach */ |
| 895 | f_TC_attach(id); |
| 896 | |
| 897 | f_detach_mo(c_GMM_DTT_MO_GPRS, false, true); |
| 898 | } |
| 899 | testcase TC_detach_nopoweroff() runs on test_CT { |
| 900 | var BSSGP_ConnHdlr vc_conn; |
| 901 | f_init(); |
| 902 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 903 | 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] | 904 | vc_conn.done; |
| 905 | } |
| 906 | |
| 907 | /* IMSI DETACH (power-off) for known TLLI */ |
| 908 | private function f_TC_detach_poweroff(charstring id) runs on BSSGP_ConnHdlr { |
| 909 | /* first perform regular attach */ |
| 910 | f_TC_attach(id); |
| 911 | |
| 912 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true); |
| 913 | } |
| 914 | testcase TC_detach_poweroff() runs on test_CT { |
| 915 | var BSSGP_ConnHdlr vc_conn; |
| 916 | f_init(); |
| 917 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 918 | vc_conn := f_start_handler(refers(f_TC_detach_poweroff), testcasename(), g_gb, 16); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 919 | vc_conn.done; |
| 920 | } |
| 921 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 922 | type record PdpActPars { |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 923 | BIT3 tid, /* L3 Transaction ID */ |
| 924 | BIT4 nsapi, /* SNDCP NSAPI */ |
| 925 | BIT4 sapi, /* LLC SAPI */ |
| 926 | QoSV qos, /* QoS parameters */ |
| 927 | PDPAddressV addr, /* IP address */ |
| 928 | octetstring apn optional, /* APN name */ |
| 929 | ProtocolConfigOptionsV pco optional, /* protoco config opts */ |
| 930 | OCT1 exp_rej_cause optional, /* expected SM reject cause */ |
Harald Welte | 1d6ae93 | 2018-02-18 21:24:44 +0100 | [diff] [blame] | 931 | OCT1 gtp_resp_cause, /* GTP response cause */ |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 932 | OCT4 chg_id, /* GTP Charging Identifier */ |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 933 | |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 934 | OCT4 ggsn_tei_c, /* GGSN TEI Control*/ |
| 935 | OCT4 ggsn_tei_u, /* GGSN TEI User */ |
| 936 | octetstring ggsn_ip_c, /* GGSN IP Control */ |
| 937 | octetstring ggsn_ip_u, /* GGSN IP User */ |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 938 | OCT1 ggsn_restart_ctr, /* GGSN Restart Counter */ |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 939 | |
Harald Welte | 822f910 | 2018-02-18 20:39:06 +0100 | [diff] [blame] | 940 | OCT4 sgsn_tei_c optional, /* SGSN TEI Control */ |
| 941 | OCT4 sgsn_tei_u optional, /* SGSN TEI User */ |
| 942 | octetstring sgsn_ip_c optional, /* SGSN IP Control */ |
| 943 | octetstring sgsn_ip_u optional /* SGSN IP USer */ |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 944 | }; |
| 945 | |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 946 | |
| 947 | private function f_process_gtp_ctx_act_req(inout PdpActPars apars, PDU_GTPC gtpc) runs on BSSGP_ConnHdlr { |
| 948 | var GTPC_PDUs gtpc_rx := gtpc.gtpc_pdu; |
| 949 | apars.sgsn_tei_c := gtpc_rx.createPDPContextRequest.teidControlPlane.teidControlPlane; |
| 950 | apars.sgsn_tei_u := gtpc_rx.createPDPContextRequest.teidDataI.teidDataI; |
| 951 | apars.sgsn_ip_c := gtpc_rx.createPDPContextRequest.sgsn_addr_signalling.addressf; |
| 952 | apars.sgsn_ip_u := gtpc_rx.createPDPContextRequest.sgsn_addr_traffic.addressf; |
| 953 | f_gtp_register_teid(apars.ggsn_tei_c); |
| 954 | f_gtp_register_teid(apars.ggsn_tei_u); |
| 955 | } |
| 956 | |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 957 | 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] | 958 | var boolean exp_rej := ispresent(apars.exp_rej_cause); |
| 959 | var Gtp1cUnitdata g_ud; |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 960 | var template Recovery_gtpc recovery := omit; |
| 961 | |
| 962 | if (send_recovery) { |
| 963 | recovery := ts_Recovery(apars.ggsn_restart_ctr); |
| 964 | } |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 965 | |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 966 | 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] | 967 | apars.apn, apars.pco)); |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 968 | GTP.receive(tr_GTPC_MsgType(?, createPDPContextRequest, ?)) -> value g_ud { |
| 969 | f_process_gtp_ctx_act_req(apars, g_ud.gtpc); |
| 970 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 971 | GTP.send(ts_GTPC_CreatePdpResp(g_ud.peer, seq_nr, |
| 972 | apars.sgsn_tei_c, apars.gtp_resp_cause, |
| 973 | apars.ggsn_tei_c, apars.ggsn_tei_u, |
| 974 | apars.nsapi, |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 975 | apars.ggsn_ip_c, apars.ggsn_ip_u, apars.chg_id, |
| 976 | omit, recovery)); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 977 | } |
| 978 | alt { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 979 | [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] | 980 | setverdict(pass); |
| 981 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 982 | [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] | 983 | setverdict(fail, "Unexpected PDP CTX ACT ACC"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 984 | mtc.stop; |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 985 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 986 | [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] | 987 | setverdict(fail, "Unexpected PDP CTX ACT FAIL"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 988 | mtc.stop; |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 989 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 990 | [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] | 991 | setverdict(pass); |
| 992 | } |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 993 | [] as_xid(apars); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 994 | } |
| 995 | } |
| 996 | |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 997 | function f_pdp_ctx_deact_mo(inout PdpActPars apars, OCT1 cause) runs on BSSGP_ConnHdlr { |
| 998 | var boolean exp_rej := ispresent(apars.exp_rej_cause); |
| 999 | var Gtp1cUnitdata g_ud; |
| 1000 | |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1001 | 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] | 1002 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextRequest, apars.ggsn_tei_c)) -> value g_ud { |
| 1003 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1004 | BSSGP[0].clear; |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1005 | GTP.send(ts_GTPC_DeletePdpResp(g_ud.peer, seq_nr, apars.sgsn_tei_c, '7F'O)); |
| 1006 | } |
| 1007 | alt { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1008 | [] 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] | 1009 | setverdict(pass); |
| 1010 | } |
| 1011 | [] as_xid(apars); |
| 1012 | } |
| 1013 | } |
| 1014 | |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1015 | 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] | 1016 | var Gtp1cUnitdata g_ud; |
| 1017 | var integer seq_nr := 23; |
| 1018 | var GtpPeer peer := valueof(ts_GtpPeerC(apars.sgsn_ip_c)); |
| 1019 | |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1020 | BSSGP[0].clear; |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1021 | if (error_ind) { |
| 1022 | GTP.send(ts_GTPU_ErrorIndication(peer, 0 /* seq */, apars.ggsn_tei_u, apars.ggsn_ip_u)); |
| 1023 | } else { |
| 1024 | GTP.send(ts_GTPC_DeletePDP(peer, seq_nr, apars.sgsn_tei_c, apars.nsapi, '1'B)); |
| 1025 | } |
Alexander Couzens | 5e71c14 | 2018-08-07 17:21:24 +0200 | [diff] [blame] | 1026 | |
| 1027 | timer T := 5.0; |
| 1028 | T.start; |
| 1029 | |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1030 | alt { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1031 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_SM_DEACT_PDP_REQ_MT(apars.tid, ?, true))) { |
| 1032 | BSSGP[0].send(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid)); |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1033 | } |
Alexander Couzens | 5e71c14 | 2018-08-07 17:21:24 +0200 | [diff] [blame] | 1034 | [not error_ind] GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, apars.ggsn_tei_c)) { |
| 1035 | repeat; |
| 1036 | } |
| 1037 | [] T.timeout { |
| 1038 | setverdict(fail, "Waiting for SM_DEACT_PDP_REQ_MT"); |
| 1039 | } |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1040 | } |
| 1041 | } |
| 1042 | |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1043 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1044 | /* Table 10.5.156/3GPP TS 24.008 */ |
| 1045 | template (value) QoSV t_QosDefault := { |
| 1046 | reliabilityClass := '011'B, /* unacknowledged GTP+LLC, acknowledged RLC */ |
| 1047 | delayClass := '100'B, /* best effort */ |
| 1048 | spare1 := '00'B, |
| 1049 | precedenceClass := '010'B, /* normal */ |
| 1050 | spare2 := '0'B, |
| 1051 | peakThroughput := '0000'B, /* subscribed */ |
| 1052 | meanThroughput := '00000'B, /* subscribed */ |
| 1053 | spare3 := '000'B, |
| 1054 | deliverErroneusSDU := omit, |
| 1055 | deliveryOrder := omit, |
| 1056 | trafficClass := omit, |
| 1057 | maxSDUSize := omit, |
| 1058 | maxBitrateUplink := omit, |
| 1059 | maxBitrateDownlink := omit, |
| 1060 | sduErrorRatio := omit, |
| 1061 | residualBER := omit, |
| 1062 | trafficHandlingPriority := omit, |
| 1063 | transferDelay := omit, |
| 1064 | guaranteedBitRateUplink := omit, |
| 1065 | guaranteedBitRateDownlink := omit, |
| 1066 | sourceStatisticsDescriptor := omit, |
| 1067 | signallingIndication := omit, |
| 1068 | spare4 := omit, |
| 1069 | maxBitrateDownlinkExt := omit, |
| 1070 | guaranteedBitRateDownlinkExt := omit, |
| 1071 | maxBitrateUplinkExt := omit, |
| 1072 | guaranteedBitRateUplinkExt := omit, |
| 1073 | maxBitrateDownlinkExt2 := omit, |
| 1074 | guaranteedBitRateDownlinkExt2 := omit, |
| 1075 | maxBitrateUplinkExt2 := omit, |
| 1076 | guaranteedBitRateUplinkExt2 := omit |
| 1077 | } |
| 1078 | |
| 1079 | /* 10.5.6.4 / 3GPP TS 24.008 */ |
| 1080 | template (value) PDPAddressV t_AddrIPv4dyn := { |
| 1081 | pdpTypeOrg := '0001'B, /* IETF */ |
| 1082 | spare := '0000'B, |
| 1083 | pdpTypeNum := '21'O, /* IPv4 */ |
| 1084 | addressInfo := omit |
| 1085 | } |
| 1086 | template (value) PDPAddressV t_AddrIPv6dyn := { |
| 1087 | pdpTypeOrg := '0001'B, /* IETF */ |
| 1088 | spare := '0000'B, |
| 1089 | pdpTypeNum := '53'O, /* IPv6 */ |
| 1090 | addressInfo := omit |
| 1091 | } |
| 1092 | |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1093 | template (value) PdpActPars t_PdpActPars(charstring ggsn_ip) := { |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1094 | tid := '000'B, |
| 1095 | nsapi := '0101'B, /* < 5 are reserved */ |
| 1096 | sapi := '0011'B, /* 3/5/9/11 */ |
| 1097 | qos := t_QosDefault, |
| 1098 | addr := t_AddrIPv4dyn, |
| 1099 | apn := omit, |
| 1100 | pco := omit, |
| 1101 | exp_rej_cause := omit, |
Harald Welte | 1d6ae93 | 2018-02-18 21:24:44 +0100 | [diff] [blame] | 1102 | gtp_resp_cause := int2oct(128, 1), |
| 1103 | chg_id := f_rnd_octstring(4), |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1104 | |
| 1105 | /* FIXME: make below dynamic !! */ |
Harald Welte | 1d6ae93 | 2018-02-18 21:24:44 +0100 | [diff] [blame] | 1106 | ggsn_tei_c := f_rnd_octstring(4), |
| 1107 | ggsn_tei_u := f_rnd_octstring(4), |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1108 | ggsn_ip_c := f_inet_addr(ggsn_ip), |
| 1109 | ggsn_ip_u := f_inet_addr(ggsn_ip), |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1110 | ggsn_restart_ctr := int2oct(2, 1), |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1111 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1112 | sgsn_tei_c := omit, |
Harald Welte | f8af5d6 | 2018-02-18 15:06:42 +0100 | [diff] [blame] | 1113 | sgsn_tei_u := omit, |
| 1114 | sgsn_ip_c := omit, |
| 1115 | sgsn_ip_u := omit |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1116 | } |
| 1117 | |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1118 | template (value) GtpPeer ts_GtpPeerU(octetstring ip) := { |
| 1119 | connId := 1, |
| 1120 | remName := f_inet_ntoa(ip), |
| 1121 | remPort := GTP1U_PORT |
| 1122 | } |
| 1123 | |
| 1124 | template (value) GtpPeer ts_GtpPeerC(octetstring ip) := { |
| 1125 | connId := 1, |
| 1126 | remName := f_inet_ntoa(ip), |
| 1127 | remPort := GTP1C_PORT |
| 1128 | } |
| 1129 | |
| 1130 | private function f_gtpu_send(inout PdpActPars apars, octetstring payload) runs on BSSGP_ConnHdlr { |
| 1131 | var GtpPeer peer := valueof(ts_GtpPeerU(apars.sgsn_ip_u)); |
| 1132 | GTP.send(ts_GTP1U_GPDU(peer, 0 /*seq*/, apars.sgsn_tei_u, payload)); |
| 1133 | } |
| 1134 | |
| 1135 | private altstep as_xid(PdpActPars apars) runs on BSSGP_ConnHdlr { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1136 | [] BSSGP[0].receive(tr_BD_LLC(tr_LLC_XID(?, apars.sapi))) { |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1137 | repeat; |
| 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | template PDU_SN tr_SN_UD(template BIT4 nsapi, template octetstring payload) := { |
| 1142 | pDU_SN_UNITDATA := { |
| 1143 | nsapi := nsapi, |
| 1144 | moreBit := ?, |
| 1145 | snPduType := '1'B, |
| 1146 | firstSegmentIndicator := ?, |
| 1147 | spareBit := ?, |
| 1148 | pcomp := ?, |
| 1149 | dcomp := ?, |
| 1150 | npduNumber := ?, |
| 1151 | segmentNumber := ?, |
| 1152 | npduNumberContinued := ?, |
| 1153 | dataSegmentSnUnitdataPdu := payload |
| 1154 | } |
| 1155 | } |
| 1156 | |
| 1157 | /* simple case: single segment, no compression */ |
| 1158 | template (value) PDU_SN ts_SN_UD(BIT4 nsapi, octetstring payload) := { |
| 1159 | pDU_SN_UNITDATA := { |
| 1160 | nsapi := nsapi, |
| 1161 | moreBit := '0'B, |
| 1162 | snPduType := '1'B, |
| 1163 | firstSegmentIndicator := '1'B, |
| 1164 | spareBit := '0'B, |
| 1165 | pcomp := '0000'B, |
| 1166 | dcomp := '0000'B, |
| 1167 | npduNumber := '0000'B, |
| 1168 | segmentNumber := '0000'B, |
| 1169 | npduNumberContinued := '00'O, |
| 1170 | dataSegmentSnUnitdataPdu := payload |
| 1171 | } |
| 1172 | } |
| 1173 | |
| 1174 | /* Transceive given 'payload' as MT message from GTP -> OsmoSGSN -> Gb */ |
| 1175 | private function f_gtpu_xceive_mt(inout PdpActPars apars, octetstring payload) runs on BSSGP_ConnHdlr { |
| 1176 | /* Send PDU via GTP from our simulated GGSN to the SGSN */ |
| 1177 | f_gtpu_send(apars, payload); |
| 1178 | /* Expect PDU via BSSGP/LLC on simulated PCU from SGSN */ |
| 1179 | alt { |
| 1180 | [] as_xid(apars); |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1181 | [] 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] | 1182 | } |
| 1183 | } |
| 1184 | |
Pau Espin Pedrol | 8be4d19 | 2018-07-18 13:43:44 +0200 | [diff] [blame] | 1185 | /* Transceive given 'payload' as MT message from Gb -> OsmoSGSN -> GTP */ |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1186 | private function f_gtpu_xceive_mo(inout PdpActPars apars, octetstring payload) runs on BSSGP_ConnHdlr { |
| 1187 | /* Send PDU via SNDCP/LLC/BSSGP/NS via simulated MS/PCU to the SGSN */ |
| 1188 | var GtpPeer peer := valueof(ts_GtpPeerU(apars.sgsn_ip_u)); |
| 1189 | var PDU_SN sndcp := valueof(ts_SN_UD(apars.nsapi, payload)); |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1190 | 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] | 1191 | /* Expect PDU via GTP from SGSN on simulated GGSN */ |
| 1192 | alt { |
| 1193 | [] GTP.receive(tr_GTPU_GPDU(peer, apars.ggsn_tei_u, payload)); |
| 1194 | } |
| 1195 | } |
| 1196 | |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1197 | 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] | 1198 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1199 | |
| 1200 | /* first perform regular attach */ |
| 1201 | f_TC_attach(id); |
| 1202 | |
| 1203 | f_pdp_ctx_act(apars); |
| 1204 | } |
| 1205 | testcase TC_attach_pdp_act() runs on test_CT { |
| 1206 | var BSSGP_ConnHdlr vc_conn; |
| 1207 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1208 | 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] | 1209 | vc_conn.done; |
| 1210 | } |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 1211 | |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1212 | /* PDP Context activation for not-attached subscriber; expect fail */ |
| 1213 | 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] | 1214 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1215 | 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] | 1216 | apars.apn, apars.pco)); |
| 1217 | alt { |
| 1218 | /* We might want toalso actually expect a PDPC CTX ACT REJ? */ |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1219 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_GMM_DET_REQ_MT(?, ?))) { |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1220 | setverdict(pass); |
| 1221 | } |
| 1222 | [] GTP.receive(tr_GTPC_MsgType(?, createPDPContextRequest, ?)) { |
| 1223 | setverdict(fail, "Unexpected GTP PDP CTX ACT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1224 | mtc.stop; |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1225 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1226 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_SM_ACT_PDP_ACCEPT(?, ?))) { |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1227 | setverdict(fail, "Unexpected SM PDP CTX ACT ACK"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1228 | mtc.stop; |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1229 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1230 | [] BSSGP[0].receive { repeat; } |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1231 | } |
| 1232 | } |
| 1233 | testcase TC_pdp_act_unattached() runs on test_CT { |
| 1234 | var BSSGP_ConnHdlr vc_conn; |
| 1235 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1236 | 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] | 1237 | vc_conn.done; |
| 1238 | } |
| 1239 | |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1240 | /* ATTACH + PDP CTX ACT + user plane traffic */ |
| 1241 | private function f_TC_attach_pdp_act_user(charstring id) runs on BSSGP_ConnHdlr { |
| 1242 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1243 | |
| 1244 | /* first perform regular attach */ |
| 1245 | f_TC_attach(id); |
| 1246 | /* then activate PDP context */ |
| 1247 | f_pdp_ctx_act(apars); |
| 1248 | /* then transceive a downlink PDU */ |
| 1249 | f_gtpu_xceive_mt(apars, f_rnd_octstring(100)); |
| 1250 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 1251 | } |
| 1252 | testcase TC_attach_pdp_act_user() runs on test_CT { |
| 1253 | var BSSGP_ConnHdlr vc_conn; |
| 1254 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1255 | 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] | 1256 | vc_conn.done; |
| 1257 | } |
| 1258 | |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 1259 | /* ATTACH + PDP CTX ACT; reject from GGSN */ |
| 1260 | private function f_TC_attach_pdp_act_ggsn_reject(charstring id) runs on BSSGP_ConnHdlr { |
| 1261 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1262 | |
| 1263 | apars.gtp_resp_cause := int2oct(199, 1); /* no resources available */ |
| 1264 | apars.exp_rej_cause := '1a'O; /* insufficient resources */ |
| 1265 | |
| 1266 | /* first perform regular attach */ |
| 1267 | f_TC_attach(id); |
| 1268 | /* then activate PDP context */ |
| 1269 | f_pdp_ctx_act(apars); |
| 1270 | } |
| 1271 | testcase TC_attach_pdp_act_ggsn_reject() runs on test_CT { |
| 1272 | var BSSGP_ConnHdlr vc_conn; |
| 1273 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1274 | 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] | 1275 | vc_conn.done; |
| 1276 | } |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1277 | |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1278 | /* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MO direction */ |
| 1279 | private function f_TC_attach_pdp_act_user_deact_mo(charstring id) runs on BSSGP_ConnHdlr { |
| 1280 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1281 | |
| 1282 | /* first perform regular attach */ |
| 1283 | f_TC_attach(id); |
| 1284 | /* then activate PDP context */ |
| 1285 | f_pdp_ctx_act(apars); |
| 1286 | /* then transceive a downlink PDU */ |
| 1287 | f_gtpu_xceive_mt(apars, f_rnd_octstring(100)); |
| 1288 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 1289 | |
| 1290 | f_pdp_ctx_deact_mo(apars, '00'O); |
| 1291 | } |
| 1292 | testcase TC_attach_pdp_act_user_deact_mo() runs on test_CT { |
| 1293 | var BSSGP_ConnHdlr vc_conn; |
| 1294 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1295 | 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] | 1296 | vc_conn.done; |
| 1297 | } |
| 1298 | |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1299 | /* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MT direction */ |
| 1300 | private function f_TC_attach_pdp_act_user_deact_mt(charstring id) runs on BSSGP_ConnHdlr { |
| 1301 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1302 | |
| 1303 | /* first perform regular attach */ |
| 1304 | f_TC_attach(id); |
| 1305 | /* then activate PDP context */ |
| 1306 | f_pdp_ctx_act(apars); |
| 1307 | /* then transceive a downlink PDU */ |
| 1308 | f_gtpu_xceive_mt(apars, f_rnd_octstring(100)); |
| 1309 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 1310 | |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1311 | f_pdp_ctx_deact_mt(apars, false); |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1312 | } |
| 1313 | testcase TC_attach_pdp_act_user_deact_mt() runs on test_CT { |
| 1314 | var BSSGP_ConnHdlr vc_conn; |
| 1315 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1316 | 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] | 1317 | vc_conn.done; |
| 1318 | } |
| 1319 | |
Alexander Couzens | 187ad5d | 2018-05-02 19:31:10 +0200 | [diff] [blame] | 1320 | /* ATTACH + ATTACH (2nd) */ |
| 1321 | private function f_TC_attach_forget_tlli_attach(charstring id) runs on BSSGP_ConnHdlr { |
| 1322 | g_pars.t_guard := 5.0; |
| 1323 | |
| 1324 | /* first perform regular attach */ |
| 1325 | f_TC_attach(id); |
| 1326 | |
| 1327 | /* second to perform regular attach */ |
| 1328 | f_TC_attach(id); |
| 1329 | } |
| 1330 | |
| 1331 | |
| 1332 | testcase TC_attach_second_attempt() runs on test_CT { |
| 1333 | var BSSGP_ConnHdlr vc_conn; |
| 1334 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1335 | 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] | 1336 | vc_conn.done; |
| 1337 | } |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1338 | |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1339 | 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] | 1340 | var Gtp1cUnitdata g_ud; |
| 1341 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1342 | |
| 1343 | /* first perform regular attach */ |
| 1344 | f_TC_attach(id); |
| 1345 | /* Activate a pdp context against the GGSN */ |
| 1346 | f_pdp_ctx_act(apars); |
| 1347 | /* Wait to receive first echo request and send initial Restart counter */ |
| 1348 | GTP.receive(tr_GTPC_MsgType(?, echoRequest, ?)) -> value g_ud { |
| 1349 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1350 | GTP.send(ts_GTPC_PONG(g_ud.peer, seq_nr, apars.ggsn_restart_ctr)); |
| 1351 | } |
| 1352 | /* Wait to receive second echo request and send incremented Restart |
| 1353 | counter. This will fake a restarted GGSN, and pdp ctx allocated |
| 1354 | should be released by SGSN */ |
| 1355 | apars.ggsn_restart_ctr := int2oct(oct2int(apars.ggsn_restart_ctr) + 1, 1); |
| 1356 | GTP.receive(tr_GTPC_MsgType(?, echoRequest, ?)) -> value g_ud { |
| 1357 | var integer seq_nr := oct2int(g_ud.gtpc.opt_part.sequenceNumber); |
| 1358 | GTP.send(ts_GTPC_PONG(g_ud.peer, seq_nr, apars.ggsn_restart_ctr)); |
| 1359 | } |
| 1360 | var OCT1 cause_network_failure := int2oct(38, 1) |
| 1361 | alt { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1362 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_SM_DEACT_PDP_REQ_MT(apars.tid, cause_network_failure, true))) { |
| 1363 | BSSGP[0].send(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid)); |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1364 | setverdict(pass); |
| 1365 | } |
| 1366 | [] as_xid(apars); |
| 1367 | } |
| 1368 | setverdict(pass); |
| 1369 | } |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1370 | /* ATTACH + trigger Recovery procedure through EchoResp */ |
| 1371 | testcase TC_attach_restart_ctr_echo() runs on test_CT { |
Pau Espin Pedrol | dc27e48 | 2018-07-10 14:02:49 +0200 | [diff] [blame] | 1372 | var BSSGP_ConnHdlr vc_conn; |
| 1373 | g_use_echo := true |
| 1374 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1375 | 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] | 1376 | vc_conn.done; |
| 1377 | g_use_echo := false |
| 1378 | } |
| 1379 | |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1380 | private function f_TC_attach_restart_ctr_create(charstring id) runs on BSSGP_ConnHdlr { |
| 1381 | var Gtp1cUnitdata g_ud; |
| 1382 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1383 | var integer seq_nr := 23; |
| 1384 | var GtpPeer peer; |
| 1385 | /* first perform regular attach */ |
| 1386 | f_TC_attach(id); |
| 1387 | |
| 1388 | /* Use this CTX ACT to send initial Restart counter to SGSN. */ |
| 1389 | apars.gtp_resp_cause := int2oct(199, 1); /* no resources available */ |
| 1390 | apars.exp_rej_cause := '1a'O; /* insufficient resources */ |
| 1391 | f_pdp_ctx_act(apars, true); |
| 1392 | |
| 1393 | /* Increment restart_ctr. This will fake a restarted GGSN when CreatePdpResp is |
| 1394 | /* received. */ |
| 1395 | apars.ggsn_restart_ctr := int2oct(oct2int(apars.ggsn_restart_ctr) + 1, 1); |
| 1396 | |
| 1397 | /* FIXME: Once we can easily handle different pdp ctx simultaneously, it |
| 1398 | would be great to have an active pdp context here before triggering |
| 1399 | Recovery, and making sure the the DEACT request is sent by the SGSN. |
| 1400 | */ |
| 1401 | |
| 1402 | /* Activate a pdp context against the GGSN, send incremented Recovery |
| 1403 | IE. This should trigger the recovery path, but still this specific |
| 1404 | CTX activation should work. */ |
| 1405 | apars.exp_rej_cause := omit; /* default value for tests */ |
| 1406 | apars.gtp_resp_cause := int2oct(128, 1); /* default value for tests */ |
| 1407 | f_pdp_ctx_act(apars, true); |
| 1408 | |
| 1409 | setverdict(pass); |
| 1410 | } |
| 1411 | /* ATTACH + trigger Recovery procedure through CreatePdpResp */ |
| 1412 | testcase TC_attach_restart_ctr_create() runs on test_CT { |
| 1413 | var BSSGP_ConnHdlr vc_conn; |
| 1414 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1415 | 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] | 1416 | vc_conn.done; |
| 1417 | } |
| 1418 | |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1419 | /* ATTACH + PDP CTX ACT + user plane traffic + PDP CTX DEACT in MT direction + trigger T3395 */ |
| 1420 | private function f_TC_attach_pdp_act_deact_mt_t3395_expire(charstring id) runs on BSSGP_ConnHdlr { |
| 1421 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1422 | var integer seq_nr := 23; |
| 1423 | var GtpPeer peer; |
| 1424 | var integer i; |
| 1425 | |
| 1426 | /* first perform regular attach */ |
| 1427 | f_TC_attach(id); |
| 1428 | /* then activate PDP context */ |
| 1429 | f_pdp_ctx_act(apars); |
| 1430 | |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1431 | BSSGP[0].clear; |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1432 | peer := valueof(ts_GtpPeerC(apars.sgsn_ip_c)); |
| 1433 | GTP.send(ts_GTPC_DeletePDP(peer, seq_nr, apars.sgsn_tei_c, apars.nsapi, '1'B)); |
| 1434 | |
| 1435 | for (i := 0; i < 5; i := i+1) { |
| 1436 | alt { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1437 | [] 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] | 1438 | [] as_xid(apars); |
| 1439 | } |
| 1440 | } |
| 1441 | |
| 1442 | GTP.receive(tr_GTPC_MsgType(?, deletePDPContextResponse, apars.ggsn_tei_c)) {} |
| 1443 | |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1444 | BSSGP[0].send(ts_SM_DEACT_PDP_ACCEPT_MO(apars.tid)); |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1445 | setverdict(pass); |
| 1446 | } |
| 1447 | testcase TC_attach_pdp_act_deact_mt_t3395_expire() runs on test_CT { |
| 1448 | var BSSGP_ConnHdlr vc_conn; |
| 1449 | f_init(); |
| 1450 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1451 | 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] | 1452 | vc_conn.done; |
| 1453 | } |
| 1454 | |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1455 | private function f_TC_hlr_location_cancel_request_update(charstring id) runs on BSSGP_ConnHdlr { |
| 1456 | /* MS: perform regular attach */ |
| 1457 | f_TC_attach(id); |
| 1458 | |
| 1459 | /* HLR: cancel the location request */ |
| 1460 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_UPDATE)); |
| 1461 | GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)); |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1462 | |
| 1463 | /* ensure no Detach Request got received */ |
| 1464 | timer T := 5.0; |
| 1465 | T.start; |
| 1466 | alt { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1467 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_GMM_DET_REQ_MT(*, *, *))) { |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1468 | T.stop; |
| 1469 | setverdict(fail, "Unexpected GMM Detach Request"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1470 | mtc.stop; |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1471 | } |
| 1472 | [] T.timeout { |
| 1473 | setverdict(pass); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1474 | mtc.stop; |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1475 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1476 | [] BSSGP[0].receive { |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1477 | repeat; |
| 1478 | } |
| 1479 | } |
| 1480 | } |
| 1481 | |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1482 | /* ATTACH + PDP CTX ACT + user plane traffic + ERROR IND in MT direction */ |
| 1483 | private function f_TC_attach_pdp_act_user_error_ind_ggsn(charstring id) runs on BSSGP_ConnHdlr { |
| 1484 | var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); |
| 1485 | |
| 1486 | /* first perform regular attach */ |
| 1487 | f_TC_attach(id); |
| 1488 | /* then activate PDP context */ |
| 1489 | f_pdp_ctx_act(apars); |
| 1490 | /* then transceive a downlink PDU */ |
| 1491 | f_gtpu_xceive_mo(apars, f_rnd_octstring(200)); |
| 1492 | |
| 1493 | /* Send Error indication as response from upload PDU and expect deact towards MS */ |
| 1494 | f_pdp_ctx_deact_mt(apars, true); |
| 1495 | } |
| 1496 | testcase TC_attach_pdp_act_user_error_ind_ggsn() runs on test_CT { |
| 1497 | var BSSGP_ConnHdlr vc_conn; |
| 1498 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1499 | 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] | 1500 | vc_conn.done; |
| 1501 | } |
| 1502 | |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1503 | testcase TC_hlr_location_cancel_request_update() runs on test_CT { |
| 1504 | /* MS <-> SGSN: GMM Attach |
| 1505 | * HLR -> SGSN: Cancel Location Request |
| 1506 | * HLR <- SGSN: Cancel Location Ack |
| 1507 | */ |
| 1508 | var BSSGP_ConnHdlr vc_conn; |
| 1509 | f_init(); |
| 1510 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1511 | 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] | 1512 | vc_conn.done; |
| 1513 | } |
| 1514 | |
| 1515 | |
Alexander Couzens | c87967a | 2018-05-22 16:09:54 +0200 | [diff] [blame] | 1516 | private function f_TC_hlr_location_cancel_request_withdraw(charstring id) runs on BSSGP_ConnHdlr { |
| 1517 | /* MS: perform regular attach */ |
| 1518 | f_TC_attach(id); |
| 1519 | |
| 1520 | /* HLR: cancel the location request */ |
| 1521 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_WITHDRAW)); |
| 1522 | GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)); |
| 1523 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1524 | |
| 1525 | /* MS: receive a Detach Request */ |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1526 | BSSGP[0].receive(tr_BD_L3_MT(tr_GMM_DET_REQ_MT(c_GMM_DTT_MT_IMSI_DETACH, ?, ?))); |
| 1527 | BSSGP[0].send(ts_GMM_DET_ACCEPT_MO); |
Alexander Couzens | c87967a | 2018-05-22 16:09:54 +0200 | [diff] [blame] | 1528 | |
| 1529 | setverdict(pass); |
| 1530 | } |
| 1531 | |
| 1532 | testcase TC_hlr_location_cancel_request_withdraw() runs on test_CT { |
| 1533 | /* MS <-> SGSN: GMM Attach |
| 1534 | * HLR -> SGSN: Cancel Location Request |
| 1535 | * HLR <- SGSN: Cancel Location Ack |
| 1536 | * MS <- SGSN: Detach Request |
| 1537 | * SGSN-> MS: Detach Complete |
| 1538 | */ |
| 1539 | var BSSGP_ConnHdlr vc_conn; |
| 1540 | f_init(); |
| 1541 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1542 | 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] | 1543 | vc_conn.done; |
| 1544 | } |
| 1545 | |
| 1546 | |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 1547 | private function f_hlr_location_cancel_request_unknown_subscriber( |
| 1548 | charstring id, |
| 1549 | GSUP_CancelType canceltype) runs on BSSGP_ConnHdlr { |
| 1550 | |
| 1551 | /* HLR: cancel the location request */ |
| 1552 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, canceltype)); |
| 1553 | |
| 1554 | /* cause 2 = IMSI_UNKNOWN */ |
| 1555 | GSUP.receive(tr_GSUP_CL_ERR(g_pars.imsi, 2)); |
| 1556 | |
| 1557 | setverdict(pass); |
| 1558 | } |
| 1559 | |
| 1560 | 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] | 1561 | 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] | 1562 | } |
| 1563 | |
| 1564 | testcase TC_hlr_location_cancel_request_unknown_subscriber_withdraw() runs on test_CT { |
| 1565 | /* HLR -> SGSN: Cancel Location Request |
| 1566 | * HLR <- SGSN: Cancel Location Error |
| 1567 | */ |
| 1568 | |
| 1569 | var BSSGP_ConnHdlr vc_conn; |
| 1570 | f_init(); |
| 1571 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1572 | 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] | 1573 | vc_conn.done; |
| 1574 | } |
| 1575 | |
| 1576 | 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] | 1577 | 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] | 1578 | } |
| 1579 | |
| 1580 | testcase TC_hlr_location_cancel_request_unknown_subscriber_update() runs on test_CT { |
| 1581 | /* HLR -> SGSN: Cancel Location Request |
| 1582 | * HLR <- SGSN: Cancel Location Error |
| 1583 | */ |
| 1584 | |
| 1585 | var BSSGP_ConnHdlr vc_conn; |
| 1586 | f_init(); |
| 1587 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1588 | 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] | 1589 | vc_conn.done; |
| 1590 | } |
| 1591 | |
Alexander Couzens | 49bb4b4 | 2018-06-05 16:28:36 +0200 | [diff] [blame] | 1592 | private function f_TC_attach_detach_check_subscriber_list(charstring id) runs on BSSGP_ConnHdlr { |
| 1593 | f_TC_attach(id); |
| 1594 | f_detach_mo(c_GMM_DTT_MO_GPRS, true, true); |
| 1595 | } |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 1596 | |
Alexander Couzens | 49bb4b4 | 2018-06-05 16:28:36 +0200 | [diff] [blame] | 1597 | testcase TC_attach_detach_check_subscriber_list() runs on test_CT { |
| 1598 | /* MS <-> SGSN: Attach |
| 1599 | * MS -> SGSN: Detach Req (Power off) |
| 1600 | * VTY -> SGSN: Check if MS is NOT in subscriber cache |
| 1601 | */ |
| 1602 | var BSSGP_ConnHdlr vc_conn; |
| 1603 | var integer id := 33; |
| 1604 | var charstring imsi := hex2str(f_gen_imsi(id)); |
| 1605 | |
| 1606 | f_init(); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1607 | 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] | 1608 | vc_conn.done; |
| 1609 | |
| 1610 | f_vty_transceive_not_match(SGSNVTY, "show subscriber cache", pattern "* IMSI: {imsi}*"); |
| 1611 | } |
Alexander Couzens | 6c47f29 | 2018-05-22 17:09:49 +0200 | [diff] [blame] | 1612 | |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1613 | /* Attempt an attach, but loose the Identification Request (IMEI) */ |
| 1614 | private function f_TC_attach_no_imei_response(charstring id) runs on BSSGP_ConnHdlr { |
| 1615 | var integer count_req := 0; |
| 1616 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 1617 | |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1618 | 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] | 1619 | |
| 1620 | alt { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1621 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_GMM_ATTACH_REJECT(?))) { |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1622 | /* break */ |
| 1623 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1624 | [] 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] | 1625 | mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1626 | BSSGP[0].send(ts_GMM_ID_RESP(mi)); |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1627 | repeat; |
| 1628 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1629 | [] 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] | 1630 | /* ignore ID REQ IMEI */ |
| 1631 | count_req := count_req + 1; |
| 1632 | repeat; |
| 1633 | } |
| 1634 | } |
| 1635 | if (count_req != 5) { |
| 1636 | setverdict(fail, "Did not received GMM ID Request Type IMEI 5 times!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1637 | mtc.stop; |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1638 | } |
| 1639 | setverdict(pass); |
| 1640 | } |
| 1641 | |
| 1642 | testcase TC_attach_no_imei_response() runs on test_CT { |
| 1643 | /* MS -> SGSN: Attach Request IMSI |
| 1644 | * MS <- SGSN: Identity Request IMSI (optional) |
| 1645 | * MS -> SGSN: Identity Response IMSI (optional) |
| 1646 | * MS <- SGSN: Identity Request IMEI |
| 1647 | * MS -x SGSN: no response |
| 1648 | * MS <- SGSN: re-send: Identity Request IMEI 4x |
| 1649 | * MS <- SGSN: Attach Reject |
| 1650 | */ |
| 1651 | var BSSGP_ConnHdlr vc_conn; |
| 1652 | f_init(); |
| 1653 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1654 | 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] | 1655 | vc_conn.done; |
| 1656 | } |
| 1657 | |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1658 | /* Attempt an attach, but loose the Identification Request (IMSI) */ |
| 1659 | private function f_TC_attach_no_imsi_response(charstring id) runs on BSSGP_ConnHdlr { |
| 1660 | var integer count_req := 0; |
| 1661 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 1662 | |
| 1663 | /* set p_tmsi to use it in Attach Req via f_mi_get_lv() */ |
| 1664 | g_pars.p_tmsi := 'c0000035'O; |
| 1665 | |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1666 | 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] | 1667 | |
| 1668 | alt { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1669 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_GMM_ATTACH_REJECT(?))) { |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1670 | /* break */ |
| 1671 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1672 | [] 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] | 1673 | /* ignore ID REQ IMSI */ |
| 1674 | count_req := count_req + 1; |
| 1675 | repeat; |
| 1676 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1677 | [] 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] | 1678 | mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1679 | BSSGP[0].send(ts_GMM_ID_RESP(mi)); |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1680 | repeat; |
| 1681 | } |
| 1682 | } |
| 1683 | if (count_req != 5) { |
| 1684 | setverdict(fail, "Did not received GMM ID Request Type IMSI 5 times!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1685 | mtc.stop; |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1686 | } |
| 1687 | setverdict(pass); |
| 1688 | } |
| 1689 | |
| 1690 | testcase TC_attach_no_imsi_response() runs on test_CT { |
| 1691 | /* MS -> SGSN: Attach Request TMSI (unknown) |
| 1692 | * MS <- SGSN: Identity Request IMEI (optional) |
| 1693 | * MS -> SGSN: Identity Response IMEI (optional) |
| 1694 | * MS <- SGSN: Identity Request IMSI |
| 1695 | * MS -x SGSN: no response |
| 1696 | * MS <- SGSN: re-send: Identity Request IMSI 4x |
| 1697 | * MS <- SGSN: Attach Reject |
| 1698 | */ |
| 1699 | var BSSGP_ConnHdlr vc_conn; |
| 1700 | f_init(); |
| 1701 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1702 | 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] | 1703 | vc_conn.done; |
| 1704 | } |
| 1705 | |
Alexander Couzens | cf81896 | 2018-06-05 18:00:00 +0200 | [diff] [blame] | 1706 | private function f_sgsn_vty_destroy_subscriber_imsi(TELNETasp_PT pt, charstring imsi) { |
| 1707 | f_vty_transceive(pt, "update-subscriber imsi " & imsi & " destroy"); |
| 1708 | } |
| 1709 | |
| 1710 | testcase TC_attach_check_subscriber_list() runs on test_CT { |
| 1711 | /* MS <-> SGSN: Attach |
| 1712 | * VTY -> SGSN: Check if MS is in subscriber cache |
| 1713 | */ |
| 1714 | var BSSGP_ConnHdlr vc_conn; |
| 1715 | var integer id := 34; |
| 1716 | var charstring imsi := hex2str(f_gen_imsi(id)); |
| 1717 | |
| 1718 | f_init(); |
| 1719 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1720 | 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] | 1721 | vc_conn.done; |
| 1722 | |
| 1723 | f_vty_transceive_match(SGSNVTY, "show subscriber cache", pattern "* IMSI: {imsi}*"); |
| 1724 | f_sgsn_vty_destroy_subscriber_imsi(SGSNVTY, imsi); |
| 1725 | } |
| 1726 | |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1727 | private function f_TC_attach_closed_imsi_added(charstring id) runs on BSSGP_ConnHdlr { |
| 1728 | var RoutingAreaIdentificationV old_ra := f_random_RAI(); |
| 1729 | var BssgpDecoded bd; |
| 1730 | |
| 1731 | /* unregister the old IMSI */ |
| 1732 | f_bssgp_client_unregister(g_pars.imsi); |
| 1733 | /* Simulate a foreign IMSI */ |
| 1734 | g_pars.imsi := '001010123456789'H; |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1735 | 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] | 1736 | |
| 1737 | /* there is no auth */ |
| 1738 | g_pars.net.expect_auth := false; |
| 1739 | |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1740 | 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] | 1741 | f_gmm_auth(); |
| 1742 | alt { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1743 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_GMM_ATTACH_REJECT(?))) { |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1744 | setverdict(fail, "Received unexpected GMM Attach REJECT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1745 | mtc.stop; |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1746 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1747 | [] 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] | 1748 | f_process_attach_accept(bd.l3_mt.msgs.gprs_mm.attachAccept); |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1749 | BSSGP[0].send(ts_GMM_ATTACH_COMPL); |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1750 | setverdict(pass); |
| 1751 | } |
| 1752 | } |
| 1753 | } |
| 1754 | testcase TC_attach_closed_add_vty() runs on test_CT { |
| 1755 | /* VTY-> SGSN: policy close |
| 1756 | * MS -> SGSN: Attach Request |
| 1757 | * MS <- SGSN: Identity Request IMSI |
| 1758 | * MS -> SGSN: Identity Response IMSI |
| 1759 | * MS <- SGSN: Attach Reject |
| 1760 | * VTY-> SGSN: policy imsi-acl add IMSI |
| 1761 | * MS -> SGSN: Attach Request |
| 1762 | * MS <- SGSN: Identity Request IMSI |
| 1763 | * MS -> SGSN: Identity Response IMSI |
| 1764 | * MS <- SGSN: Identity Request IMEI |
| 1765 | * MS -> SGSN: Identity Response IMEI |
| 1766 | * MS <- SGSN: Attach Accept |
| 1767 | */ |
| 1768 | var BSSGP_ConnHdlr vc_conn; |
| 1769 | f_init(); |
| 1770 | f_sleep(1.0); |
| 1771 | f_vty_config(SGSNVTY, "sgsn", "auth-policy closed"); |
| 1772 | f_vty_config(SGSNVTY, "sgsn", "imsi-acl del 001010123456789"); |
| 1773 | /* test with foreign IMSI: Must Reject */ |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1774 | 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] | 1775 | vc_conn.done; |
| 1776 | f_vty_config(SGSNVTY, "sgsn", "imsi-acl add 001010123456789"); |
| 1777 | /* test with same IMSI: Must Accept */ |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1778 | 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] | 1779 | vc_conn.done; |
| 1780 | } |
| 1781 | |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 1782 | /* Attempt an attach, but never answer a Attach Complete */ |
| 1783 | private function f_TC_attach_check_complete_resend(charstring id) runs on BSSGP_ConnHdlr { |
| 1784 | var integer count_req := 0; |
| 1785 | |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1786 | 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] | 1787 | f_gmm_auth(); |
| 1788 | |
| 1789 | alt { |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1790 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_GMM_ATTACH_REJECT(?))) { |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 1791 | /* break */ |
| 1792 | } |
Alexander Couzens | 0e510e6 | 2018-07-28 23:06:00 +0200 | [diff] [blame] | 1793 | [] BSSGP[0].receive(tr_BD_L3_MT(tr_GMM_ATTACH_ACCEPT(*, *, *))) { |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 1794 | /* ignore */ |
| 1795 | count_req := count_req + 1; |
| 1796 | repeat; |
| 1797 | } |
| 1798 | } |
| 1799 | if (count_req != 5) { |
| 1800 | setverdict(fail, "Did not received GMM Attach Complete."); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1801 | mtc.stop; |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 1802 | } |
| 1803 | setverdict(pass); |
| 1804 | } |
| 1805 | |
| 1806 | testcase TC_attach_check_complete_resend() runs on test_CT { |
| 1807 | /* MS -> SGSN: Attach Request IMSI |
| 1808 | * MS <- SGSN: Identity Request * |
| 1809 | * MS -> SGSN: Identity Response * |
| 1810 | * MS <- SGSN: Attach Complete 5x |
| 1811 | */ |
| 1812 | var BSSGP_ConnHdlr vc_conn; |
| 1813 | f_init(); |
| 1814 | f_sleep(1.0); |
Alexander Couzens | 51114d1 | 2018-07-31 18:41:56 +0200 | [diff] [blame^] | 1815 | 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] | 1816 | vc_conn.done; |
| 1817 | } |
| 1818 | |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 1819 | control { |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 1820 | execute( TC_attach() ); |
Neels Hofmeyr | 8df7d15 | 2018-03-14 19:03:28 +0100 | [diff] [blame] | 1821 | execute( TC_attach_mnc3() ); |
Neels Hofmeyr | 0ecb2e3 | 2018-04-30 15:13:55 +0200 | [diff] [blame] | 1822 | execute( TC_attach_umts_aka_umts_res() ); |
| 1823 | execute( TC_attach_umts_aka_gsm_sres() ); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 1824 | execute( TC_attach_auth_id_timeout() ); |
| 1825 | execute( TC_attach_auth_sai_timeout() ); |
Harald Welte | fe25388 | 2018-02-17 09:25:00 +0100 | [diff] [blame] | 1826 | execute( TC_attach_auth_sai_reject() ); |
Harald Welte | 5b7c812 | 2018-02-16 21:48:17 +0100 | [diff] [blame] | 1827 | execute( TC_attach_gsup_lu_timeout() ); |
Harald Welte | b7c14e9 | 2018-02-17 09:29:16 +0100 | [diff] [blame] | 1828 | execute( TC_attach_gsup_lu_reject() ); |
Harald Welte | 3823e2e | 2018-02-16 21:53:48 +0100 | [diff] [blame] | 1829 | execute( TC_attach_combined() ); |
Harald Welte | 76dee09 | 2018-02-16 22:12:59 +0100 | [diff] [blame] | 1830 | execute( TC_attach_accept_all() ); |
Harald Welte | b2124b2 | 2018-02-16 22:26:56 +0100 | [diff] [blame] | 1831 | execute( TC_attach_closed() ); |
Alexander Couzens | 667dd7f | 2018-06-12 16:24:01 +0200 | [diff] [blame] | 1832 | execute( TC_attach_no_imei_response() ); |
Alexander Couzens | 53f2056 | 2018-06-12 16:24:12 +0200 | [diff] [blame] | 1833 | execute( TC_attach_no_imsi_response() ); |
Alexander Couzens | f985865 | 2018-06-07 16:14:53 +0200 | [diff] [blame] | 1834 | execute( TC_attach_closed_add_vty(), 10.0 ); |
Alexander Couzens | cf81896 | 2018-06-05 18:00:00 +0200 | [diff] [blame] | 1835 | execute( TC_attach_check_subscriber_list(), 10.0 ); |
Alexander Couzens | 49bb4b4 | 2018-06-05 16:28:36 +0200 | [diff] [blame] | 1836 | execute( TC_attach_detach_check_subscriber_list(), 10.0 ); |
Alexander Couzens | 0085bd7 | 2018-06-12 19:08:44 +0200 | [diff] [blame] | 1837 | execute( TC_attach_check_complete_resend() ); |
Alexander Couzens | 5e307b4 | 2018-05-22 18:12:20 +0200 | [diff] [blame] | 1838 | execute( TC_hlr_location_cancel_request_update(), 10.0 ); |
Alexander Couzens | 234c588 | 2018-05-29 15:48:44 +0200 | [diff] [blame] | 1839 | execute( TC_hlr_location_cancel_request_withdraw(), 10.0 ); |
| 1840 | execute( TC_hlr_location_cancel_request_unknown_subscriber_withdraw(), 10.0 ); |
| 1841 | execute( TC_hlr_location_cancel_request_unknown_subscriber_update(), 10.0 ); |
Harald Welte | 04683d0 | 2018-02-16 22:43:45 +0100 | [diff] [blame] | 1842 | execute( TC_rau_unknown() ); |
Harald Welte | 91636de | 2018-02-17 10:16:14 +0100 | [diff] [blame] | 1843 | execute( TC_attach_rau() ); |
Harald Welte | 6abb9fe | 2018-02-17 15:24:48 +0100 | [diff] [blame] | 1844 | execute( TC_detach_unknown_nopoweroff() ); |
| 1845 | execute( TC_detach_unknown_poweroff() ); |
| 1846 | execute( TC_detach_nopoweroff() ); |
| 1847 | execute( TC_detach_poweroff() ); |
Harald Welte | eded9ad | 2018-02-17 20:57:34 +0100 | [diff] [blame] | 1848 | execute( TC_attach_pdp_act() ); |
Harald Welte | 835b15f | 2018-02-18 14:39:11 +0100 | [diff] [blame] | 1849 | execute( TC_pdp_act_unattached() ); |
Harald Welte | 37692d8 | 2018-02-18 15:21:34 +0100 | [diff] [blame] | 1850 | execute( TC_attach_pdp_act_user() ); |
Harald Welte | 5b5ca1b | 2018-02-18 21:25:03 +0100 | [diff] [blame] | 1851 | execute( TC_attach_pdp_act_ggsn_reject() ); |
Harald Welte | 6f20316 | 2018-02-18 22:04:55 +0100 | [diff] [blame] | 1852 | execute( TC_attach_pdp_act_user_deact_mo() ); |
Harald Welte | 57b9b7f | 2018-02-18 22:28:13 +0100 | [diff] [blame] | 1853 | execute( TC_attach_pdp_act_user_deact_mt() ); |
Alexander Couzens | 187ad5d | 2018-05-02 19:31:10 +0200 | [diff] [blame] | 1854 | execute( TC_attach_second_attempt() ); |
Pau Espin Pedrol | 9401345 | 2018-07-17 15:50:21 +0200 | [diff] [blame] | 1855 | execute( TC_attach_restart_ctr_echo() ); |
| 1856 | execute( TC_attach_restart_ctr_create() ); |
Pau Espin Pedrol | 72edc8a | 2018-07-16 15:10:08 +0200 | [diff] [blame] | 1857 | execute( TC_attach_pdp_act_deact_mt_t3395_expire() ); |
Pau Espin Pedrol | 482dde6 | 2018-07-18 13:47:42 +0200 | [diff] [blame] | 1858 | execute( TC_attach_pdp_act_user_error_ind_ggsn() ); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 1859 | } |
Harald Welte | 96a33b0 | 2018-02-04 10:36:22 +0100 | [diff] [blame] | 1860 | |
| 1861 | |
| 1862 | |
| 1863 | } |