From a1bbef66ccf9fff1213b605d06c37bb95bcdba6e Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk Date: Mon, 20 Sep 2021 13:04:26 +0200 Subject: [PATCH] [mdns/srp] Implemented delayed mDNS platform initialization The Mdns module doesn't wait for SRP platform to be initialized and ready to operate before requesting adding/removing services. SRP platform needs to remove on init all old services associated with the host. * Removed assigning mMdnsInitialized=true in DiscoveryImplPlatform::Init() method, to be sure that DiscoveryImplPlatform always waits for platform to be ready and signal it by calling HandleMdnsInit callback * Removed stopping services in DiscoveryImplPlatform::Start() method, as it is already done one step earlier by StopPublishDevice() method * Added kMdnsPlatformInitialized CHIP event informing that mDNS platform is initalized and posted event in HandleMdnsInit callback * Added OnPlatformEvent in Mdns.cpp that handles kMdnsPlatformInitialized and restarts advertising * Added removing SRP host and services on SRP platform init * Renamed FillMAC method to GetPrimaryMACAddress and moved it to the ConfigurationMgr, as it is useful also for src/lib/mdns and src/platform modules that should not use app/server API. * Bump OpenThread repo version * Bump OTBR-posix repo version --- src/app/server/Mdns.cpp | 34 +++++------ src/include/platform/CHIPDeviceEvent.h | 5 ++ src/include/platform/ConfigurationManager.h | 6 ++ src/include/platform/PlatformManager.h | 5 ++ src/include/platform/ThreadStackManager.h | 17 ++++++ .../GenericConfigurationManagerImpl.cpp | 22 +++++++ .../GenericConfigurationManagerImpl.h | 1 + src/lib/mdns/Discovery_ImplPlatform.cpp | 13 +++- ...nericThreadStackManagerImpl_OpenThread.cpp | 60 ++++++++++++++++++- ...GenericThreadStackManagerImpl_OpenThread.h | 7 ++- src/platform/OpenThread/MdnsImpl.cpp | 10 +++- src/platform/Tizen/MdnsImpl.cpp | 1 + src/platform/fake/ConfigurationManagerImpl.h | 1 + src/platform/fake/MdnsImpl.cpp | 1 + third_party/openthread/repo | 2 +- third_party/ot-br-posix/repo | 2 +- 16 files changed, 158 insertions(+), 29 deletions(-) diff --git a/src/app/server/Mdns.cpp b/src/app/server/Mdns.cpp index 26b946c9a4602b..f48a15bf08a0ed 100644 --- a/src/app/server/Mdns.cpp +++ b/src/app/server/Mdns.cpp @@ -56,26 +56,18 @@ bool HaveOperationalCredentials() return false; } -// Requires an 8-byte mac to accommodate thread. -chip::ByteSpan FillMAC(uint8_t (&mac)[8]) +void OnPlatformEvent(const DeviceLayer::ChipDeviceEvent * event) { - memset(mac, 0, 8); -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - if (chip::DeviceLayer::ThreadStackMgr().GetPrimary802154MACAddress(mac) == CHIP_NO_ERROR) + if (event->Type == DeviceLayer::DeviceEventType::kMdnsPlatformInitialized) { - ChipLogDetail(Discovery, "Using Thread extended MAC for hostname."); - return chip::ByteSpan(mac, 8); + app::MdnsServer::Instance().StartServer(); } -#endif - if (DeviceLayer::ConfigurationMgr().GetPrimaryWiFiMACAddress(mac) == CHIP_NO_ERROR) - { - ChipLogDetail(Discovery, "Using wifi MAC for hostname"); - return chip::ByteSpan(mac, 6); - } - ChipLogError(Discovery, "Wifi mac not known. Using a default."); - uint8_t temp[6] = { 0xEE, 0xAA, 0xBA, 0xDA, 0xBA, 0xD0 }; - memcpy(mac, temp, 6); - return chip::ByteSpan(mac, 6); +} + +void OnPlatformEventWrapper(const DeviceLayer::ChipDeviceEvent * event, intptr_t arg) +{ + (void) arg; + OnPlatformEvent(event); } } // namespace @@ -258,11 +250,12 @@ CHIP_ERROR MdnsServer::AdvertiseOperational() if (fabricInfo.IsInitialized()) { uint8_t mac[8]; + chip::DeviceLayer::ConfigurationMgr().GetPrimaryMACAddress(mac); const auto advertiseParameters = chip::Mdns::OperationalAdvertisingParameters() .SetPeerId(fabricInfo.GetPeerId()) - .SetMac(FillMAC(mac)) + .SetMac(chip::ByteSpan(mac, 8)) .SetPort(GetSecuredPort()) .SetMRPRetryIntervals(Optional(CHIP_CONFIG_MRP_DEFAULT_INITIAL_RETRY_INTERVAL), Optional(CHIP_CONFIG_MRP_DEFAULT_ACTIVE_RETRY_INTERVAL)) @@ -295,7 +288,8 @@ CHIP_ERROR MdnsServer::Advertise(bool commissionableNode, chip::Mdns::Commission char pairingInst[chip::Mdns::kKeyPairingInstructionMaxLength + 1]; uint8_t mac[8]; - advertiseParameters.SetMac(FillMAC(mac)); + chip::DeviceLayer::ConfigurationMgr().GetPrimaryMACAddress(mac); + advertiseParameters.SetMac(chip::ByteSpan(mac, 8)); uint16_t value; if (DeviceLayer::ConfigurationMgr().GetVendorId(value) != CHIP_NO_ERROR) @@ -412,6 +406,8 @@ void MdnsServer::StartServer(chip::Mdns::CommissioningMode mode) ClearTimeouts(); + DeviceLayer::PlatformMgr().AddEventHandler(OnPlatformEventWrapper, 0); + CHIP_ERROR err = Mdns::ServiceAdvertiser::Instance().Init(&chip::DeviceLayer::InetLayer); if (err != CHIP_NO_ERROR) { diff --git a/src/include/platform/CHIPDeviceEvent.h b/src/include/platform/CHIPDeviceEvent.h index d235f4cd838d9b..e40a89bba92650 100644 --- a/src/include/platform/CHIPDeviceEvent.h +++ b/src/include/platform/CHIPDeviceEvent.h @@ -215,6 +215,11 @@ enum PublicEventTypes * */ kOperationalNetworkEnabled, + + /** + * Signals that mDNS platform layer was initialized and is ready to operate. + */ + kMdnsPlatformInitialized, }; /** diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index f9bfc58971a7ad..2342fcb385daf3 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -69,6 +69,7 @@ class ConfigurationManager CHIP_ERROR GetProductRevisionString(char * buf, size_t bufSize); CHIP_ERROR GetProductRevision(uint16_t & productRev); CHIP_ERROR GetSerialNumber(char * buf, size_t bufSize, size_t & serialNumLen); + CHIP_ERROR GetPrimaryMACAddress(uint8_t (&buf)[8]); CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf); CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf); CHIP_ERROR GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & dayOfMonth); @@ -265,6 +266,11 @@ inline CHIP_ERROR ConfigurationManager::GetSerialNumber(char * buf, size_t bufSi return static_cast(this)->_GetSerialNumber(buf, bufSize, serialNumLen); } +inline CHIP_ERROR ConfigurationManager::GetPrimaryMACAddress(uint8_t (&buf)[8]) +{ + return static_cast(this)->_GetPrimaryMACAddress(buf); +} + inline CHIP_ERROR ConfigurationManager::GetPrimaryWiFiMACAddress(uint8_t * buf) { return static_cast(this)->_GetPrimaryWiFiMACAddress(buf); diff --git a/src/include/platform/PlatformManager.h b/src/include/platform/PlatformManager.h index 860648105e0039..d0ce20a53a35e1 100644 --- a/src/include/platform/PlatformManager.h +++ b/src/include/platform/PlatformManager.h @@ -33,6 +33,10 @@ namespace chip { +namespace Mdns { +class DiscoveryImplPlatform; +} + namespace DeviceLayer { class PlatformManagerImpl; @@ -176,6 +180,7 @@ class PlatformManager friend class PlatformManagerImpl; friend class ConnectivityManagerImpl; friend class ConfigurationManagerImpl; + friend class Mdns::DiscoveryImplPlatform; friend class TraitManager; friend class ThreadStackManagerImpl; friend class TimeSyncManager; diff --git a/src/include/platform/ThreadStackManager.h b/src/include/platform/ThreadStackManager.h index e55428a346eca1..e915b71e3322eb 100644 --- a/src/include/platform/ThreadStackManager.h +++ b/src/include/platform/ThreadStackManager.h @@ -65,6 +65,10 @@ using DnsResolveCallback = void (*)(void * context, chip::Mdns::MdnsService * re using DnsBrowseCallback = void (*)(void * context, chip::Mdns::MdnsService * services, size_t servicesSize, CHIP_ERROR error); #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT +using DnsAsyncReturnCallback = void (*)(void * context, CHIP_ERROR error); +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + /** * Provides features for initializing and interacting with the Thread stack on * a chip-enabled device. @@ -102,6 +106,8 @@ class ThreadStackManager CHIP_ERROR InvalidateAllSrpServices(); ///< Mark all SRP services as invalid CHIP_ERROR RemoveInvalidSrpServices(); ///< Remove SRP services marked as invalid CHIP_ERROR SetupSrpHost(const char * aHostName); + CHIP_ERROR ClearSrpHost(const char * aHostName); + CHIP_ERROR SetSrpDnsCallbacks(DnsAsyncReturnCallback aInitCallback, DnsAsyncReturnCallback aErrorCallback, void * aContext); #if CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT CHIP_ERROR DnsBrowse(const char * aServiceName, DnsBrowseCallback aCallback, void * aContext); @@ -275,6 +281,17 @@ inline CHIP_ERROR ThreadStackManager::SetupSrpHost(const char * aHostName) return static_cast(this)->_SetupSrpHost(aHostName); } +inline CHIP_ERROR ThreadStackManager::ClearSrpHost(const char * aHostName) +{ + return static_cast(this)->_ClearSrpHost(aHostName); +} + +inline CHIP_ERROR ThreadStackManager::SetSrpDnsCallbacks(DnsAsyncReturnCallback aInitCallback, + DnsAsyncReturnCallback aErrorCallback, void * aContext) +{ + return static_cast(this)->_SetSrpDnsCallbacks(aInitCallback, aErrorCallback, aContext); +} + #if CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT inline CHIP_ERROR ThreadStackManager::DnsBrowse(const char * aServiceName, DnsBrowseCallback aCallback, void * aContext) { diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp index 73b2df82834430..687f888977df00 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp @@ -230,6 +230,28 @@ CHIP_ERROR GenericConfigurationManagerImpl::_StorePrimaryWiFiMACAddre return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } +template +CHIP_ERROR GenericConfigurationManagerImpl::_GetPrimaryMACAddress(uint8_t (&buf)[8]) +{ + memset(buf, 0, 8); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + if (chip::DeviceLayer::ThreadStackMgr().GetPrimary802154MACAddress(buf) == CHIP_NO_ERROR) + { + ChipLogDetail(DeviceLayer, "Using Thread extended MAC for hostname."); + return CHIP_NO_ERROR; + } +#endif + if (DeviceLayer::ConfigurationMgr().GetPrimaryWiFiMACAddress(buf) == CHIP_NO_ERROR) + { + ChipLogDetail(DeviceLayer, "Using wifi MAC for hostname"); + return CHIP_NO_ERROR; + } + ChipLogError(DeviceLayer, "MAC is not known, using a default."); + uint8_t temp[6] = { 0xEE, 0xAA, 0xBA, 0xDA, 0xBA, 0xD0 }; + memcpy(buf, temp, 6); + return CHIP_NO_ERROR; +} + template CHIP_ERROR GenericConfigurationManagerImpl::_GetPrimary802154MACAddress(uint8_t * buf) { diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index 71c4765906d64a..b0d6dc0c85e36e 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -66,6 +66,7 @@ class GenericConfigurationManagerImpl uint8_t & second); CHIP_ERROR _GetSerialNumber(char * buf, size_t bufSize, size_t & serialNumLen); CHIP_ERROR _StoreSerialNumber(const char * serialNum, size_t serialNumLen); + CHIP_ERROR _GetPrimaryMACAddress(uint8_t (&buf)[8]); CHIP_ERROR _GetPrimaryWiFiMACAddress(uint8_t * buf); CHIP_ERROR _StorePrimaryWiFiMACAddress(const uint8_t * buf); CHIP_ERROR _GetPrimary802154MACAddress(uint8_t * buf); diff --git a/src/lib/mdns/Discovery_ImplPlatform.cpp b/src/lib/mdns/Discovery_ImplPlatform.cpp index fa31503b3d7743..08e017977cbad4 100644 --- a/src/lib/mdns/Discovery_ImplPlatform.cpp +++ b/src/lib/mdns/Discovery_ImplPlatform.cpp @@ -48,7 +48,6 @@ CHIP_ERROR DiscoveryImplPlatform::InitImpl() ReturnErrorCodeIf(mMdnsInitialized, CHIP_NO_ERROR); ReturnErrorOnFailure(ChipMdnsInit(HandleMdnsInit, HandleMdnsError, this)); mCommissionInstanceName = GetRandU64(); - mMdnsInitialized = true; return CHIP_NO_ERROR; } @@ -66,6 +65,18 @@ void DiscoveryImplPlatform::HandleMdnsInit(void * context, CHIP_ERROR initError) if (initError == CHIP_NO_ERROR) { publisher->mMdnsInitialized = true; + +#if !CHIP_DEVICE_LAYER_NONE + // Post an event that will start advertising + chip::DeviceLayer::ChipDeviceEvent event; + event.Type = chip::DeviceLayer::DeviceEventType::kMdnsPlatformInitialized; + + CHIP_ERROR error = chip::DeviceLayer::PlatformMgr().PostEvent(&event); + if (error != CHIP_NO_ERROR) + { + ChipLogError(Discovery, "Posting mDNS platform initialized event failed with %s", chip::ErrorStr(error)); + } +#endif } else { diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp index 46372f0e015609..d995ca5af69566 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp @@ -1506,7 +1506,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_JoinerStart(voi #if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT -static_assert(OPENTHREAD_API_VERSION >= 120, "SRP Client requires a more recent OpenThread version"); +static_assert(OPENTHREAD_API_VERSION >= 156, "SRP Client requires a more recent OpenThread version"); template void GenericThreadStackManagerImpl_OpenThread::OnSrpClientNotification(otError aError, @@ -1520,6 +1520,19 @@ void GenericThreadStackManagerImpl_OpenThread::OnSrpClientNotificatio case OT_ERROR_NONE: { ChipLogProgress(DeviceLayer, "OnSrpClientNotification: Last requested operation completed successfully"); + if (aHostInfo) + { + if (aHostInfo->mState == OT_SRP_CLIENT_ITEM_STATE_REMOVED) + { + // Clear memory for removed host + memset(ThreadStackMgrImpl().mSrpClient.mHostName, 0, sizeof(ThreadStackMgrImpl().mSrpClient.mHostName)); + + ThreadStackMgrImpl().mSrpClient.mIsInitialized = true; + ThreadStackMgrImpl().mSrpClient.mInitializedCallback(ThreadStackMgrImpl().mSrpClient.mCallbackContext, + CHIP_NO_ERROR); + } + } + if (aRemovedServices) { otSrpClientService * otService = const_cast(aRemovedServices); @@ -1620,6 +1633,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_AddSrpService(c Impl()->LockThreadStack(); + VerifyOrExit(mSrpClient.mIsInitialized, error = CHIP_ERROR_WELL_UNINITIALIZED); VerifyOrExit(aInstanceName, error = CHIP_ERROR_INVALID_ARGUMENT); VerifyOrExit(aName, error = CHIP_ERROR_INVALID_ARGUMENT); @@ -1655,7 +1669,6 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_AddSrpService(c srpService->mService.mName = alloc.Clone(aName); srpService->mService.mPort = aPort; -#if OPENTHREAD_API_VERSION >= 132 VerifyOrExit(aSubTypes.size() < ArraySize(srpService->mSubTypes), error = CHIP_ERROR_BUFFER_TOO_SMALL); entryId = 0; @@ -1666,7 +1679,6 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_AddSrpService(c srpService->mSubTypes[entryId] = nullptr; srpService->mService.mSubTypeLabels = srpService->mSubTypes; -#endif // Initialize TXT entries VerifyOrExit(aTxtEntries.size() <= ArraySize(srpService->mTxtEntries), error = CHIP_ERROR_BUFFER_TOO_SMALL); @@ -1712,6 +1724,8 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_RemoveSrpServic CHIP_ERROR error = CHIP_NO_ERROR; typename SrpClient::Service * srpService = nullptr; + VerifyOrExit(mSrpClient.mIsInitialized, error = CHIP_ERROR_WELL_UNINITIALIZED); + Impl()->LockThreadStack(); VerifyOrExit(aInstanceName, error = CHIP_ERROR_INVALID_ARGUMENT); @@ -1760,6 +1774,8 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_RemoveInvalidSr { CHIP_ERROR error = CHIP_NO_ERROR; + VerifyOrExit(mSrpClient.mIsInitialized, error = CHIP_ERROR_WELL_UNINITIALIZED); + Impl()->LockThreadStack(); for (typename SrpClient::Service & service : mSrpClient.mServices) @@ -1784,6 +1800,8 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_SetupSrpHost(co CHIP_ERROR error = CHIP_NO_ERROR; Inet::IPAddress hostAddress; + VerifyOrExit(mSrpClient.mIsInitialized, error = CHIP_ERROR_WELL_UNINITIALIZED); + Impl()->LockThreadStack(); VerifyOrExit(aHostName, error = CHIP_ERROR_INVALID_ARGUMENT); @@ -1811,6 +1829,42 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_SetupSrpHost(co return error; } +template +CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_ClearSrpHost(const char * aHostName) +{ + CHIP_ERROR error = CHIP_NO_ERROR; + + Impl()->LockThreadStack(); + + VerifyOrExit(aHostName, error = CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrExit(mSrpClient.mInitializedCallback, error = CHIP_ERROR_INCORRECT_STATE); + + // Add host and remove it with notifying SRP server to clean old information related to the host. + // Avoid adding the same host name multiple times + if (strcmp(mSrpClient.mHostName, aHostName) != 0) + { + strcpy(mSrpClient.mHostName, aHostName); + error = MapOpenThreadError(otSrpClientSetHostName(mOTInst, mSrpClient.mHostName)); + SuccessOrExit(error); + } + error = MapOpenThreadError(otSrpClientRemoveHostAndServices(mOTInst, false, true)); + +exit: + Impl()->UnlockThreadStack(); + + return error; +} + +template +CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_SetSrpDnsCallbacks(DnsAsyncReturnCallback aInitCallback, + DnsAsyncReturnCallback aErrorCallback, + void * aContext) +{ + mSrpClient.mInitializedCallback = aInitCallback; + mSrpClient.mCallbackContext = aContext; + return CHIP_NO_ERROR; +} + #if CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT template CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::FromOtDnsResponseToMdnsData( diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h index 8ea2f432bd6ac2..1ec80a0f25c024 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h @@ -108,6 +108,8 @@ class GenericThreadStackManagerImpl_OpenThread CHIP_ERROR _RemoveInvalidSrpServices(); CHIP_ERROR _SetupSrpHost(const char * aHostName); + CHIP_ERROR _ClearSrpHost(const char * aHostName); + CHIP_ERROR _SetSrpDnsCallbacks(DnsAsyncReturnCallback aInitCallback, DnsAsyncReturnCallback aErrorCallback, void * aContext); #if CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT CHIP_ERROR _DnsBrowse(const char * aServiceName, DnsBrowseCallback aCallback, void * aContext); CHIP_ERROR _DnsResolve(const char * aServiceName, const char * aInstanceName, DnsResolveCallback aCallback, void * aContext); @@ -165,9 +167,7 @@ class GenericThreadStackManagerImpl_OpenThread otSrpClientService mService; bool mIsInvalid; uint8_t mServiceBuffer[kServiceBufferSize]; -#if OPENTHREAD_API_VERSION >= 132 const char * mSubTypes[kSubTypeMaxNumber + 1]; // extra entry for null terminator -#endif otDnsTxtEntry mTxtEntries[kTxtMaxNumber]; bool IsUsed() const { return mService.mInstanceName != nullptr; } @@ -177,6 +177,9 @@ class GenericThreadStackManagerImpl_OpenThread char mHostName[kMaxHostNameSize + 1]; otIp6Address mHostAddress; Service mServices[kMaxServicesNumber]; + bool mIsInitialized; + DnsAsyncReturnCallback mInitializedCallback; + void * mCallbackContext; }; SrpClient mSrpClient; diff --git a/src/platform/OpenThread/MdnsImpl.cpp b/src/platform/OpenThread/MdnsImpl.cpp index 2c5867d058a120..1eb99f3c5bf39c 100644 --- a/src/platform/OpenThread/MdnsImpl.cpp +++ b/src/platform/OpenThread/MdnsImpl.cpp @@ -28,8 +28,14 @@ namespace Mdns { CHIP_ERROR ChipMdnsInit(MdnsAsyncReturnCallback initCallback, MdnsAsyncReturnCallback errorCallback, void * context) { - // Intentionally empty - return CHIP_NO_ERROR; + ReturnErrorOnFailure(ThreadStackMgr().SetSrpDnsCallbacks(initCallback, errorCallback, context)); + + uint8_t mac[8]; + char hostname[kMdnsHostNameMaxSize + 1] = ""; + ReturnErrorOnFailure(DeviceLayer::ConfigurationMgr().GetPrimaryMACAddress(mac)); + MakeHostName(hostname, sizeof(hostname), chip::ByteSpan(mac, 8)); + + return ThreadStackMgr().ClearSrpHost(hostname); } CHIP_ERROR ChipMdnsShutdown() diff --git a/src/platform/Tizen/MdnsImpl.cpp b/src/platform/Tizen/MdnsImpl.cpp index e4ae1fd4e1b8bc..aa571088bcdd41 100644 --- a/src/platform/Tizen/MdnsImpl.cpp +++ b/src/platform/Tizen/MdnsImpl.cpp @@ -28,6 +28,7 @@ namespace Mdns { CHIP_ERROR ChipMdnsInit(MdnsAsyncReturnCallback successCallback, MdnsAsyncReturnCallback errorCallback, void * context) { + successCallback(context, CHIP_ERROR_NOT_IMPLEMENTED); return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index a4170eeec9b6b4..5f7024a63328db 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -49,6 +49,7 @@ class ConfigurationManagerImpl final : public ConfigurationManager } CHIP_ERROR _GetSerialNumber(char * buf, size_t bufSize, size_t & serialNumLen) { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR _StoreSerialNumber(const char * serialNum, size_t serialNumLen) { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR _GetPrimaryMACAddress(uint8_t (&buf)[8]) { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR _GetPrimaryWiFiMACAddress(uint8_t * buf) { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR _StorePrimaryWiFiMACAddress(const uint8_t * buf) { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR _GetPrimary802154MACAddress(uint8_t * buf) { return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/platform/fake/MdnsImpl.cpp b/src/platform/fake/MdnsImpl.cpp index 0d5e1571763dd9..f529afb2e8d490 100644 --- a/src/platform/fake/MdnsImpl.cpp +++ b/src/platform/fake/MdnsImpl.cpp @@ -92,6 +92,7 @@ CHIP_ERROR CheckExpected(CallType type, const MdnsService * service) CHIP_ERROR ChipMdnsInit(MdnsAsyncReturnCallback initCallback, MdnsAsyncReturnCallback errorCallback, void * context) { + initCallback(context, CHIP_NO_ERROR); return CHIP_NO_ERROR; } diff --git a/third_party/openthread/repo b/third_party/openthread/repo index 009dba991b282f..9ea34d1e2053b6 160000 --- a/third_party/openthread/repo +++ b/third_party/openthread/repo @@ -1 +1 @@ -Subproject commit 009dba991b282f4b10c373187a8339efbbcbc8ce +Subproject commit 9ea34d1e2053b6b2a80e1d46b65a6aee99fc504a diff --git a/third_party/ot-br-posix/repo b/third_party/ot-br-posix/repo index 81a4392f7f7574..a4880eb0a782ad 160000 --- a/third_party/ot-br-posix/repo +++ b/third_party/ot-br-posix/repo @@ -1 +1 @@ -Subproject commit 81a4392f7f757482f37822c5e9d7fa4a899b8184 +Subproject commit a4880eb0a782adb9e6104cb00aa285d0be3a669a