Attribute
Attribute
#include <icy/stun/attributes.h>Subclassed by:
AddressAttribute,ErrorCode,FlagAttribute,MessageIntegrity,StringAttribute,UInt16ListAttribute,UInt32Attribute,UInt64Attribute,UInt8Attribute
The virtual base class for all STUN/TURN attributes.
Public Methods
| Return | Name | Description |
|---|---|---|
std::unique_ptr< Attribute > | clone | Returns a deep copy of this attribute. |
void | read | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write const | Writes the body (not the type or size) to the given buffer. |
uint16_t | type const | #### Returns |
uint16_t | size const | #### Returns |
uint16_t | paddingBytes const inline | #### Returns |
uint16_t | paddedBytes const inline | #### Returns |
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 | #### Returns |
clone
std::unique_ptr< Attribute > clone()Returns a deep copy of this attribute.
read
void read(BitReader & reader)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.
write
const
void write(BitWriter & writer) constWrites the body (not the type or size) to the given buffer.
Parameters
writerDestination bit writer.
type
const
uint16_t type() constReturns
The wire type code for this attribute.
size
const
uint16_t size() constReturns
The body length of this attribute in bytes (before padding).
paddingBytes
const inline
inline uint16_t paddingBytes() constReturns
The 4-byte alignment padding required for this attribute body.
paddedBytes
const inline
inline uint16_t paddedBytes() constReturns
The body length including 4-byte alignment padding.
consumePadding
const
void consumePadding(BitReader & reader) constAdvances the reader past any 4-byte alignment padding that follows this attribute's body.
Parameters
readerReader to advance.
writePadding
const
void writePadding(BitWriter & writer) constWrites zero-fill padding bytes to align this attribute to a 4-byte boundary.
Parameters
writerWriter to append padding to.
typeString
std::string typeString()Returns
Human-readable name for this attribute's type.
Public Static Attributes
| Return | Name | Description |
|---|---|---|
constexpr uint16_t | TypeID static |
TypeID
static
constexpr uint16_t TypeID = 0Public Static Methods
| Return | Name | Description |
|---|---|---|
std::unique_ptr< Attribute > | create static | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
constexpr uint16_t | paddingBytes static inline | Returns the 4-byte alignment padding required for a body of size bytes. |
constexpr uint16_t | paddedBytes static inline | Returns the body length including 4-byte alignment padding. |
std::string | typeString static | #### Parameters |
create
static
static std::unique_ptr< Attribute > create(uint16_t type, uint16_t size)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
static inline
static inline constexpr uint16_t paddingBytes(uint16_t size)Returns the 4-byte alignment padding required for a body of size bytes.
paddedBytes
static inline
static inline constexpr uint16_t paddedBytes(uint16_t size)Returns the body length including 4-byte alignment padding.
typeString
static
static std::string typeString(uint16_t type)Parameters
typeWire type code.
Returns
Human-readable name for the given type code.
Protected Attributes
_type
uint16_t _type_size
uint16_t _sizeProtected Methods
Attribute
Attribute(uint16_t type, uint16_t size)Parameters
typeWire type code for this attribute.sizeInitial body length in bytes.
setLength
void setLength(uint16_t size)Updates the stored body length.
Parameters
sizeNew body length in bytes.
Public Types
| Name | Description |
|---|---|
Type |
Type
enum Type| 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 |
