diff --git a/config/mbed/chip-gn/args.gni b/config/mbed/chip-gn/args.gni index 6277f2a765cb92..b458740c9512b5 100644 --- a/config/mbed/chip-gn/args.gni +++ b/config/mbed/chip-gn/args.gni @@ -20,7 +20,6 @@ chip_project_config_include = "" chip_system_project_config_include = "" chip_device_project_config_include = "" -chip_inet_config_enable_raw_endpoint = false chip_inet_config_enable_udp_endpoint = true chip_inet_config_enable_tcp_endpoint = true chip_inet_config_enable_dns_resolver = true diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt index fb308760159415..87a54154e22c1d 100644 --- a/config/nrfconnect/chip-module/CMakeLists.txt +++ b/config/nrfconnect/chip-module/CMakeLists.txt @@ -198,7 +198,6 @@ chip_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_NET_IPV4) chip_gn_arg_bool ("chip_enable_nfc" CONFIG_CHIP_NFC_COMMISSIONING) chip_gn_arg_bool ("chip_build_tests" CONFIG_CHIP_BUILD_TESTS) chip_gn_arg_bool ("chip_monolithic_tests" CONFIG_CHIP_BUILD_TESTS) -chip_gn_arg_bool ("chip_inet_config_enable_raw_endpoint" CONFIG_CHIP_BUILD_TESTS) chip_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS) chip_gn_arg_bool ("chip_inet_config_enable_dns_resolver" CONFIG_CHIP_BUILD_TESTS) chip_gn_arg_bool ("chip_build_libshell" CONFIG_CHIP_LIB_SHELL) diff --git a/config/standalone/args.gni b/config/standalone/args.gni index 594158f7acfb29..40caf42ee37b50 100644 --- a/config/standalone/args.gni +++ b/config/standalone/args.gni @@ -15,5 +15,4 @@ # Options from standalone-chip.mk that differ from configure defaults. These # options are used from examples/. chip_build_tests = false -chip_inet_config_enable_raw_endpoint = false chip_inet_config_enable_dns_resolver = false diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index 3e91af6b4145c8..9afb00b6269e83 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -196,7 +196,6 @@ chip_gn_arg_bool ("is_debug" CONFIG_DEBUG) chip_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD) chip_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_NET_IPV4) chip_gn_arg_bool ("chip_build_tests" CONFIG_CHIP_BUILD_TESTS) -chip_gn_arg_bool ("chip_inet_config_enable_raw_endpoint" CONFIG_CHIP_BUILD_TESTS) chip_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS) chip_gn_arg_bool ("chip_inet_config_enable_dns_resolver" CONFIG_CHIP_BUILD_TESTS) chip_gn_arg_bool ("chip_build_libshell" CONFIG_CHIP_LIB_SHELL) diff --git a/examples/platform/k32w/app/args.gni b/examples/platform/k32w/app/args.gni index 19b7d20a1cf122..5728bf319f542a 100644 --- a/examples/platform/k32w/app/args.gni +++ b/examples/platform/k32w/app/args.gni @@ -28,5 +28,4 @@ chip_inet_project_config_include = "" chip_system_project_config_include = "" chip_system_config_provide_statistics = false -chip_inet_config_enable_raw_endpoint = false chip_with_nlfaultinjection = true diff --git a/examples/platform/k32w/args.gni b/examples/platform/k32w/args.gni index 79a0f50c3f926e..26465096ca5d97 100644 --- a/examples/platform/k32w/args.gni +++ b/examples/platform/k32w/args.gni @@ -30,5 +30,4 @@ chip_inet_project_config_include = "" chip_system_project_config_include = "" chip_system_config_provide_statistics = false -chip_inet_config_enable_raw_endpoint = false chip_with_nlfaultinjection = true diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index 811ac5d5c5fb96..f432dc48c4ec52 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -38,7 +38,6 @@ buildconfig_header("inet_buildconfig") { "INET_CONFIG_ENABLE_IPV4=${chip_inet_config_enable_ipv4}", "INET_CONFIG_ENABLE_DNS_RESOLVER=${chip_inet_config_enable_dns_resolver}", "INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS=${chip_inet_config_enable_async_dns_sockets}", - "INET_CONFIG_ENABLE_RAW_ENDPOINT=${chip_inet_config_enable_raw_endpoint}", "INET_CONFIG_ENABLE_TCP_ENDPOINT=${chip_inet_config_enable_tcp_endpoint}", "INET_CONFIG_ENABLE_UDP_ENDPOINT=${chip_inet_config_enable_udp_endpoint}", "HAVE_LWIP_RAW_BIND_NETIF=true", @@ -107,13 +106,6 @@ static_library("inet") { public_deps += [ "${chip_root}/src/lwip" ] } - if (chip_inet_config_enable_raw_endpoint) { - sources += [ - "RawEndPoint.cpp", - "RawEndPoint.h", - ] - } - if (chip_inet_config_enable_tcp_endpoint) { sources += [ "TCPEndPoint.cpp", diff --git a/src/inet/EndPointBasis.h b/src/inet/EndPointBasis.h index 0f8a4148bd344d..31ed82ca41d2d9 100644 --- a/src/inet/EndPointBasis.h +++ b/src/inet/EndPointBasis.h @@ -44,9 +44,6 @@ //--- Declaration of LWIP protocol control buffer structure names #if CHIP_SYSTEM_CONFIG_USE_LWIP -#if INET_CONFIG_ENABLE_RAW_ENDPOINT -struct raw_pcb; -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT #if INET_CONFIG_ENABLE_UDP_ENDPOINT struct udp_pcb; #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT @@ -107,9 +104,6 @@ class DLL_EXPORT EndPointBasis : public InetLayerBasis union { const void * mVoid; /**< An untyped protocol control buffer reference */ -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - raw_pcb * mRaw; /**< Raw network interface protocol control */ -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT #if INET_CONFIG_ENABLE_UDP_ENDPOINT udp_pcb * mUDP; /**< User datagram protocol (UDP) control */ #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT diff --git a/src/inet/IPEndPointBasis.cpp b/src/inet/IPEndPointBasis.cpp index 7ebecf1c1f2b13..fdb47db8976ef7 100644 --- a/src/inet/IPEndPointBasis.cpp +++ b/src/inet/IPEndPointBasis.cpp @@ -344,12 +344,6 @@ CHIP_ERROR IPEndPointBasis::SetMulticastLoopback(IPVersion aIPVersion, bool aLoo switch (mLwIPEndPointType) { -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - case kLwIPEndPointType_Raw: - raw_set_flags(mRaw, RAW_FLAGS_MULTICAST_LOOP); - break; -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - #if INET_CONFIG_ENABLE_UDP_ENDPOINT case kLwIPEndPointType_UDP: udp_set_flags(mUDP, UDP_FLAGS_MULTICAST_LOOP); @@ -366,12 +360,6 @@ CHIP_ERROR IPEndPointBasis::SetMulticastLoopback(IPVersion aIPVersion, bool aLoo switch (mLwIPEndPointType) { -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - case kLwIPEndPointType_Raw: - raw_clear_flags(mRaw, RAW_FLAGS_MULTICAST_LOOP); - break; -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - #if INET_CONFIG_ENABLE_UDP_ENDPOINT case kLwIPEndPointType_UDP: udp_clear_flags(mUDP, UDP_FLAGS_MULTICAST_LOOP); diff --git a/src/inet/Inet.h b/src/inet/Inet.h index 84566fd0c91ce1..60eae475acf536 100644 --- a/src/inet/Inet.h +++ b/src/inet/Inet.h @@ -38,10 +38,6 @@ #include #endif // INET_CONFIG_ENABLE_DNS_RESOLVER -#if INET_CONFIG_ENABLE_RAW_ENDPOINT -#include -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - #if INET_CONFIG_ENABLE_TCP_ENDPOINT #include #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT diff --git a/src/inet/InetConfig.h b/src/inet/InetConfig.h index 00fdcdbad94299..32f0a132480f35 100644 --- a/src/inet/InetConfig.h +++ b/src/inet/InetConfig.h @@ -153,21 +153,6 @@ #define INET_CONFIG_MAX_DROPPABLE_EVENTS 0 #endif // INET_CONFIG_MAX_DROPPABLE_EVENTS -/** - * @def INET_CONFIG_NUM_RAW_ENDPOINTS - * - * @brief - * This is the total number of "raw" (direct-IP, non-TCP/-UDP) end - * point context structures. - * - * Up to this many outstanding "raw" communication flows may be in - * use. - * - */ -#ifndef INET_CONFIG_NUM_RAW_ENDPOINTS -#define INET_CONFIG_NUM_RAW_ENDPOINTS 8 -#endif // INET_CONFIG_NUM_RAW_ENDPOINTS - /** * @def INET_CONFIG_NUM_TCP_ENDPOINTS * @@ -246,18 +231,6 @@ #define INET_CONFIG_ENABLE_DNS_RESOLVER 0 #endif // INET_CONFIG_ENABLE_DNS_RESOLVER -/** - * @def INET_CONFIG_ENABLE_RAW_ENDPOINT - * - * @brief - * Defines whether (1) or not (0) to enable the ability - * to instantiate a Raw endpoint. - * - */ -#ifndef INET_CONFIG_ENABLE_RAW_ENDPOINT -#define INET_CONFIG_ENABLE_RAW_ENDPOINT 0 -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - /** * @def INET_CONFIG_ENABLE_TCP_ENDPOINT * diff --git a/src/inet/InetLayer.cpp b/src/inet/InetLayer.cpp index a449372b4ea23d..0f3c1980aefac5 100644 --- a/src/inet/InetLayer.cpp +++ b/src/inet/InetLayer.cpp @@ -93,10 +93,6 @@ void InetLayer::UpdateSnapshot(chip::System::Stats::Snapshot & aSnapshot) UDPEndPoint::sPool.GetStatistics(aSnapshot.mResourcesInUse[chip::System::Stats::kInetLayer_NumUDPEps], aSnapshot.mHighWatermarks[chip::System::Stats::kInetLayer_NumUDPEps]); #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - RawEndPoint::sPool.GetStatistics(aSnapshot.mResourcesInUse[chip::System::Stats::kInetLayer_NumRawEps], - aSnapshot.mHighWatermarks[chip::System::Stats::kInetLayer_NumRawEps]); -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT } /** @@ -332,17 +328,6 @@ CHIP_ERROR InetLayer::Shutdown() #endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS && INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS #endif // INET_CONFIG_ENABLE_DNS_RESOLVER -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - // Close all raw endpoints owned by this Inet layer instance. - RawEndPoint::sPool.ForEachActiveObject([&](RawEndPoint * lEndPoint) { - if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this)) - { - lEndPoint->Close(); - } - return true; - }); -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - #if INET_CONFIG_ENABLE_TCP_ENDPOINT // Abort all TCP endpoints owned by this instance. TCPEndPoint::sPool.ForEachActiveObject([&](TCPEndPoint * lEndPoint) { @@ -502,50 +487,6 @@ CHIP_ERROR InetLayer::GetLinkLocalAddr(InterfaceId link, IPAddress * llAddr) return CHIP_NO_ERROR; } -#if INET_CONFIG_ENABLE_RAW_ENDPOINT -/** - * Creates a new RawEndPoint object for a specific IP version and protocol. - * - * @note - * This function gets a free RawEndPoint object from a pre-allocated pool - * and also calls the explicit initializer on the new object. - * - * @param[in] ipVer IPv4 or IPv6. - * - * @param[in] ipProto A protocol within the IP family (e.g., ICMPv4 or ICMPv6). - * - * @param[in,out] retEndPoint A pointer to a pointer of the RawEndPoint object that is - * a return parameter upon completion of the object creation. - * *retEndPoint is NULL if creation fails. - * - * @retval #CHIP_ERROR_INCORRECT_STATE If the InetLayer object is not initialized. - * @retval #CHIP_ERROR_ENDPOINT_POOL_FULL If the InetLayer RawEndPoint pool is full and no new - * endpoints can be created. - * @retval #CHIP_NO_ERROR On success. - * - */ -CHIP_ERROR InetLayer::NewRawEndPoint(IPVersion ipVer, IPProtocol ipProto, RawEndPoint ** retEndPoint) -{ - assertChipStackLockedByCurrentThread(); - - *retEndPoint = nullptr; - - VerifyOrReturnError(State == kState_Initialized, CHIP_ERROR_INCORRECT_STATE); - - *retEndPoint = RawEndPoint::sPool.TryCreate(); - if (*retEndPoint == nullptr) - { - ChipLogError(Inet, "%s endpoint pool FULL", "Raw"); - return CHIP_ERROR_ENDPOINT_POOL_FULL; - } - - (*retEndPoint)->Inet::RawEndPoint::Init(this, ipVer, ipProto); - SYSTEM_STATS_INCREMENT(chip::System::Stats::kInetLayer_NumRawEps); - - return CHIP_NO_ERROR; -} -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - #if INET_CONFIG_ENABLE_TCP_ENDPOINT /** * Creates a new TCPEndPoint object. @@ -1035,13 +976,6 @@ CHIP_ERROR InetLayer::HandleInetLayerEvent(chip::System::Object & aTarget, chip: break; #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - case kInetEvent_RawDataReceived: - static_cast(aTarget).HandleDataReceived( - System::PacketBufferHandle::Adopt(reinterpret_cast(aArgument))); - break; -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - #if INET_CONFIG_ENABLE_UDP_ENDPOINT case kInetEvent_UDPDataReceived: static_cast(aTarget).HandleDataReceived( diff --git a/src/inet/InetLayer.h b/src/inet/InetLayer.h index 1e39068eeaf34e..35f6adf00dd644 100644 --- a/src/inet/InetLayer.h +++ b/src/inet/InetLayer.h @@ -61,10 +61,6 @@ #include #endif // INET_CONFIG_ENABLE_DNS_RESOLVER -#if INET_CONFIG_ENABLE_RAW_ENDPOINT -#include -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - #if INET_CONFIG_ENABLE_TCP_ENDPOINT #include #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT @@ -149,10 +145,6 @@ class DLL_EXPORT InetLayer friend class DNSResolver; #endif // INET_CONFIG_ENABLE_DNS_RESOLVER -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - friend class RawEndPoint; -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - #if INET_CONFIG_ENABLE_TCP_ENDPOINT friend class TCPEndPoint; #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT @@ -189,10 +181,6 @@ class DLL_EXPORT InetLayer // End Points -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - CHIP_ERROR NewRawEndPoint(IPVersion ipVer, IPProtocol ipProto, RawEndPoint ** retEndPoint); -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - #if INET_CONFIG_ENABLE_TCP_ENDPOINT CHIP_ERROR NewTCPEndPoint(TCPEndPoint ** retEndPoint); #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT @@ -253,9 +241,6 @@ class DLL_EXPORT InetLayer #if INET_CONFIG_ENABLE_UDP_ENDPOINT type == kInetEvent_UDPDataReceived || #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - type == kInetEvent_RawDataReceived || -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT false; } diff --git a/src/inet/RawEndPoint.cpp b/src/inet/RawEndPoint.cpp deleted file mode 100644 index 69863b34de910e..00000000000000 --- a/src/inet/RawEndPoint.cpp +++ /dev/null @@ -1,1044 +0,0 @@ -/* - * - * Copyright (c) 2020-2021 Project CHIP Authors - * Copyright (c) 2018 Google LLC. - * Copyright (c) 2013-2018 Nest Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * This file implements the Inet::RawEndPoint class, - * where the CHIP Inet Layer encapsulates methods for interacting - * interacting with IP network endpoints (SOCK_RAW sockets - * on Linux and BSD-derived systems) or LwIP raw protocol - * control blocks, as the system is configured accordingly. - * - */ - -#define __APPLE_USE_RFC_3542 - -#include "RawEndPoint.h" - -#include "InetFaultInjection.h" -#include - -#include -#include -#include - -#if CHIP_SYSTEM_CONFIG_USE_LWIP -#include -#include -#include -#if CHIP_HAVE_CONFIG_H -#include // nogncheck -#endif // CHIP_HAVE_CONFIG_H -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS -#if HAVE_SYS_SOCKET_H -#include -#endif // HAVE_SYS_SOCKET_H -#include -#include -#include -#include -#if HAVE_NETINET_ICMP6_H -#include -#endif // HAVE_NETINET_ICMP6_H -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - -// SOCK_CLOEXEC not defined on all platforms, e.g. iOS/macOS: -#ifdef SOCK_CLOEXEC -#define SOCK_FLAGS SOCK_CLOEXEC -#else -#define SOCK_FLAGS 0 -#endif - -#include -#include - -namespace chip { -namespace Inet { - -chip::System::ObjectPool RawEndPoint::sPool; - -#if CHIP_SYSTEM_CONFIG_USE_LWIP -/* - * Note that for LwIP InterfaceId is already defined to be 'struct - * netif'; consequently, some of the checking performed here could - * conceivably be optimized out and the HAVE_LWIP_UDP_BIND_NETIF case - * could simply be: - * - * udp_bind_netif(aUDP, intfId); - * - */ -static CHIP_ERROR LwIPBindInterface(struct raw_pcb * aRaw, InterfaceId intfId) -{ - CHIP_ERROR res = CHIP_NO_ERROR; - -#if HAVE_LWIP_RAW_BIND_NETIF - if (!IsInterfaceIdPresent(intfId)) - raw_bind_netif(aRaw, NULL); - else - { - struct netif * netifp = IPEndPointBasis::FindNetifFromInterfaceId(intfId); - - if (netifp == NULL) - res = INET_ERROR_UNKNOWN_INTERFACE; - else - raw_bind_netif(aRaw, netifp); - } -#else - if (!IsInterfaceIdPresent(intfId)) - aRaw->intf_filter = NULL; - else - { - struct netif * netifp = IPEndPointBasis::FindNetifFromInterfaceId(intfId); - - if (netifp == NULL) - res = INET_ERROR_UNKNOWN_INTERFACE; - else - aRaw->intf_filter = netifp; - } -#endif // HAVE_LWIP_RAW_BIND_NETIF - - return res; -} -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -/** - * @brief Bind the endpoint to an interface IP address. - * - * @param[in] addrType the protocol version of the IP address - * @param[in] addr the IP address (must be an interface address) - * @param[in] intfId an optional network interface indicator - * - * @retval CHIP_NO_ERROR success: endpoint bound to address - * @retval CHIP_ERROR_INCORRECT_STATE endpoint has been bound previously - * @retval CHIP_ERROR_NO_MEMORY insufficient memory for endpoint - * - * @retval INET_ERROR_UNKNOWN_INTERFACE - * On some platforms, the optionally specified interface is not - * present. - * - * @retval INET_ERROR_WRONG_PROTOCOL_TYPE - * \c addrType does not match \c IPVer. - * - * @retval INET_ERROR_WRONG_ADDRESS_TYPE - * \c addrType is \c kIPAddressType_Any, or the type of \c addr is not - * equal to \c addrType. - * - * @retval other another system or platform error - * - * @details - * Binds the endpoint to the specified network interface IP address. - * - * On LwIP, this method must not be called with the LwIP stack lock - * already acquired. - */ -CHIP_ERROR RawEndPoint::Bind(IPAddressType addrType, const IPAddress & addr, InterfaceId intfId) -{ - if (mState != kState_Ready && mState != kState_Bound) - { - return CHIP_ERROR_INCORRECT_STATE; - } - - if ((addr != IPAddress::Any) && (addr.Type() != kIPAddressType_Any) && (addr.Type() != addrType)) - { - return INET_ERROR_WRONG_ADDRESS_TYPE; - } - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - - // Lock LwIP stack - LOCK_TCPIP_CORE(); - - // Make sure we have the appropriate type of PCB. - CHIP_ERROR res = GetPCB(addrType); - - // Bind the PCB to the specified address. - if (res == CHIP_NO_ERROR) - { -#if LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 - ip_addr_t ipAddr = addr.ToLwIPAddr(); -#if INET_CONFIG_ENABLE_IPV4 - lwip_ip_addr_type lType = IPAddress::ToLwIPAddrType(addrType); - IP_SET_TYPE_VAL(ipAddr, lType); -#endif // INET_CONFIG_ENABLE_IPV4 - res = chip::System::MapErrorLwIP(raw_bind(mRaw, &ipAddr)); -#else // LWIP_VERSION_MAJOR <= 1 && LWIP_VERSION_MINOR < 5 - if (addrType == kIPAddressType_IPv6) - { - ip6_addr_t ipv6Addr = addr.ToIPv6(); - res = chip::System::MapErrorLwIP(raw_bind_ip6(mRaw, &ipv6Addr)); - } -#if INET_CONFIG_ENABLE_IPV4 - else if (addrType == kIPAddressType_IPv4) - { - ip4_addr_t ipv4Addr = addr.ToIPv4(); - res = chip::System::MapErrorLwIP(raw_bind(mRaw, &ipv4Addr)); - } -#endif // INET_CONFIG_ENABLE_IPV4 - else - res = INET_ERROR_WRONG_ADDRESS_TYPE; -#endif // LWIP_VERSION_MAJOR <= 1 || LWIP_VERSION_MINOR >= 5 - } - - if (res == CHIP_NO_ERROR) - { - res = LwIPBindInterface(mRaw, intfId); - } - - // Unlock LwIP stack - UNLOCK_TCPIP_CORE(); - - ReturnErrorOnFailure(res); - -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - // Make sure we have the appropriate type of socket. - ReturnErrorOnFailure(GetSocket(addrType)); - ReturnErrorOnFailure(IPEndPointBasis::Bind(addrType, addr, 0, intfId)); - -#if CHIP_SYSTEM_CONFIG_USE_DISPATCH - dispatch_queue_t dispatchQueue = static_cast(Layer().SystemLayer())->GetDispatchQueue(); - if (dispatchQueue != nullptr) - { - unsigned long fd = static_cast(mSocket); - - mReadableSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, fd, 0, dispatchQueue); - ReturnErrorCodeIf(mReadableSource == nullptr, CHIP_ERROR_NO_MEMORY); - - dispatch_source_set_event_handler(mReadableSource, ^{ - this->HandlePendingIO(System::SocketEventFlags::kRead); - }); - - dispatch_resume(mReadableSource); - } -#endif // CHIP_SYSTEM_CONFIG_USE_DISPATCH - - mBoundIntfId = intfId; -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - mState = kState_Bound; - - return CHIP_NO_ERROR; -} - -/** - * Bind the raw endpoint to an IPv6 link-local scope address at the specified - * interface index. Also sets various IPv6 socket options appropriate for - * transmitting packets to and from on-link destinations. - * - * @param[in] intfId An InterfaceId to identify the scope of the address. - * @param[in] addr An IPv6 link-local scope IPAddress object. - * - * @retval CHIP_NO_ERROR success: endpoint bound to address - * @retval CHIP_ERROR_INCORRECT_STATE endpoint has been bound previously - * @retval CHIP_ERROR_NO_MEMORY insufficient memory for endpoint - * - * @retval INET_ERROR_WRONG_PROTOCOL_TYPE - * \c addrType does not match \c IPVer. - * - * @retval INET_ERROR_WRONG_ADDRESS_TYPE - * \c addr is not an IPv6 link-local address or \c intfId is - * \c INET_NULL_INTERFACEID. - * - * @retval other another system or platform error - * - * @details - * Binds the endpoint to the IPv6 link-local address \c addr on the - * network interface indicated by \c intfId. - * - * On LwIP, this method must not be called with the LwIP stack lock - * already acquired. - */ -CHIP_ERROR RawEndPoint::BindIPv6LinkLocal(InterfaceId intfId, const IPAddress & addr) -{ - CHIP_ERROR res = CHIP_NO_ERROR; - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - const int lIfIndex = static_cast(intfId); -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - if (mState != kState_Ready && mState != kState_Bound) - { - res = CHIP_ERROR_INCORRECT_STATE; - goto ret; - } - - if (!addr.IsIPv6LinkLocal()) - { - res = INET_ERROR_WRONG_ADDRESS_TYPE; - goto ret; - } - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - - // Lock LwIP stack - LOCK_TCPIP_CORE(); - - // Make sure we have the appropriate type of PCB. - res = GetPCB(addr.Type()); - - // Bind the PCB to the specified address. - if (res == CHIP_NO_ERROR) - { -#if LWIP_VERSION_MAJOR > 1 - ip_addr_t ipAddr = addr.ToLwIPAddr(); - res = chip::System::MapErrorLwIP(raw_bind(mRaw, &ipAddr)); -#else // LWIP_VERSION_MAJOR <= 1 - ip6_addr_t ipv6Addr = addr.ToIPv6(); - res = chip::System::MapErrorLwIP(raw_bind_ip6(mRaw, &ipv6Addr)); -#endif // LWIP_VERSION_MAJOR <= 1 - - if (res != CHIP_NO_ERROR) - { - raw_remove(mRaw); - mRaw = NULL; - mLwIPEndPointType = kLwIPEndPointType_Unknown; - } - } - - // Unlock LwIP stack - UNLOCK_TCPIP_CORE(); - -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - - static const int sInt255 = 255; - - // Make sure we have the appropriate type of socket. - res = GetSocket(kIPAddressType_IPv6); - if (res != CHIP_NO_ERROR) - { - goto ret; - } - - if (::setsockopt(mSocket, IPPROTO_IPV6, IPV6_MULTICAST_IF, &lIfIndex, sizeof(lIfIndex)) != 0) - { - goto optfail; - } - - if (::setsockopt(mSocket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &sInt255, sizeof(sInt255)) != 0) - { - goto optfail; - } - - if (::setsockopt(mSocket, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &sInt255, sizeof(sInt255)) != 0) - { - goto optfail; - } - - mAddrType = kIPAddressType_IPv6; - goto ret; - -optfail: - res = chip::System::MapErrorPOSIX(errno); - static_cast(Layer().SystemLayer())->StopWatchingSocket(&mWatch); - close(mSocket); - mSocket = INET_INVALID_SOCKET_FD; - mAddrType = kIPAddressType_Unknown; - -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - -ret: - if (res == CHIP_NO_ERROR) - { - mState = kState_Bound; - } - - return res; -} - -/** - * @brief Prepare the endpoint to receive ICMP messages. - * - * @param[in] onMessageReceived The endpoint's message reception event handling function delegate. - * @param[in] onReceiveError The endpoint's receive error event handling function delegate. - * @param[in] appState Application state pointer. - * - * @retval CHIP_NO_ERROR always returned. - * - * @details - * If \c mState is already \c kState_Listening, then no operation is - * performed, otherwise the \c mState is set to \c kState_Listening and - * the endpoint is prepared to received ICMPv6 messages, according to the - * semantics of the platform. - * - * On LwIP, this method must not be called with the LwIP stack lock - * already acquired - */ -CHIP_ERROR RawEndPoint::Listen(IPEndPointBasis::OnMessageReceivedFunct onMessageReceived, - IPEndPointBasis::OnReceiveErrorFunct onReceiveError, void * appState) -{ - if (mState == kState_Listening) - { - return CHIP_NO_ERROR; - } - - if (mState != kState_Bound) - { - return CHIP_ERROR_INCORRECT_STATE; - } - - OnMessageReceived = onMessageReceived; - OnReceiveError = onReceiveError; - AppState = appState; - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - - // Lock LwIP stack - LOCK_TCPIP_CORE(); - -#if LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 - raw_recv(mRaw, LwIPReceiveRawMessage, this); -#else // LWIP_VERSION_MAJOR <= 1 && LWIP_VERSION_MINOR < 5 - if (PCB_ISIPV6(mRaw)) - raw_recv_ip6(mRaw, LwIPReceiveRawMessage, this); - else - raw_recv(mRaw, LwIPReceiveRawMessage, this); -#endif // LWIP_VERSION_MAJOR <= 1 || LWIP_VERSION_MINOR >= 5 - - // Unlock LwIP stack - UNLOCK_TCPIP_CORE(); - -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - - mState = kState_Listening; - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - // Wait for ability to read on this endpoint. - auto layer = static_cast(Layer().SystemLayer()); - ReturnErrorOnFailure(layer->SetCallback(mWatch, HandlePendingIO, reinterpret_cast(this))); - ReturnErrorOnFailure(layer->RequestCallbackOnPendingRead(mWatch)); -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - return CHIP_NO_ERROR; -} - -/** - * @brief Close the endpoint. - * - * @details - * If mState != kState_Closed, then closes the endpoint, removing - * it from the set of endpoints eligible for communication events. - * - * On LwIP systems, this method must not be called with the LwIP stack - * lock already acquired. - */ -void RawEndPoint::Close() -{ - if (mState != kState_Closed) - { -#if CHIP_SYSTEM_CONFIG_USE_LWIP - - // Lock LwIP stack - LOCK_TCPIP_CORE(); - - // Since Raw PCB is released synchronously here, but Raw endpoint itself might have to wait - // for destruction asynchronously, there could be more allocated Raw endpoints than Raw PCBs. - if (mRaw != NULL) - { - raw_remove(mRaw); - mRaw = NULL; - mLwIPEndPointType = kLwIPEndPointType_Unknown; - } - - // Unlock LwIP stack - UNLOCK_TCPIP_CORE(); - -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - if (mSocket != INET_INVALID_SOCKET_FD) - { - static_cast(Layer().SystemLayer())->StopWatchingSocket(&mWatch); - close(mSocket); - mSocket = INET_INVALID_SOCKET_FD; - } - -#if CHIP_SYSTEM_CONFIG_USE_DISPATCH - if (mReadableSource) - { - dispatch_source_cancel(mReadableSource); - dispatch_release(mReadableSource); - } -#endif // CHIP_SYSTEM_CONFIG_USE_DISPATCH -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - mState = kState_Closed; - } -} - -/** - * @brief Close the endpoint and recycle its memory. - * - * @details - * Invokes the \c Close method, then invokes the - * InetLayerBasis::Release method to return the object to its - * memory pool. - * - * On LwIP systems, this method must not be called with the LwIP stack - * lock already acquired. - */ -void RawEndPoint::Free() -{ - Close(); - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - DeferredFree(kReleaseDeferralErrorTactic_Die); -#else // !CHIP_SYSTEM_CONFIG_USE_LWIP - Release(); -#endif // !CHIP_SYSTEM_CONFIG_USE_LWIP -} - -/** - * A synonym for SendTo(addr, INET_NULL_INTERFACEID, msg, - * sendFlags). - */ -CHIP_ERROR RawEndPoint::SendTo(const IPAddress & addr, chip::System::PacketBufferHandle && msg, uint16_t sendFlags) -{ - return SendTo(addr, INET_NULL_INTERFACEID, std::move(msg), sendFlags); -} - -/** - * @brief Send an ICMP message to the specified destination address. - * - * @param[in] addr the destination IP address - * @param[in] intfId an optional network interface indicator - * @param[in] msg the packet buffer containing the UDP message - * @param[in] sendFlags optional transmit option flags - * - * @retval CHIP_NO_ERROR - * success: \c msg is queued for transmit. - * - * @retval CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE - * the system does not support the requested operation. - * - * @retval INET_ERROR_WRONG_ADDRESS_TYPE - * the destination address and the bound interface address do not - * have matching protocol versions or address type. - * - * @retval CHIP_ERROR_MESSAGE_TOO_LONG - * \c msg does not contain the whole ICMP message. - * - * @retval CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG - * On some platforms, only a truncated portion of \c msg was queued - * for transmit. - * - * @retval other another system or platform error - * - * @details - * Send the ICMP message in \c msg to the destination given in \c addr. - */ -CHIP_ERROR RawEndPoint::SendTo(const IPAddress & addr, InterfaceId intfId, chip::System::PacketBufferHandle && msg, - uint16_t sendFlags) -{ - IPPacketInfo pktInfo; - pktInfo.Clear(); - pktInfo.DestAddress = addr; - pktInfo.Interface = intfId; - return SendMsg(&pktInfo, std::move(msg), sendFlags); -} - -/** - * @brief Send an ICMP message to the specified destination. - * - * @param[in] pktInfo destination information for the message - * @param[in] msg the packet buffer containing the UDP message - * @param[in] sendFlags optional transmit option flags - * - * @retval CHIP_NO_ERROR - * success: \c msg is queued for transmit. - * - * @retval CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE - * the system does not support the requested operation. - * - * @retval INET_ERROR_WRONG_ADDRESS_TYPE - * the destination address and the bound interface address do not - * have matching protocol versions or address type. - * - * @retval CHIP_ERROR_MESSAGE_TOO_LONG - * \c msg does not contain the whole ICMP message. - * - * @retval CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG - * On some platforms, only a truncated portion of \c msg was queued - * for transmit. - * - * @retval other another system or platform error - * - * @details - * Send the ICMP message \c msg using the destination information given in \c addr. - */ -CHIP_ERROR RawEndPoint::SendMsg(const IPPacketInfo * pktInfo, chip::System::PacketBufferHandle && msg, uint16_t sendFlags) -{ - CHIP_ERROR res = CHIP_NO_ERROR; - const IPAddress & addr = pktInfo->DestAddress; - - INET_FAULT_INJECT(FaultInjection::kFault_Send, return INET_ERROR_UNKNOWN_INTERFACE;); - INET_FAULT_INJECT(FaultInjection::kFault_SendNonCritical, return CHIP_ERROR_NO_MEMORY;); - - // Do not allow sending an IPv4 address on an IPv6 end point and - // vice versa. - - if (IPVer == kIPVersion_6 && addr.Type() != kIPAddressType_IPv6) - { - return INET_ERROR_WRONG_ADDRESS_TYPE; - } -#if INET_CONFIG_ENABLE_IPV4 - if (IPVer == kIPVersion_4 && addr.Type() != kIPAddressType_IPv4) - { - return INET_ERROR_WRONG_ADDRESS_TYPE; - } -#endif // INET_CONFIG_ENABLE_IPV4 - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - - // Lock LwIP stack - LOCK_TCPIP_CORE(); - - // Make sure we have the appropriate type of PCB based on the destination address. - res = GetPCB(addr.Type()); - SuccessOrExit(res); - - // Send the message to the specified address/port. - { - err_t lwipErr = ERR_VAL; - -#if LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 - ip_addr_t ipAddr = addr.ToLwIPAddr(); - - lwipErr = raw_sendto(mRaw, System::LwIPPacketBufferView::UnsafeGetLwIPpbuf(msg), &ipAddr); -#else // LWIP_VERSION_MAJOR <= 1 && LWIP_VERSION_MINOR < 5 - if (PCB_ISIPV6(mRaw)) - { - ip6_addr_t ipv6Addr = addr.ToIPv6(); - - lwipErr = raw_sendto_ip6(mRaw, System::LwIPPacketBufferView::UnsafeGetLwIPpbuf(msg), &ipv6Addr); - } -#if INET_CONFIG_ENABLE_IPV4 - else - { - ip4_addr_t ipv4Addr = addr.ToIPv4(); - - lwipErr = raw_sendto(mRaw, System::LwIPPacketBufferView::UnsafeGetLwIPpbuf(msg), &ipv4Addr); - } -#endif // INET_CONFIG_ENABLE_IPV4 -#endif // LWIP_VERSION_MAJOR <= 1 || LWIP_VERSION_MINOR >= 5 - - if (lwipErr != ERR_OK) - res = chip::System::MapErrorLwIP(lwipErr); - } - - // Unlock LwIP stack - UNLOCK_TCPIP_CORE(); -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - // Make sure we have the appropriate type of socket based on the - // destination address. - - res = GetSocket(addr.Type()); - SuccessOrExit(res); - - res = IPEndPointBasis::SendMsg(pktInfo, std::move(msg), sendFlags); -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - -exit: - CHIP_SYSTEM_FAULT_INJECT_ASYNC_EVENT(); - - return res; -} - -/** - * @brief Set the ICMP6 filter parameters in the network stack. - * - * @param[in] numICMPTypes length of array at \c aICMPTypes - * @param[in] aICMPTypes the set of ICMPv6 type codes to filter. - * - * @retval CHIP_NO_ERROR success: filter parameters set - * @retval CHIP_ERROR_NOT_IMPLEMENTED system does not implement - * @retval INET_ERROR_WRONG_ADDRESS_TYPE endpoint not IPv6 type - * @retval INET_ERROR_WRONG_PROTOCOL_TYPE endpoint not ICMP6 type - * - * @retval other another system or platform error - * - * @details - * Apply the ICMPv6 filtering parameters for the codes in \c aICMPTypes to - * the underlying endpoint in the system networking stack. - */ -CHIP_ERROR RawEndPoint::SetICMPFilter(uint8_t numICMPTypes, const uint8_t * aICMPTypes) -{ -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS -#if !(HAVE_NETINET_ICMP6_H && HAVE_ICMP6_FILTER) - return CHIP_ERROR_NOT_IMPLEMENTED; -#endif //!(HAVE_NETINET_ICMP6_H && HAVE_ICMP6_FILTER) -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - VerifyOrReturnError(IPVer == kIPVersion_6, INET_ERROR_WRONG_ADDRESS_TYPE); - VerifyOrReturnError(IPProto == kIPProtocol_ICMPv6, INET_ERROR_WRONG_PROTOCOL_TYPE); - VerifyOrReturnError((numICMPTypes == 0 && aICMPTypes == nullptr) || (numICMPTypes != 0 && aICMPTypes != nullptr), - CHIP_ERROR_INVALID_ARGUMENT); - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - LOCK_TCPIP_CORE(); - NumICMPTypes = numICMPTypes; - ICMPTypes = aICMPTypes; - UNLOCK_TCPIP_CORE(); -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS -#if HAVE_NETINET_ICMP6_H && HAVE_ICMP6_FILTER - struct icmp6_filter filter; - if (numICMPTypes > 0) - { - ICMP6_FILTER_SETBLOCKALL(&filter); - for (int j = 0; j < numICMPTypes; ++j) - { - ICMP6_FILTER_SETPASS(aICMPTypes[j], &filter); - } - } - else - { - ICMP6_FILTER_SETPASSALL(&filter); - } - if (setsockopt(mSocket, IPPROTO_ICMPV6, ICMP6_FILTER, &filter, sizeof(filter)) == -1) - { - return chip::System::MapErrorPOSIX(errno); - } -#endif // HAVE_NETINET_ICMP6_H && HAVE_ICMP6_FILTER -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - return CHIP_NO_ERROR; -} - -/** - * @brief Bind the endpoint to a network interface. - * - * @param[in] addrType the protocol version of the IP address. - * - * @param[in] intfId indicator of the network interface. - * - * @retval CHIP_NO_ERROR success: endpoint bound to address - * @retval CHIP_ERROR_NO_MEMORY insufficient memory for endpoint - * @retval CHIP_ERROR_NOT_IMPLEMENTED system implementation not complete. - * - * @retval INET_ERROR_UNKNOWN_INTERFACE - * On some platforms, the interface is not present. - * - * @retval other another system or platform error - * - * @details - * Binds the endpoint to the specified network interface IP address. - * - * On LwIP, this method must not be called with the LwIP stack lock - * already acquired. - */ -CHIP_ERROR RawEndPoint::BindInterface(IPAddressType addrType, InterfaceId intfId) -{ - // A lock is required because the LwIP thread may be referring to intf_filter, - // while this code running in the Inet application is potentially modifying it. - // NOTE: this only supports LwIP interfaces whose number is no bigger than 9. - - if (mState != kState_Ready && mState != kState_Bound) - { - return CHIP_ERROR_INCORRECT_STATE; - } - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - LOCK_TCPIP_CORE(); - - // Make sure we have the appropriate type of PCB. - CHIP_ERROR err = GetPCB(addrType); - - if (err == CHIP_NO_ERROR) - { - err = LwIPBindInterface(mRaw, intfId); - } - - UNLOCK_TCPIP_CORE(); - - ReturnErrorOnFailure(err); - -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - // Make sure we have the appropriate type of socket. - ReturnErrorOnFailure(GetSocket(addrType)); - ReturnErrorOnFailure(IPEndPointBasis::BindInterface(addrType, intfId)); -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - mState = kState_Bound; - - return CHIP_NO_ERROR; -} - -void RawEndPoint::Init(InetLayer * inetLayer, IPVersion ipVer, IPProtocol ipProto) -{ - IPEndPointBasis::Init(inetLayer); - - IPVer = ipVer; - IPProto = ipProto; -} - -/** - * Get the bound interface on this endpoint. - * - * @return InterfaceId The bound interface id. - */ -InterfaceId RawEndPoint::GetBoundInterface() -{ -#if CHIP_SYSTEM_CONFIG_USE_LWIP -#if HAVE_LWIP_RAW_BIND_NETIF - return netif_get_by_index(mRaw->netif_idx); -#else - return mRaw->intf_filter; -#endif -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - return mBoundIntfId; -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS -} - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - -void RawEndPoint::HandleDataReceived(System::PacketBufferHandle && msg) -{ - IPEndPointBasis::HandleDataReceived(std::move(msg)); -} - -CHIP_ERROR RawEndPoint::GetPCB(IPAddressType addrType) -{ - // IMPORTANT: This method MUST be called with the LwIP stack LOCKED! - -#if LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 - if (mRaw == nullptr) - { - switch (addrType) - { - case kIPAddressType_IPv6: -#if INET_CONFIG_ENABLE_IPV4 - case kIPAddressType_IPv4: -#endif // INET_CONFIG_ENABLE_IPV4 - mRaw = raw_new_ip_type(IPAddress::ToLwIPAddrType(addrType), IPProto); - break; - - default: - return INET_ERROR_WRONG_ADDRESS_TYPE; - } - - if (mRaw == NULL) - { - ChipLogError(Inet, "raw_new_ip_type failed"); - return CHIP_ERROR_NO_MEMORY; - } - - mLwIPEndPointType = kLwIPEndPointType_Raw; - } - else - { - const lwip_ip_addr_type lLwIPAddrType = static_cast(IP_GET_TYPE(&mRaw->local_ip)); - - switch (lLwIPAddrType) - { - case IPADDR_TYPE_V6: - VerifyOrReturnError(addrType == kIPAddressType_IPv6, INET_ERROR_WRONG_ADDRESS_TYPE); - break; - -#if INET_CONFIG_ENABLE_IPV4 - case IPADDR_TYPE_V4: - VerifyOrReturnError(addrType == kIPAddressType_IPv4, INET_ERROR_WRONG_ADDRESS_TYPE); - break; -#endif // INET_CONFIG_ENABLE_IPV4 - - default: - break; - } - } -#else // LWIP_VERSION_MAJOR <= 1 && LWIP_VERSION_MINOR < 5 - if (mRaw == NULL) - { - if (IPVer == kIPVersion_6) - { - mRaw = raw_new_ip6(IPProto); - if (mRaw != NULL) - ip_set_option(mRaw, SOF_REUSEADDR); - } -#if INET_CONFIG_ENABLE_IPV4 - else if (IPVer == kIPVersion_4) - { - mRaw = raw_new(IPProto); - } -#endif // INET_CONFIG_ENABLE_IPV4 - else - { - return INET_ERROR_WRONG_ADDRESS_TYPE; - } - - if (mRaw == NULL) - { - ChipLogError(Inet, "raw_new failed"); - return CHIP_ERROR_NO_MEMORY; - } - - mLwIPEndPointType = kLwIPEndPointType_Raw; - } - else - { -#if INET_CONFIG_ENABLE_IPV4 - const IPAddressType pcbType = PCB_ISIPV6(mRaw) ? kIPAddressType_IPv6 : kIPAddressType_IPv4; -#else // !INET_CONFIG_ENABLE_IPV4 - const IPAddressType pcbType = kIPAddressType_IPv6; -#endif // !INET_CONFIG_ENABLE_IPV4 - - if (addrType != pcbType) - { - return INET_ERROR_WRONG_ADDRESS_TYPE; - } - } -#endif // LWIP_VERSION_MAJOR <= 1 || LWIP_VERSION_MINOR >= 5 - - return CHIP_NO_ERROR; -} - -/* This function is executed when a raw_pcb is listening and an IP datagram (v4 or v6) is received. - * NOTE: currently ICMPv4 filtering is currently not implemented, but it can easily be added later. - * This fn() may be executed concurrently with SetICMPFilter() - * - this fn() runs in the LwIP thread (and the lock has already been taken) - * - SetICMPFilter() runs in the Inet thread. - * Returns non-zero if and only if ownership of the pbuf has been taken. - */ -#if LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 -u8_t RawEndPoint::LwIPReceiveRawMessage(void * arg, struct raw_pcb * pcb, struct pbuf * p, const ip_addr_t * addr) -#else // LWIP_VERSION_MAJOR <= 1 && LWIP_VERSION_MINOR < 5 -u8_t RawEndPoint::LwIPReceiveRawMessage(void * arg, struct raw_pcb * pcb, struct pbuf * p, ip_addr_t * addr) -#endif // LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 -{ - RawEndPoint * ep = static_cast(arg); - IPPacketInfo * pktInfo = NULL; - uint8_t enqueue = 1; - System::PacketBufferHandle buf = System::PacketBufferHandle::Adopt(p); - - // Filtering based on the saved ICMP6 types (the only protocol currently supported.) - if ((ep->IPVer == kIPVersion_6) && (ep->IPProto == kIPProtocol_ICMPv6)) - { - if (ep->NumICMPTypes > 0) - { // When no filter is defined, let all ICMPv6 packets pass - // The type is the first 8 bits field of an ICMP (v4 or v6) packet - uint8_t icmp_type = *(buf->Start() + ip_current_header_tot_len()); - uint8_t icmp_type_found = 0; - for (int j = 0; j < ep->NumICMPTypes; ++j) - { - if (ep->ICMPTypes[j] == icmp_type) - { - icmp_type_found = 1; - break; - } - } - if (!icmp_type_found) - { - enqueue = 0; // do not eat it - } - } - } - - if (enqueue) - { - pktInfo = GetPacketInfo(buf); - - if (pktInfo != NULL) - { -#if LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 - pktInfo->SrcAddress = IPAddress::FromLwIPAddr(*addr); - pktInfo->DestAddress = IPAddress::FromLwIPAddr(*ip_current_dest_addr()); -#else // LWIP_VERSION_MAJOR <= 1 - if (PCB_ISIPV6(pcb)) - { - pktInfo->SrcAddress = IPAddress::FromIPv6(*(ip6_addr_t *) addr); - pktInfo->DestAddress = IPAddress::FromIPv6(*ip6_current_dest_addr()); - } -#if INET_CONFIG_ENABLE_IPV4 - else - { - pktInfo->SrcAddress = IPAddress::FromIPv4(*addr); - pktInfo->DestAddress = IPAddress::FromIPv4(*ip_current_dest_addr()); - } -#endif // INET_CONFIG_ENABLE_IPV4 -#endif // LWIP_VERSION_MAJOR <= 1 - - pktInfo->Interface = ip_current_netif(); - pktInfo->SrcPort = 0; - pktInfo->DestPort = 0; - } - - PostPacketBufferEvent(static_cast(ep->Layer().SystemLayer()), *ep, kInetEvent_RawDataReceived, - std::move(buf)); - } - - return enqueue; -} - -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS -CHIP_ERROR RawEndPoint::GetSocket(IPAddressType aAddressType) -{ - constexpr int lType = (SOCK_RAW | SOCK_FLAGS); - int lProtocol; - - switch (aAddressType) - { - case kIPAddressType_IPv6: - lProtocol = IPPROTO_ICMPV6; - break; - -#if INET_CONFIG_ENABLE_IPV4 - case kIPAddressType_IPv4: - lProtocol = IPPROTO_ICMP; - break; -#endif // INET_CONFIG_ENABLE_IPV4 - - default: - return INET_ERROR_WRONG_ADDRESS_TYPE; - } - - return IPEndPointBasis::GetSocket(aAddressType, lType, lProtocol); -} - -// static -void RawEndPoint::HandlePendingIO(System::SocketEvents events, intptr_t data) -{ - reinterpret_cast(data)->HandlePendingIO(events); -} - -void RawEndPoint::HandlePendingIO(System::SocketEvents events) -{ - if (mState == kState_Listening && OnMessageReceived != nullptr && events.Has(System::SocketEventFlags::kRead)) - { - const uint16_t lPort = 0; - - IPEndPointBasis::HandlePendingIO(lPort); - } -} - -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - -} // namespace Inet -} // namespace chip diff --git a/src/inet/RawEndPoint.h b/src/inet/RawEndPoint.h deleted file mode 100644 index eaafe30a0c162e..00000000000000 --- a/src/inet/RawEndPoint.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * - * Copyright (c) 2020-2021 Project CHIP Authors - * Copyright (c) 2018 Google LLC - * Copyright (c) 2013-2017 Nest Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * This header file defines the Inet::RawEndPoint - * class, where the CHIP Inet Layer encapsulates methods for - * interacting with IP network endpoints (SOCK_RAW sockets - * on Linux and BSD-derived systems) or LwIP raw protocol - * control blocks, as the system is configured accordingly. - */ - -#pragma once - -#include "inet/IPEndPointBasis.h" -#include - -#include - -#if CHIP_SYSTEM_CONFIG_USE_DISPATCH -#include -#endif - -namespace chip { -namespace Inet { - -class InetLayer; -class IPPacketInfo; - -/** - * @brief Objects of this class represent raw IP network endpoints. - * - * @details - * CHIP Inet Layer encapsulates methods for interacting with IP network - * endpoints (SOCK_RAW sockets on Linux and BSD-derived systems) or LwIP - * raw protocol control blocks, as the system is configured accordingly. - */ -class DLL_EXPORT RawEndPoint : public IPEndPointBasis -{ - friend class InetLayer; - -public: - /** - * @brief Version of the Internet protocol - * - * @details - * While this field is a mutable class variable, it is an invariant of the - * class that it not be modified. - */ - IPVersion IPVer; // This data member is read-only - - /** - * @brief version of the Internet Control Message Protocol (ICMP) - * - * @details - * While this field is a mutable class variable, it is an invariant of the - * class that it not be modified. - */ - IPProtocol IPProto; // This data member is read-only - - RawEndPoint() = default; - CHIP_ERROR Bind(IPAddressType addrType, const IPAddress & addr, InterfaceId intfId = INET_NULL_INTERFACEID); - CHIP_ERROR BindIPv6LinkLocal(InterfaceId intfId, const IPAddress & addr); - CHIP_ERROR BindInterface(IPAddressType addrType, InterfaceId intfId); - InterfaceId GetBoundInterface(); - CHIP_ERROR Listen(IPEndPointBasis::OnMessageReceivedFunct onMessageReceived, - IPEndPointBasis::OnReceiveErrorFunct onReceiveError, void * appState = nullptr); - CHIP_ERROR SendTo(const IPAddress & addr, chip::System::PacketBufferHandle && msg, uint16_t sendFlags = 0); - CHIP_ERROR SendTo(const IPAddress & addr, InterfaceId intfId, chip::System::PacketBufferHandle && msg, uint16_t sendFlags = 0); - CHIP_ERROR SendMsg(const IPPacketInfo * pktInfo, chip::System::PacketBufferHandle && msg, uint16_t sendFlags = 0); - CHIP_ERROR SetICMPFilter(uint8_t numICMPTypes, const uint8_t * aICMPTypes); - void Close(); - void Free(); - -private: - RawEndPoint(const RawEndPoint &) = delete; - - static chip::System::ObjectPool sPool; - - void Init(InetLayer * inetLayer, IPVersion ipVer, IPProtocol ipProto); - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - uint8_t NumICMPTypes; - const uint8_t * ICMPTypes; - - void HandleDataReceived(chip::System::PacketBufferHandle && msg); - CHIP_ERROR GetPCB(IPAddressType addrType); - -#if LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 - static u8_t LwIPReceiveRawMessage(void * arg, struct raw_pcb * pcb, struct pbuf * p, const ip_addr_t * addr); -#else // LWIP_VERSION_MAJOR <= 1 && LWIP_VERSION_MINOR < 5 - static u8_t LwIPReceiveRawMessage(void * arg, struct raw_pcb * pcb, struct pbuf * p, ip_addr_t * addr); -#endif // LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - CHIP_ERROR GetSocket(IPAddressType addrType); - void HandlePendingIO(System::SocketEvents events); - static void HandlePendingIO(System::SocketEvents events, intptr_t data); - -#if CHIP_SYSTEM_CONFIG_USE_DISPATCH - dispatch_source_t mReadableSource = nullptr; -#endif // CHIP_SYSTEM_CONFIG_USE_DISPATCH -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS -}; - -} // namespace Inet -} // namespace chip diff --git a/src/inet/inet.gni b/src/inet/inet.gni index 1b77bbe1a4025d..37c29ca0874354 100644 --- a/src/inet/inet.gni +++ b/src/inet/inet.gni @@ -23,9 +23,6 @@ declare_args() { # Enable DNS resolver. chip_inet_config_enable_dns_resolver = true - # Enable raw endpoint. - chip_inet_config_enable_raw_endpoint = true - # Enable UDP endpoint. chip_inet_config_enable_udp_endpoint = true diff --git a/src/inet/tests/TestInetEndPoint.cpp b/src/inet/tests/TestInetEndPoint.cpp index 7f47369777b786..f9390ab64115c2 100644 --- a/src/inet/tests/TestInetEndPoint.cpp +++ b/src/inet/tests/TestInetEndPoint.cpp @@ -80,9 +80,6 @@ void HandleTimer(Layer * aLayer, void * aAppState) // Test before init network, Inet is not initialized static void TestInetPre(nlTestSuite * inSuite, void * inContext) { -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - RawEndPoint * testRawEP = nullptr; -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT #if INET_CONFIG_ENABLE_UDP_ENDPOINT UDPEndPoint * testUDPEP = nullptr; #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT @@ -102,11 +99,6 @@ static void TestInetPre(nlTestSuite * inSuite, void * inContext) ShutdownSystemLayer(); } -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - err = gInet.NewRawEndPoint(kIPVersion_6, kIPProtocol_ICMPv6, &testRawEP); - NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_INCORRECT_STATE); -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - #if INET_CONFIG_ENABLE_UDP_ENDPOINT err = gInet.NewUDPEndPoint(&testUDPEP); NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_INCORRECT_STATE); @@ -318,29 +310,11 @@ static void TestInetEndPointInternal(nlTestSuite * inSuite, void * inContext) InterfaceId intId; // EndPoint -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - RawEndPoint * testRaw6EP = nullptr; -#if INET_CONFIG_ENABLE_IPV4 - RawEndPoint * testRaw4EP = nullptr; -#endif // INET_CONFIG_ENABLE_IPV4 -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT UDPEndPoint * testUDPEP = nullptr; TCPEndPoint * testTCPEP1 = nullptr; PacketBufferHandle buf = PacketBufferHandle::New(PacketBuffer::kMaxSize); - bool didBind = false; - bool didListen = false; // init all the EndPoints -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - err = gInet.NewRawEndPoint(kIPVersion_6, kIPProtocol_ICMPv6, &testRaw6EP); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - -#if INET_CONFIG_ENABLE_IPV4 - err = gInet.NewRawEndPoint(kIPVersion_4, kIPProtocol_ICMPv4, &testRaw4EP); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); -#endif // INET_CONFIG_ENABLE_IPV4 -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - err = gInet.NewUDPEndPoint(&testUDPEP); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); @@ -352,75 +326,10 @@ static void TestInetEndPointInternal(nlTestSuite * inSuite, void * inContext) err = gInet.GetInterfaceFromAddr(addr, intId); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - // RawEndPoint special cases to cover the error branch - uint8_t ICMP6Types[2] = { 128, 129 }; #if INET_CONFIG_ENABLE_IPV4 NL_TEST_ASSERT(inSuite, IPAddress::FromString("10.0.0.1", addr_v4)); #endif // INET_CONFIG_ENABLE_IPV4 - // error bind cases -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - err = testRaw6EP->Bind(kIPAddressType_Unknown, addr_any); - NL_TEST_ASSERT(inSuite, err == INET_ERROR_WRONG_ADDRESS_TYPE); -#if INET_CONFIG_ENABLE_IPV4 - err = testRaw6EP->Bind(kIPAddressType_IPv4, addr); - NL_TEST_ASSERT(inSuite, err == INET_ERROR_WRONG_ADDRESS_TYPE); - err = testRaw6EP->BindIPv6LinkLocal(intId, addr_v4); - NL_TEST_ASSERT(inSuite, err == INET_ERROR_WRONG_ADDRESS_TYPE); -#endif // INET_CONFIG_ENABLE_IPV4 - err = testRaw6EP->BindInterface(kIPAddressType_Unknown, INET_NULL_INTERFACEID); - NL_TEST_ASSERT(inSuite, err != CHIP_NO_ERROR); - - // A bind should succeed with appropriate permissions but will - // otherwise fail. - - err = testRaw6EP->BindIPv6LinkLocal(intId, addr); - NL_TEST_ASSERT(inSuite, (err == CHIP_NO_ERROR) || (err == System::MapErrorPOSIX(EPERM))); - - didBind = (err == CHIP_NO_ERROR); - - // Listen after bind should succeed if the prior bind succeeded. - - err = testRaw6EP->Listen(nullptr /*OnMessageReceived*/, nullptr /*OnReceiveError*/); - NL_TEST_ASSERT(inSuite, (didBind && (err == CHIP_NO_ERROR)) || (!didBind && (err == CHIP_ERROR_INCORRECT_STATE))); - - didListen = (err == CHIP_NO_ERROR); - - // If the first listen succeeded, then the second listen should be successful. - - err = testRaw6EP->Listen(nullptr /*OnMessageReceived*/, nullptr /*OnReceiveError*/); - NL_TEST_ASSERT(inSuite, (didBind && didListen && (err == CHIP_NO_ERROR)) || (!didBind && (err == CHIP_ERROR_INCORRECT_STATE))); - - didListen = (err == CHIP_NO_ERROR); - - // A bind-after-listen should result in an incorrect state error; - // otherwise, it will fail with a permissions error. - - err = testRaw6EP->Bind(kIPAddressType_IPv6, addr); - NL_TEST_ASSERT(inSuite, - (didListen && (err == CHIP_ERROR_INCORRECT_STATE)) || (!didListen && (err == System::MapErrorPOSIX(EPERM)))); - - // error SetICMPFilter case - err = testRaw6EP->SetICMPFilter(0, ICMP6Types); - NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_INVALID_ARGUMENT); - -#if INET_CONFIG_ENABLE_IPV4 - // We should never be able to send an IPv4-addressed message on an - // IPv6 raw socket. - // - // Ostensibly the address obtained above from - // gInet.GetLinkLocalAddr(INET_NULL_INTERFACEID, &addr) is an IPv6 - // LLA; however, make sure it actually is. - - NL_TEST_ASSERT(inSuite, addr.Type() == kIPAddressType_IPv6); - - err = testRaw4EP->SendTo(addr, std::move(buf)); - NL_TEST_ASSERT(inSuite, err == INET_ERROR_WRONG_ADDRESS_TYPE); - testRaw4EP->Free(); -#endif // INET_CONFIG_ENABLE_IPV4 - testRaw6EP->Free(); -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - // UdpEndPoint special cases to cover the error branch err = testUDPEP->Listen(nullptr /*OnMessageReceived*/, nullptr /*OnReceiveError*/); NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_INCORRECT_STATE); @@ -499,21 +408,11 @@ static void TestInetEndPointInternal(nlTestSuite * inSuite, void * inContext) // Test the InetLayer resource limitation static void TestInetEndPointLimit(nlTestSuite * inSuite, void * inContext) { -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - RawEndPoint * testRawEP[INET_CONFIG_NUM_RAW_ENDPOINTS + 1] = { nullptr }; -#endif // - UDPEndPoint * testUDPEP[INET_CONFIG_NUM_UDP_ENDPOINTS + 1] = { nullptr }; TCPEndPoint * testTCPEP[INET_CONFIG_NUM_TCP_ENDPOINTS + 1] = { nullptr }; CHIP_ERROR err = CHIP_NO_ERROR; -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - for (int i = 0; i < INET_CONFIG_NUM_RAW_ENDPOINTS + 1; i++) - err = gInet.NewRawEndPoint(kIPVersion_6, kIPProtocol_ICMPv6, &testRawEP[i]); - NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_ENDPOINT_POOL_FULL); -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - for (int i = 0; i < INET_CONFIG_NUM_UDP_ENDPOINTS + 1; i++) err = gInet.NewUDPEndPoint(&testUDPEP[i]); NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_ENDPOINT_POOL_FULL); @@ -539,12 +438,6 @@ static void TestInetEndPointLimit(nlTestSuite * inSuite, void * inContext) ShutdownNetwork(); ShutdownSystemLayer(); -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - // Release RAW endpoints - for (int i = 0; i < INET_CONFIG_NUM_RAW_ENDPOINTS; i++) - testRawEP[i]->Free(); -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - // Release UDP endpoints for (int i = 0; i < INET_CONFIG_NUM_UDP_ENDPOINTS; i++) testUDPEP[i]->Free(); diff --git a/src/inet/tests/TestInetLayer.cpp b/src/inet/tests/TestInetLayer.cpp index 72b55af3cfbbd6..71b5d7ddd0b57a 100644 --- a/src/inet/tests/TestInetLayer.cpp +++ b/src/inet/tests/TestInetLayer.cpp @@ -92,7 +92,6 @@ static const uint32_t kExpectedTxSizeDefault = kExpectedRxSizeDefault; static const uint32_t kOptFlagsDefault = (kOptFlagUseIPv6 | kOptFlagUseUDPIP); -static RawEndPoint * sRawIPEndPoint = nullptr; static TCPEndPoint * sTCPIPEndPoint = nullptr; // Used for connect/send/receive static TCPEndPoint * sTCPIPListenEndPoint = nullptr; // Used for accept/listen static UDPEndPoint * sUDPIPEndPoint = nullptr; @@ -121,7 +120,6 @@ static OptionDef sToolOptionDefs[] = #endif // INET_CONFIG_ENABLE_IPV4 { "ipv6", kNoArgument, kToolOptIPv6Only }, { "listen", kNoArgument, kToolOptListen }, - { "raw", kNoArgument, kToolOptRawIP }, { "send-size", kArgumentRequired, kToolOptSendSize }, { "tcp", kNoArgument, kToolOptTCPIP }, { "udp", kNoArgument, kToolOptUDPIP }, @@ -155,9 +153,6 @@ static const char * sToolOptionHelp = " -s, --send-size \n" " Send size bytes of user data (default: 59 bytes)\n" "\n" - " -r, --raw\n" - " Use raw IP (default).\n" - "\n" " -t, --tcp\n" " Use TCP over IP.\n" "\n" @@ -381,27 +376,8 @@ static bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdent gInterfaceName = aValue; break; - case kToolOptRawIP: - if (gOptFlags & kOptFlagUseUDPIP) - { - PrintArgError("%s: the use of --raw is exclusive with --udp. Please select only one of the two options.\n", aProgram); - retval = false; - } - else if (gOptFlags & kOptFlagUseTCPIP) - { - PrintArgError("%s: the use of --raw is exclusive with --tcp. Please select only one of the two options.\n", aProgram); - retval = false; - } - gOptFlags |= kOptFlagUseRawIP; - break; - case kToolOptTCPIP: - if (gOptFlags & kOptFlagUseRawIP) - { - PrintArgError("%s: the use of --tcp is exclusive with --raw. Please select only one of the two options.\n", aProgram); - retval = false; - } - else if (gOptFlags & kOptFlagUseUDPIP) + if (gOptFlags & kOptFlagUseUDPIP) { PrintArgError("%s: the use of --tcp is exclusive with --udp. Please select only one of the two options.\n", aProgram); retval = false; @@ -418,12 +394,7 @@ static bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdent break; case kToolOptUDPIP: - if (gOptFlags & kOptFlagUseRawIP) - { - PrintArgError("%s: the use of --udp is exclusive with --raw. Please select only one of the two options.\n", aProgram); - retval = false; - } - else if (gOptFlags & kOptFlagUseTCPIP) + if (gOptFlags & kOptFlagUseTCPIP) { PrintArgError("%s: the use of --udp is exclusive with --tcp. Please select only one of the two options.\n", aProgram); retval = false; @@ -470,7 +441,7 @@ bool HandleNonOptionArgs(const char * aProgram, int argc, char * argv[]) // If no IP version or transport flags were specified, use the defaults. - if (!(gOptFlags & (kOptFlagUseIPv4 | kOptFlagUseIPv6 | kOptFlagUseRawIP | kOptFlagUseTCPIP | kOptFlagUseUDPIP))) + if (!(gOptFlags & (kOptFlagUseIPv4 | kOptFlagUseIPv6 | kOptFlagUseTCPIP | kOptFlagUseUDPIP))) { gOptFlags |= kOptFlagsDefault; } @@ -652,61 +623,6 @@ static void HandleTCPConnectionReceived(TCPEndPoint * aListenEndPoint, TCPEndPoi sTCPIPEndPoint = aConnectEndPoint; } -// Raw Endpoint Callbacks - -static void HandleRawMessageReceived(IPEndPointBasis * aEndPoint, PacketBufferHandle && aBuffer, const IPPacketInfo * aPacketInfo) -{ - const bool lCheckBuffer = true; - const bool lStatsByPacket = true; - IPAddressType lAddressType; - bool lStatus; - - VerifyOrExit(aEndPoint != nullptr, lStatus = false); - VerifyOrExit(!aBuffer.IsNull(), lStatus = false); - VerifyOrExit(aPacketInfo != nullptr, lStatus = false); - - Common::HandleRawMessageReceived(aEndPoint, aBuffer, aPacketInfo); - - lAddressType = aPacketInfo->DestAddress.Type(); - - if (lAddressType == kIPAddressType_IPv6) - { - lStatus = Common::HandleICMPv6DataReceived(std::move(aBuffer), sTestState.mStats, !lStatsByPacket, lCheckBuffer); - } -#if INET_CONFIG_ENABLE_IPV4 - else if (lAddressType == kIPAddressType_IPv4) - { - const uint16_t kIPv4HeaderSize = 20; - - aBuffer->ConsumeHead(kIPv4HeaderSize); - - lStatus = Common::HandleICMPv4DataReceived(std::move(aBuffer), sTestState.mStats, !lStatsByPacket, lCheckBuffer); - } -#endif // INET_CONFIG_ENABLE_IPV4 - else - { - lStatus = false; - } - - if (lStatus) - { - PrintReceivedStats(sTestState.mStats); - } - -exit: - if (!lStatus) - { - SetStatusFailed(sTestState.mStatus); - } -} - -static void HandleRawReceiveError(IPEndPointBasis * aEndPoint, CHIP_ERROR aError, const IPPacketInfo * aPacketInfo) -{ - Common::HandleRawReceiveError(aEndPoint, aError, aPacketInfo); - - SetStatusFailed(sTestState.mStatus); -} - // UDP Endpoint Callbacks static void HandleUDPMessageReceived(IPEndPointBasis * aEndPoint, PacketBufferHandle && aBuffer, const IPPacketInfo * aPacketInfo) @@ -740,11 +656,7 @@ static bool IsTransportReadyForSend() { bool lStatus = false; - if ((gOptFlags & (kOptFlagUseRawIP)) == (kOptFlagUseRawIP)) - { - lStatus = (sRawIPEndPoint != nullptr); - } - else if ((gOptFlags & kOptFlagUseUDPIP) == kOptFlagUseUDPIP) + if ((gOptFlags & kOptFlagUseUDPIP) == kOptFlagUseUDPIP) { lStatus = (sUDPIPEndPoint != nullptr); } @@ -799,57 +711,32 @@ static CHIP_ERROR DriveSendForDestination(const IPAddress & aAddress, uint16_t a { PacketBufferHandle lBuffer; - if ((gOptFlags & (kOptFlagUseRawIP)) == (kOptFlagUseRawIP)) + if ((gOptFlags & kOptFlagUseUDPIP) == kOptFlagUseUDPIP) { - // For ICMP (v4 or v6), we'll send n aSize or smaller - // datagrams (with overhead for the ICMP header), each - // patterned from zero to aSize - 1, following the ICMP - // header. + const uint8_t lFirstValue = 0; - if ((gOptFlags & kOptFlagUseIPv6) == (kOptFlagUseIPv6)) - { - lBuffer = Common::MakeICMPv6DataBuffer(aSize); - VerifyOrReturnError(!lBuffer.IsNull(), CHIP_ERROR_NO_MEMORY); - } -#if INET_CONFIG_ENABLE_IPV4 - else if ((gOptFlags & kOptFlagUseIPv4) == (kOptFlagUseIPv4)) - { - lBuffer = Common::MakeICMPv4DataBuffer(aSize); - VerifyOrReturnError(!lBuffer.IsNull(), CHIP_ERROR_NO_MEMORY); - } -#endif // INET_CONFIG_ENABLE_IPV4 + // For UDP, we'll send n aSize or smaller datagrams, each + // patterned from zero to aSize - 1. + + lBuffer = Common::MakeDataBuffer(aSize, lFirstValue); + VerifyOrReturnError(!lBuffer.IsNull(), CHIP_ERROR_NO_MEMORY); - ReturnErrorOnFailure(sRawIPEndPoint->SendTo(aAddress, std::move(lBuffer))); + ReturnErrorOnFailure(sUDPIPEndPoint->SendTo(aAddress, kUDPPort, std::move(lBuffer))); } - else + else if ((gOptFlags & kOptFlagUseTCPIP) == kOptFlagUseTCPIP) { - if ((gOptFlags & kOptFlagUseUDPIP) == kOptFlagUseUDPIP) - { - const uint8_t lFirstValue = 0; - - // For UDP, we'll send n aSize or smaller datagrams, each - // patterned from zero to aSize - 1. - - lBuffer = Common::MakeDataBuffer(aSize, lFirstValue); - VerifyOrReturnError(!lBuffer.IsNull(), CHIP_ERROR_NO_MEMORY); + const uint32_t lFirstValue = sTestState.mStats.mTransmit.mActual; + VerifyOrReturnError(lFirstValue < 256u, CHIP_ERROR_UNEXPECTED_EVENT); - ReturnErrorOnFailure(sUDPIPEndPoint->SendTo(aAddress, kUDPPort, std::move(lBuffer))); - } - else if ((gOptFlags & kOptFlagUseTCPIP) == kOptFlagUseTCPIP) - { - const uint32_t lFirstValue = sTestState.mStats.mTransmit.mActual; - VerifyOrReturnError(lFirstValue < 256u, CHIP_ERROR_UNEXPECTED_EVENT); - - // For TCP, we'll send one byte stream of - // sTestState.mStats.mTransmit.mExpected in n aSize or - // smaller transactions, patterned from zero to - // sTestState.mStats.mTransmit.mExpected - 1. + // For TCP, we'll send one byte stream of + // sTestState.mStats.mTransmit.mExpected in n aSize or + // smaller transactions, patterned from zero to + // sTestState.mStats.mTransmit.mExpected - 1. - lBuffer = Common::MakeDataBuffer(aSize, uint8_t(lFirstValue)); - VerifyOrReturnError(!lBuffer.IsNull(), CHIP_ERROR_NO_MEMORY); + lBuffer = Common::MakeDataBuffer(aSize, uint8_t(lFirstValue)); + VerifyOrReturnError(!lBuffer.IsNull(), CHIP_ERROR_NO_MEMORY); - ReturnErrorOnFailure(sTCPIPEndPoint->Send(std::move(lBuffer))); - } + ReturnErrorOnFailure(sTCPIPEndPoint->Send(std::move(lBuffer))); } return CHIP_NO_ERROR; @@ -903,8 +790,6 @@ void DriveSend() static void StartTest() { IPAddressType lIPAddressType = kIPAddressType_IPv6; - IPProtocol lIPProtocol = kIPProtocol_ICMPv6; - IPVersion lIPVersion = kIPVersion_6; IPAddress lAddress = chip::Inet::IPAddress::Any; CHIP_ERROR lStatus; @@ -915,8 +800,6 @@ static void StartTest() if (gOptFlags & kOptFlagUseIPv4) { lIPAddressType = kIPAddressType_IPv4; - lIPProtocol = kIPProtocol_ICMPv4; - lIPVersion = kIPVersion_4; if (!gNetworkOptions.LocalIPv6Addr.empty()) lAddress = gNetworkOptions.LocalIPv4Addr[0]; else @@ -926,7 +809,7 @@ static void StartTest() // clang-format off printf("Using %sIP%s, device interface: %s (w/%c LwIP)\n", - ((gOptFlags & kOptFlagUseRawIP) ? "" : ((gOptFlags & kOptFlagUseTCPIP) ? "TCP/" : "UDP/")), + ((gOptFlags & kOptFlagUseTCPIP) ? "TCP/" : "UDP/"), ((gOptFlags & kOptFlagUseIPv4) ? "v4" : "v6"), ((gInterfaceName) ? gInterfaceName : ""), (CHIP_SYSTEM_CONFIG_USE_LWIP ? '\0' : 'o')); @@ -934,21 +817,7 @@ static void StartTest() // Allocate the endpoints for sending or receiving. -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - if (gOptFlags & kOptFlagUseRawIP) - { - lStatus = gInet.NewRawEndPoint(lIPVersion, lIPProtocol, &sRawIPEndPoint); - INET_FAIL_ERROR(lStatus, "InetLayer::NewRawEndPoint failed"); - - if (IsInterfaceIdPresent(gInterfaceId)) - { - lStatus = sRawIPEndPoint->BindInterface(lIPAddressType, gInterfaceId); - INET_FAIL_ERROR(lStatus, "RawEndPoint::BindInterface failed"); - } - } - else -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - if (gOptFlags & kOptFlagUseUDPIP) + if (gOptFlags & kOptFlagUseUDPIP) { lStatus = gInet.NewUDPEndPoint(&sUDPIPEndPoint); INET_FAIL_ERROR(lStatus, "InetLayer::NewUDPEndPoint failed"); @@ -962,24 +831,7 @@ static void StartTest() if (Common::IsReceiver()) { -#if INET_CONFIG_ENABLE_RAW_ENDPOINT - if (gOptFlags & kOptFlagUseRawIP) - { - lStatus = sRawIPEndPoint->Bind(lIPAddressType, lAddress); - INET_FAIL_ERROR(lStatus, "RawEndPoint::Bind failed"); - - if (gOptFlags & kOptFlagUseIPv6) - { - lStatus = sRawIPEndPoint->SetICMPFilter(kICMPv6_FilterTypes, gICMPv6Types); - INET_FAIL_ERROR(lStatus, "RawEndPoint::SetICMPFilter failed"); - } - - lStatus = sRawIPEndPoint->Listen(HandleRawMessageReceived, HandleRawReceiveError); - INET_FAIL_ERROR(lStatus, "RawEndPoint::Listen failed"); - } - else -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT - if (gOptFlags & kOptFlagUseUDPIP) + if (gOptFlags & kOptFlagUseUDPIP) { lStatus = sUDPIPEndPoint->Bind(lIPAddressType, IPAddress::Any, kUDPPort); INET_FAIL_ERROR(lStatus, "UDPEndPoint::Bind failed"); @@ -1021,11 +873,6 @@ static void CleanupTest() // Release the resources associated with the allocated end points. - if (sRawIPEndPoint != nullptr) - { - sRawIPEndPoint->Free(); - } - if (sTCPIPEndPoint != nullptr) { lStatus = sTCPIPEndPoint->Close(); diff --git a/src/inet/tests/TestInetLayerCommon.hpp b/src/inet/tests/TestInetLayerCommon.hpp index 9d961da65ed36e..b90aa0bd6400f8 100644 --- a/src/inet/tests/TestInetLayerCommon.hpp +++ b/src/inet/tests/TestInetLayerCommon.hpp @@ -33,7 +33,6 @@ #include #include -#include #include #include @@ -54,7 +53,6 @@ #define kToolOptIPv6Only '6' #define kToolOptInterval 'i' #define kToolOptListen 'l' -#define kToolOptRawIP 'r' #define kToolOptSendSize 's' #define kToolOptUDPIP 'u' @@ -65,7 +63,6 @@ enum OptFlagsCommon kOptFlagUseIPv4 = 0x00000001, kOptFlagUseIPv6 = 0x00000002, - kOptFlagUseRawIP = 0x00000004, kOptFlagUseUDPIP = 0x00000008, kOptFlagListen = 0x00000010, @@ -147,14 +144,6 @@ extern bool HandleICMPv6DataReceived(chip::System::PacketBufferHandle && aBuffer extern void HandleSendTimerComplete(chip::System::Layer * aSystemLayer, void * aAppState); -// Raw Endpoint Callback Handlers - -extern void HandleRawMessageReceived(const chip::Inet::IPEndPointBasis * aEndPoint, - const chip::System::PacketBufferHandle & aBuffer, - const chip::Inet::IPPacketInfo * aPacketInfo); -extern void HandleRawReceiveError(const chip::Inet::IPEndPointBasis * aEndPoint, const CHIP_ERROR & aError, - const chip::Inet::IPPacketInfo * aPacketInfo); - // UDP Endpoint Callback Handlers extern void HandleUDPMessageReceived(const chip::Inet::IPEndPointBasis * aEndPoint, diff --git a/src/inet/tests/TestInetLayerMulticast.cpp b/src/inet/tests/TestInetLayerMulticast.cpp index 4f4705a6c0be07..c71b424c765146 100644 --- a/src/inet/tests/TestInetLayerMulticast.cpp +++ b/src/inet/tests/TestInetLayerMulticast.cpp @@ -21,8 +21,7 @@ * @file * This file implements a process to effect a functional test for * the InetLayer Internet Protocol stack abstraction interfaces - * for handling IP (v4 or v6) multicast on either bare IP (i.e., - * "raw") or UDP endpoints. + * for handling IP (v4 or v6) multicast on UDP endpoints. * */ @@ -108,9 +107,8 @@ static void CleanupTest(); /* Global Variables */ // clang-format off -static const uint32_t kOptFlagsDefault = (kOptFlagUseIPv6 | kOptFlagUseRawIP); +static const uint32_t kOptFlagsDefault = (kOptFlagUseIPv6 | kOptFlagUseUDPIP); -static RawEndPoint * sRawIPEndPoint = nullptr; static UDPEndPoint * sUDPIPEndPoint = nullptr; static GroupAddresses<4> sGroupAddresses; @@ -136,7 +134,6 @@ static OptionDef sToolOptionDefs[] = { "ipv6", kNoArgument, kToolOptIPv6Only }, { "listen", kNoArgument, kToolOptListen }, { "no-loopback", kNoArgument, kToolOptNoLoopback }, - { "raw", kNoArgument, kToolOptRawIP }, { "send-size", kArgumentRequired, kToolOptSendSize }, { "udp", kNoArgument, kToolOptUDPIP }, { } @@ -175,9 +172,6 @@ static const char * sToolOptionHelp = " -s, --send-size \n" " Send size bytes of user data (default: 59 bytes)\n" "\n" - " -r, --raw\n" - " Use raw IP (default).\n" - "\n" " -u, --udp\n" " Use UDP over IP.\n" "\n"; @@ -429,15 +423,6 @@ static bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdent gInterfaceName = aValue; break; - case kToolOptRawIP: - if (gOptFlags & kOptFlagUseUDPIP) - { - PrintArgError("%s: the use of --raw is exclusive with --udp. Please select only one of the two options.\n", aProgram); - retval = false; - } - gOptFlags |= kOptFlagUseRawIP; - break; - case kToolOptSendSize: if (!ParseInt(aValue, gSendSize)) { @@ -447,11 +432,6 @@ static bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdent break; case kToolOptUDPIP: - if (gOptFlags & kOptFlagUseRawIP) - { - PrintArgError("%s: the use of --udp is exclusive with --raw. Please select only one of the two options.\n", aProgram); - retval = false; - } gOptFlags |= kOptFlagUseUDPIP; break; @@ -483,7 +463,7 @@ bool HandleNonOptionArgs(const char * aProgram, int argc, char * argv[]) // If no IP version or transport flags were specified, use the defaults. - if (!(gOptFlags & (kOptFlagUseIPv4 | kOptFlagUseIPv6 | kOptFlagUseRawIP | kOptFlagUseUDPIP))) + if (!(gOptFlags & (kOptFlagUseIPv4 | kOptFlagUseIPv6 | kOptFlagUseUDPIP))) { gOptFlags |= kOptFlagsDefault; } @@ -609,65 +589,6 @@ static bool HandleDataReceived(const PacketBufferHandle & aBuffer, const IPPacke return true; } -// Raw Endpoint Callbacks - -static void HandleRawMessageReceived(IPEndPointBasis * aEndPoint, PacketBufferHandle && aBuffer, const IPPacketInfo * aPacketInfo) -{ - const bool lCheckBuffer = true; - const bool lStatsByPacket = true; - IPAddressType lAddressType; - bool lStatus = true; - GroupAddress * lGroupAddress; - - VerifyOrExit(aEndPoint != nullptr, lStatus = false); - VerifyOrExit(!aBuffer.IsNull(), lStatus = false); - VerifyOrExit(aPacketInfo != nullptr, lStatus = false); - - Common::HandleRawMessageReceived(aEndPoint, aBuffer, aPacketInfo); - - lGroupAddress = FindGroupAddress(aPacketInfo->DestAddress); - - if (lGroupAddress != nullptr) - { - lAddressType = aPacketInfo->DestAddress.Type(); - - if (lAddressType == kIPAddressType_IPv4) - { - const uint16_t kIPv4HeaderSize = 20; - - aBuffer->ConsumeHead(kIPv4HeaderSize); - - lStatus = Common::HandleICMPv4DataReceived(std::move(aBuffer), lGroupAddress->mStats, lStatsByPacket, lCheckBuffer); - } - else if (lAddressType == kIPAddressType_IPv6) - { - lStatus = Common::HandleICMPv6DataReceived(std::move(aBuffer), lGroupAddress->mStats, lStatsByPacket, lCheckBuffer); - } - else - { - lStatus = false; - } - - if (lStatus) - { - PrintReceivedStats(*lGroupAddress); - } - } - -exit: - if (!lStatus) - { - SetStatusFailed(sTestState.mStatus); - } -} - -static void HandleRawReceiveError(IPEndPointBasis * aEndPoint, CHIP_ERROR aError, const IPPacketInfo * aPacketInfo) -{ - Common::HandleRawReceiveError(aEndPoint, aError, aPacketInfo); - - SetStatusFailed(sTestState.mStatus); -} - // UDP Endpoint Callbacks static void HandleUDPMessageReceived(IPEndPointBasis * aEndPoint, PacketBufferHandle && aBuffer, const IPPacketInfo * aPacketInfo) @@ -701,11 +622,7 @@ static bool IsTransportReadyForSend() { bool lStatus = false; - if ((gOptFlags & (kOptFlagUseRawIP)) == (kOptFlagUseRawIP)) - { - lStatus = (sRawIPEndPoint != nullptr); - } - else if ((gOptFlags & kOptFlagUseUDPIP) == kOptFlagUseUDPIP) + if ((gOptFlags & kOptFlagUseUDPIP) == kOptFlagUseUDPIP) { lStatus = (sUDPIPEndPoint != nullptr); } @@ -724,29 +641,6 @@ static CHIP_ERROR DriveSendForDestination(const IPAddress & aAddress, uint16_t a { PacketBufferHandle lBuffer; - if ((gOptFlags & (kOptFlagUseRawIP)) == (kOptFlagUseRawIP)) - { - // For ICMP (v4 or v6), we'll send n aSize or smaller - // datagrams (with overhead for the ICMP header), each - // patterned from zero to aSize - 1, following the ICMP - // header. - - if ((gOptFlags & kOptFlagUseIPv6) == (kOptFlagUseIPv6)) - { - lBuffer = Common::MakeICMPv6DataBuffer(aSize); - VerifyOrReturnError(!lBuffer.IsNull(), CHIP_ERROR_NO_MEMORY); - } -#if INET_CONFIG_ENABLE_IPV4 - else if ((gOptFlags & kOptFlagUseIPv4) == (kOptFlagUseIPv4)) - { - lBuffer = Common::MakeICMPv4DataBuffer(aSize); - VerifyOrReturnError(!lBuffer.IsNull(), CHIP_ERROR_NO_MEMORY); - } -#endif // INET_CONFIG_ENABLE_IPV4 - - return sRawIPEndPoint->SendTo(aAddress, std::move(lBuffer)); - } - if ((gOptFlags & kOptFlagUseUDPIP) == kOptFlagUseUDPIP) { const uint8_t lFirstValue = 0; @@ -843,7 +737,7 @@ static void StartTest() // clang-format off printf("Using %sIP%s, device interface: %s (w/%c LwIP)\n", - ((gOptFlags & kOptFlagUseRawIP) ? "" : "UDP/"), + "UDP/", ((gOptFlags & kOptFlagUseIPv4) ? "v4" : "v6"), ((gInterfaceName) ? gInterfaceName : ""), (CHIP_SYSTEM_CONFIG_USE_LWIP ? '\0' : 'o')); @@ -851,32 +745,7 @@ static void StartTest() // Allocate the endpoints for sending or receiving. - if (gOptFlags & kOptFlagUseRawIP) - { - lStatus = gInet.NewRawEndPoint(lIPVersion, lIPProtocol, &sRawIPEndPoint); - INET_FAIL_ERROR(lStatus, "InetLayer::NewRawEndPoint failed"); - - lStatus = sRawIPEndPoint->Bind(lIPAddressType, lAddress); - INET_FAIL_ERROR(lStatus, "RawEndPoint::Bind failed"); - - if (gOptFlags & kOptFlagUseIPv6) - { - lStatus = sRawIPEndPoint->SetICMPFilter(kICMPv6_FilterTypes, gICMPv6Types); - INET_FAIL_ERROR(lStatus, "RawEndPoint::SetICMPFilter (IPv6) failed"); - } - - if (IsInterfaceIdPresent(gInterfaceId)) - { - lStatus = sRawIPEndPoint->BindInterface(lIPAddressType, gInterfaceId); - INET_FAIL_ERROR(lStatus, "RawEndPoint::BindInterface failed"); - } - - lStatus = sRawIPEndPoint->Listen(HandleRawMessageReceived, HandleRawReceiveError); - INET_FAIL_ERROR(lStatus, "RawEndPoint::Listen failed"); - - lEndPoint = sRawIPEndPoint; - } - else if (gOptFlags & kOptFlagUseUDPIP) + if (gOptFlags & kOptFlagUseUDPIP) { lStatus = gInet.NewUDPEndPoint(&sUDPIPEndPoint); INET_FAIL_ERROR(lStatus, "InetLayer::NewUDPEndPoint failed"); @@ -946,11 +815,7 @@ static void CleanupTest() // Leave the multicast groups - if (gOptFlags & kOptFlagUseRawIP) - { - lEndPoint = sRawIPEndPoint; - } - else if (gOptFlags & kOptFlagUseUDPIP) + if (gOptFlags & kOptFlagUseUDPIP) { lEndPoint = sUDPIPEndPoint; } @@ -974,11 +839,6 @@ static void CleanupTest() // Release the resources associated with the allocated end points. - if (sRawIPEndPoint != nullptr) - { - sRawIPEndPoint->Free(); - } - if (sUDPIPEndPoint != nullptr) { sUDPIPEndPoint->Free(); diff --git a/src/lwip/k32w/lwipopts.h b/src/lwip/k32w/lwipopts.h index d2f0203b1df40b..3ee26ae5641c11 100644 --- a/src/lwip/k32w/lwipopts.h +++ b/src/lwip/k32w/lwipopts.h @@ -55,13 +55,6 @@ #define LWIP_SOCKET 0 -#if INET_CONFIG_ENABLE_RAW_ENDPOINT -#define LWIP_RAW 1 -#define MEMP_NUM_RAW_PCB (5) -#else -#define LWIP_RAW 0 -#define MEMP_NUM_RAW_PCB 0 -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT #if INET_CONFIG_ENABLE_TCP_ENDPOINT #define LWIP_TCP 1 #else diff --git a/src/lwip/qpg/lwipopts.h b/src/lwip/qpg/lwipopts.h index 1db3ccb248e874..f352d4bce3ae4b 100644 --- a/src/lwip/qpg/lwipopts.h +++ b/src/lwip/qpg/lwipopts.h @@ -50,13 +50,6 @@ #define LWIP_SOCKET 0 -#ifdef INET_CONFIG_ENABLE_RAW_ENDPOINT -#define LWIP_RAW 1 -#define MEMP_NUM_RAW_PCB (5) -#else -#define LWIP_RAW 0 -#define MEMP_NUM_RAW_PCB 0 -#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT #ifdef INET_CONFIG_ENABLE_TCP_ENDPOINT #define LWIP_TCP 1 #else diff --git a/src/platform/K32W/args.gni b/src/platform/K32W/args.gni index 758135675b1e0e..e4203cf5b71ea4 100644 --- a/src/platform/K32W/args.gni +++ b/src/platform/K32W/args.gni @@ -24,7 +24,6 @@ chip_inet_config_enable_ipv4 = false chip_inet_config_enable_dns_resolver = false chip_inet_config_enable_tcp_endpoint = false -chip_inet_config_enable_raw_endpoint = false chip_build_tests = false diff --git a/src/platform/qpg/args.gni b/src/platform/qpg/args.gni index ecb114318a83b0..386dc90cebe1d9 100644 --- a/src/platform/qpg/args.gni +++ b/src/platform/qpg/args.gni @@ -28,7 +28,6 @@ lwip_platform = "qpg" chip_inet_config_enable_ipv4 = false chip_inet_config_enable_dns_resolver = false chip_inet_config_enable_tcp_endpoint = false -chip_inet_config_enable_raw_endpoint = false # Size opt's #chip_progress_logging = false diff --git a/src/system/SystemLayerImplSelect.h b/src/system/SystemLayerImplSelect.h index 0378327c3730da..c2a2ebf8eb245c 100644 --- a/src/system/SystemLayerImplSelect.h +++ b/src/system/SystemLayerImplSelect.h @@ -77,8 +77,7 @@ class LayerImplSelect : public LayerSocketsLoop protected: static SocketEvents SocketEventsFromFDs(int socket, const fd_set & readfds, const fd_set & writefds, const fd_set & exceptfds); - static constexpr int kSocketWatchMax = (INET_CONFIG_ENABLE_RAW_ENDPOINT ? INET_CONFIG_NUM_RAW_ENDPOINTS : 0) + - (INET_CONFIG_ENABLE_TCP_ENDPOINT ? INET_CONFIG_NUM_TCP_ENDPOINTS : 0) + + static constexpr int kSocketWatchMax = (INET_CONFIG_ENABLE_TCP_ENDPOINT ? INET_CONFIG_NUM_TCP_ENDPOINTS : 0) + (INET_CONFIG_ENABLE_UDP_ENDPOINT ? INET_CONFIG_NUM_UDP_ENDPOINTS : 0) + (INET_CONFIG_ENABLE_DNS_RESOLVER ? INET_CONFIG_NUM_DNS_RESOLVERS : 0); diff --git a/src/system/SystemPacketBuffer.h b/src/system/SystemPacketBuffer.h index 0adf690deca3a1..e59e00cba17729 100644 --- a/src/system/SystemPacketBuffer.h +++ b/src/system/SystemPacketBuffer.h @@ -844,7 +844,6 @@ using PacketBufferWriter = PacketBufferWriterBase