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.28 by tdb, Thu Feb 12 23:58:32 2004 UTC vs.
Revision 1.31 by ats, Fri Feb 13 15:12:26 2004 UTC

# Line 339 | Line 339 | void network_iface_stat_init(int start, int end, netwo
339          for(net_stats+=start; start<end; start++){
340                  net_stats->interface_name=NULL;
341                  net_stats->speed=0;
342 <                net_stats->dup=NO_DUPLEX;
342 >                net_stats->dup=UNKNOWN_DUPLEX;
343                  net_stats++;
344          }
345   }
# Line 450 | Line 450 | network_iface_stat_t *get_network_iface_stats(int *ent
450                          case(IFM_1000_SX):
451                          case(IFM_1000_LX):
452                          case(IFM_1000_CX):
453 < #ifdef FREEBSD5
454 <                        case(IFM_1000_T):
455 < #else
453 > #if defined(FREEBSD) && !defined(FREEBSD5)
454                          case(IFM_1000_TX):
455                          case(IFM_1000_FX):
456 + #else
457 +                        case(IFM_1000_T):
458   #endif
459                                  network_iface_stat_ptr->speed = 1000;
460                                  break;
# Line 469 | Line 469 | network_iface_stat_t *get_network_iface_stats(int *ent
469                  }else if( (ifmed.ifm_active | IFM_HDX) == ifmed.ifm_active ){
470                          network_iface_stat_ptr->dup = HALF_DUPLEX;
471                  }else{
472 <                        network_iface_stat_ptr->dup = NO_DUPLEX;
472 >                        network_iface_stat_ptr->dup = UNKNOWN_DUPLEX;
473                  }
474                  ifaces++;
475          }      
476          freeifaddrs(net);
477 +        close(s);
478   #endif
479  
480   #ifdef SOLARIS
# Line 532 | Line 533 | network_iface_stat_t *get_network_iface_stats(int *ent
533          if(eth_tool_cmd_buf == NULL) return NULL;
534  
535          /* Ignore first 2 lines.. Just headings */
536 <        fgets(line, sizeof(line), f);
537 <        fgets(line, sizeof(line), f);
536 >        if((fgets(line, sizeof(line), f)) == NULL) return NULL;
537 >        if((fgets(line, sizeof(line), f)) == NULL) return NULL;
538  
539          while((fgets(line, sizeof(line), f)) != NULL){
540                  char *name, *ptr;
# Line 555 | Line 556 | network_iface_stat_t *get_network_iface_stats(int *ent
556                  ifr.ifr_data = (caddr_t) eth_tool_cmd_buf;
557                  strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
558  
559 <                ethcmd = (struct ethtool_cmd *)(&ifr)->ifr_data;
559 >                ethcmd = (struct ethtool_cmd *) ifr.ifr_data;
560                  ethcmd->cmd = ETHTOOL_GSET;
561  
562                  err = ioctl(sock, SIOCETHTOOL, &ifr);
# Line 574 | Line 575 | network_iface_stat_t *get_network_iface_stats(int *ent
575                  network_iface_stat_ptr = network_iface_stats + ifaces;
576                  network_iface_stat_ptr->interface_name = strdup(name);
577                  network_iface_stat_ptr->speed = ethcmd->speed;
578 <                network_iface_stat_ptr->dup = NO_DUPLEX;
578 >                network_iface_stat_ptr->dup = UNKNOWN_DUPEX;
579                  if(ethcmd->duplex == 0x00){
580                          network_iface_stat_ptr->dup = FULL_DUPLEX;
581                  }
# Line 583 | Line 584 | network_iface_stat_t *get_network_iface_stats(int *ent
584                  }
585                  ifaces++;
586          }
587 <
587 >        close(sock);
588          free(eth_tool_cmd_buf);
589   #endif
590          *entries = ifaces;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines