From 9d7339bb262bcbfb6627deb6c0a359efd80591ff Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Thu, 13 Aug 2020 13:25:08 -0700 Subject: [PATCH 1/2] Remove tunneling support from CHIP codebase * Cleanup all tunneling support from CHIP codebase since this feature will not be used in CHIP. --- src/include/platform/CHIPDeviceConfig.h | 68 +- src/include/platform/CHIPDeviceEvent.h | 16 - src/include/platform/ConnectivityManager.h | 45 - .../GenericConnectivityManagerImpl_NoTunnel.h | 109 --- .../GenericConnectivityManagerImpl_Thread.ipp | 5 +- src/inet/BUILD.gn | 12 - src/inet/EndPointBasis.h | 6 - src/inet/Inet.h | 4 - src/inet/InetConfig.h | 38 - src/inet/InetLayer.am | 5 - src/inet/InetLayer.cpp | 85 +- src/inet/InetLayer.h | 15 - src/inet/InetLayerEvents.h | 3 +- src/inet/TunEndPoint.cpp | 823 ------------------ src/inet/TunEndPoint.h | 239 ----- src/inet/inet.gni | 3 - src/inet/tests/TestInetEndPoint.cpp | 40 - src/lib/core/BUILD.gn | 1 - src/lib/core/CHIPConfig.h | 13 - src/lib/core/CHIPError.cpp | 21 - src/lib/core/CHIPError.h | 155 +--- src/lib/core/CHIPTunnelConfig.h | 474 ---------- src/lib/core/CoreLayer.am | 1 - src/lib/core/tests/TestCHIPErrorStr.cpp | 7 - src/lib/message/CHIPConnection.cpp | 93 +- src/lib/message/CHIPMessageLayer.cpp | 183 +--- src/lib/message/CHIPMessageLayer.h | 99 +-- src/lib/support/CHIPFaultInjection.cpp | 4 - src/lib/support/CHIPFaultInjection.h | 5 - src/lib/support/logging/CHIPLogging.cpp | 1 - src/lib/support/logging/CHIPLogging.h | 1 - src/platform/BUILD.gn | 1 - .../Darwin/CHIPDevicePlatformConfig.h | 1 - src/platform/Darwin/CHIPPlatformConfig.h | 3 - src/platform/Darwin/ConnectivityManagerImpl.h | 4 +- src/platform/EFR32/CHIPDevicePlatformConfig.h | 1 - src/platform/EFR32/CHIPPlatformConfig.h | 3 - src/platform/EFR32/ConnectivityManagerImpl.h | 4 +- src/platform/ESP32/CHIPDevicePlatformConfig.h | 3 - src/platform/ESP32/CHIPPlatformConfig.h | 2 - .../ESP32/ConnectivityManagerImpl.cpp | 115 --- src/platform/ESP32/ConnectivityManagerImpl.h | 21 +- src/platform/ESP32/InetPlatformConfig.h | 4 - src/platform/K32W/CHIPDevicePlatformConfig.h | 1 - src/platform/K32W/CHIPPlatformConfig.h | 3 - src/platform/K32W/ConnectivityManagerImpl.h | 4 +- src/platform/Linux/CHIPDevicePlatformConfig.h | 1 - src/platform/Linux/CHIPPlatformConfig.h | 3 - src/platform/Linux/ConnectivityManagerImpl.h | 4 +- src/platform/Makefile.am | 1 - src/platform/nRF5/CHIPDevicePlatformConfig.h | 1 - src/platform/nRF5/CHIPPlatformConfig.h | 3 - src/platform/nRF5/ConnectivityManagerImpl.h | 4 +- .../nrfconnect/CHIPDevicePlatformConfig.h | 1 - src/platform/nrfconnect/CHIPPlatformConfig.h | 3 - .../nrfconnect/ConnectivityManagerImpl.h | 4 +- src/system/SystemStats.cpp | 3 - src/system/SystemStats.h | 3 - 58 files changed, 74 insertions(+), 2701 deletions(-) delete mode 100644 src/include/platform/internal/GenericConnectivityManagerImpl_NoTunnel.h delete mode 100644 src/inet/TunEndPoint.cpp delete mode 100644 src/inet/TunEndPoint.h delete mode 100644 src/lib/core/CHIPTunnelConfig.h diff --git a/src/include/platform/CHIPDeviceConfig.h b/src/include/platform/CHIPDeviceConfig.h index 5ff0c233315c2d..72912612221746 100644 --- a/src/include/platform/CHIPDeviceConfig.h +++ b/src/include/platform/CHIPDeviceConfig.h @@ -565,17 +565,6 @@ #define CHIP_DEVICE_CONFIG_THREAD_CONNECTIVITY_TIMEOUT 30000 #endif -// -------------------- Tunnel Configuration -------------------- - -/** - * CHIP_DEVICE_CONFIG_LWIP_SERVICE_TUN_IF_NAME - * - * Name of the service TUN interface on LwIP-based platforms. - */ -#ifndef CHIP_DEVICE_CONFIG_LWIP_SERVICE_TUN_IF_NAME -#define CHIP_DEVICE_CONFIG_LWIP_SERVICE_TUN_IF_NAME "tn" -#endif - // -------------------- Trait Manager Configuration -------------------- /** @@ -604,34 +593,6 @@ #define CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY 0 #endif -/** - * CHIP_DEVICE_CONFIG_ENABLE_FIXED_TUNNEL_SERVER - * - * Forces the use of a service tunnel server at a fixed IP address and port. This - * bypasses the need for a directory query to the service directory endpoint to - * determine the tunnel server address. When enabled, this option allows devices - * that haven't been service provisioned to establish a service tunnel. - * - * When this option is enabled, CHIP_DEVICE_CONFIG_TUNNEL_SERVER_ADDRESS must - * be set to the address of the tunnel server. - */ -#ifndef CHIP_DEVICE_CONFIG_ENABLE_FIXED_TUNNEL_SERVER -#define CHIP_DEVICE_CONFIG_ENABLE_FIXED_TUNNEL_SERVER 0 -#endif - -/** CHIP_DEVICE_CONFIG_TUNNEL_SERVER_ADDRESS - * - * The address of the server to which the device should establish a service tunnel. - * - * This value is only meaningful if CHIP_DEVICE_CONFIG_ENABLE_FIXED_TUNNEL_SERVER - * has been enabled. - * - * Note: Currently this must be a dot-notation IP address--not a host name. - */ -#ifndef CHIP_DEVICE_CONFIG_TUNNEL_SERVER_ADDRESS -#define CHIP_DEVICE_CONFIG_TUNNEL_SERVER_ADDRESS "" -#endif - /** * CHIP_DEVICE_CONFIG_DISABLE_ACCOUNT_PAIRING * @@ -687,24 +648,9 @@ #error "If CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL set, then CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY must also be set." #endif -/** - * @def CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY - * - * @brief - * Enable automatically uploading chip tunnel telemetry via trait on an interval. - */ -#ifndef CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY -#define CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY (0) -#endif - -#if CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY && !CHIP_CONFIG_ENABLE_TUNNELING -#error "If CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY set, then CHIP_CONFIG_ENABLE_TUNNELING must also be set." -#endif - // Enable Network Telemetry feature if it is enabled for at lease one network. #define CHIP_DEVICE_CONFIG_ENABLE_NETWORK_TELEMETRY \ - (CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY || CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY || \ - CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY) + (CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY || CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY) /** * @def CHIP_DEVICE_CONFIG_DEFAULT_TELEMETRY_INTERVAL_MS @@ -719,18 +665,6 @@ #define CHIP_DEVICE_CONFIG_DEFAULT_TELEMETRY_INTERVAL_MS 90000 #endif -/** - * @def CHIP_DEVICE_CONFIG_DEFAULT_TUNNEL_TELEMETRY_INTERVAL_MS - * - * @brief - * This sets the default interval at which chip tunnel telemetry events - * will be logged to chip buffers. - * - */ -#ifndef CHIP_DEVICE_CONFIG_DEFAULT_TUNNEL_TELEMETRY_INTERVAL_MS -#define CHIP_DEVICE_CONFIG_DEFAULT_TUNNEL_TELEMETRY_INTERVAL_MS 300000 -#endif - // -------------------- Event Logging Configuration -------------------- /** diff --git a/src/include/platform/CHIPDeviceEvent.h b/src/include/platform/CHIPDeviceEvent.h index ace79c752268ef..5e4237e0cc7ebd 100644 --- a/src/include/platform/CHIPDeviceEvent.h +++ b/src/include/platform/CHIPDeviceEvent.h @@ -123,13 +123,6 @@ enum PublicEventTypes */ kInternetConnectivityChange, - /** - * Service Tunnel State Change - * - * Signals a change in connectivity of the device's IP tunnel to a chip-enabled service. - */ - kServiceTunnelStateChange, - /** * Service Connectivity Change * @@ -316,21 +309,12 @@ struct ChipDeviceEvent final ConnectivityChange IPv6; } InternetConnectivityChange; struct - { - ConnectivityChange Result; - bool IsRestricted; - } ServiceTunnelStateChange; - struct { struct { ConnectivityChange Result; } Overall; struct - { - ConnectivityChange Result; - } ViaTunnel; - struct { ConnectivityChange Result; } ViaThread; diff --git a/src/include/platform/ConnectivityManager.h b/src/include/platform/ConnectivityManager.h index 4f7ef3c26f085a..e42e1b15b7a960 100644 --- a/src/include/platform/ConnectivityManager.h +++ b/src/include/platform/ConnectivityManager.h @@ -83,13 +83,6 @@ class ConnectivityManager kThreadMode_Enabled = 3, }; - enum ServiceTunnelMode - { - kServiceTunnelMode_NotSupported = 0, - kServiceTunnelMode_Disabled = 1, - kServiceTunnelMode_Enabled = 2, - }; - enum CHIPoBLEServiceMode { kCHIPoBLEServiceMode_NotSupported = 0, @@ -149,13 +142,6 @@ class ConnectivityManager bool HaveIPv4InternetConnectivity(void); bool HaveIPv6InternetConnectivity(void); - // Service tunnel methods - ServiceTunnelMode GetServiceTunnelMode(void); - CHIP_ERROR SetServiceTunnelMode(ServiceTunnelMode val); - bool IsServiceTunnelConnected(void); - bool IsServiceTunnelRestricted(void); - bool HaveServiceConnectivityViaTunnel(void); - // Service connectivity methods bool HaveServiceConnectivity(void); @@ -184,7 +170,6 @@ class ConnectivityManager // Support methods static const char * WiFiStationModeToStr(WiFiStationMode mode); static const char * WiFiAPModeToStr(WiFiAPMode mode); - static const char * ServiceTunnelModeToStr(ServiceTunnelMode mode); static const char * CHIPoBLEServiceModeToStr(CHIPoBLEServiceMode mode); private: @@ -361,11 +346,6 @@ inline CHIP_ERROR ConnectivityManager::GetAndLogWifiStatsCounters(void) return static_cast(this)->_GetAndLogWifiStatsCounters(); } -inline bool ConnectivityManager::HaveServiceConnectivityViaTunnel(void) -{ - return static_cast(this)->_HaveServiceConnectivityViaTunnel(); -} - inline bool ConnectivityManager::HaveIPv4InternetConnectivity(void) { return static_cast(this)->_HaveIPv4InternetConnectivity(); @@ -376,26 +356,6 @@ inline bool ConnectivityManager::HaveIPv6InternetConnectivity(void) return static_cast(this)->_HaveIPv6InternetConnectivity(); } -inline ConnectivityManager::ServiceTunnelMode ConnectivityManager::GetServiceTunnelMode(void) -{ - return static_cast(this)->_GetServiceTunnelMode(); -} - -inline CHIP_ERROR ConnectivityManager::SetServiceTunnelMode(ServiceTunnelMode val) -{ - return static_cast(this)->_SetServiceTunnelMode(val); -} - -inline bool ConnectivityManager::IsServiceTunnelConnected(void) -{ - return static_cast(this)->_IsServiceTunnelConnected(); -} - -inline bool ConnectivityManager::IsServiceTunnelRestricted(void) -{ - return static_cast(this)->_IsServiceTunnelRestricted(); -} - inline bool ConnectivityManager::HaveServiceConnectivity(void) { return static_cast(this)->_HaveServiceConnectivity(); @@ -556,11 +516,6 @@ inline const char * ConnectivityManager::WiFiAPModeToStr(WiFiAPMode mode) return ImplClass::_WiFiAPModeToStr(mode); } -inline const char * ConnectivityManager::ServiceTunnelModeToStr(ServiceTunnelMode mode) -{ - return ImplClass::_ServiceTunnelModeToStr(mode); -} - inline const char * ConnectivityManager::CHIPoBLEServiceModeToStr(CHIPoBLEServiceMode mode) { return ImplClass::_CHIPoBLEServiceModeToStr(mode); diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_NoTunnel.h b/src/include/platform/internal/GenericConnectivityManagerImpl_NoTunnel.h deleted file mode 100644 index d7bca1bc1dff68..00000000000000 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_NoTunnel.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 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 - * Provides an generic implementation of ConnectivityManager features - * for use on platforms that don't support a service tunnel. - */ - -#ifndef GENERIC_CONNECTIVITY_MANAGER_IMPL_NO_TUNNEL_H -#define GENERIC_CONNECTIVITY_MANAGER_IMPL_NO_TUNNEL_H - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -/** - * Provides a generic implementation of service tunnel-specific ConnectivityManager features for - * platforms that don't support a service tunnel. - * - * This class is intended to be inherited (directly or indirectly) by the ConnectivityManagerImpl - * class, which also appears as the template's ImplClass parameter. - * - * The members of this class are all inlined methods that do nothing, and return static return - * values. This allows the compiler to optimize away dead code without the use of #ifdef's. - * For example: - * - * ``` - * if (ConnectivityMgr().GetServiceTunnelMode() != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported) - * { - * // ... do something on devices that support service tunnels ... - * } - * ``` - */ -template -class GenericConnectivityManagerImpl_NoTunnel -{ -public: - // ===== Methods that implement the ConnectivityManager abstract interface. - - ConnectivityManager::ServiceTunnelMode _GetServiceTunnelMode(void); - CHIP_ERROR _SetServiceTunnelMode(ConnectivityManager::ServiceTunnelMode val); - bool _IsServiceTunnelConnected(void); - bool _IsServiceTunnelRestricted(void); - bool _HaveServiceConnectivityViaTunnel(void); - static const char * _ServiceTunnelModeToStr(ConnectivityManager::ServiceTunnelMode mode); - -private: - ImplClass * Impl() { return static_cast(this); } -}; - -template -inline ConnectivityManager::ServiceTunnelMode GenericConnectivityManagerImpl_NoTunnel::_GetServiceTunnelMode(void) -{ - return ConnectivityManager::kServiceTunnelMode_NotSupported; -} - -template -inline CHIP_ERROR -GenericConnectivityManagerImpl_NoTunnel::_SetServiceTunnelMode(ConnectivityManager::ServiceTunnelMode val) -{ - return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -} - -template -inline bool GenericConnectivityManagerImpl_NoTunnel::_IsServiceTunnelConnected(void) -{ - return false; -} - -template -inline bool GenericConnectivityManagerImpl_NoTunnel::_IsServiceTunnelRestricted(void) -{ - return false; -} - -template -inline bool GenericConnectivityManagerImpl_NoTunnel::_HaveServiceConnectivityViaTunnel(void) -{ - return false; -} - -template -inline const char * -GenericConnectivityManagerImpl_NoTunnel::_ServiceTunnelModeToStr(ConnectivityManager::ServiceTunnelMode mode) -{ - return NULL; -} - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip - -#endif // GENERIC_CONNECTIVITY_MANAGER_IMPL_NO_TUNNEL_H diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.ipp b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.ipp index 4de31bfcb990eb..481f8f875a81ef 100644 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.ipp +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.ipp @@ -108,10 +108,7 @@ void GenericConnectivityManagerImpl_Thread::UpdateServiceConnectivity event.Type = DeviceEventType::kServiceConnectivityChange; event.ServiceConnectivityChange.ViaThread.Result = (haveServiceConnectivity) ? kConnectivity_Established : kConnectivity_Lost; - event.ServiceConnectivityChange.ViaTunnel.Result = kConnectivity_NoChange; - event.ServiceConnectivityChange.Overall.Result = (Impl()->HaveServiceConnectivityViaTunnel()) - ? kConnectivity_NoChange - : event.ServiceConnectivityChange.ViaThread.Result; + event.ServiceConnectivityChange.Overall.Result = event.ServiceConnectivityChange.ViaThread.Result; PlatformMgr().PostEvent(&event); } } diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index a2f78c7bea4532..2359c2f43044da 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -68,11 +68,6 @@ config("inet_config") { } else { defines += [ "INET_CONFIG_ENABLE_TCP_ENDPOINT=0" ] } - if (chip_inet_config_enable_tun_endpoint) { - defines += [ "INET_CONFIG_ENABLE_TUN_ENDPOINT=1" ] - } else { - defines += [ "INET_CONFIG_ENABLE_TUN_ENDPOINT=0" ] - } if (chip_inet_config_enable_udp_endpoint) { defines += [ "INET_CONFIG_ENABLE_UDP_ENDPOINT=1" ] } else { @@ -161,13 +156,6 @@ static_library("inet") { ] } - if (chip_inet_config_enable_tun_endpoint) { - sources += [ - "TunEndPoint.cpp", - "TunEndPoint.h", - ] - } - if (chip_with_nlfaultinjection) { sources += [ "InetFaultInjection.cpp" ] public_deps += [ "${nlfaultinjection_root}:nlfaultinjection" ] diff --git a/src/inet/EndPointBasis.h b/src/inet/EndPointBasis.h index ae108fa80edd12..c958abee2c5a44 100644 --- a/src/inet/EndPointBasis.h +++ b/src/inet/EndPointBasis.h @@ -50,9 +50,6 @@ struct udp_pcb; #if INET_CONFIG_ENABLE_TCP_ENDPOINT struct tcp_pcb; #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT -struct netif; -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT #endif // CHIP_SYSTEM_CONFIG_USE_LWIP namespace chip { @@ -116,9 +113,6 @@ class DLL_EXPORT EndPointBasis : public InetLayerBasis #if INET_CONFIG_ENABLE_TCP_ENDPOINT tcp_pcb * mTCP; /**< Transmission control protocol (TCP) control */ #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - netif * mNetIf; /**< Tunnel interface control */ -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT }; enum diff --git a/src/inet/Inet.h b/src/inet/Inet.h index 5ab4263e774343..48fa94874d07a5 100644 --- a/src/inet/Inet.h +++ b/src/inet/Inet.h @@ -51,8 +51,4 @@ #include #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT -#include -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT - #endif // !defined(INET_H) diff --git a/src/inet/InetConfig.h b/src/inet/InetConfig.h index 97eb060f57573b..316eba66a3caeb 100644 --- a/src/inet/InetConfig.h +++ b/src/inet/InetConfig.h @@ -256,19 +256,6 @@ #define INET_CONFIG_NUM_UDP_ENDPOINTS 64 #endif // INET_CONFIG_NUM_UDP_ENDPOINTS -/** - * @def INET_CONFIG_NUM_TUN_ENDPOINTS - * - * @brief - * This is the total number of TUN end point context structures. - * - * Up to this many outstanding TUN endpoints may be instantiated. - * - */ -#ifndef INET_CONFIG_NUM_TUN_ENDPOINTS -#define INET_CONFIG_NUM_TUN_ENDPOINTS 64 -#endif // INET_CONFIG_NUM_TUN_ENDPOINTS - /** * @def INET_CONFIG_NUM_DNS_RESOLVERS * @@ -343,21 +330,6 @@ #define INET_CONFIG_ENABLE_TCP_ENDPOINT 0 #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT -/** - * @def INET_CONFIG_ENABLE_TUN_ENDPOINT - * - * @brief - * Defines whether (1) or not (0) to enable the ability - * to instantiate a Tunnel endpoint for tun interfaces. - * By default, set when LWIP is enabled or being built - * on a Linux platform. - * - */ -#ifndef INET_CONFIG_ENABLE_TUN_ENDPOINT -#define INET_CONFIG_ENABLE_TUN_ENDPOINT 0 -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT - - /** * @def INET_CONFIG_ENABLE_UDP_ENDPOINT * @@ -406,16 +378,6 @@ #define INET_CONFIG_TEST 0 #endif -/** - * @def INET_CONFIG_TUNNEL_DEVICE_NAME - * - * @brief - * Defines tunnel device name - */ -#ifndef INET_CONFIG_TUNNEL_DEVICE_NAME -#define INET_CONFIG_TUNNEL_DEVICE_NAME "/dev/net/tun" -#endif //INET_CONFIG_TUNNEL_DEVICE_NAME - /** * @def INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS * diff --git a/src/inet/InetLayer.am b/src/inet/InetLayer.am index 933f2cf5db2212..544c9f1e7ad206 100644 --- a/src/inet/InetLayer.am +++ b/src/inet/InetLayer.am @@ -58,7 +58,6 @@ CHIP_BUILD_INET_LAYER_HEADER_FILES = \ @top_builddir@/src/inet/InetLayerEvents.h \ @top_builddir@/src/inet/RawEndPoint.h \ @top_builddir@/src/inet/TCPEndPoint.h \ - @top_builddir@/src/inet/TunEndPoint.h \ @top_builddir@/src/inet/UDPEndPoint.h \ @top_builddir@/src/inet/ZephyrSocket.h \ $(NULL) @@ -79,10 +78,6 @@ if INET_WANT_ENDPOINT_UDP CHIP_BUILD_INET_LAYER_SOURCE_FILES += @top_builddir@/src/inet/UDPEndPoint.cpp endif # INET_WANT_ENDPOINT_UDP -if INET_WANT_ENDPOINT_TUN -CHIP_BUILD_INET_LAYER_SOURCE_FILES += @top_builddir@/src/inet/TunEndPoint.cpp -endif # INET_WANT_ENDPOINT_TUN - if CHIP_SYSTEM_CONFIG_USE_SOCKETS if INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS CHIP_BUILD_INET_LAYER_SOURCE_FILES += @top_builddir@/src/inet/AsyncDNSResolverSockets.cpp diff --git a/src/inet/InetLayer.cpp b/src/inet/InetLayer.cpp index 9317b023efe7e3..c3ff57d541d7ea 100644 --- a/src/inet/InetLayer.cpp +++ b/src/inet/InetLayer.cpp @@ -97,10 +97,6 @@ void InetLayer::UpdateSnapshot(chip::System::Stats::Snapshot & aSnapshot) RawEndPoint::sPool.GetStatistics(aSnapshot.mResourcesInUse[chip::System::Stats::kInetLayer_NumRawEps], aSnapshot.mHighWatermarks[chip::System::Stats::kInetLayer_NumRawEps]); #endif // INET_CONFIG_ENABLE_RAW_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - TunEndPoint::sPool.GetStatistics(aSnapshot.mResourcesInUse[chip::System::Stats::kInetLayer_NumTunEps], - aSnapshot.mHighWatermarks[chip::System::Stats::kInetLayer_NumTunEps]); -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT } /** @@ -664,48 +660,6 @@ INET_ERROR InetLayer::NewUDPEndPoint(UDPEndPoint ** retEndPoint) } #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT -/** - * Creates a new TunEndPoint object. - * - * @note - * This function gets a free TunEndPoint object from a pre-allocated pool - * and also calls the explicit initializer on the new object. - * - * @param[in,out] retEndPoint A pointer to a pointer of the TunEndPoint object that is - * a return parameter upon completion of the object creation. - * *retEndPoint is NULL if creation fails. - * - * @retval #INET_ERROR_INCORRECT_STATE If the InetLayer object is not initialized. - * @retval #INET_ERROR_NO_ENDPOINTS If the InetLayer TunEndPoint pool is full and no new - * ones can be created. - * @retval #INET_NO_ERROR On success. - * - */ -INET_ERROR InetLayer::NewTunEndPoint(TunEndPoint ** retEndPoint) -{ - INET_ERROR err = INET_NO_ERROR; - *retEndPoint = NULL; - - VerifyOrExit(State == kState_Initialized, err = INET_ERROR_INCORRECT_STATE); - - *retEndPoint = TunEndPoint::sPool.TryCreate(*mSystemLayer); - if (*retEndPoint != NULL) - { - (*retEndPoint)->Init(this); - SYSTEM_STATS_INCREMENT(chip::System::Stats::kInetLayer_NumTunEps); - } - else - { - ChipLogError(Inet, "%s endpoint pool FULL", "Tun"); - err = INET_ERROR_NO_ENDPOINTS; - } - -exit: - return err; -} -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT - #if INET_CONFIG_ENABLE_DNS_RESOLVER /** * Perform an IP address resolution of a specified hostname. @@ -1130,12 +1084,6 @@ chip::System::Error InetLayer::HandleInetLayerEvent(chip::System::Object & aTarg break; #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - case kInetEvent_TunDataReceived: - static_cast(aTarget).HandleDataReceived(reinterpret_cast(aArgument)); - break; -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT - #if INET_CONFIG_ENABLE_DNS_RESOLVER case kInetEvent_DNSResolveComplete: static_cast(aTarget).HandleResolveComplete(); @@ -1208,15 +1156,6 @@ void InetLayer::PrepareSelect(int & nfds, fd_set * readfds, fd_set * writefds, f lEndPoint->PrepareIO().SetFDs(lEndPoint->mSocket, nfds, readfds, writefds, exceptfds); } #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT - -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - for (size_t i = 0; i < TunEndPoint::sPool.Size(); i++) - { - TunEndPoint * lEndPoint = TunEndPoint::sPool.Get(*mSystemLayer, i); - if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this)) - lEndPoint->PrepareIO().SetFDs(lEndPoint->mSocket, nfds, readfds, writefds, exceptfds); - } -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT } /** @@ -1290,18 +1229,7 @@ void InetLayer::HandleSelectResult(int selectRes, fd_set * readfds, fd_set * wri } #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - for (size_t i = 0; i < TunEndPoint::sPool.Size(); i++) - { - TunEndPoint * lEndPoint = TunEndPoint::sPool.Get(*mSystemLayer, i); - if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this)) - { - lEndPoint->mPendingIO = SocketEvents::FromFDs(lEndPoint->mSocket, readfds, writefds, exceptfds); - } - } -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT - - // Now call each active endpoint to handle its pending I/O. + // Now call each active endpoint to handle its pending I/O. #if INET_CONFIG_ENABLE_RAW_ENDPOINT for (size_t i = 0; i < RawEndPoint::sPool.Size(); i++) { @@ -1334,17 +1262,6 @@ void InetLayer::HandleSelectResult(int selectRes, fd_set * readfds, fd_set * wri } } #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT - -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - for (size_t i = 0; i < TunEndPoint::sPool.Size(); i++) - { - TunEndPoint * lEndPoint = TunEndPoint::sPool.Get(*mSystemLayer, i); - if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this)) - { - lEndPoint->HandlePendingIO(); - } - } -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT } } diff --git a/src/inet/InetLayer.h b/src/inet/InetLayer.h index 00b2b3206b8739..29a1b1eca8be36 100644 --- a/src/inet/InetLayer.h +++ b/src/inet/InetLayer.h @@ -74,10 +74,6 @@ #include #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT -#include -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT - #if CHIP_SYSTEM_CONFIG_USE_SOCKETS #if INET_CONFIG_ENABLE_DNS_RESOLVER && INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS #include @@ -160,10 +156,6 @@ class DLL_EXPORT InetLayer friend class UDPEndPoint; #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - friend class TunEndPoint; -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT - #if CHIP_SYSTEM_CONFIG_USE_SOCKETS #if INET_CONFIG_ENABLE_DNS_RESOLVER && INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS friend class AsyncDNSResolverSockets; @@ -202,10 +194,6 @@ class DLL_EXPORT InetLayer INET_ERROR NewUDPEndPoint(UDPEndPoint ** retEndPoint); #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - INET_ERROR NewTunEndPoint(TunEndPoint ** retEndPoint); -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT - // DNS Resolution #if INET_CONFIG_ENABLE_DNS_RESOLVER @@ -261,9 +249,6 @@ class DLL_EXPORT InetLayer inline static bool IsDroppableEvent(chip::System::EventType type) { return -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - type == kInetEvent_TunDataReceived || -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT #if INET_CONFIG_ENABLE_UDP_ENDPOINT type == kInetEvent_UDPDataReceived || #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT diff --git a/src/inet/InetLayerEvents.h b/src/inet/InetLayerEvents.h index ba5315519d9acc..1f52e758606955 100644 --- a/src/inet/InetLayerEvents.h +++ b/src/inet/InetLayerEvents.h @@ -48,8 +48,7 @@ enum kInetEvent_TCPError = _INET_CONFIG_EVENT(4), /**< The event for an error on a TCP connection */ kInetEvent_UDPDataReceived = _INET_CONFIG_EVENT(5), /**< The event for data reception over UDP */ kInetEvent_DNSResolveComplete = _INET_CONFIG_EVENT(6), /**< The event for DNS name resolution completion */ - kInetEvent_TunDataReceived = _INET_CONFIG_EVENT(7), /**< The event for data reception over a chip tunnel */ - kInetEvent_RawDataReceived = _INET_CONFIG_EVENT(8) /**< The event for data reception over an InetLayer raw endpoint */ + kInetEvent_RawDataReceived = _INET_CONFIG_EVENT(7) /**< The event for data reception over an InetLayer raw endpoint */ }; /** diff --git a/src/inet/TunEndPoint.cpp b/src/inet/TunEndPoint.cpp deleted file mode 100644 index 8ff11dde3c4f03..00000000000000 --- a/src/inet/TunEndPoint.cpp +++ /dev/null @@ -1,823 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2014-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 file implements the TunnelEndPoint abstraction APIs in the Inet - * Layer for creation and management of tunnel interfaces instantiated - * within either Linux Sockets or LwIP. - * - */ - -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS -#endif -#include "TunEndPoint.h" - -#include - -#include - -#include -#include - -#include "arpa-inet-compatibility.h" -#include -#include - -namespace chip { -namespace Inet { - -using chip::System::PacketBuffer; - -chip::System::ObjectPool TunEndPoint::sPool; - -using namespace chip::Encoding; - -/** - * Initialize the Tunnel EndPoint object. - * - * @note - * By convention, the \c Init method on \c EndPointBasis - * subclasses is \c private. It should not be used outside \c InetLayer. - * - * @param[in] inetLayer A pointer to the Inet layer object that - * created the Tunnel EndPoint. - * - */ -void TunEndPoint::Init(InetLayer * inetLayer) -{ - InitEndPointBasis(*inetLayer); -} - -/** - * Open a tunnel pseudo interface and create a handle to it. - * - * @note - * This method has different signatures on LwIP systems and - * POSIX systems. On LwIP, there is an argument for specifying the name - * of the tunnel interface. On POSIX, the method has no arguments and the - * name of the tunnel device is implied. - * - * @return INET_NO_ERROR on success, else a corresponding INET mapped OS error. - */ -#if CHIP_SYSTEM_CONFIG_USE_LWIP -INET_ERROR TunEndPoint::Open(void) -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - INET_ERROR TunEndPoint::Open(const char * intfName) -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS -{ - INET_ERROR err = INET_NO_ERROR; - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - struct netif * tNetif = NULL; - // Lock LwIP stack - LOCK_TCPIP_CORE(); - - tNetif = netif_add(&mTunNetIf, NULL, NULL, NULL, this, TunInterfaceNetifInit, tcpip_input); - - // UnLock LwIP stack - UNLOCK_TCPIP_CORE(); - - VerifyOrExit(tNetif != NULL, err = INET_ERROR_INTERFACE_INIT_FAILURE); - -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - - // Create the tunnel device - err = TunDevOpen(intfName); - SuccessOrExit(err); - - printf("Opened tunnel device: %s\n", intfName); - -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - if (err == INET_NO_ERROR) - mState = kState_Open; - -exit: - - return err; -} - -/** - * Close the tunnel pseudo interface device. - * - */ -void TunEndPoint::Close(void) -{ - if (mState != kState_Closed) - { - - // For LwIP, we do not remove the netif as it would have - // an impact on the interface iterator in CHIP which - // might lose reference to a particular netif index that - // it might be holding on to. -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - if (mSocket >= 0) - { - chip::System::Layer & lSystemLayer = SystemLayer(); - - // Wake the thread calling select so that it recognizes the socket is closed. - lSystemLayer.WakeSelect(); - TunDevClose(); - } - - // Clear any results from select() that indicate pending I/O for the socket. - mPendingIO.Clear(); - -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - mState = kState_Closed; - } -} - -/** - * Close the tunnel pseudo interface device and decrement the reference count - * of the InetLayer object. - * - */ -void TunEndPoint::Free() -{ - Close(); - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - DeferredFree(kReleaseDeferralErrorTactic_Release); -#else // !CHIP_SYSTEM_CONFIG_USE_LWIP - Release(); -#endif // !CHIP_SYSTEM_CONFIG_USE_LWIP -} - -/** - * Send an IPv6 packet to the tun device to be sent out. - * - * @note - * This method performs a couple of minimal sanity checks on the packet to - * be sure it is IP version 6 then dispatches it for encapsulation in a - * CHIP tunneling message. - * - * @param[in] message the IPv6 packet to send. - * - * @retval INET_NO_ERROR success: packet encapsulated and queued to send - * @retval INET_ERROR_NOT_SUPPORTED packet not IP version 6 - * @retval INET_ERROR_BAD_ARGS \c message is a \c NULL pointer - * - */ -INET_ERROR TunEndPoint::Send(PacketBuffer * msg) -{ - INET_ERROR ret = INET_NO_ERROR; - - ret = CheckV6Sanity(msg); - - if (ret == INET_NO_ERROR) - { - ret = TunDevSendMessage(msg); - } - - return ret; -} - -/** - * Extract the activation state of the tunnel interface. - * - * @returns \c true if the tunnel interface is active, - * otherwise \c false. - */ -bool TunEndPoint::IsInterfaceUp(void) const -{ - bool ret = false; - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - // Lock LwIP stack - LOCK_TCPIP_CORE(); - - ret = netif_is_up(&mTunNetIf); - - // UnLock LwIP stack - UNLOCK_TCPIP_CORE(); - - ExitNow(); -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - int sockfd = INET_INVALID_SOCKET_FD; - struct ::ifreq ifr; - - memset(&ifr, 0, sizeof(ifr)); - - // Get interface - if (TunGetInterface(mSocket, &ifr) < 0) - { - ExitNow(); - } - - sockfd = socket(AF_INET6, SOCK_DGRAM | NL_SOCK_CLOEXEC, IPPROTO_IP); - if (sockfd < 0) - { - ExitNow(); - } - - // Get interface flags - if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) - { - ExitNow(); - } - - ret = ((ifr.ifr_flags & IFF_UP) == IFF_UP); - -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - -exit: -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - if (sockfd >= 0) - { - close(sockfd); - } -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - return ret; -} - -/** - * Activate the tunnel interface. - * - * @retval INET_NO_ERROR success: tunnel interface is activated. - * @retval other another system or platform error - */ -INET_ERROR TunEndPoint::InterfaceUp(void) -{ - INET_ERROR err = INET_NO_ERROR; - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - // Lock LwIP stack - LOCK_TCPIP_CORE(); - - netif_set_up(&mTunNetIf); - - // UnLock LwIP stack - UNLOCK_TCPIP_CORE(); - - ExitNow(); -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - int sockfd = INET_INVALID_SOCKET_FD; - struct ::ifreq ifr; - - memset(&ifr, 0, sizeof(ifr)); - - // Get interface - if (TunGetInterface(mSocket, &ifr) < 0) - { - ExitNow(err = chip::System::MapErrorPOSIX(errno)); - } - - sockfd = socket(AF_INET6, SOCK_DGRAM | NL_SOCK_CLOEXEC, IPPROTO_IP); - if (sockfd < 0) - { - ExitNow(err = chip::System::MapErrorPOSIX(errno)); - } - - // Get interface flags - if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) - { - ExitNow(err = chip::System::MapErrorPOSIX(errno)); - } - - // Set flag to activate interface - ifr.ifr_flags |= (IFF_UP | IFF_RUNNING); - if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) - { - err = chip::System::MapErrorPOSIX(errno); - } - - // Set the MTU - ifr.ifr_mtu = CHIP_CONFIG_TUNNEL_INTERFACE_MTU; - if (ioctl(sockfd, SIOCSIFMTU, &ifr) < 0) - { - ExitNow(err = chip::System::MapErrorPOSIX(errno)); - } - -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - -exit: -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - if (sockfd >= 0) - { - close(sockfd); - } -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - return err; -} - -/** - * @brief Deactivate the tunnel interface. - * - * @retval INET_NO_ERROR success: tunnel interface is deactivated. - * @retval other another system or platform error - */ -INET_ERROR TunEndPoint::InterfaceDown(void) -{ - INET_ERROR err = INET_NO_ERROR; -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - int sockfd = INET_INVALID_SOCKET_FD; - struct ::ifreq ifr; -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - // Lock LwIP stack - LOCK_TCPIP_CORE(); - - // Remove the link local address from the netif - memset(&(mTunNetIf.ip6_addr[0]), 0, sizeof(ip6_addr_t)); - - netif_set_down(&mTunNetIf); - - // UnLock LwIP stack - UNLOCK_TCPIP_CORE(); - - ExitNow(); -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - memset(&ifr, 0, sizeof(ifr)); - - // Get interface - if (TunGetInterface(mSocket, &ifr) < 0) - { - ExitNow(err = chip::System::MapErrorPOSIX(errno)); - } - - sockfd = socket(AF_INET6, SOCK_DGRAM | NL_SOCK_CLOEXEC, IPPROTO_IP); - if (sockfd < 0) - { - ExitNow(err = chip::System::MapErrorPOSIX(errno)); - } - - // Get interface flags - if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) - { - ExitNow(err = chip::System::MapErrorPOSIX(errno)); - } - - // Set flag to deactivate interface - ifr.ifr_flags &= ~(IFF_UP); - if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) - { - err = chip::System::MapErrorPOSIX(errno); - } -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - -exit: -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - if (sockfd >= 0) - { - close(sockfd); - } -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - return err; -} - -/** - * @brief Get the tunnel interface identifier. - * - * @return The tunnel interface identifier. - */ -InterfaceId TunEndPoint::GetTunnelInterfaceId(void) -{ -#if CHIP_SYSTEM_CONFIG_USE_LWIP - return &mTunNetIf; -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - INET_ERROR err = INET_NO_ERROR; - InterfaceId tunIntfId = INET_NULL_INTERFACEID; - const char * tunIntfPtr = &tunIntfName[0]; - - err = InterfaceNameToId(tunIntfPtr, tunIntfId); - if (err != INET_NO_ERROR) - { - tunIntfId = INET_NULL_INTERFACEID; - } - - return tunIntfId; -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS -} - -#if CHIP_SYSTEM_CONFIG_USE_LWIP -/* Function for sending the IPv6 packets over LwIP */ -INET_ERROR TunEndPoint::TunDevSendMessage(PacketBuffer * msg) -{ - INET_ERROR ret = INET_NO_ERROR; - struct pbuf * p = NULL; - err_t err = ERR_OK; - - // no packet could be read, silently ignore this - VerifyOrExit(msg != NULL, ret = INET_ERROR_BAD_ARGS); - - p = (struct pbuf *) msg; - - // Call the input function for the netif object in LWIP. - // This essentially creates a TCP_IP msg and puts into - // the mbox message queue for processing by the TCP/IP - // stack. - - if ((err = tcpip_input(p, &mTunNetIf)) != ERR_OK) - { - LWIP_DEBUGF(NETIF_DEBUG, ("tunNetif_input: IP input error\n")); - ExitNow(ret = chip::System::MapErrorLwIP(err)); - } - -exit: - return (ret); -} -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS -/* Function for sending the IPv6 packets over Linux sockets */ -INET_ERROR TunEndPoint::TunDevSendMessage(PacketBuffer * msg) -{ - INET_ERROR ret = INET_NO_ERROR; - ssize_t lenSent = 0; - uint8_t * p = NULL; - - // no packet could be read, silently ignore this - VerifyOrExit(msg != NULL, ret = INET_ERROR_BAD_ARGS); - - p = msg->Start(); - - lenSent = write(mSocket, p, msg->DataLength()); - if (lenSent < 0) - { - ExitNow(ret = chip::System::MapErrorPOSIX(errno)); - } - else if (lenSent < msg->DataLength()) - { - ExitNow(ret = INET_ERROR_OUTBOUND_MESSAGE_TRUNCATED); - } - -exit: - if (msg != NULL) - { - PacketBuffer::Free(msg); - } - - return (ret); -} -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - -/* Function that performs some basic sanity checks for IPv6 packets */ -INET_ERROR TunEndPoint::CheckV6Sanity(PacketBuffer * msg) -{ - INET_ERROR err = INET_NO_ERROR; - uint8_t * p = NULL; - struct ip6_hdr * ip6hdr = NULL; - - p = msg->Start(); - - ip6hdr = (struct ip6_hdr *) p; - - VerifyOrExit(ip6hdr != NULL, err = INET_ERROR_BAD_ARGS); - - // Do some IPv6 sanity checks -#if CHIP_SYSTEM_CONFIG_USE_LWIP - if (IP6H_V(ip6hdr) != 6) -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - if ((ip6hdr->ip6_vfc >> 4) != 6) -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - { - ExitNow(err = INET_ERROR_NOT_SUPPORTED); - } - -exit: - - return err; -} - -#if CHIP_SYSTEM_CONFIG_USE_LWIP -/* Handler to send received packet to upper layer callback */ -void TunEndPoint::HandleDataReceived(PacketBuffer * msg) -{ - INET_ERROR err = INET_NO_ERROR; - if (mState == kState_Open && OnPacketReceived != NULL) - { - err = CheckV6Sanity(msg); - if (err == INET_NO_ERROR) - { - OnPacketReceived(this, msg); - } - else - { - if (OnReceiveError != NULL) - { - OnReceiveError(this, err); - } - - PacketBuffer::Free(msg); - } - } - else - { - PacketBuffer::Free(msg); - } -} - -/* Post an event to the Inet layer event queue from LwIP */ -err_t TunEndPoint::LwIPPostToInetEventQ(struct netif * netif, struct pbuf * p) -{ - err_t lwipErr = ERR_OK; - INET_ERROR err = INET_NO_ERROR; - TunEndPoint * ep = static_cast(netif->state); - chip::System::Layer & lSystemLayer = ep->SystemLayer(); - PacketBuffer * buf = PacketBuffer::NewWithAvailableSize(p->tot_len); - - // Starting off with a reserved size of the default CHIP_SYSTEM_CONFIG_HEADER_RESERVE_SIZE - // which allows for adding the CHIP header and the underlying transport and IP headers - // encapsulating this tunneled packet. - - VerifyOrExit(buf != NULL, lwipErr = ERR_MEM); - - buf->SetDataLength(p->tot_len); - - // Make a pbuf alloc and copy to post to Inetlayer queue because LwIP would free the - // passed pbuf as it made a down-call to send it out the tunnel netif. - - lwipErr = pbuf_copy((struct pbuf *) buf, p); - VerifyOrExit(lwipErr == ERR_OK, (void) lwipErr); - - err = lSystemLayer.PostEvent(*ep, kInetEvent_TunDataReceived, (uintptr_t) buf); - VerifyOrExit(err == INET_NO_ERROR, lwipErr = ERR_MEM); - - buf = NULL; - -exit: - if (buf != NULL) - { - PacketBuffer::Free(buf); - } - - return lwipErr; -} - -#if LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 -#if LWIP_IPV4 -/* Output handler for netif */ -err_t TunEndPoint::LwIPOutputIPv4(struct netif * netif, struct pbuf * p, const ip4_addr_t * addr) -{ - LWIP_UNUSED_ARG(addr); - - return LwIPPostToInetEventQ(netif, p); -} -#endif // LWIP_IPV4 - -#if LWIP_IPV6 -/* Output handler for netif */ -err_t TunEndPoint::LwIPOutputIPv6(struct netif * netif, struct pbuf * p, const ip6_addr_t * addr) -{ - LWIP_UNUSED_ARG(addr); - - return LwIPPostToInetEventQ(netif, p); -} -#endif // LWIP_IPV4 -#else // LWIP_VERSION_MAJOR <= 1 || LWIP_VERSION_MINOR < 5 -/* Receive message in LwIP */ -err_t TunEndPoint::LwIPReceiveTunMessage(struct netif * netif, struct pbuf * p, ip4_addr_t * addr) -{ - LWIP_UNUSED_ARG(addr); - - return LwIPPostToInetEventQ(netif, p); -} - -#if LWIP_IPV6 -err_t TunEndPoint::LwIPReceiveTunV6Message(struct netif * netif, struct pbuf * p, ip6_addr_t * addr) -{ - LWIP_UNUSED_ARG(addr); - - return LwIPPostToInetEventQ(netif, p); -} -#endif // LWIP_IPV6 -#endif // LWIP_VERSION_MAJOR <= 1 || LWIP_VERSION_MINOR < 5 - -/* Initialize the LwIP tunnel netif interface */ -err_t TunEndPoint::TunInterfaceNetifInit(struct netif * netif) -{ - netif->name[0] = 't'; - netif->name[1] = 'n'; -#if LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 -#if LWIP_IPV4 - netif->output = LwIPOutputIPv4; -#endif /* LWIP_IPV6 */ -#if LWIP_IPV6 - netif->output_ip6 = LwIPOutputIPv6; -#endif /* LWIP_IPV6 */ -#else // LWIP_VERSION_MAJOR <= 1 || LWIP_VERSION_MINOR < 5 - netif->output = LwIPReceiveTunMessage; -#if LWIP_IPV6 - netif->output_ip6 = LwIPReceiveTunV6Message; -#endif /* LWIP_IPV6 */ -#endif // LWIP_VERSION_MAJOR <= 1 || LWIP_VERSION_MINOR < 5 - netif->linkoutput = NULL; - - netif->mtu = CHIP_CONFIG_TUNNEL_INTERFACE_MTU; - - netif->hwaddr_len = 6; - memset(netif->hwaddr, 0, NETIF_MAX_HWADDR_LEN); - netif->hwaddr[5] = 1; - -#if LWIP_VERSION_MAJOR == 1 && LWIP_VERSION_MINOR < 5 - /* device capabilities */ - netif->flags |= NETIF_FLAG_POINTTOPOINT; -#endif // LWIP_VERSION_MAJOR <= 1 || LWIP_VERSION_MINOR >= 5 - - return ERR_OK; -} - -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS -/* Open a tun device in linux */ -INET_ERROR TunEndPoint::TunDevOpen(const char * intfName) -{ - struct ::ifreq ifr; - int fd = INET_INVALID_SOCKET_FD; - INET_ERROR ret = INET_NO_ERROR; - - if ((fd = open(INET_CONFIG_TUNNEL_DEVICE_NAME, O_RDWR | NL_O_CLOEXEC)) < 0) - { - ExitNow(ret = chip::System::MapErrorPOSIX(errno)); - } - - // Keep copy of open device fd - mSocket = fd; - - memset(&ifr, 0, sizeof(ifr)); - -#if HAVE_LINUX_IF_TUN_H - ifr.ifr_flags = IFF_TUN | IFF_NO_PI; -#endif - - if (*intfName) - { - strncpy(ifr.ifr_name, intfName, sizeof(ifr.ifr_name) - 1); - ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; - } - -#if HAVE_LINUX_IF_TUN_H - if (ioctl(fd, TUNSETIFF, (void *) &ifr) < 0) - { - ExitNow(ret = chip::System::MapErrorPOSIX(errno)); - } -#endif - - // Verify name - memset(&ifr, 0, sizeof(ifr)); - if (TunGetInterface(fd, &ifr) < 0) - { - ExitNow(ret = chip::System::MapErrorPOSIX(errno)); - } - - if (ifr.ifr_name[0] != '\0') - { - // Keep member copy of interface name and Id - strncpy(tunIntfName, ifr.ifr_name, sizeof(tunIntfName) - 1); - tunIntfName[sizeof(tunIntfName) - 1] = '\0'; - } - else - { - ExitNow(ret = chip::System::MapErrorPOSIX(errno)); - } - -exit: - - if (ret != INET_NO_ERROR) - { - TunDevClose(); - } - - return ret; -} - -/* Close a tun device */ -void TunEndPoint::TunDevClose(void) -{ - if (mSocket >= 0) - { - close(mSocket); - } - mSocket = INET_INVALID_SOCKET_FD; -} - -/* Get the tun device interface in Linux */ -int TunEndPoint::TunGetInterface(int fd, struct ::ifreq * ifr) -{ -#if HAVE_LINUX_IF_TUN_H - return ioctl(fd, TUNGETIFF, (void *) ifr); -#else - return -1; -#endif -} - -/* Read packets from TUN device in Linux */ -INET_ERROR TunEndPoint::TunDevRead(PacketBuffer * msg) -{ - ssize_t rcvLen; - INET_ERROR err = INET_NO_ERROR; - uint8_t * p = NULL; - p = msg->Start(); - - rcvLen = read(mSocket, p, msg->AvailableDataLength()); - if (rcvLen < 0) - { - err = chip::System::MapErrorPOSIX(errno); - } - else if (rcvLen > msg->AvailableDataLength()) - { - err = INET_ERROR_INBOUND_MESSAGE_TOO_BIG; - } - else - { - msg->SetDataLength((uint16_t) rcvLen); - } - - return err; -} - -/* Prepare socket for reading */ -SocketEvents TunEndPoint::PrepareIO() -{ - SocketEvents res; - - if (mState == kState_Open && OnPacketReceived != NULL) - { - res.SetRead(); - } - - return res; -} - -/* Read from the Tun device in Linux and pass up to upper layer callback */ -void TunEndPoint::HandlePendingIO() -{ - INET_ERROR err = INET_NO_ERROR; - - if (mState == kState_Open && OnPacketReceived != NULL && mPendingIO.IsReadable()) - { - - PacketBuffer * buf = PacketBuffer::New(0); - - if (buf != NULL) - { - // Read data from Tun Device - err = TunDevRead(buf); - if (err == INET_NO_ERROR) - { - err = CheckV6Sanity(buf); - } - } - else - { - err = INET_ERROR_NO_MEMORY; - } - - if (err == INET_NO_ERROR) - { - OnPacketReceived(this, buf); - } - else - { - PacketBuffer::Free(buf); - if (OnReceiveError != NULL) - { - OnReceiveError(this, err); - } - } - } - - mPendingIO.Clear(); -} - -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - -} // namespace Inet -} // namespace chip diff --git a/src/inet/TunEndPoint.h b/src/inet/TunEndPoint.h deleted file mode 100644 index 140d722e1139e2..00000000000000 --- a/src/inet/TunEndPoint.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2014-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::TunEndPoint class, where - * the CHIP Inet Layer encapsulates its foundational logic for the chip - * tunneling agent. - */ - -#ifndef TUNENDPOINT_H -#define TUNENDPOINT_H - -#include -#include -#include - -#include - -#if CHIP_SYSTEM_CONFIG_USE_LWIP -#include "lwip/netif.h" -#include -#include -#include -#include -#include -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS -#include -#include -#include -#include -#include -#include -#include -#include - -#if HAVE_LINUX_IF_TUN_H -#include -#endif // HAVE_LINUX_IF_TUN_H - -#if HAVE_LINUX_ROUTE_H -#include -#endif // HAVE_LINUX_ROUTE_H - -#if HAVE_LINUX_IPV6_ROUTE_H -#include -#endif // HAVE_LINUX_IPV6_ROUTE_H -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - -/** Define portable flags for closing file descriptor upon - * inheritance by an external sub-process. This is only a - * safety guard. Code that spawns a child process must make - * sure that any unneeded inherited file descriptor is closed. - */ -#ifdef O_CLOEXEC -#define NL_O_CLOEXEC O_CLOEXEC -#else -#define NL_O_CLOEXEC 0 -#endif - -#ifdef SOCK_CLOEXEC -#define NL_SOCK_CLOEXEC SOCK_CLOEXEC -#else -#define NL_SOCK_CLOEXEC 0 -#endif - -namespace chip { -namespace Inet { - -class InetLayer; -class IPPacketInfo; - -/** - * @brief Objects of this class represent tunnel interfaces. - * - * @details - * CHIP Inet Layer encapsulates methods for interacting on both POSIX systems - * and LwIP systems with an IP-in-IP tunneling mechanism for supporting the - * chip tunnel agent. - */ -class DLL_EXPORT TunEndPoint : public EndPointBasis -{ - friend class InetLayer; - -public: - /** - * @brief Basic dynamic state of the underlying tunnel. - * - * @details - * Objects are initialized in the "open" state, proceed to the "closed" - * state when they are ready to be recycled. - */ - enum - { - kState_Open = 0, - kState_Closed = 1 - } mState; - - /** - * @brief Operation when setting route to tunnel interface. - * - * @details - * Values of this enumerated type are used when setting a route for the - * encapsulated tunnel. - */ - typedef enum RouteOp - { - kRouteTunIntf_Add = 0, /**< Add route for a prefix. */ - kRouteTunIntf_Del = 1 /**< Remove route for a prefix. */ - } RouteOp; - - /** Pointer to application-specific state object. */ - void * mAppState; - - void Init(InetLayer * inetLayer); - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - INET_ERROR Open(void); -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - INET_ERROR Open(const char * intfName); -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS - - /** Close the tunnel and release handle on the object. */ - void Free(void); - - INET_ERROR Send(chip::System::PacketBuffer * message); - - bool IsInterfaceUp(void) const; - - INET_ERROR InterfaceUp(void); - - INET_ERROR InterfaceDown(void); - - /** - * @brief Type of packet receive event handler. - * - * @details - * Type of delegate to a higher layer to act upon receipt of an IPv6 - * packet from the tunnel. - * - * @param[in] endPoint A pointer to the TunEndPoint object. - * @param[in] message A pointer to the chip::System::PacketBuffer message object. - */ - typedef void (*OnPacketReceivedFunct)(TunEndPoint * endPoint, chip::System::PacketBuffer * message); - - /** The endpoint's packet receive event handler delegate. */ - OnPacketReceivedFunct OnPacketReceived; - - /** - * @brief Type of error event handler. - * - * @details - * Type of delegate to a higher layer to act upon error processing an IPv6 - * packet from the tunnel. - * - * @param[in] endPoint The TunEndPoint object. - * @param[in] err Error code reported. - */ - typedef void (*OnReceiveErrorFunct)(TunEndPoint * endPoint, INET_ERROR err); - OnReceiveErrorFunct OnReceiveError; - - InterfaceId GetTunnelInterfaceId(void); - -private: - TunEndPoint(void); // not defined - TunEndPoint(const TunEndPoint &); // not defined - ~TunEndPoint(void); // not defined - - static chip::System::ObjectPool sPool; - - /** Close the tunnel. */ - void Close(void); - - // Function that performs some sanity tests for IPv6 packets. - INET_ERROR CheckV6Sanity(chip::System::PacketBuffer * message); - // Function for sending the IPv6 packets over Linux sockets or LwIP. - INET_ERROR TunDevSendMessage(chip::System::PacketBuffer * msg); - -#if CHIP_SYSTEM_CONFIG_USE_LWIP - // Network interface structure holding the tunnel interface in LwIP. - struct netif mTunNetIf; - - INET_ERROR TunDevOpen(void); - void HandleDataReceived(chip::System::PacketBuffer * msg); - - static err_t LwIPPostToInetEventQ(struct netif * netif, struct pbuf * p); -#if LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5 -#if LWIP_IPV4 - static err_t LwIPOutputIPv4(struct netif * netif, struct pbuf * p, const ip4_addr_t * addr); -#endif // LWIP_IPV4 -#if LWIP_IPV6 - static err_t LwIPOutputIPv6(struct netif * netif, struct pbuf * p, const ip6_addr_t * addr); -#endif // LWIP_IPV6 -#else // LWIP_VERSION_MAJOR <= 1 || LWIP_VERSION_MINOR < 5 - static err_t LwIPReceiveTunMessage(struct netif * netif, struct pbuf * p, ip4_addr_t * addr); -#if LWIP_IPV6 - static err_t LwIPReceiveTunV6Message(struct netif * netif, struct pbuf * p, ip6_addr_t * addr); -#endif // LWIP_IPV6 -#endif // LWIP_VERSION_MAJOR <= 1 || LWIP_VERSION_MINOR < 5 - static err_t TunInterfaceNetifInit(struct netif * netif); -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP - -#if CHIP_SYSTEM_CONFIG_USE_SOCKETS - // Tunnel interface name - char tunIntfName[IFNAMSIZ]; - - INET_ERROR TunDevOpen(const char * interfaceName); - void TunDevClose(void); - INET_ERROR TunDevRead(chip::System::PacketBuffer * msg); - static int TunGetInterface(int fd, struct ::ifreq * ifr); - - SocketEvents PrepareIO(void); - void HandlePendingIO(void); -#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS -}; - -} // namespace Inet -} // namespace chip - -#endif // !defined(TUNENDPOINT_H) diff --git a/src/inet/inet.gni b/src/inet/inet.gni index 4b72ebf2eaf9e0..1b77bbe1a4025d 100644 --- a/src/inet/inet.gni +++ b/src/inet/inet.gni @@ -31,9 +31,6 @@ declare_args() { # Enable TCP endpoint. chip_inet_config_enable_tcp_endpoint = true - - # Enable TUN endpoint. - chip_inet_config_enable_tun_endpoint = current_os == "linux" } declare_args() { diff --git a/src/inet/tests/TestInetEndPoint.cpp b/src/inet/tests/TestInetEndPoint.cpp index 9ac01c473f3698..dd86d1b6b44648 100644 --- a/src/inet/tests/TestInetEndPoint.cpp +++ b/src/inet/tests/TestInetEndPoint.cpp @@ -93,9 +93,6 @@ static void TestInetPre(nlTestSuite * inSuite, void * inContext) #if INET_CONFIG_ENABLE_TCP_ENDPOINT TCPEndPoint * testTCPEP = NULL; #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - TunEndPoint * testTunEP = NULL; -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT INET_ERROR err = INET_NO_ERROR; IPAddress testDestAddr = IPAddress::Any; char testHostName[20] = "www.nest.com"; @@ -110,11 +107,6 @@ static void TestInetPre(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, err == INET_ERROR_INCORRECT_STATE); #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - err = gInet.NewTunEndPoint(&testTunEP); - NL_TEST_ASSERT(inSuite, err == INET_ERROR_INCORRECT_STATE); -#endif // INET_CONFIG_ENABLE_TUN_ENDPOINT - #if INET_CONFIG_ENABLE_TCP_ENDPOINT err = gInet.NewTCPEndPoint(&testTCPEP); NL_TEST_ASSERT(inSuite, err == INET_ERROR_INCORRECT_STATE); @@ -318,9 +310,6 @@ static void TestInetEndPoint(nlTestSuite * inSuite, void * inContext) RawEndPoint * testRaw4EP = NULL; #endif // INET_CONFIG_ENABLE_IPV4 UDPEndPoint * testUDPEP = NULL; -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - TunEndPoint * testTunEP = NULL; -#endif TCPEndPoint * testTCPEP1 = NULL; PacketBuffer * buf = PacketBuffer::New(); bool didBind = false; @@ -338,11 +327,6 @@ static void TestInetEndPoint(nlTestSuite * inSuite, void * inContext) err = gInet.NewUDPEndPoint(&testUDPEP); NL_TEST_ASSERT(inSuite, err == INET_NO_ERROR); -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - err = gInet.NewTunEndPoint(&testTunEP); - NL_TEST_ASSERT(inSuite, err == INET_NO_ERROR); -#endif - err = gInet.NewTCPEndPoint(&testTCPEP1); NL_TEST_ASSERT(inSuite, err == INET_NO_ERROR); @@ -488,21 +472,6 @@ static void TestInetEndPoint(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, err == INET_ERROR_INCORRECT_STATE); #endif // INET_CONFIG_ENABLE_IPV4 -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - // TunEndPoint special cases to cover the error branch - testTunEP->Init(&gInet); - InterfaceId tunId = testTunEP->GetTunnelInterfaceId(); - NL_TEST_ASSERT(inSuite, tunId == INET_NULL_INTERFACEID); - NL_TEST_ASSERT(inSuite, !testTunEP->IsInterfaceUp()); - err = testTunEP->InterfaceUp(); - NL_TEST_ASSERT(inSuite, err != INET_NO_ERROR); - err = testTunEP->InterfaceDown(); - NL_TEST_ASSERT(inSuite, err != INET_NO_ERROR); - err = testTunEP->Send(buf); - NL_TEST_ASSERT(inSuite, err != INET_NO_ERROR); - testTunEP->Free(); -#endif - testTCPEP1->Shutdown(); } @@ -511,9 +480,6 @@ static void TestInetEndPointLimit(nlTestSuite * inSuite, void * inContext) { RawEndPoint * testRawEP = NULL; UDPEndPoint * testUDPEP = NULL; -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - TunEndPoint * testTunEP = NULL; -#endif TCPEndPoint * testTCPEP = NULL; INET_ERROR err; char numTimersTest[CHIP_SYSTEM_CONFIG_NUM_TIMERS + 1]; @@ -526,12 +492,6 @@ static void TestInetEndPointLimit(nlTestSuite * inSuite, void * inContext) err = gInet.NewUDPEndPoint(&testUDPEP); NL_TEST_ASSERT(inSuite, err == INET_ERROR_NO_ENDPOINTS); -#if INET_CONFIG_ENABLE_TUN_ENDPOINT - for (int i = 0; i < INET_CONFIG_NUM_TUN_ENDPOINTS + 1; i++) - err = gInet.NewTunEndPoint(&testTunEP); - NL_TEST_ASSERT(inSuite, err == INET_ERROR_NO_ENDPOINTS); -#endif - for (int i = 0; i < INET_CONFIG_NUM_TCP_ENDPOINTS + 1; i++) err = gInet.NewTCPEndPoint(&testTCPEP); NL_TEST_ASSERT(inSuite, err == INET_ERROR_NO_ENDPOINTS); diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index b6e1cf7b1958c3..09b2e33d3dd3cc 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -122,7 +122,6 @@ source_set("chip_config_header") { "CHIPConfig.h", "CHIPEventLoggingConfig.h", "CHIPTimeConfig.h", - "CHIPTunnelConfig.h", ] public_configs = [ ":chip_config" ] diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index cf628edbde6e1b..b96357aad36955 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -79,8 +79,6 @@ #include "CHIPTimeConfig.h" -#include "CHIPTunnelConfig.h" - #include "CHIPEventLoggingConfig.h" #include "CHIPWRMPConfig.h" @@ -1044,17 +1042,6 @@ #define CHIP_CONFIG_MAX_INCOMING_TCP_CON_FROM_SINGLE_IP 2 #endif // CHIP_CONFIG_MAX_INCOMING_TCP_CON_FROM_SINGLE_IP -/** - * @def CHIP_CONFIG_MAX_TUNNELS - * - * @brief - * Maximum number of simultaneously active connection tunnels. - * - */ -#ifndef CHIP_CONFIG_MAX_TUNNELS -#define CHIP_CONFIG_MAX_TUNNELS 1 -#endif // CHIP_CONFIG_MAX_TUNNELS - /** * @def CHIP_CONFIG_MAX_SESSION_KEYS * diff --git a/src/lib/core/CHIPError.cpp b/src/lib/core/CHIPError.cpp index 1e8aac85cd4ed3..3e668852872ee3 100644 --- a/src/lib/core/CHIPError.cpp +++ b/src/lib/core/CHIPError.cpp @@ -402,24 +402,9 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, int32_t err) case CHIP_ERROR_UNSOLICITED_MSG_NO_ORIGINATOR: desc = "Unsolicited msg with originator bit clear"; break; - case CHIP_ERROR_UNSUPPORTED_TUNNEL_VERSION: - desc = "Unsupported Tunnel version"; - break; case CHIP_ERROR_INVALID_FABRIC_ID: desc = "Invalid Fabric Id"; break; - case CHIP_ERROR_TUNNEL_NEXTHOP_TABLE_FULL: - desc = "Local tunnel nexthop table full"; - break; - case CHIP_ERROR_TUNNEL_SERVICE_QUEUE_FULL: - desc = "Service queue full"; - break; - case CHIP_ERROR_TUNNEL_PEER_ENTRY_NOT_FOUND: - desc = "Shortcut Tunnel peer entry not found"; - break; - case CHIP_ERROR_TUNNEL_FORCE_ABORT: - desc = "Forced Tunnel Abort"; - break; case CHIP_ERROR_DRBG_ENTROPY_SOURCE_FAILED: desc = "DRBG entropy source failed to generate entropy data"; break; @@ -558,12 +543,6 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, int32_t err) case CHIP_ERROR_INCOMPATIBLE_SCHEMA_VERSION: desc = "Incompatible data schema version"; break; - case CHIP_ERROR_TUNNEL_ROUTING_RESTRICTED: - desc = "Restricted Routing: Border Routing disabled"; - break; - case CHIP_ERROR_TUNNEL_RESET_RECONNECT_ALREADY_ARMED: - desc = "The Reset reconnect timer is already armed"; - break; case CHIP_ERROR_MISMATCH_UPDATE_REQUIRED_VERSION: desc = "Update Required Version mismatch"; break; diff --git a/src/lib/core/CHIPError.h b/src/lib/core/CHIPError.h index f7911d2e2482ae..c9db9464fb0640 100644 --- a/src/lib/core/CHIPError.h +++ b/src/lib/core/CHIPError.h @@ -1124,33 +1124,6 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; */ #define CHIP_ERROR_INVALID_FABRIC_ID _CHIP_ERROR(113) -/** - * @def CHIP_ERROR_UNSUPPORTED_TUNNEL_VERSION - * - * @brief - * A tunnel version is unsupported. - * - */ -#define CHIP_ERROR_UNSUPPORTED_TUNNEL_VERSION _CHIP_ERROR(114) - -/** - * @def CHIP_ERROR_TUNNEL_NEXTHOP_TABLE_FULL - * - * @brief - * A tunnel nexthop table is full. - * - */ -#define CHIP_ERROR_TUNNEL_NEXTHOP_TABLE_FULL _CHIP_ERROR(115) - -/** - * @def CHIP_ERROR_TUNNEL_SERVICE_QUEUE_FULL - * - * @brief - * A tunnel service queue is full. - * - */ -#define CHIP_ERROR_TUNNEL_SERVICE_QUEUE_FULL _CHIP_ERROR(116) - /** * @def CHIP_ERROR_DRBG_ENTROPY_SOURCE_FAILED * @@ -1313,15 +1286,6 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; */ #define CHIP_ERROR_INVALID_TIME _CHIP_ERROR(134) -/** - * @def CHIP_ERROR_TUNNEL_PEER_ENTRY_NOT_FOUND - * - * @brief - * A tunnel shortcut peer entry not found in the cache. - * - */ -#define CHIP_ERROR_TUNNEL_PEER_ENTRY_NOT_FOUND _CHIP_ERROR(135) - /** * @def CHIP_ERROR_LOCKING_FAILURE * @@ -1329,7 +1293,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * Failure to acquire or release an OS provided mutex. * */ -#define CHIP_ERROR_LOCKING_FAILURE _CHIP_ERROR(136) +#define CHIP_ERROR_LOCKING_FAILURE _CHIP_ERROR(135) /** * @def CHIP_ERROR_UNSUPPORTED_PASSCODE_CONFIG @@ -1338,7 +1302,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * A passcode encryption configuration is unsupported. * */ -#define CHIP_ERROR_UNSUPPORTED_PASSCODE_CONFIG _CHIP_ERROR(137) +#define CHIP_ERROR_UNSUPPORTED_PASSCODE_CONFIG _CHIP_ERROR(136) /** * @def CHIP_ERROR_PASSCODE_AUTHENTICATION_FAILED @@ -1347,7 +1311,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The CHIP passcode authentication failed. * */ -#define CHIP_ERROR_PASSCODE_AUTHENTICATION_FAILED _CHIP_ERROR(138) +#define CHIP_ERROR_PASSCODE_AUTHENTICATION_FAILED _CHIP_ERROR(137) /** * @def CHIP_ERROR_PASSCODE_FINGERPRINT_FAILED @@ -1356,18 +1320,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The CHIP passcode fingerprint failed. * */ -#define CHIP_ERROR_PASSCODE_FINGERPRINT_FAILED _CHIP_ERROR(139) - -/** - * @def CHIP_ERROR_TUNNEL_FORCE_ABORT - * - * @brief - * The CHIP error code to be used with the API for stopping - * the tunnel to enforce it to abort its TCP connection and return - * synchronously to the caller. - * - */ -#define CHIP_ERROR_TUNNEL_FORCE_ABORT _CHIP_ERROR(140) +#define CHIP_ERROR_PASSCODE_FINGERPRINT_FAILED _CHIP_ERROR(138) /** * @def CHIP_ERROR_SERIALIZATION_ELEMENT_NULL @@ -1376,7 +1329,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The element of the struct is null. * */ -#define CHIP_ERROR_SERIALIZATION_ELEMENT_NULL _CHIP_ERROR(141) +#define CHIP_ERROR_SERIALIZATION_ELEMENT_NULL _CHIP_ERROR(139) /** * @def CHIP_ERROR_WRONG_CERT_SIGNATURE_ALGORITHM @@ -1385,7 +1338,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The certificate was not signed using the required signature algorithm. * */ -#define CHIP_ERROR_WRONG_CERT_SIGNATURE_ALGORITHM _CHIP_ERROR(142) +#define CHIP_ERROR_WRONG_CERT_SIGNATURE_ALGORITHM _CHIP_ERROR(140) /** * @def CHIP_ERROR_WRONG_CHIP_SIGNATURE_ALGORITHM @@ -1394,7 +1347,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The CHIP signature was not signed using the required signature algorithm. * */ -#define CHIP_ERROR_WRONG_CHIP_SIGNATURE_ALGORITHM _CHIP_ERROR(143) +#define CHIP_ERROR_WRONG_CHIP_SIGNATURE_ALGORITHM _CHIP_ERROR(141) /** * @def CHIP_ERROR_SCHEMA_MISMATCH @@ -1403,7 +1356,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * A mismatch in schema was encountered. * */ -#define CHIP_ERROR_SCHEMA_MISMATCH _CHIP_ERROR(144) +#define CHIP_ERROR_SCHEMA_MISMATCH _CHIP_ERROR(142) /** * @def CHIP_ERROR_INVALID_INTEGER_VALUE @@ -1412,7 +1365,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * An integer does not have the kind of value we expect. * */ -#define CHIP_ERROR_INVALID_INTEGER_VALUE _CHIP_ERROR(145) +#define CHIP_ERROR_INVALID_INTEGER_VALUE _CHIP_ERROR(143) /** * @def CHIP_ERROR_CASE_RECONFIG_REQUIRED @@ -1421,7 +1374,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * CASE is required to reconfigure. * */ -#define CHIP_ERROR_CASE_RECONFIG_REQUIRED _CHIP_ERROR(146) +#define CHIP_ERROR_CASE_RECONFIG_REQUIRED _CHIP_ERROR(144) /** * @def CHIP_ERROR_TOO_MANY_CASE_RECONFIGURATIONS @@ -1430,7 +1383,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * Too many CASE reconfigurations were received. * */ -#define CHIP_ERROR_TOO_MANY_CASE_RECONFIGURATIONS _CHIP_ERROR(147) +#define CHIP_ERROR_TOO_MANY_CASE_RECONFIGURATIONS _CHIP_ERROR(145) /** * @def CHIP_ERROR_BAD_REQUEST @@ -1439,7 +1392,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The request cannot be processed or fulfilled * */ -#define CHIP_ERROR_BAD_REQUEST _CHIP_ERROR(148) +#define CHIP_ERROR_BAD_REQUEST _CHIP_ERROR(146) /** * @def CHIP_ERROR_INVALID_MESSAGE_FLAG @@ -1448,7 +1401,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * One or more message flags have invalid value. * */ -#define CHIP_ERROR_INVALID_MESSAGE_FLAG _CHIP_ERROR(149) +#define CHIP_ERROR_INVALID_MESSAGE_FLAG _CHIP_ERROR(147) /** * @def CHIP_ERROR_KEY_EXPORT_RECONFIGURE_REQUIRED @@ -1457,7 +1410,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * Key export protocol required to reconfigure. * */ -#define CHIP_ERROR_KEY_EXPORT_RECONFIGURE_REQUIRED _CHIP_ERROR(150) +#define CHIP_ERROR_KEY_EXPORT_RECONFIGURE_REQUIRED _CHIP_ERROR(148) /** * @def CHIP_ERROR_INVALID_KEY_EXPORT_CONFIGURATION @@ -1466,7 +1419,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * A key export protocol configuration is invalid. * */ -#define CHIP_ERROR_INVALID_KEY_EXPORT_CONFIGURATION _CHIP_ERROR(151) +#define CHIP_ERROR_INVALID_KEY_EXPORT_CONFIGURATION _CHIP_ERROR(149) /** * @def CHIP_ERROR_NO_COMMON_KEY_EXPORT_CONFIGURATIONS @@ -1475,7 +1428,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * No key export protocol configuration is in common. * */ -#define CHIP_ERROR_NO_COMMON_KEY_EXPORT_CONFIGURATIONS _CHIP_ERROR(152) +#define CHIP_ERROR_NO_COMMON_KEY_EXPORT_CONFIGURATIONS _CHIP_ERROR(150) /** * @def CHIP_ERROR_NO_KEY_EXPORT_DELEGATE @@ -1484,7 +1437,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * No key export delegate is set. * */ -#define CHIP_ERROR_NO_KEY_EXPORT_DELEGATE _CHIP_ERROR(153) +#define CHIP_ERROR_NO_KEY_EXPORT_DELEGATE _CHIP_ERROR(151) /** * @def CHIP_ERROR_UNAUTHORIZED_KEY_EXPORT_REQUEST @@ -1493,7 +1446,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * Unauthorized key export request. * */ -#define CHIP_ERROR_UNAUTHORIZED_KEY_EXPORT_REQUEST _CHIP_ERROR(154) +#define CHIP_ERROR_UNAUTHORIZED_KEY_EXPORT_REQUEST _CHIP_ERROR(152) /** * @def CHIP_ERROR_UNAUTHORIZED_KEY_EXPORT_RESPONSE @@ -1502,7 +1455,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * Unauthorized key export response. * */ -#define CHIP_ERROR_UNAUTHORIZED_KEY_EXPORT_RESPONSE _CHIP_ERROR(155) +#define CHIP_ERROR_UNAUTHORIZED_KEY_EXPORT_RESPONSE _CHIP_ERROR(153) /** * @def CHIP_ERROR_EXPORTED_KEY_AUTHENTICATION_FAILED @@ -1511,7 +1464,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The CHIP exported encrypted key authentication failed. * */ -#define CHIP_ERROR_EXPORTED_KEY_AUTHENTICATION_FAILED _CHIP_ERROR(156) +#define CHIP_ERROR_EXPORTED_KEY_AUTHENTICATION_FAILED _CHIP_ERROR(154) /** * @def CHIP_ERROR_TOO_MANY_SHARED_SESSION_END_NODES @@ -1521,7 +1474,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * the maximum limit. * */ -#define CHIP_ERROR_TOO_MANY_SHARED_SESSION_END_NODES _CHIP_ERROR(157) +#define CHIP_ERROR_TOO_MANY_SHARED_SESSION_END_NODES _CHIP_ERROR(155) /** * @def CHIP_ERROR_MALFORMED_DATA_ELEMENT @@ -1531,7 +1484,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * the required elements, or it contais both the MergeData element * and DeletedDictionaryKeyList. */ -#define CHIP_ERROR_MALFORMED_DATA_ELEMENT _CHIP_ERROR(158) +#define CHIP_ERROR_MALFORMED_DATA_ELEMENT _CHIP_ERROR(156) /** * @def CHIP_ERROR_WRONG_CERT_TYPE @@ -1539,7 +1492,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * @brief * The presented certificate was of the wrong type. */ -#define CHIP_ERROR_WRONG_CERT_TYPE _CHIP_ERROR(159) +#define CHIP_ERROR_WRONG_CERT_TYPE _CHIP_ERROR(157) /** * @def CHIP_ERROR_DEFAULT_EVENT_HANDLER_NOT_CALLED @@ -1548,7 +1501,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The application's event handler failed to call the default event handler function * when presented with an unknown event. */ -#define CHIP_ERROR_DEFAULT_EVENT_HANDLER_NOT_CALLED _CHIP_ERROR(162) +#define CHIP_ERROR_DEFAULT_EVENT_HANDLER_NOT_CALLED _CHIP_ERROR(158) /** * @def CHIP_ERROR_PERSISTED_STORAGE_FAILED @@ -1557,7 +1510,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * Persisted storage memory read/write failure. * */ -#define CHIP_ERROR_PERSISTED_STORAGE_FAILED _CHIP_ERROR(163) +#define CHIP_ERROR_PERSISTED_STORAGE_FAILED _CHIP_ERROR(159) /** * @def CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND @@ -1566,7 +1519,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The specific value is not found in the persisted storage. * */ -#define CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND _CHIP_ERROR(164) +#define CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND _CHIP_ERROR(160) /** * @def CHIP_ERROR_PROFILE_STRING_CONTEXT_ALREADY_REGISTERED @@ -1575,7 +1528,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The specified profile string support context is already registered. * */ -#define CHIP_ERROR_PROFILE_STRING_CONTEXT_ALREADY_REGISTERED _CHIP_ERROR(165) +#define CHIP_ERROR_PROFILE_STRING_CONTEXT_ALREADY_REGISTERED _CHIP_ERROR(161) /** * @def CHIP_ERROR_PROFILE_STRING_CONTEXT_NOT_REGISTERED @@ -1584,7 +1537,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The specified profile string support context is not registered. * */ -#define CHIP_ERROR_PROFILE_STRING_CONTEXT_NOT_REGISTERED _CHIP_ERROR(166) +#define CHIP_ERROR_PROFILE_STRING_CONTEXT_NOT_REGISTERED _CHIP_ERROR(162) /** * @def CHIP_ERROR_INCOMPATIBLE_SCHEMA_VERSION @@ -1592,25 +1545,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * @brief * Encountered a mismatch in compatibility w.r.t to IDL schema version */ -#define CHIP_ERROR_INCOMPATIBLE_SCHEMA_VERSION _CHIP_ERROR(167) - -/** - * @def CHIP_ERROR_TUNNEL_ROUTING_RESTRICTED - * - * @brief - * Indicates that the Tunnel can only be used by the border gateway - * for itself and, it cannot forward packets for any other device. - * - */ -#define CHIP_ERROR_TUNNEL_ROUTING_RESTRICTED _CHIP_ERROR(168) - -/** - * @def CHIP_ERROR_TUNNEL_RESET_RECONNECT_ALREADY_ARMED - * - * @brief - * The Tunnel reset reconnect timer is already armed - */ -#define CHIP_ERROR_TUNNEL_RESET_RECONNECT_ALREADY_ARMED _CHIP_ERROR(169) +#define CHIP_ERROR_INCOMPATIBLE_SCHEMA_VERSION _CHIP_ERROR(163) /** * @def CHIP_ERROR_MISMATCH_UPDATE_REQUIRED_VERSION @@ -1618,7 +1553,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * @brief * Encountered a mismatch between update required version and current version */ -#define CHIP_ERROR_MISMATCH_UPDATE_REQUIRED_VERSION _CHIP_ERROR(170) +#define CHIP_ERROR_MISMATCH_UPDATE_REQUIRED_VERSION _CHIP_ERROR(164) /** @@ -1627,7 +1562,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * @brief * The CHIP message is not granted access for further processing. */ -#define CHIP_ERROR_ACCESS_DENIED _CHIP_ERROR(173) +#define CHIP_ERROR_ACCESS_DENIED _CHIP_ERROR(165) /** * @def CHIP_ERROR_UNKNOWN_RESOURCE_ID @@ -1636,7 +1571,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * Unknown resource ID * */ -#define CHIP_ERROR_UNKNOWN_RESOURCE_ID _CHIP_ERROR(174) +#define CHIP_ERROR_UNKNOWN_RESOURCE_ID _CHIP_ERROR(166) /** * @def CHIP_ERROR_VERSION_MISMATCH @@ -1646,7 +1581,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * because the local changes are based on an obsolete version of the * data. */ -#define CHIP_ERROR_VERSION_MISMATCH _CHIP_ERROR(176) +#define CHIP_ERROR_VERSION_MISMATCH _CHIP_ERROR(167) /** * @def CHIP_ERROR_UNSUPPORTED_THREAD_NETWORK_CREATE @@ -1657,7 +1592,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * together with CHIP Fabric using CrateFabric() message. * */ -#define CHIP_ERROR_UNSUPPORTED_THREAD_NETWORK_CREATE _CHIP_ERROR(178) +#define CHIP_ERROR_UNSUPPORTED_THREAD_NETWORK_CREATE _CHIP_ERROR(168) /** * @def CHIP_ERROR_INCONSISTENT_CONDITIONALITY @@ -1668,7 +1603,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * same Trait Instance. * */ -#define CHIP_ERROR_INCONSISTENT_CONDITIONALITY _CHIP_ERROR(179) +#define CHIP_ERROR_INCONSISTENT_CONDITIONALITY _CHIP_ERROR(169) /** * @def CHIP_ERROR_LOCAL_DATA_INCONSISTENT @@ -1678,7 +1613,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * Trait Instance and cannot support the operation requested. * */ -#define CHIP_ERROR_LOCAL_DATA_INCONSISTENT _CHIP_ERROR(180) +#define CHIP_ERROR_LOCAL_DATA_INCONSISTENT _CHIP_ERROR(170) /** * @def CHIP_EVENT_ID_FOUND @@ -1686,7 +1621,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * @brief * Event ID matching the criteria was found */ -#define CHIP_EVENT_ID_FOUND _CHIP_ERROR(182) +#define CHIP_EVENT_ID_FOUND _CHIP_ERROR(171) /** * @def CHIP_ERROR_INTERNAL @@ -1694,7 +1629,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * @brief * Internal error */ -#define CHIP_ERROR_INTERNAL _CHIP_ERROR(183) +#define CHIP_ERROR_INTERNAL _CHIP_ERROR(172) /** * @def CHIP_ERROR_OPEN_FAILED @@ -1702,7 +1637,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * @brief * Open file failed */ -#define CHIP_ERROR_OPEN_FAILED _CHIP_ERROR(184) +#define CHIP_ERROR_OPEN_FAILED _CHIP_ERROR(173) /** * @def CHIP_ERROR_READ_FAILED @@ -1710,7 +1645,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * @brief * Read from file failed */ -#define CHIP_ERROR_READ_FAILED _CHIP_ERROR(185) +#define CHIP_ERROR_READ_FAILED _CHIP_ERROR(174) /** * @def CHIP_ERROR_WRITE_FAILED @@ -1718,7 +1653,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * @brief * Write to file failed */ -#define CHIP_ERROR_WRITE_FAILED _CHIP_ERROR(186) +#define CHIP_ERROR_WRITE_FAILED _CHIP_ERROR(175) /** * @def CHIP_ERROR_DECODE_FAILED @@ -1726,7 +1661,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * @brief * Decoding failed */ -#define CHIP_ERROR_DECODE_FAILED _CHIP_ERROR(187) +#define CHIP_ERROR_DECODE_FAILED _CHIP_ERROR(176) /** @@ -1736,7 +1671,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * Use of the identified session key is suspended. * */ -#define CHIP_ERROR_SESSION_KEY_SUSPENDED _CHIP_ERROR(188) +#define CHIP_ERROR_SESSION_KEY_SUSPENDED _CHIP_ERROR(177) /** * @def CHIP_ERROR_UNSUPPORTED_WIRELESS_REGULATORY_DOMAIN @@ -1745,7 +1680,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The specified wireless regulatory domain is unsupported. * */ -#define CHIP_ERROR_UNSUPPORTED_WIRELESS_REGULATORY_DOMAIN _CHIP_ERROR(189) +#define CHIP_ERROR_UNSUPPORTED_WIRELESS_REGULATORY_DOMAIN _CHIP_ERROR(178) /** * @def CHIP_ERROR_UNSUPPORTED_WIRELESS_OPERATING_LOCATION @@ -1754,7 +1689,7 @@ typedef CHIP_CONFIG_ERROR_TYPE CHIP_ERROR; * The specified wireless operating location is unsupported. * */ -#define CHIP_ERROR_UNSUPPORTED_WIRELESS_OPERATING_LOCATION _CHIP_ERROR(190) +#define CHIP_ERROR_UNSUPPORTED_WIRELESS_OPERATING_LOCATION _CHIP_ERROR(179) /** * @} diff --git a/src/lib/core/CHIPTunnelConfig.h b/src/lib/core/CHIPTunnelConfig.h deleted file mode 100644 index 6de9d99df482dc..00000000000000 --- a/src/lib/core/CHIPTunnelConfig.h +++ /dev/null @@ -1,474 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2014-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 file defines default compile-time configurations - * for the chip Tunneling Feature. - * - */ - -#ifndef CHIP_TUNNEL_CONFIG_H_ -#define CHIP_TUNNEL_CONFIG_H_ - -// clang-format off - -/** - * @def CHIP_CONFIG_ENABLE_TUNNELING - * - * @brief - * (Default) Set equivalent to INET_CONFIG_ENABLE_TUN_ENDPOINT. - * - */ -#ifndef CHIP_CONFIG_ENABLE_TUNNELING -#define CHIP_CONFIG_ENABLE_TUNNELING (INET_CONFIG_ENABLE_TUN_ENDPOINT) -#endif // CHIP_CONFIG_ENABLE_TUNNELING - -/** - * - * @brief - * Check to throw an error if CHIP_CONFIG_ENABLE_TUNNELING is explicitly set without - * INET_CONFIG_ENABLE_TUN_ENDPOINT being set. - * - */ -#if (CHIP_CONFIG_ENABLE_TUNNELING && !(INET_CONFIG_ENABLE_TUN_ENDPOINT)) -#error chip Tunneling requires Tunnel EndPoint in InetLayer to be enabled -#endif // CHIP_CONFIG_ENABLE_TUNNELING - -/** - * @def CHIP_CONFIG_TUNNELING_SHORTCUT_TUNNEL_ADV_INTERVAL_SECS - * - * @brief - * This defines the default time period(in seconds) at which - * the border gateway and the mobile device sends advertisements - * for any local tunneling peer to pick up and populate its - * nexthop cache in order to locally tunnel over UDP between them. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_SHORTCUT_TUNNEL_ADV_INTERVAL_SECS -#define CHIP_CONFIG_TUNNELING_SHORTCUT_TUNNEL_ADV_INTERVAL_SECS (5) -#endif // CHIP_CONFIG_TUNNELING_SHORTCUT_TUNNEL_ADV_INTERVAL_SECS - -/** - * @def CHIP_CONFIG_TUNNELING_MAX_NUM_PACKETS_QUEUED - * - * @brief - * This defines the default queue depth for queueing data packets - * destined for the Service when the connection to the Service - * is not yet established. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_MAX_NUM_PACKETS_QUEUED -#define CHIP_CONFIG_TUNNELING_MAX_NUM_PACKETS_QUEUED (8) -#endif // CHIP_CONFIG_TUNNELING_MAX_NUM_PACKETS_QUEUED - -/** - * @def CHIP_CONFIG_TUNNELING_MAX_NUM_SHORTCUT_TUNNEL_PEERS - * - * @brief - * This defines the default value for the maximum number of shortcut - * tunneling peers for which to keep an entry in the nexthop table. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_MAX_NUM_SHORTCUT_TUNNEL_PEERS -#define CHIP_CONFIG_TUNNELING_MAX_NUM_SHORTCUT_TUNNEL_PEERS (8) -#endif // CHIP_CONFIG_TUNNELING_MAX_NUM_SHORTCUT_TUNNEL_PEERS - -/** - * @def CHIP_TUNNEL_CONFIG_WILL_OVERRIDE_ADDR_ROUTING_FUNCS - * - * @brief - * This defines whether (1) or not (0) the underlying platform-specific - * functions implemented within the chip Addressing and Routing Module, - * a.k.a. WARM, would override the corresponding supplied default - * implementation. - * - */ -#ifndef CHIP_TUNNEL_CONFIG_WILL_OVERRIDE_ADDR_ROUTING_FUNCS -#define CHIP_TUNNEL_CONFIG_WILL_OVERRIDE_ADDR_ROUTING_FUNCS (0) -#endif /* CHIP_TUNNEL_CONFIG_WILL_OVERRIDE_ADDR_ROUTING_FUNCS */ - -/** - * @def CHIP_CONFIG_TUNNELING_MAX_NUM_CONNECT_BEFORE_NOTIFY - * - * @brief - * This defines the default value for the maximum number of - * connection attempts before a notification is made about the - * connection failure. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_MAX_NUM_CONNECT_BEFORE_NOTIFY -#define CHIP_CONFIG_TUNNELING_MAX_NUM_CONNECT_BEFORE_NOTIFY (3) -#endif // CHIP_CONFIG_TUNNELING_MAX_NUM_CONNECT_BEFORE_NOTIFY - -/** - * @def CHIP_CONFIG_TUNNELING_CTRL_RESPONSE_TIMEOUT_SECS - * - * @brief - * This defines the default value of the response timeout - * (in seconds) for control messages sent over the - * tunnel. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_CTRL_RESPONSE_TIMEOUT_SECS -#define CHIP_CONFIG_TUNNELING_CTRL_RESPONSE_TIMEOUT_SECS (5) -#endif // CHIP_CONFIG_TUNNELING_CTRL_RESPONSE_TIMEOUT_SECS - -/** - * @def CHIP_CONFIG_PRIMARY_TUNNEL_KEEPALIVE_INTERVAL_SECS - * - * @brief - * This defines the default interval (in seconds) between - * keepalive probes for the primary tunnel's TCP connection. - * This value also controls the time between last data - * packet sent and the transmission of the first keepalive - * probe. - * - */ -#ifndef CHIP_CONFIG_PRIMARY_TUNNEL_KEEPALIVE_INTERVAL_SECS -#define CHIP_CONFIG_PRIMARY_TUNNEL_KEEPALIVE_INTERVAL_SECS (25) -#endif // CHIP_CONFIG_PRIMARY_TUNNEL_KEEPALIVE_INTERVAL_SECS - -/** - * @def CHIP_CONFIG_TUNNEL_MAX_KEEPALIVE_PROBES - * - * @brief - * This defines the default value for the maximum number of - * keepalive probes for both the primary and backup tunnel's - * TCP connection. - * - */ -#ifndef CHIP_CONFIG_TUNNEL_MAX_KEEPALIVE_PROBES -#define CHIP_CONFIG_TUNNEL_MAX_KEEPALIVE_PROBES (2) -#endif // CHIP_CONFIG_TUNNEL_MAX_KEEPALIVE_PROBES - -/** - * @def CHIP_CONFIG_PRIMARY_TUNNEL_MAX_TIMEOUT_SECS - * - * @brief - * This defines the default value for the maximum timeout - * of unacknowledged data for the primary tunnel's TCP - * connection. - * - */ -#ifndef CHIP_CONFIG_PRIMARY_TUNNEL_MAX_TIMEOUT_SECS -#define CHIP_CONFIG_PRIMARY_TUNNEL_MAX_TIMEOUT_SECS (20) -#endif // CHIP_CONFIG_PRIMARY_TUNNEL_MAX_TIMEOUT_SECS - -/** - * @def CHIP_CONFIG_BACKUP_TUNNEL_KEEPALIVE_INTERVAL_SECS - * - * @brief - * This defines the default interval (in seconds) between - * keepalive probes for the backup tunnel's TCP connection. - * This value also controls the time between last data - * packet sent and the transmission of the first keepalive - * probe. - * - */ -#ifndef CHIP_CONFIG_BACKUP_TUNNEL_KEEPALIVE_INTERVAL_SECS -#define CHIP_CONFIG_BACKUP_TUNNEL_KEEPALIVE_INTERVAL_SECS (50) -#endif // CHIP_CONFIG_BACKUP_TUNNEL_KEEPALIVE_INTERVAL_SECS - -/** - * @def CHIP_CONFIG_BACKUP_TUNNEL_MAX_TIMEOUT_SECS - * - * @brief - * This defines the default value for the maximum timeout - * of unacknowledged data for the backup tunnel's TCP - * connection. - * - */ -#ifndef CHIP_CONFIG_BACKUP_TUNNEL_MAX_TIMEOUT_SECS -#define CHIP_CONFIG_BACKUP_TUNNEL_MAX_TIMEOUT_SECS (10) -#endif // CHIP_CONFIG_BACKUP_TUNNEL_MAX_TIMEOUT_SECS - -/** - * @def CHIP_CONFIG_PRIMARY_TUNNEL_LIVENESS_INTERVAL_SECS - * - * @brief - * This defines the default interval that the primary - * tunnel would wait since the last activity over the tunnel - * to send a Tunnel Liveness probe to the other end. - * - * @note - * A smaller value for this interval would mean a faster - * detection of a broken connection while, simultaneously, - * increasing the amount of traffic over the connection. - * This trade-off needs to be carefully considered when - * setting this value especially for devices that are - * operating in a power constrained mode and are sensitive - * to traffic induced wake-ups. - * - */ -#ifndef CHIP_CONFIG_PRIMARY_TUNNEL_LIVENESS_INTERVAL_SECS -#define CHIP_CONFIG_PRIMARY_TUNNEL_LIVENESS_INTERVAL_SECS (195) -#endif // CHIP_CONFIG_PRIMARY_TUNNEL_LIVENESS_INTERVAL_SECS - -/** - * @def CHIP_CONFIG_BACKUP_TUNNEL_LIVENESS_INTERVAL_SECS - * - * @brief - * This defines the default interval that the backup - * tunnel would wait since the last activity over the tunnel - * to send a Tunnel Liveness probe to the other end. - * - * @note - * A smaller value for this interval would mean a faster - * detection of a broken connection while, simultaneously, - * increasing the amount of traffic over the connection. - * This trade-off needs to be carefully considered when - * setting this value especially for devices that are - * operating in a power constrained mode and are sensitive - * to traffic induced wake-ups. - * - */ -#ifndef CHIP_CONFIG_BACKUP_TUNNEL_LIVENESS_INTERVAL_SECS -#define CHIP_CONFIG_BACKUP_TUNNEL_LIVENESS_INTERVAL_SECS (195) -#endif // CHIP_CONFIG_BACKUP_TUNNEL_LIVENESS_INTERVAL_SECS - - -/** - * @def CHIP_CONFIG_TUNNEL_CONNECT_TIMEOUT_SECS - * - * @brief - * This defines the default timeout for the tunnel connect - * attempt to either succeed or notify the caller of an - * error. - * - */ -#ifndef CHIP_CONFIG_TUNNEL_CONNECT_TIMEOUT_SECS -#define CHIP_CONFIG_TUNNEL_CONNECT_TIMEOUT_SECS (10) -#endif // CHIP_CONFIG_TUNNEL_CONNECT_TIMEOUT_SECS - -/** - * @def CHIP_CONFIG_TUNNEL_FAILOVER_SUPPORTED - * - * @brief - * This defines whether support for tunnel redundancy - * and failover is present. - * - */ -#ifndef CHIP_CONFIG_TUNNEL_FAILOVER_SUPPORTED -#define CHIP_CONFIG_TUNNEL_FAILOVER_SUPPORTED (0) -#endif // CHIP_CONFIG_TUNNEL_FAILOVER_SUPPORTED - -/** - * @def CHIP_CONFIG_TUNNEL_LIVENESS_SUPPORTED - * - * @brief - * This defines whether support for the periodic tunnel - * liveness is present. - * - */ -#ifndef CHIP_CONFIG_TUNNEL_LIVENESS_SUPPORTED -#define CHIP_CONFIG_TUNNEL_LIVENESS_SUPPORTED (1) -#endif // CHIP_CONFIG_TUNNEL_LIVENESS_SUPPORTED - -/** - * @def CHIP_CONFIG_TUNNEL_TCP_KEEPALIVE_SUPPORTED - * - * @brief - * This defines whether support for enabling the TCP - * Keepalive socket option is present for the chip - * Tunnel. - * - */ -#ifndef CHIP_CONFIG_TUNNEL_TCP_KEEPALIVE_SUPPORTED -#define CHIP_CONFIG_TUNNEL_TCP_KEEPALIVE_SUPPORTED (!CHIP_CONFIG_TUNNEL_LIVENESS_SUPPORTED) -#endif // CHIP_CONFIG_TUNNEL_TCP_KEEPALIVE_SUPPORTED - -/** - * @def CHIP_CONFIG_TUNNEL_TCP_USER_TIMEOUT_SUPPORTED - * - * @brief - * This defines whether support for enabling the TCP - * UserTimeout socket option is present for the chip - * Tunnel. - * - */ -#ifndef CHIP_CONFIG_TUNNEL_TCP_USER_TIMEOUT_SUPPORTED -#define CHIP_CONFIG_TUNNEL_TCP_USER_TIMEOUT_SUPPORTED (1) -#endif // CHIP_CONFIG_TUNNEL_TCP_USER_TIMEOUT_SUPPORTED - -/** - * @def CHIP_CONFIG_TUNNEL_ENABLE_TCP_IDLE_CALLBACK - * - * @brief - * This defines whether support for enabling the TCP - * send channel being idle is present for the chip - * Tunnel. - * - */ -#ifndef CHIP_CONFIG_TUNNEL_ENABLE_TCP_IDLE_CALLBACK -#define CHIP_CONFIG_TUNNEL_ENABLE_TCP_IDLE_CALLBACK (INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS) -#endif // CHIP_CONFIG_TUNNEL_ENABLE_TCP_IDLE_CALLBACK - -/** - * @def CHIP_CONFIG_TUNNEL_SHORTCUT_SUPPORTED - * - * @brief - * This defines whether support for tunnel shortcut - * is present. - * - */ -#ifndef CHIP_CONFIG_TUNNEL_SHORTCUT_SUPPORTED -#define CHIP_CONFIG_TUNNEL_SHORTCUT_SUPPORTED (0) -#endif // CHIP_CONFIG_TUNNEL_SHORTCUT_SUPPORTED - -/** - * @def CHIP_CONFIG_TUNNEL_ENABLE_STATISTICS - * - * @brief - * This defines whether support for tunnel statistics - * collection is present. - * - */ -#ifndef CHIP_CONFIG_TUNNEL_ENABLE_STATISTICS -#define CHIP_CONFIG_TUNNEL_ENABLE_STATISTICS (1) -#endif // CHIP_CONFIG_TUNNEL_ENABLE_STATISTICS - -/** - * @def CHIP_CONFIG_TUNNEL_ENABLE_TRANSIT_CALLBACK - * - * @brief - * This defines whether the transiting packet would be - * passed to the application, for example, for logging purposes. - * - */ -#ifndef CHIP_CONFIG_TUNNEL_ENABLE_TRANSIT_CALLBACK -#define CHIP_CONFIG_TUNNEL_ENABLE_TRANSIT_CALLBACK (1) -#endif // CHIP_CONFIG_TUNNEL_ENABLE_TRANSIT_CALLBACK - -/** - * @def CHIP_CONFIG_TUNNELING_RECONNECT_MAX_FIBONACCI_INDEX - * - * @brief - * This defines the maximum fibonacci index value for the - * back-off algortihm to generate the next reconnect time. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_RECONNECT_MAX_FIBONACCI_INDEX -#define CHIP_CONFIG_TUNNELING_RECONNECT_MAX_FIBONACCI_INDEX (14) -#endif // CHIP_CONFIG_TUNNELING_RECONNECT_MAX_FIBONACCI_INDEX - -/** - * @def CHIP_CONFIG_TUNNELING_CONNECT_WAIT_TIME_MULTIPLIER_SECS - * - * @brief - * This specifies the multiplying factor to the result of - * a fibonacci computation based on a specific index to provide - * a max wait time for the next connection attempt. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_CONNECT_WAIT_TIME_MULTIPLIER_SECS -#define CHIP_CONFIG_TUNNELING_CONNECT_WAIT_TIME_MULTIPLIER_SECS (10) -#endif // CHIP_CONFIG_TUNNELING_CONNECT_WAIT_TIME_MULTIPLIER_SECS - -/** - * @def CHIP_CONFIG_TUNNELING_MIN_WAIT_TIME_INTERVAL_PERCENT - * - * @brief - * The minimum wait time as a percentage of the max wait interval - * for that step. - * - * @note - * The minimum delay specified in the reconnect param configuration - * will get precedence if it is greater than the delay calculated - * using this percentage calculation. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_MIN_WAIT_TIME_INTERVAL_PERCENT -#define CHIP_CONFIG_TUNNELING_MIN_WAIT_TIME_INTERVAL_PERCENT (30) -#endif // CHIP_CONFIG_TUNNELING_MIN_WAIT_TIME_INTERVAL_PERCENT - -/** - * @def CHIP_CONFIG_TUNNELING_RESET_RECONNECT_TIMEOUT_SECS - * - * @brief - * The maximum time to wait when the current reconnect timeout - * is reset. - * - * @note - * The actual wait period is chosen as a random duration - * less than this value. The user can also request to not - * wait and reconnect immediately. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_RESET_RECONNECT_TIMEOUT_SECS -#define CHIP_CONFIG_TUNNELING_RESET_RECONNECT_TIMEOUT_SECS (10) -#endif // CHIP_CONFIG_TUNNELING_RESET_RECONNECT_TIMEOUT_SECS - -/** - * @def CHIP_CONFIG_TUNNELING_ONLINE_CHECK_FAST_FREQ_SECS - * - * @brief - * The frequency of performing a network online check when - * the corresponding tunnel is down. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_ONLINE_CHECK_FAST_FREQ_SECS -#define CHIP_CONFIG_TUNNELING_ONLINE_CHECK_FAST_FREQ_SECS (30) -#endif // CHIP_CONFIG_TUNNELING_ONLINE_CHECK_FAST_FREQ_SECS - -/** - * @def CHIP_CONFIG_TUNNELING_ONLINE_CHECK_PRIMARY_SLOW_FREQ_SECS - * - * @brief - * The slower frequency of performing a network online check - * after detecting that the network has come online and before - * corresponding tunnel is established. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_ONLINE_CHECK_PRIMARY_SLOW_FREQ_SECS -#define CHIP_CONFIG_TUNNELING_ONLINE_CHECK_PRIMARY_SLOW_FREQ_SECS (60) -#endif // CHIP_CONFIG_TUNNELING_ONLINE_CHECK_PRIMARY_SLOW_FREQ_SECS - -/** - * @def CHIP_CONFIG_TUNNELING_ONLINE_CHECK_BACKUP_SLOW_FREQ_SECS - * - * @brief - * The slower frequency of performing a network online check - * after detecting that the network has come online and before - * backup tunnel is established. - * - */ -#ifndef CHIP_CONFIG_TUNNELING_ONLINE_CHECK_BACKUP_SLOW_FREQ_SECS -#define CHIP_CONFIG_TUNNELING_ONLINE_CHECK_BACKUP_SLOW_FREQ_SECS (90) -#endif // CHIP_CONFIG_TUNNELING_ONLINE_CHECK_BACKUP_SLOW_FREQ_SECS - -/** - * @def CHIP_CONFIG_TUNNEL_INTERFACE_MTU - * - * @brief - * The maximum transmission unit for the Tunnel interface - * on a border gateway. - * - * @note - * Setting a non-default value may also require updating - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_CAPACITY_MAX for socket - * platforms and PBUF size for LwIP platforms. - * - */ -#ifndef CHIP_CONFIG_TUNNEL_INTERFACE_MTU -#define CHIP_CONFIG_TUNNEL_INTERFACE_MTU (1536) -#endif // CHIP_CONFIG_TUNNEL_INTERFACE_MTU - -// clang-format on - -#endif /* CHIP_TUNNEL_CONFIG_H_ */ diff --git a/src/lib/core/CoreLayer.am b/src/lib/core/CoreLayer.am index a0dbfce75e0ab2..8ea1bcc11efc3c 100644 --- a/src/lib/core/CoreLayer.am +++ b/src/lib/core/CoreLayer.am @@ -49,7 +49,6 @@ CHIP_BUILD_CORE_LAYER_HEADER_FILES = \ @top_builddir@/src/lib/core/CHIPTLVTypes.h \ @top_builddir@/src/lib/core/CHIPTLVUtilities.hpp \ @top_builddir@/src/lib/core/CHIPTimeConfig.h \ - @top_builddir@/src/lib/core/CHIPTunnelConfig.h \ @top_builddir@/src/lib/core/CHIPKeyIds.h \ @top_builddir@/src/lib/core/Optional.h \ @top_builddir@/src/lib/core/ReferenceCounted.h \ diff --git a/src/lib/core/tests/TestCHIPErrorStr.cpp b/src/lib/core/tests/TestCHIPErrorStr.cpp index cf5c70980fc449..b7debb409ab6de 100644 --- a/src/lib/core/tests/TestCHIPErrorStr.cpp +++ b/src/lib/core/tests/TestCHIPErrorStr.cpp @@ -164,9 +164,6 @@ static int32_t sContext[] = CHIP_ERROR_NO_COMMON_PASE_CONFIGURATIONS, CHIP_ERROR_UNSOLICITED_MSG_NO_ORIGINATOR, CHIP_ERROR_INVALID_FABRIC_ID, - CHIP_ERROR_UNSUPPORTED_TUNNEL_VERSION, - CHIP_ERROR_TUNNEL_NEXTHOP_TABLE_FULL, - CHIP_ERROR_TUNNEL_SERVICE_QUEUE_FULL, CHIP_ERROR_DRBG_ENTROPY_SOURCE_FAILED, CHIP_ERROR_TLV_TAG_NOT_FOUND, CHIP_ERROR_INVALID_TOKENPAIRINGBUNDLE, @@ -185,12 +182,10 @@ static int32_t sContext[] = CHIP_ERROR_INTERNAL_KEY_ERROR_FROM_PEER, CHIP_ERROR_INVALID_KEY_ID, CHIP_ERROR_INVALID_TIME, - CHIP_ERROR_TUNNEL_PEER_ENTRY_NOT_FOUND, CHIP_ERROR_LOCKING_FAILURE, CHIP_ERROR_UNSUPPORTED_PASSCODE_CONFIG, CHIP_ERROR_PASSCODE_AUTHENTICATION_FAILED, CHIP_ERROR_PASSCODE_FINGERPRINT_FAILED, - CHIP_ERROR_TUNNEL_FORCE_ABORT, CHIP_ERROR_SERIALIZATION_ELEMENT_NULL, CHIP_ERROR_WRONG_CERT_SIGNATURE_ALGORITHM, CHIP_ERROR_WRONG_CHIP_SIGNATURE_ALGORITHM, @@ -216,8 +211,6 @@ static int32_t sContext[] = CHIP_ERROR_PROFILE_STRING_CONTEXT_ALREADY_REGISTERED, CHIP_ERROR_PROFILE_STRING_CONTEXT_NOT_REGISTERED, CHIP_ERROR_INCOMPATIBLE_SCHEMA_VERSION, - CHIP_ERROR_TUNNEL_ROUTING_RESTRICTED, - CHIP_ERROR_TUNNEL_RESET_RECONNECT_ALREADY_ARMED, CHIP_ERROR_MISMATCH_UPDATE_REQUIRED_VERSION, CHIP_ERROR_ACCESS_DENIED, CHIP_ERROR_UNKNOWN_RESOURCE_ID, diff --git a/src/lib/message/CHIPConnection.cpp b/src/lib/message/CHIPConnection.cpp index 946c429c7ae001..f05ac9d18db88f 100644 --- a/src/lib/message/CHIPConnection.cpp +++ b/src/lib/message/CHIPConnection.cpp @@ -576,36 +576,6 @@ void ChipConnection::GetPeerDescription(char * buf, size_t bufSize) const (NetworkType == kNetworkType_IP) ? PeerPort : 0, INET_NULL_INTERFACEID, this); } -#if CHIP_CONFIG_ENABLE_TUNNELING -/** - * Send a tunneled CHIP message over an established connection. - * - * @param[in] msgInfo A pointer to a ChipMessageInfo object. - * - * @param[in] msgBuf A pointer to the PacketBuffer object holding the packet to send. - * - * @retval #CHIP_NO_ERROR on successfully sending the message down to - * the network layer. - * @retval #CHIP_ERROR_INCORRECT_STATE if the ChipConnection object is not - * in the correct state for sending messages. - * @retval #CHIP_ERROR_INVALID_DESTINATION_NODE_ID if the destination node identifier is unspecified. - * @retval #CHIP_ERROR_SENDING_BLOCKED if the message is too long to be sent. - * @retval other Inet layer errors related to the specific endpoint send operations. - * - */ -CHIP_ERROR ChipConnection::SendTunneledMessage(ChipMessageInfo * msgInfo, PacketBuffer * msgBuf) -{ - - // Set message version to V2 - msgInfo->MessageVersion = kChipMessageVersion_V2; - - // Set the tunneling flag - msgInfo->Flags |= kChipMessageFlag_TunneledData; - - return SendMessage(msgInfo, msgBuf); -} -#endif // CHIP_CONFIG_ENABLE_TUNNELING - /** * Send a CHIP message over an established connection. * @@ -1386,11 +1356,7 @@ void ChipConnection::HandleDataReceived(TCPEndPoint * endPoint, PacketBuffer * d // While in a state that allows receiving, process the received data... while (data != NULL && con->StateAllowsReceive() && con->ReceiveEnabled && - (con->OnMessageReceived != NULL -#if CHIP_CONFIG_ENABLE_TUNNELING - || con->OnTunneledMessageReceived != NULL -#endif - )) + (con->OnMessageReceived != NULL)) { IPPacketInfo packetInfo; ChipMessageInfo msgInfo; @@ -1533,56 +1499,16 @@ void ChipConnection::HandleDataReceived(TCPEndPoint * endPoint, PacketBuffer * d break; } - // Check if message carries tunneled data and needs to be sent to Tunnel Agent - if (msgInfo.MessageVersion == kChipMessageVersion_V2) + // Pass the message header and payload to the application. + // NOTE that when this function returns, the state of the connection may have changed. + if (con->OnMessageReceived) { - if (msgInfo.Flags & kChipMessageFlag_TunneledData) - { -#if CHIP_CONFIG_ENABLE_TUNNELING - // Dispatch the tunneled data message to the application if it is not a duplicate. - // Although TCP guarantees in-order, at-most-once delivery in normal conditions, - // checking for and eliminating duplicate tunneled messages here prevents replay - // of messages by a malicious man-in-the-middle. - if (!(msgInfo.Flags & kChipMessageFlag_DuplicateMessage)) - { - if (con->OnTunneledMessageReceived) - { - con->OnTunneledMessageReceived(con, &msgInfo, payloadBuf); - } - else - { - con->DisconnectOnError(CHIP_ERROR_NO_MESSAGE_HANDLER); - break; - } - } -#endif - } - else - { - if (con->OnMessageReceived) - { - con->OnMessageReceived(con, &msgInfo, payloadBuf); - } - else - { - con->DisconnectOnError(CHIP_ERROR_NO_MESSAGE_HANDLER); - break; - } - } + con->OnMessageReceived(con, &msgInfo, payloadBuf); } - else if (msgInfo.MessageVersion == kChipMessageVersion_V1) + else { - // Pass the message header and payload to the application. - // NOTE that when this function returns, the state of the connection may have changed. - if (con->OnMessageReceived) - { - con->OnMessageReceived(con, &msgInfo, payloadBuf); - } - else - { - con->DisconnectOnError(CHIP_ERROR_NO_MESSAGE_HANDLER); - break; - } + con->DisconnectOnError(CHIP_ERROR_NO_MESSAGE_HANDLER); + break; } } @@ -1657,9 +1583,6 @@ void ChipConnection::Init(ChipMessageLayer * msgLayer) ReceiveEnabled = true; OnConnectionComplete = NULL; OnMessageReceived = NULL; -#if CHIP_CONFIG_ENABLE_TUNNELING - OnTunneledMessageReceived = NULL; -#endif OnConnectionClosed = DefaultConnectionClosedHandler; OnReceiveError = NULL; memset(&mPeerAddrs, 0, sizeof(mPeerAddrs)); diff --git a/src/lib/message/CHIPMessageLayer.cpp b/src/lib/message/CHIPMessageLayer.cpp index 7b04ddb16d256d..a5b6fa1899ed88 100644 --- a/src/lib/message/CHIPMessageLayer.cpp +++ b/src/lib/message/CHIPMessageLayer.cpp @@ -147,7 +147,6 @@ CHIP_ERROR ChipMessageLayer::Init(InitContext * context) OnAcceptError = NULL; OnMessageLayerActivityChange = NULL; memset(mConPool, 0, sizeof(mConPool)); - memset(mTunnelPool, 0, sizeof(mTunnelPool)); AppState = NULL; ExchangeMgr = NULL; SecurityMgr = NULL; @@ -246,7 +245,6 @@ CHIP_ERROR ChipMessageLayer::Shutdown() OnAcceptError = NULL; OnMessageLayerActivityChange = NULL; memset(mConPool, 0, sizeof(mConPool)); - memset(mTunnelPool, 0, sizeof(mTunnelPool)); ExchangeMgr = NULL; AppState = NULL; mFlags = 0; @@ -254,40 +252,6 @@ CHIP_ERROR ChipMessageLayer::Shutdown() return CHIP_NO_ERROR; } -#if CHIP_CONFIG_ENABLE_TUNNELING -/** - * Send a tunneled IPv6 data message over UDP. - * - * @param[in] msgInfo A pointer to a ChipMessageInfo object. - * - * @param[in] destAddr IPAddress of the UDP tunnel destination. - * - * @param[in] msgBuf A pointer to the PacketBuffer object holding the packet to send. - * - * @retval #CHIP_NO_ERROR on successfully sending the message down to the network - * layer. - * @retval #CHIP_ERROR_INVALID_ADDRESS if the destAddr is not specified or cannot be determined - * from destination node id. - * @retval errors generated from the lower Inet layer UDP endpoint during sending. - * - */ -CHIP_ERROR ChipMessageLayer::SendUDPTunneledMessage(const IPAddress & destAddr, ChipMessageInfo * msgInfo, PacketBuffer * msgBuf) -{ - CHIP_ERROR res = CHIP_NO_ERROR; - - // Set message version to V2 - msgInfo->MessageVersion = kChipMessageVersion_V2; - - // Set the tunneling flag - msgInfo->Flags |= kChipMessageFlag_TunneledData; - - res = SendMessage(destAddr, msgInfo, msgBuf); - msgBuf = NULL; - - return res; -} -#endif // CHIP_CONFIG_ENABLE_TUNNELING - /** * Encode a CHIP Message layer header into an PacketBuffer. * @@ -906,90 +870,6 @@ void ChipMessageLayer::GetIncomingTCPConCount(const IPAddress & peerAddr, uint16 } } -/** - * Create a new ChipConnectionTunnel object from a pool. - * - * @return a pointer to the newly created ChipConnectionTunnel object if successful, - * otherwise NULL. - * - */ -ChipConnectionTunnel * ChipMessageLayer::NewConnectionTunnel() -{ - ChipConnectionTunnel * tun = (ChipConnectionTunnel *) mTunnelPool; - for (int i = 0; i < CHIP_CONFIG_MAX_TUNNELS; i++, tun++) - { - if (tun->IsInUse() == false) - { - tun->Init(this); - return tun; - } - } - - ChipLogError(ExchangeManager, "New tun FAILED"); - return NULL; -} - -/** - * Create a ChipConnectionTunnel by coupling together two specified ChipConnections. - On successful creation, the TCPEndPoints corresponding to the component ChipConnection - objects are handed over to the ChipConnectionTunnel, otherwise the ChipConnections are - closed. - * - * @param[out] tunPtr A pointer to pointer of a ChipConnectionTunnel object. - * - * @param[in] conOne A reference to the first ChipConnection object. - * - * @param[in] conTwo A reference to the second ChipConnection object. - * - * @param[in] inactivityTimeoutMS The maximum time in milliseconds that the CHIP - * connection tunnel could be idle. - * - * @retval #CHIP_NO_ERROR on successful creation of the ChipConnectionTunnel. - * @retval #CHIP_ERROR_INCORRECT_STATE if the component ChipConnection objects of the - * ChipConnectionTunnel is not in the correct state. - * @retval #CHIP_ERROR_NO_MEMORY if a new ChipConnectionTunnel object cannot be created. - * - */ -CHIP_ERROR ChipMessageLayer::CreateTunnel(ChipConnectionTunnel ** tunPtr, ChipConnection & conOne, ChipConnection & conTwo, - uint32_t inactivityTimeoutMS) -{ - ChipLogDetail(ExchangeManager, "Entering CreateTunnel"); - CHIP_ERROR err = CHIP_NO_ERROR; - - VerifyOrExit(conOne.State == ChipConnection::kState_Connected && conTwo.State == ChipConnection::kState_Connected, - err = CHIP_ERROR_INCORRECT_STATE); - - *tunPtr = NewConnectionTunnel(); - VerifyOrExit(*tunPtr != NULL, err = CHIP_ERROR_NO_MEMORY); - - // Form ChipConnectionTunnel from former ChipConnections' TCPEndPoints. - err = (*tunPtr)->MakeTunnelConnected(conOne.mTcpEndPoint, conTwo.mTcpEndPoint); - SuccessOrExit(err); - - ChipLogProgress(ExchangeManager, "Created CHIP tunnel from Cons (%04X, %04X) with EPs (%04X, %04X)", conOne.LogId(), - conTwo.LogId(), conOne.mTcpEndPoint->LogId(), conTwo.mTcpEndPoint->LogId()); - - if (inactivityTimeoutMS > 0) - { - // Set TCPEndPoint inactivity timeouts. - conOne.mTcpEndPoint->SetIdleTimeout(inactivityTimeoutMS); - conTwo.mTcpEndPoint->SetIdleTimeout(inactivityTimeoutMS); - } - - // Remove TCPEndPoints from ChipConnections now that we've handed the former to our new ChipConnectionTunnel. - conOne.mTcpEndPoint = NULL; - conTwo.mTcpEndPoint = NULL; - -exit: - ChipLogDetail(ExchangeManager, "Exiting CreateTunnel"); - - // Close ChipConnection args. - conOne.Close(true); - conTwo.Close(true); - - return err; -} - CHIP_ERROR ChipMessageLayer::SetUnsecuredConnectionListener(ConnectionReceiveFunct newOnUnsecuredConnectionReceived, CallbackRemovedFunct newOnUnsecuredConnectionCallbacksRemoved, bool force, void * listenerState) @@ -1659,52 +1539,14 @@ void ChipMessageLayer::HandleUDPMessage(UDPEndPoint * endPoint, PacketBuffer * m )); #endif // CHIP_CONFIG_ENABLE_EPHEMERAL_UDP_PORT - // Check if message carries tunneled data and needs to be sent to Tunnel Agent - if (msgInfo.MessageVersion == kChipMessageVersion_V2) + // Call the supplied OnMessageReceived callback. + if (msgLayer->OnMessageReceived != NULL) { - if (msgInfo.Flags & kChipMessageFlag_TunneledData) - { -#if CHIP_CONFIG_ENABLE_TUNNELING - // Policy for handling duplicate tunneled UDP message: - // - Eliminate duplicate tunneled encrypted messages to prevent replay of messages by - // a malicious man-in-the-middle. - // - Handle duplicate tunneled unencrypted message. - // Dispatch the tunneled data message to the application if it is not a duplicate or unencrypted. - if (!(msgInfo.Flags & kChipMessageFlag_DuplicateMessage) || msgInfo.KeyId == ChipKeyId::kNone) - { - if (msgLayer->OnUDPTunneledMessageReceived) - { - msgLayer->OnUDPTunneledMessageReceived(msgLayer, msg); - } - else - { - ExitNow(err = CHIP_ERROR_NO_MESSAGE_HANDLER); - } - } -#endif - } - else - { - // Call the supplied OnMessageReceived callback. - if (msgLayer->OnMessageReceived != NULL) - { - msgLayer->OnMessageReceived(msgLayer, &msgInfo, msg); - } - else - { - ExitNow(err = CHIP_ERROR_NO_MESSAGE_HANDLER); - } - } + msgLayer->OnMessageReceived(msgLayer, &msgInfo, msg); } - else if (msgInfo.MessageVersion == kChipMessageVersion_V1) + else { - // Call the supplied OnMessageReceived callback. - if (msgLayer->OnMessageReceived != NULL) - msgLayer->OnMessageReceived(msgLayer, &msgInfo, msg); - else - { - ExitNow(err = CHIP_ERROR_NO_MESSAGE_HANDLER); - } + ExitNow(err = CHIP_ERROR_NO_MESSAGE_HANDLER); } exit: @@ -2236,8 +2078,7 @@ void ChipMessageLayer::ComputeIntegrityCheck_AES128CTRSHA1(const ChipMessageInfo /** * Close all open TCP and UDP endpoints. Then abort any - * open ChipConnections and shutdown any open - * ChipConnectionTunnel objects. + * open ChipConnections * * @note * A call to CloseEndpoints() terminates all communication @@ -2258,18 +2099,6 @@ CHIP_ERROR ChipMessageLayer::CloseEndpoints() if (con->mRefCount > 0) con->Abort(); - // Shut down any open tunnels. - ChipConnectionTunnel * tun = static_cast(mTunnelPool); - for (int i = 0; i < CHIP_CONFIG_MAX_TUNNELS; i++, tun++) - { - if (tun->mMessageLayer != NULL) - { - // Suppress callback as we're shutting down the whole stack. - tun->OnShutdown = NULL; - tun->Shutdown(); - } - } - return CHIP_NO_ERROR; } diff --git a/src/lib/message/CHIPMessageLayer.h b/src/lib/message/CHIPMessageLayer.h index a09df67f4f0b9b..79c988b3d74937 100644 --- a/src/lib/message/CHIPMessageLayer.h +++ b/src/lib/message/CHIPMessageLayer.h @@ -30,7 +30,6 @@ #include #include -#include #include #include #include @@ -73,11 +72,9 @@ enum kChipHeaderFlag_DestNodeId = 0x0100, /**< Indicates that the destination node ID is present in the CHIP message header. */ kChipHeaderFlag_SourceNodeId = 0x0200, /**< Indicates that the source node ID is present in the CHIP message header. */ - kChipHeaderFlag_TunneledData = 0x0400, /**< Indicates that the CHIP message payload is a tunneled IP packet. */ kChipHeaderFlag_MsgCounterSyncReq = 0x0800, /**< Indicates that the sender requests message counter synchronization. */ - kMsgHeaderField_ReservedFlagsMask = kMsgHeaderField_FlagsMask & ~kChipHeaderFlag_DestNodeId & ~kChipHeaderFlag_SourceNodeId & - ~kChipHeaderFlag_TunneledData & ~kChipHeaderFlag_MsgCounterSyncReq, + kMsgHeaderField_ReservedFlagsMask = kMsgHeaderField_FlagsMask & ~kChipHeaderFlag_DestNodeId & ~kChipHeaderFlag_SourceNodeId & ~kChipHeaderFlag_MsgCounterSyncReq, kMsgHeaderField_MessageHMACMask = ~((kChipHeaderFlag_DestNodeId | kChipHeaderFlag_SourceNodeId | kChipHeaderFlag_MsgCounterSyncReq) @@ -149,8 +146,6 @@ typedef enum ChipMessageFlags /**< Indicates that the destination node ID is present in the CHIP message header. */ kChipMessageFlag_SourceNodeId = kChipHeaderFlag_SourceNodeId, /**< Indicates that the source node ID is present in the CHIP message header. */ - kChipMessageFlag_TunneledData = kChipHeaderFlag_TunneledData, - /**< Indicates that the CHIP message payload is a tunneled IP packet. */ kChipMessageFlag_MsgCounterSyncReq = kChipHeaderFlag_MsgCounterSyncReq, /**< Indicates that the sender requests peer's message counter synchronization. */ @@ -277,12 +272,6 @@ class ChipConnection void GetPeerDescription(char * buf, size_t bufSize) const; CHIP_ERROR SendMessage(ChipMessageInfo * msgInfo, PacketBuffer * msgBuf); -#if CHIP_CONFIG_ENABLE_TUNNELING - /** - * Function to send a Tunneled packet over a CHIP connection. - */ - CHIP_ERROR SendTunneledMessage(ChipMessageInfo * msgInfo, PacketBuffer * msgBuf); -#endif // TODO COM-311: implement EnableReceived/DisableReceive for BLE ChipConnections. void EnableReceive(void); @@ -344,22 +333,6 @@ class ChipConnection typedef void (*MessageReceiveFunct)(ChipConnection * con, ChipMessageInfo * msgInfo, PacketBuffer * msgBuf); MessageReceiveFunct OnMessageReceived; -#if CHIP_CONFIG_ENABLE_TUNNELING - /** - * This function is the application callback that is invoked upon receipt of a Tunneled data packet over the - * CHIP connection. - * - * @param[in] con A pointer to the ChipConnection object. - * - * @param[in] msgInfo A pointer to the ChipMessageInfo object. - * - * @param[in] msgBuf A pointer to the PacketBuffer object containing the tunneled packet received. - * - */ - typedef void (*TunneledMsgReceiveFunct)(ChipConnection * con, const ChipMessageInfo * msgInfo, PacketBuffer * msgBuf); - TunneledMsgReceiveFunct OnTunneledMessageReceived; -#endif - /** * This function is the application callback invoked upon encountering an error when receiving * a CHIP message. @@ -438,48 +411,6 @@ class ChipConnection #endif }; -/** - * @class ChipConnectionTunnel - * - * @brief - * The definition of the ChipConnectionTunnel class, which manages a pair of TCPEndPoints - * whose original ChipConnections have been coupled, and between which the ChipMessageLayer - * forwards all data and connection closures. - */ -class ChipConnectionTunnel -{ - friend class ChipMessageLayer; - -public: - uint16_t LogId(void) const { return (uint16_t)((intptr_t) this); } - void Shutdown(void); - - /** - * This function is the application callback that is invoked when the CHIP connection tunnel is shut down. - * - * @param[in] tun A pointer to the ChipConnectionTunnel object. - * - */ - typedef void (*ShutdownFunct)(ChipConnectionTunnel * tun); - ShutdownFunct OnShutdown; - - void * AppState; /**< A pointer to application-specific state object. */ - -private: - ChipMessageLayer * mMessageLayer; - TCPEndPoint * mEPOne; - TCPEndPoint * mEPTwo; - - void Init(ChipMessageLayer * messageLayer); - CHIP_ERROR MakeTunnelConnected(TCPEndPoint * endpointOne, TCPEndPoint * endpointTwo); - void CloseEndPoint(TCPEndPoint ** endPoint); - inline bool IsInUse(void) const { return mMessageLayer != NULL; }; - - static void HandleTunnelDataReceived(TCPEndPoint * endPoint, PacketBuffer * data); - static void HandleTunnelConnectionClosed(TCPEndPoint * endPoint, INET_ERROR err); - static void HandleReceiveShutdown(TCPEndPoint * endPoint); -}; - /** * @class ChipMessageLayer * @@ -586,20 +517,11 @@ class DLL_EXPORT ChipMessageLayer CHIP_ERROR ResendMessage(const IPAddress & destAddr, uint16_t destPort, ChipMessageInfo * msgInfo, PacketBuffer * msgBuf); CHIP_ERROR ResendMessage(const IPAddress & destAddr, uint16_t destPort, InterfaceId interfaceId, ChipMessageInfo * msgInfo, PacketBuffer * msgBuf); -#if CHIP_CONFIG_ENABLE_TUNNELING - /** - * Function to send a Tunneled packet over a local UDP tunnel. - */ - CHIP_ERROR SendUDPTunneledMessage(const IPAddress & destAddr, ChipMessageInfo * msgInfo, PacketBuffer * msgBuf); -#endif + ChipConnection * NewConnection(void); - ChipConnectionTunnel * NewConnectionTunnel(void); void GetConnectionPoolStats(chip::System::Stats::count_t & aOutInUse) const; - CHIP_ERROR CreateTunnel(ChipConnectionTunnel ** tunPtr, ChipConnection & conOne, ChipConnection & conTwo, - uint32_t inactivityTimeoutMS); - /** * This function is the higher layer callback that is invoked upon receipt of a CHIP message over UDP. * @@ -607,26 +529,12 @@ class DLL_EXPORT ChipMessageLayer * * @param[in] msgInfo A pointer to the ChipMessageInfo object. * - * @param[in] payload Pointer to PacketBuffer message containing tunneled packet received. + * @param[in] payload Pointer to PacketBuffer message containing packet received. * */ typedef void (*MessageReceiveFunct)(ChipMessageLayer * msgLayer, ChipMessageInfo * msgInfo, PacketBuffer * payload); MessageReceiveFunct OnMessageReceived; -#if CHIP_CONFIG_ENABLE_TUNNELING - /** - * This function is the higher layer callback that is invoked upon receipt of a Tunneled packet over a local - * UDP tunnel. - * - * @param[in] msgLayer A pointer to the ChipMessageLayer object. - * - * @param[in] payload Pointer to PacketBuffer message containing tunneled packet received. - * - */ - typedef void (*TunneledMsgReceiveFunct)(ChipMessageLayer * msgLayer, PacketBuffer * payload); - TunneledMsgReceiveFunct OnUDPTunneledMessageReceived; -#endif - /** * This function is the higher layer callback invoked upon encountering an error. * @@ -739,7 +647,6 @@ class DLL_EXPORT ChipMessageLayer TCPEndPoint * mIPv6TCPListen; UDPEndPoint * mIPv6UDP; ChipConnection mConPool[CHIP_CONFIG_MAX_CONNECTIONS]; - ChipConnectionTunnel mTunnelPool[CHIP_CONFIG_MAX_TUNNELS]; uint8_t mFlags; #if CHIP_CONFIG_ENABLE_TARGETED_LISTEN diff --git a/src/lib/support/CHIPFaultInjection.cpp b/src/lib/support/CHIPFaultInjection.cpp index de732a85f7d7a7..95f980ba768f6b 100644 --- a/src/lib/support/CHIPFaultInjection.cpp +++ b/src/lib/support/CHIPFaultInjection.cpp @@ -52,10 +52,6 @@ static const nl::FaultInjection::Name sFaultNames[] = { "BDXAllocTransfer", "CASEKeyConfirm", "SecMgrBusy", -#if CHIP_CONFIG_ENABLE_TUNNELING - "TunnelQueueFull", - "TunnelPacketDropByPolicy", -#endif // CHIP_CONFIG_ENABLE_TUNNELING #if CONFIG_NETWORK_LAYER_BLE "CHIPOBLESend", #endif // CONFIG_NETWORK_LAYER_BLE diff --git a/src/lib/support/CHIPFaultInjection.h b/src/lib/support/CHIPFaultInjection.h index 7e653c90c285a6..a66ad6bdad2c3e 100644 --- a/src/lib/support/CHIPFaultInjection.h +++ b/src/lib/support/CHIPFaultInjection.h @@ -27,7 +27,6 @@ #include #include #include -#include #if CHIP_CONFIG_TEST && CHIP_WITH_NLFAULTINJECTION @@ -63,10 +62,6 @@ typedef enum kFault_BDXBadBlockCounter, /**< Corrupt the BDX Block Counter in the BDX BlockSend or BlockEOF message about to be sent */ kFault_BDXAllocTransfer, /**< Fail the allocation of a BDXTransfer object */ kFault_SecMgrBusy, /**< Trigger a WEAVE_ERROR_SECURITY_MANAGER_BUSY when starting an authentication session */ -#if CHIP_CONFIG_ENABLE_TUNNELING - kFault_TunnelQueueFull, /**< Trigger a CHIP_ERROR_TUNNEL_SERVICE_QUEUE_FULL when enqueueing a packet in the Tunnel queue */ - kFault_TunnelPacketDropByPolicy, /**< Trigger an explicit drop of the packet as if done by an application policy */ -#endif // CHIP_CONFIG_ENABLE_TUNNELING #if CONFIG_NETWORK_LAYER_BLE kFault_CHIPOBLESend, /**< Inject a GATT error when sending the first fragment of a chip message over BLE */ #endif // CONFIG_NETWORK_LAYER_BLE diff --git a/src/lib/support/logging/CHIPLogging.cpp b/src/lib/support/logging/CHIPLogging.cpp index 4caf5c562ae0ce..0d7aed4e527aba 100644 --- a/src/lib/support/logging/CHIPLogging.cpp +++ b/src/lib/support/logging/CHIPLogging.cpp @@ -79,7 +79,6 @@ static const char ModuleNames[] = "-\0\0" // None "SWU" // SoftwareUpdate "TP\0" // TokenPairing "TS\0" // TimeServices - "TUN" // chipTunnel "HB\0" // Heartbeat "CSL" // chipSystemLayer "EVL" // Event Logging diff --git a/src/lib/support/logging/CHIPLogging.h b/src/lib/support/logging/CHIPLogging.h index 4852e695a5b5dd..a5e0752bc53638 100644 --- a/src/lib/support/logging/CHIPLogging.h +++ b/src/lib/support/logging/CHIPLogging.h @@ -101,7 +101,6 @@ enum LogModule kLogModule_SoftwareUpdate, kLogModule_TokenPairing, kLogModule_TimeService, - kLogModule_chipTunnel, kLogModule_Heartbeat, kLogModule_chipSystemLayer, kLogModule_EventLogging, diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 58295cf5a682ae..fa51d9f495b67c 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -136,7 +136,6 @@ if (chip_device_platform != "none") { "../include/platform/internal/GenericConnectivityManagerImpl_BLE.h", "../include/platform/internal/GenericConnectivityManagerImpl_NoBLE.h", "../include/platform/internal/GenericConnectivityManagerImpl_NoThread.h", - "../include/platform/internal/GenericConnectivityManagerImpl_NoTunnel.h", "../include/platform/internal/GenericConnectivityManagerImpl_NoWiFi.h", "../include/platform/internal/GenericConnectivityManagerImpl_Thread.h", "../include/platform/internal/GenericNetworkProvisioningServerImpl.h", diff --git a/src/platform/Darwin/CHIPDevicePlatformConfig.h b/src/platform/Darwin/CHIPDevicePlatformConfig.h index dd9696fa4019af..4a719631eff576 100644 --- a/src/platform/Darwin/CHIPDevicePlatformConfig.h +++ b/src/platform/Darwin/CHIPDevicePlatformConfig.h @@ -78,7 +78,6 @@ #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 -#define CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY 0 // TODO: CHIP has redesigned the crypto interface, pending on the final version of CHIP HASH APIs #define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH 0 diff --git a/src/platform/Darwin/CHIPPlatformConfig.h b/src/platform/Darwin/CHIPPlatformConfig.h index 05fe76ec33d727..f27f36a8a48b84 100644 --- a/src/platform/Darwin/CHIPPlatformConfig.h +++ b/src/platform/Darwin/CHIPPlatformConfig.h @@ -28,9 +28,6 @@ #define ChipDie() abort() -//#define CHIP_CONFIG_ENABLE_TUNNELING 0 -//#define CHIP_CONFIG_MAX_TUNNELS 0 - // TODO:(#756) Add FabricState support #define CHIP_CONFIG_ENABLE_FABRIC_STATE 0 diff --git a/src/platform/Darwin/ConnectivityManagerImpl.h b/src/platform/Darwin/ConnectivityManagerImpl.h index 1e27726cfc86a7..41c10f1afafcf3 100644 --- a/src/platform/Darwin/ConnectivityManagerImpl.h +++ b/src/platform/Darwin/ConnectivityManagerImpl.h @@ -31,7 +31,6 @@ #else #include #endif -#include #include #include @@ -48,7 +47,6 @@ namespace DeviceLayer { * Concrete implementation of the ConnectivityManager singleton object for Darwin platforms. */ class ConnectivityManagerImpl final : public ConnectivityManager, - public Internal::GenericConnectivityManagerImpl, #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE public Internal::GenericConnectivityManagerImpl_BLE, #else @@ -60,7 +58,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, public Internal::GenericConnectivityManagerImpl_NoThread, #endif public Internal::GenericConnectivityManagerImpl_NoWiFi, - public Internal::GenericConnectivityManagerImpl_NoTunnel + public Internal::GenericConnectivityManagerImpl { // Allow the ConnectivityManager interface class to delegate method calls to // the implementation methods provided by this class. diff --git a/src/platform/EFR32/CHIPDevicePlatformConfig.h b/src/platform/EFR32/CHIPDevicePlatformConfig.h index 92350771a52386..8be57b9b1ca2dd 100644 --- a/src/platform/EFR32/CHIPDevicePlatformConfig.h +++ b/src/platform/EFR32/CHIPDevicePlatformConfig.h @@ -124,7 +124,6 @@ #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 -#define CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY 0 #ifndef CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME #define CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME "Bluetooth App Task" diff --git a/src/platform/EFR32/CHIPPlatformConfig.h b/src/platform/EFR32/CHIPPlatformConfig.h index c370e80de1b160..72f3394e30559b 100644 --- a/src/platform/EFR32/CHIPPlatformConfig.h +++ b/src/platform/EFR32/CHIPPlatformConfig.h @@ -41,9 +41,6 @@ #define ChipDie() abort() -#define CHIP_CONFIG_ENABLE_TUNNELING 0 -#define CHIP_CONFIG_MAX_TUNNELS 0 - #define CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE uint8_t #define CHIP_CONFIG_PERSISTED_STORAGE_ENC_MSG_CNTR_ID 1 #define CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH 2 diff --git a/src/platform/EFR32/ConnectivityManagerImpl.h b/src/platform/EFR32/ConnectivityManagerImpl.h index bda007fba3378b..1c24076d07cee2 100644 --- a/src/platform/EFR32/ConnectivityManagerImpl.h +++ b/src/platform/EFR32/ConnectivityManagerImpl.h @@ -31,7 +31,6 @@ #else #include #endif -#include #include #include @@ -57,8 +56,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, #else public Internal::GenericConnectivityManagerImpl_NoThread, #endif - public Internal::GenericConnectivityManagerImpl_NoWiFi, - public Internal::GenericConnectivityManagerImpl_NoTunnel + public Internal::GenericConnectivityManagerImpl_NoWiFi { // Allow the ConnectivityManager interface class to delegate method calls to // the implementation methods provided by this class. diff --git a/src/platform/ESP32/CHIPDevicePlatformConfig.h b/src/platform/ESP32/CHIPDevicePlatformConfig.h index 8595a4a65e0378..242a9aa5076127 100644 --- a/src/platform/ESP32/CHIPDevicePlatformConfig.h +++ b/src/platform/ESP32/CHIPDevicePlatformConfig.h @@ -64,8 +64,6 @@ #define CHIP_DEVICE_CONFIG_SERVICE_PROVISIONING_CONNECTIVITY_TIMEOUT CONFIG_SERVICE_PROVISIONING_CONNECTIVITY_TIMEOUT #define CHIP_DEVICE_CONFIG_SERVICE_PROVISIONING_REQUEST_TIMEOUT CONFIG_SERVICE_PROVISIONING_REQUEST_TIMEOUT #define CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY CONFIG_ENABLE_TEST_DEVICE_IDENTITY -#define CHIP_DEVICE_CONFIG_ENABLE_FIXED_TUNNEL_SERVER CONFIG_ENABLE_FIXED_TUNNEL_SERVER -#define CHIP_DEVICE_CONFIG_TUNNEL_SERVER_ADDRESS CONFIG_TUNNEL_SERVER_ADDRESS #define CHIP_DEVICE_CONFIG_DISABLE_ACCOUNT_PAIRING CONFIG_DISABLE_ACCOUNT_PAIRING #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE CONFIG_USE_TEST_SETUP_PIN_CODE #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR CONFIG_USE_TEST_SETUP_DISCRIMINATOR @@ -74,7 +72,6 @@ #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY CONFIG_ENABLE_WIFI_TELEMETRY #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY CONFIG_ENABLE_THREAD_TELEMETRY #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL CONFIG_ENABLE_THREAD_TELEMETRY_FULL -#define CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY CONFIG_ENABLE_TUNNEL_TELEMETRY #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_PROD_BUFFER_SIZE CONFIG_EVENT_LOGGING_PROD_BUFFER_SIZE #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE diff --git a/src/platform/ESP32/CHIPPlatformConfig.h b/src/platform/ESP32/CHIPPlatformConfig.h index b4d3fe5bfc490f..c910e1a1287ea5 100644 --- a/src/platform/ESP32/CHIPPlatformConfig.h +++ b/src/platform/ESP32/CHIPPlatformConfig.h @@ -30,8 +30,6 @@ // ==================== General Platform Adaptations ==================== -#define CHIP_CONFIG_MAX_TUNNELS 0 -#define CHIP_CONFIG_ENABLE_TUNNELING 0 #define CHIP_CONFIG_PERSISTED_STORAGE_ENC_MSG_CNTR_ID "enc-msg-counter" // The ESP NVS implementation limits key names to 15 characters. #define CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH 15 diff --git a/src/platform/ESP32/ConnectivityManagerImpl.cpp b/src/platform/ESP32/ConnectivityManagerImpl.cpp index e778ceff4f70d3..2617c10e968626 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl.cpp @@ -378,35 +378,6 @@ CHIP_ERROR ConnectivityManagerImpl::_GetAndLogWifiStatsCounters(void) return CHIP_NO_ERROR; } -CHIP_ERROR ConnectivityManagerImpl::_SetServiceTunnelMode(ServiceTunnelMode val) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - VerifyOrExit(val != kServiceTunnelMode_NotSupported, err = CHIP_ERROR_INVALID_ARGUMENT); - - mServiceTunnelMode = val; - - SystemLayer.ScheduleWork(DriveServiceTunnelState, NULL); - -exit: - return err; -} - -bool ConnectivityManagerImpl::_IsServiceTunnelConnected(void) -{ - return false; -} - -bool ConnectivityManagerImpl::_IsServiceTunnelRestricted(void) -{ - return false; -} - -bool ConnectivityManagerImpl::_HaveServiceConnectivityViaTunnel(void) -{ - return IsServiceTunnelConnected() && !IsServiceTunnelRestricted(); -} - // ==================== ConnectivityManager Platform Internal Methods ==================== CHIP_ERROR ConnectivityManagerImpl::_Init() @@ -419,15 +390,12 @@ CHIP_ERROR ConnectivityManagerImpl::_Init() mWiFiStationState = kWiFiStationState_NotConnected; mWiFiAPMode = kWiFiAPMode_Disabled; mWiFiAPState = kWiFiAPState_NotActive; - mServiceTunnelMode = kServiceTunnelMode_Enabled; mWiFiStationReconnectIntervalMS = CHIP_DEVICE_CONFIG_WIFI_STATION_RECONNECT_INTERVAL; mWiFiAPIdleTimeoutMS = CHIP_DEVICE_CONFIG_WIFI_AP_IDLE_TIMEOUT; mFlags = 0; // TODO Initialize the Chip Addressing and Routing Module. - // TODO Initialize the service tunnel agent. - // Ensure that ESP station mode is enabled. err = Internal::ESP32Utils::EnableStationMode(); SuccessOrExit(err); @@ -542,38 +510,6 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) break; } } - - // Handle fabric membership changes. - else if (event->Type == DeviceEventType::kFabricMembershipChange) - { - DriveServiceTunnelState(); - } - - // Handle service provisioning changes. - else if (event->Type == DeviceEventType::kServiceProvisioningChange) - { - DriveServiceTunnelState(); - } - -#if !CHIP_DEVICE_CONFIG_DISABLE_ACCOUNT_PAIRING - - // Handle account pairing changes. - else if (event->Type == DeviceEventType::kAccountPairingChange) - { - // When account pairing successfully completes, if the tunnel to the - // service is subject to routing restrictions (imposed because at the time - // the tunnel was established the device was not paired to an account) - // then force the tunnel to close. This will result in the tunnel being - // re-established, which should lift the service-side restrictions. - if (event->AccountPairingChange.IsPairedToAccount && GetFlag(mFlags, kFlag_ServiceTunnelStarted)) - { - ChipLogProgress(DeviceLayer, "Restarting service tunnel to lift routing restrictions"); - ClearFlag(mFlags, kFlag_ServiceTunnelStarted); - DriveServiceTunnelState(); - } - } - -#endif // !CHIP_DEVICE_CONFIG_DISABLE_ACCOUNT_PAIRING } void ConnectivityManagerImpl::_OnWiFiScanDone() @@ -1014,8 +950,6 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) { ChipLogProgress(DeviceLayer, "%s Internet connectivity %s", "IPv6", (haveIPv6Conn) ? "ESTABLISHED" : "LOST"); } - - DriveServiceTunnelState(); } } @@ -1063,40 +997,6 @@ void ConnectivityManagerImpl::OnIPv6AddressAvailable(const system_event_got_ip6_ UpdateInternetConnectivityState(); } -void ConnectivityManagerImpl::DriveServiceTunnelState(void) -{ - bool startServiceTunnel; - - // Determine if the tunnel to the service should be started. - startServiceTunnel = (mServiceTunnelMode == kServiceTunnelMode_Enabled && GetFlag(mFlags, kFlag_HaveIPv4InternetConnectivity)); - - // If the tunnel should be started but isn't, or vice versa, ... - if (startServiceTunnel != GetFlag(mFlags, kFlag_ServiceTunnelStarted)) - { - // Update the tunnel started state. - SetFlag(mFlags, kFlag_ServiceTunnelStarted, startServiceTunnel); - - // Start or stop the tunnel as necessary. - if (startServiceTunnel) - { - ChipLogProgress(DeviceLayer, "Starting service tunnel"); - - ChipLogError(DeviceLayer, "Service tunnel unsupported"); - ClearFlag(mFlags, kFlag_ServiceTunnelStarted); - } - - else - { - ChipLogProgress(DeviceLayer, "Stopping service tunnel"); - } - } -} - -void ConnectivityManagerImpl::DriveServiceTunnelState(chip::System::Layer * aLayer, void * aAppState, chip::System::Error aError) -{ - sInstance.DriveServiceTunnelState(); -} - const char * ConnectivityManagerImpl::_WiFiStationModeToStr(WiFiStationMode mode) { switch (mode) @@ -1135,21 +1035,6 @@ const char * ConnectivityManagerImpl::_WiFiAPModeToStr(WiFiAPMode mode) } } -const char * ConnectivityManagerImpl::_ServiceTunnelModeToStr(ServiceTunnelMode mode) -{ - switch (mode) - { - case kServiceTunnelMode_NotSupported: - return "NotSupported"; - case kServiceTunnelMode_Disabled: - return "Disabled"; - case kServiceTunnelMode_Enabled: - return "Enabled"; - default: - return "(unknown)"; - } -} - const char * ConnectivityManagerImpl::WiFiStationStateToStr(WiFiStationState state) { switch (state) diff --git a/src/platform/ESP32/ConnectivityManagerImpl.h b/src/platform/ESP32/ConnectivityManagerImpl.h index df66cec267767f..059e940d00d36c 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.h +++ b/src/platform/ESP32/ConnectivityManagerImpl.h @@ -90,11 +90,6 @@ class ConnectivityManagerImpl final : public ConnectivityManager, CHIP_ERROR _GetAndLogWifiStatsCounters(void); bool _HaveIPv4InternetConnectivity(void); bool _HaveIPv6InternetConnectivity(void); - ServiceTunnelMode _GetServiceTunnelMode(void); - CHIP_ERROR _SetServiceTunnelMode(ServiceTunnelMode val); - bool _IsServiceTunnelConnected(void); - bool _IsServiceTunnelRestricted(void); - bool _HaveServiceConnectivityViaTunnel(void); bool _HaveServiceConnectivity(void); CHIP_ERROR _Init(void); void _OnPlatformEvent(const ChipDeviceEvent * event); @@ -103,7 +98,6 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void _OnWiFiStationProvisionChange(); static const char * _WiFiStationModeToStr(WiFiStationMode mode); static const char * _WiFiAPModeToStr(WiFiAPMode mode); - static const char * _ServiceTunnelModeToStr(ServiceTunnelMode mode); // ===== Members for internal use by the following friends. @@ -136,9 +130,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, { kFlag_HaveIPv4InternetConnectivity = 0x0001, kFlag_HaveIPv6InternetConnectivity = 0x0002, - kFlag_ServiceTunnelStarted = 0x0004, - kFlag_ServiceTunnelUp = 0x0008, - kFlag_AwaitingConnectivity = 0x0010, + kFlag_AwaitingConnectivity = 0x0004, }; uint64_t mLastStationConnectFailTime; @@ -147,7 +139,6 @@ class ConnectivityManagerImpl final : public ConnectivityManager, WiFiStationState mWiFiStationState; WiFiAPMode mWiFiAPMode; WiFiAPState mWiFiAPState; - ServiceTunnelMode mServiceTunnelMode; uint32_t mWiFiStationReconnectIntervalMS; uint32_t mWiFiAPIdleTimeoutMS; uint16_t mFlags; @@ -168,9 +159,6 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void OnStationIPv4AddressLost(void); void OnIPv6AddressAvailable(const system_event_got_ip6_t & got_ip); - void DriveServiceTunnelState(void); - static void DriveServiceTunnelState(::chip::System::Layer * aLayer, void * aAppState, ::chip::System::Error aError); - static const char * WiFiStationStateToStr(WiFiStationState state); static const char * WiFiAPStateToStr(WiFiAPState state); static void RefreshMessageLayer(void); @@ -221,11 +209,6 @@ inline bool ConnectivityManagerImpl::_HaveIPv6InternetConnectivity(void) return ::chip::GetFlag(mFlags, kFlag_HaveIPv6InternetConnectivity); } -inline ConnectivityManager::ServiceTunnelMode ConnectivityManagerImpl::_GetServiceTunnelMode(void) -{ - return mServiceTunnelMode; -} - inline bool ConnectivityManagerImpl::_CanStartWiFiScan() { return mWiFiStationState != kWiFiStationState_Connecting; @@ -233,7 +216,7 @@ inline bool ConnectivityManagerImpl::_CanStartWiFiScan() inline bool ConnectivityManagerImpl::_HaveServiceConnectivity(void) { - return HaveServiceConnectivityViaTunnel() || HaveServiceConnectivityViaThread(); + return HaveServiceConnectivityViaThread(); } /** diff --git a/src/platform/ESP32/InetPlatformConfig.h b/src/platform/ESP32/InetPlatformConfig.h index d34c324d74a971..c7f89e690896de 100644 --- a/src/platform/ESP32/InetPlatformConfig.h +++ b/src/platform/ESP32/InetPlatformConfig.h @@ -48,8 +48,4 @@ #define INET_CONFIG_NUM_UDP_ENDPOINTS CONFIG_NUM_UDP_ENDPOINTS #endif // INET_CONFIG_NUM_UDP_ENDPOINTS -#ifndef INET_CONFIG_NUM_TUN_ENDPOINTS -#define INET_CONFIG_NUM_TUN_ENDPOINTS 1 -#endif // INET_CONFIG_NUM_TUN_ENDPOINTS - #endif // INET_PLATFORM_CONFIG_H diff --git a/src/platform/K32W/CHIPDevicePlatformConfig.h b/src/platform/K32W/CHIPDevicePlatformConfig.h index fe226b396db83d..e38339b5049e93 100644 --- a/src/platform/K32W/CHIPDevicePlatformConfig.h +++ b/src/platform/K32W/CHIPDevicePlatformConfig.h @@ -85,6 +85,5 @@ #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 1 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 -#define CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY 0 #endif // CHIP_DEVICE_PLATFORM_CONFIG_H diff --git a/src/platform/K32W/CHIPPlatformConfig.h b/src/platform/K32W/CHIPPlatformConfig.h index 2706bfc70304be..1e0eebc8f3eb78 100644 --- a/src/platform/K32W/CHIPPlatformConfig.h +++ b/src/platform/K32W/CHIPPlatformConfig.h @@ -42,9 +42,6 @@ #define ChipDie() abort() -#define CHIP_CONFIG_ENABLE_TUNNELING 0 -#define CHIP_CONFIG_MAX_TUNNELS 0 - #define CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE uint16_t #define CHIP_CONFIG_PERSISTED_STORAGE_ENC_MSG_CNTR_ID 1 #define CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH 2 diff --git a/src/platform/K32W/ConnectivityManagerImpl.h b/src/platform/K32W/ConnectivityManagerImpl.h index 4a68a368dce9b7..1fb67e003de94b 100644 --- a/src/platform/K32W/ConnectivityManagerImpl.h +++ b/src/platform/K32W/ConnectivityManagerImpl.h @@ -32,7 +32,6 @@ #else #include #endif -#include #include #include @@ -49,7 +48,6 @@ namespace DeviceLayer { * Concrete implementation of the ConnectivityManager singleton object for NXP K32W platforms. */ class ConnectivityManagerImpl final : public ConnectivityManager, - public Internal::GenericConnectivityManagerImpl, #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE public Internal::GenericConnectivityManagerImpl_BLE, #else @@ -61,7 +59,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, public Internal::GenericConnectivityManagerImpl_NoThread, #endif public Internal::GenericConnectivityManagerImpl_NoWiFi, - public Internal::GenericConnectivityManagerImpl_NoTunnel + public Internal::GenericConnectivityManagerImpl { // Allow the ConnectivityManager interface class to delegate method calls to // the implementation methods provided by this class. diff --git a/src/platform/Linux/CHIPDevicePlatformConfig.h b/src/platform/Linux/CHIPDevicePlatformConfig.h index bfa34fb14492cf..56422c48d3cd01 100644 --- a/src/platform/Linux/CHIPDevicePlatformConfig.h +++ b/src/platform/Linux/CHIPDevicePlatformConfig.h @@ -80,7 +80,6 @@ #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 -#define CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY 0 // TODO: CHIP has redesigned the crypto interface, pending on the final version of CHIP HASH APIs #define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH 0 diff --git a/src/platform/Linux/CHIPPlatformConfig.h b/src/platform/Linux/CHIPPlatformConfig.h index 7c321f62b90a2c..fb21bd9f210998 100644 --- a/src/platform/Linux/CHIPPlatformConfig.h +++ b/src/platform/Linux/CHIPPlatformConfig.h @@ -28,9 +28,6 @@ #define ChipDie() abort() -//#define CHIP_CONFIG_ENABLE_TUNNELING 0 -//#define CHIP_CONFIG_MAX_TUNNELS 0 - // TODO:(#756) Add FabricState support #define CHIP_CONFIG_ENABLE_FABRIC_STATE 0 diff --git a/src/platform/Linux/ConnectivityManagerImpl.h b/src/platform/Linux/ConnectivityManagerImpl.h index 82ecedb56c904b..ab663edecca9dc 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.h +++ b/src/platform/Linux/ConnectivityManagerImpl.h @@ -31,7 +31,6 @@ #else #include #endif -#include #if CHIP_DEVICE_CONFIG_ENABLE_WPA #include #else @@ -85,7 +84,6 @@ struct GDBusWpaSupplicant * Concrete implementation of the ConnectivityManager singleton object for Linux platforms. */ class ConnectivityManagerImpl final : public ConnectivityManager, - public Internal::GenericConnectivityManagerImpl, #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE public Internal::GenericConnectivityManagerImpl_BLE, #else @@ -101,7 +99,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, #else public Internal::GenericConnectivityManagerImpl_NoWiFi, #endif - public Internal::GenericConnectivityManagerImpl_NoTunnel + public Internal::GenericConnectivityManagerImpl { // Allow the ConnectivityManager interface class to delegate method calls to // the implementation methods provided by this class. diff --git a/src/platform/Makefile.am b/src/platform/Makefile.am index f625f5f0b48c06..51f471785fe842 100644 --- a/src/platform/Makefile.am +++ b/src/platform/Makefile.am @@ -58,7 +58,6 @@ noinst_HEADERS = \ @top_srcdir@/src/include/platform/internal/GenericConnectivityManagerImpl_BLE.ipp \ @top_srcdir@/src/include/platform/internal/GenericConnectivityManagerImpl_NoBLE.h \ @top_srcdir@/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h \ - @top_srcdir@/src/include/platform/internal/GenericConnectivityManagerImpl_NoTunnel.h \ @top_srcdir@/src/include/platform/internal/GenericConnectivityManagerImpl_NoWiFi.h \ @top_srcdir@/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h \ @top_srcdir@/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.ipp \ diff --git a/src/platform/nRF5/CHIPDevicePlatformConfig.h b/src/platform/nRF5/CHIPDevicePlatformConfig.h index d9219df4b91102..a9ee2a0cbe464d 100644 --- a/src/platform/nRF5/CHIPDevicePlatformConfig.h +++ b/src/platform/nRF5/CHIPDevicePlatformConfig.h @@ -87,7 +87,6 @@ #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 -#define CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH 0 #endif // CHIP_DEVICE_PLATFORM_CONFIG_H diff --git a/src/platform/nRF5/CHIPPlatformConfig.h b/src/platform/nRF5/CHIPPlatformConfig.h index a5f04912e7c24d..905debc8e004c9 100644 --- a/src/platform/nRF5/CHIPPlatformConfig.h +++ b/src/platform/nRF5/CHIPPlatformConfig.h @@ -42,9 +42,6 @@ #define ChipDie() abort() -#define CHIP_CONFIG_ENABLE_TUNNELING 0 -#define CHIP_CONFIG_MAX_TUNNELS 0 - #define CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE uint16_t #define CHIP_CONFIG_PERSISTED_STORAGE_ENC_MSG_CNTR_ID 1 #define CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH 2 diff --git a/src/platform/nRF5/ConnectivityManagerImpl.h b/src/platform/nRF5/ConnectivityManagerImpl.h index ac12b5d9537f75..d5ce8e1fe0314d 100644 --- a/src/platform/nRF5/ConnectivityManagerImpl.h +++ b/src/platform/nRF5/ConnectivityManagerImpl.h @@ -31,7 +31,6 @@ #else #include #endif -#include #include #include @@ -59,8 +58,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, #else public Internal::GenericConnectivityManagerImpl_NoThread, #endif - public Internal::GenericConnectivityManagerImpl_NoWiFi, - public Internal::GenericConnectivityManagerImpl_NoTunnel + public Internal::GenericConnectivityManagerImpl_NoWiFi { // Allow the ConnectivityManager interface class to delegate method calls to // the implementation methods provided by this class. diff --git a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h index 0aa45cd16b3184..9dbb63fa72e1b0 100644 --- a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h +++ b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h @@ -60,7 +60,6 @@ #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 -#define CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH 0 #endif // CHIP_DEVICE_PLATFORM_CONFIG_H diff --git a/src/platform/nrfconnect/CHIPPlatformConfig.h b/src/platform/nrfconnect/CHIPPlatformConfig.h index 4dbfb410a8c283..3699f1b1194905 100644 --- a/src/platform/nrfconnect/CHIPPlatformConfig.h +++ b/src/platform/nrfconnect/CHIPPlatformConfig.h @@ -28,9 +28,6 @@ #define ChipDie() abort() -//#define CHIP_CONFIG_ENABLE_TUNNELING 0 -//#define CHIP_CONFIG_MAX_TUNNELS 0 - #define CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE const char * #define CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH 2 diff --git a/src/platform/nrfconnect/ConnectivityManagerImpl.h b/src/platform/nrfconnect/ConnectivityManagerImpl.h index 81dbefec9386c7..4165fe9b0ac8c0 100644 --- a/src/platform/nrfconnect/ConnectivityManagerImpl.h +++ b/src/platform/nrfconnect/ConnectivityManagerImpl.h @@ -30,7 +30,6 @@ #else #include #endif -#include #include #include @@ -60,8 +59,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, #else public Internal::GenericConnectivityManagerImpl_NoThread, #endif - public Internal::GenericConnectivityManagerImpl_NoWiFi, - public Internal::GenericConnectivityManagerImpl_NoTunnel + public Internal::GenericConnectivityManagerImpl_NoWiFi { // Allow the ConnectivityManager interface class to delegate method calls to // the implementation methods provided by this class. diff --git a/src/system/SystemStats.cpp b/src/system/SystemStats.cpp index 4e34d98e552dab..da3acaefcd2bc9 100644 --- a/src/system/SystemStats.cpp +++ b/src/system/SystemStats.cpp @@ -55,9 +55,6 @@ static const Label sStatsStrings[chip::System::Stats::kNumEntries] = { #if INET_CONFIG_NUM_UDP_ENDPOINTS "InetLayer_NumUDPEpsInUse", #endif -#if INET_CONFIG_NUM_TUN_ENDPOINTS - "InetLayer_NumTunEpsInUse", -#endif #if INET_CONFIG_NUM_DNS_RESOLVERS "InetLayer_NumDNSResolversInUse", #endif diff --git a/src/system/SystemStats.h b/src/system/SystemStats.h index 2b2e581c668608..00e21fe38f9a90 100644 --- a/src/system/SystemStats.h +++ b/src/system/SystemStats.h @@ -66,9 +66,6 @@ enum #if INET_CONFIG_NUM_UDP_ENDPOINTS kInetLayer_NumUDPEps, #endif -#if INET_CONFIG_NUM_TUN_ENDPOINTS - kInetLayer_NumTunEps, -#endif #if INET_CONFIG_NUM_DNS_RESOLVERS kInetLayer_NumDNSResolvers, #endif From 8a3ae43d9e660b46bbd4b1197b069256856248a1 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 13 Aug 2020 22:19:27 +0000 Subject: [PATCH 2/2] Restyled by clang-format --- src/inet/InetLayer.cpp | 2 +- src/inet/tests/TestInetEndPoint.cpp | 2 +- src/lib/message/CHIPConnection.cpp | 7 +++---- src/lib/message/CHIPMessageLayer.h | 3 ++- src/lib/support/CHIPFaultInjection.cpp | 17 ++++------------- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/inet/InetLayer.cpp b/src/inet/InetLayer.cpp index c3ff57d541d7ea..201bcc9a8d18cf 100644 --- a/src/inet/InetLayer.cpp +++ b/src/inet/InetLayer.cpp @@ -1229,7 +1229,7 @@ void InetLayer::HandleSelectResult(int selectRes, fd_set * readfds, fd_set * wri } #endif // INET_CONFIG_ENABLE_UDP_ENDPOINT - // Now call each active endpoint to handle its pending I/O. + // Now call each active endpoint to handle its pending I/O. #if INET_CONFIG_ENABLE_RAW_ENDPOINT for (size_t i = 0; i < RawEndPoint::sPool.Size(); i++) { diff --git a/src/inet/tests/TestInetEndPoint.cpp b/src/inet/tests/TestInetEndPoint.cpp index dd86d1b6b44648..0977315743de58 100644 --- a/src/inet/tests/TestInetEndPoint.cpp +++ b/src/inet/tests/TestInetEndPoint.cpp @@ -309,7 +309,7 @@ static void TestInetEndPoint(nlTestSuite * inSuite, void * inContext) #if INET_CONFIG_ENABLE_IPV4 RawEndPoint * testRaw4EP = NULL; #endif // INET_CONFIG_ENABLE_IPV4 - UDPEndPoint * testUDPEP = NULL; + UDPEndPoint * testUDPEP = NULL; TCPEndPoint * testTCPEP1 = NULL; PacketBuffer * buf = PacketBuffer::New(); bool didBind = false; diff --git a/src/lib/message/CHIPConnection.cpp b/src/lib/message/CHIPConnection.cpp index f05ac9d18db88f..d00d7cdbc46ed1 100644 --- a/src/lib/message/CHIPConnection.cpp +++ b/src/lib/message/CHIPConnection.cpp @@ -1355,8 +1355,7 @@ void ChipConnection::HandleDataReceived(TCPEndPoint * endPoint, PacketBuffer * d ChipMessageLayer * msgLayer = con->MessageLayer; // While in a state that allows receiving, process the received data... - while (data != NULL && con->StateAllowsReceive() && con->ReceiveEnabled && - (con->OnMessageReceived != NULL)) + while (data != NULL && con->StateAllowsReceive() && con->ReceiveEnabled && (con->OnMessageReceived != NULL)) { IPPacketInfo packetInfo; ChipMessageInfo msgInfo; @@ -1583,8 +1582,8 @@ void ChipConnection::Init(ChipMessageLayer * msgLayer) ReceiveEnabled = true; OnConnectionComplete = NULL; OnMessageReceived = NULL; - OnConnectionClosed = DefaultConnectionClosedHandler; - OnReceiveError = NULL; + OnConnectionClosed = DefaultConnectionClosedHandler; + OnReceiveError = NULL; memset(&mPeerAddrs, 0, sizeof(mPeerAddrs)); mTcpEndPoint = NULL; #if CONFIG_NETWORK_LAYER_BLE diff --git a/src/lib/message/CHIPMessageLayer.h b/src/lib/message/CHIPMessageLayer.h index 79c988b3d74937..faeb712b12439f 100644 --- a/src/lib/message/CHIPMessageLayer.h +++ b/src/lib/message/CHIPMessageLayer.h @@ -74,7 +74,8 @@ enum kChipHeaderFlag_SourceNodeId = 0x0200, /**< Indicates that the source node ID is present in the CHIP message header. */ kChipHeaderFlag_MsgCounterSyncReq = 0x0800, /**< Indicates that the sender requests message counter synchronization. */ - kMsgHeaderField_ReservedFlagsMask = kMsgHeaderField_FlagsMask & ~kChipHeaderFlag_DestNodeId & ~kChipHeaderFlag_SourceNodeId & ~kChipHeaderFlag_MsgCounterSyncReq, + kMsgHeaderField_ReservedFlagsMask = kMsgHeaderField_FlagsMask & ~kChipHeaderFlag_DestNodeId & ~kChipHeaderFlag_SourceNodeId & + ~kChipHeaderFlag_MsgCounterSyncReq, kMsgHeaderField_MessageHMACMask = ~((kChipHeaderFlag_DestNodeId | kChipHeaderFlag_SourceNodeId | kChipHeaderFlag_MsgCounterSyncReq) diff --git a/src/lib/support/CHIPFaultInjection.cpp b/src/lib/support/CHIPFaultInjection.cpp index 95f980ba768f6b..639fc91c8ff4a6 100644 --- a/src/lib/support/CHIPFaultInjection.cpp +++ b/src/lib/support/CHIPFaultInjection.cpp @@ -37,21 +37,12 @@ static int32_t sFault_FuzzExchangeHeader_Arguments[1]; static class nl::FaultInjection::Manager sChipFaultInMgr; static const nl::FaultInjection::Name sManagerName = "chip"; static const nl::FaultInjection::Name sFaultNames[] = { - "AllocExchangeContext", - "DropIncomingUDPMsg", - "DropOutgoingUDPMsg", - "AllocBinding", - "SendAlarm", - "HandleAlarm", - "FuzzExchangeHeaderTx", + "AllocExchangeContext", "DropIncomingUDPMsg", "DropOutgoingUDPMsg", "AllocBinding", "SendAlarm", + "HandleAlarm", "FuzzExchangeHeaderTx", #if WEAVE_CONFIG_ENABLE_RELIABLE_MESSAGING - "WRMDoubleTx", - "WRMSendError", + "WRMDoubleTx", "WRMSendError", #endif // WEAVE_CONFIG_ENABLE_RELIABLE_MESSAGING - "BDXBadBlockCounter", - "BDXAllocTransfer", - "CASEKeyConfirm", - "SecMgrBusy", + "BDXBadBlockCounter", "BDXAllocTransfer", "CASEKeyConfirm", "SecMgrBusy", #if CONFIG_NETWORK_LAYER_BLE "CHIPOBLESend", #endif // CONFIG_NETWORK_LAYER_BLE