diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-03-28 15:49:48 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-03-28 15:49:48 +0000 |
commit | b461f076273b3bf78c5f889515cc7541e9d3b701 (patch) | |
tree | 1eb57d0d03bc90a07b246e417b0b099cc78ca4ca /pjnath/include | |
parent | 047dad8b9f0e7ef5c92ce4e750bcfbb20d4c4796 (diff) |
Updated projects and Makefiles with the new pjnath library
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1111 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath/include')
-rw-r--r-- | pjnath/include/pjnath.h | 4 | ||||
-rw-r--r-- | pjnath/include/pjnath/ice_session.h (renamed from pjnath/include/pjnath/ice.h) | 246 | ||||
-rw-r--r-- | pjnath/include/pjnath/ice_strans.h (renamed from pjnath/include/pjnath/ice_stream_transport.h) | 166 | ||||
-rw-r--r-- | pjnath/include/pjnath/stun_msg.h | 2 | ||||
-rw-r--r-- | pjnath/include/pjnath/types.h | 31 |
5 files changed, 236 insertions, 213 deletions
diff --git a/pjnath/include/pjnath.h b/pjnath/include/pjnath.h index 68eab315..20fb28b4 100644 --- a/pjnath/include/pjnath.h +++ b/pjnath/include/pjnath.h @@ -19,8 +19,8 @@ #include <pjnath/config.h> #include <pjnath/errno.h> -#include <pjnath/ice.h> -#include <pjnath/ice_stream_transport.h> +#include <pjnath/ice_session.h> +#include <pjnath/ice_strans.h> #include <pjnath/stun_auth.h> #include <pjnath/stun_config.h> #include <pjnath/stun_msg.h> diff --git a/pjnath/include/pjnath/ice.h b/pjnath/include/pjnath/ice_session.h index 02c05882..fd7da751 100644 --- a/pjnath/include/pjnath/ice.h +++ b/pjnath/include/pjnath/ice_session.h @@ -20,7 +20,7 @@ #define __PJNATH_ICE_SOCK_H__ /** - * @file ice.h + * @file ice_session.h * @brief ICE session management */ #include <pjnath/types.h> @@ -43,10 +43,10 @@ PJ_BEGIN_DECL * @ingroup PJNATH_ICE * @{ * - * This module describes #pj_ice, a transport independent ICE session, + * This module describes #pj_ice_sess, a transport independent ICE session, * part of PJNATH - the Open Source NAT helper library. * - * An ICE session, represented by #pj_ice structure, is the lowest + * An ICE session, represented by #pj_ice_sess structure, is the lowest * abstraction of ICE in PJNATH, and it is used to perform and manage * connectivity checks of transport address candidates <b>within a * single media stream</b> (note: this differs from what is described @@ -69,10 +69,31 @@ PJ_BEGIN_DECL */ typedef enum pj_ice_cand_type { - PJ_ICE_CAND_TYPE_HOST, /**< ICE host candidate. */ - PJ_ICE_CAND_TYPE_SRFLX, /**< ICE server reflexive candidate. */ - PJ_ICE_CAND_TYPE_PRFLX, /**< ICE peer reflexive candidate. */ - PJ_ICE_CAND_TYPE_RELAYED /**< ICE relayed candidate. */ + /** + * ICE host candidate. A host candidate represents the actual local + * transport address in the host. + */ + PJ_ICE_CAND_TYPE_HOST, + + /** + * ICE server reflexive candidate, which represents the public mapped + * address of the local address, and is obtained by sending STUN + * Binding request from the host candidate to a STUN server. + */ + PJ_ICE_CAND_TYPE_SRFLX, + + /** + * ICE peer reflexive candidate, which is the address as seen by peer + * agent during connectivity check. + */ + PJ_ICE_CAND_TYPE_PRFLX, + + /** + * ICE relayed candidate, which represents the address allocated in + * TURN server. + */ + PJ_ICE_CAND_TYPE_RELAYED + } pj_ice_cand_type; @@ -88,11 +109,11 @@ enum pj_ice_type_pref PJ_ICE_RELAYED_PREF = 0 /**< Preference value for relay */ }; -/** Forward declaration for pj_ice */ -typedef struct pj_ice pj_ice; +/** Forward declaration for pj_ice_sess */ +typedef struct pj_ice_sess pj_ice_sess; -/** Forward declaration for pj_ice_check */ -typedef struct pj_ice_check pj_ice_check; +/** Forward declaration for pj_ice_sess_check */ +typedef struct pj_ice_sess_check pj_ice_sess_check; /** @@ -102,16 +123,16 @@ typedef struct pj_ice_check pj_ice_check; * based on RTP, there are two components per media stream - one for RTP, * and one for RTCP. */ -typedef struct pj_ice_comp +typedef struct pj_ice_sess_comp { /** * The pointer to ICE check which was nominated for this component. * The value will be NULL if a nominated check has not been found * for this component. */ - pj_ice_check *valid_check; + pj_ice_sess_check *valid_check; -} pj_ice_comp; +} pj_ice_sess_comp; /** @@ -122,7 +143,7 @@ typedef struct pj_ice_comp * (server reflexive, relayed or host), priority, foundation, and * base. */ -typedef struct pj_ice_cand +typedef struct pj_ice_sess_cand { /** * The component ID of this candidate. Note that component IDs starts @@ -184,50 +205,50 @@ typedef struct pj_ice_cand */ pj_stun_session *stun_sess; -} pj_ice_cand; +} pj_ice_sess_cand; /** * This enumeration describes the state of ICE check. */ -typedef enum pj_ice_check_state +typedef enum pj_ice_sess_check_state { /** * A check for this pair hasn't been performed, and it can't * yet be performed until some other check succeeds, allowing this * pair to unfreeze and move into the Waiting state. */ - PJ_ICE_CHECK_STATE_FROZEN, + PJ_ICE_SESS_CHECK_STATE_FROZEN, /** * A check has not been performed for this pair, and can be * performed as soon as it is the highest priority Waiting pair on * the check list. */ - PJ_ICE_CHECK_STATE_WAITING, + PJ_ICE_SESS_CHECK_STATE_WAITING, /** * A check has not been performed for this pair, and can be * performed as soon as it is the highest priority Waiting pair on * the check list. */ - PJ_ICE_CHECK_STATE_IN_PROGRESS, + PJ_ICE_SESS_CHECK_STATE_IN_PROGRESS, /** * A check has not been performed for this pair, and can be * performed as soon as it is the highest priority Waiting pair on * the check list. */ - PJ_ICE_CHECK_STATE_SUCCEEDED, + PJ_ICE_SESS_CHECK_STATE_SUCCEEDED, /** * A check for this pair was already done and failed, either * never producing any response or producing an unrecoverable failure * response. */ - PJ_ICE_CHECK_STATE_FAILED + PJ_ICE_SESS_CHECK_STATE_FAILED -} pj_ice_check_state; +} pj_ice_sess_check_state; /** @@ -237,17 +258,17 @@ typedef enum pj_ice_check_state * A check is sent from the local candidate to the remote candidate * of a candidate pair. */ -struct pj_ice_check +struct pj_ice_sess_check { /** * Pointer to local candidate entry of this check. */ - pj_ice_cand *lcand; + pj_ice_sess_cand *lcand; /** * Pointer to remote candidate entry of this check. */ - pj_ice_cand *rcand; + pj_ice_sess_cand *rcand; /** * Check priority. @@ -257,7 +278,7 @@ struct pj_ice_check /** * Connectivity check state. */ - pj_ice_check_state state; + pj_ice_sess_check_state state; /** * STUN transmit data containing STUN Binding request that was sent @@ -284,38 +305,38 @@ struct pj_ice_check /** * This enumeration describes ICE checklist state. */ -typedef enum pj_ice_checklist_state +typedef enum pj_ice_sess_checklist_state { /** * The checklist is not yet running. */ - PJ_ICE_CHECKLIST_ST_IDLE, + PJ_ICE_SESS_CHECKLIST_ST_IDLE, /** * In this state, ICE checks are still in progress for this * media stream. */ - PJ_ICE_CHECKLIST_ST_RUNNING, + PJ_ICE_SESS_CHECKLIST_ST_RUNNING, /** * In this state, ICE checks have completed for this media stream, * either successfully or with failure. */ - PJ_ICE_CHECKLIST_ST_COMPLETED + PJ_ICE_SESS_CHECKLIST_ST_COMPLETED -} pj_ice_checklist_state; +} pj_ice_sess_checklist_state; /** * This structure represents ICE check list, that is an ordered set of * candidate pairs that an agent will use to generate checks. */ -typedef struct pj_ice_checklist +typedef struct pj_ice_sess_checklist { /** * The checklist state. */ - pj_ice_checklist_state state; + pj_ice_sess_checklist_state state; /** * Number of candidate pairs (checks). @@ -325,21 +346,21 @@ typedef struct pj_ice_checklist /** * Array of candidate pairs (checks). */ - pj_ice_check checks[PJ_ICE_MAX_CHECKS]; + pj_ice_sess_check checks[PJ_ICE_MAX_CHECKS]; /** * A timer used to perform periodic check for this checklist. */ pj_timer_entry timer; -} pj_ice_checklist; +} pj_ice_sess_checklist; /** * This structure contains callbacks that will be called by the ICE * session. */ -typedef struct pj_ice_cb +typedef struct pj_ice_sess_cb { /** * An optional callback that will be called by the ICE session when @@ -349,7 +370,7 @@ typedef struct pj_ice_cb * @param status Will contain PJ_SUCCESS if ICE negotiation is * successful, or some error code. */ - void (*on_ice_complete)(pj_ice *ice, pj_status_t status); + void (*on_ice_complete)(pj_ice_sess *ice, pj_status_t status); /** * A mandatory callback which will be called by the ICE session when @@ -363,7 +384,7 @@ typedef struct pj_ice_cb * @param dst_addr Packet destination address. * @param dst_addr_len Length of destination address. */ - pj_status_t (*on_tx_pkt)(pj_ice *ice, unsigned comp_id, + pj_status_t (*on_tx_pkt)(pj_ice_sess *ice, unsigned comp_id, unsigned cand_id, const void *pkt, pj_size_t size, const pj_sockaddr_t *dst_addr, @@ -381,29 +402,29 @@ typedef struct pj_ice_cb * from. * @param src_addr_len The length of source address. */ - void (*on_rx_data)(pj_ice *ice, unsigned comp_id, + void (*on_rx_data)(pj_ice_sess *ice, unsigned comp_id, void *pkt, pj_size_t size, const pj_sockaddr_t *src_addr, unsigned src_addr_len); -} pj_ice_cb; +} pj_ice_sess_cb; /** - * This enumeration describes ICE role. + * This enumeration describes the role of the ICE agent. */ -typedef enum pj_ice_role +typedef enum pj_ice_sess_role { /** * The ICE agent is in controlled role. */ - PJ_ICE_ROLE_CONTROLLED, + PJ_ICE_SESS_ROLE_CONTROLLED, /** * The ICE agent is in controlling role. */ - PJ_ICE_ROLE_CONTROLLING + PJ_ICE_SESS_ROLE_CONTROLLING -} pj_ice_role; +} pj_ice_sess_role; /** @@ -415,17 +436,17 @@ typedef enum pj_ice_role * while still allowing application to utilize multiple media streams by * creating multiple ICE sessions, one for each media stream. */ -struct pj_ice +struct pj_ice_sess { char obj_name[PJ_MAX_OBJ_NAME]; /**< Object name. */ pj_pool_t *pool; /**< Pool instance. */ void *user_data; /**< App. data. */ pj_mutex_t *mutex; /**< Mutex. */ - pj_ice_role role; /**< ICE role. */ + pj_ice_sess_role role; /**< ICE role. */ pj_bool_t is_complete; /**< Complete? */ pj_status_t ice_status; /**< Error status. */ - pj_ice_cb cb; /**< Callback. */ + pj_ice_sess_cb cb; /**< Callback. */ pj_stun_config stun_cfg; /**< STUN settings. */ @@ -439,21 +460,21 @@ struct pj_ice /* Components */ unsigned comp_cnt; /**< # of components. */ - pj_ice_comp comp[PJ_ICE_MAX_COMP]; /**< Component array */ + pj_ice_sess_comp comp[PJ_ICE_MAX_COMP]; /**< Component array */ /* Local candidates */ unsigned lcand_cnt; /**< # of local cand. */ - pj_ice_cand lcand[PJ_ICE_MAX_CAND]; /**< Array of cand. */ + pj_ice_sess_cand lcand[PJ_ICE_MAX_CAND]; /**< Array of cand. */ /* Remote candidates */ unsigned rcand_cnt; /**< # of remote cand. */ - pj_ice_cand rcand[PJ_ICE_MAX_CAND]; /**< Array of cand. */ + pj_ice_sess_cand rcand[PJ_ICE_MAX_CAND]; /**< Array of cand. */ /* Checklist */ - pj_ice_checklist clist; /**< Active checklist */ + pj_ice_sess_checklist clist; /**< Active checklist */ /* Valid list */ - pj_ice_checklist valid_list; /**< Valid list. */ + pj_ice_sess_checklist valid_list; /**< Valid list. */ }; @@ -461,19 +482,34 @@ struct pj_ice * This is a utility function to retrieve the string name for the * particular candidate type. * - * @param type Candidate type. + * @param type Candidate type. * - * @return The string representation of the candidate type. + * @return The string representation of the candidate type. */ PJ_DECL(const char*) pj_ice_get_cand_type_name(pj_ice_cand_type type); /** + * This is a utility function to calculate the foundation identification + * for a candidate. + * + * @param pool Pool to allocate the foundation string. + * @param foundation Pointer to receive the foundation string. + * @param type Candidate type. + * @param base_addr Base address of the candidate. + */ +PJ_DECL(void) pj_ice_calc_foundation(pj_pool_t *pool, + pj_str_t *foundation, + pj_ice_cand_type type, + const pj_sockaddr *base_addr); + + +/** * Create ICE session with the specified role and number of components. * Application would typically need to create an ICE session before * sending an offer or upon receiving one. After the session is created, * application can register candidates to the ICE session by calling - * #pj_ice_add_cand() function. + * #pj_ice_sess_add_cand() function. * * @param stun_cfg The STUN configuration settings, containing among * other things the timer heap instance to be used @@ -492,27 +528,31 @@ PJ_DECL(const char*) pj_ice_get_cand_type_name(pj_ice_cand_type type); * * @return PJ_SUCCESS if ICE session is created successfully. */ -PJ_DECL(pj_status_t) pj_ice_create(pj_stun_config *stun_cfg, - const char *name, - pj_ice_role role, - unsigned comp_cnt, - const pj_ice_cb *cb, - const pj_str_t *local_ufrag, - const pj_str_t *local_passwd, - pj_ice **p_ice); +PJ_DECL(pj_status_t) pj_ice_sess_create(pj_stun_config *stun_cfg, + const char *name, + pj_ice_sess_role role, + unsigned comp_cnt, + const pj_ice_sess_cb *cb, + const pj_str_t *local_ufrag, + const pj_str_t *local_passwd, + pj_ice_sess **p_ice); /** - * Destroy ICE session. + * Destroy ICE session. This will cancel any connectivity checks currently + * running, if any, and any other events scheduled by this session, as well + * as all memory resources. * * @param ice ICE session instance. * * @return PJ_SUCCESS on success. */ -PJ_DECL(pj_status_t) pj_ice_destroy(pj_ice *ice); +PJ_DECL(pj_status_t) pj_ice_sess_destroy(pj_ice_sess *ice); /** - * Add a candidate to this ICE session. + * Add a candidate to this ICE session. Application must add candidates for + * each components ID before it can start pairing the candidates and + * performing connectivity checks. * * @param ice ICE session instance. * @param comp_id Component ID of this candidate. @@ -528,16 +568,16 @@ PJ_DECL(pj_status_t) pj_ice_destroy(pj_ice *ice); * * @return PJ_SUCCESS if candidate is successfully added. */ -PJ_DECL(pj_status_t) pj_ice_add_cand(pj_ice *ice, - unsigned comp_id, - pj_ice_cand_type type, - pj_uint16_t local_pref, - const pj_str_t *foundation, - const pj_sockaddr_t *addr, - const pj_sockaddr_t *base_addr, - const pj_sockaddr_t *rel_addr, - int addr_len, - unsigned *p_cand_id); +PJ_DECL(pj_status_t) pj_ice_sess_add_cand(pj_ice_sess *ice, + unsigned comp_id, + pj_ice_cand_type type, + pj_uint16_t local_pref, + const pj_str_t *foundation, + const pj_sockaddr_t *addr, + const pj_sockaddr_t *base_addr, + const pj_sockaddr_t *rel_addr, + int addr_len, + unsigned *p_cand_id); /** * Find default candidate for the specified component ID, using this @@ -553,9 +593,9 @@ PJ_DECL(pj_status_t) pj_ice_add_cand(pj_ice *ice, * * @return PJ_SUCCESS if a candidate has been selected. */ -PJ_DECL(pj_status_t) pj_ice_find_default_cand(pj_ice *ice, - unsigned comp_id, - int *p_cand_id); +PJ_DECL(pj_status_t) pj_ice_sess_find_default_cand(pj_ice_sess *ice, + unsigned comp_id, + int *p_cand_id); /** * Pair the local and remote candidates to create check list. Application @@ -564,7 +604,7 @@ PJ_DECL(pj_status_t) pj_ice_find_default_cand(pj_ice *ice, * offer, for UAS, or upon receiving the answer, for UAC). * * Note that ICE connectivity check will not start until application calls - * #pj_ice_start_check(). + * #pj_ice_sess_start_check(). * * @param ice ICE session instance. * @param rem_ufrag Remote ufrag, as seen in the SDP received from @@ -578,22 +618,23 @@ PJ_DECL(pj_status_t) pj_ice_find_default_cand(pj_ice *ice, * * @return PJ_SUCCESS or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_ice_create_check_list(pj_ice *ice, - const pj_str_t *rem_ufrag, - const pj_str_t *rem_passwd, - unsigned rem_cand_cnt, - const pj_ice_cand rem_cand[]); +PJ_DECL(pj_status_t) +pj_ice_sess_create_check_list(pj_ice_sess *ice, + const pj_str_t *rem_ufrag, + const pj_str_t *rem_passwd, + unsigned rem_cand_cnt, + const pj_ice_sess_cand rem_cand[]); /** * Start ICE periodic check. This function will return immediately, and * application will be notified about the connectivity check status in - * #pj_ice_cb callback. + * #pj_ice_sess_cb callback. * * @param ice The ICE session instance. * * @return PJ_SUCCESS or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_ice_start_check(pj_ice *ice); +PJ_DECL(pj_status_t) pj_ice_sess_start_check(pj_ice_sess *ice); /** @@ -603,6 +644,9 @@ PJ_DECL(pj_status_t) pj_ice_start_check(pj_ice *ice); * destination using the nominated local candidate for the specified * component. * + * This function will in turn call \a on_tx_pkt function in + * #pj_ice_sess_cb callback to actually send the packet to the wire. + * * @param ice The ICE session. * @param comp_id Component ID. * @param data The data or packet to be sent. @@ -610,17 +654,17 @@ PJ_DECL(pj_status_t) pj_ice_start_check(pj_ice *ice); * * @return PJ_SUCCESS if data is sent successfully. */ -PJ_DECL(pj_status_t) pj_ice_send_data(pj_ice *ice, - unsigned comp_id, - const void *data, - pj_size_t data_len); +PJ_DECL(pj_status_t) pj_ice_sess_send_data(pj_ice_sess *ice, + unsigned comp_id, + const void *data, + pj_size_t data_len); /** * Report the arrival of packet to the ICE session. Since ICE session * itself doesn't have any transports, it relies on application or * higher layer component to give incoming packets to the ICE session. * If the packet is not a STUN packet, this packet will be given back - * to application via \a on_rx_data() callback in #pj_ice_cb. + * to application via \a on_rx_data() callback in #pj_ice_sess_cb. * * @param ice The ICE session. * @param comp_id Component ID. @@ -632,13 +676,13 @@ PJ_DECL(pj_status_t) pj_ice_send_data(pj_ice *ice, * * @return PJ_SUCCESS or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_ice_on_rx_pkt(pj_ice *ice, - unsigned comp_id, - unsigned cand_id, - void *pkt, - pj_size_t pkt_size, - const pj_sockaddr_t *src_addr, - int src_addr_len); +PJ_DECL(pj_status_t) pj_ice_sess_on_rx_pkt(pj_ice_sess *ice, + unsigned comp_id, + unsigned cand_id, + void *pkt, + pj_size_t pkt_size, + const pj_sockaddr_t *src_addr, + int src_addr_len); diff --git a/pjnath/include/pjnath/ice_stream_transport.h b/pjnath/include/pjnath/ice_strans.h index 0403d841..b26b6a49 100644 --- a/pjnath/include/pjnath/ice_stream_transport.h +++ b/pjnath/include/pjnath/ice_strans.h @@ -21,10 +21,10 @@ /** - * @file ice_stream_transport.h + * @file ice_strans.h * @brief ICE Stream Transport */ -#include <pjnath/ice.h> +#include <pjnath/ice_session.h> #include <pjlib-util/resolver.h> #include <pj/ioqueue.h> @@ -38,11 +38,11 @@ PJ_BEGIN_DECL * @ingroup PJNATH_ICE * @{ * - * This module describes ICE stream transport, as represented by #pj_ice_st + * This module describes ICE stream transport, as represented by #pj_ice_strans * structure, and is part of PJNATH - the Open Source NAT traversal helper * library. * - * ICE stream transport, as represented by #pj_ice_st structure, is an ICE + * ICE stream transport, as represented by #pj_ice_strans structure, is an ICE * capable component for transporting media within a media stream. * It consists of one or more transport sockets (typically two for RTP * based communication - one for RTP and one for RTCP), and an @@ -71,13 +71,13 @@ PJ_BEGIN_DECL * \subsection PJNATH_ICE_ST_TRA_INIT Stream Transport Initialization * * Application creates the ICE stream transport by calling - * #pj_ice_st_create() function. + * #pj_ice_strans_create() function. * * After the ICE stream transport is created, application may set up the * STUN servers to be used to obtain STUN server reflexive and relayed - * candidate, by calling #pj_ice_st_set_stun_domain() or - * #pj_ice_st_set_stun_srv(). Then it has to create each component by - * calling #pj_ice_st_create_comp(); this would create an actual socket + * candidate, by calling #pj_ice_strans_set_stun_domain() or + * #pj_ice_strans_set_stun_srv(). Then it has to create each component by + * calling #pj_ice_strans_create_comp(); this would create an actual socket * which listens to the specified local address, and it would also * perform lookup to find various transport address candidates for this * socket. @@ -86,16 +86,16 @@ PJ_BEGIN_DECL * * When application is about to send an offer containing ICE capability, * or when it receives an offer containing ICE capability, it would - * create the ICE session by calling #pj_ice_st_init_ice(). This would + * create the ICE session by calling #pj_ice_strans_init_ice(). This would * register all transport address aliases for each component to the ICE * session as candidates. After this application can enumerate all local - * candidates by calling #pj_ice_st_enum_cands(), and encode these + * candidates by calling #pj_ice_strans_enum_cands(), and encode these * candidates in the SDP to be sent to remote agent. * * \subsection PJNATH_ICE_ST_TRA_START Starting Connectivity Checks * * Once application receives the SDP from remote, it can start ICE - * connectivity checks by calling #pj_ice_st_start_ice(), specifying + * connectivity checks by calling #pj_ice_strans_start_ice(), specifying * the username, password, and candidates of the remote agent. The ICE * session/transport will then notify the application via the callback * when ICE connectivity checks completes, either successfully or with @@ -104,7 +104,7 @@ PJ_BEGIN_DECL * \subsection PJNATH_ICE_ST_TRA_STOP Stopping ICE Session * * Once the call is terminated, application no longer needs to keep the - * ICE session, so it should call #pj_ice_st_stop_ice() to destroy the + * ICE session, so it should call #pj_ice_strans_stop_ice() to destroy the * ICE session within this ICE stream transport. Note that this WILL NOT * destroy the sockets/transports, it only destroys the ICE session * within this ICE stream transport. @@ -112,26 +112,26 @@ PJ_BEGIN_DECL * \subsection PJNATH_ICE_ST_TRA_RESTART Restarting ICE Session * * When a new call is made, application can repeat the above - * #pj_ice_st_init_ice() to #pj_ice_st_stop_ice() cycle for the new call, - * using this same ICE stream transport. + * #pj_ice_strans_init_ice() to #pj_ice_strans_stop_ice() cycle for + * the new call, using this same ICE stream transport. * * \subsection PJNATH_ICE_ST_TRA_DESTROY Destroying ICE Stream Transport * * Finally, when the ICE stream transport itself is no longer needed, * for example when the application quits, application should call - * #pj_ice_st_destroy() to release back all resources allocated by this + * #pj_ice_strans_destroy() to release back all resources allocated by this * ICE stream transport. * */ /** Forward declaration for ICE stream transport. */ -typedef struct pj_ice_st pj_ice_st; +typedef struct pj_ice_strans pj_ice_strans; /** * This structure contains callbacks that will be called by the * ICE stream transport. */ -typedef struct pj_ice_st_cb +typedef struct pj_ice_strans_cb { /** * This callback will be called when the ICE transport receives @@ -145,7 +145,7 @@ typedef struct pj_ice_st_cb * @param src_addr Source address of the packet. * @param src_addr_len Length of the source address. */ - void (*on_rx_data)(pj_ice_st *ice_st, + void (*on_rx_data)(pj_ice_strans *ice_st, unsigned comp_id, void *pkt, pj_size_t size, const pj_sockaddr_t *src_addr, @@ -158,18 +158,18 @@ typedef struct pj_ice_st_cb * @param ice_st The ICE stream transport. * @param status The ICE connectivity check status. */ - void (*on_ice_complete)(pj_ice_st *ice_st, + void (*on_ice_complete)(pj_ice_strans *ice_st, pj_status_t status); -} pj_ice_st_cb; +} pj_ice_strans_cb; /** * Various flags that can be specified when creating a component with - * #pj_ice_st_create_comp(). These options may be combined together + * #pj_ice_strans_create_comp(). These options may be combined together * with bitmask operation. */ -enum pj_ice_st_option +enum pj_ice_strans_option { /** * If this option is specified, only a listening socket will be @@ -209,7 +209,7 @@ enum pj_ice_st_option * in ICE stream transport can be viewed as alias transport address * for the socket. */ -typedef struct pj_ice_st_cand +typedef struct pj_ice_strans_cand { /** * Candidate type. @@ -251,7 +251,7 @@ typedef struct pj_ice_st_cand */ pj_str_t foundation; -} pj_ice_st_cand; +} pj_ice_strans_cand; /** @@ -261,13 +261,13 @@ typedef struct pj_ice_st_cand * component may have multiple alias addresses, for example one alias * address for each interfaces in multi-homed host, another for server * reflexive alias, and another for relayed alias. For each transport - * address alias, an ICE stream transport candidate (#pj_ice_st_cand) will + * address alias, an ICE stream transport candidate (#pj_ice_strans_cand) will * be created, and these candidates will eventually registered to the ICE * session. */ -typedef struct pj_ice_st_comp +typedef struct pj_ice_strans_comp { - pj_ice_st *ice_st; /**< ICE stream transport. */ + pj_ice_strans *ice_st; /**< ICE stream transport. */ unsigned comp_id; /**< Component ID. */ pj_uint32_t options; /**< Option flags. */ pj_sock_t sock; /**< Socket descriptor. */ @@ -280,7 +280,7 @@ typedef struct pj_ice_st_comp pj_status_t last_status; /**< Last status. */ unsigned cand_cnt; /**< # of candidates/aliaes. */ - pj_ice_st_cand cand_list[PJ_ICE_ST_MAX_CAND]; /**< Cand array */ + pj_ice_strans_cand cand_list[PJ_ICE_ST_MAX_CAND]; /**< Cand array */ int default_cand; /**< Default candidate selected */ pj_ioqueue_key_t *key; /**< ioqueue key. */ @@ -290,25 +290,25 @@ typedef struct pj_ice_st_comp pj_sockaddr src_addr; /**< source packet address buf. */ int src_addr_len; /**< length of src addr. buf. */ -} pj_ice_st_comp; +} pj_ice_strans_comp; /** * This structure represents the ICE stream transport. */ -struct pj_ice_st +struct pj_ice_strans { char obj_name[PJ_MAX_OBJ_NAME]; /**< Log ID. */ pj_pool_t *pool; /**< Pool used by this object. */ void *user_data; /**< Application data. */ pj_stun_config stun_cfg; /**< STUN settings. */ - pj_ice_st_cb cb; /**< Application callback. */ + pj_ice_strans_cb cb; /**< Application callback. */ - pj_ice *ice; /**< ICE session. */ + pj_ice_sess *ice; /**< ICE session. */ unsigned comp_cnt; /**< Number of components. */ - pj_ice_st_comp **comp; /**< Components array. */ + pj_ice_strans_comp **comp; /**< Components array. */ pj_dns_resolver *resolver; /**< The resolver instance. */ pj_bool_t has_rjob; /**< Has pending resolve? */ @@ -321,7 +321,7 @@ struct pj_ice_st * Create the ICE stream transport containing the specified number of * components. After the ICE stream transport is created, application * may initialize the STUN server settings, and after that it has to - * initialize each components by calling #pj_ice_st_create_comp() + * initialize each components by calling #pj_ice_strans_create_comp() * function. * * @param stun_cfg The STUN settings. @@ -336,12 +336,12 @@ struct pj_ice_st * @return PJ_SUCCESS if ICE stream transport is created * successfully. */ -PJ_DECL(pj_status_t) pj_ice_st_create(pj_stun_config *stun_cfg, - const char *name, - unsigned comp_cnt, - void *user_data, - const pj_ice_st_cb *cb, - pj_ice_st **p_ice_st); +PJ_DECL(pj_status_t) pj_ice_strans_create(pj_stun_config *stun_cfg, + const char *name, + unsigned comp_cnt, + void *user_data, + const pj_ice_strans_cb *cb, + pj_ice_strans **p_ice_st); /** * Destroy the ICE stream transport. This will destroy the ICE session @@ -352,13 +352,13 @@ PJ_DECL(pj_status_t) pj_ice_st_create(pj_stun_config *stun_cfg, * * @return PJ_SUCCESS, or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_ice_st_destroy(pj_ice_st *ice_st); +PJ_DECL(pj_status_t) pj_ice_strans_destroy(pj_ice_strans *ice_st); /** * Set the domain to be used when resolving the STUN servers. If application * wants to utillize STUN, then STUN server must be specified, either by - * calling this function or by calling #pj_ice_st_set_stun_srv(). + * calling this function or by calling #pj_ice_strans_set_stun_srv(). * * If application calls this function, then the STUN/TURN servers will * be resolved by querying DNS SRV records for the specified domain. @@ -372,14 +372,14 @@ PJ_DECL(pj_status_t) pj_ice_st_destroy(pj_ice_st *ice_st); * started. The resolution process itself will * complete asynchronously. */ -PJ_DECL(pj_status_t) pj_ice_st_set_stun_domain(pj_ice_st *ice_st, - pj_dns_resolver *resolver, - const pj_str_t *domain); +PJ_DECL(pj_status_t) pj_ice_strans_set_stun_domain(pj_ice_strans *ice_st, + pj_dns_resolver *resolver, + const pj_str_t *domain); /** * Set the STUN and TURN server addresses. If application * wants to utillize STUN, then STUN server must be specified, either by - * calling this function or by calling #pj_ice_st_set_stun_domain(). + * calling this function or by calling #pj_ice_strans_set_stun_domain(). * * With this function, the STUN and TURN server addresses will be * assigned immediately, that is no DNS resolution will need to be @@ -393,9 +393,10 @@ PJ_DECL(pj_status_t) pj_ice_st_set_stun_domain(pj_ice_st *ice_st, * * @return PJ_SUCCESS, or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_ice_st_set_stun_srv(pj_ice_st *ice_st, - const pj_sockaddr_in *stun_srv, - const pj_sockaddr_in *turn_srv); +PJ_DECL(pj_status_t) +pj_ice_strans_set_stun_srv( pj_ice_strans *ice_st, + const pj_sockaddr_in *stun_srv, + const pj_sockaddr_in *turn_srv); /** * Create and initialize the specified component. This function will @@ -406,7 +407,7 @@ PJ_DECL(pj_status_t) pj_ice_st_set_stun_srv(pj_ice_st *ice_st, * it will add an ICE stream transport candidate for this component. * * After all components have been initialized, application should poll - * the #pj_ice_st_get_comps_status() peridically to check if STUN + * the #pj_ice_strans_get_comps_status() peridically to check if STUN * server reflexive and relayed candidates have been obtained * successfully. * @@ -414,7 +415,7 @@ PJ_DECL(pj_status_t) pj_ice_st_set_stun_srv(pj_ice_st *ice_st, * @param comp_id The component ID, which value must be greater than * zero and less than or equal to the number of * components in this ICE stream transport. - * @param options Options, see #pj_ice_st_option. + * @param options Options, see #pj_ice_strans_option. * @param addr Local address where socket will be bound to. This * address will be used as follows: * - if the value is NULL, then socket will be bound @@ -436,16 +437,16 @@ PJ_DECL(pj_status_t) pj_ice_st_set_stun_srv(pj_ice_st *ice_st, * * @return PJ_SUCCESS, or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_ice_st_create_comp(pj_ice_st *ice_st, - unsigned comp_id, - pj_uint32_t options, - const pj_sockaddr_in *addr); +PJ_DECL(pj_status_t) pj_ice_strans_create_comp(pj_ice_strans *ice_st, + unsigned comp_id, + pj_uint32_t options, + const pj_sockaddr_in *addr); /** * Manually add a candidate (transport address alias) for the specified * component. Normally application shouldn't need to use this function, * as candidates will be added automatically when component is created - * with #pj_ice_st_create_comp(). + * with #pj_ice_strans_create_comp(). * * @param ice_st ICE stream transport. * @param comp_id The component ID. @@ -458,12 +459,12 @@ PJ_DECL(pj_status_t) pj_ice_st_create_comp(pj_ice_st *ice_st, * * @return PJ_SUCCESS, or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_ice_st_add_cand(pj_ice_st *ice_st, - unsigned comp_id, - pj_ice_cand_type type, - pj_uint16_t local_pref, - const pj_sockaddr_in *addr, - pj_bool_t set_default); +PJ_DECL(pj_status_t) pj_ice_strans_add_cand(pj_ice_strans *ice_st, + unsigned comp_id, + pj_ice_cand_type type, + pj_uint16_t local_pref, + const pj_sockaddr_in *addr, + pj_bool_t set_default); /** * Get the status of components in the ICE stream transports. Since @@ -478,7 +479,7 @@ PJ_DECL(pj_status_t) pj_ice_st_add_cand(pj_ice_st *ice_st, * successfully, PJ_EPENDING if transport resolution * is still in progress, or other status on failure. */ -PJ_DECL(pj_status_t) pj_ice_st_get_comps_status(pj_ice_st *ice_st); +PJ_DECL(pj_status_t) pj_ice_strans_get_comps_status(pj_ice_strans *ice_st); /** * Initialize the ICE session in the ICE stream transport. @@ -490,10 +491,10 @@ PJ_DECL(pj_status_t) pj_ice_st_get_comps_status(pj_ice_st *ice_st); * * @return PJ_SUCCESS, or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_ice_st_init_ice(pj_ice_st *ice_st, - pj_ice_role role, - const pj_str_t *local_ufrag, - const pj_str_t *local_passwd); +PJ_DECL(pj_status_t) pj_ice_strans_init_ice(pj_ice_strans *ice_st, + pj_ice_sess_role role, + const pj_str_t *local_ufrag, + const pj_str_t *local_passwd); /** * Enumerate the local candidates. This function can only be called @@ -508,9 +509,9 @@ PJ_DECL(pj_status_t) pj_ice_st_init_ice(pj_ice_st *ice_st, * * @return PJ_SUCCESS, or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_ice_st_enum_cands(pj_ice_st *ice_st, - unsigned *count, - pj_ice_cand cand[]); +PJ_DECL(pj_status_t) pj_ice_strans_enum_cands(pj_ice_strans *ice_st, + unsigned *count, + pj_ice_sess_cand cand[]); /** * Start ICE connectivity checks. This function can only be called @@ -532,11 +533,12 @@ PJ_DECL(pj_status_t) pj_ice_st_enum_cands(pj_ice_st *ice_st, * * @return PJ_SUCCESS, or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_ice_st_start_ice(pj_ice_st *ice_st, - const pj_str_t *rem_ufrag, - const pj_str_t *rem_passwd, - unsigned rem_cand_cnt, - const pj_ice_cand rem_cand[]); +PJ_DECL(pj_status_t) +pj_ice_strans_start_ice( pj_ice_strans *ice_st, + const pj_str_t *rem_ufrag, + const pj_str_t *rem_passwd, + unsigned rem_cand_cnt, + const pj_ice_sess_cand rem_cand[]); /** * Stop and destroy the ICE session inside this media transport. @@ -545,7 +547,7 @@ PJ_DECL(pj_status_t) pj_ice_st_start_ice(pj_ice_st *ice_st, * * @return PJ_SUCCESS, or the appropriate error code. */ -PJ_DECL(pj_status_t) pj_ice_st_stop_ice(pj_ice_st *ice_st); +PJ_DECL(pj_status_t) pj_ice_strans_stop_ice(pj_ice_strans *ice_st); /** @@ -564,12 +566,12 @@ PJ_DECL(pj_status_t) pj_ice_st_stop_ice(pj_ice_st *ice_st); * * @return PJ_SUCCESS if data is sent successfully. */ -PJ_DECL(pj_status_t) pj_ice_st_sendto(pj_ice_st *ice_st, - unsigned comp_id, - const void *data, - pj_size_t data_len, - const pj_sockaddr_t *dst_addr, - int dst_addr_len); +PJ_DECL(pj_status_t) pj_ice_strans_sendto(pj_ice_strans *ice_st, + unsigned comp_id, + const void *data, + pj_size_t data_len, + const pj_sockaddr_t *dst_addr, + int dst_addr_len); /** diff --git a/pjnath/include/pjnath/stun_msg.h b/pjnath/include/pjnath/stun_msg.h index a63fb7a0..6c43ee9b 100644 --- a/pjnath/include/pjnath/stun_msg.h +++ b/pjnath/include/pjnath/stun_msg.h @@ -136,7 +136,7 @@ enum pj_stun_msg_class_e /** * Determine if the message type is a response. */ -#define PJ_STUN_IS_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0100) +#define PJ_STUN_IS_SUCCESS_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0100) /** diff --git a/pjnath/include/pjnath/types.h b/pjnath/include/pjnath/types.h index bc47c9a2..2eaf6313 100644 --- a/pjnath/include/pjnath/types.h +++ b/pjnath/include/pjnath/types.h @@ -109,33 +109,8 @@ PJ_END_DECL * * \subsection PJNATH_STUN_ARCH STUN Library Organization * - - \verbatim - - +-----------------------------------------------------------------+ - | | - | A P P L I C A T I O N | - | | - +-----------------------------------------------------------------+ - ^ ^ - | | - v v - +--------+ +-----------------------------------+ +----------+ - | | | | | | - | Appl- |<-->| S T U N S E S S I O N |<-->| S T U N | - | ication| | | | Authen- | - | Trans- | +-----------------------------------+ | tication | - | port | | | | | - | |<-->| S T U N T R A N S A C T I O N | +----------+ - | | | | - | | +-----------------------------------+ - | | | | - | | | STUN MESSAGE REPRESENTATION | - +--------+ | AND PARSING | - +-----------------------------------+ - - \endverbatim - + * \image html stun-arch.jpg "STUN Library Architecture" + * * The STUN library is organized as follows: * * - the lowest layer of the library is \ref PJNATH_STUN_MSG. This layer @@ -173,6 +148,8 @@ PJ_END_DECL * * \subsection PJNATH_ICE_ARCH ICE Library Organization * + * \image html ice-arch.jpg "ICE Architecture" + * * The ICE library is organized as follows: * * - the lowest layer is \ref PJNATH_ICE_SESSION, which provides |