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.71 by ats, Mon Nov 8 08:07:25 2004 UTC vs.
Revision 1.74 by tdb, Wed Jul 13 09:31:54 2005 UTC

# Line 52 | Line 52
52   /* Stuff which could be defined by defining KERNEL, but
53   * that would be a bad idea, so we'll just declare it here
54   */
55 + #include <linux/version.h>
56 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
57 + typedef __uint8_t __u8;
58 + typedef __uint16_t __u16;
59 + typedef __uint32_t __u32;
60 + typedef __uint64_t __u64;
61 + #else
62   typedef __uint8_t u8;
63   typedef __uint16_t u16;
64   typedef __uint32_t u32;
65   typedef __uint64_t u64;
66 + #endif
67   #include <linux/ethtool.h>
68   #include <linux/sockios.h>
69   #include <unistd.h>
# Line 406 | Line 414 | int sg_network_io_compare_name(const void *va, const v
414   static void network_iface_stat_init(sg_network_iface_stats *s) {
415          s->interface_name = NULL;
416          s->speed = 0;
417 <        s->dup = SG_IFACE_DUPLEX_UNKNOWN;
417 >        s->duplex = SG_IFACE_DUPLEX_UNKNOWN;
418   }
419  
420   static void network_iface_stat_destroy(sg_network_iface_stats *s) {
# Line 473 | Line 481 | sg_network_iface_stats *sg_get_network_iface_stats(int
481                  }
482  
483                  network_iface_stat_ptr->speed = 0;
484 <                network_iface_stat_ptr->dup = SG_IFACE_DUPLEX_UNKNOWN;
484 >                network_iface_stat_ptr->duplex = SG_IFACE_DUPLEX_UNKNOWN;
485                  ifaces++;
486  
487                  memset(&ifmed, 0, sizeof(struct ifmediareq));
# Line 530 | Line 538 | sg_network_iface_stats *sg_get_network_iface_stats(int
538                  }
539  
540                  if( (ifmed.ifm_active | IFM_FDX) == ifmed.ifm_active ){
541 <                        network_iface_stat_ptr->dup = SG_IFACE_DUPLEX_FULL;
541 >                        network_iface_stat_ptr->duplex = SG_IFACE_DUPLEX_FULL;
542                  }else if( (ifmed.ifm_active | IFM_HDX) == ifmed.ifm_active ){
543 <                        network_iface_stat_ptr->dup = SG_IFACE_DUPLEX_HALF;
543 >                        network_iface_stat_ptr->duplex = SG_IFACE_DUPLEX_HALF;
544                  }else{
545 <                        network_iface_stat_ptr->dup = SG_IFACE_DUPLEX_UNKNOWN;
545 >                        network_iface_stat_ptr->duplex = SG_IFACE_DUPLEX_UNKNOWN;
546                  }
547  
548          }      
# Line 588 | Line 596 | sg_network_iface_stats *sg_get_network_iface_stats(int
596                                  network_iface_stat_ptr->speed = 0;
597                          }
598  
599 <                        network_iface_stat_ptr->dup = SG_IFACE_DUPLEX_UNKNOWN;
599 >                        network_iface_stat_ptr->duplex = SG_IFACE_DUPLEX_UNKNOWN;
600                          if ((knp = kstat_data_lookup(ksp, "link_duplex")) != NULL) {
601                                  switch (knp->value.ui32) {
602                                  case 1:
603 <                                        network_iface_stat_ptr->dup = SG_IFACE_DUPLEX_HALF;
603 >                                        network_iface_stat_ptr->duplex = SG_IFACE_DUPLEX_HALF;
604                                          break;
605                                  case 2:
606 <                                        network_iface_stat_ptr->dup = SG_IFACE_DUPLEX_FULL;
606 >                                        network_iface_stat_ptr->duplex = SG_IFACE_DUPLEX_FULL;
607                                          break;
608                                  }
609                          }
# Line 675 | Line 683 | sg_network_iface_stats *sg_get_network_iface_stats(int
683                          network_iface_stat_ptr->speed = ethcmd.speed;
684  
685                          switch (ethcmd.duplex) {
686 <                        case 0x00:
687 <                                network_iface_stat_ptr->dup = SG_IFACE_DUPLEX_FULL;
686 >                        case DUPLEX_FULL:
687 >                                network_iface_stat_ptr->duplex = SG_IFACE_DUPLEX_FULL;
688                                  break;
689 <                        case 0x01:
690 <                                network_iface_stat_ptr->dup = SG_IFACE_DUPLEX_HALF;
689 >                        case DUPLEX_HALF:
690 >                                network_iface_stat_ptr->duplex = SG_IFACE_DUPLEX_HALF;
691                                  break;
692                          default:
693 <                                network_iface_stat_ptr->dup = SG_IFACE_DUPLEX_UNKNOWN;
693 >                                network_iface_stat_ptr->duplex = SG_IFACE_DUPLEX_UNKNOWN;
694                          }
695                  } else {
696                          /* Not all interfaces support the ethtool ioctl. */
697                          network_iface_stat_ptr->speed = 0;
698 <                        network_iface_stat_ptr->dup = SG_IFACE_DUPLEX_UNKNOWN;
698 >                        network_iface_stat_ptr->duplex = SG_IFACE_DUPLEX_UNKNOWN;
699                  }
700  
701                  ifaces++;
# Line 702 | Line 710 | sg_network_iface_stats *sg_get_network_iface_stats(int
710   #ifdef HPUX
711          sg_set_error(SG_ERROR_UNSUPPORTED, "HP-UX");
712          return NULL;
713 + #endif
714 +
715 + #ifdef SG_ENABLE_DEPRECATED
716 +        network_iface_stat_ptr->dup = network_iface_stat_ptr->duplex;
717   #endif
718  
719          *entries = ifaces;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines