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