ifiter_sysctl.c revision 499b34cea04a46823d003d4c0520c8b03e8513cb
/*
* Copyright (C) 1999-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* 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 INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM 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.12 2001/01/09 21:58:20 bwelling Exp $ */
/*
* 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. */
};
return (ISC_R_NOMEMORY);
/*
* Determine the amount of memory needed.
*/
bufsize = 0;
"getting interface "
"list size: sysctl: %s"),
goto failure;
}
goto failure;
}
"getting interface list: "
"sysctl: %s"),
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 {
"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.
*/
}