diff --git a/examples/lighting-app/efr32/args.gni b/examples/lighting-app/efr32/args.gni index d3853c338ba61e..0f2b60d59f6054 100644 --- a/examples/lighting-app/efr32/args.gni +++ b/examples/lighting-app/efr32/args.gni @@ -22,4 +22,4 @@ pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" pw_assert_BACKEND = "$dir_pw_assert_log" chip_enable_openthread = true chip_openthread_ftd = true -chip_system_config_use_ot_udp = true +chip_system_config_use_open_thread_udp = true diff --git a/examples/platform/efr32/project_include/OpenThreadConfig.h b/examples/platform/efr32/project_include/OpenThreadConfig.h index 639127a079cb09..adce0c493aaadc 100644 --- a/examples/platform/efr32/project_include/OpenThreadConfig.h +++ b/examples/platform/efr32/project_include/OpenThreadConfig.h @@ -61,6 +61,7 @@ #define OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE 0 #define OPENTHREAD_CONFIG_TCP_ENABLE 0 +// Support udp multicast by enabling Multicast Listener Registration (MRL) #define OPENTHREAD_CONFIG_MLR_ENABLE 1 // Use the SiLabs-supplied default platform configuration for remainder diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 17d65245c1115a..3c2dd19a90e460 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -127,9 +127,9 @@ CHIP_ERROR Server::Init(AppDelegate * delegate, uint16_t secureServicePort, uint err = mTransports.Init(UdpListenParameters(DeviceLayer::UDPEndPointManager()) .SetAddressType(IPAddressType::kIPv6) .SetListenPort(mSecuredServicePort) -#if CHIP_SYSTEM_CONFIG_USE_OT_UDP - .SetOtInstance(chip::DeviceLayer::ThreadStackMgrImpl().OTInstance()) -#endif // CHIP_SYSTEM_CONFIG_USE_OT_UDP +#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_UDP + .SetNativeParams(chip::DeviceLayer::ThreadStackMgrImpl().OTInstance()) +#endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_UDP #if INET_CONFIG_ENABLE_IPV4 , diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index 709b2c39a7e9f5..164c0076c5a546 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -24,7 +24,7 @@ import("${chip_root}/src/lwip/lwip.gni") import("${chip_root}/src/platform/device.gni") import("inet.gni") -if (chip_system_config_use_ot_udp) { +if (chip_system_config_use_open_thread_udp) { import("//build_overrides/openthread.gni") } @@ -55,9 +55,10 @@ buildconfig_header("inet_buildconfig") { } defines += [ "INET_TCP_END_POINT_IMPL_CONFIG_FILE=" ] - if (chip_system_config_use_ot_udp) { - defines += - [ "INET_UDP_END_POINT_IMPL_CONFIG_FILE=" ] + if (chip_system_config_use_open_thread_udp) { + defines += [ + "INET_UDP_END_POINT_IMPL_CONFIG_FILE=", + ] } else { defines += [ "INET_UDP_END_POINT_IMPL_CONFIG_FILE=" ] } @@ -112,7 +113,7 @@ static_library("inet") { public_deps += [ "${chip_root}/src/lwip" ] } - if (chip_system_config_use_ot_udp) { + if (chip_system_config_use_open_thread_udp) { if (chip_openthread_ftd) { public_deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-ftd" ] @@ -139,10 +140,10 @@ static_library("inet") { "UDPEndPointImpl.h", ] - if (chip_system_config_use_ot_udp) { + if (chip_system_config_use_open_thread_udp) { sources += [ - "UDPEndPointImplOT.cpp", - "UDPEndPointImplOT.h", + "UDPEndPointImpl_OpenThread.cpp", + "UDPEndPointImpl_OpenThread.h", ] } else { sources += [ diff --git a/src/inet/UDPEndPoint.h b/src/inet/UDPEndPoint.h index e9a603f7a2dcd5..f8510b3ad9b75f 100644 --- a/src/inet/UDPEndPoint.h +++ b/src/inet/UDPEndPoint.h @@ -247,7 +247,7 @@ class DLL_EXPORT UDPEndPoint : public EndPointBasis */ virtual void Free() = 0; - virtual inline void SetOtInstance(otInstance * instance) { (void) instance; } + virtual inline void SetNativeParams(void * params) { (void) params; } protected: UDPEndPoint(EndPointManager & endPointManager) : diff --git a/src/inet/UDPEndPointImplOT.cpp b/src/inet/UDPEndPointImpl_OpenThread.cpp similarity index 98% rename from src/inet/UDPEndPointImplOT.cpp rename to src/inet/UDPEndPointImpl_OpenThread.cpp index 7634523fe65224..1f7f0f2e26ceea 100644 --- a/src/inet/UDPEndPointImplOT.cpp +++ b/src/inet/UDPEndPointImpl_OpenThread.cpp @@ -17,18 +17,13 @@ * limitations under the License. */ -/** - * This file implements Inet::UDPEndPoint using OpenThread. - */ - -#include +#include #include #include #include #include -//#include #include diff --git a/src/inet/UDPEndPointImplOT.h b/src/inet/UDPEndPointImpl_OpenThread.h similarity index 93% rename from src/inet/UDPEndPointImplOT.h rename to src/inet/UDPEndPointImpl_OpenThread.h index 6a53fac903b4e5..013d46464c8ad7 100644 --- a/src/inet/UDPEndPointImplOT.h +++ b/src/inet/UDPEndPointImpl_OpenThread.h @@ -17,10 +17,6 @@ * limitations under the License. */ -/** - * This file declares an implementation of Inet::UDPEndPoint using sockets. - */ - #pragma once #include @@ -47,7 +43,7 @@ class UDPEndPointImplOT : public UDPEndPoint uint16_t GetBoundPort() const override; void Free() override; void HandleDataReceived(System::PacketBufferHandle && msg); - inline void SetOtInstance(otInstance * instance) { mOTInstance = instance; } + inline void SetNativeParams(otInstance * params) { mOTInstance = static_cast(params); } CHIP_ERROR SetMulticastLoopback(IPVersion aIPVersion, bool aLoopback) override; CHIP_ERROR BindInterfaceImpl(IPAddressType addressType, InterfaceId interfaceId) override; diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp index 432a27b5ba6c2a..171751d58947e7 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp @@ -233,7 +233,7 @@ void GenericThreadStackManagerImpl_OpenThread_LwIP::UpdateThreadInter // Multicast won't work with LWIP on top of OT // Duplication of listeners, unecessary timers, buffer duplication, hardfault etc... -#if CHIP_SYSTEM_CONFIG_USE_OT_UDP +#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_UDP // Refresh Multicast listening if (GenericThreadStackManagerImpl_OpenThread::IsThreadAttachedNoLock()) { @@ -262,7 +262,7 @@ void GenericThreadStackManagerImpl_OpenThread_LwIP::UpdateThreadInter } } } -#endif // CHIP_SYSTEM_CONFIG_USE_OT_UDP +#endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_UDP } ChipLogDetail(DeviceLayer, "LwIP Thread interface addresses %s", isInterfaceUp ? "updated" : "cleared"); diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index e5b441a25770b5..8a60c03dbb9b56 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -59,7 +59,7 @@ buildconfig_header("system_buildconfig") { "CHIP_WITH_NLFAULTINJECTION=${chip_with_nlfaultinjection}", "CHIP_SYSTEM_CONFIG_USE_DISPATCH=${chip_system_config_use_dispatch}", "CHIP_SYSTEM_CONFIG_USE_LWIP=${chip_system_config_use_lwip}", - "CHIP_SYSTEM_CONFIG_USE_OT_UDP=${chip_system_config_use_ot_udp}", + "CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_UDP=${chip_system_config_use_open_thread_udp}", "CHIP_SYSTEM_CONFIG_USE_SOCKETS=${chip_system_config_use_sockets}", "CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK=false", "CHIP_SYSTEM_CONFIG_POSIX_LOCKING=${chip_system_config_posix_locking}", diff --git a/src/system/SystemPacketBuffer.h b/src/system/SystemPacketBuffer.h index 6f973229d8998a..4f877afb0bf048 100644 --- a/src/system/SystemPacketBuffer.h +++ b/src/system/SystemPacketBuffer.h @@ -847,8 +847,10 @@ namespace Inet { class UDPEndPointImplLwIP; } // namespace Inet -#if CHIP_SYSTEM_CONFIG_USE_OT_UDP +#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_UDP // TODO : Temp Implementation issue : 13085 +// Still use LwIP buffer even if using OpenThread UDP implementation +// since decoupling of LwIP from OpenThread is still in progress namespace Inet { class UDPEndPointImplOT; } // namespace Inet @@ -871,8 +873,10 @@ class LwIPPacketBufferView : public PacketBufferHandle */ static struct pbuf * UnsafeGetLwIPpbuf(const PacketBufferHandle & handle) { return PacketBufferHandle::GetLwIPpbuf(handle); } friend class Inet::UDPEndPointImplLwIP; -#if CHIP_SYSTEM_CONFIG_USE_OT_UDP +#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_UDP // TODO : Temp Implementation issue : 13085 + // Still use LwIP buffer even if using OpenThread UDP implementation + // since decoupling of LwIP from OpenThread is still in progress friend class Inet::UDPEndPointImplOT; #endif }; diff --git a/src/system/system.gni b/src/system/system.gni index df7a38d35c394c..71fb601192f99d 100644 --- a/src/system/system.gni +++ b/src/system/system.gni @@ -33,7 +33,7 @@ declare_args() { chip_system_config_provide_statistics = true # Use OpenThread UDP stack directly - chip_system_config_use_ot_udp = false + chip_system_config_use_open_thread_udp = false } declare_args() { diff --git a/src/transport/raw/UDP.cpp b/src/transport/raw/UDP.cpp index ae9652487c2643..c27190ad7b1e6f 100644 --- a/src/transport/raw/UDP.cpp +++ b/src/transport/raw/UDP.cpp @@ -49,9 +49,7 @@ CHIP_ERROR UDP::Init(UdpListenParameters & params) err = params.GetEndPointManager()->NewEndPoint(&mUDPEndPoint); SuccessOrExit(err); -#if CHIP_SYSTEM_CONFIG_USE_OT_UDP - mUDPEndPoint->SetOtInstance(params.GetOtInstance()); -#endif // CHIP_SYSTEM_CONFIG_USE_OT_UDP + mUDPEndPoint->SetNativeParams(params.GetNativeParams()); ChipLogDetail(Inet, "UDP::Init bind&listen port=%d", params.GetListenPort()); diff --git a/src/transport/raw/UDP.h b/src/transport/raw/UDP.h index ab4f1b4de85ffa..3a8f0e36005cf4 100644 --- a/src/transport/raw/UDP.h +++ b/src/transport/raw/UDP.h @@ -34,9 +34,9 @@ #include #include -#if CHIP_SYSTEM_CONFIG_USE_OT_UDP +#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_UDP struct otInstance; -#endif // CHIP_SYSTEM_CONFIG_USE_OT_UDP +#endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_UDP namespace chip { namespace Transport { @@ -75,26 +75,20 @@ class UdpListenParameters return *this; } -private: - Inet::EndPointManager * mEndPointManager; ///< Associated endpoint factory - Inet::IPAddressType mAddressType = Inet::IPAddressType::kIPv6; ///< type of listening socket - uint16_t mListenPort = CHIP_PORT; ///< UDP listen port - Inet::InterfaceId mInterfaceId = Inet::InterfaceId::Null(); ///< Interface to listen on - -#if CHIP_SYSTEM_CONFIG_USE_OT_UDP -public: - otInstance * GetOtInstance() const { return mOtInstance; } - UdpListenParameters & SetOtInstance(otInstance * instance) + void * GetNativeParams() const { return mNativeParams; } + UdpListenParameters & SetNativeParams(void * params) { - mOtInstance = instance; + mNativeParams = params; return *this; } private: - otInstance * mOtInstance = nullptr; - -#endif // CHIP_SYSTEM_CONFIG_USE_OT_UDP + Inet::EndPointManager * mEndPointManager; ///< Associated endpoint factory + Inet::IPAddressType mAddressType = Inet::IPAddressType::kIPv6; ///< type of listening socket + uint16_t mListenPort = CHIP_PORT; ///< UDP listen port + Inet::InterfaceId mInterfaceId = Inet::InterfaceId::Null(); ///< Interface to listen on + void * mNativeParams = nullptr; }; /** Implements a transport using UDP. */