summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1996-02-13 17:30:37 +0000
committerwollman <wollman@FreeBSD.org>1996-02-13 17:30:37 +0000
commit379b9b388fc8788659993af038bb322bfbcea8b2 (patch)
tree0853393f80e81ab72567bd7838b4c2b218a67558
parent45f8e7f5c1b5de36c0bce4e71f98e7bb5fa9236f (diff)
downloadFreeBSD-src-379b9b388fc8788659993af038bb322bfbcea8b2.zip
FreeBSD-src-379b9b388fc8788659993af038bb322bfbcea8b2.tar.gz
XNS sort-of-support is no more.
-rw-r--r--lib/libc/net/Makefile.inc7
-rw-r--r--sbin/ifconfig/ifconfig.861
-rw-r--r--sbin/ifconfig/ifconfig.c14
-rw-r--r--sbin/route/route.c28
-rw-r--r--usr.bin/netstat/Makefile4
-rw-r--r--usr.bin/netstat/if.c6
-rw-r--r--usr.bin/netstat/main.c14
-rw-r--r--usr.sbin/Makefile13
-rw-r--r--usr.sbin/XNSrouted/Makefile9
-rw-r--r--usr.sbin/XNSrouted/XNSrouted.8186
-rw-r--r--usr.sbin/XNSrouted/af.c246
-rw-r--r--usr.sbin/XNSrouted/af.h64
-rw-r--r--usr.sbin/XNSrouted/defs.h94
-rw-r--r--usr.sbin/XNSrouted/if.c147
-rw-r--r--usr.sbin/XNSrouted/input.c189
-rw-r--r--usr.sbin/XNSrouted/interface.h90
-rw-r--r--usr.sbin/XNSrouted/main.c255
-rw-r--r--usr.sbin/XNSrouted/output.c147
-rw-r--r--usr.sbin/XNSrouted/protocol.h85
-rw-r--r--usr.sbin/XNSrouted/startup.c274
-rw-r--r--usr.sbin/XNSrouted/table.h99
-rw-r--r--usr.sbin/XNSrouted/tables.c319
-rw-r--r--usr.sbin/XNSrouted/timer.c139
-rw-r--r--usr.sbin/XNSrouted/tools/query.c232
-rw-r--r--usr.sbin/XNSrouted/trace.c313
-rw-r--r--usr.sbin/XNSrouted/trace.h96
-rw-r--r--usr.sbin/trsp/Makefile9
-rw-r--r--usr.sbin/trsp/trsp.8141
-rw-r--r--usr.sbin/trsp/trsp.c433
29 files changed, 98 insertions, 3616 deletions
diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc
index fa40736..bb0c4ea 100644
--- a/lib/libc/net/Makefile.inc
+++ b/lib/libc/net/Makefile.inc
@@ -8,9 +8,10 @@ SRCS+= gethostbydns.c gethostbyht.c gethostbynis.c gethostnamadr.c \
getproto.c getprotoent.c getprotoname.c getservbyname.c \
getservbyport.c getservent.c herror.c inet_addr.c inet_lnaof.c \
inet_makeaddr.c inet_netof.c inet_network.c inet_ntoa.c \
- linkaddr.c ns_addr.c ns_ntoa.c rcmd.c recv.c res_comp.c \
- res_data.c res_debug.c res_init.c res_mkquery.c res_query.c \
- res_send.c send.c ether_addr.c
+ linkaddr.c rcmd.c recv.c res_comp.c res_data.c res_debug.c \
+ res_init.c res_mkquery.c res_query.c res_send.c send.c ether_addr.c
+
+# ns_addr.c ns_ntoa.c
# machine-dependent net sources
.include "${.CURDIR}/${MACHINE}/net/Makefile.inc"
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index e2e4ce2..2bdaa23 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -30,9 +30,9 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
-.\" $Id$
+.\" $Id: ifconfig.8,v 1.6 1996/02/06 20:35:51 wollman Exp $
.\"
-.Dd February 6, 1996
+.Dd February 13, 1996
.Dt IFCONFIG 8
.Os BSD 4.2
.Sh NAME
@@ -80,20 +80,20 @@ or a
.Tn DARPA
Internet address expressed in the Internet standard
.Dq dot notation .
-For the Xerox Network Systems(tm) family,
-addresses are
-.Ar net:a.b.c.d.e.f ,
-where
-.Ar net
-is the assigned network number (in decimal),
-and each of the six bytes of the host number,
-.Ar a
-through
-.Ar f ,
-are specified in hexadecimal.
-The host number may be omitted on 10Mb/s Ethernet interfaces,
-which use the hardware physical address,
-and on interfaces other than the first.
+.\" For the Xerox Network Systems(tm) family,
+.\" addresses are
+.\" .Ar net:a.b.c.d.e.f ,
+.\" where
+.\" .Ar net
+.\" is the assigned network number (in decimal),
+.\" and each of the six bytes of the host number,
+.\" .Ar a
+.\" through
+.\" .Ar f ,
+.\" are specified in hexadecimal.
+.\" The host number may be omitted on 10Mb/s Ethernet interfaces,
+.\" which use the hardware physical address,
+.\" and on interfaces other than the first.
.\" For the
.\" .Tn ISO
.\" family, addresses are specified as a long hexadecimal string,
@@ -108,11 +108,12 @@ Since an interface can receive transmissions in differing protocols
with different naming schemes, specifying the address family is recommended.
The address or protocol families currently
supported are
-.Dq inet ,
+.Dq inet
.\" .Dq iso ,
-.Dq ipx ,
and
-.Dq ns .
+.Dq ipx .
+.\" and
+.\" .Dq ns .
.It Ar Interface
The
.Ar interface
@@ -164,15 +165,15 @@ marked ``down'', the system will not attempt to
transmit messages through that interface.
If possible, the interface will be reset to disable reception as well.
This action does not automatically disable routes using the interface.
-.It Cm ipdst
-This is used to specify an Internet host who is willing to receive
-ip packets encapsulating NS packets bound for a remote network.
-An apparent point to point link is constructed, and
-the address specified will be taken as the NS address and network
-of the destination.
-IP encapsulation of
-.Tn CLNP
-packets is done differently.
+.\" .It Cm ipdst
+.\" This is used to specify an Internet host who is willing to receive
+.\" ip packets encapsulating NS packets bound for a remote network.
+.\" An apparent point to point link is constructed, and
+.\" the address specified will be taken as the NS address and network
+.\" of the destination.
+.\" IP encapsulation of
+.\" .Tn CLNP
+.\" packets is done differently.
.It Cm metric Ar n
Set the routing metric of the interface to
.Ar n ,
@@ -250,8 +251,10 @@ the hardware will be re-initialized.
.El
.Pp
.Pp
-.Nm Ifconfig
+The
+.Nm ifconfig
.Fl a
+command
displays information on all interfaces. When followed by a configuration
parameter, it will also set the configuration on all interfaces.
.Pp
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 480a803..c578c6a 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -68,9 +68,11 @@ static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
#include <netipx/ipx.h>
#include <netipx/ipx_if.h>
+#ifdef NS
#define NSIP
#include <netns/ns.h>
#include <netns/ns_if.h>
+#endif
#ifdef ISO
#define EON
@@ -102,7 +104,9 @@ char name[32];
int flags;
int metric;
int mtu;
+#ifdef ISO
int nsellength = 1;
+#endif
int setaddr;
int setipdst;
int doalias;
@@ -171,7 +175,9 @@ struct cmd {
*/
int in_status(), in_getaddr();
int ipx_status(), ipx_getaddr();
+#ifdef NS
int xns_status(), xns_getaddr();
+#endif
#ifdef ISO
int iso_status(), iso_getaddr();
#endif
@@ -193,8 +199,10 @@ struct afswtch {
SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
{ "ipx", AF_IPX, ipx_status, ipx_getaddr,
SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
+#ifdef NS
{ "ns", AF_NS, xns_status, xns_getaddr,
SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
+#endif
#ifdef ISO
{ "iso", AF_ISO, iso_status, iso_getaddr,
SIOCDIFADDR_ISO, SIOCAIFADDR_ISO, C(iso_ridreq), C(iso_addreq) },
@@ -436,6 +444,7 @@ ifconfig(argc,argv,af,rafp)
if (setsockopt(s, 0, SO_IPXIP_ROUTE, &rq, size) < 0)
Perror("Encapsulation Routing");
}
+#ifdef NS
if (setipdst && af==AF_NS) {
struct nsip_req rq;
int size = sizeof(rq);
@@ -446,6 +455,7 @@ ifconfig(argc,argv,af,rafp)
if (setsockopt(s, 0, SO_NSIP_ROUTE, &rq, size) < 0)
Perror("Encapsulation Routing");
}
+#endif
if (clearaddr) {
if (rafp->af_ridreq == NULL || rafp->af_difaddr == 0) {
warnx("interface %s cannot change %s addresses!",
@@ -748,6 +758,7 @@ ipx_status(force)
}
+#ifdef NS
xns_status(force)
int force;
{
@@ -781,6 +792,7 @@ xns_status(force)
putchar('\n');
}
+#endif
#ifdef ISO
iso_status(force)
@@ -941,6 +953,7 @@ char *addr;
printf("Attempt to set IPX netmask will be ineffectual\n");
}
+#ifdef NS
#define SNS(x) ((struct sockaddr_ns *) &(x))
struct sockaddr_ns *snstab[] = {
SNS(ridreq.ifr_addr), SNS(addreq.ifra_addr),
@@ -958,6 +971,7 @@ char *addr;
if (which == MASK)
printf("Attempt to set XNS netmask will be ineffectual\n");
}
+#endif
#ifdef ISO
#define SISO(x) ((struct sockaddr_iso *) &(x))
diff --git a/sbin/route/route.c b/sbin/route/route.c
index 536cd8b..5b285f9 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -43,7 +43,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)route.c 8.3 (Berkeley) 3/19/94";
*/
static const char rcsid[] =
- "$Id: route.c,v 1.4 1996/01/20 12:56:57 mpp Exp $";
+ "$Id: route.c,v 1.5 1996/02/06 20:36:10 wollman Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -57,7 +57,9 @@ static const char rcsid[] =
#include <net/route.h>
#include <net/if_dl.h>
#include <netinet/in.h>
+#ifdef NS
#include <netns/ns.h>
+#endif
#ifdef ISO
#include <netiso/iso.h>
#endif
@@ -89,7 +91,9 @@ struct ortentry route;
union sockunion {
struct sockaddr sa;
struct sockaddr_in sin;
+#ifdef NS
struct sockaddr_ns sns;
+#endif
#ifdef ISO
struct sockaddr_iso siso;
#endif
@@ -229,9 +233,11 @@ flushroutes(argc, argv)
case K_INET:
af = AF_INET;
break;
+#ifdef NS
case K_XNS:
af = AF_NS;
break;
+#endif
case K_LINK:
af = AF_LINK;
break;
@@ -313,7 +319,9 @@ routename(sa)
struct hostent *hp;
static char domain[MAXHOSTNAMELEN + 1];
static int first = 1;
+#ifdef NS
char *ns_print();
+#endif
if (first) {
first = 0;
@@ -357,8 +365,10 @@ routename(sa)
break;
}
+#ifdef NS
case AF_NS:
return (ns_print((struct sockaddr_ns *)sa));
+#endif
case AF_LINK:
return (link_ntoa((struct sockaddr_dl *)sa));
@@ -396,7 +406,9 @@ netname(sa)
u_long net, mask;
register u_long i;
int subnetshift;
+#ifdef NS
char *ns_print();
+#endif
switch (sa->sa_family) {
@@ -450,9 +462,11 @@ netname(sa)
break;
}
+#ifdef NS
case AF_NS:
return (ns_print((struct sockaddr_ns *)sa));
break;
+#endif
case AF_LINK:
return (link_ntoa((struct sockaddr_dl *)sa));
@@ -548,10 +562,12 @@ newroute(argc, argv)
af = PF_ROUTE;
aflen = sizeof(union sockunion);
break;
+#ifdef NS
case K_XNS:
af = AF_NS;
aflen = sizeof(struct sockaddr_ns);
break;
+#endif
case K_IFACE:
case K_INTERFACE:
iflag++;
@@ -768,7 +784,9 @@ getaddr(which, s, hpp)
struct hostent **hpp;
{
register sup su;
+#ifdef NS
struct ns_addr ns_addr();
+#endif
#ifdef ISO
struct iso_addr *iso_addr();
#endif
@@ -822,6 +840,7 @@ getaddr(which, s, hpp)
return (0);
}
switch (af) {
+#ifdef NS
case AF_NS:
if (which == RTA_DST) {
extern short ns_bh[3];
@@ -834,6 +853,7 @@ getaddr(which, s, hpp)
}
su->sns.sns_addr = ns_addr(s);
return (!ns_nullhost(su->sns.sns_addr));
+#endif
#ifdef ISO
case AF_OSI:
@@ -914,6 +934,7 @@ x25_makemask()
}
#endif
+#ifdef NS
short ns_nullh[] = {0,0,0};
short ns_bh[] = {-1,-1,-1};
@@ -961,6 +982,7 @@ ns_print(sns)
host, cport);
return (mybuf);
}
+#endif
void
interfaces()
@@ -1095,7 +1117,9 @@ mask_addr()
if ((rtm_addrs & RTA_DST) == 0)
return;
switch (so_dst.sa.sa_family) {
+#ifdef NS
case AF_NS:
+#endif
case AF_INET:
#ifdef CCITT
case AF_CCITT:
@@ -1381,10 +1405,12 @@ sodump(su, which)
(void) printf("%s: inet %s; ",
which, inet_ntoa(su->sin.sin_addr));
break;
+#ifdef NS
case AF_NS:
(void) printf("%s: xns %s; ",
which, ns_ntoa(su->sns.sns_addr));
break;
+#endif
}
(void) fflush(stdout);
}
diff --git a/usr.bin/netstat/Makefile b/usr.bin/netstat/Makefile
index 2f73360..45fa21e 100644
--- a/usr.bin/netstat/Makefile
+++ b/usr.bin/netstat/Makefile
@@ -1,8 +1,8 @@
# @(#)Makefile 8.1 (Berkeley) 6/12/93
PROG= netstat
-SRCS= if.c inet.c main.c mbuf.c mroute.c ipx.c ns.c route.c \
- unix.c # iso.c tp_astring.c
+SRCS= if.c inet.c main.c mbuf.c mroute.c ipx.c route.c \
+ unix.c # iso.c ns.c tp_astring.c
CFLAGS+=-I/sys # -g
#.PATH: ${.CURDIR}/../../sys/netiso
BINGRP= kmem
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index e1a6ba9..4abe863 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -45,8 +45,10 @@ static char sccsid[] = "@(#)if.c 8.3 (Berkeley) 4/28/95";
#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>
@@ -79,7 +81,9 @@ intpr(interval, ifnetaddr)
struct ifaddr ifa;
struct in_ifaddr in;
struct ipx_ifaddr ipx;
+#ifdef NS
struct ns_ifaddr ns;
+#endif
#ifdef ISO
struct iso_ifaddr iso;
#endif
@@ -182,6 +186,7 @@ intpr(interval, ifnetaddr)
ipx_phost((struct sockaddr *)sipx));
}
break;
+#ifdef NS
case AF_NS:
{
struct sockaddr_ns *sns =
@@ -197,6 +202,7 @@ intpr(interval, ifnetaddr)
ns_phost((struct sockaddr *)sns));
}
break;
+#endif
case AF_LINK:
{
struct sockaddr_dl *sdl =
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index c136305..fb05caa 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -169,6 +169,7 @@ struct protox ipxprotox[] = {
0, 0 }
};
+#ifdef NS
struct protox nsprotox[] = {
{ N_IDP, N_IDPSTAT, 1, nsprotopr,
idp_stats, "idp" },
@@ -179,6 +180,7 @@ struct protox nsprotox[] = {
{ -1, -1, 0, 0,
0, 0 }
};
+#endif
#ifdef ISO
struct protox isoprotox[] = {
@@ -195,7 +197,10 @@ struct protox isoprotox[] = {
};
#endif
-struct protox *protoprotox[] = { protox, ipxprotox, nsprotox,
+struct protox *protoprotox[] = { protox, ipxprotox,
+#ifdef NS
+ nsprotox,
+#endif
#ifdef ISO
isoprotox,
#endif
@@ -244,9 +249,12 @@ main(argc, argv)
dflag = 1;
break;
case 'f':
+#ifdef NS
if (strcmp(optarg, "ns") == 0)
af = AF_NS;
- else if (strcmp(optarg, "ipx") == 0)
+ else
+#endif
+ if (strcmp(optarg, "ipx") == 0)
af = AF_IPX;
else if (strcmp(optarg, "inet") == 0)
af = AF_INET;
@@ -424,9 +432,11 @@ main(argc, argv)
if (af == AF_IPX || af == AF_UNSPEC)
for (tp = ipxprotox; 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++)
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index 88c2de6..5e69ad1 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -1,5 +1,5 @@
# From: @(#)Makefile 5.20 (Berkeley) 6/12/93
-# $Id: Makefile,v 1.82 1996/02/09 12:35:25 jkh Exp $
+# $Id: Makefile,v 1.83 1996/02/12 15:11:59 wpaul Exp $
# XXX MISSING: mkproto
SUBDIR= ac accton adduser amd arp bootparamd cdcontrol chown chroot \
@@ -12,17 +12,6 @@ SUBDIR= ac accton adduser amd arp bootparamd cdcontrol chown chroot \
vnconfig watch wormcontrol xntpd xten ypbind yppoll yppush ypset \
ypserv zic
-#
-# XNSrouted and trsp are of very marginal utility to anyone at this
-# point. Users who actually have a use for these programs (unlikely)
-# are free to add them back in.
-#
-# SUBDIR+=XNSrouted trsp
-
-#
-# IPXrouted is part of the optional IPX support, but it doesn't take long
-# to build and is _far_ more likely to be used than XNSrouted. :-)
-#
SUBDIR+=IPXrouted
.if make(clean) || make(cleandir)
diff --git a/usr.sbin/XNSrouted/Makefile b/usr.sbin/XNSrouted/Makefile
deleted file mode 100644
index 0c9d6e3..0000000
--- a/usr.sbin/XNSrouted/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# @(#)Makefile 8.1 (Berkeley) 6/5/93
-
-PROG= XNSrouted
-MAN8= XNSrouted.8
-SRCS= af.c if.c input.c main.c output.c startup.c tables.c timer.c trace.c
-DPADD= ${LIBCOMPAT}
-LDADD= -lcompat
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/XNSrouted/XNSrouted.8 b/usr.sbin/XNSrouted/XNSrouted.8
deleted file mode 100644
index 7b278bd..0000000
--- a/usr.sbin/XNSrouted/XNSrouted.8
+++ /dev/null
@@ -1,186 +0,0 @@
-.\" Copyright (c) 1986, 1991, 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.
-.\"
-.\" @(#)XNSrouted.8 8.1 (Berkeley) 6/5/93
-.\"
-.Dd June 5, 1993
-.Dt XNSROUTED 8
-.Os BSD 4.3
-.Sh NAME
-.Nm XNSrouted
-.Nd NS Routing Information Protocol daemon
-.Sh SYNOPSIS
-.Nm XNSrouted
-.Op Fl q
-.Op Fl s
-.Op Fl t
-.Op Ar logfile
-.Sh DESCRIPTION
-.Nm XNSrouted
-is invoked at boot time to manage the Xerox NS routing tables.
-The NS routing daemon uses the Xerox NS Routing
-Information Protocol in maintaining up to date kernel routing
-table entries.
-.Pp
-Available options:
-.Bl -tag -width logfile
-.It Fl q
-Do not supply routing information (opposite of
-.Fl s
-option below).
-.It Fl s
-Forces
-.Nm XNSrouted
-to supply routing information whether it is acting as an internetwork
-router or not.
-.It Fl t
-All packets sent or received are
-printed on the standard output. In addition,
-.Nm XNSrouted
-will not divorce itself from the controlling terminal
-so that interrupts from the keyboard will kill the process.
-.It Ar logfile
-Name of file in which
-.Nm XNSrouted Ns 's
-actions should be logged. This log contains information
-about any changes to the routing tables and a history of
-recent messages sent and received which are related to
-the changed route.
-.El
-.Pp
-In normal operation
-.Nm XNSrouted
-listens
-for routing information packets. If the host is connected to
-multiple NS networks, it periodically supplies copies
-of its routing tables to any directly connected hosts
-and networks.
-.Pp
-When
-.Nm XNSrouted
-is started, it uses the
-.Dv SIOCGIFCONF
-.Xr ioctl 2
-to find those
-directly connected interfaces configured into the
-system and marked
-.Dq up
-(the software loopback interface
-is ignored). If multiple interfaces
-are present, it is assumed the host will forward packets
-between networks.
-.Nm XNSrouted
-then transmits a
-.Em request
-packet on each interface (using a broadcast packet if
-the interface supports it) and enters a loop, listening
-for
-.Em request
-and
-.Em response
-packets from other hosts.
-.Pp
-When a
-.Em request
-packet is received,
-.Nm XNSrouted
-formulates a reply based on the information maintained in its
-internal tables. The
-.Em response
-packet generated contains a list of known routes, each marked
-with a
-.Dq hop count
-metric (a count of 16, or greater, is
-considered
-.Dq infinite ) .
-The metric associated with each
-route returned provides a metric
-.Em relative to the sender .
-.Pp
-.Em Response
-packets received by
-.Nm XNSrouted
-are used to update the routing tables if one of the following
-conditions is satisfied:
-.Bl -bullet
-.It
-No routing table entry exists for the destination network
-or host, and the metric indicates the destination is ``reachable''
-(i.e. the hop count is not infinite).
-.It
-The source host of the packet is the same as the router in the
-existing routing table entry. That is, updated information is
-being received from the very internetwork router through which
-packets for the destination are being routed.
-.It
-The existing entry in the routing table has not been updated for
-some time (defined to be 90 seconds) and the route is at least
-as cost effective as the current route.
-.It
-The new route describes a shorter route to the destination than
-the one currently stored in the routing tables; the metric of
-the new route is compared against the one stored in the table
-to decide this.
-.El
-.Pp
-When an update is applied,
-.Nm XNSrouted
-records the change in its internal tables and generates a
-.Em response
-packet to all directly connected hosts and networks.
-.Xr Routed 8
-waits a short period
-of time (no more than 30 seconds) before modifying the kernel's
-routing tables to allow possible unstable situations to settle.
-.Pp
-In addition to processing incoming packets,
-.Nm XNSrouted
-also periodically checks the routing table entries.
-If an entry has not been updated for 3 minutes, the entry's metric
-is set to infinity and marked for deletion. Deletions are delayed
-an additional 60 seconds to insure the invalidation is propagated
-to other routers.
-.Pp
-Hosts acting as internetwork routers gratuitously supply their
-routing tables every 30 seconds to all directly connected hosts
-and networks.
-.Sh SEE ALSO
-.Xr idp 4
-.Rs
-.%T "Internet Transport Protocols"
-.%R "XSIS 028112"
-.%Q "Xerox System Integration Standard"
-.Re
-.Sh HISTORY
-The
-.Nm
-command appeared in
-.Bx 4.3 .
diff --git a/usr.sbin/XNSrouted/af.c b/usr.sbin/XNSrouted/af.c
deleted file mode 100644
index f6d59c8..0000000
--- a/usr.sbin/XNSrouted/af.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (c) 1985, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This file includes significant work done at Cornell University by
- * Bill Nesheim. That work included by permission.
- *
- * 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[] = "@(#)af.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-
-#include "defs.h"
-
-/*
- * Address family support routines
- */
-int null_hash(), null_netmatch(), null_output(),
- null_portmatch(), null_portcheck(),
- null_checkhost(), null_ishost(), null_canon();
-int xnnet_hash(), xnnet_netmatch(), xnnet_output(),
- xnnet_portmatch(),
- xnnet_checkhost(), xnnet_ishost(), xnnet_canon();
-#define NIL \
- { null_hash, null_netmatch, null_output, \
- null_portmatch, null_portcheck, null_checkhost, \
- null_ishost, null_canon }
-#define XNSNET \
- { xnnet_hash, xnnet_netmatch, xnnet_output, \
- xnnet_portmatch, xnnet_portmatch, xnnet_checkhost, \
- xnnet_ishost, xnnet_canon }
-
-struct afswitch afswitch[AF_MAX] =
- { NIL, NIL, NIL, NIL, NIL, NIL, XNSNET, NIL, NIL, NIL, NIL };
-
-struct sockaddr_ns xnnet_default = { sizeof(struct sockaddr_ns), AF_NS };
-
-union ns_net ns_anynet;
-union ns_net ns_zeronet;
-
-xnnet_hash(sns, hp)
- register struct sockaddr_ns *sns;
- struct afhash *hp;
-{
- register long hash = 0;
- register u_short *s = sns->sns_addr.x_host.s_host;
- union ns_net_u net;
-
- net.net_e = sns->sns_addr.x_net;
- hp->afh_nethash = net.long_e;
- hash = *s++; hash <<= 8; hash += *s++; hash <<= 8; hash += *s;
- hp->afh_hosthash = hash;
-}
-
-xnnet_netmatch(sxn1, sxn2)
- struct sockaddr_ns *sxn1, *sxn2;
-{
- return (ns_neteq(sxn1->sns_addr, sxn2->sns_addr));
-}
-
-/*
- * Verify the message is from the right port.
- */
-xnnet_portmatch(sns)
- register struct sockaddr_ns *sns;
-{
-
- return (ntohs(sns->sns_addr.x_port) == IDPPORT_RIF );
-}
-
-
-/*
- * xns output routine.
- */
-#ifdef DEBUG
-int do_output = 0;
-#endif
-xnnet_output(flags, sns, size)
- int flags;
- struct sockaddr_ns *sns;
- int size;
-{
- struct sockaddr_ns dst;
-
- dst = *sns;
- sns = &dst;
- if (sns->sns_addr.x_port == 0)
- sns->sns_addr.x_port = htons(IDPPORT_RIF);
-#ifdef DEBUG
- if(do_output || ntohs(msg->rip_cmd) == RIPCMD_REQUEST)
-#endif
- /*
- * Kludge to allow us to get routes out to machines that
- * don't know their addresses yet; send to that address on
- * ALL connected nets
- */
- if (ns_neteqnn(sns->sns_addr.x_net, ns_zeronet)) {
- extern struct interface *ifnet;
- register struct interface *ifp;
-
- for (ifp = ifnet; ifp; ifp = ifp->int_next) {
- sns->sns_addr.x_net =
- satons_addr(ifp->int_addr).x_net;
- (void) sendto(s, msg, size, flags,
- (struct sockaddr *)sns, sizeof (*sns));
- }
- return;
- }
-
- (void) sendto(s, msg, size, flags,
- (struct sockaddr *)sns, sizeof (*sns));
-}
-
-/*
- * Return 1 if we want this route.
- * We use this to disallow route net G entries for one for multiple
- * point to point links.
- */
-xnnet_checkhost(sns)
- struct sockaddr_ns *sns;
-{
- register struct interface *ifp = if_ifwithnet(sns);
- /*
- * We want this route if there is no more than one
- * point to point interface with this network.
- */
- if (ifp == 0 || (ifp->int_flags & IFF_POINTOPOINT)==0) return (1);
- return (ifp->int_sq.n == ifp->int_sq.p);
-}
-
-/*
- * Return 1 if the address is
- * for a host, 0 for a network.
- */
-xnnet_ishost(sns)
-struct sockaddr_ns *sns;
-{
- register u_short *s = sns->sns_addr.x_host.s_host;
-
- if ((s[0]==0xffff) && (s[1]==0xffff) && (s[2]==0xffff))
- return (0);
- else
- return (1);
-}
-
-xnnet_canon(sns)
- struct sockaddr_ns *sns;
-{
-
- sns->sns_addr.x_port = 0;
-}
-
-/*ARGSUSED*/
-null_hash(addr, hp)
- struct sockaddr *addr;
- struct afhash *hp;
-{
-
- hp->afh_nethash = hp->afh_hosthash = 0;
-}
-
-/*ARGSUSED*/
-null_netmatch(a1, a2)
- struct sockaddr *a1, *a2;
-{
-
- return (0);
-}
-
-/*ARGSUSED*/
-null_output(s, f, a1, n)
- int s, f;
- struct sockaddr *a1;
- int n;
-{
-
- ;
-}
-
-/*ARGSUSED*/
-null_portmatch(a1)
- struct sockaddr *a1;
-{
-
- return (0);
-}
-
-/*ARGSUSED*/
-null_portcheck(a1)
- struct sockaddr *a1;
-{
-
- return (0);
-}
-
-/*ARGSUSED*/
-null_ishost(a1)
- struct sockaddr *a1;
-{
-
- return (0);
-}
-
-/*ARGSUSED*/
-null_checkhost(a1)
- struct sockaddr *a1;
-{
-
- return (0);
-}
-
-/*ARGSUSED*/
-null_canon(a1)
- struct sockaddr *a1;
-{
-
- ;
-}
diff --git a/usr.sbin/XNSrouted/af.h b/usr.sbin/XNSrouted/af.h
deleted file mode 100644
index 9b74463..0000000
--- a/usr.sbin/XNSrouted/af.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 1983, 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.
- *
- * @(#)af.h 5.1 (Berkeley) 6/4/85 (routed/af.h)
- *
- * @(#)af.h 8.1 (Berkeley) 6/5/93
- */
-
-/*
- * Routing table management daemon.
- */
-
-/*
- * Per address family routines.
- */
-struct afswitch {
- int (*af_hash)(); /* returns keys based on address */
- int (*af_netmatch)(); /* verifies net # matching */
- int (*af_output)(); /* interprets address for sending */
- int (*af_portmatch)(); /* packet from some other router? */
- int (*af_portcheck)(); /* packet from privileged peer? */
- int (*af_checkhost)(); /* tells if address for host or net */
- int (*af_ishost)(); /* tells if address is valid */
- int (*af_canon)(); /* canonicalize address for compares */
-};
-
-/*
- * Structure returned by af_hash routines.
- */
-struct afhash {
- u_int afh_hosthash; /* host based hash */
- u_int afh_nethash; /* network based hash */
-};
-
-struct afswitch afswitch[AF_MAX]; /* table proper */
diff --git a/usr.sbin/XNSrouted/defs.h b/usr.sbin/XNSrouted/defs.h
deleted file mode 100644
index c6f8b5f..0000000
--- a/usr.sbin/XNSrouted/defs.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 1983, 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.
- *
- * @(#)defs.h 8.1 (Berkeley) 6/5/93
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <net/route.h>
-#include <netns/ns.h>
-#include <netns/idp.h>
-#if defined(vax) || defined(pdp11)
-#define xnnet(x) ((u_long) (x)->rip_dst[1] << 16 | (u_long) (x)->rip_dst[0] )
-#else
-#define xnnet(x) ((u_long) (x)->rip_dst[0] << 16 | (u_long) (x)->rip_dst[1] )
-#endif
-#define IDPPORT_RIF 1
-
-#include <stdio.h>
-#include <syslog.h>
-
-#include "protocol.h"
-#include "trace.h"
-#include "interface.h"
-#include "table.h"
-#include "af.h"
-
-
-/*
- * When we find any interfaces marked down we rescan the
- * kernel every CHECK_INTERVAL seconds to see if they've
- * come up.
- */
-#define CHECK_INTERVAL (5*60)
-
-#define equal(a1, a2) \
- (bcmp((caddr_t)(a1), (caddr_t)(a2), sizeof (struct sockaddr)) == 0)
-#define min(a,b) ((a)>(b)?(b):(a))
-
-struct sockaddr_ns addr; /* Daemon's Address */
-int s; /* Socket to listen on */
-int kmem;
-int supplier; /* process should supply updates */
-int install; /* if 1 call kernel */
-int lookforinterfaces; /* if 1 probe kernel for new up interfaces */
-int performnlist; /* if 1 check if /kernel has changed */
-int externalinterfaces; /* # of remote and local interfaces */
-int timeval; /* local idea of time */
-int noteremoterequests; /* squawk on requests from non-local nets */
-int r; /* Routing socket to install updates with */
-struct sockaddr_ns ns_netmask; /* Used in installing routes */
-
-char packet[MAXPACKETSIZE+sizeof(struct idp)+1];
-struct rip *msg;
-
-char **argv0;
-
-int sndmsg();
-int supply();
-int cleanup();
-int rtioctl();
-#define ADD 1
-#define DELETE 2
-#define CHANGE 3
diff --git a/usr.sbin/XNSrouted/if.c b/usr.sbin/XNSrouted/if.c
deleted file mode 100644
index a06c7c1..0000000
--- a/usr.sbin/XNSrouted/if.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 1983, 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.
- *
- * static char sccsid[] = "@(#)if.c 5.1 (Berkeley) 6/4/85"; (routed/if.c)
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)if.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-
-/*
- * Routing Table Management Daemon
- */
-#include "defs.h"
-
-extern struct interface *ifnet;
-
-/*
- * Find the interface with address addr.
- */
-struct interface *
-if_ifwithaddr(addr)
- struct sockaddr *addr;
-{
- register struct interface *ifp;
-
-#define same(a1, a2) \
- (bcmp((caddr_t)((a1)->sa_data), (caddr_t)((a2)->sa_data), 14) == 0)
- for (ifp = ifnet; ifp; ifp = ifp->int_next) {
- if (ifp->int_flags & IFF_REMOTE)
- continue;
- if (ifp->int_addr.sa_family != addr->sa_family)
- continue;
- if (same(&ifp->int_addr, addr))
- break;
- if ((ifp->int_flags & IFF_BROADCAST) &&
- same(&ifp->int_broadaddr, addr))
- break;
- }
- return (ifp);
-}
-
-/*
- * Find the point-to-point interface with destination address addr.
- */
-struct interface *
-if_ifwithdstaddr(addr)
- struct sockaddr *addr;
-{
- register struct interface *ifp;
-
- for (ifp = ifnet; ifp; ifp = ifp->int_next) {
- if ((ifp->int_flags & IFF_POINTOPOINT) == 0)
- continue;
- if (same(&ifp->int_dstaddr, addr))
- break;
- }
- return (ifp);
-}
-
-/*
- * Find the interface on the network
- * of the specified address.
- */
-struct interface *
-if_ifwithnet(addr)
- register struct sockaddr *addr;
-{
- register struct interface *ifp;
- register int af = addr->sa_family;
- register int (*netmatch)();
-
- if (af >= AF_MAX)
- return (0);
- netmatch = afswitch[af].af_netmatch;
- for (ifp = ifnet; ifp; ifp = ifp->int_next) {
- if (ifp->int_flags & IFF_REMOTE)
- continue;
- if (af != ifp->int_addr.sa_family)
- continue;
- if ((*netmatch)(addr, &ifp->int_addr))
- break;
- }
- return (ifp);
-}
-
-/*
- * Find an interface from which the specified address
- * should have come from. Used for figuring out which
- * interface a packet came in on -- for tracing.
- */
-struct interface *
-if_iflookup(addr)
- struct sockaddr *addr;
-{
- register struct interface *ifp, *maybe;
- register int af = addr->sa_family;
- register int (*netmatch)();
-
- if (af >= AF_MAX)
- return (0);
- maybe = 0;
- netmatch = afswitch[af].af_netmatch;
- for (ifp = ifnet; ifp; ifp = ifp->int_next) {
- if (ifp->int_addr.sa_family != af)
- continue;
- if (same(&ifp->int_addr, addr))
- break;
- if ((ifp->int_flags & IFF_BROADCAST) &&
- same(&ifp->int_broadaddr, addr))
- break;
- if (maybe == 0 && (*netmatch)(addr, &ifp->int_addr))
- maybe = ifp;
- }
- if (ifp == 0)
- ifp = maybe;
- return (ifp);
-}
diff --git a/usr.sbin/XNSrouted/input.c b/usr.sbin/XNSrouted/input.c
deleted file mode 100644
index 14d352f..0000000
--- a/usr.sbin/XNSrouted/input.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 1985, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This file includes significant work done at Cornell University by
- * Bill Nesheim. That work included by permission.
- *
- * 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[] = "@(#)input.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-
-/*
- * XNS Routing Table Management Daemon
- */
-#include "defs.h"
-
-struct sockaddr *
-xns_nettosa(net)
-union ns_net net;
-{
- static struct sockaddr_ns sxn;
- extern char ether_broadcast_addr[6];
-
- bzero(&sxn, sizeof (struct sockaddr_ns));
- sxn.sns_family = AF_NS;
- sxn.sns_len = sizeof (sxn);
- sxn.sns_addr.x_net = net;
- sxn.sns_addr.x_host = *(union ns_host *)ether_broadcast_addr;
- return( (struct sockaddr *)&sxn);
-
-}
-
-/*
- * Process a newly received packet.
- */
-rip_input(from, size)
- struct sockaddr *from;
- int size;
-{
- struct rt_entry *rt;
- struct netinfo *n;
- struct interface *ifp;
- int newsize;
- struct afswitch *afp;
-
-
- ifp = 0;
- TRACE_INPUT(ifp, from, size);
- if (from->sa_family >= AF_MAX)
- return;
- afp = &afswitch[from->sa_family];
-
- size -= sizeof (u_short) /* command */;
- n = msg->rip_nets;
-
- switch (ntohs(msg->rip_cmd)) {
-
- case RIPCMD_REQUEST:
- newsize = 0;
- while (size > 0) {
- if (size < sizeof (struct netinfo))
- break;
- size -= sizeof (struct netinfo);
-
- /*
- * A single entry with rip_dst == DSTNETS_ALL and
- * metric ``infinity'' means ``all routes''.
- */
- if (ns_neteqnn(n->rip_dst, ns_anynet) &&
- ntohs(n->rip_metric) == HOPCNT_INFINITY &&
- size == 0) {
- ifp = if_ifwithnet(from);
- supply(from, 0, ifp);
- return;
- }
- /*
- * request for specific nets
- */
- rt = rtlookup(xns_nettosa(n->rip_dst));
- if (ftrace) {
- fprintf(ftrace,
- "specific request for %s",
- xns_nettoa(n->rip_dst));
- fprintf(ftrace,
- " yields route %x\n",
- rt);
- }
- n->rip_metric = htons( rt == 0 ? HOPCNT_INFINITY :
- min(rt->rt_metric+1, HOPCNT_INFINITY));
- n++;
- newsize += sizeof (struct netinfo);
- }
- if (newsize > 0) {
- msg->rip_cmd = htons(RIPCMD_RESPONSE);
- newsize += sizeof (u_short);
- /* should check for if with dstaddr(from) first */
- (*afp->af_output)(0, from, newsize);
- ifp = if_ifwithnet(from);
- TRACE_OUTPUT(ifp, from, newsize);
- if (ftrace) {
- fprintf(ftrace,
- "request arrived on interface %s\n",
- ifp->int_name);
- }
- }
- return;
-
- case RIPCMD_RESPONSE:
- /* verify message came from a router */
- if ((*afp->af_portmatch)(from) == 0)
- return;
- (*afp->af_canon)(from);
- /* are we talking to ourselves? */
- if (ifp = if_ifwithaddr(from)) {
- rt = rtfind(from);
- if (rt == 0 || (rt->rt_state & RTS_INTERFACE) == 0)
- addrouteforif(ifp);
- else
- rt->rt_timer = 0;
- return;
- }
- /* Update timer for interface on which the packet arrived.
- * If from other end of a point-to-point link that isn't
- * in the routing tables, (re-)add the route.
- */
- if ((rt = rtfind(from)) && (rt->rt_state & RTS_INTERFACE)) {
- if(ftrace) fprintf(ftrace, "Got route\n");
- rt->rt_timer = 0;
- } else if (ifp = if_ifwithdstaddr(from)) {
- if(ftrace) fprintf(ftrace, "Got partner\n");
- addrouteforif(ifp);
- }
- for (; size > 0; size -= sizeof (struct netinfo), n++) {
- struct sockaddr *sa;
- if (size < sizeof (struct netinfo))
- break;
- if ((unsigned) ntohs(n->rip_metric) >= HOPCNT_INFINITY)
- continue;
- rt = rtfind(sa = xns_nettosa(n->rip_dst));
- if (rt == 0) {
- rtadd(sa, from, ntohs(n->rip_metric), 0);
- continue;
- }
-
- /*
- * Update if from gateway and different,
- * from anywhere and shorter, or getting stale and equivalent.
- */
- if ((equal(from, &rt->rt_router) &&
- ntohs(n->rip_metric) != rt->rt_metric ) ||
- (unsigned) ntohs(n->rip_metric) < rt->rt_metric ||
- (rt->rt_timer > (EXPIRE_TIME/2) &&
- rt->rt_metric == ntohs(n->rip_metric))) {
- rtchange(rt, from, ntohs(n->rip_metric));
- rt->rt_timer = 0;
- }
- }
- return;
- }
-}
diff --git a/usr.sbin/XNSrouted/interface.h b/usr.sbin/XNSrouted/interface.h
deleted file mode 100644
index 64e1580..0000000
--- a/usr.sbin/XNSrouted/interface.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 1983, 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.
- *
- * @(#)interface.h 8.1 (Berkeley) 6/5/93
- */
-
-/*
- * Routing table management daemon.
- */
-
-/*
- * An ``interface'' is similar to an ifnet structure,
- * except it doesn't contain q'ing info, and it also
- * handles ``logical'' interfaces (remote gateways
- * that we want to keep polling even if they go down).
- * The list of interfaces which we maintain is used
- * in supplying the gratuitous routing table updates.
- * We list only one address for each interface, the AF_XNS one.
- */
-#define NIFADDR 3
-struct interface {
- struct interface *int_next;
- struct sockaddr int_addr; /* address on this host */
- union {
- struct sockaddr intu_broadaddr;
- struct sockaddr intu_dstaddr;
- } int_intu;
-#define int_broadaddr int_intu.intu_broadaddr /* broadcast address */
-#define int_dstaddr int_intu.intu_dstaddr /* other end of p-to-p link */
- int int_metric; /* init's routing entry */
- int int_flags; /* see below */
- struct ifdebug int_input, int_output; /* packet tracing stuff */
- int int_ipackets; /* input packets received */
- int int_opackets; /* output packets sent */
- char *int_name; /* from kernel if structure */
- u_short int_transitions; /* times gone up-down */
-/*XNS Specific entry */
- struct sameq {
- struct sameq *n; /* q of other pt-to-pt links */
- struct sameq *p; /* with same net # */
- } int_sq;
-};
-
-/*
- * 0x1 to 0x10 are reused from the kernel's ifnet definitions,
- * the others agree with the RTS_ flags defined elsewhere.
- */
-#define IFF_UP 0x1 /* interface is up */
-#define IFF_BROADCAST 0x2 /* broadcast address valid */
-#define IFF_DEBUG 0x4 /* turn on debugging */
-#define IFF_ROUTE 0x8 /* routing entry installed */
-#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
-
-#define IFF_PASSIVE 0x2000 /* can't tell if up/down */
-#define IFF_INTERFACE 0x4000 /* hardware interface */
-#define IFF_REMOTE 0x8000 /* interface isn't on this machine */
-
-struct interface *if_ifwithaddr();
-struct interface *if_ifwithdstaddr();
-struct interface *if_ifwithnet();
-struct interface *if_iflookup();
diff --git a/usr.sbin/XNSrouted/main.c b/usr.sbin/XNSrouted/main.c
deleted file mode 100644
index f350ae4..0000000
--- a/usr.sbin/XNSrouted/main.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Copyright (c) 1985, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This file includes significant work done at Cornell University by
- * Bill Nesheim. That work included by permission.
- *
- * 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 copyright[] =
-"@(#) Copyright (c) 1985, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-
-/*
- * XNS Routing Information Protocol Daemon
- */
-#include "defs.h"
-#include <sys/time.h>
-
-#include <net/if.h>
-
-#include <errno.h>
-#include <nlist.h>
-#include <signal.h>
-#include <paths.h>
-
-int supplier = -1; /* process should supply updates */
-extern int gateway;
-
-struct rip *msg = (struct rip *) &packet[sizeof (struct idp)];
-void hup(), fkexit(), timer();
-
-main(argc, argv)
- int argc;
- char *argv[];
-{
- int cc;
- struct sockaddr from;
- u_char retry;
-
- argv0 = argv;
- argv++, argc--;
- while (argc > 0 && **argv == '-') {
- if (strcmp(*argv, "-s") == 0) {
- supplier = 1;
- argv++, argc--;
- continue;
- }
- if (strcmp(*argv, "-q") == 0) {
- supplier = 0;
- argv++, argc--;
- continue;
- }
- if (strcmp(*argv, "-R") == 0) {
- noteremoterequests++;
- argv++, argc--;
- continue;
- }
- if (strcmp(*argv, "-t") == 0) {
- tracepackets++;
- argv++, argc--;
- ftrace = stderr;
- tracing = 1;
- continue;
- }
- if (strcmp(*argv, "-g") == 0) {
- gateway = 1;
- argv++, argc--;
- continue;
- }
- if (strcmp(*argv, "-l") == 0) {
- gateway = -1;
- argv++, argc--;
- continue;
- }
- fprintf(stderr,
- "usage: xnsrouted [ -s ] [ -q ] [ -t ] [ -g ] [ -l ]\n");
- exit(1);
- }
-
-
-#ifndef DEBUG
- if (!tracepackets)
- daemon(0, 0);
-#endif
- openlog("XNSrouted", LOG_PID, LOG_DAEMON);
-
- addr.sns_family = AF_NS;
- addr.sns_len = sizeof(addr);
- addr.sns_port = htons(IDPPORT_RIF);
- ns_anynet.s_net[0] = ns_anynet.s_net[1] = -1;
- ns_netmask.sns_addr.x_net = ns_anynet;
- ns_netmask.sns_len = 6;
- r = socket(AF_ROUTE, SOCK_RAW, 0);
- /* later, get smart about lookingforinterfaces */
- if (r)
- shutdown(r, 0); /* for now, don't want reponses */
- else {
- fprintf(stderr, "routed: no routing socket\n");
- exit(1);
- }
- s = getsocket(SOCK_DGRAM, 0, &addr);
- if (s < 0)
- exit(1);
- /*
- * Any extra argument is considered
- * a tracing log file.
- */
- if (argc > 0)
- traceon(*argv);
- /*
- * Collect an initial view of the world by
- * snooping in the kernel. Then, send a request packet on all
- * directly connected networks to find out what
- * everyone else thinks.
- */
- rtinit();
- ifinit();
- if (supplier < 0)
- supplier = 0;
- /* request the state of the world */
- msg->rip_cmd = htons(RIPCMD_REQUEST);
- msg->rip_nets[0].rip_dst = ns_anynet;
- msg->rip_nets[0].rip_metric = htons(HOPCNT_INFINITY);
- toall(sndmsg);
- signal(SIGALRM, timer);
- signal(SIGHUP, hup);
- signal(SIGINT, hup);
- signal(SIGEMT, fkexit);
- timer();
-
-
- for (;;)
- process(s);
-
-}
-
-process(fd)
- int fd;
-{
- struct sockaddr from;
- int fromlen = sizeof (from), cc, omask;
- struct idp *idp = (struct idp *)packet;
-
- cc = recvfrom(fd, packet, sizeof (packet), 0, &from, &fromlen);
- if (cc <= 0) {
- if (cc < 0 && errno != EINTR)
- syslog(LOG_ERR, "recvfrom: %m");
- return;
- }
- if (tracepackets > 1 && ftrace) {
- fprintf(ftrace,"rcv %d bytes on %s ", cc, xns_ntoa(&idp->idp_dna));
- fprintf(ftrace," from %s\n", xns_ntoa(&idp->idp_sna));
- }
-
- if (noteremoterequests && !ns_neteqnn(idp->idp_sna.x_net, ns_zeronet)
- && !ns_neteq(idp->idp_sna, idp->idp_dna))
- {
- syslog(LOG_ERR,
- "net of interface (%s) != net on ether (%s)!\n",
- xns_nettoa(idp->idp_dna.x_net),
- xns_nettoa(idp->idp_sna.x_net));
- }
-
- /* We get the IDP header in front of the RIF packet*/
- cc -= sizeof (struct idp);
-#define mask(s) (1<<((s)-1))
- omask = sigblock(mask(SIGALRM));
- rip_input(&from, cc);
- sigsetmask(omask);
-}
-
-getsocket(type, proto, sns)
- int type, proto;
- struct sockaddr_ns *sns;
-{
- int domain = sns->sns_family;
- int retry, s, on = 1;
-
- retry = 1;
- while ((s = socket(domain, type, proto)) < 0 && retry) {
- syslog(LOG_ERR, "socket: %m");
- sleep(5 * retry);
- retry <<= 1;
- }
- if (retry == 0)
- return (-1);
- while (bind(s, (struct sockaddr *)sns, sizeof (*sns)) < 0 && retry) {
- syslog(LOG_ERR, "bind: %m");
- sleep(5 * retry);
- retry <<= 1;
- }
- if (retry == 0)
- return (-1);
- if (domain==AF_NS) {
- struct idp idp;
- if (setsockopt(s, 0, SO_HEADERS_ON_INPUT, &on, sizeof(on))) {
- syslog(LOG_ERR, "setsockopt SEE HEADERS: %m");
- exit(1);
- }
- idp.idp_pt = NSPROTO_RI;
- if (setsockopt(s, 0, SO_DEFAULT_HEADERS, &idp, sizeof(idp))) {
- syslog(LOG_ERR, "setsockopt SET HEADER: %m");
- exit(1);
- }
- }
- if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) {
- syslog(LOG_ERR, "setsockopt SO_BROADCAST: %m");
- exit(1);
- }
- return (s);
-}
-
-/*
- * Fork and exit on EMT-- for profiling.
- */
-void
-fkexit()
-{
- if (fork() == 0)
- exit(0);
-}
diff --git a/usr.sbin/XNSrouted/output.c b/usr.sbin/XNSrouted/output.c
deleted file mode 100644
index fae1c39..0000000
--- a/usr.sbin/XNSrouted/output.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 1985, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This file includes significant work done at Cornell University by
- * Bill Nesheim. That work included by permission.
- *
- * 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[] = "@(#)output.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-
-/*
- * Routing Table Management Daemon
- */
-#include "defs.h"
-
-/*
- * Apply the function "f" to all non-passive
- * interfaces. If the interface supports the
- * use of broadcasting use it, otherwise address
- * the output to the known router.
- */
-toall(f)
- int (*f)();
-{
- register struct interface *ifp;
- register struct sockaddr *dst;
- register int flags;
- extern struct interface *ifnet;
-
- for (ifp = ifnet; ifp; ifp = ifp->int_next) {
- if (ifp->int_flags & IFF_PASSIVE)
- continue;
- dst = ifp->int_flags & IFF_BROADCAST ? &ifp->int_broadaddr :
- ifp->int_flags & IFF_POINTOPOINT ? &ifp->int_dstaddr :
- &ifp->int_addr;
- flags = ifp->int_flags & IFF_INTERFACE ? MSG_DONTROUTE : 0;
- (*f)(dst, flags, ifp);
- }
-}
-
-/*
- * Output a preformed packet.
- */
-/*ARGSUSED*/
-sndmsg(dst, flags, ifp)
- struct sockaddr *dst;
- int flags;
- struct interface *ifp;
-{
-
- (*afswitch[dst->sa_family].af_output)
- (flags, dst, sizeof (struct rip));
- TRACE_OUTPUT(ifp, dst, sizeof (struct rip));
-}
-
-/*
- * Supply dst with the contents of the routing tables.
- * If this won't fit in one packet, chop it up into several.
- */
-supply(dst, flags, ifp)
- struct sockaddr *dst;
- int flags;
- struct interface *ifp;
-{
- register struct rt_entry *rt;
- register struct rthash *rh;
- register struct netinfo *nn;
- register struct netinfo *n = msg->rip_nets;
- struct rthash *base = hosthash;
- struct sockaddr_ns *sns = (struct sockaddr_ns *) dst;
- int (*output)() = afswitch[dst->sa_family].af_output;
- int doinghost = 1, size, metric;
- union ns_net net;
-
- msg->rip_cmd = ntohs(RIPCMD_RESPONSE);
-again:
- for (rh = base; rh < &base[ROUTEHASHSIZ]; rh++)
- for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) {
- size = (char *)n - (char *)msg;
- if (size > MAXPACKETSIZE - sizeof (struct netinfo)) {
- (*output)(flags, dst, size);
- TRACE_OUTPUT(ifp, dst, size);
- n = msg->rip_nets;
- }
- sns = (struct sockaddr_ns *)&rt->rt_dst;
- if ((rt->rt_flags & (RTF_HOST|RTF_GATEWAY)) == RTF_HOST)
- sns = (struct sockaddr_ns *)&rt->rt_router;
- metric = min(rt->rt_metric + 1, HOPCNT_INFINITY);
- net = sns->sns_addr.x_net;
- /*
- * Make sure that we don't put out a two net entries
- * for a pt to pt link (one for the G route, one for the if)
- * This is a kludge, and won't work if there are lots of nets.
- */
- for (nn = msg->rip_nets; nn < n; nn++) {
- if (ns_neteqnn(net, nn->rip_dst)) {
- if (metric < ntohs(nn->rip_metric))
- nn->rip_metric = htons(metric);
- goto next;
- }
- }
- n->rip_dst = net;
- n->rip_metric = htons(metric);
- n++;
- next:;
- }
- if (doinghost) {
- doinghost = 0;
- base = nethash;
- goto again;
- }
- if (n != msg->rip_nets) {
- size = (char *)n - (char *)msg;
- (*output)(flags, dst, size);
- TRACE_OUTPUT(ifp, dst, size);
- }
-}
diff --git a/usr.sbin/XNSrouted/protocol.h b/usr.sbin/XNSrouted/protocol.h
deleted file mode 100644
index 372340a..0000000
--- a/usr.sbin/XNSrouted/protocol.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 1985, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This file includes significant work done at Cornell University by
- * Bill Nesheim. That work included by permission.
- *
- * 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.
- *
- * @(#)protocol.h 8.1 (Berkeley) 6/5/93
- */
-
-/*
- * Xerox Routing Information Protocol
- *
- */
-
-struct netinfo {
- union ns_net rip_dst; /* destination net */
- u_short rip_metric; /* cost of route */
-};
-
-struct rip {
- u_short rip_cmd; /* request/response */
- struct netinfo rip_nets[1]; /* variable length */
-};
-
-/*
- * Packet types.
- */
-#define RIPCMD_REQUEST 1 /* want info */
-#define RIPCMD_RESPONSE 2 /* responding to request */
-
-#define RIPCMD_MAX 3
-#ifdef RIPCMDS
-char *ripcmds[RIPCMD_MAX] =
- { "#0", "REQUEST", "RESPONSE" };
-#endif
-
-#define HOPCNT_INFINITY 16 /* per Xerox NS */
-#define DSTNETS_ALL 0xffffffff /* per Xerox NS */
-#define MAXPACKETSIZE 512 /* max broadcast size */
-
-extern union ns_net ns_anynet;
-extern union ns_net ns_zeronet;
-
-/*
- * Timer values used in managing the routing table.
- * Every update forces an entry's timer to be reset. After
- * EXPIRE_TIME without updates, the entry is marked invalid,
- * but held onto until GARBAGE_TIME so that others may
- * see it "be deleted".
- */
-#define TIMER_RATE 30 /* alarm clocks every 30 seconds */
-
-#define SUPPLY_INTERVAL 30 /* time to supply tables */
-
-#define EXPIRE_TIME 180 /* time to mark entry invalid */
-#define GARBAGE_TIME 240 /* time to garbage collect */
diff --git a/usr.sbin/XNSrouted/startup.c b/usr.sbin/XNSrouted/startup.c
deleted file mode 100644
index 5959706..0000000
--- a/usr.sbin/XNSrouted/startup.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (c) 1985, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This file includes significant work done at Cornell University by
- * Bill Nesheim. That work included by permission.
- *
- * 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[] = "@(#)startup.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-
-/*
- * Routing Table Management Daemon
- */
-#include "defs.h"
-
-#include <sys/param.h>
-#include <sys/ioctl.h>
-#include <sys/sysctl.h>
-
-#include <net/if.h>
-#include <net/if_dl.h>
-
-#include <nlist.h>
-#include <stdlib.h>
-
-struct interface *ifnet;
-int lookforinterfaces = 1;
-int performnlist = 1;
-int gateway = 0;
-int externalinterfaces = 0; /* # of remote and local interfaces */
-char ether_broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
-
-void
-quit(s)
- char *s;
-{
- extern int errno;
- int sverrno = errno;
-
- (void) fprintf(stderr, "route: ");
- if (s)
- (void) fprintf(stderr, "%s: ", s);
- (void) fprintf(stderr, "%s\n", strerror(sverrno));
- exit(1);
- /* NOTREACHED */
-}
-
-struct rt_addrinfo info;
-/* Sleazy use of local variables throughout file, warning!!!! */
-#define netmask info.rti_info[RTAX_NETMASK]
-#define ifaaddr info.rti_info[RTAX_IFA]
-#define brdaddr info.rti_info[RTAX_BRD]
-
-#define ROUNDUP(a) \
- ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
-#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
-
-void
-rt_xaddrs(cp, cplim, rtinfo)
- register caddr_t cp, cplim;
- register struct rt_addrinfo *rtinfo;
-{
- register struct sockaddr *sa;
- register int i;
-
- bzero(rtinfo->rti_info, sizeof(rtinfo->rti_info));
- for (i = 0; (i < RTAX_MAX) && (cp < cplim); i++) {
- if ((rtinfo->rti_addrs & (1 << i)) == 0)
- continue;
- rtinfo->rti_info[i] = sa = (struct sockaddr *)cp;
- ADVANCE(cp, sa);
- }
-}
-
-/*
- * Find the network interfaces which have configured themselves.
- * If the interface is present but not yet up (for example an
- * ARPANET IMP), set the lookforinterfaces flag so we'll
- * come back later and look again.
- */
-ifinit()
-{
- struct interface ifs, *ifp;
- size_t needed;
- int mib[6], no_nsaddr = 0, flags = 0;
- char *buf, *cplim, *cp;
- register struct if_msghdr *ifm;
- register struct ifa_msghdr *ifam;
- struct sockaddr_dl *sdl;
- u_long i;
-
- mib[0] = CTL_NET;
- mib[1] = PF_ROUTE;
- mib[2] = 0;
- mib[3] = AF_NS;
- mib[4] = NET_RT_IFLIST;
- mib[5] = 0;
- if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
- quit("route-sysctl-estimate");
- if ((buf = malloc(needed)) == NULL)
- quit("malloc");
- if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
- lookforinterfaces = 0;
- cplim = buf + needed;
- for (cp = buf; cp < cplim; cp += ifm->ifm_msglen) {
- ifm = (struct if_msghdr *)cp;
- if (ifm->ifm_type == RTM_IFINFO) {
- bzero(&ifs, sizeof(ifs));
- ifs.int_flags = flags = ifm->ifm_flags | IFF_INTERFACE;
- if ((flags & IFF_UP) == 0 || no_nsaddr)
- lookforinterfaces = 1;
- sdl = (struct sockaddr_dl *) (ifm + 1);
- sdl->sdl_data[sdl->sdl_nlen] = 0;
- no_nsaddr = 1;
- continue;
- }
- if (ifm->ifm_type != RTM_NEWADDR)
- quit("ifinit: out of sync");
- if ((flags & IFF_UP) == 0)
- continue;
- ifam = (struct ifa_msghdr *)ifm;
- info.rti_addrs = ifam->ifam_addrs;
- rt_xaddrs((char *)(ifam + 1), cp + ifam->ifam_msglen, &info);
- if (ifaaddr == 0) {
- syslog(LOG_ERR, "%s: (get addr)", sdl->sdl_data);
- continue;
- }
- ifs.int_addr = *ifaaddr;
- if (ifs.int_addr.sa_family != AF_NS)
- continue;
- no_nsaddr = 0;
- if (ifs.int_flags & IFF_POINTOPOINT) {
- if (brdaddr == 0) {
- syslog(LOG_ERR, "%s: (get dstaddr)",
- sdl->sdl_data);
- continue;
- }
- if (brdaddr->sa_family == AF_UNSPEC) {
- lookforinterfaces = 1;
- continue;
- }
- ifs.int_dstaddr = *brdaddr;
- }
- if (ifs.int_flags & IFF_BROADCAST) {
- if (brdaddr == 0) {
- syslog(LOG_ERR, "%s: (get broadaddr)",
- sdl->sdl_data);
- continue;
- }
- ifs.int_dstaddr = *brdaddr;
- }
- /*
- * already known to us?
- * what makes a POINTOPOINT if unique is its dst addr,
- * NOT its source address
- */
- if ( ((ifs.int_flags & IFF_POINTOPOINT) &&
- if_ifwithdstaddr(&ifs.int_dstaddr)) ||
- ( ((ifs.int_flags & IFF_POINTOPOINT) == 0) &&
- if_ifwithaddr(&ifs.int_addr)))
- continue;
- /* no one cares about software loopback interfaces */
- if (ifs.int_flags & IFF_LOOPBACK)
- continue;
- ifp = (struct interface *)
- malloc(sdl->sdl_nlen + 1 + sizeof(ifs));
- if (ifp == 0) {
- syslog(LOG_ERR, "XNSrouted: out of memory\n");
- lookforinterfaces = 1;
- break;
- }
- *ifp = ifs;
- /*
- * Count the # of directly connected networks
- * and point to point links which aren't looped
- * back to ourself. This is used below to
- * decide if we should be a routing ``supplier''.
- */
- if ((ifs.int_flags & IFF_POINTOPOINT) == 0 ||
- if_ifwithaddr(&ifs.int_dstaddr) == 0)
- externalinterfaces++;
- /*
- * If we have a point-to-point link, we want to act
- * as a supplier even if it's our only interface,
- * as that's the only way our peer on the other end
- * can tell that the link is up.
- */
- if ((ifs.int_flags & IFF_POINTOPOINT) && supplier < 0)
- supplier = 1;
- ifp->int_name = (char *)(ifp + 1);
- strcpy(ifp->int_name, sdl->sdl_data);
- ifp->int_metric = ifam->ifam_metric;
- ifp->int_next = ifnet;
- ifnet = ifp;
- traceinit(ifp);
- addrouteforif(ifp);
- }
- if (externalinterfaces > 1 && supplier < 0)
- supplier = 1;
- free(buf);
-}
-
-addrouteforif(ifp)
- struct interface *ifp;
-{
- struct sockaddr_ns net;
- struct sockaddr *dst;
- int state, metric;
- struct rt_entry *rt;
-
- if (ifp->int_flags & IFF_POINTOPOINT) {
- int (*match)();
- register struct interface *ifp2 = ifnet;
- register struct interface *ifprev = ifnet;
-
- dst = &ifp->int_dstaddr;
-
- /* Search for interfaces with the same net */
- ifp->int_sq.n = ifp->int_sq.p = &(ifp->int_sq);
- match = afswitch[dst->sa_family].af_netmatch;
- if (match)
- for (ifp2 = ifnet; ifp2; ifp2 =ifp2->int_next) {
- if (ifp->int_flags & IFF_POINTOPOINT == 0)
- continue;
- if ((*match)(&ifp2->int_dstaddr,&ifp->int_dstaddr)) {
- insque(&ifp2->int_sq,&ifp->int_sq);
- break;
- }
- }
- } else {
- dst = &ifp->int_broadaddr;
- }
- rt = rtlookup(dst);
- if (rt)
- rtdelete(rt);
- if (tracing)
- fprintf(stderr, "Adding route to interface %s\n", ifp->int_name);
- if (ifp->int_transitions++ > 0)
- syslog(LOG_ERR, "re-installing interface %s", ifp->int_name);
- rtadd(dst, &ifp->int_addr, ifp->int_metric,
- ifp->int_flags & (IFF_INTERFACE|IFF_PASSIVE|IFF_REMOTE));
-}
-
diff --git a/usr.sbin/XNSrouted/table.h b/usr.sbin/XNSrouted/table.h
deleted file mode 100644
index 1de2a95..0000000
--- a/usr.sbin/XNSrouted/table.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 1983, 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.
- *
- * @(#)table.h 5.1 (Berkeley) 6/4/85 (routed/table.h)
- *
- * @(#)table.h 8.1 (Berkeley) 6/5/93
- */
-
-/*
- * Routing table management daemon.
- */
-
-/*
- * Routing table structure; differs a bit from kernel tables.
- *
- * Note: the union below must agree in the first 4 members
- * so the ioctl's will work.
- */
-struct rthash {
- struct rt_entry *rt_forw;
- struct rt_entry *rt_back;
-};
-
-#ifdef RTM_ADD
-#define rtentry ortentry
-#endif
-
-struct rt_entry {
- struct rt_entry *rt_forw;
- struct rt_entry *rt_back;
- union {
- struct rtentry rtu_rt;
- struct {
- u_long rtu_hash;
- struct sockaddr rtu_dst;
- struct sockaddr rtu_router;
- short rtu_flags;
- short rtu_state;
- int rtu_timer;
- int rtu_metric;
- struct interface *rtu_ifp;
- } rtu_entry;
- } rt_rtu;
-};
-
-#define rt_rt rt_rtu.rtu_rt /* pass to ioctl */
-#define rt_hash rt_rtu.rtu_entry.rtu_hash /* for net or host */
-#define rt_dst rt_rtu.rtu_entry.rtu_dst /* match value */
-#define rt_router rt_rtu.rtu_entry.rtu_router /* who to forward to */
-#define rt_flags rt_rtu.rtu_entry.rtu_flags /* kernel flags */
-#define rt_timer rt_rtu.rtu_entry.rtu_timer /* for invalidation */
-#define rt_state rt_rtu.rtu_entry.rtu_state /* see below */
-#define rt_metric rt_rtu.rtu_entry.rtu_metric /* cost of route */
-#define rt_ifp rt_rtu.rtu_entry.rtu_ifp /* interface to take */
-
-#define ROUTEHASHSIZ 32 /* must be a power of 2 */
-#define ROUTEHASHMASK (ROUTEHASHSIZ - 1)
-
-/*
- * "State" of routing table entry.
- */
-#define RTS_CHANGED 0x1 /* route has been altered recently */
-#define RTS_PASSIVE IFF_PASSIVE /* don't time out route */
-#define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */
-#define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */
-
-struct rthash nethash[ROUTEHASHSIZ];
-struct rthash hosthash[ROUTEHASHSIZ];
-struct rt_entry *rtlookup();
-struct rt_entry *rtfind();
diff --git a/usr.sbin/XNSrouted/tables.c b/usr.sbin/XNSrouted/tables.c
deleted file mode 100644
index 4b00dc5..0000000
--- a/usr.sbin/XNSrouted/tables.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright (c) 1985, 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[] = "@(#)tables.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-
-/*
- * Routing Table Management Daemon
- */
-#include "defs.h"
-#include <sys/ioctl.h>
-#include <errno.h>
-
-#ifndef DEBUG
-#define DEBUG 0
-#endif
-
-extern char *xns_ntoa();
-#define FIXLEN(s) { if ((s)->sa_len == 0) (s)->sa_len = sizeof (*(s));}
-
-int install = !DEBUG; /* if 1 call kernel */
-int delete = 1;
-/*
- * Lookup dst in the tables for an exact match.
- */
-struct rt_entry *
-rtlookup(dst)
- struct sockaddr *dst;
-{
- register struct rt_entry *rt;
- register struct rthash *rh;
- register u_int hash;
- struct afhash h;
- int doinghost = 1;
-
- if (dst->sa_family >= AF_MAX)
- return (0);
- (*afswitch[dst->sa_family].af_hash)(dst, &h);
- hash = h.afh_hosthash;
- rh = &hosthash[hash & ROUTEHASHMASK];
-again:
- for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) {
- if (rt->rt_hash != hash)
- continue;
- if (equal(&rt->rt_dst, dst))
- return (rt);
- }
- if (doinghost) {
- doinghost = 0;
- hash = h.afh_nethash;
- rh = &nethash[hash & ROUTEHASHMASK];
- goto again;
- }
- return (0);
-}
-
-/*
- * Find a route to dst as the kernel would.
- */
-struct rt_entry *
-rtfind(dst)
- struct sockaddr *dst;
-{
- register struct rt_entry *rt;
- register struct rthash *rh;
- register u_int hash;
- struct afhash h;
- int af = dst->sa_family;
- int doinghost = 1, (*match)();
-
- if (af >= AF_MAX)
- return (0);
- (*afswitch[af].af_hash)(dst, &h);
- hash = h.afh_hosthash;
- rh = &hosthash[hash & ROUTEHASHMASK];
-
-again:
- for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) {
- if (rt->rt_hash != hash)
- continue;
- if (doinghost) {
- if (equal(&rt->rt_dst, dst))
- return (rt);
- } else {
- if (rt->rt_dst.sa_family == af &&
- (*match)(&rt->rt_dst, dst))
- return (rt);
- }
- }
- if (doinghost) {
- doinghost = 0;
- hash = h.afh_nethash;
- rh = &nethash[hash & ROUTEHASHMASK];
- match = afswitch[af].af_netmatch;
- goto again;
- }
- return (0);
-}
-
-rtadd(dst, gate, metric, state)
- struct sockaddr *dst, *gate;
- int metric, state;
-{
- struct afhash h;
- register struct rt_entry *rt;
- struct rthash *rh;
- int af = dst->sa_family, flags;
- u_int hash;
-
- FIXLEN(dst);
- FIXLEN(gate);
- if (af >= AF_MAX)
- return;
- (*afswitch[af].af_hash)(dst, &h);
- flags = (*afswitch[af].af_ishost)(dst) ? RTF_HOST : 0;
- if (flags & RTF_HOST) {
- hash = h.afh_hosthash;
- rh = &hosthash[hash & ROUTEHASHMASK];
- } else {
- hash = h.afh_nethash;
- rh = &nethash[hash & ROUTEHASHMASK];
- }
- rt = (struct rt_entry *)malloc(sizeof (*rt));
- if (rt == 0)
- return;
- rt->rt_hash = hash;
- rt->rt_dst = *dst;
- rt->rt_router = *gate;
- rt->rt_metric = metric;
- rt->rt_timer = 0;
- rt->rt_flags = RTF_UP | flags;
- rt->rt_state = state | RTS_CHANGED;
- rt->rt_ifp = if_ifwithnet(&rt->rt_router);
- if (metric)
- rt->rt_flags |= RTF_GATEWAY;
- insque(rt, rh);
- TRACE_ACTION(ADD, rt);
- /*
- * If the ioctl fails because the gateway is unreachable
- * from this host, discard the entry. This should only
- * occur because of an incorrect entry in /etc/gateways.
- */
- if (install && rtioctl(ADD, &rt->rt_rt) < 0) {
- if (errno != EEXIST)
- perror("SIOCADDRT");
- if (errno == ENETUNREACH) {
- TRACE_ACTION(DELETE, rt);
- remque(rt);
- free((char *)rt);
- }
- }
-}
-
-rtchange(rt, gate, metric)
- struct rt_entry *rt;
- struct sockaddr *gate;
- short metric;
-{
- int doioctl = 0, metricchanged = 0;
- struct rtentry oldroute;
-
- FIXLEN(gate);
- if (!equal(&rt->rt_router, gate))
- doioctl++;
- if (metric != rt->rt_metric)
- metricchanged++;
- if (doioctl || metricchanged) {
- TRACE_ACTION(CHANGE FROM, rt);
- if (doioctl) {
- oldroute = rt->rt_rt;
- rt->rt_router = *gate;
- }
- rt->rt_metric = metric;
- if ((rt->rt_state & RTS_INTERFACE) && metric) {
- rt->rt_state &= ~RTS_INTERFACE;
- syslog(LOG_ERR,
- "changing route from interface %s (timed out)",
- rt->rt_ifp->int_name);
- }
- if (metric)
- rt->rt_flags |= RTF_GATEWAY;
- else
- rt->rt_flags &= ~RTF_GATEWAY;
- rt->rt_state |= RTS_CHANGED;
- TRACE_ACTION(CHANGE TO, rt);
- }
- if (doioctl && install) {
-#ifndef RTM_ADD
- if (rtioctl(ADD, &rt->rt_rt) < 0)
- syslog(LOG_ERR, "rtioctl ADD dst %s, gw %s: %m",
- xns_ntoa(&((struct sockaddr_ns *)&rt->rt_dst)->sns_addr),
- xns_ntoa(&((struct sockaddr_ns *)&rt->rt_router)->sns_addr));
- if (delete && rtioctl(DELETE, &oldroute) < 0)
- perror("rtioctl DELETE");
-#else
- if (delete == 0) {
- if (rtioctl(ADD, &rt->rt_rt) >= 0)
- return;
- } else {
- if (rtioctl(CHANGE, &rt->rt_rt) >= 0)
- return;
- }
- syslog(LOG_ERR, "rtioctl ADD dst %s, gw %s: %m",
- xns_ntoa(&((struct sockaddr_ns *)&rt->rt_dst)->sns_addr),
- xns_ntoa(&((struct sockaddr_ns *)&rt->rt_router)->sns_addr));
-#endif
- }
-}
-
-rtdelete(rt)
- struct rt_entry *rt;
-{
-
- struct sockaddr *sa = &(rt->rt_rt.rt_gateway);
- FIXLEN(sa);
-#undef rt_dst
- sa = &(rt->rt_rt.rt_dst);
- FIXLEN(sa);
- if (rt->rt_state & RTS_INTERFACE) {
- syslog(LOG_ERR, "deleting route to interface %s (timed out)",
- rt->rt_ifp->int_name);
- }
- TRACE_ACTION(DELETE, rt);
- if (install && rtioctl(DELETE, &rt->rt_rt) < 0)
- perror("rtioctl DELETE");
- remque(rt);
- free((char *)rt);
-}
-
-rtinit()
-{
- register struct rthash *rh;
-
- for (rh = nethash; rh < &nethash[ROUTEHASHSIZ]; rh++)
- rh->rt_forw = rh->rt_back = (struct rt_entry *)rh;
- for (rh = hosthash; rh < &hosthash[ROUTEHASHSIZ]; rh++)
- rh->rt_forw = rh->rt_back = (struct rt_entry *)rh;
-}
-int seqno;
-
-rtioctl(action, ort)
- int action;
- struct ortentry *ort;
-{
-#ifndef RTM_ADD
- switch (action) {
-
- case ADD:
- return (ioctl(s, SIOCADDRT, (char *)ort));
-
- case DELETE:
- return (ioctl(s, SIOCDELRT, (char *)ort));
-
- default:
- return (-1);
- }
-#else /* RTM_ADD */
- struct {
- struct rt_msghdr w_rtm;
- struct sockaddr w_dst;
- struct sockaddr w_gate;
- struct sockaddr_ns w_netmask;
- } w;
-#define rtm w.w_rtm
-
- bzero((char *)&w, sizeof(w));
- rtm.rtm_msglen = sizeof(w);
- rtm.rtm_version = RTM_VERSION;
- rtm.rtm_type = (action == ADD ? RTM_ADD :
- (action == DELETE ? RTM_DELETE : RTM_CHANGE));
-#undef rt_flags
- rtm.rtm_flags = ort->rt_flags;
- rtm.rtm_seq = ++seqno;
- rtm.rtm_addrs = RTA_DST|RTA_GATEWAY;
- bcopy((char *)&ort->rt_dst, (char *)&w.w_dst, sizeof(w.w_dst));
- bcopy((char *)&ort->rt_gateway, (char *)&w.w_gate, sizeof(w.w_gate));
- w.w_gate.sa_family = w.w_dst.sa_family = AF_NS;
- w.w_gate.sa_len = w.w_dst.sa_len = sizeof(w.w_dst);
- if (rtm.rtm_flags & RTF_HOST) {
- rtm.rtm_msglen -= sizeof(w.w_netmask);
- } else {
- w.w_netmask = ns_netmask;
- rtm.rtm_msglen -= 8;
- }
- errno = 0;
- return write(r, (char *)&w, rtm.rtm_msglen);
-#endif /* RTM_ADD */
-}
diff --git a/usr.sbin/XNSrouted/timer.c b/usr.sbin/XNSrouted/timer.c
deleted file mode 100644
index dd91e6d..0000000
--- a/usr.sbin/XNSrouted/timer.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 1985, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This file includes significant work done at Cornell University by
- * Bill Nesheim. That work included by permission.
- *
- * 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[] = "@(#)timer.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-
-/*
- * Routing Table Management Daemon
- */
-#include "defs.h"
-
-int timeval = -TIMER_RATE;
-
-/*
- * Timer routine. Performs routing information supply
- * duties and manages timers on routing table entries.
- */
-void
-timer()
-{
- register struct rthash *rh;
- register struct rt_entry *rt;
- struct rthash *base = hosthash;
- int doinghost = 1, timetobroadcast;
-
- timeval += TIMER_RATE;
- if (lookforinterfaces && (timeval % CHECK_INTERVAL) == 0)
- ifinit();
- timetobroadcast = supplier && (timeval % SUPPLY_INTERVAL) == 0;
-again:
- for (rh = base; rh < &base[ROUTEHASHSIZ]; rh++) {
- rt = rh->rt_forw;
- for (; rt != (struct rt_entry *)rh; rt = rt->rt_forw) {
- /*
- * We don't advance time on a routing entry for
- * a passive gateway or that for our only interface.
- * The latter is excused because we don't act as
- * a routing information supplier and hence would
- * time it out. This is fair as if it's down
- * we're cut off from the world anyway and it's
- * not likely we'll grow any new hardware in
- * the mean time.
- */
- if (!(rt->rt_state & RTS_PASSIVE) &&
- (supplier || !(rt->rt_state & RTS_INTERFACE)))
- rt->rt_timer += TIMER_RATE;
- if (rt->rt_timer >= EXPIRE_TIME)
- rt->rt_metric = HOPCNT_INFINITY;
- if (rt->rt_timer >= GARBAGE_TIME) {
- rt = rt->rt_back;
- /* Perhaps we should send a REQUEST for this route? */
- rtdelete(rt->rt_forw);
- continue;
- }
- if (rt->rt_state & RTS_CHANGED) {
- rt->rt_state &= ~RTS_CHANGED;
- /* don't send extraneous packets */
- if (!supplier || timetobroadcast)
- continue;
- msg->rip_cmd = htons(RIPCMD_RESPONSE);
- msg->rip_nets[0].rip_dst =
- (satons_addr(rt->rt_dst)).x_net;
- msg->rip_nets[0].rip_metric =
- htons(min(rt->rt_metric+1, HOPCNT_INFINITY));
- toall(sndmsg);
- }
- }
- }
- if (doinghost) {
- doinghost = 0;
- base = nethash;
- goto again;
- }
- if (timetobroadcast)
- toall(supply);
- alarm(TIMER_RATE);
-}
-
-/*
- * On hangup, let everyone know we're going away.
- */
-void
-hup()
-{
- register struct rthash *rh;
- register struct rt_entry *rt;
- struct rthash *base = hosthash;
- int doinghost = 1;
-
- if (supplier) {
-again:
- for (rh = base; rh < &base[ROUTEHASHSIZ]; rh++) {
- rt = rh->rt_forw;
- for (; rt != (struct rt_entry *)rh; rt = rt->rt_forw)
- rt->rt_metric = HOPCNT_INFINITY;
- }
- if (doinghost) {
- doinghost = 0;
- base = nethash;
- goto again;
- }
- toall(supply);
- }
- exit(1);
-}
diff --git a/usr.sbin/XNSrouted/tools/query.c b/usr.sbin/XNSrouted/tools/query.c
deleted file mode 100644
index 71b3733..0000000
--- a/usr.sbin/XNSrouted/tools/query.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/*-
- * Copyright (c) 1983, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code includes software contributed to Berkeley by
- * Bill Nesheim at Cornell University.
- *
- * 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 copyright[] =
-"@(#) Copyright (c) 1983, 1986, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/protosw.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <netns/ns.h>
-#include <netns/idp.h>
-#include <errno.h>
-#include <stdio.h>
-#include <netdb.h>
-#include "../protocol.h"
-#define IDPPORT_RIF 1
-
-#define WTIME 5 /* Time to wait for responses */
-
-int s;
-int timedout, timeout();
-char packet[MAXPACKETSIZE];
-extern int errno;
-struct sockaddr_ns myaddr = {sizeof(myaddr), AF_NS};
-char *ns_ntoa();
-struct ns_addr ns_addr();
-main(argc, argv)
-int argc;
-char *argv[];
-{
- int cc, count, bits;
- struct sockaddr from;
- int fromlen = sizeof(from);
- struct timeval notime;
-
- if (argc < 2) {
- printf("usage: query hosts...\n");
- exit(1);
- }
- s = getsocket(SOCK_DGRAM, 0);
- if (s < 0) {
- perror("socket");
- exit(2);
- }
-
- argv++, argc--;
- query(argv,argc);
-
- /*
- * Listen for returning packets;
- * may be more than one packet per host.
- */
- bits = 1 << s;
- bzero(&notime, sizeof(notime));
- signal(SIGALRM, timeout);
- alarm(WTIME);
- while (!timedout ||
- select(20, &bits, 0, 0, &notime) > 0) {
- struct nspacket {
- struct idp hdr;
- char data[512];
- } response;
- cc = recvfrom(s, &response, sizeof (response), 0,
- &from, &fromlen);
- if (cc <= 0) {
- if (cc < 0) {
- if (errno == EINTR)
- continue;
- perror("recvfrom");
- (void) close(s);
- exit(1);
- }
- continue;
- }
- rip_input(&from, response.data, cc);
- count--;
- }
-}
-static struct sockaddr_ns router = {sizeof(myaddr), AF_NS};
-static struct ns_addr zero_addr;
-static short allones[] = {-1, -1, -1};
-
-query(argv,argc)
-char **argv;
-{
- register struct rip *msg = (struct rip *)packet;
- char *host = *argv;
- int flags = 0;
- struct ns_addr specific;
-
- if (bcmp(*argv, "-r", 3) == 0) {
- flags = MSG_DONTROUTE; argv++; argc--;
- }
- host = *argv;
- router.sns_addr = ns_addr(host);
- router.sns_addr.x_port = htons(IDPPORT_RIF);
- if (ns_hosteq(zero_addr, router.sns_addr)) {
- router.sns_addr.x_host = *(union ns_host *) allones;
- }
- msg->rip_cmd = htons(RIPCMD_REQUEST);
- msg->rip_nets[0].rip_dst = *(union ns_net *) allones;
- msg->rip_nets[0].rip_metric = htons(HOPCNT_INFINITY);
- if (argc > 0) {
- specific = ns_addr(*argv);
- msg->rip_nets[0].rip_dst = specific.x_net;
- specific.x_host = zero_addr.x_host;
- specific.x_port = zero_addr.x_port;
- printf("Net asked for was %s\n", ns_ntoa(specific));
- }
- if (sendto(s, packet, sizeof (struct rip), flags,
- &router, sizeof(router)) < 0)
- perror(host);
-}
-
-/*
- * Handle an incoming routing packet.
- */
-rip_input(from, msg, size)
- struct sockaddr_ns *from;
- register struct rip *msg;
- int size;
-{
- struct netinfo *n;
- char *name;
- int lna, net, subnet;
- struct hostent *hp;
- struct netent *np;
- static struct ns_addr work;
-
- if (htons(msg->rip_cmd) != RIPCMD_RESPONSE)
- return;
- printf("from %s\n", ns_ntoa(from->sns_addr));
- size -= sizeof (struct idp);
- size -= sizeof (short);
- n = msg->rip_nets;
- while (size > 0) {
- union ns_net_u net;
- if (size < sizeof (struct netinfo))
- break;
- net.net_e = n->rip_dst;
- printf("\t%d, metric %d\n", ntohl(net.long_e),
- ntohs(n->rip_metric));
- size -= sizeof (struct netinfo), n++;
- }
-}
-
-timeout()
-{
- timedout = 1;
-}
-getsocket(type, proto)
- int type, proto;
-{
- struct sockaddr_ns *sns = &myaddr;
- int domain = sns->sns_family;
- int retry, s, on = 1;
-
- retry = 1;
- while ((s = socket(domain, type, proto)) < 0 && retry) {
- perror("socket");
- sleep(5 * retry);
- retry <<= 1;
- }
- if (retry == 0)
- return (-1);
- while (bind(s, sns, sizeof (*sns), 0) < 0 && retry) {
- perror("bind");
- sleep(5 * retry);
- retry <<= 1;
- }
- if (retry == 0)
- return (-1);
- if (domain==AF_NS) {
- struct idp idp;
- if (setsockopt(s, 0, SO_HEADERS_ON_INPUT, &on, sizeof(on))) {
- perror("setsockopt SEE HEADERS");
- exit(1);
- }
- idp.idp_pt = NSPROTO_RI;
- if (setsockopt(s, 0, SO_DEFAULT_HEADERS, &idp, sizeof(idp))) {
- perror("setsockopt SET HEADERS");
- exit(1);
- }
- }
- if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) {
- perror("setsockopt SO_BROADCAST");
- exit(1);
- }
- return (s);
-}
diff --git a/usr.sbin/XNSrouted/trace.c b/usr.sbin/XNSrouted/trace.c
deleted file mode 100644
index 859d991..0000000
--- a/usr.sbin/XNSrouted/trace.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (c) 1985, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This file includes significant work done at Cornell University by
- * Bill Nesheim. That work included by permission.
- *
- * 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[] = "@(#)trace.c 8.1 (Berkeley) 6/5/93";
-#endif /* not lint */
-
-/*
- * Routing Table Management Daemon
- */
-#define RIPCMDS
-#include <stdlib.h>
-#include "defs.h"
-
-#define NRECORDS 50 /* size of circular trace buffer */
-#ifdef DEBUG
-FILE *ftrace = stdout;
-int tracing = 1;
-#else DEBUG
-FILE *ftrace = NULL;
-int tracing = 0;
-#endif
-
-char *xns_ntoa();
-
-traceinit(ifp)
- register struct interface *ifp;
-{
- static int iftraceinit();
-
- if (iftraceinit(ifp, &ifp->int_input) &&
- iftraceinit(ifp, &ifp->int_output))
- return;
- tracing = 0;
- syslog(LOG_ERR, "traceinit: can't init %s\n", ifp->int_name);
-}
-
-static
-iftraceinit(ifp, ifd)
- struct interface *ifp;
- register struct ifdebug *ifd;
-{
- register struct iftrace *t;
-
- ifd->ifd_records =
- (struct iftrace *)malloc(NRECORDS * sizeof (struct iftrace));
- if (ifd->ifd_records == 0)
- return (0);
- ifd->ifd_front = ifd->ifd_records;
- ifd->ifd_count = 0;
- for (t = ifd->ifd_records; t < ifd->ifd_records + NRECORDS; t++) {
- t->ift_size = 0;
- t->ift_packet = 0;
- }
- ifd->ifd_if = ifp;
- return (1);
-}
-
-traceon(file)
- char *file;
-{
-
- if (ftrace != NULL)
- return;
- ftrace = fopen(file, "a");
- if (ftrace == NULL)
- return;
- dup2(fileno(ftrace), 1);
- dup2(fileno(ftrace), 2);
- tracing = 1;
-}
-
-traceoff()
-{
- if (!tracing)
- return;
- if (ftrace != NULL)
- fclose(ftrace);
- ftrace = NULL;
- tracing = 0;
-}
-
-trace(ifd, who, p, len, m)
- register struct ifdebug *ifd;
- struct sockaddr *who;
- char *p;
- int len, m;
-{
- register struct iftrace *t;
-
- if (ifd->ifd_records == 0)
- return;
- t = ifd->ifd_front++;
- if (ifd->ifd_front >= ifd->ifd_records + NRECORDS)
- ifd->ifd_front = ifd->ifd_records;
- if (ifd->ifd_count < NRECORDS)
- ifd->ifd_count++;
- if (t->ift_size > 0 && t->ift_packet)
- free(t->ift_packet);
- t->ift_packet = 0;
- t->ift_stamp = time(0);
- t->ift_who = *who;
- if (len > 0) {
- t->ift_packet = malloc(len);
- if (t->ift_packet)
- bcopy(p, t->ift_packet, len);
- else
- len = 0;
- }
- t->ift_size = len;
- t->ift_metric = m;
-}
-
-traceaction(fd, action, rt)
- FILE *fd;
- char *action;
- struct rt_entry *rt;
-{
- struct sockaddr_ns *dst, *gate;
- static struct bits {
- int t_bits;
- char *t_name;
- } flagbits[] = {
- { RTF_UP, "UP" },
- { RTF_GATEWAY, "GATEWAY" },
- { RTF_HOST, "HOST" },
- { 0 }
- }, statebits[] = {
- { RTS_PASSIVE, "PASSIVE" },
- { RTS_REMOTE, "REMOTE" },
- { RTS_INTERFACE,"INTERFACE" },
- { RTS_CHANGED, "CHANGED" },
- { 0 }
- };
- register struct bits *p;
- register int first;
- char *cp;
- struct interface *ifp;
-
- if (fd == NULL)
- return;
- fprintf(fd, "%s ", action);
- dst = (struct sockaddr_ns *)&rt->rt_dst;
- gate = (struct sockaddr_ns *)&rt->rt_router;
- fprintf(fd, "dst %s, ", xns_ntoa(&dst->sns_addr));
- fprintf(fd, "router %s, metric %d, flags",
- xns_ntoa(&gate->sns_addr), rt->rt_metric);
- cp = " %s";
- for (first = 1, p = flagbits; p->t_bits > 0; p++) {
- if ((rt->rt_flags & p->t_bits) == 0)
- continue;
- fprintf(fd, cp, p->t_name);
- if (first) {
- cp = "|%s";
- first = 0;
- }
- }
- fprintf(fd, " state");
- cp = " %s";
- for (first = 1, p = statebits; p->t_bits > 0; p++) {
- if ((rt->rt_state & p->t_bits) == 0)
- continue;
- fprintf(fd, cp, p->t_name);
- if (first) {
- cp = "|%s";
- first = 0;
- }
- }
- putc('\n', fd);
- if (!tracepackets && (rt->rt_state & RTS_PASSIVE) == 0 && rt->rt_ifp)
- dumpif(fd, rt->rt_ifp);
- fflush(fd);
-}
-
-dumpif(fd, ifp)
- register struct interface *ifp;
- FILE *fd;
-{
- if (ifp->int_input.ifd_count || ifp->int_output.ifd_count) {
- fprintf(fd, "*** Packet history for interface %s ***\n",
- ifp->int_name);
- dumptrace(fd, "to", &ifp->int_output);
- dumptrace(fd, "from", &ifp->int_input);
- fprintf(fd, "*** end packet history ***\n");
- }
-}
-
-dumptrace(fd, dir, ifd)
- FILE *fd;
- char *dir;
- register struct ifdebug *ifd;
-{
- register struct iftrace *t;
- char *cp = !strcmp(dir, "to") ? "Output" : "Input";
-
- if (ifd->ifd_front == ifd->ifd_records &&
- ifd->ifd_front->ift_size == 0) {
- fprintf(fd, "%s: no packets.\n", cp);
- return;
- }
- fprintf(fd, "%s trace:\n", cp);
- t = ifd->ifd_front - ifd->ifd_count;
- if (t < ifd->ifd_records)
- t += NRECORDS;
- for ( ; ifd->ifd_count; ifd->ifd_count--, t++) {
- if (t >= ifd->ifd_records + NRECORDS)
- t = ifd->ifd_records;
- if (t->ift_size == 0)
- continue;
- fprintf(fd, "%.24s: metric=%d\n", ctime(&t->ift_stamp),
- t->ift_metric);
- dumppacket(fd, dir, &t->ift_who, t->ift_packet, t->ift_size);
- }
-}
-
-dumppacket(fd, dir, who, cp, size)
- FILE *fd;
- struct sockaddr_ns *who; /* should be sockaddr */
- char *dir, *cp;
- register int size;
-{
- register struct rip *msg = (struct rip *)cp;
- register struct netinfo *n;
- char *xns_nettoa();
-
- if (msg->rip_cmd && ntohs(msg->rip_cmd) < RIPCMD_MAX)
- fprintf(fd, "%s %s %s#%x", ripcmds[ntohs(msg->rip_cmd)],
- dir, xns_ntoa(&who->sns_addr), ntohs(who->sns_addr.x_port));
- else {
- fprintf(fd, "Bad cmd 0x%x %s %s#%x\n", ntohs(msg->rip_cmd),
- dir, xns_ntoa(&who->sns_addr), ntohs(who->sns_addr.x_port));
- fprintf(fd, "size=%d cp=%x packet=%x\n", size, cp, packet);
- return;
- }
- switch (ntohs(msg->rip_cmd)) {
-
- case RIPCMD_REQUEST:
- case RIPCMD_RESPONSE:
- fprintf(fd, ":\n");
- size -= sizeof (u_short);
- n = msg->rip_nets;
- for (; size > 0; n++, size -= sizeof (struct netinfo)) {
- if (size < sizeof (struct netinfo))
- break;
- fprintf(fd, "\tnet %s metric %d\n",
- xns_nettoa(n->rip_dst),
- ntohs(n->rip_metric));
- }
- break;
-
- }
-}
-
-union ns_net_u net;
-
-char *
-xns_nettoa(val)
-union ns_net val;
-{
- static char buf[100];
- net.net_e = val;
- (void)sprintf(buf, "%lx", ntohl(net.long_e));
- return (buf);
-}
-
-
-char *
-xns_ntoa(addr)
-struct ns_addr *addr;
-{
- static char buf[100];
-
- (void)sprintf(buf, "%s#%x:%x:%x:%x:%x:%x",
- xns_nettoa(addr->x_net),
- addr->x_host.c_host[0], addr->x_host.c_host[1],
- addr->x_host.c_host[2], addr->x_host.c_host[3],
- addr->x_host.c_host[4], addr->x_host.c_host[5]);
-
- return(buf);
-}
diff --git a/usr.sbin/XNSrouted/trace.h b/usr.sbin/XNSrouted/trace.h
deleted file mode 100644
index b7cf3a8..0000000
--- a/usr.sbin/XNSrouted/trace.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This file includes significant work done at Cornell University by
- * Bill Nesheim. That work included by permission.
- *
- * 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.
- *
- * @(#)trace.h 8.1 (Berkeley) 6/5/93
- */
-
-/*
- * Xerox Routing Information Protocol.
- */
-
-/*
- * Trace record format.
- */
-struct iftrace {
- time_t ift_stamp; /* time stamp */
- struct sockaddr ift_who; /* from/to */
- char *ift_packet; /* pointer to packet */
- short ift_size; /* size of packet */
- short ift_metric; /* metric */
-};
-
-/*
- * Per interface packet tracing buffers. An incoming and
- * outgoing circular buffer of packets is maintained, per
- * interface, for debugging. Buffers are dumped whenever
- * an interface is marked down.
- */
-struct ifdebug {
- struct iftrace *ifd_records; /* array of trace records */
- struct iftrace *ifd_front; /* next empty trace record */
- int ifd_count; /* number of unprinted records */
- struct interface *ifd_if; /* for locating stuff */
-};
-
-/*
- * Packet tracing stuff.
- */
-int tracepackets; /* watch packets as they go by */
-int tracing; /* on/off */
-FILE *ftrace; /* output trace file */
-
-#define TRACE_ACTION(action, route) { \
- if (tracing) \
- traceaction(ftrace, "action", route); \
- }
-#define TRACE_INPUT(ifp, src, size) { \
- if (tracing) { \
- ifp = if_iflookup(src); \
- if (ifp) \
- trace(&ifp->int_input, src, &packet[sizeof(struct idp)], size, \
- ntohl(ifp->int_metric)); \
- } \
- if (tracepackets && ftrace) \
- dumppacket(ftrace, "from", src, &packet[sizeof(struct idp)], size); \
- }
-#define TRACE_OUTPUT(ifp, dst, size) { \
- if (tracing) { \
- ifp = if_iflookup(dst); \
- if (ifp) \
- trace(&ifp->int_output, dst, &packet[sizeof(struct idp)], size, ifp->int_metric); \
- } \
- if (tracepackets && ftrace) \
- dumppacket(ftrace, "to", dst, &packet[sizeof(struct idp)], size); \
- }
diff --git a/usr.sbin/trsp/Makefile b/usr.sbin/trsp/Makefile
deleted file mode 100644
index 2d0bcea..0000000
--- a/usr.sbin/trsp/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-
-PROG= trsp
-MAN8= trsp.8
-BINGRP= kmem
-BINMODE=2555
-
-.include <bsd.prog.mk>
-
diff --git a/usr.sbin/trsp/trsp.8 b/usr.sbin/trsp/trsp.8
deleted file mode 100644
index dd8db27..0000000
--- a/usr.sbin/trsp/trsp.8
+++ /dev/null
@@ -1,141 +0,0 @@
-.\" Copyright (c) 1985, 1991, 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.
-.\"
-.\" @(#)trsp.8 8.1 (Berkeley) 6/6/93
-.\"
-.Dd June 6, 1993
-.Dt TRSP 8
-.Os BSD 4.2
-.Sh NAME
-.Nm trsp
-.Nd transliterate sequenced packet protocol trace
-.Sh SYNOPSIS
-.Nm trsp
-.Op Fl a
-.Op Fl s
-.Op Fl t
-.Op Fl j
-.Op Fl p Ar hex-address
-.Oo
-.Ar system Op Ar core
-.Oc
-.Sh DESCRIPTION
-.Xr Trpt
-interrogates the buffer of
-.Tn SPP
-trace records created
-when a socket is marked for
-.Dq debugging
-(see
-.Xr setsockopt 2 ) ,
-and prints a readable description of these records.
-When no options are supplied,
-.Nm trsp
-prints all the trace records found in the system
-grouped according to
-.Tn SPP
-connection protocol control
-block
-.Pq Tn PCB .
-The following options may be used to
-alter this behavior.
-.Bl -tag -width Ds
-.It Fl a
-In addition to the normal output,
-print the values of the source and destination
-addresses for each packet recorded.
-.It Fl j
-Just give a list of the protocol control block
-addresses for which there are trace records.
-.It Fl p
-Show only trace records associated with the protocol
-control block at the given address,
-.Ar hex-address .
-.It Fl s
-in addition to the normal output,
-print a detailed description of the packet
-sequencing information.
-.It Fl t
-in addition to the normal output,
-print the values for all timers at each
-point in the trace,
-.El
-.Pp
-The recommended use of
-.Nm trsp
-is as follows.
-Isolate the problem and enable debugging on the
-socket(s) involved in the connection.
-Find the address of the protocol control blocks
-associated with the sockets using the
-.Fl A
-option to
-.Xr netstat 1 .
-Then run
-.Nm trsp
-with the
-.Fl p
-option, supplying the associated
-protocol control block addresses. If there are
-many sockets using the debugging option, the
-.Fl j
-option may be useful in checking to see if
-any trace records are present for the socket in
-question.
-.Pp
-If debugging is being performed on a system or
-core file other than the default, the last two
-arguments may be used to supplant the defaults.
-.Sh FILES
-.Bl -tag -width /dev/kmem -compact
-.It Pa /kernel
-.It Pa /dev/kmem
-.El
-.Sh SEE ALSO
-.Xr netstat 1 ,
-.Xr setsockopt 2
-.Sh DIAGNOSTICS
-.Bl -tag -width Ds
-.It Sy no namelist
-When the system image doesn't
-contain the proper symbols to find the trace buffer;
-others which should be self explanatory.
-.Sh BUGS
-Should also print the data for each input or output,
-but this is not saved in the race record.
-.Pp
-The output format is inscrutable and should be described
-here.
-.Sh HISTORY
-The
-.Nm
-command appeared in
-.Bx 4.3 .
diff --git a/usr.sbin/trsp/trsp.c b/usr.sbin/trsp/trsp.c
deleted file mode 100644
index 2fde4f8..0000000
--- a/usr.sbin/trsp/trsp.c
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Copyright (c) 1985, 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 copyright[] =
-"@(#) Copyright (c) 1985, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)trsp.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#define PRUREQUESTS
-#include <sys/protosw.h>
-
-#include <net/route.h>
-#include <net/if.h>
-
-#define TCPSTATES
-#include <netinet/tcp_fsm.h>
-#define TCPTIMERS
-#include <netinet/tcp_timer.h>
-
-#include <netns/ns.h>
-#include <netns/sp.h>
-#include <netns/idp.h>
-#include <netns/spidp.h>
-#include <netns/spp_timer.h>
-#include <netns/spp_var.h>
-#include <netns/ns_pcb.h>
-#include <netns/idp_var.h>
-#define SANAMES
-#include <netns/spp_debug.h>
-
-#include <stdio.h>
-#include <errno.h>
-#include <nlist.h>
-#include <paths.h>
-
-unsigned long ntime;
-int sflag;
-int tflag;
-int jflag;
-int aflag;
-int zflag;
-int numeric();
-struct nlist nl[] = {
- { "_spp_debug" },
- { "_spp_debx" },
- 0
-};
-struct spp_debug spp_debug[SPP_NDEBUG];
-caddr_t spp_pcbs[SPP_NDEBUG];
-int spp_debx;
-
-main(argc, argv)
- int argc;
- char **argv;
-{
- int i, mask = 0, npcbs = 0;
- char *system, *core;
-
- system = (char *)getbootfile();
- core = _PATH_KMEM;
-
- argc--, argv++;
-again:
- if (argc > 0 && !strcmp(*argv, "-a")) {
- aflag++, argc--, argv++;
- goto again;
- }
- if (argc > 0 && !strcmp(*argv, "-z")) {
- zflag++, argc--, argv++;
- goto again;
- }
- if (argc > 0 && !strcmp(*argv, "-s")) {
- sflag++, argc--, argv++;
- goto again;
- }
- if (argc > 0 && !strcmp(*argv, "-t")) {
- tflag++, argc--, argv++;
- goto again;
- }
- if (argc > 0 && !strcmp(*argv, "-j")) {
- jflag++, argc--, argv++;
- goto again;
- }
- if (argc > 0 && !strcmp(*argv, "-p")) {
- argc--, argv++;
- if (argc < 1) {
- fprintf(stderr, "-p: missing sppcb address\n");
- exit(1);
- }
- if (npcbs >= SPP_NDEBUG) {
- fprintf(stderr, "-p: too many pcb's specified\n");
- exit(1);
- }
- sscanf(*argv, "%x", &spp_pcbs[npcbs++]);
- argc--, argv++;
- goto again;
- }
- if (argc > 0) {
- system = *argv;
- argc--, argv++;
- mask++;
- /*
- * Discard setgid privileges if not the running kernel so that
- * bad guys can't print interesting stuff from kernel memory.
- */
- setgid(getgid());
- }
- if (argc > 0) {
- core = *argv;
- argc--, argv++;
- mask++;
- setgid(getgid());
- }
- (void) nlist(system, nl);
- if (nl[0].n_value == 0) {
- fprintf(stderr, "trsp: %s: no namelist\n", system);
- exit(1);
- }
- (void) close(0);
- if (open(core, 0) < 0) {
- fprintf(stderr, "trsp: "); perror(core);
- exit(2);
- }
- if (mask) {
- nl[0].n_value &= 0x7fffffff;
- nl[1].n_value &= 0x7fffffff;
- }
- (void) lseek(0, nl[1].n_value, 0);
- if (read(0, &spp_debx, sizeof (spp_debx)) != sizeof (spp_debx)) {
- fprintf(stderr, "trsp: "); perror("spp_debx");
- exit(3);
- }
- printf("spp_debx=%d\n", spp_debx);
- (void) lseek(0, nl[0].n_value, 0);
- if (read(0, spp_debug, sizeof (spp_debug)) != sizeof (spp_debug)) {
- fprintf(stderr, "trsp: "); perror("spp_debug");
- exit(3);
- }
- /*
- * Here, we just want to clear out the old trace data and start over.
- */
- if (zflag) {
- char *cp = (char *) spp_debug,
- *cplim = cp + sizeof(spp_debug);
- (void) close(0);
- if (open(core, 2) < 0) {
- fprintf(stderr, "trsp: "); perror(core);
- exit(2);
- }
- while(cp < cplim) *cp++ = 0;
- (void) lseek(0, nl[0].n_value, 0);
- if (write(0, spp_debug, sizeof (spp_debug)) != sizeof (spp_debug)) {
- fprintf(stderr, "trsp: "); perror("spp_debug");
- exit(3);
- }
- (void) lseek(0, nl[1].n_value, 0);
- spp_debx = 0;
- if (write(0, &spp_debx, sizeof (spp_debx)) != sizeof (spp_debx)) {
- fprintf(stderr, "trsp: "); perror("spp_debx");
- exit(3);
- }
- exit(0);
- }
- /*
- * If no control blocks have been specified, figure
- * out how many distinct one we have and summarize
- * them in spp_pcbs for sorting the trace records
- * below.
- */
- if (npcbs == 0) {
- for (i = 0; i < SPP_NDEBUG; i++) {
- register int j;
- register struct spp_debug *sd = &spp_debug[i];
-
- if (sd->sd_cb == 0)
- continue;
- for (j = 0; j < npcbs; j++)
- if (spp_pcbs[j] == sd->sd_cb)
- break;
- if (j >= npcbs)
- spp_pcbs[npcbs++] = sd->sd_cb;
- }
- }
- qsort(spp_pcbs, npcbs, sizeof (caddr_t), numeric);
- if (jflag) {
- char *cp = "";
-
- for (i = 0; i < npcbs; i++) {
- printf("%s%x", cp, spp_pcbs[i]);
- cp = ", ";
- }
- if (*cp)
- putchar('\n');
- exit(0);
- }
- for (i = 0; i < npcbs; i++) {
- printf("\n%x:\n", spp_pcbs[i]);
- dotrace(spp_pcbs[i]);
- }
- exit(0);
-}
-
-dotrace(sppcb)
- register caddr_t sppcb;
-{
- register int i;
- register struct spp_debug *sd;
-
- for (i = spp_debx % SPP_NDEBUG; i < SPP_NDEBUG; i++) {
- sd = &spp_debug[i];
- if (sppcb && sd->sd_cb != sppcb)
- continue;
- ntime = ntohl(sd->sd_time);
- spp_trace(sd->sd_act, sd->sd_ostate, sd->sd_cb, &sd->sd_sp,
- &sd->sd_si, sd->sd_req);
- }
- for (i = 0; i < spp_debx % SPP_NDEBUG; i++) {
- sd = &spp_debug[i];
- if (sppcb && sd->sd_cb != sppcb)
- continue;
- ntime = ntohl(sd->sd_time);
- spp_trace(sd->sd_act, sd->sd_ostate, sd->sd_cb, &sd->sd_sp,
- &sd->sd_si, sd->sd_req);
- }
-}
-
-ptime(ms)
- int ms;
-{
-
- printf("%03d ", (ms/10) % 1000);
-}
-
-numeric(c1, c2)
- caddr_t *c1, *c2;
-{
-
- return (*c1 - *c2);
-}
-
-spp_trace(act, ostate, asp, sp, si, req)
- short act, ostate;
- struct sppcb *asp, *sp;
- struct spidp *si;
- int req;
-{
- u_short seq, ack, len, alo;
- int flags, timer;
- char *cp;
-
- if(ostate >= TCP_NSTATES) ostate = 0;
- if(act > SA_DROP) act = SA_DROP;
- printf("\n");
- ptime(ntime);
- printf("%s:%s", tcpstates[ostate], sanames[act]);
-
- if (si != 0) {
- seq = si->si_seq;
- ack = si->si_ack;
- alo = si->si_alo;
- len = si->si_len;
- switch (act) {
- case SA_RESPOND:
- case SA_OUTPUT:
- seq = ntohs(seq);
- ack = ntohs(ack);
- alo = ntohs(alo);
- len = ntohs(len);
- case SA_INPUT:
- case SA_DROP:
- if (aflag) {
- printf("\n\tsna=");
- ns_printhost(&si->si_sna);
- printf("\tdna=");
- ns_printhost(&si->si_dna);
- }
- printf("\n\t");
-#define p1(name, f) { \
- printf("%s = %x, ", name, f); \
- }
- p1("seq", seq);
- p1("ack", ack);
- p1("alo", alo);
- p1("len", len);
- flags = si->si_cc;
- printf("flags=%x", flags);
-#define pf(name, f) { \
- if (flags & f) { \
- printf("%s%s", cp, name); \
- cp = ","; \
- } \
-}
- if (flags) {
- char *cp = "<";
- pf("SP_SP", SP_SP);
- pf("SP_SA", SP_SA);
- pf("SP_OB", SP_OB);
- pf("SP_EM", SP_EM);
- printf(">");
- }
- printf(", ");
-#define p2(name, f) { \
- printf("%s = %x, ", name, f); \
-}
- p2("sid", si->si_sid);
- p2("did", si->si_did);
- p2("dt", si->si_dt);
- printf("\n\tsna=");
- ns_printhost(&si->si_sna);
- printf("\tdna=");
- ns_printhost(&si->si_dna);
- }
- }
- if(act == SA_USER) {
- printf("\treq=%s", prurequests[req&0xff]);
- if ((req & 0xff) == PRU_SLOWTIMO)
- printf("<%s>", tcptimers[req>>8]);
- }
- printf(" -> %s", tcpstates[sp->s_state]);
-
- /* print out internal state of sp !?! */
- printf("\n");
- if (sp == 0)
- return;
-#define p3(name, f) { \
- printf("%s = %x, ", name, f); \
-}
- if (sflag) {
- printf("\t");
- p3("rack", sp->s_rack);
- p3("ralo", sp->s_ralo);
- p3("smax", sp->s_smax);
- p3("snxt", sp->s_snxt);
- p3("flags", sp->s_flags);
-#undef pf
-#define pf(name, f) { \
- if (flags & f) { \
- printf("%s%s", cp, name); \
- cp = ","; \
- } \
-}
- flags = sp->s_flags;
- if (flags || sp->s_oobflags) {
- char *cp = "<";
- pf("ACKNOW", SF_ACKNOW);
- pf("DELACK", SF_DELACK);
- pf("HI", SF_HI);
- pf("HO", SF_HO);
- pf("PI", SF_PI);
- pf("WIN", SF_WIN);
- pf("RXT", SF_RXT);
- pf("RVD", SF_RVD);
- flags = sp->s_oobflags;
- pf("SOOB", SF_SOOB);
- pf("IOOB", SF_IOOB);
- printf(">");
- }
- }
- /* print out timers? */
- if (tflag) {
- char *cp = "\t";
- register int i;
-
- printf("\n\tTIMERS: ");
- p3("idle", sp->s_idle);
- p3("force", sp->s_force);
- p3("rtseq", sp->s_rtseq);
- for (i = 0; i < TCPT_NTIMERS; i++) {
- if (sp->s_timer[i] == 0)
- continue;
- printf("%s%s=%d", cp, tcptimers[i], sp->s_timer[i]);
- if (i == TCPT_REXMT)
- printf(" (s_rxtshft=%d)", sp->s_rxtshift);
- cp = ", ";
- }
- if (*cp != '\t')
- putchar('\n');
- }
-}
-
-ns_printhost(p)
-register struct ns_addr *p;
-{
-
- printf("<net:%x%x,host:%4.4x%4.4x%4.4x,port:%x>",
- p->x_net.s_net[0],
- p->x_net.s_net[1],
- p->x_host.s_host[0],
- p->x_host.s_host[1],
- p->x_host.s_host[2],
- p->x_port);
-
-}
-
OpenPOWER on IntegriCloud