mirror of
https://github.com/espressif/openthread.git
synced 2026-10-30 03:03:58 +00:00
Set IEEE EUI-64 Unique/Local bit when generating Extended Address. (#290)
This commit is contained in:
@@ -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));
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user