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.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/freebsd/lib/libc/net/name6.c b/freebsd/lib/libc/net/name6.c
index 2a93efce..a106ad98 100644
--- a/freebsd/lib/libc/net/name6.c
+++ b/freebsd/lib/libc/net/name6.c
@@ -44,11 +44,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -100,7 +96,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/in.h>
#ifdef INET6
#include <net/if.h>
-#include <net/if_var.h>
#include <sys/sysctl.h>
#include <sys/ioctl.h>
#include <netinet6/in6_var.h> /* XXX */
@@ -241,13 +236,13 @@ getipnodebyname(const char *name, int af, int flags, int *errp)
if (flags & AI_ADDRCONFIG) {
int s;
- if ((s = _socket(af, SOCK_DGRAM, 0)) < 0)
+ if ((s = _socket(af, SOCK_DGRAM | SOCK_CLOEXEC, 0)) < 0)
return NULL;
/*
* TODO:
* Note that implementation dependent test for address
- * configuration should be done everytime called
- * (or apropriate interval),
+ * configuration should be done every time called
+ * (or appropriate interval),
* because addresses will be dynamically assigned or deleted.
*/
_close(s);
@@ -337,7 +332,7 @@ getipnodebyaddr(const void *src, size_t len, int af, int *errp)
*errp = NO_RECOVERY;
return NULL;
}
- if ((long)src & ~(sizeof(struct in_addr) - 1)) {
+ if (rounddown2((long)src, sizeof(struct in_addr))) {
memcpy(&addrbuf, src, len);
src = &addrbuf;
}
@@ -350,7 +345,8 @@ getipnodebyaddr(const void *src, size_t len, int af, int *errp)
*errp = NO_RECOVERY;
return NULL;
}
- if ((long)src & ~(sizeof(struct in6_addr) / 2 - 1)) { /*XXX*/
+ if (rounddown2((long)src, sizeof(struct in6_addr) / 2)) {
+ /* XXX */
memcpy(&addrbuf, src, len);
src = &addrbuf;
}
@@ -661,7 +657,6 @@ _hpreorder(struct hostent *hp)
#endif
break;
default:
- free_addrselectpolicy(&policyhead);
return hp;
}
@@ -742,11 +737,11 @@ get_addrselectpolicy(struct policyhead *head)
char *buf;
struct in6_addrpolicy *pol, *ep;
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0)
+ if (sysctl(mib, nitems(mib), NULL, &l, NULL, 0) < 0)
return (0);
if ((buf = malloc(l)) == NULL)
return (0);
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
+ if (sysctl(mib, nitems(mib), buf, &l, NULL, 0) < 0) {
free(buf);
return (0);
}
@@ -801,10 +796,9 @@ match_addrselectpolicy(struct sockaddr *addr, struct policyhead *head)
memset(&key, 0, sizeof(key));
key.sin6_family = AF_INET6;
key.sin6_len = sizeof(key);
- key.sin6_addr.s6_addr[10] = 0xff;
- key.sin6_addr.s6_addr[11] = 0xff;
- memcpy(&key.sin6_addr.s6_addr[12],
- &((struct sockaddr_in *)addr)->sin_addr, 4);
+ _map_v4v6_address(
+ (char *)&((struct sockaddr_in *)addr)->sin_addr,
+ (char *)&key.sin6_addr);
break;
default:
return(NULL);
@@ -874,7 +868,8 @@ set_source(struct hp_order *aio, struct policyhead *ph)
}
/* open a socket to get the source address for the given dst */
- if ((s = _socket(ss.ss_family, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+ if ((s = _socket(ss.ss_family, SOCK_DGRAM | SOCK_CLOEXEC,
+ IPPROTO_UDP)) < 0)
return; /* give up */
if (_connect(s, (struct sockaddr *)&ss, ss.ss_len) < 0)
goto cleanup;