#include <address.h>
Public Types | |
enum | MaxSize_e |
Public Member Functions | |
Address () | |
Address (uint8_t type, const uint8_t *buffer, uint8_t len) | |
bool | IsInvalid (void) const |
uint8_t | GetLength (void) const |
uint32_t | CopyTo (uint8_t buffer[MAX_SIZE]) const |
uint32_t | CopyAllTo (uint8_t *buffer, uint8_t len) const |
uint32_t | CopyFrom (const uint8_t *buffer, uint8_t len) |
uint32_t | CopyAllFrom (const uint8_t *buffer, uint8_t len) |
bool | CheckCompatible (uint8_t type, uint8_t len) const |
bool | IsMatchingType (uint8_t type) const |
uint32_t | GetSerializedSize (void) const |
void | Serialize (TagBuffer buffer) const |
void | Deserialize (TagBuffer buffer) |
Static Public Member Functions | |
static uint8_t | Register (void) |
This class is very similar in design and spirit to the BSD sockaddr structure: they are both used to hold multiple types of addresses together with the type of the address.
A new address class defined by a user needs to:
Typical code to create a new class type looks like:
// this class represents addresses which are 2 bytes long. class MyAddress { public: Address ConvertTo (void) const; static MyAddress ConvertFrom (void); private: static uint8_t GetType (void); }; Address MyAddress::ConvertTo (void) const { return Address (GetType (), m_buffer, 2); } MyAddress MyAddress::ConvertFrom (const Address &address) { MyAddress ad; NS_ASSERT (address.CheckCompatible (GetType (), 2)); address.CopyTo (ad.m_buffer, 2); return ad; } uint8_t MyAddress::GetType (void) { static uint8_t type = Address::Register (); return type; }
The maximum size of a byte buffer which can be stored in an Address instance.
ns3::Address::Address | ( | ) |
Create an invalid address
ns3::Address::Address | ( | uint8_t | type, | |
const uint8_t * | buffer, | |||
uint8_t | len | |||
) |
type | the type of the Address to create | |
buffer | a pointer to a buffer of bytes which hold a serialized representation of the address in network byte order. | |
len | the length of the buffer. |
bool ns3::Address::CheckCompatible | ( | uint8_t | type, | |
uint8_t | len | |||
) | const |
type | a type id as returned by Address::Register | |
len | the length associated to this type id. |
uint32_t ns3::Address::CopyAllFrom | ( | const uint8_t * | buffer, | |
uint8_t | len | |||
) |
buffer | pointer to a buffer of bytes which contain a copy of all the members of this Address class. | |
len | the length of the buffer |
uint32_t ns3::Address::CopyAllTo | ( | uint8_t * | buffer, | |
uint8_t | len | |||
) | const |
buffer | buffer to copy the whole address data structure to | |
len | the size of the buffer |
uint32_t ns3::Address::CopyFrom | ( | const uint8_t * | buffer, | |
uint8_t | len | |||
) |
buffer | pointer to a buffer of bytes which contain a serialized representation of the address in network byte order. | |
len | length of buffer |
uint32_t ns3::Address::CopyTo | ( | uint8_t | buffer[MAX_SIZE] | ) | const |
buffer | buffer to copy the address bytes to. |
void ns3::Address::Deserialize | ( | TagBuffer | buffer | ) |
buffer | buffer to read address from |
uint8_t ns3::Address::GetLength | ( | void | ) | const |
uint32_t ns3::Address::GetSerializedSize | ( | void | ) | const |
bool ns3::Address::IsInvalid | ( | void | ) | const |
bool ns3::Address::IsMatchingType | ( | uint8_t | type | ) | const |
type | a type id as returned by Address::Register |
static uint8_t ns3::Address::Register | ( | void | ) | [static] |
Allocate a new type id for a new type of address.
void ns3::Address::Serialize | ( | TagBuffer | buffer | ) | const |
Serialize this address in host byte order to a byte buffer
buffer | output buffer that gets written with this Address |