diff --git a/CHANGES b/CHANGES index 3f0ed8ef30e4659197c751997b2ef041d02d25f5..19ae366a1d984904e42525ce7760d4ebb58c72bf 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +1065. [func] Runtime support to select new / old style interface + scanning using ioctls. + 1064. [bug] Do not shutdown active interfaces if we are unable to scan the list of interfaces. [RT #1921] diff --git a/config.h.in b/config.h.in index d55479f283d7bd2f9753f5407e871407902d924a..cb1e835d96cbcd16b128136c284bd51fe82d9406 100644 --- a/config.h.in +++ b/config.h.in @@ -16,7 +16,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: config.h.in,v 1.48 2001/08/30 04:33:17 marka Exp $ */ +/* $Id: config.h.in,v 1.49 2001/10/22 04:01:26 marka Exp $ */ /*** *** This file is not to be included by any public header files, because @@ -165,6 +165,9 @@ int sigwait(const unsigned int *set, int *sig); /* Define if you have the header file. */ #undef HAVE_UNISTD_H +/* Define if you have the header file. */ +#undef NET_IF6_H + /* Define if you have the nsl library (-lnsl). */ #undef HAVE_LIBNSL diff --git a/configure.in b/configure.in index a8502ad07a4822c2ce4d2ada94671ee2b1a8d495..4cdf8f965fe68626aa75ef97d2082b819acd46a8 100644 --- a/configure.in +++ b/configure.in @@ -18,7 +18,7 @@ AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl esyscmd([sed "s/^/# /" COPYRIGHT])dnl AC_DIVERT_POP()dnl -AC_REVISION($Revision: 1.304 $) +AC_REVISION($Revision: 1.305 $) AC_INIT(lib/dns/name.c) AC_PREREQ(2.13) @@ -194,7 +194,7 @@ AC_PROG_CC AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h sys/sockio.h sys/select.h sys/sysctl.h) +AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h sys/sockio.h sys/select.h sys/sysctl.h net/if6.h) AC_C_CONST AC_C_INLINE @@ -1109,6 +1109,28 @@ AC_SUBST(ISC_ISCIPV6_O) AC_SUBST(ISC_IPV6_C) AC_SUBST(LWRES_HAVE_SIN6_SCOPE_ID) +AC_MSG_CHECKING([for struct if_laddrreq]) +AC_TRY_LINK([ +#include +#include +],[ struct if_laddrreq a; ], + [AC_MSG_RESULT(yes) + ISC_PLATFORM_HAVEIF_LADDRREQ="#define ISC_PLATFORM_HAVEIF_LADDRREQ 1"], + [AC_MSG_RESULT(no) + ISC_PLATFORM_HAVEIF_LADDRREQ="#undef ISC_PLATFORM_HAVEIF_LADDRREQ"]) +AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRREQ) + +AC_MSG_CHECKING([for struct if_laddrconf]) +AC_TRY_LINK([ +#include +#include +],[ struct if_laddrconf a; ], + [AC_MSG_RESULT(yes) + ISC_PLATFORM_HAVEIF_LADDRCONF="#define ISC_PLATFORM_HAVEIF_LADDRCONF 1"], + [AC_MSG_RESULT(no) + 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 diff --git a/lib/isc/include/isc/platform.h.in b/lib/isc/include/isc/platform.h.in index b2e485d74dfa4cf142d5ae5c7a2700587f4fdbde..bc42592efe4b35d8eb495ed196f61782d2d5035d 100644 --- a/lib/isc/include/isc/platform.h.in +++ b/lib/isc/include/isc/platform.h.in @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: platform.h.in,v 1.25 2001/10/03 05:08:30 marka Exp $ */ +/* $Id: platform.h.in,v 1.26 2001/10/22 04:01:29 marka Exp $ */ #ifndef ISC_PLATFORM_H #define ISC_PLATFORM_H 1 @@ -153,6 +153,17 @@ */ @ISC_PLATFORM_HAVELIFCONF@ +/* + * Define if the system has struct if_laddrconf which is a extended struct + * ifconf for IPv6. + */ +@ISC_PLATFORM_HAVEIF_LADDRCONF@ + +/* + * Define if the system has struct if_laddrreq. + */ +@ISC_PLATFORM_HAVEIF_LADDRREQ@ + /* * Used to control how extern data is linked; needed for Win32 platforms. */ diff --git a/lib/isc/unix/ifiter_ioctl.c b/lib/isc/unix/ifiter_ioctl.c index d5fa2b1f8d3975405ef7904196ce5186f466b596..4ecd62102831acd039ebb81da6efab75ecd3cdda 100644 --- a/lib/isc/unix/ifiter_ioctl.c +++ b/lib/isc/unix/ifiter_ioctl.c @@ -15,44 +15,36 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ifiter_ioctl.c,v 1.22 2001/10/03 05:08:32 marka Exp $ */ +/* $Id: ifiter_ioctl.c,v 1.23 2001/10/22 04:01:31 marka Exp $ */ /* * Obtain the list of network interfaces using the SIOCGLIFCONF ioctl. * See netintro(4). */ -#ifndef ISC_PLATFORM_HAVELIFCONF -/* - * HP uses these differently to Sun. - */ -#undef SIOCGLIFCONF -#undef SIOCGLIFADDR -#endif - -#ifndef SIOCGLIFCONF -#define SIOCGLIFCONF SIOCGIFCONF -#define lifc_len ifc_len -#define lifc_buf ifc_buf -#define lifc_req ifc_req -#define lifconf ifconf +#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 -#ifndef SIOCGLIFADDR -#define SIOCGLIFADDR SIOCGIFADDR -#define SIOCGLIFFLAGS SIOCGIFFLAGS -#define SIOCGLIFDSTADDR SIOCGIFDSTADDR -#define SIOCGLIFNETMASK SIOCGIFNETMASK -#define lifr_addr ifr_addr -#define lifr_name ifr_name -#define lifr_dstaddr ifr_dstaddr -#define lifr_flags ifr_flags + +#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 ifreq +#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) @@ -61,7 +53,11 @@ struct isc_interfaceiter { unsigned int magic; /* Magic number. */ isc_mem_t *mctx; int socket; - struct lifconf ifc; + int mode; + struct ifconf ifc; +#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR) + struct LIFCONF lifc; +#endif void *buf; /* Buffer for sysctl data. */ unsigned int bufsize; /* Bytes allocated. */ unsigned int pos; /* Current offset in @@ -78,67 +74,109 @@ struct isc_interfaceiter { #define IFCONF_BUFSIZE_INITIAL 4096 #define IFCONF_BUFSIZE_MAX 1048576 -isc_result_t -isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { - isc_interfaceiter_t *iter; - isc_result_t result; +static isc_result_t +getbuf4(isc_interfaceiter_t *iter) { char strbuf[ISC_STRERRORSIZE]; - REQUIRE(mctx != NULL); - REQUIRE(iterp != NULL); - REQUIRE(*iterp == NULL); + iter->bufsize = IFCONF_BUFSIZE_INITIAL; - iter = isc_mem_get(mctx, sizeof(*iter)); - if (iter == NULL) - return (ISC_R_NOMEMORY); + for (;;) { + iter->buf = isc_mem_get(iter->mctx, iter->bufsize); + if (iter->buf == NULL) + return (ISC_R_NOMEMORY); - iter->mctx = mctx; - iter->buf = NULL; + memset(&iter->ifc.ifc_len, 0, sizeof(iter->ifc.ifc_len)); + iter->ifc.ifc_len = iter->bufsize; + iter->ifc.ifc_buf = iter->buf; + /* + * Ignore the HP/UX warning about "interger overflow during + * conversion". It comes from its own macro definition, + * and is really hard to shut up. + */ + if (ioctl(iter->socket, SIOCGIFCONF, (char *)&iter->ifc) + == -1) { + if (errno != EINVAL) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, + isc_msgcat_get(isc_msgcat, + ISC_MSGSET_IFITERIOCTL, + ISC_MSG_GETIFCONFIG, + "get interface " + "configuration: %s"), + strbuf); + goto unexpected; + } + /* + * EINVAL. Retry with a bigger buffer. + */ + } else { + /* + * The ioctl succeeded. + * Some OS's just return what will fit rather + * than set EINVAL if the buffer is too small + * to fit all the interfaces in. If + * ifc.lifc_len is too near to the end of the + * buffer we will grow it just in case and + * retry. + */ + if (iter->ifc.ifc_len + 2 * sizeof(struct ifreq) + < iter->bufsize) + break; + } + if (iter->bufsize >= IFCONF_BUFSIZE_MAX) { + UNEXPECTED_ERROR(__FILE__, __LINE__, + isc_msgcat_get(isc_msgcat, + ISC_MSGSET_IFITERIOCTL, + ISC_MSG_BUFFERMAX, + "get interface " + "configuration: " + "maximum buffer " + "size exceeded")); + goto unexpected; + } + isc_mem_put(iter->mctx, iter->buf, iter->bufsize); - /* - * Create an unbound datagram socket to do the SIOCGLIFADDR ioctl on. - */ - if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - isc__strerror(errno, strbuf, sizeof(strbuf)); - UNEXPECTED_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_IFITERIOCTL, - ISC_MSG_MAKESCANSOCKET, - "making interface " - "scan socket: %s"), - strbuf); - result = ISC_R_UNEXPECTED; - goto socket_failure; + iter->bufsize *= 2; } + iter->mode = 4; + return (ISC_R_SUCCESS); + + unexpected: + isc_mem_put(iter->mctx, iter->buf, iter->bufsize); + iter->buf = NULL; + return (ISC_R_UNEXPECTED); +} + +static isc_result_t +getbuf6(isc_interfaceiter_t *iter) { +#if !defined(SIOCGLIFCONF) || !defined(SIOCGLIFADDR) + UNUSED(iter); + return (ISC_R_NOTIMPLEMENTED); +#else + char strbuf[ISC_STRERRORSIZE]; - /* - * Get the interface configuration, allocating more memory if - * necessary. - */ iter->bufsize = IFCONF_BUFSIZE_INITIAL; for (;;) { - iter->buf = isc_mem_get(mctx, iter->bufsize); - if (iter->buf == NULL) { - result = ISC_R_NOMEMORY; - goto alloc_failure; - } + iter->buf = isc_mem_get(iter->mctx, iter->bufsize); + if (iter->buf == NULL) + return (ISC_R_NOMEMORY); - memset(&iter->ifc.lifc_len, 0, sizeof(iter->ifc.lifc_len)); + memset(&iter->lifc.lifc_len, 0, sizeof(iter->lifc.lifc_len)); #ifdef ISC_HAVE_LIFC_FAMILY - iter->ifc.lifc_family = AF_UNSPEC; + iter->lifc.lifc_family = AF_UNSPEC; #endif #ifdef ISC_HAVE_LIFC_FLAGS - iter->ifc.lifc_flags = 0; + iter->lifc.lifc_flags = 0; #endif - iter->ifc.lifc_len = iter->bufsize; - iter->ifc.lifc_buf = iter->buf; + iter->lifc.lifc_len = iter->bufsize; + iter->lifc.lifc_buf = iter->buf; /* * Ignore the HP/UX warning about "interger overflow during * conversion". It comes from its own macro definition, * and is really hard to shut up. */ - if (ioctl(iter->socket, SIOCGLIFCONF, (char *)&iter->ifc) + if (ioctl(iter->socket, SIOCGLIFCONF, (char *)&iter->lifc) == -1) { if (errno != EINVAL) { isc__strerror(errno, strbuf, sizeof(strbuf)); @@ -149,8 +187,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { "get interface " "configuration: %s"), strbuf); - result = ISC_R_UNEXPECTED; - goto ioctl_failure; + goto unexpected; } /* * EINVAL. Retry with a bigger buffer. @@ -161,11 +198,11 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { * Some OS's just return what will fit rather * than set EINVAL if the buffer is too small * to fit all the interfaces in. If - * ifc.lifc_len is too near to the end of the + * ifc.ifc_len is too near to the end of the * buffer we will grow it just in case and * retry. */ - if (iter->ifc.lifc_len + 2 * sizeof(struct lifreq) + if (iter->lifc.lifc_len + 2 * sizeof(struct LIFREQ) < iter->bufsize) break; } @@ -178,14 +215,70 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { "configuration: " "maximum buffer " "size exceeded")); - result = ISC_R_UNEXPECTED; - goto ioctl_failure; + goto unexpected; } - isc_mem_put(mctx, iter->buf, iter->bufsize); + isc_mem_put(iter->mctx, iter->buf, iter->bufsize); iter->bufsize *= 2; } + iter->mode = 6; + return (ISC_R_SUCCESS); + + unexpected: + isc_mem_put(iter->mctx, iter->buf, iter->bufsize); + iter->buf = NULL; + return (ISC_R_UNEXPECTED); +#endif +} + +isc_result_t +isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { + isc_interfaceiter_t *iter; + isc_result_t result; + char strbuf[ISC_STRERRORSIZE]; + + REQUIRE(mctx != NULL); + REQUIRE(iterp != NULL); + REQUIRE(*iterp == NULL); + + iter = isc_mem_get(mctx, sizeof(*iter)); + if (iter == NULL) + return (ISC_R_NOMEMORY); + + iter->mctx = mctx; + iter->buf = NULL; + iter->mode = 0; + + /* + * Create an unbound datagram socket to do the SIOCGLIFADDR ioctl on. + */ + if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, + isc_msgcat_get(isc_msgcat, + ISC_MSGSET_IFITERIOCTL, + ISC_MSG_MAKESCANSOCKET, + "making interface " + "scan socket: %s"), + strbuf); + result = ISC_R_UNEXPECTED; + goto socket_failure; + } + + /* + * Get the interface configuration, allocating more memory if + * necessary. + */ + + result = isc_net_probeipv6(); + if (result == ISC_R_SUCCESS) + result = getbuf6(iter); + if (result != ISC_R_SUCCESS) + result = getbuf4(iter); + if (result != ISC_R_SUCCESS) + goto ioctl_failure; + /* * A newly created iterator has an undefined position * until isc_interfaceiter_first() is called. @@ -198,9 +291,8 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { return (ISC_R_SUCCESS); ioctl_failure: - isc_mem_put(mctx, iter->buf, iter->bufsize); - - alloc_failure: + if (iter->buf != NULL) + isc_mem_put(mctx, iter->buf, iter->bufsize); (void) close(iter->socket); socket_failure: @@ -217,22 +309,149 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { */ static isc_result_t -internal_current(isc_interfaceiter_t *iter) { - struct lifreq *ifrp; - struct lifreq lifreq; +internal_current4(isc_interfaceiter_t *iter) { + struct ifreq *ifrp; + struct ifreq ifreq; + int family; + char strbuf[ISC_STRERRORSIZE]; + + REQUIRE(VALID_IFITER(iter)); + REQUIRE (iter->pos < (unsigned int) iter->ifc.ifc_len); + + ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos); + + memset(&ifreq, 0, sizeof ifreq); + memcpy(&ifreq, ifrp, sizeof ifreq); + + family = ifreq.ifr_addr.sa_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)); + iter->current.af = family; + + INSIST(sizeof(ifreq.ifr_name) <= sizeof(iter->current.name)); + memset(iter->current.name, 0, sizeof(iter->current.name)); + memcpy(iter->current.name, ifreq.ifr_name, sizeof(ifreq.ifr_name)); + + get_addr(family, &iter->current.address, + (struct sockaddr *)&ifreq.ifr_addr); + + /* + * Get interface flags. + */ + + iter->current.flags = 0; + + /* + * Ignore the HP/UX warning about "interger overflow during + * conversion. It comes from its own macro definition, + * and is really hard to shut up. + */ + if (ioctl(iter->socket, SIOCGIFFLAGS, (char *) &ifreq) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, + "%s: getting interface flags: %s", + ifreq.ifr_name, strbuf); + return (ISC_R_IGNORE); + } + + if ((ifreq.ifr_flags & IFF_UP) != 0) + iter->current.flags |= INTERFACE_F_UP; + + if ((ifreq.ifr_flags & IFF_POINTOPOINT) != 0) + iter->current.flags |= INTERFACE_F_POINTTOPOINT; + + if ((ifreq.ifr_flags & IFF_LOOPBACK) != 0) + iter->current.flags |= INTERFACE_F_LOOPBACK; + + /* + * If the interface is point-to-point, get the destination address. + */ + if ((iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0) { + /* + * Ignore the HP/UX warning about "interger overflow during + * conversion. It comes from its own macro definition, + * and is really hard to shut up. + */ + if (ioctl(iter->socket, SIOCGIFDSTADDR, (char *)&ifreq) + < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, + isc_msgcat_get(isc_msgcat, + ISC_MSGSET_IFITERIOCTL, + ISC_MSG_GETDESTADDR, + "%s: getting " + "destination address: %s"), + ifreq.ifr_name, strbuf); + return (ISC_R_IGNORE); + } + get_addr(family, &iter->current.dstaddress, + (struct sockaddr *)&ifreq.ifr_dstaddr); + } + + /* + * Get the network mask. + */ + memset(&ifreq, 0, sizeof ifreq); + memcpy(&ifreq, ifrp, sizeof ifreq); + switch (family) { + case AF_INET: + /* + * Ignore the HP/UX warning about "interger overflow during + * conversion. It comes from its own macro definition, + * and is really hard to shut up. + */ + if (ioctl(iter->socket, SIOCGIFNETMASK, (char *)&ifreq) + < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, + isc_msgcat_get(isc_msgcat, + ISC_MSGSET_IFITERIOCTL, + ISC_MSG_GETNETMASK, + "%s: getting netmask: %s"), + ifreq.ifr_name, strbuf); + return (ISC_R_IGNORE); + } + get_addr(family, &iter->current.netmask, + (struct sockaddr *)&ifreq.ifr_addr); + break; + case AF_INET6: + break; + } + + return (ISC_R_SUCCESS); +} + +static isc_result_t +internal_current6(isc_interfaceiter_t *iter) { +#if !defined(SIOCGLIFCONF) || !defined(SIOCGLIFADDR) + UNUSED(iter); + return (ISC_R_NOTIMPLEMENTED); +#else + struct LIFREQ *ifrp; + struct LIFREQ lifreq; int family; char strbuf[ISC_STRERRORSIZE]; REQUIRE(VALID_IFITER(iter)); - REQUIRE (iter->pos < (unsigned int) iter->ifc.lifc_len); + REQUIRE (iter->pos < (unsigned int) iter->lifc.lifc_len); - ifrp = (struct lifreq *)((char *) iter->ifc.lifc_req + iter->pos); + ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos); memset(&lifreq, 0, sizeof lifreq); memcpy(&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)); @@ -344,6 +563,14 @@ internal_current(isc_interfaceiter_t *iter) { } return (ISC_R_SUCCESS); +#endif +} + +static isc_result_t +internal_current(isc_interfaceiter_t *iter) { + if (iter->mode == 6) + return (internal_current6(iter)); + return (internal_current4(iter)); } /* @@ -354,12 +581,37 @@ internal_current(isc_interfaceiter_t *iter) { * interfaces, otherwise ISC_R_SUCCESS. */ static isc_result_t -internal_next(isc_interfaceiter_t *iter) { - struct lifreq *ifrp; +internal_next4(isc_interfaceiter_t *iter) { + struct ifreq *ifrp; - REQUIRE (iter->pos < (unsigned int) iter->ifc.lifc_len); + REQUIRE (iter->pos < (unsigned int) iter->ifc.ifc_len); - ifrp = (struct lifreq *)((char *) iter->ifc.lifc_req + iter->pos); + ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos); + +#ifdef ISC_PLATFORM_HAVESALEN + 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 *ifrp; + + if (iter->pos >= (unsigned int) iter->ifc.ifc_len) + return (ISC_R_NOMORE); + + return (ISC_R_SUCCESS); +} + +static isc_result_t +internal_next6(isc_interfaceiter_t *iter) { +#if !defined(SIOCGLIFCONF) || !defined(SIOCGLIFADDR) + UNUSED(iter); + return (ISC_R_NOTIMPLEMENTED); +#else + struct LIFREQ *ifrp; + + REQUIRE (iter->pos < (unsigned int) iter->lifc.lifc_len); + + ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos); #ifdef ISC_PLATFORM_HAVESALEN if (ifrp->lifr_addr.sa_len > sizeof(struct sockaddr)) @@ -368,10 +620,18 @@ internal_next(isc_interfaceiter_t *iter) { #endif iter->pos += sizeof *ifrp; - if (iter->pos >= (unsigned int) iter->ifc.lifc_len) + if (iter->pos >= (unsigned int) iter->lifc.lifc_len) return (ISC_R_NOMORE); return (ISC_R_SUCCESS); +#endif +} + +static isc_result_t +internal_next(isc_interfaceiter_t *iter) { + if (iter->mode == 6) + return (internal_next6(iter)); + return (internal_next4(iter)); } static void diff --git a/lib/isc/unix/interfaceiter.c b/lib/isc/unix/interfaceiter.c index 8ec32ac55199f4312afd56c7cba18d041abd7ffe..22481d60f6e9fc943accc8ac35be5129c1d2ef2c 100644 --- a/lib/isc/unix/interfaceiter.c +++ b/lib/isc/unix/interfaceiter.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: interfaceiter.c,v 1.23 2001/08/31 05:57:53 marka Exp $ */ +/* $Id: interfaceiter.c,v 1.24 2001/10/22 04:01:32 marka Exp $ */ #include @@ -41,7 +41,11 @@ #include #include -#include /* Must follow . */ +/* Must follow . */ +#ifdef HAVE_NET_IF6_H +#include +#endif +#include /* Common utility functions */