aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorsvn2git <svn2git@FreeBSD.org>1994-05-01 08:00:00 +0000
committersvn2git <svn2git@FreeBSD.org>1994-05-01 08:00:00 +0000
commita16f65c7d117419bd266c28a1901ef129a337569 (patch)
tree2626602f66dc3551e7a7c7bc9ad763c3bc7ab40a /usr.bin/netstat
parent8503f4f13f77abf7adc8f7e329c6f9c1d52b6a20 (diff)
This commit was manufactured to restore the state of the 1.1-RELEASE image. Releases prior to 5.3-RELEASE are omitting the secure/ and crypto/ subdirs.
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/host.c4
-rw-r--r--usr.bin/netstat/if.c6
-rw-r--r--usr.bin/netstat/inet.c5
-rw-r--r--usr.bin/netstat/iso.c10
-rw-r--r--usr.bin/netstat/main.c4
-rw-r--r--usr.bin/netstat/mbuf.c4
-rw-r--r--usr.bin/netstat/ns.c4
-rw-r--r--usr.bin/netstat/route.c188
-rw-r--r--usr.bin/netstat/tp_astring.c78
-rw-r--r--usr.bin/netstat/unix.c8
10 files changed, 228 insertions, 83 deletions
diff --git a/usr.bin/netstat/host.c b/usr.bin/netstat/host.c
index b459fb06b043..041ec2418e76 100644
--- a/usr.bin/netstat/host.c
+++ b/usr.bin/netstat/host.c
@@ -32,7 +32,9 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)host.c 5.12 (Berkeley) 2/2/91";
+/* From: static char sccsid[] = "@(#)host.c 5.12 (Berkeley) 2/2/91"; */
+const char host_c_rcsid[] =
+ "$Id: host.c,v 1.2 1993/11/17 20:19:17 wollman Exp $";
#endif /* not lint */
#include <sys/param.h>
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index 6ec3387ed856..8e75e41c7c1e 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -32,7 +32,9 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)if.c 5.15 (Berkeley) 3/1/91";
+/* From: static char sccsid[] = "@(#)if.c 5.15 (Berkeley) 3/1/91"; */
+static const char if_c_rcsid[] =
+ "$Id: if.c,v 1.3 1994/02/21 11:35:23 rgrimes Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -123,7 +125,7 @@ intpr(interval, ifnetaddr)
(strcmp(name, interface) != 0 || unit != ifnet.if_unit))
continue;
cp = index(name, '\0');
- *cp++ = ifnet.if_unit + '0';
+ cp += sprintf(cp, "%d", ifnet.if_unit);
if ((ifnet.if_flags&IFF_UP) == 0)
*cp++ = '*';
*cp = '\0';
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 2d8fe285d32e..ed80baea14c5 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -32,7 +32,10 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)inet.c 5.15 (Berkeley) 6/18/90";
+/* From: static char sccsid[] = "@(#)inet.c 5.15 (Berkeley) 6/18/90"; */
+static const char inet_c_rcsid[] =
+ "$Id: inet.c,v 1.2 1993/11/17 20:19:20 wollman Exp $";
+
#endif /* not lint */
#include <sys/param.h>
diff --git a/usr.bin/netstat/iso.c b/usr.bin/netstat/iso.c
index 11e2219c95c6..1ba49ffb1347 100644
--- a/usr.bin/netstat/iso.c
+++ b/usr.bin/netstat/iso.c
@@ -32,13 +32,11 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)iso.c 5.6 (Berkeley) 4/27/91";
+/* From: static char sccsid[] = "@(#)iso.c 5.6 (Berkeley) 4/27/91"; */
+static const char iso_c_rcsid[] =
+ "$Id: iso.c,v 1.4 1993/11/17 20:19:21 wollman Exp $";
#endif /* not lint */
-/*
- * $Header: /a/cvs/386BSD/src/usr.bin/netstat/iso.c,v 1.2 1993/09/05 23:41:49 rgrimes Exp $
- * $Source: /a/cvs/386BSD/src/usr.bin/netstat/iso.c,v $
- */
/*******************************************************************************
Copyright IBM Corporation 1987
@@ -85,7 +83,7 @@ SOFTWARE.
#undef satosiso
#include <netiso/tp_param.h>
#include <netiso/tp_states.h>
-#include <netiso/tp_astring.c>
+#include "tp_astring.c"
#include <netiso/tp_pcb.h>
#include <netiso/tp_stat.h>
#include <netiso/iso_pcb.h>
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index 95bc1e5d5758..6809f4c0475c 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -38,7 +38,9 @@ char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 5.23 (Berkeley) 7/1/91";
+/* From: static char sccsid[] = "@(#)main.c 5.23 (Berkeley) 7/1/91"; */
+const char main_c_rcsid[] =
+ "$Id: main.c,v 1.2 1993/11/17 20:19:22 wollman Exp $";
#endif /* not lint */
#include <sys/param.h>
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c
index 36c10037145f..531699123c4f 100644
--- a/usr.bin/netstat/mbuf.c
+++ b/usr.bin/netstat/mbuf.c
@@ -32,7 +32,9 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)mbuf.c 5.10 (Berkeley) 1/30/91";
+/* From: static char sccsid[] = "@(#)mbuf.c 5.10 (Berkeley) 1/30/91"; */
+static const char mbuf_c_rcsid[] =
+ "$Id: mbuf.c,v 1.2 1993/11/17 20:19:23 wollman Exp $";
#endif /* not lint */
#include <stdio.h>
diff --git a/usr.bin/netstat/ns.c b/usr.bin/netstat/ns.c
index 8bdc89cfe3c4..2258b9abdbed 100644
--- a/usr.bin/netstat/ns.c
+++ b/usr.bin/netstat/ns.c
@@ -32,7 +32,9 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)ns.c 5.13 (Berkeley) 3/1/91";
+/* From: static char sccsid[] = "@(#)ns.c 5.13 (Berkeley) 3/1/91"; */
+static const char ns_c_rcsid[] =
+ "$Id: ns.c,v 1.2 1993/11/17 20:19:24 wollman Exp $";
#endif /* not lint */
#include <sys/param.h>
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 582f52c7e70c..d7d1350a0678 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -32,7 +32,9 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)route.c 5.20 (Berkeley) 11/29/90";
+/* From: static char sccsid[] = "@(#)route.c 5.20 (Berkeley) 11/29/90"; */
+static const char route_c_rcsid[] =
+ "$Id: route.c,v 1.9 1993/12/17 16:52:18 wollman Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -54,6 +56,7 @@ static char sccsid[] = "@(#)route.c 5.20 (Berkeley) 11/29/90";
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
extern int nflag, aflag, Aflag, af;
int do_rtent;
@@ -61,7 +64,7 @@ extern char *routename(), *netname(), *plural();
#ifdef NS
extern char *ns_print();
#endif
-extern char *malloc();
+
#define kget(p, d) \
(kvm_read((off_t)(p), (char *)&(d), sizeof (d)))
@@ -81,6 +84,8 @@ struct bits {
{ RTF_XRESOLVE, 'X' },
{ RTF_LLINFO, 'L' },
{ RTF_REJECT, 'R' },
+ { RTF_PROTO2, '2' },
+ { RTF_PROTO1, '1' },
{ 0 }
};
@@ -96,6 +101,18 @@ p_proto(proto)
case AF_INET:
printf("inet");
break;
+ case AF_NS:
+ printf("NS");
+ break;
+ case AF_OSI:
+ printf("OSI");
+ break;
+ case AF_CCITT:
+ printf("CCITT");
+ break;
+ case AF_APPLETALK:
+ printf("AppleTalk");
+ break;
default:
printf("%d", proto);
break;
@@ -106,6 +123,7 @@ p_proto(proto)
/*
* Print routing tables.
*/
+int
routepr(hostaddr, netaddr, hashsizeaddr, treeaddr)
off_t hostaddr, netaddr, hashsizeaddr, treeaddr;
{
@@ -117,50 +135,26 @@ routepr(hostaddr, netaddr, hashsizeaddr, treeaddr)
int hashsize;
int i, doinghost = 1;
+ if (!treeaddr) {
+ printf("Could not find routing tables\n");
+ return 1;
+ }
printf("Routing tables\n");
if (Aflag)
printf("%-8.8s ","Address");
- printf("%-16.16s %-18.18s %-6.6s %6.6s%8.8s %s\n",
+ printf("%-16.16s %-18.18s %-6.6s %6.6s%8.8s %-5.5s",
"Destination", "Gateway",
- "Flags", "Refs", "Use", "Interface");
- if (treeaddr)
- return treestuff(treeaddr);
- if (hostaddr == 0) {
- printf("rthost: symbol not in namelist\n");
- return;
- }
- if (netaddr == 0) {
- printf("rtnet: symbol not in namelist\n");
- return;
- }
- if (hashsizeaddr == 0) {
- printf("rthashsize: symbol not in namelist\n");
- return;
- }
- kget(hashsizeaddr, hashsize);
- routehash = (struct mbuf **)malloc( hashsize*sizeof (struct mbuf *) );
- kvm_read(hostaddr, (char *)routehash, hashsize*sizeof (struct mbuf *));
-again:
- for (i = 0; i < hashsize; i++) {
- if (routehash[i] == 0)
- continue;
- m = routehash[i];
- while (m) {
- kget(m, mb);
- if (Aflag)
- printf("%8.8x ", m);
- p_ortentry((struct ortentry *)(mb.m_dat));
- m = mb.m_next;
- }
- }
- if (doinghost) {
- kvm_read(netaddr, (char *)routehash,
- hashsize*sizeof (struct mbuf *));
- doinghost = 0;
- goto again;
+ "Flags", "Refs", "Use", "Iface");
+ if(!aflag) {
+ printf("%-6.6s %-6.6s\n", "MTU", "Rtt");
+ } else {
+ printf("\n %8s %8s %8s %8s %8s %8s %8s %8s\n",
+ "MTU", "Hopcount", "Expire", "recvpipe",
+ "sendpipe", "ssthresh", "RTT", "RTT var.");
}
- free((char *)routehash);
- return;
+
+ return treestuff(treeaddr);
+
}
static union {
@@ -355,15 +349,14 @@ int flags, width;
default:
{
- register u_short *s = ((u_short *)sa->sa_data), *slim;
+ register u_char *s = ((u_char *)sa->sa_data), *slim;
- slim = (u_short *) sa + ((sa->sa_len + sizeof(u_short) - 1) /
- sizeof(u_short));
+ slim = (u_char *) sa + sa->sa_len;
cp = workbuf;
cplim = cp + sizeof(workbuf) - 6;
cp += sprintf(cp, "(%d)", sa->sa_family);
while (s < slim && cp < cplim)
- cp += sprintf(cp, " %x", *s++);
+ cp += sprintf(cp, " %02x%02x", s[0], s[1]), s += 2;
cp = workbuf;
}
}
@@ -407,29 +400,90 @@ register struct rtentry *rt;
}
kget(rt->rt_ifp, ifnet);
kvm_read((off_t)ifnet.if_name, name, 16);
- printf(" %.15s%d%s", name, ifnet.if_unit,
- rt->rt_nodes[0].rn_dupedkey ? " =>\n" : "\n");
-}
-
-p_ortentry(rt)
-register struct ortentry *rt;
-{
- char name[16], *flags;
- register struct bits *p;
- register struct sockaddr_in *sin;
- struct ifnet ifnet;
-
- p_sockaddr(&rt->rt_dst, rt->rt_flags, 16);
- p_sockaddr(&rt->rt_gateway, 0, 18);
- p_flags(rt->rt_flags, "%-6.6s ");
- printf("%6d %8d ", rt->rt_refcnt, rt->rt_use);
- if (rt->rt_ifp == 0) {
- putchar('\n');
- return;
+ printf(" %.2s%d", name, ifnet.if_unit);
+ if(aflag) {
+ /*
+ * MTU
+ */
+ if(rt->rt_rmx.rmx_mtu)
+ printf("\n %7d%c", rt->rt_rmx.rmx_mtu,
+ (rt->rt_rmx.rmx_locks & RTV_MTU) ? '*' : ' ');
+ else
+ printf("\n %7s ", "-");
+
+ /*
+ * Hop count
+ */
+ if(rt->rt_rmx.rmx_hopcount)
+ printf(" %7d%c", rt->rt_rmx.rmx_hopcount,
+ (rt->rt_rmx.rmx_locks & RTV_HOPCOUNT) ? '*' : ' ');
+ else
+ printf(" %7s ", "-");
+
+ /*
+ * Expiration time
+ */
+ if(rt->rt_rmx.rmx_expire)
+ printf(" %7d%c", rt->rt_rmx.rmx_expire,
+ (rt->rt_rmx.rmx_locks & RTV_EXPIRE) ? '*' : ' ');
+ else
+ printf(" %7s ", "-");
+
+ /*
+ * Receive pipe size (bytes)
+ */
+ if(rt->rt_rmx.rmx_recvpipe)
+ printf(" %7d%c", rt->rt_rmx.rmx_recvpipe,
+ (rt->rt_rmx.rmx_locks & RTV_RPIPE) ? '*' : ' ');
+ else
+ printf(" %7s ", "-");
+
+ /*
+ * Send pipe size (bytes)
+ */
+ if(rt->rt_rmx.rmx_sendpipe)
+ printf(" %7d%c", rt->rt_rmx.rmx_sendpipe,
+ (rt->rt_rmx.rmx_locks & RTV_SPIPE) ? '*' : ' ');
+ else
+ printf(" %7s ", "-");
+
+ /*
+ * Slow-start threshold (bytes)
+ */
+ if(rt->rt_rmx.rmx_ssthresh)
+ printf(" %7d%c", rt->rt_rmx.rmx_ssthresh,
+ (rt->rt_rmx.rmx_locks & RTV_SSTHRESH) ? '*' : ' ');
+ else
+ printf(" %7s ", "-");
+
+ /*
+ * Round-trip time (seconds)
+ */
+ if(rt->rt_rmx.rmx_rtt)
+ printf(" %7.4f%c", (1.0 * rt->rt_rmx.rmx_rtt) / RTM_RTTUNIT,
+ (rt->rt_rmx.rmx_locks & RTV_RTT) ? '*' : ' ');
+ else
+ printf(" %7s ", "-");
+
+ /*
+ * Round-trip time variance (seconds)
+ */
+ if(rt->rt_rmx.rmx_rttvar)
+ printf(" %7.4f%c", (1.0 * rt->rt_rmx.rmx_rttvar) / RTM_RTTUNIT,
+ (rt->rt_rmx.rmx_locks & RTV_RTTVAR) ? '*' : ' ');
+ else
+ printf(" %7s ", "-");
+ } else { /* no -a flag */
+ if(rt->rt_rmx.rmx_mtu)
+ printf(" %6d", rt->rt_rmx.rmx_mtu);
+ else
+ printf(" %-6s", "-");
+ if(rt->rt_rmx.rmx_rtt)
+ printf(" %6.3f", (1. * rt->rt_rmx.rmx_rtt) / RTM_RTTUNIT);
+ else
+ printf(" %-6s", "-");
}
- kget(rt->rt_ifp, ifnet);
- kvm_read((off_t)ifnet.if_name, name, 16);
- printf(" %.15s%d\n", name, ifnet.if_unit);
+ printf(rt->rt_nodes[0].rn_dupedkey ? " =>\n" : "\n");
}
char *
diff --git a/usr.bin/netstat/tp_astring.c b/usr.bin/netstat/tp_astring.c
new file mode 100644
index 000000000000..654bab6999d4
--- /dev/null
+++ b/usr.bin/netstat/tp_astring.c
@@ -0,0 +1,78 @@
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)tp_astring.c 7.4 (Berkeley) 5/6/91
+ * $Id: tp_astring.c,v 1.1 1993/11/16 01:44:52 wollman Exp $
+ */
+
+#ifndef _NFILE
+#include <stdio.h>
+#endif _NFILE
+char *tp_sstring[] = {
+"ST_ERROR(0x0)",
+"TP_CLOSED(0x1)",
+"TP_CRSENT(0x2)",
+"TP_AKWAIT(0x3)",
+"TP_OPEN(0x4)",
+"TP_CLOSING(0x5)",
+"TP_REFWAIT(0x6)",
+"TP_LISTENING(0x7)",
+"TP_CONFIRMING(0x8)",
+};
+
+char *tp_estring[] = {
+"TM_inact(0x0)",
+"TM_retrans(0x1)",
+"TM_sendack(0x2)",
+"TM_notused(0x3)",
+"TM_reference(0x4)",
+"TM_data_retrans(0x5)",
+"ER_TPDU(0x6)",
+"CR_TPDU(0x7)",
+"DR_TPDU(0x8)",
+"DC_TPDU(0x9)",
+"CC_TPDU(0xa)",
+"AK_TPDU(0xb)",
+"DT_TPDU(0xc)",
+"XPD_TPDU(0xd)",
+"XAK_TPDU(0xe)",
+"T_CONN_req(0xf)",
+"T_DISC_req(0x10)",
+"T_LISTEN_req(0x11)",
+"T_DATA_req(0x12)",
+"T_XPD_req(0x13)",
+"T_USR_rcvd(0x14)",
+"T_USR_Xrcvd(0x15)",
+"T_DETACH(0x16)",
+"T_NETRESET(0x17)",
+"T_ACPT_req(0x18)",
+};
diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c
index a9225d536da6..3c8857455159 100644
--- a/usr.bin/netstat/unix.c
+++ b/usr.bin/netstat/unix.c
@@ -32,7 +32,9 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)unix.c 5.11 (Berkeley) 7/1/91";
+/* from: static char sccsid[] = "@(#)unix.c 5.11 (Berkeley) 7/1/91"; */
+static const char unix_c_rcsid[] =
+ "$Id: unix.c,v 1.5 1994/02/04 03:17:15 wollman Exp $";
#endif /* not lint */
/*
@@ -133,7 +135,7 @@ unixdomainpr(so, soaddr)
} else
m = (struct mbuf *)0;
if (first) {
- printf("Active UNIX domain sockets\n");
+ printf("Active local domain sockets\n");
printf(
"%-8.8s %-6.6s %-6.6s %-6.6s %8.8s %8.8s %8.8s %8.8s Addr\n",
"Address", "Type", "Recv-Q", "Send-Q",
@@ -145,7 +147,7 @@ unixdomainpr(so, soaddr)
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 - sizeof(sa->sun_family) - 1,
sa->sun_path);
putchar('\n');
}