From 050af3159e072d2cde0e4354a596a5b10959cd55 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Thu, 20 Dec 2007 11:23:07 +0000 Subject: Related to Ticket #429: when bind address is specified and public address is not, the bind address should be used as the public address (thanks Arie Velthoen) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1636 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsua-lib/pjsua_core.c | 14 +++++++++----- pjsip/src/pjsua-lib/pjsua_media.c | 17 +++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index f7addbd3..985608cc 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -1299,11 +1299,15 @@ static pj_status_t create_sip_udp_sock(int af, } else { pj_bzero(p_pub_addr, sizeof(pj_sockaddr)); - status = pj_gethostip(af, p_pub_addr); - if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, "Unable to get local host IP", status); - pj_sock_close(sock); - return status; + if (pj_sockaddr_has_addr(&bind_addr)) { + pj_sockaddr_copy_addr(p_pub_addr, &bind_addr); + } else { + status = pj_gethostip(af, p_pub_addr); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Unable to get local host IP", status); + pj_sock_close(sock); + return status; + } } p_pub_addr->addr.sa_family = (pj_uint16_t)af; diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index 38788478..3a577247 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -346,16 +346,21 @@ static pj_status_t create_rtp_rtcp_sock(const pjsua_transport_config *cfg, break; } else { - pj_sockaddr addr; - /* Get local IP address. */ - status = pj_gethostip(pj_AF_INET(), &addr); - if (status != PJ_SUCCESS) - goto on_error; + if (bound_addr.sin_addr.s_addr == 0) { + pj_sockaddr addr; + + /* Get local IP address. */ + status = pj_gethostip(pj_AF_INET(), &addr); + if (status != PJ_SUCCESS) + goto on_error; + + bound_addr.sin_addr.s_addr = addr.ipv4.sin_addr.s_addr; + } for (i=0; i<2; ++i) { pj_sockaddr_in_init(&mapped_addr[i], NULL, 0); - mapped_addr[i].sin_addr.s_addr = addr.ipv4.sin_addr.s_addr; + mapped_addr[i].sin_addr.s_addr = bound_addr.sin_addr.s_addr; } mapped_addr[0].sin_port=pj_htons((pj_uint16_t)next_rtp_port); -- cgit v1.2.3