summaryrefslogtreecommitdiffstats
path: root/freebsd/lib/libc/net/name6.c
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/lib/libc/net/name6.c')
-rw-r--r--freebsd/lib/libc/net/name6.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/freebsd/lib/libc/net/name6.c b/freebsd/lib/libc/net/name6.c
index c60a3efd..564721ae 100644
--- a/freebsd/lib/libc/net/name6.c
+++ b/freebsd/lib/libc/net/name6.c
@@ -200,6 +200,7 @@ static struct hostent *_hpmapv6(struct hostent *, int *);
#endif
static struct hostent *_hpsort(struct hostent *, res_state);
+#ifdef INET6
static struct hostent *_hpreorder(struct hostent *);
static int get_addrselectpolicy(struct policyhead *);
static void free_addrselectpolicy(struct policyhead *);
@@ -209,6 +210,7 @@ static void set_source(struct hp_order *, struct policyhead *);
static int matchlen(struct sockaddr *, struct sockaddr *);
static int comp_dst(const void *, const void *);
static int gai_addr2scopetype(struct sockaddr *);
+#endif
/*
* Functions defined in RFC2553
@@ -285,8 +287,10 @@ getipnodebyname(const char *name, int af, int flags, int *errp)
hp = gethostbyname2(name, af);
hp = _hpcopy(hp, errp);
-
#ifdef INET6
+ if (af == AF_INET6)
+ hp = _hpreorder(hp);
+
if (af == AF_INET6 && ((flags & AI_ALL) || hp == NULL) &&
MAPADDRENABLED(flags)) {
struct hostent *hp2 = gethostbyname2(name, AF_INET);
@@ -309,7 +313,7 @@ getipnodebyname(const char *name, int af, int flags, int *errp)
*errp = statp->res_h_errno;
statp->options = options;
- return _hpreorder(_hpsort(hp, statp));
+ return _hpsort(hp, statp);
}
struct hostent *
@@ -632,6 +636,7 @@ _hpsort(struct hostent *hp, res_state statp)
return hp;
}
+#ifdef INET6
/*
* _hpreorder: sort address by default address selection
*/
@@ -884,8 +889,6 @@ set_source(struct hp_order *aio, struct policyhead *ph)
struct in6_ifreq ifr6;
u_int32_t flags6;
- /* XXX: interface name should not be hardcoded */
- strncpy(ifr6.ifr_name, "lo0", sizeof(ifr6.ifr_name));
memset(&ifr6, 0, sizeof(ifr6));
memcpy(&ifr6.ifr_addr, &ss, ss.ss_len);
if (_ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) == 0) {
@@ -1111,3 +1114,4 @@ gai_addr2scopetype(struct sockaddr *sa)
return(-1);
}
}
+#endif