From 5aa030d578b0857162365015c6062c4bf90a5f67 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 26 Sep 2016 17:59:40 +0200 Subject: [PATCH] Replace sal_op_is_ipv6() by sal_op_get_address_family(). This is necessary because in some cases the op cannot tell whether it is IPv6 or IPv4. And in such cases we can fallback to an other method to get the information (get_local_ip_for()). --- coreapi/bellesip_sal/sal_op_impl.c | 10 +++++----- coreapi/linphonecall.c | 9 ++++++--- include/sal/sal.h | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index 11cec683f..aa1b7ca55 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -738,7 +738,7 @@ void sal_op_set_manual_refresher_mode(SalOp *op, bool_t enabled){ op->manual_refresher=enabled; } -bool_t sal_op_is_ipv6(SalOp *op){ +int sal_op_get_address_family(SalOp *op){ belle_sip_transaction_t *tr=NULL; belle_sip_header_address_t *contact; @@ -753,7 +753,7 @@ bool_t sal_op_is_ipv6(SalOp *op){ if (tr==NULL){ ms_error("Unable to determine IP version from signaling operation."); - return FALSE; + return AF_UNSPEC; } @@ -762,16 +762,16 @@ bool_t sal_op_is_ipv6(SalOp *op){ belle_sip_header_via_t *via = resp ?belle_sip_message_get_header_by_type(resp,belle_sip_header_via_t):NULL; if (!via){ ms_error("Unable to determine IP version from signaling operation, no via header found."); - return FALSE; + return AF_UNSPEC; } - return strchr(belle_sip_header_via_get_host(via),':') != NULL; + return (strchr(belle_sip_header_via_get_host(via),':') != NULL) ? AF_INET6 : AF_INET; } else { belle_sip_request_t *req = belle_sip_transaction_get_request(tr); contact=(belle_sip_header_address_t*)belle_sip_message_get_header_by_type(req,belle_sip_header_contact_t); if (!contact){ ms_error("Unable to determine IP version from signaling operation, no contact header found."); } - return sal_address_is_ipv6((SalAddress*)contact); + return sal_address_is_ipv6((SalAddress*)contact) ? AF_INET6 : AF_INET; } } diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index dcaccf725..5b275254c 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1048,8 +1048,11 @@ static void linphone_call_outgoing_select_ip_version(LinphoneCall *call, Linphon if (sal_address_is_ipv6((SalAddress*)to)){ call->af=AF_INET6; }else if (cfg && cfg->op){ - call->af=sal_op_is_ipv6(cfg->op) ? AF_INET6 : AF_INET; + call->af=sal_op_get_address_family(cfg->op); }else{ + call->af=AF_UNSPEC; + } + if (call->af == AF_UNSPEC) { char ipv4[LINPHONE_IPADDR_SIZE]; char ipv6[LINPHONE_IPADDR_SIZE]; bool_t have_ipv6 = FALSE; @@ -1231,9 +1234,9 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr static void linphone_call_incoming_select_ip_version(LinphoneCall *call, LinphoneProxyConfig *cfg){ if (linphone_core_ipv6_enabled(call->core)){ if (cfg && cfg->op){ - call->af=sal_op_is_ipv6(cfg->op) ? AF_INET6 : AF_INET; + call->af=sal_op_get_address_family(cfg->op); }else{ - call->af=sal_op_is_ipv6(call->op) ? AF_INET6 : AF_INET; + call->af=sal_op_get_address_family(call->op); } }else call->af=AF_INET; } diff --git a/include/sal/sal.h b/include/sal/sal.h index e22d42259..85b6a1600 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -710,7 +710,7 @@ const SalAddress* sal_op_get_service_route(const SalOp *op); void sal_op_set_service_route(SalOp *op,const SalAddress* service_route); void sal_op_set_manual_refresher_mode(SalOp *op, bool_t enabled); -bool_t sal_op_is_ipv6(SalOp *op); +int sal_op_get_address_family(SalOp *op); /*returns TRUE if there is no pending request that may block a future one */ bool_t sal_op_is_idle(SalOp *op);