57 namespace Mac {
class Mac; }
58 namespace NetworkData {
class Leader; }
114 kAloc16Leader = 0xfc00,
115 kAloc16DhcpAgentStart = 0xfc01,
116 kAloc16DhcpAgentEnd = 0xfc0f,
117 kAloc16DhcpAgentMask = 0x000f,
118 kAloc16ServiceStart = 0xfc10,
119 kAloc16ServiceEnd = 0xfc2f,
120 kAloc16CommissionerStart = 0xfc30,
121 kAloc16CommissionerEnd = 0xfc37,
122 kAloc16NeighborDiscoveryAgentStart = 0xfc40,
123 kAloc16NeighborDiscoveryAgentEnd = 0xfc4e,
148 void Init(
void) { mSecuritySuite = k154Security; mSecurityControl = Mac::Frame::kSecEncMic32; }
158 return (mSecuritySuite == kNoSecurity) ||
159 (mSecuritySuite == k154Security &&
160 mSecurityControl == (Mac::Frame::kKeyIdMode2 | Mac::Frame::kSecEncMic32));
170 uint8_t rval =
sizeof(mSecuritySuite) +
sizeof(mCommand);
172 if (mSecuritySuite == k154Security) {
173 rval +=
sizeof(mSecurityControl) +
sizeof(mFrameCounter) +
sizeof(mKeySource) +
sizeof(mKeyIndex);
208 return sizeof(mSecurityControl) +
sizeof(mFrameCounter) +
sizeof(mKeySource) +
sizeof(mKeyIndex);
218 return reinterpret_cast<const uint8_t *
>(&mSecuritySuite);
237 return (mSecurityControl & Mac::Frame::kKeyIdModeMask) == Mac::Frame::kKeyIdMode2;
245 mSecurityControl = (mSecurityControl & ~Mac::Frame::kKeyIdModeMask) | Mac::Frame::kKeyIdMode2;
255 return Encoding::BigEndian::HostSwap32(mKeySource);
265 mKeySource = Encoding::BigEndian::HostSwap32(aKeySequence);
266 mKeyIndex = (aKeySequence & 0x7f) + 1;
276 return Encoding::LittleEndian::HostSwap32(mFrameCounter);
286 mFrameCounter = Encoding::LittleEndian::HostSwap32(aFrameCounter);
295 kCommandLinkRequest = 0,
296 kCommandLinkAccept = 1,
297 kCommandLinkAcceptAndRequest = 2,
298 kCommandLinkReject = 3,
299 kCommandAdvertisement = 4,
301 kCommandUpdateRequest = 6,
302 kCommandDataRequest = 7,
303 kCommandDataResponse = 8,
304 kCommandParentRequest = 9,
305 kCommandParentResponse = 10,
306 kCommandChildIdRequest = 11,
307 kCommandChildIdResponse = 12,
308 kCommandChildUpdateRequest = 13,
309 kCommandChildUpdateResponse = 14,
310 kCommandAnnounce = 15,
311 kCommandDiscoveryRequest = 16,
312 kCommandDiscoveryResponse = 17,
322 if (mSecuritySuite == kNoSecurity) {
323 return static_cast<Command>(mSecurityControl);
326 return static_cast<Command>(mCommand);
337 if (mSecuritySuite == kNoSecurity) {
338 mSecurityControl =
static_cast<uint8_t
>(aCommand);
341 mCommand =
static_cast<uint8_t
>(aCommand);
346 uint8_t mSecuritySuite;
347 uint8_t mSecurityControl;
348 uint32_t mFrameCounter;
376 mSendTime = aSendTime;
377 mDestination = aDestination;
390 return aMessage.
Append(
this,
sizeof(*
this));
402 return aMessage.
Read(aMessage.
GetLength() -
sizeof(*this),
sizeof(*this),
this);
441 bool IsEarlier(uint32_t aTime) {
return (static_cast<int32_t>(aTime - mSendTime) > 0); };
451 bool IsLater(uint32_t aTime) {
return (static_cast<int32_t>(aTime - mSendTime) < 0); };
501 otError Start(
bool aEnableReattach,
bool aAnnounceAttach);
511 otError Stop(
bool aClearNetworkDatasets);
555 otError Discover(uint32_t aScanChannels, uint16_t aPanId,
bool aJoiner,
bool aEnableEui64Filtering,
556 DiscoverHandler aCallback,
565 bool IsDiscoverInProgress(
void);
571 void HandleDiscoverComplete(
void);
583 otError SendAnnounce(uint8_t aChannel,
bool aOrphanAnnounce);
613 bool IsAttached(
void)
const;
638 return (mDeviceMode & (ModeTlv::kModeFFD | ModeTlv::kModeRxOnWhenIdle)) !=
639 (ModeTlv::kModeFFD | ModeTlv::kModeRxOnWhenIdle);
649 otError SetDeviceMode(uint8_t aMode);
657 const uint8_t *GetMeshLocalPrefix(
void)
const;
667 otError SetMeshLocalPrefix(
const uint8_t *aPrefix);
687 otError UpdateLinkLocalAddress(
void);
695 const Ip6::Address *GetLinkLocalAllThreadNodesAddress(
void)
const;
703 const Ip6::Address *GetRealmLocalAllThreadNodesAddress(
void)
const;
720 bool IsRoutingLocator(
const Ip6::Address &aAddress)
const;
729 bool IsAnycastLocator(
const Ip6::Address &aAddress)
const;
738 bool IsMeshLocalAddress(
const Ip6::Address &aAddress)
const;
752 otError SetTimeout(uint32_t aTimeout);
760 uint16_t GetRloc16(
void)
const;
784 uint8_t GetLeaderId(
void)
const;
808 #if OPENTHREAD_ENABLE_SERVICE 879 static uint8_t
GetServiceIdFromAloc(uint16_t aAloc16) {
return static_cast<uint8_t
>(aAloc16 - kAloc16ServiceStart); }
889 static uint16_t
GetServiceAlocFromId(uint8_t aServiceId) {
return static_cast<uint16_t
>(aServiceId + kAloc16ServiceStart); }
910 static bool IsActiveRouter(uint16_t aRloc16) {
return GetChildId(aRloc16) == 0; }
932 kMleMaxResponseDelay = 1000u,
1001 otError AppendChallenge(
Message &aMessage,
const uint8_t *aChallenge, uint8_t aChallengeLength);
1014 otError AppendResponse(
Message &aMessage,
const uint8_t *aResponse, uint8_t aResponseLength);
1073 otError AppendTlvRequest(
Message &aMessage,
const uint8_t *aTlvs, uint8_t aTlvsLength);
1120 otError AppendLinkMargin(
Message &aMessage, uint8_t aLinkMargin);
1177 otError CheckReachability(uint16_t aMeshSource, uint16_t aMeshDest,
Ip6::Header &aIp6Header);
1241 otError SendDataRequest(
const Ip6::Address &aDestination,
const uint8_t *aTlvs, uint8_t aTlvsLength,
1251 otError SendChildUpdateRequest(
void);
1264 otError SendChildUpdateResponse(
const uint8_t *aTlvs, uint8_t aNumTlvs,
const ChallengeTlv &aChallenge);
1286 otError SetRloc16(uint16_t aRloc16);
1294 otError SetStateDetached(
void);
1302 otError SetStateChild(uint16_t aRloc16);
1312 void SetLeaderData(uint32_t aPartitionId, uint8_t aWeighting, uint8_t aLeaderRouterId);
1334 void LogMleMessage(
const char *aLogMessage,
const Ip6::Address &aAddress)
const;
1344 void LogMleMessage(
const char *aLogMessage,
const Ip6::Address &aAddress, uint16_t aRloc)
const;
1376 kReattachActive = 2,
1377 kReattachPending = 3,
1388 uint8_t mParentLeaderCost;
1397 void GenerateNonce(
const Mac::ExtAddress &aMacAddr, uint32_t aFrameCounter, uint8_t aSecurityLevel,
1400 static void HandleNetifStateChanged(uint32_t aFlags,
void *aContext);
1401 void HandleNetifStateChanged(uint32_t aFlags);
1402 static void HandleParentRequestTimer(
Timer &aTimer);
1403 void HandleParentRequestTimer(
void);
1404 static void HandleDelayedResponseTimer(
Timer &aTimer);
1405 void HandleDelayedResponseTimer(
void);
1406 static void HandleChildUpdateRequestTimer(
Timer &aTimer);
1407 void HandleChildUpdateRequestTimer(
void);
1410 static void HandleSendChildUpdateRequest(
Tasklet &aTasklet);
1411 void HandleSendChildUpdateRequest(
void);
1419 uint32_t aKeySequence);
1424 otError SendParentRequest(
void);
1425 otError SendChildIdRequest(
void);
1426 void SendOrphanAnnounce(
void);
1428 bool IsBetterParent(uint16_t aRloc16, uint8_t aLinkQuality, uint8_t aLinkMargin,
1430 void ResetParentCandidate(
void);
1432 #if OPENTHREAD_ENABLE_SERVICE 1437 void UpdateServiceAlocs(
void);
1440 #if OPENTHREAD_CONFIG_INFORM_PREVIOUS_PARENT_ON_REATTACH 1441 otError InformPreviousParent(
void);
1444 static Mle &GetOwner(
const Context &aContext);
1450 uint8_t mChallenge[ChallengeTlv::kMaxSize];
1451 uint8_t mChallengeLength;
1456 uint8_t mChallenge[ChallengeTlv::kMaxSize];
1460 int8_t mParentPriority;
1461 uint8_t mParentLinkQuality3;
1462 uint8_t mParentLinkQuality2;
1463 uint8_t mParentLinkQuality1;
1464 uint8_t mChildUpdateAttempts;
1466 uint8_t mParentLinkMargin;
1467 bool mParentIsSingleton;
1474 Tasklet mSendChildUpdateRequest;
1476 DiscoverHandler mDiscoverHandler;
1477 void *mDiscoverContext;
1478 bool mIsDiscoverInProgress;
1479 bool mEnableEui64Filtering;
1481 #if OPENTHREAD_CONFIG_INFORM_PREVIOUS_PARENT_ON_REATTACH 1482 uint16_t mPreviousParentRloc;
1485 uint8_t mAnnounceChannel;
1486 uint8_t mPreviousChannel;
1487 uint16_t mPreviousPanId;
1491 #if OPENTHREAD_ENABLE_SERVICE
bool IsMinimalEndDevice(void) const
This method indicates whether or not the device is a Minimal End Device.
Definition: mle.hpp:637
Command
MLE Command Types.
Definition: mle.hpp:293
static uint16_t GetServiceAlocFromId(uint8_t aServiceId)
This method returns the Service Aloc corresponding to a Service ID.
Definition: mle.hpp:889
This type represents all the static / global variables used by OpenThread allocated in one place...
Definition: openthread-instance.h:59
static uint8_t GetRouterId(uint16_t aRloc16)
This method returns the Router ID portion of an RLOC16.
Definition: mle.hpp:869
SecuritySuite GetSecuritySuite(void) const
This method returns the Security Suite value.
Definition: mle.hpp:191
void SetFrameCounter(uint32_t aFrameCounter)
This method sets the Frame Counter value.
Definition: mle.hpp:285
otDeviceRole
Represents a Thread device role.
Definition: types.h:910
uint32_t GetTimeout(void) const
This method returns the MLE Timeout value.
Definition: mle.hpp:746
static uint16_t GetRloc16(uint8_t aRouterId)
This method returns the RLOC16 of a given Router ID.
Definition: mle.hpp:899
Not currently searching for a parent.
Definition: mle.hpp:1359
This class implements a message queue.
Definition: message.hpp:806
Maximal Service ID.
Definition: mle.hpp:133
const MessageQueue & GetMessageQueue(void) const
This method returns a reference to the send queue.
Definition: mle.hpp:927
This structure represents an IEEE 802.15.4 Short or Extended Address.
Definition: mac_frame.hpp:147
Command GetCommand(void) const
This method returns the Command Type value.
Definition: mle.hpp:321
uint32_t GetKeyId(void) const
This method returns the Key ID value.
Definition: mle.hpp:254
This file includes definitions for the Joiner Router role.
This class implements an IPv6 address object.
Definition: ip6_address.hpp:60
This file includes definitions for locator class for OpenThread objects.
This class implements MLE functionality required by the Thread EndDevices, Router, and Leader roles.
Definition: mle.hpp:462
Attach to the same Thread partition (attempt 1).
Definition: mle.hpp:103
Router mParent
Parent information.
Definition: mle.hpp:1350
uint16_t GetLength(void) const
This method returns the number of bytes in the message.
Definition: message.hpp:252
uint32_t GetSendTime(void) const
This method returns a time when the message shall be sent.
Definition: mle.hpp:423
uint16_t ReadFrom(Message &aMessage)
This method reads delayed response header from the message.
Definition: mle.hpp:401
This class implements message information for an IPv6 message.
Definition: socket.hpp:57
This class implements an IPv6 network interface multicast address.
Definition: netif.hpp:137
ReattachState
States when reattaching network using stored dataset.
Definition: mle.hpp:1372
uint8_t GetLength(void) const
This method returns the MLE header and Command Type length.
Definition: mle.hpp:169
uint16_t Read(uint16_t aOffset, uint16_t aLength, void *aBuf) const
This method reads bytes from the message.
Definition: message.cpp:475
This class implements Source Address TLV generation and parsing.
Definition: mle_tlvs.hpp:306
This class implements Source Address TLV generation and parsing.
Definition: mle_tlvs.hpp:811
Searching for a Router to attach to.
Definition: mle.hpp:1362
This class is used to represent a tasklet.
Definition: tasklet.hpp:64
otError AppendTo(Message &aMessage)
This method appends delayed response header to the message.
Definition: mle.hpp:389
This file includes definitions for maintaining Thread network topologies.
This type points to an OpenThread message buffer.
Definition: types.h:479
Sending a Child ID Request message.
Definition: mle.hpp:1364
This class represents a Thread neighbor.
Definition: topology.hpp:53
This class implements a timer.
Definition: timer.hpp:69
This class implements the millisecond timer.
Definition: timer.hpp:145
Minimal Service ID.
Definition: mle.hpp:132
uint8_t mDeviceMode
Device mode setting.
Definition: mle.hpp:1351
const uint8_t * GetBytes(void) const
This method returns a pointer to first byte of the MLE header.
Definition: mle.hpp:217
bool IsEarlier(uint32_t aTime)
This method checks if the message shall be sent before the given time.
Definition: mle.hpp:441
static bool IsActiveRouter(uint16_t aRloc16)
This method indicates whether or not aRloc16 refers to an active router.
Definition: mle.hpp:910
bool IsValid(void) const
This method indicates whether or not the TLV appears to be well-formed.
Definition: mle.hpp:157
This file includes definitions for UDP/IPv6 sockets.
This structure represents an IEEE 802.15.4 Extended Address.
Definition: mac_frame.hpp:84
bool IsLater(uint32_t aTime)
This method checks if the message shall be sent after the given time.
Definition: mle.hpp:451
uint32_t GetFrameCounter(void) const
This method returns the Frame Counter value.
Definition: mle.hpp:275
This class implements an IPv6 network interface unicast address.
Definition: netif.hpp:85
ParentRequestState
States when searching for a parent.
Definition: mle.hpp:1357
This class implements definitions for maintaining a pointer to arbitrary context information.
Definition: context.hpp:61
TimerMilli mChildUpdateRequestTimer
The timer for sending MLE Child Update Request messages.
Definition: mle.hpp:1383
This class represents a message.
Definition: message.hpp:195
TimerMilli mParentRequestTimer
The timer for driving the Parent Request process.
Definition: mle.hpp:1381
SecuritySuite
Definition: mle.hpp:179
High priority level.
Definition: message.hpp:225
This file includes definitions for generating and processing MLE TLVs.
void SetKeyId(uint32_t aKeySequence)
This method sets the Key ID value.
Definition: mle.hpp:264
uint8_t mLastPartitionIdTimeout
The time remaining to avoid the previous Thread partition.
Definition: mle.hpp:1386
This struct represents a received IEEE 802.15.4 Beacon.
Definition: types.h:522
Attach to the same Thread partition (attempt 2).
Definition: mle.hpp:104
This structure represents the Thread Leader Data.
Definition: types.h:999
Looking to synchronize with a parent (after reset).
Definition: mle.hpp:1360
otError Append(const void *aBuf, uint16_t aLength)
This method appends bytes to the end of the message.
Definition: message.cpp:405
TimerMilli mDelayedResponseTimer
The timer to delay MLE responses.
Definition: mle.hpp:1382
void SetSecuritySuite(SecuritySuite aSecuritySuite)
This method sets the Security Suite value.
Definition: mle.hpp:199
bool IsKeyIdMode2(void) const
This method indicates whether or not the Key ID Mode is set to 2.
Definition: mle.hpp:236
This file includes definitions for the IEEE 802.15.4 MAC.
This class implements locator for otInstance object.
Definition: locator.hpp:63
Searching for Routers or REEDs to attach to.
Definition: mle.hpp:1363
This file includes definitions for byte-ordering encoding.
Attach to a better (i.e. higher weight/partition id) Thread partition.
Definition: mle.hpp:105
Starting to look for a parent.
Definition: mle.hpp:1361
void SetKeyIdMode2(void)
This method sets the Key ID Mode to 2.
Definition: mle.hpp:244
This file includes definitions for MLE functionality required by the Thread Child, Router, and Leader roles.
DelayedResponseHeader(void)
Default constructor for the object.
Definition: mle.hpp:366
uint8_t GetHeaderLength(void) const
This method returns the MLE header length (excluding the Command Type).
Definition: mle.hpp:207
This file defines the top-level functions for the OpenThread library.
static uint8_t GetServiceIdFromAloc(uint16_t aAloc16)
This method returns the Service ID corresponding to a Service ALOC16.
Definition: mle.hpp:879
This file includes definitions for the multiplexed timer service.
otDeviceRole mRole
Current Thread role.
Definition: mle.hpp:1349
This class represents a Thread Router.
Definition: topology.hpp:707
bool mRetrieveNewNetworkData
Indicating new Network Data is needed if set.
Definition: mle.hpp:1347
#define OPENTHREAD_CONFIG_MAX_SERVER_ALOCS
The maximum number of supported Service ALOCs registrations for this device.
Definition: openthread-core-default-config.h:291
const Ip6::Address & GetDestination(void) const
This method returns a destination of the delayed message.
Definition: mle.hpp:431
This structure represents the local and peer IPv6 socket addresses.
Definition: types.h:436
Status
Status values.
Definition: mle_tlvs.hpp:1255
static otError RemoveFrom(Message &aMessage)
This method removes delayed response header from the message.
Definition: mle.hpp:413
This class implements Source Address TLV generation and parsing.
Definition: mle_tlvs.hpp:700
LeaderDataTlv mLeaderData
Last received Leader Data TLV.
Definition: mle.hpp:1346
This class implements a UDP/IPv6 socket.
Definition: udp6.hpp:63
ServiceID
Service IDs.
Definition: mle.hpp:130
DelayedResponseHeader(uint32_t aSendTime, const Ip6::Address &aDestination)
This constructor initializes the object with specific values.
Definition: mle.hpp:375
AttachMode
MLE Attach modes.
Definition: mle.hpp:100
Maximum Child ID.
Definition: mle_constants.hpp:77
Attach to any Thread partition.
Definition: mle.hpp:102
uint8_t GetSecurityControl(void) const
This method returns the Security Control value.
Definition: mle.hpp:227
Neighbor * GetNeighbor(const Ip6::Address &aAddress)
This method returns a pointer to the neighbor object.
Definition: mle.hpp:1217
otDeviceRole GetRole(void) const
This method returns the current Thread interface state.
Definition: mle.hpp:621
This class implements network interface handlers.
Definition: netif.hpp:181
AlocAllocation
This enumeration represents the allocation of the ALOC Space.
Definition: mle.hpp:112
Bit offset of Router ID in RLOC16.
Definition: mle_constants.hpp:78
void SetCommand(Command aCommand)
This method sets the Command Type value.
Definition: mle.hpp:336
This class implements Source Address TLV generation and parsing.
Definition: mle_tlvs.hpp:1001
ParentRequestState mParentRequestState
The parent request state.
Definition: mle.hpp:1366
void Init(void)
This method initializes the MLE header.
Definition: mle.hpp:148
otError
This enumeration represents error codes used throughout OpenThread.
Definition: types.h:107
otError SetLength(uint16_t aLength)
This method sets the number of bytes in the message.
Definition: message.cpp:289
otShortAddress ShortAddress
This type represents the IEEE 802.15.4 Short Address.
Definition: mac_frame.hpp:78
This file includes compile-time configuration constants for OpenThread.
uint8_t GetDeviceMode(void) const
This method returns the Device Mode as reported in the Mode TLV.
Definition: mle.hpp:629
uint32_t mLastPartitionId
The partition ID of the previous Thread partition.
Definition: mle.hpp:1384
static uint16_t GetChildId(uint16_t aRloc16)
This method returns the Child ID portion of an RLOC16.
Definition: mle.hpp:859
uint8_t mLastPartitionRouterIdSequence
The router ID sequence from the previous Thread partition.
Definition: mle.hpp:1385