📄 stun_session.h
字号:
* pj_stun_session_set_user_data().
*
* @param sess The STUN session instance.
*
* @return The user data associated with this STUN session.
*/
PJ_DECL(void*) pj_stun_session_get_user_data(pj_stun_session *sess);
/**
* Set server name to be included in all response.
*
* @param sess The STUN session instance.
* @param srv_name Server name string.
*
* @return The user data associated with this STUN session.
*/
PJ_DECL(pj_status_t) pj_stun_session_set_server_name(pj_stun_session *sess,
const pj_str_t *srv_name);
/**
* Set credential to be used by this session. Once credential is set, all
* outgoing messages will include MESSAGE-INTEGRITY, and all incoming
* message will be authenticated against this credential.
*
* To disable authentication after it has been set, call this function
* again with NULL as the argument.
*
* @param sess The STUN session instance.
* @param cred The credential to be used by this session. If NULL
* is specified, authentication will be disabled.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*/
PJ_DECL(void) pj_stun_session_set_credential(pj_stun_session *sess,
const pj_stun_auth_cred *cred);
/**
* 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 tsx_id Optional transaction ID.
* @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_req(pj_stun_session *sess,
int msg_type,
const pj_uint8_t tsx_id[12],
pj_stun_tx_data **p_tdata);
/**
* 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_ind(pj_stun_session *sess,
int msg_type,
pj_stun_tx_data **p_tdata);
/**
* Create a STUN response 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 req The STUN request where the response is to be created.
* @param err_code Error code to be set in the response, if error response
* is to be created, according to pj_stun_status enumeration.
* This argument MUST be zero if successful response is
* to be created.
* @param err_msg Optional pointer for the error message string, when
* creating error response. If the value is NULL and the
* \a err_code is non-zero, then default error message will
* be used.
* @param p_tdata Pointer to receive the response message created.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*/
PJ_DECL(pj_status_t) pj_stun_session_create_res(pj_stun_session *sess,
const pj_stun_msg *req,
unsigned err_code,
const pj_str_t *err_msg,
pj_stun_tx_data **p_tdata);
/**
* Send STUN message to the specified destination. This function will encode
* the pj_stun_msg instance to a packet buffer, and add credential or
* fingerprint if necessary. If the message is a request, the session will
* also create and manage a STUN client transaction to be used to manage the
* retransmission of the request. After the message has been encoded and
* transaction is setup, the \a on_send_msg() callback of pj_stun_session_cb
* (which is registered when the STUN session is created) will be called
* to actually send the message to the wire.
*
* @param sess The STUN session instance.
* @param cache_res If PJ_TRUE then response will be cached.
* @param dst_addr The destination socket address.
* @param addr_len Length of destination address.
* @param tdata The STUN transmit data containing the STUN message to
* be sent.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*/
PJ_DECL(pj_status_t) pj_stun_session_send_msg(pj_stun_session *sess,
pj_bool_t cache_res,
const pj_sockaddr_t *dst_addr,
unsigned addr_len,
pj_stun_tx_data *tdata);
/**
* Cancel outgoing STUN transaction. This operation is only valid for outgoing
* STUN request, to cease retransmission of the request and destroy the
* STUN client transaction that is used to send the request.
*
* @param sess The STUN session instance.
* @param tdata The request message previously sent.
* @param notify Specify whether \a on_request_complete() callback should
* be called.
* @param status If \a on_request_complete() callback is to be called,
* specify the error status to be given when calling the
* callback. This error status MUST NOT be PJ_SUCCESS.
*
* @return PJ_SUCCESS if transaction is successfully cancelled.
*/
PJ_DECL(pj_status_t) pj_stun_session_cancel_req(pj_stun_session *sess,
pj_stun_tx_data *tdata,
pj_bool_t notify,
pj_status_t status);
/**
* Explicitly request retransmission of the request. Normally application
* doesn't need to do this, but this functionality is needed by ICE to
* speed up connectivity check completion.
*
* @param sess The STUN session instance.
* @param tdata The request message previously sent.
*
* @return PJ_SUCCESS on success, or the appropriate error.
*/
PJ_DECL(pj_status_t) pj_stun_session_retransmit_req(pj_stun_session *sess,
pj_stun_tx_data *tdata);
/**
* Application must call this function to notify the STUN session about
* the arrival of STUN packet. The STUN packet MUST have been checked
* first with #pj_stun_msg_check() to verify that this is indeed a valid
* STUN packet.
*
* The STUN session will decode the packet into pj_stun_msg, and process
* the message accordingly. If the message is a response, it will search
* through the outstanding STUN client transactions for a matching
* transaction ID and hand over the response to the transaction.
*
* On successful message processing, application will be notified about
* the message via one of the pj_stun_session_cb callback.
*
* @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_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).
* @param src_addr The source address of the packet.
* @param src_addr_len Length of the source address.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*/
PJ_DECL(pj_status_t) pj_stun_session_on_rx_pkt(pj_stun_session *sess,
const void *packet,
pj_size_t pkt_size,
unsigned options,
unsigned *parsed_len,
const pj_sockaddr_t *src_addr,
unsigned src_addr_len);
/**
* Destroy the transmit data. Call this function only when tdata has been
* created but application doesn't want to send the message (perhaps
* because of other error).
*
* @param sess The STUN session.
* @param tdata The transmit data.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*/
PJ_DECL(void) pj_stun_msg_destroy_tdata(pj_stun_session *sess,
pj_stun_tx_data *tdata);
/**
* @}
*/
PJ_END_DECL
#endif /* __PJNATH_STUN_SESSION_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -