deal with lwres portability issues

This commit is contained in:
Bob Halley
2000-02-04 06:04:16 +00:00
parent 2ba9ea4e1e
commit 35c842e05d
5 changed files with 37 additions and 17 deletions

View File

@@ -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 <sys/socket.h>],
[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

View File

@@ -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 <resolv.h>
#include <lwres/lwres.h>
#include <lwres/net.h>
#include <lwres/netdb.h> /* XXX #include <netdb.h> */
#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;

View File

@@ -27,6 +27,7 @@
#include <string.h>
#include <lwres/lwres.h>
#include <lwres/net.h>
#include <lwres/netdb.h> /* XXX #include <netdb.h> */
#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)

View File

@@ -44,9 +44,11 @@
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <lwres/lwres.h>
#include <lwres/net.h>
#include <lwres/netdb.h>
#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)

View File

@@ -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