socket: add function to check supported family

Don't log error when an IPv6 socket cannot be opened and chronyd was
built without IPv6 support.

Reported-by: Lonnie Abelbeck <lonnie@abelbeck.com>
This commit is contained in:
Miroslav Lichvar
2020-01-03 09:36:59 +01:00
parent bfcd8ecc56
commit dd0679ad45
4 changed files with 24 additions and 1 deletions

View File

@@ -1115,6 +1115,23 @@ SCK_Finalise(void)
/* ================================================== */
int
SCK_IsFamilySupported(int family)
{
switch (family) {
case IPADDR_INET4:
return 1;
case IPADDR_INET6:
#ifdef FEAT_IPV6
return 1;
#endif
default:
return 0;
}
}
/* ================================================== */
void
SCK_GetAnyLocalIPAddress(int family, IPAddr *local_addr)
{