Group PJNATH_STUN_MSG

group PJNATH_STUN_MSG

Low-level representation and parsing of STUN messages.

Defines

PJ_STUN_MAGIC

STUN magic cookie.

PJ_STUN_GET_METHOD(msg_type)

Retrieve the STUN method from the message-type field of the STUN message.

PJ_STUN_IS_REQUEST(msg_type)

Determine if the message type is a request.

PJ_STUN_IS_SUCCESS_RESPONSE(msg_type)

Determine if the message type is a successful response.

PJ_STUN_SUCCESS_RESPONSE_BIT

The response bit in the message type.

PJ_STUN_IS_ERROR_RESPONSE(msg_type)

Determine if the message type is an error response.

PJ_STUN_ERROR_RESPONSE_BIT

The error response bit in the message type.

PJ_STUN_IS_RESPONSE(msg_type)

Determine if the message type is a response.

PJ_STUN_IS_INDICATION(msg_type)

Determine if the message type is an indication message.

PJ_STUN_INDICATION_BIT

The error response bit in the message type.

PJ_STUN_GET_CH_NB(u32)

Get 16bit channel number from 32bit integral value. Note that uint32 attributes are always stored in host byte order after they have been parsed from the PDU, so no need to do ntohs() here.

PJ_STUN_SET_CH_NB(chnum)

Convert 16bit channel number into 32bit integral value. Note that uint32 attributes will be converted to network byte order when the attribute is written to packet, so no need to do htons() here.

PJ_STUN_GET_RT_PROTO(u32)

Get protocol value from 32bit TURN REQUESTED-TRANSPORT attribute.

PJ_STUN_SET_RT_PROTO(proto)

Convert protocol value to be placed in 32bit TURN REQUESTED-TRANSPORT attribute.

Enums

enum pj_stun_method_e

STUN method constants.

Values:

enumerator PJ_STUN_BINDING_METHOD

STUN Binding method as defined by RFC 3489-bis.

enumerator PJ_STUN_SHARED_SECRET_METHOD

STUN Shared Secret method as defined by RFC 3489-bis.

enumerator PJ_STUN_ALLOCATE_METHOD

STUN/TURN Allocate method as defined by draft-ietf-behave-turn

enumerator PJ_STUN_REFRESH_METHOD

STUN/TURN Refresh method as defined by draft-ietf-behave-turn

enumerator PJ_STUN_SEND_METHOD

STUN/TURN Send indication as defined by draft-ietf-behave-turn

enumerator PJ_STUN_DATA_METHOD

STUN/TURN Data indication as defined by draft-ietf-behave-turn

enumerator PJ_STUN_CREATE_PERM_METHOD

STUN/TURN CreatePermission method as defined by draft-ietf-behave-turn

enumerator PJ_STUN_CHANNEL_BIND_METHOD

STUN/TURN ChannelBind as defined by draft-ietf-behave-turn

enumerator PJ_STUN_CONNECT_METHOD

STUN/TURN Connect as defined by RFC 6062

enumerator PJ_STUN_CONNECTION_BIND_METHOD

STUN/TURN ConnectionBind as defined by RFC 6062

enumerator PJ_STUN_CONNECTION_ATTEMPT_METHOD

STUN/TURN ConnectionAttempt as defined by RFC 6062

enumerator PJ_STUN_METHOD_MAX

All known methods.

enum pj_stun_msg_class_e

STUN message classes constants.

Values:

enumerator PJ_STUN_REQUEST_CLASS

This specifies that the message type is a STUN request message.

enumerator PJ_STUN_INDICATION_CLASS

This specifies that the message type is a STUN indication message.

enumerator PJ_STUN_SUCCESS_CLASS

This specifies that the message type is a STUN successful response.

enumerator PJ_STUN_ERROR_CLASS

This specifies that the message type is a STUN error response.

enum pj_stun_msg_type

This enumeration describes STUN message types.

Values:

enumerator PJ_STUN_BINDING_REQUEST

STUN BINDING request.

enumerator PJ_STUN_BINDING_RESPONSE

Successful response to STUN BINDING-REQUEST.

enumerator PJ_STUN_BINDING_ERROR_RESPONSE

Error response to STUN BINDING-REQUEST.

enumerator PJ_STUN_BINDING_INDICATION

Binding Indication (ICE)

enumerator PJ_STUN_SHARED_SECRET_REQUEST

STUN SHARED-SECRET reqeust.

enumerator PJ_STUN_SHARED_SECRET_RESPONSE

Successful response to STUN SHARED-SECRET reqeust.

enumerator PJ_STUN_SHARED_SECRET_ERROR_RESPONSE

Error response to STUN SHARED-SECRET reqeust.

enumerator PJ_STUN_ALLOCATE_REQUEST

STUN/TURN Allocate Request

enumerator PJ_STUN_ALLOCATE_RESPONSE

Successful response to STUN/TURN Allocate Request

enumerator PJ_STUN_ALLOCATE_ERROR_RESPONSE

Failure response to STUN/TURN Allocate Request

enumerator PJ_STUN_REFRESH_REQUEST

STUN/TURN REFRESH Request

enumerator PJ_STUN_REFRESH_RESPONSE

Successful response to STUN REFRESH request

enumerator PJ_STUN_REFRESH_ERROR_RESPONSE

Error response to STUN REFRESH request.

enumerator PJ_STUN_SEND_INDICATION

TURN Send indication

enumerator PJ_STUN_DATA_INDICATION

TURN Data indication

enumerator PJ_STUN_CREATE_PERM_REQUEST

TURN CreatePermission request

enumerator PJ_STUN_CREATE_PERM_RESPONSE

TURN CreatePermission successful response.

enumerator PJ_STUN_CREATE_PERM_ERROR_RESPONSE

TURN CreatePermission failure response

