Set IEEE EUI-64 Unique/Local bit when generating Extended Address. (#290)

This commit is contained in:
Jonathan Hui
2016-07-27 23:25:58 -07:00
committed by GitHub
parent b2b10b8dce
commit ad94ff6703
2 changed files with 39 additions and 1 deletions
+2 -1
View File
@@ -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));
+37
View File
@@ -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,
};
};
/**