Home --> Documentations --> PJNATH Reference

stun_msg.h File Reference

STUN message components. More...

Go to the source code of this file.

Data Structures

struct  pj_stun_msg_hdr
 
struct  pj_stun_attr_hdr
 
struct  pj_stun_xor_reflected_from_attr
 
struct  pj_stun_use_candidate_attr
 
struct  pj_stun_password_attr
 
struct  pj_stun_icmp_attr
 
struct  pj_stun_ice_controlled_attr
 
struct  pj_stun_data_attr
 
struct  pj_stun_msgint_attr
 
struct  pj_stun_errcode_attr
 
struct  pj_stun_unknown_attr
 
struct  pj_stun_msg
 

Macros

#define PJ_STUN_MAGIC   0x2112A442
 
#define PJ_STUN_GET_METHOD(msg_type)   ((msg_type) & 0xFEEF)
 
#define PJ_STUN_IS_REQUEST(msg_type)   (((msg_type) & 0x0110) == 0x0000)
 
#define PJ_STUN_IS_SUCCESS_RESPONSE(msg_type)   (((msg_type) & 0x0110) == 0x0100)
 
#define PJ_STUN_SUCCESS_RESPONSE_BIT   (0x0100)
 
#define PJ_STUN_IS_ERROR_RESPONSE(msg_type)   (((msg_type) & 0x0110) == 0x0110)
 
#define PJ_STUN_ERROR_RESPONSE_BIT   (0x0110)
 
#define PJ_STUN_IS_RESPONSE(msg_type)   (((msg_type) & 0x0100) == 0x0100)
 
#define PJ_STUN_IS_INDICATION(msg_type)   (((msg_type) & 0x0110) == 0x0010)
 
#define PJ_STUN_INDICATION_BIT   (0x0010)
 
#define PJ_STUN_GET_CH_NB(u32)   ((pj_uint16_t)(u32>>16))
 
#define PJ_STUN_SET_CH_NB(chnum)   (((pj_uint32_t)chnum) << 16)
 
#define PJ_STUN_GET_RT_PROTO(u32)   (u32 >> 24)
 
#define PJ_STUN_SET_RT_PROTO(proto)   (((pj_uint32_t)(proto)) << 24)
 

Enumerations

enum  pj_stun_method_e {
  PJ_STUN_BINDING_METHOD = 1,
  PJ_STUN_SHARED_SECRET_METHOD = 2,
  PJ_STUN_ALLOCATE_METHOD = 3,
  PJ_STUN_REFRESH_METHOD = 4,
  PJ_STUN_SEND_METHOD = 6,
  PJ_STUN_DATA_METHOD = 7,
  PJ_STUN_CREATE_PERM_METHOD = 8,
  PJ_STUN_CHANNEL_BIND_METHOD = 9,
  PJ_STUN_METHOD_MAX
}
 
enum  pj_stun_msg_class_e {
  PJ_STUN_REQUEST_CLASS = 0,
  PJ_STUN_INDICATION_CLASS = 1,
  PJ_STUN_SUCCESS_CLASS = 2,
  PJ_STUN_ERROR_CLASS = 3
}
 
enum  pj_stun_msg_type {
  PJ_STUN_BINDING_REQUEST = 0x0001,
  PJ_STUN_BINDING_RESPONSE = 0x0101,
  PJ_STUN_BINDING_ERROR_RESPONSE = 0x0111,
  PJ_STUN_BINDING_INDICATION = 0x0011,
  PJ_STUN_SHARED_SECRET_REQUEST = 0x0002,
  PJ_STUN_SHARED_SECRET_RESPONSE = 0x0102,
  PJ_STUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112,
  PJ_STUN_ALLOCATE_REQUEST = 0x0003,
  PJ_STUN_ALLOCATE_RESPONSE = 0x0103,
  PJ_STUN_ALLOCATE_ERROR_RESPONSE = 0x0113,
  PJ_STUN_REFRESH_REQUEST = 0x0004,
  PJ_STUN_REFRESH_RESPONSE = 0x0104,
  PJ_STUN_REFRESH_ERROR_RESPONSE = 0x0114,
  PJ_STUN_SEND_INDICATION = 0x0016,
  PJ_STUN_DATA_INDICATION = 0x0017,
  PJ_STUN_CREATE_PERM_REQUEST = 0x0008,
  PJ_STUN_CREATE_PERM_RESPONSE = 0x0108,
  PJ_STUN_CREATE_PERM_ERROR_RESPONSE = 0x0118,
  PJ_STUN_CHANNEL_BIND_REQUEST = 0x0009,
  PJ_STUN_CHANNEL_BIND_RESPONSE = 0x0109,
  PJ_STUN_CHANNEL_BIND_ERROR_RESPONSE = 0x0119
}
 
