50 |
|
typedef __uint32_t u32; |
51 |
|
#include <linux/ethtool.h> |
52 |
|
#include <linux/sockios.h> |
53 |
+ |
#include <unistd.h> |
54 |
|
#endif |
55 |
|
#ifdef ALLBSD |
56 |
|
#include <sys/types.h> |
340 |
|
for(net_stats+=start; start<end; start++){ |
341 |
|
net_stats->interface_name=NULL; |
342 |
|
net_stats->speed=0; |
343 |
< |
net_stats->dup=NO_DUPLEX; |
343 |
> |
net_stats->dup=UNKNOWN_DUPLEX; |
344 |
|
net_stats++; |
345 |
|
} |
346 |
|
} |
451 |
|
case(IFM_1000_SX): |
452 |
|
case(IFM_1000_LX): |
453 |
|
case(IFM_1000_CX): |
454 |
< |
#ifdef FREEBSD5 |
454 |
< |
case(IFM_1000_T): |
455 |
< |
#else |
454 |
> |
#if defined(FREEBSD) && !defined(FREEBSD5) |
455 |
|
case(IFM_1000_TX): |
456 |
|
case(IFM_1000_FX): |
457 |
+ |
#else |
458 |
+ |
case(IFM_1000_T): |
459 |
|
#endif |
460 |
|
network_iface_stat_ptr->speed = 1000; |
461 |
|
break; |
470 |
|
}else if( (ifmed.ifm_active | IFM_HDX) == ifmed.ifm_active ){ |
471 |
|
network_iface_stat_ptr->dup = HALF_DUPLEX; |
472 |
|
}else{ |
473 |
< |
network_iface_stat_ptr->dup = NO_DUPLEX; |
473 |
> |
network_iface_stat_ptr->dup = UNKNOWN_DUPLEX; |
474 |
|
} |
475 |
|
ifaces++; |
476 |
|
} |
477 |
|
freeifaddrs(net); |
478 |
+ |
close(s); |
479 |
|
#endif |
480 |
|
|
481 |
|
#ifdef SOLARIS |
502 |
|
continue; |
503 |
|
} |
504 |
|
|
505 |
< |
if(knp->value.ui64 == 0){ |
505 |
> |
network_iface_stat_ptr->dup = UNKNOWN_DUPLEX; |
506 |
> |
if(knp->value.ui32 == 2){ |
507 |
|
network_iface_stat_ptr->dup = FULL_DUPLEX; |
508 |
< |
}else{ |
508 |
> |
} |
509 |
> |
if(knp->value.ui32 == 1){ |
510 |
|
network_iface_stat_ptr->dup = HALF_DUPLEX; |
511 |
|
} |
512 |
|
|
536 |
|
if(eth_tool_cmd_buf == NULL) return NULL; |
537 |
|
|
538 |
|
/* Ignore first 2 lines.. Just headings */ |
539 |
< |
fgets(line, sizeof(line), f); |
540 |
< |
fgets(line, sizeof(line), f); |
539 |
> |
if((fgets(line, sizeof(line), f)) == NULL) return NULL; |
540 |
> |
if((fgets(line, sizeof(line), f)) == NULL) return NULL; |
541 |
|
|
542 |
|
while((fgets(line, sizeof(line), f)) != NULL){ |
543 |
|
char *name, *ptr; |
559 |
|
ifr.ifr_data = (caddr_t) eth_tool_cmd_buf; |
560 |
|
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); |
561 |
|
|
562 |
< |
ethcmd = (struct ethtool_cmd *)(&ifr)->ifr_data; |
562 |
> |
ethcmd = (struct ethtool_cmd *) ifr.ifr_data; |
563 |
|
ethcmd->cmd = ETHTOOL_GSET; |
564 |
|
|
565 |
|
err = ioctl(sock, SIOCETHTOOL, &ifr); |
578 |
|
network_iface_stat_ptr = network_iface_stats + ifaces; |
579 |
|
network_iface_stat_ptr->interface_name = strdup(name); |
580 |
|
network_iface_stat_ptr->speed = ethcmd->speed; |
581 |
< |
network_iface_stat_ptr->dup = NO_DUPLEX; |
581 |
> |
network_iface_stat_ptr->dup = UNKNOWN_DUPLEX; |
582 |
|
if(ethcmd->duplex == 0x00){ |
583 |
|
network_iface_stat_ptr->dup = FULL_DUPLEX; |
584 |
|
} |
587 |
|
} |
588 |
|
ifaces++; |
589 |
|
} |
590 |
< |
|
590 |
> |
close(sock); |
591 |
|
free(eth_tool_cmd_buf); |
592 |
|
#endif |
593 |
|
*entries = ifaces; |