STUN module (rfc5389)

AddressAttribute

Implements a STUN/TURN attribute that contains a socket address.

AddressAttribute

#include <icy/stun/attributes.h>

Inherits: Attribute

Implements a STUN/TURN attribute that contains a socket address. Handles XOR encoding/decoding for address and port as required by RFC 5389 section 15.2.

Public Methods

ReturnNameDescription
AddressAttribute#### Parameters
AddressAttributeCopy constructor; duplicates the stored address.
std::unique_ptr< Attribute >clone virtualReturns a deep copy of this attribute.
stun::AddressFamilyfamily const inline#### Returns
net::Addressaddress virtual const#### Returns
voidread virtualReads the body (not the type or size) for this type of attribute from the given buffer.
voidwrite virtual constWrites the body (not the type or size) to the given buffer.
voidsetAddress virtual inlineSets the address to encode into this attribute.
boolisXorType const inline#### Returns

AddressAttribute

AddressAttribute(uint16_t type, bool ipv4)

Parameters

  • type Wire type code (e.g. XorMappedAddress::TypeID).

  • ipv4 When true, initialises the size for IPv4; otherwise IPv6.


AddressAttribute

AddressAttribute(const AddressAttribute & r)

Copy constructor; duplicates the stored address.


clone

virtual

virtual std::unique_ptr< Attribute > clone()

Returns a deep copy of this attribute.


family

const inline

inline stun::AddressFamily family() const

Returns

The STUN address family (IPv4, IPv6, or Undefined) of the stored address.


address

virtual const

virtual net::Address address() const

Returns

The decoded socket address stored in this attribute.


read

virtual

virtual void read(BitReader & reader)

Reads the body (not the type or size) for this type of attribute from the given buffer.

Parameters

  • reader Source bit reader positioned at the attribute body.

write

virtual const

virtual void write(BitWriter & writer) const

Writes the body (not the type or size) to the given buffer.

Parameters

  • writer Destination bit writer.

setAddress

virtual inline

virtual inline void setAddress(const net::Address & addr)

Sets the address to encode into this attribute.

Parameters

  • addr Address to store.

isXorType

const inline

inline bool isXorType() const

Returns

true if this attribute type uses XOR encoding (RFC 5389).

Public Static Attributes

ReturnNameDescription
constexpr uint16_tIPv4Size static
constexpr uint16_tIPv6Size static

IPv4Size

static

constexpr uint16_t IPv4Size = 8

IPv6Size

static

constexpr uint16_t IPv6Size = 20

Private Attributes

ReturnNameDescription
net::Address_address

_address

net::Address _address