summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c
diff options
context:
space:
mode:
authorjakob <jakob@openbsd.org>2004-09-28 16:32:07 +0000
committerjakob <jakob@openbsd.org>2004-09-28 16:32:07 +0000
commitfaa7e856a16b326b2afee3ddb8d19f2f91f85161 (patch)
treea66b6d52d6af5dba140eb36c266ce2cc83b741f9 /usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c
parentsync (oops) (diff)
downloadwireguard-openbsd-faa7e856a16b326b2afee3ddb8d19f2f91f85161.tar.xz
wireguard-openbsd-faa7e856a16b326b2afee3ddb8d19f2f91f85161.zip
ISC BIND version 9.3.0. ok deraadt@
Diffstat (limited to 'usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c')
-rw-r--r--usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c b/usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c
index 3d0aa6606bc..70ffa64fdb4 100644
--- a/usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c
+++ b/usr.sbin/bind/lib/isc/unix/ifiter_sysctl.c
@@ -1,21 +1,21 @@
/*
- * Copyright (C) 1999-2001 Internet Software Consortium.
+ * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
- * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
- * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
- * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
*/
-/* $ISC: ifiter_sysctl.c,v 1.14 2001/06/04 19:33:34 tale Exp $ */
+/* $ISC: ifiter_sysctl.c,v 1.14.12.7 2004/03/08 09:04:56 marka Exp $ */
/*
* Obtain the list of network interfaces using sysctl.
@@ -69,6 +69,8 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
isc_result_t result;
size_t bufsize;
size_t bufused;
+ char strbuf[ISC_STRERRORSIZE];
+
REQUIRE(mctx != NULL);
REQUIRE(iterp != NULL);
REQUIRE(*iterp == NULL);
@@ -85,13 +87,14 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
*/
bufsize = 0;
if (sysctl(mib, 6, NULL, &bufsize, NULL, (size_t) 0) < 0) {
+ isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_IFITERSYSCTL,
ISC_MSG_GETIFLISTSIZE,
"getting interface "
"list size: sysctl: %s"),
- strerror(errno));
+ strbuf);
result = ISC_R_UNEXPECTED;
goto failure;
}
@@ -105,13 +108,14 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
bufused = bufsize;
if (sysctl(mib, 6, iter->buf, &bufused, NULL, (size_t) 0) < 0) {
+ isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_IFITERSYSCTL,
ISC_MSG_GETIFLIST,
"getting interface list: "
"sysctl: %s"),
- strerror(errno));
+ strbuf);
result = ISC_R_UNEXPECTED;
goto failure;
}
@@ -132,7 +136,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
failure:
if (iter->buf != NULL)
isc_mem_put(mctx, iter->buf, iter->bufsize);
- isc_mem_put(mctx, iter, sizeof *iter);
+ isc_mem_put(mctx, iter, sizeof(*iter));
return (result);
}
@@ -234,19 +238,22 @@ internal_current(isc_interfaceiter_t *iter) {
return (ISC_R_IGNORE);
family = addr_sa->sa_family;
- if (family != AF_INET) /* XXX IP6 */
+ if (family != AF_INET && family != AF_INET6)
return (ISC_R_IGNORE);
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)
- get_addr(family, &iter->current.netmask, mask_sa);
+ get_addr(family, &iter->current.netmask, mask_sa,
+ iter->current.name);
if (dst_sa != NULL &&
(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);
} else {
@@ -288,3 +295,7 @@ internal_destroy(isc_interfaceiter_t *iter) {
*/
}
+static
+void internal_first(isc_interfaceiter_t *iter) {
+ iter->pos = 0;
+}