--- projects/libstatgrab/src/libstatgrab/network_stats.c 2004/02/13 18:54:29 1.36 +++ projects/libstatgrab/src/libstatgrab/network_stats.c 2004/02/14 00:08:51 1.37 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA * - * $Id: network_stats.c,v 1.36 2004/02/13 18:54:29 pajs Exp $ + * $Id: network_stats.c,v 1.37 2004/02/14 00:08:51 ats Exp $ */ #ifdef HAVE_CONFIG_H @@ -386,7 +386,7 @@ network_iface_stat_t *get_network_iface_stats(int *ent struct ifaddrs *net, *net_ptr; struct ifmediareq ifmed; struct ifreq ifr; - int s; + int sock; int x; #endif #ifdef LINUX @@ -403,7 +403,7 @@ network_iface_stat_t *get_network_iface_stats(int *ent return NULL; } - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == NULL) return NULL; + if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == 0) return NULL; for(net_ptr=net; net_ptr!=NULL; net_ptr=net_ptr->ifa_next){ if(net_ptr->ifa_addr->sa_family != AF_LINK) continue; @@ -415,7 +415,7 @@ network_iface_stat_t *get_network_iface_stats(int *ent memset(&ifmed, 0, sizeof(struct ifmediareq)); strlcpy(ifmed.ifm_name, net_ptr->ifa_name, sizeof(ifmed.ifm_name)); - if(ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmed) == -1){ + if(ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifmed) == -1){ continue; } @@ -474,6 +474,9 @@ network_iface_stat_t *get_network_iface_stats(int *ent network_iface_stat_ptr->dup = UNKNOWN_DUPLEX; } + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, net_ptr->ifa_name, sizeof(ifr.ifr_name)); + if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0){ continue; } @@ -486,7 +489,7 @@ network_iface_stat_t *get_network_iface_stats(int *ent ifaces++; } freeifaddrs(net); - close(s); + close(sock); #endif #ifdef SOLARIS