ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/network_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/network_stats.c (file contents):
Revision 1.31 by ats, Fri Feb 13 15:12:26 2004 UTC vs.
Revision 1.35 by pajs, Fri Feb 13 18:45:43 2004 UTC

# Line 50 | Line 50 | typedef __uint16_t u16;
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>
# Line 464 | Line 465 | network_iface_stat_t *get_network_iface_stats(int *ent
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 ){
# Line 496 | Line 503 | network_iface_stat_t *get_network_iface_stats(int *ent
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  
# Line 575 | Line 591 | network_iface_stat_t *get_network_iface_stats(int *ent
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 = UNKNOWN_DUPEX;
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                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines