stun
May 15, 2026 ยท View on GitHub
{#stunmodulerfc5389}
stun
The [STUN module (rfc5389)](#stunmodulerfc5389) module contains a STUN (rfc5389) implementation.
Namespaces
| Name | Description |
|---|---|
stun | STUN messages, attributes, and transaction helpers defined by RFC 5389. |
Macros
| Name | Description |
|---|---|
DECLARE_FIXLEN_STUN_ATTRIBUTE | Attribute 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
| Name | Description |
|---|---|
AddressAttribute | 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. |
Attribute | The virtual base class for all STUN/TURN attributes. |
ErrorCode | 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. |
FlagAttribute | Implements a zero-length STUN/TURN flag attribute (presence implies the flag is set). |
Message | STUN/TURN protocol message with method, class, transaction ID, and attributes. |
MessageIntegrity | 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(). |
StringAttribute | Implements a STUN/TURN attribute that holds an arbitrary byte string. Used for Username, Password, Realm, Nonce, Software, Data, and similar attributes. |
Transaction | 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). |
UInt16ListAttribute | Implements a STUN/TURN attribute that holds a list of attribute type codes. Used by the UNKNOWN-ATTRIBUTES attribute (RFC 5389 section 15.9). |
UInt32Attribute | Implements a STUN/TURN attribute that holds a 32-bit integer. |
UInt64Attribute | Implements a STUN/TURN attribute that holds a 64-bit integer. |
UInt8Attribute | Implements a STUN/TURN attribute that holds an 8-bit integer. |
Enumerations
| Name | Description |
|---|---|
AddressFamily | STUN 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.
| Value | Description |
|---|---|
Undefined | Not a valid STUN address family; used as a sentinel. |
IPv4 | IPv4 transport address. |
IPv6 | IPv6 transport address. |
Typedefs
| Return | Name | Description |
|---|---|---|
std::string | TransactionID | Fixed-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
| Return | Name | Description |
|---|---|---|
bool | isValidMethod nodiscard constexpr | Returns 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
methodTypeRaw method bits extracted from the message type field.
Returns
true if the method is one of the defined MethodType values.
Variables
| Return | Name | Description |
|---|---|---|
int | kAttributeHeaderSize constexpr | Bytes in a STUN attribute header. |
int | kMessageHeaderSize constexpr | Bytes in the fixed STUN message header. |
int | kTransactionIdOffset constexpr | Byte offset of the transaction ID inside the message header. |
int | kTransactionIdLength constexpr | Length in bytes of a STUN transaction ID. |
uint32_t | kMagicCookie constexpr | RFC 5389 magic cookie used by modern STUN/TURN messages. |
int | kMagicCookieLength constexpr | Length 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
| Name | Kind | Owner |
|---|---|---|
AddressAttribute | function | Declared here |
AddressAttribute | function | Declared here |
clone | function | Declared here |
family | function | Declared here |
address | function | Declared here |
read | function | Declared here |
write | function | Declared here |
setAddress | function | Declared here |
isXorType | function | Declared here |
IPv4Size | variable | Declared here |
IPv6Size | variable | Declared here |
_address | variable | Declared here |
clone | function | Inherited from Attribute |
read | function | Inherited from Attribute |
write | function | Inherited from Attribute |
type | function | Inherited from Attribute |
size | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
consumePadding | function | Inherited from Attribute |
writePadding | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
TypeID | variable | Inherited from Attribute |
create | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
_type | variable | Inherited from Attribute |
_size | variable | Inherited from Attribute |
Attribute | function | Inherited from Attribute |
setLength | function | Inherited from Attribute |
Type | enum | Inherited from Attribute |
Inherited from Attribute
| Kind | Name | Description |
|---|---|---|
function | clone virtual | Returns a deep copy of this attribute. |
function | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
function | write virtual const | Writes the body (not the type or size) to the given buffer. |
function | type const nodiscard | |
function | size const nodiscard | |
function | paddingBytes const inline nodiscard | |
function | paddedBytes const inline nodiscard | |
function | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
function | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
function | typeString nodiscard | |
variable | TypeID static constexpr | |
function | create static nodiscard | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
function | paddingBytes static inline nodiscard constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline nodiscard constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static nodiscard | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
AddressAttribute | ||
AddressAttribute | Copy constructor; duplicates the stored address. | |
std::unique_ptr< Attribute > | clone virtual override | Returns a deep copy of this attribute. |
stun::AddressFamily | family const inline nodiscard | |
net::Address | address virtual const nodiscard | |
void | read virtual override | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const override | Writes the body (not the type or size) to the given buffer. |
void | setAddress virtual inline | Sets the address to encode into this attribute. |
bool | isXorType const inline nodiscard |
{#addressattribute-1}
AddressAttribute
AddressAttribute(uint16_t type, bool ipv4 = true)
Defined in src/stun/include/icy/stun/attributes.h:169
Parameters
-
typeWire type code (e.g. XorMappedAddress::TypeID). -
ipv4When 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
readerSource 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
writerDestination 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
addrAddress 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
| Return | Name | Description |
|---|---|---|
uint16_t | IPv4Size static constexpr | |
uint16_t | IPv6Size 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
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
clone | function | Declared here |
read | function | Declared here |
write | function | Declared here |
type | function | Declared here |
size | function | Declared here |
paddingBytes | function | Declared here |
paddedBytes | function | Declared here |
consumePadding | function | Declared here |
writePadding | function | Declared here |
typeString | function | Declared here |
TypeID | variable | Declared here |
create | function | Declared here |
paddingBytes | function | Declared here |
paddedBytes | function | Declared here |
typeString | function | Declared here |
_type | variable | Declared here |
_size | variable | Declared here |
Attribute | function | Declared here |
setLength | function | Declared here |
Type | enum | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
std::unique_ptr< Attribute > | clone virtual | Returns a deep copy of this attribute. |
void | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const | Writes the body (not the type or size) to the given buffer. |
uint16_t | type const nodiscard | |
uint16_t | size const nodiscard | |
uint16_t | paddingBytes const inline nodiscard | |
uint16_t | paddedBytes const inline nodiscard | |
void | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
void | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
std::string | typeString 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
readerSource 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
writerDestination 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
readerReader 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
writerWriter 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
| Return | Name | Description |
|---|---|---|
uint16_t | TypeID static constexpr |
{#typeid}
TypeID
static constexpr
uint16_t TypeID = 0
Defined in src/stun/include/icy/stun/attributes.h:138
Public Static Methods
| Return | Name | Description |
|---|---|---|
std::unique_ptr< Attribute > | create static nodiscard | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
uint16_t | paddingBytes static inline nodiscard constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
uint16_t | paddedBytes static inline nodiscard constexpr | Returns the body length including 4-byte alignment padding. |
std::string | typeString 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
-
typeWire type code (one of Attribute::Type). -
sizeBody 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
typeWire type code.
Returns
Human-readable name for the given type code.
Protected Attributes
| Return | Name | Description |
|---|---|---|
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
| Return | Name | Description |
|---|---|---|
Attribute | ||
void | setLength | Updates 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
-
typeWire type code for this attribute. -
sizeInitial 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
sizeNew body length in bytes.
Public Types
| Name | Description |
|---|---|
Type |
{#type-15}
Type
enum Type
Defined in src/stun/include/icy/stun/attributes.h:37
| Value | Description |
|---|---|
NotExist | |
MappedAddress | |
ResponseAddress | |
ChangeRequest | |
SourceAddress | |
ChangedAddress | |
Username | |
Password | |
MessageIntegrity | |
ErrorCode | |
Bandwidth | |
DestinationAddress | |
UnknownAttributes | |
ReflectedFrom | |
MagicCookie | |
Realm | |
Nonce | |
XorMappedAddress | |
Software | |
Options | |
AlternateServer | |
Fingerprint | |
ChannelNumber | TURN. |
Lifetime | |
XorPeerAddress | |
Data | |
XorRelayedAddress | |
EventPort | |
RequestedTransport | |
DontFragment | |
ReservationToken | 0x0021: Reserved (was TIMER-VAL) |
ConnectionID | TURN TCP. |
ICEControlled | ICE. |
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
| Name | Kind | Owner |
|---|---|---|
ErrorCode | function | Declared here |
ErrorCode | function | Declared here |
clone | function | Declared here |
setErrorCode | function | Declared here |
setReason | function | Declared here |
errorCode | function | Declared here |
errorClass | function | Declared here |
errorNumber | function | Declared here |
reason | function | Declared here |
read | function | Declared here |
write | function | Declared here |
TypeID | variable | Declared here |
MinSize | variable | Declared here |
_class | variable | Declared here |
_number | variable | Declared here |
_reason | variable | Declared here |
clone | function | Inherited from Attribute |
read | function | Inherited from Attribute |
write | function | Inherited from Attribute |
type | function | Inherited from Attribute |
size | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
consumePadding | function | Inherited from Attribute |
writePadding | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
TypeID | variable | Inherited from Attribute |
create | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
_type | variable | Inherited from Attribute |
_size | variable | Inherited from Attribute |
Attribute | function | Inherited from Attribute |
setLength | function | Inherited from Attribute |
Type | enum | Inherited from Attribute |
Inherited from Attribute
| Kind | Name | Description |
|---|---|---|
function | clone virtual | Returns a deep copy of this attribute. |
function | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
function | write virtual const | Writes the body (not the type or size) to the given buffer. |
function | type const nodiscard | |
function | size const nodiscard | |
function | paddingBytes const inline nodiscard | |
function | paddedBytes const inline nodiscard | |
function | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
function | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
function | typeString nodiscard | |
variable | TypeID static constexpr | |
function | create static nodiscard | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
function | paddingBytes static inline nodiscard constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline nodiscard constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static nodiscard | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
ErrorCode | ||
ErrorCode | Copy constructor. | |
std::unique_ptr< Attribute > | clone virtual override | Returns a deep copy of this attribute. |
void | setErrorCode | Sets the error code, splitting it into class and number fields. |
void | setReason | Sets the UTF-8 reason phrase and updates the attribute size. |
int | errorCode const nodiscard | |
uint8_t | errorClass const inline nodiscard | |
uint8_t | errorNumber const inline nodiscard | |
const std::string & | reason const inline nodiscard | |
void | read virtual override | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const override | Writes 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
sizeInitial 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
code3-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
reasonHuman-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
readerSource 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
writerDestination bit writer.
Reimplements
Public Static Attributes
| Return | Name | Description |
|---|---|---|
uint16_t | TypeID static constexpr | |
uint16_t | MinSize static constexpr | 4 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
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
FlagAttribute | function | Declared here |
clone | function | Declared here |
read | function | Declared here |
write | function | Declared here |
Size | variable | Declared here |
clone | function | Inherited from Attribute |
read | function | Inherited from Attribute |
write | function | Inherited from Attribute |
type | function | Inherited from Attribute |
size | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
consumePadding | function | Inherited from Attribute |
writePadding | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
TypeID | variable | Inherited from Attribute |
create | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
_type | variable | Inherited from Attribute |
_size | variable | Inherited from Attribute |
Attribute | function | Inherited from Attribute |
setLength | function | Inherited from Attribute |
Type | enum | Inherited from Attribute |
Inherited from Attribute
| Kind | Name | Description |
|---|---|---|
function | clone virtual | Returns a deep copy of this attribute. |
function | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
function | write virtual const | Writes the body (not the type or size) to the given buffer. |
function | type const nodiscard | |
function | size const nodiscard | |
function | paddingBytes const inline nodiscard | |
function | paddedBytes const inline nodiscard | |
function | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
function | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
function | typeString nodiscard | |
variable | TypeID static constexpr | |
function | create static nodiscard | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
function | paddingBytes static inline nodiscard constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline nodiscard constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static nodiscard | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
FlagAttribute | ||
std::unique_ptr< Attribute > | clone virtual override | Returns a deep copy of this attribute. |
void | read virtual inline override | No-op: flag attributes carry no body bytes. |
void | write virtual const inline override | No-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
typeWire 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
| Return | Name | Description |
|---|---|---|
uint16_t | Size 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
STUN/TURN protocol message with method, class, transaction ID, and attributes.
List of all members
| Name | Kind | Owner |
|---|---|---|
Message | function | Declared here |
Message | function | Declared here |
Message | function | Declared here |
Message | function | Declared here |
operator= | function | Declared here |
operator= | function | Declared here |
clone | function | Declared here |
setClass | function | Declared here |
setMethod | function | Declared here |
setTransactionID | function | Declared here |
classType | function | Declared here |
methodType | function | Declared here |
transactionID | function | Declared here |
size | function | Declared here |
methodString | function | Declared here |
classString | function | Declared here |
errorString | function | Declared here |
add | function | Declared here |
add | function | Declared here |
get | function | Declared here |
get | function | Declared here |
read | function | Declared here |
write | function | Declared here |
toString | function | Declared here |
print | function | Declared here |
className | function | Declared here |
_class | variable | Declared here |
_method | variable | Declared here |
_size | variable | Declared here |
_transactionID | variable | Declared here |
_attrs | variable | Declared here |
MethodType | enum | Declared here |
ClassType | enum | Declared here |
ErrorCodes | enum | Declared here |
computeBodySize | function | Declared here |
opaque | variable | Inherited from IPacket |
info | variable | Inherited from IPacket |
flags | variable | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
operator= | function | Inherited from IPacket |
clone | function | Inherited from IPacket |
~IPacket | function | Inherited from IPacket |
read | function | Inherited from IPacket |
write | function | Inherited from IPacket |
size | function | Inherited from IPacket |
hasData | function | Inherited from IPacket |
data | function | Inherited from IPacket |
constData | function | Inherited from IPacket |
className | function | Inherited from IPacket |
print | function | Inherited from IPacket |
operator<< | friend | Inherited from IPacket |
Inherited from IPacket
| Kind | Name | Description |
|---|---|---|
variable | opaque | Optional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime. |
variable | info | Optional extra information about the packet. |
variable | flags | Provides basic information about the packet. |
function | IPacket inline | |
function | IPacket inline | Copy constructor; clones the info object if present. |
function | operator= inline | Copy assignment; clones the info object if present. |
function | clone virtual const | Returns a heap-allocated deep copy of this packet. |
function | ~IPacket virtual | Defaulted destructor. |
function | read virtual | Read/parse to the packet from the given input buffer. The number of bytes read is returned. |
function | write virtual const | Copy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer. |
function | size virtual const inline | The size of the packet in bytes. |
function | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
function | data virtual const inline | The packet data pointer for buffered packets. |
function | constData virtual const inline | The const packet data pointer for buffered packets. |
function | className virtual const | Returns the class name of this packet type for logging and diagnostics. |
function | print virtual const inline | Prints a human-readable representation to the given stream. |
friend | operator<< inline | Stream insertion operator; delegates to print(). |
Public Methods
| Return | Name | Description |
|---|---|---|
Message | Constructs a default message (Request class, Undefined method) with a randomly generated 12-byte transaction ID. | |
Message | Constructs a message with explicit class and method. | |
Message | Deep-copy constructor; clones all attributes. | |
Message noexcept | Move constructor. | |
Message & | operator= | Deep-copy assignment; clones all attributes from that. |
Message & | operator= noexcept | Move assignment. |
std::unique_ptr< IPacket > | clone virtual const override | |
void | setClass | Sets the message class field. |
void | setMethod | Sets the message method field. |
void | setTransactionID | Sets the 12-byte transaction ID. |
ClassType | classType const nodiscard | |
MethodType | methodType const nodiscard | |
const TransactionID & | transactionID const inline nodiscard | |
size_t | size virtual const inline nodiscard override | |
std::string | methodString const nodiscard | |
std::string | classString const nodiscard | |
std::string | errorString const nodiscard | Maps a numeric error code to its canonical string description. |
T & | add inline | Constructs an attribute of type T in-place and appends it to the message. Returns a reference to the new attribute for further configuration. |
void | add | Appends an attribute to the message, taking ownership via unique_ptr. |
Attribute * | get const nodiscard | Returns the Nth attribute of the given type, or nullptr if not found. |
T * | get const inline nodiscard | Type-safe attribute accessor using the concrete attribute's TypeID. |
ssize_t | read virtual override | Parses a STUN/TURN packet from the given buffer. |
void | write virtual const override | Serialises this message into a STUN/TURN wire-format packet. |
std::string | toString const nodiscard | |
void | print virtual const override | Writes the same representation as toString() to the given stream. |
const char * | className virtual const inline override | Returns 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
-
clssMessage class (Request, Indication, SuccessResponse, or ErrorResponse). -
methMessage 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
typeOne 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
typeOne of the MethodType enumerators.
{#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
idMust 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
errorCodeOne of the ErrorCodes enumerators.
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
TConcrete 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
attrAttribute to add.
{#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
-
typeAttribute type code to search for. -
indexZero-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
TConcrete attribute type (must define TypeID).
Parameters
indexZero-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
bufBuffer 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
bufDestination 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}
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
osOutput 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
| Return | Name | Description |
|---|---|---|
uint16_t | _class | |
uint16_t | _method | |
uint16_t | _size | Set 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
| Name | Description |
|---|---|
MethodType | |
ClassType | |
ErrorCodes |
{#methodtype-1}
MethodType
enum MethodType
Defined in src/stun/include/icy/stun/message.h:34
| Value | Description |
|---|---|
Undefined | default error type |
Binding | STUN. |
Allocate | TURN. |
Refresh | |
SendIndication | (only indication semantics defined) |
DataIndication | (only indication semantics defined) |
CreatePermission | (only request/response semantics defined) |
ChannelBind | (only request/response semantics defined) |
Connect | TURN TCP RFC 6062. |
ConnectionBind | |
ConnectionAttempt |
{#classtype-1}
ClassType
enum ClassType
Defined in src/stun/include/icy/stun/message.h:55
| Value | Description |
|---|---|
Request | |
Indication | |
SuccessResponse | |
ErrorResponse |
{#errorcodes}
ErrorCodes
enum ErrorCodes
Defined in src/stun/include/icy/stun/message.h:63
| Value | Description |
|---|---|
TryAlternate | |
BadRequest | |
NotAuthorized | |
Forbidden | |
UnknownAttribute | |
StaleCredentials | |
IntegrityCheckFailure | |
MissingUsername | |
UseTLS | |
AllocationMismatch | |
StaleNonce | |
WrongCredentials | |
UnsupportedTransport | |
AllocationQuotaReached | |
RoleConflict | |
ServerError | |
InsufficientCapacity | |
GlobalFailure | |
ConnectionAlreadyExists | TURN TCP. |
ConnectionTimeoutOrFailure |
Private Methods
| Return | Name | Description |
|---|---|---|
uint16_t | computeBodySize const nodiscard | Computes 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
| Name | Kind | Owner |
|---|---|---|
MessageIntegrity | function | Declared here |
MessageIntegrity | function | Declared here |
clone | function | Declared here |
verifyHmac | function | Declared here |
input | function | Declared here |
hmac | function | Declared here |
key | function | Declared here |
setInput | function | Declared here |
setHmac | function | Declared here |
setKey | function | Declared here |
read | function | Declared here |
write | function | Declared here |
TypeID | variable | Declared here |
Size | variable | Declared here |
_input | variable | Declared here |
_hmac | variable | Declared here |
_key | variable | Declared here |
clone | function | Inherited from Attribute |
read | function | Inherited from Attribute |
write | function | Inherited from Attribute |
type | function | Inherited from Attribute |
size | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
consumePadding | function | Inherited from Attribute |
writePadding | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
TypeID | variable | Inherited from Attribute |
create | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
_type | variable | Inherited from Attribute |
_size | variable | Inherited from Attribute |
Attribute | function | Inherited from Attribute |
setLength | function | Inherited from Attribute |
Type | enum | Inherited from Attribute |
Inherited from Attribute
| Kind | Name | Description |
|---|---|---|
function | clone virtual | Returns a deep copy of this attribute. |
function | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
function | write virtual const | Writes the body (not the type or size) to the given buffer. |
function | type const nodiscard | |
function | size const nodiscard | |
function | paddingBytes const inline nodiscard | |
function | paddedBytes const inline nodiscard | |
function | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
function | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
function | typeString nodiscard | |
variable | TypeID static constexpr | |
function | create static nodiscard | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
function | paddingBytes static inline nodiscard constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline nodiscard constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static nodiscard | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
MessageIntegrity | ||
MessageIntegrity | ||
std::unique_ptr< Attribute > | clone virtual override | Returns a deep copy of this attribute. |
bool | verifyHmac const nodiscard | Verifies the stored HMAC against the stored input bytes using key. |
std::string | input const inline nodiscard | |
std::string | hmac const inline nodiscard | |
std::string | key const inline nodiscard | |
void | setInput inline | Sets the raw message bytes used as HMAC input during verification. |
void | setHmac inline | Sets the raw HMAC value (used when copying a received attribute). |
void | setKey inline | Sets the HMAC key; triggers HMAC computation on write(). |
void | read virtual override | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const override | Writes 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
keyHMAC 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
inputByte 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
hmac20-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
keyMD5 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
readerSource 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
writerDestination bit writer.
Reimplements
Public Static Attributes
| Return | Name | Description |
|---|---|---|
uint16_t | TypeID static constexpr | |
uint16_t | Size static constexpr | HMAC-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
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
StringAttribute | function | Declared here |
StringAttribute | function | Declared here |
clone | function | Declared here |
bytes | function | Declared here |
setBytes | function | Declared here |
asString | function | Declared here |
copyBytes | function | Declared here |
copyBytes | function | Declared here |
getByte | function | Declared here |
setByte | function | Declared here |
read | function | Declared here |
write | function | Declared here |
_bytes | variable | Declared here |
clone | function | Inherited from Attribute |
read | function | Inherited from Attribute |
write | function | Inherited from Attribute |
type | function | Inherited from Attribute |
size | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
consumePadding | function | Inherited from Attribute |
writePadding | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
TypeID | variable | Inherited from Attribute |
create | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
_type | variable | Inherited from Attribute |
_size | variable | Inherited from Attribute |
Attribute | function | Inherited from Attribute |
setLength | function | Inherited from Attribute |
Type | enum | Inherited from Attribute |
Inherited from Attribute
| Kind | Name | Description |
|---|---|---|
function | clone virtual | Returns a deep copy of this attribute. |
function | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
function | write virtual const | Writes the body (not the type or size) to the given buffer. |
function | type const nodiscard | |
function | size const nodiscard | |
function | paddingBytes const inline nodiscard | |
function | paddedBytes const inline nodiscard | |
function | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
function | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
function | typeString nodiscard | |
variable | TypeID static constexpr | |
function | create static nodiscard | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
function | paddingBytes static inline nodiscard constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline nodiscard constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static nodiscard | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
StringAttribute | ||
StringAttribute | Copy constructor; duplicates stored bytes. | |
std::unique_ptr< Attribute > | clone virtual override | Returns a deep copy of this attribute. |
const char * | bytes const inline nodiscard | |
void | setBytes | Replaces the stored bytes with a copy of the given buffer and updates the attribute's reported size. |
std::string | asString const nodiscard | |
void | copyBytes | Copies a null-terminated string into the attribute, using strlen to determine the length. |
void | copyBytes | Copies an arbitrary block of memory into the attribute. |
uint8_t | getByte const nodiscard | Returns a single byte from the stored buffer. |
void | setByte | Overwrites a single byte in the stored buffer. |
void | read virtual override | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const override | Writes 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
-
typeWire type code for the concrete attribute. -
sizeInitial 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
-
bytesSource data pointer. -
sizeNumber 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
bytesNull-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
-
bytesSource data pointer. -
sizeNumber 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
indexZero-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
-
indexZero-based byte offset. -
valueNew 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
readerSource 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
writerDestination bit writer.
Reimplements
Private Attributes
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
IntrusivePtr | friend | Declared here |
Transaction | function | Declared here |
checkResponse | function | Declared here |
onResponse | function | Declared here |
Ptr | typedef | Declared here |
IntrusivePtr | friend | Inherited from Transaction |
Transaction | function | Inherited from Transaction |
send | function | Inherited from Transaction |
cancel | function | Inherited from Transaction |
dispose | function | Inherited from Transaction |
peerAddress | function | Inherited from Transaction |
_peerAddress | variable | Inherited from Transaction |
onPacket | function | Inherited from Transaction |
onResponse | function | Inherited from Transaction |
checkResponse | function | Inherited from Transaction |
BaseT | typedef | Inherited from Transaction |
Ptr | typedef | Inherited from PacketTransaction |
IntrusivePtr | friend | Inherited from PacketTransaction |
_request | variable | Inherited from PacketTransaction |
_response | variable | Inherited from PacketTransaction |
_timer | variable | Inherited from PacketTransaction |
_retries | variable | Inherited from PacketTransaction |
_attempts | variable | Inherited from PacketTransaction |
_disposed | variable | Inherited from PacketTransaction |
PacketTransaction | function | Inherited from PacketTransaction |
PacketTransaction | function | Inherited from PacketTransaction |
send | function | Inherited from PacketTransaction |
cancel | function | Inherited from PacketTransaction |
cancelled | function | Inherited from PacketTransaction |
dispose | function | Inherited from PacketTransaction |
disposed | function | Inherited from PacketTransaction |
canResend | function | Inherited from PacketTransaction |
attempts | function | Inherited from PacketTransaction |
retries | function | Inherited from PacketTransaction |
request | function | Inherited from PacketTransaction |
request | function | Inherited from PacketTransaction |
response | function | Inherited from PacketTransaction |
response | function | Inherited from PacketTransaction |
~PacketTransaction | function | Inherited from PacketTransaction |
onStateChange | function | Inherited from PacketTransaction |
handlePotentialResponse | function | Inherited from PacketTransaction |
checkResponse | function | Inherited from PacketTransaction |
onResponse | function | Inherited from PacketTransaction |
onTimeout | function | Inherited from PacketTransaction |
send | function | Inherited from Sendable |
cancel | function | Inherited from Sendable |
StateChange | variable | Inherited from Stateful |
_state | variable | Inherited from Stateful |
Stateful | function | Inherited from Stateful |
~Stateful | function | Inherited from Stateful |
stateEquals | function | Inherited from Stateful |
stateBetween | function | Inherited from Stateful |
state | function | Inherited from Stateful |
state | function | Inherited from Stateful |
beforeStateChange | function | Inherited from Stateful |
onStateChange | function | Inherited from Stateful |
setState | function | Inherited from Stateful |
setState | function | Inherited from Stateful |
_refCount | variable | Inherited from RefCounted |
RefCounted | function | Inherited from RefCounted |
RefCounted | function | Inherited from RefCounted |
operator= | function | Inherited from RefCounted |
addRef | function | Inherited from RefCounted |
releaseRef | function | Inherited from RefCounted |
refCount | function | Inherited from RefCounted |
~RefCounted | function | Inherited from RefCounted |
factory | variable | Inherited from PacketSocketEmitter |
PacketSocketEmitter | function | Inherited from PacketSocketEmitter |
onSocketRecv | function | Inherited from PacketSocketEmitter |
onPacket | function | Inherited from PacketSocketEmitter |
Connect | variable | Inherited from SocketEmitter |
Recv | variable | Inherited from SocketEmitter |
Error | variable | Inherited from SocketEmitter |
Close | variable | Inherited from SocketEmitter |
impl | variable | Inherited from SocketEmitter |
SocketEmitter | function | Inherited from SocketEmitter |
SocketEmitter | function | Inherited from SocketEmitter |
~SocketEmitter | function | Inherited from SocketEmitter |
addReceiver | function | Inherited from SocketEmitter |
removeReceiver | function | Inherited from SocketEmitter |
swap | function | Inherited from SocketEmitter |
as | function | Inherited from SocketEmitter |
operator-> | function | Inherited from SocketEmitter |
onSocketConnect | function | Inherited from SocketEmitter |
onSocketRecv | function | Inherited from SocketEmitter |
onSocketError | function | Inherited from SocketEmitter |
onSocketClose | function | Inherited from SocketEmitter |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from Transaction
| Kind | Name | Description |
|---|---|---|
friend | IntrusivePtr | |
function | Transaction inline | Constructs a Transaction on the given socket targeting peerAddress. |
function | send virtual inline override | Sends 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. |
function | cancel virtual inline override | Cancels the transaction and stops the timeout timer. |
function | dispose virtual inline override | Stops the timer and unregisters callbacks. |
function | peerAddress const inline | Returns the remote peer address used for this transaction. |
variable | _peerAddress | |
function | onPacket virtual inline override | Checks whether packet is a matching response for the pending request. If it matches, the transaction completes; socket data propagation stops. |
function | onResponse virtual inline override | Called when a confirmed response is received; emits the response via PacketSignal. |
function | checkResponse virtual inline override | Returns true if packet is a valid response for this transaction. |
typedef | BaseT |
Inherited from PacketTransaction
| Kind | Name | Description |
|---|---|---|
typedef | Ptr | |
friend | IntrusivePtr | |
variable | _request | |
variable | _response | |
variable | _timer | The request timeout callback. |
variable | _retries | The maximum number of attempts before the transaction is considered failed. |
variable | _attempts | The number of times the transaction has been sent. |
variable | _disposed | |
function | PacketTransaction inline | |
function | PacketTransaction inline | |
function | send virtual inline override | Starts the transaction timer and sends the request. Overriding classes should implement send logic here. |
function | cancel virtual inline override | Cancellation 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. |
function | cancelled const inline | |
function | dispose virtual inline | Stops 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. |
function | disposed const inline nodiscard | |
function | canResend virtual inline | |
function | attempts const inline | |
function | retries const inline | |
function | request inline | |
function | request const inline | |
function | response inline | |
function | response const inline | |
function | ~PacketTransaction virtual inline | |
function | onStateChange virtual inline override | Post state change hook. Calls dispose() on terminal states to stop the timer, but does not delete the object; IntrusivePtr handles that. |
function | handlePotentialResponse virtual inline | Processes a potential response candidate and updates the state accordingly. |
function | checkResponse virtual | Checks a potential response candidate and returns true on successful match. |
function | onResponse virtual inline | Called when a successful response is received. |
function | onTimeout virtual inline | Called by the timer when the transaction timeout elapses. Retransmits if retries remain, otherwise transitions to Failed. |
Inherited from Sendable
| Kind | Name | Description |
|---|---|---|
function | send virtual | Initiates the send operation. |
function | cancel virtual | Cancels a pending send operation. |
Inherited from Stateful
| Kind | Name | Description |
|---|---|---|
variable | StateChange | Signals when the state changes. |
variable | _state | |
function | Stateful inline | |
function | ~Stateful virtual inline | |
function | stateEquals virtual const inline | Returns true if the current state ID equals the given ID. |
function | stateBetween virtual const inline | Returns true if the current state ID is in the inclusive range [lid, rid]. |
function | state virtual inline | Returns a mutable reference to the current state. |
function | state virtual const inline | Returns a copy of the current state. |
function | beforeStateChange virtual inline | Override to handle pre state change logic. Return false to prevent state change. |
function | onStateChange virtual inline | Override to handle post state change logic. |
function | setState virtual inline | Sets the state and sends the state signal if the state change was successful. |
function | setState virtual inline | Sets the state and sends the state signal if the state change was successful. |
Inherited from RefCounted
| Kind | Name | Description |
|---|---|---|
variable | _refCount | |
function | RefCounted | Defaulted constructor. |
function | RefCounted inline noexcept | |
function | operator= inline noexcept | |
function | addRef const inline noexcept | Increments the reference count. Called by IntrusivePtr on acquisition. |
function | releaseRef const inline noexcept | Decrements the reference count. |
function | refCount const inline nodiscard noexcept | Returns the current reference count. |
function | ~RefCounted | Defaulted destructor. |
Inherited from PacketSocketEmitter
| Kind | Name | Description |
|---|---|---|
variable | factory | The packet factory. |
function | PacketSocketEmitter | Creates the PacketSocketEmitter and attaches it to the given socket. |
function | onSocketRecv virtual override | Parses raw received data into packets via the factory and forwards each parsed packet to onPacket(). Returns true if propagation should stop. |
function | onPacket virtual | Process a parsed packet. Returns true to stop propagation. |
Inherited from SocketEmitter
| Kind | Name | Description |
|---|---|---|
variable | Connect | Signals that the socket is connected. |
variable | Recv | Signals when data is received by the socket. |
variable | Error | Signals that the socket is closed in error. This signal will be sent just before the Closed signal. |
variable | Close | Signals that the underlying socket is closed. |
variable | impl | Pointer to the underlying socket. Sent data will be proxied to this socket. |
function | SocketEmitter | Creates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver. |
function | SocketEmitter | Copy constructor; copies all signal connections and attaches to the same socket. |
function | ~SocketEmitter virtual noexcept | Destroys the SocketAdapter. |
function | addReceiver virtual override | Attaches a SocketAdapter as a receiver; wires it to all four socket signals. |
function | removeReceiver virtual override | Detaches a SocketAdapter from all four socket signals. |
function | swap virtual | Replaces the underlying socket with socket. |
function | as inline | Returns the underlying socket cast to type T, or nullptr if the cast fails. |
function | operator-> const inline | Returns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer. |
function | onSocketConnect virtual override | Forwards the connect event to chained adapters, then fires the Connect signal. |
function | onSocketRecv virtual override | Forwards the recv event to chained adapters, then fires the Recv signal. |
function | onSocketError virtual override | Forwards the error event to chained adapters, then fires the Error signal. |
function | onSocketClose virtual override | Forwards the close event to chained adapters, then fires the Close signal. |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends 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. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends 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. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends 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. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called 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. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Friends
| Name | Description |
|---|---|
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
| Return | Name | Description |
|---|---|---|
Transaction | Constructs a STUN transaction bound to a specific socket and peer. | |
bool | checkResponse override | Checks that message is a valid response for the pending request. In addition to the base class check, verifies that the transaction IDs match. |
void | onResponse virtual override | 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. |
{#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
-
socketSocket used to send the request and receive the response. -
peerAddressRemote address of the STUN/TURN server. -
timeoutResponse timeout in milliseconds (default 10 s). -
retriesNumber 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
messageIncoming 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
| Name | Description |
|---|---|
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
| Name | Kind | Owner |
|---|---|---|
UInt16ListAttribute | function | Declared here |
UInt16ListAttribute | function | Declared here |
clone | function | Declared here |
size | function | Declared here |
getType | function | Declared here |
setType | function | Declared here |
addType | function | Declared here |
read | function | Declared here |
write | function | Declared here |
_attrTypes | variable | Declared here |
clone | function | Inherited from Attribute |
read | function | Inherited from Attribute |
write | function | Inherited from Attribute |
type | function | Inherited from Attribute |
size | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
consumePadding | function | Inherited from Attribute |
writePadding | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
TypeID | variable | Inherited from Attribute |
create | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
_type | variable | Inherited from Attribute |
_size | variable | Inherited from Attribute |
Attribute | function | Inherited from Attribute |
setLength | function | Inherited from Attribute |
Type | enum | Inherited from Attribute |
Inherited from Attribute
| Kind | Name | Description |
|---|---|---|
function | clone virtual | Returns a deep copy of this attribute. |
function | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
function | write virtual const | Writes the body (not the type or size) to the given buffer. |
function | type const nodiscard | |
function | size const nodiscard | |
function | paddingBytes const inline nodiscard | |
function | paddedBytes const inline nodiscard | |
function | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
function | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
function | typeString nodiscard | |
variable | TypeID static constexpr | |
function | create static nodiscard | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
function | paddingBytes static inline nodiscard constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline nodiscard constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static nodiscard | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
UInt16ListAttribute | ||
UInt16ListAttribute | Copy constructor; duplicates the type list. | |
std::unique_ptr< Attribute > | clone virtual override | Returns a deep copy of this attribute. |
size_t | size const nodiscard | |
uint16_t | getType const nodiscard | Returns the type code at the given list position. |
void | setType | Overwrites the type code at the given list position. |
void | addType | Appends a type code to the list and updates the attribute size. |
void | read virtual override | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const override | Writes 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
-
typeWire type code for the concrete attribute. -
sizeInitial 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
indexZero-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
-
indexZero-based list index. -
valueNew 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
valueAttribute type code to append.
{#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
readerSource 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
writerDestination bit writer.
Reimplements
Private Attributes
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
UInt32Attribute | function | Declared here |
UInt32Attribute | function | Declared here |
clone | function | Declared here |
value | function | Declared here |
setValue | function | Declared here |
getBit | function | Declared here |
setBit | function | Declared here |
read | function | Declared here |
write | function | Declared here |
Size | variable | Declared here |
_bits | variable | Declared here |
clone | function | Inherited from Attribute |
read | function | Inherited from Attribute |
write | function | Inherited from Attribute |
type | function | Inherited from Attribute |
size | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
consumePadding | function | Inherited from Attribute |
writePadding | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
TypeID | variable | Inherited from Attribute |
create | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
_type | variable | Inherited from Attribute |
_size | variable | Inherited from Attribute |
Attribute | function | Inherited from Attribute |
setLength | function | Inherited from Attribute |
Type | enum | Inherited from Attribute |
Inherited from Attribute
| Kind | Name | Description |
|---|---|---|
function | clone virtual | Returns a deep copy of this attribute. |
function | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
function | write virtual const | Writes the body (not the type or size) to the given buffer. |
function | type const nodiscard | |
function | size const nodiscard | |
function | paddingBytes const inline nodiscard | |
function | paddedBytes const inline nodiscard | |
function | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
function | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
function | typeString nodiscard | |
variable | TypeID static constexpr | |
function | create static nodiscard | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
function | paddingBytes static inline nodiscard constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline nodiscard constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static nodiscard | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
UInt32Attribute | ||
UInt32Attribute | Copy constructor. | |
std::unique_ptr< Attribute > | clone virtual override | Returns a deep copy of this attribute. |
uint32_t | value const inline nodiscard | |
void | setValue inline | Sets the stored 32-bit value. |
bool | getBit const nodiscard | Returns the state of a single bit within the stored word. |
void | setBit | Sets or clears a single bit within the stored word. |
void | read virtual override | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const override | Writes 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
typeWire 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
bitsValue 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
indexBit 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
-
indexBit position (0 = LSB, 31 = MSB). -
valuetrue 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
readerSource 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
writerDestination bit writer.
Reimplements
Public Static Attributes
| Return | Name | Description |
|---|---|---|
uint16_t | Size static constexpr |
{#size-9}
Size
static constexpr
uint16_t Size = 4
Defined in src/stun/include/icy/stun/attributes.h:281
Private Attributes
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
UInt64Attribute | function | Declared here |
UInt64Attribute | function | Declared here |
clone | function | Declared here |
value | function | Declared here |
setValue | function | Declared here |
getBit | function | Declared here |
setBit | function | Declared here |
read | function | Declared here |
write | function | Declared here |
Size | variable | Declared here |
_bits | variable | Declared here |
clone | function | Inherited from Attribute |
read | function | Inherited from Attribute |
write | function | Inherited from Attribute |
type | function | Inherited from Attribute |
size | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
consumePadding | function | Inherited from Attribute |
writePadding | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
TypeID | variable | Inherited from Attribute |
create | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
_type | variable | Inherited from Attribute |
_size | variable | Inherited from Attribute |
Attribute | function | Inherited from Attribute |
setLength | function | Inherited from Attribute |
Type | enum | Inherited from Attribute |
Inherited from Attribute
| Kind | Name | Description |
|---|---|---|
function | clone virtual | Returns a deep copy of this attribute. |
function | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
function | write virtual const | Writes the body (not the type or size) to the given buffer. |
function | type const nodiscard | |
function | size const nodiscard | |
function | paddingBytes const inline nodiscard | |
function | paddedBytes const inline nodiscard | |
function | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
function | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
function | typeString nodiscard | |
variable | TypeID static constexpr | |
function | create static nodiscard | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
function | paddingBytes static inline nodiscard constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline nodiscard constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static nodiscard | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
UInt64Attribute | ||
UInt64Attribute | Copy constructor. | |
std::unique_ptr< Attribute > | clone virtual override | Returns a deep copy of this attribute. |
uint64_t | value const inline nodiscard | |
void | setValue inline | Sets the stored 64-bit value. |
bool | getBit const nodiscard | Returns the state of a single bit within the stored quad-word. |
void | setBit | Sets or clears a single bit within the stored quad-word. |
void | read virtual override | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const override | Writes 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
typeWire 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
bitsValue 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
indexBit 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
-
indexBit position (0 = LSB, 63 = MSB). -
valuetrue 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
readerSource 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
writerDestination bit writer.
Reimplements
Public Static Attributes
| Return | Name | Description |
|---|---|---|
uint16_t | Size static constexpr |
{#size-10}
Size
static constexpr
uint16_t Size = 8
Defined in src/stun/include/icy/stun/attributes.h:321
Private Attributes
| Return | Name | Description |
|---|---|---|
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
| Name | Kind | Owner |
|---|---|---|
UInt8Attribute | function | Declared here |
UInt8Attribute | function | Declared here |
clone | function | Declared here |
value | function | Declared here |
setValue | function | Declared here |
getBit | function | Declared here |
setBit | function | Declared here |
read | function | Declared here |
write | function | Declared here |
Size | variable | Declared here |
_bits | variable | Declared here |
clone | function | Inherited from Attribute |
read | function | Inherited from Attribute |
write | function | Inherited from Attribute |
type | function | Inherited from Attribute |
size | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
consumePadding | function | Inherited from Attribute |
writePadding | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
TypeID | variable | Inherited from Attribute |
create | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
_type | variable | Inherited from Attribute |
_size | variable | Inherited from Attribute |
Attribute | function | Inherited from Attribute |
setLength | function | Inherited from Attribute |
Type | enum | Inherited from Attribute |
Inherited from Attribute
| Kind | Name | Description |
|---|---|---|
function | clone virtual | Returns a deep copy of this attribute. |
function | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
function | write virtual const | Writes the body (not the type or size) to the given buffer. |
function | type const nodiscard | |
function | size const nodiscard | |
function | paddingBytes const inline nodiscard | |
function | paddedBytes const inline nodiscard | |
function | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
function | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
function | typeString nodiscard | |
variable | TypeID static constexpr | |
function | create static nodiscard | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
function | paddingBytes static inline nodiscard constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline nodiscard constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static nodiscard | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
UInt8Attribute | ||
UInt8Attribute | Copy constructor. | |
std::unique_ptr< Attribute > | clone virtual override | Returns a deep copy of this attribute. |
uint8_t | value const inline nodiscard | |
void | setValue inline | Sets the stored 8-bit value. |
bool | getBit const nodiscard | Returns the state of a single bit within the stored byte. |
void | setBit | Sets or clears a single bit within the stored byte. |
void | read virtual override | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const override | Writes 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
typeWire 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
bitsValue 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
indexBit 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
-
indexBit position (0 = LSB, 7 = MSB). -
valuetrue 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
readerSource 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
writerDestination bit writer.
Reimplements
Public Static Attributes
| Return | Name | Description |
|---|---|---|
uint16_t | Size static constexpr |
{#size-11}
Size
static constexpr
uint16_t Size = 1
Defined in src/stun/include/icy/stun/attributes.h:241
Private Attributes
| Return | Name | Description |
|---|---|---|
uint8_t | _bits |
{#_bits-2}
_bits
uint8_t _bits
Defined in src/stun/include/icy/stun/attributes.h:264