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; |
465 |
|
break; |
466 |
|
} |
467 |
|
|
468 |
+ |
if((ifmr.ifm_status & IFM_ACTIVE)){ |
469 |
+ |
network_iface_stat_ptr->up = 1; |
470 |
+ |
}else{ |
471 |
+ |
network_iface_stat_ptr->up = 0; |
472 |
+ |
} |
473 |
+ |
|
474 |
|
if( (ifmed.ifm_active | IFM_FDX) == ifmed.ifm_active ){ |
475 |
|
network_iface_stat_ptr->dup = FULL_DUPLEX; |
476 |
|
}else if( (ifmed.ifm_active | IFM_HDX) == ifmed.ifm_active ){ |
477 |
|
network_iface_stat_ptr->dup = HALF_DUPLEX; |
478 |
|
}else{ |
479 |
< |
network_iface_stat_ptr->dup = NO_DUPLEX; |
479 |
> |
network_iface_stat_ptr->dup = UNKNOWN_DUPLEX; |
480 |
|
} |
481 |
|
ifaces++; |
482 |
|
} |
483 |
|
freeifaddrs(net); |
484 |
+ |
close(s); |
485 |
|
#endif |
486 |
|
|
487 |
|
#ifdef SOLARIS |
503 |
|
network_iface_stat_ptr = network_iface_stats + ifaces; |
504 |
|
network_iface_stat_ptr->speed = knp->value.ui64 / (1000*1000); |
505 |
|
|
506 |
+ |
if((knp=kstat_data_lookup(ksp, "link_up"))==NULL){ |
507 |
+ |
/* Not a network interface, so skip to the next entry */ |
508 |
+ |
continue; |
509 |
+ |
} |
510 |
+ |
/* Solaris has 1 for up, and 0 for not. As we do too */ |
511 |
+ |
network_iface_stat_ptr->up = value.ui32; |
512 |
+ |
|
513 |
|
if((knp=kstat_data_lookup(ksp, "link_duplex"))==NULL){ |
514 |
|
/* Not a network interface, so skip to the next entry */ |
515 |
|
continue; |
516 |
|
} |
517 |
|
|
518 |
< |
if(knp->value.ui64 == 0){ |
518 |
> |
network_iface_stat_ptr->dup = UNKNOWN_DUPLEX; |
519 |
> |
if(knp->value.ui32 == 2){ |
520 |
|
network_iface_stat_ptr->dup = FULL_DUPLEX; |
521 |
< |
}else{ |
521 |
> |
} |
522 |
> |
if(knp->value.ui32 == 1){ |
523 |
|
network_iface_stat_ptr->dup = HALF_DUPLEX; |
524 |
|
} |
525 |
|
|
549 |
|
if(eth_tool_cmd_buf == NULL) return NULL; |
550 |
|
|
551 |
|
/* Ignore first 2 lines.. Just headings */ |
552 |
< |
fgets(line, sizeof(line), f); |
553 |
< |
fgets(line, sizeof(line), f); |
552 |
> |
if((fgets(line, sizeof(line), f)) == NULL) return NULL; |
553 |
> |
if((fgets(line, sizeof(line), f)) == NULL) return NULL; |
554 |
|
|
555 |
|
while((fgets(line, sizeof(line), f)) != NULL){ |
556 |
|
char *name, *ptr; |
572 |
|
ifr.ifr_data = (caddr_t) eth_tool_cmd_buf; |
573 |
|
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); |
574 |
|
|
575 |
< |
ethcmd = (struct ethtool_cmd *)(&ifr)->ifr_data; |
575 |
> |
ethcmd = (struct ethtool_cmd *) ifr.ifr_data; |
576 |
|
ethcmd->cmd = ETHTOOL_GSET; |
577 |
|
|
578 |
|
err = ioctl(sock, SIOCETHTOOL, &ifr); |
591 |
|
network_iface_stat_ptr = network_iface_stats + ifaces; |
592 |
|
network_iface_stat_ptr->interface_name = strdup(name); |
593 |
|
network_iface_stat_ptr->speed = ethcmd->speed; |
594 |
< |
network_iface_stat_ptr->dup = NO_DUPLEX; |
594 |
> |
if((ifr.ifr_flags & IFF_UP) != 0){ |
595 |
> |
network_iface_stat_ptr->up = 1; |
596 |
> |
}else{ |
597 |
> |
network_iface_stat_ptr->up = 0; |
598 |
> |
} |
599 |
> |
|
600 |
> |
network_iface_stat_ptr->dup = UNKNOWN_DUPLEX; |
601 |
|
if(ethcmd->duplex == 0x00){ |
602 |
|
network_iface_stat_ptr->dup = FULL_DUPLEX; |
603 |
|
} |
606 |
|
} |
607 |
|
ifaces++; |
608 |
|
} |
609 |
< |
|
609 |
> |
close(sock); |
610 |
|
free(eth_tool_cmd_buf); |
611 |
|
#endif |
612 |
|
*entries = ifaces; |