2
* Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
2
* Copyright (C) 2004, 2005, 2007-2009 Internet Systems Consortium, Inc. ("ISC")
3
3
* Copyright (C) 1999-2003 Internet Software Consortium.
5
5
* Permission to use, copy, modify, and/or distribute this software for any
153
161
#include "ifiter_ioctl.c"
166
linux_if_inet6_first(isc_interfaceiter_t *iter) {
167
if (iter->proc != NULL) {
169
(void)linux_if_inet6_next(iter);
171
iter->valid = ISC_R_NOMORE;
175
linux_if_inet6_next(isc_interfaceiter_t *iter) {
176
if (iter->proc != NULL &&
177
fgets(iter->entry, sizeof(iter->entry), iter->proc) != NULL)
178
iter->valid = ISC_R_SUCCESS;
180
iter->valid = ISC_R_NOMORE;
181
return (iter->valid);
185
linux_if_inet6_current(isc_interfaceiter_t *iter) {
187
char name[IF_NAMESIZE+1];
188
struct in6_addr addr6;
189
int ifindex, prefix, flag3, flag4;
193
if (iter->valid != ISC_R_SUCCESS)
194
return (iter->valid);
195
if (iter->proc == NULL) {
196
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
197
ISC_LOGMODULE_INTERFACE, ISC_LOG_ERROR,
198
"/proc/net/if_inet6:iter->proc == NULL");
199
return (ISC_R_FAILURE);
202
res = sscanf(iter->entry, "%32[a-f0-9] %x %x %x %x %16s\n",
203
address, &ifindex, &prefix, &flag3, &flag4, name);
205
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
206
ISC_LOGMODULE_INTERFACE, ISC_LOG_ERROR,
207
"/proc/net/if_inet6:sscanf() -> %d (expected 6)",
209
return (ISC_R_FAILURE);
211
if (strlen(address) != 32) {
212
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
213
ISC_LOGMODULE_INTERFACE, ISC_LOG_ERROR,
214
"/proc/net/if_inet6:strlen(%s) != 32", address);
215
return (ISC_R_FAILURE);
217
for (i = 0; i < 16; i++) {
219
static const char hex[] = "0123456789abcdef";
220
byte = ((strchr(hex, address[i * 2]) - hex) << 4) |
221
(strchr(hex, address[i * 2 + 1]) - hex);
222
addr6.s6_addr[i] = byte;
224
iter->current.af = AF_INET6;
225
iter->current.flags = INTERFACE_F_UP;
226
isc_netaddr_fromin6(&iter->current.address, &addr6);
227
if (isc_netaddr_islinklocal(&iter->current.address)) {
228
isc_netaddr_setzone(&iter->current.address,
229
(isc_uint32_t)ifindex);
231
for (i = 0; i < 16; i++) {
233
addr6.s6_addr[i] = 0xff;
236
addr6.s6_addr[i] = (0xff << (8 - prefix)) & 0xff;
240
isc_netaddr_fromin6(&iter->current.netmask, &addr6);
241
strncpy(iter->current.name, name, sizeof(iter->current.name));
242
return (ISC_R_SUCCESS);
157
247
* The remaining code is common to the sysctl and ioctl case.