From 483805f79570115ab95c69698792d238c1719b1b Mon Sep 17 00:00:00 2001 From: Jason Parker Date: Mon, 11 Mar 2013 15:09:56 -0500 Subject: Import pjproject-2.1 --- pjnath/include/pjnath/config.h | 13 +++++++++++- pjnath/include/pjnath/ice_session.h | 8 ++++++-- pjnath/include/pjnath/stun_config.h | 10 +++++++++- pjnath/include/pjnath/stun_session.h | 27 +++++++++---------------- pjnath/include/pjnath/stun_sock.h | 27 ++++++++++++++++++++++--- pjnath/include/pjnath/stun_transaction.h | 15 +++++++++----- pjnath/include/pjnath/turn_session.h | 8 ++++++-- pjnath/include/pjnath/turn_sock.h | 34 +++++++++++++++++++++++++++++++- 8 files changed, 109 insertions(+), 33 deletions(-) (limited to 'pjnath/include/pjnath') diff --git a/pjnath/include/pjnath/config.h b/pjnath/include/pjnath/config.h index 06368df..3ee5d91 100644 --- a/pjnath/include/pjnath/config.h +++ b/pjnath/include/pjnath/config.h @@ -1,4 +1,4 @@ -/* $Id: config.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: config.h 4199 2012-07-05 10:52:55Z nanang $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono @@ -487,6 +487,17 @@ # define PJNATH_POOL_INC_TURN_SOCK 1000 #endif +/** Default STUN software name */ +#ifndef PJNATH_STUN_SOFTWARE_NAME +# define PJNATH_MAKE_SW_NAME(a,b,c,d) "pjnath-" #a "." #b "." #c d +# define PJNATH_MAKE_SW_NAME2(a,b,c,d) PJNATH_MAKE_SW_NAME(a,b,c,d) +# define PJNATH_STUN_SOFTWARE_NAME PJNATH_MAKE_SW_NAME2( \ + PJ_VERSION_NUM_MAJOR, \ + PJ_VERSION_NUM_MINOR, \ + PJ_VERSION_NUM_REV, \ + PJ_VERSION_NUM_EXTRA) +#endif + /** * @} */ diff --git a/pjnath/include/pjnath/ice_session.h b/pjnath/include/pjnath/ice_session.h index 1e65943..e21f520 100644 --- a/pjnath/include/pjnath/ice_session.h +++ b/pjnath/include/pjnath/ice_session.h @@ -1,4 +1,4 @@ -/* $Id: ice_session.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: ice_session.h 4360 2013-02-21 11:26:35Z bennylp $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono @@ -612,13 +612,14 @@ struct pj_ice_sess pj_pool_t *pool; /**< Pool instance. */ void *user_data; /**< App. data. */ - pj_mutex_t *mutex; /**< Mutex. */ + pj_grp_lock_t *grp_lock; /**< Group lock */ pj_ice_sess_role role; /**< ICE role. */ pj_ice_sess_options opt; /**< Options */ pj_timestamp tie_breaker; /**< Tie breaker value */ pj_uint8_t *prefs; /**< Type preference. */ pj_bool_t is_nominating; /**< Nominating stage */ pj_bool_t is_complete; /**< Complete? */ + pj_bool_t is_destroying; /**< Destroy is called */ pj_status_t ice_status; /**< Error status. */ pj_timer_entry timer; /**< ICE timer. */ pj_ice_sess_cb cb; /**< Callback. */ @@ -729,6 +730,8 @@ PJ_DECL(void) pj_ice_sess_options_default(pj_ice_sess_options *opt); * the value is NULL, a random string will be * generated. * @param local_passwd Optional string to be used as local password. + * @param grp_lock Optional group lock to be used by this session. + * If NULL, the session will create one itself. * @param p_ice Pointer to receive the ICE session instance. * * @return PJ_SUCCESS if ICE session is created successfully. @@ -740,6 +743,7 @@ PJ_DECL(pj_status_t) pj_ice_sess_create(pj_stun_config *stun_cfg, const pj_ice_sess_cb *cb, const pj_str_t *local_ufrag, const pj_str_t *local_passwd, + pj_grp_lock_t *grp_lock, pj_ice_sess **p_ice); /** diff --git a/pjnath/include/pjnath/stun_config.h b/pjnath/include/pjnath/stun_config.h index 199c452..e5a0b98 100644 --- a/pjnath/include/pjnath/stun_config.h +++ b/pjnath/include/pjnath/stun_config.h @@ -1,4 +1,4 @@ -/* $Id: stun_config.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: stun_config.h 4199 2012-07-05 10:52:55Z nanang $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono @@ -81,6 +81,13 @@ typedef struct pj_stun_config */ unsigned res_cache_msec; + /** + * Software name to be included in all STUN requests and responses. + * + * Default: PJNATH_STUN_SOFTWARE_NAME. + */ + pj_str_t software_name; + } pj_stun_config; @@ -102,6 +109,7 @@ PJ_INLINE(void) pj_stun_config_init(pj_stun_config *cfg, cfg->timer_heap = timer_heap; cfg->rto_msec = PJ_STUN_RTO_VALUE; cfg->res_cache_msec = PJ_STUN_RES_CACHE_DURATION; + cfg->software_name = pj_str((char*)PJNATH_STUN_SOFTWARE_NAME); } diff --git a/pjnath/include/pjnath/stun_session.h b/pjnath/include/pjnath/stun_session.h index 29efe1a..dd12e91 100644 --- a/pjnath/include/pjnath/stun_session.h +++ b/pjnath/include/pjnath/stun_session.h @@ -1,4 +1,4 @@ -/* $Id: stun_session.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: stun_session.h 4360 2013-02-21 11:26:35Z bennylp $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono @@ -30,6 +30,7 @@ #include #include #include +#include #include PJ_BEGIN_DECL @@ -384,6 +385,8 @@ typedef enum pj_stun_sess_msg_log_flag * name will be used for example for logging purpose. * @param cb Session callback. * @param fingerprint Enable message fingerprint for outgoing messages. + * @param grp_lock Optional group lock to be used by this session. + * If NULL, the session will create one itself. * @param p_sess Pointer to receive STUN session instance. * * @return PJ_SUCCESS on success, or the appropriate error code. @@ -392,6 +395,7 @@ PJ_DECL(pj_status_t) pj_stun_session_create(pj_stun_config *cfg, const char *name, const pj_stun_session_cb *cb, pj_bool_t fingerprint, + pj_grp_lock_t *grp_lock, pj_stun_session **p_sess); /** @@ -430,22 +434,6 @@ PJ_DECL(pj_status_t) pj_stun_session_set_user_data(pj_stun_session *sess, */ PJ_DECL(void*) pj_stun_session_get_user_data(pj_stun_session *sess); -/** - * Change the lock object used by the STUN session. By default, the STUN - * session uses a mutex to protect its internal data. If application already - * protects access to STUN session with higher layer lock, it may disable - * the mutex protection in the STUN session by changing the STUN session - * lock to a NULL mutex. - * - * @param sess The STUN session instance. - * @param lock New lock instance to be used by the STUN session. - * @param auto_del Specify whether STUN session should destroy this - * lock instance when it's destroyed. - */ -PJ_DECL(pj_status_t) pj_stun_session_set_lock(pj_stun_session *sess, - pj_lock_t *lock, - pj_bool_t auto_del); - /** * Set SOFTWARE name to be included in all requests and responses. * @@ -682,6 +670,8 @@ PJ_DECL(pj_status_t) pj_stun_session_cancel_req(pj_stun_session *sess, * * @param sess The STUN session instance. * @param tdata The request message previously sent. + * @param mod_count Boolean flag to indicate whether transmission count + * needs to be incremented. * * @return PJ_SUCCESS on success, or the appropriate error. * This function will return PJNATH_ESTUNDESTROYED if @@ -689,7 +679,8 @@ PJ_DECL(pj_status_t) pj_stun_session_cancel_req(pj_stun_session *sess, * callback. */ PJ_DECL(pj_status_t) pj_stun_session_retransmit_req(pj_stun_session *sess, - pj_stun_tx_data *tdata); + pj_stun_tx_data *tdata, + pj_bool_t mod_count); /** diff --git a/pjnath/include/pjnath/stun_sock.h b/pjnath/include/pjnath/stun_sock.h index decba9a..c18741a 100644 --- a/pjnath/include/pjnath/stun_sock.h +++ b/pjnath/include/pjnath/stun_sock.h @@ -1,4 +1,4 @@ -/* $Id: stun_sock.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: stun_sock.h 4360 2013-02-21 11:26:35Z bennylp $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -218,7 +219,17 @@ typedef struct pj_stun_sock_info typedef struct pj_stun_sock_cfg { /** - * Packet buffer size. Default value is PJ_STUN_SOCK_PKT_LEN. + * The group lock to be used by the STUN socket. If NULL, the STUN socket + * will create one internally. + * + * Default: NULL + */ + pj_grp_lock_t *grp_lock; + + /** + * Packet buffer size. + * + * Default value is PJ_STUN_SOCK_PKT_LEN. */ unsigned max_pkt_size; @@ -236,10 +247,20 @@ typedef struct pj_stun_sock_cfg * address is zero, socket will be bound to INADDR_ANY. If the address * is non-zero, socket will be bound to this address only, and the * transport will have only one address alias (the \a alias_cnt field - * in #pj_stun_sock_info structure. + * in #pj_stun_sock_info structure. If the port is set to zero, the + * socket will bind at any port (chosen by the OS). */ pj_sockaddr bound_addr; + /** + * Specify the port range for STUN socket binding, relative to the start + * port number specified in \a bound_addr. Note that this setting is only + * applicable when the start port number is non zero. + * + * Default value is zero. + */ + pj_uint16_t port_range; + /** * Specify the STUN keep-alive duration, in seconds. The STUN transport * does keep-alive by sending STUN Binding request to the STUN server. diff --git a/pjnath/include/pjnath/stun_transaction.h b/pjnath/include/pjnath/stun_transaction.h index 526186f..2acb56c 100644 --- a/pjnath/include/pjnath/stun_transaction.h +++ b/pjnath/include/pjnath/stun_transaction.h @@ -1,4 +1,4 @@ -/* $Id: stun_transaction.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: stun_transaction.h 4360 2013-02-21 11:26:35Z bennylp $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono @@ -27,6 +27,7 @@ #include #include +#include PJ_BEGIN_DECL @@ -124,6 +125,7 @@ typedef struct pj_stun_tsx_cb * @param cfg The STUN endpoint, which will be used to retrieve * various settings for the transaction. * @param pool Pool to be used to allocate memory from. + * @param grp_lock Group lock to synchronize. * @param cb Callback structure, to be used by the transaction * to send message and to notify the application about * the completion of the transaction. @@ -133,6 +135,7 @@ typedef struct pj_stun_tsx_cb */ PJ_DECL(pj_status_t) pj_stun_client_tsx_create( pj_stun_config *cfg, pj_pool_t *pool, + pj_grp_lock_t *grp_lock, const pj_stun_tsx_cb *cb, pj_stun_client_tsx **p_tsx); @@ -159,15 +162,14 @@ pj_stun_client_tsx_schedule_destroy(pj_stun_client_tsx *tsx, /** - * Destroy a STUN client transaction immediately. This function can be - * called at any time to stop the transaction and destroy it. + * Stop the client transaction. * * @param tsx The STUN transaction. * * @return PJ_SUCCESS on success or PJ_EINVAL if the parameter * is NULL. */ -PJ_DECL(pj_status_t) pj_stun_client_tsx_destroy(pj_stun_client_tsx *tsx); +PJ_DECL(pj_status_t) pj_stun_client_tsx_stop(pj_stun_client_tsx *tsx); /** @@ -234,13 +236,16 @@ PJ_DECL(pj_status_t) pj_stun_client_tsx_send_msg(pj_stun_client_tsx *tsx, * but this functionality is needed by ICE. * * @param tsx The STUN client transaction instance. + * @param mod_count Boolean flag to indicate whether transmission count + * needs to be incremented. * * @return PJ_SUCCESS on success, or PJNATH_ESTUNDESTROYED * when the user has destroyed the transaction in * \a on_send_msg() callback, or any other error code * as returned by \a on_send_msg() callback. */ -PJ_DECL(pj_status_t) pj_stun_client_tsx_retransmit(pj_stun_client_tsx *tsx); +PJ_DECL(pj_status_t) pj_stun_client_tsx_retransmit(pj_stun_client_tsx *tsx, + pj_bool_t mod_count); /** diff --git a/pjnath/include/pjnath/turn_session.h b/pjnath/include/pjnath/turn_session.h index 0eeb6e3..eb6d16b 100644 --- a/pjnath/include/pjnath/turn_session.h +++ b/pjnath/include/pjnath/turn_session.h @@ -1,4 +1,4 @@ -/* $Id: turn_session.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: turn_session.h 4360 2013-02-21 11:26:35Z bennylp $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono @@ -417,7 +417,10 @@ PJ_DECL(const char*) pj_turn_state_name(pj_turn_state_t state); * @param name Optional name to identify this session in the log. * @param af Address family of the client connection. Currently * pj_AF_INET() and pj_AF_INET6() are supported. - * @param conn_type Connection type to the TURN server. + * @param conn_type Connection type to the TURN server. + * @param grp_lock Optional group lock object to be used by this session. + * If this value is NULL, the session will create + * a group lock internally. * @param cb Callback to receive events from the TURN session. * @param options Option flags, currently this value must be zero. * @param user_data Arbitrary application data to be associated with @@ -432,6 +435,7 @@ PJ_DECL(pj_status_t) pj_turn_session_create(const pj_stun_config *cfg, const char *name, int af, pj_turn_tp_type conn_type, + pj_grp_lock_t *grp_lock, const pj_turn_session_cb *cb, unsigned options, void *user_data, diff --git a/pjnath/include/pjnath/turn_sock.h b/pjnath/include/pjnath/turn_sock.h index 1a75a64..b13057c 100644 --- a/pjnath/include/pjnath/turn_sock.h +++ b/pjnath/include/pjnath/turn_sock.h @@ -1,4 +1,4 @@ -/* $Id: turn_sock.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: turn_sock.h 4360 2013-02-21 11:26:35Z bennylp $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono @@ -108,6 +108,21 @@ typedef struct pj_turn_sock_cb */ typedef struct pj_turn_sock_cfg { + /** + * The group lock to be used by the STUN socket. If NULL, the STUN socket + * will create one internally. + * + * Default: NULL + */ + pj_grp_lock_t *grp_lock; + + /** + * Packet buffer size. + * + * Default value is PJ_TURN_MAX_PKT_LEN. + */ + unsigned max_pkt_size; + /** * QoS traffic type to be set on this transport. When application wants * to apply QoS tagging to the transport, it's preferable to set this @@ -134,6 +149,23 @@ typedef struct pj_turn_sock_cfg */ pj_bool_t qos_ignore_error; + /** + * Specify the interface where the socket should be bound to. If the + * address is zero, socket will be bound to INADDR_ANY. If the address + * is non-zero, socket will be bound to this address only. If the port is + * set to zero, the socket will bind at any port (chosen by the OS). + */ + pj_sockaddr bound_addr; + + /** + * Specify the port range for TURN socket binding, relative to the start + * port number specified in \a bound_addr. Note that this setting is only + * applicable when the start port number is non zero. + * + * Default value is zero. + */ + pj_uint16_t port_range; + } pj_turn_sock_cfg; -- cgit v1.2.3