enumerator PJ_STUN_CHANNEL_BIND_REQUEST

STUN/TURN ChannelBind Request

enumerator PJ_STUN_CHANNEL_BIND_RESPONSE

Successful response to STUN ChannelBind request

enumerator PJ_STUN_CHANNEL_BIND_ERROR_RESPONSE

Error response to STUN ChannelBind request.

enumerator PJ_STUN_CONNECT_REQUEST

STUN/TURN Connect Request

enumerator PJ_STUN_CONNECTION_BIND_REQUEST

STUN/TURN ConnectBind Request

enumerator PJ_STUN_CONNECTION_ATTEMPT_INDICATION

TURN ConnectionAttempt indication

enum pj_stun_attr_type

This enumeration describes STUN attribute types.

Values:

enumerator PJ_STUN_ATTR_MAPPED_ADDR

MAPPED-ADDRESS.

enumerator PJ_STUN_ATTR_RESPONSE_ADDR

RESPONSE-ADDRESS (deprcatd)

enumerator PJ_STUN_ATTR_CHANGE_REQUEST

CHANGE-REQUEST (deprecated)

enumerator PJ_STUN_ATTR_SOURCE_ADDR

SOURCE-ADDRESS (deprecated)

enumerator PJ_STUN_ATTR_CHANGED_ADDR

CHANGED-ADDRESS (deprecatd)

enumerator PJ_STUN_ATTR_USERNAME

USERNAME attribute.

enumerator PJ_STUN_ATTR_PASSWORD

was PASSWORD attribute.

enumerator PJ_STUN_ATTR_MESSAGE_INTEGRITY

MESSAGE-INTEGRITY.

enumerator PJ_STUN_ATTR_ERROR_CODE

ERROR-CODE.

enumerator PJ_STUN_ATTR_UNKNOWN_ATTRIBUTES

UNKNOWN-ATTRIBUTES.

enumerator PJ_STUN_ATTR_REFLECTED_FROM

REFLECTED-FROM (deprecatd)

enumerator PJ_STUN_ATTR_CHANNEL_NUMBER

TURN CHANNEL-NUMBER

enumerator PJ_STUN_ATTR_LIFETIME

TURN LIFETIME attr.

enumerator PJ_STUN_ATTR_MAGIC_COOKIE

MAGIC-COOKIE attr (deprec)

enumerator PJ_STUN_ATTR_BANDWIDTH

TURN BANDWIDTH (deprec)

enumerator PJ_STUN_ATTR_XOR_PEER_ADDR

TURN XOR-PEER-ADDRESS

enumerator PJ_STUN_ATTR_DATA

DATA attribute.

enumerator PJ_STUN_ATTR_REALM

REALM attribute.

enumerator PJ_STUN_ATTR_NONCE

NONCE attribute.

enumerator PJ_STUN_ATTR_XOR_RELAYED_ADDR

TURN XOR-RELAYED-ADDRESS

enumerator PJ_STUN_ATTR_REQ_ADDR_TYPE

REQUESTED-ADDRESS-TYPE

enumerator PJ_STUN_ATTR_REQ_ADDR_FAMILY

REQUESTED-ADDRESS-FAMILY

enumerator PJ_STUN_ATTR_EVEN_PORT

TURN EVEN-PORT

enumerator PJ_STUN_ATTR_REQ_TRANSPORT

TURN REQUESTED-TRANSPORT

enumerator PJ_STUN_ATTR_DONT_FRAGMENT

TURN DONT-FRAGMENT

enumerator PJ_STUN_ATTR_XOR_MAPPED_ADDR

XOR-MAPPED-ADDRESS

enumerator PJ_STUN_ATTR_TIMER_VAL

TIMER-VAL attribute.

enumerator PJ_STUN_ATTR_RESERVATION_TOKEN

TURN RESERVATION-TOKEN

enumerator PJ_STUN_ATTR_XOR_REFLECTED_FROM

XOR-REFLECTED-FROM

enumerator PJ_STUN_ATTR_PRIORITY

PRIORITY

enumerator PJ_STUN_ATTR_USE_CANDIDATE

USE-CANDIDATE

enumerator PJ_STUN_ATTR_CONNECTION_ID

CONNECTION-ID

enumerator PJ_STUN_ATTR_ICMP

ICMP (TURN)

enumerator PJ_STUN_ATTR_END_MANDATORY_ATTR
enumerator PJ_STUN_ATTR_START_EXTENDED_ATTR
enumerator PJ_STUN_ATTR_SOFTWARE

SOFTWARE attribute.

enumerator PJ_STUN_ATTR_ALTERNATE_SERVER

ALTERNATE-SERVER.

enumerator PJ_STUN_ATTR_REFRESH_INTERVAL

REFRESH-INTERVAL.

enumerator PJ_STUN_ATTR_FINGERPRINT

FINGERPRINT attribute.

enumerator PJ_STUN_ATTR_ICE_CONTROLLED

ICE-CCONTROLLED attribute.

enumerator PJ_STUN_ATTR_ICE_CONTROLLING

ICE-CCONTROLLING attribute

enumerator PJ_STUN_ATTR_END_EXTENDED_ATTR
enum pj_stun_status

STUN error codes, which goes into STUN ERROR-CODE attribute.

Values:

enumerator PJ_STUN_SC_TRY_ALTERNATE

Try Alternate

enumerator PJ_STUN_SC_BAD_REQUEST

Bad Request

enumerator PJ_STUN_SC_UNAUTHORIZED

Unauthorized

enumerator PJ_STUN_SC_FORBIDDEN

Forbidden (TURN)

enumerator PJ_STUN_SC_UNKNOWN_ATTRIBUTE

Unknown Attribute

enumerator PJ_STUN_SC_ALLOCATION_MISMATCH

