21#include "ns3/address.h"
22#include "ns3/assert.h"
24#include "ns3/simulator.h"
41#define ASCII_COLON (0x3a)
42#define ASCII_ZERO (0x30)
79 while (*str != 0 && i < 8)
138 return address.CheckCompatible(
GetType(), 8);
166 uint64_t shift = 0xFF;
167 uint64_t addr =
static_cast<uint64_t
>(
m_address[7]) & (shift);
168 addr |= (
static_cast<uint64_t
>(
m_address[6]) << 8) & (shift << 8);
169 addr |= (
static_cast<uint64_t
>(
m_address[5]) << 16) & (shift << 16);
170 addr |= (
static_cast<uint64_t
>(
m_address[4]) << 24) & (shift << 24);
172 addr |= (
static_cast<uint64_t
>(
m_address[3]) << 32) & (shift << 32);
173 addr |= (
static_cast<uint64_t
>(
m_address[2]) << 40) & (shift << 40);
174 addr |= (
static_cast<uint64_t
>(
m_address[1]) << 48) & (shift << 48);
175 addr |= (
static_cast<uint64_t
>(
m_address[0]) << 56) & (shift << 56);
224 os.setf(std::ios::hex, std::ios::basefield);
226 for (uint8_t i = 0; i < 7; i++)
228 os << std::setw(2) << (
uint32_t)ad[i] <<
":";
231 os << std::setw(2) << (
uint32_t)ad[7];
232 os.setf(std::ios::dec, std::ios::basefield);
243 std::string::size_type col = 0;
244 for (uint8_t i = 0; i < 8; ++i)
247 std::string::size_type next;
248 next = v.find(
':', col);
249 if (next == std::string::npos)
251 tmp = v.substr(col, v.size() - col);
252 address.m_address[i] = std::stoul(tmp,
nullptr, 16);
257 tmp = v.substr(col, next - col);
258 address.m_address[i] = std::stoul(tmp,
nullptr, 16);
a polymophic address class
static uint8_t Register()
Allocate a new type id for a new type of address.
uint8_t m_address[8]
address value
Address ConvertTo() const
uint64_t ConvertToInt() const
static bool IsMatchingType(const Address &address)
static Mac64Address Allocate()
Allocate a new Mac64Address.
void CopyFrom(const uint8_t buffer[8])
void CopyTo(uint8_t buffer[8]) const
static Mac64Address ConvertFrom(const Address &address)
static void ResetAllocationIndex()
Reset the Mac64Address allocation index.
static uint8_t GetType()
Return the Type of address.
static uint64_t m_allocationIndex
Address allocation index.
static EventId ScheduleDestroy(FUNC f, Ts &&... args)
Schedule an event to run at the end of the simulation, when Simulator::Destroy() is called.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
std::istream & operator>>(std::istream &is, Angles &a)
static char AsciiToLowCase(char c)
Converts a char to lower case.