Fix bug with Samba not recognising an 6to4 IPv6 interface.
[samba.git] / lib / socket / interfaces.c
index 618714d1a73f9a9c53c12aa41d036a24d5d58044..9bdecb243d8ed434ed813031f825eab9280b5f36 100644 (file)
@@ -195,6 +195,19 @@ static int _get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
                        memcpy(&ifaces[total].bcast,
                                ifptr->ifa_dstaddr,
                                copy_size);
+#if defined(HAVE_IPV6)
+               } else if (ifptr->ifa_addr->sa_family == AF_INET6) {
+                       const struct sockaddr_in6 *sin6 =
+                               (const struct sockaddr_in6 *)ifptr->ifa_addr;
+                       const struct in6_addr *in6 =
+                               (const struct in6_addr *)&sin6->sin6_addr;
+
+                       if (IN6_IS_ADDR_LINKLOCAL(in6) || IN6_IS_ADDR_V4COMPAT(in6)) {
+                               continue;
+                       }
+                       /* IPv6 does not have broadcast it uses multicast. */
+                       memset(&ifaces[total].bcast, '\0', copy_size);
+#endif
                } else {
                        continue;
                }