#include <icy/stun/attributes.h>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.
| Return | Name | Description |
|---|---|---|
ErrorCode | #### Parameters | |
ErrorCode | Copy constructor. | |
std::unique_ptr< Attribute > | clone virtual | 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 | #### Returns |
uint8_t | errorClass const inline | #### Returns |
uint8_t | errorNumber const inline | #### Returns |
const std::string & | reason const inline | #### Returns |
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. |
ErrorCode(uint16_t size)size Initial body length in bytes (must be >= MinSize).ErrorCode(const ErrorCode & r)Copy constructor.
virtual
virtual std::unique_ptr< Attribute > clone()Returns a deep copy of this attribute.
void setErrorCode(int code)Sets the error code, splitting it into class and number fields.
code 3-digit error code (e.g. 401, 438).void setReason(const std::string & reason)Sets the UTF-8 reason phrase and updates the attribute size.
reason Human-readable error description.const
int errorCode() constThe full 3-digit error code (class * 100 + number).
const inline
inline uint8_t errorClass() constThe hundreds digit of the error code (e.g. 4 for a 4xx error).
const inline
inline uint8_t errorNumber() constThe tens+units portion of the error code (0-99).
const inline
inline const std::string & reason() constThe reason phrase string (may be empty).
virtual
virtual void read(BitReader & reader)Reads the body (not the type or size) for this type of attribute from the given buffer.
reader Source bit reader positioned at the attribute body.virtual const
virtual void write(BitWriter & writer) constWrites the body (not the type or size) to the given buffer.
writer Destination bit writer.| Return | Name | Description |
|---|---|---|
constexpr uint16_t | TypeID static | |
constexpr uint16_t | MinSize static | 4 bytes before the reason phrase. |
static
constexpr uint16_t TypeID = 0x0009static
constexpr uint16_t MinSize = 44 bytes before the reason phrase.
uint8_t _classuint8_t _numberstd::string _reason