ifiter_ioctl.c revision 91c49d591c79159a965adb9d78c03cc2f334991e
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * Copyright (C) 1999 Internet Software Consortium.
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * Permission to use, copy, modify, and distribute this software for any
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * purpose with or without fee is hereby granted, provided that the above
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * copyright notice and this permission notice appear in all copies.
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence * Obtain the list of network interfaces using the SIOCGIFCONF ioctl.
ae302c18c296f31c02efb613887f206894caa749David Lawrence * See netintro(4).
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff#define VALID_IFITER(t) ((t) != NULL && (t)->magic == IFITER_MAGIC)
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff SIOCGIFCONF data */
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff isc_interface_t current; /* Current interface data. */
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * Size of buffer for SIOCGIFCONF, in bytes. We assume no sane system
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * will have more than a megabyte of interface configuration data.
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graffisc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp)
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff /* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff "making interface scan socket: %s",
890fb60939f93161ca0c63e19c7154eaf3fed156Michael Graff * Get the interface configuration, allocating more memory if
goto alloc_failure;
goto ioctl_failure;
goto ioctl_failure;
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
int family;
return (ISC_R_FAILURE);
return (ISC_R_UNEXPECTED);
return (ISC_R_UNEXPECTED);
return (ISC_R_UNEXPECTED);
return (ISC_R_SUCCESS);
static isc_result_t
#ifdef ISC_PLATFORM_HAVESALEN
return (ISC_R_NOMORE);
return (ISC_R_SUCCESS);