Home
STUN module (rfc5389)

AddressAttribute

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

AddressAttribute

#include <icy/stun/attributes.h>
class AddressAttribute

Defined in src/stun/include/icy/stun/attributes.h:164

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.

List of all members

NameKindOwner
AddressAttributefunctionDeclared here
AddressAttributefunctionDeclared here
clonefunctionDeclared here
familyfunctionDeclared here
addressfunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
setAddressfunctionDeclared here
isXorTypefunctionDeclared here
IPv4SizevariableDeclared here
IPv6SizevariableDeclared here
_addressvariableDeclared here
~AttributefunctionInherited from Attribute
clonefunctionInherited from Attribute
readfunctionInherited from Attribute
writefunctionInherited from Attribute
typefunctionInherited from Attribute
sizefunctionInherited from Attribute
paddingBytesfunctionInherited from Attribute
paddedBytesfunctionInherited from Attribute
consumePaddingfunctionInherited from Attribute
writePaddingfunctionInherited from Attribute
typeStringfunctionInherited from Attribute
TypeIDvariableInherited from Attribute
createfunctionInherited from Attribute
paddingBytesfunctionInherited from Attribute
paddedBytesfunctionInherited from Attribute
typeStringfunctionInherited from Attribute
_typevariableInherited from Attribute
_sizevariableInherited from Attribute
AttributefunctionInherited from Attribute
setLengthfunctionInherited from Attribute
TypeenumInherited from Attribute

Inherited from Attribute

KindNameDescription
function~Attribute virtual inline
functionclone virtualReturns a deep copy of this attribute.
functionread virtualReads the body (not the type or size) for this type of attribute from the given buffer.
functionwrite virtual constWrites the body (not the type or size) to the given buffer.
functiontype const
functionsize const
functionpaddingBytes const inline
functionpaddedBytes const inline
functionconsumePadding constAdvances the reader past any 4-byte alignment padding that follows this attribute's body.
functionwritePadding constWrites zero-fill padding bytes to align this attribute to a 4-byte boundary.
functiontypeString
variableTypeID static constexpr
functioncreate staticCreates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid.
functionpaddingBytes static inline constexprReturns the 4-byte alignment padding required for a body of size bytes.
functionpaddedBytes static inline constexprReturns the body length including 4-byte alignment padding.
functiontypeString static
variable_type
variable_size
functionAttribute
functionsetLengthUpdates the stored body length.
enumType

Public Methods

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

AddressAttribute

AddressAttribute(uint16_t type, bool ipv4 = true)

Defined in src/stun/include/icy/stun/attributes.h:169

Parameters

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

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


AddressAttribute

AddressAttribute(const AddressAttribute & r)

Defined in src/stun/include/icy/stun/attributes.h:172

Copy constructor; duplicates the stored address.


clone

virtual override

virtual std::unique_ptr< Attribute > clone() override

Defined in src/stun/include/icy/stun/attributes.h:175

Returns a deep copy of this attribute.

Reimplements

family

const inline

inline stun::AddressFamily family() const

Defined in src/stun/include/icy/stun/attributes.h:181

Returns

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


address

virtual const

virtual net::Address address() const

Defined in src/stun/include/icy/stun/attributes.h:193

Returns

The decoded socket address stored in this attribute.


read

virtual override

virtual void read(BitReader & reader) override

Defined in src/stun/include/icy/stun/attributes.h:196

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.
Reimplements

write

virtual const override

virtual void write(BitWriter & writer) const override

Defined in src/stun/include/icy/stun/attributes.h:199

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

Parameters

  • writer Destination bit writer.
Reimplements

setAddress

virtual inline

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

Defined in src/stun/include/icy/stun/attributes.h:203

Sets the address to encode into this attribute.

Parameters

  • addr Address to store.

isXorType

const inline

inline bool isXorType() const

Defined in src/stun/include/icy/stun/attributes.h:217

Returns

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

Public Static Attributes

ReturnNameDescription
constexpr uint16_tIPv4Size static constexpr
constexpr uint16_tIPv6Size static constexpr

IPv4Size

static constexpr

constexpr uint16_t IPv4Size = 8

Defined in src/stun/include/icy/stun/attributes.h:177


IPv6Size

static constexpr

constexpr uint16_t IPv6Size = 20

Defined in src/stun/include/icy/stun/attributes.h:178

Private Attributes

ReturnNameDescription
net::Address_address

_address

net::Address _address

Defined in src/stun/include/icy/stun/attributes.h:224