network: Add Mac16 and Mac64 functions
This commit is contained in:
@@ -20,6 +20,8 @@ Changes from ns-3.38 to ns-3-dev
|
||||
|
||||
* (lr-wpan) Added support for orphan scans. Orphan scans can now be performed using the existing `LrWpanMac::MlmeScanRequest`; This orphan scan use the added orphan notification commands and coordinator realigment commands. Usage is shown in added `lr-wpan-orphan-scan.cc` example and in the `TestOrphanScan` included in `lr-wpan-mac-test.cc`.
|
||||
* (network) Added `Mac64Address::ConvertToInt`. Converts a Mac64Address object to a uint64_t.
|
||||
* (network) Added `Mac16Address::ConvertToInt`. Converts a Mac16Address object to a uint16_t.
|
||||
* (network) Added `Mac16Address::Mac16Address(uint16t addr)` and `Mac16Address::Mac64Address(uint64t addr)` constructors.
|
||||
* (lr-wpan) Added `LrwpanMac::MlmeGetRequest` function and the corresponding confirm callbacks as well as `LrwpanMac::SetMlmeGetConfirm` function.
|
||||
|
||||
### Changes to existing API
|
||||
|
||||
@@ -23,6 +23,7 @@ Release 3-dev
|
||||
- (lr-wpan) !1399 - Add orphan scan support.
|
||||
- (network) !1405 - Add ConvertToInt to Mac64Address
|
||||
- (lr-wpan) !1402 - Add attributes to MLME-SET and MLME-GET
|
||||
- (lr-wpan) 1410 - Add Mac16 and Mac64 functions
|
||||
|
||||
### Bugs fixed
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ Mac16Address::Mac16Address(const char* str)
|
||||
|
||||
Mac16Address::Mac16Address(uint16_t addr)
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
m_address[1] = addr & 0xFF;
|
||||
m_address[0] = (addr >> 8) & 0xFF;
|
||||
}
|
||||
@@ -153,6 +154,15 @@ Mac16Address::ConvertTo() const
|
||||
return Address(GetType(), m_address, 2);
|
||||
}
|
||||
|
||||
uint16_t
|
||||
Mac16Address::ConvertToInt() const
|
||||
{
|
||||
uint16_t addr = m_address[1] & (0xFF);
|
||||
addr |= (m_address[0] << 8) & (0xFF << 8);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
Mac16Address
|
||||
Mac16Address::Allocate()
|
||||
{
|
||||
|
||||
@@ -51,9 +51,9 @@ class Mac16Address
|
||||
Mac16Address(const char* str);
|
||||
|
||||
/**
|
||||
* \param addr The 16 bit integer used to create a Mac16Address object.
|
||||
* \param addr The 16 bit unsigned integer used to create a Mac16Address object.
|
||||
*
|
||||
* Create a Mac16Address from an 16 bit integer.
|
||||
* Create a Mac16Address from an 16 bit unsigned integer.
|
||||
*/
|
||||
Mac16Address(uint16_t addr);
|
||||
|
||||
@@ -95,6 +95,13 @@ class Mac16Address
|
||||
*/
|
||||
Address ConvertTo() const;
|
||||
|
||||
/**
|
||||
* \return the mac address in a 16 bit unsigned integer
|
||||
*
|
||||
* Convert an instance of this class to a 16 bit unsigned integer.
|
||||
*/
|
||||
uint16_t ConvertToInt() const;
|
||||
|
||||
/**
|
||||
* \param address address to test
|
||||
* \returns true if the address matches, false otherwise.
|
||||
|
||||
@@ -104,6 +104,19 @@ Mac64Address::Mac64Address(const char* str)
|
||||
NS_ASSERT(i == 8);
|
||||
}
|
||||
|
||||
Mac64Address::Mac64Address(uint64_t addr)
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
m_address[7] = addr & 0xFF;
|
||||
m_address[6] = (addr >> 8) & 0xFF;
|
||||
m_address[5] = (addr >> 16) & 0xFF;
|
||||
m_address[4] = (addr >> 24) & 0xFF;
|
||||
m_address[3] = (addr >> 32) & 0xFF;
|
||||
m_address[2] = (addr >> 40) & 0xFF;
|
||||
m_address[1] = (addr >> 48) & 0xFF;
|
||||
m_address[0] = (addr >> 56) & 0xFF;
|
||||
}
|
||||
|
||||
void
|
||||
Mac64Address::CopyFrom(const uint8_t buffer[8])
|
||||
{
|
||||
@@ -150,10 +163,8 @@ Mac64Address::ConvertTo() const
|
||||
uint64_t
|
||||
Mac64Address::ConvertToInt() const
|
||||
{
|
||||
uint64_t addr = 0;
|
||||
uint64_t shift = 0xFF;
|
||||
|
||||
addr = static_cast<uint64_t>(m_address[7]) & (shift);
|
||||
uint64_t addr = static_cast<uint64_t>(m_address[7]) & (shift);
|
||||
addr |= (static_cast<uint64_t>(m_address[6]) << 8) & (shift << 8);
|
||||
addr |= (static_cast<uint64_t>(m_address[5]) << 16) & (shift << 16);
|
||||
addr |= (static_cast<uint64_t>(m_address[4]) << 24) & (shift << 24);
|
||||
|
||||
@@ -49,10 +49,17 @@ class Mac64Address
|
||||
/**
|
||||
* \param str a string representing the new Mac64Address
|
||||
*
|
||||
* The format of the string is "xx:xx:xx:xx:xx:xx"
|
||||
* The format of the string is "xx:xx:xx:xx:xx:xx:xx:xx"
|
||||
*/
|
||||
Mac64Address(const char* str);
|
||||
|
||||
/**
|
||||
* \param addr The 64 bit unsigned integer used to create a Mac64Address object.
|
||||
*
|
||||
* Create a Mac64Address from an 64 bit unsigned integer.
|
||||
*/
|
||||
Mac64Address(uint64_t addr);
|
||||
|
||||
/**
|
||||
* \param buffer address in network order
|
||||
*
|
||||
@@ -88,9 +95,9 @@ class Mac64Address
|
||||
Address ConvertTo() const;
|
||||
|
||||
/**
|
||||
* \return the mac address in a 64 bit int
|
||||
* \return the mac address in a 64 bit unsigned integer.
|
||||
*
|
||||
* Convert an instance of this class to a 64 bit int.
|
||||
* Convert an instance of this class to a 64 bit unsigned integer.
|
||||
*/
|
||||
uint64_t ConvertToInt() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user