[BACK]Return to if.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / systat

Diff for /src/usr.bin/systat/if.c between version 1.1 and 1.2

version 1.1, 2004/11/16 09:52:33 version 1.2, 2004/11/25 23:08:13
Line 75 
Line 75 
 }  }
   
 #define UPDATE(x, y) do { \  #define UPDATE(x, y) do { \
                 ifs->ifs_now.x = ifm->y; \                  ifs->ifs_now.x = ifm.y; \
                 ifs->ifs_cur.x = ifs->ifs_now.x - ifs->ifs_old.x; \                  ifs->ifs_cur.x = ifs->ifs_now.x - ifs->ifs_old.x; \
                 sum.x += ifs->ifs_cur.x; \                  sum.x += ifs->ifs_cur.x; \
                 if (state == TIME) \                  if (state == TIME) \
Line 102 
Line 102 
 fetchifstat(void)  fetchifstat(void)
 {  {
         struct ifstat *newstats, *ifs;          struct ifstat *newstats, *ifs;
         struct if_msghdr *ifm;          struct if_msghdr ifm;
         struct sockaddr *info[RTAX_MAX];          struct sockaddr *info[RTAX_MAX];
         struct sockaddr_dl *sdl;          struct sockaddr_dl *sdl;
         char *buf, *next, *lim;          char *buf, *next, *lim;
Line 128 
Line 128 
         bzero(&sum, sizeof(sum));          bzero(&sum, sizeof(sum));
   
         lim = buf + need;          lim = buf + need;
         for (next = buf; next < lim; next += ifm->ifm_msglen) {          for (next = buf; next < lim; next += ifm.ifm_msglen) {
                 ifm = (struct if_msghdr *)next;                  bcopy(next, &ifm, sizeof ifm);
                 if (ifm->ifm_type != RTM_IFINFO ||                  if (ifm.ifm_type != RTM_IFINFO ||
                    !(ifm->ifm_addrs & RTA_IFP))                     !(ifm.ifm_addrs & RTA_IFP))
                         continue;                          continue;
                 if (ifm->ifm_index >= nifs) {                  if (ifm.ifm_index >= nifs) {
                         if ((newstats = realloc(ifstats, (ifm->ifm_index + 4) *                          if ((newstats = realloc(ifstats, (ifm.ifm_index + 4) *
                             sizeof(struct ifstat))) == NULL)                              sizeof(struct ifstat))) == NULL)
                                 continue;                                  continue;
                         ifstats = newstats;                          ifstats = newstats;
                         for (; nifs < ifm->ifm_index + 4; nifs++)                          for (; nifs < ifm.ifm_index + 4; nifs++)
                                 ifstats[nifs].ifs_name[0] = '\0';                                  ifstats[nifs].ifs_name[0] = '\0';
                 }                  }
                 ifs = &ifstats[ifm->ifm_index];                  ifs = &ifstats[ifm.ifm_index];
                 if (ifs->ifs_name[0] == '\0') {                  if (ifs->ifs_name[0] == '\0') {
                         bzero(&info, sizeof(info));                          bzero(&info, sizeof(info));
                         rt_getaddrinfo((struct sockaddr *)(ifm + 1),                          rt_getaddrinfo(
                             ifm->ifm_addrs, info);                              (struct sockaddr *)((struct if_msghdr *)next + 1),
                               ifm.ifm_addrs, info);
                         if ((sdl = (struct sockaddr_dl *)info[RTAX_IFP])) {                          if ((sdl = (struct sockaddr_dl *)info[RTAX_IFP])) {
                                 if (sdl->sdl_family == AF_LINK &&                                  if (sdl->sdl_family == AF_LINK &&
                                     sdl->sdl_nlen > 0)                                      sdl->sdl_nlen > 0)

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2