diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-09-26 13:21:02 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-09-26 13:21:02 +0000 |
commit | 506917fa7dfa0cec64586417feb081b6dcf1f97e (patch) | |
tree | 9627c2f90727f171fbe2c82fcb256a6efb8b0c12 /pjsip/include | |
parent | decb295824ef9cf2df5683d11b1c40fb6eff6ab5 (diff) |
Added support for specifying IP address in PJSUA-LIB/pjsua.
This option can be used for example to select the IP
interface of SIP/RTP/RTCP transports, or to specify the
public IP address of NAT/router in case port forwarding is
used.
For SIP transports, this feature works for both UDP and
TCP transports.
Changes:
- added public_ip field in pjsua_transport_config, and
change SIP and media transport creation to consider this
option.
- added --ip-addr option in pjsua
- added pjsip_tcp_transport_start2() which allows
specifying alternate TCP published address when creating
TCP transports.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@742 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include')
-rw-r--r-- | pjsip/include/pjsip/sip_transport.h | 2 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_transport_tcp.h | 37 | ||||
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 25 |
3 files changed, 61 insertions, 3 deletions
diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h index f0f915cd..4c9120e9 100644 --- a/pjsip/include/pjsip/sip_transport.h +++ b/pjsip/include/pjsip/sip_transport.h @@ -726,6 +726,8 @@ struct pjsip_tpfactory /** This list is managed by transport manager. */ PJ_DECL_LIST_MEMBER(struct pjsip_tpfactory); + char obj_name[PJ_MAX_OBJ_NAME]; /**< Name. */ + pj_pool_t *pool; /**< Owned memory pool. */ pj_lock_t *lock; /**< Lock object. */ diff --git a/pjsip/include/pjsip/sip_transport_tcp.h b/pjsip/include/pjsip/sip_transport_tcp.h index 4f5664d4..db308d7d 100644 --- a/pjsip/include/pjsip/sip_transport_tcp.h +++ b/pjsip/include/pjsip/sip_transport_tcp.h @@ -78,6 +78,43 @@ PJ_DECL(pj_status_t) pjsip_tcp_transport_start(pjsip_endpoint *endpt, pjsip_tpfactory **p_factory); + +/** + * A newer variant of #pjsip_tcp_transport_start(), which allows specifying + * the published/public address of the TCP transport. + * + * @param endpt The SIP endpoint. + * @param local Optional local address to bind, or specify the + * address to bind the server socket to. Both IP + * interface address and port fields are optional. + * If IP interface address is not specified, socket + * will be bound to PJ_INADDR_ANY. If port is not + * specified, socket will be bound to any port + * selected by the operating system. + * @param a_name Optional published address, which is the address to be + * advertised as the address of this SIP transport. + * If this argument is NULL, then the bound address + * will be used as the published address. + * @param async_cnt Number of simultaneous asynchronous accept() + * operations to be supported. It is recommended that + * the number here corresponds to the number of + * processors in the system (or the number of SIP + * worker threads). + * @param p_factory Optional pointer to receive the instance of the + * SIP TCP transport factory just created. + * + * @return PJ_SUCCESS when the transport has been successfully + * started and registered to transport manager, or + * the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsip_tcp_transport_start2(pjsip_endpoint *endpt, + const pj_sockaddr_in *local, + const pjsip_host_port *a_name, + unsigned async_cnt, + pjsip_tpfactory **p_factory); + + + PJ_END_DECL /** diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 47641c92..9ded3f15 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -724,7 +724,7 @@ PJ_INLINE(void) pjsua_stun_config_default(pjsua_stun_config *cfg) /** - * Transport configuration for creating UDP transports for both SIP + * Transport configuration for creating transports for both SIP * and media. */ typedef struct pjsua_transport_config @@ -738,9 +738,28 @@ typedef struct pjsua_transport_config unsigned port; /** - * Optional address where the socket should be bound. + * Optional address to advertise as the address of this transport. + * Application can specify any address or hostname for this field, + * for example it can point to one of the interface address in the + * system, or it can point to the public address of a NAT router + * where port mappings have been configured for the application. + * + * Note: this option can be used for both UDP and TCP as well! + */ + pj_str_t public_addr; + + /** + * Optional address where the socket should be bound to. This option + * SHOULD only be used to selectively bind the socket to particular + * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the + * published address of a transport (the public_addr field should be + * used for that purpose). + * + * Note that unlike public_addr field, the address (or hostname) here + * MUST correspond to the actual interface address in the host, since + * this address will be specified as bind() argument. */ - pj_in_addr ip_addr; + pj_str_t bound_addr; /** * Flag to indicate whether STUN should be used. |