for walsh
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Thu, 19 Sep 1985 07:58:38 +0000 (23:58 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Thu, 19 Sep 1985 07:58:38 +0000 (23:58 -0800)
SCCS-vsn: usr.bin/netstat/Makefile 5.3
SCCS-vsn: usr.bin/netstat/main.c 5.3

usr/src/usr.bin/netstat/Makefile
usr/src/usr.bin/netstat/main.c

index 1739da7..4a23567 100644 (file)
@@ -3,9 +3,9 @@
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
-#      @(#)Makefile    5.2 (Berkeley) %G%
+#      @(#)Makefile    5.3 (Berkeley) %G%
 #
 #
-OBJS=  host.o inet.o if.o main.o mbuf.o route.o unix.o ns.o
+OBJS=  host.o inet.o if.o main.o mbuf.o route.o unix.o ns.o bbnnet.o
 CFLAGS=-O
 DESTDIR=
 
 CFLAGS=-O
 DESTDIR=
 
index f655b48..039a488 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.3 (Berkeley) %G%";
 #endif not lint
 
 #include <sys/param.h>
 #endif not lint
 
 #include <sys/param.h>
@@ -71,12 +71,24 @@ struct nlist nl[] = {
        { "_spp_istat"},
 #define N_NSERR                22
        { "_ns_errstat"},
        { "_spp_istat"},
 #define N_NSERR                22
        { "_ns_errstat"},
+
+    /* BBN Internet protocol implementation */
+#define        N_TCP           23
+       { "_tcp" },
+#define        N_UDP           24
+       { "_udp" },
+#define N_RDP          25
+       { "_rdp" },
+#define        N_RDPSTAT       26
+       { "_rdpstat" },
+
        "",
 };
 
 /* internet protocols */
        "",
 };
 
 /* internet protocols */
-extern int protopr();
+extern int protopr(), bbnprotopr();
 extern int tcp_stats(), udp_stats(), ip_stats(), icmp_stats();
 extern int tcp_stats(), udp_stats(), ip_stats(), icmp_stats();
+extern int tcpstats(), udpstats(), ipstats(), icmpstats(), rdpstats();
 extern int nsprotopr();
 extern int spp_stats(), idp_stats(), nserr_stats();
 
 extern int nsprotopr();
 extern int spp_stats(), idp_stats(), nserr_stats();
 
@@ -87,7 +99,9 @@ struct protox {
        int     (*pr_cblocks)();        /* control blocks printing routine */
        int     (*pr_stats)();          /* statistics printing routine */
        char    *pr_name;               /* well-known name */
        int     (*pr_cblocks)();        /* control blocks printing routine */
        int     (*pr_stats)();          /* statistics printing routine */
        char    *pr_name;               /* well-known name */
-} protox[] = {
+};
+
+struct  protox berkprotox[] = {
        { N_TCB,        N_TCPSTAT,      1,      protopr,
          tcp_stats,    "tcp" },
        { N_UDB,        N_UDPSTAT,      1,      protopr,
        { N_TCB,        N_TCPSTAT,      1,      protopr,
          tcp_stats,    "tcp" },
        { N_UDB,        N_UDPSTAT,      1,      protopr,
@@ -100,6 +114,23 @@ struct protox {
          0,            0 }
 };
 
          0,            0 }
 };
 
+struct protox bbnprotox[] = {
+       { N_TCP,        N_TCPSTAT,      1,      bbnprotopr,
+         tcpstats,     "tcp" },
+       { N_UDP,        N_UDPSTAT,      1,      bbnprotopr,
+         udpstats,     "udp" },
+       { N_RDP,        N_RDPSTAT,      1,      bbnprotopr,
+         rdpstats,     "rdp" },
+       { N_RAWCB,      0,              1,      bbnprotopr,
+         0,            "raw" },
+       { -1,           N_IPSTAT,       1,      0,
+         ipstats,      "ip" },
+       { -1,           N_ICMPSTAT,     1,      0,
+         icmpstats,    "icmp" },
+       { -1,           -1,             0,      0,
+         0,            0 }
+};
+
 struct protox nsprotox[] = {
        { N_IDP,        N_IDPSTAT,      1,      nsprotopr,
          idp_stats,    "idp" },
 struct protox nsprotox[] = {
        { N_IDP,        N_IDPSTAT,      1,      nsprotopr,
          idp_stats,    "idp" },
@@ -291,21 +322,21 @@ use:
                exit(0);
        }
     if (af == AF_INET || af == AF_UNSPEC) {
                exit(0);
        }
     if (af == AF_INET || af == AF_UNSPEC) {
+       struct protox *head;
+
+       head = (nl[N_TCB].n_type == 0) ? bbnprotox : berkprotox;
        setprotoent(1);
        setservent(1);
        setprotoent(1);
        setservent(1);
-       while (p = getprotoent()) {
 
 
-               for (tp = protox; tp->pr_name; tp++)
-                       if (strcmp(tp->pr_name, p->p_name) == 0)
-                               break;
-               if (tp->pr_name == 0 || tp->pr_wanted == 0)
-                       continue;
-               if (sflag && tp->pr_stats) {
-                       (*tp->pr_stats)(nl[tp->pr_sindex].n_value, p->p_name);
+       for (tp = head; tp->pr_name; tp++) {
+               if (tp->pr_wanted == 0)
                        continue;
                        continue;
-               }
-               if (tp->pr_cblocks)
-                       (*tp->pr_cblocks)(nl[tp->pr_index].n_value, p->p_name);
+
+               if (sflag) {
+                       if (tp->pr_stats)
+                           (*tp->pr_stats)(nl[tp->pr_sindex].n_value, tp->pr_name);
+               } else if (tp->pr_cblocks)
+                       (*tp->pr_cblocks)(nl[tp->pr_index].n_value, tp->pr_name);
        }
        endprotoent();
     }
        }
        endprotoent();
     }