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

Diff for /src/usr.bin/netstat/mbuf.c between version 1.7 and 1.8

version 1.7, 1999/02/27 21:22:19 version 1.8, 2001/05/18 02:41:38
Line 42 
Line 42 
 #endif  #endif
 #endif /* not lint */  #endif /* not lint */
   
   #define __POOL_EXPOSE
   
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/protosw.h>  #include <sys/protosw.h>
 #include <sys/socket.h>  #include <sys/socket.h>
 #include <sys/mbuf.h>  #include <sys/mbuf.h>
   #include <sys/pool.h>
   
 #include <limits.h>  #include <limits.h>
 #include <stdio.h>  #include <stdio.h>
Line 55 
Line 58 
 typedef int bool;  typedef int bool;
   
 struct  mbstat mbstat;  struct  mbstat mbstat;
   struct pool mbpool, mclpool;
   
   
 static struct mbtypes {  static struct mbtypes {
         int     mt_type;          int     mt_type;
         char    *mt_name;          char    *mt_name;
Line 64 
Line 69 
         { MT_OOBDATA,   "oob data" },          { MT_OOBDATA,   "oob data" },
         { MT_CONTROL,   "ancillary data" },          { MT_CONTROL,   "ancillary data" },
         { MT_HEADER,    "packet headers" },          { MT_HEADER,    "packet headers" },
         { MT_SOCKET,    "socket structures" },                  /* XXX */  
         { MT_PCB,       "protocol control blocks" },            /* XXX */  
         { MT_RTABLE,    "routing table entries" },              /* XXX */  
         { MT_HTABLE,    "IMP host table entries" },             /* XXX */  
         { MT_ATABLE,    "address resolution tables" },  
         { MT_FTABLE,    "fragment reassembly queue headers" },  /* XXX */          { MT_FTABLE,    "fragment reassembly queue headers" },  /* XXX */
         { MT_SONAME,    "socket names and addresses" },          { MT_SONAME,    "socket names and addresses" },
         { MT_SOOPTS,    "socket options" },          { MT_SOOPTS,    "socket options" },
         { MT_RIGHTS,    "access rights" },  
         { MT_IFADDR,    "interface addresses" },                /* XXX */  
         { 0, 0 }          { 0, 0 }
 };  };
   
Line 84 
Line 82 
  * Print mbuf statistics.   * Print mbuf statistics.
  */   */
 void  void
 mbpr(mbaddr)  mbpr(mbaddr, mbpooladdr, mclpooladdr)
         u_long mbaddr;          u_long mbaddr;
           u_long mbpooladdr, mclpooladdr;
 {  {
         register int totmem, totfree, totmbufs;          register int totmem, totused, totmbufs, totpct;
         register int i;          register int i;
         register struct mbtypes *mp;          register struct mbtypes *mp;
   
Line 104 
Line 103 
         }          }
         if (kread(mbaddr, (char *)&mbstat, sizeof (mbstat)))          if (kread(mbaddr, (char *)&mbstat, sizeof (mbstat)))
                 return;                  return;
           if (kread(mbpooladdr, (char *)&mbpool, sizeof (mbpool)))
                   return;
   
           if (kread(mclpooladdr, (char *)&mclpool, sizeof (mclpool)))
                   return;
   
         totmbufs = 0;          totmbufs = 0;
         for (mp = mbtypes; mp->mt_name; mp++)          for (mp = mbtypes; mp->mt_name; mp++)
                 totmbufs += mbstat.m_mtypes[mp->mt_type];                  totmbufs += mbstat.m_mtypes[mp->mt_type];
Line 124 
Line 129 
                             plural((int)mbstat.m_mtypes[i]), i);                              plural((int)mbstat.m_mtypes[i]), i);
                 }                  }
         printf("%lu/%lu mapped pages in use\n",          printf("%lu/%lu mapped pages in use\n",
                 mbstat.m_clusters - mbstat.m_clfree, mbstat.m_clusters);                 (u_long)(mclpool.pr_nget - mclpool.pr_nput),
         totmem = totmbufs * MSIZE + mbstat.m_clusters * MCLBYTES;                 ((u_long)mclpool.pr_npages * mclpool.pr_itemsperpage));
         totfree = mbstat.m_clfree * MCLBYTES;          totmem = (mbpool.pr_npages << mbpool.pr_pageshift) +
               (mclpool.pr_npages << mclpool.pr_pageshift);
           totused = (mbpool.pr_nget - mbpool.pr_nput) * mbpool.pr_size +
               (mclpool.pr_nget - mclpool.pr_nput) * mclpool.pr_size;
           totpct = (totmem == 0)? 0 : ((totused * 100)/totmem);
         printf("%u Kbytes allocated to network (%d%% in use)\n",          printf("%u Kbytes allocated to network (%d%% in use)\n",
             totmem / 1024,              totmem / 1024, totpct);
             totmem ? (totmem - totfree) * 100 / totmem : 100);  
         printf("%lu requests for memory denied\n", mbstat.m_drops);          printf("%lu requests for memory denied\n", mbstat.m_drops);
         printf("%lu requests for memory delayed\n", mbstat.m_wait);          printf("%lu requests for memory delayed\n", mbstat.m_wait);
         printf("%lu calls to protocol drain routines\n", mbstat.m_drain);          printf("%lu calls to protocol drain routines\n", mbstat.m_drain);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8