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