From 12b8a79058b3930091723e4a97c2dcdc8a27b56f Mon Sep 17 00:00:00 2001 From: Liong Sauw Ming Date: Mon, 29 Feb 2016 08:24:58 +0000 Subject: Re #1882 (misc): Various IPv6 fixes: - For contact rewrite feature, when contact address is IPv6, it shouldn't be replaced with IPv4 address - If tp_type is already of type IPv6, adding it with PJSIP_TRANSPORT_IPV6 will result in an invalid transport type - Add check if pj_getaddrinfo() returns zero address. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5249 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsua-lib/pjsua_acc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c index 61501431..2eee77d4 100644 --- a/pjsip/src/pjsua-lib/pjsua_acc.c +++ b/pjsip/src/pjsua-lib/pjsua_acc.c @@ -1645,8 +1645,12 @@ static pj_bool_t acc_check_nat_addr(pjsua_acc *acc, status = pj_sockaddr_parse(pj_AF_UNSPEC(), 0, via_addr, &recv_addr); if (status == PJ_SUCCESS) { - /* Compare the addresses as sockaddr according to the ticket above */ - matched = (uri->port == rport && + /* Compare the addresses as sockaddr according to the ticket above, + * but only if they have the same family (ipv4 vs ipv4, or + * ipv6 vs ipv6) + */ + matched = (contact_addr.addr.sa_family != recv_addr.addr.sa_family) || + (uri->port == rport && pj_sockaddr_cmp(&contact_addr, &recv_addr)==0); } else { /* Compare the addresses as string, as before */ @@ -3099,7 +3103,8 @@ pj_status_t pjsua_acc_get_uac_addr(pjsua_acc_id acc_id, * to use IPv6 as well. */ if (pj_strchr(&sip_uri->host, ':')) - tp_type = (pjsip_transport_type_e)(((int)tp_type) + PJSIP_TRANSPORT_IPV6); + tp_type = (pjsip_transport_type_e)(((int)tp_type) | + PJSIP_TRANSPORT_IPV6); flag = pjsip_transport_get_flag_from_type(tp_type); @@ -3164,6 +3169,7 @@ pj_status_t pjsua_acc_get_uac_addr(pjsua_acc_id acc_id, af = (dinfo.type & PJSIP_TRANSPORT_IPV6)? PJ_AF_INET6 : PJ_AF_INET; status = pj_getaddrinfo(af, &dinfo.addr.host, &cnt, &ai); + if (cnt == 0) status = PJ_ENOTSUP; } if (status == PJ_SUCCESS) { -- cgit v1.2.3