TURN Alloc Mismatch

enumerator PJ_STUN_SC_STALE_NONCE

Stale Nonce

enumerator PJ_STUN_SC_TRANSITIONING

Transitioning.

enumerator PJ_STUN_SC_WRONG_CREDENTIALS

TURN Wrong Credentials

enumerator PJ_STUN_SC_UNSUPP_TRANSPORT_PROTO

Unsupported Transport or Protocol (TURN)

enumerator PJ_STUN_SC_OPER_TCP_ONLY

Operation for TCP Only

enumerator PJ_STUN_SC_CONNECTION_FAILURE

Connection Failure

enumerator PJ_STUN_SC_CONNECTION_TIMEOUT

Connection Timeout

enumerator PJ_STUN_SC_ALLOCATION_QUOTA_REACHED

Allocation Quota Reached (TURN)

enumerator PJ_STUN_SC_ROLE_CONFLICT

Role Conflict

enumerator PJ_STUN_SC_SERVER_ERROR

Server Error

enumerator PJ_STUN_SC_INSUFFICIENT_CAPACITY

Insufficient Capacity (TURN)

enumerator PJ_STUN_SC_GLOBAL_FAILURE

Global Failure

enum pj_stun_decode_options

STUN decoding options

Values:

enumerator PJ_STUN_IS_DATAGRAM

Tell the decoder that the message was received from datagram oriented transport (such as UDP).

enumerator PJ_STUN_CHECK_PACKET

Tell pj_stun_msg_decode() to check the validity of the STUN message by calling pj_stun_msg_check() before starting to decode the packet.

enumerator PJ_STUN_NO_AUTHENTICATE

This option current is only valid for pj_stun_session_on_rx_pkt(). When specified, it tells the session NOT to authenticate the message.

enumerator PJ_STUN_NO_FINGERPRINT_CHECK

Disable FINGERPRINT verification. This option can be used when calling pj_stun_msg_check() and pj_stun_msg_decode() to disable the verification of FINGERPRINT, for example when the STUN usage says when FINGERPRINT mechanism shall not be used.

Functions

const char *pj_stun_get_method_name(unsigned msg_type)

Get STUN message method name.

Parameters:

msg_type – The STUN message type (in host byte order)

Returns:

The STUN message method name string.

const char *pj_stun_get_class_name(unsigned msg_type)

Get STUN message class name.

Parameters:

msg_type – The STUN message type (in host byte order)

Returns:

The STUN message class name string.

const char *pj_stun_get_attr_name(unsigned attr_type)

Get STUN attribute name.

Returns:

attr_type The STUN attribute type (in host byte order).

Returns:

The STUN attribute type name string.

pj_str_t pj_stun_get_err_reason(int err_code)

Get STUN standard reason phrase for the specified error code.

Parameters:

err_code – The STUN error code.

Returns:

The STUN error reason phrase.

int pj_stun_set_padding_char(int chr)

Internal: set the padding character for string attribute. The default padding character is PJ_STUN_STRING_ATTR_PAD_CHR.

Returns:

The previous padding character.

pj_status_t pj_stun_msg_init(pj_stun_msg *msg, unsigned msg_type, pj_uint32_t magic, const pj_uint8_t tsx_id[12])

Initialize a generic STUN message.

Parameters:
  • msg – The message structure to be initialized.

  • msg_type – The 14bit message type (see pj_stun_msg_type constants).

  • magic – Magic value to be put to the mesage; for requests, the value normally should be PJ_STUN_MAGIC.

  • tsx_id – Optional transaction ID, or NULL to let the function generates a random transaction ID.

Returns:

PJ_SUCCESS on success.

pj_status_t pj_stun_msg_create(pj_pool_t *pool, unsigned msg_type, pj_uint32_t magic, const pj_uint8_t tsx_id[12], pj_stun_msg **p_msg)

Create a generic STUN message.

Parameters:
  • pool – Pool to create the STUN message.

  • msg_type – The 14bit message type.

  • magic – Magic value to be put to the mesage; for requests, the value should be PJ_STUN_MAGIC.

  • tsx_id – Optional transaction ID, or NULL to let the function generates a random transaction ID.

  • p_msg – Pointer to receive the message.

Returns:

PJ_SUCCESS on success.

pj_stun_msg *pj_stun_msg_clone(pj_pool_t *pool, const pj_stun_msg *msg)

Clone a STUN message with all of its attributes.

Parameters:
  • pool – Pool to allocate memory for the new message.

  • msg – The message to be cloned.

Returns:

The duplicate message.

pj_status_t pj_stun_msg_create_response(pj_pool_t *pool, const pj_stun_msg *req_msg, unsigned err_code, const pj_str_t *err_msg, pj_stun_msg **p_response)

Create STUN response message.

Parameters:
  • pool – Pool to create the mesage.

  • req_msg – The request message.

  • err_code – STUN error code. If this value is not zero, then error response will be created, otherwise successful response will be created.

  • err_msg – Optional error message to explain err_code. If this value is NULL and err_code is not zero, the error string will be taken from the default STUN error message.

  • p_response – Pointer to receive the response.

Returns:

PJ_SUCCESS on success, or the appropriate error.

pj_status_t pj_stun_msg_add_attr(pj_stun_msg *msg, pj_stun_attr_hdr *attr)

Add STUN attribute to STUN message.

Parameters:
  • msg – The STUN message.

  • attr – The STUN attribute to be added to the message.

Returns:

PJ_SUCCESS on success, or PJ_ETOOMANY if there are already too many attributes in the message.

pj_status_t pj_stun_msg_encode(pj_stun_msg *msg, pj_uint8_t *pkt_buf, pj_size_t buf_size, unsigned options, const pj_str_t *key, pj_size_t *p_msg_len)

