not every value return in an nlist structure was being
[unix-history] / usr / src / usr.bin / netstat / main.c
index 524ecd1..5832f69 100644 (file)
@@ -12,23 +12,27 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.28 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.30 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
+#include <sys/file.h>
 #include <sys/protosw.h>
 #include <sys/socket.h>
 #include <sys/protosw.h>
 #include <sys/socket.h>
-#include <sys/file.h>
+
+#include <netinet/in.h>
+
+#include <ctype.h>
 #include <errno.h>
 #include <errno.h>
-#include <netdb.h>
-#include <nlist.h>
 #include <kvm.h>
 #include <limits.h>
 #include <kvm.h>
 #include <limits.h>
+#include <netdb.h>
+#include <nlist.h>
+#include <paths.h>
 #include <stdio.h>
 #include <stdio.h>
-#include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdlib.h>
 #include <string.h>
-#include <paths.h>
+#include <unistd.h>
 #include "netstat.h"
 
 struct nlist nl[] = {
 #include "netstat.h"
 
 struct nlist nl[] = {
@@ -80,6 +84,20 @@ struct nlist nl[] = {
        { "_cltb"},
 #define N_CLTPSTAT     23
        { "_cltpstat"},
        { "_cltb"},
 #define N_CLTPSTAT     23
        { "_cltpstat"},
+#define        N_NFILE         24
+       { "_nfile" },
+#define        N_FILE          25
+       { "_file" },
+#define N_IGMPSTAT     26
+       { "_igmpstat" },
+#define N_MRTPROTO     27
+       { "_ip_mrtproto" },
+#define N_MRTSTAT      28
+       { "_mrtstat" },
+#define N_MRTTABLE     29
+       { "_mrttable" },
+#define N_VIFTABLE     30
+       { "_viftable" },
 
     /* BBN Internet protocol implementation */
 #define        N_TCP           23
 
     /* BBN Internet protocol implementation */
 #define        N_TCP           23
@@ -186,7 +204,7 @@ main(argc, argv)
                prog = argv[0];
        af = AF_UNSPEC;
 
                prog = argv[0];
        af = AF_UNSPEC;
 
-       while ((ch = getopt(argc, argv, "Aadf:hI:iM:mN:np:rstuw")) != EOF)
+       while ((ch = getopt(argc, argv, "AaBdf:hI:iM:mN:np:rstuw")) != EOF)
                switch((char)ch) {
                case 'A':
                        Aflag = 1;
                switch((char)ch) {
                case 'A':
                        Aflag = 1;
@@ -194,6 +212,9 @@ main(argc, argv)
                case 'a':
                        aflag = 1;
                        break;
                case 'a':
                        aflag = 1;
                        break;
+               case 'B':
+                       Bflag = 1;
+                       break;
                case 'd':
                        dflag = 1;
                        break;
                case 'd':
                        dflag = 1;
                        break;
@@ -309,7 +330,7 @@ main(argc, argv)
                exit(1);
        }
        if (mflag) {
                exit(1);
        }
        if (mflag) {
-               mbpr((off_t)nl[N_MBSTAT].n_value);
+               mbpr(nl[N_MBSTAT].n_value);
                exit(0);
        }
        if (pflag) {
                exit(0);
        }
        if (pflag) {
@@ -336,9 +357,19 @@ main(argc, argv)
        }
        if (rflag) {
                if (sflag)
        }
        if (rflag) {
                if (sflag)
-                       rt_stats((off_t)nl[N_RTSTAT].n_value);
+                       rt_stats(nl[N_RTSTAT].n_value);
+               else
+                       routepr(nl[N_RTREE].n_value);
+               exit(0);
+       }
+       if (Bflag) {
+               if (sflag)
+                       mrt_stats(nl[N_MRTPROTO].n_value,
+                           nl[N_MRTSTAT].n_value);
                else
                else
-                       routepr((off_t)nl[N_RTREE].n_value);
+                       mroutepr(nl[N_MRTPROTO].n_value,
+                           nl[N_MRTTABLE].n_value,
+                           nl[N_VIFTABLE].n_value);
                exit(0);
        }
 
                exit(0);
        }
 
@@ -358,7 +389,7 @@ main(argc, argv)
  */
 int
 kread(addr, buf, size)
  */
 int
 kread(addr, buf, size)
-       off_t addr;
+       u_long addr;
        char *buf;
        int size;
 {
        char *buf;
        int size;
 {
@@ -379,6 +410,13 @@ plural(n)
        return (n != 1 ? "s" : "");
 }
 
        return (n != 1 ? "s" : "");
 }
 
+char *
+plurales(n)
+       int n;
+{
+       return (n != 1 ? "es" : "");
+}
+
 /*
  * Find the protox for the given "well-known" name.
  */
 /*
  * Find the protox for the given "well-known" name.
  */