ifiter_sysctl.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 1999-2005, 2007, 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_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
}