mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
1517. [port] Support for IPv6 interface scanning on HP/UX and
TrueUNIX 5.1.
This commit is contained in:
parent
a2b8bb8777
commit
846f974d57
3
CHANGES
3
CHANGES
@ -13,7 +13,8 @@
|
|||||||
contained a off-by-one error when working out the
|
contained a off-by-one error when working out the
|
||||||
number of octets in the bitmap.
|
number of octets in the bitmap.
|
||||||
|
|
||||||
1517. [placeholder]
|
1517. [port] Support for IPv6 interface scanning on HP/UX and
|
||||||
|
TrueUNIX 5.1.
|
||||||
|
|
||||||
1516. [func] Roll the DNSSEC types to RRSIG, NSEC and DNSKEY.
|
1516. [func] Roll the DNSSEC types to RRSIG, NSEC and DNSKEY.
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
|
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
|
||||||
"http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
|
"http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
|
||||||
|
|
||||||
<!-- File: $Id: Bv9ARM-book.xml,v 1.230 2003/09/25 18:16:45 jinmei Exp $ -->
|
<!-- File: $Id: Bv9ARM-book.xml,v 1.231 2003/10/07 03:34:30 marka Exp $ -->
|
||||||
|
|
||||||
<book>
|
<book>
|
||||||
<title>BIND 9 Administrator Reference Manual</title>
|
<title>BIND 9 Administrator Reference Manual</title>
|
||||||
@ -2099,7 +2099,12 @@ interfaces on the system.</para></entry>
|
|||||||
<row rowsep = "0">
|
<row rowsep = "0">
|
||||||
<entry colname = "1"><para><command>localnets</command></para></entry>
|
<entry colname = "1"><para><command>localnets</command></para></entry>
|
||||||
<entry colname = "2"><para>Matches any host on an IPv4 or IPv6 network
|
<entry colname = "2"><para>Matches any host on an IPv4 or IPv6 network
|
||||||
for which the system has an interface.</para></entry>
|
for which the system has an interface.
|
||||||
|
Some systems do not provide a way to determine the prefix lengths of
|
||||||
|
local IPv6 addresses.
|
||||||
|
In such a case, <command>localnets</command> only matches the local
|
||||||
|
IPv6 addresses, just like <command>localhost</command>.
|
||||||
|
</para></entry>
|
||||||
</row>
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup></informaltable>
|
</tgroup></informaltable>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: ifiter_getifaddrs.c,v 1.2 2003/04/01 05:18:22 marka Exp $ */
|
/* $Id: ifiter_getifaddrs.c,v 1.3 2003/10/07 03:34:30 marka Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Obtain the list of network interfaces using the getifaddrs(3) library.
|
* Obtain the list of network interfaces using the getifaddrs(3) library.
|
||||||
@ -134,14 +134,16 @@ internal_current(isc_interfaceiter_t *iter) {
|
|||||||
|
|
||||||
iter->current.af = family;
|
iter->current.af = family;
|
||||||
|
|
||||||
get_addr(family, &iter->current.address, ifa->ifa_addr);
|
get_addr(family, &iter->current.address, ifa->ifa_addr, ifa->ifa_name);
|
||||||
|
|
||||||
if (ifa->ifa_netmask != NULL)
|
if (ifa->ifa_netmask != NULL)
|
||||||
get_addr(family, &iter->current.netmask, ifa->ifa_netmask);
|
get_addr(family, &iter->current.netmask, ifa->ifa_netmask,
|
||||||
|
ifa->ifa_name);
|
||||||
|
|
||||||
if (ifa->ifa_dstaddr != NULL &&
|
if (ifa->ifa_dstaddr != NULL &&
|
||||||
(iter->current.flags & IFF_POINTOPOINT) != 0)
|
(iter->current.flags & IFF_POINTOPOINT) != 0)
|
||||||
get_addr(family, &iter->current.dstaddress, ifa->ifa_dstaddr);
|
get_addr(family, &iter->current.dstaddress, ifa->ifa_dstaddr,
|
||||||
|
ifa->ifa_name);
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: ifiter_ioctl.c,v 1.40 2003/10/03 06:12:34 marka Exp $ */
|
/* $Id: ifiter_ioctl.c,v 1.41 2003/10/07 03:34:30 marka Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Obtain the list of network interfaces using the SIOCGLIFCONF ioctl.
|
* Obtain the list of network interfaces using the SIOCGLIFCONF ioctl.
|
||||||
@ -55,16 +55,27 @@
|
|||||||
struct isc_interfaceiter {
|
struct isc_interfaceiter {
|
||||||
unsigned int magic; /* Magic number. */
|
unsigned int magic; /* Magic number. */
|
||||||
isc_mem_t *mctx;
|
isc_mem_t *mctx;
|
||||||
int socket;
|
|
||||||
int mode;
|
int mode;
|
||||||
|
int socket;
|
||||||
struct ifconf ifc;
|
struct ifconf ifc;
|
||||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
|
||||||
struct LIFCONF lifc;
|
|
||||||
#endif
|
|
||||||
void *buf; /* Buffer for sysctl data. */
|
void *buf; /* Buffer for sysctl data. */
|
||||||
unsigned int bufsize; /* Bytes allocated. */
|
unsigned int bufsize; /* Bytes allocated. */
|
||||||
|
unsigned int pos; /* Current offset in
|
||||||
|
SIOCGIFCONF data */
|
||||||
|
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||||
|
int socket6;
|
||||||
|
struct LIFCONF lifc;
|
||||||
|
void *buf6; /* Buffer for sysctl data. */
|
||||||
|
unsigned int bufsize6; /* Bytes allocated. */
|
||||||
|
unsigned int pos6; /* Current offset in
|
||||||
|
SIOCGLIFCONF data */
|
||||||
|
isc_result_t result6; /* Last result code. */
|
||||||
|
isc_boolean_t first6;
|
||||||
|
#endif
|
||||||
#ifdef HAVE_TRUCLUSTER
|
#ifdef HAVE_TRUCLUSTER
|
||||||
int clua_context; /* Cluster alias context */
|
int clua_context; /* Cluster alias context */
|
||||||
|
isc_boolean_t clua_done;
|
||||||
|
struct sockaddr clua_sa;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
FILE * proc;
|
FILE * proc;
|
||||||
@ -72,8 +83,6 @@ struct isc_interfaceiter {
|
|||||||
isc_result_t valid;
|
isc_result_t valid;
|
||||||
isc_boolean_t first;
|
isc_boolean_t first;
|
||||||
#endif
|
#endif
|
||||||
unsigned int pos; /* Current offset in
|
|
||||||
SIOCGLIFCONF data */
|
|
||||||
isc_interface_t current; /* Current interface data. */
|
isc_interface_t current; /* Current interface data. */
|
||||||
isc_result_t result; /* Last result code. */
|
isc_result_t result; /* Last result code. */
|
||||||
};
|
};
|
||||||
@ -155,7 +164,6 @@ getbuf4(isc_interfaceiter_t *iter) {
|
|||||||
|
|
||||||
iter->bufsize *= 2;
|
iter->bufsize *= 2;
|
||||||
}
|
}
|
||||||
iter->mode = 4;
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
|
|
||||||
unexpected:
|
unexpected:
|
||||||
@ -164,37 +172,34 @@ getbuf4(isc_interfaceiter_t *iter) {
|
|||||||
return (ISC_R_UNEXPECTED);
|
return (ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
getbuf6(isc_interfaceiter_t *iter) {
|
getbuf6(isc_interfaceiter_t *iter) {
|
||||||
#if !defined(SIOCGLIFCONF) || !defined(SIOCGLIFADDR)
|
|
||||||
UNUSED(iter);
|
|
||||||
return (ISC_R_NOTIMPLEMENTED);
|
|
||||||
#else
|
|
||||||
char strbuf[ISC_STRERRORSIZE];
|
char strbuf[ISC_STRERRORSIZE];
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
iter->bufsize = IFCONF_BUFSIZE_INITIAL;
|
iter->bufsize6 = IFCONF_BUFSIZE_INITIAL;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
iter->buf = isc_mem_get(iter->mctx, iter->bufsize);
|
iter->buf6 = isc_mem_get(iter->mctx, iter->bufsize6);
|
||||||
if (iter->buf == NULL)
|
if (iter->buf6 == NULL)
|
||||||
return (ISC_R_NOMEMORY);
|
return (ISC_R_NOMEMORY);
|
||||||
|
|
||||||
memset(&iter->lifc, 0, sizeof(iter->lifc));
|
memset(&iter->lifc, 0, sizeof(iter->lifc));
|
||||||
#ifdef ISC_HAVE_LIFC_FAMILY
|
#ifdef ISC_HAVE_LIFC_FAMILY
|
||||||
iter->lifc.lifc_family = AF_UNSPEC;
|
iter->lifc.lifc_family = AF_INET6;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ISC_HAVE_LIFC_FLAGS
|
#ifdef ISC_HAVE_LIFC_FLAGS
|
||||||
iter->lifc.lifc_flags = 0;
|
iter->lifc.lifc_flags = 0;
|
||||||
#endif
|
#endif
|
||||||
iter->lifc.lifc_len = iter->bufsize;
|
iter->lifc.lifc_len = iter->bufsize6;
|
||||||
iter->lifc.lifc_buf = iter->buf;
|
iter->lifc.lifc_buf = iter->buf6;
|
||||||
/*
|
/*
|
||||||
* Ignore the HP/UX warning about "interger overflow during
|
* Ignore the HP/UX warning about "interger overflow during
|
||||||
* conversion". It comes from its own macro definition,
|
* conversion". It comes from its own macro definition,
|
||||||
* and is really hard to shut up.
|
* and is really hard to shut up.
|
||||||
*/
|
*/
|
||||||
if (ioctl(iter->socket, SIOCGLIFCONF, (char *)&iter->lifc)
|
if (ioctl(iter->socket6, SIOCGLIFCONF, (char *)&iter->lifc)
|
||||||
== -1) {
|
== -1) {
|
||||||
#ifdef __hpux
|
#ifdef __hpux
|
||||||
/*
|
/*
|
||||||
@ -242,10 +247,10 @@ getbuf6(isc_interfaceiter_t *iter) {
|
|||||||
* retry.
|
* retry.
|
||||||
*/
|
*/
|
||||||
if (iter->lifc.lifc_len + 2 * sizeof(struct LIFREQ)
|
if (iter->lifc.lifc_len + 2 * sizeof(struct LIFREQ)
|
||||||
< iter->bufsize)
|
< iter->bufsize6)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (iter->bufsize >= IFCONF_BUFSIZE_MAX) {
|
if (iter->bufsize6 >= IFCONF_BUFSIZE_MAX) {
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
isc_msgcat_get(isc_msgcat,
|
isc_msgcat_get(isc_msgcat,
|
||||||
ISC_MSGSET_IFITERIOCTL,
|
ISC_MSGSET_IFITERIOCTL,
|
||||||
@ -257,20 +262,20 @@ getbuf6(isc_interfaceiter_t *iter) {
|
|||||||
result = ISC_R_UNEXPECTED;
|
result = ISC_R_UNEXPECTED;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
|
isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
|
||||||
|
|
||||||
iter->bufsize *= 2;
|
iter->bufsize6 *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
iter->mode = 6;
|
iter->mode = 6;
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
|
isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
|
||||||
iter->buf = NULL;
|
iter->buf6 = NULL;
|
||||||
return (result);
|
return (result);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
||||||
@ -287,12 +292,48 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
|||||||
return (ISC_R_NOMEMORY);
|
return (ISC_R_NOMEMORY);
|
||||||
|
|
||||||
iter->mctx = mctx;
|
iter->mctx = mctx;
|
||||||
|
iter->mode = 4;
|
||||||
iter->buf = NULL;
|
iter->buf = NULL;
|
||||||
iter->mode = 0;
|
iter->pos = (unsigned int) -1;
|
||||||
|
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||||
|
iter->buf6 = NULL;
|
||||||
|
iter->pos6 = (unsigned int) -1;
|
||||||
|
iter->result6 = ISC_R_NOMORE;
|
||||||
|
iter->socket6 = -1;
|
||||||
|
iter->first6 = ISC_FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create an unbound datagram socket to do the SIOCGLIFADDR ioctl on.
|
* Get the interface configuration, allocating more memory if
|
||||||
|
* necessary.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||||
|
result = isc_net_probeipv6();
|
||||||
|
if (result == ISC_R_SUCCESS) {
|
||||||
|
/*
|
||||||
|
* Create an unbound datagram socket to do the SIOCGLIFCONF
|
||||||
|
* ioctl on. HP/UX requires an AF_INET6 socket for
|
||||||
|
* SIOCGLIFCONF to get IPv6 addresses.
|
||||||
|
*/
|
||||||
|
if ((iter->socket6 = socket(AF_INET6, 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 socket6_failure;
|
||||||
|
}
|
||||||
|
iter->result6 = getbuf6(iter);
|
||||||
|
if (iter->result6 != ISC_R_NOTIMPLEMENTED &&
|
||||||
|
iter->result6 != ISC_R_SUCCESS)
|
||||||
|
goto ioctl6_failure;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
@ -305,17 +346,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
|||||||
result = ISC_R_UNEXPECTED;
|
result = ISC_R_UNEXPECTED;
|
||||||
goto socket_failure;
|
goto socket_failure;
|
||||||
}
|
}
|
||||||
|
result = getbuf4(iter);
|
||||||
/*
|
|
||||||
* 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)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto ioctl_failure;
|
goto ioctl_failure;
|
||||||
|
|
||||||
@ -325,13 +356,13 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
|||||||
*/
|
*/
|
||||||
#ifdef HAVE_TRUCLUSTER
|
#ifdef HAVE_TRUCLUSTER
|
||||||
iter->clua_context = -1;
|
iter->clua_context = -1;
|
||||||
|
iter->clua_done = ISC_TRUE;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
iter->proc = fopen("/proc/net/if_inet6", "r");
|
iter->proc = fopen("/proc/net/if_inet6", "r");
|
||||||
iter->valid = ISC_R_FAILURE;
|
iter->valid = ISC_R_FAILURE;
|
||||||
iter->first = ISC_FALSE;
|
iter->first = ISC_FALSE;
|
||||||
#endif
|
#endif
|
||||||
iter->pos = (unsigned int) -1;
|
|
||||||
iter->result = ISC_R_FAILURE;
|
iter->result = ISC_R_FAILURE;
|
||||||
|
|
||||||
iter->magic = IFITER_MAGIC;
|
iter->magic = IFITER_MAGIC;
|
||||||
@ -344,6 +375,15 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
|||||||
(void) close(iter->socket);
|
(void) close(iter->socket);
|
||||||
|
|
||||||
socket_failure:
|
socket_failure:
|
||||||
|
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||||
|
if (iter->buf6 != NULL)
|
||||||
|
isc_mem_put(mctx, iter->buf6, iter->bufsize6);
|
||||||
|
ioctl6_failure:
|
||||||
|
if (iter->socket6 != -1)
|
||||||
|
(void) close(iter->socket6);
|
||||||
|
socket6_failure:
|
||||||
|
#endif
|
||||||
|
|
||||||
isc_mem_put(mctx, iter, sizeof(*iter));
|
isc_mem_put(mctx, iter, sizeof(*iter));
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
@ -357,21 +397,17 @@ get_inaddr(isc_netaddr_t *dst, struct in_addr *src) {
|
|||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
internal_current_clusteralias(isc_interfaceiter_t *iter) {
|
internal_current_clusteralias(isc_interfaceiter_t *iter) {
|
||||||
struct sockaddr sa;
|
|
||||||
struct clua_info ci;
|
struct clua_info ci;
|
||||||
while (clua_getaliasaddress(&sa, &iter->clua_context) == CLUA_SUCCESS) {
|
if (clua_getaliasinfo(&iter->clua_sa, &ci) != CLUA_SUCCESS)
|
||||||
if (clua_getaliasinfo(&sa, &ci) != CLUA_SUCCESS)
|
return (ISC_R_IGNORE);
|
||||||
continue;
|
memset(&iter->current, 0, sizeof(iter->current));
|
||||||
memset(&iter->current, 0, sizeof(iter->current));
|
iter->current.af = iter->clua_sa.sa_family;
|
||||||
iter->current.af = sa.sa_family;
|
memset(iter->current.name, 0, sizeof(iter->current.name));
|
||||||
memset(iter->current.name, 0, sizeof(iter->current.name));
|
sprintf(iter->current.name, "clua%d", ci.aliasid);
|
||||||
sprintf(iter->current.name, "clua%d", ci.aliasid);
|
iter->current.flags = INTERFACE_F_UP;
|
||||||
iter->current.flags = INTERFACE_F_UP;
|
get_inaddr(&iter->current.address, &ci.addr);
|
||||||
get_inaddr(&iter->current.address, &ci.addr);
|
get_inaddr(&iter->current.netmask, &ci.netmask);
|
||||||
get_inaddr(&iter->current.netmask, &ci.netmask);
|
return (ISC_R_SUCCESS);
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
}
|
|
||||||
return (ISC_R_NOMORE);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -459,10 +495,12 @@ internal_current4(isc_interfaceiter_t *iter) {
|
|||||||
struct ifreq ifreq;
|
struct ifreq ifreq;
|
||||||
int family;
|
int family;
|
||||||
char strbuf[ISC_STRERRORSIZE];
|
char strbuf[ISC_STRERRORSIZE];
|
||||||
#if !defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
#if !defined(ISC_PLATFORM_HAVEIF_LADDRREQ) && defined(SIOCGLIFADDR)
|
||||||
struct if_laddrreq if_laddrreq;
|
struct lifreq lifreq;
|
||||||
int i, bits;
|
#else
|
||||||
|
char sabuf[256];
|
||||||
#endif
|
#endif
|
||||||
|
int i, bits, prefixlen;
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
#endif
|
#endif
|
||||||
@ -483,8 +521,7 @@ internal_current4(isc_interfaceiter_t *iter) {
|
|||||||
memcpy(&ifreq, ifrp, sizeof(ifreq));
|
memcpy(&ifreq, ifrp, sizeof(ifreq));
|
||||||
|
|
||||||
family = ifreq.ifr_addr.sa_family;
|
family = ifreq.ifr_addr.sa_family;
|
||||||
#if !defined (SIOCGLIFCONF) && defined(SIOCGLIFADDR) && \
|
#if defined(ISC_PLATFORM_HAVEIPV6)
|
||||||
defined(ISC_PLATFORM_HAVEIPV6)
|
|
||||||
if (family != AF_INET && family != AF_INET6)
|
if (family != AF_INET && family != AF_INET6)
|
||||||
#else
|
#else
|
||||||
if (family != AF_INET)
|
if (family != AF_INET)
|
||||||
@ -499,7 +536,7 @@ internal_current4(isc_interfaceiter_t *iter) {
|
|||||||
memcpy(iter->current.name, ifreq.ifr_name, sizeof(ifreq.ifr_name));
|
memcpy(iter->current.name, ifreq.ifr_name, sizeof(ifreq.ifr_name));
|
||||||
|
|
||||||
get_addr(family, &iter->current.address,
|
get_addr(family, &iter->current.address,
|
||||||
(struct sockaddr *)&ifrp->ifr_addr);
|
(struct sockaddr *)&ifrp->ifr_addr, ifreq.ifr_name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the interface does not have a address ignore it.
|
* If the interface does not have a address ignore it.
|
||||||
@ -546,42 +583,53 @@ internal_current4(isc_interfaceiter_t *iter) {
|
|||||||
if ((ifreq.ifr_flags & IFF_LOOPBACK) != 0)
|
if ((ifreq.ifr_flags & IFF_LOOPBACK) != 0)
|
||||||
iter->current.flags |= INTERFACE_F_LOOPBACK;
|
iter->current.flags |= INTERFACE_F_LOOPBACK;
|
||||||
|
|
||||||
#if !defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
if (family == AF_INET)
|
||||||
if (family == AF_INET)
|
|
||||||
goto inet;
|
goto inet;
|
||||||
|
|
||||||
memset(&if_laddrreq, 0, sizeof(if_laddrreq));
|
#if !defined(ISC_PLATFORM_HAVEIF_LADDRREQ) && defined(SIOCGLIFADDR)
|
||||||
memcpy(if_laddrreq.iflr_name, iter->current.name,
|
memset(&lifreq, 0, sizeof(lifreq));
|
||||||
sizeof(if_laddrreq.iflr_name));
|
memcpy(lifreq.lifr_name, iter->current.name, sizeof(lifreq.lifr_name));
|
||||||
memcpy(&if_laddrreq.addr, &iter->current.address.type.in6,
|
memcpy(&lifreq.lifr_addr, &iter->current.address.type.in6,
|
||||||
sizeof(iter->current.address.type.in6));
|
sizeof(iter->current.address.type.in6));
|
||||||
|
|
||||||
if (ioctl(iter->socket, SIOCGLIFADDR, &if_laddrreq) < 0) {
|
if (ioctl(iter->socket, SIOCGLIFADDR, &lifreq) < 0) {
|
||||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
"%s: getting interface address: %s",
|
"%s: getting interface address: %s",
|
||||||
ifreq.ifr_name, strbuf);
|
ifreq.ifr_name, strbuf);
|
||||||
return (ISC_R_IGNORE);
|
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,
|
||||||
|
ISC_LOG_INFO,
|
||||||
|
isc_msgcat_get(isc_msgcat,
|
||||||
|
ISC_MSGSET_IFITERIOCTL,
|
||||||
|
ISC_MSG_GETIFCONFIG,
|
||||||
|
"prefix length for %s is unknown "
|
||||||
|
"(assume 128)"), sabuf);
|
||||||
|
prefixlen = 128;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Netmask already zeroed.
|
* Netmask already zeroed.
|
||||||
*/
|
*/
|
||||||
iter->current.netmask.family = family;
|
iter->current.netmask.family = family;
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
if (if_laddrreq.prefixlen > 8) {
|
if (prefixlen > 8) {
|
||||||
bits = 0;
|
bits = 0;
|
||||||
if_laddrreq.prefixlen -= 8;
|
prefixlen -= 8;
|
||||||
} else {
|
} else {
|
||||||
bits = 8 - if_laddrreq.prefixlen;
|
bits = 8 - prefixlen;
|
||||||
if_laddrreq.prefixlen = 0;
|
prefixlen = 0;
|
||||||
}
|
}
|
||||||
iter->current.netmask.type.in6.s6_addr[i] = (~0 << bits) & 0xff;
|
iter->current.netmask.type.in6.s6_addr[i] = (~0 << bits) & 0xff;
|
||||||
}
|
}
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
|
|
||||||
inet:
|
inet:
|
||||||
#endif
|
|
||||||
if (family != AF_INET)
|
if (family != AF_INET)
|
||||||
return (ISC_R_IGNORE);
|
return (ISC_R_IGNORE);
|
||||||
#ifdef IFF_POINTTOPOINT
|
#ifdef IFF_POINTTOPOINT
|
||||||
@ -607,7 +655,7 @@ internal_current4(isc_interfaceiter_t *iter) {
|
|||||||
return (ISC_R_IGNORE);
|
return (ISC_R_IGNORE);
|
||||||
}
|
}
|
||||||
get_addr(family, &iter->current.dstaddress,
|
get_addr(family, &iter->current.dstaddress,
|
||||||
(struct sockaddr *)&ifreq.ifr_dstaddr);
|
(struct sockaddr *)&ifreq.ifr_dstaddr, ireq.ifr_name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -633,16 +681,13 @@ internal_current4(isc_interfaceiter_t *iter) {
|
|||||||
return (ISC_R_IGNORE);
|
return (ISC_R_IGNORE);
|
||||||
}
|
}
|
||||||
get_addr(family, &iter->current.netmask,
|
get_addr(family, &iter->current.netmask,
|
||||||
(struct sockaddr *)&ifreq.ifr_addr);
|
(struct sockaddr *)&ifreq.ifr_addr, ifreq.ifr_name);
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
internal_current6(isc_interfaceiter_t *iter) {
|
internal_current6(isc_interfaceiter_t *iter) {
|
||||||
#if !defined(SIOCGLIFCONF) || !defined(SIOCGLIFADDR)
|
|
||||||
UNUSED(iter);
|
|
||||||
return (ISC_R_NOTIMPLEMENTED);
|
|
||||||
#else
|
|
||||||
struct LIFREQ *ifrp;
|
struct LIFREQ *ifrp;
|
||||||
struct LIFREQ lifreq;
|
struct LIFREQ lifreq;
|
||||||
int family;
|
int family;
|
||||||
@ -650,9 +695,11 @@ internal_current6(isc_interfaceiter_t *iter) {
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
REQUIRE(VALID_IFITER(iter));
|
REQUIRE(VALID_IFITER(iter));
|
||||||
REQUIRE (iter->pos < (unsigned int) iter->lifc.lifc_len);
|
if (iter->result6 != ISC_R_SUCCESS)
|
||||||
|
return (iter->result6);
|
||||||
|
REQUIRE(iter->pos6 < (unsigned int) iter->lifc.lifc_len);
|
||||||
|
|
||||||
ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos);
|
ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos6);
|
||||||
|
|
||||||
memset(&lifreq, 0, sizeof(lifreq));
|
memset(&lifreq, 0, sizeof(lifreq));
|
||||||
memcpy(&lifreq, ifrp, sizeof(lifreq));
|
memcpy(&lifreq, ifrp, sizeof(lifreq));
|
||||||
@ -673,7 +720,7 @@ internal_current6(isc_interfaceiter_t *iter) {
|
|||||||
memcpy(iter->current.name, lifreq.lifr_name, sizeof(lifreq.lifr_name));
|
memcpy(iter->current.name, lifreq.lifr_name, sizeof(lifreq.lifr_name));
|
||||||
|
|
||||||
get_addr(family, &iter->current.address,
|
get_addr(family, &iter->current.address,
|
||||||
(struct sockaddr *)&lifreq.lifr_addr);
|
(struct sockaddr *)&lifreq.lifr_addr, lifreq.lifr_name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the interface does not have a address ignore it.
|
* If the interface does not have a address ignore it.
|
||||||
@ -696,14 +743,10 @@ internal_current6(isc_interfaceiter_t *iter) {
|
|||||||
|
|
||||||
iter->current.flags = 0;
|
iter->current.flags = 0;
|
||||||
|
|
||||||
fd = socket(family, SOCK_DGRAM, 0);
|
if (family == AF_INET6)
|
||||||
if (fd < 0) {
|
fd = iter->socket6;
|
||||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
else
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
fd = iter->socket;
|
||||||
"%s: socket: %s",
|
|
||||||
lifreq.lifr_name, strbuf);
|
|
||||||
return (ISC_R_IGNORE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ignore the HP/UX warning about "interger overflow during
|
* Ignore the HP/UX warning about "interger overflow during
|
||||||
@ -715,7 +758,6 @@ internal_current6(isc_interfaceiter_t *iter) {
|
|||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
"%s: getting interface flags: %s",
|
"%s: getting interface flags: %s",
|
||||||
lifreq.lifr_name, strbuf);
|
lifreq.lifr_name, strbuf);
|
||||||
close(fd);
|
|
||||||
return (ISC_R_IGNORE);
|
return (ISC_R_IGNORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,47 +789,28 @@ internal_current6(isc_interfaceiter_t *iter) {
|
|||||||
"%s: getting "
|
"%s: getting "
|
||||||
"destination address: %s"),
|
"destination address: %s"),
|
||||||
lifreq.lifr_name, strbuf);
|
lifreq.lifr_name, strbuf);
|
||||||
close(fd);
|
|
||||||
return (ISC_R_IGNORE);
|
return (ISC_R_IGNORE);
|
||||||
}
|
}
|
||||||
get_addr(family, &iter->current.dstaddress,
|
get_addr(family, &iter->current.dstaddress,
|
||||||
(struct sockaddr *)&lifreq.lifr_dstaddr);
|
(struct sockaddr *)&lifreq.lifr_dstaddr,
|
||||||
|
lifreq.lifr_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the network mask.
|
* Get the network mask. Netmask already zeroed.
|
||||||
*/
|
*/
|
||||||
memset(&lifreq, 0, sizeof(lifreq));
|
memset(&lifreq, 0, sizeof(lifreq));
|
||||||
memcpy(&lifreq, ifrp, sizeof(lifreq));
|
memcpy(&lifreq, ifrp, sizeof(lifreq));
|
||||||
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(fd, SIOCGLIFNETMASK, (char *)&lifreq)
|
|
||||||
< 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"),
|
|
||||||
lifreq.lifr_name, strbuf);
|
|
||||||
close(fd);
|
|
||||||
return (ISC_R_IGNORE);
|
|
||||||
}
|
|
||||||
get_addr(family, &iter->current.netmask,
|
|
||||||
(struct sockaddr *)&lifreq.lifr_addr);
|
|
||||||
break;
|
|
||||||
case AF_INET6: {
|
|
||||||
#ifdef lifr_addrlen
|
#ifdef lifr_addrlen
|
||||||
|
/*
|
||||||
|
* Special case: if the system provides lifr_addrlen member, the
|
||||||
|
* netmask of an IPv6 address can be derived from the length, since
|
||||||
|
* an IPv6 address always has a contiguous mask.
|
||||||
|
*/
|
||||||
|
if (family == AF_INET6) {
|
||||||
int i, bits;
|
int i, bits;
|
||||||
|
|
||||||
/*
|
|
||||||
* Netmask already zeroed.
|
|
||||||
*/
|
|
||||||
iter->current.netmask.family = family;
|
iter->current.netmask.family = family;
|
||||||
for (i = 0; i < lifreq.lifr_addrlen; i += 8) {
|
for (i = 0; i < lifreq.lifr_addrlen; i += 8) {
|
||||||
bits = lifreq.lifr_addrlen - i;
|
bits = lifreq.lifr_addrlen - i;
|
||||||
@ -795,20 +818,46 @@ internal_current6(isc_interfaceiter_t *iter) {
|
|||||||
iter->current.netmask.type.in6.s6_addr[i / 8] =
|
iter->current.netmask.type.in6.s6_addr[i / 8] =
|
||||||
(~0 << bits) & 0xff;
|
(~0 << bits) & 0xff;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
close(fd);
|
return (ISC_R_SUCCESS);
|
||||||
return (ISC_R_SUCCESS);
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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(fd, SIOCGLIFNETMASK, (char *)&lifreq) < 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"),
|
||||||
|
lifreq.lifr_name, strbuf);
|
||||||
|
return (ISC_R_IGNORE);
|
||||||
|
}
|
||||||
|
get_addr(family, &iter->current.netmask,
|
||||||
|
(struct sockaddr *)&lifreq.lifr_addr, lifreq.lifr_name);
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
internal_current(isc_interfaceiter_t *iter) {
|
internal_current(isc_interfaceiter_t *iter) {
|
||||||
if (iter->mode == 6)
|
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||||
return (internal_current6(iter));
|
if (iter->mode == 6) {
|
||||||
|
iter->result6 = internal_current6(iter);
|
||||||
|
if (iter->result6 != ISC_R_NOMORE)
|
||||||
|
return (iter->result6);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_TRUCLUSTER
|
||||||
|
if (!iter->clua_done)
|
||||||
|
return(internal_current_clusteralias(iter));
|
||||||
|
#endif
|
||||||
return (internal_current4(iter));
|
return (internal_current4(iter));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -825,10 +874,6 @@ internal_next4(isc_interfaceiter_t *iter) {
|
|||||||
|
|
||||||
REQUIRE (iter->pos < (unsigned int) iter->ifc.ifc_len);
|
REQUIRE (iter->pos < (unsigned int) iter->ifc.ifc_len);
|
||||||
|
|
||||||
#ifdef HAVE_TRUCLUSTER
|
|
||||||
if (internal_current_clusteralias(iter) == ISC_R_SUCCESS)
|
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
#endif
|
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
if (linux_if_inet6_next(iter) == ISC_R_SUCCESS)
|
if (linux_if_inet6_next(iter) == ISC_R_SUCCESS)
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
@ -850,42 +895,70 @@ internal_next4(isc_interfaceiter_t *iter) {
|
|||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
internal_next6(isc_interfaceiter_t *iter) {
|
internal_next6(isc_interfaceiter_t *iter) {
|
||||||
#if !defined(SIOCGLIFCONF) || !defined(SIOCGLIFADDR)
|
|
||||||
UNUSED(iter);
|
|
||||||
return (ISC_R_NOTIMPLEMENTED);
|
|
||||||
#else
|
|
||||||
struct LIFREQ *ifrp;
|
struct LIFREQ *ifrp;
|
||||||
|
|
||||||
|
if (iter->result6 != ISC_R_SUCCESS && iter->result6 != ISC_R_IGNORE)
|
||||||
|
return (iter->result6);
|
||||||
|
|
||||||
REQUIRE (iter->pos < (unsigned int) iter->lifc.lifc_len);
|
REQUIRE(iter->pos6 < (unsigned int) iter->lifc.lifc_len);
|
||||||
|
|
||||||
ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos);
|
ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos6);
|
||||||
|
|
||||||
#ifdef ISC_PLATFORM_HAVESALEN
|
#ifdef ISC_PLATFORM_HAVESALEN
|
||||||
if (ifrp->lifr_addr.sa_len > sizeof(struct sockaddr))
|
if (ifrp->lifr_addr.sa_len > sizeof(struct sockaddr))
|
||||||
iter->pos += sizeof(ifrp->lifr_name) + ifrp->lifr_addr.sa_len;
|
iter->pos6 += sizeof(ifrp->lifr_name) + ifrp->lifr_addr.sa_len;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
iter->pos += sizeof(*ifrp);
|
iter->pos6 += sizeof(*ifrp);
|
||||||
|
|
||||||
if (iter->pos >= (unsigned int) iter->lifc.lifc_len)
|
if (iter->pos6 >= (unsigned int) iter->lifc.lifc_len)
|
||||||
return (ISC_R_NOMORE);
|
return (ISC_R_NOMORE);
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
internal_next(isc_interfaceiter_t *iter) {
|
internal_next(isc_interfaceiter_t *iter) {
|
||||||
if (iter->mode == 6)
|
#ifdef HAVE_TRUCLUSTER
|
||||||
return (internal_next6(iter));
|
int clua_result;
|
||||||
|
#endif
|
||||||
|
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||||
|
if (iter->mode == 6) {
|
||||||
|
iter->result6 = internal_next6(iter);
|
||||||
|
if (iter->result6 != ISC_R_NOMORE)
|
||||||
|
return (iter->result6);
|
||||||
|
if (iter->first6) {
|
||||||
|
iter->first6 = ISC_FALSE;
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_TRUCLUSTER
|
||||||
|
if (!iter->clua_done) {
|
||||||
|
clua_result = clua_getaliasaddress(&intr->clua_sa,
|
||||||
|
&iter->clua_context);
|
||||||
|
if (clua_result != CLUA_SUCCESS)
|
||||||
|
iter->clua_done = ISC_TRUE;
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return (internal_next4(iter));
|
return (internal_next4(iter));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
internal_destroy(isc_interfaceiter_t *iter) {
|
internal_destroy(isc_interfaceiter_t *iter) {
|
||||||
(void) close(iter->socket);
|
(void) close(iter->socket);
|
||||||
|
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||||
|
if (iter->socket6 != -1)
|
||||||
|
(void) close(iter->socket6);
|
||||||
|
if (iter->buf6 != NULL) {
|
||||||
|
isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
if (iter->proc != NULL)
|
if (iter->proc != NULL)
|
||||||
fclose(iter->proc);
|
fclose(iter->proc);
|
||||||
@ -894,9 +967,21 @@ internal_destroy(isc_interfaceiter_t *iter) {
|
|||||||
|
|
||||||
static
|
static
|
||||||
void internal_first(isc_interfaceiter_t *iter) {
|
void internal_first(isc_interfaceiter_t *iter) {
|
||||||
|
#ifdef HAVE_TRUCLUSTER
|
||||||
|
int clua_result;
|
||||||
|
#endif
|
||||||
iter->pos = 0;
|
iter->pos = 0;
|
||||||
|
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||||
|
iter->pos6 = 0;
|
||||||
|
if (iter->result6 == ISC_R_NOMORE)
|
||||||
|
iter->result6 = ISC_R_SUCCESS;
|
||||||
|
iter->first6 = ISC_TRUE;
|
||||||
|
#endif
|
||||||
#ifdef HAVE_TRUCLUSTER
|
#ifdef HAVE_TRUCLUSTER
|
||||||
iter->clua_context = 0;
|
iter->clua_context = 0;
|
||||||
|
clua_result = clua_getaliasaddress(&intr->clua_sa,
|
||||||
|
&iter->clua_context);
|
||||||
|
iter->clua_done = ISC_TF(clua_result != CLUA_SUCCESS);
|
||||||
#endif
|
#endif
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
linux_if_inet6_first(iter);
|
linux_if_inet6_first(iter);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: ifiter_sysctl.c,v 1.18 2003/02/24 01:46:11 marka Exp $ */
|
/* $Id: ifiter_sysctl.c,v 1.19 2003/10/07 03:34:30 marka Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Obtain the list of network interfaces using sysctl.
|
* Obtain the list of network interfaces using sysctl.
|
||||||
@ -243,14 +243,17 @@ internal_current(isc_interfaceiter_t *iter) {
|
|||||||
|
|
||||||
iter->current.af = family;
|
iter->current.af = family;
|
||||||
|
|
||||||
get_addr(family, &iter->current.address, addr_sa);
|
get_addr(family, &iter->current.address, addr_sa,
|
||||||
|
iter->current.name);
|
||||||
|
|
||||||
if (mask_sa != NULL)
|
if (mask_sa != NULL)
|
||||||
get_addr(family, &iter->current.netmask, mask_sa);
|
get_addr(family, &iter->current.netmask, mask_sa,
|
||||||
|
iter->current.name);
|
||||||
|
|
||||||
if (dst_sa != NULL &&
|
if (dst_sa != NULL &&
|
||||||
(iter->current.flags & IFF_POINTOPOINT) != 0)
|
(iter->current.flags & IFF_POINTOPOINT) != 0)
|
||||||
get_addr(family, &iter->current.dstaddress, dst_sa);
|
get_addr(family, &iter->current.dstaddress, dst_sa,
|
||||||
|
iter->current.name);
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: interfaceiter.c,v 1.33 2003/04/01 05:18:22 marka Exp $ */
|
/* $Id: interfaceiter.c,v 1.34 2003/10/07 03:34:30 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -60,7 +60,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src) {
|
get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
|
||||||
|
char *ifname)
|
||||||
|
{
|
||||||
struct sockaddr_in6 *sa6;
|
struct sockaddr_in6 *sa6;
|
||||||
|
|
||||||
/* clear any remaining value for safety */
|
/* clear any remaining value for safety */
|
||||||
@ -93,16 +95,31 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src) {
|
|||||||
* we only consider unicast link-local addresses.
|
* we only consider unicast link-local addresses.
|
||||||
*/
|
*/
|
||||||
if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr)) {
|
if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr)) {
|
||||||
isc_uint16_t zone;
|
isc_uint16_t zone16;
|
||||||
|
|
||||||
memcpy(&zone, &sa6->sin6_addr.s6_addr[2],
|
memcpy(&zone16, &sa6->sin6_addr.s6_addr[2],
|
||||||
sizeof(zone));
|
sizeof(zone16));
|
||||||
zone = ntohs(zone);
|
zone16 = ntohs(zone16);
|
||||||
if (zone != 0) { /* the zone ID is embedded */
|
if (zone16 != 0) {
|
||||||
|
/* the zone ID is embedded */
|
||||||
isc_netaddr_setzone(dst,
|
isc_netaddr_setzone(dst,
|
||||||
(isc_uint32_t)zone);
|
(isc_uint32_t)zone16);
|
||||||
dst->type.in6.s6_addr[2] = 0;
|
dst->type.in6.s6_addr[2] = 0;
|
||||||
dst->type.in6.s6_addr[3] = 0;
|
dst->type.in6.s6_addr[3] = 0;
|
||||||
|
} else if (ifname != NULL) {
|
||||||
|
unsigned int zone;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sin6_scope_id is still not provided,
|
||||||
|
* but the corresponding interface name
|
||||||
|
* is know. Use the interface ID as
|
||||||
|
* the link ID.
|
||||||
|
*/
|
||||||
|
zone = if_nametoindex(ifname);
|
||||||
|
if (zone != 0) {
|
||||||
|
isc_netaddr_setzone(dst,
|
||||||
|
(isc_uint32_t)zone);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user