ifiter_sysctl.c revision 3759f10fc543747668b1ca4b4671f35b0dea8445
/*
* Copyright (C) 2004, 2005, 2007, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* 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 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.
*/
/* $Id: ifiter_sysctl.c,v 1.25 2007/06/19 23:47:18 tbox Exp $ */
/*! \file
* \brief
* Obtain the list of network interfaces using sysctl.
* and 19.16.
*/
/* XXX what about Alpha? */
#ifdef sgi
#define ROUNDUP(a) ((a) > 0 ? \
sizeof(__uint64_t))
#else
: sizeof(long))
#endif
struct isc_interfaceiter {
unsigned int magic; /* Magic number. */
void *buf; /* Buffer for sysctl data. */
unsigned int bufsize; /* Bytes allocated. */
unsigned int bufused; /* Bytes used. */
unsigned int pos; /* Current offset in
sysctl data. */
};
static int mib[6] = {
0,
0, /* Any address family. */
0 /* Flags. */
};
char strbuf[ISC_STRERRORSIZE];
return (ISC_R_NOMEMORY);
/*
* Determine the amount of memory needed.
*/
bufsize = 0;
"getting interface "
"list size: sysctl: %s"),
strbuf);
goto failure;
}
goto failure;
}
"getting interface list: "
"sysctl: %s"),
strbuf);
goto failure;
}
/*
* A newly created iterator has an undefined position
* until isc_interfaceiter_first() is called.
*/
return (ISC_R_SUCCESS);
return (result);
}
/*
* Get information about the current interface to iter->current.
* If successful, return ISC_R_SUCCESS.
* If the interface has an unsupported address family,
* return ISC_R_IGNORE. In case of other failure,
* return ISC_R_UNEXPECTED.
*/
static isc_result_t
unsigned int namelen;
/*
* This is not an interface address.
* Force another iteration.
*/
return (ISC_R_IGNORE);
int i;
int family;
for (i = 0; i < RTAX_MAX; i++)
{
continue;
switch (i) {
case RTAX_NETMASK: /* Netmask */
break;
case RTAX_IFA: /* Interface address */
break;
case RTAX_BRD: /* Broadcast or destination address */
break;
}
#ifdef ISC_PLATFORM_HAVESALEN
#else
#ifdef sgi
/*
* Do as the contributed SGI code does.
*/
#else
/* XXX untested. */
#endif
#endif
}
return (ISC_R_IGNORE);
return (ISC_R_IGNORE);
return (ISC_R_SUCCESS);
} else {
printf("%s",
"warning: unexpected interface list "
"message type\n"));
return (ISC_R_IGNORE);
}
}
/*
* Step the iterator to the next interface. Unlike
* isc_interfaceiter_next(), this may leave the iterator
* positioned on an interface that will ultimately
* be ignored. Return ISC_R_NOMORE if there are no more
* interfaces, otherwise ISC_R_SUCCESS.
*/
static isc_result_t
struct ifa_msghdr *ifam;
return (ISC_R_NOMORE);
return (ISC_R_SUCCESS);
}
static void
/*
* Do nothing.
*/
}
static
}