mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[dnssd] allow Dnssd platform to use native OT mDNS modules (#9944)
Updates the `Dnssd` module to allow it use - Either the native OT mDNS implementation - Or use the platform `otPlatDnssd` APIs (delegated to platform) Also adds `OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF` for mDNS module to be automatically enabled/disabled on the same infra-if used for border routing based on infra-if state.
This commit is contained in:
committed by
GitHub
parent
59572efb4e
commit
4737231d64
@@ -61,6 +61,7 @@ OT_BUILD_OPTIONS=(
|
||||
"-DOT_JOINER=ON"
|
||||
"-DOT_LOG_LEVEL_DYNAMIC=ON"
|
||||
"-DOT_MAC_FILTER=ON"
|
||||
"-DOT_MDNS=ON"
|
||||
"-DOT_MESH_DIAG=ON"
|
||||
"-DOT_NAT64_BORDER_ROUTING=ON"
|
||||
"-DOT_NAT64_TRANSLATOR=ON"
|
||||
|
||||
@@ -122,6 +122,7 @@ OT_CLANG_TIDY_BUILD_OPTS=(
|
||||
'-DOT_LINK_METRICS_INITIATOR=ON'
|
||||
'-DOT_LINK_METRICS_SUBJECT=ON'
|
||||
'-DOT_MAC_FILTER=ON'
|
||||
'-DOT_MDNS=ON'
|
||||
'-DOT_MESH_DIAG=ON'
|
||||
'-DOT_NAT64_BORDER_ROUTING=ON'
|
||||
'-DOT_NAT64_TRANSLATOR=ON'
|
||||
|
||||
@@ -156,6 +156,10 @@ Error InfraIf::HandleStateChanged(uint32_t aIfIndex, bool aIsRunning)
|
||||
Get<Srp::AdvertisingProxy>().HandleInfraIfStateChanged();
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE && OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF
|
||||
Get<Dns::Multicast::Core>().HandleInfraIfStateChanged();
|
||||
#endif
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -109,6 +109,11 @@ Error RoutingManager::Init(uint32_t aInfraIfIndex, bool aInfraIfIsRunning)
|
||||
else if (aInfraIfIndex != mInfraIf.GetIfIndex())
|
||||
{
|
||||
LogInfo("Reinitializing - InfraIfIndex:%lu -> %lu", ToUlong(mInfraIf.GetIfIndex()), ToUlong(aInfraIfIndex));
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE && OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF
|
||||
IgnoreError(Get<Dns::Multicast::Core>().SetEnabled(false, mInfraIf.GetIfIndex()));
|
||||
#endif
|
||||
|
||||
mInfraIf.SetIfIndex(aInfraIfIndex);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,17 @@
|
||||
#define OPENTHREAD_CONFIG_MULTICAST_DNS_PUBLIC_API_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF
|
||||
*
|
||||
* Define to 1 for mDNS module to be automatically enabled/disabled on the same infra-if used for border routing
|
||||
* based on infra-if state.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF
|
||||
#define OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MULTICAST_DNS_DEFAULT_QUESTION_UNICAST_ALLOWED
|
||||
*
|
||||
|
||||
@@ -116,7 +116,21 @@
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
*
|
||||
* Define as 1 to enable run-time selection of DNSSD module, i.e., whether the native OpenThread mDNS module is used or
|
||||
* the platform `otPlatDnssd` APIs are used (DNSSD support is delegated to the platform layer).
|
||||
*
|
||||
* This config is mainly intended for testing, allowing test-specific `otPlatDnssd` APIs to be used instead of the
|
||||
* native mDNS module in unit tests.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,7 @@ Instance::Instance(void)
|
||||
, mSettings(*this)
|
||||
, mSettingsDriver(*this)
|
||||
, mMessagePool(*this)
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE || OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
// DNS-SD (mDNS) platform is initialized early to
|
||||
// allow other modules to use it.
|
||||
, mDnssd(*this)
|
||||
|
||||
@@ -481,7 +481,7 @@ private:
|
||||
SettingsDriver mSettingsDriver;
|
||||
MessagePool mMessagePool;
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE || OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
// DNS-SD (mDNS) platform is initialized early to
|
||||
// allow other modules to use it.
|
||||
Dnssd mDnssd;
|
||||
@@ -902,7 +902,7 @@ template <> inline EnergyScanClient &Instance::Get(void) { return mCommissioner.
|
||||
template <> inline PanIdQueryClient &Instance::Get(void) { return mCommissioner.GetPanIdQueryClient(); }
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE || OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
template <> inline Dnssd &Instance::Get(void) { return mDnssd; }
|
||||
#endif
|
||||
|
||||
|
||||
+142
-16
@@ -28,12 +28,12 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements infrastructure DNS-SD (mDNS) platform APIs.
|
||||
* This file implements infrastructure DNS-SD module.
|
||||
*/
|
||||
|
||||
#include "dnssd.hpp"
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE || OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/locator_getters.hpp"
|
||||
@@ -88,58 +88,184 @@ bool Dnssd::RequestIdRange::Contains(RequestId aId) const
|
||||
|
||||
Dnssd::Dnssd(Instance &aInstance)
|
||||
: InstanceLocator(aInstance)
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
, mUseNativeMdns(true)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
Dnssd::State Dnssd::GetState(void) const { return MapEnum(otPlatDnssdGetState(&GetInstance())); }
|
||||
Dnssd::State Dnssd::GetState(void) const
|
||||
{
|
||||
State state;
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
if (mUseNativeMdns)
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
{
|
||||
state = Get<Dns::Multicast::Core>().IsEnabled() ? kReady : kStopped;
|
||||
ExitNow();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
state = MapEnum(otPlatDnssdGetState(&GetInstance()));
|
||||
ExitNow();
|
||||
#endif
|
||||
|
||||
exit:
|
||||
return state;
|
||||
}
|
||||
|
||||
void Dnssd::RegisterService(const Service &aService, RequestId aRequestId, RegisterCallback aCallback)
|
||||
{
|
||||
if (IsReady())
|
||||
VerifyOrExit(IsReady());
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
if (mUseNativeMdns)
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
{
|
||||
otPlatDnssdRegisterService(&GetInstance(), &aService, aRequestId, aCallback);
|
||||
IgnoreError(Get<Dns::Multicast::Core>().RegisterService(aService, aRequestId, aCallback));
|
||||
ExitNow();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
otPlatDnssdRegisterService(&GetInstance(), &aService, aRequestId, aCallback);
|
||||
#endif
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void Dnssd::UnregisterService(const Service &aService, RequestId aRequestId, RegisterCallback aCallback)
|
||||
{
|
||||
if (IsReady())
|
||||
VerifyOrExit(IsReady());
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
if (mUseNativeMdns)
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
{
|
||||
otPlatDnssdUnregisterService(&GetInstance(), &aService, aRequestId, aCallback);
|
||||
IgnoreError(Get<Dns::Multicast::Core>().UnregisterService(aService));
|
||||
VerifyOrExit(aCallback != nullptr);
|
||||
aCallback(&GetInstance(), aRequestId, kErrorNone);
|
||||
ExitNow();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
otPlatDnssdUnregisterService(&GetInstance(), &aService, aRequestId, aCallback);
|
||||
#endif
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void Dnssd::RegisterHost(const Host &aHost, RequestId aRequestId, RegisterCallback aCallback)
|
||||
{
|
||||
if (IsReady())
|
||||
VerifyOrExit(IsReady());
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
if (mUseNativeMdns)
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
{
|
||||
otPlatDnssdRegisterHost(&GetInstance(), &aHost, aRequestId, aCallback);
|
||||
IgnoreError(Get<Dns::Multicast::Core>().RegisterHost(aHost, aRequestId, aCallback));
|
||||
ExitNow();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
otPlatDnssdRegisterHost(&GetInstance(), &aHost, aRequestId, aCallback);
|
||||
#endif
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void Dnssd::UnregisterHost(const Host &aHost, RequestId aRequestId, RegisterCallback aCallback)
|
||||
{
|
||||
if (IsReady())
|
||||
VerifyOrExit(IsReady());
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
if (mUseNativeMdns)
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
{
|
||||
otPlatDnssdUnregisterHost(&GetInstance(), &aHost, aRequestId, aCallback);
|
||||
IgnoreError(Get<Dns::Multicast::Core>().UnregisterHost(aHost));
|
||||
VerifyOrExit(aCallback != nullptr);
|
||||
aCallback(&GetInstance(), aRequestId, kErrorNone);
|
||||
ExitNow();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
otPlatDnssdUnregisterHost(&GetInstance(), &aHost, aRequestId, aCallback);
|
||||
#endif
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void Dnssd::RegisterKey(const Key &aKey, RequestId aRequestId, RegisterCallback aCallback)
|
||||
{
|
||||
if (IsReady())
|
||||
VerifyOrExit(IsReady());
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
if (mUseNativeMdns)
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
{
|
||||
otPlatDnssdRegisterKey(&GetInstance(), &aKey, aRequestId, aCallback);
|
||||
IgnoreError(Get<Dns::Multicast::Core>().RegisterKey(aKey, aRequestId, aCallback));
|
||||
ExitNow();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
otPlatDnssdRegisterKey(&GetInstance(), &aKey, aRequestId, aCallback);
|
||||
#endif
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void Dnssd::UnregisterKey(const Key &aKey, RequestId aRequestId, RegisterCallback aCallback)
|
||||
{
|
||||
if (IsReady())
|
||||
VerifyOrExit(IsReady());
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
if (mUseNativeMdns)
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
{
|
||||
otPlatDnssdUnregisterKey(&GetInstance(), &aKey, aRequestId, aCallback);
|
||||
IgnoreError(Get<Dns::Multicast::Core>().UnregisterKey(aKey));
|
||||
VerifyOrExit(aCallback != nullptr);
|
||||
aCallback(&GetInstance(), aRequestId, kErrorNone);
|
||||
ExitNow();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
otPlatDnssdUnregisterKey(&GetInstance(), &aKey, aRequestId, aCallback);
|
||||
#endif
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
void Dnssd::HandleMdnsCoreStateChange(void)
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
if (mUseNativeMdns)
|
||||
#endif
|
||||
{
|
||||
HandleStateChange();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void Dnssd::HandleStateChange(void)
|
||||
{
|
||||
@@ -155,4 +281,4 @@ extern "C" void otPlatDnssdStateHandleStateChange(otInstance *aInstance)
|
||||
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
#endif // OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE || OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
|
||||
+51
-5
@@ -28,7 +28,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes definitions for infrastructure DNS-SD (mDNS) platform.
|
||||
* This file includes definitions for DNS-SD module.
|
||||
*/
|
||||
|
||||
#ifndef DNSSD_HPP_
|
||||
@@ -36,7 +36,17 @@
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE || OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
|
||||
#if !OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE && OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
#error "Must enable either `PLATFORM_DNSSD_ENABLE` or `MULTICAST_DNS_ENABLE` and not both."
|
||||
#endif
|
||||
#else
|
||||
#if !OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE || !OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
#error "`PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION` requires both `PLATFORM_DNSSD_ENABLE` or `MULTICAST_DNS_ENABLE`.".
|
||||
#endif
|
||||
#endif // !OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
|
||||
#include <openthread/platform/dnssd.h>
|
||||
|
||||
@@ -51,7 +61,10 @@ namespace ot {
|
||||
* @addtogroup core-dns
|
||||
*
|
||||
* @brief
|
||||
* This module includes definitions for DNS-SD (mDNS) platform.
|
||||
* This module includes definitions for DNS-SD (mDNS) APIs used by other modules in OT (e.g. advertising proxy).
|
||||
*
|
||||
* The DNS-SD is implemented either using the native mDNS module in OpenThread or using `otPlatDnssd` platform
|
||||
* APIs (delegating the DNS-SD implementation to platform layer).
|
||||
*
|
||||
* @{
|
||||
*
|
||||
@@ -60,7 +73,7 @@ namespace ot {
|
||||
extern "C" void otPlatDnssdStateHandleStateChange(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Represents DNS-SD (mDNS) platform.
|
||||
* Represents DNS-SD module.
|
||||
*
|
||||
*/
|
||||
class Dnssd : public InstanceLocator, private NonCopyable
|
||||
@@ -261,8 +274,41 @@ public:
|
||||
*/
|
||||
void UnregisterKey(const Key &aKey, RequestId aRequestId, RegisterCallback aCallback);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
/**
|
||||
* Handles native mDNS state change.
|
||||
*
|
||||
* This is used to notify `Dnssd` when `Multicast::Dns::Core` gets enabled or disabled.
|
||||
*
|
||||
*/
|
||||
void HandleMdnsCoreStateChange(void);
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
/**
|
||||
* Selects whether to use the native mDNS or the platform `otPlatDnssd` APIs.
|
||||
*
|
||||
* @param[in] aUseMdns TRUE to use the native mDNS module, FALSE to use platform APIs.
|
||||
*
|
||||
*/
|
||||
void SetUseNativeMdns(bool aUseMdns) { mUseNativeMdns = aUseMdns; }
|
||||
|
||||
/**
|
||||
* Indicates whether the `Dnssd` is using the native mDNS or the platform `otPlatDnssd` APIs.
|
||||
*
|
||||
* @retval TRUE `Dnssd` is using the native mDSN module.
|
||||
* @retval FALSE `Dnssd` is using the platform `otPlatDnssd` APIs.
|
||||
*
|
||||
*/
|
||||
bool ShouldUseNativeMdns(void) const { return mUseNativeMdns; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
void HandleStateChange(void);
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
bool mUseNativeMdns;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -277,6 +323,6 @@ DefineCoreType(otPlatDnssdKey, Dnssd::Key);
|
||||
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
#endif // OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE || OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
|
||||
#endif // DNSSD_HPP_
|
||||
|
||||
@@ -122,10 +122,19 @@ Error Core::SetEnabled(bool aEnable, uint32_t aInfraIfIndex)
|
||||
mCacheTimer.Stop();
|
||||
}
|
||||
|
||||
Get<Dnssd>().HandleMdnsCoreStateChange();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF
|
||||
void Core::HandleInfraIfStateChanged(void)
|
||||
{
|
||||
IgnoreError(SetEnabled(Get<BorderRouter::InfraIf>().IsRunning(), Get<BorderRouter::InfraIf>().GetIfIndex()));
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename EntryType, typename ItemInfo>
|
||||
Error Core::Register(const ItemInfo &aItemInfo, RequestId aRequestId, RegisterCallback aCallback)
|
||||
{
|
||||
@@ -3426,6 +3435,8 @@ void Core::RxMessage::AnswerQuestion(const Question &aQuestion, TimeMilli aAnswe
|
||||
|
||||
// Question is for `ServiceEntry`
|
||||
|
||||
VerifyOrExit(serviceEntry != nullptr);
|
||||
|
||||
if (!aQuestion.mIsServiceType)
|
||||
{
|
||||
serviceEntry->AnswerServiceNameQuestion(answerInfo);
|
||||
|
||||
+15
-3
@@ -53,6 +53,10 @@
|
||||
#include "crypto/sha256.hpp"
|
||||
#include "net/dns_types.hpp"
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF && !OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
#error "OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF requires OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes definitions for the Multicast DNS per RFC 6762.
|
||||
@@ -157,6 +161,14 @@ public:
|
||||
*/
|
||||
bool IsEnabled(void) const { return mIsEnabled; }
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF
|
||||
/**
|
||||
* Notifies `AdvertisingProxy` that `InfraIf` state changed.
|
||||
*
|
||||
*/
|
||||
void HandleInfraIfStateChanged(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Sets whether mDNS module is allowed to send questions requesting unicast responses referred to as "QU" questions.
|
||||
*
|
||||
@@ -916,7 +928,7 @@ private:
|
||||
Error Init(Instance &aInstance, const Service &aService);
|
||||
Error Init(Instance &aInstance, const Key &aKey);
|
||||
bool IsEmpty(void) const;
|
||||
bool Matches(const Name &aName) const;
|
||||
bool Matches(const Name &aFullName) const;
|
||||
bool Matches(const Service &aService) const;
|
||||
bool Matches(const Key &aKey) const;
|
||||
bool Matches(State aState) const { return GetState() == aState; }
|
||||
@@ -1625,7 +1637,7 @@ private:
|
||||
public:
|
||||
bool Matches(const Name &aFullName) const;
|
||||
bool Matches(const char *aName) const;
|
||||
bool Matches(const AddressResolver &aBrowser) const;
|
||||
bool Matches(const AddressResolver &aResolver) const;
|
||||
bool Matches(const ExpireChecker &aExpireChecker) const;
|
||||
Error Add(const AddressResolver &aResolver);
|
||||
void Remove(const AddressResolver &aResolver);
|
||||
@@ -1715,7 +1727,7 @@ private:
|
||||
|
||||
void InvokeConflictCallback(const char *aName, const char *aServiceType);
|
||||
void HandleMessage(Message &aMessage, bool aIsUnicast, const AddressInfo &aSenderAddress);
|
||||
void AddPassiveSrvTxtCache(const char *aServiceInstance, const char *aServcieType);
|
||||
void AddPassiveSrvTxtCache(const char *aServiceInstance, const char *aServiceType);
|
||||
void AddPassiveIp6AddrCache(const char *aHostName);
|
||||
TimeMilli RandomizeFirstProbeTxTime(void);
|
||||
TimeMilli RandomizeInitialQueryTxTime(void);
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
|
||||
#if OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE
|
||||
|
||||
#if !OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE
|
||||
#error "OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE requires OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE"
|
||||
#if !OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE && !OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE
|
||||
#error "OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE requires PLATFORM_DNSSD_ENABLE or MULTICAST_DNS_ENABLE"
|
||||
#endif
|
||||
|
||||
#if !OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
|
||||
|
||||
@@ -41,6 +41,12 @@
|
||||
|
||||
#define OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_MULTICAST_DNS_PUBLIC_API_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE 0
|
||||
|
||||
#ifdef __linux__
|
||||
#define OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE 1
|
||||
#endif
|
||||
|
||||
@@ -48,6 +48,16 @@
|
||||
|
||||
#define OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_MULTICAST_DNS_PUBLIC_API_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF 0
|
||||
|
||||
#define OPENTHREAD_SIMULATION_MDNS_SOCKET_IMPLEMENT_POSIX 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 0
|
||||
@@ -64,8 +74,6 @@
|
||||
|
||||
#define OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE 1
|
||||
|
||||
@@ -178,10 +178,6 @@
|
||||
|
||||
#define OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_MULTICAST_DNS_PUBLIC_API_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_CLI_REGISTER_IP6_RECV_CALLBACK 1
|
||||
|
||||
+10
-10
@@ -1282,7 +1282,7 @@ static void SendHostAddrResponse(const char *aHostName,
|
||||
|
||||
Log("Sending AAAA response for %s numAddrs:%u, cach-flush:%u", aHostName, aNumAddrs, aCacheFlush);
|
||||
|
||||
for (uint16_t index = 0; index < aNumAddrs; index++)
|
||||
for (uint32_t index = 0; index < aNumAddrs; index++)
|
||||
{
|
||||
record.SetTtl(aAddrAndTtls[index].mTtl);
|
||||
record.SetAddress(aAddrAndTtls[index].mAddress);
|
||||
@@ -2563,7 +2563,7 @@ void TestServiceSubTypeReg(void)
|
||||
dnsMsg->ValidateHeader(kMulticastResponse, /* Q */ 0, /* Ans */ 7, /* Auth */ 0, /* Addnl */ 1);
|
||||
dnsMsg->Validate(service, kInAnswerSection, kCheckSrv | kCheckTxt | kCheckPtr | kCheckServicesPtr);
|
||||
|
||||
for (uint8_t index = 0; index < service.mSubTypeLabelsLength; index++)
|
||||
for (uint16_t index = 0; index < service.mSubTypeLabelsLength; index++)
|
||||
{
|
||||
dnsMsg->ValidateSubType(service.mSubTypeLabels[index], service);
|
||||
}
|
||||
@@ -2647,7 +2647,7 @@ void TestServiceSubTypeReg(void)
|
||||
dnsMsg->ValidateHeader(kMulticastResponse, /* Q */ 0, /* Ans */ 1, /* Auth */ 0, /* Addnl */ 0);
|
||||
dnsMsg->Validate(service, kInAnswerSection, kCheckServicesPtr);
|
||||
|
||||
for (uint8_t index = 0; index < service.mSubTypeLabelsLength; index++)
|
||||
for (uint16_t index = 0; index < service.mSubTypeLabelsLength; index++)
|
||||
{
|
||||
Log("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
|
||||
Log("Send a PTR query for sub-type `%s` and validate the response", service.mSubTypeLabels[index]);
|
||||
@@ -2746,7 +2746,7 @@ void TestServiceSubTypeReg(void)
|
||||
dnsMsg->ValidateHeader(kMulticastResponse, /* Q */ 0, /* Ans */ 6, /* Auth */ 0, /* Addnl */ 1);
|
||||
dnsMsg->Validate(service, kInAnswerSection, kCheckSrv | kCheckTxt | kCheckPtr);
|
||||
|
||||
for (uint8_t index = 0; index < service.mSubTypeLabelsLength; index++)
|
||||
for (uint16_t index = 0; index < service.mSubTypeLabelsLength; index++)
|
||||
{
|
||||
dnsMsg->ValidateSubType(service.mSubTypeLabels[index], service);
|
||||
}
|
||||
@@ -2803,7 +2803,7 @@ void TestServiceSubTypeReg(void)
|
||||
dnsMsg->ValidateHeader(kMulticastResponse, /* Q */ 0, /* Ans */ 7, /* Auth */ 0, /* Addnl */ 0);
|
||||
dnsMsg->Validate(service, kInAnswerSection, kCheckSrv | kCheckTxt | kCheckPtr, kGoodBye);
|
||||
|
||||
for (uint8_t index = 0; index < service.mSubTypeLabelsLength; index++)
|
||||
for (uint16_t index = 0; index < service.mSubTypeLabelsLength; index++)
|
||||
{
|
||||
dnsMsg->ValidateSubType(service.mSubTypeLabels[index], service, kGoodBye);
|
||||
}
|
||||
@@ -3347,12 +3347,12 @@ void TestQuery(void)
|
||||
dnsMsg->Validate(key1, kInAnswerSection);
|
||||
dnsMsg->Validate(key2, kInAnswerSection);
|
||||
|
||||
for (uint8_t index = 0; index < service1.mSubTypeLabelsLength; index++)
|
||||
for (uint16_t index = 0; index < service1.mSubTypeLabelsLength; index++)
|
||||
{
|
||||
dnsMsg->ValidateSubType(service1.mSubTypeLabels[index], service1);
|
||||
}
|
||||
|
||||
for (uint8_t index = 0; index < service3.mSubTypeLabelsLength; index++)
|
||||
for (uint16_t index = 0; index < service3.mSubTypeLabelsLength; index++)
|
||||
{
|
||||
dnsMsg->ValidateSubType(service3.mSubTypeLabels[index], service3);
|
||||
}
|
||||
@@ -3654,7 +3654,7 @@ void TestQuery(void)
|
||||
dnsMsg->ValidateHeader(kMulticastResponse, /* Q */ 0, /* Ans */ 5, /* Auth */ 0, /* Addnl */ 0);
|
||||
dnsMsg->Validate(service1, kInAnswerSection, kCheckSrv | kCheckTxt | kCheckPtr, kGoodBye);
|
||||
|
||||
for (uint8_t index = 0; index < service1.mSubTypeLabelsLength; index++)
|
||||
for (uint16_t index = 0; index < service1.mSubTypeLabelsLength; index++)
|
||||
{
|
||||
dnsMsg->ValidateSubType(service1.mSubTypeLabels[index], service1, kGoodBye);
|
||||
}
|
||||
@@ -3683,7 +3683,7 @@ void TestQuery(void)
|
||||
dnsMsg->ValidateHeader(kMulticastResponse, /* Q */ 0, /* Ans */ 5, /* Auth */ 0, /* Addnl */ 0);
|
||||
dnsMsg->Validate(service1, kInAnswerSection, kCheckSrv | kCheckTxt | kCheckPtr, kGoodBye);
|
||||
|
||||
for (uint8_t index = 0; index < service1.mSubTypeLabelsLength; index++)
|
||||
for (uint16_t index = 0; index < service1.mSubTypeLabelsLength; index++)
|
||||
{
|
||||
dnsMsg->ValidateSubType(service1.mSubTypeLabels[index], service1, kGoodBye);
|
||||
}
|
||||
@@ -3767,7 +3767,7 @@ void TestMultiPacket(void)
|
||||
dnsMsg->ValidateHeader(kMulticastResponse, /* Q */ 0, /* Ans */ 7, /* Auth */ 0, /* Addnl */ 1);
|
||||
dnsMsg->Validate(service, kInAnswerSection, kCheckSrv | kCheckTxt | kCheckPtr | kCheckServicesPtr);
|
||||
|
||||
for (uint8_t index = 0; index < service.mSubTypeLabelsLength; index++)
|
||||
for (uint16_t index = 0; index < service.mSubTypeLabelsLength; index++)
|
||||
{
|
||||
dnsMsg->ValidateSubType(service.mSubTypeLabels[index], service);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
#if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE && OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE && \
|
||||
OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE && !OPENTHREAD_CONFIG_TIME_SYNC_ENABLE && \
|
||||
!OPENTHREAD_PLATFORM_POSIX
|
||||
!OPENTHREAD_PLATFORM_POSIX && OPENTHREAD_CONFIG_PLATFORM_DNSSD_ALLOW_RUN_TIME_SELECTION
|
||||
#define ENABLE_ADV_PROXY_TEST 1
|
||||
#else
|
||||
#define ENABLE_ADV_PROXY_TEST 0
|
||||
@@ -543,6 +543,10 @@ void InitTest(void)
|
||||
SuccessOrQuit(otIp6SetEnabled(sInstance, true));
|
||||
SuccessOrQuit(otThreadSetEnabled(sInstance, true));
|
||||
|
||||
// Configure the `Dnssd` module to use `otPlatDnssd` APIs.
|
||||
|
||||
sInstance->Get<Dnssd>().SetUseNativeMdns(false);
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Ensure device starts as leader.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user