Print the STUN message structure to a packet buffer, ready to be sent to remote destination. This function will take care about calculating the MESSAGE-INTEGRITY digest as well as FINGERPRINT value, if these attributes are present in the message.

If application wants to apply credential to the message, it MUST include a blank MESSAGE-INTEGRITY attribute in the message as the last attribute or the attribute before FINGERPRINT. This function will calculate the HMAC digest from the message using the supplied key in the parameter. The key should be set to the password if short term credential is used, or calculated from the MD5 hash of the realm, username, and password using pj_stun_create_key() if long term credential is used.

If FINGERPRINT attribute is present, this function will calculate the FINGERPRINT CRC attribute for the message. The FINGERPRINT MUST be added as the last attribute of the message.

Parameters:
  • msg – The STUN message to be printed. Upon return, some fields in the header (such as message length) will be updated.

  • pkt_buf – The buffer to be filled with the packet.

  • buf_size – Size of the buffer.

  • options – Options, which currently must be zero.

  • key – Authentication key to calculate MESSAGE-INTEGRITY value. Application can create this key by using pj_stun_create_key() function.

  • p_msg_len – Upon return, it will be filed with the size of the packet in bytes, or negative value on error.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_msg_check(const pj_uint8_t *pdu, pj_size_t pdu_len, unsigned options)

Check that the PDU is potentially a valid STUN message. This function is useful when application needs to multiplex STUN packets with other application traffic. When this function returns PJ_SUCCESS, there is a big chance that the packet is a STUN packet.

Note that we cannot be sure that the PDU is a really valid STUN message until we actually parse the PDU.

Parameters:
  • pdu – The packet buffer.

  • pdu_len – The length of the packet buffer.

  • options – Additional options to be applied in the checking, which can be taken from pj_stun_decode_options. One of the useful option is PJ_STUN_IS_DATAGRAM which means that the pdu represents a whole STUN packet.

Returns:

PJ_SUCCESS if the PDU is a potentially valid STUN message.

pj_status_t pj_stun_msg_decode(pj_pool_t *pool, const pj_uint8_t *pdu, pj_size_t pdu_len, unsigned options, pj_stun_msg **p_msg, pj_size_t *p_parsed_len, pj_stun_msg **p_response)

Decode incoming packet into STUN message.

Parameters:
  • pool – Pool to allocate the message.

  • pdu – The incoming packet to be parsed.

  • pdu_len – The length of the incoming packet.

  • options – Parsing flags, according to pj_stun_decode_options.

  • p_msg – Pointer to receive the parsed message.

  • p_parsed_len – Optional pointer to receive how many bytes have been parsed for the STUN message. This is useful when the packet is received over stream oriented transport.

  • p_response – Optional pointer to receive an instance of response message, if one can be created. If the packet being decoded is a request message, and it contains error, and a response can be created, then the STUN response message will be returned on this argument.

Returns:

PJ_SUCCESS if a STUN message has been successfully decoded.

char *pj_stun_msg_dump(const pj_stun_msg *msg, char *buffer, unsigned length, unsigned *printed_len)

Dump STUN message to a printable string output.

Parameters:
  • msg – The STUN message

  • buffer – Buffer where the printable string output will be printed on.

  • length – Specify the maximum length of the buffer.

  • printed_len – Optional pointer, which on output will be filled up with the actual length of the output string.

Returns:

The message string output.

pj_stun_attr_hdr *pj_stun_msg_find_attr(const pj_stun_msg *msg, int attr_type, unsigned start_index)

Find STUN attribute in the STUN message, starting from the specified index.

Parameters:
  • msg – The STUN message.

  • attr_type – The attribute type to be found, from pj_stun_attr_type.

  • start_index – The start index of the attribute in the message. Specify zero to start searching from the first attribute.

Returns:

The attribute instance, or NULL if it cannot be found.

pj_stun_attr_hdr *pj_stun_attr_clone(pj_pool_t *pool, const pj_stun_attr_hdr *attr)

Clone a STUN attribute.

Parameters:
  • pool – Pool to allocate memory.

  • attr – Attribute to clone.

Returns:

Duplicate attribute.

pj_status_t pj_stun_sockaddr_attr_init(pj_stun_sockaddr_attr *attr, int attr_type, pj_bool_t xor_ed, const pj_sockaddr_t *addr, unsigned addr_len)

Initialize generic STUN IP address attribute. The addr_len and addr parameters specify whether the address is IPv4 or IPv4 address.

Parameters:
  • attr – The socket address attribute to initialize.

  • attr_type – Attribute type, from pj_stun_attr_type.

  • xor_ed – If non-zero, the port and address will be XOR-ed with magic, to make the XOR-MAPPED-ADDRESS attribute.

  • addr – A pj_sockaddr_in or pj_sockaddr_in6 structure.

  • addr_len – Length of addr parameter.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_sockaddr_attr_create(pj_pool_t *pool, int attr_type, pj_bool_t xor_ed, const pj_sockaddr_t *addr, unsigned addr_len, pj_stun_sockaddr_attr **p_attr)

Create a generic STUN IP address attribute. The addr_len and addr parameters specify whether the address is IPv4 or IPv4 address.

Parameters:
  • pool – The pool to allocate memory from.

  • attr_type – Attribute type, from pj_stun_attr_type.

  • xor_ed – If non-zero, the port and address will be XOR-ed with magic, to make the XOR-MAPPED-ADDRESS attribute.

  • addr – A pj_sockaddr_in or pj_sockaddr_in6 structure.

  • addr_len – Length of addr parameter.

  • p_attr – Pointer to receive the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_msg_add_sockaddr_attr(pj_pool_t *pool, pj_stun_msg *msg, int attr_type, pj_bool_t xor_ed, const pj_sockaddr_t *addr, unsigned addr_len)

