summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-06-06 15:18:12 +1000
committerAndrew Tridgell <tridge@samba.org>2011-06-07 12:55:37 +1000
commit6a6d4d8884788c1e860bda886d168301623e1ea3 (patch)
tree6cd4b7fcb46688157527a5c3927fb4a754eee126 /source4/lib
parent776598a98103a20fc6a0bfafdebd105e448518ac (diff)
downloadsamba-6a6d4d8884788c1e860bda886d168301623e1ea3.tar.gz
samba-6a6d4d8884788c1e860bda886d168301623e1ea3.tar.bz2
samba-6a6d4d8884788c1e860bda886d168301623e1ea3.zip
s4-ipv6: fix iface_list_best_ip() for IPv6
return an interface with the same address family as the target
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/socket/interface.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c
index 96cee2fbe6..1bf1e4f62b 100644
--- a/source4/lib/socket/interface.c
+++ b/source4/lib/socket/interface.c
@@ -372,6 +372,23 @@ const char *iface_list_first_v4(struct interface *ifaces)
}
/**
+ 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
**/
bool iface_list_n_is_v4(struct interface *ifaces, int n)
@@ -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);
}
/**