version 1.7, 2004/09/28 15:10:51 |
version 1.8, 2007/07/26 16:10:16 |
|
|
/* |
/* |
* Copyright (c) 1996, 1998-2003 Todd C. Miller <Todd.Miller@courtesan.com> |
* Copyright (c) 1996, 1998-2005 Todd C. Miller <Todd.Miller@courtesan.com> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
struct rtentry; |
struct rtentry; |
#endif |
#endif |
|
|
#include "config.h" |
#include <config.h> |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/socket.h> |
#include <sys/socket.h> |
|
|
# include "emul/err.h" |
# include "emul/err.h" |
#endif /* HAVE_ERR_H */ |
#endif /* HAVE_ERR_H */ |
#include <netdb.h> |
#include <netdb.h> |
|
#include <errno.h> |
#ifdef _ISC |
#ifdef _ISC |
# include <sys/stream.h> |
# include <sys/stream.h> |
# include <sys/sioctl.h> |
# include <sys/sioctl.h> |
|
|
#include "interfaces.h" |
#include "interfaces.h" |
|
|
#ifndef lint |
#ifndef lint |
static const char rcsid[] = "$Sudo: interfaces.c,v 1.72 2004/02/13 21:36:43 millert Exp $"; |
__unused static const char rcsid[] = "$Sudo: interfaces.c,v 1.72.2.4 2007/06/14 16:24:09 millert Exp $"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
|
|
|
|
#ifdef HAVE_FREEIFADDRS |
#ifdef HAVE_FREEIFADDRS |
freeifaddrs(ifaddrs); |
freeifaddrs(ifaddrs); |
#else |
#else |
free(ifaddrs); |
efree(ifaddrs); |
#endif |
#endif |
} |
} |
|
|
|
|
ifconf->ifc_len = len - sizeof(struct ifconf); |
ifconf->ifc_len = len - sizeof(struct ifconf); |
ifconf->ifc_buf = (caddr_t) (ifconf_buf + sizeof(struct ifconf)); |
ifconf->ifc_buf = (caddr_t) (ifconf_buf + sizeof(struct ifconf)); |
|
|
/* Networking may not be installed in kernel... */ |
|
#ifdef _ISC |
#ifdef _ISC |
STRSET(SIOCGIFCONF, (caddr_t) ifconf, len); |
STRSET(SIOCGIFCONF, (caddr_t) ifconf, len); |
if (ioctl(sock, I_STR, (caddr_t) &strioctl) < 0) { |
if (ioctl(sock, I_STR, (caddr_t) &strioctl) < 0) { |
#else |
#else |
if (ioctl(sock, SIOCGIFCONF, (caddr_t) ifconf) < 0) { |
/* Note that some kernels return EINVAL if the buffer is too small */ |
|
if (ioctl(sock, SIOCGIFCONF, (caddr_t) ifconf) < 0 && errno != EINVAL) { |
#endif /* _ISC */ |
#endif /* _ISC */ |
free(ifconf_buf); |
efree(ifconf_buf); |
(void) close(sock); |
(void) close(sock); |
return; |
return; |
} |
} |
|
|
interfaces = (struct interface *) erealloc3(interfaces, |
interfaces = (struct interface *) erealloc3(interfaces, |
num_interfaces, sizeof(struct interface)); |
num_interfaces, sizeof(struct interface)); |
else |
else |
free(interfaces); |
efree(interfaces); |
} |
} |
free(ifconf_buf); |
efree(ifconf_buf); |
(void) close(sock); |
(void) close(sock); |
} |
} |
|
|