Create and add generic STUN IP address attribute to a STUN message. The addr_len and addr parameters specify whether the address is IPv4 or IPv4 address.

Parameters:
  • pool – The pool to allocate memory from.

  • msg – The STUN message.

  • attr_type – Attribute type, from pj_stun_attr_type.

  • xor_ed – If non-zero, the port and address will be XOR-ed with magic, to make the XOR-MAPPED-ADDRESS attribute.

  • addr – A pj_sockaddr_in or pj_sockaddr_in6 structure.

  • addr_len – Length of addr parameter.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_string_attr_init(pj_stun_string_attr *attr, pj_pool_t *pool, int attr_type, const pj_str_t *value)

Initialize a STUN generic string attribute.

Parameters:
  • attr – The string attribute to be initialized.

  • pool – Pool to duplicate the value into the attribute, if value is not NULL or empty.

  • attr_type – Attribute type, from pj_stun_attr_type.

  • value – The string value to be assigned to the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_string_attr_create(pj_pool_t *pool, int attr_type, const pj_str_t *value, pj_stun_string_attr **p_attr)

Create a STUN generic string attribute.

Parameters:
  • pool – The pool to allocate memory from.

  • attr_type – Attribute type, from pj_stun_attr_type.

  • value – The string value to be assigned to the attribute.

  • p_attr – Pointer to receive the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_msg_add_string_attr(pj_pool_t *pool, pj_stun_msg *msg, int attr_type, const pj_str_t *value)

Create and add STUN generic string attribute to the message.

Parameters:
  • pool – The pool to allocate memory from.

  • msg – The STUN message.

  • attr_type – Attribute type, from pj_stun_attr_type.

  • value – The string value to be assigned to the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_uint_attr_create(pj_pool_t *pool, int attr_type, pj_uint32_t value, pj_stun_uint_attr **p_attr)

Create a STUN generic 32bit value attribute.

Parameters:
  • pool – The pool to allocate memory from.

  • attr_type – Attribute type, from pj_stun_attr_type.

  • value – The 32bit value to be assigned to the attribute.

  • p_attr – Pointer to receive the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_msg_add_uint_attr(pj_pool_t *pool, pj_stun_msg *msg, int attr_type, pj_uint32_t value)

Create and add STUN generic 32bit value attribute to the message.

Parameters:
  • pool – The pool to allocate memory from.

  • msg – The STUN message

  • attr_type – Attribute type, from pj_stun_attr_type.

  • value – The 32bit value to be assigned to the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_uint64_attr_create(pj_pool_t *pool, int attr_type, const pj_timestamp *value, pj_stun_uint64_attr **p_attr)

Create a STUN generic 64bit value attribute.

Parameters:
  • pool – Pool to allocate memory from.

  • attr_type – Attribute type, from pj_stun_attr_type.

  • value – Optional value to be assigned.

  • p_attr – Pointer to receive the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_msg_add_uint64_attr(pj_pool_t *pool, pj_stun_msg *msg, int attr_type, const pj_timestamp *value)

Create and add STUN generic 64bit value attribute to the message.

Parameters:
  • pool – The pool to allocate memory from.

  • msg – The STUN message

  • attr_type – Attribute type, from pj_stun_attr_type.

  • value – The 64bit value to be assigned to the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_msgint_attr_create(pj_pool_t *pool, pj_stun_msgint_attr **p_attr)

Create a STUN MESSAGE-INTEGRITY attribute.

Parameters:
  • pool – The pool to allocate memory from.

  • p_attr – Pointer to receive the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_msg_add_msgint_attr(pj_pool_t *pool, pj_stun_msg *msg)

Create and add STUN MESSAGE-INTEGRITY attribute.

Parameters:
  • pool – The pool to allocate memory from.

  • msg – The STUN message

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_errcode_attr_create(pj_pool_t *pool, int err_code, const pj_str_t *err_reason, pj_stun_errcode_attr **p_attr)

Create a STUN ERROR-CODE attribute.

Parameters:
  • pool – The pool to allocate memory from.

  • err_code – STUN error code.

  • err_reason – Optional STUN error reason. If NULL is given, the standard error reason will be given.

  • p_attr – Pointer to receive the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_msg_add_errcode_attr(pj_pool_t *pool, pj_stun_msg *msg, int err_code, const pj_str_t *err_reason)

Create and add STUN ERROR-CODE attribute to the message.

Parameters:
  • pool – The pool to allocate memory from.

  • msg – The STUN mesage.

  • err_code – STUN error code.

  • err_reason – Optional STUN error reason. If NULL is given, the standard error reason will be given.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_unknown_attr_create(pj_pool_t *pool, unsigned attr_cnt, const pj_uint16_t attr[], pj_stun_unknown_attr **p_attr)

Create instance of STUN UNKNOWN-ATTRIBUTES attribute and copy the unknown attribute array to the attribute.

Parameters:
  • pool – The pool to allocate memory from.

  • attr_cnt – Number of attributes in the array (can be zero).

  • attr – Optional array of attributes.

  • p_attr – Pointer to receive the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_msg_add_unknown_attr(pj_pool_t *pool, pj_stun_msg *msg, unsigned attr_cnt, const pj_uint16_t attr[])

Create and add STUN UNKNOWN-ATTRIBUTES attribute to the message.

Parameters:
  • pool – The pool to allocate memory from.

  • msg – The STUN message.

  • attr_cnt – Number of attributes in the array (can be zero).

  • attr – Optional array of attribute types.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_binary_attr_init(pj_stun_binary_attr *attr, pj_pool_t *pool, int attr_type, const pj_uint8_t *data, unsigned length)

Initialize STUN binary attribute.

