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