Merge branch 'sigar-1.6'

This commit is contained in:
Doug MacEachern 2009-05-24 18:19:15 -07:00
commit 099f021675
1 changed files with 31 additions and 5 deletions

View File

@ -2456,6 +2456,26 @@ static int sigar_ifmsg_init(sigar_t *sigar)
return SIGAR_OK;
}
static int has_ifaddr(char *name)
{
int sock, status;
struct ifreq ifr;
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
return errno;
}
SIGAR_SSTRCPY(ifr.ifr_name, name);
if (ioctl(sock, SIOCGIFADDR, &ifr) == 0) {
status = SIGAR_OK;
}
else {
status = errno;
}
close(sock);
return status;
}
static int sigar_ifmsg_iter(sigar_t *sigar, ifmsg_iter_t *iter)
{
char *end = sigar->ifconf_buf + sigar->ifconf_len;
@ -2490,14 +2510,20 @@ static int sigar_ifmsg_iter(sigar_t *sigar, ifmsg_iter_t *iter)
if (sdl->sdl_family != AF_LINK) {
continue;
}
if (!((sdl->sdl_type == IFT_ETHER) ||
(sdl->sdl_type == IFT_LOOP)))
{
continue; /* XXX deal w/ other weirdo interfaces */
}
switch (iter->type) {
case IFMSG_ITER_LIST:
if (sdl->sdl_type == IFT_OTHER) {
if (has_ifaddr(sdl->sdl_data) != SIGAR_OK) {
break;
}
}
else if (!((sdl->sdl_type == IFT_ETHER) ||
(sdl->sdl_type == IFT_LOOP)))
{
break; /* XXX deal w/ other weirdo interfaces */
}
SIGAR_NET_IFLIST_GROW(iter->data.iflist);
/* sdl_data doesn't include a trailing \0, it is only sdl_nlen long */