Parameters:
  • attr – The attribute to be initialized.

  • pool – Pool to copy data, if the data and length are set.

  • attr_type – The attribute type, from pj_stun_attr_type.

  • data – Data to be coped to the attribute, or NULL if no data to be copied now.

  • length – Length of data, or zero if no data is to be copied now.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_binary_attr_create(pj_pool_t *pool, int attr_type, const pj_uint8_t *data, unsigned length, pj_stun_binary_attr **p_attr)

Create STUN binary attribute.

Parameters:
  • pool – The pool to allocate memory from.

  • attr_type – The attribute type, from pj_stun_attr_type.

  • data – Data to be coped to the attribute, or NULL if no data to be copied now.

  • length – Length of data, or zero if no data is to be copied now.

  • p_attr – Pointer to receive the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_msg_add_binary_attr(pj_pool_t *pool, pj_stun_msg *msg, int attr_type, const pj_uint8_t *data, unsigned length)

Create STUN binary attribute and add the attribute to the message.

Parameters:
  • pool – The pool to allocate memory from.

  • msg – The STUN message.

  • attr_type – The attribute type, from pj_stun_attr_type.

  • data – Data to be coped to the attribute, or NULL if no data to be copied now.

  • length – Length of data, or zero if no data is to be copied now.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_empty_attr_create(pj_pool_t *pool, int attr_type, pj_stun_empty_attr **p_attr)

Create STUN empty attribute.

Parameters:
  • pool – The pool to allocate memory from.

  • attr_type – The attribute type, from pj_stun_attr_type.

  • p_attr – Pointer to receive the attribute.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pj_stun_msg_add_empty_attr(pj_pool_t *pool, pj_stun_msg *msg, int attr_type)

Create STUN empty attribute and add the attribute to the message.

Parameters:
  • pool – The pool to allocate memory from.

  • msg – The STUN message.

  • attr_type – The attribute type, from pj_stun_attr_type.

Returns:

PJ_SUCCESS on success or the appropriate error code.

struct pj_stun_msg_hdr
#include <stun_msg.h>

This structure describes STUN message header. A STUN message has the following format:

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |0 0|     STUN Message Type     |         Message Length        |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                         Magic Cookie                          |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                             Transaction ID
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                                                    |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Public Members

pj_uint16_t type

STUN message type, which the first two bits must be zeroes.

pj_uint16_t length

The message length is the size, in bytes, of the message not including the 20 byte STUN header.

pj_uint32_t magic

The magic cookie is a fixed value, 0x2112A442 (PJ_STUN_MAGIC constant). In the previous version of this specification [15] this field was part of the transaction ID.

pj_uint8_t tsx_id[12]

The transaction ID is a 96 bit identifier. STUN transactions are identified by their unique 96-bit transaction ID. For request/ response transactions, the transaction ID is chosen by the STUN client and MUST be unique for each new STUN transaction generated by that STUN client. The transaction ID MUST be uniformly and randomly distributed between 0 and 2**96 - 1.

struct pj_stun_attr_hdr
#include <stun_msg.h>

This structre describes STUN attribute header. Each attribute is TLV encoded, with a 16 bit type, 16 bit length, and variable value. Each STUN attribute ends on a 32 bit boundary:

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |         Type                  |            Length             |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Public Members

pj_uint16_t type

STUN attribute type.

pj_uint16_t length

The Length refers to the length of the actual useful content of the Value portion of the attribute, measured in bytes. The value in the Length field refers to the length of the Value part of the attribute prior to padding - i.e., the useful content.

struct pj_stun_sockaddr_attr
#include <stun_msg.h>

This structure describes STUN generic IP address attribute, used for example to represent STUN MAPPED-ADDRESS attribute.

The generic IP address attribute indicates the transport address. It consists of an eight bit address family, and a sixteen bit port, followed by a fixed length value representing the IP address. If the address family is IPv4, the address is 32 bits, in network byte order. If the address family is IPv6, the address is 128 bits in network byte order.

The format of the generic IP address attribute is:

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |x x x x x x x x|    Family     |           Port                |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                   Address  (variable)
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

This structure describes STUN MAPPED-ADDRESS attribute. The MAPPED-ADDRESS attribute indicates the mapped transport address.

This describes STUN XOR-MAPPED-ADDRESS attribute (which has the same format as STUN MAPPED-ADDRESS attribute). The XOR-MAPPED-ADDRESS attribute is present in responses. It provides the same information that would present in the MAPPED- ADDRESS attribute but because the NAT’s public IP address is obfuscated through the XOR function, STUN messages are able to pass through NATs which would otherwise interfere with STUN.

This describes STUN ALTERNATE-SERVER attribute. The alternate server represents an alternate transport address for a different STUN server to try. It is encoded in the same way as MAPPED-ADDRESS.

This structure describes STUN RESPONSE-ADDRESS attribute. The RESPONSE-ADDRESS attribute indicates where the response to a Binding Request should be sent. Its syntax is identical to MAPPED- ADDRESS.

Note that the usage of this attribute has been deprecated by the RFC 3489-bis standard.

This structure describes STUN CHANGED-ADDRESS attribute. The CHANGED-ADDRESS attribute indicates the IP address and port where responses would have been sent from if the “change IP” and “change

port” flags had been set in the CHANGE-REQUEST attribute of the Binding Request. The attribute is always present in a Binding Response, independent of the value of the flags. Its syntax is identical to MAPPED-ADDRESS.

Note that the usage of this attribute has been deprecated by the RFC 3489-bis standard.

This structure describes STUN SOURCE-ADDRESS attribute. The SOURCE-ADDRESS attribute is present in Binding Responses. It indicates the source IP address and port that the server is sending the response from. Its syntax is identical to that of MAPPED- ADDRESS.

Note that the usage of this attribute has been deprecated by the RFC 3489-bis standard.

