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 < 6)
125 return address.CheckCompatible(
GetType(), 6);
234 uint8_t etherBuffer[6];
235 etherAddr.
CopyTo(etherBuffer);
249 etherBuffer[3] |= ipBuffer[1] & 0x7f;
250 etherBuffer[4] = ipBuffer[2];
251 etherBuffer[5] = ipBuffer[3];
267 uint8_t etherBuffer[6];
268 uint8_t ipBuffer[16];
272 etherAddr.
CopyTo(etherBuffer);
275 etherBuffer[2] = ipBuffer[12];
276 etherBuffer[3] = ipBuffer[13];
277 etherBuffer[4] = ipBuffer[14];
278 etherBuffer[5] = ipBuffer[15];
291 os.setf(std::ios::hex, std::ios::basefield);
293 for (uint8_t i = 0; i < 5; i++)
295 os << std::setw(2) << (
uint32_t)ad[i] <<
":";
298 os << std::setw(2) << (
uint32_t)ad[5];
299 os.setf(std::ios::dec, std::ios::basefield);
310 std::string::size_type col = 0;
311 for (uint8_t i = 0; i < 6; ++i)
314 std::string::size_type next;
315 next = v.find(
':', col);
316 if (next == std::string::npos)
318 tmp = v.substr(col, v.size() - col);
319 address.m_address[i] = std::stoul(tmp,
nullptr, 16);
324 tmp = v.substr(col, next - col);
325 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.
Ipv4 addresses are stored in host order in this class.
void Serialize(uint8_t buf[4]) const
Serialize this address to a 4-byte buffer.
Describes an IPv6 address.
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.
static Mac48Address GetMulticast(Ipv4Address address)
static void ResetAllocationIndex()
Reset the Mac48Address allocation index.
static bool IsMatchingType(const Address &address)
void CopyFrom(const uint8_t buffer[6])
static uint8_t GetType()
Return the Type of address.
static Mac48Address ConvertFrom(const Address &address)
uint8_t m_address[6]
address value
static Mac48Address GetBroadcast()
static Mac48Address Allocate()
Allocate a new Mac48Address.
static Mac48Address GetMulticast6Prefix()
Get the multicast prefix for IPv6 (33:33:00:00:00:00).
void CopyTo(uint8_t buffer[6]) const
static Mac48Address GetMulticastPrefix()
static uint64_t m_allocationIndex
Address allocation index.
Address ConvertTo() const
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.