ErrorCode
#include <icy/stun/attributes.h>
class ErrorCodeDefined 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 |
~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 |
~Attribute | function | Inherited from Attribute |
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 | ~Attribute virtual inline | |
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 | |
function | size const | |
function | paddingBytes const inline | |
function | paddedBytes const inline | |
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 | |
variable | TypeID static constexpr | |
function | 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. |
function | paddingBytes static inline constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
ErrorCode | ||
ErrorCode | Copy constructor. | |
~ErrorCode virtual | ||
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 | |
uint8_t | errorClass const inline | |
uint8_t | errorNumber const inline | |
const std::string & | reason const inline | |
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
ErrorCode(uint16_t size = MinSize)Defined in src/stun/include/icy/stun/attributes.h:524
Parameters
| Parameter | Type | Description |
|---|---|---|
size | uint16_t | Initial body length in bytes (must be >= MinSize). |
ErrorCode
ErrorCode(const ErrorCode & r)Defined in src/stun/include/icy/stun/attributes.h:527
Copy constructor.
~ErrorCode
virtual
virtual ~ErrorCode()Defined in src/stun/include/icy/stun/attributes.h:528
clone
virtual override
virtual std::unique_ptr< Attribute > clone() overrideDefined in src/stun/include/icy/stun/attributes.h:531
Returns a deep copy of this attribute.
Reimplements
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
| Parameter | Type | Description |
|---|---|---|
code | int | 3-digit error code (e.g. 401, 438). |
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
| Parameter | Type | Description |
|---|---|---|
reason | const std::string & | Human-readable error description. |
errorCode
const
int errorCode() constDefined in src/stun/include/icy/stun/attributes.h:545
Returns
The full 3-digit error code (class * 100 + number).
errorClass
const inline
inline uint8_t errorClass() constDefined 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
const inline
inline uint8_t errorNumber() constDefined in src/stun/include/icy/stun/attributes.h:551
Returns
The tens+units portion of the error code (0-99).
reason
const inline
inline const std::string & reason() constDefined in src/stun/include/icy/stun/attributes.h:554
Returns
The reason phrase string (may be empty).
read
virtual override
virtual void read(BitReader & reader) overrideDefined 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.
Reimplements
Parameters
| Parameter | Type | Description |
|---|---|---|
reader | BitReader & | Source bit reader positioned at the attribute body. |
write
virtual const override
virtual void write(BitWriter & writer) const overrideDefined in src/stun/include/icy/stun/attributes.h:557
Writes the body (not the type or size) to the given buffer.
Reimplements
Parameters
| Parameter | Type | Description |
|---|---|---|
writer | BitWriter & | Destination bit writer. |
Public Static Attributes
| Return | Name | Description |
|---|---|---|
constexpr uint16_t | TypeID static constexpr | |
constexpr uint16_t | MinSize static constexpr | 4 bytes before the reason phrase. |
TypeID
static constexpr
constexpr uint16_t TypeID = 0x0009Defined in src/stun/include/icy/stun/attributes.h:533
MinSize
static constexpr
constexpr uint16_t MinSize = 4Defined in src/stun/include/icy/stun/attributes.h:534
4 bytes before the reason phrase.
Private Attributes
_class
uint8_t _classDefined in src/stun/include/icy/stun/attributes.h:560
_number
uint8_t _numberDefined in src/stun/include/icy/stun/attributes.h:561
_reason
std::string _reason