Remove support for legacy systems without inet_{ntop,pton} w/ IPv6 support
This commit is contained in:
69
configure.in
69
configure.in
@@ -1946,6 +1946,7 @@ AC_COMPILE_IFELSE(
|
||||
struct sockaddr_in6 sin6;
|
||||
struct in6_addr in6;
|
||||
struct in6_pktinfo in6_pi;
|
||||
struct sockaddr_storage storage;
|
||||
in6 = in6addr_any;
|
||||
in6 = in6addr_loopback;
|
||||
sin6.sin6_scope_id = 0;
|
||||
@@ -1954,19 +1955,6 @@ AC_COMPILE_IFELSE(
|
||||
[AC_MSG_RESULT([yes])],
|
||||
[AC_MSG_FAILURE([IPv6 support is mandatory])])
|
||||
|
||||
AC_MSG_CHECKING(for struct sockaddr_storage)
|
||||
AC_TRY_COMPILE([
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
],
|
||||
[struct sockaddr_storage storage; return (0);],
|
||||
[AC_MSG_RESULT(yes)
|
||||
ISC_PLATFORM_HAVESOCKADDRSTORAGE="#define ISC_PLATFORM_HAVESOCKADDRSTORAGE 1"],
|
||||
[AC_MSG_RESULT(no)
|
||||
ISC_PLATFORM_HAVESOCKADDRSTORAGE="#undef ISC_PLATFORM_HAVESOCKADDRSTORAGE"])
|
||||
|
||||
AC_SUBST(ISC_PLATFORM_HAVESOCKADDRSTORAGE)
|
||||
|
||||
AC_MSG_CHECKING([for struct if_laddrreq])
|
||||
AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
@@ -1989,61 +1977,6 @@ AC_TRY_LINK([
|
||||
ISC_PLATFORM_HAVEIF_LADDRCONF="#undef ISC_PLATFORM_HAVEIF_LADDRCONF"])
|
||||
AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRCONF)
|
||||
|
||||
#
|
||||
# Check for network functions that are often missing. We do this
|
||||
# after the libtool checking, so we can put the right suffix on
|
||||
# the files. It also needs to come after checking for a Kame add-on,
|
||||
# which provides some (all?) of the desired functions.
|
||||
#
|
||||
|
||||
AC_MSG_CHECKING([for inet_ntop with IPv6 support])
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
main() {
|
||||
char a[16],b[64]; return(inet_ntop(AF_INET6, a, b, sizeof(b)) == (char*)0);}],
|
||||
[AC_MSG_RESULT(yes)
|
||||
ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"],
|
||||
|
||||
[AC_MSG_RESULT(no)
|
||||
ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.$O"
|
||||
ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_ntop.c"
|
||||
ISC_PLATFORM_NEEDNTOP="#define ISC_PLATFORM_NEEDNTOP 1"],
|
||||
[AC_MSG_RESULT(assuming inet_ntop not needed)
|
||||
ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"])
|
||||
|
||||
|
||||
# On NetBSD 1.4.2 and maybe others, inet_pton() incorrectly accepts
|
||||
# addresses with less than four octets, like "1.2.3". Also leading
|
||||
# zeros should also be rejected.
|
||||
|
||||
AC_MSG_CHECKING([for working inet_pton with IPv6 support])
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
main() { char a[16]; return (inet_pton(AF_INET, "1.2.3", a) == 1 ? 1 :
|
||||
inet_pton(AF_INET, "1.2.3.04", a) == 1 ? 1 :
|
||||
(inet_pton(AF_INET6, "::1.2.3.4", a) != 1)); }],
|
||||
[AC_MSG_RESULT(yes)
|
||||
ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"],
|
||||
[AC_MSG_RESULT(no)
|
||||
ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
|
||||
ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_pton.c"
|
||||
ISC_PLATFORM_NEEDPTON="#define ISC_PLATFORM_NEEDPTON 1"],
|
||||
[AC_MSG_RESULT(assuming inet_pton needed)
|
||||
ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
|
||||
ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_pton.c"
|
||||
ISC_PLATFORM_NEEDPTON="#define ISC_PLATFORM_NEEDPTON 1"])
|
||||
|
||||
AC_SUBST(ISC_PLATFORM_NEEDNTOP)
|
||||
AC_SUBST(ISC_PLATFORM_NEEDPTON)
|
||||
AC_SUBST(ISC_EXTRA_OBJS)
|
||||
AC_SUBST(ISC_EXTRA_SRCS)
|
||||
|
||||
AC_MSG_CHECKING(for sa_len in struct sockaddr)
|
||||
AC_TRY_COMPILE([
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -44,7 +44,7 @@ WIN32OBJS = win32/condition.@O@ win32/dir.@O@ win32/errno.@O@ \
|
||||
win32/stdtime.@O@ win32/thread.@O@ win32/time.@O@
|
||||
|
||||
# Alphabetically
|
||||
OBJS = @ISC_EXTRA_OBJS@ pk11.@O@ pk11_result.@O@ \
|
||||
OBJS = pk11.@O@ pk11_result.@O@ \
|
||||
aes.@O@ assertions.@O@ backtrace.@O@ base32.@O@ base64.@O@ \
|
||||
bind9.@O@ buffer.@O@ bufferlist.@O@ \
|
||||
commandline.@O@ counter.@O@ crc64.@O@ error.@O@ entropy.@O@ \
|
||||
@@ -63,7 +63,7 @@ OBJS = @ISC_EXTRA_OBJS@ pk11.@O@ pk11_result.@O@ \
|
||||
SYMTBLOBJS = backtrace-emptytbl.@O@
|
||||
|
||||
# Alphabetically
|
||||
SRCS = @ISC_EXTRA_SRCS@ pk11.c pk11_result.c \
|
||||
SRCS = pk11.c pk11_result.c \
|
||||
aes.c assertions.c backtrace.c base32.c base64.c bind9.c \
|
||||
buffer.c bufferlist.c commandline.c counter.c crc64.c \
|
||||
entropy.c error.c event.c hash.c ht.c heap.c hex.c hmacmd5.c \
|
||||
|
||||
@@ -36,16 +36,6 @@
|
||||
*/
|
||||
@ISC_PLATFORM_HAVESALEN@
|
||||
|
||||
/*! \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.
|
||||
*/
|
||||
@@ -78,11 +68,6 @@
|
||||
*/
|
||||
@ISC_PLATFORM_HAVEIFNAMETOINDEX@
|
||||
|
||||
/*! \brief
|
||||
* Define if the system has struct sockaddr_storage.
|
||||
*/
|
||||
@ISC_PLATFORM_HAVESOCKADDRSTORAGE@
|
||||
|
||||
/*! \brief
|
||||
* Define if the system has TCP_FASTOPEN socket option.
|
||||
*/
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.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 */
|
||||
@@ -1,204 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
|
||||
#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);
|
||||
}
|
||||
@@ -11,7 +11,6 @@ tp: file_test
|
||||
tp: hash_test
|
||||
tp: heap_test
|
||||
tp: ht_test
|
||||
tp: inet_ntop_test
|
||||
tp: lex_test
|
||||
tp: mem_test
|
||||
tp: netaddr_test
|
||||
|
||||
@@ -10,7 +10,6 @@ atf_test_program{name='file_test'}
|
||||
atf_test_program{name='hash_test'}
|
||||
atf_test_program{name='heap_test'}
|
||||
atf_test_program{name='ht_test'}
|
||||
atf_test_program{name='inet_ntop_test'}
|
||||
atf_test_program{name='lex_test'}
|
||||
atf_test_program{name='mem_test'}
|
||||
atf_test_program{name='netaddr_test'}
|
||||
|
||||
@@ -33,7 +33,7 @@ CMOCKA_LIBS = @CMOCKA_LIBS@
|
||||
OBJS = isctest.@O@
|
||||
SRCS = isctest.c aes_test.c atomic_test.c buffer_test.c \
|
||||
counter_test.c errno_test.c file_test.c hash_test.c \
|
||||
heap_test.c ht_test.c inet_ntop_test.c lex_test.c \
|
||||
heap_test.c ht_test.c lex_test.c \
|
||||
mem_test.c netaddr_test.c parse_test.c pool_test.c \
|
||||
queue_test.c radix_test.c random_test.c \
|
||||
regex_test.c result_test.c safe_test.c sockaddr_test.c \
|
||||
@@ -44,7 +44,7 @@ SUBDIRS =
|
||||
TARGETS = aes_test@EXEEXT@ atomic_test@EXEEXT@ buffer_test@EXEEXT@ \
|
||||
counter_test@EXEEXT@ errno_test@EXEEXT@ file_test@EXEEXT@ \
|
||||
hash_test@EXEEXT@ heap_test@EXEEXT@ ht_test@EXEEXT@ \
|
||||
inet_ntop_test@EXEEXT@ lex_test@EXEEXT@ mem_test@EXEEXT@ \
|
||||
lex_test@EXEEXT@ mem_test@EXEEXT@ \
|
||||
netaddr_test@EXEEXT@ parse_test@EXEEXT@ pool_test@EXEEXT@ \
|
||||
queue_test@EXEEXT@ radix_test@EXEEXT@ \
|
||||
random_test@EXEEXT@ regex_test@EXEEXT@ result_test@EXEEXT@ \
|
||||
@@ -90,11 +90,6 @@ ht_test@EXEEXT@: ht_test.@O@ ${ISCDEPLIBS}
|
||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||
ht_test.@O@ ${ISCLIBS} ${LIBS}
|
||||
|
||||
inet_ntop_test.c.@O@: ${top_srcdir}/lib/isc/ntop_test.c
|
||||
inet_ntop_test@EXEEXT@: inet_ntop_test.@O@ ${ISCDEPLIBS}
|
||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||
inet_ntop_test.@O@ ${ISCLIBS} ${LIBS}
|
||||
|
||||
lex_test@EXEEXT@: lex_test.@O@ ${ISCDEPLIBS}
|
||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||
lex_test.@O@ ${ISCLIBS} ${LIBS}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
/*
|
||||
* Force the prototype for isc_net_ntop to be declared.
|
||||
*/
|
||||
#include <isc/platform.h>
|
||||
#undef ISC_PLATFORM_NEEDNTOP
|
||||
#define ISC_PLATFORM_NEEDNTOP
|
||||
#include "../inet_ntop.c"
|
||||
|
||||
ATF_TC(isc_net_ntop);
|
||||
ATF_TC_HEAD(isc_net_ntop, tc) {
|
||||
atf_tc_set_md_var(tc, "descr", "isc_net_ntop implementation");
|
||||
}
|
||||
ATF_TC_BODY(isc_net_ntop, tc) {
|
||||
char buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
|
||||
int r;
|
||||
size_t i;
|
||||
unsigned char abuf[16];
|
||||
struct {
|
||||
int family;
|
||||
const char * address;
|
||||
} testdata[] = {
|
||||
{ AF_INET, "0.0.0.0" },
|
||||
{ AF_INET, "0.1.0.0" },
|
||||
{ AF_INET, "0.0.2.0" },
|
||||
{ AF_INET, "0.0.0.3" },
|
||||
{ AF_INET, "255.255.255.255" },
|
||||
{ AF_INET6, "::" },
|
||||
{ AF_INET6, "::1.2.3.4" },
|
||||
{ AF_INET6, "::ffff:1.2.3.4" },
|
||||
{ AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" }
|
||||
};
|
||||
|
||||
for (i = 0; i < sizeof(testdata)/sizeof(testdata[0]); i++) {
|
||||
r = inet_pton(testdata[i].family, testdata[i].address, abuf);
|
||||
ATF_REQUIRE_EQ_MSG(r, 1, "%s", testdata[i].address);
|
||||
isc_net_ntop(testdata[i].family, abuf, buf, sizeof(buf));
|
||||
ATF_CHECK_STREQ(buf, testdata[i].address);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
ATF_TP_ADD_TCS(tp) {
|
||||
ATF_TP_ADD_TC(tp, isc_net_ntop);
|
||||
return (atf_no_error());
|
||||
}
|
||||
@@ -158,32 +158,6 @@
|
||||
#define INADDR_LOOPBACK 0x7f000001UL
|
||||
#endif
|
||||
|
||||
#ifndef ISC_PLATFORM_HAVESOCKADDRSTORAGE
|
||||
#define _SS_MAXSIZE 128
|
||||
#define _SS_ALIGNSIZE (sizeof (uint64_t))
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - (2 * sizeof(uint8_t)))
|
||||
#define _SS_PAD2SIZE (_SS_MAXSIZE - (_SS_ALIGNSIZE + _SS_PAD1SIZE \
|
||||
+ 2 * sizeof(uint8_t)))
|
||||
#else
|
||||
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(uint16_t))
|
||||
#define _SS_PAD2SIZE (_SS_MAXSIZE - (_SS_ALIGNSIZE + _SS_PAD1SIZE \
|
||||
+ sizeof(uint16_t)))
|
||||
#endif
|
||||
|
||||
struct sockaddr_storage {
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
uint8_t ss_len;
|
||||
uint8_t ss_family;
|
||||
#else
|
||||
uint16_t ss_family;
|
||||
#endif
|
||||
char __ss_pad1[_SS_PAD1SIZE];
|
||||
uint64_t __ss_align; /* field to force desired structure */
|
||||
char __ss_pad2[_SS_PAD2SIZE];
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDPORTT
|
||||
/*%
|
||||
* Ensure type in_port_t is defined.
|
||||
@@ -319,20 +293,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
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_NET_H */
|
||||
|
||||
@@ -392,19 +392,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);
|
||||
#define inet_pton isc_net_pton
|
||||
#endif
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_NET_H */
|
||||
|
||||
@@ -44,9 +44,6 @@
|
||||
|
||||
#define ISC_PLATFORM_NEEDPORTT
|
||||
#undef MSG_TRUNC
|
||||
#define ISC_PLATFORM_NEEDNTOP
|
||||
#define ISC_PLATFORM_NEEDPTON
|
||||
#define ISC_PLATFORM_HAVESOCKADDRSTORAGE
|
||||
|
||||
#define ISC_PLATFORM_NEEDSTRSEP
|
||||
#define ISC_PLATFORM_NEEDSTRLCPY
|
||||
|
||||
@@ -3522,7 +3522,6 @@
|
||||
./lib/isc/tests/hash_test.c C 2011,2012,2013,2014,2015,2016,2017,2018
|
||||
./lib/isc/tests/heap_test.c C 2017,2018
|
||||
./lib/isc/tests/ht_test.c C 2016,2017,2018
|
||||
./lib/isc/tests/inet_ntop_test.c C 2017,2018
|
||||
./lib/isc/tests/isctest.c C 2011,2012,2013,2014,2016,2017,2018
|
||||
./lib/isc/tests/isctest.h C 2011,2012,2016,2018
|
||||
./lib/isc/tests/lex_test.c C 2013,2016,2018
|
||||
|
||||
Reference in New Issue
Block a user