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

Diff for /src/usr.bin/netstat/inet.c between version 1.101 and 1.102

version 1.101, 2007/09/03 06:10:54 version 1.102, 2007/12/13 20:00:53
Line 44 
Line 44 
 #include <sys/socketvar.h>  #include <sys/socketvar.h>
 #include <sys/mbuf.h>  #include <sys/mbuf.h>
 #include <sys/protosw.h>  #include <sys/protosw.h>
   #include <sys/sysctl.h>
   
 #include <net/route.h>  #include <net/route.h>
 #include <netinet/in.h>  #include <netinet/in.h>
Line 245 
Line 246 
 tcp_stats(u_long off, char *name)  tcp_stats(u_long off, char *name)
 {  {
         struct tcpstat tcpstat;          struct tcpstat tcpstat;
           size_t len;
           int mib[] = { CTL_NET, AF_INET, IPPROTO_TCP, TCPCTL_STATS };
   
         if (off == 0)          if (off == 0)
                 return;                  return;
         printf("%s:\n", name);  
         kread(off, &tcpstat, sizeof (tcpstat));  
   
           len = sizeof(tcpstat);
           if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
               &tcpstat, &len, NULL, 0) == -1) {
                   warn(name);
                   return;
           }
   
           printf("%s:\n", name);
 #define p(f, m) if (tcpstat.f || sflag <= 1) \  #define p(f, m) if (tcpstat.f || sflag <= 1) \
         printf(m, tcpstat.f, plural(tcpstat.f))          printf(m, tcpstat.f, plural(tcpstat.f))
 #define p1(f, m) if (tcpstat.f || sflag <= 1) \  #define p1(f, m) if (tcpstat.f || sflag <= 1) \
Line 371 
Line 380 
 {  {
         struct udpstat udpstat;          struct udpstat udpstat;
         u_long delivered;          u_long delivered;
           size_t len;
           int mib[] = { CTL_NET, AF_INET, IPPROTO_UDP, UDPCTL_STATS };
   
         if (off == 0)          if (off == 0)
                 return;                  return;
         kread(off, &udpstat, sizeof (udpstat));  
           len = sizeof(udpstat);
           if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
               &udpstat, &len, NULL, 0) == -1) {
                   warn(name);
                   return;
           }
   
         printf("%s:\n", name);          printf("%s:\n", name);
 #define p(f, m) if (udpstat.f || sflag <= 1) \  #define p(f, m) if (udpstat.f || sflag <= 1) \
         printf(m, udpstat.f, plural(udpstat.f))          printf(m, udpstat.f, plural(udpstat.f))
Line 411 
Line 429 
 ip_stats(u_long off, char *name)  ip_stats(u_long off, char *name)
 {  {
         struct ipstat ipstat;          struct ipstat ipstat;
           size_t len;
           int mib[] = { CTL_NET, AF_INET, IPPROTO_IP, IPCTL_STATS };
   
         if (off == 0)          if (off == 0)
                 return;                  return;
         kread(off, &ipstat, sizeof (ipstat));  
         printf("%s:\n", name);  
   
           len = sizeof(ipstat);
           if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
               &ipstat, &len, NULL, 0) == -1) {
                   warn(name);
                   return;
           }
   
           printf("%s:\n", name);
 #define p(f, m) if (ipstat.f || sflag <= 1) \  #define p(f, m) if (ipstat.f || sflag <= 1) \
         printf(m, ipstat.f, plural(ipstat.f))          printf(m, ipstat.f, plural(ipstat.f))
 #define p1(f, m) if (ipstat.f || sflag <= 1) \  #define p1(f, m) if (ipstat.f || sflag <= 1) \
Line 510 
Line 536 
 {  {
         struct icmpstat icmpstat;          struct icmpstat icmpstat;
         int i, first;          int i, first;
           int mib[] = { CTL_NET, AF_INET, IPPROTO_ICMP, ICMPCTL_STATS };
           size_t len;
   
         if (off == 0)          if (off == 0)
                 return;                  return;
         kread(off, &icmpstat, sizeof (icmpstat));  
         printf("%s:\n", name);  
   
           len = sizeof(icmpstat);
           if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
               &icmpstat, &len, NULL, 0) == -1) {
                   warn(name);
                   return;
           }
   
           printf("%s:\n", name);
 #define p(f, m) if (icmpstat.f || sflag <= 1) \  #define p(f, m) if (icmpstat.f || sflag <= 1) \
         printf(m, icmpstat.f, plural(icmpstat.f))          printf(m, icmpstat.f, plural(icmpstat.f))
   

Legend:
Removed from v.1.101  
changed lines
  Added in v.1.102