stun

May 15, 2026 ยท View on GitHub

{#stunmodulerfc5389}

stun

The [STUN module (rfc5389)](#stunmodulerfc5389) module contains a STUN (rfc5389) implementation.

Namespaces

NameDescription
stunSTUN messages, attributes, and transaction helpers defined by RFC 5389.

Macros

NameDescription
DECLARE_FIXLEN_STUN_ATTRIBUTEAttribute macros.

{#declare_fixlen_stun_attribute}

DECLARE_FIXLEN_STUN_ATTRIBUTE

DECLARE_FIXLEN_STUN_ATTRIBUTE()

Attribute macros.

{#stun}

stun

STUN messages, attributes, and transaction helpers defined by RFC 5389.

Classes

NameDescription
AddressAttributeImplements 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.
AttributeThe virtual base class for all STUN/TURN attributes.
ErrorCodeImplements the STUN ERROR-CODE attribute (RFC 5389 section 15.6). Encodes a 3-digit error code as a class (hundreds digit) and number (tens + units digits), plus an optional UTF-8 reason phrase.
FlagAttributeImplements a zero-length STUN/TURN flag attribute (presence implies the flag is set).
MessageSTUN/TURN protocol message with method, class, transaction ID, and attributes.
MessageIntegrityImplements the STUN MESSAGE-INTEGRITY attribute (RFC 5389 section 15.4). On write, computes an HMAC-SHA1 over the message bytes preceding this attribute when a key is set. On read, captures the raw HMAC bytes and the input bytes needed to verify them later via verifyHmac().
StringAttributeImplements a STUN/TURN attribute that holds an arbitrary byte string. Used for Username, Password, Realm, Nonce, Software, Data, and similar attributes.
TransactionSTUN request/response transaction with timeout and retry logic. Extends the generic net::Transaction with STUN-specific transaction ID matching and response class inference (Success, Error, or Indication).
UInt16ListAttributeImplements a STUN/TURN attribute that holds a list of attribute type codes. Used by the UNKNOWN-ATTRIBUTES attribute (RFC 5389 section 15.9).
UInt32AttributeImplements a STUN/TURN attribute that holds a 32-bit integer.
UInt64AttributeImplements a STUN/TURN attribute that holds a 64-bit integer.
UInt8AttributeImplements a STUN/TURN attribute that holds an 8-bit integer.

Enumerations

NameDescription
AddressFamilySTUN address types as defined in RFC 5389. NB: Undefined is not part of the STUN spec.

{#addressfamily}

AddressFamily

enum AddressFamily

STUN address types as defined in RFC 5389. NB: Undefined is not part of the STUN spec.

ValueDescription
UndefinedNot a valid STUN address family; used as a sentinel.
IPv4IPv4 transport address.
IPv6IPv6 transport address.

Typedefs

ReturnNameDescription
std::stringTransactionIDFixed-width 12-byte STUN transaction identifier stored as raw bytes.

{#transactionid-1}

TransactionID

using TransactionID = std::string

Fixed-width 12-byte STUN transaction identifier stored as raw bytes.

Functions

ReturnNameDescription
boolisValidMethod nodiscard constexprReturns true if methodType corresponds to a recognised STUN/TURN method. Used during parsing to reject malformed packets.

{#isvalidmethod}

isValidMethod

nodiscard constexpr

[[nodiscard]] constexpr bool isValidMethod(uint16_t methodType)

Returns true if methodType corresponds to a recognised STUN/TURN method. Used during parsing to reject malformed packets.

Parameters

  • methodType Raw method bits extracted from the message type field.

Returns

true if the method is one of the defined MethodType values.

Variables

ReturnNameDescription
intkAttributeHeaderSize constexprBytes in a STUN attribute header.
intkMessageHeaderSize constexprBytes in the fixed STUN message header.
intkTransactionIdOffset constexprByte offset of the transaction ID inside the message header.
intkTransactionIdLength constexprLength in bytes of a STUN transaction ID.
uint32_tkMagicCookie constexprRFC 5389 magic cookie used by modern STUN/TURN messages.
intkMagicCookieLength constexprLength in bytes of the magic cookie field.

{#kattributeheadersize}

kAttributeHeaderSize

constexpr

int kAttributeHeaderSize = 4

Bytes in a STUN attribute header.


{#kmessageheadersize}

kMessageHeaderSize

constexpr

int kMessageHeaderSize = 20

Bytes in the fixed STUN message header.


{#ktransactionidoffset}

kTransactionIdOffset

constexpr

int kTransactionIdOffset = 8

Byte offset of the transaction ID inside the message header.


{#ktransactionidlength}

kTransactionIdLength

constexpr

int kTransactionIdLength = 12

Length in bytes of a STUN transaction ID.


{#kmagiccookie}

kMagicCookie

constexpr

uint32_t kMagicCookie = 0x2112A442

RFC 5389 magic cookie used by modern STUN/TURN messages.


{#kmagiccookielength}

kMagicCookieLength

constexpr

int kMagicCookieLength = sizeof()

Length in bytes of the magic cookie field.

{#addressattribute}

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
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
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 nodiscard
functionsize const nodiscard
functionpaddingBytes const inline nodiscard
functionpaddedBytes const inline nodiscard
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 nodiscard
variableTypeID static constexpr
functioncreate static nodiscardCreates 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 nodiscard constexprReturns the 4-byte alignment padding required for a body of size bytes.
functionpaddedBytes static inline nodiscard constexprReturns the body length including 4-byte alignment padding.
functiontypeString static nodiscard
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 nodiscard
net::Addressaddress virtual const nodiscard
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 nodiscard

{#addressattribute-1}

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-2}

AddressAttribute

AddressAttribute(const AddressAttribute & r)

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

Copy constructor; duplicates the stored address.


{#clone-7}

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-2}

family

const inline nodiscard

[[nodiscard]] 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-12}

address

virtual const nodiscard

[[nodiscard]] 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-2}

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-17}

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}

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}

isXorType

const inline nodiscard

[[nodiscard]] 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
uint16_tIPv4Size static constexpr
uint16_tIPv6Size static constexpr

{#ipv4size}

IPv4Size

static constexpr

uint16_t IPv4Size = 8

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


{#ipv6size}

IPv6Size

static constexpr

uint16_t IPv6Size = 20

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

Private Attributes

ReturnNameDescription
net::Address_address

{#_address-1}

_address

net::Address _address

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

{#attribute}

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
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 nodiscard
uint16_tsize const nodiscard
uint16_tpaddingBytes const inline nodiscard
uint16_tpaddedBytes const inline nodiscard
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 nodiscard

{#clone-8}

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-3}

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-18}

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-14}

type

const nodiscard

[[nodiscard]] uint16_t type() const

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

Returns

The wire type code for this attribute.


{#size-4}

size

const nodiscard

[[nodiscard]] 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}

paddingBytes

const inline nodiscard

[[nodiscard]] 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}

paddedBytes

const inline nodiscard

[[nodiscard]] 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}

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}

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}

typeString

nodiscard

[[nodiscard]] 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
uint16_tTypeID static constexpr

{#typeid}

TypeID

static constexpr

uint16_t TypeID = 0

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

Public Static Methods

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

{#create-8}

create

static nodiscard

[[nodiscard]] 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-1}

paddingBytes

static inline nodiscard constexpr

[[nodiscard]] constexpr static inline 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-1}

paddedBytes

static inline nodiscard constexpr

[[nodiscard]] constexpr static inline 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-1}

typeString

static nodiscard

[[nodiscard]] 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-1}

_type

uint16_t _type

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


{#_size}

_size

uint16_t _size

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

Protected Methods

ReturnNameDescription
Attribute
voidsetLengthUpdates the stored body length.

{#attribute-1}

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}

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-15}

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

{#errorcode-1}

ErrorCode

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

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

Inherits: Attribute

Implements the STUN ERROR-CODE attribute (RFC 5389 section 15.6). Encodes a 3-digit error code as a class (hundreds digit) and number (tens + units digits), plus an optional UTF-8 reason phrase.

List of all members

NameKindOwner
ErrorCodefunctionDeclared here
ErrorCodefunctionDeclared here
clonefunctionDeclared here
setErrorCodefunctionDeclared here
setReasonfunctionDeclared here
errorCodefunctionDeclared here
errorClassfunctionDeclared here
errorNumberfunctionDeclared here
reasonfunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
TypeIDvariableDeclared here
MinSizevariableDeclared here
_classvariableDeclared here
_numbervariableDeclared here
_reasonvariableDeclared here
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
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 nodiscard
functionsize const nodiscard
functionpaddingBytes const inline nodiscard
functionpaddedBytes const inline nodiscard
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 nodiscard
variableTypeID static constexpr
functioncreate static nodiscardCreates 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 nodiscard constexprReturns the 4-byte alignment padding required for a body of size bytes.
functionpaddedBytes static inline nodiscard constexprReturns the body length including 4-byte alignment padding.
functiontypeString static nodiscard
variable_type
variable_size
functionAttribute
functionsetLengthUpdates the stored body length.
enumType

Public Methods

ReturnNameDescription
ErrorCode
ErrorCodeCopy constructor.
std::unique_ptr< Attribute >clone virtual overrideReturns a deep copy of this attribute.
voidsetErrorCodeSets the error code, splitting it into class and number fields.
voidsetReasonSets the UTF-8 reason phrase and updates the attribute size.
interrorCode const nodiscard
uint8_terrorClass const inline nodiscard
uint8_terrorNumber const inline nodiscard
const std::string &reason const inline nodiscard
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.

{#errorcode-2}

ErrorCode

ErrorCode(uint16_t size = MinSize)

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

Parameters

  • size Initial body length in bytes (must be >= MinSize).

{#errorcode-3}

ErrorCode

ErrorCode(const ErrorCode & r)

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

Copy constructor.


{#clone-9}

clone

virtual override

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

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

Returns a deep copy of this attribute.

Reimplements

{#seterrorcode}

setErrorCode

void setErrorCode(int code)

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

Sets the error code, splitting it into class and number fields.

Parameters

  • code 3-digit error code (e.g. 401, 438).

{#setreason-1}

setReason

void setReason(const std::string & reason)

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

Sets the UTF-8 reason phrase and updates the attribute size.

Parameters

  • reason Human-readable error description.

{#errorcode-4}

errorCode

const nodiscard

[[nodiscard]] int errorCode() const

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

Returns

The full 3-digit error code (class * 100 + number).


{#errorclass}

errorClass

const inline nodiscard

[[nodiscard]] inline uint8_t errorClass() const

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

Returns

The hundreds digit of the error code (e.g. 4 for a 4xx error).


{#errornumber-1}

errorNumber

const inline nodiscard

[[nodiscard]] inline uint8_t errorNumber() const

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

Returns

The tens+units portion of the error code (0-99).


{#reason-1}

reason

const inline nodiscard

[[nodiscard]] inline const std::string & reason() const

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

Returns

The reason phrase string (may be empty).


{#read-4}

read

virtual override

virtual void read(BitReader & reader) override

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

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-19}

write

virtual const override

virtual void write(BitWriter & writer) const override

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

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

Parameters

  • writer Destination bit writer.
Reimplements

Public Static Attributes

ReturnNameDescription
uint16_tTypeID static constexpr
uint16_tMinSize static constexpr4 bytes before the reason phrase.

{#typeid-1}

TypeID

static constexpr

uint16_t TypeID = 0x0009

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


{#minsize}

MinSize

static constexpr

uint16_t MinSize = 4

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

4 bytes before the reason phrase.

Private Attributes

ReturnNameDescription
uint8_t_class
uint8_t_number
std::string_reason

{#_class}

_class

uint8_t _class

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


{#_number}

_number

uint8_t _number

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


{#_reason-1}

_reason

std::string _reason

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

{#flagattribute}

FlagAttribute

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

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

Inherits: Attribute

Implements a zero-length STUN/TURN flag attribute (presence implies the flag is set).

List of all members

NameKindOwner
FlagAttributefunctionDeclared here
clonefunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
SizevariableDeclared here
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
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 nodiscard
functionsize const nodiscard
functionpaddingBytes const inline nodiscard
functionpaddedBytes const inline nodiscard
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 nodiscard
variableTypeID static constexpr
functioncreate static nodiscardCreates 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 nodiscard constexprReturns the 4-byte alignment padding required for a body of size bytes.
functionpaddedBytes static inline nodiscard constexprReturns the body length including 4-byte alignment padding.
functiontypeString static nodiscard
variable_type
variable_size
functionAttribute
functionsetLengthUpdates the stored body length.
enumType

Public Methods

ReturnNameDescription
FlagAttribute
std::unique_ptr< Attribute >clone virtual overrideReturns a deep copy of this attribute.
voidread virtual inline overrideNo-op: flag attributes carry no body bytes.
voidwrite virtual const inline overrideNo-op: flag attributes carry no body bytes.

{#flagattribute-1}

FlagAttribute

FlagAttribute(uint16_t type)

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

Parameters

  • type Wire type code for the concrete attribute.

{#clone-10}

clone

virtual override

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

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

Returns a deep copy of this attribute.

Reimplements

{#read-5}

read

virtual inline override

virtual inline void read(BitReader &) override

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

No-op: flag attributes carry no body bytes.

Reimplements

{#write-20}

write

virtual const inline override

virtual inline void write(BitWriter &) const override

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

No-op: flag attributes carry no body bytes.

Reimplements

Public Static Attributes

ReturnNameDescription
uint16_tSize static constexpr

{#size-5}

Size

static constexpr

uint16_t Size = 0

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

{#message-5}

Message

#include <icy/stun/message.h>
class Message

Defined in src/stun/include/icy/stun/message.h:31

Inherits: IPacket Subclassed by: Request

STUN/TURN protocol message with method, class, transaction ID, and attributes.

List of all members

NameKindOwner
MessagefunctionDeclared here
MessagefunctionDeclared here
MessagefunctionDeclared here
MessagefunctionDeclared here
operator=functionDeclared here
operator=functionDeclared here
clonefunctionDeclared here
setClassfunctionDeclared here
setMethodfunctionDeclared here
setTransactionIDfunctionDeclared here
classTypefunctionDeclared here
methodTypefunctionDeclared here
transactionIDfunctionDeclared here
sizefunctionDeclared here
methodStringfunctionDeclared here
classStringfunctionDeclared here
errorStringfunctionDeclared here
addfunctionDeclared here
addfunctionDeclared here
getfunctionDeclared here
getfunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
toStringfunctionDeclared here
printfunctionDeclared here
classNamefunctionDeclared here
_classvariableDeclared here
_methodvariableDeclared here
_sizevariableDeclared here
_transactionIDvariableDeclared here
_attrsvariableDeclared here
MethodTypeenumDeclared here
ClassTypeenumDeclared here
ErrorCodesenumDeclared here
computeBodySizefunctionDeclared here
opaquevariableInherited from IPacket
infovariableInherited from IPacket
flagsvariableInherited from IPacket
IPacketfunctionInherited from IPacket
IPacketfunctionInherited from IPacket
operator=functionInherited from IPacket
clonefunctionInherited from IPacket
~IPacketfunctionInherited from IPacket
readfunctionInherited from IPacket
writefunctionInherited from IPacket
sizefunctionInherited from IPacket
hasDatafunctionInherited from IPacket
datafunctionInherited from IPacket
constDatafunctionInherited from IPacket
classNamefunctionInherited from IPacket
printfunctionInherited from IPacket
operator<<friendInherited from IPacket

Inherited from IPacket

KindNameDescription
variableopaqueOptional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime.
variableinfoOptional extra information about the packet.
variableflagsProvides basic information about the packet.
functionIPacket inline
functionIPacket inlineCopy constructor; clones the info object if present.
functionoperator= inlineCopy assignment; clones the info object if present.
functionclone virtual constReturns a heap-allocated deep copy of this packet.
function~IPacket virtualDefaulted destructor.
functionread virtualRead/parse to the packet from the given input buffer. The number of bytes read is returned.
functionwrite virtual constCopy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer.
functionsize virtual const inlineThe size of the packet in bytes.
functionhasData virtual const inlineReturns true if the packet has a non-null data pointer.
functiondata virtual const inlineThe packet data pointer for buffered packets.
functionconstData virtual const inlineThe const packet data pointer for buffered packets.
functionclassName virtual constReturns the class name of this packet type for logging and diagnostics.
functionprint virtual const inlinePrints a human-readable representation to the given stream.
friendoperator<< inlineStream insertion operator; delegates to print().

Public Methods

ReturnNameDescription
MessageConstructs a default message (Request class, Undefined method) with a randomly generated 12-byte transaction ID.
MessageConstructs a message with explicit class and method.
MessageDeep-copy constructor; clones all attributes.
Message noexceptMove constructor.
Message &operator=Deep-copy assignment; clones all attributes from that.
Message &operator= noexceptMove assignment.
std::unique_ptr< IPacket >clone virtual const override
voidsetClassSets the message class field.
voidsetMethodSets the message method field.
voidsetTransactionIDSets the 12-byte transaction ID.
ClassTypeclassType const nodiscard
MethodTypemethodType const nodiscard
const TransactionID &transactionID const inline nodiscard
size_tsize virtual const inline nodiscard override
std::stringmethodString const nodiscard
std::stringclassString const nodiscard
std::stringerrorString const nodiscardMaps a numeric error code to its canonical string description.
T &add inlineConstructs an attribute of type T in-place and appends it to the message. Returns a reference to the new attribute for further configuration.
voidaddAppends an attribute to the message, taking ownership via unique_ptr.
Attribute *get const nodiscardReturns the Nth attribute of the given type, or nullptr if not found.
T *get const inline nodiscardType-safe attribute accessor using the concrete attribute's TypeID.
ssize_tread virtual overrideParses a STUN/TURN packet from the given buffer.
voidwrite virtual const overrideSerialises this message into a STUN/TURN wire-format packet.
std::stringtoString const nodiscard
voidprint virtual const overrideWrites the same representation as toString() to the given stream.
const char *className virtual const inline overrideReturns the class name of this packet type for logging and diagnostics.

{#message-6}

Message

Message()

Defined in src/stun/include/icy/stun/message.h:92

Constructs a default message (Request class, Undefined method) with a randomly generated 12-byte transaction ID.


{#message-7}

Message

Message(ClassType clss, MethodType meth)

Defined in src/stun/include/icy/stun/message.h:97

Constructs a message with explicit class and method.

Parameters

  • clss Message class (Request, Indication, SuccessResponse, or ErrorResponse).

  • meth Message method (Binding, Allocate, Refresh, etc.).


{#message-8}

Message

Message(const Message & that)

Defined in src/stun/include/icy/stun/message.h:100

Deep-copy constructor; clones all attributes.


{#message-9}

Message

noexcept

Message(Message && that) noexcept

Defined in src/stun/include/icy/stun/message.h:103

Move constructor.


{#operator-30}

operator=

Message & operator=(const Message & that)

Defined in src/stun/include/icy/stun/message.h:106

Deep-copy assignment; clones all attributes from that.


{#operator-31}

operator=

noexcept

Message & operator=(Message && that) noexcept

Defined in src/stun/include/icy/stun/message.h:109

Move assignment.


{#clone-11}

clone

virtual const override

virtual std::unique_ptr< IPacket > clone() const override

Defined in src/stun/include/icy/stun/message.h:114

Returns

A heap-allocated deep copy of this message.

Reimplements

{#setclass}

setClass

void setClass(ClassType type)

Defined in src/stun/include/icy/stun/message.h:118

Sets the message class field.

Parameters

  • type One of Request, Indication, SuccessResponse, ErrorResponse.

{#setmethod-1}

setMethod

void setMethod(MethodType type)

Defined in src/stun/include/icy/stun/message.h:122

Sets the message method field.

Parameters


{#settransactionid}

setTransactionID

void setTransactionID(const std::string & id)

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

Sets the 12-byte transaction ID.

Parameters

  • id Must be exactly kTransactionIdLength (12) bytes.

{#classtype}

classType

const nodiscard

[[nodiscard]] ClassType classType() const

Defined in src/stun/include/icy/stun/message.h:129

Returns

The message class.


{#methodtype}

methodType

const nodiscard

[[nodiscard]] MethodType methodType() const

Defined in src/stun/include/icy/stun/message.h:132

Returns

The message method.


{#transactionid-2}

transactionID

const inline nodiscard

[[nodiscard]] inline const TransactionID & transactionID() const

Defined in src/stun/include/icy/stun/message.h:135

Returns

Reference to the 12-byte transaction ID string.


{#size-6}

size

virtual const inline nodiscard override

[[nodiscard]] virtual inline size_t size() const override

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

Returns

Total body size in bytes (sum of padded attribute headers and bodies).

Reimplements

{#methodstring}

methodString

const nodiscard

[[nodiscard]] std::string methodString() const

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

Returns

Human-readable method name (e.g. "BINDING", "ALLOCATE").


{#classstring}

classString

const nodiscard

[[nodiscard]] std::string classString() const

Defined in src/stun/include/icy/stun/message.h:144

Returns

Human-readable class name (e.g. "Request", "SuccessResponse").


{#errorstring}

errorString

const nodiscard

[[nodiscard]] std::string errorString(uint16_t errorCode) const

Defined in src/stun/include/icy/stun/message.h:149

Maps a numeric error code to its canonical string description.

Parameters

Returns

Human-readable error string, or "UnknownError" if not recognised.


{#add-1}

add

inline

template<typename T> inline T & add()

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

Constructs an attribute of type T in-place and appends it to the message. Returns a reference to the new attribute for further configuration.

Parameters

  • T Concrete attribute type (e.g. stun::Lifetime, stun::XorMappedAddress).

Returns

Reference to the newly added attribute.


{#add-2}

add

void add(std::unique_ptr< Attribute > attr)

Defined in src/stun/include/icy/stun/message.h:166

Appends an attribute to the message, taking ownership via unique_ptr.

Parameters


{#get-5}

get

const nodiscard

[[nodiscard]] Attribute * get(Attribute::Type type, int index = 0) const

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

Returns the Nth attribute of the given type, or nullptr if not found.

Parameters

  • type Attribute type code to search for.

  • index Zero-based occurrence index (0 = first match).

Returns

Raw pointer to the attribute (owned by this message), or nullptr.


{#get-6}

get

const inline nodiscard

template<typename T> [[nodiscard]] inline T * get(int index = 0) const

Defined in src/stun/include/icy/stun/message.h:179

Type-safe attribute accessor using the concrete attribute's TypeID.

Parameters

  • T Concrete attribute type (must define TypeID).

Parameters

  • index Zero-based occurrence index.

Returns

Pointer to T, or nullptr if the attribute is absent.


{#read-6}

read

virtual override

virtual ssize_t read(const ConstBuffer & buf) override

Defined in src/stun/include/icy/stun/message.h:188

Parses a STUN/TURN packet from the given buffer.

Parameters

  • buf Buffer containing at least one complete STUN message.

Returns

Number of bytes consumed, or 0 on parse failure.

Reimplements

{#write-21}

write

virtual const override

virtual void write(Buffer & buf) const override

Defined in src/stun/include/icy/stun/message.h:192

Serialises this message into a STUN/TURN wire-format packet.

Parameters

  • buf Destination buffer; data is appended.
Reimplements

{#tostring-8}

toString

const nodiscard

[[nodiscard]] std::string toString() const

Defined in src/stun/include/icy/stun/message.h:195

Returns

A concise string representation for logging (method, transaction ID, attribute types).


{#print-13}

print

virtual const override

virtual void print(std::ostream & os) const override

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

Writes the same representation as toString() to the given stream.

Parameters

  • os Output stream.
Reimplements

{#classname-7}

className

virtual const inline override

virtual inline const char * className() const override

Defined in src/stun/include/icy/stun/message.h:201

Returns the class name of this packet type for logging and diagnostics.

Reimplements

Protected Attributes

ReturnNameDescription
uint16_t_class
uint16_t_method
uint16_t_sizeSet by read(); write() uses computeBodySize() instead.
TransactionID_transactionID
std::vector< std::unique_ptr< Attribute > >_attrs

{#_class-1}

_class

uint16_t _class

Defined in src/stun/include/icy/stun/message.h:204


{#_method-1}

_method

uint16_t _method

Defined in src/stun/include/icy/stun/message.h:205


{#_size-1}

_size

uint16_t _size

Defined in src/stun/include/icy/stun/message.h:206

Set by read(); write() uses computeBodySize() instead.


{#_transactionid}

_transactionID

TransactionID _transactionID

Defined in src/stun/include/icy/stun/message.h:207


{#_attrs}

_attrs

std::vector< std::unique_ptr< Attribute > > _attrs

Defined in src/stun/include/icy/stun/message.h:208

Public Types

NameDescription
MethodType
ClassType
ErrorCodes

{#methodtype-1}

MethodType

enum MethodType

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

ValueDescription
Undefineddefault error type
BindingSTUN.
AllocateTURN.
Refresh
SendIndication(only indication semantics defined)
DataIndication(only indication semantics defined)
CreatePermission(only request/response semantics defined)
ChannelBind(only request/response semantics defined)
ConnectTURN TCP RFC 6062.
ConnectionBind
ConnectionAttempt

{#classtype-1}

ClassType

enum ClassType

Defined in src/stun/include/icy/stun/message.h:55

ValueDescription
Request
Indication
SuccessResponse
ErrorResponse

{#errorcodes}

ErrorCodes

enum ErrorCodes

Defined in src/stun/include/icy/stun/message.h:63

ValueDescription
TryAlternate
BadRequest
NotAuthorized
Forbidden
UnknownAttribute
StaleCredentials
IntegrityCheckFailure
MissingUsername
UseTLS
AllocationMismatch
StaleNonce
WrongCredentials
UnsupportedTransport
AllocationQuotaReached
RoleConflict
ServerError
InsufficientCapacity
GlobalFailure
ConnectionAlreadyExistsTURN TCP.
ConnectionTimeoutOrFailure

Private Methods

ReturnNameDescription
uint16_tcomputeBodySize const nodiscardComputes the wire body size from the current attribute list.

{#computebodysize}

computeBodySize

const nodiscard

[[nodiscard]] uint16_t computeBodySize() const

Defined in src/stun/include/icy/stun/message.h:212

Computes the wire body size from the current attribute list.

{#messageintegrity}

MessageIntegrity

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

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

Inherits: Attribute

Implements the STUN MESSAGE-INTEGRITY attribute (RFC 5389 section 15.4). On write, computes an HMAC-SHA1 over the message bytes preceding this attribute when a key is set. On read, captures the raw HMAC bytes and the input bytes needed to verify them later via verifyHmac().

List of all members

NameKindOwner
MessageIntegrityfunctionDeclared here
MessageIntegrityfunctionDeclared here
clonefunctionDeclared here
verifyHmacfunctionDeclared here
inputfunctionDeclared here
hmacfunctionDeclared here
keyfunctionDeclared here
setInputfunctionDeclared here
setHmacfunctionDeclared here
setKeyfunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
TypeIDvariableDeclared here
SizevariableDeclared here
_inputvariableDeclared here
_hmacvariableDeclared here
_keyvariableDeclared here
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
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 nodiscard
functionsize const nodiscard
functionpaddingBytes const inline nodiscard
functionpaddedBytes const inline nodiscard
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 nodiscard
variableTypeID static constexpr
functioncreate static nodiscardCreates 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 nodiscard constexprReturns the 4-byte alignment padding required for a body of size bytes.
functionpaddedBytes static inline nodiscard constexprReturns the body length including 4-byte alignment padding.
functiontypeString static nodiscard
variable_type
variable_size
functionAttribute
functionsetLengthUpdates the stored body length.
enumType

Public Methods

ReturnNameDescription
MessageIntegrity
MessageIntegrity
std::unique_ptr< Attribute >clone virtual overrideReturns a deep copy of this attribute.
boolverifyHmac const nodiscardVerifies the stored HMAC against the stored input bytes using key.
std::stringinput const inline nodiscard
std::stringhmac const inline nodiscard
std::stringkey const inline nodiscard
voidsetInput inlineSets the raw message bytes used as HMAC input during verification.
voidsetHmac inlineSets the raw HMAC value (used when copying a received attribute).
voidsetKey inlineSets the HMAC key; triggers HMAC computation on write().
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.

{#messageintegrity-1}

MessageIntegrity

MessageIntegrity()

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


{#messageintegrity-2}

MessageIntegrity

MessageIntegrity(const MessageIntegrity & r)

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


{#clone-12}

clone

virtual override

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

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

Returns a deep copy of this attribute.

Reimplements

{#verifyhmac}

verifyHmac

const nodiscard

[[nodiscard]] bool verifyHmac(std::string_view key) const

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

Verifies the stored HMAC against the stored input bytes using key.

Parameters

  • key HMAC key (MD5 of username:realm:password for long-term creds).

Returns

true if the computed HMAC matches the stored HMAC.


{#input}

input

const inline nodiscard

[[nodiscard]] inline std::string input() const

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

Returns

The raw message bytes captured at read time, used for HMAC verification.


{#hmac}

hmac

const inline nodiscard

[[nodiscard]] inline std::string hmac() const

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

Returns

The raw 20-byte HMAC value as read from the wire.


{#key-2}

key

const inline nodiscard

[[nodiscard]] inline std::string key() const

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

Returns

The HMAC key set for outgoing message signing (empty if not set).


{#setinput}

setInput

inline

inline void setInput(const std::string & input)

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

Sets the raw message bytes used as HMAC input during verification.

Parameters

  • input Byte string of the message up to this attribute.

{#sethmac}

setHmac

inline

inline void setHmac(const std::string & hmac)

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

Sets the raw HMAC value (used when copying a received attribute).

Parameters

  • hmac 20-byte HMAC string.

{#setkey}

setKey

inline

inline void setKey(const std::string & key)

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

Sets the HMAC key; triggers HMAC computation on write().

Parameters

  • key MD5 digest of the long-term credential (username:realm:password).

{#read-7}

read

virtual override

virtual void read(BitReader & reader) override

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

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-22}

write

virtual const override

virtual void write(BitWriter & writer) const override

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

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

Parameters

  • writer Destination bit writer.
Reimplements

Public Static Attributes

ReturnNameDescription
uint16_tTypeID static constexpr
uint16_tSize static constexprHMAC-SHA1 output is always 20 bytes.

{#typeid-2}

TypeID

static constexpr

uint16_t TypeID = 0x0008

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


{#size-7}

Size

static constexpr

uint16_t Size = 20

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

HMAC-SHA1 output is always 20 bytes.

Private Attributes

ReturnNameDescription
std::string_input
std::string_hmac
std::string_key

{#_input}

_input

std::string _input

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


{#_hmac}

_hmac

std::string _hmac

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


{#_key-1}

_key

std::string _key

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

{#stringattribute}

StringAttribute

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

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

Inherits: Attribute

Implements a STUN/TURN attribute that holds an arbitrary byte string. Used for Username, Password, Realm, Nonce, Software, Data, and similar attributes.

List of all members

NameKindOwner
StringAttributefunctionDeclared here
StringAttributefunctionDeclared here
clonefunctionDeclared here
bytesfunctionDeclared here
setBytesfunctionDeclared here
asStringfunctionDeclared here
copyBytesfunctionDeclared here
copyBytesfunctionDeclared here
getBytefunctionDeclared here
setBytefunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
_bytesvariableDeclared here
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
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 nodiscard
functionsize const nodiscard
functionpaddingBytes const inline nodiscard
functionpaddedBytes const inline nodiscard
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 nodiscard
variableTypeID static constexpr
functioncreate static nodiscardCreates 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 nodiscard constexprReturns the 4-byte alignment padding required for a body of size bytes.
functionpaddedBytes static inline nodiscard constexprReturns the body length including 4-byte alignment padding.
functiontypeString static nodiscard
variable_type
variable_size
functionAttribute
functionsetLengthUpdates the stored body length.
enumType

Public Methods

ReturnNameDescription
StringAttribute
StringAttributeCopy constructor; duplicates stored bytes.
std::unique_ptr< Attribute >clone virtual overrideReturns a deep copy of this attribute.
const char *bytes const inline nodiscard
voidsetBytesReplaces the stored bytes with a copy of the given buffer and updates the attribute's reported size.
std::stringasString const nodiscard
voidcopyBytesCopies a null-terminated string into the attribute, using strlen to determine the length.
voidcopyBytesCopies an arbitrary block of memory into the attribute.
uint8_tgetByte const nodiscardReturns a single byte from the stored buffer.
voidsetByteOverwrites a single byte in the stored buffer.
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.

{#stringattribute-1}

StringAttribute

StringAttribute(uint16_t type, uint16_t size = 0)

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

Parameters

  • type Wire type code for the concrete attribute.

  • size Initial body length in bytes (0 for variable-length attributes).


{#stringattribute-2}

StringAttribute

StringAttribute(const StringAttribute & r)

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

Copy constructor; duplicates stored bytes.


{#clone-13}

clone

virtual override

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

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

Returns a deep copy of this attribute.

Reimplements

{#bytes-1}

bytes

const inline nodiscard

[[nodiscard]] inline const char * bytes() const

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

Returns

Pointer to the raw byte buffer.


{#setbytes}

setBytes

void setBytes(const char * bytes, size_t size)

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

Replaces the stored bytes with a copy of the given buffer and updates the attribute's reported size.

Parameters

  • bytes Source data pointer.

  • size Number of bytes to copy.


{#asstring}

asString

const nodiscard

[[nodiscard]] std::string asString() const

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

Returns

The stored bytes as a std::string.


{#copybytes}

copyBytes

void copyBytes(const char * bytes)

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

Copies a null-terminated string into the attribute, using strlen to determine the length.

Parameters

  • bytes Null-terminated source string.

{#copybytes-1}

copyBytes

void copyBytes(const void * bytes, size_t size)

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

Copies an arbitrary block of memory into the attribute.

Parameters

  • bytes Source data pointer.

  • size Number of bytes to copy.


{#getbyte}

getByte

const nodiscard

[[nodiscard]] uint8_t getByte(int index) const

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

Returns a single byte from the stored buffer.

Parameters

  • index Zero-based byte offset.

Returns

The byte value at index.


{#setbyte}

setByte

void setByte(int index, uint8_t value)

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

Overwrites a single byte in the stored buffer.

Parameters

  • index Zero-based byte offset.

  • value New value to write.


{#read-8}

read

virtual override

virtual void read(BitReader & reader) override

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

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-23}

write

virtual const override

virtual void write(BitWriter & writer) const override

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

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

Parameters

  • writer Destination bit writer.
Reimplements

Private Attributes

ReturnNameDescription
std::vector< char >_bytes

{#_bytes}

_bytes

std::vector< char > _bytes

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

{#transaction-2}

Transaction

#include <icy/stun/transaction.h>
class Transaction

Defined in src/stun/include/icy/stun/transaction.h:31

Inherits: Transaction< Message >

STUN request/response transaction with timeout and retry logic. Extends the generic net::Transaction with STUN-specific transaction ID matching and response class inference (Success, Error, or Indication).

Lifetime is managed by IntrusivePtr. Create via makeIntrusive or wrap in IntrusivePtr immediately after construction.

List of all members

NameKindOwner
IntrusivePtrfriendDeclared here
TransactionfunctionDeclared here
checkResponsefunctionDeclared here
onResponsefunctionDeclared here
PtrtypedefDeclared here
IntrusivePtrfriendInherited from Transaction
TransactionfunctionInherited from Transaction
sendfunctionInherited from Transaction
cancelfunctionInherited from Transaction
disposefunctionInherited from Transaction
peerAddressfunctionInherited from Transaction
_peerAddressvariableInherited from Transaction
onPacketfunctionInherited from Transaction
onResponsefunctionInherited from Transaction
checkResponsefunctionInherited from Transaction
BaseTtypedefInherited from Transaction
PtrtypedefInherited from PacketTransaction
IntrusivePtrfriendInherited from PacketTransaction
_requestvariableInherited from PacketTransaction
_responsevariableInherited from PacketTransaction
_timervariableInherited from PacketTransaction
_retriesvariableInherited from PacketTransaction
_attemptsvariableInherited from PacketTransaction
_disposedvariableInherited from PacketTransaction
PacketTransactionfunctionInherited from PacketTransaction
PacketTransactionfunctionInherited from PacketTransaction
sendfunctionInherited from PacketTransaction
cancelfunctionInherited from PacketTransaction
cancelledfunctionInherited from PacketTransaction
disposefunctionInherited from PacketTransaction
disposedfunctionInherited from PacketTransaction
canResendfunctionInherited from PacketTransaction
attemptsfunctionInherited from PacketTransaction
retriesfunctionInherited from PacketTransaction
requestfunctionInherited from PacketTransaction
requestfunctionInherited from PacketTransaction
responsefunctionInherited from PacketTransaction
responsefunctionInherited from PacketTransaction
~PacketTransactionfunctionInherited from PacketTransaction
onStateChangefunctionInherited from PacketTransaction
handlePotentialResponsefunctionInherited from PacketTransaction
checkResponsefunctionInherited from PacketTransaction
onResponsefunctionInherited from PacketTransaction
onTimeoutfunctionInherited from PacketTransaction
sendfunctionInherited from Sendable
cancelfunctionInherited from Sendable
StateChangevariableInherited from Stateful
_statevariableInherited from Stateful
StatefulfunctionInherited from Stateful
~StatefulfunctionInherited from Stateful
stateEqualsfunctionInherited from Stateful
stateBetweenfunctionInherited from Stateful
statefunctionInherited from Stateful
statefunctionInherited from Stateful
beforeStateChangefunctionInherited from Stateful
onStateChangefunctionInherited from Stateful
setStatefunctionInherited from Stateful
setStatefunctionInherited from Stateful
_refCountvariableInherited from RefCounted
RefCountedfunctionInherited from RefCounted
RefCountedfunctionInherited from RefCounted
operator=functionInherited from RefCounted
addReffunctionInherited from RefCounted
releaseReffunctionInherited from RefCounted
refCountfunctionInherited from RefCounted
~RefCountedfunctionInherited from RefCounted
factoryvariableInherited from PacketSocketEmitter
PacketSocketEmitterfunctionInherited from PacketSocketEmitter
onSocketRecvfunctionInherited from PacketSocketEmitter
onPacketfunctionInherited from PacketSocketEmitter
ConnectvariableInherited from SocketEmitter
RecvvariableInherited from SocketEmitter
ErrorvariableInherited from SocketEmitter
ClosevariableInherited from SocketEmitter
implvariableInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
~SocketEmitterfunctionInherited from SocketEmitter
addReceiverfunctionInherited from SocketEmitter
removeReceiverfunctionInherited from SocketEmitter
swapfunctionInherited from SocketEmitter
asfunctionInherited from SocketEmitter
operator->functionInherited from SocketEmitter
onSocketConnectfunctionInherited from SocketEmitter
onSocketRecvfunctionInherited from SocketEmitter
onSocketErrorfunctionInherited from SocketEmitter
onSocketClosefunctionInherited from SocketEmitter
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from Transaction

KindNameDescription
friendIntrusivePtr
functionTransaction inlineConstructs a Transaction on the given socket targeting peerAddress.
functionsend virtual inline overrideSends the request packet to the peer address and starts the timeout timer. Sets state to Failed and returns false if the packet could not be sent.
functioncancel virtual inline overrideCancels the transaction and stops the timeout timer.
functiondispose virtual inline overrideStops the timer and unregisters callbacks.
functionpeerAddress const inlineReturns the remote peer address used for this transaction.
variable_peerAddress
functiononPacket virtual inline overrideChecks whether packet is a matching response for the pending request. If it matches, the transaction completes; socket data propagation stops.
functiononResponse virtual inline overrideCalled when a confirmed response is received; emits the response via PacketSignal.
functioncheckResponse virtual inline overrideReturns true if packet is a valid response for this transaction.
typedefBaseT

Inherited from PacketTransaction

KindNameDescription
typedefPtr
friendIntrusivePtr
variable_request
variable_response
variable_timerThe request timeout callback.
variable_retriesThe maximum number of attempts before the transaction is considered failed.
variable_attemptsThe number of times the transaction has been sent.
variable_disposed
functionPacketTransaction inline
functionPacketTransaction inline
functionsend virtual inline overrideStarts the transaction timer and sends the request. Overriding classes should implement send logic here.
functioncancel virtual inline overrideCancellation means that the agent will not retransmit the request, will not treat the lack of response to be a failure, but will wait the duration of the transaction timeout for a response. Transitions the transaction to the Cancelled state.
functioncancelled const inline
functiondispose virtual inlineStops the timer and unregisters callbacks. Does NOT delete the object; the IntrusivePtr destructor handles deletion when the last reference is released. Safe to call multiple times.
functiondisposed const inline nodiscard
functioncanResend virtual inline
functionattempts const inline
functionretries const inline
functionrequest inline
functionrequest const inline
functionresponse inline
functionresponse const inline
function~PacketTransaction virtual inline
functiononStateChange virtual inline overridePost state change hook. Calls dispose() on terminal states to stop the timer, but does not delete the object; IntrusivePtr handles that.
functionhandlePotentialResponse virtual inlineProcesses a potential response candidate and updates the state accordingly.
functioncheckResponse virtualChecks a potential response candidate and returns true on successful match.
functiononResponse virtual inlineCalled when a successful response is received.
functiononTimeout virtual inlineCalled by the timer when the transaction timeout elapses. Retransmits if retries remain, otherwise transitions to Failed.

Inherited from Sendable

KindNameDescription
functionsend virtualInitiates the send operation.
functioncancel virtualCancels a pending send operation.

Inherited from Stateful

KindNameDescription
variableStateChangeSignals when the state changes.
variable_state
functionStateful inline
function~Stateful virtual inline
functionstateEquals virtual const inlineReturns true if the current state ID equals the given ID.
functionstateBetween virtual const inlineReturns true if the current state ID is in the inclusive range [lid, rid].
functionstate virtual inlineReturns a mutable reference to the current state.
functionstate virtual const inlineReturns a copy of the current state.
functionbeforeStateChange virtual inlineOverride to handle pre state change logic. Return false to prevent state change.
functiononStateChange virtual inlineOverride to handle post state change logic.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.

Inherited from RefCounted

KindNameDescription
variable_refCount
functionRefCountedDefaulted constructor.
functionRefCounted inline noexcept
functionoperator= inline noexcept
functionaddRef const inline noexceptIncrements the reference count. Called by IntrusivePtr on acquisition.
functionreleaseRef const inline noexceptDecrements the reference count.
functionrefCount const inline nodiscard noexceptReturns the current reference count.
function~RefCountedDefaulted destructor.

Inherited from PacketSocketEmitter

KindNameDescription
variablefactoryThe packet factory.
functionPacketSocketEmitterCreates the PacketSocketEmitter and attaches it to the given socket.
functiononSocketRecv virtual overrideParses raw received data into packets via the factory and forwards each parsed packet to onPacket(). Returns true if propagation should stop.
functiononPacket virtualProcess a parsed packet. Returns true to stop propagation.

Inherited from SocketEmitter

KindNameDescription
variableConnectSignals that the socket is connected.
variableRecvSignals when data is received by the socket.
variableErrorSignals that the socket is closed in error. This signal will be sent just before the Closed signal.
variableCloseSignals that the underlying socket is closed.
variableimplPointer to the underlying socket. Sent data will be proxied to this socket.
functionSocketEmitterCreates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver.
functionSocketEmitterCopy constructor; copies all signal connections and attaches to the same socket.
function~SocketEmitter virtual noexceptDestroys the SocketAdapter.
functionaddReceiver virtual overrideAttaches a SocketAdapter as a receiver; wires it to all four socket signals.
functionremoveReceiver virtual overrideDetaches a SocketAdapter from all four socket signals.
functionswap virtualReplaces the underlying socket with socket.
functionas inlineReturns the underlying socket cast to type T, or nullptr if the cast fails.
functionoperator-> const inlineReturns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer.
functiononSocketConnect virtual overrideForwards the connect event to chained adapters, then fires the Connect signal.
functiononSocketRecv virtual overrideForwards the recv event to chained adapters, then fires the Recv signal.
functiononSocketError virtual overrideForwards the error event to chained adapters, then fires the Error signal.
functiononSocketClose virtual overrideForwards the close event to chained adapters, then fires the Close signal.

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address.
functionsendPacket virtual
functionsendPacket virtualSends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Friends

NameDescription
icy::IntrusivePtr

{#icy-intrusiveptr-1}

icy::IntrusivePtr

template<typename U> friend class icy::IntrusivePtr

Defined in src/stun/include/icy/stun/transaction.h:57

Public Methods

ReturnNameDescription
TransactionConstructs a STUN transaction bound to a specific socket and peer.
boolcheckResponse overrideChecks that message is a valid response for the pending request. In addition to the base class check, verifies that the transaction IDs match.
voidonResponse virtual overrideCalled when a valid response is received. Infers the response class (SuccessResponse, ErrorResponse, or Indication) from the response attributes and delegates to the base class handler.

{#transaction-3}

Transaction

Transaction(const net::Socket::Ptr & socket, const net::Address & peerAddress, long timeout = 10000, int retries = 1)

Defined in src/stun/include/icy/stun/transaction.h:41

Constructs a STUN transaction bound to a specific socket and peer.

Parameters

  • socket Socket used to send the request and receive the response.

  • peerAddress Remote address of the STUN/TURN server.

  • timeout Response timeout in milliseconds (default 10 s).

  • retries Number of send retries before declaring failure (default 1).


{#checkresponse-1}

checkResponse

override

bool checkResponse(const Message & message) override

Defined in src/stun/include/icy/stun/transaction.h:48

Checks that message is a valid response for the pending request. In addition to the base class check, verifies that the transaction IDs match.

Parameters

  • message Incoming STUN message to evaluate.

Returns

true if message is the expected response.


{#onresponse-1}

onResponse

virtual override

virtual void onResponse() override

Defined in src/stun/include/icy/stun/transaction.h:53

Called when a valid response is received. Infers the response class (SuccessResponse, ErrorResponse, or Indication) from the response attributes and delegates to the base class handler.

Reimplements

Public Types

NameDescription
Ptr

{#ptr-16}

Ptr

using Ptr = IntrusivePtr< Transaction >

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

{#uint16listattribute}

UInt16ListAttribute

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

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

Inherits: Attribute

Implements a STUN/TURN attribute that holds a list of attribute type codes. Used by the UNKNOWN-ATTRIBUTES attribute (RFC 5389 section 15.9).

List of all members

NameKindOwner
UInt16ListAttributefunctionDeclared here
UInt16ListAttributefunctionDeclared here
clonefunctionDeclared here
sizefunctionDeclared here
getTypefunctionDeclared here
setTypefunctionDeclared here
addTypefunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
_attrTypesvariableDeclared here
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
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 nodiscard
functionsize const nodiscard
functionpaddingBytes const inline nodiscard
functionpaddedBytes const inline nodiscard
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 nodiscard
variableTypeID static constexpr
functioncreate static nodiscardCreates 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 nodiscard constexprReturns the 4-byte alignment padding required for a body of size bytes.
functionpaddedBytes static inline nodiscard constexprReturns the body length including 4-byte alignment padding.
functiontypeString static nodiscard
variable_type
variable_size
functionAttribute
functionsetLengthUpdates the stored body length.
enumType

Public Methods

ReturnNameDescription
UInt16ListAttribute
UInt16ListAttributeCopy constructor; duplicates the type list.
std::unique_ptr< Attribute >clone virtual overrideReturns a deep copy of this attribute.
size_tsize const nodiscard
uint16_tgetType const nodiscardReturns the type code at the given list position.
voidsetTypeOverwrites the type code at the given list position.
voidaddTypeAppends a type code to the list and updates the attribute size.
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.

{#uint16listattribute-1}

UInt16ListAttribute

UInt16ListAttribute(uint16_t type, uint16_t size)

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

Parameters

  • type Wire type code for the concrete attribute.

  • size Initial body length in bytes.


{#uint16listattribute-2}

UInt16ListAttribute

UInt16ListAttribute(const UInt16ListAttribute & r)

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

Copy constructor; duplicates the type list.


{#clone-14}

clone

virtual override

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

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

Returns a deep copy of this attribute.

Reimplements

{#size-8}

size

const nodiscard

[[nodiscard]] size_t size() const

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

Returns

Number of attribute type codes in the list.


{#gettype}

getType

const nodiscard

[[nodiscard]] uint16_t getType(int index) const

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

Returns the type code at the given list position.

Parameters

  • index Zero-based list index.

Returns

Attribute type code at index.


{#settype}

setType

void setType(int index, uint16_t value)

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

Overwrites the type code at the given list position.

Parameters

  • index Zero-based list index.

  • value New attribute type code.


{#addtype}

addType

void addType(uint16_t value)

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

Appends a type code to the list and updates the attribute size.

Parameters


{#read-9}

read

virtual override

virtual void read(BitReader & reader) override

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

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-24}

write

virtual const override

virtual void write(BitWriter & writer) const override

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

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

Parameters

  • writer Destination bit writer.
Reimplements

Private Attributes

ReturnNameDescription
std::vector< uint16_t >_attrTypes

{#_attrtypes}

_attrTypes

std::vector< uint16_t > _attrTypes

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

{#uint32attribute}

UInt32Attribute

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

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

Inherits: Attribute

Implements a STUN/TURN attribute that holds a 32-bit integer.

List of all members

NameKindOwner
UInt32AttributefunctionDeclared here
UInt32AttributefunctionDeclared here
clonefunctionDeclared here
valuefunctionDeclared here
setValuefunctionDeclared here
getBitfunctionDeclared here
setBitfunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
SizevariableDeclared here
_bitsvariableDeclared here
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
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 nodiscard
functionsize const nodiscard
functionpaddingBytes const inline nodiscard
functionpaddedBytes const inline nodiscard
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 nodiscard
variableTypeID static constexpr
functioncreate static nodiscardCreates 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 nodiscard constexprReturns the 4-byte alignment padding required for a body of size bytes.
functionpaddedBytes static inline nodiscard constexprReturns the body length including 4-byte alignment padding.
functiontypeString static nodiscard
variable_type
variable_size
functionAttribute
functionsetLengthUpdates the stored body length.
enumType

Public Methods

ReturnNameDescription
UInt32Attribute
UInt32AttributeCopy constructor.
std::unique_ptr< Attribute >clone virtual overrideReturns a deep copy of this attribute.
uint32_tvalue const inline nodiscard
voidsetValue inlineSets the stored 32-bit value.
boolgetBit const nodiscardReturns the state of a single bit within the stored word.
voidsetBitSets or clears a single bit within the stored word.
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.

{#uint32attribute-1}

UInt32Attribute

UInt32Attribute(uint16_t type)

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

Parameters

  • type Wire type code for the concrete attribute.

{#uint32attribute-2}

UInt32Attribute

UInt32Attribute(const UInt32Attribute & r)

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

Copy constructor.


{#clone-15}

clone

virtual override

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

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

Returns a deep copy of this attribute.

Reimplements

{#value-1}

value

const inline nodiscard

[[nodiscard]] inline uint32_t value() const

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

Returns

The stored 32-bit value.


{#setvalue-1}

setValue

inline

inline void setValue(uint32_t bits)

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

Sets the stored 32-bit value.

Parameters

  • bits Value to store.

{#getbit}

getBit

const nodiscard

[[nodiscard]] bool getBit(int index) const

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

Returns the state of a single bit within the stored word.

Parameters

  • index Bit position (0 = LSB, 31 = MSB).

Returns

true if the bit is set.


{#setbit}

setBit

void setBit(int index, bool value)

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

Sets or clears a single bit within the stored word.

Parameters

  • index Bit position (0 = LSB, 31 = MSB).

  • value true to set, false to clear.


{#read-10}

read

virtual override

virtual void read(BitReader & reader) override

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

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-25}

write

virtual const override

virtual void write(BitWriter & writer) const override

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

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

Parameters

  • writer Destination bit writer.
Reimplements

Public Static Attributes

ReturnNameDescription
uint16_tSize static constexpr

{#size-9}

Size

static constexpr

uint16_t Size = 4

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

Private Attributes

ReturnNameDescription
uint32_t_bits

{#_bits}

_bits

uint32_t _bits

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

{#uint64attribute}

UInt64Attribute

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

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

Inherits: Attribute

Implements a STUN/TURN attribute that holds a 64-bit integer.

List of all members

NameKindOwner
UInt64AttributefunctionDeclared here
UInt64AttributefunctionDeclared here
clonefunctionDeclared here
valuefunctionDeclared here
setValuefunctionDeclared here
getBitfunctionDeclared here
setBitfunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
SizevariableDeclared here
_bitsvariableDeclared here
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
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 nodiscard
functionsize const nodiscard
functionpaddingBytes const inline nodiscard
functionpaddedBytes const inline nodiscard
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 nodiscard
variableTypeID static constexpr
functioncreate static nodiscardCreates 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 nodiscard constexprReturns the 4-byte alignment padding required for a body of size bytes.
functionpaddedBytes static inline nodiscard constexprReturns the body length including 4-byte alignment padding.
functiontypeString static nodiscard
variable_type
variable_size
functionAttribute
functionsetLengthUpdates the stored body length.
enumType

Public Methods

ReturnNameDescription
UInt64Attribute
UInt64AttributeCopy constructor.
std::unique_ptr< Attribute >clone virtual overrideReturns a deep copy of this attribute.
uint64_tvalue const inline nodiscard
voidsetValue inlineSets the stored 64-bit value.
boolgetBit const nodiscardReturns the state of a single bit within the stored quad-word.
voidsetBitSets or clears a single bit within the stored quad-word.
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.

{#uint64attribute-1}

UInt64Attribute

UInt64Attribute(uint16_t type)

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

Parameters

  • type Wire type code for the concrete attribute.

{#uint64attribute-2}

UInt64Attribute

UInt64Attribute(const UInt64Attribute & r)

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

Copy constructor.


{#clone-16}

clone

virtual override

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

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

Returns a deep copy of this attribute.

Reimplements

{#value-2}

value

const inline nodiscard

[[nodiscard]] inline uint64_t value() const

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

Returns

The stored 64-bit value.


{#setvalue-2}

setValue

inline

inline void setValue(uint64_t bits)

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

Sets the stored 64-bit value.

Parameters

  • bits Value to store.

{#getbit-1}

getBit

const nodiscard

[[nodiscard]] bool getBit(int index) const

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

Returns the state of a single bit within the stored quad-word.

Parameters

  • index Bit position (0 = LSB, 63 = MSB).

Returns

true if the bit is set.


{#setbit-1}

setBit

void setBit(int index, bool value)

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

Sets or clears a single bit within the stored quad-word.

Parameters

  • index Bit position (0 = LSB, 63 = MSB).

  • value true to set, false to clear.


{#read-11}

read

virtual override

virtual void read(BitReader & reader) override

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

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-26}

write

virtual const override

virtual void write(BitWriter & writer) const override

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

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

Parameters

  • writer Destination bit writer.
Reimplements

Public Static Attributes

ReturnNameDescription
uint16_tSize static constexpr

{#size-10}

Size

static constexpr

uint16_t Size = 8

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

Private Attributes

ReturnNameDescription
uint64_t_bits

{#_bits-1}

_bits

uint64_t _bits

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

{#uint8attribute}

UInt8Attribute

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

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

Inherits: Attribute

Implements a STUN/TURN attribute that holds an 8-bit integer.

List of all members

NameKindOwner
UInt8AttributefunctionDeclared here
UInt8AttributefunctionDeclared here
clonefunctionDeclared here
valuefunctionDeclared here
setValuefunctionDeclared here
getBitfunctionDeclared here
setBitfunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
SizevariableDeclared here
_bitsvariableDeclared here
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
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 nodiscard
functionsize const nodiscard
functionpaddingBytes const inline nodiscard
functionpaddedBytes const inline nodiscard
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 nodiscard
variableTypeID static constexpr
functioncreate static nodiscardCreates 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 nodiscard constexprReturns the 4-byte alignment padding required for a body of size bytes.
functionpaddedBytes static inline nodiscard constexprReturns the body length including 4-byte alignment padding.
functiontypeString static nodiscard
variable_type
variable_size
functionAttribute
functionsetLengthUpdates the stored body length.
enumType

Public Methods

ReturnNameDescription
UInt8Attribute
UInt8AttributeCopy constructor.
std::unique_ptr< Attribute >clone virtual overrideReturns a deep copy of this attribute.
uint8_tvalue const inline nodiscard
voidsetValue inlineSets the stored 8-bit value.
boolgetBit const nodiscardReturns the state of a single bit within the stored byte.
voidsetBitSets or clears a single bit within the stored byte.
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.

{#uint8attribute-1}

UInt8Attribute

UInt8Attribute(uint16_t type)

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

Parameters

  • type Wire type code for the concrete attribute.

{#uint8attribute-2}

UInt8Attribute

UInt8Attribute(const UInt8Attribute & r)

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

Copy constructor.


{#clone-17}

clone

virtual override

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

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

Returns a deep copy of this attribute.

Reimplements

{#value-3}

value

const inline nodiscard

[[nodiscard]] inline uint8_t value() const

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

Returns

The stored 8-bit value.


{#setvalue-3}

setValue

inline

inline void setValue(uint8_t bits)

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

Sets the stored 8-bit value.

Parameters

  • bits Value to store.

{#getbit-2}

getBit

const nodiscard

[[nodiscard]] bool getBit(int index) const

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

Returns the state of a single bit within the stored byte.

Parameters

  • index Bit position (0 = LSB, 7 = MSB).

Returns

true if the bit is set.


{#setbit-2}

setBit

void setBit(int index, bool value)

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

Sets or clears a single bit within the stored byte.

Parameters

  • index Bit position (0 = LSB, 7 = MSB).

  • value true to set, false to clear.


{#read-12}

read

virtual override

virtual void read(BitReader & reader) override

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

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-27}

write

virtual const override

virtual void write(BitWriter & writer) const override

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

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

Parameters

  • writer Destination bit writer.
Reimplements

Public Static Attributes

ReturnNameDescription
uint16_tSize static constexpr

{#size-11}

Size

static constexpr

uint16_t Size = 1

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

Private Attributes

ReturnNameDescription
uint8_t_bits

{#_bits-2}

_bits

uint8_t _bits

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