22#include "ns3/assert.h"
52 : m_type(address.m_type),
64 m_len = address.m_len;
110 std::memcpy(
m_data, buffer, len);
149 static uint8_t type = 1;
158 return 1 + 1 +
m_len;
231 for (uint8_t i = 0; i < a.
GetLength(); i++)
248 os.setf(std::ios::hex, std::ios::basefield);
250 os << std::setw(2) << (
uint32_t)address.m_type <<
"-" << std::setw(2) << (
uint32_t)address.m_len
252 for (uint8_t i = 0; i < (address.m_len - 1); ++i)
254 os << std::setw(2) << (
uint32_t)address.m_data[i] <<
":";
257 os << std::setw(2) << (
uint32_t)address.m_data[address.m_len - 1];
258 os.setf(std::ios::dec, std::ios::basefield);
268 std::string::size_type firstDash;
269 std::string::size_type secondDash;
270 firstDash = v.find(
'-');
271 secondDash = v.find(
'-', firstDash + 1);
272 std::string type = v.substr(0, firstDash);
273 std::string len = v.substr(firstDash + 1, secondDash - (firstDash + 1));
275 address.m_type = std::stoul(type,
nullptr, 16);
276 address.m_len = std::stoul(len,
nullptr, 16);
279 std::string::size_type col = secondDash + 1;
280 for (uint8_t i = 0; i < address.m_len; ++i)
283 std::string::size_type next;
284 next = v.find(
':', col);
285 if (next == std::string::npos)
287 tmp = v.substr(col, v.size() - col);
288 address.m_data[i] = std::stoul(tmp,
nullptr, 16);
293 tmp = v.substr(col, next - col);
294 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)