This describes the STUN REFLECTED-FROM attribute. The REFLECTED-FROM attribute is present only in Binding Responses, when the Binding Request contained a RESPONSE-ADDRESS attribute. The attribute contains the identity (in terms of IP address) of the source where the request came from. Its purpose is to provide traceability, so that a STUN server cannot be used as a reflector for denial-of-service attacks.

This describes the STUN XOR-PEER-ADDRESS attribute. The XOR-PEER-ADDRESS specifies the address and port of the peer as seen from the TURN server. It is encoded in the same way as XOR-MAPPED- ADDRESS.

This describes the STUN XOR-RELAYED-ADDRESS attribute. The XOR-RELAYED-ADDRESS is present in Allocate responses. It specifies the address and port that the server allocated to the client. It is encoded in the same way as XOR-MAPPED-ADDRESS.

This describes the XOR-REFLECTED-FROM attribute, as described by draft-macdonald-behave-nat-behavior-discovery-00. The XOR-REFLECTED-FROM attribute is used in place of the REFLECTED- FROM attribute. It provides the same information, but because the NAT’s public address is obfuscated through the XOR function, It can pass through a NAT that would otherwise attempt to translate it to the private network address. XOR-REFLECTED-FROM has identical syntax to XOR-MAPPED-ADDRESS.

Public Members

pj_stun_attr_hdr hdr

Standard STUN attribute header.

pj_bool_t xor_ed

Flag to indicate whether this attribute should be sent in XOR-ed format, or has been received in XOR-ed format.

pj_sockaddr sockaddr

The socket address

struct pj_stun_empty_attr
#include <stun_msg.h>

This structure represents a generic STUN attributes with no payload, and it is used for example by ICE USE-CANDIDATE attribute.

This describes the TURN DONT-FRAGMENT attribute.

This attribute is used by the client to request that the server set the DF (Don’t Fragment) bit in the IP header when relaying the application data onward to the peer. This attribute has no value part and thus the attribute length field is 0.

This describes the USE-CANDIDATE attribute from draft-ietf-mmusic-ice-13. The USE-CANDIDATE attribute indicates that the candidate pair resulting from this check should be used for transmission of media. The attribute has no content (the Length field of the attribute is zero); it serves as a flag.

Public Members

pj_stun_attr_hdr hdr

Standard STUN attribute header.

struct pj_stun_string_attr
#include <stun_msg.h>

This structure represents generic STUN string attributes, such as STUN USERNAME, PASSWORD, SOFTWARE, REALM, and NONCE attributes.

This describes STUN REALM attribute. The REALM attribute is present in requests and responses. It contains text which meets the grammar for “realm” as described in RFC 3261 [11], and will thus contain a quoted string (including the quotes).

This describes STUN NONCE attribute. The NONCE attribute is present in requests and in error responses. It contains a sequence of qdtext or quoted-pair, which are defined in RFC 3261 [11]. See RFC 2617 [7] for guidance on selection of nonce values in a server.

This describes STUN SOFTWARE attribute. The SOFTWARE attribute contains a textual description of the software being used by the agent sending the message. It is used by clients and servers. Its value SHOULD include manufacturer and version number.

This describes STUN USERNAME attribute. The USERNAME attribute is used for message integrity. It identifies the shared secret used in the message integrity check. Consequently, the USERNAME MUST be included in any request that contains the MESSAGE-INTEGRITY attribute.

This describes STUN PASSWORD attribute. If the message type is Shared Secret Response it MUST include the PASSWORD attribute.

Public Members

pj_stun_attr_hdr hdr

Standard STUN attribute header.

pj_str_t value

The string value.

struct pj_stun_uint_attr
#include <stun_msg.h>

This structure represents a generic STUN attributes with 32bit (unsigned) integer value, such as STUN FINGERPRINT and REFRESH-INTERVAL attributes.

This structure describes STUN FINGERPRINT attribute. The FINGERPRINT attribute can be present in all STUN messages. It is computed as the CRC-32 of the STUN message up to (but excluding) the FINGERPRINT attribute itself, xor-d with the 32 bit value 0x5354554e

This describes STUN REFRESH-INTERVAL attribute. The REFRESH-INTERVAL indicates the number of milliseconds that the server suggests the client should use between refreshes of the NAT bindings between the client and server.

This structure describes STUN CHANGE-REQUEST attribute. The CHANGE-REQUEST attribute is used by the client to request that the server use a different address and/or port when sending the response.

Bit 29 of the value is the “change IP” flag. If true, it requests the server to send the Binding Response with a different IP address than the one the Binding Request was received on.

Bit 30 of the value is the “change port” flag. If true, it requests the server to send the Binding Response with a different port than the one the Binding Request was received on.

Note that the usage of this attribute has been deprecated by the RFC 3489-bis standard.

This describes TURN CHANNEL-NUMBER attribute. In this library, this attribute is represented with 32bit integer. Application may use PJ_STUN_GET_CH_NB() and PJ_STUN_SET_CH_NB() to extract/set channel number value from the 32bit integral value.

The CHANNEL-NUMBER attribute contains the number of the channel. It is a 16-bit unsigned integer, followed by a two-octet RFFU field which MUST be set to 0 on transmission and ignored on reception.

   0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |        Channel Number         |         RFFU                  |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

This describes STUN LIFETIME attribute. The lifetime attribute represents the duration for which the server will maintain an allocation in the absence of data traffic either from or to the client. It is a 32 bit value representing the number of seconds remaining until expiration.

This describes STUN BANDWIDTH attribute. The bandwidth attribute represents the peak bandwidth, measured in kbits per second, that the client expects to use on the binding. The value represents the sum in the receive and send directions.

