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