386 |
|
struct ifaddrs *net, *net_ptr; |
387 |
|
struct ifmediareq ifmed; |
388 |
|
struct ifreq ifr; |
389 |
< |
int s; |
389 |
> |
int sock; |
390 |
|
int x; |
391 |
|
#endif |
392 |
|
#ifdef LINUX |
403 |
|
return NULL; |
404 |
|
} |
405 |
|
|
406 |
< |
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == NULL) return NULL; |
406 |
> |
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == 0) return NULL; |
407 |
|
|
408 |
|
for(net_ptr=net; net_ptr!=NULL; net_ptr=net_ptr->ifa_next){ |
409 |
|
if(net_ptr->ifa_addr->sa_family != AF_LINK) continue; |
415 |
|
|
416 |
|
memset(&ifmed, 0, sizeof(struct ifmediareq)); |
417 |
|
strlcpy(ifmed.ifm_name, net_ptr->ifa_name, sizeof(ifmed.ifm_name)); |
418 |
< |
if(ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmed) == -1){ |
418 |
> |
if(ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifmed) == -1){ |
419 |
|
continue; |
420 |
|
} |
421 |
|
|
474 |
|
network_iface_stat_ptr->dup = UNKNOWN_DUPLEX; |
475 |
|
} |
476 |
|
|
477 |
+ |
memset(&ifr, 0, sizeof(ifr)); |
478 |
+ |
strncpy(ifr.ifr_name, net_ptr->ifa_name, sizeof(ifr.ifr_name)); |
479 |
+ |
|
480 |
|
if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0){ |
481 |
|
continue; |
482 |
|
} |
489 |
|
ifaces++; |
490 |
|
} |
491 |
|
freeifaddrs(net); |
492 |
< |
close(s); |
492 |
> |
close(sock); |
493 |
|
#endif |
494 |
|
|
495 |
|
#ifdef SOLARIS |