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