summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/socket/config.m41
-rw-r--r--source4/lib/socket/socket_ip.c33
2 files changed, 25 insertions, 9 deletions
diff --git a/source4/lib/socket/config.m4 b/source4/lib/socket/config.m4
index 9c0072dd8b..fa987a1f46 100644
--- a/source4/lib/socket/config.m4
+++ b/source4/lib/socket/config.m4
@@ -1,6 +1,5 @@
AC_CHECK_FUNCS(writev)
AC_CHECK_FUNCS(readv)
-AC_CHECK_FUNCS(gethostbyname2)
############################################
# check for unix domain sockets
diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c
index bca0aab924..cdb75fe021 100644
--- a/source4/lib/socket/socket_ip.c
+++ b/source4/lib/socket/socket_ip.c
@@ -549,19 +549,36 @@ _PUBLIC_ const struct socket_ops *socket_ipv4_ops(enum socket_type type)
static struct in6_addr interpret_addr6(const char *name)
{
- struct hostent *he;
-
- if (name == NULL) return in6addr_any;
+ char addr[INET6_ADDRSTRLEN];
+ struct in6_addr dest6;
+ const char *sp = name;
+ char *p = strchr_m(sp, '%');
+ int ret;
+
+ if (sp == NULL) return in6addr_any;
- if (strcasecmp(name, "localhost") == 0) {
- name = "::1";
+ if (strcasecmp(sp, "localhost") == 0) {
+ sp = "::1";
}
- he = gethostbyname2(name, PF_INET6);
+ /*
+ * Cope with link-local.
+ * This is IP:v6:addr%ifname.
+ */
+
+ if (p && (p > sp) && (if_nametoindex(p+1) != 0)) {
+ strlcpy(addr, sp,
+ MIN(PTR_DIFF(p,sp)+1,
+ sizeof(addr)));
+ sp = addr;
+ }
- if (he == NULL) return in6addr_any;
+ ret = inet_pton(AF_INET6, sp, &dest6);
+ if (ret > 0) {
+ return dest6;
+ }
- return *((struct in6_addr *)he->h_addr);
+ return in6addr_any;
}
static NTSTATUS ipv6_init(struct socket_context *sock)