diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-08-16 09:29:35 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-08-16 09:29:35 +0000 |
commit | 5549b523cab632628d47a9e1c0c6f84ba6b9e691 (patch) | |
tree | bf0c478237a0f84d22b9218758864948cec960e6 /usr.bin/netstat | |
parent | 9e1e83a0e7fb47df10ae0985cabf2316562d900d (diff) |
ipx.
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r-- | usr.bin/netstat/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/netstat/if.c | 22 | ||||
-rw-r--r-- | usr.bin/netstat/ipx.c | 353 | ||||
-rw-r--r-- | usr.bin/netstat/main.c | 36 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.1 | 5 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.h | 9 | ||||
-rw-r--r-- | usr.bin/netstat/route.c | 80 |
7 files changed, 495 insertions, 14 deletions
diff --git a/usr.bin/netstat/Makefile b/usr.bin/netstat/Makefile index 18bd05cd87a..7f04105b745 100644 --- a/usr.bin/netstat/Makefile +++ b/usr.bin/netstat/Makefile @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile,v 1.2 1996/06/26 05:37:19 deraadt Exp $ +# $OpenBSD: Makefile,v 1.3 1996/08/16 09:29:31 mickey Exp $ # $NetBSD: Makefile,v 1.11 1995/10/03 21:42:34 thorpej Exp $ PROG= netstat -SRCS= if.c inet.c iso.c main.c mbuf.c mroute.c ns.c route.c \ +SRCS= if.c inet.c ipx.c iso.c main.c mbuf.c mroute.c ns.c route.c \ tp_astring.c unix.c .PATH: ${.CURDIR}/../../sys/netiso BINGRP= kmem diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index 3bf1b1f0cdf..924a5366e6f 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.7 1996/06/26 05:37:20 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.8 1996/08/16 09:29:32 mickey Exp $ */ /* $NetBSD: if.c,v 1.16.4.2 1996/06/07 21:46:46 thorpej Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94"; #else -static char *rcsid = "$OpenBSD: if.c,v 1.7 1996/06/26 05:37:20 deraadt Exp $"; +static char *rcsid = "$OpenBSD: if.c,v 1.8 1996/08/16 09:29:32 mickey Exp $"; #endif #endif /* not lint */ @@ -53,6 +53,8 @@ static char *rcsid = "$OpenBSD: if.c,v 1.7 1996/06/26 05:37:20 deraadt Exp $"; #include <netinet/in_var.h> #include <netns/ns.h> #include <netns/ns_if.h> +#include <netipx/ipx.h> +#include <netipx/ipx_if.h> #include <netiso/iso.h> #include <netiso/iso_var.h> #include <arpa/inet.h> @@ -85,6 +87,7 @@ intpr(interval, ifnetaddr) struct ifaddr ifa; struct in_ifaddr in; struct ns_ifaddr ns; + struct ipx_ifaddr ipx; struct iso_ifaddr iso; } ifaddr; u_long ifaddraddr; @@ -188,6 +191,21 @@ intpr(interval, ifnetaddr) } } break; + case AF_IPX: + { + struct sockaddr_ipx *sipx = + (struct sockaddr_ipx *)sa; + u_long net; + char netnum[8]; + + *(union ipx_net *) &net = sipx->sipx_addr.ipx_net; + sprintf(netnum, "%lxH", ntohl(net)); + upHex(netnum); + printf("ipx:%-8s", netnum); + printf("%-17s ", + ipx_phost((struct sockaddr *)sipx)); + } + break; case AF_NS: { struct sockaddr_ns *sns = diff --git a/usr.bin/netstat/ipx.c b/usr.bin/netstat/ipx.c new file mode 100644 index 00000000000..8c0ad9e5119 --- /dev/null +++ b/usr.bin/netstat/ipx.c @@ -0,0 +1,353 @@ +/* $OpenBSD: ipx.c,v 1.1 1996/08/16 09:29:32 mickey Exp $ */ + +/* + * Copyright (c) 1996 Michael Shalayeff + * 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[] = "from: @(#)ns.c 8.1 (Berkeley) 6/6/93"; +#else +static char *rcsid = "$OpenBSD: ipx.c,v 1.1 1996/08/16 09:29:32 mickey Exp $"; +#endif +#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 <netipx/ipx.h> +#include <netipx/ipx_pcb.h> +#include <netipx/ipx.h> +#include <netipx/ipx_var.h> +#include <netipx/ipx_error.h> +#include <netipx/spx.h> +#include <netipx/spx_timer.h> +#include <netipx/spx_var.h> +#define SANAMES +#include <netipx/spx_debug.h> + +#include <nlist.h> +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include "netstat.h" + +struct ipxpcb ipxpcb; +struct spxpcb spxpcb; +struct socket sockb; + +static char *ipx_prpr __P((struct ipx_addr *)); +static void ipx_erputil __P((int, int)); + +static int first = 1; + +/* + * Print a summary of connections related to an IPX + * protocol. For SPX, also give state of connection. + * Listening processes (aflag) are suppressed unless the + * -a (all) flag is specified. + */ + +void +ipxprotopr(off, name) + u_long off; + char *name; +{ + struct ipxpcbtable table; + register struct ipxpcb *head, *prev, *next; + int isspx; + + if (off == 0) + return; + isspx = strcmp(name, "spx") == 0; + kread(off, (char *)&table, sizeof (table)); + prev = head = (struct ipxpcb *) + &((struct ipxpcbtable *)off)->ipxpt_queue.cqh_first; + next = table.ipxpt_queue.cqh_first; + + while (next != head) { + kread((u_long)next, (char *)&ipxpcb, sizeof (ipxpcb)); + if (ipxpcb.ipxp_queue.cqe_prev != prev) { + printf("???\n"); + break; + } + prev = next; + next = ipxpcb.ipxp_queue.cqe_next; + + if (!aflag && ipx_nullhost(ipxpcb.ipxp_faddr) ) + continue; + + kread((u_long)ipxpcb.ipxp_socket, + (char *)&sockb, sizeof (sockb)); + if (isspx) { + kread((u_long)ipxpcb.ipxp_ppcb, + (char *)&spxpcb, sizeof (spxpcb)); + } + if (first) { + printf("Active Internetwork Packet Exchange 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 ", ipxpcb.ipxp_ppcb); + printf("%-5.5s %6d %6d ", name, sockb.so_rcv.sb_cc, + sockb.so_snd.sb_cc); + printf(" %-22.22s", ipx_prpr(&ipxpcb.ipxp_laddr)); + printf(" %-22.22s", ipx_prpr(&ipxpcb.ipxp_faddr)); + if (isspx) { + extern char *tcpstates[]; + if (spxpcb.s_state >= TCP_NSTATES) + printf(" %d", spxpcb.s_state); + else + printf(" %s", tcpstates[spxpcb.s_state]); + } + putchar('\n'); + } +} +#define ANY(x,y,z) \ + ((x) ? printf("\t%d %s%s%s -- %s\n",x,y,plural(x),z,"x") : 0) + +/* + * Dump SPX statistics structure. + */ +void +spx_stats(off, name) + u_long off; + char *name; +{ + struct spx_istat spx_istat; +#define spxstat spx_istat.newstats + + if (off == 0) + return; + kread(off, (char *)&spx_istat, sizeof (spx_istat)); + printf("%s:\n", name); + ANY(spx_istat.nonucn, "connection", " dropped due to no new sockets "); + ANY(spx_istat.gonawy, "connection", " terminated due to our end dying"); + ANY(spx_istat.nonucn, "connection", + " dropped due to inability to connect"); + ANY(spx_istat.noconn, "connection", + " dropped due to inability to connect"); + ANY(spx_istat.notme, "connection", + " incompleted due to mismatched id's"); + ANY(spx_istat.wrncon, "connection", " dropped due to mismatched id's"); + ANY(spx_istat.bdreas, "packet", " dropped out of sequence"); + ANY(spx_istat.lstdup, "packet", " duplicating the highest packet"); + ANY(spx_istat.notyet, "packet", " refused as exceeding allocation"); + ANY(spxstat.spxs_connattempt, "connection", " initiated"); + ANY(spxstat.spxs_accepts, "connection", " accepted"); + ANY(spxstat.spxs_connects, "connection", " established"); + ANY(spxstat.spxs_drops, "connection", " dropped"); + ANY(spxstat.spxs_conndrops, "embryonic connection", " dropped"); + ANY(spxstat.spxs_closed, "connection", " closed (includes drops)"); + ANY(spxstat.spxs_segstimed, "packet", " where we tried to get rtt"); + ANY(spxstat.spxs_rttupdated, "time", " we got rtt"); + ANY(spxstat.spxs_delack, "delayed ack", " sent"); + ANY(spxstat.spxs_timeoutdrop, "connection", " dropped in rxmt timeout"); + ANY(spxstat.spxs_rexmttimeo, "retransmit timeout", ""); + ANY(spxstat.spxs_persisttimeo, "persist timeout", ""); + ANY(spxstat.spxs_keeptimeo, "keepalive timeout", ""); + ANY(spxstat.spxs_keepprobe, "keepalive probe", " sent"); + ANY(spxstat.spxs_keepdrops, "connection", " dropped in keepalive"); + ANY(spxstat.spxs_sndtotal, "total packet", " sent"); + ANY(spxstat.spxs_sndpack, "data packet", " sent"); + ANY(spxstat.spxs_sndbyte, "data byte", " sent"); + ANY(spxstat.spxs_sndrexmitpack, "data packet", " retransmitted"); + ANY(spxstat.spxs_sndrexmitbyte, "data byte", " retransmitted"); + ANY(spxstat.spxs_sndacks, "ack-only packet", " sent"); + ANY(spxstat.spxs_sndprobe, "window probe", " sent"); + ANY(spxstat.spxs_sndurg, "packet", " sent with URG only"); + ANY(spxstat.spxs_sndwinup, "window update-only packet", " sent"); + ANY(spxstat.spxs_sndctrl, "control (SYN|FIN|RST) packet", " sent"); + ANY(spxstat.spxs_sndvoid, "request", " to send a non-existant packet"); + ANY(spxstat.spxs_rcvtotal, "total packet", " received"); + ANY(spxstat.spxs_rcvpack, "packet", " received in sequence"); + ANY(spxstat.spxs_rcvbyte, "byte", " received in sequence"); + ANY(spxstat.spxs_rcvbadsum, "packet", " received with ccksum errs"); + ANY(spxstat.spxs_rcvbadoff, "packet", " received with bad offset"); + ANY(spxstat.spxs_rcvshort, "packet", " received too short"); + ANY(spxstat.spxs_rcvduppack, "duplicate-only packet", " received"); + ANY(spxstat.spxs_rcvdupbyte, "duplicate-only byte", " received"); + ANY(spxstat.spxs_rcvpartduppack, "packet", " with some duplicate data"); + ANY(spxstat.spxs_rcvpartdupbyte, "dup. byte", " in part-dup. packet"); + ANY(spxstat.spxs_rcvoopack, "out-of-order packet", " received"); + ANY(spxstat.spxs_rcvoobyte, "out-of-order byte", " received"); + ANY(spxstat.spxs_rcvpackafterwin, "packet", " with data after window"); + ANY(spxstat.spxs_rcvbyteafterwin, "byte", " rcvd after window"); + ANY(spxstat.spxs_rcvafterclose, "packet", " rcvd after 'close'"); + ANY(spxstat.spxs_rcvwinprobe, "rcvd window probe packet", ""); + ANY(spxstat.spxs_rcvdupack, "rcvd duplicate ack", ""); + ANY(spxstat.spxs_rcvacktoomuch, "rcvd ack", " for unsent data"); + ANY(spxstat.spxs_rcvackpack, "rcvd ack packet", ""); + ANY(spxstat.spxs_rcvackbyte, "byte", " acked by rcvd acks"); + ANY(spxstat.spxs_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 IPX statistics structure. + */ +void +ipx_stats(off, name) + u_long off; + char *name; +{ + struct ipxstat ipxstat; + + if (off == 0) + return; + kread(off, (char *)&ipxstat, sizeof (ipxstat)); + printf("%s:\n", name); + ANY(ipxstat.ipxs_toosmall, "packet", " smaller than a header"); + ANY(ipxstat.ipxs_tooshort, "packet", " smaller than advertised"); + ANY(ipxstat.ipxs_badsum, "packet", " with bad checksums"); +} + +static struct { + u_short code; + char *name; + char *where; +} ipx_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 IPX Error statistics structure. + */ +/*ARGSUSED*/ +void +ipxerr_stats(off, name) + u_long off; + char *name; +{ + struct ipx_errstat ipx_errstat; + register int j; + register int histoprint = 1; + int z; + + if (off == 0) + return; + kread(off, (char *)&ipx_errstat, sizeof (ipx_errstat)); + printf("IPX error statistics:\n"); + ANY(ipx_errstat.ipx_es_error, "call", " to ipx_error"); + ANY(ipx_errstat.ipx_es_oldshort, "error", + " ignored due to insufficient addressing"); + ANY(ipx_errstat.ipx_es_oldipx_err, "error request", + " in response to error packets"); + ANY(ipx_errstat.ipx_es_tooshort, "error packet", + " received incomplete"); + ANY(ipx_errstat.ipx_es_badcode, "error packet", + " received of unknown type"); + for(j = 0; j < IPX_ERR_MAX; j ++) { + z = ipx_errstat.ipx_es_outhist[j]; + if (z && histoprint) { + printf("Output Error Histogram:\n"); + histoprint = 0; + } + ipx_erputil(z, ipx_errstat.ipx_es_codes[j]); + + } + histoprint = 1; + for(j = 0; j < IPX_ERR_MAX; j ++) { + z = ipx_errstat.ipx_es_inhist[j]; + if (z && histoprint) { + printf("Input Error Histogram:\n"); + histoprint = 0; + } + ipx_erputil(z, ipx_errstat.ipx_es_codes[j]); + } +} + +static void +ipx_erputil(z, c) + int z, c; +{ + int j; + char codebuf[30]; + char *name, *where; + + for(j = 0;; j ++) { + if ((name = ipx_errnames[j].name) == 0) + break; + if (ipx_errnames[j].code == c) + break; + } + if (name == 0) { + if (c > 01000) + where = "in transit"; + else + where = "at destination"; + sprintf(codebuf, "Unknown IPX error code 0%o", c); + name = codebuf; + } else + where = ipx_errnames[j].where; + ANY(z, name, where); +} + +static struct sockaddr_ipx ssipx = {AF_IPX}; + +static char * +ipx_prpr(x) + struct ipx_addr *x; +{ + struct sockaddr_ipx *sipx = &ssipx; + + sipx->sipx_addr = *x; + return(ipx_print((struct sockaddr *)sipx)); +} diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 1f27a1a2f9d..5407435c04e 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.3 1996/06/26 05:37:22 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.4 1996/08/16 09:29:33 mickey Exp $ */ /* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */ /* @@ -44,7 +44,7 @@ char copyright[] = #if 0 static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94"; #else -static char *rcsid = "$OpenBSD: main.c,v 1.3 1996/06/26 05:37:22 deraadt Exp $"; +static char *rcsid = "$OpenBSD: main.c,v 1.4 1996/08/16 09:29:33 mickey Exp $"; #endif #endif /* not lint */ @@ -133,6 +133,14 @@ struct nlist nl[] = { { "_mfchash" }, #define N_VIFTABLE 31 { "_viftable" }, +#define N_IPX 32 + { "_ipxcbtable"}, +#define N_IPXSTAT 33 + { "_ipxstat"}, +#define N_SPXSTAT 34 + { "_spx_istat"}, +#define N_IPXERR 35 + { "_ipx_errstat"}, "", }; @@ -158,6 +166,17 @@ struct protox { 0, 0 } }; +struct protox ipxprotox[] = { + { N_IPX, N_IPXSTAT, 1, ipxprotopr, + ipx_stats, "ipx" }, + { N_IPX, N_SPXSTAT, 1, ipxprotopr, + spx_stats, "spx" }, + { -1, N_IPXERR, 1, 0, + ipxerr_stats, "ipx_err" }, + { -1, -1, 0, 0, + 0, 0 } +}; + struct protox nsprotox[] = { { N_IDP, N_IDPSTAT, 1, nsprotopr, idp_stats, "idp" }, @@ -182,7 +201,7 @@ struct protox isoprotox[] = { 0, 0 } }; -struct protox *protoprotox[] = { protox, nsprotox, isoprotox, NULL }; +struct protox *protoprotox[] = { protox, ipxprotox, nsprotox, isoprotox, NULL }; static void printproto __P((struct protox *, char *)); static void usage __P((void)); @@ -219,12 +238,14 @@ main(argc, argv) dflag = 1; break; case 'f': - if (strcmp(optarg, "ns") == 0) - af = AF_NS; - else if (strcmp(optarg, "inet") == 0) + if (strcmp(optarg, "inet") == 0) af = AF_INET; else if (strcmp(optarg, "unix") == 0) af = AF_UNIX; + else if (strcmp(optarg, "ipx") == 0) + af = AF_IPX; + else if (strcmp(optarg, "ns") == 0) + af = AF_NS; else if (strcmp(optarg, "iso") == 0) af = AF_ISO; else { @@ -380,6 +401,9 @@ main(argc, argv) } endprotoent(); } + if (af == AF_IPX || af == AF_UNSPEC) + for (tp = ipxprotox; tp->pr_name; tp++) + printproto(tp, tp->pr_name); if (af == AF_NS || af == AF_UNSPEC) for (tp = nsprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1 index e0f8da7d814..c29649825cb 100644 --- a/usr.bin/netstat/netstat.1 +++ b/usr.bin/netstat/netstat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: netstat.1,v 1.3 1996/07/08 22:09:42 ccappuc Exp $ +.\" $OpenBSD: netstat.1,v 1.4 1996/08/16 09:29:33 mickey Exp $ .\" $NetBSD: netstat.1,v 1.11 1995/10/03 21:42:43 thorpej Exp $ .\" .\" Copyright (c) 1983, 1990, 1992, 1993 @@ -104,6 +104,9 @@ are recognized: .Ar inet , for .Dv AF_INET , +.Ar ipx , +for +.Dv AF_IPX , .Ar ns , for .Dv AF_NS , diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index d3f8a8fa804..7d494f98cf2 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: netstat.h,v 1.3 1996/06/26 05:37:24 deraadt Exp $ */ +/* $OpenBSD: netstat.h,v 1.4 1996/08/16 09:29:34 mickey Exp $ */ /* $NetBSD: netstat.h,v 1.6 1996/05/07 02:55:05 thorpej Exp $ */ /* @@ -82,11 +82,13 @@ void pr_rthdr __P(()); void pr_family __P((int)); void rt_stats __P((u_long)); char *ns_phost __P((struct sockaddr *)); +char *ipx_phost __P((struct sockaddr *)); void upHex __P((char *)); char *routename __P((u_int32_t)); char *netname __P((u_int32_t, u_int32_t)); char *ns_print __P((struct sockaddr *)); +char *ipx_print __P((struct sockaddr *)); void routepr __P((u_long)); void nsprotopr __P((u_long, char *)); @@ -94,6 +96,11 @@ void spp_stats __P((u_long, char *)); void idp_stats __P((u_long, char *)); void nserr_stats __P((u_long, char *)); +void ipxprotopr __P((u_long, char *)); +void spx_stats __P((u_long, char *)); +void ipx_stats __P((u_long, char *)); +void ipxerr_stats __P((u_long, char *)); + void intpr __P((int, u_long)); void unixpr __P((u_long)); diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 07e28194244..5426b2cfd54 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.4 1996/08/06 18:35:09 deraadt Exp $ */ +/* $OpenBSD: route.c,v 1.5 1996/08/16 09:29:34 mickey Exp $ */ /* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94"; #else -static char *rcsid = "$OpenBSD: route.c,v 1.4 1996/08/06 18:35:09 deraadt Exp $"; +static char *rcsid = "$OpenBSD: route.c,v 1.5 1996/08/16 09:29:34 mickey Exp $"; #endif #endif /* not lint */ @@ -57,6 +57,8 @@ static char *rcsid = "$OpenBSD: route.c,v 1.4 1996/08/06 18:35:09 deraadt Exp $" #include <netns/ns.h> +#include <netipx/ipx.h> + #include <sys/sysctl.h> #include <netdb.h> @@ -169,6 +171,9 @@ pr_family(af) case AF_NS: afname = "XNS"; break; + case AF_IPX: + afname = "IPX"; + break; case AF_ISO: afname = "ISO"; break; @@ -376,6 +381,10 @@ p_sockaddr(sa, flags, width) cp = ns_print(sa); break; + case AF_IPX: + cp = ipx_print(sa); + break; + case AF_LINK: { register struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa; @@ -599,6 +608,7 @@ rt_stats(off) printf("\t%u use%s of a wildcard route\n", rtstat.rts_wildcard, plural(rtstat.rts_wildcard)); } + short ns_nullh[] = {0,0,0}; short ns_bh[] = {-1,-1,-1}; @@ -667,6 +677,72 @@ ns_phost(sa) return(p); } +u_short ipx_nullh[] = {0,0,0}; +u_short ipx_bh[] = {0xffff,0xffff,0xffff}; + +char * +ipx_print(sa) + register struct sockaddr *sa; +{ + register struct sockaddr_ipx *sipx = (struct sockaddr_ipx*)sa; + struct ipx_addr work; + union { union ipx_net net_e; u_long long_e; } net; + u_short port; + static char mybuf[50], cport[10], chost[25]; + char *host = ""; + register char *p; register u_char *q; + + work = sipx->sipx_addr; + port = ntohs(work.ipx_port); + work.ipx_port = 0; + net.net_e = work.ipx_net; + if (ipx_nullhost(work) && net.long_e == 0) { + if (port != 0) { + sprintf(mybuf, "*.%xH", port); + upHex(mybuf); + } else + sprintf(mybuf, "*.*"); + return (mybuf); + } + + if (bcmp(ipx_bh, work.ipx_host.c_host, 6) == 0) { + host = "any"; + } else if (bcmp(ipx_nullh, work.ipx_host.c_host, 6) == 0) { + host = "*"; + } else { + q = work.ipx_host.c_host; + sprintf(chost, "%02x:%02x:%02x:%02x:%02x:%02x", + q[0], q[1], q[2], q[3], q[4], q[5]); + host = chost; + } + 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 * +ipx_phost(sa) + struct sockaddr *sa; +{ + register struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)sa; + struct sockaddr_ipx work; + static union ipx_net ipx_zeronet; + char *p; + + work = *sipx; + work.sipx_addr.ipx_port = 0; + work.sipx_addr.ipx_net = ipx_zeronet; + + p = ipx_print((struct sockaddr *)&work); + if (strncmp("0H.", p, 3) == 0) p += 3; + return(p); +} + void upHex(p0) char *p0; |