mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-27 13:16:21 +00:00
Fix algorithm for IP version selection on outgoing calls. In particular, the "prefer_ipv6" option wasn't really taken into account.
This commit is contained in:
parent
8ef84da0a0
commit
3fd706a702
1 changed files with 28 additions and 30 deletions
|
|
@ -1216,44 +1216,42 @@ void linphone_call_create_op(LinphoneCall *call){
|
||||||
* Choose IP version we are going to use for RTP streams IP address advertised in SDP.
|
* Choose IP version we are going to use for RTP streams IP address advertised in SDP.
|
||||||
* The algorithm is as follows:
|
* The algorithm is as follows:
|
||||||
* - if ipv6 is disabled at the core level, it is always AF_INET
|
* - if ipv6 is disabled at the core level, it is always AF_INET
|
||||||
* - Otherwise, if the destination address for the call is an IPv6 address, use IPv6.
|
|
||||||
* - Otherwise, if the call is done through a known proxy config, then use the information obtained during REGISTER
|
* - Otherwise, if the call is done through a known proxy config, then use the information obtained during REGISTER
|
||||||
|
* - Otherwise if the destination address for the call is an IPv6 address, use IPv6.
|
||||||
* to know if IPv6 is supported by the server.
|
* to know if IPv6 is supported by the server.
|
||||||
**/
|
**/
|
||||||
static void linphone_call_outgoing_select_ip_version(LinphoneCall *call, LinphoneAddress *to, LinphoneProxyConfig *cfg){
|
static void linphone_call_outgoing_select_ip_version(LinphoneCall *call, LinphoneAddress *to, LinphoneProxyConfig *cfg){
|
||||||
|
char ipv4[LINPHONE_IPADDR_SIZE];
|
||||||
|
char ipv6[LINPHONE_IPADDR_SIZE];
|
||||||
|
bool_t have_ipv6 = FALSE;
|
||||||
|
bool_t have_ipv4 = FALSE;
|
||||||
|
|
||||||
|
call->af = AF_UNSPEC;
|
||||||
|
if (linphone_core_get_local_ip_for(AF_INET, NULL, ipv4) == 0){
|
||||||
|
have_ipv4 = TRUE;
|
||||||
|
}
|
||||||
if (linphone_core_ipv6_enabled(call->core)){
|
if (linphone_core_ipv6_enabled(call->core)){
|
||||||
if (sal_address_is_ipv6((SalAddress*)to)){
|
if (linphone_core_get_local_ip_for(AF_INET6, NULL, ipv6) == 0){
|
||||||
call->af=AF_INET6;
|
have_ipv6 = TRUE;
|
||||||
}else if (cfg && cfg->op){
|
|
||||||
call->af=sal_op_get_address_family(cfg->op);
|
|
||||||
}else{
|
|
||||||
call->af=AF_UNSPEC;
|
|
||||||
}
|
}
|
||||||
if (call->af == AF_UNSPEC) {
|
if (cfg && cfg->op){
|
||||||
char ipv4[LINPHONE_IPADDR_SIZE];
|
/*we can determine from the proxy connection whether IPv6 works - this is the most reliable*/
|
||||||
char ipv6[LINPHONE_IPADDR_SIZE];
|
call->af = sal_op_get_address_family(cfg->op);
|
||||||
bool_t have_ipv6 = FALSE;
|
}else if (sal_address_is_ipv6((SalAddress*)to)){
|
||||||
bool_t have_ipv4 = FALSE;
|
call->af = AF_INET6;
|
||||||
/*check connectivity for IPv4 and IPv6*/
|
}
|
||||||
if (linphone_core_get_local_ip_for(AF_INET6, NULL, ipv6) == 0){
|
|
||||||
have_ipv6 = TRUE;
|
if (lp_config_get_int(call->core->config, "rtp", "prefer_ipv6", 1) == 0 && have_ipv4){
|
||||||
}
|
/* This is the case where ipv4 is to be prefered if both are available.*/
|
||||||
if (linphone_core_get_local_ip_for(AF_INET, NULL, ipv4) == 0){
|
call->af = AF_INET; /*we'll use IPv4*/
|
||||||
have_ipv4 = TRUE;
|
ms_message("prefer_ipv6 is set to false, as both IP versions are available we are going to use IPv4");
|
||||||
}
|
}
|
||||||
if (have_ipv6){
|
if (call->af == AF_UNSPEC){
|
||||||
if (!have_ipv4) {
|
call->af = have_ipv6 ? AF_INET6 : AF_INET;
|
||||||
call->af = AF_INET6;
|
|
||||||
}else if (lp_config_get_int(call->core->config, "rtp", "prefer_ipv6", 1)){ /*this property tells whether ipv6 is prefered if two versions are available*/
|
|
||||||
call->af = AF_INET6;
|
|
||||||
}else{
|
|
||||||
call->af = AF_INET;
|
|
||||||
}
|
|
||||||
}else call->af = AF_INET;
|
|
||||||
/*fill the media_localip default value since we have it here*/
|
|
||||||
strncpy(call->media_localip,call->af == AF_INET6 ? ipv6 : ipv4, LINPHONE_IPADDR_SIZE);
|
|
||||||
}
|
}
|
||||||
}else call->af=AF_INET;
|
}else call->af=AF_INET;
|
||||||
|
/*fill the media_localip default value since we have it here*/
|
||||||
|
strncpy(call->media_localip,call->af == AF_INET6 ? ipv6 : ipv4, LINPHONE_IPADDR_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue