From 027ad9eb03c441f39126f96de33ff5ad085472b7 Mon Sep 17 00:00:00 2001 From: rongli Date: Wed, 10 May 2017 14:10:24 +0800 Subject: [PATCH] Update TmfFilter as specification (#1733) --- include/openthread/types.h | 5 +++++ src/core/coap/coap_server.cpp | 6 +++--- src/core/coap/coap_server.hpp | 2 +- src/core/thread/thread_netif.cpp | 22 ++++++++++------------ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/include/openthread/types.h b/include/openthread/types.h index 8e0e80c8f..912992859 100644 --- a/include/openthread/types.h +++ b/include/openthread/types.h @@ -199,6 +199,11 @@ typedef enum ThreadError */ kThreadError_ReassemblyTimeout = 32, + /** + * Message is not a TMF Message. + */ + kThreadError_NotTmf = 33, + kThreadError_Error = 255, } ThreadError; diff --git a/src/core/coap/coap_server.cpp b/src/core/coap/coap_server.cpp index eb7983509..f187f51bf 100644 --- a/src/core/coap/coap_server.cpp +++ b/src/core/coap/coap_server.cpp @@ -47,11 +47,11 @@ namespace Coap { Server::Server(Ip6::Netif &aNetif, uint16_t aPort) : CoapBase(aNetif.GetIp6().mUdp), + mPort(aPort), + mResources(NULL), + mInterceptor(NULL), mResponsesQueue(aNetif) { - mPort = aPort; - mResources = NULL; - mInterceptor = NULL; } ThreadError Server::Start(void) diff --git a/src/core/coap/coap_server.hpp b/src/core/coap/coap_server.hpp index 4c75b93be..0d3466839 100644 --- a/src/core/coap/coap_server.hpp +++ b/src/core/coap/coap_server.hpp @@ -296,7 +296,7 @@ public: * @retval kThreadError_None Server should continue processing this message, other * return values indicates the server should stop processing * this message. - * @retval kThreadError_Security The message does not comply with security rules. + * @retval kThreadError_NotTmf The message is not a TMF message. * */ typedef ThreadError(* Interceptor)(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo); diff --git a/src/core/thread/thread_netif.cpp b/src/core/thread/thread_netif.cpp index 081384f1e..b95c3c865 100644 --- a/src/core/thread/thread_netif.cpp +++ b/src/core/thread/thread_netif.cpp @@ -196,18 +196,16 @@ ThreadError ThreadNetif::TmfFilter(const Message &aMessage, const Ip6::MessageIn { ThreadError error = kThreadError_None; - // A TMF message must comply one of the following rules: - // 1. Source address is RLOC or ALOC, and destination address is RLOC, ALOC or realm-local multicast. - // 2. Both source and destination addresses are link-local.(for Joiner Entrust) - VerifyOrExit(((aMessageInfo.GetPeerAddr().IsRoutingLocator() || - aMessageInfo.GetPeerAddr().IsAnycastRoutingLocator()) && - (aMessageInfo.GetSockAddr().IsRoutingLocator() || - aMessageInfo.GetSockAddr().IsAnycastRoutingLocator() || - aMessageInfo.GetSockAddr().IsRealmLocalMulticast())) || - (aMessageInfo.GetPeerAddr().IsLinkLocal() && - aMessageInfo.GetSockAddr().IsLinkLocal()), - error = kThreadError_Security); - + // A TMF message must comply at least one of the following rules: + // 1. The IPv6 source address is RLOC or ALOC. + // 2. The IPv6 destination address is RLOC or ALOC. + // 3. The IPv6 destination address is Link-Local address. + VerifyOrExit(aMessageInfo.GetPeerAddr().IsRoutingLocator() || + aMessageInfo.GetPeerAddr().IsAnycastRoutingLocator() || + aMessageInfo.GetSockAddr().IsRoutingLocator() || + aMessageInfo.GetSockAddr().IsAnycastRoutingLocator() || + aMessageInfo.GetSockAddr().IsLinkLocal(), + error = kThreadError_NotTmf); exit: (void)aMessage; return error;