enum  pj_stun_attr_type {
  PJ_STUN_ATTR_MAPPED_ADDR = 0x0001,
  PJ_STUN_ATTR_RESPONSE_ADDR = 0x0002,
  PJ_STUN_ATTR_CHANGE_REQUEST = 0x0003,
  PJ_STUN_ATTR_SOURCE_ADDR = 0x0004,
  PJ_STUN_ATTR_CHANGED_ADDR = 0x0005,
  PJ_STUN_ATTR_USERNAME = 0x0006,
  PJ_STUN_ATTR_PASSWORD = 0x0007,
  PJ_STUN_ATTR_MESSAGE_INTEGRITY = 0x0008,
  PJ_STUN_ATTR_ERROR_CODE = 0x0009,
  PJ_STUN_ATTR_UNKNOWN_ATTRIBUTES = 0x000A,
  PJ_STUN_ATTR_REFLECTED_FROM = 0x000B,
  PJ_STUN_ATTR_CHANNEL_NUMBER = 0x000C,
  PJ_STUN_ATTR_LIFETIME = 0x000D,
  PJ_STUN_ATTR_MAGIC_COOKIE = 0x000F,
  PJ_STUN_ATTR_BANDWIDTH = 0x0010,
  PJ_STUN_ATTR_XOR_PEER_ADDR = 0x0012,
  PJ_STUN_ATTR_DATA = 0x0013,
  PJ_STUN_ATTR_REALM = 0x0014,
  PJ_STUN_ATTR_NONCE = 0x0015,
  PJ_STUN_ATTR_XOR_RELAYED_ADDR = 0x0016,
  PJ_STUN_ATTR_REQ_ADDR_TYPE = 0x0017,
  PJ_STUN_ATTR_REQ_ADDR_FAMILY = 0x0017,
  PJ_STUN_ATTR_EVEN_PORT = 0x0018,
  PJ_STUN_ATTR_REQ_TRANSPORT = 0x0019,
  PJ_STUN_ATTR_DONT_FRAGMENT = 0x001A,
  PJ_STUN_ATTR_XOR_MAPPED_ADDR = 0x0020,
  PJ_STUN_ATTR_TIMER_VAL = 0x0021,
  PJ_STUN_ATTR_RESERVATION_TOKEN = 0x0022,
  PJ_STUN_ATTR_XOR_REFLECTED_FROM = 0x0023,
  PJ_STUN_ATTR_PRIORITY = 0x0024,
  PJ_STUN_ATTR_USE_CANDIDATE = 0x0025,
  PJ_STUN_ATTR_ICMP = 0x0030,
  PJ_STUN_ATTR_END_MANDATORY_ATTR,
  PJ_STUN_ATTR_START_EXTENDED_ATTR = 0x8021,
  PJ_STUN_ATTR_SOFTWARE = 0x8022,
  PJ_STUN_ATTR_ALTERNATE_SERVER = 0x8023,
  PJ_STUN_ATTR_REFRESH_INTERVAL = 0x8024,
  PJ_STUN_ATTR_FINGERPRINT = 0x8028,
  PJ_STUN_ATTR_ICE_CONTROLLED = 0x8029,
  PJ_STUN_ATTR_ICE_CONTROLLING = 0x802a,
  PJ_STUN_ATTR_END_EXTENDED_ATTR
}
 
