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.36 by pajs, Fri Feb 13 18:54:29 2004 UTC vs.
Revision 1.37 by ats, Sat Feb 14 00:08:51 2004 UTC

# Line 386 | Line 386 | network_iface_stat_t *get_network_iface_stats(int *ent
386          struct ifaddrs *net, *net_ptr;
387          struct ifmediareq ifmed;
388          struct ifreq ifr;
389 <        int s;
389 >        int sock;
390          int x;
391   #endif
392   #ifdef LINUX
# Line 403 | Line 403 | network_iface_stat_t *get_network_iface_stats(int *ent
403                  return NULL;
404          }
405  
406 <        if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == NULL) return NULL;
406 >        if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == 0) return NULL;
407  
408          for(net_ptr=net; net_ptr!=NULL; net_ptr=net_ptr->ifa_next){
409                  if(net_ptr->ifa_addr->sa_family != AF_LINK) continue;
# Line 415 | Line 415 | network_iface_stat_t *get_network_iface_stats(int *ent
415  
416                  memset(&ifmed, 0, sizeof(struct ifmediareq));
417                  strlcpy(ifmed.ifm_name, net_ptr->ifa_name, sizeof(ifmed.ifm_name));
418 <                if(ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmed) == -1){
418 >                if(ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifmed) == -1){
419                          continue;
420                  }
421  
# Line 474 | Line 474 | network_iface_stat_t *get_network_iface_stats(int *ent
474                          network_iface_stat_ptr->dup = UNKNOWN_DUPLEX;
475                  }
476  
477 +                memset(&ifr, 0, sizeof(ifr));
478 +                strncpy(ifr.ifr_name, net_ptr->ifa_name, sizeof(ifr.ifr_name));
479 +
480                  if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0){
481                          continue;
482                  }      
# Line 486 | Line 489 | network_iface_stat_t *get_network_iface_stats(int *ent
489                  ifaces++;
490          }      
491          freeifaddrs(net);
492 <        close(s);
492 >        close(sock);
493   #endif
494  
495   #ifdef SOLARIS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines