Simplification to p2p-net-device and p2p-channel (work in progress)
This commit is contained in:
@@ -33,6 +33,9 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
// Static variables
|
||||
uint8_t MacAddress::g_nextAddress[MacAddress::MAX_LEN];
|
||||
|
||||
static char
|
||||
AsciiToLowCase (char c)
|
||||
{
|
||||
@@ -54,6 +57,13 @@ MacAddress::MacAddress () : m_len(0)
|
||||
}
|
||||
}
|
||||
|
||||
MacAddress::MacAddress(uint8_t len) : m_len(len)
|
||||
{
|
||||
NS_ASSERT (len <= MacAddress::MAX_LEN);
|
||||
AdvanceAddress();
|
||||
memcpy(m_address, g_nextAddress, len);
|
||||
}
|
||||
|
||||
MacAddress::MacAddress (uint8_t const *address, uint8_t len)
|
||||
{
|
||||
NS_ASSERT (len <= MacAddress::MAX_LEN);
|
||||
@@ -148,6 +158,17 @@ MacAddress::Set (uint8_t const ad[MacAddress::MAX_LEN], uint8_t len)
|
||||
m_len = len;
|
||||
}
|
||||
|
||||
// Static methods
|
||||
void MacAddress::AdvanceAddress()
|
||||
{
|
||||
// Advance to next address, little end first
|
||||
for(size_t i = 0; i < MAX_LEN; ++i)
|
||||
{
|
||||
if (++g_nextAddress[i] != 0) break;
|
||||
}
|
||||
}
|
||||
|
||||
// Non-member operators
|
||||
bool operator == (MacAddress const&a, MacAddress const&b)
|
||||
{
|
||||
return a.IsEqual (b);
|
||||
|
||||
@@ -46,6 +46,13 @@ public:
|
||||
* This MacAddress has length of zero, and is internally all zeros
|
||||
*/
|
||||
MacAddress (void);
|
||||
/**
|
||||
* \brief Construct a MacAddress using the next available
|
||||
* address.
|
||||
* \see MacAddres::Next
|
||||
* \param len length, in bytes, of the desired address
|
||||
*/
|
||||
MacAddress(uint8_t len);
|
||||
/**
|
||||
* \brief Construct a MacAddress from a byte-array
|
||||
*
|
||||
@@ -97,6 +104,14 @@ public:
|
||||
*/
|
||||
void Set (uint8_t const ad[MAX_LEN], uint8_t len);
|
||||
|
||||
// Static methods/members
|
||||
/**
|
||||
*
|
||||
* Advance the global to the next available mac address.
|
||||
*/
|
||||
static void AdvanceAddress();
|
||||
static uint8_t g_nextAddress[MAX_LEN];
|
||||
|
||||
private:
|
||||
uint8_t m_address[MAX_LEN];
|
||||
uint8_t m_len;
|
||||
|
||||
Reference in New Issue
Block a user