From 96de36385ae67b689fc574512234ce4916538e7c Mon Sep 17 00:00:00 2001 From: Krzysztof Bogucki Date: Wed, 13 Feb 2019 17:59:33 +0100 Subject: [PATCH] [ip6] messages sent to Service Locator will not be filtered out (#3585) Messages sent to Service Locator will not be filtered out, when thread control traffic filtering is enabled via SetReceiveIp6FilterEnabled(). --- src/core/net/ip6.cpp | 9 +++++---- src/core/net/ip6_address.cpp | 6 ++++++ src/core/net/ip6_address.hpp | 9 +++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/core/net/ip6.cpp b/src/core/net/ip6.cpp index 9bfcf9b70..84c73f0f8 100644 --- a/src/core/net/ip6.cpp +++ b/src/core/net/ip6.cpp @@ -701,10 +701,11 @@ otError Ip6::ProcessReceiveCallback(const Message & aMessage, if (mIsReceiveIp6FilterEnabled) { - // do not pass messages sent to an RLOC/ALOC - VerifyOrExit(!aMessageInfo.GetSockAddr().IsRoutingLocator() && - !aMessageInfo.GetSockAddr().IsAnycastRoutingLocator(), - error = OT_ERROR_NO_ROUTE); + // do not pass messages sent to an RLOC/ALOC, except Service Locator + VerifyOrExit( + (!aMessageInfo.GetSockAddr().IsRoutingLocator() && !aMessageInfo.GetSockAddr().IsAnycastRoutingLocator()) || + aMessageInfo.GetSockAddr().IsAnycastServiceLocator(), + error = OT_ERROR_NO_ROUTE); switch (aIpProto) { diff --git a/src/core/net/ip6_address.cpp b/src/core/net/ip6_address.cpp index afe61a666..4975755c9 100644 --- a/src/core/net/ip6_address.cpp +++ b/src/core/net/ip6_address.cpp @@ -130,6 +130,12 @@ bool Address::IsAnycastRoutingLocator(void) const mFields.m16[6] == HostSwap16(0xfe00) && mFields.m8[14] == kAloc16Mask); } +bool Address::IsAnycastServiceLocator(void) const +{ + return IsAnycastRoutingLocator() && (mFields.m16[7] >= HostSwap16(Mle::kAloc16ServiceStart)) && + (mFields.m16[7] <= HostSwap16(Mle::kAloc16ServiceEnd)); +} + bool Address::IsSubnetRouterAnycast(void) const { return (mFields.m32[2] == 0 && mFields.m32[3] == 0); diff --git a/src/core/net/ip6_address.hpp b/src/core/net/ip6_address.hpp index 44a8f955b..e5af2f5fb 100644 --- a/src/core/net/ip6_address.hpp +++ b/src/core/net/ip6_address.hpp @@ -243,6 +243,15 @@ public: */ bool IsAnycastRoutingLocator(void) const; + /** + * This method indicates whether or not the IPv6 address is an Anycast Service Locator. + * + * @retval TRUE If the IPv6 address is an Anycast Service Locator. + * @retval FALSE If the IPv6 address is not an Anycast Service Locator. + * + */ + bool IsAnycastServiceLocator(void) const; + /** * This method indicates whether or not the IPv6 address is Subnet-Router Anycast (RFC 4291), *