Home
STUN module (rfc5389)

Attribute

The virtual base class for all STUN/TURN attributes.

Attribute

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

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

Subclassed by: AddressAttribute, ErrorCode, FlagAttribute, MessageIntegrity, StringAttribute, UInt16ListAttribute, UInt32Attribute, UInt64Attribute, UInt8Attribute

The virtual base class for all STUN/TURN attributes.

List of all members

NameKindOwner
~AttributefunctionDeclared here
clonefunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
typefunctionDeclared here
sizefunctionDeclared here
paddingBytesfunctionDeclared here
paddedBytesfunctionDeclared here
consumePaddingfunctionDeclared here
writePaddingfunctionDeclared here
typeStringfunctionDeclared here
TypeIDvariableDeclared here
createfunctionDeclared here
paddingBytesfunctionDeclared here
paddedBytesfunctionDeclared here
typeStringfunctionDeclared here
_typevariableDeclared here
_sizevariableDeclared here
AttributefunctionDeclared here
setLengthfunctionDeclared here
TypeenumDeclared here

Public Methods

ReturnNameDescription
std::unique_ptr< Attribute >clone virtualReturns a deep copy of this attribute.
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.
uint16_ttype const
uint16_tsize const
uint16_tpaddingBytes const inline
uint16_tpaddedBytes const inline
voidconsumePadding constAdvances the reader past any 4-byte alignment padding that follows this attribute's body.
voidwritePadding constWrites zero-fill padding bytes to align this attribute to a 4-byte boundary.
std::stringtypeString

clone

virtual

virtual std::unique_ptr< Attribute > clone()

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

Returns a deep copy of this attribute.

Reimplemented by

read

virtual

virtual void read(BitReader & reader)

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

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.
Reimplemented by

write

virtual const

virtual void write(BitWriter & writer) const

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

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

Parameters

  • writer Destination bit writer.
Reimplemented by

type

const

uint16_t type() const

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

Returns

The wire type code for this attribute.


size

const

uint16_t size() const

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

Returns

The body length of this attribute in bytes (before padding).


paddingBytes

const inline

inline uint16_t paddingBytes() const

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

Returns

The 4-byte alignment padding required for this attribute body.


paddedBytes

const inline

inline uint16_t paddedBytes() const

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

Returns

The body length including 4-byte alignment padding.


consumePadding

const

void consumePadding(BitReader & reader) const

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

Advances the reader past any 4-byte alignment padding that follows this attribute's body.

Parameters

  • reader Reader to advance.

writePadding

const

void writePadding(BitWriter & writer) const

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

Writes zero-fill padding bytes to align this attribute to a 4-byte boundary.

Parameters

  • writer Writer to append padding to.

typeString

std::string typeString()

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

Returns

Human-readable name for this attribute's type.

Public Static Attributes

ReturnNameDescription
constexpr uint16_tTypeID static constexpr

TypeID

static constexpr

constexpr uint16_t TypeID = 0

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

Public Static Methods

ReturnNameDescription
std::unique_ptr< Attribute >create staticCreates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid.
constexpr uint16_tpaddingBytes static inline constexprReturns the 4-byte alignment padding required for a body of size bytes.
constexpr uint16_tpaddedBytes static inline constexprReturns the body length including 4-byte alignment padding.
std::stringtypeString static

create

static

static std::unique_ptr< Attribute > create(uint16_t type, uint16_t size = 0)

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

Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid.

Parameters

  • type Wire type code (one of Attribute::Type).

  • size Body length in bytes as read from the wire header.

Returns

Owning pointer to the new attribute, or nullptr on failure.


paddingBytes

static inline constexpr

constexpr static inline constexpr uint16_t paddingBytes(uint16_t size)

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

Returns the 4-byte alignment padding required for a body of size bytes.


paddedBytes

static inline constexpr

constexpr static inline constexpr uint16_t paddedBytes(uint16_t size)

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

Returns the body length including 4-byte alignment padding.


typeString

static

static std::string typeString(uint16_t type)

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

Parameters

  • type Wire type code.

Returns

Human-readable name for the given type code.

Protected Attributes

ReturnNameDescription
uint16_t_type
uint16_t_size

_type

uint16_t _type

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


_size

uint16_t _size

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

Protected Methods

ReturnNameDescription
Attribute
voidsetLengthUpdates the stored body length.

Attribute

Attribute(uint16_t type, uint16_t size = 0)

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

Parameters

  • type Wire type code for this attribute.

  • size Initial body length in bytes.


setLength

void setLength(uint16_t size)

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

Updates the stored body length.

Parameters

  • size New body length in bytes.

Public Types

NameDescription
Type

Type

enum Type

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

ValueDescription
NotExist
MappedAddress
ResponseAddress
ChangeRequest
SourceAddress
ChangedAddress
Username
Password
MessageIntegrity
ErrorCode
Bandwidth
DestinationAddress
UnknownAttributes
ReflectedFrom
MagicCookie
Realm
Nonce
XorMappedAddress
Software
Options
AlternateServer
Fingerprint
ChannelNumberTURN.
Lifetime
XorPeerAddress
Data
XorRelayedAddress
EventPort
RequestedTransport
DontFragment
ReservationToken0x0021: Reserved (was TIMER-VAL)
ConnectionIDTURN TCP.
ICEControlledICE.
ICEControlling
ICEPriority
ICEUseCandidate