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.33 by pajs, Fri Feb 13 15:29:16 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 339 | Line 340 | void network_iface_stat_init(int start, int end, netwo
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   }
# Line 450 | Line 451 | network_iface_stat_t *get_network_iface_stats(int *ent
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;
# Line 469 | Line 470 | network_iface_stat_t *get_network_iface_stats(int *ent
470                  }else if( (ifmed.ifm_active | IFM_HDX) == ifmed.ifm_active ){
471                          network_iface_stat_ptr->dup = HALF_DUPLEX;
472                  }else{
473 <                        network_iface_stat_ptr->dup = NO_DUPLEX;
473 >                        network_iface_stat_ptr->dup = UNKNOWN_DUPLEX;
474                  }
475                  ifaces++;
476          }      
477          freeifaddrs(net);
478 +        close(s);
479   #endif
480  
481   #ifdef SOLARIS
# Line 500 | Line 502 | network_iface_stat_t *get_network_iface_stats(int *ent
502                                  continue;
503                          }
504  
505 <                        if(knp->value.ui64 == 0){
505 >                        network_iface_stat_ptr->dup = UNKNOWN_DUPLEX;
506 >                        if(knp->value.ui64 == 2){
507                                  network_iface_stat_ptr->dup = FULL_DUPLEX;
508 <                        }else{
508 >                        }
509 >                        if(knp->value.ui64 == 1){
510                                  network_iface_stat_ptr->dup = HALF_DUPLEX;
511                          }
512  
# Line 532 | Line 536 | network_iface_stat_t *get_network_iface_stats(int *ent
536          if(eth_tool_cmd_buf == NULL) return NULL;
537  
538          /* Ignore first 2 lines.. Just headings */
539 <        fgets(line, sizeof(line), f);
540 <        fgets(line, sizeof(line), f);
539 >        if((fgets(line, sizeof(line), f)) == NULL) return NULL;
540 >        if((fgets(line, sizeof(line), f)) == NULL) return NULL;
541  
542          while((fgets(line, sizeof(line), f)) != NULL){
543                  char *name, *ptr;
# Line 555 | Line 559 | network_iface_stat_t *get_network_iface_stats(int *ent
559                  ifr.ifr_data = (caddr_t) eth_tool_cmd_buf;
560                  strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
561  
562 <                ethcmd = (struct ethtool_cmd *)(&ifr)->ifr_data;
562 >                ethcmd = (struct ethtool_cmd *) ifr.ifr_data;
563                  ethcmd->cmd = ETHTOOL_GSET;
564  
565                  err = ioctl(sock, SIOCETHTOOL, &ifr);
# Line 574 | Line 578 | network_iface_stat_t *get_network_iface_stats(int *ent
578                  network_iface_stat_ptr = network_iface_stats + ifaces;
579                  network_iface_stat_ptr->interface_name = strdup(name);
580                  network_iface_stat_ptr->speed = ethcmd->speed;
581 <                network_iface_stat_ptr->dup = NO_DUPLEX;
581 >                network_iface_stat_ptr->dup = UNKNOWN_DUPLEX;
582                  if(ethcmd->duplex == 0x00){
583                          network_iface_stat_ptr->dup = FULL_DUPLEX;
584                  }
# Line 583 | Line 587 | network_iface_stat_t *get_network_iface_stats(int *ent
587                  }
588                  ifaces++;
589          }
590 <
590 >        close(sock);
591          free(eth_tool_cmd_buf);
592   #endif
593          *entries = ifaces;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines