Add -4 and -6 options to set address family when resolving names

This commit is contained in:
Miroslav Lichvar
2009-10-13 13:10:28 +02:00
parent a7892a1a15
commit fbd20c429e
4 changed files with 25 additions and 1 deletions

View File

@@ -40,6 +40,14 @@
#define MAXRETRIES 10
static unsigned int retries = 0;
static int address_family = IPADDR_UNSPEC;
void
DNS_SetAddressFamily(int family)
{
address_family = family;
}
int
DNS_Name2IPAddress(const char *name, IPAddr *addr, int retry)
{
@@ -80,6 +88,8 @@ try_again:
break;
#endif
}
if (result && address_family != IPADDR_UNSPEC && address_family != addr->family)
result = 0;
}
freeaddrinfo(res);