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