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