diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 611aabe3e..d9fda4bf6 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -106,7 +106,8 @@ Mac::Mac(ThreadNetif &aThreadNetif): mExtAddress.m8[i] = otPlatRandomGet(); } - mExtAddress.m8[0] &= ~1; // always remove multicast bit + mExtAddress.SetGroup(false); + mExtAddress.SetLocal(true); memset(&mCounters, 0, sizeof(otMacCounters)); diff --git a/src/core/mac/mac_frame.hpp b/src/core/mac/mac_frame.hpp index c3b964abf..45cfe26df 100644 --- a/src/core/mac/mac_frame.hpp +++ b/src/core/mac/mac_frame.hpp @@ -81,6 +81,36 @@ typedef otShortAddress ShortAddress; class ExtAddress: public otExtAddress { public: + /** + * This method sets the Group bit. + * + * @param[in] aLocal TRUE if group address, FALSE otherwise. + * + */ + void SetGroup(bool aGroup) { + if (aGroup) { + m8[0] |= kGroupFlag; + } + else { + m8[0] &= ~kGroupFlag; + } + } + + /** + * This method sets the Local bit. + * + * @param[in] aLocal TRUE if locally administered, FALSE otherwise. + * + */ + void SetLocal(bool aLocal) { + if (aLocal) { + m8[0] |= kLocalFlag; + } + else { + m8[0] &= ~kLocalFlag; + } + } + /** * This method converts an IPv6 Interface Identifier to an IEEE 802.15.4 Extended Address. * @@ -88,6 +118,13 @@ public: * */ void Set(const Ip6::Address &aIpAddress); + +private: + enum + { + kGroupFlag = 1 << 0, + kLocalFlag = 1 << 1, + }; }; /**