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