11#include "ns3/assert.h"
41 : m_type(address.m_type),
53 m_len = address.m_len;
99 std::memcpy(
m_data, buffer, len);
138 static uint8_t type = 1;
147 return 1 + 1 +
m_len;
220 for (uint8_t i = 0; i < a.
GetLength(); i++)
237 if (address.m_len == 0)
241 os.setf(std::ios::hex, std::ios::basefield);
243 os << std::setw(2) << (
uint32_t)address.m_type <<
"-" << std::setw(2) << (
uint32_t)address.m_len
245 for (uint8_t i = 0; i < (address.m_len - 1); ++i)
247 os << std::setw(2) << (
uint32_t)address.m_data[i] <<
":";
250 os << std::setw(2) << (
uint32_t)address.m_data[address.m_len - 1];
251 os.setf(std::ios::dec, std::ios::basefield);
261 std::string::size_type firstDash;
262 std::string::size_type secondDash;
263 firstDash = v.find(
'-');
264 secondDash = v.find(
'-', firstDash + 1);
265 std::string type = v.substr(0, firstDash);
266 std::string len = v.substr(firstDash + 1, secondDash - (firstDash + 1));
268 address.m_type = std::stoul(type,
nullptr, 16);
269 address.m_len = std::stoul(len,
nullptr, 16);
272 std::string::size_type col = secondDash + 1;
273 for (uint8_t i = 0; i < address.m_len; ++i)
276 std::string::size_type next;
277 next = v.find(
':', col);
278 if (next == std::string::npos)
280 tmp = v.substr(col, v.size() - col);
281 address.m_data[i] = std::stoul(tmp,
nullptr, 16);
286 tmp = v.substr(col, next - col);
287 address.m_data[i] = std::stoul(tmp,
nullptr, 16);
a polymophic address class
uint32_t GetSerializedSize() const
Get the number of bytes needed to serialize the underlying Address Typically, this is GetLength () + ...
void Serialize(TagBuffer buffer) const
Serialize this address in host byte order to a byte buffer.
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
static constexpr uint32_t MAX_SIZE
The maximum size of a byte buffer which can be stored in an Address instance.
uint8_t m_len
Length of the address.
uint8_t m_data[MAX_SIZE]
The address value.
uint8_t m_type
Type of the address.
Address & operator=(const Address &address)
Basic assignment operator.
Address()
Create an invalid address.
uint32_t CopyAllFrom(const uint8_t *buffer, uint8_t len)
bool CheckCompatible(uint8_t type, uint8_t len) const
static uint8_t Register()
Allocate a new type id for a new type of address.
uint8_t GetLength() const
Get the length of the underlying address.
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
void Deserialize(TagBuffer buffer)
bool IsMatchingType(uint8_t type) const
uint32_t CopyAllTo(uint8_t *buffer, uint8_t len) const
void Read(uint8_t *buffer, uint32_t size)
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
TAG_BUFFER_INLINE uint8_t ReadU8()
void Write(const uint8_t *buffer, uint32_t size)
#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.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
bool operator==(const EventId &a, const EventId &b)
std::ostream & operator<<(std::ostream &os, const Angles &a)
std::istream & operator>>(std::istream &is, Angles &a)
bool operator<(const EventId &a, const EventId &b)