Harald Welte | 379d45a | 2017-08-03 09:55:15 +0200 | [diff] [blame] | 1 | module GGSN_Tests { |
| 2 | |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 3 | /* GGSN test suite in TTCN-3 |
| 4 | * (C) 2017-2019 Harald Welte <laforge@gnumonks.org> |
| 5 | * (C) 2018-2019 sysmocom - s.f.m.c. GmbH |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Released under the terms of GNU General Public License, Version 2 or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | */ |
| 13 | |
| 14 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 15 | import from General_Types all; |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 16 | import from Osmocom_Types all; |
Pau Espin Pedrol | c04c69e | 2020-03-03 16:46:29 +0100 | [diff] [blame] | 17 | import from Misc_Helpers all; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 18 | import from IPL4asp_PortType all; |
| 19 | import from IPL4asp_Types all; |
| 20 | import from GTP_CodecPort all; |
| 21 | import from GTP_CodecPort_CtrlFunct all; |
Harald Welte | c69cf4e | 2018-02-17 20:57:02 +0100 | [diff] [blame] | 22 | import from GTP_Templates all; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 23 | import from GTPC_Types all; |
| 24 | import from GTPU_Types all; |
Harald Welte | 71a3602 | 2017-12-04 18:55:58 +0100 | [diff] [blame] | 25 | import from IPCP_Types all; |
Harald Welte | f829854 | 2019-04-10 10:15:28 +0200 | [diff] [blame] | 26 | import from PAP_Types all; |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 27 | import from IP_Types all; |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 28 | import from ICMP_Types all; |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 29 | import from ICMPv6_Types all; |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 30 | import from Native_Functions all; |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 31 | import from Osmocom_VTY_Functions all; |
| 32 | import from TELNETasp_PortType all; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 33 | |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 34 | import from DIAMETER_Types all; |
| 35 | import from DIAMETER_Templates all; |
| 36 | import from DIAMETER_Emulation all; |
| 37 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 38 | const integer GTP0_PORT := 3386; |
| 39 | const integer GTP1C_PORT := 2123; |
| 40 | const integer GTP1U_PORT := 2152; |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 41 | const integer PCRF_PORT := 3868; |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 42 | const integer OCS_PORT := 3869; |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 43 | |
Pau Espin Pedrol | c1b1ddf | 2022-01-19 18:10:30 +0100 | [diff] [blame] | 44 | type enumerated GGSN_Impl { |
| 45 | GGSN_IMPL_OSMOCOM, |
| 46 | GGSN_IMPL_OPEN5GS |
| 47 | }; |
| 48 | |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 49 | modulepar { |
Stefan Sperling | cb782b9 | 2018-04-03 16:03:15 +0200 | [diff] [blame] | 50 | /* Default IP addresses. May be overridden by GGSN_Tests configuration files. */ |
| 51 | |
| 52 | /* The SGSN simulated by TTCN3 will bind to these addresses for GTP control and GTP user planes. */ |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 53 | charstring m_bind_ip_gtpc := "127.23.42.1"; |
| 54 | charstring m_bind_ip_gtpu := "127.23.42.1"; |
| 55 | |
Stefan Sperling | cb782b9 | 2018-04-03 16:03:15 +0200 | [diff] [blame] | 56 | /* Addresses the GGSN which is being tested is listening on for SGSN connections. */ |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 57 | charstring m_ggsn_ip_gtpc := "127.0.0.6"; |
| 58 | charstring m_ggsn_ip_gtpu := "127.0.0.6"; |
Pau Espin Pedrol | f69a438 | 2018-01-29 13:09:00 +0100 | [diff] [blame] | 59 | |
Stefan Sperling | cb782b9 | 2018-04-03 16:03:15 +0200 | [diff] [blame] | 60 | /* |
| 61 | * Our tests expect to see these DNS servers in 'Create PDP context responses' sent by the GGSN. |
| 62 | * These addresses must therefore match 'ip[v6] dns' options configured in osmo-ggsn.conf. |
| 63 | * |
| 64 | * These addresses are not expected to serve actual DNS requests. However, tests may expect to be |
| 65 | * able to ping these addresses (currently, IPv4 addresses must respond with an ICMP 'echo reply', |
| 66 | * and IPv6 addresses may respond with either ICMPv6 'echo reply' or 'destination unreachable'). |
| 67 | */ |
Pau Espin Pedrol | f69a438 | 2018-01-29 13:09:00 +0100 | [diff] [blame] | 68 | charstring m_ggsn_ip4_dns1 := "192.168.100.1" |
| 69 | charstring m_ggsn_ip4_dns2 := "8.8.8.8" |
Pau Espin Pedrol | 363ba48 | 2018-01-29 18:42:00 +0100 | [diff] [blame] | 70 | charstring m_ggsn_ip6_dns1 := "2001:4860:4860::8888" |
| 71 | charstring m_ggsn_ip6_dns2 := "2001:4860:4860::8844" |
Stefan Sperling | cb782b9 | 2018-04-03 16:03:15 +0200 | [diff] [blame] | 72 | |
| 73 | /* |
| 74 | * Additional address ranges are defined in osmo-ggsn.conf from which addresses are assigned |
| 75 | * to MS "behind" the simulated SGSN. These addresses appear on tun devices used by osmo-ggsn. |
| 76 | * The tests expect to be able to send ping packets between any two simulated MS within the same |
| 77 | * address range. This requires IP forwarding to be enabled on the corresponding tun interfaces. |
| 78 | */ |
Pau Espin Pedrol | c1b1ddf | 2022-01-19 18:10:30 +0100 | [diff] [blame] | 79 | |
| 80 | GGSN_Impl m_ggsn_impl := GGSN_IMPL_OSMOCOM; |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 81 | } |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 82 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 83 | type set PdpContext { |
| 84 | hexstring imsi, |
| 85 | octetstring msisdn optional, |
| 86 | octetstring apn, |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 87 | ProtConfigOptions pco_req optional, |
| 88 | ProtConfigOptions pco_neg optional, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 89 | EndUserAddress eua, |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 90 | OCT16 ip6_prefix optional, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 91 | BIT4 nsapi, |
| 92 | /* TEI (Data) local side */ |
| 93 | OCT4 teid, |
| 94 | /* TEI (Control) local side */ |
| 95 | OCT4 teic, |
| 96 | /* TEI (Data) remote side */ |
| 97 | OCT4 teid_remote, |
| 98 | /* TEI (Control) remote side */ |
Pau Espin Pedrol | 38aeffb | 2022-02-01 20:46:29 +0100 | [diff] [blame] | 99 | OCT4 teic_remote, |
Pau Espin Pedrol | ca587f1 | 2022-02-02 10:42:01 +0100 | [diff] [blame] | 100 | OCT1 ratType optional, |
Pau Espin Pedrol | 0e12787 | 2022-05-12 17:58:50 +0200 | [diff] [blame] | 101 | UserLocationInformation uli optional, |
Pau Espin Pedrol | 38968e9 | 2022-05-13 16:17:48 +0200 | [diff] [blame] | 102 | OCT2 charging_char optional, |
Pau Espin Pedrol | 535ca26 | 2022-05-16 14:07:17 +0200 | [diff] [blame^] | 103 | OCT8 imeisv optional, |
| 104 | MS_TimeZone ms_tz optional |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 105 | } |
| 106 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 107 | type component GT_CT { |
| 108 | port GTPC_PT GTPC; |
| 109 | port GTPU_PT GTPU; |
| 110 | |
Harald Welte | 0be142b | 2017-08-13 13:28:10 +0200 | [diff] [blame] | 111 | var boolean g_initialized := false; |
| 112 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 113 | var OCT1 g_restart_ctr := '01'O; |
| 114 | /* FIXME: unify with g_bind_ip + parse from config file */ |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 115 | var OCT4 g_sgsn_ip_c; |
| 116 | var OCT4 g_sgsn_ip_u; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 117 | /* FIXME: parse remName from config file */ |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 118 | var GtpPeer g_peer_c := { connId := 0, remName := m_ggsn_ip_gtpc, remPort := GTP1C_PORT }; |
| 119 | var GtpPeer g_peer_u := { connId := 0, remName := m_ggsn_ip_gtpu, remPort := GTP1U_PORT }; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 120 | timer T_default := 3.0; |
Harald Welte | 5438b9d | 2017-08-13 13:27:48 +0200 | [diff] [blame] | 121 | |
| 122 | /* next to-be-sent GTP-C sequence number */ |
| 123 | var uint16_t g_c_seq_nr; |
| 124 | /* next to-be-sent GTP-U sequence number */ |
| 125 | var uint16_t g_d_seq_nr; |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 126 | |
| 127 | port TELNETasp_PT GGSNVTY; |
Harald Welte | d2394e9 | 2018-04-26 10:21:49 +0200 | [diff] [blame] | 128 | var boolean use_gtpu_txseq := false; |
Pau Espin Pedrol | 0511802 | 2022-02-17 19:49:13 +0100 | [diff] [blame] | 129 | var integer g_use_echo_intval := 0; /* 0 = disabled */ |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 130 | |
| 131 | /* emulated PCRF, used with m_ggsn_impl = GGSN_IMPL_OPEN5GS */ |
Pau Espin Pedrol | 45d5702 | 2022-03-08 13:49:02 +0100 | [diff] [blame] | 132 | var DIAMETER_Emulation_CT vc_Gx; |
| 133 | port DIAMETER_PT Gx_UNIT; |
| 134 | port DIAMETEREM_PROC_PT Gx_PROC; |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 135 | var DIAMETER_Emulation_CT vc_Gy; |
| 136 | port DIAMETER_PT Gy_UNIT; |
| 137 | port DIAMETEREM_PROC_PT Gy_PROC; |
| 138 | var integer g_gy_validity_time := 0; /* In seconds. 0 => disabled, !0 => grant over CC-Time period */ |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | private function f_init_vty() runs on GT_CT { |
| 142 | map(self:GGSNVTY, system:GGSNVTY); |
| 143 | f_vty_set_prompts(GGSNVTY); |
| 144 | f_vty_transceive(GGSNVTY, "enable"); |
| 145 | } |
| 146 | |
| 147 | private function f_vty_set_gpdu_txseq(boolean enable) runs on GT_CT { |
| 148 | f_vty_enter_config(GGSNVTY); |
| 149 | f_vty_transceive(GGSNVTY, "ggsn ggsn0"); |
Pau Espin Pedrol | 205a384 | 2018-07-06 13:24:14 +0200 | [diff] [blame] | 150 | |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 151 | f_vty_transceive(GGSNVTY, "apn internet"); |
| 152 | if (enable) { |
| 153 | f_vty_transceive(GGSNVTY, "g-pdu tx-sequence-numbers"); |
| 154 | } else { |
| 155 | f_vty_transceive(GGSNVTY, "no g-pdu tx-sequence-numbers"); |
| 156 | } |
Pau Espin Pedrol | 205a384 | 2018-07-06 13:24:14 +0200 | [diff] [blame] | 157 | f_vty_transceive(GGSNVTY, "exit"); |
| 158 | |
| 159 | f_vty_transceive(GGSNVTY, "apn inet6"); |
| 160 | if (enable) { |
| 161 | f_vty_transceive(GGSNVTY, "g-pdu tx-sequence-numbers"); |
| 162 | } else { |
| 163 | f_vty_transceive(GGSNVTY, "no g-pdu tx-sequence-numbers"); |
| 164 | } |
| 165 | f_vty_transceive(GGSNVTY, "exit"); |
| 166 | |
| 167 | f_vty_transceive(GGSNVTY, "apn inet46"); |
| 168 | if (enable) { |
| 169 | f_vty_transceive(GGSNVTY, "g-pdu tx-sequence-numbers"); |
| 170 | } else { |
| 171 | f_vty_transceive(GGSNVTY, "no g-pdu tx-sequence-numbers"); |
| 172 | } |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 173 | f_vty_transceive(GGSNVTY, "end"); |
| 174 | } |
| 175 | |
| 176 | private function f_verify_gtpu_txseq(in PDU_GTPU gtpu, in boolean expect_gptu_txseq) return boolean { |
| 177 | if (expect_gptu_txseq) { |
| 178 | if (gtpu.s_bit != '1'B) { |
| 179 | log("GTPU sequence number expected but not present") |
| 180 | return false; |
| 181 | } |
| 182 | } else { |
| 183 | if (gtpu.s_bit != '0'B) { |
| 184 | log("GTPU sequence number not expected but present") |
| 185 | return false; |
| 186 | } |
| 187 | } |
| 188 | return true; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 189 | } |
| 190 | |
Pau Espin Pedrol | 0511802 | 2022-02-17 19:49:13 +0100 | [diff] [blame] | 191 | private function f_vty_enable_echo_interval(integer intval_sec) runs on GT_CT { |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 192 | f_vty_enter_config(GGSNVTY); |
| 193 | f_vty_transceive(GGSNVTY, "ggsn ggsn0"); |
Pau Espin Pedrol | 0511802 | 2022-02-17 19:49:13 +0100 | [diff] [blame] | 194 | if (intval_sec > 0) { |
| 195 | f_vty_transceive(GGSNVTY, "echo-interval " & int2str(intval_sec)); |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 196 | } else { |
| 197 | f_vty_transceive(GGSNVTY, "no echo-interval"); |
| 198 | } |
| 199 | f_vty_transceive(GGSNVTY, "end"); |
| 200 | } |
| 201 | |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 202 | private function DiameterForwardUnitdataCallback(PDU_DIAMETER msg) |
| 203 | runs on DIAMETER_Emulation_CT return template PDU_DIAMETER { |
| 204 | DIAMETER_UNIT.send(msg); |
| 205 | return omit; |
| 206 | } |
| 207 | |
| 208 | private function f_init_diameter(charstring id) runs on GT_CT { |
| 209 | var DIAMETEROps ops := { |
| 210 | create_cb := refers(DIAMETER_Emulation.ExpectedCreateCallback), |
| 211 | unitdata_cb := refers(DiameterForwardUnitdataCallback), |
| 212 | raw := true /* handler mode (single component for all IMSI)) */ |
| 213 | }; |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 214 | var DIAMETER_conn_parameters pars; |
| 215 | |
| 216 | /* Gx setup: */ |
| 217 | pars := { |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 218 | remote_ip := m_ggsn_ip_gtpc, |
| 219 | remote_sctp_port := -1, |
| 220 | local_ip := m_bind_ip_gtpc, |
| 221 | local_sctp_port := PCRF_PORT, |
Pau Espin Pedrol | 45d5702 | 2022-03-08 13:49:02 +0100 | [diff] [blame] | 222 | origin_host := "pcrf.localdomain", |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 223 | origin_realm := "localdomain", |
Pau Espin Pedrol | 33b4749 | 2022-03-08 17:43:01 +0100 | [diff] [blame] | 224 | auth_app_id := omit, |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 225 | vendor_app_id := c_DIAMETER_3GPP_Gx_AID |
| 226 | }; |
Pau Espin Pedrol | 45d5702 | 2022-03-08 13:49:02 +0100 | [diff] [blame] | 227 | vc_Gx := DIAMETER_Emulation_CT.create(id); |
| 228 | map(vc_Gx:DIAMETER, system:DIAMETER_CODEC_PT); |
| 229 | connect(vc_Gx:DIAMETER_UNIT, self:Gx_UNIT); |
| 230 | connect(vc_Gx:DIAMETER_PROC, self:Gx_PROC); |
| 231 | vc_Gx.start(DIAMETER_Emulation.main(ops, pars, id)); |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 232 | |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 233 | /* Gy setup: */ |
| 234 | pars := { |
| 235 | remote_ip := m_ggsn_ip_gtpc, |
| 236 | remote_sctp_port := -1, |
| 237 | local_ip := m_bind_ip_gtpc, |
| 238 | local_sctp_port := OCS_PORT, |
| 239 | origin_host := "ocs.localdomain", |
| 240 | origin_realm := "localdomain", |
| 241 | auth_app_id := c_DIAMETER_CREDIT_CONTROL_AID, |
| 242 | vendor_app_id := omit |
| 243 | }; |
| 244 | vc_Gy := DIAMETER_Emulation_CT.create(id); |
| 245 | map(vc_Gy:DIAMETER, system:DIAMETER_CODEC_PT); |
| 246 | connect(vc_Gy:DIAMETER_UNIT, self:Gy_UNIT); |
| 247 | connect(vc_Gy:DIAMETER_PROC, self:Gy_PROC); |
| 248 | vc_Gy.start(DIAMETER_Emulation.main(ops, pars, id)); |
| 249 | |
Pau Espin Pedrol | 45d5702 | 2022-03-08 13:49:02 +0100 | [diff] [blame] | 250 | f_diameter_wait_capability(Gx_UNIT); |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 251 | f_diameter_wait_capability(Gy_UNIT); |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 252 | /* Give some time for our emulation to get out of SUSPECT list of SUT (3 watchdong ping-pongs): |
| 253 | * RFC6733 sec 5.1 |
| 254 | * RFC3539 sec 3.4.1 [5] |
| 255 | * https://github.com/freeDiameter/freeDiameter/blob/master/libfdcore/p_psm.c#L49 |
| 256 | */ |
| 257 | f_sleep(1.0); |
| 258 | } |
| 259 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 260 | function f_init() runs on GT_CT { |
Harald Welte | 0be142b | 2017-08-13 13:28:10 +0200 | [diff] [blame] | 261 | if (g_initialized == true) { |
| 262 | return; |
| 263 | } |
| 264 | g_initialized := true; |
| 265 | |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 266 | g_sgsn_ip_c := f_inet_addr(m_bind_ip_gtpc); |
| 267 | g_sgsn_ip_u := f_inet_addr(m_bind_ip_gtpu); |
| 268 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 269 | var Result res; |
| 270 | map(self:GTPC, system:GTPC); |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 271 | res := GTP_CodecPort_CtrlFunct.f_IPL4_listen(GTPC, m_bind_ip_gtpc, GTP1C_PORT, {udp:={}}); |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 272 | log("GTP1C ConnectionID: ", res.connId); |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 273 | g_peer_c.connId := res.connId; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 274 | |
| 275 | map(self:GTPU, system:GTPU); |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 276 | res := GTP_CodecPort_CtrlFunct.f_GTPU_listen(GTPU, m_bind_ip_gtpu, GTP1U_PORT, {udp:={}}); |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 277 | g_peer_u.connId:= res.connId; |
Harald Welte | 5438b9d | 2017-08-13 13:27:48 +0200 | [diff] [blame] | 278 | |
| 279 | g_restart_ctr := f_rnd_octstring(1); |
Harald Welte | 11dbc7b | 2017-08-13 18:57:56 +0200 | [diff] [blame] | 280 | g_c_seq_nr := f_rnd_int(65535); |
| 281 | g_d_seq_nr := f_rnd_int(65535); |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 282 | |
Pau Espin Pedrol | c1b1ddf | 2022-01-19 18:10:30 +0100 | [diff] [blame] | 283 | if (m_ggsn_impl == GGSN_IMPL_OSMOCOM) { |
| 284 | f_init_vty(); |
| 285 | f_vty_set_gpdu_txseq(use_gtpu_txseq); |
Pau Espin Pedrol | 0511802 | 2022-02-17 19:49:13 +0100 | [diff] [blame] | 286 | f_vty_enable_echo_interval(g_use_echo_intval); |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 287 | } else if (m_ggsn_impl == GGSN_IMPL_OPEN5GS) { |
| 288 | f_init_diameter(testcasename()); |
Pau Espin Pedrol | c1b1ddf | 2022-01-19 18:10:30 +0100 | [diff] [blame] | 289 | } |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 290 | } |
| 291 | |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 292 | function f_shutdown_helper() runs on GT_CT { |
| 293 | /* Sleep N3_REQUESTS * T3_REQUEST seconds, nowadays 5*3=15s. |
| 294 | * This ensures all retransmit queues are cleared before jumping |
| 295 | * into next tests, hence avoding situation where a test resuses |
| 296 | * a seqnum still in the GGSN's resp queue (dup req detector). |
| 297 | * See OS#5485 avout decreasing time. We could also add a new |
| 298 | * VTY command that calls gtp_clear_queues() */ |
| 299 | f_sleep(15.0); |
| 300 | setverdict(pass); |
| 301 | } |
| 302 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 303 | /* Altstep implementing responses to any incoming echo requests */ |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 304 | private altstep pingpong() runs on GT_CT { |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 305 | var Gtp1cUnitdata ud; |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 306 | var Gtp1uUnitdata udu; |
Pau Espin Pedrol | 0511802 | 2022-02-17 19:49:13 +0100 | [diff] [blame] | 307 | [g_use_echo_intval > 0] GTPC.receive(tr_GTPC_PING(?)) -> value ud { |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 308 | var uint16_t seq := oct2int(ud.gtpc.opt_part.sequenceNumber); |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 309 | GTPC.send(ts_GTPC_PONG(ud.peer, seq, g_restart_ctr)); |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 310 | repeat; |
| 311 | }; |
Pau Espin Pedrol | 0511802 | 2022-02-17 19:49:13 +0100 | [diff] [blame] | 312 | [g_use_echo_intval == 0] GTPC.receive(tr_GTPC_PING(?)) { |
Pau Espin Pedrol | c04c69e | 2020-03-03 16:46:29 +0100 | [diff] [blame] | 313 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 314 | "GTP Echo Req rceived but not enabled in VTY"); |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 315 | }; |
Pau Espin Pedrol | c04c69e | 2020-03-03 16:46:29 +0100 | [diff] [blame] | 316 | [] T_default.timeout { |
| 317 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 318 | "pinpong T_default timeout"); |
| 319 | }; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 320 | } |
| 321 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 322 | /* 'internet' in DNS encoding */ |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 323 | const octetstring c_ApnInternet := '08696E7465726E6574'O; |
| 324 | const octetstring c_ApnInet6 := '05696E657436'O; |
| 325 | const octetstring c_ApnInet46 := '06696E65743436'O; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 326 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 327 | /* return random NSAPI */ |
| 328 | function f_rnd_nsapi() return BIT4 { |
| 329 | return int2bit(f_rnd_int(16), 4); |
| 330 | } |
| 331 | |
| 332 | /* return random TEI[DC] */ |
| 333 | function f_rnd_tei() return OCT4 { |
| 334 | return int2oct(f_rnd_int(4294967296), 4); |
| 335 | } |
| 336 | |
Pau Espin Pedrol | 38968e9 | 2022-05-13 16:17:48 +0200 | [diff] [blame] | 337 | /* return random IMEI(SV) */ |
| 338 | function f_rnd_imeisv() return OCT8 { |
| 339 | return hex2oct(f_rnd_hexstring(16, 10)); |
| 340 | } |
| 341 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 342 | /* define an (internal) representation of a PDP context */ |
| 343 | template PdpContext t_DefinePDP(hexstring imsi, octetstring msisdn, octetstring apn, |
Pau Espin Pedrol | 38aeffb | 2022-02-01 20:46:29 +0100 | [diff] [blame] | 344 | EndUserAddress eua, OCT1 ratType := '02'O /* GERAN */) := { |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 345 | imsi := imsi, |
| 346 | msisdn := msisdn, |
| 347 | nsapi := f_rnd_nsapi(), |
| 348 | apn := apn, |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 349 | pco_req := omit, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 350 | eua := eua, |
| 351 | teid := f_rnd_tei(), |
Pau Espin Pedrol | 38aeffb | 2022-02-01 20:46:29 +0100 | [diff] [blame] | 352 | teic := f_rnd_tei(), |
Pau Espin Pedrol | ca587f1 | 2022-02-02 10:42:01 +0100 | [diff] [blame] | 353 | ratType := ratType, |
| 354 | uli := { |
| 355 | type_gtpc := '98'O, |
| 356 | lengthf := 0 /* filled in by encoder */, |
| 357 | geographicLocationType := '00'O /* CGI */, |
| 358 | geographicLocation := { |
| 359 | geographicLocationCGI := ts_GeographicLocationCGI('262'H, '42F'H, '0001'O, '0002'O) |
| 360 | } |
Pau Espin Pedrol | 0e12787 | 2022-05-12 17:58:50 +0200 | [diff] [blame] | 361 | }, |
Pau Espin Pedrol | 38968e9 | 2022-05-13 16:17:48 +0200 | [diff] [blame] | 362 | charging_char := '0000'O, |
Pau Espin Pedrol | 535ca26 | 2022-05-16 14:07:17 +0200 | [diff] [blame^] | 363 | imeisv := f_rnd_imeisv(), |
| 364 | ms_tz := f_ts_MS_TimeZone('03'O, '01'B) |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | /* send GTP-C for a given context and increment sequence number */ |
Harald Welte | 41575e9 | 2017-08-13 13:49:57 +0200 | [diff] [blame] | 368 | function f_send_gtpc(in template Gtp1cUnitdata data) runs on GT_CT { |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 369 | GTPC.send(data); |
Harald Welte | 5438b9d | 2017-08-13 13:27:48 +0200 | [diff] [blame] | 370 | g_c_seq_nr := g_c_seq_nr + 1; |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | /* send GTP-U for a given context and increment sequence number */ |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 374 | function f_send_gtpu(inout PdpContext ctx, in octetstring data) runs on GT_CT { |
Harald Welte | 3e0b039 | 2018-04-26 09:46:21 +0200 | [diff] [blame] | 375 | if (use_gtpu_txseq) { |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 376 | GTPU.send(ts_GTP1U_GPDU(g_peer_u, g_d_seq_nr, ctx.teid_remote, data)); |
| 377 | g_d_seq_nr := g_d_seq_nr + 1; |
| 378 | } else { |
| 379 | GTPU.send(ts_GTP1U_GPDU(g_peer_u, omit, ctx.teid_remote, data)); |
| 380 | } |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 381 | } |
| 382 | |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 383 | function f_handle_create_req(inout PdpContext ctx, in Gtp1cUnitdata ud, in template OCT1 exp_cause := '80'O) runs on GT_CT { |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 384 | var CreatePDPContextResponse cpr := ud.gtpc.gtpc_pdu.createPDPContextResponse; |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 385 | |
| 386 | if (not match(cpr.cause.causevalue, exp_cause)) { |
| 387 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 388 | "CreatePDPContextResp: cause expectancies didn't match"); |
| 389 | } |
| 390 | |
| 391 | if (cpr.cause.causevalue == '80'O) { /* Accepted */ |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 392 | /* Check if EUA type corresponds to requested type */ |
| 393 | if (match(ctx.eua, t_EuaIPv4(?)) and |
| 394 | not match(cpr.endUserAddress, tr_EuaIPv4(?))){ |
Pau Espin Pedrol | 8ad031a | 2022-02-16 17:33:43 +0100 | [diff] [blame] | 395 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 396 | "EUAv4 expectancies didn't match"); |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 397 | } |
| 398 | if (match(ctx.eua, t_EuaIPv6(?)) and |
| 399 | not match(cpr.endUserAddress, tr_EuaIPv6(?))) { |
Pau Espin Pedrol | 8ad031a | 2022-02-16 17:33:43 +0100 | [diff] [blame] | 400 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 401 | "EUAv6 expectancies didn't match"); |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 402 | } |
| 403 | if (match(ctx.eua, t_EuaIPv4v6(?, ?)) and |
| 404 | not match(cpr.endUserAddress, tr_EuaIPv4v6(?, ?))) { |
Pau Espin Pedrol | 8ad031a | 2022-02-16 17:33:43 +0100 | [diff] [blame] | 405 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 406 | "EUAv4v6 expectancies didn't match"); |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 407 | } |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 408 | } else if (cpr.cause.causevalue == '81'O) { /* Cause: New PDP type due to network preference */ |
| 409 | /* ETSI TS 129 060 7.3.2 Create PDP Context Response. OS#5449 */ |
| 410 | /* This should only happen if EUA requested type is v4v6: */ |
| 411 | if (not ischosen(ctx.eua.endUserAddress.endUserAddressIPv4andIPv6)) { |
| 412 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 413 | "Cause not expected when requesting a non v4v6 EUA"); |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 414 | } |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 415 | if (not match(cpr.endUserAddress, (tr_EuaIPv4(?), tr_EuaIPv6(?)))) { |
| 416 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 417 | "Cause not expected when requesting+receiving EUAv4v6"); |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 418 | } |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 419 | } else { |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 420 | if (ispresent(cpr.endUserAddress)) { |
| 421 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 422 | "EUA received on createPDPContextResponse cause=" & oct2str(cpr.cause.causevalue)); |
| 423 | } |
| 424 | setverdict(pass); |
| 425 | return; |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 426 | } |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 427 | |
| 428 | /* Check if PCO response corresponds to request */ |
| 429 | if (ispresent(ctx.pco_req)) { |
| 430 | if (match(ctx.pco_req, ts_PCO_IPv4_DNS_CONT) and |
| 431 | not match(cpr.protConfigOptions, tr_PCO_IPv4_DNS_CONT_resp(?))) { |
| 432 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 433 | "IPv4 DNS Container requested, but missing"); |
| 434 | } |
| 435 | if (match(ctx.pco_req, ts_PCO_IPv6_DNS) and |
| 436 | not match(cpr.protConfigOptions, tr_PCO_IPv6_DNS_resp(?))) { |
| 437 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 438 | "IPv6 DNS Container requested, but missing"); |
| 439 | } |
| 440 | } |
| 441 | ctx.teid_remote := cpr.teidDataI.teidDataI; |
| 442 | ctx.teic_remote := cpr.teidControlPlane.teidControlPlane; |
| 443 | ctx.eua := cpr.endUserAddress; |
| 444 | ctx.pco_neg := cpr.protConfigOptions; |
| 445 | setverdict(pass); |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 446 | } |
| 447 | |
Pau Espin Pedrol | cd326c5 | 2022-02-14 18:57:43 +0100 | [diff] [blame] | 448 | function f_handle_update_req(inout PdpContext ctx, in Gtp1cUnitdata ud, in OCT1 exp_cause := '80'O) runs on GT_CT { |
| 449 | var UpdatePDPContextResponseGGSN upr := ud.gtpc.gtpc_pdu.updatePDPContextResponse.updatePDPContextResponseGGSN; |
| 450 | if (exp_cause == '80'O and exp_cause == upr.cause.causevalue) { |
| 451 | ctx.teid_remote := upr.teidDataI.teidDataI; |
| 452 | ctx.teic_remote := upr.teidControlPlane.teidControlPlane; |
| 453 | if (ispresent(upr.protConfigOptions)) { |
| 454 | ctx.pco_neg := upr.protConfigOptions; |
| 455 | } |
| 456 | setverdict(pass); |
| 457 | } else if (exp_cause != '80'O and exp_cause == upr.cause.causevalue) { |
| 458 | setverdict(pass); |
| 459 | } else { |
Pau Espin Pedrol | 8ad031a | 2022-02-16 17:33:43 +0100 | [diff] [blame] | 460 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 461 | "UpdatePDPContextResp: cause expectancies didn't match"); |
Pau Espin Pedrol | cd326c5 | 2022-02-14 18:57:43 +0100 | [diff] [blame] | 462 | } |
| 463 | } |
| 464 | |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 465 | private altstep as_DIA_Gx_CCR(DCC_NONE_CC_Request_Type req_type) runs on GT_CT { |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 466 | var PDU_DIAMETER rx_dia; |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 467 | [] Gx_UNIT.receive(tr_DIA_Gx_CCR(req_type := req_type)) -> value rx_dia { |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 468 | var template (omit) AVP avp; |
| 469 | var octetstring sess_id; |
| 470 | var AVP_Unsigned32 req_num; |
| 471 | |
| 472 | avp := f_DIAMETER_get_avp(rx_dia, c_AVP_Code_BASE_NONE_Session_Id); |
| 473 | sess_id := valueof(avp.avp_data.avp_BASE_NONE_Session_Id); |
| 474 | |
| 475 | avp := f_DIAMETER_get_avp(rx_dia, c_AVP_Code_DCC_NONE_CC_Request_Number); |
| 476 | req_num := valueof(avp.avp_data.avp_DCC_NONE_CC_Request_Number); |
| 477 | |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 478 | Gx_UNIT.send(ts_DIA_Gx_CCA(rx_dia.hop_by_hop_id, rx_dia.end_to_end_id, sess_id, |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 479 | req_type, req_num)); |
| 480 | } |
Pau Espin Pedrol | 45d5702 | 2022-03-08 13:49:02 +0100 | [diff] [blame] | 481 | [] Gx_UNIT.receive(PDU_DIAMETER:?) -> value rx_dia { |
Pau Espin Pedrol | 8ad031a | 2022-02-16 17:33:43 +0100 | [diff] [blame] | 482 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 483 | log2str("Received unexpected DIAMETER ", rx_dia)); |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 484 | } |
| 485 | } |
| 486 | |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 487 | private altstep as_DIA_Gy_CCR(DCC_NONE_CC_Request_Type req_type) runs on GT_CT { |
| 488 | var PDU_DIAMETER rx_dia; |
| 489 | [] Gy_UNIT.receive(tr_DIA_Gy_CCR(req_type := req_type)) -> value rx_dia { |
| 490 | var template (value) PDU_DIAMETER tx_dia; |
| 491 | var template (omit) AVP avp; |
| 492 | var octetstring sess_id; |
| 493 | var AVP_Unsigned32 req_num; |
| 494 | |
| 495 | avp := f_DIAMETER_get_avp(rx_dia, c_AVP_Code_BASE_NONE_Session_Id); |
| 496 | sess_id := valueof(avp.avp_data.avp_BASE_NONE_Session_Id); |
| 497 | |
| 498 | avp := f_DIAMETER_get_avp(rx_dia, c_AVP_Code_DCC_NONE_CC_Request_Number); |
| 499 | req_num := valueof(avp.avp_data.avp_DCC_NONE_CC_Request_Number); |
| 500 | if (g_gy_validity_time > 0) { |
| 501 | tx_dia := ts_DIA_Gy_CCA_ValidityTime(rx_dia.hop_by_hop_id, rx_dia.end_to_end_id, sess_id, |
| 502 | req_type, req_num, g_gy_validity_time); |
| 503 | } else { |
| 504 | tx_dia := ts_DIA_Gy_CCA(rx_dia.hop_by_hop_id, rx_dia.end_to_end_id, sess_id, |
| 505 | req_type, req_num); |
| 506 | } |
| 507 | Gy_UNIT.send(tx_dia); |
| 508 | } |
| 509 | [] Gy_UNIT.receive(PDU_DIAMETER:?) -> value rx_dia { |
| 510 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 511 | log2str("Received unexpected DIAMETER Gy", rx_dia)); |
| 512 | } |
| 513 | } |
| 514 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 515 | /* send a PDP context activation */ |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 516 | function f_pdp_ctx_act(inout PdpContext ctx, template OCT1 exp_cause := '80'O) runs on GT_CT return CreatePDPContextResponse { |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 517 | var Gtp1cUnitdata ud; |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 518 | var CreatePDPContextResponse cpr; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 519 | var default d; |
| 520 | |
| 521 | log("sending CreatePDP"); |
Harald Welte | 41575e9 | 2017-08-13 13:49:57 +0200 | [diff] [blame] | 522 | f_send_gtpc(ts_GTPC_CreatePDP(g_peer_c, g_c_seq_nr, ctx.imsi, g_restart_ctr, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 523 | ctx.teid, ctx.teic, ctx.nsapi, ctx.eua, ctx.apn, |
Pau Espin Pedrol | 0e12787 | 2022-05-12 17:58:50 +0200 | [diff] [blame] | 524 | g_sgsn_ip_c, g_sgsn_ip_u, ctx.msisdn, ctx.pco_req, ctx.ratType, |
Pau Espin Pedrol | 535ca26 | 2022-05-16 14:07:17 +0200 | [diff] [blame^] | 525 | ctx.uli, ctx.charging_char, ctx.imeisv, ctx.ms_tz)); |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 526 | T_default.start; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 527 | d := activate(pingpong()); |
Pau Espin Pedrol | 45d5702 | 2022-03-08 13:49:02 +0100 | [diff] [blame] | 528 | if (Gx_PROC.checkstate("Connected")) { |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 529 | as_DIA_Gx_CCR(INITIAL_REQUEST); |
| 530 | } |
| 531 | if (Gy_PROC.checkstate("Connected")) { |
| 532 | as_DIA_Gy_CCR(INITIAL_REQUEST); |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 533 | } |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 534 | alt { |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 535 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, createPDPContextResponse, ctx.teic)) -> value ud { |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 536 | f_handle_create_req(ctx, ud, exp_cause); |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 537 | cpr := ud.gtpc.gtpc_pdu.createPDPContextResponse; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 538 | } |
| 539 | } |
| 540 | deactivate(d); |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 541 | T_default.stop; |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 542 | return cpr; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 543 | } |
| 544 | |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 545 | function f_pdp_ctx_exp_del_req(PdpContext ctx, template (omit) OCT1 expect_cause := omit, boolean expect_teardown := false) runs on GT_CT { |
| 546 | var Gtp1cUnitdata ud; |
| 547 | var default d; |
| 548 | |
| 549 | T_default.start; |
| 550 | d := activate(pingpong()); |
| 551 | alt { |
| 552 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextRequest, ctx.teic)) -> value ud { |
| 553 | if (istemplatekind(expect_cause, "omit") and not ispresent(ud.gtpc.gtpc_pdu.deletePDPContextRequest.cause.causevalue)) { |
| 554 | setverdict(pass); |
| 555 | } else if (not istemplatekind(expect_cause, "omit") and |
| 556 | ispresent(ud.gtpc.gtpc_pdu.deletePDPContextRequest.cause.causevalue) and |
| 557 | ud.gtpc.gtpc_pdu.deletePDPContextRequest.cause.causevalue == valueof(expect_cause)) { |
| 558 | setverdict(pass); |
| 559 | } else { |
Pau Espin Pedrol | 8ad031a | 2022-02-16 17:33:43 +0100 | [diff] [blame] | 560 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 561 | "DeletePDPContextReq: cause expectancies didn't match"); |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | if (expect_teardown == ispresent(ud.gtpc.gtpc_pdu.deletePDPContextRequest.tearDownIndicator)) { |
| 565 | setverdict(pass); |
| 566 | } else { |
| 567 | setverdict(fail); |
Pau Espin Pedrol | 8ad031a | 2022-02-16 17:33:43 +0100 | [diff] [blame] | 568 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 569 | "DeletePDPContextReq: tearDownIndicator expectancies didn't match"); |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 570 | } |
| 571 | } |
| 572 | } |
| 573 | deactivate(d); |
| 574 | T_default.stop; |
| 575 | } |
| 576 | |
Pau Espin Pedrol | 10ec96e | 2022-02-09 17:03:15 +0100 | [diff] [blame] | 577 | function f_pdp_ctx_del(PdpContext ctx, template BIT1 teardown_ind, OCT1 expect_causevalue := '80'O, boolean expect_diameter := true) runs on GT_CT { |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 578 | var Gtp1cUnitdata ud; |
| 579 | var default d; |
Pau Espin Pedrol | 9a5f42f | 2019-05-27 20:04:35 +0200 | [diff] [blame] | 580 | var OCT4 expect_teid; |
| 581 | |
| 582 | /* 3GPP TS 29.060 sec 7.3.6 specifies TEID used in response |
| 583 | message with cause value "Non existent" shall be zero. */ |
| 584 | if (expect_causevalue == 'C0'O) { |
| 585 | expect_teid := '00000000'O; |
| 586 | } else { |
| 587 | expect_teid := ctx.teic; |
| 588 | } |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 589 | |
Harald Welte | 41575e9 | 2017-08-13 13:49:57 +0200 | [diff] [blame] | 590 | f_send_gtpc(ts_GTPC_DeletePDP(g_peer_c, g_c_seq_nr, ctx.teic_remote, ctx.nsapi, teardown_ind)); |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 591 | T_default.start; |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 592 | d := activate(pingpong()); |
Pau Espin Pedrol | 45d5702 | 2022-03-08 13:49:02 +0100 | [diff] [blame] | 593 | if (Gx_PROC.checkstate("Connected") and expect_diameter) { |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 594 | as_DIA_Gx_CCR(TERMINATION_REQUEST); |
| 595 | } |
| 596 | if (Gy_PROC.checkstate("Connected") and expect_diameter) { |
| 597 | as_DIA_Gy_CCR(TERMINATION_REQUEST); |
Pau Espin Pedrol | 0bcfd9d | 2022-02-02 11:01:35 +0100 | [diff] [blame] | 598 | } |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 599 | alt { |
Pau Espin Pedrol | 9a5f42f | 2019-05-27 20:04:35 +0200 | [diff] [blame] | 600 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextResponse, expect_teid)) -> value ud { |
| 601 | if (ud.gtpc.gtpc_pdu.deletePDPContextResponse.cause.causevalue == expect_causevalue) { |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 602 | setverdict(pass); |
| 603 | } else { |
Pau Espin Pedrol | 8ad031a | 2022-02-16 17:33:43 +0100 | [diff] [blame] | 604 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 605 | "DeletePDPContextResp: cause expectancies didn't match"); |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 606 | } |
| 607 | } |
| 608 | } |
| 609 | deactivate(d); |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 610 | T_default.stop; |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 611 | } |
Pau Espin Pedrol | cd326c5 | 2022-02-14 18:57:43 +0100 | [diff] [blame] | 612 | |
| 613 | /* send a Update PdP Context Request, expect Response */ |
| 614 | function f_pdp_ctx_update(inout PdpContext ctx, OCT1 exp_cause := '80'O, template (omit) OCT4 new_teid := omit, template (omit) OCT4 new_teic := omit) runs on GT_CT { |
| 615 | var Gtp1cUnitdata ud; |
| 616 | var default d; |
| 617 | |
| 618 | if (not istemplatekind(new_teid, "omit")) { |
| 619 | ctx.teid := valueof(new_teid); |
| 620 | } |
| 621 | if (not istemplatekind(new_teic, "omit")) { |
| 622 | ctx.teic := valueof(new_teic); |
| 623 | } |
| 624 | |
| 625 | log("sending UpdatePDP"); |
| 626 | f_send_gtpc(ts_GTPC_UpdatePDP(g_peer_c, ctx.teic_remote, g_c_seq_nr, ctx.imsi, g_restart_ctr, |
| 627 | ctx.teid, ctx.teic, ctx.nsapi, g_sgsn_ip_c, g_sgsn_ip_u, |
| 628 | ctx.pco_req, ctx.ratType, ctx.uli)); |
| 629 | T_default.start; |
| 630 | d := activate(pingpong()); |
| 631 | alt { |
| 632 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, updatePDPContextResponse, ctx.teic)) -> value ud { |
| 633 | f_handle_update_req(ctx, ud, exp_cause); |
| 634 | } |
| 635 | } |
| 636 | deactivate(d); |
| 637 | T_default.stop; |
| 638 | } |
| 639 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 640 | /* IPv6 router solicitation fe80::2 -> ff02::2 from 02:88:b5:1f:25:59 */ |
| 641 | const octetstring c_router_solicit := '6000000000103afffe800000000000000000000000000002ff02000000000000000000000000000285009f2b0000000001010288b51f2559'O; |
| 642 | /* IPv6 neighbor solicitation fe80::2 -> ff02::1:ff00:2 from 02:88:b5:1f:25:59 */ |
| 643 | const octetstring c_neigh_solicit:= '6000000000203afffe800000000000000000000000000002ff0200000000000000000001ff00000287009f9600000000fe80000000000000000000000000000201010288b51f2559'O; |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 644 | |
Stefan Sperling | 6cd217e | 2018-03-30 15:17:34 +0200 | [diff] [blame] | 645 | /* template for sending an ICMPv4 echo request */ |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 646 | template PDU_ICMP ts_ICMPv4_ERQ := { |
| 647 | echo := { |
| 648 | type_field := 8, |
| 649 | code := 0, |
| 650 | checksum := '0000'O, |
| 651 | identifier := '0345'O, |
| 652 | sequence_number := '0001'O, |
| 653 | data := ''O |
| 654 | } |
| 655 | } |
| 656 | |
Stefan Sperling | 6cd217e | 2018-03-30 15:17:34 +0200 | [diff] [blame] | 657 | /* template for receiving/matching an ICMPv4 echo request */ |
Pau Espin Pedrol | 6c7285d | 2018-01-30 17:20:22 +0100 | [diff] [blame] | 658 | template PDU_ICMP tr_ICMPv4_ERQ := { |
| 659 | echo := { |
| 660 | type_field := 8, |
| 661 | code := 0, |
| 662 | checksum := ?, |
| 663 | identifier := ?, |
| 664 | sequence_number := ?, |
| 665 | data := ? |
| 666 | } |
| 667 | } |
| 668 | |
Stefan Sperling | 6cd217e | 2018-03-30 15:17:34 +0200 | [diff] [blame] | 669 | /* template for receiving/matching an ICMPv4 echo reply */ |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 670 | template PDU_ICMP tr_ICMPv4_ERP(template octetstring data := *) := { |
| 671 | echo_reply := { |
| 672 | type_field := 0, |
| 673 | code := 0, |
| 674 | checksum := ?, |
| 675 | identifier := ?, |
| 676 | sequence_number := ?, |
| 677 | data := data |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | /* template for receiving/matching an ICMPv6 Destination Unreachable */ |
| 682 | template PDU_ICMP tr_ICMPv4_DU := { |
| 683 | destination_unreachable := { |
| 684 | type_field := 1, |
| 685 | code := ?, |
| 686 | checksum := ?, |
| 687 | unused := ?, |
| 688 | original_ip_msg := ? |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | /* template to construct IPv4_packet from input arguments, ready for use in f_IPv4_enc() */ |
| 693 | template IPv4_packet ts_IP4(OCT4 srcaddr, OCT4 dstaddr, LIN1 proto, LIN2_BO_LAST tlen, octetstring payload) := { |
| 694 | header := { |
| 695 | ver := 4, |
| 696 | hlen := 5, |
| 697 | tos := 0, |
| 698 | tlen := tlen, |
| 699 | id := 35902, |
| 700 | res := '0'B, |
| 701 | dfrag := '1'B, |
| 702 | mfrag := '0'B, |
| 703 | foffset := 0, |
| 704 | ttl := 64, |
| 705 | proto := proto, |
| 706 | cksum := 0, |
| 707 | srcaddr := srcaddr, |
| 708 | dstaddr := dstaddr |
| 709 | }, |
| 710 | ext_headers := omit, |
| 711 | payload := payload |
| 712 | } |
| 713 | |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 714 | /* template to generate a 'Prefix Information' ICMPv6 option */ |
| 715 | template OptionField ts_ICMP6_OptPrefix(OCT16 prefix, INT1 prefix_len) := { |
| 716 | prefixInformation := { |
| 717 | typeField := 3, |
| 718 | lengthIndicator := 8, |
| 719 | prefixLength := prefix_len, |
| 720 | reserved1 := '000000'B, |
| 721 | a_Bit := '0'B, |
| 722 | l_Bit := '0'B, |
| 723 | validLifetime := oct2int('FFFFFFFF'O), |
| 724 | preferredLifetime := oct2int('FFFFFFFF'O), |
| 725 | reserved2 := '00000000'O, |
| 726 | prefix := prefix |
| 727 | } |
| 728 | } |
| 729 | |
Stefan Sperling | 6cd217e | 2018-03-30 15:17:34 +0200 | [diff] [blame] | 730 | /* template for sending an ICMPv6 echo request */ |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 731 | template PDU_ICMPv6 ts_ICMPv6_ERQ := { |
| 732 | echoRequest := { |
| 733 | typeField := 128, |
| 734 | code := 0, |
| 735 | checksum := '0000'O, |
| 736 | identifier := 0, |
| 737 | sequenceNr := 0, |
| 738 | data := ''O |
| 739 | } |
| 740 | } |
| 741 | |
Stefan Sperling | 6cd217e | 2018-03-30 15:17:34 +0200 | [diff] [blame] | 742 | /* template for sending an ICMPv6 router solicitation */ |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 743 | template PDU_ICMPv6 ts_ICMPv6_RS := { |
| 744 | routerSolicitation := { |
| 745 | typeField := 133, |
| 746 | code := 0, |
| 747 | checksum := '0000'O, |
| 748 | reserved := '00000000'O, |
| 749 | /* TODO: do we need 'Source link-layer address' ? */ |
| 750 | options := omit |
| 751 | } |
| 752 | } |
| 753 | |
Stefan Sperling | 6cd217e | 2018-03-30 15:17:34 +0200 | [diff] [blame] | 754 | /* template for sending an ICMPv6 router advertisement */ |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 755 | template PDU_ICMPv6 ts_ICMPv6_RA(OCT16 prefix, INT1 prefix_len) := { |
| 756 | routerAdvertisement := { |
| 757 | typeField := 134, |
| 758 | code := 0, |
| 759 | checksum := '0000'O, |
| 760 | curHopLimit := ?, |
| 761 | reserved := '000000'B, |
| 762 | o_Bit := '0'B, |
| 763 | m_Bit := '0'B, |
| 764 | routerLifetime := oct2int('FFFF'O), |
| 765 | reachableTime := oct2int('FFFFFFFF'O), |
| 766 | retransTimer := oct2int('FFFFFFFF'O), |
| 767 | options := { |
| 768 | ts_ICMP6_OptPrefix(prefix, prefix_len) |
| 769 | } |
| 770 | } |
| 771 | } |
| 772 | |
Stefan Sperling | 6cd217e | 2018-03-30 15:17:34 +0200 | [diff] [blame] | 773 | /* template for sending an ICMPv6 neighbor solicitation */ |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 774 | template PDU_ICMPv6 ts_ICMPv6_NS(OCT16 target_addr) := { |
| 775 | neighborSolicitation := { |
| 776 | typeField := 135, |
| 777 | code := 0, |
| 778 | checksum := '0000'O, |
| 779 | reserved := '00000000'O, |
| 780 | targetAddress := target_addr, |
| 781 | /* TODO: do we need 'Source link-layer address' ? */ |
| 782 | options := omit |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | /* derive ICMPv6 link-local address from lower 64bit of link_id */ |
| 787 | /* template for receiving/matching an ICMPv6 'Prefix Information' option */ |
| 788 | template OptionField tr_ICMP6_OptPrefix(template OCT16 prefix, template INT1 prefix_len) := { |
| 789 | prefixInformation := { |
| 790 | typeField := 3, |
| 791 | lengthIndicator := 4, |
| 792 | prefixLength := prefix_len, |
| 793 | reserved1 := ?, |
| 794 | a_Bit := ?, |
| 795 | l_Bit := ?, |
| 796 | validLifetime := ?, |
| 797 | preferredLifetime := ?, |
| 798 | reserved2 := ?, |
| 799 | prefix := prefix |
| 800 | } |
| 801 | } |
| 802 | |
| 803 | /* template for receiving/matching an ICMPv6 router advertisement */ |
| 804 | template PDU_ICMPv6 tr_ICMPv6_RA(template OCT16 prefix, template INT1 prefix_len) := { |
| 805 | routerAdvertisement := { |
| 806 | typeField := 134, |
| 807 | code := 0, |
| 808 | checksum := ?, |
| 809 | curHopLimit := ?, |
| 810 | reserved := ?, |
| 811 | o_Bit := '0'B, |
| 812 | m_Bit := '0'B, |
| 813 | routerLifetime := ?, |
| 814 | reachableTime := ?, |
| 815 | retransTimer := ?, |
| 816 | options := { |
| 817 | tr_ICMP6_OptPrefix(prefix, prefix_len) |
| 818 | } |
| 819 | } |
| 820 | } |
| 821 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 822 | /* template for receiving/matching an ICMPv6 Destination Unreachable */ |
| 823 | template PDU_ICMPv6 tr_ICMPv6_DU := { |
| 824 | destinationUnreachable := { |
| 825 | typeField := 1, |
| 826 | code := ?, |
| 827 | checksum := ?, |
| 828 | unused := ?, |
| 829 | originalIpMsg := ? |
| 830 | } |
| 831 | } |
| 832 | |
Stefan Sperling | 6cd217e | 2018-03-30 15:17:34 +0200 | [diff] [blame] | 833 | /* template for receiving/matching an ICMPv6 echo request */ |
Pau Espin Pedrol | 6c7285d | 2018-01-30 17:20:22 +0100 | [diff] [blame] | 834 | template PDU_ICMPv6 tr_ICMPv6_ERQ := { |
| 835 | echoRequest := { |
| 836 | typeField := 128, |
| 837 | code := 0, |
| 838 | checksum := ?, |
| 839 | identifier := ?, |
| 840 | sequenceNr := ?, |
| 841 | data := ? |
| 842 | } |
| 843 | } |
| 844 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 845 | /* template for receiving/matching an ICMPv6 echo reply */ |
| 846 | template PDU_ICMPv6 tr_ICMPv6_ERP(template octetstring data := *) := { |
| 847 | echoReply := { |
| 848 | typeField := 129, |
| 849 | code := 0, |
| 850 | checksum := ?, |
| 851 | identifier := ?, |
| 852 | sequenceNr := ?, |
| 853 | data := data |
| 854 | } |
| 855 | } |
| 856 | |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 857 | /* template to construct IPv6_packet from input arguments, ready for use in f_IPv6_enc() */ |
| 858 | template IPv6_packet ts_IP6(OCT16 srcaddr, OCT16 dstaddr, LIN1 nexthead, octetstring payload, LIN1 hlim := 255) := { |
| 859 | header := { |
| 860 | ver := 6, |
| 861 | trclass := 0, |
| 862 | flabel := 0, |
| 863 | plen := 0, |
| 864 | nexthead := nexthead, |
| 865 | hlim := hlim, |
| 866 | srcaddr := srcaddr, |
| 867 | dstaddr := dstaddr |
| 868 | }, |
| 869 | ext_headers := omit, |
| 870 | payload := payload |
| 871 | } |
| 872 | |
| 873 | function f_ipv6_link_local(in OCT16 link_id) return OCT16 { |
| 874 | return 'FE80000000000000'O & substr(link_id, 8, 8); |
| 875 | } |
| 876 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 877 | function f_ipv6_global(in OCT16 link_id) return OCT16 { |
| 878 | return substr(link_id, 0, 8) & '1234123412341234'O; |
| 879 | } |
| 880 | |
| 881 | /* Create a new different IPv6 addr from input. Starts mangling at byte prefix. */ |
| 882 | function f_ipv6_mangle(in OCT16 addr, in integer prefix := 0) return OCT16 { |
| 883 | var integer i; |
| 884 | var octetstring res := substr(addr, 0, prefix); |
| 885 | for (i := prefix; i < lengthof(addr); i := i + 1) { |
| 886 | var octetstring a := addr[i] xor4b '11'O; |
| 887 | res := res & a; |
| 888 | } |
| 889 | return res; |
| 890 | } |
| 891 | |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 892 | /* Compute solicited-node multicast address as per RFC4291 2.7.1 */ |
| 893 | function f_ipv6_sol_node_mcast(in OCT16 addr) return OCT16 { |
| 894 | return 'FF0200000000000000000001FF'O & substr(addr, 13, 3); |
| 895 | } |
| 896 | |
| 897 | /* generate and encode ICMPv6 router solicitation */ |
| 898 | function f_gen_icmpv6_router_solicitation(in OCT16 link_id) return octetstring { |
| 899 | const OCT16 c_ip6_all_router_mcast := 'FF020000000000000000000000000002'O; |
| 900 | var OCT16 saddr := f_ipv6_link_local(link_id); |
| 901 | |
| 902 | var octetstring tmp; |
| 903 | tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_RS), saddr, c_ip6_all_router_mcast); |
| 904 | var IPv6_packet ip6 := valueof(ts_IP6(saddr, c_ip6_all_router_mcast, 58, tmp)); |
| 905 | |
| 906 | return f_IPv6_enc(ip6); |
| 907 | } |
| 908 | |
Pau Espin Pedrol | 5760421 | 2022-02-14 16:54:18 +0100 | [diff] [blame] | 909 | /* Get link-id from PDP Context EUA */ |
| 910 | function f_ctx_get_ipv6_interface_id(in PdpContext ctx) return OCT16 { |
| 911 | var OCT16 interface_id; |
| 912 | if (ischosen(ctx.eua.endUserAddress.endUserAddressIPv4andIPv6)) { |
| 913 | interface_id := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address; |
| 914 | } else if (ischosen(ctx.eua.endUserAddress.endUserAddressIPv6)) { |
| 915 | interface_id := ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address; |
| 916 | } else { |
| 917 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected request to submit icmpv6 rs in IPv4 PDP context"); |
| 918 | } |
| 919 | return interface_id; |
| 920 | } |
| 921 | |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 922 | /* create ICMPv6 router solicitation deriving link-id from PDP Context EUA */ |
| 923 | function f_icmpv6_rs_for_pdp(in PdpContext ctx) return octetstring { |
Pau Espin Pedrol | 5760421 | 2022-02-14 16:54:18 +0100 | [diff] [blame] | 924 | var OCT16 interface_id := f_ctx_get_ipv6_interface_id(ctx); |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 925 | return f_gen_icmpv6_router_solicitation(interface_id); |
| 926 | } |
| 927 | |
| 928 | /* generate and encode ICMPv6 neighbor solicitation */ |
| 929 | function f_gen_icmpv6_neigh_solicit(in OCT16 saddr, in OCT16 daddr, in OCT16 tgt_addr) return octetstring { |
| 930 | var octetstring tmp; |
| 931 | tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_NS(tgt_addr)), saddr, daddr); |
| 932 | var IPv6_packet ip6 := valueof(ts_IP6(saddr, daddr, 58, tmp)); |
| 933 | return f_IPv6_enc(ip6); |
| 934 | } |
| 935 | |
| 936 | /* generate and encode ICMPv6 neighbor solicitation for PDP Context */ |
| 937 | function f_gen_icmpv6_neigh_solicit_for_pdp(in PdpContext ctx) return octetstring { |
Pau Espin Pedrol | 5760421 | 2022-02-14 16:54:18 +0100 | [diff] [blame] | 938 | var OCT16 interface_id := f_ctx_get_ipv6_interface_id(ctx); |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 939 | var OCT16 link_local := f_ipv6_link_local(interface_id); |
| 940 | var OCT16 daddr := f_ipv6_sol_node_mcast(link_local); |
| 941 | |
| 942 | return f_gen_icmpv6_neigh_solicit(link_local, daddr, link_local); |
| 943 | } |
| 944 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 945 | /* Send an ICMPv4 echo msg through GTP given pdp ctx, and ip src and dst addr */ |
| 946 | function f_gen_icmpv4_echo(OCT4 saddr, OCT4 daddr) return octetstring { |
| 947 | var octetstring tmp := f_enc_PDU_ICMP(valueof(ts_ICMPv4_ERQ)); |
| 948 | var IPv4_packet ip4 := valueof(ts_IP4(saddr, daddr, 1, 50, tmp)); |
| 949 | var octetstring data := f_IPv4_enc(ip4); |
| 950 | var OCT2 cksum := f_IPv4_checksum(data); |
| 951 | data[10] := cksum[0]; |
| 952 | data[11] := cksum[1]; |
| 953 | return data; |
| 954 | } |
| 955 | |
| 956 | /* Send an ICMPv6 echo msg through GTP given pdp ctx, and ip src and dst addr */ |
| 957 | function f_gen_icmpv6_echo(OCT16 saddr, OCT16 daddr) return octetstring { |
| 958 | var octetstring tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_ERQ), saddr, daddr); |
| 959 | var IPv6_packet ip6 := valueof(ts_IP6(saddr, daddr, 58, tmp)); |
| 960 | var octetstring data := f_IPv6_enc(ip6); |
| 961 | return data; |
| 962 | } |
| 963 | |
| 964 | /* Wait for ICMPv4 from GTP */ |
| 965 | function f_wait_icmp4(PdpContext ctx, template PDU_ICMP expected) runs on GT_CT { |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 966 | var Gtp1uUnitdata ud; |
| 967 | T_default.start; |
| 968 | alt { |
Pau Espin Pedrol | cd326c5 | 2022-02-14 18:57:43 +0100 | [diff] [blame] | 969 | [] GTPU.receive(tr_GTPU_GPDU(g_peer_u, ctx.teid)) -> value ud { |
Harald Welte | 3e0b039 | 2018-04-26 09:46:21 +0200 | [diff] [blame] | 970 | if (f_verify_gtpu_txseq(ud.gtpu, use_gtpu_txseq) == false) { |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 971 | setverdict(fail); |
| 972 | stop; |
| 973 | } |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 974 | var octetstring gpdu := ud.gtpu.gtpu_IEs.g_PDU_IEs.data; |
| 975 | var IPv4_packet ip4 := f_IPv4_dec(gpdu); |
| 976 | if (ip4.header.ver != 4) { |
| 977 | repeat; |
| 978 | } |
| 979 | var PDU_ICMP icmp4 := f_dec_PDU_ICMP(ip4.payload); |
| 980 | if (not match(icmp4, expected)) { |
| 981 | repeat; |
| 982 | } |
| 983 | } |
Pau Espin Pedrol | cd326c5 | 2022-02-14 18:57:43 +0100 | [diff] [blame] | 984 | [] GTPU.receive(tr_GTPU_GPDU(g_peer_u, ?)) -> value ud { |
| 985 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 986 | "Received wrong local TEID"); |
| 987 | } |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 988 | [] GTPU.receive { setverdict(fail); } |
| 989 | [] T_default.timeout { setverdict(fail); } |
| 990 | } |
| 991 | T_default.stop; |
| 992 | } |
| 993 | |
Pau Espin Pedrol | 6c7285d | 2018-01-30 17:20:22 +0100 | [diff] [blame] | 994 | /* Wait for ICMPv4 echo request from GTP */ |
| 995 | function f_wait_icmp4_echo_request(PdpContext ctx) runs on GT_CT { |
| 996 | f_wait_icmp4(ctx, tr_ICMPv4_ERQ); |
| 997 | } |
| 998 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 999 | /* Wait for ICMPv4 echo reply (or unreachable) from GTP */ |
| 1000 | function f_wait_icmp4_echo_reply(PdpContext ctx) runs on GT_CT { |
| 1001 | f_wait_icmp4(ctx, (tr_ICMPv4_ERP, tr_ICMPv4_DU)); |
| 1002 | } |
| 1003 | |
| 1004 | /* Wait for ICMPv6 from GTP */ |
| 1005 | function f_wait_icmp6(PdpContext ctx, template PDU_ICMPv6 expected) runs on GT_CT { |
| 1006 | var Gtp1uUnitdata ud; |
| 1007 | T_default.start; |
| 1008 | alt { |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 1009 | [] GTPU.receive(tr_GTPU_GPDU(g_peer_u, ?)) -> value ud { |
Harald Welte | 3e0b039 | 2018-04-26 09:46:21 +0200 | [diff] [blame] | 1010 | if (f_verify_gtpu_txseq(ud.gtpu, use_gtpu_txseq) == false) { |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 1011 | setverdict(fail); |
| 1012 | stop; |
| 1013 | } |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 1014 | var octetstring gpdu := ud.gtpu.gtpu_IEs.g_PDU_IEs.data; |
| 1015 | var IPv6_packet ip6 := f_IPv6_dec(gpdu); |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1016 | if (ip6.header.ver != 6 or ip6.header.nexthead != 58) { |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 1017 | repeat; |
| 1018 | } |
| 1019 | var PDU_ICMPv6 icmp6 := f_dec_PDU_ICMPv6(ip6.payload); |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1020 | if (not match(icmp6, expected)) { |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 1021 | repeat; |
| 1022 | } |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1023 | /* We are waiting for RA, update ctx */ |
| 1024 | if (match(icmp6, tr_ICMPv6_RA(?, 64))) { |
| 1025 | ctx.ip6_prefix := icmp6.routerAdvertisement.options[0].prefixInformation.prefix; |
| 1026 | log("RA with /64 prefix ", ctx.ip6_prefix); |
| 1027 | } |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 1028 | } |
| 1029 | [] GTPU.receive(tr_GTPU_GPDU(?, ?)) { repeat; } |
| 1030 | [] GTPU.receive { setverdict(fail); } |
| 1031 | [] T_default.timeout { setverdict(fail); } |
| 1032 | } |
| 1033 | T_default.stop; |
| 1034 | } |
| 1035 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1036 | /* wait for GGSN to send us an ICMPv6 router advertisement */ |
| 1037 | function f_wait_rtr_adv(PdpContext ctx) runs on GT_CT { |
| 1038 | f_wait_icmp6(ctx, tr_ICMPv6_RA(?, 64)); |
| 1039 | } |
| 1040 | |
Pau Espin Pedrol | 6c7285d | 2018-01-30 17:20:22 +0100 | [diff] [blame] | 1041 | /* Wait for ICMPv6 echo request from GTP */ |
| 1042 | function f_wait_icmp6_echo_request(PdpContext ctx) runs on GT_CT { |
| 1043 | f_wait_icmp6(ctx, tr_ICMPv6_ERQ); |
| 1044 | } |
| 1045 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1046 | /* Wait for ICMPv6 echo reply (or unreachable) from GTP */ |
| 1047 | function f_wait_icmp6_echo_reply(PdpContext ctx) runs on GT_CT { |
| 1048 | f_wait_icmp6(ctx, (tr_ICMPv6_ERP,tr_ICMPv6_DU)); |
| 1049 | } |
| 1050 | |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1051 | /* create ICMPv6 router solicitation deriving link-id from PDP Context EUA */ |
| 1052 | function f_icmpv6_rs_for_pdp46(in PdpContext ctx) return octetstring { |
| 1053 | var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address; |
| 1054 | return f_gen_icmpv6_router_solicitation(interface_id); |
| 1055 | } |
| 1056 | |
| 1057 | /* generate and encode ICMPv6 neighbor solicitation for PDP Context */ |
| 1058 | function f_gen_icmpv6_neigh_solicit_for_pdp46(in PdpContext ctx) return octetstring { |
| 1059 | var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address; |
| 1060 | var OCT16 link_local := f_ipv6_link_local(interface_id); |
| 1061 | var OCT16 daddr := f_ipv6_sol_node_mcast(link_local); |
| 1062 | |
| 1063 | return f_gen_icmpv6_neigh_solicit(link_local, daddr, link_local); |
| 1064 | } |
| 1065 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1066 | /* Assert we don't receive a ICMPv4/6 echo reply (or unreachable) from GTP */ |
| 1067 | function f_wait_gtpu_fail(PdpContext ctx) runs on GT_CT { |
| 1068 | T_default.start; |
| 1069 | alt { |
| 1070 | [] GTPU.receive { setverdict(fail); } |
| 1071 | [] T_default.timeout { } |
| 1072 | } |
| 1073 | T_default.stop; |
| 1074 | } |
| 1075 | |
Harald Welte | 79737b4 | 2019-04-10 10:39:30 +0200 | [diff] [blame] | 1076 | /* list of protocols where we don't accept duplicates */ |
| 1077 | const OCT2List protocol_ids_nodupes := { 'C021'O, 'C023'O, 'C223'O, '8021'O }; |
| 1078 | private function f_PCO_permits_duplicates(OCT2 id) return boolean { |
| 1079 | var integer i; |
| 1080 | for (i := 0; i < lengthof(protocol_ids_nodupes); i := i+1) { |
| 1081 | if (id == protocol_ids_nodupes[i]) { |
| 1082 | return false; |
| 1083 | } |
| 1084 | } |
| 1085 | return true; |
| 1086 | } |
| 1087 | |
| 1088 | /* ensure that every given protocol Identifier exist only exactly once in the PCO */ |
| 1089 | function f_PCO_ensure_no_duplicates(ProtConfigOptions pco) { |
| 1090 | var OCT2List protocol_ids := {}; |
| 1091 | var integer i, j; |
| 1092 | for (i := 0; i < lengthof(pco.protocols); i := i+1) { |
| 1093 | var OCT2 id := pco.protocols[i].protocolID; |
| 1094 | for (j := 0; j < lengthof(protocol_ids); j := j+1) { |
| 1095 | if (not f_PCO_permits_duplicates(id) and id == protocol_ids[j]) { |
| 1096 | setverdict(fail, "Duplicate ProtocolID ", id, " already present in ", pco.protocols); |
| 1097 | } |
| 1098 | } |
| 1099 | protocol_ids := protocol_ids & { id }; |
| 1100 | } |
| 1101 | } |
| 1102 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 1103 | /* Test IPv6 context activation for dynamic IPv6 EUA without request of IPv6 DNS */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1104 | testcase TC_pdp6_act_deact() runs on GT_CT { |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 1105 | f_init(); |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 1106 | |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 1107 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 1108 | f_pdp_ctx_act(ctx); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1109 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1110 | f_shutdown_helper(); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1111 | } |
| 1112 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 1113 | /* Test IPv6 context activation for dynamic IPv6 EUA wirh request of IPv6 DNS in PCO */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1114 | testcase TC_pdp6_act_deact_pcodns() runs on GT_CT { |
| 1115 | f_init(); |
| 1116 | |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 1117 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1118 | ctx.pco_req := valueof(ts_PCO_IPv6_DNS); |
| 1119 | f_pdp_ctx_act(ctx); |
Pau Espin Pedrol | 363ba48 | 2018-01-29 18:42:00 +0100 | [diff] [blame] | 1120 | |
Harald Welte | 79737b4 | 2019-04-10 10:39:30 +0200 | [diff] [blame] | 1121 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
Pau Espin Pedrol | 363ba48 | 2018-01-29 18:42:00 +0100 | [diff] [blame] | 1122 | /* verify PCO contains both primary and secondary DNS */ |
| 1123 | var OCT4 ggsn_ip6_dns1 := f_inet6_addr(m_ggsn_ip6_dns1); |
| 1124 | if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 1), ggsn_ip6_dns1)) { |
| 1125 | setverdict(fail, "Primary DNS IPv6 PCO option not found"); |
| 1126 | } |
| 1127 | |
| 1128 | var OCT4 ggsn_ip6_dns2 := f_inet6_addr(m_ggsn_ip6_dns2); |
| 1129 | if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 2), ggsn_ip6_dns2)) { |
| 1130 | setverdict(fail, "Secondary DNS IPv6 PCO option not found"); |
| 1131 | } |
| 1132 | |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1133 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1134 | f_shutdown_helper(); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1135 | } |
| 1136 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 1137 | /* Test PDP context activation for dynamic IPv6 EUA with IPv6 DNS in PCO and router solicitation/advertisement */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1138 | testcase TC_pdp6_act_deact_icmp6() runs on GT_CT { |
| 1139 | f_init(); |
| 1140 | |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 1141 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1142 | ctx.pco_req := valueof(ts_PCO_IPv6_DNS); |
| 1143 | f_pdp_ctx_act(ctx); |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 1144 | |
Harald Welte | 79737b4 | 2019-04-10 10:39:30 +0200 | [diff] [blame] | 1145 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 1146 | //f_send_gtpu(ctx, c_router_solicit); |
| 1147 | //f_send_gtpu(ctx, c_neigh_solicit); |
| 1148 | |
| 1149 | f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx)); |
| 1150 | f_wait_rtr_adv(ctx); |
| 1151 | f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx)); |
| 1152 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 1153 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1154 | f_shutdown_helper(); |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 1155 | } |
| 1156 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1157 | /* Test PDP context activation for dynamic IPv6 EUA with IPv6 DNS in PCO and router solicitation/advertisement. |
| 1158 | Test we can send ICMPv6 ping over GTPU to DNS server. */ |
| 1159 | testcase TC_pdp6_act_deact_gtpu_access() runs on GT_CT { |
| 1160 | f_init(); |
| 1161 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
| 1162 | ctx.pco_req := valueof(ts_PCO_IPv6_DNS); |
| 1163 | f_pdp_ctx_act(ctx); |
| 1164 | |
| 1165 | f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx)); |
| 1166 | f_wait_rtr_adv(ctx); |
| 1167 | f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx)); |
| 1168 | |
| 1169 | var OCT16 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '0003'O); |
| 1170 | |
| 1171 | /* Check if we can use valid link-local src addr. */ |
| 1172 | var OCT16 saddr_ll := f_ipv6_link_local(ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address); |
| 1173 | f_send_gtpu(ctx, f_gen_icmpv6_echo(saddr_ll, dns1_addr)); |
Pau Espin Pedrol | b63d85f | 2022-02-07 16:11:47 +0100 | [diff] [blame] | 1174 | if (m_ggsn_impl == GGSN_IMPL_OSMOCOM) { |
| 1175 | f_wait_icmp6_echo_reply(ctx); |
| 1176 | } else { |
| 1177 | f_wait_gtpu_fail(ctx); |
| 1178 | } |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1179 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1180 | /* Check if we can use valid global src addr, should work */ |
| 1181 | var OCT16 saddr_glob := f_ipv6_global(ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address); |
| 1182 | f_send_gtpu(ctx, f_gen_icmpv6_echo(saddr_glob, dns1_addr)); |
| 1183 | f_wait_icmp6_echo_reply(ctx); |
| 1184 | |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1185 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1186 | f_shutdown_helper(); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1187 | } |
| 1188 | |
| 1189 | /* Check that attempting RA with another ll src addr won't work, packet dropped: */ |
| 1190 | testcase TC_pdp6_act_deact_gtpu_access_wrong_ll_saddr() runs on GT_CT { |
| 1191 | f_init(); |
| 1192 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
| 1193 | ctx.pco_req := valueof(ts_PCO_IPv6_DNS); |
| 1194 | f_pdp_ctx_act(ctx); |
| 1195 | |
| 1196 | f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx)); |
| 1197 | f_wait_rtr_adv(ctx); |
| 1198 | f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx)); |
| 1199 | |
| 1200 | var OCT16 saddr_ll := f_ipv6_link_local(ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address); |
| 1201 | var OCT16 saddr_ll_wrong := f_ipv6_mangle(saddr_ll, 8); |
| 1202 | f_send_gtpu(ctx, f_gen_icmpv6_router_solicitation(saddr_ll_wrong)); |
| 1203 | f_wait_gtpu_fail(ctx); |
| 1204 | |
| 1205 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1206 | f_shutdown_helper(); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1207 | } |
| 1208 | |
| 1209 | /* Assert that packets with wrong global src addr are dropped by GGSN */ |
| 1210 | testcase TC_pdp6_act_deact_gtpu_access_wrong_global_saddr() runs on GT_CT { |
| 1211 | f_init(); |
| 1212 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
| 1213 | ctx.pco_req := valueof(ts_PCO_IPv6_DNS); |
| 1214 | f_pdp_ctx_act(ctx); |
| 1215 | |
| 1216 | f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx)); |
| 1217 | f_wait_rtr_adv(ctx); |
| 1218 | f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx)); |
| 1219 | |
| 1220 | var OCT16 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '0003'O); |
| 1221 | var OCT16 saddr_glob := f_ipv6_global(ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address); |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1222 | var OCT16 saddr_wrong := f_ipv6_mangle(saddr_glob); |
| 1223 | f_send_gtpu(ctx, f_gen_icmpv6_echo(saddr_wrong, dns1_addr)); |
| 1224 | f_wait_gtpu_fail(ctx); |
| 1225 | |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1226 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1227 | f_shutdown_helper(); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1228 | } |
| 1229 | |
| 1230 | /* Send an IPv4 ICMP ECHO REQUEST to APN6, should fail (packet dropped */ |
| 1231 | testcase TC_pdp6_act_deact_gtpu_access_ipv4_apn6() runs on GT_CT { |
| 1232 | f_init(); |
| 1233 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
| 1234 | ctx.pco_req := valueof(ts_PCO_IPv6_DNS); |
| 1235 | f_pdp_ctx_act(ctx); |
| 1236 | |
| 1237 | f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx)); |
| 1238 | f_wait_rtr_adv(ctx); |
| 1239 | f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx)); |
| 1240 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1241 | var OCT4 saddr_v4 := f_inet_addr("192.168.10.2"); |
| 1242 | var OCT4 daddr_v4 := f_inet_addr("8.8.8.8"); |
| 1243 | f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr_v4, daddr_v4)); |
| 1244 | f_wait_gtpu_fail(ctx); |
| 1245 | |
| 1246 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1247 | f_shutdown_helper(); |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1248 | } |
| 1249 | |
Pau Espin Pedrol | 6c7285d | 2018-01-30 17:20:22 +0100 | [diff] [blame] | 1250 | /* Validate if different clients (pdp ctx) can reach one another through GGSN. */ |
| 1251 | testcase TC_pdp6_clients_interact() runs on GT_CT { |
| 1252 | f_init(); |
| 1253 | var PdpContext ctxA := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
| 1254 | var PdpContext ctxB := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
| 1255 | f_pdp_ctx_act(ctxA); |
| 1256 | f_send_gtpu(ctxA, f_icmpv6_rs_for_pdp(ctxA)); |
| 1257 | f_wait_rtr_adv(ctxA); |
| 1258 | f_send_gtpu(ctxA, f_gen_icmpv6_neigh_solicit_for_pdp(ctxA)); |
| 1259 | |
| 1260 | f_pdp_ctx_act(ctxB); |
| 1261 | f_send_gtpu(ctxB, f_icmpv6_rs_for_pdp(ctxB)); |
| 1262 | f_wait_rtr_adv(ctxB); |
| 1263 | f_send_gtpu(ctxB, f_gen_icmpv6_neigh_solicit_for_pdp(ctxB)); |
| 1264 | |
| 1265 | var OCT16 addrA_ll := f_ipv6_link_local(ctxA.eua.endUserAddress.endUserAddressIPv6.ipv6_address); |
| 1266 | var OCT16 addrB_ll := f_ipv6_link_local(ctxB.eua.endUserAddress.endUserAddressIPv6.ipv6_address); |
| 1267 | var OCT16 addrA_glob := f_ipv6_global(ctxA.eua.endUserAddress.endUserAddressIPv6.ipv6_address); |
| 1268 | var OCT16 addrB_glob := f_ipv6_global(ctxB.eua.endUserAddress.endUserAddressIPv6.ipv6_address); |
| 1269 | |
| 1270 | /* Validate if clients can interact using ll addr. */ |
| 1271 | f_send_gtpu(ctxA, f_gen_icmpv6_echo(addrA_ll, addrB_ll)); |
| 1272 | f_wait_gtpu_fail(ctxB); |
| 1273 | |
| 1274 | /* Validate if clients can interact using global addr. */ |
| 1275 | f_send_gtpu(ctxA, f_gen_icmpv6_echo(addrA_glob, addrB_glob)); |
| 1276 | f_wait_gtpu_fail(ctxB); |
| 1277 | |
| 1278 | f_pdp_ctx_del(ctxA, '1'B); |
Pau Espin Pedrol | bb2bb06 | 2019-09-03 12:28:12 +0200 | [diff] [blame] | 1279 | f_pdp_ctx_del(ctxB, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1280 | f_shutdown_helper(); |
Pau Espin Pedrol | 6c7285d | 2018-01-30 17:20:22 +0100 | [diff] [blame] | 1281 | } |
| 1282 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 1283 | /* Test PDP context activation for dynamic IPv4 EUA without DNS request */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1284 | testcase TC_pdp4_act_deact() runs on GT_CT { |
| 1285 | f_init(); |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 1286 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1287 | f_pdp_ctx_act(ctx); |
| 1288 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1289 | f_shutdown_helper(); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1290 | } |
| 1291 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 1292 | /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in IPCP */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1293 | testcase TC_pdp4_act_deact_ipcp() runs on GT_CT { |
| 1294 | f_init(); |
Pau Espin Pedrol | f69a438 | 2018-01-29 13:09:00 +0100 | [diff] [blame] | 1295 | var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1); |
| 1296 | var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2); |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 1297 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 1298 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_IPCP); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1299 | f_pdp_ctx_act(ctx); |
Harald Welte | 79737b4 | 2019-04-10 10:39:30 +0200 | [diff] [blame] | 1300 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
Harald Welte | 71a3602 | 2017-12-04 18:55:58 +0100 | [diff] [blame] | 1301 | /* verify IPCP is at all contained */ |
| 1302 | if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) { |
| 1303 | setverdict(fail, "IPCP not found in PCO"); |
| 1304 | } |
| 1305 | /* verify IPCP contains both primary and secondary DNS */ |
| 1306 | var IpcpPacket ipcp := dec_IpcpPacket(f_PCO_extract_proto(ctx.pco_neg, '8021'O)); |
Pau Espin Pedrol | f69a438 | 2018-01-29 13:09:00 +0100 | [diff] [blame] | 1307 | if (not match(ipcp, tr_IPCP_Ack_DNS(0, ggsn_ip4_dns1, ggsn_ip4_dns2))) { |
| 1308 | if (not match(ipcp, tr_IPCP_Ack_DNS(0))) { |
| 1309 | setverdict(fail, "Primary/Secondary DNS PCO IPCP option not found"); |
| 1310 | } else { |
| 1311 | setverdict(fail, "Primary/Secondary DNS PCO IPCP option found but not matching expected values"); |
| 1312 | } |
Harald Welte | 71a3602 | 2017-12-04 18:55:58 +0100 | [diff] [blame] | 1313 | } |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1314 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1315 | f_shutdown_helper(); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1316 | } |
| 1317 | |
Harald Welte | f829854 | 2019-04-10 10:15:28 +0200 | [diff] [blame] | 1318 | /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in IPCP + PAP authentication (broken) */ |
| 1319 | testcase TC_pdp4_act_deact_ipcp_pap_broken() runs on GT_CT { |
| 1320 | f_init(); |
| 1321 | var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1); |
| 1322 | var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2); |
| 1323 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1324 | ctx.pco_req := valueof(ts_PCO_PAP_IPv4_DNS); |
| 1325 | f_pdp_ctx_act(ctx); |
| 1326 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
| 1327 | /* verify IPCP is at all contained */ |
| 1328 | if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) { |
| 1329 | setverdict(fail, "IPCP not found in PCO"); |
| 1330 | } |
| 1331 | /* verify IPCP contains both primary and secondary DNS */ |
| 1332 | var IpcpPacket ipcp := dec_IpcpPacket(f_PCO_extract_proto(ctx.pco_neg, '8021'O)); |
| 1333 | if (not match(ipcp, tr_IPCP_Ack_DNS(0, ggsn_ip4_dns1, ggsn_ip4_dns2))) { |
| 1334 | if (not match(ipcp, tr_IPCP_Ack_DNS(0))) { |
| 1335 | setverdict(fail, "Primary/Secondary DNS PCO IPCP option not found"); |
| 1336 | } else { |
| 1337 | setverdict(fail, "Primary/Secondary DNS PCO IPCP option found but not matching expected values"); |
| 1338 | } |
| 1339 | } |
| 1340 | /* verify that PAP is contained */ |
| 1341 | if (not match(ctx.pco_neg, tr_PCO_Contains('C023'O))) { |
| 1342 | setverdict(fail, "PAP not found in PCO"); |
| 1343 | } |
| 1344 | var PapPacket pap := dec_PapPacket(f_PCO_extract_proto(ctx.pco_neg, 'C023'O)); |
| 1345 | if (not match(pap, tr_PAP_AuthAck)) { |
| 1346 | setverdict(fail, "PAP isn't an AuthenticateAck: ", pap); |
| 1347 | } |
| 1348 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1349 | f_shutdown_helper(); |
Harald Welte | f829854 | 2019-04-10 10:15:28 +0200 | [diff] [blame] | 1350 | } |
| 1351 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 1352 | /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in PCO */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1353 | testcase TC_pdp4_act_deact_pcodns() runs on GT_CT { |
| 1354 | f_init(); |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 1355 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 1356 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1357 | f_pdp_ctx_act(ctx); |
Pau Espin Pedrol | 363ba48 | 2018-01-29 18:42:00 +0100 | [diff] [blame] | 1358 | |
Harald Welte | 79737b4 | 2019-04-10 10:39:30 +0200 | [diff] [blame] | 1359 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
Pau Espin Pedrol | 363ba48 | 2018-01-29 18:42:00 +0100 | [diff] [blame] | 1360 | /* verify PCO contains both primary and secondary DNS */ |
| 1361 | var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1); |
| 1362 | if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 1), ggsn_ip4_dns1)) { |
| 1363 | setverdict(fail, "Primary DNS IPv4 PCO option not found"); |
| 1364 | } |
| 1365 | |
| 1366 | var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2); |
| 1367 | if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 2), ggsn_ip4_dns2)) { |
| 1368 | setverdict(fail, "Secondary DNS IPv4 PCO option not found"); |
| 1369 | } |
| 1370 | |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1371 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1372 | f_shutdown_helper(); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1373 | } |
| 1374 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1375 | /* Test PDP context activation for dynamic IPv4 EUA. |
| 1376 | Test we can send ICMPv6 ping over GTPU to DNS server. */ |
| 1377 | testcase TC_pdp4_act_deact_gtpu_access() runs on GT_CT { |
| 1378 | f_init(); |
| 1379 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1380 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
| 1381 | f_pdp_ctx_act(ctx); |
| 1382 | |
Harald Welte | 79737b4 | 2019-04-10 10:39:30 +0200 | [diff] [blame] | 1383 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1384 | var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O); |
| 1385 | |
| 1386 | /* Check if we can use valid global src addr, should work */ |
| 1387 | var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4.ipv4_address; |
| 1388 | f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr)); |
| 1389 | f_wait_icmp4_echo_reply(ctx); |
| 1390 | |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1391 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1392 | f_shutdown_helper(); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1393 | } |
| 1394 | |
| 1395 | /* Assert that packets with wrong global src addr are dropped by GGSN */ |
| 1396 | testcase TC_pdp4_act_deact_gtpu_access_wrong_saddr() runs on GT_CT { |
| 1397 | f_init(); |
| 1398 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1399 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
| 1400 | f_pdp_ctx_act(ctx); |
| 1401 | |
| 1402 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
| 1403 | var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O); |
| 1404 | var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4.ipv4_address; |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1405 | var OCT4 saddr_wrong := substr(saddr, 0, 3) & (saddr[3] xor4b '11'O); |
| 1406 | f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr_wrong, dns1_addr)); |
| 1407 | f_wait_gtpu_fail(ctx); |
| 1408 | |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1409 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1410 | f_shutdown_helper(); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1411 | } |
| 1412 | |
| 1413 | /* Send an IPv6 RA to APN4, should fail (packet dropped) */ |
| 1414 | testcase TC_pdp4_act_deact_gtpu_access_ipv6_apn4() runs on GT_CT { |
| 1415 | f_init(); |
| 1416 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1417 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
| 1418 | f_pdp_ctx_act(ctx); |
| 1419 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1420 | /* Send an IPv6 RA to APN4, should fail (packet dropped) */ |
| 1421 | var OCT16 saddr_v6 := f_inet6_addr("fde4:8dba:82e1:2000:1:2:3:4"); |
| 1422 | f_send_gtpu(ctx, f_gen_icmpv6_router_solicitation(saddr_v6)); |
| 1423 | f_wait_gtpu_fail(ctx); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1424 | |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1425 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1426 | f_shutdown_helper(); |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 1427 | } |
| 1428 | |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 1429 | /* Helper function for tests below. */ |
| 1430 | function f_pdp4_clients_interact() runs on GT_CT { |
Pau Espin Pedrol | 6c7285d | 2018-01-30 17:20:22 +0100 | [diff] [blame] | 1431 | f_init(); |
| 1432 | var PdpContext ctxA := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1433 | var PdpContext ctxB := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1434 | f_pdp_ctx_act(ctxA); |
| 1435 | f_pdp_ctx_act(ctxB); |
| 1436 | var OCT4 addrA := ctxA.eua.endUserAddress.endUserAddressIPv4.ipv4_address; |
| 1437 | var OCT4 addrB := ctxB.eua.endUserAddress.endUserAddressIPv4.ipv4_address; |
| 1438 | f_send_gtpu(ctxA, f_gen_icmpv4_echo(addrA, addrB)); |
| 1439 | f_wait_icmp4_echo_request(ctxB); |
| 1440 | |
| 1441 | f_pdp_ctx_del(ctxA, '1'B); |
Pau Espin Pedrol | bb2bb06 | 2019-09-03 12:28:12 +0200 | [diff] [blame] | 1442 | f_pdp_ctx_del(ctxB, '1'B); |
Pau Espin Pedrol | 6c7285d | 2018-01-30 17:20:22 +0100 | [diff] [blame] | 1443 | } |
| 1444 | |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 1445 | /* Validate if different clients (pdp ctx) can reach one another through GGSN. */ |
| 1446 | testcase TC_pdp4_clients_interact_with_txseq() runs on GT_CT { |
Harald Welte | 3e0b039 | 2018-04-26 09:46:21 +0200 | [diff] [blame] | 1447 | use_gtpu_txseq := true; |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 1448 | f_pdp4_clients_interact(); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1449 | f_shutdown_helper(); |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 1450 | } |
| 1451 | |
| 1452 | /* Validate if different clients (pdp ctx) can reach one another through GGSN (without Tx sequence number). */ |
| 1453 | testcase TC_pdp4_clients_interact_without_txseq() runs on GT_CT { |
Harald Welte | 3e0b039 | 2018-04-26 09:46:21 +0200 | [diff] [blame] | 1454 | use_gtpu_txseq := false; |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 1455 | f_pdp4_clients_interact(); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1456 | f_shutdown_helper(); |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 1457 | } |
| 1458 | |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 1459 | testcase TC_echo_req_resp() runs on GT_CT { |
| 1460 | f_init(); |
| 1461 | f_send_gtpc(ts_GTPC_PING(g_peer_c, g_c_seq_nr)); |
| 1462 | T_default.start; |
| 1463 | alt { |
| 1464 | [] GTPC.receive(tr_GTPC_PONG(g_peer_c)) { setverdict(pass); }; |
| 1465 | [] GTPC.receive { repeat; }; |
| 1466 | [] T_default.timeout { setverdict(fail); } |
| 1467 | } |
| 1468 | T_default.stop; |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1469 | f_shutdown_helper(); |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 1470 | } |
| 1471 | |
Pau Espin Pedrol | 480e67f | 2022-02-09 16:37:47 +0100 | [diff] [blame] | 1472 | testcase TC_echo_req_resp_gtpu() runs on GT_CT { |
| 1473 | f_init(); |
| 1474 | GTPU.send(ts_GTPU_PING(g_peer_u, g_d_seq_nr)); |
| 1475 | T_default.start; |
| 1476 | alt { |
| 1477 | [] GTPU.receive(tr_GTPU_PONG(g_peer_u)) { setverdict(pass); }; |
| 1478 | [] GTPU.receive { repeat; }; |
| 1479 | [] T_default.timeout { setverdict(fail); } |
| 1480 | } |
| 1481 | T_default.stop; |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1482 | f_shutdown_helper(); |
Pau Espin Pedrol | 480e67f | 2022-02-09 16:37:47 +0100 | [diff] [blame] | 1483 | } |
| 1484 | |
Philipp Maier | 33e5261 | 2018-05-30 17:22:02 +0200 | [diff] [blame] | 1485 | /* Test if the parser can cope with PCO that only contain either a |
| 1486 | * single primary DNS or a secondary DNS. */ |
| 1487 | testcase TC_pdp4_act_deact_with_single_dns() runs on GT_CT { |
| 1488 | |
| 1489 | /* Note: an unpatched osmo-ggsn version will enter an endless-loop when |
| 1490 | * the test is executed. |
| 1491 | * see also: Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */ |
| 1492 | |
| 1493 | f_init(); |
| 1494 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1495 | var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1); |
| 1496 | var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2); |
| 1497 | var octetstring pco_neg_dns; |
| 1498 | var octetstring pco_neg_dns_expected; |
| 1499 | |
| 1500 | /* PCO with primary DNS only */ |
| 1501 | ctx.pco_req := valueof(ts_PCO_IPv4_PRI_DNS_IPCP); |
| 1502 | f_pdp_ctx_act(ctx); |
Harald Welte | 79737b4 | 2019-04-10 10:39:30 +0200 | [diff] [blame] | 1503 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
Philipp Maier | 33e5261 | 2018-05-30 17:22:02 +0200 | [diff] [blame] | 1504 | pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 1); |
| 1505 | pco_neg_dns_expected := '0200000A8106'O & ggsn_ip4_dns1 |
| 1506 | /* Note: The prepended hex bytes encode the following information: |
| 1507 | * 0x02 = Configuration ACK |
| 1508 | * 0x00 = Identifier |
| 1509 | * 0x000a = Length |
| 1510 | * 0x81 = Type (Primary DNS Server Address) |
| 1511 | * 0x06 = Length |
| 1512 | * (4 byte IP-Address appended) */ |
| 1513 | if (not match(pco_neg_dns, pco_neg_dns_expected)) { |
| 1514 | setverdict(fail, "Primary DNS IPv4 PCO option not found"); |
| 1515 | } |
| 1516 | f_pdp_ctx_del(ctx, '1'B); |
| 1517 | |
| 1518 | /* PCO with secondary DNS only */ |
Harald Welte | 7ef6d10 | 2021-04-01 21:24:35 +0200 | [diff] [blame] | 1519 | ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
Philipp Maier | 33e5261 | 2018-05-30 17:22:02 +0200 | [diff] [blame] | 1520 | ctx.pco_req := valueof(ts_PCO_IPv4_SEC_DNS_IPCP); |
| 1521 | f_pdp_ctx_act(ctx); |
| 1522 | pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 1); |
| 1523 | pco_neg_dns_expected := '0200000A8306'O & ggsn_ip4_dns2 |
| 1524 | if (not match(pco_neg_dns, pco_neg_dns_expected)) { |
| 1525 | setverdict(fail, "Secondary DNS IPv4 PCO option not found"); |
| 1526 | } |
| 1527 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1528 | f_shutdown_helper(); |
Philipp Maier | 33e5261 | 2018-05-30 17:22:02 +0200 | [diff] [blame] | 1529 | } |
| 1530 | |
| 1531 | /* Test if the parser can cope with PCO that contains primary and secondary DNS in a separate IPCP container. |
| 1532 | * Note: an unpatched osmo-ggsn version will enter an endless-loop when the test is run |
| 1533 | * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288. */ |
| 1534 | testcase TC_pdp4_act_deact_with_separate_dns() runs on GT_CT { |
| 1535 | |
| 1536 | /* Note: an unpatched osmo-ggsn version will enter an endless-loop when |
| 1537 | * the test is executed. |
| 1538 | * see also: Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */ |
| 1539 | |
| 1540 | f_init(); |
| 1541 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1542 | var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1); |
| 1543 | var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2); |
| 1544 | var octetstring pco_neg_dns; |
| 1545 | var octetstring pco_neg_dns_expected; |
| 1546 | |
| 1547 | ctx.pco_req := valueof(ts_PCO_IPv4_SEPARATE_DNS_IPCP); |
| 1548 | f_pdp_ctx_act(ctx); |
| 1549 | |
| 1550 | /* Check if primary DNS is contained */ |
| 1551 | pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 1); |
| 1552 | pco_neg_dns_expected := '0200000A8106'O & ggsn_ip4_dns1 |
| 1553 | if (not match(pco_neg_dns, pco_neg_dns_expected)) { |
| 1554 | setverdict(fail, "Primary DNS IPv4 PCO option not found"); |
| 1555 | } |
Philipp Maier | 33e5261 | 2018-05-30 17:22:02 +0200 | [diff] [blame] | 1556 | |
| 1557 | /* Check if secondary DNS is contained */ |
Stefan Sperling | 8e7a396 | 2018-07-19 19:24:38 +0200 | [diff] [blame] | 1558 | /* This used to fail due to a bug in osmo-ggsn, see OS#3381 */ |
| 1559 | pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 2); |
Philipp Maier | 33e5261 | 2018-05-30 17:22:02 +0200 | [diff] [blame] | 1560 | pco_neg_dns_expected := '0200000A8306'O & ggsn_ip4_dns2 |
| 1561 | if (not match(pco_neg_dns, pco_neg_dns_expected)) { |
| 1562 | setverdict(fail, "Secondary DNS IPv4 PCO option not found"); |
| 1563 | } |
| 1564 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1565 | f_shutdown_helper(); |
Philipp Maier | 33e5261 | 2018-05-30 17:22:02 +0200 | [diff] [blame] | 1566 | } |
| 1567 | |
Pau Espin Pedrol | cd326c5 | 2022-02-14 18:57:43 +0100 | [diff] [blame] | 1568 | /* Validate that SUT updates remote TEIC when requested through UpdatePDPContextRequest */ |
| 1569 | testcase TC_pdp4_act_update_teic() runs on GT_CT { |
| 1570 | f_init(); |
| 1571 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1572 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
| 1573 | f_pdp_ctx_act(ctx); |
| 1574 | |
| 1575 | /* UpdatePDPContestRequest changing the local TEIC */ |
| 1576 | var OCT4 new_teic := ctx.teic; |
| 1577 | new_teic[3] := new_teic[3] xor4b '11'O; |
| 1578 | f_pdp_ctx_update(ctx, new_teic := new_teic); |
| 1579 | |
| 1580 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1581 | f_shutdown_helper(); |
Pau Espin Pedrol | cd326c5 | 2022-02-14 18:57:43 +0100 | [diff] [blame] | 1582 | } |
| 1583 | |
| 1584 | /* Validate that SUT updates remote TEID when requested through UpdatePDPContextRequest */ |
| 1585 | testcase TC_pdp4_act_update_teid() runs on GT_CT { |
| 1586 | f_init(); |
| 1587 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1588 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
| 1589 | f_pdp_ctx_act(ctx); |
| 1590 | |
| 1591 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
| 1592 | var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O); |
| 1593 | var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4.ipv4_address; |
| 1594 | |
| 1595 | /* Data is sent (back) to the local TEID established during CreatePDPContext */ |
| 1596 | f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr)); |
| 1597 | f_wait_icmp4_echo_reply(ctx); |
| 1598 | |
| 1599 | /* UpdatePDPContestRequest changing the local TEID */ |
| 1600 | var OCT4 new_teid := ctx.teid; |
| 1601 | new_teid[3] := new_teid[3] xor4b '11'O; |
| 1602 | f_pdp_ctx_update(ctx, new_teid := new_teid); |
| 1603 | |
| 1604 | /* Check if we can send data after updating the PDP context. Answer should be sent to the new TEID */ |
| 1605 | f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr)); |
| 1606 | f_wait_icmp4_echo_reply(ctx); |
| 1607 | |
| 1608 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1609 | f_shutdown_helper(); |
Pau Espin Pedrol | cd326c5 | 2022-02-14 18:57:43 +0100 | [diff] [blame] | 1610 | } |
| 1611 | |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1612 | /* Test IPv4v6 context activation for dynamic IPv4v6 EUA without DNS request */ |
| 1613 | testcase TC_pdp46_act_deact() runs on GT_CT { |
| 1614 | f_init(); |
| 1615 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn))); |
| 1616 | f_pdp_ctx_act(ctx); |
| 1617 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1618 | f_shutdown_helper(); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1619 | } |
| 1620 | |
| 1621 | /* Test PDP context activation for dynamic IPv4v6 EUA with IPv4 DNS in IPCP */ |
| 1622 | testcase TC_pdp46_act_deact_ipcp() runs on GT_CT { |
| 1623 | f_init(); |
| 1624 | var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1); |
| 1625 | var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2); |
| 1626 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn))); |
| 1627 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_IPCP); |
| 1628 | f_pdp_ctx_act(ctx); |
Harald Welte | 79737b4 | 2019-04-10 10:39:30 +0200 | [diff] [blame] | 1629 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1630 | /* verify IPCP is at all contained */ |
| 1631 | if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) { |
| 1632 | setverdict(fail, "IPCP not found in PCO"); |
| 1633 | } |
Harald Welte | 79737b4 | 2019-04-10 10:39:30 +0200 | [diff] [blame] | 1634 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1635 | /* verify IPCP contains both primary and secondary IPv4 DNS */ |
| 1636 | var IpcpPacket ipcp := dec_IpcpPacket(f_PCO_extract_proto(ctx.pco_neg, '8021'O)); |
| 1637 | if (not match(ipcp, tr_IPCP_Ack_DNS(0, ggsn_ip4_dns1, ggsn_ip4_dns2))) { |
| 1638 | if (not match(ipcp, tr_IPCP_Ack_DNS(0))) { |
| 1639 | setverdict(fail, "Primary/Secondary DNS PCO IPCP option not found"); |
| 1640 | } else { |
| 1641 | setverdict(fail, "Primary/Secondary DNS PCO IPCP option found but not matching expected values"); |
| 1642 | } |
| 1643 | } |
| 1644 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1645 | f_shutdown_helper(); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1646 | } |
| 1647 | |
| 1648 | /* Test PDP context activation for dynamic IPv4v6 EUA with IPv6 DNS in PCO and router solicitation/advertisement */ |
| 1649 | testcase TC_pdp46_act_deact_icmp6() runs on GT_CT { |
| 1650 | f_init(); |
| 1651 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn))); |
| 1652 | ctx.pco_req := valueof(ts_PCO_IPv6_DNS); |
| 1653 | f_pdp_ctx_act(ctx); |
| 1654 | |
| 1655 | f_send_gtpu(ctx, f_icmpv6_rs_for_pdp46(ctx)); |
| 1656 | f_wait_rtr_adv(ctx); |
| 1657 | f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp46(ctx)); |
| 1658 | |
| 1659 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1660 | f_shutdown_helper(); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1661 | } |
| 1662 | |
| 1663 | /* Test IPv4v6 context activation for dynamic IPv4v6 EUA with request of IPv4 DNS in PCO */ |
| 1664 | testcase TC_pdp46_act_deact_pcodns4() runs on GT_CT { |
| 1665 | f_init(); |
| 1666 | |
| 1667 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn))); |
| 1668 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
| 1669 | f_pdp_ctx_act(ctx); |
| 1670 | |
Harald Welte | 79737b4 | 2019-04-10 10:39:30 +0200 | [diff] [blame] | 1671 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1672 | /* verify PCO contains both primary and secondary IPv4 DNS */ |
| 1673 | var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1); |
| 1674 | if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 1), ggsn_ip4_dns1)) { |
| 1675 | setverdict(fail, "Primary DNS IPv4 PCO option not found"); |
| 1676 | } |
| 1677 | |
| 1678 | var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2); |
| 1679 | if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 2), ggsn_ip4_dns2)) { |
| 1680 | setverdict(fail, "Secondary DNS IPv4 PCO option not found"); |
| 1681 | } |
| 1682 | |
| 1683 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1684 | f_shutdown_helper(); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1685 | } |
| 1686 | |
| 1687 | /* Test IPv4v6 context activation for dynamic IPv4v6 EUA with request of IPv6 DNS in PCO */ |
| 1688 | testcase TC_pdp46_act_deact_pcodns6() runs on GT_CT { |
| 1689 | f_init(); |
| 1690 | |
| 1691 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn))); |
| 1692 | ctx.pco_req := valueof(ts_PCO_IPv6_DNS); |
| 1693 | f_pdp_ctx_act(ctx); |
| 1694 | |
Harald Welte | 79737b4 | 2019-04-10 10:39:30 +0200 | [diff] [blame] | 1695 | f_PCO_ensure_no_duplicates(ctx.pco_neg); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1696 | /* verify PCO contains both primary and secondary IPv6 DNS */ |
| 1697 | var OCT4 ggsn_ip6_dns1 := f_inet6_addr(m_ggsn_ip6_dns1); |
| 1698 | if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 1), ggsn_ip6_dns1)) { |
| 1699 | setverdict(fail, "Primary DNS IPv6 PCO option not found"); |
| 1700 | } |
| 1701 | |
| 1702 | var OCT4 ggsn_ip6_dns2 := f_inet6_addr(m_ggsn_ip6_dns2); |
| 1703 | if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 2), ggsn_ip6_dns2)) { |
| 1704 | setverdict(fail, "Secondary DNS IPv6 PCO option not found"); |
| 1705 | } |
| 1706 | |
| 1707 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1708 | f_shutdown_helper(); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1709 | } |
| 1710 | |
| 1711 | /* Test PDP context activation for dynamic IPv4v6 EUA. |
| 1712 | Test we can send ICMPv6 ping over GTPU to DNS server. */ |
| 1713 | testcase TC_pdp46_act_deact_gtpu_access() runs on GT_CT { |
| 1714 | f_init(); |
| 1715 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn))); |
| 1716 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
| 1717 | f_pdp_ctx_act(ctx); |
| 1718 | |
| 1719 | var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O); |
| 1720 | |
| 1721 | /* Check if we can use valid global src addr, should work */ |
| 1722 | var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv4_address; |
| 1723 | f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr)); |
| 1724 | f_wait_icmp4_echo_reply(ctx); |
| 1725 | |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1726 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1727 | f_shutdown_helper(); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1728 | } |
| 1729 | |
| 1730 | /* Assert that packets with wrong ipv4 src addr are dropped by GGSN on APN IPv4v6 */ |
| 1731 | testcase TC_pdp46_act_deact_gtpu_access_wrong_saddr_ipv4() runs on GT_CT { |
| 1732 | f_init(); |
| 1733 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn))); |
| 1734 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
| 1735 | f_pdp_ctx_act(ctx); |
| 1736 | |
| 1737 | var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O); |
| 1738 | var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv4_address; |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1739 | var OCT4 saddr_wrong := substr(saddr, 0, 3) & (saddr[3] xor4b '11'O); |
| 1740 | f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr_wrong, dns1_addr)); |
| 1741 | f_wait_gtpu_fail(ctx); |
| 1742 | |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1743 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1744 | f_shutdown_helper(); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1745 | } |
| 1746 | |
Pau Espin Pedrol | c6ac695 | 2022-02-14 11:19:23 +0100 | [diff] [blame] | 1747 | /* Check that attempting RA with another ll src addr won't work, packet dropped: */ |
| 1748 | testcase TC_pdp46_act_deact_gtpu_access_wrong_ll_saddr_ipv6() runs on GT_CT { |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1749 | f_init(); |
| 1750 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn))); |
| 1751 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
| 1752 | f_pdp_ctx_act(ctx); |
| 1753 | |
Pau Espin Pedrol | c6ac695 | 2022-02-14 11:19:23 +0100 | [diff] [blame] | 1754 | var OCT16 saddr_ll := f_ipv6_link_local(ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address); |
| 1755 | var OCT16 saddr_ll_wrong := f_ipv6_mangle(saddr_ll, 8); |
| 1756 | f_send_gtpu(ctx, f_gen_icmpv6_router_solicitation(saddr_ll_wrong)); |
| 1757 | f_wait_gtpu_fail(ctx); |
| 1758 | |
| 1759 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1760 | f_shutdown_helper(); |
Pau Espin Pedrol | c6ac695 | 2022-02-14 11:19:23 +0100 | [diff] [blame] | 1761 | } |
| 1762 | |
| 1763 | /* Assert that packets with wrong ipv6 global src addr are dropped by GGSN on APN IPv4v6 */ |
| 1764 | testcase TC_pdp46_act_deact_gtpu_access_wrong_global_saddr_ipv6() runs on GT_CT { |
| 1765 | f_init(); |
| 1766 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn))); |
| 1767 | ctx.pco_req := valueof(ts_PCO_IPv6_DNS); |
| 1768 | f_pdp_ctx_act(ctx); |
| 1769 | |
| 1770 | f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx)); |
| 1771 | f_wait_rtr_adv(ctx); |
| 1772 | f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx)); |
| 1773 | |
| 1774 | var OCT16 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '0003'O); |
| 1775 | var OCT16 saddr_glob := f_ipv6_global(ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address); |
| 1776 | var OCT16 saddr_wrong := f_ipv6_mangle(saddr_glob); |
| 1777 | f_send_gtpu(ctx, f_gen_icmpv6_echo(saddr_wrong, dns1_addr)); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1778 | f_wait_gtpu_fail(ctx); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 1779 | |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1780 | f_pdp_ctx_del(ctx, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1781 | f_shutdown_helper(); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1782 | } |
| 1783 | |
| 1784 | /* Validate if different clients (pdp ctx) can reach one another through GGSN. */ |
| 1785 | testcase TC_pdp46_clients_interact() runs on GT_CT { |
| 1786 | f_init(); |
| 1787 | var PdpContext ctxA := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn))); |
| 1788 | var PdpContext ctxB := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn))); |
| 1789 | f_pdp_ctx_act(ctxA); |
| 1790 | f_send_gtpu(ctxA, f_icmpv6_rs_for_pdp46(ctxA)); |
| 1791 | f_wait_rtr_adv(ctxA); |
| 1792 | f_send_gtpu(ctxA, f_gen_icmpv6_neigh_solicit_for_pdp46(ctxA)); |
| 1793 | |
| 1794 | f_pdp_ctx_act(ctxB); |
| 1795 | f_send_gtpu(ctxB, f_icmpv6_rs_for_pdp46(ctxB)); |
| 1796 | f_wait_rtr_adv(ctxB); |
| 1797 | f_send_gtpu(ctxB, f_gen_icmpv6_neigh_solicit_for_pdp46(ctxB)); |
| 1798 | |
| 1799 | var OCT16 addrA_ll := f_ipv6_link_local(ctxA.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address); |
| 1800 | var OCT16 addrB_ll := f_ipv6_link_local(ctxB.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address); |
| 1801 | var OCT16 addrA_glob := f_ipv6_global(ctxA.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address); |
| 1802 | var OCT16 addrB_glob := f_ipv6_global(ctxB.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address); |
| 1803 | |
| 1804 | /* Validate if clients can interact using ll addr. */ |
| 1805 | f_send_gtpu(ctxA, f_gen_icmpv6_echo(addrA_ll, addrB_ll)); |
| 1806 | f_wait_gtpu_fail(ctxB); |
| 1807 | |
| 1808 | /* Validate if clients can interact using global addr. */ |
| 1809 | f_send_gtpu(ctxA, f_gen_icmpv6_echo(addrA_glob, addrB_glob)); |
| 1810 | f_wait_gtpu_fail(ctxB); |
| 1811 | |
| 1812 | f_pdp_ctx_del(ctxA, '1'B); |
Pau Espin Pedrol | bb2bb06 | 2019-09-03 12:28:12 +0200 | [diff] [blame] | 1813 | f_pdp_ctx_del(ctxB, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1814 | f_shutdown_helper(); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 1815 | } |
| 1816 | |
Pau Espin Pedrol | 22d597f | 2019-08-21 16:16:58 +0200 | [diff] [blame] | 1817 | /* Test IPv4v6 context activation for dynamic IPv4v6 EUA on a v4-only APN */ |
| 1818 | testcase TC_pdp46_act_deact_apn4() runs on GT_CT { |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 1819 | const OCT1 cause_accept := '80'O; /* Normal accept cause */ |
| 1820 | const OCT1 cause_new_pdp_type := '81'O; /* Cause: New PDP type due to network preference */ |
| 1821 | const OCT1 cause_unknown_pdp := 'DC'O; /* Cause: Unknown PDP address or PDP type */ |
| 1822 | var CreatePDPContextResponse cpr; |
| 1823 | |
Pau Espin Pedrol | 22d597f | 2019-08-21 16:16:58 +0200 | [diff] [blame] | 1824 | f_init(); |
Pau Espin Pedrol | 22d597f | 2019-08-21 16:16:58 +0200 | [diff] [blame] | 1825 | var PdpContext ctx46 := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dynv6Dyn))); |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 1826 | cpr := f_pdp_ctx_act(ctx46, (cause_unknown_pdp, cause_new_pdp_type)); |
Pau Espin Pedrol | 22d597f | 2019-08-21 16:16:58 +0200 | [diff] [blame] | 1827 | |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 1828 | if (cpr.cause.causevalue == cause_new_pdp_type) { |
| 1829 | /* 3GPP TS 23.060 sec 9.2.1: "If the MS requests PDP type IPv4v6, |
| 1830 | * but the operator preferences dictate the use of a single IP |
| 1831 | * version only, the PDP type shall be changed to a single address |
| 1832 | * PDP type (IPv4 or IPv6) and a reason cause shall be returned to |
| 1833 | * the MS indicating that only the assigned PDP type is allowed. In |
| 1834 | * this case, the MS shall not request another PDP context for the |
| 1835 | * other PDP type during the existence of the PDP context." */ |
| 1836 | f_pdp_ctx_del(ctx46, '1'B); |
| 1837 | } else { |
| 1838 | /* 3GPP TS 23.060 sec 9.2.1 NOTE 5: If the MS requests PDP type |
| 1839 | * IPv4v6, and the PDP context is rejected due to "unknown PDP |
| 1840 | * type", the MS can attempt to establish dual-stack connectivity |
| 1841 | * by performing two PDP context request procedures to activate an |
| 1842 | * IPv4 PDP context and an IPv6 PDP context, both to the same APN. A |
| 1843 | * typical MS first attempts v4v6, and if rejected, then tries v4 |
| 1844 | * and v6 separetly */ |
| 1845 | var PdpContext ctx4 := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1846 | f_pdp_ctx_act(ctx4, cause_accept); /* Normal accept cause */ |
Pau Espin Pedrol | 22d597f | 2019-08-21 16:16:58 +0200 | [diff] [blame] | 1847 | |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 1848 | var PdpContext ctx6 := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv6Dyn))); |
| 1849 | f_pdp_ctx_act(ctx6, cause_unknown_pdp); /* Cause: Unknown PDP address or PDP type */ |
Pau Espin Pedrol | 22d597f | 2019-08-21 16:16:58 +0200 | [diff] [blame] | 1850 | |
Pau Espin Pedrol | 0f464d6 | 2022-02-23 14:04:29 +0100 | [diff] [blame] | 1851 | f_pdp_ctx_del(ctx4, '1'B); |
| 1852 | } |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1853 | f_shutdown_helper(); |
Pau Espin Pedrol | 22d597f | 2019-08-21 16:16:58 +0200 | [diff] [blame] | 1854 | } |
| 1855 | |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 1856 | /* Validate if 2nd CtxCreateReq with increased Recovery IE causes ggsn to drop 1st one (while keeping 2nd one). */ |
| 1857 | testcase TC_pdp_act2_recovery() runs on GT_CT { |
| 1858 | var Gtp1cUnitdata ud; |
| 1859 | var default d; |
| 1860 | var boolean ctxA_deleted := false; |
| 1861 | var boolean ctxB_created := false; |
| 1862 | |
| 1863 | f_init(); |
| 1864 | var PdpContext ctxA := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1865 | var PdpContext ctxB := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1866 | f_pdp_ctx_act(ctxA); |
| 1867 | |
Vadim Yanitskiy | d344b4a | 2022-02-09 18:28:18 +0600 | [diff] [blame] | 1868 | g_restart_ctr := int2oct((oct2int(g_restart_ctr) + 1) mod 256, 1); |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 1869 | |
| 1870 | log("sending 2nd CreatePDP (recovery increased)"); |
| 1871 | f_send_gtpc(ts_GTPC_CreatePDP(g_peer_c, g_c_seq_nr, ctxB.imsi, g_restart_ctr, |
| 1872 | ctxB.teid, ctxB.teic, ctxB.nsapi, ctxB.eua, ctxB.apn, |
| 1873 | g_sgsn_ip_c, g_sgsn_ip_u, ctxB.msisdn, ctxB.pco_req)); |
| 1874 | T_default.start; |
| 1875 | d := activate(pingpong()); |
| 1876 | alt { |
| 1877 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, createPDPContextResponse, ctxB.teic)) -> value ud { |
| 1878 | f_handle_create_req(ctxB, ud); |
| 1879 | if (not ctxB_created) { |
| 1880 | ctxB_created := true; |
| 1881 | setverdict(pass); |
| 1882 | } else { |
| 1883 | setverdict(fail, "Repeated createPDPContextResponse(ctxB)"); |
| 1884 | } |
| 1885 | |
| 1886 | if (not ctxA_deleted) { |
| 1887 | repeat; |
| 1888 | } |
| 1889 | } |
| 1890 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextRequest, ctxA.teic)) -> value ud { |
| 1891 | if (ispresent(ud.gtpc.gtpc_pdu.deletePDPContextRequest.tearDownIndicator)) { |
| 1892 | setverdict(pass); |
| 1893 | } else { |
| 1894 | setverdict(fail); |
| 1895 | } |
| 1896 | |
| 1897 | if (not ctxA_deleted) { |
| 1898 | ctxA_deleted := true; |
| 1899 | setverdict(pass); |
| 1900 | } else { |
| 1901 | setverdict(fail, "Repeated deletePDPContextRequest(ctxA)"); |
| 1902 | } |
| 1903 | |
| 1904 | if (not ctxB_created) { |
| 1905 | repeat; |
| 1906 | } |
| 1907 | } |
| 1908 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextRequest, ctxB.teic)) -> value ud { |
| 1909 | setverdict(fail, "GGSN dropping still valid pdp ctx"); |
| 1910 | } |
| 1911 | } |
| 1912 | deactivate(d); |
| 1913 | T_default.stop; |
| 1914 | |
| 1915 | f_pdp_ctx_del(ctxB, '1'B); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1916 | f_shutdown_helper(); |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 1917 | } |
| 1918 | |
| 1919 | |
Pau Espin Pedrol | 9a5f42f | 2019-05-27 20:04:35 +0200 | [diff] [blame] | 1920 | /* Send a duplicate echo req. osmo-ggsn maintains a queue for sent |
| 1921 | responses (60 seconds): If same delete req is sent and duplicate is |
| 1922 | detected, saved duplicate response should be sent back. */ |
| 1923 | testcase TC_act_deact_retrans_duplicate() runs on GT_CT { |
| 1924 | f_init(); |
| 1925 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1926 | f_pdp_ctx_act(ctx); |
| 1927 | f_pdp_ctx_del(ctx, '1'B); |
| 1928 | /* leave some time in between to make sure retransmit response queue keeps packets for a while */ |
| 1929 | f_sleep(1.0); |
| 1930 | /* g_c_seq_nr was increased during f_pdp_ctx_del(), we want a |
| 1931 | duplicate. If it was not a duplicate, osmo-ggsn would answer |
| 1932 | with a failure since that PDP ctx was already deleted. */ |
| 1933 | g_c_seq_nr := g_c_seq_nr - 1; |
Pau Espin Pedrol | 10ec96e | 2022-02-09 17:03:15 +0100 | [diff] [blame] | 1934 | f_pdp_ctx_del(ctx, '1'B, expect_diameter := false); |
Pau Espin Pedrol | 9a5f42f | 2019-05-27 20:04:35 +0200 | [diff] [blame] | 1935 | |
| 1936 | /* Now send a new pdp ctx del (increased seqnum). It should fail with cause "non-existent": */ |
| 1937 | var OCT1 cause_nonexistent := 'C0'O; |
Pau Espin Pedrol | 10ec96e | 2022-02-09 17:03:15 +0100 | [diff] [blame] | 1938 | f_pdp_ctx_del(ctx, '1'B, cause_nonexistent, expect_diameter := false); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1939 | f_shutdown_helper(); |
Pau Espin Pedrol | 9a5f42f | 2019-05-27 20:04:35 +0200 | [diff] [blame] | 1940 | } |
| 1941 | |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 1942 | /* Activate PDP context + trigger Recovery procedure through EchoResp */ |
| 1943 | testcase TC_pdp_act_restart_ctr_echo() runs on GT_CT { |
| 1944 | var Gtp1cUnitdata ud; |
Pau Espin Pedrol | 0511802 | 2022-02-17 19:49:13 +0100 | [diff] [blame] | 1945 | g_use_echo_intval := 5; |
| 1946 | timer T_echo; |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 1947 | f_init(); |
| 1948 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 1949 | f_pdp_ctx_act(ctx); |
| 1950 | |
| 1951 | /* Wait to receive echo request and send initial Restart counter */ |
Pau Espin Pedrol | 0511802 | 2022-02-17 19:49:13 +0100 | [diff] [blame] | 1952 | T_echo.start(int2float(g_use_echo_intval) + 1.0); |
| 1953 | alt { |
| 1954 | [] GTPC.receive(tr_GTPC_PING(?)) -> value ud { |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 1955 | var uint16_t seq := oct2int(ud.gtpc.opt_part.sequenceNumber); |
| 1956 | GTPC.send(ts_GTPC_PONG(ud.peer, seq, g_restart_ctr)); |
Pau Espin Pedrol | 0511802 | 2022-02-17 19:49:13 +0100 | [diff] [blame] | 1957 | } |
| 1958 | [] T_echo.timeout { |
| 1959 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1960 | "Timeout waiting for ping"); |
| 1961 | } |
| 1962 | } |
| 1963 | T_echo.stop; |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 1964 | |
| 1965 | /* Wait to receive second echo request and send incremented Restart |
| 1966 | counter. This will fake a restarted SGSN, and pdp ctx allocated |
| 1967 | should be released by GGSN */ |
Vadim Yanitskiy | d344b4a | 2022-02-09 18:28:18 +0600 | [diff] [blame] | 1968 | g_restart_ctr := int2oct((oct2int(g_restart_ctr) + 1) mod 256, 1); |
Pau Espin Pedrol | 0511802 | 2022-02-17 19:49:13 +0100 | [diff] [blame] | 1969 | T_echo.start(int2float(g_use_echo_intval) + 1.0); |
| 1970 | alt { |
| 1971 | [] GTPC.receive(tr_GTPC_PING(?)) -> value ud { |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 1972 | var uint16_t seq := oct2int(ud.gtpc.opt_part.sequenceNumber); |
| 1973 | GTPC.send(ts_GTPC_PONG(ud.peer, seq, g_restart_ctr)); |
Pau Espin Pedrol | 0511802 | 2022-02-17 19:49:13 +0100 | [diff] [blame] | 1974 | } |
| 1975 | [] T_echo.timeout { |
| 1976 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1977 | "Timeout waiting for ping"); |
| 1978 | } |
| 1979 | } |
| 1980 | T_echo.stop; |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 1981 | f_pdp_ctx_exp_del_req(ctx, omit, true); |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 1982 | f_shutdown_helper(); |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 1983 | } |
| 1984 | |
Pau Espin Pedrol | 68c2af5 | 2022-02-25 11:56:17 +0100 | [diff] [blame] | 1985 | /* Test creation, user plane and deletion of big amount (1000) of concurrent PDP context */ |
| 1986 | testcase TC_lots_of_concurrent_pdp_ctx() runs on GT_CT { |
| 1987 | var Gtp1cUnitdata udc; |
| 1988 | var Gtp1uUnitdata udu; |
| 1989 | const integer num_ctx := 1000; |
| 1990 | var PdpContext ctx[num_ctx]; |
| 1991 | timer T_next := 0.01; |
| 1992 | var integer next_req_ctx := 0; |
| 1993 | var integer rx_resp_ctx := 0; |
| 1994 | var integer rx_pong := 0; |
| 1995 | var OCT4 dns1_addr; |
| 1996 | var OCT4 saddr; |
| 1997 | var integer teic; |
| 1998 | var integer idx; |
| 1999 | |
| 2000 | f_init(); |
| 2001 | |
| 2002 | for (var integer i := 0; i < num_ctx; i := i + 1) { |
| 2003 | ctx[i] := valueof(t_DefinePDP(f_rnd_imsi('26242'H), f_rnd_msisdn('1234'O), c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 2004 | ctx[i].teic := int2oct(i+1, 4); /* +1: skip TEIC=0 */ |
| 2005 | ctx[i].teid := int2oct(i+1, 4); /* +1: skip TEID=0 */ |
| 2006 | ctx[i].pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
| 2007 | } |
| 2008 | |
| 2009 | T_default.start(60.0); |
| 2010 | |
| 2011 | T_next.start; |
| 2012 | alt { |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 2013 | [Gx_PROC.checkstate("Connected")] as_DIA_Gx_CCR(INITIAL_REQUEST) { repeat; } |
| 2014 | [Gy_PROC.checkstate("Connected")] as_DIA_Gy_CCR(INITIAL_REQUEST) { repeat; } |
Pau Espin Pedrol | 68c2af5 | 2022-02-25 11:56:17 +0100 | [diff] [blame] | 2015 | [] pingpong(); |
| 2016 | [] T_next.timeout { |
| 2017 | f_send_gtpc(ts_GTPC_CreatePDP(g_peer_c, g_c_seq_nr, ctx[next_req_ctx].imsi, g_restart_ctr, |
| 2018 | ctx[next_req_ctx].teid, ctx[next_req_ctx].teic, ctx[next_req_ctx].nsapi, |
| 2019 | ctx[next_req_ctx].eua, ctx[next_req_ctx].apn, g_sgsn_ip_c, g_sgsn_ip_u, |
| 2020 | ctx[next_req_ctx].msisdn, ctx[next_req_ctx].pco_req, ctx[next_req_ctx].ratType, |
Pau Espin Pedrol | 535ca26 | 2022-05-16 14:07:17 +0200 | [diff] [blame^] | 2021 | ctx[next_req_ctx].uli, ctx[next_req_ctx].charging_char, ctx[next_req_ctx].imeisv, |
| 2022 | ctx[next_req_ctx].ms_tz)); |
Pau Espin Pedrol | 68c2af5 | 2022-02-25 11:56:17 +0100 | [diff] [blame] | 2023 | next_req_ctx := next_req_ctx + 1; |
| 2024 | if (next_req_ctx < num_ctx) { |
| 2025 | T_next.start; |
| 2026 | } |
| 2027 | repeat; |
| 2028 | } |
| 2029 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, createPDPContextResponse, ?)) -> value udc { |
| 2030 | teic := oct2int(udc.gtpc.teid); |
| 2031 | if (not match(teic, (1 .. num_ctx))) { |
| 2032 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2033 | "Rx Unexpected TEIC"); |
| 2034 | } |
| 2035 | idx := teic - 1; |
| 2036 | f_handle_create_req(ctx[idx], udc); |
| 2037 | rx_resp_ctx := rx_resp_ctx + 1; |
| 2038 | |
| 2039 | dns1_addr := f_PCO_extract_proto(ctx[idx].pco_neg, '000d'O); |
| 2040 | saddr := ctx[idx].eua.endUserAddress.endUserAddressIPv4.ipv4_address; |
| 2041 | f_send_gtpu(ctx[idx], f_gen_icmpv4_echo(saddr, dns1_addr)); |
| 2042 | repeat; |
| 2043 | } |
| 2044 | [] GTPU.receive(tr_GTPU_GPDU(g_peer_u, ?)) -> value udu { |
| 2045 | var octetstring gpdu := udu.gtpu.gtpu_IEs.g_PDU_IEs.data; |
| 2046 | var IPv4_packet ip4 := f_IPv4_dec(gpdu); |
| 2047 | if (ip4.header.ver != 4) { |
| 2048 | repeat; |
| 2049 | } |
| 2050 | var PDU_ICMP icmp4 := f_dec_PDU_ICMP(ip4.payload); |
| 2051 | if (not match(icmp4, (tr_ICMPv4_ERP, tr_ICMPv4_DU))) { |
| 2052 | repeat; |
| 2053 | } |
| 2054 | rx_pong := rx_pong + 1; |
| 2055 | if (rx_pong < num_ctx) { |
| 2056 | repeat; |
| 2057 | } |
| 2058 | setverdict(pass); |
| 2059 | } |
| 2060 | [] GTPC.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPC"); } |
| 2061 | [] GTPU.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPU"); } |
| 2062 | } |
| 2063 | |
| 2064 | /* Let's close them now: */ |
| 2065 | next_req_ctx := 0; |
| 2066 | rx_resp_ctx := 0; |
| 2067 | T_next.start; |
| 2068 | alt { |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 2069 | [Gx_PROC.checkstate("Connected")] as_DIA_Gx_CCR(TERMINATION_REQUEST) { repeat; } |
| 2070 | [Gy_PROC.checkstate("Connected")] as_DIA_Gy_CCR(TERMINATION_REQUEST) { repeat; } |
Pau Espin Pedrol | 68c2af5 | 2022-02-25 11:56:17 +0100 | [diff] [blame] | 2071 | [] pingpong(); |
| 2072 | [] T_next.timeout { |
| 2073 | f_send_gtpc(ts_GTPC_DeletePDP(g_peer_c, g_c_seq_nr, ctx[next_req_ctx].teic_remote, ctx[next_req_ctx].nsapi, '1'B)); |
| 2074 | next_req_ctx := next_req_ctx + 1; |
| 2075 | if (next_req_ctx < num_ctx) { |
| 2076 | T_next.start; |
| 2077 | } |
| 2078 | repeat; |
| 2079 | } |
| 2080 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextResponse, ?)) -> value udc { |
| 2081 | teic := oct2int(udc.gtpc.teid); |
| 2082 | if (not match(teic, (1 .. num_ctx))) { |
| 2083 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2084 | "Rx Unexpected TEIC"); |
| 2085 | } |
| 2086 | rx_resp_ctx := rx_resp_ctx + 1; |
| 2087 | if (rx_resp_ctx < num_ctx) { |
| 2088 | repeat; |
| 2089 | } |
| 2090 | setverdict(pass); |
| 2091 | } |
| 2092 | [] GTPC.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPC"); } |
| 2093 | [] GTPU.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPU"); } |
| 2094 | } |
| 2095 | T_next.stop; |
| 2096 | |
| 2097 | T_default.stop; |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 2098 | f_shutdown_helper(); |
Pau Espin Pedrol | 68c2af5 | 2022-02-25 11:56:17 +0100 | [diff] [blame] | 2099 | } |
| 2100 | |
Pau Espin Pedrol | bfea835 | 2022-02-28 12:11:26 +0100 | [diff] [blame] | 2101 | /* Test callocation of PDP contexts until reaching addr pool exhaustion */ |
| 2102 | type record of OCT4 TEIClist; |
| 2103 | testcase TC_addr_pool_exhaustion() runs on GT_CT { |
| 2104 | var Gtp1cUnitdata udc; |
| 2105 | var Gtp1uUnitdata udu; |
| 2106 | var PdpContext ctx; |
| 2107 | timer T_next := 0.005; |
| 2108 | var integer next_req_ctx := 0; |
| 2109 | var integer rx_resp_ctx := 0; |
| 2110 | var integer num_ctx; |
| 2111 | var boolean cont_req := true; |
| 2112 | var CreatePDPContextResponse cpr; |
| 2113 | var TEIClist teic_list := {}; |
| 2114 | var integer teic; |
| 2115 | |
| 2116 | f_init(); |
| 2117 | |
| 2118 | T_default.start(120.0); |
| 2119 | |
| 2120 | T_next.start; |
| 2121 | alt { |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 2122 | [Gx_PROC.checkstate("Connected")] as_DIA_Gx_CCR(INITIAL_REQUEST) { repeat; } |
| 2123 | [Gy_PROC.checkstate("Connected")] as_DIA_Gy_CCR(INITIAL_REQUEST) { repeat; } |
Pau Espin Pedrol | bfea835 | 2022-02-28 12:11:26 +0100 | [diff] [blame] | 2124 | [] pingpong(); |
| 2125 | [] T_next.timeout { |
| 2126 | if (cont_req) { |
| 2127 | if (next_req_ctx - rx_resp_ctx < 100) { /* if we have too many in progress, wait a bit to continue */ |
| 2128 | ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), f_rnd_msisdn('1234'O), c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
| 2129 | ctx.nsapi := '0001'B; |
| 2130 | ctx.teic := int2oct(next_req_ctx+1, 4); /* +1: skip TEIC=0 */ |
| 2131 | ctx.teid := int2oct(next_req_ctx+1, 4); /* +1: skip TEID=0 */ |
| 2132 | f_send_gtpc(ts_GTPC_CreatePDP(g_peer_c, g_c_seq_nr, ctx.imsi, g_restart_ctr, |
| 2133 | ctx.teid, ctx.teic, ctx.nsapi, |
| 2134 | ctx.eua, ctx.apn, g_sgsn_ip_c, g_sgsn_ip_u, |
| 2135 | ctx.msisdn, ctx.pco_req, ctx.ratType, |
Pau Espin Pedrol | 535ca26 | 2022-05-16 14:07:17 +0200 | [diff] [blame^] | 2136 | ctx.uli, ctx.charging_char, ctx.imeisv, |
| 2137 | ctx.ms_tz)); |
Pau Espin Pedrol | bfea835 | 2022-02-28 12:11:26 +0100 | [diff] [blame] | 2138 | next_req_ctx := next_req_ctx + 1; |
| 2139 | } |
| 2140 | T_next.start; |
| 2141 | } |
| 2142 | repeat; |
| 2143 | } |
| 2144 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, createPDPContextResponse, ?)) -> value udc { |
| 2145 | cpr := udc.gtpc.gtpc_pdu.createPDPContextResponse; |
| 2146 | |
| 2147 | if (cpr.cause.causevalue == '80'O) { |
| 2148 | teic_list := teic_list & {cpr.teidControlPlane.teidControlPlane}; |
| 2149 | } else { |
| 2150 | if (cont_req == true) { |
| 2151 | num_ctx := rx_resp_ctx; |
| 2152 | log("Successfully created ", num_ctx, " PDP contexts before exhausting the pool"); |
| 2153 | setverdict(pass); |
| 2154 | } |
| 2155 | cont_req := false; |
| 2156 | } |
| 2157 | rx_resp_ctx := rx_resp_ctx + 1; |
| 2158 | if (not cont_req and next_req_ctx == rx_resp_ctx) { |
| 2159 | break; |
| 2160 | } else { |
| 2161 | repeat; |
| 2162 | } |
| 2163 | } |
| 2164 | [] GTPC.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPC"); } |
| 2165 | [] GTPU.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPU"); } |
| 2166 | } |
| 2167 | |
| 2168 | /* Let's close them now: */ |
| 2169 | next_req_ctx := 0; |
| 2170 | rx_resp_ctx := 0; |
| 2171 | T_next.start; |
| 2172 | alt { |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 2173 | [Gx_PROC.checkstate("Connected")] as_DIA_Gx_CCR(TERMINATION_REQUEST) { repeat; } |
Pau Espin Pedrol | cb1e827 | 2022-04-20 14:43:43 +0200 | [diff] [blame] | 2174 | [Gy_PROC.checkstate("Connected")] as_DIA_Gy_CCR(TERMINATION_REQUEST) { repeat; } |
Pau Espin Pedrol | bfea835 | 2022-02-28 12:11:26 +0100 | [diff] [blame] | 2175 | [] pingpong(); |
| 2176 | [] T_next.timeout { |
| 2177 | f_send_gtpc(ts_GTPC_DeletePDP(g_peer_c, g_c_seq_nr, teic_list[next_req_ctx], '0001'B, '1'B)); |
| 2178 | next_req_ctx := next_req_ctx + 1; |
| 2179 | if (next_req_ctx < num_ctx) { |
| 2180 | T_next.start; |
| 2181 | } |
| 2182 | repeat; |
| 2183 | } |
| 2184 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextResponse, ?)) -> value udc { |
| 2185 | teic := oct2int(udc.gtpc.teid); |
| 2186 | if (not match(teic, (1 .. num_ctx))) { |
| 2187 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2188 | "Rx Unexpected TEIC"); |
| 2189 | } |
| 2190 | rx_resp_ctx := rx_resp_ctx + 1; |
| 2191 | if (rx_resp_ctx < num_ctx) { |
| 2192 | repeat; |
| 2193 | } |
| 2194 | setverdict(pass); |
| 2195 | } |
| 2196 | [] GTPC.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPC"); } |
| 2197 | [] GTPU.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPU"); } |
| 2198 | } |
| 2199 | T_next.stop; |
| 2200 | |
| 2201 | T_default.stop; |
Pau Espin Pedrol | c441ce0 | 2022-03-07 14:35:45 +0100 | [diff] [blame] | 2202 | f_shutdown_helper(); |
Pau Espin Pedrol | bfea835 | 2022-02-28 12:11:26 +0100 | [diff] [blame] | 2203 | } |
| 2204 | |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 2205 | /* Test charging over Gy interface. */ |
| 2206 | testcase TC_gy_charging_cc_time() runs on GT_CT { |
| 2207 | var default d; |
| 2208 | |
| 2209 | g_gy_validity_time := 3; /* Grant access for 3 seconds, needs to be re-validated afterwards */ |
| 2210 | f_init(); |
Pau Espin Pedrol | 2fe8895 | 2022-05-03 14:56:15 +0200 | [diff] [blame] | 2211 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234567890'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 2212 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
| 2213 | f_pdp_ctx_act(ctx); |
| 2214 | |
| 2215 | var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O); |
| 2216 | |
| 2217 | /* Send some UL traffic: */ |
| 2218 | var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4.ipv4_address; |
| 2219 | f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr)); |
| 2220 | f_wait_icmp4_echo_reply(ctx); |
| 2221 | |
| 2222 | T_default.start(10.0); |
| 2223 | d := activate(pingpong()); |
| 2224 | |
| 2225 | g_gy_validity_time := 2; |
| 2226 | /* First update reports octests/pkt on both UL/DL (see icmp ping-pong above) */ |
| 2227 | as_DIA_Gy_CCR(UPDATE_REQUEST); |
| 2228 | |
| 2229 | /* Second update: 0 ul/dl pkt/octet should be reported, since nothing was sent */ |
| 2230 | as_DIA_Gy_CCR(UPDATE_REQUEST); |
| 2231 | |
| 2232 | /* Third update: make sure report contains again octets/pkts for both UL/DL: */ |
| 2233 | f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr)); |
| 2234 | f_wait_icmp4_echo_reply(ctx); |
| 2235 | f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr)); |
| 2236 | f_wait_icmp4_echo_reply(ctx); |
| 2237 | as_DIA_Gy_CCR(UPDATE_REQUEST); |
| 2238 | |
| 2239 | /* Let the CCA reach the GGSN */ |
| 2240 | f_sleep(0.5); |
| 2241 | deactivate(d); |
| 2242 | T_default.stop; |
| 2243 | |
| 2244 | /* Send some data and validate it is reported in the TERMINATION_REQUEST |
| 2245 | * (triggered by PFCP Session Deletion Response): */ |
| 2246 | f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr)); |
| 2247 | f_wait_icmp4_echo_reply(ctx); |
| 2248 | |
| 2249 | f_pdp_ctx_del(ctx, '1'B); |
| 2250 | |
| 2251 | |
| 2252 | f_shutdown_helper(); |
| 2253 | } |
| 2254 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 2255 | control { |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 2256 | execute(TC_pdp4_act_deact()); |
| 2257 | execute(TC_pdp4_act_deact_ipcp()); |
Harald Welte | f829854 | 2019-04-10 10:15:28 +0200 | [diff] [blame] | 2258 | execute(TC_pdp4_act_deact_ipcp_pap_broken()); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 2259 | execute(TC_pdp4_act_deact_pcodns()); |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 2260 | execute(TC_pdp4_act_deact_gtpu_access()); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 2261 | execute(TC_pdp4_act_deact_gtpu_access_wrong_saddr()); |
| 2262 | execute(TC_pdp4_act_deact_gtpu_access_ipv6_apn4()); |
Stefan Sperling | c479e4f | 2018-04-03 19:34:16 +0200 | [diff] [blame] | 2263 | execute(TC_pdp4_clients_interact_with_txseq()); |
| 2264 | execute(TC_pdp4_clients_interact_without_txseq()); |
Philipp Maier | 33e5261 | 2018-05-30 17:22:02 +0200 | [diff] [blame] | 2265 | execute(TC_pdp4_act_deact_with_single_dns()); |
| 2266 | execute(TC_pdp4_act_deact_with_separate_dns()); |
Pau Espin Pedrol | cd326c5 | 2022-02-14 18:57:43 +0100 | [diff] [blame] | 2267 | execute(TC_pdp4_act_update_teic()); |
| 2268 | execute(TC_pdp4_act_update_teid()); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 2269 | |
| 2270 | execute(TC_pdp6_act_deact()); |
| 2271 | execute(TC_pdp6_act_deact_pcodns()); |
| 2272 | execute(TC_pdp6_act_deact_icmp6()); |
Pau Espin Pedrol | 3d9338f | 2018-01-29 20:42:54 +0100 | [diff] [blame] | 2273 | execute(TC_pdp6_act_deact_gtpu_access()); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 2274 | execute(TC_pdp6_act_deact_gtpu_access_wrong_ll_saddr()); |
| 2275 | execute(TC_pdp6_act_deact_gtpu_access_wrong_global_saddr()); |
| 2276 | execute(TC_pdp6_act_deact_gtpu_access_ipv4_apn6()); |
Pau Espin Pedrol | 6c7285d | 2018-01-30 17:20:22 +0100 | [diff] [blame] | 2277 | execute(TC_pdp6_clients_interact()); |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 2278 | |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 2279 | execute(TC_pdp46_act_deact()); |
| 2280 | execute(TC_pdp46_act_deact_ipcp()); |
| 2281 | execute(TC_pdp46_act_deact_icmp6()); |
| 2282 | execute(TC_pdp46_act_deact_pcodns4()); |
| 2283 | execute(TC_pdp46_act_deact_pcodns6()); |
| 2284 | execute(TC_pdp46_act_deact_gtpu_access()); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 2285 | execute(TC_pdp46_act_deact_gtpu_access_wrong_saddr_ipv4()); |
Pau Espin Pedrol | c6ac695 | 2022-02-14 11:19:23 +0100 | [diff] [blame] | 2286 | execute(TC_pdp46_act_deact_gtpu_access_wrong_ll_saddr_ipv6()); |
Pau Espin Pedrol | c8c0341 | 2022-02-11 13:39:26 +0100 | [diff] [blame] | 2287 | execute(TC_pdp46_act_deact_gtpu_access_wrong_global_saddr_ipv6()); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 2288 | execute(TC_pdp46_clients_interact()); |
Pau Espin Pedrol | 22d597f | 2019-08-21 16:16:58 +0200 | [diff] [blame] | 2289 | execute(TC_pdp46_act_deact_apn4()); |
Oliver Smith | ee6a088 | 2019-03-08 11:05:46 +0100 | [diff] [blame] | 2290 | |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 2291 | execute(TC_echo_req_resp()); |
Pau Espin Pedrol | 480e67f | 2022-02-09 16:37:47 +0100 | [diff] [blame] | 2292 | execute(TC_echo_req_resp_gtpu()); |
Pau Espin Pedrol | fa1ca02 | 2019-08-23 18:58:53 +0200 | [diff] [blame] | 2293 | execute(TC_pdp_act2_recovery()); |
Pau Espin Pedrol | 9a5f42f | 2019-05-27 20:04:35 +0200 | [diff] [blame] | 2294 | execute(TC_act_deact_retrans_duplicate()); |
Pau Espin Pedrol | 6916ec4 | 2019-08-23 16:15:07 +0200 | [diff] [blame] | 2295 | |
Pau Espin Pedrol | 6f319f9 | 2020-01-03 20:18:57 +0100 | [diff] [blame] | 2296 | execute(TC_pdp_act_restart_ctr_echo()); |
Pau Espin Pedrol | 68c2af5 | 2022-02-25 11:56:17 +0100 | [diff] [blame] | 2297 | |
| 2298 | execute(TC_lots_of_concurrent_pdp_ctx()); |
Pau Espin Pedrol | bfea835 | 2022-02-28 12:11:26 +0100 | [diff] [blame] | 2299 | /* Keep at the end, crashes older osmo-ggsn versions (OS#5469): */ |
| 2300 | execute(TC_addr_pool_exhaustion()); |
Pau Espin Pedrol | 77fdd0b | 2022-03-08 14:03:33 +0100 | [diff] [blame] | 2301 | |
| 2302 | /* open5gs specific tests: */ |
| 2303 | if (m_ggsn_impl == GGSN_IMPL_OPEN5GS) { |
| 2304 | execute(TC_gy_charging_cc_time()); |
| 2305 | } |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 2306 | } |
Harald Welte | 379d45a | 2017-08-03 09:55:15 +0200 | [diff] [blame] | 2307 | } |