summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2016-07-14 04:37:37 +0000
committerNanang Izzuddin <nanang@teluu.com>2016-07-14 04:37:37 +0000
commit15ce2ebbd72bab8e91cd16ec77419897aa99bbde (patch)
treebd2c1f444ca0f2d8677dc0fa3b89f54b1d8507a0 /pjsip
parent8e050f5a6fdc2afc35eeb80c60bf5bc6e378f130 (diff)
Misc (re #1928): Use host IP for SIP UDP transport address when STUN resolution fails to avoid zero address.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5382 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 6fa3da99..ea7aab2e 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -2151,10 +2151,24 @@ static pj_status_t create_sip_udp_sock(int af,
pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port);
status = pjstun_get_mapped_addr2(&pjsua_var.cp.factory, &stun_opt,
1, &sock, &p_pub_addr->ipv4);
- if (status != PJ_SUCCESS && !pjsua_var.ua_cfg.stun_ignore_failure) {
+ if (status != PJ_SUCCESS) {
+ /* Failed getting mapped address via STUN */
pjsua_perror(THIS_FILE, "Error contacting STUN server", status);
- pj_sock_close(sock);
- return status;
+
+ /* Return error if configured to not ignore STUN failure */
+ if (!pjsua_var.ua_cfg.stun_ignore_failure) {
+ pj_sock_close(sock);
+ return status;
+ }
+
+ /* Otherwise, just use host IP */
+ pj_sockaddr_init(af, p_pub_addr, NULL, (pj_uint16_t)port);
+ 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;
+ }
}
} else {