From 5718c9d17d1cbbb19dbaa4fc517c873832420624 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 9 Mar 2007 23:25:11 +0000 Subject: Today's work on TURN server. All looks to be implemented git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1052 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib-util/include/pjlib-util/stun_msg.h | 57 ++++++++-------- pjlib-util/include/pjlib-util/stun_session.h | 98 +++++----------------------- 2 files changed, 46 insertions(+), 109 deletions(-) (limited to 'pjlib-util/include') diff --git a/pjlib-util/include/pjlib-util/stun_msg.h b/pjlib-util/include/pjlib-util/stun_msg.h index 7a38c9d4..b9b9275d 100644 --- a/pjlib-util/include/pjlib-util/stun_msg.h +++ b/pjlib-util/include/pjlib-util/stun_msg.h @@ -334,7 +334,7 @@ typedef enum pj_stun_attr_type PJ_STUN_ATTR_REFLECTED_FROM = 0x000B,/**< REFLECTED-FROM (deprecatd)*/ PJ_STUN_ATTR_LIFETIME = 0x000D,/**< LIFETIME attribute. */ PJ_STUN_ATTR_BANDWIDTH = 0x0010,/**< BANDWIDTH attribute */ - PJ_STUN_ATTR_REMOTE_ADDRESS = 0x0012,/**< REMOTE-ADDRESS attribute */ + PJ_STUN_ATTR_REMOTE_ADDR = 0x0012,/**< REMOTE-ADDRESS attribute */ PJ_STUN_ATTR_DATA = 0x0013,/**< DATA attribute. */ PJ_STUN_ATTR_REALM = 0x0014,/**< REALM attribute. */ PJ_STUN_ATTR_NONCE = 0x0015,/**< NONCE attribute. */ @@ -354,10 +354,10 @@ typedef enum pj_stun_attr_type PJ_STUN_ATTR_START_EXTENDED_ATTR= 0x8021, - PJ_STUN_ATTR_FINGERPRINT = 0x8021,/**< FINGERPRINT attribute. */ PJ_STUN_ATTR_SERVER = 0x8022,/**< SERVER attribute. */ PJ_STUN_ATTR_ALTERNATE_SERVER = 0x8023,/**< ALTERNATE-SERVER. */ PJ_STUN_ATTR_REFRESH_INTERVAL = 0x8024,/**< REFRESH-INTERVAL. */ + PJ_STUN_ATTR_FINGERPRINT = 0x8028,/**< FINGERPRINT attribute. */ PJ_STUN_ATTR_END_EXTENDED_ATTR @@ -369,31 +369,34 @@ typedef enum pj_stun_attr_type */ typedef enum pj_stun_status { - PJ_STUN_STATUS_TRY_ALTERNATE = 300, /**< Try Alternate */ - PJ_STUN_STATUS_BAD_REQUEST = 400, /**< Bad Request */ - PJ_STUN_STATUS_UNAUTHORIZED = 401, /**< Unauthorized */ - PJ_STUN_STATUS_UNKNOWN_ATTRIBUTE = 420, /**< Unknown Attribute */ - PJ_STUN_STATUS_STALE_CREDENTIALS = 430, /**< Stale Credentials */ - PJ_STUN_STATUS_INTEGRITY_CHECK_FAILURE = 431, /**< Integrity Chk Fail */ - PJ_STUN_STATUS_MISSING_USERNAME = 432, /**< Missing Username */ - PJ_STUN_STATUS_USE_TLS = 433, /**< Use TLS */ - PJ_STUN_STATUS_MISSING_REALM = 434, /**< Missing Realm */ - PJ_STUN_STATUS_MISSING_NONCE = 435, /**< Missing Nonce */ - PJ_STUN_STATUS_UNKNOWN_USERNAME = 436, /**< Unknown Username */ - PJ_STUN_STATUS_NO_BINDING = 437, /**< No Binding. */ - PJ_STUN_STATUS_STALE_NONCE = 438, /**< Stale Nonce */ - PJ_STUN_STATUS_TRANSITIONING = 439, /**< Transitioning. */ - PJ_STUN_STATUS_WRONG_USERNAME = 441, /**< Wrong Username. */ - PJ_STUN_STATUS_UNSUPP_TRANSPORT_PROTO = 442, /**< Unsupported Transport Protocol */ - PJ_STUN_STATUS_INVALID_IP_ADDR = 443, /**< Invalid IP Address */ - PJ_STUN_STATUS_INVALID_PORT = 444, /**< Invalid Port */ - PJ_STUN_STATUS_OPER_TCP_ONLY = 445, /**< Operation for TCP Only */ - PJ_STUN_STATUS_CONNECTION_FAILURE = 446, /**< Connection Failure */ - PJ_STUN_STATUS_CONNECTION_TIMEOUT = 447, /**< Connection Timeout */ - PJ_STUN_STATUS_ALLOCATION_QUOTA_REACHED = 486, /**< Allocation Quota Reached (TURN) */ - PJ_STUN_STATUS_SERVER_ERROR = 500, /**< Server Error */ - PJ_STUN_STATUS_INSUFFICIENT_CAPACITY = 507, /**< Insufficient Capacity (TURN) */ - PJ_STUN_STATUS_GLOBAL_FAILURE = 600 /**< Global Failure */ + PJ_STUN_SC_TRY_ALTERNATE = 300, /**< Try Alternate */ + PJ_STUN_SC_BAD_REQUEST = 400, /**< Bad Request */ + PJ_STUN_SC_UNAUTHORIZED = 401, /**< Unauthorized */ + PJ_STUN_SC_UNKNOWN_ATTRIBUTE = 420, /**< Unknown Attribute */ + PJ_STUN_SC_STALE_CREDENTIALS = 430, /**< Stale Credentials */ + PJ_STUN_SC_INTEGRITY_CHECK_FAILURE = 431, /**< Integrity Chk Fail */ + PJ_STUN_SC_MISSING_USERNAME = 432, /**< Missing Username */ + PJ_STUN_SC_USE_TLS = 433, /**< Use TLS */ + PJ_STUN_SC_MISSING_REALM = 434, /**< Missing Realm */ + PJ_STUN_SC_MISSING_NONCE = 435, /**< Missing Nonce */ + PJ_STUN_SC_UNKNOWN_USERNAME = 436, /**< Unknown Username */ + PJ_STUN_SC_NO_BINDING = 437, /**< No Binding. */ + PJ_STUN_SC_STALE_NONCE = 438, /**< Stale Nonce */ + PJ_STUN_SC_TRANSITIONING = 439, /**< Transitioning. */ + PJ_STUN_SC_WRONG_USERNAME = 441, /**< Wrong Username. */ + PJ_STUN_SC_UNSUPP_TRANSPORT_PROTO = 442, /**< Unsupported Transport or + Protocol */ + PJ_STUN_SC_INVALID_IP_ADDR = 443, /**< Invalid IP Address */ + PJ_STUN_SC_INVALID_PORT = 444, /**< Invalid Port */ + PJ_STUN_SC_OPER_TCP_ONLY = 445, /**< Operation for TCP Only */ + PJ_STUN_SC_CONNECTION_FAILURE = 446, /**< Connection Failure */ + PJ_STUN_SC_CONNECTION_TIMEOUT = 447, /**< Connection Timeout */ + PJ_STUN_SC_ALLOCATION_QUOTA_REACHED = 486, /**< Allocation Quota Reached + (TURN) */ + PJ_STUN_SC_SERVER_ERROR = 500, /**< Server Error */ + PJ_STUN_SC_INSUFFICIENT_CAPACITY = 507, /**< Insufficient Capacity + (TURN) */ + PJ_STUN_SC_GLOBAL_FAILURE = 600 /**< Global Failure */ } pj_stun_status; diff --git a/pjlib-util/include/pjlib-util/stun_session.h b/pjlib-util/include/pjlib-util/stun_session.h index 8fe7b1ca..81fc5640 100644 --- a/pjlib-util/include/pjlib-util/stun_session.h +++ b/pjlib-util/include/pjlib-util/stun_session.h @@ -138,7 +138,6 @@ struct pj_stun_tx_data pj_pool_t *pool; /**< Pool. */ pj_stun_session *sess; /**< The STUN session. */ pj_stun_msg *msg; /**< The STUN message. */ - void *user_data; /**< Arbitrary user data. */ pj_stun_client_tsx *client_tsx; /**< Client STUN transaction. */ pj_uint32_t msg_magic; /**< Message magic. */ @@ -232,104 +231,39 @@ PJ_DECL(void) pj_stun_session_set_credential(pj_stun_session *sess, const pj_stun_auth_cred *cred); /** - * Create a STUN Bind request message. After the message has been - * successfully created, application can send the message by calling + * Create a STUN request message. After the message has been successfully + * created, application can send the message by calling * pj_stun_session_send_msg(). * * @param sess The STUN session instance. + * @param msg_type The STUN request message type, from pj_stun_method_e or + * from pj_stun_msg_type. * @param p_tdata Pointer to receive STUN transmit data instance containing * the request. * * @return PJ_SUCCESS on success, or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_stun_session_create_bind_req(pj_stun_session *sess, - pj_stun_tx_data **p_tdata); +PJ_DECL(pj_status_t) pj_stun_session_create_req(pj_stun_session *sess, + int msg_type, + pj_stun_tx_data **p_tdata); /** - * Create a STUN Allocate request message. After the message has been - * successfully created, application can send the message by calling - * pj_stun_session_send_msg(). - * - * @param sess The STUN session instance. - * @param p_tdata Pointer to receive STUN transmit data instance containing - * the request. - * - * @return PJ_SUCCESS on success, or the appropriate error code. - */ -PJ_DECL(pj_status_t) pj_stun_session_create_allocate_req(pj_stun_session *sess, - pj_stun_tx_data **p_tdata); - -/** - * Create a STUN Set Active Destination request message. After the message - * has been successfully created, application can send the message by calling - * pj_stun_session_send_msg(). - * - * @param sess The STUN session instance. - * @param p_tdata Pointer to receive STUN transmit data instance containing - * the request. - * - * @return PJ_SUCCESS on success, or the appropriate error code. - */ -PJ_DECL(pj_status_t) -pj_stun_session_create_set_active_destination_req(pj_stun_session *sess, - pj_stun_tx_data **p_tdata); - -/** - * Create a STUN Connect request message. After the message has been - * successfully created, application can send the message by calling - * pj_stun_session_send_msg(). - * - * @param sess The STUN session instance. - * @param p_tdata Pointer to receive STUN transmit data instance containing - * the request. - * - * @return PJ_SUCCESS on success, or the appropriate error code. - */ -PJ_DECL(pj_status_t) pj_stun_session_create_connect_req(pj_stun_session *sess, - pj_stun_tx_data **p_tdata); - -/** - * Create a STUN Connection Status Indication message. After the message - * has been successfully created, application can send the message by calling - * pj_stun_session_send_msg(). - * - * @param sess The STUN session instance. - * @param p_tdata Pointer to receive STUN transmit data instance containing - * the message. - * - * @return PJ_SUCCESS on success, or the appropriate error code. - */ -PJ_DECL(pj_status_t) -pj_stun_session_create_connection_status_ind(pj_stun_session *sess, - pj_stun_tx_data **p_tdata); - -/** - * Create a STUN Send Indication message. After the message has been - * successfully created, application can send the message by calling - * pj_stun_session_send_msg(). - * - * @param sess The STUN session instance. - * @param p_tdata Pointer to receive STUN transmit data instance containing - * the message. - * - * @return PJ_SUCCESS on success, or the appropriate error code. - */ -PJ_DECL(pj_status_t) pj_stun_session_create_send_ind(pj_stun_session *sess, - pj_stun_tx_data **p_tdata); - -/** - * Create a STUN Data Indication message. After the message has been - * successfully created, application can send the message by calling + * Create a STUN Indication message. After the message has been successfully + * created, application can send the message by calling * pj_stun_session_send_msg(). * * @param sess The STUN session instance. + * @param msg_type The STUN request message type, from pj_stun_method_e or + * from pj_stun_msg_type. This function will add the + * indication bit as necessary. * @param p_tdata Pointer to receive STUN transmit data instance containing * the message. * * @return PJ_SUCCESS on success, or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_stun_session_create_data_ind(pj_stun_session *sess, - pj_stun_tx_data **p_tdata); +PJ_DECL(pj_status_t) pj_stun_session_create_ind(pj_stun_session *sess, + int msg_type, + pj_stun_tx_data **p_tdata); /** * Create a STUN response message. After the message has been @@ -399,7 +333,7 @@ PJ_DECL(pj_status_t) pj_stun_session_send_msg(pj_stun_session *sess, * @param sess The STUN session instance. * @param packet The packet containing STUN message. * @param pkt_size Size of the packet. - * @param options Options, from pj_stun_options. + * @param options Options, from #pj_stun_decode_options. * @param parsed_len Optional pointer to receive the size of the parsed * STUN message (useful if packet is received via a * stream oriented protocol). -- cgit v1.2.3