19#ifndef __PJNATH_STUN_MSG_H__
20#define __PJNATH_STUN_MSG_H__
46#define PJ_STUN_MAGIC 0x2112A442
120#define PJ_STUN_GET_METHOD(msg_type) ((msg_type) & 0xFEEF)
153#define PJ_STUN_IS_REQUEST(msg_type) (((msg_type) & 0x0110) == 0x0000)
159#define PJ_STUN_IS_SUCCESS_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0100)
164#define PJ_STUN_SUCCESS_RESPONSE_BIT (0x0100)
170#define PJ_STUN_IS_ERROR_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0110)
175#define PJ_STUN_ERROR_RESPONSE_BIT (0x0110)
180#define PJ_STUN_IS_RESPONSE(msg_type) (((msg_type) & 0x0100) == 0x0100)
186#define PJ_STUN_IS_INDICATION(msg_type) (((msg_type) & 0x0110) == 0x0010)
191#define PJ_STUN_INDICATION_BIT (0x0010)
368 PJ_STUN_ATTR_END_MANDATORY_ATTR,
370 PJ_STUN_ATTR_START_EXTENDED_ATTR= 0x8021,
379 PJ_STUN_ATTR_END_EXTENDED_ATTR
938#define PJ_STUN_GET_CH_NB(u32) ((pj_uint16_t)(u32>>16))
946#define PJ_STUN_SET_CH_NB(chnum) (((pj_uint32_t)chnum) << 16)
1079#define PJ_STUN_GET_RT_PROTO(u32) (u32 >> 24)
1085#define PJ_STUN_SET_RT_PROTO(proto) (((pj_uint32_t)(proto)) << 24)
1461#if PJ_LOG_MAX_LEVEL > 0
1465 unsigned *printed_len);
1467# define pj_stun_msg_dump(msg, buf, length, printed_len) ""
1486 unsigned start_index);
#define PJ_STUN_MAX_ATTR
Definition: config.h:63
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)
const char * pj_stun_get_method_name(unsigned msg_type)
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_empty_attr_create(pj_pool_t *pool, int attr_type, pj_stun_empty_attr **p_attr)
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_uint64_attr(pj_pool_t *pool, pj_stun_msg *msg, int attr_type, const pj_timestamp *value)
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_stun_msg_type
Definition: stun_msg.h:198
pj_stun_status
Definition: stun_msg.h:388
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_string_attr(pj_pool_t *pool, pj_stun_msg *msg, int attr_type, const pj_str_t *value)
const char * pj_stun_get_class_name(unsigned msg_type)
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_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)
pj_stun_attr_hdr * pj_stun_msg_find_attr(const pj_stun_msg *msg, int attr_type, unsigned start_index)
pj_status_t pj_stun_msg_add_empty_attr(pj_pool_t *pool, pj_stun_msg *msg, int attr_type)
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_stun_method_e
Definition: stun_msg.h:53
pj_stun_decode_options
Definition: stun_msg.h:1193
pj_status_t pj_stun_msg_check(const pj_uint8_t *pdu, pj_size_t pdu_len, unsigned options)
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_stun_attr_type
Definition: stun_msg.h:333
const char * pj_stun_get_attr_name(unsigned attr_type)
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_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_sockaddr_attr_init(pj_stun_sockaddr_attr *attr, int attr_type, pj_bool_t xor_ed, const pj_sockaddr_t *addr, unsigned addr_len)
int pj_stun_set_padding_char(int chr)
pj_stun_attr_hdr * pj_stun_attr_clone(pj_pool_t *pool, const pj_stun_attr_hdr *attr)
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_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_add_attr(pj_stun_msg *msg, pj_stun_attr_hdr *attr)
pj_stun_msg_class_e
Definition: stun_msg.h:127
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_msg_add_msgint_attr(pj_pool_t *pool, pj_stun_msg *msg)
pj_str_t pj_stun_get_err_reason(int err_code)
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_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_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_msgint_attr_create(pj_pool_t *pool, pj_stun_msgint_attr **p_attr)
pj_stun_msg * pj_stun_msg_clone(pj_pool_t *pool, const pj_stun_msg *msg)
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_msg_add_binary_attr(pj_pool_t *pool, pj_stun_msg *msg, int attr_type, const pj_uint8_t *data, unsigned length)
char * pj_stun_msg_dump(const pj_stun_msg *msg, char *buffer, unsigned length, unsigned *printed_len)
@ PJ_STUN_SHARED_SECRET_ERROR_RESPONSE
Definition: stun_msg.h:232
@ PJ_STUN_REFRESH_RESPONSE
Definition: stun_msg.h:259
@ PJ_STUN_CHANNEL_BIND_REQUEST
Definition: stun_msg.h:298
@ PJ_STUN_BINDING_REQUEST
Definition: stun_msg.h:202
@ PJ_STUN_SHARED_SECRET_REQUEST
Definition: stun_msg.h:222
@ PJ_STUN_BINDING_RESPONSE
Definition: stun_msg.h:207
@ PJ_STUN_SEND_INDICATION
Definition: stun_msg.h:270
@ PJ_STUN_ALLOCATE_REQUEST
Definition: stun_msg.h:238
@ PJ_STUN_ALLOCATE_RESPONSE
Definition: stun_msg.h:243
@ PJ_STUN_CONNECTION_ATTEMPT_INDICATION
Definition: stun_msg.h:323
@ PJ_STUN_CHANNEL_BIND_RESPONSE
Definition: stun_msg.h:303
@ PJ_STUN_BINDING_ERROR_RESPONSE
Definition: stun_msg.h:212
@ PJ_STUN_REFRESH_REQUEST
Definition: stun_msg.h:254
@ PJ_STUN_CONNECTION_BIND_REQUEST
Definition: stun_msg.h:318
@ PJ_STUN_DATA_INDICATION
Definition: stun_msg.h:276
@ PJ_STUN_REFRESH_ERROR_RESPONSE
Definition: stun_msg.h:264
@ PJ_STUN_CHANNEL_BIND_ERROR_RESPONSE
Definition: stun_msg.h:308
@ PJ_STUN_BINDING_INDICATION
Definition: stun_msg.h:217
@ PJ_STUN_CREATE_PERM_REQUEST
Definition: stun_msg.h:282
@ PJ_STUN_CREATE_PERM_ERROR_RESPONSE
Definition: stun_msg.h:292
@ PJ_STUN_ALLOCATE_ERROR_RESPONSE
Definition: stun_msg.h:248
@ PJ_STUN_SHARED_SECRET_RESPONSE
Definition: stun_msg.h:227
@ PJ_STUN_CONNECT_REQUEST
Definition: stun_msg.h:313
@ PJ_STUN_CREATE_PERM_RESPONSE
Definition: stun_msg.h:287
@ PJ_STUN_SC_ROLE_CONFLICT
Definition: stun_msg.h:415
@ PJ_STUN_SC_FORBIDDEN
Definition: stun_msg.h:392
@ PJ_STUN_SC_SERVER_ERROR
Definition: stun_msg.h:416
@ PJ_STUN_SC_UNAUTHORIZED
Definition: stun_msg.h:391
@ PJ_STUN_SC_GLOBAL_FAILURE
Definition: stun_msg.h:419
@ PJ_STUN_SC_CONNECTION_TIMEOUT
Definition: stun_msg.h:412
@ PJ_STUN_SC_STALE_NONCE
Definition: stun_msg.h:405
@ PJ_STUN_SC_UNSUPP_TRANSPORT_PROTO
Definition: stun_msg.h:408
@ PJ_STUN_SC_CONNECTION_FAILURE
Definition: stun_msg.h:411
@ PJ_STUN_SC_OPER_TCP_ONLY
Definition: stun_msg.h:410
@ PJ_STUN_SC_INSUFFICIENT_CAPACITY
Definition: stun_msg.h:417
@ PJ_STUN_SC_WRONG_CREDENTIALS
Definition: stun_msg.h:407
@ PJ_STUN_SC_BAD_REQUEST
Definition: stun_msg.h:390
@ PJ_STUN_SC_ALLOCATION_QUOTA_REACHED
Definition: stun_msg.h:413
@ PJ_STUN_SC_UNKNOWN_ATTRIBUTE
Definition: stun_msg.h:393
@ PJ_STUN_SC_TRANSITIONING
Definition: stun_msg.h:406
@ PJ_STUN_SC_TRY_ALTERNATE
Definition: stun_msg.h:389
@ PJ_STUN_SC_ALLOCATION_MISMATCH
Definition: stun_msg.h:404
@ PJ_STUN_ALLOCATE_METHOD
Definition: stun_msg.h:67
@ PJ_STUN_SHARED_SECRET_METHOD
Definition: stun_msg.h:62
@ PJ_STUN_CONNECTION_ATTEMPT_METHOD
Definition: stun_msg.h:107
@ PJ_STUN_CHANNEL_BIND_METHOD
Definition: stun_msg.h:92
@ PJ_STUN_METHOD_MAX
Definition: stun_msg.h:112
@ PJ_STUN_CONNECT_METHOD
Definition: stun_msg.h:97
@ PJ_STUN_CREATE_PERM_METHOD
Definition: stun_msg.h:87
@ PJ_STUN_DATA_METHOD
Definition: stun_msg.h:82
@ PJ_STUN_CONNECTION_BIND_METHOD
Definition: stun_msg.h:102
@ PJ_STUN_REFRESH_METHOD
Definition: stun_msg.h:72
@ PJ_STUN_SEND_METHOD
Definition: stun_msg.h:77
@ PJ_STUN_BINDING_METHOD
Definition: stun_msg.h:57
@ PJ_STUN_IS_DATAGRAM
Definition: stun_msg.h:1198
@ PJ_STUN_CHECK_PACKET
Definition: stun_msg.h:1205
@ PJ_STUN_NO_FINGERPRINT_CHECK
Definition: stun_msg.h:1220
@ PJ_STUN_NO_AUTHENTICATE
Definition: stun_msg.h:1212
@ PJ_STUN_ATTR_USERNAME
Definition: stun_msg.h:339
@ PJ_STUN_ATTR_UNKNOWN_ATTRIBUTES
Definition: stun_msg.h:343
@ PJ_STUN_ATTR_DATA
Definition: stun_msg.h:350
@ PJ_STUN_ATTR_CHANGED_ADDR
Definition: stun_msg.h:338
@ PJ_STUN_ATTR_MAPPED_ADDR
Definition: stun_msg.h:334
@ PJ_STUN_ATTR_ALTERNATE_SERVER
Definition: stun_msg.h:373
@ PJ_STUN_ATTR_CHANNEL_NUMBER
Definition: stun_msg.h:345
@ PJ_STUN_ATTR_ERROR_CODE
Definition: stun_msg.h:342
@ PJ_STUN_ATTR_ICMP
Definition: stun_msg.h:366
@ PJ_STUN_ATTR_ICE_CONTROLLING
Definition: stun_msg.h:377
@ PJ_STUN_ATTR_MAGIC_COOKIE
Definition: stun_msg.h:347
@ PJ_STUN_ATTR_XOR_PEER_ADDR
Definition: stun_msg.h:349
@ PJ_STUN_ATTR_NONCE
Definition: stun_msg.h:352
@ PJ_STUN_ATTR_REQ_ADDR_TYPE
Definition: stun_msg.h:354
@ PJ_STUN_ATTR_ICE_CONTROLLED
Definition: stun_msg.h:376
@ PJ_STUN_ATTR_USE_CANDIDATE
Definition: stun_msg.h:364
@ PJ_STUN_ATTR_SOFTWARE
Definition: stun_msg.h:372
@ PJ_STUN_ATTR_REQ_TRANSPORT
Definition: stun_msg.h:357
@ PJ_STUN_ATTR_REFLECTED_FROM
Definition: stun_msg.h:344
@ PJ_STUN_ATTR_CHANGE_REQUEST
Definition: stun_msg.h:336
@ PJ_STUN_ATTR_REALM
Definition: stun_msg.h:351
@ PJ_STUN_ATTR_BANDWIDTH
Definition: stun_msg.h:348
@ PJ_STUN_ATTR_TIMER_VAL
Definition: stun_msg.h:360
@ PJ_STUN_ATTR_XOR_REFLECTED_FROM
Definition: stun_msg.h:362
@ PJ_STUN_ATTR_XOR_MAPPED_ADDR
Definition: stun_msg.h:359
@ PJ_STUN_ATTR_RESPONSE_ADDR
Definition: stun_msg.h:335
@ PJ_STUN_ATTR_CONNECTION_ID
Definition: stun_msg.h:365
@ PJ_STUN_ATTR_XOR_RELAYED_ADDR
Definition: stun_msg.h:353
@ PJ_STUN_ATTR_DONT_FRAGMENT
Definition: stun_msg.h:358
@ PJ_STUN_ATTR_REFRESH_INTERVAL
Definition: stun_msg.h:374
@ PJ_STUN_ATTR_SOURCE_ADDR
Definition: stun_msg.h:337
@ PJ_STUN_ATTR_FINGERPRINT
Definition: stun_msg.h:375
@ PJ_STUN_ATTR_PRIORITY
Definition: stun_msg.h:363
@ PJ_STUN_ATTR_RESERVATION_TOKEN
Definition: stun_msg.h:361
@ PJ_STUN_ATTR_EVEN_PORT
Definition: stun_msg.h:356
@ PJ_STUN_ATTR_LIFETIME
Definition: stun_msg.h:346
@ PJ_STUN_ATTR_REQ_ADDR_FAMILY
Definition: stun_msg.h:355
@ PJ_STUN_ATTR_PASSWORD
Definition: stun_msg.h:340
@ PJ_STUN_ATTR_MESSAGE_INTEGRITY
Definition: stun_msg.h:341
@ PJ_STUN_ERROR_CLASS
Definition: stun_msg.h:146
@ PJ_STUN_REQUEST_CLASS
Definition: stun_msg.h:131
@ PJ_STUN_SUCCESS_CLASS
Definition: stun_msg.h:141
@ PJ_STUN_INDICATION_CLASS
Definition: stun_msg.h:136
unsigned short pj_uint16_t
Definition: stun_msg.h:494
pj_uint16_t length
Definition: stun_msg.h:506
pj_uint16_t type
Definition: stun_msg.h:498
Definition: stun_msg.h:633
pj_stun_attr_hdr hdr
Definition: stun_msg.h:637
unsigned length
Definition: stun_msg.h:648
pj_uint8_t * data
Definition: stun_msg.h:653
pj_uint32_t magic
Definition: stun_msg.h:643
Definition: stun_msg.h:562
pj_stun_attr_hdr hdr
Definition: stun_msg.h:566
Definition: stun_msg.h:708
pj_str_t reason
Definition: stun_msg.h:722
int err_code
Definition: stun_msg.h:717
pj_stun_attr_hdr hdr
Definition: stun_msg.h:712
Definition: stun_msg.h:446
pj_uint16_t length
Definition: stun_msg.h:456
pj_uint16_t type
Definition: stun_msg.h:450
pj_uint32_t magic
Definition: stun_msg.h:463
pj_uint8_t tsx_id[12]
Definition: stun_msg.h:473
Definition: stun_msg.h:1172
pj_stun_msg_hdr hdr
Definition: stun_msg.h:1176
pj_stun_attr_hdr * attr[PJ_STUN_MAX_ATTR]
Definition: stun_msg.h:1186
unsigned attr_count
Definition: stun_msg.h:1181
Definition: stun_msg.h:666
pj_stun_attr_hdr hdr
Definition: stun_msg.h:670
pj_uint8_t hmac[20]
Definition: stun_msg.h:675
Definition: stun_msg.h:537
pj_stun_attr_hdr hdr
Definition: stun_msg.h:541
pj_sockaddr sockaddr
Definition: stun_msg.h:552
pj_bool_t xor_ed
Definition: stun_msg.h:547
Definition: stun_msg.h:576
pj_stun_attr_hdr hdr
Definition: stun_msg.h:580
pj_str_t value
Definition: stun_msg.h:585
Definition: stun_msg.h:614
pj_timestamp value
Definition: stun_msg.h:623
pj_stun_attr_hdr hdr
Definition: stun_msg.h:618
Definition: stun_msg.h:595
pj_uint32_t value
Definition: stun_msg.h:604
pj_stun_attr_hdr hdr
Definition: stun_msg.h:599
Definition: stun_msg.h:758
pj_uint16_t attrs[PJ_STUN_MAX_ATTR]
Definition: stun_msg.h:772
pj_stun_attr_hdr hdr
Definition: stun_msg.h:762
unsigned attr_count
Definition: stun_msg.h:767