15#include "ns3/attribute-helper.h"
16#include "ns3/attribute.h"
22#include <unordered_map>
133 return std::hash<std::string>()(k.first) ^ (std::hash<uint8_t>()(k.second));
176 Address(uint8_t type,
const uint8_t* buffer, uint8_t len);
186 void SetType(
const std::string& kind, uint8_t length);
276 static uint8_t
Register(
const std::string& kind, uint8_t length);
a polymophic address class
friend std::istream & operator>>(std::istream &is, Address &address)
Stream extraction operator.
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.
static constexpr uint8_t UNASSIGNED_TYPE
Unassigned Address type is reserved. Defined for clarity.
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
friend std::ostream & operator<<(std::ostream &os, const Address &address)
Stream insertion operator.
static constexpr uint32_t MAX_SIZE
The maximum size of a byte buffer which can be stored in an Address instance.
std::pair< std::string, uint8_t > KindType
Key for the address registry: kind (string) / type (uint8_t).
uint8_t m_len
Length of the address.
void SetType(const std::string &kind, uint8_t length)
Set the address type.
std::array< uint8_t, MAX_SIZE > m_data
The address value.
uint8_t m_type
Type of the address.
std::unordered_map< KindType, uint8_t, Address::KeyHash > KindTypeRegistry
Type of the address registry.
static KindTypeRegistry m_typeRegistry
Container of allocated address types.
uint32_t CopyAllFrom(const uint8_t *buffer, uint8_t len)
bool CheckCompatible(uint8_t type, uint8_t len) const
Address()=default
Create an invalid address.
uint8_t GetLength() const
Get the length of the underlying address.
constexpr std::strong_ordering operator<=>(const Address &other) const =default
Three-way comparison operator.
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
void Deserialize(TagBuffer buffer)
static uint8_t Register(const std::string &kind, uint8_t length)
Allocate a new type id for a new type of address.
bool IsMatchingType(uint8_t type) const
uint32_t CopyAllTo(uint8_t *buffer, uint8_t len) const
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type.
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)
Structure necessary to hash KindType, used as the key for the m_typeRegistry map.
std::size_t operator()(const KindType &k) const
Functional operator for (string, uint8_t) hash computation.