From e9c6fc3ef35731207c0b55bac76a385d579f862c Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Fri, 19 Feb 2021 17:41:37 -0500 Subject: [PATCH] Do a mDNS advertisement on minmdns server startup (#4884) * Listen on all IPv4 interfaces (not only NULL interface ID) so that replies to queries can be sent with link local information as well * Do a startup mDNS broadcast for available services - no filtering by interface/capability yet * Ensure mdns advertise at boot only happens on interfaces that it is aware of * Remove FIXME since it was already addressed * Revise doc comment on boot time advertisement * Add a constant for maximum interface name length * Restyle fixes * Fix LWIP interface name max size * Increase LWIP max size some more, to support for 32bit interface numbers (even if unlikely) * Update include file for zephyr interface name constant * Deduplicate the detection of usable mdns interfaces * Deduplicate ip addresses for global mdns broadcast * Fix compilation * Fix linkage too * do not use pre-main initialization for mDNS broadcast IP addresses * Fix typo: Trottle -> Throttle * Fix typo: Trottle -> Throttle * Add todo to have better local loopback detection for interfaces * Log on IP parse error - we seem to crash in esp32 and am not sure why. Better to log instead of dying * Fix condition inversion * Fix logic error: IP address returns a bool not CHIP_ERROR --- examples/minimal-mdns/AllInterfaceListener.h | 3 +- src/inet/InetInterface.h | 15 ++ src/inet/tests/TestInetCommonPosix.cpp | 2 +- src/inet/tests/TestInetEndPoint.cpp | 2 +- src/lib/mdns/Advertiser_ImplMinimalMdns.cpp | 169 +++++++++++++++--- src/lib/mdns/minimal/Parser.h | 13 +- src/lib/mdns/minimal/QueryReplyFilter.h | 42 ++++- src/lib/mdns/minimal/ResponseSender.cpp | 4 +- src/lib/mdns/minimal/Server.cpp | 45 +++-- src/lib/mdns/minimal/Server.h | 33 +++- .../minimal/responders/QueryResponder.cpp | 8 + .../mdns/minimal/responders/QueryResponder.h | 4 + src/transport/NetworkProvisioning.cpp | 8 +- 13 files changed, 281 insertions(+), 67 deletions(-) diff --git a/examples/minimal-mdns/AllInterfaceListener.h b/examples/minimal-mdns/AllInterfaceListener.h index 844305ee0b2c17..ccedc2d0c95e8d 100644 --- a/examples/minimal-mdns/AllInterfaceListener.h +++ b/examples/minimal-mdns/AllInterfaceListener.h @@ -94,7 +94,8 @@ class AllInterfaces : public mdns::Minimal::ListenIterator { return true; // not a usable interface } - char name[64]; + + char name[chip::Inet::InterfaceIterator::kMaxIfNameLength]; if (mIterator.GetInterfaceName(name, sizeof(name)) != CHIP_NO_ERROR) { printf("!!!! FAILED TO GET INTERFACE NAME\n"); diff --git a/src/inet/InetInterface.h b/src/inet/InetInterface.h index ed8643126f3e90..6939049a0f1786 100644 --- a/src/inet/InetInterface.h +++ b/src/inet/InetInterface.h @@ -42,6 +42,8 @@ struct ifaddrs; #endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS #if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF +#include + struct net_if; struct net_if_ipv4; struct net_if_ipv6; @@ -152,6 +154,19 @@ class InterfaceIterator bool SupportsMulticast(); bool HasBroadcastAddress(); +#if CHIP_SYSTEM_CONFIG_USE_LWIP + static constexpr size_t kMaxIfNameLength = 13; // Names are formatted as %c%c%d +#elif CHIP_SYSTEM_CONFIG_USE_SOCKETS && CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS + static constexpr size_t kMaxIfNameLength = IF_NAMESIZE; +#elif CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF + static constexpr size_t kMaxIfNameLength = Z_DEVICE_MAX_NAME_LEN; +#elif defined(IFNAMSIZ) + static constexpr size_t kMaxIfNameLength = IFNAMSIZ; +#else + // No constant available here - set some reasonable size + static constexpr size_t kMaxIfNameLength = 33; +#endif + protected: #if CHIP_SYSTEM_CONFIG_USE_LWIP struct netif * mCurNetif; diff --git a/src/inet/tests/TestInetCommonPosix.cpp b/src/inet/tests/TestInetCommonPosix.cpp index 6dcacb4dcbe6bb..6193bf97983477 100644 --- a/src/inet/tests/TestInetCommonPosix.cpp +++ b/src/inet/tests/TestInetCommonPosix.cpp @@ -177,7 +177,7 @@ void ShutdownSystemLayer() #if CHIP_SYSTEM_CONFIG_USE_LWIP static void PrintNetworkState() { - char intfName[10]; + char intfName[chip::Inet::InterfaceIterator::kMaxIfNameLength]; for (size_t j = 0; j < gNetworkOptions.TapDeviceName.size(); j++) { diff --git a/src/inet/tests/TestInetEndPoint.cpp b/src/inet/tests/TestInetEndPoint.cpp index 7ff2c0936a5b5e..d8cb6e99ac2ebe 100644 --- a/src/inet/tests/TestInetEndPoint.cpp +++ b/src/inet/tests/TestInetEndPoint.cpp @@ -224,7 +224,7 @@ static void TestInetInterface(nlTestSuite * inSuite, void * inContext) { InterfaceIterator intIterator; InterfaceAddressIterator addrIterator; - char intName[20]; + char intName[chip::Inet::InterfaceIterator::kMaxIfNameLength]; InterfaceId intId; IPAddress addr; IPPrefix addrWithPrefix; diff --git a/src/lib/mdns/Advertiser_ImplMinimalMdns.cpp b/src/lib/mdns/Advertiser_ImplMinimalMdns.cpp index d6b61ce2679df9..69bec2b3f0f3b3 100644 --- a/src/lib/mdns/Advertiser_ImplMinimalMdns.cpp +++ b/src/lib/mdns/Advertiser_ImplMinimalMdns.cpp @@ -86,35 +86,66 @@ void LogQuery(const QueryData & data) ChipLogDetail(Discovery, "%s", logString.c_str()); } +/// Checks if the current interface is powered on +/// and not local loopback. +template +bool IsCurrentInterfaceUsable(T & iterator) +{ + if (!iterator.IsUp() || !iterator.SupportsMulticast()) + { + return false; // not a usable interface + } + char name[chip::Inet::InterfaceIterator::kMaxIfNameLength]; + if (iterator.GetInterfaceName(name, sizeof(name)) != CHIP_NO_ERROR) + { + ChipLogError(Discovery, "Failed to get interface name."); + return false; + } + + // TODO: need a better way to ignore local loopback interfaces/addresses + // We do not want to listen on local loopback even though they are up and + // support multicast + // + // Some way to detect 'is local looback' that is smarter (e.g. at least + // strict string compare on linux instead of substring) would be better. + // + // This would reject likely valid interfaces like 'lollipop' or 'lostinspace' + if (strncmp(name, "lo", 2) == 0) + { + /// local loopback interface is not usable by MDNS + return false; + } + return true; +} + class AllInterfaces : public ListenIterator { +private: public: - AllInterfaces() {} + AllInterfaces() { SkipToFirstValidInterface(); } bool Next(chip::Inet::InterfaceId * id, chip::Inet::IPAddressType * type) override { + if (!mIterator.HasCurrent()) + { + return false; + } + #if INET_CONFIG_ENABLE_IPV4 if (mState == State::kIpV4) { - *id = INET_NULL_INTERFACEID; + *id = mIterator.GetInterfaceId(); *type = chip::Inet::kIPAddressType_IPv4; mState = State::kIpV6; - - SkipToFirstValidInterface(); return true; } -#else - mState = State::kIpV6; - SkipToFirstValidInterface(); #endif - if (!mIterator.HasCurrent()) - { - return false; - } - *id = mIterator.GetInterfaceId(); *type = chip::Inet::kIPAddressType_IPv6; +#if INET_CONFIG_ENABLE_IPV4 + mState = State::kIpV4; +#endif for (mIterator.Next(); SkipCurrentInterface(); mIterator.Next()) { @@ -128,7 +159,11 @@ class AllInterfaces : public ListenIterator kIpV4, kIpV6, }; +#if INET_CONFIG_ENABLE_IPV4 State mState = State::kIpV4; +#else + State mState = State::kIpV6; +#endif chip::Inet::InterfaceIterator mIterator; void SkipToFirstValidInterface() @@ -149,23 +184,7 @@ class AllInterfaces : public ListenIterator return false; // nothing to try. } - if (!mIterator.IsUp() || !mIterator.SupportsMulticast()) - { - return true; // not a usable interface - } - char name[64]; - if (mIterator.GetInterfaceName(name, sizeof(name)) != CHIP_NO_ERROR) - { - ChipLogError(Discovery, "Interface iterator failed to get interface name."); - return true; - } - - if (strncmp(name, "lo", 2) == 0) - { - ChipLogDetail(Discovery, "Skipping interface '%s' (assume local loopback)", name); - return true; - } - return false; + return !IsCurrentInterfaceUsable(mIterator); } }; @@ -209,6 +228,15 @@ class AdvertiserMinMdns : public ServiceAdvertiser, /// allocated memory. void Clear(); + /// Advertise available records configured within the server + /// + /// Usable as boot-time advertisement of available SRV records. + void AdvertiseRecords(); + + /// Determine if advertisement on the specified interface/address is ok given the + /// interfaces on which the mDNS server is listening + bool ShouldAdvertiseOn(const chip::Inet::InterfaceId id, const chip::Inet::IPAddress & addr); + QueryResponderSettings AddAllocatedResponder(Responder * responder) { if (responder == nullptr) @@ -327,6 +355,9 @@ CHIP_ERROR AdvertiserMinMdns::Start(chip::Inet::InetLayer * inetLayer, uint16_t ReturnErrorOnFailure(mServer.Listen(inetLayer, &allInterfaces, port)); ChipLogProgress(Discovery, "CHIP minimal mDNS started advertising."); + + AdvertiseRecords(); + return CHIP_NO_ERROR; } @@ -569,6 +600,86 @@ FullQName AdvertiserMinMdns::GetCommisioningTextEntries(const CommissionAdvertis } } +bool AdvertiserMinMdns::ShouldAdvertiseOn(const chip::Inet::InterfaceId id, const chip::Inet::IPAddress & addr) +{ + for (unsigned i = 0; i < mServer.GetEndpointCount(); i++) + { + const ServerBase::EndpointInfo & info = mServer.GetEndpoints()[i]; + + if (info.udp == nullptr) + { + continue; + } + + if (info.interfaceId != id) + { + continue; + } + + if (info.addressType != addr.Type()) + { + continue; + } + + return true; + } + + return false; +} + +void AdvertiserMinMdns::AdvertiseRecords() +{ + chip::Inet::InterfaceAddressIterator interfaceAddress; + + if (!interfaceAddress.Next()) + { + return; + } + + for (; interfaceAddress.HasCurrent(); interfaceAddress.Next()) + { + if (!IsCurrentInterfaceUsable(interfaceAddress)) + { + continue; + } + + if (!ShouldAdvertiseOn(interfaceAddress.GetInterfaceId(), interfaceAddress.GetAddress())) + { + continue; + } + + chip::Inet::IPPacketInfo packetInfo; + + packetInfo.Clear(); + packetInfo.SrcAddress = interfaceAddress.GetAddress(); + if (interfaceAddress.GetAddress().IsIPv4()) + { + BroadcastIpAddresses::GetIpv4Into(packetInfo.DestAddress); + } + else + { + BroadcastIpAddresses::GetIpv6Into(packetInfo.DestAddress); + } + packetInfo.SrcPort = kMdnsPort; + packetInfo.DestPort = kMdnsPort; + packetInfo.Interface = interfaceAddress.GetInterfaceId(); + + QueryData queryData(QType::PTR, QClass::IN, false /* unicast */); + queryData.SetIsBootAdvertising(true); + + mQueryResponder.ClearBroadcastThrottle(); + + CHIP_ERROR err = mResponseSender.Respond(0, queryData, &packetInfo); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Discovery, "Failed to advertise records: %s", ErrorStr(err)); + } + } + + // Once all automatic broadcasts are done, allow immediate replies once. + mQueryResponder.ClearBroadcastThrottle(); +} + AdvertiserMinMdns gAdvertiser; } // namespace diff --git a/src/lib/mdns/minimal/Parser.h b/src/lib/mdns/minimal/Parser.h index ef23d6c8e725d6..ff08d3c9ccd463 100644 --- a/src/lib/mdns/minimal/Parser.h +++ b/src/lib/mdns/minimal/Parser.h @@ -31,6 +31,8 @@ class QueryData QueryData(const QueryData &) = default; QueryData & operator=(const QueryData &) = default; + QueryData(QType type, QClass klass, bool unicast) : mType(type), mClass(klass), mAnswerViaUnicast(unicast) {} + QueryData(QType type, QClass klass, bool unicast, const uint8_t * nameStart, const BytesRange & validData) : mType(type), mClass(klass), mAnswerViaUnicast(unicast), mNameIterator(validData, nameStart) {} @@ -39,6 +41,11 @@ class QueryData QClass GetClass() const { return mClass; } bool RequestedUnicastAnswer() const { return mAnswerViaUnicast; } + /// Boot advertisement is an internal query meant to advertise all available + /// services at device startup time. + bool IsBootAdvertising() const { return mIsBootAdvertising; } + void SetIsBootAdvertising(bool isBootAdvertising) { mIsBootAdvertising = isBootAdvertising; } + SerializedQNameIterator GetName() const { return mNameIterator; } /// Parses a query structure @@ -55,7 +62,11 @@ class QueryData QType mType = QType::ANY; QClass mClass = QClass::ANY; bool mAnswerViaUnicast = false; - SerializedQNameIterator mNameIterator; // const since we reuse it + SerializedQNameIterator mNameIterator; + + /// Flag as a boot-time internal query. This allows query replies + /// to be built accordingly. + bool mIsBootAdvertising = false; }; class ResourceData diff --git a/src/lib/mdns/minimal/QueryReplyFilter.h b/src/lib/mdns/minimal/QueryReplyFilter.h index efbfa05b3cde72..ca3602efcbbe14 100644 --- a/src/lib/mdns/minimal/QueryReplyFilter.h +++ b/src/lib/mdns/minimal/QueryReplyFilter.h @@ -33,19 +33,17 @@ class QueryReplyFilter : public ReplyFilter bool Accept(QType qType, QClass qClass, FullQName qname) override { - // resource type is ignored - if ((mQueryData.GetType() != QType::ANY) && (mQueryData.GetType() != qType)) + if (!AcceptableQueryType(qType)) { return false; } - if ((mQueryData.GetClass() != QClass::ANY) && (mQueryData.GetClass() != qClass)) + if (!AcceptableQueryClass(qClass)) { return false; } - // path must match - return mIgnoreNameMatch || (mQueryData.GetName() == qname); + return AcceptablePath(qname); } /// Ignore qname matches during Accept calls (if set to true, only qtype and qclass are matched). @@ -59,9 +57,41 @@ class QueryReplyFilter : public ReplyFilter return *this; } + QueryReplyFilter & SetSendingAdditionalItems(bool additional) + { + mSendingAdditionalItems = additional; + return *this; + } + private: + bool AcceptableQueryType(QType qType) + { + if (mSendingAdditionalItems && mQueryData.IsBootAdvertising()) + { + return true; + } + + return ((mQueryData.GetType() == QType::ANY) || (mQueryData.GetType() == qType)); + } + + bool AcceptableQueryClass(QClass qClass) + { + return ((mQueryData.GetClass() == QClass::ANY) || (mQueryData.GetClass() == qClass)); + } + + bool AcceptablePath(FullQName qname) + { + if (mIgnoreNameMatch || mQueryData.IsBootAdvertising()) + { + return true; + } + + return (mQueryData.GetName() == qname); + } + const QueryData & mQueryData; - bool mIgnoreNameMatch = false; + bool mIgnoreNameMatch = false; + bool mSendingAdditionalItems = false; }; } // namespace Minimal diff --git a/src/lib/mdns/minimal/ResponseSender.cpp b/src/lib/mdns/minimal/ResponseSender.cpp index f84bd634e957be..94dde151d04bbc 100644 --- a/src/lib/mdns/minimal/ResponseSender.cpp +++ b/src/lib/mdns/minimal/ResponseSender.cpp @@ -74,7 +74,6 @@ CHIP_ERROR ResponseSender::Respond(uint32_t messageId, const QueryData & query, const uint64_t kTimeNowMs = chip::System::Platform::Layer::GetClock_MonotonicMS(); QueryReplyFilter queryReplyFilter(query); - QueryResponderRecordFilter responseFilter; responseFilter.SetReplyFilter(&queryReplyFilter); @@ -108,7 +107,8 @@ CHIP_ERROR ResponseSender::Respond(uint32_t messageId, const QueryData & query, mSendState.SetResourceType(ResourceType::kAdditional); QueryReplyFilter queryReplyFilter(query); - queryReplyFilter.SetIgnoreNameMatch(true); + + queryReplyFilter.SetIgnoreNameMatch(true).SetSendingAdditionalItems(true); QueryResponderRecordFilter responseFilter; responseFilter diff --git a/src/lib/mdns/minimal/Server.cpp b/src/lib/mdns/minimal/Server.cpp index d0ab63d64138c8..00b8905988ee42 100644 --- a/src/lib/mdns/minimal/Server.cpp +++ b/src/lib/mdns/minimal/Server.cpp @@ -26,20 +26,6 @@ namespace mdns { namespace Minimal { namespace { -struct BroadcastIpAddresses -{ - chip::Inet::IPAddress ipv6; - chip::Inet::IPAddress ipv4; - - BroadcastIpAddresses() - { - chip::Inet::IPAddress::FromString("FF02::FB", ipv6); - chip::Inet::IPAddress::FromString("224.0.0.251", ipv4); - } -}; - -const BroadcastIpAddresses kBroadcastIp; - class ShutdownOnError { public: @@ -64,6 +50,28 @@ class ShutdownOnError } // namespace +namespace BroadcastIpAddresses { + +// Get standard mDNS Broadcast addresses + +void GetIpv6Into(chip::Inet::IPAddress & dest) +{ + if (!chip::Inet::IPAddress::FromString("FF02::FB", dest)) + { + ChipLogError(Discovery, "Failed to parse standard IPv6 broadcast address"); + } +} + +void GetIpv4Into(chip::Inet::IPAddress & dest) +{ + if (!chip::Inet::IPAddress::FromString("224.0.0.251", dest)) + { + ChipLogError(Discovery, "Failed to parse standard IPv4 broadcast address"); + } +} + +} // namespace BroadcastIpAddresses + ServerBase::~ServerBase() { Shutdown(); @@ -100,6 +108,7 @@ CHIP_ERROR ServerBase::Listen(chip::Inet::InetLayer * inetLayer, ListenIterator EndpointInfo * info = &mEndpoints[endpointIndex]; info->addressType = addressType; + info->interfaceId = interfaceId; CHIP_ERROR err = inetLayer->NewUDPEndPoint(&info->udp); if (err != CHIP_NO_ERROR) @@ -182,12 +191,12 @@ CHIP_ERROR ServerBase::BroadcastSend(chip::System::PacketBufferHandle data, uint if (info->addressType == chip::Inet::kIPAddressType_IPv6) { - err = info->udp->SendTo(kBroadcastIp.ipv6, port, info->udp->GetBoundInterface(), std::move(copy)); + err = info->udp->SendTo(mIpv6BroadcastAddress, port, info->udp->GetBoundInterface(), std::move(copy)); } #if INET_CONFIG_ENABLE_IPV4 else if (info->addressType == chip::Inet::kIPAddressType_IPv4) { - err = info->udp->SendTo(kBroadcastIp.ipv4, port, info->udp->GetBoundInterface(), std::move(copy)); + err = info->udp->SendTo(mIpv4BroadcastAddress, port, info->udp->GetBoundInterface(), std::move(copy)); } #endif else @@ -224,12 +233,12 @@ CHIP_ERROR ServerBase::BroadcastSend(chip::System::PacketBufferHandle data, uint if (info->addressType == chip::Inet::kIPAddressType_IPv6) { - err = info->udp->SendTo(kBroadcastIp.ipv6, port, info->udp->GetBoundInterface(), std::move(copy)); + err = info->udp->SendTo(mIpv6BroadcastAddress, port, info->udp->GetBoundInterface(), std::move(copy)); } #if INET_CONFIG_ENABLE_IPV4 else if (info->addressType == chip::Inet::kIPAddressType_IPv4) { - err = info->udp->SendTo(kBroadcastIp.ipv4, port, info->udp->GetBoundInterface(), std::move(copy)); + err = info->udp->SendTo(mIpv4BroadcastAddress, port, info->udp->GetBoundInterface(), std::move(copy)); } #endif else diff --git a/src/lib/mdns/minimal/Server.h b/src/lib/mdns/minimal/Server.h index e1e66ecce0ddb5..5a6616e81dd6e3 100644 --- a/src/lib/mdns/minimal/Server.h +++ b/src/lib/mdns/minimal/Server.h @@ -28,6 +28,15 @@ namespace mdns { namespace Minimal { +namespace BroadcastIpAddresses { + +// Get standard mDNS Broadcast addresses + +void GetIpv6Into(chip::Inet::IPAddress & dest); +void GetIpv4Into(chip::Inet::IPAddress & dest); + +} // namespace BroadcastIpAddresses + /// Provides a list of intefaces to listen on. /// /// When listening on IP, both IP address type (IPv4 or IPv6) and interface id @@ -68,6 +77,7 @@ class ServerBase public: struct EndpointInfo { + chip::Inet::InterfaceId interfaceId = INET_NULL_INTERFACEID; chip::Inet::IPAddressType addressType; chip::Inet::UDPEndPoint * udp = nullptr; }; @@ -78,6 +88,12 @@ class ServerBase { mEndpoints[i].udp = nullptr; } + + BroadcastIpAddresses::GetIpv6Into(mIpv6BroadcastAddress); + +#if INET_CONFIG_ENABLE_IPV4 + BroadcastIpAddresses::GetIpv4Into(mIpv4BroadcastAddress); +#endif } ~ServerBase(); @@ -106,13 +122,28 @@ class ServerBase return *this; } + /// How many endpoints are availabe to be used by the server. + size_t GetEndpointCount() const { return mEndpointCount; } + + /// Get the endpoints that are used by this server + /// + /// Entries with non-null UDP are considered usable. + const EndpointInfo * GetEndpoints() const { return mEndpoints; } + private: static void OnUdpPacketReceived(chip::Inet::IPEndPointBasis * endPoint, chip::System::PacketBufferHandle buffer, const chip::Inet::IPPacketInfo * info); EndpointInfo * mEndpoints; // possible endpoints, to listen on multiple interfaces - const size_t mEndpointCount; // how many endpoints are used + const size_t mEndpointCount; // how many endpoints are allocated ServerDelegate * mDelegate = nullptr; + + // Broadcast IP addresses are cached to not require a string parse every time + // Ideally we should be able to constexpr these + chip::Inet::IPAddress mIpv6BroadcastAddress; +#if INET_CONFIG_ENABLE_IPV4 + chip::Inet::IPAddress mIpv4BroadcastAddress; +#endif }; template diff --git a/src/lib/mdns/minimal/responders/QueryResponder.cpp b/src/lib/mdns/minimal/responders/QueryResponder.cpp index 33ac506818cae5..4b215dd7c4c905 100644 --- a/src/lib/mdns/minimal/responders/QueryResponder.cpp +++ b/src/lib/mdns/minimal/responders/QueryResponder.cpp @@ -158,5 +158,13 @@ void QueryResponderBase::AddAllResponses(const chip::Inet::IPPacketInfo * source } } +void QueryResponderBase::ClearBroadcastThrottle() +{ + for (size_t i = 0; i < mResponderInfoSize; i++) + { + mResponderInfos[i].lastMulticastTime = 0; + } +} + } // namespace Minimal } // namespace mdns diff --git a/src/lib/mdns/minimal/responders/QueryResponder.h b/src/lib/mdns/minimal/responders/QueryResponder.h index d57dae0af9f021..b31c22f8dae102 100644 --- a/src/lib/mdns/minimal/responders/QueryResponder.h +++ b/src/lib/mdns/minimal/responders/QueryResponder.h @@ -266,6 +266,10 @@ class QueryResponderBase : public Responder // "_services._dns-sd._udp.local" /// Flag any additional responses required for the given iterator void MarkAdditionalRepliesFor(QueryResponderIterator it); + /// Resets the internal broadcast throttle setting to allow re-broadcasting + /// of all packets without a timedelay. + void ClearBroadcastThrottle(); + private: Internal::QueryResponderInfo * mResponderInfos; size_t mResponderInfoSize; diff --git a/src/transport/NetworkProvisioning.cpp b/src/transport/NetworkProvisioning.cpp index d201d80751d4d5..f54774bf489d67 100644 --- a/src/transport/NetworkProvisioning.cpp +++ b/src/transport/NetworkProvisioning.cpp @@ -35,12 +35,6 @@ namespace chip { -#ifdef IFNAMSIZ -constexpr uint16_t kMaxInterfaceName = IFNAMSIZ; -#else -constexpr uint16_t kMaxInterfaceName = 32; -#endif - constexpr char kAPInterfaceNamePrefix[] = "ap"; constexpr char kLoobackInterfaceNamePrefix[] = "lo"; @@ -208,7 +202,7 @@ CHIP_ERROR NetworkProvisioning::SendCurrentIPv4Address() { for (chip::Inet::InterfaceAddressIterator it; it.HasCurrent(); it.Next()) { - char ifName[kMaxInterfaceName]; + char ifName[chip::Inet::InterfaceIterator::kMaxIfNameLength]; if (it.IsUp() && CHIP_NO_ERROR == it.GetInterfaceName(ifName, sizeof(ifName)) && memcmp(ifName, kAPInterfaceNamePrefix, sizeof(kAPInterfaceNamePrefix) - 1) && memcmp(ifName, kLoobackInterfaceNamePrefix, sizeof(kLoobackInterfaceNamePrefix) - 1))