diff options
Diffstat (limited to 'usr.sbin/bind/lib')
-rw-r--r-- | usr.sbin/bind/lib/isc/include/isc/ipv6.h | 8 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/include/isc/platform.h.in | 125 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/inet_ntop.c | 205 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/inet_pton.c | 214 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/netaddr.c | 6 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/netscope.c | 8 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/sockaddr.c | 22 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/unix/entropy.c | 4 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/unix/ifiter_ioctl.c | 54 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c | 16 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/unix/include/isc/net.h | 107 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/unix/interfaceiter.c | 11 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/unix/net.c | 32 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isc/unix/socket.c | 126 | ||||
-rw-r--r-- | usr.sbin/bind/lib/isccfg/parser.c | 4 |
15 files changed, 10 insertions, 932 deletions
diff --git a/usr.sbin/bind/lib/isc/include/isc/ipv6.h b/usr.sbin/bind/lib/isc/include/isc/ipv6.h index 486d930554c..86626e7890a 100644 --- a/usr.sbin/bind/lib/isc/include/isc/ipv6.h +++ b/usr.sbin/bind/lib/isc/include/isc/ipv6.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ipv6.h,v 1.3 2019/12/17 01:46:35 sthen Exp $ */ +/* $Id: ipv6.h,v 1.4 2020/01/09 13:45:33 florian Exp $ */ #ifndef ISC_IPV6_H #define ISC_IPV6_H 1 @@ -78,21 +78,15 @@ LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_any; LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_loopback; struct sockaddr_in6 { -#ifdef ISC_PLATFORM_HAVESALEN isc_uint8_t sin6_len; isc_uint8_t sin6_family; -#else - isc_uint16_t sin6_family; -#endif isc_uint16_t sin6_port; isc_uint32_t sin6_flowinfo; struct in6_addr sin6_addr; isc_uint32_t sin6_scope_id; }; -#ifdef ISC_PLATFORM_HAVESALEN #define SIN6_LEN 1 -#endif /*% * Unspecified diff --git a/usr.sbin/bind/lib/isc/include/isc/platform.h.in b/usr.sbin/bind/lib/isc/include/isc/platform.h.in index c1bbd006e53..350a004b550 100644 --- a/usr.sbin/bind/lib/isc/include/isc/platform.h.in +++ b/usr.sbin/bind/lib/isc/include/isc/platform.h.in @@ -23,131 +23,6 @@ ***** Platform-dependent defines. *****/ -/*** - *** Network. - ***/ - -/*! \brief - * Define if this system needs the <netinet/in6.h> header file included - * for full IPv6 support (pretty much only UnixWare). - */ -@ISC_PLATFORM_NEEDNETINETIN6H@ - -/*! \brief - * Define if this system needs the <netinet6/in6.h> header file included - * to support in6_pkinfo (pretty much only BSD/OS). - */ -@ISC_PLATFORM_NEEDNETINET6IN6H@ - -/*! \brief - * If sockaddrs on this system have an sa_len field, ISC_PLATFORM_HAVESALEN - * will be defined. - */ -@ISC_PLATFORM_HAVESALEN@ - -/*! \brief - * If this system has the IPv6 structure definitions, ISC_PLATFORM_HAVEIPV6 - * will be defined. - */ -@ISC_PLATFORM_HAVEIPV6@ - -/*! \brief - * If this system is missing in6addr_any, ISC_PLATFORM_NEEDIN6ADDRANY will - * be defined. - */ -@ISC_PLATFORM_NEEDIN6ADDRANY@ - -/*! \brief - * If this system is missing in6addr_loopback, ISC_PLATFORM_NEEDIN6ADDRLOOPBACK - * will be defined. - */ -@ISC_PLATFORM_NEEDIN6ADDRLOOPBACK@ - -/*! \brief - * If this system has in6_pktinfo, ISC_PLATFORM_HAVEIN6PKTINFO will be - * defined. - */ -@ISC_PLATFORM_HAVEIN6PKTINFO@ - -/*! \brief - * If this system has in_addr6, rather than in6_addr, ISC_PLATFORM_HAVEINADDR6 - * will be defined. - */ -@ISC_PLATFORM_HAVEINADDR6@ - -/*! \brief - * If this system has sin6_scope_id, ISC_PLATFORM_HAVESCOPEID will be defined. - */ -@ISC_PLATFORM_HAVESCOPEID@ - -/*! \brief - * If this system needs inet_ntop(), ISC_PLATFORM_NEEDNTOP will be defined. - */ -@ISC_PLATFORM_NEEDNTOP@ - -/*! \brief - * If this system needs inet_pton(), ISC_PLATFORM_NEEDPTON will be defined. - */ -@ISC_PLATFORM_NEEDPTON@ - -/*! \brief - * If this system needs in_port_t, ISC_PLATFORM_NEEDPORTT will be defined. - */ -@ISC_PLATFORM_NEEDPORTT@ - -/*! \brief - * Define if the system has struct lifconf which is a extended struct ifconf - * for IPv6. - */ -@ISC_PLATFORM_HAVELIFCONF@ - -/*! \brief - * Define if the system has struct if_laddrconf which is a extended struct - * ifconf for IPv6. - */ -@ISC_PLATFORM_HAVEIF_LADDRCONF@ - -/*! \brief - * Define if the system has struct if_laddrreq. - */ -@ISC_PLATFORM_HAVEIF_LADDRREQ@ - -/*! \brief - * Define either ISC_PLATFORM_BSD44MSGHDR or ISC_PLATFORM_BSD43MSGHDR. - */ -@ISC_PLATFORM_MSGHDRFLAVOR@ - -/*! \brief - * Define if the system supports if_nametoindex. - */ -@ISC_PLATFORM_HAVEIFNAMETOINDEX@ - -/*! \brief - * Define on some UnixWare systems to fix erroneous definitions of various - * IN6_IS_ADDR_* macros. - */ -@ISC_PLATFORM_FIXIN6ISADDR@ - -/*! \brief - * Define if the system has struct sockaddr_storage. - */ -@ISC_PLATFORM_HAVESOCKADDRSTORAGE@ - -/*! \brief - * Define if the system supports kqueue multiplexing - */ -@ISC_PLATFORM_HAVEKQUEUE@ - -/*! \brief - * Define if the system supports epoll multiplexing - */ -@ISC_PLATFORM_HAVEEPOLL@ - -/*! \brief - * Define if the system supports /dev/poll multiplexing - */ -@ISC_PLATFORM_HAVEDEVPOLL@ - /* *** Printing. ***/ diff --git a/usr.sbin/bind/lib/isc/inet_ntop.c b/usr.sbin/bind/lib/isc/inet_ntop.c deleted file mode 100644 index 58a032009a8..00000000000 --- a/usr.sbin/bind/lib/isc/inet_ntop.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/*! \file */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = - "$Id: inet_ntop.c,v 1.7 2019/12/17 01:46:34 sthen Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include <config.h> - -#include <errno.h> -#include <stdio.h> -#include <string.h> - -#include <isc/net.h> -#include <isc/print.h> -#include <isc/string.h> -#include <isc/util.h> - -#define NS_INT16SZ 2 -#define NS_IN6ADDRSZ 16 - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static const char *inet_ntop4(const unsigned char *src, char *dst, - size_t size); - -#ifdef AF_INET6 -static const char *inet_ntop6(const unsigned char *src, char *dst, - size_t size); -#endif - -/*! char * - * isc_net_ntop(af, src, dst, size) - * convert a network format address to presentation format. - * \return - * pointer to presentation format address (`dst'), or NULL (see errno). - * \author - * Paul Vixie, 1996. - */ -const char * -isc_net_ntop(int af, const void *src, char *dst, size_t size) -{ - switch (af) { - case AF_INET: - return (inet_ntop4(src, dst, size)); -#ifdef AF_INET6 - case AF_INET6: - return (inet_ntop6(src, dst, size)); -#endif - default: - errno = EAFNOSUPPORT; - return (NULL); - } - /* NOTREACHED */ -} - -/*! const char * - * inet_ntop4(src, dst, size) - * format an IPv4 address - * \return - * `dst' (as a const) - * \note - * (1) uses no statics - * \note - * (2) takes a unsigned char* not an in_addr as input - * \author - * Paul Vixie, 1996. - */ -static const char * -inet_ntop4(const unsigned char *src, char *dst, size_t size) -{ - static const char *fmt = "%u.%u.%u.%u"; - char tmp[sizeof("255.255.255.255")]; - int n; - - - n = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]); - if (n < 0 || (size_t)n >= size) { - errno = ENOSPC; - return (NULL); - } - strlcpy(dst, tmp, size); - - return (dst); -} - -/*! const char * - * isc_inet_ntop6(src, dst, size) - * convert IPv6 binary address into presentation (printable) format - * \author - * Paul Vixie, 1996. - */ -#ifdef AF_INET6 -static const char * -inet_ntop6(const unsigned char *src, char *dst, size_t size) -{ - /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. - */ - char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")], *tp; - struct { int base, len; } best, cur; - unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ]; - int i; - - /* - * Preprocess: - * Copy the input (bytewise) array into a wordwise array. - * Find the longest run of 0x00's in src[] for :: shorthanding. - */ - memset(words, '\0', sizeof(words)); - for (i = 0; i < NS_IN6ADDRSZ; i++) - words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); - best.base = -1; - best.len = 0; /* silence compiler */ - cur.base = -1; - cur.len = 0; /* silence compiler */ - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - if (words[i] == 0) { - if (cur.base == -1) - cur.base = i, cur.len = 1; - else - cur.len++; - } else { - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - cur.base = -1; - } - } - } - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - } - if (best.base != -1 && best.len < 2) - best.base = -1; - - /* - * Format the result. - */ - tp = tmp; - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= best.base && - i < (best.base + best.len)) { - if (i == best.base) - *tp++ = ':'; - continue; - } - /* Are we following an initial run of 0x00s or any real hex? */ - if (i != 0) - *tp++ = ':'; - /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && (best.len == 6 || - (best.len == 7 && words[7] != 0x0001) || - (best.len == 5 && words[5] == 0xffff))) { - if (!inet_ntop4(src+12, tp, - sizeof(tmp) - (tp - tmp))) - return (NULL); - tp += strlen(tp); - break; - } - INSIST((size_t)(tp - tmp) < sizeof(tmp)); - tp += snprintf(tp, sizeof(tmp) - (tp - tmp), "%x", words[i]); - } - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == - (NS_IN6ADDRSZ / NS_INT16SZ)) - *tp++ = ':'; - *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) { - errno = ENOSPC; - return (NULL); - } - strlcpy(dst, tmp, size); - return (dst); -} -#endif /* AF_INET6 */ diff --git a/usr.sbin/bind/lib/isc/inet_pton.c b/usr.sbin/bind/lib/isc/inet_pton.c deleted file mode 100644 index d43485c9646..00000000000 --- a/usr.sbin/bind/lib/isc/inet_pton.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/*! \file */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = - "$Id: inet_pton.c,v 1.7 2019/12/17 01:46:34 sthen Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include <config.h> - -#include <errno.h> -#include <string.h> - -#include <isc/net.h> - -/*% INT16 Size */ -#define NS_INT16SZ 2 -/*% IPv4 Address Size */ -#define NS_INADDRSZ 4 -/*% IPv6 Address Size */ -#define NS_IN6ADDRSZ 16 - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static int inet_pton4(const char *src, unsigned char *dst); -static int inet_pton6(const char *src, unsigned char *dst); - -/*% - * convert from presentation format (which usually means ASCII printable) - * to network format (which is usually some kind of binary format). - * \return - * 1 if the address was valid for the specified address family - * 0 if the address wasn't valid (`dst' is untouched in this case) - * -1 if some other error occurred (`dst' is untouched in this case, too) - * \author - * Paul Vixie, 1996. - */ -int -isc_net_pton(int af, const char *src, void *dst) { - switch (af) { - case AF_INET: - return (inet_pton4(src, dst)); - case AF_INET6: - return (inet_pton6(src, dst)); - default: - errno = EAFNOSUPPORT; - return (-1); - } - /* NOTREACHED */ -} - -/*!\fn static int inet_pton4(const char *src, unsigned char *dst) - * \brief - * like inet_aton() but without all the hexadecimal and shorthand. - * \return - * 1 if `src' is a valid dotted quad, else 0. - * \note - * does not touch `dst' unless it's returning 1. - * \author - * Paul Vixie, 1996. - */ -static int -inet_pton4(const char *src, unsigned char *dst) { - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - unsigned char tmp[NS_INADDRSZ], *tp; - - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) { - unsigned int byte = *tp * 10; - - byte += (int)(pch - digits); - if (saw_digit && *tp == 0) - return (0); - if (byte > 255) - return (0); - *tp = byte; - if (!saw_digit) { - if (++octets > 4) - return (0); - saw_digit = 1; - } - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return (0); - *++tp = 0; - saw_digit = 0; - } else - return (0); - } - if (octets < 4) - return (0); - memmove(dst, tmp, NS_INADDRSZ); - return (1); -} - -/*% - * convert presentation level address to network order binary form. - * \return - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. - * \note - * (1) does not touch `dst' unless it's returning 1. - * \note - * (2) :: in a full address is silently ignored. - * \author - * inspired by Mark Andrews. - * \author - * Paul Vixie, 1996. - */ -static int -inet_pton6(const char *src, unsigned char *dst) { - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, seen_xdigits; - unsigned int val; - - memset((tp = tmp), '\0', NS_IN6ADDRSZ); - endp = tp + NS_IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - seen_xdigits = 0; - val = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (pch - xdigits); - if (++seen_xdigits > 4) - return (0); - continue; - } - if (ch == ':') { - curtok = src; - if (!seen_xdigits) { - if (colonp) - return (0); - colonp = tp; - continue; - } - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - seen_xdigits = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && - inet_pton4(curtok, tp) > 0) { - tp += NS_INADDRSZ; - seen_xdigits = 0; - break; /* '\0' was seen by inet_pton4(). */ - } - return (0); - } - if (seen_xdigits) { - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const int n = (int)(tp - colonp); - int i; - - if (tp == endp) - return (0); - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return (0); - memmove(dst, tmp, NS_IN6ADDRSZ); - return (1); -} diff --git a/usr.sbin/bind/lib/isc/netaddr.c b/usr.sbin/bind/lib/isc/netaddr.c index d3e27df0dca..b76ae3cf21d 100644 --- a/usr.sbin/bind/lib/isc/netaddr.c +++ b/usr.sbin/bind/lib/isc/netaddr.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: netaddr.c,v 1.4 2019/12/17 01:46:34 sthen Exp $ */ +/* $Id: netaddr.c,v 1.5 2020/01/09 13:45:33 florian Exp $ */ /*! \file */ @@ -340,11 +340,7 @@ isc_netaddr_fromsockaddr(isc_netaddr_t *t, const isc_sockaddr_t *s) { break; case AF_INET6: memmove(&t->type.in6, &s->type.sin6.sin6_addr, 16); -#ifdef ISC_PLATFORM_HAVESCOPEID t->zone = s->type.sin6.sin6_scope_id; -#else - t->zone = 0; -#endif break; #ifdef ISC_PLATFORM_HAVESYSUNH case AF_UNIX: diff --git a/usr.sbin/bind/lib/isc/netscope.c b/usr.sbin/bind/lib/isc/netscope.c index 31513c48fe2..90775bf2326 100644 --- a/usr.sbin/bind/lib/isc/netscope.c +++ b/usr.sbin/bind/lib/isc/netscope.c @@ -18,7 +18,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char rcsid[] = - "$Id: netscope.c,v 1.3 2019/12/17 01:46:34 sthen Exp $"; + "$Id: netscope.c,v 1.4 2020/01/09 13:45:33 florian Exp $"; #endif /* LIBC_SCCS and not lint */ #include <config.h> @@ -31,10 +31,8 @@ static char rcsid[] = isc_result_t isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid) { char *ep; -#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX unsigned int ifid; struct in6_addr *in6; -#endif isc_uint32_t zone; isc_uint64_t llz; @@ -50,13 +48,11 @@ isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid) { * interface names as link names, assuming one to one mapping between * interfaces and links. */ -#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX in6 = (struct in6_addr *)addr; if (IN6_IS_ADDR_LINKLOCAL(in6) && (ifid = if_nametoindex((const char *)scopename)) != 0) zone = (isc_uint32_t)ifid; else { -#endif llz = isc_string_touint64(scopename, &ep, 10); if (ep == scopename) return (ISC_R_FAILURE); @@ -65,9 +61,7 @@ isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid) { zone = (isc_uint32_t)(llz & 0xffffffffUL); if (zone != llz) return (ISC_R_FAILURE); -#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX } -#endif *zoneid = zone; return (ISC_R_SUCCESS); diff --git a/usr.sbin/bind/lib/isc/sockaddr.c b/usr.sbin/bind/lib/isc/sockaddr.c index 5c4e761b51c..b40667ab549 100644 --- a/usr.sbin/bind/lib/isc/sockaddr.c +++ b/usr.sbin/bind/lib/isc/sockaddr.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sockaddr.c,v 1.9 2019/12/17 01:46:34 sthen Exp $ */ +/* $Id: sockaddr.c,v 1.10 2020/01/09 13:45:33 florian Exp $ */ /*! \file */ @@ -76,7 +76,6 @@ isc_sockaddr_compare(const isc_sockaddr_t *a, const isc_sockaddr_t *b, memcmp(&a->type.sin6.sin6_addr, &b->type.sin6.sin6_addr, sizeof(a->type.sin6.sin6_addr)) != 0) return (ISC_FALSE); -#ifdef ISC_PLATFORM_HAVESCOPEID /* * If ISC_SOCKADDR_CMPSCOPEZERO is set then don't return * ISC_FALSE if one of the scopes in zero. @@ -87,7 +86,6 @@ isc_sockaddr_compare(const isc_sockaddr_t *a, const isc_sockaddr_t *b, (a->type.sin6.sin6_scope_id != 0 && b->type.sin6.sin6_scope_id != 0))) return (ISC_FALSE); -#endif if ((flags & ISC_SOCKADDR_CMPPORT) != 0 && a->type.sin6.sin6_port != b->type.sin6.sin6_port) return (ISC_FALSE); @@ -249,9 +247,7 @@ isc_sockaddr_any(isc_sockaddr_t *sockaddr) { memset(sockaddr, 0, sizeof(*sockaddr)); sockaddr->type.sin.sin_family = AF_INET; -#ifdef ISC_PLATFORM_HAVESALEN sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin); -#endif sockaddr->type.sin.sin_addr.s_addr = INADDR_ANY; sockaddr->type.sin.sin_port = 0; sockaddr->length = sizeof(sockaddr->type.sin); @@ -263,9 +259,7 @@ isc_sockaddr_any6(isc_sockaddr_t *sockaddr) { memset(sockaddr, 0, sizeof(*sockaddr)); sockaddr->type.sin6.sin6_family = AF_INET6; -#ifdef ISC_PLATFORM_HAVESALEN sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6); -#endif sockaddr->type.sin6.sin6_addr = in6addr_any; sockaddr->type.sin6.sin6_port = 0; sockaddr->length = sizeof(sockaddr->type.sin6); @@ -278,9 +272,7 @@ isc_sockaddr_fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina, { memset(sockaddr, 0, sizeof(*sockaddr)); sockaddr->type.sin.sin_family = AF_INET; -#ifdef ISC_PLATFORM_HAVESALEN sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin); -#endif sockaddr->type.sin.sin_addr = *ina; sockaddr->type.sin.sin_port = htons(port); sockaddr->length = sizeof(sockaddr->type.sin); @@ -307,9 +299,7 @@ isc_sockaddr_fromin6(isc_sockaddr_t *sockaddr, const struct in6_addr *ina6, { memset(sockaddr, 0, sizeof(*sockaddr)); sockaddr->type.sin6.sin6_family = AF_INET6; -#ifdef ISC_PLATFORM_HAVESALEN sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6); -#endif sockaddr->type.sin6.sin6_addr = *ina6; sockaddr->type.sin6.sin6_port = htons(port); sockaddr->length = sizeof(sockaddr->type.sin6); @@ -322,9 +312,7 @@ isc_sockaddr_v6fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina, { memset(sockaddr, 0, sizeof(*sockaddr)); sockaddr->type.sin6.sin6_family = AF_INET6; -#ifdef ISC_PLATFORM_HAVESALEN sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6); -#endif sockaddr->type.sin6.sin6_addr.s6_addr[10] = 0xff; sockaddr->type.sin6.sin6_addr.s6_addr[11] = 0xff; memmove(&sockaddr->type.sin6.sin6_addr.s6_addr[12], ina, 4); @@ -370,21 +358,15 @@ isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na, switch (na->family) { case AF_INET: sockaddr->length = sizeof(sockaddr->type.sin); -#ifdef ISC_PLATFORM_HAVESALEN sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin); -#endif sockaddr->type.sin.sin_addr = na->type.in; sockaddr->type.sin.sin_port = htons(port); break; case AF_INET6: sockaddr->length = sizeof(sockaddr->type.sin6); -#ifdef ISC_PLATFORM_HAVESALEN sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6); -#endif memmove(&sockaddr->type.sin6.sin6_addr, &na->type.in6, 16); -#ifdef ISC_PLATFORM_HAVESCOPEID sockaddr->type.sin6.sin6_scope_id = isc_netaddr_getzone(na); -#endif sockaddr->type.sin6.sin6_port = htons(port); break; default: @@ -497,10 +479,8 @@ isc_sockaddr_frompath(isc_sockaddr_t *sockaddr, const char *path) { memset(sockaddr, 0, sizeof(*sockaddr)); sockaddr->length = sizeof(sockaddr->type.sunix); sockaddr->type.sunix.sun_family = AF_UNIX; -#ifdef ISC_PLATFORM_HAVESALEN sockaddr->type.sunix.sun_len = (unsigned char)sizeof(sockaddr->type.sunix); -#endif strlcpy(sockaddr->type.sunix.sun_path, path, sizeof(sockaddr->type.sunix.sun_path)); return (ISC_R_SUCCESS); diff --git a/usr.sbin/bind/lib/isc/unix/entropy.c b/usr.sbin/bind/lib/isc/unix/entropy.c index 95466a86cec..8788c7c3db3 100644 --- a/usr.sbin/bind/lib/isc/unix/entropy.c +++ b/usr.sbin/bind/lib/isc/unix/entropy.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: entropy.c,v 1.8 2019/12/17 01:46:37 sthen Exp $ */ +/* $Id: entropy.c,v 1.9 2020/01/09 13:45:33 florian Exp $ */ /* \file unix/entropy.c * \brief @@ -541,13 +541,11 @@ isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname) { memset(&sname, 0, sizeof(sname)); sname.sun_family = AF_UNIX; strlcpy(sname.sun_path, fname, sizeof(sname.sun_path)); -#ifdef ISC_PLATFORM_HAVESALEN #if !defined(SUN_LEN) #define SUN_LEN(su) \ (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) #endif sname.sun_len = SUN_LEN(&sname); -#endif if (connect(fd, (struct sockaddr *) &sname, sizeof(struct sockaddr_un)) < 0) { diff --git a/usr.sbin/bind/lib/isc/unix/ifiter_ioctl.c b/usr.sbin/bind/lib/isc/unix/ifiter_ioctl.c index f0f8200e36b..078dbd4effe 100644 --- a/usr.sbin/bind/lib/isc/unix/ifiter_ioctl.c +++ b/usr.sbin/bind/lib/isc/unix/ifiter_ioctl.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ifiter_ioctl.c,v 1.10 2019/12/17 01:46:37 sthen Exp $ */ +/* $Id: ifiter_ioctl.c,v 1.11 2020/01/09 13:45:33 florian Exp $ */ #include <isc/print.h> @@ -25,28 +25,12 @@ */ #if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR) -#ifdef ISC_PLATFORM_HAVEIF_LADDRCONF -#define lifc_len iflc_len -#define lifc_buf iflc_buf -#define lifc_req iflc_req -#define LIFCONF if_laddrconf -#else #define ISC_HAVE_LIFC_FAMILY 1 #define ISC_HAVE_LIFC_FLAGS 1 #define LIFCONF lifconf -#endif -#ifdef ISC_PLATFORM_HAVEIF_LADDRREQ -#define lifr_addr iflr_addr -#define lifr_name iflr_name -#define lifr_dstaddr iflr_dstaddr -#define lifr_flags iflr_flags -#define ss_family sa_family -#define LIFREQ if_laddrreq -#else #define LIFREQ lifreq #endif -#endif #define IFITER_MAGIC ISC_MAGIC('I', 'F', 'I', 'T') #define VALID_IFITER(t) ISC_MAGIC_VALID(t, IFITER_MAGIC) @@ -433,11 +417,7 @@ internal_current4(isc_interfaceiter_t *iter) { struct ifreq ifreq; int family; char strbuf[ISC_STRERRORSIZE]; -#if !defined(ISC_PLATFORM_HAVEIF_LADDRREQ) && defined(SIOCGLIFADDR) - struct lifreq lifreq; -#else char sabuf[256]; -#endif int i, bits, prefixlen; REQUIRE(VALID_IFITER(iter)); @@ -459,11 +439,7 @@ internal_current4(isc_interfaceiter_t *iter) { memmove(&ifreq, ifrp, sizeof(ifreq)); family = ifreq.ifr_addr.sa_family; -#if defined(ISC_PLATFORM_HAVEIPV6) if (family != AF_INET && family != AF_INET6) -#else - if (family != AF_INET) -#endif return (ISC_R_IGNORE); memset(&iter->current, 0, sizeof(iter->current)); @@ -524,21 +500,6 @@ internal_current4(isc_interfaceiter_t *iter) { if (family == AF_INET) goto inet; -#if !defined(ISC_PLATFORM_HAVEIF_LADDRREQ) && defined(SIOCGLIFADDR) - memset(&lifreq, 0, sizeof(lifreq)); - memmove(lifreq.lifr_name, iter->current.name, sizeof(lifreq.lifr_name)); - memmove(&lifreq.lifr_addr, &iter->current.address.type.in6, - sizeof(iter->current.address.type.in6)); - - if (ioctl(iter->socket, SIOCGLIFADDR, &lifreq) < 0) { - isc__strerror(errno, strbuf, sizeof(strbuf)); - UNEXPECTED_ERROR(__FILE__, __LINE__, - "%s: getting interface address: %s", - ifreq.ifr_name, strbuf); - return (ISC_R_IGNORE); - } - prefixlen = lifreq.lifr_addrlen; -#else isc_netaddr_format(&iter->current.address, sabuf, sizeof(sabuf)); isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_INTERFACE, @@ -549,7 +510,6 @@ internal_current4(isc_interfaceiter_t *iter) { "prefix length for %s is unknown " "(assume 128)"), sabuf); prefixlen = 128; -#endif /* * Netmask already zeroed. @@ -643,11 +603,7 @@ internal_current6(isc_interfaceiter_t *iter) { memmove(&lifreq, ifrp, sizeof(lifreq)); family = lifreq.lifr_addr.ss_family; -#ifdef ISC_PLATFORM_HAVEIPV6 if (family != AF_INET && family != AF_INET6) -#else - if (family != AF_INET) -#endif return (ISC_R_IGNORE); memset(&iter->current, 0, sizeof(iter->current)); @@ -812,19 +768,15 @@ internal_current(isc_interfaceiter_t *iter) { */ static isc_result_t internal_next4(isc_interfaceiter_t *iter) { -#ifdef ISC_PLATFORM_HAVESALEN struct ifreq *ifrp; -#endif if (iter->pos < (unsigned int) iter->ifc.ifc_len) { -#ifdef ISC_PLATFORM_HAVESALEN ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos); if (ifrp->ifr_addr.sa_len > sizeof(struct sockaddr)) iter->pos += sizeof(ifrp->ifr_name) + ifrp->ifr_addr.sa_len; else -#endif iter->pos += sizeof(struct ifreq); } else { @@ -841,22 +793,18 @@ internal_next4(isc_interfaceiter_t *iter) { #if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR) static isc_result_t internal_next6(isc_interfaceiter_t *iter) { -#ifdef ISC_PLATFORM_HAVESALEN struct LIFREQ *ifrp; -#endif if (iter->result6 != ISC_R_SUCCESS && iter->result6 != ISC_R_IGNORE) return (iter->result6); REQUIRE(iter->pos6 < (unsigned int) iter->lifc.lifc_len); -#ifdef ISC_PLATFORM_HAVESALEN ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos6); if (ifrp->lifr_addr.sa_len > sizeof(struct sockaddr)) iter->pos6 += sizeof(ifrp->lifr_name) + ifrp->lifr_addr.sa_len; else -#endif iter->pos6 += sizeof(struct LIFREQ); if (iter->pos6 >= (unsigned int) iter->lifc.lifc_len) diff --git a/usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c b/usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c index 339745421c3..5e55630e5f1 100644 --- a/usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c +++ b/usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ifiter_sysctl.c,v 1.3 2019/12/17 01:46:37 sthen Exp $ */ +/* $Id: ifiter_sysctl.c,v 1.4 2020/01/09 13:45:33 florian Exp $ */ /*! \file * \brief @@ -218,22 +218,8 @@ internal_current(isc_interfaceiter_t *iter) { dst_sa = sa; break; } -#ifdef ISC_PLATFORM_HAVESALEN sa = (struct sockaddr *)((char*)(sa) + ROUNDUP(sa->sa_len)); -#else -#ifdef sgi - /* - * Do as the contributed SGI code does. - */ - sa = (struct sockaddr *)((char*)(sa) - + ROUNDUP(_FAKE_SA_LEN_DST(sa))); -#else - /* XXX untested. */ - sa = (struct sockaddr *)((char*)(sa) - + ROUNDUP(sizeof(struct sockaddr))); -#endif -#endif } if (addr_sa == NULL) diff --git a/usr.sbin/bind/lib/isc/unix/include/isc/net.h b/usr.sbin/bind/lib/isc/unix/include/isc/net.h index 3d5ee894f8b..5c804d10956 100644 --- a/usr.sbin/bind/lib/isc/unix/include/isc/net.h +++ b/usr.sbin/bind/lib/isc/unix/include/isc/net.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: net.h,v 1.3 2019/12/17 01:46:37 sthen Exp $ */ +/* $Id: net.h,v 1.4 2020/01/09 13:45:34 florian Exp $ */ #ifndef ISC_NET_H #define ISC_NET_H 1 @@ -80,25 +80,10 @@ #include <netinet/in.h> /* Contractual promise. */ #include <arpa/inet.h> /* Contractual promise. */ -#ifdef ISC_PLATFORM_NEEDNETINETIN6H -#include <netinet/in6.h> /* Required on UnixWare. */ -#endif -#ifdef ISC_PLATFORM_NEEDNETINET6IN6H -#include <netinet6/in6.h> /* Required on BSD/OS for in6_pktinfo. */ -#endif - -#ifndef ISC_PLATFORM_HAVEIPV6 -#include <isc/ipv6.h> /* Contractual promise. */ -#endif #include <isc/lang.h> #include <isc/types.h> -#ifdef ISC_PLATFORM_HAVEINADDR6 -#define in6_addr in_addr6 /*%< Required for pre RFC2133 implementations. */ -#endif - -#ifdef ISC_PLATFORM_HAVEIPV6 #ifndef IN6ADDR_ANY_INIT #ifdef s6_addr /*% @@ -171,7 +156,6 @@ #define IN6_IS_ADDR_LOOPBACK(x) \ (memcmp((x)->s6_addr, in6addr_loopback.s6_addr, 16) == 0) #endif -#endif #ifndef AF_INET6 /*% IPv6 */ @@ -193,81 +177,6 @@ #define INADDR_LOOPBACK 0x7f000001UL #endif -#ifndef ISC_PLATFORM_HAVEIN6PKTINFO -/*% IPv6 packet info */ -struct in6_pktinfo { - struct in6_addr ipi6_addr; /*%< src/dst IPv6 address */ - unsigned int ipi6_ifindex; /*%< send/recv interface index */ -}; -#endif - - -#ifndef ISC_PLATFORM_HAVESOCKADDRSTORAGE -#define _SS_MAXSIZE 128 -#define _SS_ALIGNSIZE (sizeof (isc_uint64_t)) -#ifdef ISC_PLATFORM_HAVESALEN -#define _SS_PAD1SIZE (_SS_ALIGNSIZE - (2 * sizeof(isc_uint8_t))) -#define _SS_PAD2SIZE (_SS_MAXSIZE - (_SS_ALIGNSIZE + _SS_PAD1SIZE \ - + 2 * sizeof(isc_uint8_t))) -#else -#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(isc_uint16_t)) -#define _SS_PAD2SIZE (_SS_MAXSIZE - (_SS_ALIGNSIZE + _SS_PAD1SIZE \ - + sizeof(isc_uint16_t))) -#endif - -struct sockaddr_storage { -#ifdef ISC_PLATFORM_HAVESALEN - isc_uint8_t ss_len; - isc_uint8_t ss_family; -#else - isc_uint16_t ss_family; -#endif - char __ss_pad1[_SS_PAD1SIZE]; - isc_uint64_t __ss_align; /* field to force desired structure */ - char __ss_pad2[_SS_PAD2SIZE]; -}; -#endif - -#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY) -extern const struct in6_addr isc_net_in6addrany; -/*% - * Cope with a missing in6addr_any and in6addr_loopback. - */ -#define in6addr_any isc_net_in6addrany -#endif - -#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK) -extern const struct in6_addr isc_net_in6addrloop; -#define in6addr_loopback isc_net_in6addrloop -#endif - -#ifdef ISC_PLATFORM_FIXIN6ISADDR -#undef IN6_IS_ADDR_GEOGRAPHIC -/*! - * \brief - * Fix UnixWare 7.1.1's broken IN6_IS_ADDR_* definitions. - */ -#define IN6_IS_ADDR_GEOGRAPHIC(a) (((a)->S6_un.S6_l[0] & 0xE0) == 0x80) -#undef IN6_IS_ADDR_IPX -#define IN6_IS_ADDR_IPX(a) (((a)->S6_un.S6_l[0] & 0xFE) == 0x04) -#undef IN6_IS_ADDR_LINKLOCAL -#define IN6_IS_ADDR_LINKLOCAL(a) (((a)->S6_un.S6_l[0] & 0xC0FF) == 0x80FE) -#undef IN6_IS_ADDR_MULTICAST -#define IN6_IS_ADDR_MULTICAST(a) (((a)->S6_un.S6_l[0] & 0xFF) == 0xFF) -#undef IN6_IS_ADDR_NSAP -#define IN6_IS_ADDR_NSAP(a) (((a)->S6_un.S6_l[0] & 0xFE) == 0x02) -#undef IN6_IS_ADDR_PROVIDER -#define IN6_IS_ADDR_PROVIDER(a) (((a)->S6_un.S6_l[0] & 0xE0) == 0x40) -#undef IN6_IS_ADDR_SITELOCAL -#define IN6_IS_ADDR_SITELOCAL(a) (((a)->S6_un.S6_l[0] & 0xC0FF) == 0xC0FE) -#endif /* ISC_PLATFORM_FIXIN6ISADDR */ - -#ifdef ISC_PLATFORM_NEEDPORTT -/*% - * Ensure type in_port_t is defined. - */ -typedef isc_uint16_t in_port_t; -#endif #ifndef MSG_TRUNC /*% @@ -397,20 +306,6 @@ isc_net_getudpportrange(int af, in_port_t *low, in_port_t *high); * the range. */ -#ifdef ISC_PLATFORM_NEEDNTOP -const char * -isc_net_ntop(int af, const void *src, char *dst, size_t size); -#undef inet_ntop -#define inet_ntop isc_net_ntop -#endif - -#ifdef ISC_PLATFORM_NEEDPTON -int -isc_net_pton(int af, const char *src, void *dst); -#undef inet_pton -#define inet_pton isc_net_pton -#endif - int isc_net_aton(const char *cp, struct in_addr *addr); #undef inet_aton diff --git a/usr.sbin/bind/lib/isc/unix/interfaceiter.c b/usr.sbin/bind/lib/isc/unix/interfaceiter.c index acb88b6aa96..7f01777f8c1 100644 --- a/usr.sbin/bind/lib/isc/unix/interfaceiter.c +++ b/usr.sbin/bind/lib/isc/unix/interfaceiter.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: interfaceiter.c,v 1.3 2019/12/17 01:46:37 sthen Exp $ */ +/* $Id: interfaceiter.c,v 1.4 2020/01/09 13:45:33 florian Exp $ */ /*! \file */ @@ -67,11 +67,6 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src, { struct sockaddr_in6 *sa6; -#if !defined(ISC_PLATFORM_HAVEIFNAMETOINDEX) || \ - !defined(ISC_PLATFORM_HAVESCOPEID) - UNUSED(ifname); -#endif - /* clear any remaining value for safety */ memset(dst, 0, sizeof(*dst)); @@ -86,7 +81,6 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src, sa6 = (struct sockaddr_in6 *)src; memmove(&dst->type.in6, &sa6->sin6_addr, sizeof(struct in6_addr)); -#ifdef ISC_PLATFORM_HAVESCOPEID if (sa6->sin6_scope_id != 0) isc_netaddr_setzone(dst, sa6->sin6_scope_id); else { @@ -113,7 +107,6 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src, (isc_uint32_t)zone16); dst->type.in6.s6_addr[2] = 0; dst->type.in6.s6_addr[3] = 0; -#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX } else if (ifname != NULL) { unsigned int zone; @@ -128,11 +121,9 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src, isc_netaddr_setzone(dst, (isc_uint32_t)zone); } -#endif } } } -#endif break; default: INSIST(0); diff --git a/usr.sbin/bind/lib/isc/unix/net.c b/usr.sbin/bind/lib/isc/unix/net.c index d88dbd65616..9988989e3dd 100644 --- a/usr.sbin/bind/lib/isc/unix/net.c +++ b/usr.sbin/bind/lib/isc/unix/net.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: net.c,v 1.9 2019/12/19 03:57:28 deraadt Exp $ */ +/* $Id: net.c,v 1.10 2020/01/09 13:45:33 florian Exp $ */ #include <config.h> @@ -98,23 +98,11 @@ #endif /* HAVE_SYSCTLBYNAME */ -#if defined(ISC_PLATFORM_HAVEIPV6) -# if defined(ISC_PLATFORM_NEEDIN6ADDRANY) -const struct in6_addr isc_net_in6addrany = IN6ADDR_ANY_INIT; -# endif - -# if defined(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK) -const struct in6_addr isc_net_in6addrloop = IN6ADDR_LOOPBACK_INIT; -# endif - # if defined(WANT_IPV6) static isc_once_t once_ipv6only = ISC_ONCE_INIT; -# if defined(ISC_PLATFORM_HAVEIN6PKTINFO) static isc_once_t once_ipv6pktinfo = ISC_ONCE_INIT; -# endif # endif /* WANT_IPV6 */ -#endif /* ISC_PLATFORM_HAVEIPV6 */ #ifndef ISC_CMSG_IP_TOS #ifdef __APPLE__ @@ -170,9 +158,7 @@ try_proto(int domain) { } } -#ifdef ISC_PLATFORM_HAVEIPV6 #ifdef WANT_IPV6 -#ifdef ISC_PLATFORM_HAVEIN6PKTINFO if (domain == PF_INET6) { struct sockaddr_in6 sin6; unsigned int len; @@ -211,8 +197,6 @@ try_proto(int domain) { } } #endif -#endif -#endif (void)close(s); @@ -222,13 +206,9 @@ try_proto(int domain) { static void initialize_action(void) { ipv4_result = try_proto(PF_INET); -#ifdef ISC_PLATFORM_HAVEIPV6 #ifdef WANT_IPV6 -#ifdef ISC_PLATFORM_HAVEIN6PKTINFO ipv6_result = try_proto(PF_INET6); #endif -#endif -#endif } static void @@ -254,7 +234,6 @@ isc_net_probeunix(void) { return (unix_result); } -#ifdef ISC_PLATFORM_HAVEIPV6 #ifdef WANT_IPV6 static void try_ipv6only(void) { @@ -333,7 +312,6 @@ initialize_ipv6only(void) { } #endif /* WANT_IPV6 */ -#ifdef ISC_PLATFORM_HAVEIN6PKTINFO #ifdef WANT_IPV6 static void try_ipv6pktinfo(void) { @@ -387,32 +365,24 @@ initialize_ipv6pktinfo(void) { try_ipv6pktinfo) == ISC_R_SUCCESS); } #endif /* WANT_IPV6 */ -#endif /* ISC_PLATFORM_HAVEIN6PKTINFO */ -#endif /* ISC_PLATFORM_HAVEIPV6 */ isc_result_t isc_net_probe_ipv6only(void) { -#ifdef ISC_PLATFORM_HAVEIPV6 #ifdef WANT_IPV6 initialize_ipv6only(); #else ipv6only_result = ISC_R_NOTFOUND; #endif -#endif return (ipv6only_result); } isc_result_t isc_net_probe_ipv6pktinfo(void) { -#ifdef ISC_PLATFORM_HAVEIPV6 -#ifdef ISC_PLATFORM_HAVEIN6PKTINFO #ifdef WANT_IPV6 initialize_ipv6pktinfo(); #else ipv6pktinfo_result = ISC_R_NOTFOUND; #endif -#endif -#endif return (ipv6pktinfo_result); } diff --git a/usr.sbin/bind/lib/isc/unix/socket.c b/usr.sbin/bind/lib/isc/unix/socket.c index da07dc699e4..5ad9c0e1a01 100644 --- a/usr.sbin/bind/lib/isc/unix/socket.c +++ b/usr.sbin/bind/lib/isc/unix/socket.c @@ -68,19 +68,7 @@ #ifdef ISC_PLATFORM_HAVESYSUNH #include <sys/un.h> #endif -#ifdef ISC_PLATFORM_HAVEKQUEUE #include <sys/event.h> -#endif -#ifdef ISC_PLATFORM_HAVEEPOLL -#include <sys/epoll.h> -#endif -#ifdef ISC_PLATFORM_HAVEDEVPOLL -#if defined(HAVE_SYS_DEVPOLL_H) -#include <sys/devpoll.h> -#elif defined(HAVE_DEVPOLL_H) -#include <devpoll.h> -#endif -#endif #include <netinet/tcp.h> @@ -101,19 +89,7 @@ /*% * Choose the most preferable multiplex method. */ -#ifdef ISC_PLATFORM_HAVEKQUEUE #define USE_KQUEUE -#elif defined (ISC_PLATFORM_HAVEEPOLL) -#define USE_EPOLL -#elif defined (ISC_PLATFORM_HAVEDEVPOLL) -#define USE_DEVPOLL -typedef struct { - unsigned int want_read : 1, - want_write : 1; -} pollinfo_t; -#else -#define USE_SELECT -#endif /* ISC_PLATFORM_HAVEKQUEUE */ #ifndef USE_WATCHER_THREAD #if defined(USE_KQUEUE) || defined(USE_EPOLL) || defined(USE_DEVPOLL) @@ -279,22 +255,12 @@ typedef isc_event_t intev_t; * to collect the destination address and interface so the client can * set them on outgoing packets. */ -#ifdef ISC_PLATFORM_HAVEIN6PKTINFO -#ifndef USE_CMSG -#define USE_CMSG 1 -#endif -#endif /*% * NetBSD and FreeBSD can timestamp packets. XXXMLG Should we have * a setsockopt() like interface to request timestamps, and if the OS * doesn't do it for us, call gettimeofday() on every UDP receive? */ -#ifdef SO_TIMESTAMP -#ifndef USE_CMSG -#define USE_CMSG 1 -#endif -#endif /*% * The size to raise the receive buffer to (from BIND 8). @@ -315,23 +281,11 @@ typedef isc_event_t intev_t; * multiplied by 2, everything should fit. Those sizes are not * large enough to cause any concern. */ -#if defined(USE_CMSG) && defined(ISC_PLATFORM_HAVEIN6PKTINFO) #define CMSG_SP_IN6PKT 40 -#else -#define CMSG_SP_IN6PKT 0 -#endif -#if defined(USE_CMSG) && defined(SO_TIMESTAMP) #define CMSG_SP_TIMESTAMP 32 -#else -#define CMSG_SP_TIMESTAMP 0 -#endif -#if defined(USE_CMSG) && (defined(IPV6_TCLASS) || defined(IP_TOS)) #define CMSG_SP_TCTOS 24 -#else -#define CMSG_SP_TCTOS 0 -#endif #define CMSG_SP_INT 24 @@ -1233,7 +1187,6 @@ make_nonblock(int fd) { return (ISC_R_SUCCESS); } -#ifdef USE_CMSG /* * Not all OSes support advanced CMSG macros: CMSG_LEN and CMSG_SPACE. * In order to ensure as much portability as possible, we provide wrapper @@ -1284,24 +1237,15 @@ cmsg_space(ISC_SOCKADDR_LEN_T len) { return (0); #endif } -#endif /* USE_CMSG */ /* * Process control messages received on a socket. */ static void process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { -#ifdef ISC_NET_BSD44MSGHDR -#ifdef USE_CMSG struct cmsghdr *cmsgp; -#ifdef ISC_PLATFORM_HAVEIN6PKTINFO struct in6_pktinfo *pktinfop; -#endif -#ifdef SO_TIMESTAMP void *timevalp; -#endif -#endif -#endif /* * sock is used only when ISC_NET_BSD44MSGHDR and USE_CMSG are defined. @@ -1313,8 +1257,6 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { UNUSED(msg); UNUSED(dev); -#ifdef ISC_NET_BSD44MSGHDR - #ifdef MSG_TRUNC if ((msg->msg_flags & MSG_TRUNC) == MSG_TRUNC) dev->attributes |= ISC_SOCKEVENTATTR_TRUNC; @@ -1325,18 +1267,11 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { dev->attributes |= ISC_SOCKEVENTATTR_CTRUNC; #endif -#ifndef USE_CMSG - return; -#else if (msg->msg_controllen == 0U || msg->msg_control == NULL) return; -#ifdef SO_TIMESTAMP timevalp = NULL; -#endif -#ifdef ISC_PLATFORM_HAVEIN6PKTINFO pktinfop = NULL; -#endif cmsgp = CMSG_FIRSTHDR(msg); while (cmsgp != NULL) { @@ -1344,7 +1279,6 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_PROCESSCMSG, "processing cmsg %p", cmsgp); -#ifdef ISC_PLATFORM_HAVEIN6PKTINFO if (cmsgp->cmsg_level == IPPROTO_IPV6 && cmsgp->cmsg_type == IPV6_PKTINFO) { @@ -1361,9 +1295,7 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { dev->attributes |= ISC_SOCKEVENTATTR_MULTICAST; goto next; } -#endif -#ifdef SO_TIMESTAMP if (cmsgp->cmsg_level == SOL_SOCKET && cmsgp->cmsg_type == SCM_TIMESTAMP) { struct timeval tv; @@ -1374,9 +1306,7 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { dev->attributes |= ISC_SOCKEVENTATTR_TIMESTAMP; goto next; } -#endif -#ifdef IPV6_TCLASS if (cmsgp->cmsg_level == IPPROTO_IPV6 && cmsgp->cmsg_type == IPV6_TCLASS) { dev->dscp = *(int *)CMSG_DATA(cmsgp); @@ -1384,9 +1314,7 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { dev->attributes |= ISC_SOCKEVENTATTR_DSCP; goto next; } -#endif -#ifdef IP_TOS if (cmsgp->cmsg_level == IPPROTO_IP && (cmsgp->cmsg_type == IP_TOS #ifdef IP_RECVTOS @@ -1398,13 +1326,10 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { dev->attributes |= ISC_SOCKEVENTATTR_DSCP; goto next; } -#endif next: cmsgp = CMSG_NXTHDR(msg, cmsgp); } -#endif /* USE_CMSG */ -#endif /* ISC_NET_BSD44MSGHDR */ } /* @@ -1428,9 +1353,7 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev, isc_region_t used; size_t write_count; size_t skip_count; -#ifdef ISC_NET_BSD44MSGHDR struct cmsghdr *cmsgp; -#endif memset(msg, 0, sizeof(*msg)); @@ -1493,13 +1416,10 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev, msg->msg_iov = iov; msg->msg_iovlen = iovcount; -#ifdef ISC_NET_BSD44MSGHDR msg->msg_control = NULL; msg->msg_controllen = 0; msg->msg_flags = 0; -#if defined(USE_CMSG) -#if defined(ISC_PLATFORM_HAVEIN6PKTINFO) if ((sock->type == isc_sockettype_udp) && ((dev->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0)) { @@ -1521,7 +1441,6 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev, pktinfop = (struct in6_pktinfo *)CMSG_DATA(cmsgp); memmove(pktinfop, &dev->pktinfo, sizeof(struct in6_pktinfo)); } -#endif #if defined(IPV6_USE_MIN_MTU) if ((sock->type == isc_sockettype_udp) && @@ -1550,7 +1469,6 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev, INSIST((int)sock->dscp == isc_dscp_check_value); } -#if defined(IP_TOS) || (defined(IPPROTO_IPV6) && defined(IPV6_TCLASS)) if ((sock->type == isc_sockettype_udp) && ((dev->attributes & ISC_SOCKEVENTATTR_DSCP) != 0)) { @@ -1558,7 +1476,6 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev, INSIST(dev->dscp < 0x40); -#ifdef IP_TOS if (sock->pf == AF_INET && sock->pktdscp) { cmsgp = (struct cmsghdr *)(cmsgbuf + msg->msg_controllen); @@ -1588,7 +1505,6 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev, } else sock->dscp = dscp; } -#endif #if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS) if (sock->pf == AF_INET6 && sock->pktdscp) { cmsgp = (struct cmsghdr *)(cmsgbuf + @@ -1626,12 +1542,6 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev, SENDCMSGBUFLEN - msg->msg_controllen); } } -#endif -#endif /* USE_CMSG */ -#else /* ISC_NET_BSD44MSGHDR */ - msg->msg_accrights = NULL; - msg->msg_accrightslen = 0; -#endif /* ISC_NET_BSD44MSGHDR */ if (write_countp != NULL) *write_countp = write_count; @@ -1746,19 +1656,9 @@ build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev, msg->msg_iov = iov; msg->msg_iovlen = iovcount; -#ifdef ISC_NET_BSD44MSGHDR -#if defined(USE_CMSG) msg->msg_control = cmsgbuf; msg->msg_controllen = RECVCMSGBUFLEN; -#else - msg->msg_control = NULL; - msg->msg_controllen = 0; -#endif /* USE_CMSG */ msg->msg_flags = 0; -#else /* ISC_NET_BSD44MSGHDR */ - msg->msg_accrights = NULL; - msg->msg_accrightslen = 0; -#endif /* ISC_NET_BSD44MSGHDR */ if (read_countp != NULL) *read_countp = read_count; @@ -1830,10 +1730,8 @@ dump_msg(struct msghdr *msg) { printf("\t\t%u\tbase %p, len %ld\n", i, msg->msg_iov[i].iov_base, (long) msg->msg_iov[i].iov_len); -#ifdef ISC_NET_BSD44MSGHDR printf("\tcontrol %p, controllen %ld\n", msg->msg_control, (long) msg->msg_controllen); -#endif } #endif @@ -2379,7 +2277,6 @@ set_rcvbuf(void) { ISC_SOCKADDR_LEN_T len; fd = socket(AF_INET, SOCK_DGRAM | SOCK_DNS, IPPROTO_UDP); -#if defined(ISC_PLATFORM_HAVEIPV6) if (fd == -1) { switch (errno) { case EPROTONOSUPPORT: @@ -2394,7 +2291,6 @@ set_rcvbuf(void) { break; } } -#endif if (fd == -1) return; @@ -2504,9 +2400,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, char strbuf[ISC_STRERRORSIZE]; const char *err = "socket"; int tries = 0; -#if defined(USE_CMSG) || defined(SO_BSDCOMPAT) || defined(SO_NOSIGPIPE) int on = 1; -#endif #if defined(SO_RCVBUF) ISC_SOCKADDR_LEN_T optlen; int size; @@ -2706,11 +2600,8 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, set_tcp_maxseg(sock, 1280 - 20 - 40); /* 1280 - TCP - IPV6 */ } -#if defined(USE_CMSG) || defined(SO_RCVBUF) if (sock->type == isc_sockettype_udp) { -#if defined(USE_CMSG) -#if defined(SO_TIMESTAMP) if (setsockopt(sock->fd, SOL_SOCKET, SO_TIMESTAMP, (void *)&on, sizeof(on)) < 0 && errno != ENOPROTOOPT) { @@ -2725,10 +2616,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, strbuf); /* Press on... */ } -#endif /* SO_TIMESTAMP */ -#if defined(ISC_PLATFORM_HAVEIPV6) -#ifdef ISC_PLATFORM_HAVEIN6PKTINFO #ifdef IPV6_RECVPKTINFO /* RFC 3542 */ if ((sock->pf == AF_INET6) @@ -2760,7 +2648,6 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, strbuf); } #endif /* IPV6_RECVPKTINFO */ -#endif /* ISC_PLATFORM_HAVEIN6PKTINFO */ #if defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DONT) /* * Turn off Path MTU discovery on IPv6/UDP sockets. @@ -2772,8 +2659,6 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, sizeof(action)); } #endif -#endif /* ISC_PLATFORM_HAVEIPV6 */ -#endif /* defined(USE_CMSG) */ #if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT) /* @@ -2830,7 +2715,6 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, } #endif } -#endif /* defined(USE_CMSG) || defined(SO_RCVBUF) */ setup_done: inc_stats(manager->stats, sock->statsindex[STATID_OPEN]); @@ -6148,13 +6032,10 @@ isc__socket_ipv6only(isc_socket_t *sock0, isc_boolean_t yes) { static void setdscp(isc__socket_t *sock, isc_dscp_t dscp) { -#if defined(IP_TOS) || defined(IPV6_TCLASS) int value = dscp << 2; -#endif sock->dscp = dscp; -#ifdef IP_TOS if (sock->pf == AF_INET) { if (setsockopt(sock->fd, IPPROTO_IP, IP_TOS, (void *)&value, sizeof(value)) < 0) { @@ -6170,8 +6051,6 @@ setdscp(isc__socket_t *sock, isc_dscp_t dscp) { strbuf); } } -#endif -#ifdef IPV6_TCLASS if (sock->pf == AF_INET6) { if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_TCLASS, (void *)&value, sizeof(value)) < 0) { @@ -6187,7 +6066,6 @@ setdscp(isc__socket_t *sock, isc_dscp_t dscp) { strbuf); } } -#endif } void @@ -6197,16 +6075,12 @@ isc__socket_dscp(isc_socket_t *sock0, isc_dscp_t dscp) { REQUIRE(VALID_SOCKET(sock)); REQUIRE(dscp < 0x40); -#if !defined(IP_TOS) && !defined(IPV6_TCLASS) - UNUSED(dscp); -#else if (dscp < 0) return; /* The DSCP value must not be changed once it has been set. */ if (isc_dscp_check_value != -1) INSIST(dscp == isc_dscp_check_value); -#endif #ifdef notyet diff --git a/usr.sbin/bind/lib/isccfg/parser.c b/usr.sbin/bind/lib/isccfg/parser.c index 8e5128b1c14..ecf17cd6c42 100644 --- a/usr.sbin/bind/lib/isccfg/parser.c +++ b/usr.sbin/bind/lib/isccfg/parser.c @@ -2084,7 +2084,6 @@ token_addr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na) { if (inet_pton(AF_INET6, buf, &in6a) == 1) { if (d != NULL) { -#ifdef ISC_PLATFORM_HAVESCOPEID isc_result_t result; result = isc_netscope_pton(AF_INET6, @@ -2093,9 +2092,6 @@ token_addr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na) { &zone); if (result != ISC_R_SUCCESS) return (result); -#else - return (ISC_R_BADADDRESSFORM); -#endif } isc_netaddr_fromin6(na, &in6a); |