SCCS-vsn: usr.bin/netstat/ns.c 5.15
SCCS-vsn: usr.bin/netstat/main.c 5.29
SCCS-vsn: usr.bin/netstat/if.c 5.17
SCCS-vsn: usr.bin/netstat/iso.c 5.12
SCCS-vsn: usr.bin/netstat/route.c 5.24
SCCS-vsn: usr.bin/netstat/inet.c 5.18
SCCS-vsn: usr.bin/netstat/unix.c 5.13
SCCS-vsn: usr.bin/netstat/Makefile 5.16
SCCS-vsn: usr.bin/netstat/netstat.h 5.3
-# @(#)Makefile 5.15 (Berkeley) %G%
+# @(#)Makefile 5.16 (Berkeley) %G%
PROG= netstat
OBJS= host.o inet.o if.o main.o mbuf.o route.o unix.o ns.o bbnnet.o
PROG= netstat
OBJS= host.o inet.o if.o main.o mbuf.o route.o unix.o ns.o bbnnet.o
-static char sccsid[] = "@(#)if.c 5.16 (Berkeley) %G%";
+static char sccsid[] = "@(#)if.c 5.17 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include "netstat.h"
#define YES 1
#include "netstat.h"
#define YES 1
* Copyright (c) 1983, 1988 Regents of the University of California.
* All rights reserved.
*
* Copyright (c) 1983, 1988 Regents of the University of California.
* All rights reserved.
*
-static char sccsid[] = "@(#)inet.c 5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)inet.c 5.18 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include "netstat.h"
struct inpcb inpcb;
struct tcpcb tcpcb;
struct socket sockb;
#include "netstat.h"
struct inpcb inpcb;
struct tcpcb tcpcb;
struct socket sockb;
-char *inetname __P((struct in_addr *));
-void inetprint __P((struct in_addr *, int, char *));
+char *inetname __P((struct in_addr *));
+void inetprint __P((struct in_addr *, int, char *));
/*
* Print a summary of connections related to an Internet
/*
* Print a summary of connections related to an Internet
-/*-
- * Copyright (c) 1989, 1990 The Regents of the University of California.
+/*
+ * Copyright (c) 1983, 1988 Regents of the University of California.
* All rights reserved.
*
* %sccs.include.redist.c%
*/
#ifndef lint
* All rights reserved.
*
* %sccs.include.redist.c%
*/
#ifndef lint
-static char sccsid[] = "@(#)iso.c 5.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)iso.c 5.12 (Berkeley) %G%";
- * $Header: iso.c,v 3.3 88/12/08 14:44:49 hagens Exp $
- * $Source: /usr/argo/src/ucb/netstat/RCS/iso.c,v $
+ * $Header: iso.c,v 1.5 92/06/04 00:36:32 leres Exp $
+ * $Source: /usr/src/usr.bin/netstat/RCS/iso.c,v $
*/
/*******************************************************************************
Copyright IBM Corporation 1987
*/
/*******************************************************************************
Copyright IBM Corporation 1987
#undef IncStat
#endif
#include <netiso/cons_pcb.h>
#undef IncStat
#endif
#include <netiso/cons_pcb.h>
#include <netdb.h>
#include <string.h>
#include <stdio.h>
#include <netdb.h>
#include <string.h>
#include <stdio.h>
#include "netstat.h"
static void tprintstat __P((struct tp_stat *, int));
static void isonetprint __P((struct sockaddr_iso *, int));
static void hexprint __P((int, char *, char *));
#include "netstat.h"
static void tprintstat __P((struct tp_stat *, int));
static void isonetprint __P((struct sockaddr_iso *, int));
static void hexprint __P((int, char *, char *));
+extern void inetprint __P((struct in_addr *, int, char *));
iso_protopr1(kern_addr, istp)
iso_protopr1(kern_addr, istp)
+ off_t kern_addr;
+ int istp;
{
if (first) {
printf("Active ISO net connections");
{
if (first) {
printf("Active ISO net connections");
}
if (Aflag)
printf("%8x ",
}
if (Aflag)
printf("%8x ",
- (sockb.so_pcb ? (off_t)sockb.so_pcb : (off_t)kern_addr));
+ (sockb.so_pcb ? (void *)sockb.so_pcb : (void *)kern_addr));
printf("%-5.5s %6d %6d ", "tp", sockb.so_rcv.sb_cc, sockb.so_snd.sb_cc);
if (istp && tpcb.tp_lsuffixlen) {
hexprint(tpcb.tp_lsuffixlen, tpcb.tp_lsuffix, "()");
printf("%-5.5s %6d %6d ", "tp", sockb.so_rcv.sb_cc, sockb.so_snd.sb_cc);
if (istp && tpcb.tp_lsuffixlen) {
hexprint(tpcb.tp_lsuffixlen, tpcb.tp_lsuffix, "()");
+ off_t off;
+ char *name;
{
struct tp_ref *tpr, *tpr_base;
struct tp_refinfo tpkerninfo;
{
struct tp_ref *tpr, *tpr_base;
struct tp_refinfo tpkerninfo;
kget(tpcb.tp_sock, sockb);
if (tpcb.tp_npcb) switch(tpcb.tp_netservice) {
case IN_CLNS:
kget(tpcb.tp_sock, sockb);
if (tpcb.tp_npcb) switch(tpcb.tp_netservice) {
case IN_CLNS:
- tp_inproto(tpkerninfo.tpr_base);
+ tp_inproto((off_t)tpkerninfo.tpr_base);
break;
default:
kget(tpcb.tp_npcb, isopcb);
break;
default:
kget(tpcb.tp_npcb, isopcb);
- iso_protopr1(tpcb.tp_npcb, 1);
+ iso_protopr1((off_t)tpcb.tp_npcb, 1);
break;
}
if (tpcb.tp_state >= tp_NSTATES)
break;
}
if (tpcb.tp_state >= tp_NSTATES)
{
struct inpcb inpcb;
kget(tpcb.tp_npcb, inpcb);
{
struct inpcb inpcb;
kget(tpcb.tp_npcb, inpcb);
return;
if (Aflag)
printf("%8x ", pcb);
return;
if (Aflag)
printf("%8x ", pcb);
- printf("%-5.5s %6d %6d ", "tpip", sockb.so_rcv.sb_cc, sockb.so_snd.sb_cc);
+ printf("%-5.5s %6d %6d ", "tpip",
+ sockb.so_rcv.sb_cc, sockb.so_snd.sb_cc);
inetprint(&inpcb.inp_laddr, inpcb.inp_lport, "tp");
inetprint(&inpcb.inp_faddr, inpcb.inp_fport, "tp");
}
inetprint(&inpcb.inp_laddr, inpcb.inp_lport, "tp");
inetprint(&inpcb.inp_faddr, inpcb.inp_fport, "tp");
}
/*
* Pretty print an iso address (net address + port).
* If the nflag was specified, use numbers instead of names.
/*
* Pretty print an iso address (net address + port).
* If the nflag was specified, use numbers instead of names.
fprintf(OUT,
"\n%*sACK reasons:\n", indent, " ");
fprintf(OUT, "\t%*s%6d not acked immediately\n", indent, " ",
fprintf(OUT,
"\n%*sACK reasons:\n", indent, " ");
fprintf(OUT, "\t%*s%6d not acked immediately\n", indent, " ",
- s->ts_ackreason[_ACK_DONT_] );
+ s->ts_ackreason[_ACK_DONT_] );
fprintf(OUT, "\t%*s%6d strategy==each\n", indent, " ",
fprintf(OUT, "\t%*s%6d strategy==each\n", indent, " ",
- s->ts_ackreason[_ACK_STRAT_EACH_] );
+ s->ts_ackreason[_ACK_STRAT_EACH_] );
fprintf(OUT, "\t%*s%6d strategy==fullwindow\n", indent, " ",
fprintf(OUT, "\t%*s%6d strategy==fullwindow\n", indent, " ",
- s->ts_ackreason[_ACK_STRAT_FULLWIN_] );
+ s->ts_ackreason[_ACK_STRAT_FULLWIN_] );
fprintf(OUT, "\t%*s%6d duplicate DT\n", indent, " ",
fprintf(OUT, "\t%*s%6d duplicate DT\n", indent, " ",
- s->ts_ackreason[_ACK_DUP_] );
+ s->ts_ackreason[_ACK_DUP_] );
fprintf(OUT, "\t%*s%6d EOTSDU\n", indent, " ",
fprintf(OUT, "\t%*s%6d EOTSDU\n", indent, " ",
- s->ts_ackreason[_ACK_EOT_] );
+ s->ts_ackreason[_ACK_EOT_] );
fprintf(OUT, "\t%*s%6d reordered DT\n", indent, " ",
fprintf(OUT, "\t%*s%6d reordered DT\n", indent, " ",
- s->ts_ackreason[_ACK_REORDER_] );
+ s->ts_ackreason[_ACK_REORDER_] );
fprintf(OUT, "\t%*s%6d user rcvd\n", indent, " ",
fprintf(OUT, "\t%*s%6d user rcvd\n", indent, " ",
- s->ts_ackreason[_ACK_USRRCV_] );
+ s->ts_ackreason[_ACK_USRRCV_] );
fprintf(OUT, "\t%*s%6d fcc reqd\n", indent, " ",
fprintf(OUT, "\t%*s%6d fcc reqd\n", indent, " ",
- s->ts_ackreason[_ACK_FCC_] );
+ s->ts_ackreason[_ACK_FCC_] );
}
#ifndef SSEL
#define SSEL(s) ((s)->siso_tlen + TSEL(s))
}
#ifndef SSEL
#define SSEL(s) ((s)->siso_tlen + TSEL(s))
hexprint(siso->siso_plen, PSEL(siso), "<>");
putchar(' ');
}
hexprint(siso->siso_plen, PSEL(siso), "<>");
putchar(' ');
}
static char hexlist[] = "0123456789abcdef", obuf[128];
static void
static char hexlist[] = "0123456789abcdef", obuf[128];
static void
#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.29 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/protosw.h>
#include <sys/socket.h>
+
+#include <netinet/in.h>
+
+#include <ctype.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 <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include "netstat.h"
struct nlist nl[] = {
#include "netstat.h"
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
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;
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;
routepr((off_t)nl[N_RTREE].n_value);
exit(0);
}
routepr((off_t)nl[N_RTREE].n_value);
exit(0);
}
+ if (Bflag) {
+ if (sflag)
+ mrt_stats((off_t)nl[N_MRTPROTO].n_value,
+ (off_t)nl[N_MRTSTAT].n_value);
+ else
+ mroutepr((off_t)nl[N_MRTPROTO].n_value,
+ (off_t)nl[N_MRTTABLE].n_value,
+ (off_t)nl[N_VIFTABLE].n_value);
+ exit(0);
+ }
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.
*/
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)netstat.h 5.2 (Berkeley) %G%
+ * @(#)netstat.h 5.3 (Berkeley) %G%
*/
#include <sys/cdefs.h>
*/
#include <sys/cdefs.h>
int dflag; /* show i/f dropped packets */
int hflag; /* show IMP host table */
int iflag; /* show interfaces */
int dflag; /* show i/f dropped packets */
int hflag; /* show IMP host table */
int iflag; /* show interfaces */
+int Bflag; /* show multicast tables (or multicast stats) */
int mflag; /* show memory stats */
int nflag; /* show addresses numerically */
int pflag; /* show given protocol */
int mflag; /* show memory stats */
int nflag; /* show addresses numerically */
int pflag; /* show given protocol */
int kread __P((off_t addr, char *buf, int size));
char *plural __P((int));
int kread __P((off_t addr, char *buf, int size));
char *plural __P((int));
+char *plurales __P((int));
void protopr __P((off_t, char *));
void tcp_stats __P((off_t, char *));
void protopr __P((off_t, char *));
void tcp_stats __P((off_t, char *));
void spp_stats __P((off_t, char *));
void idp_stats __P((off_t, char *));
void nserr_stats __P((off_t, char *));
void spp_stats __P((off_t, char *));
void idp_stats __P((off_t, char *));
void nserr_stats __P((off_t, char *));
-void ns_erputil __P((int, int));
void intpr __P((int, off_t));
void intpr __P((int, off_t));
void clnp_stats __P((off_t, char *));
void cltp_stats __P((off_t, char *));
void iso_protopr __P((off_t, char *));
void clnp_stats __P((off_t, char *));
void cltp_stats __P((off_t, char *));
void iso_protopr __P((off_t, char *));
+void iso_protopr1 __P((off_t, int));
+void tp_protopr __P((off_t, char *));
+void tp_inproto __P((off_t));
void tp_stats __P((caddr_t, caddr_t));
void tp_stats __P((caddr_t, caddr_t));
+
+void mroutepr __P((off_t, off_t, off_t));
+void mrt_stats __P((off_t, off_t));
- * Copyright (c) 1985, 1988 Regents of the University of California.
+ * Copyright (c) 1983, 1988 Regents of the University of California.
* All rights reserved.
*
* %sccs.include.redist.c%
*/
#ifndef lint
* All rights reserved.
*
* %sccs.include.redist.c%
*/
#ifndef lint
-static char sccsid[] = "@(#)ns.c 5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)ns.c 5.15 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
struct socket sockb;
static char *ns_prpr __P((struct ns_addr *));
struct socket sockb;
static char *ns_prpr __P((struct ns_addr *));
+static void ns_erputil __P((int, int));
-static char sccsid[] = "@(#)route.c 5.23 (Berkeley) %G%";
+static char sccsid[] = "@(#)route.c 5.24 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#define kget(p, d) \
- (kread((off_t)(p), (char *)&(d), sizeof (d)))
+#define kget(p, d) (kread((off_t)(p), (char *)&(d), sizeof (d)))
/*
* Definitions for showing gateway flags.
/*
* Definitions for showing gateway flags.
{ RTF_UP, 'U' },
{ RTF_GATEWAY, 'G' },
{ RTF_HOST, 'H' },
{ RTF_UP, 'U' },
{ RTF_GATEWAY, 'G' },
{ RTF_HOST, 'H' },
{ RTF_DYNAMIC, 'D' },
{ RTF_MODIFIED, 'M' },
{ RTF_DYNAMIC, 'D' },
{ RTF_MODIFIED, 'M' },
+ { RTF_DONE, 'd' }, /* Completed -- for routing messages only */
+ { RTF_MASK, 'm' }, /* Mask Present -- for routing messages only */
{ RTF_CLONING, 'C' },
{ RTF_XRESOLVE, 'X' },
{ RTF_LLINFO, 'L' },
{ RTF_CLONING, 'C' },
{ RTF_XRESOLVE, 'X' },
{ RTF_LLINFO, 'L' },
+ { RTF_PROTO1, '1' },
+ { RTF_PROTO2, '2' },
-static char sccsid[] = "@(#)unix.c 5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)unix.c 5.13 (Berkeley) %G%";
struct uio;
struct proc;
#include <sys/file.h>
struct uio;
struct proc;
#include <sys/file.h>
+
+#include <netinet/in.h>
+
+#include <stdio.h>
#include <stdlib.h>
#include "netstat.h"
#include <stdlib.h>
#include "netstat.h"
-static void unixdomainpr __P((struct socket *, caddr_t));
+static void unixdomainpr __P((struct socket *, caddr_t));
-struct file *file, *fileNFILE;
-int nfiles;
+struct file *file, *fileNFILE;
+int nfiles;
unp->unp_vnode, unp->unp_conn,
unp->unp_refs, unp->unp_nextref);
if (m)
unp->unp_vnode, unp->unp_conn,
unp->unp_refs, unp->unp_nextref);
if (m)
- printf(" %.*s", m->m_len - sizeof(sa->sun_family),
+ printf(" %.*s", m->m_len - (int)sizeof(sa->sun_family),
sa->sun_path);
putchar('\n');
}
sa->sun_path);
putchar('\n');
}