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.32 by ats, Fri Feb 13 15:24:16 2004 UTC vs.
Revision 1.36 by pajs, Fri Feb 13 18:54:29 2004 UTC

# Line 385 | Line 385 | network_iface_stat_t *get_network_iface_stats(int *ent
385   #ifdef ALLBSD
386          struct ifaddrs *net, *net_ptr;
387          struct ifmediareq ifmed;
388 +        struct ifreq ifr;
389          int s;
390          int x;
391   #endif
# Line 472 | Line 473 | network_iface_stat_t *get_network_iface_stats(int *ent
473                  }else{
474                          network_iface_stat_ptr->dup = UNKNOWN_DUPLEX;
475                  }
476 +
477 +                if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0){
478 +                        continue;
479 +                }      
480 +                if((ifr.ifr_flags & IFF_UP) != 0){
481 +                        network_iface_stat_ptr->up = 1;
482 +                }else{
483 +                        network_iface_stat_ptr->up = 0;
484 +                }
485 +
486                  ifaces++;
487          }      
488          freeifaddrs(net);
# Line 497 | Line 508 | network_iface_stat_t *get_network_iface_stats(int *ent
508                          network_iface_stat_ptr = network_iface_stats + ifaces;
509                          network_iface_stat_ptr->speed = knp->value.ui64 / (1000*1000);
510  
511 +                        if((knp=kstat_data_lookup(ksp, "link_up"))==NULL){
512 +                                /* Not a network interface, so skip to the next entry */
513 +                                continue;
514 +                        }
515 +                        /* Solaris has 1 for up, and 0 for not. As we do too */
516 +                        network_iface_stat_ptr->up = value.ui32;
517 +
518                          if((knp=kstat_data_lookup(ksp, "link_duplex"))==NULL){
519                                  /* Not a network interface, so skip to the next entry */
520                                  continue;
521                          }
522  
523 <                        if(knp->value.ui64 == 0){
523 >                        network_iface_stat_ptr->dup = UNKNOWN_DUPLEX;
524 >                        if(knp->value.ui32 == 2){
525                                  network_iface_stat_ptr->dup = FULL_DUPLEX;
526 <                        }else{
526 >                        }
527 >                        if(knp->value.ui32 == 1){
528                                  network_iface_stat_ptr->dup = HALF_DUPLEX;
529                          }
530  
# Line 576 | Line 596 | network_iface_stat_t *get_network_iface_stats(int *ent
596                  network_iface_stat_ptr = network_iface_stats + ifaces;
597                  network_iface_stat_ptr->interface_name = strdup(name);
598                  network_iface_stat_ptr->speed = ethcmd->speed;
599 +                if((ifr.ifr_flags & IFF_UP) != 0){
600 +                        network_iface_stat_ptr->up = 1;
601 +                }else{
602 +                        network_iface_stat_ptr->up = 0;
603 +                }
604 +
605                  network_iface_stat_ptr->dup = UNKNOWN_DUPLEX;
606                  if(ethcmd->duplex == 0x00){
607                          network_iface_stat_ptr->dup = FULL_DUPLEX;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines