1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

s4-ipv6: fix iface_list_best_ip() for IPv6

return an interface with the same address family as the target
This commit is contained in:
Andrew Tridgell 2011-06-06 15:18:12 +10:00
parent 776598a981
commit 6a6d4d8884

View File

@ -371,6 +371,23 @@ const char *iface_list_first_v4(struct interface *ifaces)
return NULL;
}
/**
return the first IPv6 interface address we have registered
**/
static const char *iface_list_first_v6(struct interface *ifaces)
{
struct interface *i;
#ifdef HAVE_IPV6
for (i=ifaces; i; i=i->next) {
if (i->ip.ss_family == AF_INET6) {
return i->ip_s;
}
}
#endif
return NULL;
}
/**
check if an interface is IPv4
**/
@ -435,7 +452,12 @@ const char *iface_list_best_ip(struct interface *ifaces, const char *dest)
if (iface) {
return iface->ip_s;
}
return iface_list_n_ip(ifaces, 0);
#ifdef HAVE_IPV6
if (ss.ss_family == AF_INET6) {
return iface_list_first_v6(ifaces);
}
#endif
return iface_list_first_v4(ifaces);
}
/**