Attribute
Attribute
#include <icy/stun/attributes.h>class AttributeDefined 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 |
|---|---|---|
~Attribute | function | Declared here |
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 | |
uint16_t | size const | |
uint16_t | paddingBytes const inline | |
uint16_t | paddedBytes const inline | |
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 |
clone
virtual
virtual std::unique_ptr< Attribute > clone()Defined in src/stun/include/icy/stun/attributes.h:86
Returns a deep copy of this attribute.
Reimplemented by
read
virtual
virtual void read(BitReader & reader)Defined in src/stun/include/icy/stun/attributes.h:91
Reads the body (not the type or size) for this type of attribute from the given buffer.
Parameters
readerSource bit reader positioned at the attribute body.
Reimplemented by
write
virtual const
virtual void write(BitWriter & writer) constDefined 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
const
uint16_t type() constDefined in src/stun/include/icy/stun/attributes.h:105
Returns
The wire type code for this attribute.
size
const
uint16_t size() constDefined in src/stun/include/icy/stun/attributes.h:108
Returns
The body length of this attribute in bytes (before padding).
paddingBytes
const inline
inline uint16_t paddingBytes() constDefined in src/stun/include/icy/stun/attributes.h:123
Returns
The 4-byte alignment padding required for this attribute body.
paddedBytes
const inline
inline uint16_t paddedBytes() constDefined in src/stun/include/icy/stun/attributes.h:126
Returns
The body length including 4-byte alignment padding.
consumePadding
const
void consumePadding(BitReader & reader) constDefined 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
const
void writePadding(BitWriter & writer) constDefined 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
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 |
|---|---|---|
constexpr uint16_t | TypeID static constexpr |
TypeID
static constexpr
constexpr uint16_t TypeID = 0Defined in src/stun/include/icy/stun/attributes.h:138
Public 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 constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
constexpr uint16_t | paddedBytes static inline constexpr | Returns the body length including 4-byte alignment padding. |
std::string | typeString static |
create
static
static std::unique_ptr< Attribute > create(uint16_t type, uint16_t size = 0)Defined in src/stun/include/icy/stun/attributes.h:102
Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid.
Parameters
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 constexpr
constexpr static inline constexpr uint16_t paddingBytes(uint16_t size)Defined in src/stun/include/icy/stun/attributes.h:111
Returns the 4-byte alignment padding required for a body of size bytes.
paddedBytes
static inline constexpr
constexpr static inline constexpr uint16_t paddedBytes(uint16_t size)Defined in src/stun/include/icy/stun/attributes.h:117
Returns the body length including 4-byte alignment padding.
typeString
static
static std::string typeString(uint16_t type)Defined in src/stun/include/icy/stun/attributes.h:145
Parameters
typeWire type code.
Returns
Human-readable name for the given type code.
Protected Attributes
_type
uint16_t _typeDefined in src/stun/include/icy/stun/attributes.h:156
_size
uint16_t _sizeDefined in src/stun/include/icy/stun/attributes.h:157
Protected Methods
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
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
enum TypeDefined 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 |
