0.01.00
mle.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, The OpenThread Authors.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
34 #ifndef MLE_HPP_
35 #define MLE_HPP_
36 
37 #include "openthread-core-config.h"
38 
39 #include <openthread/openthread.h>
40 
41 #include "common/encoding.hpp"
42 #include "common/locator.hpp"
43 #include "common/timer.hpp"
44 #include "mac/mac.hpp"
46 #include "net/udp6.hpp"
47 #include "thread/mle_constants.hpp"
48 #include "thread/mle_tlvs.hpp"
49 #include "thread/topology.hpp"
50 
51 namespace ot {
52 
53 class ThreadNetif;
54 class KeyManager;
55 class MeshForwarder;
56 
57 namespace Mac { class Mac; }
58 namespace NetworkData { class Leader; }
59 
82 namespace Mle {
83 
84 class MleRouter;
85 
101 {
106 };
107 
113 {
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,
124 };
125 
131 {
132  kServiceMinId = 0x00,
133  kServiceMaxId = 0x0f,
134 };
135 
141 class Header
142 {
143 public:
148  void Init(void) { mSecuritySuite = k154Security; mSecurityControl = Mac::Frame::kSecEncMic32; }
149 
157  bool IsValid(void) const {
158  return (mSecuritySuite == kNoSecurity) ||
159  (mSecuritySuite == k154Security &&
160  mSecurityControl == (Mac::Frame::kKeyIdMode2 | Mac::Frame::kSecEncMic32));
161  }
162 
169  uint8_t GetLength(void) const {
170  uint8_t rval = sizeof(mSecuritySuite) + sizeof(mCommand);
171 
172  if (mSecuritySuite == k154Security) {
173  rval += sizeof(mSecurityControl) + sizeof(mFrameCounter) + sizeof(mKeySource) + sizeof(mKeyIndex);
174  }
175 
176  return rval;
177  }
178 
180  {
181  k154Security = 0,
182  kNoSecurity = 255,
183  };
184 
191  SecuritySuite GetSecuritySuite(void) const { return static_cast<SecuritySuite>(mSecuritySuite); }
192 
199  void SetSecuritySuite(SecuritySuite aSecuritySuite) { mSecuritySuite = static_cast<uint8_t>(aSecuritySuite); }
200 
207  uint8_t GetHeaderLength(void) const {
208  return sizeof(mSecurityControl) + sizeof(mFrameCounter) + sizeof(mKeySource) + sizeof(mKeyIndex);
209  }
210 
217  const uint8_t *GetBytes(void) const {
218  return reinterpret_cast<const uint8_t *>(&mSecuritySuite);
219  }
220 
227  uint8_t GetSecurityControl(void) const { return mSecurityControl; }
228 
236  bool IsKeyIdMode2(void) const {
237  return (mSecurityControl & Mac::Frame::kKeyIdModeMask) == Mac::Frame::kKeyIdMode2;
238  }
239 
244  void SetKeyIdMode2(void) {
245  mSecurityControl = (mSecurityControl & ~Mac::Frame::kKeyIdModeMask) | Mac::Frame::kKeyIdMode2;
246  }
247 
254  uint32_t GetKeyId(void) const {
255  return Encoding::BigEndian::HostSwap32(mKeySource);
256  }
257 
264  void SetKeyId(uint32_t aKeySequence) {
265  mKeySource = Encoding::BigEndian::HostSwap32(aKeySequence);
266  mKeyIndex = (aKeySequence & 0x7f) + 1;
267  }
268 
275  uint32_t GetFrameCounter(void) const {
276  return Encoding::LittleEndian::HostSwap32(mFrameCounter);
277  }
278 
285  void SetFrameCounter(uint32_t aFrameCounter) {
286  mFrameCounter = Encoding::LittleEndian::HostSwap32(aFrameCounter);
287  }
288 
293  enum Command
294  {
295  kCommandLinkRequest = 0,
296  kCommandLinkAccept = 1,
297  kCommandLinkAcceptAndRequest = 2,
298  kCommandLinkReject = 3,
299  kCommandAdvertisement = 4,
300  kCommandUpdate = 5,
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,
313  };
314 
321  Command GetCommand(void) const {
322  if (mSecuritySuite == kNoSecurity) {
323  return static_cast<Command>(mSecurityControl);
324  }
325  else {
326  return static_cast<Command>(mCommand);
327  }
328  }
329 
336  void SetCommand(Command aCommand) {
337  if (mSecuritySuite == kNoSecurity) {
338  mSecurityControl = static_cast<uint8_t>(aCommand);
339  }
340  else {
341  mCommand = static_cast<uint8_t>(aCommand);
342  }
343  }
344 
345 private:
346  uint8_t mSecuritySuite;
347  uint8_t mSecurityControl;
348  uint32_t mFrameCounter;
349  uint32_t mKeySource;
350  uint8_t mKeyIndex;
351  uint8_t mCommand;
353 
360 {
361 public:
366  DelayedResponseHeader(void) { memset(this, 0, sizeof(*this)); };
367 
375  DelayedResponseHeader(uint32_t aSendTime, const Ip6::Address &aDestination) {
376  mSendTime = aSendTime;
377  mDestination = aDestination;
378  };
379 
389  otError AppendTo(Message &aMessage) {
390  return aMessage.Append(this, sizeof(*this));
391  };
392 
401  uint16_t ReadFrom(Message &aMessage) {
402  return aMessage.Read(aMessage.GetLength() - sizeof(*this), sizeof(*this), this);
403  };
404 
413  static otError RemoveFrom(Message &aMessage) {
414  return aMessage.SetLength(aMessage.GetLength() - sizeof(DelayedResponseHeader));
415  };
416 
423  uint32_t GetSendTime(void) const { return mSendTime; };
424 
431  const Ip6::Address &GetDestination(void) const { return mDestination; };
432 
441  bool IsEarlier(uint32_t aTime) { return (static_cast<int32_t>(aTime - mSendTime) > 0); };
442 
451  bool IsLater(uint32_t aTime) { return (static_cast<int32_t>(aTime - mSendTime) < 0); };
452 
453 private:
454  Ip6::Address mDestination;
455  uint32_t mSendTime;
457 
462 class Mle: public InstanceLocator
463 {
464 public:
471  explicit Mle(otInstance &aInstance);
472 
480  otError Enable(void);
481 
488  otError Disable(void);
489 
501  otError Start(bool aEnableReattach, bool aAnnounceAttach);
502 
511  otError Stop(bool aClearNetworkDatasets);
512 
520  otError Restore(void);
521 
529  otError Store(void);
530 
538  typedef void (*DiscoverHandler)(otActiveScanResult *aResult, void *aContext);
539 
555  otError Discover(uint32_t aScanChannels, uint16_t aPanId, bool aJoiner, bool aEnableEui64Filtering,
556  DiscoverHandler aCallback,
557  void *aContext);
558 
565  bool IsDiscoverInProgress(void);
566 
571  void HandleDiscoverComplete(void);
572 
583  otError SendAnnounce(uint8_t aChannel, bool aOrphanAnnounce);
584 
592  otError BecomeDetached(void);
593 
604  otError BecomeChild(AttachMode aMode);
605 
613  bool IsAttached(void) const;
614 
621  otDeviceRole GetRole(void) const { return mRole; }
622 
629  uint8_t GetDeviceMode(void) const { return mDeviceMode; }
630 
637  bool IsMinimalEndDevice(void) const {
638  return (mDeviceMode & (ModeTlv::kModeFFD | ModeTlv::kModeRxOnWhenIdle)) !=
639  (ModeTlv::kModeFFD | ModeTlv::kModeRxOnWhenIdle);
640  }
641 
649  otError SetDeviceMode(uint8_t aMode);
650 
657  const uint8_t *GetMeshLocalPrefix(void) const;
658 
667  otError SetMeshLocalPrefix(const uint8_t *aPrefix);
668 
677  const Ip6::Address &GetLinkLocalAddress(void) const;
678 
687  otError UpdateLinkLocalAddress(void);
688 
695  const Ip6::Address *GetLinkLocalAllThreadNodesAddress(void) const;
696 
703  const Ip6::Address *GetRealmLocalAllThreadNodesAddress(void) const;
704 
711  Router *GetParent(void);
712 
720  bool IsRoutingLocator(const Ip6::Address &aAddress) const;
721 
729  bool IsAnycastLocator(const Ip6::Address &aAddress) const;
730 
738  bool IsMeshLocalAddress(const Ip6::Address &aAddress) const;
739 
746  uint32_t GetTimeout(void) const { return mTimeout; }
747 
752  otError SetTimeout(uint32_t aTimeout);
753 
760  uint16_t GetRloc16(void) const;
761 
768  const Ip6::Address &GetMeshLocal16(void) const;
769 
776  const Ip6::Address &GetMeshLocal64(void) const;
777 
784  uint8_t GetLeaderId(void) const;
785 
795  otError GetLeaderAddress(Ip6::Address &aAddress) const;
796 
806  otError GetLeaderAloc(Ip6::Address &aAddress) const;
807 
808 #if OPENTHREAD_ENABLE_SERVICE
809 
819  otError GetServiceAloc(uint8_t aServiceId, Ip6::Address &aAddress) const;
820 #endif
821 
830  otError AddLeaderAloc(void);
831 
838  const LeaderDataTlv &GetLeaderDataTlv(void);
839 
849  otError GetLeaderData(otLeaderData &aLeaderData);
850 
859  static uint16_t GetChildId(uint16_t aRloc16) { return aRloc16 & kMaxChildId; }
860 
869  static uint8_t GetRouterId(uint16_t aRloc16) { return aRloc16 >> kRouterIdOffset; }
870 
879  static uint8_t GetServiceIdFromAloc(uint16_t aAloc16) { return static_cast<uint8_t>(aAloc16 - kAloc16ServiceStart); }
880 
889  static uint16_t GetServiceAlocFromId(uint8_t aServiceId) { return static_cast<uint16_t>(aServiceId + kAloc16ServiceStart); }
890 
899  static uint16_t GetRloc16(uint8_t aRouterId) { return static_cast<uint16_t>(aRouterId << kRouterIdOffset); }
900 
910  static bool IsActiveRouter(uint16_t aRloc16) { return GetChildId(aRloc16) == 0; }
911 
919  void FillNetworkDataTlv(NetworkDataTlv &aTlv, bool aStableOnly);
920 
927  const MessageQueue &GetMessageQueue(void) const { return mDelayedResponses; }
928 
929 protected:
930  enum
931  {
932  kMleMaxResponseDelay = 1000u,
933  };
934 
941  Message *NewMleMessage(void);
942 
953  otError AppendHeader(Message &aMessage, Header::Command aCommand);
954 
964  otError AppendSourceAddress(Message &aMessage);
965 
976  otError AppendMode(Message &aMessage, uint8_t aMode);
977 
988  otError AppendTimeout(Message &aMessage, uint32_t aTimeout);
989 
1001  otError AppendChallenge(Message &aMessage, const uint8_t *aChallenge, uint8_t aChallengeLength);
1002 
1014  otError AppendResponse(Message &aMessage, const uint8_t *aResponse, uint8_t aResponseLength);
1015 
1025  otError AppendLinkFrameCounter(Message &aMessage);
1026 
1036  otError AppendMleFrameCounter(Message &aMessage);
1037 
1048  otError AppendAddress16(Message &aMessage, uint16_t aRloc16);
1049 
1060  otError AppendNetworkData(Message &aMessage, bool aStableOnly);
1061 
1073  otError AppendTlvRequest(Message &aMessage, const uint8_t *aTlvs, uint8_t aTlvsLength);
1074 
1084  otError AppendLeaderData(Message &aMessage);
1085 
1096  otError AppendScanMask(Message &aMessage, uint8_t aScanMask);
1097 
1108  otError AppendStatus(Message &aMessage, StatusTlv::Status aStatus);
1109 
1120  otError AppendLinkMargin(Message &aMessage, uint8_t aLinkMargin);
1121 
1131  otError AppendVersion(Message &aMessage);
1132 
1142  otError AppendAddressRegistration(Message &aMessage);
1143 
1153  otError AppendActiveTimestamp(Message &aMessage);
1154 
1164  otError AppendPendingTimestamp(Message &aMessage);
1165 
1177  otError CheckReachability(uint16_t aMeshSource, uint16_t aMeshDest, Ip6::Header &aIp6Header);
1178 
1187  Neighbor *GetNeighbor(const Mac::Address &aAddress);
1188 
1197  Neighbor *GetNeighbor(Mac::ShortAddress aAddress);
1198 
1207  Neighbor *GetNeighbor(const Mac::ExtAddress &aAddress);
1208 
1217  Neighbor *GetNeighbor(const Ip6::Address &aAddress) { OT_UNUSED_VARIABLE(aAddress); return NULL; }
1218 
1227  Mac::ShortAddress GetNextHop(uint16_t aDestination) const;
1228 
1241  otError SendDataRequest(const Ip6::Address &aDestination, const uint8_t *aTlvs, uint8_t aTlvsLength,
1242  uint16_t aDelay);
1243 
1251  otError SendChildUpdateRequest(void);
1252 
1264  otError SendChildUpdateResponse(const uint8_t *aTlvs, uint8_t aNumTlvs, const ChallengeTlv &aChallenge);
1265 
1276  otError SendMessage(Message &aMessage, const Ip6::Address &aDestination);
1277 
1286  otError SetRloc16(uint16_t aRloc16);
1287 
1294  otError SetStateDetached(void);
1295 
1302  otError SetStateChild(uint16_t aRloc16);
1303 
1312  void SetLeaderData(uint32_t aPartitionId, uint8_t aWeighting, uint8_t aLeaderRouterId);
1313 
1325  otError AddDelayedResponse(Message &aMessage, const Ip6::Address &aDestination, uint16_t aDelay);
1326 
1334  void LogMleMessage(const char *aLogMessage, const Ip6::Address &aAddress) const;
1335 
1344  void LogMleMessage(const char *aLogMessage, const Ip6::Address &aAddress, uint16_t aRloc) const;
1345 
1348 
1351  uint8_t mDeviceMode;
1352 
1358  {
1365  };
1367 
1373  {
1374  kReattachStop = 0,
1375  kReattachStart = 1,
1376  kReattachActive = 2,
1377  kReattachPending = 3,
1378  };
1379  ReattachState mReattachState;
1380 
1384  uint32_t mLastPartitionId;
1387 
1388  uint8_t mParentLeaderCost;
1389 
1390 private:
1391  enum
1392  {
1393  kMleMessagePriority = Message::kPriorityHigh,
1394  kMleHopLimit = 255,
1395  };
1396 
1397  void GenerateNonce(const Mac::ExtAddress &aMacAddr, uint32_t aFrameCounter, uint8_t aSecurityLevel,
1398  uint8_t *aNonce);
1399 
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);
1408  static void HandleUdpReceive(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
1409  void HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
1410  static void HandleSendChildUpdateRequest(Tasklet &aTasklet);
1411  void HandleSendChildUpdateRequest(void);
1412 
1413  otError HandleAdvertisement(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
1414  otError HandleChildIdResponse(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
1415  otError HandleChildUpdateRequest(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
1416  otError HandleChildUpdateResponse(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
1417  otError HandleDataResponse(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
1418  otError HandleParentResponse(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo,
1419  uint32_t aKeySequence);
1420  otError HandleAnnounce(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
1421  otError HandleDiscoveryResponse(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
1422  otError HandleLeaderData(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
1423 
1424  otError SendParentRequest(void);
1425  otError SendChildIdRequest(void);
1426  void SendOrphanAnnounce(void);
1427 
1428  bool IsBetterParent(uint16_t aRloc16, uint8_t aLinkQuality, uint8_t aLinkMargin,
1429  ConnectivityTlv &aConnectivityTlv);
1430  void ResetParentCandidate(void);
1431 
1432 #if OPENTHREAD_ENABLE_SERVICE
1433 
1437  void UpdateServiceAlocs(void);
1438 #endif
1439 
1440 #if OPENTHREAD_CONFIG_INFORM_PREVIOUS_PARENT_ON_REATTACH
1441  otError InformPreviousParent(void);
1442 #endif
1443 
1444  static Mle &GetOwner(const Context &aContext);
1445 
1446  MessageQueue mDelayedResponses;
1447 
1448  struct
1449  {
1450  uint8_t mChallenge[ChallengeTlv::kMaxSize];
1451  uint8_t mChallengeLength;
1452  } mChildIdRequest;
1453 
1454  struct
1455  {
1456  uint8_t mChallenge[ChallengeTlv::kMaxSize];
1457  } mParentRequest;
1458 
1459  AttachMode mParentRequestMode;
1460  int8_t mParentPriority;
1461  uint8_t mParentLinkQuality3;
1462  uint8_t mParentLinkQuality2;
1463  uint8_t mParentLinkQuality1;
1464  uint8_t mChildUpdateAttempts;
1465  LeaderDataTlv mParentLeaderData;
1466  uint8_t mParentLinkMargin;
1467  bool mParentIsSingleton;
1468 
1469  Router mParentCandidate;
1470 
1471  Ip6::UdpSocket mSocket;
1472  uint32_t mTimeout;
1473 
1474  Tasklet mSendChildUpdateRequest;
1475 
1476  DiscoverHandler mDiscoverHandler;
1477  void *mDiscoverContext;
1478  bool mIsDiscoverInProgress;
1479  bool mEnableEui64Filtering;
1480 
1481 #if OPENTHREAD_CONFIG_INFORM_PREVIOUS_PARENT_ON_REATTACH
1482  uint16_t mPreviousParentRloc;
1483 #endif
1484 
1485  uint8_t mAnnounceChannel;
1486  uint8_t mPreviousChannel;
1487  uint16_t mPreviousPanId;
1488 
1489  Ip6::NetifUnicastAddress mLeaderAloc;
1490 
1491 #if OPENTHREAD_ENABLE_SERVICE
1493 #endif
1494 
1495  Ip6::NetifUnicastAddress mLinkLocal64;
1496  Ip6::NetifUnicastAddress mMeshLocal64;
1497  Ip6::NetifUnicastAddress mMeshLocal16;
1498  Ip6::NetifMulticastAddress mLinkLocalAllThreadNodes;
1499  Ip6::NetifMulticastAddress mRealmLocalAllThreadNodes;
1500 
1501  Ip6::NetifCallback mNetifCallback;
1502 };
1503 
1504 } // namespace Mle
1505 
1511 } // namespace ot
1512 
1513 #endif // MLE_HPP_
This class implements IPv6 header generation and parsing.
Definition: ip6_headers.hpp:136
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
Definition: cli.cpp:90
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 implements functionality required for delaying MLE responses.
Definition: mle.hpp:359
This class represents a Thread neighbor.
Definition: topology.hpp:53
#define OT_TOOL_PACKED_BEGIN
Compiler-specific indication that a class or struct must be byte packed.
Definition: toolchain.h:170
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
#define OT_UNUSED_VARIABLE(VARIABLE)
Suppress unused variable warning in specific toolchains.
Definition: toolchain.h:263
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
This class implements MLE Header generation and parsing.
Definition: mle.hpp:141
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 OT_TOOL_PACKED_END
Compiler-specific indication at the end of a byte packed class or struct.
Definition: toolchain.h:172
#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