According to RFC 6156, this describes the REQUESTED-ADDRESS-FAMILY attribute (formerly known as REQUESTED-ADDRESS-TYPE in the draft). The REQUESTED-ADDRESS-FAMILY attribute is used by clients to request the allocation of a specific address type from a server. The following is the format of the REQUESTED-ADDRESS-FAMILY attribute.

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |        Family                 |           Reserved            |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

This describes the TURN REQUESTED-TRANSPORT attribute, encoded in STUN generic integer attribute.

This attribute allows the client to request that the port in the relayed-transport-address be even, and (optionally) that the server reserve the next-higher port number. The attribute is 8 bits long. Its format is:

      0
      0 1 2 3 4 5 6 7
     +-+-+-+-+-+-+-+-+
     |R|    RFFU     |
     +-+-+-+-+-+-+-+-+

The attribute contains a single 1-bit flag:

R: If 1, the server is requested to reserve the next higher port number (on the same IP address) for a subsequent allocation. If 0, no such reservation is requested.

The other 7 bits of the attribute must be set to zero on transmission and ignored on reception.

This describes the TURN REQUESTED-TRANSPORT attribute, encoded in STUN generic integer attribute.

This attribute is used by the client to request a specific transport protocol for the allocated transport address. It has the following format:

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |    Protocol   |                    RFFU                       |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

The Protocol field specifies the desired protocol. The codepoints used in this field are taken from those allowed in the Protocol field in the IPv4 header and the NextHeader field in the IPv6 header [Protocol-Numbers]. This specification only allows the use of codepoint 17 (User Datagram Protocol).

The RFFU field is set to zero on transmission and ignored on receiption. It is reserved for future uses.

This describes the PRIORITY attribute from draft-ietf-mmusic-ice-13. The PRIORITY attribute indicates the priority that is to be associated with a peer reflexive candidate, should one be discovered by this check. It is a 32 bit unsigned integer, and has an attribute type of 0x0024.

This describes the STUN TIMER-VAL attribute. The TIMER-VAL attribute is used only in conjunction with the Set Active Destination response. It conveys from the server, to the client, the value of the timer used in the server state machine.

This describes TURN ICMP attribute

Public Members

pj_stun_attr_hdr hdr

Standard STUN attribute header.

pj_uint32_t value

The 32bit value, in host byte order.

struct pj_stun_uint64_attr
#include <stun_msg.h>

This structure represents a generic STUN attributes with 64bit (unsigned) integer value, such as ICE-CONTROLLED and ICE-CONTROLLING attributes.

This describes the TURN RESERVATION-TOKEN attribute. The RESERVATION-TOKEN attribute contains a token that uniquely identifies a relayed transport address being held in reserve by the server. The server includes this attribute in a success response to tell the client about the token, and the client includes this attribute in a subsequent Allocate request to request the server use that relayed transport address for the allocation.

The attribute value is a 64-bit-long field containing the token value.

This describes ICE-CONTROLLING attribute.

This describes ICE-CONTROLLED attribute.

Public Members

pj_stun_attr_hdr hdr

Standard STUN attribute header.

pj_timestamp value

The 64bit value, in host byte order, represented with pj_timestamp.

struct pj_stun_binary_attr
#include <stun_msg.h>

This structure represents generic STUN attributes to hold a raw binary data.

This describes the STUN DATA attribute. The DATA attribute is present in Send Indications and Data Indications. It contains raw payload data that is to be sent (in the case of a Send Request) or was received (in the case of a Data Indication)..

Public Members

pj_stun_attr_hdr hdr

Standard STUN attribute header.

pj_uint32_t magic

Special signature to indicate that this is a valid attribute even though we don’t have meta-data to describe this attribute.

unsigned length

Length of the data.

pj_uint8_t *data

The raw data.

struct pj_stun_msgint_attr
#include <stun_msg.h>

This structure describes STUN MESSAGE-INTEGRITY attribute. The MESSAGE-INTEGRITY attribute contains an HMAC-SHA1 [10] of the STUN message. The MESSAGE-INTEGRITY attribute can be present in any STUN message type. Since it uses the SHA1 hash, the HMAC will be 20 bytes.

Public Members

pj_stun_attr_hdr hdr

Standard STUN attribute header.

pj_uint8_t hmac[20]

The 20 bytes hmac value.

struct pj_stun_errcode_attr
#include <stun_msg.h>

This structure represents STUN ERROR-CODE attribute. The ERROR-CODE attribute is present in the Binding Error Response and Shared Secret Error Response. It is a numeric value in the range of 100 to 699 plus a textual reason phrase encoded in UTF-8

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                   0                     |Class|     Number    |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |      Reason Phrase (variable)                                ..
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Public Members

pj_stun_attr_hdr hdr

Standard STUN attribute header.

int err_code

STUN error code.

pj_str_t reason

The reason phrase.

struct pj_stun_unknown_attr
#include <stun_msg.h>

This describes STUN UNKNOWN-ATTRIBUTES attribute. The UNKNOWN-ATTRIBUTES attribute is present only in an error response when the response code in the ERROR-CODE attribute is 420. The attribute contains a list of 16 bit values, each of which represents an attribute type that was not understood by the server. If the number of unknown attributes is an odd number, one of the attributes MUST be repeated in the list, so that the total length of the list is a multiple of 4 bytes.

Public Members

pj_stun_attr_hdr hdr

Standard STUN attribute header.

unsigned attr_count

Number of unknown attributes in the array.

pj_uint16_t attrs[PJ_STUN_MAX_ATTR]

Array of unknown attribute IDs.

struct pj_stun_msg
#include <stun_msg.h>

This structure describes a parsed STUN message. All integral fields in this structure (including IP addresses) will be in the host byte order.

Public Members

pj_stun_msg_hdr hdr

STUN message header.

unsigned attr_count

Number of attributes in the STUN message.

pj_stun_attr_hdr *attr[PJ_STUN_MAX_ATTR]

Array of STUN attributes.