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