Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
17e4a1ff
Commit
17e4a1ff
authored
Jul 06, 2017
by
Ghislain MARY
Browse files
Improve selection of IP address to use to connect to the STUN server for ICE candidates gathering.
parent
786c1614
Changes
1
Hide whitespace changes
Inline
Side-by-side
coreapi/misc.c
View file @
17e4a1ff
...
...
@@ -564,30 +564,44 @@ static void linphone_core_add_local_ice_candidates(LinphoneCall *call, int famil
}
}
static
const
struct
addrinfo
*
get_preferred_stun_server_addrinfo
(
const
struct
addrinfo
*
ai
)
{
char
ip
[
NI_MAXHOST
];
const
struct
addrinfo
*
preferred_ai
=
NULL
;
static
const
struct
addrinfo
*
find_nat64_addrinfo
(
const
struct
addrinfo
*
ai
)
{
while
(
ai
!=
NULL
)
{
bctbx_addrinfo_to_printable_ip_address
(
ai
,
ip
,
sizeof
(
ip
));
if
(
ai
->
ai_family
==
AF_INET
)
{
preferred_ai
=
ai
;
break
;
}
else
if
(
ai
->
ai_family
==
AF_INET6
)
{
if
(
ai
->
ai_family
==
AF_INET6
)
{
struct
sockaddr_storage
ss
;
socklen_t
sslen
=
sizeof
(
ss
);
bctbx_sockaddr_remove_nat64_mapping
(
ai
->
ai_addr
,
(
struct
sockaddr
*
)
&
ss
,
&
sslen
);
if
(
ss
.
ss_family
==
AF_INET
)
{
preferred_ai
=
ai
;
break
;
}
preferred_ai
=
ai
;
if
(
ss
.
ss_family
==
AF_INET
)
break
;
}
ai
=
ai
->
ai_next
;
}
return
ai
;
}
static
const
struct
addrinfo
*
find_ipv4_addrinfo
(
const
struct
addrinfo
*
ai
)
{
while
(
ai
!=
NULL
)
{
if
(
ai
->
ai_family
==
AF_INET
)
break
;
ai
=
ai
->
ai_next
;
}
return
ai
;
}
static
const
struct
addrinfo
*
find_ipv6_addrinfo
(
const
struct
addrinfo
*
ai
)
{
while
(
ai
!=
NULL
)
{
if
(
ai
->
ai_family
==
AF_INET6
)
break
;
ai
=
ai
->
ai_next
;
}
return
ai
;
}
bctbx_addrinfo_to_printable_ip_address
(
preferred_ai
,
ip
,
sizeof
(
ip
));
/**
* Choose the preferred IP address to use to contact the STUN server from the list of IP addresses
* the DNS resolution returned. If a NAT64 address is present, use it, otherwise if an IPv4 address
* is present, use it, otherwise use an IPv6 address if it is present.
*/
static
const
struct
addrinfo
*
get_preferred_stun_server_addrinfo
(
const
struct
addrinfo
*
ai
)
{
const
struct
addrinfo
*
preferred_ai
=
find_nat64_addrinfo
(
ai
);
if
(
!
preferred_ai
)
preferred_ai
=
find_ipv4_addrinfo
(
ai
);
if
(
!
preferred_ai
)
preferred_ai
=
find_ipv6_addrinfo
(
ai
);
return
preferred_ai
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment