mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 01:17:46 +00:00
Update TmfFilter as specification (#1733)
This commit is contained in:
@@ -199,6 +199,11 @@ typedef enum ThreadError
|
||||
*/
|
||||
kThreadError_ReassemblyTimeout = 32,
|
||||
|
||||
/**
|
||||
* Message is not a TMF Message.
|
||||
*/
|
||||
kThreadError_NotTmf = 33,
|
||||
|
||||
kThreadError_Error = 255,
|
||||
} ThreadError;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user