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()).
This commit is contained in:
Ghislain MARY 2016-09-26 17:59:40 +02:00
parent fd78a2f7b9
commit 5aa030d578
3 changed files with 12 additions and 9 deletions

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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);