21 #include "ns3/assert.h" 45 NS_LOG_FUNCTION (
this << static_cast<uint32_t> (type) << &buffer << static_cast<uint32_t> (len));
105 std::memcpy (
m_data, buffer, len);
124 NS_LOG_FUNCTION (
this << static_cast<uint32_t> (type) << static_cast<uint32_t> (len));
141 static uint8_t type = 1;
150 return 1 + 1 +
m_len;
221 for (uint8_t i = 0; i < a.
GetLength (); i++)
237 os.setf (std::ios::hex, std::ios::basefield);
239 os << std::setw (2) << (uint32_t)
address.m_type <<
"-" << std::setw (2) << (uint32_t)
address.m_len <<
"-";
240 for (uint8_t i = 0; i < (
address.m_len-1); ++i)
242 os << std::setw (2) << (uint32_t)
address.m_data[i] <<
":";
245 os << std::setw (2) << (uint32_t)
address.m_data[
address.m_len-1];
246 os.setf (std::ios::dec, std::ios::basefield);
255 std::string::size_type firstDash, secondDash;
256 firstDash = v.find (
"-");
257 secondDash = v.find (
"-", firstDash+1);
258 std::string type = v.substr (0, firstDash-0);
259 std::string len = v.substr (firstDash+1, secondDash-(firstDash+1));
261 address.m_type = strtoul (type.c_str(), 0, 16);
262 address.m_len = strtoul (len.c_str(), 0, 16);
265 std::string::size_type col = secondDash + 1;
266 for (uint8_t i = 0; i <
address.m_len; ++i)
269 std::string::size_type next;
270 next = v.find (
":", col);
271 if (next == std::string::npos)
273 tmp = v.substr (col, v.size ()-col);
274 address.m_data[i] = strtoul (tmp.c_str(), 0, 16);
279 tmp = v.substr (col, next-col);
280 address.m_data[i] = strtoul (tmp.c_str(), 0, 16);
uint8_t m_len
Length of the address.
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
bool IsInvalid(void) const
void Write(const uint8_t *buffer, uint32_t size)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint8_t GetLength(void) const
Get the length of the underlying address.
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type.
bool CheckCompatible(uint8_t type, uint8_t len) const
uint32_t CopyAllTo(uint8_t *buffer, uint8_t len) const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#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.
Address()
Create an invalid address.
TAG_BUFFER_INLINE uint8_t ReadU8(void)
a polymophic address class
bool operator<(const EventId &a, const EventId &b)
uint32_t GetSerializedSize(void) const
Get the number of bytes needed to serialize the underlying Address Typically, this is GetLength () + ...
Address & operator=(const Address &address)
Basic assignment operator.
uint8_t m_type
Type of the address.
uint32_t CopyAllFrom(const uint8_t *buffer, uint8_t len)
void Deserialize(TagBuffer buffer)
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
void Serialize(TagBuffer buffer) const
Serialize this address in host byte order to a byte buffer.
bool operator!=(Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > a, Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > b)
Inequality test.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
bool IsMatchingType(uint8_t type) const
uint8_t m_data[MAX_SIZE]
The address value.
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
bool operator==(const EventId &a, const EventId &b)
void Read(uint8_t *buffer, uint32_t size)
static uint8_t Register(void)
Allocate a new type id for a new type of address.
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.