summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-12-20 11:23:07 +0000
committerBenny Prijono <bennylp@teluu.com>2007-12-20 11:23:07 +0000
commit050af3159e072d2cde0e4354a596a5b10959cd55 (patch)
treed18b49cef4d1dbad6b33bcf0afafc88614834ddb /pjsip
parentb2a057941ada78ae228da21c311347d2d5469162 (diff)
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
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c14
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c17
2 files changed, 20 insertions, 11 deletions
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);