diff options
author | peter <peter@FreeBSD.org> | 2003-03-05 19:20:29 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2003-03-05 19:20:29 +0000 |
commit | 6467f119a1ad62ff9f05c304ee003b4e44b53f66 (patch) | |
tree | 72211e01f1c5e835f3fc9f66f9e75b6dd4cc80bd /usr.bin | |
parent | 60fad63fbf9c78c2146cc731d77f894e904ff08d (diff) | |
download | FreeBSD-src-6467f119a1ad62ff9f05c304ee003b4e44b53f66.zip FreeBSD-src-6467f119a1ad62ff9f05c304ee003b4e44b53f66.tar.gz |
Kill #ifdef NS and some leftover #ifdef ISO code. Re-pack the nlist[]
array, it isn't likely to find any ARPAnet IMP drivers in FreeBSD.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/netstat/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/netstat/if.c | 31 | ||||
-rw-r--r-- | usr.bin/netstat/iso.c | 816 | ||||
-rw-r--r-- | usr.bin/netstat/main.c | 154 | ||||
-rw-r--r-- | usr.bin/netstat/ns.c | 345 | ||||
-rw-r--r-- | usr.bin/netstat/route.c | 83 |
6 files changed, 34 insertions, 1397 deletions
diff --git a/usr.bin/netstat/Makefile b/usr.bin/netstat/Makefile index 2cb8485..876e928 100644 --- a/usr.bin/netstat/Makefile +++ b/usr.bin/netstat/Makefile @@ -3,7 +3,7 @@ PROG= netstat SRCS= if.c inet.c inet6.c main.c mbuf.c mroute.c ipx.c route.c \ - unix.c atalk.c netgraph.c mroute6.c ipsec.c # iso.c ns.c tp_astring.c + unix.c atalk.c netgraph.c mroute6.c ipsec.c CFLAGS+=-DIPSEC CFLAGS+=-DINET6 diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index 7b85ddf..e563907 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -55,14 +55,6 @@ static const char rcsid[] = #include <netinet/in_var.h> #include <netipx/ipx.h> #include <netipx/ipx_if.h> -#ifdef NS -#include <netns/ns.h> -#include <netns/ns_if.h> -#endif -#ifdef ISO -#include <netiso/iso.h> -#include <netiso/iso_var.h> -#endif #include <arpa/inet.h> #include <signal.h> @@ -163,12 +155,6 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *)) struct in6_ifaddr in6; #endif struct ipx_ifaddr ipx; -#ifdef NS - struct ns_ifaddr ns; -#endif -#ifdef ISO - struct iso_ifaddr iso; -#endif } ifaddr; u_long ifaddraddr; u_long ifaddrfound; @@ -347,23 +333,6 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *)) printf("atalk:%-12.12s ",atalk_print(sa,0x10) ); printf("%-11.11s ",atalk_print(sa,0x0b) ); break; -#ifdef NS - case AF_NS: - { - struct sockaddr_ns *sns = - (struct sockaddr_ns *)sa; - u_long net; - char netnum[10]; - - *(union ns_net *) &net = sns->sns_addr.x_net; - sprintf(netnum, "%lxH", ntohl(net)); - upHex(netnum); - printf("ns:%-10s ", netnum); - printf("%-17s ", - ns_phost((struct sockaddr *)sns)); - } - break; -#endif case AF_LINK: { struct sockaddr_dl *sdl = diff --git a/usr.bin/netstat/iso.c b/usr.bin/netstat/iso.c deleted file mode 100644 index c0de1d1..0000000 --- a/usr.bin/netstat/iso.c +++ /dev/null @@ -1,816 +0,0 @@ -/* - * Copyright (c) 1983, 1988, 1993 - * 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. - */ - -#ifndef lint -static char sccsid[] = "@(#)iso.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * $FreeBSD$ - */ -/******************************************************************************* - Copyright IBM Corporation 1987 - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of IBM not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL -IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -*******************************************************************************/ - -/* - * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison - */ - -#include <sys/param.h> -#include <sys/mbuf.h> -#include <sys/time.h> -#include <sys/domain.h> -#include <sys/protosw.h> -#include <sys/socket.h> -#include <sys/socketvar.h> -#include <sys/queue.h> -#include <errno.h> -#include <net/if.h> -#include <net/route.h> -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/ip.h> -#include <netinet/in_pcb.h> -#include <netinet/ip_var.h> -#include <netiso/iso.h> -#include <netiso/iso_errno.h> -#include <netiso/clnp.h> -#include <netiso/esis.h> -#include <netiso/clnp_stat.h> -#include <netiso/argo_debug.h> -#undef satosiso -#include <netiso/tp_param.h> -#include <netiso/tp_states.h> -#include <netiso/tp_pcb.h> -#include <netiso/tp_stat.h> -#include <netiso/iso_pcb.h> -#include <netiso/cltp_var.h> -#include <netiso/cons.h> -#ifdef IncStat -#undef IncStat -#endif -#include <netiso/cons_pcb.h> -#include <arpa/inet.h> -#include <netdb.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include "netstat.h" - -static void tprintstat (struct tp_stat *, int); -static void isonetprint (struct sockaddr_iso *, int); -static void hexprint (int, char *, char *); -extern void inetprint (struct in_addr *, int, char *); - -/* - * Dump esis stats - */ -void -esis_stats(u_long off, const char *name, int af __unused) -{ - struct esis_stat esis_stat; - - if (off == 0 || - kread(off, (char *)&esis_stat, sizeof (struct esis_stat))) - return; - printf("%s:\n", name); - printf("\t%d esh sent, %d esh received\n", esis_stat.es_eshsent, - esis_stat.es_eshrcvd); - printf("\t%d ish sent, %d ish received\n", esis_stat.es_ishsent, - esis_stat.es_ishrcvd); - printf("\t%d rd sent, %d rd received\n", esis_stat.es_rdsent, - esis_stat.es_rdrcvd); - printf("\t%d pdus not sent due to insufficient memory\n", - esis_stat.es_nomem); - printf("\t%d pdus received with bad checksum\n", esis_stat.es_badcsum); - printf("\t%d pdus received with bad version number\n", - esis_stat.es_badvers); - printf("\t%d pdus received with bad type field\n", esis_stat.es_badtype); - printf("\t%d short pdus received\n", esis_stat.es_toosmall); -} - -/* - * Dump clnp statistics structure. - */ -void -clnp_stats(u_long off, const char *name, int af __unused) -{ - struct clnp_stat clnp_stat; - - if (off == 0 || - kread(off, (char *)&clnp_stat, sizeof (clnp_stat))) - return; - - printf("%s:\n\t%d total packets sent\n", name, clnp_stat.cns_sent); - printf("\t%d total fragments sent\n", clnp_stat.cns_fragments); - printf("\t%d total packets received\n", clnp_stat.cns_total); - printf("\t%d with fixed part of header too small\n", - clnp_stat.cns_toosmall); - printf("\t%d with header length not reasonable\n", clnp_stat.cns_badhlen); - printf("\t%d incorrect checksum%s\n", - clnp_stat.cns_badcsum, plural(clnp_stat.cns_badcsum)); - printf("\t%d with unreasonable address lengths\n", clnp_stat.cns_badaddr); - printf("\t%d with forgotten segmentation information\n", - clnp_stat.cns_noseg); - printf("\t%d with an incorrect protocol identifier\n", clnp_stat.cns_noproto); - printf("\t%d with an incorrect version\n", clnp_stat.cns_badvers); - printf("\t%d dropped because the ttl has expired\n", - clnp_stat.cns_ttlexpired); - printf("\t%d clnp cache misses\n", clnp_stat.cns_cachemiss); - printf("\t%d clnp congestion experience bits set\n", - clnp_stat.cns_congest_set); - printf("\t%d clnp congestion experience bits received\n", - clnp_stat.cns_congest_rcvd); -} -/* - * Dump CLTP statistics structure. - */ -void -cltp_stats(u_long off, const char *name, int af __unused) -{ - struct cltpstat cltpstat; - - if (off == 0 || - kread(off, (char *)&cltpstat, sizeof (cltpstat))) - return; - printf("%s:\n\t%u incomplete header%s\n", name, - cltpstat.cltps_hdrops, plural(cltpstat.cltps_hdrops)); - printf("\t%u bad data length field%s\n", - cltpstat.cltps_badlen, plural(cltpstat.cltps_badlen)); - printf("\t%u bad checksum%s\n", - cltpstat.cltps_badsum, plural(cltpstat.cltps_badsum)); -} - -struct tp_pcb tpcb; -struct isopcb isopcb; -struct socket sockb; -union { - struct sockaddr_iso siso; - char data[128]; -} laddr, faddr; -#define kget(o, p) \ - (kread((u_long)(o), (char *)&p, sizeof (p))) - -static int first = 1; - -/* - * Print a summary of connections related to an Internet - * protocol. For TP, also give state of connection. - * Listening processes (aflag) are suppressed unless the - * -a (all) flag is specified. - */ -void -iso_protopr(u_long off, const char *name, int af __unused) -{ - struct isopcb cb; - struct isopcb *prev, *next; - - if (off == 0) { - printf("%s control block: symbol not in namelist\n", name); - return; - } - if (strcmp(name, "tp") == 0) { - tp_protopr(off, name); - return; - } - if (kread(off, (char *)&cb, sizeof(cb))) - return; - isopcb = cb; - prev = (struct isopcb *)off; - if (isopcb.isop_next == (struct isopcb *)off) - return; - while (isopcb.isop_next != (struct isopcb *)off) { - next = isopcb.isop_next; - kget(next, isopcb); - if (isopcb.isop_prev != prev) { - printf("prev 0x%x next 0x%x isop_prev 0x%x isop_next 0x%x???\n", - prev, next, isopcb.isop_prev, isopcb.isop_next); - break; - } - kget(isopcb.isop_socket, sockb); - iso_protopr1((u_long)next, 0); - putchar('\n'); - prev = next; - } -} - -void -iso_protopr1(u_long kern_addr, int istp) -{ - if (first) { - printf("Active ISO net connections"); - if (aflag) - printf(" (including servers)"); - putchar('\n'); - if (Aflag) - printf("%-8.8s ", "PCB"); - printf(Aflag ? - "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" : - "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n", - "Proto", "Recv-Q", "Send-Q", - "Local Address", "Foreign Address", "(state)"); - first = 0; - } - if (Aflag) - printf("%8x ", - (sockb.so_pcb ? (void *)sockb.so_pcb : (void *)kern_addr)); - printf("%-5.5s %6u %6u ", "tp", sockb.so_rcv.sb_cc, sockb.so_snd.sb_cc); - if (istp && tpcb.tp_lsuffixlen) { - hexprint(tpcb.tp_lsuffixlen, tpcb.tp_lsuffix, "()"); - printf("\t"); - } else if (isopcb.isop_laddr == 0) - printf("*.*\t"); - else { - if ((char *)isopcb.isop_laddr == ((char *)kern_addr) + - _offsetof(struct isopcb, isop_sladdr)) - laddr.siso = isopcb.isop_sladdr; - else - kget(isopcb.isop_laddr, laddr); - isonetprint((struct sockaddr_iso *)&laddr, 1); - } - if (istp && tpcb.tp_fsuffixlen) { - hexprint(tpcb.tp_fsuffixlen, tpcb.tp_fsuffix, "()"); - printf("\t"); - } else if (isopcb.isop_faddr == 0) - printf("*.*\t"); - else { - if ((char *)isopcb.isop_faddr == ((char *)kern_addr) + - _offsetof(struct isopcb, isop_sfaddr)) - faddr.siso = isopcb.isop_sfaddr; - else - kget(isopcb.isop_faddr, faddr); - isonetprint((struct sockaddr_iso *)&faddr, 0); - } -} - -void -tp_protopr(u_long off, const char *name, int af __unused) -{ - extern char *tp_sstring[]; - struct tp_ref *tpr, *tpr_base; - struct tp_refinfo tpkerninfo; - int size; - - kget(off, tpkerninfo); - size = tpkerninfo.tpr_size * sizeof (*tpr); - tpr_base = (struct tp_ref *)malloc(size); - if (tpr_base == 0) - return; - kread((u_long)(tpkerninfo.tpr_base), (char *)tpr_base, size); - for (tpr = tpr_base; tpr < tpr_base + tpkerninfo.tpr_size; tpr++) { - if (tpr->tpr_pcb == 0) - continue; - kget(tpr->tpr_pcb, tpcb); - if (tpcb.tp_state == ST_ERROR) - printf("undefined tpcb state: 0x%x\n", tpr->tpr_pcb); - if (!aflag && - (tpcb.tp_state == TP_LISTENING || - tpcb.tp_state == TP_CLOSED || - tpcb.tp_state == TP_REFWAIT)) { - continue; - } - kget(tpcb.tp_sock, sockb); - if (tpcb.tp_npcb) switch(tpcb.tp_netservice) { - case IN_CLNS: - tp_inproto((u_long)tpkerninfo.tpr_base); - break; - default: - kget(tpcb.tp_npcb, isopcb); - iso_protopr1((u_long)tpcb.tp_npcb, 1); - break; - } - if (tpcb.tp_state >= tp_NSTATES) - printf(" %d", tpcb.tp_state); - else - printf(" %-12.12s", tp_sstring[tpcb.tp_state]); - putchar('\n'); - } -} - -void -tp_inproto(u_long pcb) -{ - struct inpcb inpcb; - kget(tpcb.tp_npcb, inpcb); - if (!aflag && inet_lnaof(inpcb.inp_laddr) == INADDR_ANY) - return; - if (Aflag) - printf("%8x ", pcb); - printf("%-5.5s %6u %6u ", "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"); -} - -/* - * Pretty print an iso address (net address + port). - * If the numeric_addr or numeric_port were specified, - * use numbers instead of names. - */ - -#ifdef notdef -char * -isonetname(struct iso_addr *iso) -{ - struct sockaddr_iso sa; - struct iso_hostent *ihe = 0; - struct iso_hostent *iso_gethostentrybyaddr(); - struct iso_hostent *iso_getserventrybytsel(); - struct iso_hostent Ihe; - static char line[80]; - - bzero(line, sizeof(line)); - if( iso->isoa_afi ) { - sa.siso_family = AF_ISO; - sa.siso_addr = *iso; - sa.siso_tsuffix = 0; - - if ( !numeric_addr ) - ihe = iso_gethostentrybyaddr( &sa, 0, 0 ); - if( ihe ) { - Ihe = *ihe; - ihe = &Ihe; - sprintf(line, "%s", ihe->isoh_hname); - } else { - sprintf(line, "%s", iso_ntoa(iso)); - } - } else { - sprintf(line, "*"); - } - return line; -} - -static void -isonetprint(struct iso_addr *iso, char *sufx, u_short sufxlen, int islocal) -{ - struct iso_hostent *iso_getserventrybytsel(), *ihe; - struct iso_hostent Ihe; - char *line, *cp; - int Alen = Aflag?18:22; - - line = isonetname(iso); - cp = index(line, '\0'); - ihe = (struct iso_hostent *)0; - - if( islocal ) - islocal = 20; - else - islocal = 22 + Alen; - - if(Aflag) - islocal += 10 ; - - if(!numeric_addr) { - if( (cp -line)>10 ) { - cp = line+10; - bzero(cp, sizeof(line)-10); - } - } - - *cp++ = '.'; - if(sufxlen) { - if( !Aflag && !numeric_port && (ihe=iso_getserventrybytsel(sufx, sufxlen))) { - Ihe = *ihe; - ihe = &Ihe; - } - if( ihe && (strlen(ihe->isoh_aname)>0) ) { - sprintf(cp, "%s", ihe->isoh_aname); - } else { - iso_sprinttsel(cp, sufx, sufxlen); - } - } else - sprintf(cp, "*"); - /* - fprintf(stdout, Aflag?" %-18.18s":" %-22.22s", line); - */ - - if( strlen(line) > Alen ) { - fprintf(stdout, " %s", line); - fprintf(stdout, "\n %*.s", islocal+Alen," "); - } else { - fprintf(stdout, " %-*.*s", Alen, Alen,line); - } -} -#endif - -#ifdef notdef -static void -x25_protopr(u_long off, const char *name, int af __unused) -{ - static char *xpcb_states[] = { - "CLOSED", - "LISTENING", - "CLOSING", - "CONNECTING", - "ACKWAIT", - "OPEN", - }; - struct isopcb *prev, *next; - struct x25_pcb xpcb; - - if (off == 0) { - printf("%s control block: symbol not in namelist\n", name); - return; - } - kread(off, &xpcb, sizeof (struct x25_pcb)); - prev = (struct isopcb *)off; - if (xpcb.x_next == (struct isopcb *)off) - return; - while (xpcb.x_next != (struct isopcb *)off) { - next = isopcb.isop_next; - kread((u_long)next, &xpcb, sizeof (struct x25_pcb)); - if (xpcb.x_prev != prev) { - printf("???\n"); - break; - } - kread((u_long)xpcb.x_socket, &sockb, sizeof (sockb)); - - if (!aflag && - xpcb.x_state == LISTENING || - xpcb.x_state == TP_CLOSED ) { - prev = next; - continue; - } - if (first) { - printf("Active X25 net connections"); - if (aflag) - printf(" (including servers)"); - putchar('\n'); - if (Aflag) - printf("%-8.8s ", "PCB"); - printf(Aflag ? - "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" : - "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n", - "Proto", "Recv-Q", "Send-Q", - "Local Address", "Foreign Address", "(state)"); - first = 0; - } - printf("%-5.5s %6u %6u ", name, sockb.so_rcv.sb_cc, - sockb.so_snd.sb_cc); - isonetprint(&xpcb.x_laddr.siso_addr, &xpcb.x_lport, - sizeof(xpcb.x_lport), 1); - isonetprint(&xpcb.x_faddr.siso_addr, &xpcb.x_fport, - sizeof(xpcb.x_lport), 0); - if (xpcb.x_state < 0 || xpcb.x_state >= x25_NSTATES) - printf(" 0x0x0x0x0x0x0x0x0x%x", xpcb.x_state); - else - printf(" %-12.12s", xpcb_states[xpcb.x_state]); - putchar('\n'); - prev = next; - } -} -#endif - -struct tp_stat tp_stat; - -void -tp_stats(caddr_t off, caddr_t name) -{ - if (off == 0) { - printf("TP not configured\n\n"); - return; - } - printf("%s:\n", name); - kget(off, tp_stat); - tprintstat(&tp_stat, 8); -} - -#define OUT stdout - -static void -tprintstat(struct tp_stat *s, int indent) -{ - fprintf(OUT, - "%*sReceiving:\n",indent," "); - fprintf(OUT, - "\t%*s%d variable parameter%s ignored\n", indent," ", - s->ts_param_ignored ,plural(s->ts_param_ignored)); - fprintf(OUT, - "\t%*s%d invalid parameter code%s\n", indent, " ", - s->ts_inv_pcode ,plural(s->ts_inv_pcode)); - fprintf(OUT, - "\t%*s%d invalid parameter value%s\n", indent, " ", - s->ts_inv_pval ,plural(s->ts_inv_pval)); - fprintf(OUT, - "\t%*s%d invalid dutype%s\n", indent, " ", - s->ts_inv_dutype ,plural(s->ts_inv_dutype)); - fprintf(OUT, - "\t%*s%d negotiation failure%s\n", indent, " ", - s->ts_negotfailed ,plural(s->ts_negotfailed)); - fprintf(OUT, - "\t%*s%d invalid destination reference%s\n", indent, " ", - s->ts_inv_dref ,plural(s->ts_inv_dref)); - fprintf(OUT, - "\t%*s%d invalid suffix parameter%s\n", indent, " ", - s->ts_inv_sufx ,plural(s->ts_inv_sufx)); - fprintf(OUT, - "\t%*s%d invalid length\n",indent, " ", s->ts_inv_length); - fprintf(OUT, - "\t%*s%d invalid checksum%s\n", indent, " ", - s->ts_bad_csum ,plural(s->ts_bad_csum)); - fprintf(OUT, - "\t%*s%d DT%s out of order\n", indent, " ", - s->ts_dt_ooo ,plural(s->ts_dt_ooo)); - fprintf(OUT, - "\t%*s%d DT%s not in window\n", indent, " ", - s->ts_dt_niw ,plural(s->ts_dt_niw)); - fprintf(OUT, - "\t%*s%d duplicate DT%s\n", indent, " ", - s->ts_dt_dup ,plural(s->ts_dt_dup)); - fprintf(OUT, - "\t%*s%d XPD%s not in window\n", indent, " ", - s->ts_xpd_niw ,plural(s->ts_xpd_niw)); - fprintf(OUT, - "\t%*s%d XPD%s w/o credit to stash\n", indent, " ", - s->ts_xpd_dup ,plural(s->ts_xpd_dup)); - fprintf(OUT, - "\t%*s%d time%s local credit reneged\n", indent, " ", - s->ts_lcdt_reduced ,plural(s->ts_lcdt_reduced)); - fprintf(OUT, - "\t%*s%d concatenated TPDU%s\n", indent, " ", - s->ts_concat_rcvd ,plural(s->ts_concat_rcvd)); - fprintf(OUT, - "%*sSending:\n", indent, " "); - fprintf(OUT, - "\t%*s%d XPD mark%s discarded\n", indent, " ", - s->ts_xpdmark_del ,plural(s->ts_xpdmark_del)); - fprintf(OUT, - "\t%*sXPD stopped data flow %d time%s\n", indent, " ", - s->ts_xpd_intheway ,plural(s->ts_xpd_intheway)); - fprintf(OUT, - "\t%*s%d time%s foreign window closed\n", indent, " ", - s->ts_zfcdt ,plural(s->ts_zfcdt)); - fprintf(OUT, - "%*sMiscellaneous:\n", indent, " "); - fprintf(OUT, - "\t%*s%d small mbuf%s\n", indent, " ", - s->ts_mb_small ,plural(s->ts_mb_small)); - fprintf(OUT, - "\t%*s%d cluster%s\n", indent, " ", - s->ts_mb_cluster, plural(s->ts_mb_cluster)); - fprintf(OUT, - "\t%*s%d source quench \n",indent, " ", - s->ts_quench); - fprintf(OUT, - "\t%*s%d dec bit%s\n", indent, " ", - s->ts_rcvdecbit, plural(s->ts_rcvdecbit)); - fprintf(OUT, - "\t%*sM:L ( M mbuf chains of length L)\n", indent, " "); - { - int j; - - fprintf(OUT, "\t%*s%d: over 16\n", indent, " ", - s->ts_mb_len_distr[0]); - for( j=1; j<=8; j++) { - fprintf(OUT, - "\t%*s%d: %d\t\t%d: %d\n", indent, " ", - s->ts_mb_len_distr[j],j, - s->ts_mb_len_distr[j<<1],j<<1 - ); - } - } - fprintf(OUT, - "\t%*s%d EOT rcvd\n", indent, " ", s->ts_eot_input); - fprintf(OUT, - "\t%*s%d EOT sent\n", indent, " ", s->ts_EOT_sent); - fprintf(OUT, - "\t%*s%d EOT indication%s\n", indent, " ", - s->ts_eot_user ,plural(s->ts_eot_user)); - - fprintf(OUT, - "%*sConnections:\n", indent, " "); - fprintf(OUT, - "\t%*s%d connection%s used extended format\n", indent, " ", - s->ts_xtd_fmt ,plural(s->ts_xtd_fmt)); - fprintf(OUT, - "\t%*s%d connection%s allowed transport expedited data\n", indent, " ", - s->ts_use_txpd ,plural(s->ts_use_txpd)); - fprintf(OUT, - "\t%*s%d connection%s turned off checksumming\n", indent, " ", - s->ts_csum_off ,plural(s->ts_csum_off)); - fprintf(OUT, - "\t%*s%d connection%s dropped due to retrans limit\n", indent, " ", - s->ts_conn_gaveup ,plural(s->ts_conn_gaveup)); - fprintf(OUT, - "\t%*s%d tp 4 connection%s\n", indent, " ", - s->ts_tp4_conn ,plural(s->ts_tp4_conn)); - fprintf(OUT, - "\t%*s%d tp 0 connection%s\n", indent, " ", - s->ts_tp0_conn ,plural(s->ts_tp0_conn)); - { - int j; - static char *name[]= { - "~LOCAL, PDN", - "~LOCAL,~PDN", - " LOCAL,~PDN", - " LOCAL, PDN" - }; - - fprintf(OUT, - "\n%*sRound trip times, listed in ticks:\n", indent, " "); - fprintf(OUT, - "\t%*s%11.11s %12.12s | %12.12s | %s\n", indent, " ", - "Category", - "Smoothed avg", "Deviation", "Deviation/Avg"); - for (j = 0; j <= 3; j++) { - fprintf(OUT, - "\t%*s%11.11s: %-11d | %-11d | %-11d | %-11d\n", indent, " ", - name[j], - s->ts_rtt[j], - s->ts_rtt[j], - s->ts_rtv[j], - s->ts_rtv[j]); - } - } - fprintf(OUT, -"\n%*sTpdus RECVD [%d valid, %3.6f %% of total (%d); %d dropped]\n",indent," ", - s->ts_tpdu_rcvd , - ((s->ts_pkt_rcvd > 0) ? - ((100 * (float)s->ts_tpdu_rcvd)/(float)s->ts_pkt_rcvd) - : 0), - s->ts_pkt_rcvd, - s->ts_recv_drop ); - - fprintf(OUT, - "\t%*sDT %6d AK %6d DR %4d CR %4d \n", indent, " ", - s->ts_DT_rcvd, s->ts_AK_rcvd, s->ts_DR_rcvd, s->ts_CR_rcvd); - fprintf(OUT, - "\t%*sXPD %6d XAK %6d DC %4d CC %4d ER %4d\n", indent, " ", - s->ts_XPD_rcvd, s->ts_XAK_rcvd, s->ts_DC_rcvd, s->ts_CC_rcvd, - s->ts_ER_rcvd); - fprintf(OUT, - "\n%*sTpdus SENT [%d total, %d dropped]\n", indent, " ", - s->ts_tpdu_sent, s->ts_send_drop); - - fprintf(OUT, - "\t%*sDT %6d AK %6d DR %4d CR %4d \n", indent, " ", - s->ts_DT_sent, s->ts_AK_sent, s->ts_DR_sent, s->ts_CR_sent); - fprintf(OUT, - "\t%*sXPD %6d XAK %6d DC %4d CC %4d ER %4d\n", indent, " ", - s->ts_XPD_sent, s->ts_XAK_sent, s->ts_DC_sent, s->ts_CC_sent, - s->ts_ER_sent); - - fprintf(OUT, - "\n%*sRetransmissions:\n", indent, " "); -#define PERCENT(X,Y) (((Y)>0)?((100 *(float)(X)) / (float) (Y)):0) - - fprintf(OUT, - "\t%*sCR %6d CC %6d DR %6d \n", indent, " ", - s->ts_retrans_cr, s->ts_retrans_cc, s->ts_retrans_dr); - fprintf(OUT, - "\t%*sDT %6d (%5.2f%%)\n", indent, " ", - s->ts_retrans_dt, - PERCENT(s->ts_retrans_dt, s->ts_DT_sent)); - fprintf(OUT, - "\t%*sXPD %6d (%5.2f%%)\n", indent, " ", - s->ts_retrans_xpd, - PERCENT(s->ts_retrans_xpd, s->ts_XPD_sent)); - - - fprintf(OUT, - "\n%*sE Timers: [%6d ticks]\n", indent, " ", s->ts_Eticks); - fprintf(OUT, - "%*s%6d timer%s set \t%6d timer%s expired \t%6d timer%s cancelled\n",indent, " ", - s->ts_Eset ,plural(s->ts_Eset), - s->ts_Eexpired ,plural(s->ts_Eexpired), - s->ts_Ecan_act ,plural(s->ts_Ecan_act)); - - fprintf(OUT, - "\n%*sC Timers: [%6d ticks]\n", indent, " ",s->ts_Cticks); - fprintf(OUT, - "%*s%6d timer%s set \t%6d timer%s expired \t%6d timer%s cancelled\n", - indent, " ", - s->ts_Cset ,plural(s->ts_Cset), - s->ts_Cexpired ,plural(s->ts_Cexpired), - s->ts_Ccan_act ,plural(s->ts_Ccan_act)); - fprintf(OUT, - "%*s%6d inactive timer%s cancelled\n", indent, " ", - s->ts_Ccan_inact ,plural(s->ts_Ccan_inact)); - - fprintf(OUT, - "\n%*sPathological debugging activity:\n", indent, " "); - fprintf(OUT, - "\t%*s%6d CC%s sent to zero dref\n", indent, " ", - s->ts_zdebug ,plural(s->ts_zdebug)); - /* SAME LINE AS ABOVE */ - fprintf(OUT, - "\t%*s%6d random DT%s dropped\n", indent, " ", - s->ts_ydebug ,plural(s->ts_ydebug)); - fprintf(OUT, - "\t%*s%6d illegally large XPD TPDU%s\n", indent, " ", - s->ts_vdebug ,plural(s->ts_vdebug)); - fprintf(OUT, - "\t%*s%6d faked reneging of cdt\n", indent, " ", - s->ts_ldebug ); - - fprintf(OUT, - "\n%*sACK reasons:\n", indent, " "); - fprintf(OUT, "\t%*s%6d not acked immediately\n", indent, " ", - s->ts_ackreason[_ACK_DONT_] ); - fprintf(OUT, "\t%*s%6d strategy==each\n", indent, " ", - s->ts_ackreason[_ACK_STRAT_EACH_] ); - fprintf(OUT, "\t%*s%6d strategy==fullwindow\n", indent, " ", - s->ts_ackreason[_ACK_STRAT_FULLWIN_] ); - fprintf(OUT, "\t%*s%6d duplicate DT\n", indent, " ", - s->ts_ackreason[_ACK_DUP_] ); - fprintf(OUT, "\t%*s%6d EOTSDU\n", indent, " ", - s->ts_ackreason[_ACK_EOT_] ); - fprintf(OUT, "\t%*s%6d reordered DT\n", indent, " ", - s->ts_ackreason[_ACK_REORDER_] ); - fprintf(OUT, "\t%*s%6d user rcvd\n", indent, " ", - s->ts_ackreason[_ACK_USRRCV_] ); - fprintf(OUT, "\t%*s%6d fcc reqd\n", indent, " ", - s->ts_ackreason[_ACK_FCC_] ); -} -#ifndef SSEL -#define SSEL(s) ((s)->siso_tlen + TSEL(s)) -#define PSEL(s) ((s)->siso_slen + SSEL(s)) -#endif - -static void -isonetprint(struct sockaddr_iso *siso, int islocal) -{ - hexprint(siso->siso_nlen, siso->siso_addr.isoa_genaddr, "{}"); - if (siso->siso_tlen || siso->siso_slen || siso->siso_plen) - hexprint(siso->siso_tlen, TSEL(siso), "()"); - if (siso->siso_slen || siso->siso_plen) - hexprint(siso->siso_slen, SSEL(siso), "[]"); - if (siso->siso_plen) - hexprint(siso->siso_plen, PSEL(siso), "<>"); - putchar(' '); -} - -static char hexlist[] = "0123456789abcdef", obuf[128]; - -static void -hexprint(int n, char *buf, char *delim) -{ - u_char *in = (u_char *)buf, *top = in + n; - char *out = obuf; - int i; - - if (n == 0) - return; - while (in < top) { - i = *in++; - *out++ = '.'; - if (i > 0xf) { - out[1] = hexlist[i & 0xf]; - i >>= 4; - out[0] = hexlist[i]; - out += 2; - } else - *out++ = hexlist[i]; - } - *obuf = *delim; *out++ = delim[1]; *out = 0; - printf("%s", obuf); -} diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 4409f4b..ac70c41 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -71,103 +71,69 @@ static const char rcsid[] = static struct nlist nl[] = { #define N_IFNET 0 { "_ifnet" }, -#define N_IMP 1 - { "_imp_softc" }, -#define N_RTSTAT 2 +#define N_RTSTAT 1 { "_rtstat" }, -#define N_UNIXSW 3 - { "_localsw" }, -#define N_IDP 4 - { "_nspcb"}, -#define N_IDPSTAT 5 - { "_idpstat"}, -#define N_SPPSTAT 6 - { "_spp_istat"}, -#define N_NSERR 7 - { "_ns_errstat"}, -#define N_CLNPSTAT 8 - { "_clnp_stat"}, -#define IN_NOTUSED 9 - { "_tp_inpcb" }, -#define ISO_TP 10 - { "_tp_refinfo" }, -#define N_TPSTAT 11 - { "_tp_stat" }, -#define N_ESISSTAT 12 - { "_esis_stat"}, -#define N_NIMP 13 - { "_nimp"}, -#define N_RTREE 14 +#define N_RTREE 2 { "_rt_tables"}, -#define N_CLTP 15 - { "_cltb"}, -#define N_CLTPSTAT 16 - { "_cltpstat"}, -#define N_NFILE 17 - { "_nfile" }, -#define N_FILE 18 - { "_file" }, -#define N_MRTSTAT 19 +#define N_MRTSTAT 3 { "_mrtstat" }, -#define N_MFCTABLE 20 +#define N_MFCTABLE 4 { "_mfctable" }, -#define N_VIFTABLE 21 +#define N_VIFTABLE 5 { "_viftable" }, -#define N_IPX 22 +#define N_IPX 6 { "_ipxpcb"}, -#define N_IPXSTAT 23 +#define N_IPXSTAT 7 { "_ipxstat"}, -#define N_SPXSTAT 24 +#define N_SPXSTAT 8 { "_spx_istat"}, -#define N_DDPSTAT 25 +#define N_DDPSTAT 9 { "_ddpstat"}, -#define N_DDPCB 26 +#define N_DDPCB 10 { "_ddpcb"}, -#define N_NGSOCKS 27 +#define N_NGSOCKS 11 { "_ngsocklist"}, -#define N_IP6STAT 28 +#define N_IP6STAT 12 { "_ip6stat" }, -#define N_ICMP6STAT 29 +#define N_ICMP6STAT 13 { "_icmp6stat" }, -#define N_IPSECSTAT 30 +#define N_IPSECSTAT 14 { "_ipsecstat" }, -#define N_IPSEC6STAT 31 +#define N_IPSEC6STAT 15 { "_ipsec6stat" }, -#define N_PIM6STAT 32 +#define N_PIM6STAT 16 { "_pim6stat" }, -#define N_MRT6PROTO 33 - { "_ip6_mrtproto" }, -#define N_MRT6STAT 34 +#define N_MRT6STAT 17 { "_mrt6stat" }, -#define N_MF6CTABLE 35 +#define N_MF6CTABLE 18 { "_mf6ctable" }, -#define N_MIF6TABLE 36 +#define N_MIF6TABLE 19 { "_mif6table" }, -#define N_PFKEYSTAT 37 +#define N_PFKEYSTAT 20 { "_pfkeystat" }, -#define N_MBSTAT 38 +#define N_MBSTAT 21 { "_mbstat" }, -#define N_MBTYPES 39 +#define N_MBTYPES 22 { "_mbtypes" }, -#define N_NMBCLUSTERS 40 +#define N_NMBCLUSTERS 23 { "_nmbclusters" }, -#define N_NMBUFS 41 +#define N_NMBUFS 24 { "_nmbufs" }, -#define N_MBHI 42 +#define N_MBHI 25 { "_mbuf_hiwm" }, -#define N_CLHI 43 +#define N_CLHI 26 { "_clust_hiwm" }, -#define N_NCPUS 44 +#define N_NCPUS 27 { "_smp_cpus" }, -#define N_PAGESZ 45 +#define N_PAGESZ 28 { "_pagesize" }, -#define N_MBPSTAT 46 +#define N_MBPSTAT 29 { "_mb_statpcpu" }, -#define N_RTTRASH 47 +#define N_RTTRASH 30 { "_rttrash" }, -#define N_MBLO 48 +#define N_MBLO 31 { "_mbuf_lowm" }, -#define N_CLLO 49 +#define N_CLLO 32 { "_clust_lowm" }, { "" }, }; @@ -267,34 +233,6 @@ struct protox ipxprotox[] = { 0, NULL, 0, 0 } }; -#ifdef NS -struct protox nsprotox[] = { - { N_IDP, N_IDPSTAT, 1, nsprotopr, - idp_stats, NULL, "idp" }, - { N_IDP, N_SPPSTAT, 1, nsprotopr, - spp_stats, NULL, "spp" }, - { -1, N_NSERR, 1, 0, - nserr_stats, NULL, "ns_err" }, - { -1, -1, 0, 0, - 0, NULL, 0 } -}; -#endif - -#ifdef ISO -struct protox isoprotox[] = { - { ISO_TP, N_TPSTAT, 1, iso_protopr, - tp_stats, NULL, "tp" }, - { N_CLTP, N_CLTPSTAT, 1, iso_protopr, - cltp_stats, NULL, "cltp" }, - { -1, N_CLNPSTAT, 1, 0, - clnp_stats, NULL, "clnp"}, - { -1, N_ESISSTAT, 1, 0, - esis_stats, NULL, "esis"}, - { -1, -1, 0, 0, - 0, NULL, 0 } -}; -#endif - struct protox *protoprotox[] = { protox, #ifdef INET6 @@ -303,14 +241,7 @@ struct protox *protoprotox[] = { #ifdef IPSEC pfkeyprotox, #endif - ipxprotox, atalkprotox, -#ifdef NS - nsprotox, -#endif -#ifdef ISO - isoprotox, -#endif - NULL }; + ipxprotox, atalkprotox, NULL }; static void printproto (struct protox *, const char *); static void usage (void); @@ -367,11 +298,6 @@ main(int argc, char *argv[]) dflag = 1; break; case 'f': -#ifdef NS - if (strcmp(optarg, "ns") == 0) - af = AF_NS; - else -#endif if (strcmp(optarg, "ipx") == 0) af = AF_IPX; else if (strcmp(optarg, "inet") == 0) @@ -391,10 +317,6 @@ main(int argc, char *argv[]) else if (strcmp(optarg, "ng") == 0 || strcmp(optarg, "netgraph") == 0) af = AF_NETGRAPH; -#ifdef ISO - else if (strcmp(optarg, "iso") == 0) - af = AF_ISO; -#endif else if (strcmp(optarg, "link") == 0) af = AF_LINK; else { @@ -593,16 +515,6 @@ main(int argc, char *argv[]) if (af == AF_NETGRAPH || af == AF_UNSPEC) for (tp = netgraphprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); -#ifdef NS - if (af == AF_NS || af == AF_UNSPEC) - for (tp = nsprotox; tp->pr_name; tp++) - printproto(tp, tp->pr_name); -#endif -#ifdef ISO - if (af == AF_ISO || af == AF_UNSPEC) - for (tp = isoprotox; tp->pr_name; tp++) - printproto(tp, tp->pr_name); -#endif if ((af == AF_UNIX || af == AF_UNSPEC) && !Lflag && !sflag) unixpr(); exit(0); diff --git a/usr.bin/netstat/ns.c b/usr.bin/netstat/ns.c deleted file mode 100644 index ff235a2..0000000 --- a/usr.bin/netstat/ns.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) 1983, 1988, 1993 - * 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)ns.c 8.1 (Berkeley) 6/6/93"; -#endif -static const char rcsid[] = - "$FreeBSD$"; -#endif /* not lint */ - -#include <sys/param.h> -#include <sys/socket.h> -#include <sys/socketvar.h> -#include <sys/mbuf.h> -#include <sys/protosw.h> - -#include <net/route.h> -#include <net/if.h> - -#include <netinet/tcp_fsm.h> - -#include <netns/ns.h> -#include <netns/ns_pcb.h> -#include <netns/idp.h> -#include <netns/idp_var.h> -#include <netns/ns_error.h> -#include <netns/sp.h> -#include <netns/spidp.h> -#include <netns/spp_timer.h> -#include <netns/spp_var.h> -#define SANAMES -#include <netns/spp_debug.h> - -#include <nlist.h> -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include "netstat.h" - -struct nspcb nspcb; -struct sppcb sppcb; -struct socket sockb; - -static char *ns_prpr (struct ns_addr *); -static void ns_erputil (int, int); - -static int first = 1; - -/* - * Print a summary of connections related to a Network Systems - * protocol. For SPP, also give state of connection. - * Listening processes (aflag) are suppressed unless the - * -a (all) flag is specified. - */ - -void -nsprotopr(u_long off, const char *name, int af __unused) -{ - struct nspcb cb; - struct nspcb *prev, *next; - int isspp; - - if (off == 0) - return; - isspp = strcmp(name, "spp") == 0; - kread(off, (char *)&cb, sizeof (struct nspcb)); - nspcb = cb; - prev = (struct nspcb *)off; - if (nspcb.nsp_next == (struct nspcb *)off) - return; - for (;nspcb.nsp_next != (struct nspcb *)off; prev = next) { - u_long ppcb; - - next = nspcb.nsp_next; - kread((u_long)next, (char *)&nspcb, sizeof (nspcb)); - if (nspcb.nsp_prev != prev) { - printf("???\n"); - break; - } - if (!aflag && ns_nullhost(nspcb.nsp_faddr) ) { - continue; - } - kread((u_long)nspcb.nsp_socket, - (char *)&sockb, sizeof (sockb)); - ppcb = (u_long) nspcb.nsp_pcb; - if (ppcb) { - if (isspp) { - kread(ppcb, (char *)&sppcb, sizeof (sppcb)); - } else continue; - } else - if (isspp) continue; - if (first) { - printf("Active NS connections"); - if (aflag) - printf(" (including servers)"); - putchar('\n'); - if (Aflag) - printf("%-8.8s ", "PCB"); - printf(Aflag ? - "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" : - "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n", - "Proto", "Recv-Q", "Send-Q", - "Local Address", "Foreign Address", "(state)"); - first = 0; - } - if (Aflag) - printf("%8x ", ppcb); - printf("%-5.5s %6u %6u ", name, sockb.so_rcv.sb_cc, - sockb.so_snd.sb_cc); - printf(" %-22.22s", ns_prpr(&nspcb.nsp_laddr)); - printf(" %-22.22s", ns_prpr(&nspcb.nsp_faddr)); - if (isspp) { - extern char *tcpstates[]; - if (sppcb.s_state >= TCP_NSTATES) - printf(" %d", sppcb.s_state); - else - printf(" %s", tcpstates[sppcb.s_state]); - } - putchar('\n'); - prev = next; - } -} -#define ANY(x,y,z) \ - ((x) ? printf("\t%d %s%s%s -- %s\n",x,y,plural(x),z,"x") : 0) - -/* - * Dump SPP statistics structure. - */ -void -spp_stats(u_long off, const char *name, int af __unused) -{ - struct spp_istat spp_istat; -#define sppstat spp_istat.newstats - - if (off == 0) - return; - kread(off, (char *)&spp_istat, sizeof (spp_istat)); - printf("%s:\n", name); - ANY(spp_istat.nonucn, "connection", " dropped due to no new sockets "); - ANY(spp_istat.gonawy, "connection", " terminated due to our end dying"); - ANY(spp_istat.nonucn, "connection", - " dropped due to inability to connect"); - ANY(spp_istat.noconn, "connection", - " dropped due to inability to connect"); - ANY(spp_istat.notme, "connection", - " incompleted due to mismatched id's"); - ANY(spp_istat.wrncon, "connection", " dropped due to mismatched id's"); - ANY(spp_istat.bdreas, "packet", " dropped out of sequence"); - ANY(spp_istat.lstdup, "packet", " duplicating the highest packet"); - ANY(spp_istat.notyet, "packet", " refused as exceeding allocation"); - ANY(sppstat.spps_connattempt, "connection", " initiated"); - ANY(sppstat.spps_accepts, "connection", " accepted"); - ANY(sppstat.spps_connects, "connection", " established"); - ANY(sppstat.spps_drops, "connection", " dropped"); - ANY(sppstat.spps_conndrops, "embryonic connection", " dropped"); - ANY(sppstat.spps_closed, "connection", " closed (includes drops)"); - ANY(sppstat.spps_segstimed, "packet", " where we tried to get rtt"); - ANY(sppstat.spps_rttupdated, "time", " we got rtt"); - ANY(sppstat.spps_delack, "delayed ack", " sent"); - ANY(sppstat.spps_timeoutdrop, "connection", " dropped in rxmt timeout"); - ANY(sppstat.spps_rexmttimeo, "retransmit timeout", ""); - ANY(sppstat.spps_persisttimeo, "persist timeout", ""); - ANY(sppstat.spps_keeptimeo, "keepalive timeout", ""); - ANY(sppstat.spps_keepprobe, "keepalive probe", " sent"); - ANY(sppstat.spps_keepdrops, "connection", " dropped in keepalive"); - ANY(sppstat.spps_sndtotal, "total packet", " sent"); - ANY(sppstat.spps_sndpack, "data packet", " sent"); - ANY(sppstat.spps_sndbyte, "data byte", " sent"); - ANY(sppstat.spps_sndrexmitpack, "data packet", " retransmitted"); - ANY(sppstat.spps_sndrexmitbyte, "data byte", " retransmitted"); - ANY(sppstat.spps_sndacks, "ack-only packet", " sent"); - ANY(sppstat.spps_sndprobe, "window probe", " sent"); - ANY(sppstat.spps_sndurg, "packet", " sent with URG only"); - ANY(sppstat.spps_sndwinup, "window update-only packet", " sent"); - ANY(sppstat.spps_sndctrl, "control (SYN|FIN|RST) packet", " sent"); - ANY(sppstat.spps_sndvoid, "request", " to send a non-existant packet"); - ANY(sppstat.spps_rcvtotal, "total packet", " received"); - ANY(sppstat.spps_rcvpack, "packet", " received in sequence"); - ANY(sppstat.spps_rcvbyte, "byte", " received in sequence"); - ANY(sppstat.spps_rcvbadsum, "packet", " received with ccksum errs"); - ANY(sppstat.spps_rcvbadoff, "packet", " received with bad offset"); - ANY(sppstat.spps_rcvshort, "packet", " received too short"); - ANY(sppstat.spps_rcvduppack, "duplicate-only packet", " received"); - ANY(sppstat.spps_rcvdupbyte, "duplicate-only byte", " received"); - ANY(sppstat.spps_rcvpartduppack, "packet", " with some duplicate data"); - ANY(sppstat.spps_rcvpartdupbyte, "dup. byte", " in part-dup. packet"); - ANY(sppstat.spps_rcvoopack, "out-of-order packet", " received"); - ANY(sppstat.spps_rcvoobyte, "out-of-order byte", " received"); - ANY(sppstat.spps_rcvpackafterwin, "packet", " with data after window"); - ANY(sppstat.spps_rcvbyteafterwin, "byte", " rcvd after window"); - ANY(sppstat.spps_rcvafterclose, "packet", " rcvd after 'close'"); - ANY(sppstat.spps_rcvwinprobe, "rcvd window probe packet", ""); - ANY(sppstat.spps_rcvdupack, "rcvd duplicate ack", ""); - ANY(sppstat.spps_rcvacktoomuch, "rcvd ack", " for unsent data"); - ANY(sppstat.spps_rcvackpack, "rcvd ack packet", ""); - ANY(sppstat.spps_rcvackbyte, "byte", " acked by rcvd acks"); - ANY(sppstat.spps_rcvwinupd, "rcvd window update packet", ""); -} -#undef ANY -#define ANY(x,y,z) ((x) ? printf("\t%d %s%s%s\n",x,y,plural(x),z) : 0) - -/* - * Dump IDP statistics structure. - */ -void -idp_stats(u_long off, const char *name, int af __unused) -{ - struct idpstat idpstat; - - if (off == 0) - return; - kread(off, (char *)&idpstat, sizeof (idpstat)); - printf("%s:\n", name); - ANY(idpstat.idps_toosmall, "packet", " smaller than a header"); - ANY(idpstat.idps_tooshort, "packet", " smaller than advertised"); - ANY(idpstat.idps_badsum, "packet", " with bad checksums"); -} - -static struct { - u_short code; - char *name; - char *where; -} ns_errnames[] = { - {0, "Unspecified Error", " at Destination"}, - {1, "Bad Checksum", " at Destination"}, - {2, "No Listener", " at Socket"}, - {3, "Packet", " Refused due to lack of space at Destination"}, - {01000, "Unspecified Error", " while gatewayed"}, - {01001, "Bad Checksum", " while gatewayed"}, - {01002, "Packet", " forwarded too many times"}, - {01003, "Packet", " too large to be forwarded"}, - {-1, 0, 0}, -}; - -/* - * Dump NS Error statistics structure. - */ -/*ARGSUSED*/ -void -nserr_stats(u_long off, const char *name, int af __unused) -{ - struct ns_errstat ns_errstat; - int j; - int histoprint = 1; - int z; - - if (off == 0) - return; - kread(off, (char *)&ns_errstat, sizeof (ns_errstat)); - printf("NS error statistics:\n"); - ANY(ns_errstat.ns_es_error, "call", " to ns_error"); - ANY(ns_errstat.ns_es_oldshort, "error", - " ignored due to insufficient addressing"); - ANY(ns_errstat.ns_es_oldns_err, "error request", - " in response to error packets"); - ANY(ns_errstat.ns_es_tooshort, "error packet", - " received incomplete"); - ANY(ns_errstat.ns_es_badcode, "error packet", - " received of unknown type"); - for(j = 0; j < NS_ERR_MAX; j ++) { - z = ns_errstat.ns_es_outhist[j]; - if (z && histoprint) { - printf("Output Error Histogram:\n"); - histoprint = 0; - } - ns_erputil(z, ns_errstat.ns_es_codes[j]); - - } - histoprint = 1; - for(j = 0; j < NS_ERR_MAX; j ++) { - z = ns_errstat.ns_es_inhist[j]; - if (z && histoprint) { - printf("Input Error Histogram:\n"); - histoprint = 0; - } - ns_erputil(z, ns_errstat.ns_es_codes[j]); - } -} - -static void -ns_erputil(int z, int c) -{ - int j; - char codebuf[30]; - char *name, *where; - - for(j = 0;; j ++) { - if ((name = ns_errnames[j].name) == 0) - break; - if (ns_errnames[j].code == c) - break; - } - if (name == 0) { - if (c > 01000) - where = "in transit"; - else - where = "at destination"; - sprintf(codebuf, "Unknown XNS error code 0%o", c); - name = codebuf; - } else - where = ns_errnames[j].where; - ANY(z, name, where); -} - -static struct sockaddr_ns ssns = {AF_NS}; - -static -char *ns_prpr(struct ns_addr *x) -{ - struct sockaddr_ns *sns = &ssns; - - sns->sns_addr = *x; - return(ns_print((struct sockaddr *)sns)); -} diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index fecdabe..09572dd 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -56,10 +56,6 @@ static const char rcsid[] = #include <netatalk/at.h> #include <netgraph/ng_socket.h> -#ifdef NS -#include <netns/ns.h> -#endif - #include <sys/sysctl.h> #include <arpa/inet.h> @@ -202,11 +198,6 @@ pr_family(int af1) case AF_IPX: afname = "IPX"; break; -#ifdef NS - case AF_NS: - afname = "XNS"; - break; -#endif case AF_ISO: afname = "ISO"; break; @@ -649,11 +640,6 @@ fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags) printf("%s", ((struct sockaddr_ng *)sa)->sg_data); break; } -#ifdef NS - case AF_NS: - cp = ns_print(sa); - break; -#endif case AF_LINK: { @@ -1127,75 +1113,6 @@ ipx_phost(struct sockaddr *sa) return(p); } -#ifdef NS -short ns_nullh[] = {0,0,0}; -short ns_bh[] = {-1,-1,-1}; - -char * -ns_print(struct sockaddr *sa) -{ - struct sockaddr_ns *sns = (struct sockaddr_ns*)sa; - struct ns_addr work; - union { union ns_net net_e; u_long long_e; } net; - u_short port; - static char mybuf[50], cport[10], chost[25]; - char *host = ""; - char *p; u_char *q; - - work = sns->sns_addr; - port = ntohs(work.x_port); - work.x_port = 0; - net.net_e = work.x_net; - if (ns_nullhost(work) && net.long_e == 0) { - if (port ) { - sprintf(mybuf, "*.%xH", port); - upHex(mybuf); - } else - sprintf(mybuf, "*.*"); - return (mybuf); - } - - if (bcmp(ns_bh, work.x_host.c_host, 6) == 0) { - host = "any"; - } else if (bcmp(ns_nullh, work.x_host.c_host, 6) == 0) { - host = "*"; - } else { - q = work.x_host.c_host; - sprintf(chost, "%02x%02x%02x%02x%02x%02xH", - q[0], q[1], q[2], q[3], q[4], q[5]); - for (p = chost; *p == '0' && p < chost + 12; p++) - continue; - host = p; - } - if (port) - sprintf(cport, ".%xH", htons(port)); - else - *cport = 0; - - sprintf(mybuf,"%xH.%s%s", ntohl(net.long_e), host, cport); - upHex(mybuf); - return(mybuf); -} - -char * -ns_phost(struct sockaddr *sa) -{ - struct sockaddr_ns *sns = (struct sockaddr_ns *)sa; - struct sockaddr_ns work; - static union ns_net ns_zeronet; - char *p; - - work = *sns; - work.sns_addr.x_port = 0; - work.sns_addr.x_net = ns_zeronet; - - p = ns_print((struct sockaddr *)&work); - if (strncmp("0H.", p, 3) == 0) - p += 3; - return(p); -} -#endif - void upHex(char *p0) { |