ifiter_getifaddrs.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2003-2005, 2007-2009, 2014, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: ifiter_getifaddrs.c,v 1.13 2009/09/24 23:48:13 tbox Exp $ */
/*! \file
* \brief
* Obtain the list of network interfaces using the getifaddrs(3) library.
*/
#include <ifaddrs.h>
/*% Iterator Magic */
/*% Valid Iterator */
#ifdef __linux
#endif
/*% Iterator structure */
struct isc_interfaceiter {
unsigned int magic; /*%< Magic number. */
void *buf; /*%< (unused) */
unsigned int bufsize; /*%< (always 0) */
#ifdef __linux
char entry[ISC_IF_INET6_SZ];
#endif
};
char strbuf[ISC_STRERRORSIZE];
return (ISC_R_NOMEMORY);
#ifdef __linux
/*
* address returned by getifaddrs().
*/
if (!seenv6)
else
#endif
"getting interface "
"addresses: getifaddrs: %s"),
strbuf);
goto failure;
}
/*
* A newly created iterator has an undefined position
* until isc_interfaceiter_first() is called.
*/
return (ISC_R_SUCCESS);
#ifdef __linux
#endif
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.
*/
static isc_result_t
int family;
unsigned int namelen;
#ifdef __linux
return (linux_if_inet6_current(iter));
#endif
return (ISC_R_IGNORE);
return (ISC_R_IGNORE);
#ifdef __linux
#endif
return (ISC_R_SUCCESS);
}
/*
* 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
#ifdef __linux
if (!seenv6)
return (linux_if_inet6_next(iter));
#endif
return (ISC_R_NOMORE);
}
return (ISC_R_SUCCESS);
}
static void
#ifdef __linux
#endif
}
static
#ifdef __linux
#endif
}