enum  pj_stun_status {
  PJ_STUN_SC_TRY_ALTERNATE = 300,
  PJ_STUN_SC_BAD_REQUEST = 400,
  PJ_STUN_SC_UNAUTHORIZED = 401,
  PJ_STUN_SC_FORBIDDEN = 403,
  PJ_STUN_SC_UNKNOWN_ATTRIBUTE = 420,
  PJ_STUN_SC_ALLOCATION_MISMATCH = 437,
  PJ_STUN_SC_STALE_NONCE = 438,
  PJ_STUN_SC_TRANSITIONING = 439,
  PJ_STUN_SC_WRONG_CREDENTIALS = 441,
  PJ_STUN_SC_UNSUPP_TRANSPORT_PROTO = 442,
  PJ_STUN_SC_OPER_TCP_ONLY = 445,
  PJ_STUN_SC_CONNECTION_FAILURE = 446,
  PJ_STUN_SC_CONNECTION_TIMEOUT = 447,
  PJ_STUN_SC_ALLOCATION_QUOTA_REACHED = 486,
  PJ_STUN_SC_ROLE_CONFLICT = 487,
  PJ_STUN_SC_SERVER_ERROR = 500,
  PJ_STUN_SC_INSUFFICIENT_CAPACITY = 508,
  PJ_STUN_SC_GLOBAL_FAILURE = 600
}
 
enum  pj_stun_decode_options {
  PJ_STUN_IS_DATAGRAM = 1,
  PJ_STUN_CHECK_PACKET = 2,
  PJ_STUN_NO_AUTHENTICATE = 4,
  PJ_STUN_NO_FINGERPRINT_CHECK = 8
}
 

Functions

const char * pj_stun_get_method_name (unsigned msg_type)
 
const char * pj_stun_get_class_name (unsigned msg_type)
 
const char * pj_stun_get_attr_name (unsigned attr_type)
 
pj_str_t pj_stun_get_err_reason (int err_code)
 
int pj_stun_set_padding_char (int chr)
 
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])
 
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)
 
pj_stun_msgpj_stun_msg_clone (pj_pool_t *pool, const pj_stun_msg *msg)
 
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)
 
pj_status_t pj_stun_msg_add_attr (pj_stun_msg *msg, pj_stun_attr_hdr *attr)
 
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)
 
pj_status_t pj_stun_msg_check (const pj_uint8_t *pdu, pj_size_t pdu_len, unsigned options)
 
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)
 
char * pj_stun_msg_dump (const pj_stun_msg *msg, char *buffer, unsigned length, unsigned *printed_len)
 
pj_stun_attr_hdrpj_stun_msg_find_attr (const pj_stun_msg *msg, int attr_type, unsigned start_index)
 
pj_stun_attr_hdrpj_stun_attr_clone (pj_pool_t *pool, const pj_stun_attr_hdr *attr)
 
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)
 
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)
 
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)
 
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)
 
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)
 
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)
 
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)
 
pj_status_t pj_stun_msg_add_uint_attr (pj_pool_t *pool, pj_stun_msg *msg, int attr_type, pj_uint32_t value)
 
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)
 
pj_status_t pj_stun_msg_add_uint64_attr (pj_pool_t *pool, pj_stun_msg *msg, int attr_type, const pj_timestamp *value)
 
pj_status_t pj_stun_msgint_attr_create (pj_pool_t *pool, pj_stun_msgint_attr **p_attr)
 
pj_status_t pj_stun_msg_add_msgint_attr (pj_pool_t *pool, pj_stun_msg *msg)
 
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)
 
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)
 
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)
 
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[])
 
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)
 
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)
 
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)
 
pj_status_t pj_stun_empty_attr_create (pj_pool_t *pool, int attr_type, pj_stun_empty_attr **p_attr)
 
pj_status_t pj_stun_msg_add_empty_attr (pj_pool_t *pool, pj_stun_msg *msg, int attr_type)
 

 


PJNATH - Open Source NAT traversal helper library supporting STUN, TURN, and ICE
Copyright (C) 2006-2009 Teluu Inc.