diff --git a/configure.in b/configure.in index a8dbcea783..f7aa3aa1e9 100644 --- a/configure.in +++ b/configure.in @@ -13,7 +13,7 @@ dnl PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS dnl ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS dnl SOFTWARE. -AC_REVISION($Revision: 1.89 $) +AC_REVISION($Revision: 1.90 $) AC_PREREQ(2.13) @@ -156,12 +156,15 @@ dnl case "$ac_cv_header_netinet6_in6_h" in yes) ISC_PLATFORM_HAVENETINET6IN6H="#define ISC_PLATFORM_HAVENETINET6IN6H 1" + LWRES_PLATFORM_HAVENETINET6IN6H="#define LWRES_PLATFORM_HAVENETINET6IN6H 1" ;; no) ISC_PLATFORM_HAVENETINET6IN6H="#undef ISC_PLATFORM_HAVENETINET6IN6H" + LWRES_PLATFORM_HAVENETINET6IN6H="#undef LWRES_PLATFORM_HAVENETINET6IN6H" ;; esac AC_SUBST(ISC_PLATFORM_HAVENETINET6IN6H) +AC_SUBST(LWRES_PLATFORM_HAVENETINET6IN6H) AC_C_CONST AC_C_INLINE @@ -289,10 +292,13 @@ AC_TRY_COMPILE([ #include ], [struct sockaddr sa; sa.sa_len = 0; return (0);], [AC_MSG_RESULT(yes) - ISC_PLATFORM_HAVESALEN="#define ISC_PLATFORM_HAVESALEN 1"], + ISC_PLATFORM_HAVESALEN="#define ISC_PLATFORM_HAVESALEN 1" + LWRES_PLATFORM_HAVESALEN="#define LWRES_PLATFORM_HAVESALEN 1"], [AC_MSG_RESULT(no) - ISC_PLATFORM_HAVESALEN="#undef ISC_PLATFORM_HAVESALEN"]) + ISC_PLATFORM_HAVESALEN="#undef ISC_PLATFORM_HAVESALEN" + LWRES_PLATFORM_HAVESALEN="#undef LWRES_PLATFORM_HAVESALEN"]) AC_SUBST(ISC_PLATFORM_HAVESALEN) +AC_SUBST(LWRES_PLATFORM_HAVESALEN) dnl dnl Look for a 4.4BSD or 4.3BSD struct msghdr @@ -491,10 +497,12 @@ esac case "$found_ipv6" in yes) - ISC_PLATFORM_HAVEIPV6="#define ISC_PLATFORM_HAVEIPV6 1", + ISC_PLATFORM_HAVEIPV6="#define ISC_PLATFORM_HAVEIPV6 1" + LWRES_PLATFORM_HAVEIPV6="#define LWRES_PLATFORM_HAVEIPV6 1" ;; no) ISC_PLATFORM_HAVEIPV6="#undef ISC_PLATFORM_HAVEIPV6" + LWRES_PLATFORM_HAVEIPV6="#undef LWRES_PLATFORM_HAVEIPV6" ISC_IPV6_H="ipv6.h" ISC_IPV6_O="ipv6.$O" ISC_ISCIPV6_O="unix/ipv6.$O" @@ -503,6 +511,7 @@ case "$found_ipv6" in esac AC_SUBST(ISC_PLATFORM_HAVEIPV6) +AC_SUBST(LWRES_PLATFORM_HAVEIPV6) AC_SUBST(ISC_IPV6_H) AC_SUBST(ISC_IPV6_O) AC_SUBST(ISC_ISCIPV6_O) @@ -680,6 +689,7 @@ AC_OUTPUT( lib/lwres/include/Makefile lib/lwres/include/lwres/Makefile lib/lwres/include/lwres/netdb.h + lib/lwres/include/lwres/platform.h lib/omapi/Makefile lib/omapi/include/Makefile lib/omapi/include/omapi/Makefile diff --git a/lib/lwres/getaddrinfo.c b/lib/lwres/getaddrinfo.c index 6309f46f03..b01f8e8c9b 100644 --- a/lib/lwres/getaddrinfo.c +++ b/lib/lwres/getaddrinfo.c @@ -3,7 +3,7 @@ * The Berkeley Software Design Inc. software License Agreement specifies * the terms and conditions for redistribution. * - * BSDI $Id: getaddrinfo.c,v 1.11 2000/02/03 21:54:08 marka Exp $ + * BSDI $Id: getaddrinfo.c,v 1.12 2000/02/04 06:03:28 halley Exp $ */ @@ -22,6 +22,7 @@ #include #include +#include #include /* XXX #include */ #define SA(addr) ((struct sockaddr *)(addr)) @@ -215,7 +216,7 @@ lwres_getaddrinfo(const char *hostname, const char *servname, char nbuf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx00")]; int addrsize, addroff; - if (inet_aton(hostname, (struct in_addr *)abuf)) { + if (lwres_net_aton(hostname, (struct in_addr *)abuf)) { if (family == AF_INET6) { /* Convert to a V4 mapped address */ struct in6_addr *a6 = (struct in6_addr *)abuf; @@ -229,7 +230,7 @@ lwres_getaddrinfo(const char *hostname, const char *servname, family = AF_INET; goto common; - } else if (inet_pton(AF_INET6, hostname, abuf)) { + } else if (lwres_net_pton(AF_INET6, hostname, abuf)) { if (family && family != AF_INET6) return (EAI_NONAME); inet6_addr: @@ -245,7 +246,8 @@ lwres_getaddrinfo(const char *hostname, const char *servname, SIN(ai->ai_addr)->sin_port = port; memcpy((char *)ai->ai_addr + addroff, abuf, addrsize); if (flags & AI_CANONNAME) { - inet_ntop(family, abuf, nbuf, sizeof(nbuf)); + lwres_net_ntop(family, abuf, nbuf, + sizeof(nbuf)); ai->ai_canonname = strdup(nbuf); } goto done; diff --git a/lib/lwres/getipnode.c b/lib/lwres/getipnode.c index 0073d82b7a..78a49960ec 100644 --- a/lib/lwres/getipnode.c +++ b/lib/lwres/getipnode.c @@ -27,6 +27,7 @@ #include #include +#include #include /* XXX #include */ #include "assert_p.h" @@ -38,6 +39,8 @@ #define IN6ADDRSZ 16 #endif +const struct in6_addr lwres_in6addr_any = IN6ADDR_ANY_INIT; + #ifndef IN6_IS_ADDR_V4COMPAT static const unsigned char in6addr_compat[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -102,8 +105,8 @@ lwres_getipnodebyname(const char *name, int af, int flags, int *error_num) { } /* Check for literal address. */ - if ((v4 = inet_pton(AF_INET, name, &in4)) != 1) - v6 = inet_pton(AF_INET6, name, &in6); + if ((v4 = lwres_net_pton(AF_INET, name, &in4)) != 1) + v6 = lwres_net_pton(AF_INET6, name, &in6); /* Impossible combination? */ @@ -259,7 +262,8 @@ lwres_getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { /* * Lookup IPv6 address. */ - if (memcmp((struct in6_addr *)src, &in6addr_any, IN6ADDRSZ) == 0) { + if (memcmp((struct in6_addr *)src, &lwres_in6addr_any, + IN6ADDRSZ) == 0) { *error_num = HOST_NOT_FOUND; return (NULL); } @@ -432,7 +436,8 @@ scan_interfaces(int *have_v4, int *have_v6) { memcpy(&in6, &((struct sockaddr_in6 *) &ifreq.ifr_addr)->sin6_addr, sizeof in6); - if (memcmp(&in6, &in6addr_any, sizeof in6) == 0) + if (memcmp(&in6, &lwres_in6addr_any, + sizeof in6) == 0) break; n = ioctl(s, SIOCGIFFLAGS, (char *)&ifreq); if (n < 0) diff --git a/lib/lwres/getnameinfo.c b/lib/lwres/getnameinfo.c index 672f242d8f..4d28192e52 100644 --- a/lib/lwres/getnameinfo.c +++ b/lib/lwres/getnameinfo.c @@ -44,9 +44,11 @@ #include +#include #include #include +#include #include #include "assert_p.h" @@ -143,7 +145,7 @@ lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, /* Caller does not want service. */ } else if ((flags & NI_NUMERICSERV) != 0 || (sp = getservbyport(port, proto)) == NULL) { - snprintf(numserv, sizeof(numserv), "%d", ntohs(port)); + sprintf(numserv, "%d", ntohs(port)); if ((strlen(numserv) + 1) > servlen) ERR(ENI_MEMORY); strcpy(serv, numserv); @@ -175,7 +177,7 @@ lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, if (host == NULL || hostlen == 0) { /* what should we do? */ } else if (flags & NI_NUMERICHOST) { - if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) + if (lwres_net_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) == NULL) ERR(ENI_SYSTEM); if (strlen(numaddr) > hostlen) @@ -209,7 +211,8 @@ lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, } else { if (flags & NI_NAMEREQD) ERR(ENI_NOHOSTNAME); - if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) + if (lwres_net_ntop(afd->a_af, addr, numaddr, + sizeof(numaddr)) == NULL) ERR(ENI_NOHOSTNAME); if ((strlen(numaddr) + 1) > hostlen) diff --git a/lib/lwres/include/lwres/Makefile.in b/lib/lwres/include/lwres/Makefile.in index f4c03cbf56..734088dc04 100644 --- a/lib/lwres/include/lwres/Makefile.in +++ b/lib/lwres/include/lwres/Makefile.in @@ -21,7 +21,7 @@ top_srcdir = @top_srcdir@ # Only list headers that are to be installed! # HEADERS = context.h lwbuffer.h lwpacket.h lwres.h netdb.h result.h \ - int.h lang.h + int.h lang.h net.h ipv6.h platform.h SUBDIRS = TARGETS = @@ -42,4 +42,4 @@ install:: installdirs done distclean:: - rm -f netdb.h + rm -f netdb.h platform.h