#!/bin/sh
# this is vxrouted_5.1.1-shar.05 (part 5 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file vxrouted_5.1.1/trace.c continued
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo 'WARNING: not restoring timestamps'
fi
rm -f 1231235999 $$.touch
#
if test ! -r _sharseq.tmp; then
  echo 'Please unpack part 1 first!'
  exit 1
fi
shar_sequence=`cat _sharseq.tmp`
if test "$shar_sequence" != 5; then
  echo "Please unpack part $shar_sequence next!"
  exit 1
fi
if test ! -f _sharnew.tmp; then
  echo 'x - still skipping vxrouted_5.1.1/trace.c'
else
  echo 'x - continuing file vxrouted_5.1.1/trace.c'
  sed 's/^X//' << 'SHAR_EOF' >> 'vxrouted_5.1.1/trace.c' &&
X		return;
X	if (msg->rip_cmd && msg->rip_cmd < RIPCMD_MAX) {
X		inet_ntoa_b(who->sin_addr,intabuf);
X		fprintf(fd, "%s %s %s.%d %.19s:\n", ripcmds[msg->rip_cmd],
X		    dir, intabuf, ntohs(who->sin_port),
X		    ctime((time_t *)&stamp->tv_sec));
X	}
X	else {
X		inet_ntoa_b(who->sin_addr,intabuf);
X		fprintf(fd, "Bad cmd 0x%x %s %x.%d %.19s\n", msg->rip_cmd,
X		    dir, intabuf, ntohs(who->sin_port));
X		fprintf(fd, "size=%d cp=%x packet=%x\n", size, cp, packet,
X		    ctime((time_t *)&stamp->tv_sec));
X		fflush(fd);
X		return;
X	}
X	if (tracepackets && tracecontents == 0) {
X		fflush(fd);
X		return;
X	}
X	switch (msg->rip_cmd) {
X
X	case RIPCMD_REQUEST:
X	case RIPCMD_RESPONSE:
X		size -= 4 * sizeof (char);
X		n = msg->rip_nets;
X		for (; size > 0; n++, size -= sizeof (struct netinfo)) {
X			if (size < sizeof (struct netinfo)) {
X				fprintf(fd, "(truncated record, len %d)\n",
X				    size);
X				break;
X			}
X			if (sizeof(n->rip_dst.sa_family) > 1)
X			    n->rip_dst.sa_family = ntohs(n->rip_dst.sa_family);
X
X			switch ((int)n->rip_dst.sa_family) {
X
X			case AF_INET:
#define	satosin(sa)	((struct sockaddr_in *)&sa)
X				inet_ntoa_b(satosin(n->rip_dst)->sin_addr,intabuf);
X				fprintf(fd, "\tdst %s metric %d\n",
X				     intabuf,
X				     ntohl(n->rip_metric));
X				break;
X
X			default:
X				fprintf(fd, "\taf %d? metric %d\n",
X				     n->rip_dst.sa_family,
X				     ntohl(n->rip_metric));
X				break;
X			}
X		}
X		break;
X
X	case RIPCMD_TRACEON:
X		fprintf(fd, "\tfile=%*s\n", size, msg->rip_tracefile);
X		break;
X
X	case RIPCMD_TRACEOFF:
X		break;
X	}
X	fflush(fd);
X	if (ferror(fd))
X		traceoff();
}
SHAR_EOF
  echo 'File vxrouted_5.1.1/trace.c is complete' &&
  $shar_touch -am 1129062593 'vxrouted_5.1.1/trace.c' &&
  chmod 0644 'vxrouted_5.1.1/trace.c' ||
  echo 'restore of vxrouted_5.1.1/trace.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/trace.c'`"
  test 9999 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/trace.c: original size 9999, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/trace.h ==============
if test -f 'vxrouted_5.1.1/trace.h' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/trace.h (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/trace.h (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/trace.h' &&
/*
X * Copyright (c) 1983, 1988 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley.  The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X *
X *	@(#)trace.h	5.7 (Berkeley) 2/20/89
X */
X
/*
X * Routing table management daemon.
X */
X
/*
X * Trace record format.
X */
struct	iftrace {
X	struct	timeval ift_stamp;	/* time stamp */
X	struct	sockaddr ift_who;	/* from/to */
X	char	*ift_packet;		/* pointer to packet */
X	short	ift_size;		/* size of packet */
X	short	ift_metric;		/* metric on associated metric */
};
X
/*
X * Per interface packet tracing buffers.  An incoming and
X * outgoing circular buffer of packets is maintained, per
X * interface, for debugging.  Buffers are dumped whenever
X * an interface is marked down.
X */
struct	ifdebug {
X	struct	iftrace *ifd_records;	/* array of trace records */
X	struct	iftrace *ifd_front;	/* next empty trace record */
X	int	ifd_count;		/* number of unprinted records */
X	struct	interface *ifd_if;	/* for locating stuff */
};
X
/*
X * Packet tracing stuff.
X */
int	tracepackets;		/* watch packets as they go by */
int	tracecontents;		/* watch packet contents as they go by */
int	traceactions;		/* on/off */
int	tracehistory;		/* on/off */
FILE	*ftrace;		/* output trace file */
X
#define	TRACE_ACTION(action, route) { \
X	  if (traceactions) \
X		traceaction(ftrace, action, route); \
X	}
#define	TRACE_NEWMETRIC(route, newmetric) { \
X	  if (traceactions) \
X		tracenewmetric(ftrace, route, newmetric); \
X	}
#define	TRACE_INPUT(ifp, src, pack, size) { \
X	  if (tracehistory) { \
X		ifp = if_iflookup(src); \
X		if (ifp) \
X			trace(&ifp->int_input, src, pack, size, \
X				ntohl(ifp->int_metric)); \
X	  } \
X	  if (tracepackets) \
X		dumppacket(ftrace, "from", src, pack, size, &now); \
X	}
#define	TRACE_OUTPUT(ifp, dst, size) { \
X	  if (tracehistory && ifp) \
X		trace(&ifp->int_output, dst, packet, size, ifp->int_metric); \
X	  if (tracepackets) \
X		dumppacket(ftrace, "to", dst, packet, size, &now); \
X	}
SHAR_EOF
  $shar_touch -am 0220182189 'vxrouted_5.1.1/trace.h' &&
  chmod 0644 'vxrouted_5.1.1/trace.h' ||
  echo 'restore of vxrouted_5.1.1/trace.h failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/trace.h'`"
  test 2608 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/trace.h: original size 2608, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/tzfile.h ==============
if test -f 'vxrouted_5.1.1/tzfile.h' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/tzfile.h (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/tzfile.h (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/tzfile.h' &&
/*	@(#)tzfile.h 1.9 89/04/11 SMI; from Arthur Olson's 6.1	*/
X
#ifndef TZFILE_H
X
#define TZFILE_H
X
/*
** Information about time zone files.
*/
X
#define TZDIR	"/usr/share/lib/zoneinfo" /* Time zone object file directory */
X
#define TZDEFAULT	"localtime"
X
#define TZDEFRULES	"posixrules"
X
/*
** Each file begins with. . .
*/
X
struct tzhead {
X	char	tzh_reserved[24];	/* reserved for future use */
X	char	tzh_ttisstdcnt[4];	/* coded number of trans. time flags */
X	char	tzh_leapcnt[4];		/* coded number of leap seconds */
X	char	tzh_timecnt[4];		/* coded number of transition times */
X	char	tzh_typecnt[4];		/* coded number of local time types */
X	char	tzh_charcnt[4];		/* coded number of abbr. chars */
};
X
/*
** . . .followed by. . .
**
**	tzh_timecnt (char [4])s		coded transition times a la time(2)
**	tzh_timecnt (unsigned char)s	types of local time starting at above
**	tzh_typecnt repetitions of
**		one (char [4])		coded GMT offset in seconds
**		one (unsigned char)	used to set tm_isdst
**		one (unsigned char)	that's an abbreviation list index
**	tzh_charcnt (char)s		'\0'-terminated zone abbreviations
**	tzh_leapcnt repetitions of
**		one (char [4])		coded leap second transition times
**		one (char [4])		total correction after above
**	tzh_ttisstdcnt (char)s		indexed by type; if TRUE, transition
**					time is standard time, if FALSE,
**					transition time is wall clock time
**					if absent, transition times are
**					assumed to be wall clock time
*/
X
/*
** In the current implementation, "tzset()" refuses to deal with files that
** exceed any of the limits below.
*/
X
/*
** The TZ_MAX_TIMES value below is enough to handle a bit more than a
** year's worth of solar time (corrected daily to the nearest second) or
** 138 years of Pacific Presidential Election time
** (where there are three time zone transitions every fourth year).
*/
#define TZ_MAX_TIMES	370
X
#define TZ_MAX_TYPES	256	/* Limited by what (unsigned char)'s can hold */
X
#define TZ_MAX_CHARS	50	/* Maximum number of abbreviation characters */
X
#define	TZ_MAX_LEAPS	50	/* Maximum number of leap second corrections */
X
#define SECSPERMIN	60
#define MINSPERHOUR	60
#define HOURSPERDAY	24
#define DAYSPERWEEK	7
#define DAYSPERNYEAR	365
#define DAYSPERLYEAR	366
#define SECSPERHOUR	(SECSPERMIN * MINSPERHOUR)
#define SECSPERDAY	((long) SECSPERHOUR * HOURSPERDAY)
#define MONSPERYEAR	12
X
#define TM_SUNDAY	0
#define TM_MONDAY	1
#define TM_TUESDAY	2
#define TM_WEDNESDAY	3
#define TM_THURSDAY	4
#define TM_FRIDAY	5
#define TM_SATURDAY	6
X
#define TM_JANUARY	0
#define TM_FEBRUARY	1
#define TM_MARCH	2
#define TM_APRIL	3
#define TM_MAY		4
#define TM_JUNE		5
#define TM_JULY		6
#define TM_AUGUST	7
#define TM_SEPTEMBER	8
#define TM_OCTOBER	9
#define TM_NOVEMBER	10
#define TM_DECEMBER	11
X
#define TM_YEAR_BASE	1900
X
#define EPOCH_YEAR	1970
#define EPOCH_WDAY	TM_THURSDAY
X
/*
** Accurate only for the past couple of centuries;
** that will probably do.
*/
X
#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
X
/*
** Use of the underscored variants may cause problems if you move your code to
** certain System-V-based systems; for maximum portability, use the
** underscore-free variants.  The underscored variants are provided for
** backward compatibility only; they may disappear from future versions of
** this file.
*/
X
#define SECS_PER_MIN	SECSPERMIN
#define MINS_PER_HOUR	MINSPERHOUR
#define HOURS_PER_DAY	HOURSPERDAY
#define DAYS_PER_WEEK	DAYSPERWEEK
#define DAYS_PER_NYEAR	DAYSPERNYEAR
#define DAYS_PER_LYEAR	DAYSPERLYEAR
#define SECS_PER_HOUR	SECSPERHOUR
#define SECS_PER_DAY	SECSPERDAY
#define MONS_PER_YEAR	MONSPERYEAR
X
#endif /* !defined TZFILE_H */
SHAR_EOF
  $shar_touch -am 1111121293 'vxrouted_5.1.1/tzfile.h' &&
  chmod 0644 'vxrouted_5.1.1/tzfile.h' ||
  echo 'restore of vxrouted_5.1.1/tzfile.h failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/tzfile.h'`"
  test 3657 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/tzfile.h: original size 3657, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/README ==============
if test -f 'vxrouted_5.1.1/README' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/README (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/README (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/README' &&
X
X     File: README
X
X     Last update of README file: July 12, 1994
X
X     Description: README notes about routed
X
X     Created by: Robert Barbrow
X                 Project Engineer
X                 LXE Inc.
X                 125 Technology Parkway
X                 Norcorss, GA. 30092
X
X                 Internet e-mail rcb0135@lxe6.lxe.com
X                                 robert@crl.com
X
X                 Phone #(404)447-4224 ex.3365
X 
X
This port of a copy of the BSD ROUTED to Wind River VxWorks
version 5.1.1 (SUN host, 68302 target) has been tested and
verified to process RIP packets from a SUN IPC, CISCO router, and
3COM router.
X
Since the test unit has only a single interface the routed
advertisement (-s option) feature has not been tested and may not
work at all.
X
The sys_time_ut and sys_time_t are variables of type time_t that are pseudo
implemented in my versions of sysLib.c.  It is an attempt to
implement some sort of timeval functionality with this version of
VxWorks.  Since I have ported other BSD sources this made it much
easier than having to work around any sources requiring this type
of time services.
X
The file misc.c contains missing functions required to port the
routed source.
X
The files remque.c, insque.c, random.c, ctime.c are external
BSD sources that are needed to port routed. They have been ported
and are included in this archive.
X
You may also notice that some of the internal function routine
names have been changed.  This was done to eliminate some of the
duplicate function names within VxWorks that were not compatible.
X
The original source code located at:
URL: ftp://gatekeeper.dec.com/pub/BSD/net1/src/network/routed.tar.Z
is included in this archive in the subdirectory /BSDrouted.
X
---------------- Revision History --------------------------
June 24, 1994:
The files main.c query.c af.c misc.c defs.h have been modified
to fix some bugs that have been found during recent testing.
X
July 12, 1994:
Included the header file netdb.h in the tar archive, it was
left out of the previous release.
SHAR_EOF
  $shar_touch -am 0712070094 'vxrouted_5.1.1/README' &&
  chmod 0644 'vxrouted_5.1.1/README' ||
  echo 'restore of vxrouted_5.1.1/README failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/README'`"
  test 2040 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/README: original size 2040, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/BSDrouted/routed.8 ==============
if test ! -d 'vxrouted_5.1.1/BSDrouted'; then
  echo 'x - creating directory vxrouted_5.1.1/BSDrouted'
  mkdir 'vxrouted_5.1.1/BSDrouted'
fi
if test -f 'vxrouted_5.1.1/BSDrouted/routed.8' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/BSDrouted/routed.8 (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/BSDrouted/routed.8 (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/BSDrouted/routed.8' &&
X.\" Copyright (c) 1983 The Regents of the University of California.
X.\" All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms are permitted
X.\" provided that the above copyright notice and this paragraph are
X.\" duplicated in all such forms and that any documentation,
X.\" advertising materials, and other materials related to such
X.\" distribution and use acknowledge that the software was developed
X.\" by the University of California, Berkeley.  The name of the
X.\" University may not be used to endorse or promote products derived
X.\" from this software without specific prior written permission.
X.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X.\"
X.\"	@(#)routed.8	6.4 (Berkeley) 2/15/89
X.\"
X.TH ROUTED 8 "February 15, 1989"
X.UC 5
X.SH NAME
routed \- network routing daemon
X.SH SYNOPSIS
X.B /etc/routed
[
X.B \-d
] [
X.B \-g
] [
X.B \-s
] [
X.B \-q
] [
X.B \-t
] [
X.I logfile
]
X.SH DESCRIPTION
X.I Routed
is invoked at boot time to manage the network routing tables.
The routing daemon uses a variant of the Xerox NS Routing
Information Protocol in maintaining up to date kernel routing
table entries.
It used a generalized protocol capable of use with multiple
address types, but is currently used only for Internet routing
within a cluster of networks.
X.PP
In normal operation
X.I routed
listens on the
X.IR udp (4)
socket for the
X.I route
service (see
X.IR services (5))
for routing information packets.  If the host is an
internetwork router, it periodically supplies copies
of its routing tables to any directly connected hosts
and networks.
X.PP
When
X.I routed
is started, it uses the SIOCGIFCONF
X.I ioctl
to find those
directly connected interfaces configured into the
system and marked ``up'' (the software loopback interface
is ignored).  If multiple interfaces
are present, it is assumed that the host will forward packets
between networks.
X.I Routed
then transmits a 
X.I request
packet on each interface (using a broadcast packet if
the interface supports it) and enters a loop, listening
for
X.I request
and
X.I response
packets from other hosts.
X.PP
When a
X.I request
packet is received, 
X.I routed
formulates a reply based on the information maintained in its
internal tables.  The
X.I response
packet generated contains a list of known routes, each marked
with a ``hop count'' metric (a count of 16, or greater, is
considered ``infinite'').  The metric associated with each
route returned provides a metric
X.IR "relative to the sender" .
X.PP
X.I Response
packets received by
X.I routed
are used to update the routing tables if one of the following
conditions is satisfied:
X.TP
(1)
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).
X.TP
(2)
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.
X.TP
(3)
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.
X.TP
(4)
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.
X.PP
When an update is applied,
X.I routed
records the change in its internal tables and updates the kernel
routing table.
The change is reflected in the next
X.I response
packet sent.
X.PP
In addition to processing incoming packets,
X.I routed
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
throughout the local internet.
X.PP
Hosts acting as internetwork routers gratuitously supply their
routing tables every 30 seconds to all directly connected hosts
and networks.
The response is sent to the broadcast address on nets capable of that function,
to the destination address on point-to-point links, and to the router's
own address on other networks.
The normal routing tables are bypassed when sending gratuitous responses.
The reception of responses on each network is used to determine that the
network and interface are functioning correctly.
If no response is received on an interface, another route may be chosen
to route around the interface, or the route may be dropped if no alternative
is available.
X.PP
X.I Routed supports several options:
X.TP
X.B \-d
Enable additional debugging information to be logged,
such as bad packets received.
X.TP
X.B \-g
This flag is used on internetwork routers to offer a route
to the ``default'' destination.
This is typically used on a gateway to the Internet,
or on a gateway that uses another routing protocol whose routes
are not reported to other local routers.
X.TP
X.B \-s
Supplying this
option forces 
X.I routed
to supply routing information whether it is acting as an internetwork
router or not.
This is the default if multiple network interfaces are present,
or if a point-to-point link is in use.
X.TP
X.B \-q
This
is the opposite of the
X.B \-s
option.
X.TP
X.B \-t
If the
X.B \-t
option is specified, all packets sent or received are
printed on the standard output.  In addition,
X.I routed
will not divorce itself from the controlling terminal
so that interrupts from the keyboard will kill the process.
X.PP
Any other argument supplied is interpreted as the name
of file in which 
X.IR routed 's
actions should be logged.  This log contains information
about any changes to the routing tables and, if not tracing all packets,
a history of recent messages sent and received which are related to
the changed route.
X.PP
In addition to the facilities described above, 
X.I routed
supports the notion of ``distant''
X.I passive
and 
X.I active
gateways.  When 
X.I routed
is started up, it reads the file
X.I /etc/gateways
to find gateways which may not be located using
only information from the SIOGIFCONF
X.IR ioctl .
Gateways specified in this manner should be marked passive
if they are not expected to exchange routing information,
while gateways marked active
should be willing to exchange routing information (i.e.
they should have a
X.I routed
process running on the machine).
Routes through passive gateways are installed in the
kernel's routing tables once upon startup.
Such routes are not included in
any routing information transmitted.
Active gateways are treated equally to network
interfaces.  Routing information is distributed
to the gateway and if no routing information is
received for a period of the time, the associated
route is deleted.
Gateways marked
X.I external
are also passive, but are not placed in the kernel
routing table nor are they included in routing updates.
The function of external entries is to inform
X.I routed
that another routing process
will install such a route, and that alternate routes to that destination
should not be installed.
Such entries are only required when both routers may learn of routes
to the same destination.
X.PP
The 
X.I /etc/gateways
is comprised of a series of lines, each in
the following format:
X.PP
X.nf
< \fBnet\fP | \fBhost\fP > \fIname1\fP \fBgateway\fP \fIname2\fP \fBmetric\fP \fIvalue\fP < \fBpassive\fP | \fBactive\fP | \fBexternal\fP >
X.fi
X.PP
The 
X.B net
or
X.B host
keyword indicates if the route is to a network or specific host.
X.PP
X.I Name1
is the name of the destination network or host.  This may be a
symbolic name located in
X.I /etc/networks
or
X.I /etc/hosts
(or, if started after
X.IR named (8),
known to the name server), 
or an Internet address specified in ``dot'' notation; see
X.IR inet (3).
X.PP
X.I Name2
is the name or address of the gateway to which messages should
be forwarded.
X.PP
X.I Value
is a metric indicating the hop count to the destination host
or network.
X.PP
One of the keywords
X.BR passive ,
X.B active
or
X.B external
indicates if the gateway should be treated as 
X.I passive
or
X.I active
(as described above),
or whether the gateway is
X.I external
to the scope of the
X.I routed
protocol.
X.PP
Internetwork routers that are directly attached to the Arpanet or Milnet
should use the Exterior Gateway Protocol (EGP) to gather routing information
rather then using a static routing table of passive gateways.
EGP is required in order to provide routes for local networks to the rest
of the Internet system.
Sites needing assistance with such configurations
should contact the Computer Systems Research Group at Berkeley.
X.SH FILES
X.DT
/etc/gateways	for distant gateways
X.SH "SEE ALSO"
``Internet Transport Protocols'', XSIS 028112, Xerox System Integration
Standard.
X.br
udp(4), icmp(4), XNSrouted(8), htable(8)
X.SH BUGS
The kernel's routing tables may not correspond to those of
X.I routed
when redirects change or add routes.
X.I Routed
should note any redirects received by reading
the ICMP packets received via a raw socket.
X.PP
X.I Routed
should incorporate other routing protocols,
such as Xerox NS
X.RI ( XNSrouted (8))
and EGP.
Using separate processes for each requires configuration options
to avoid redundant or competing routes.
X.PP
X.I Routed
should listen to intelligent interfaces, such as an IMP,
to gather more information.
It does not always detect unidirectional failures in network interfaces
(e.g., when the output side fails).
SHAR_EOF
  $shar_touch -am 0215145989 'vxrouted_5.1.1/BSDrouted/routed.8' &&
  chmod 0444 'vxrouted_5.1.1/BSDrouted/routed.8' ||
  echo 'restore of vxrouted_5.1.1/BSDrouted/routed.8 failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/BSDrouted/routed.8'`"
  test 9633 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/BSDrouted/routed.8: original size 9633, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/BSDrouted/tools/query.c ==============
if test ! -d 'vxrouted_5.1.1/BSDrouted/tools'; then
  echo 'x - creating directory vxrouted_5.1.1/BSDrouted/tools'
  mkdir 'vxrouted_5.1.1/BSDrouted/tools'
fi
if test -f 'vxrouted_5.1.1/BSDrouted/tools/query.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/BSDrouted/tools/query.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/BSDrouted/tools/query.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/BSDrouted/tools/query.c' &&
/*
X * Copyright (c) 1980 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that this notice is preserved and that due credit is given
X * to the University of California at Berkeley. The name of the University
X * may not be used to endorse or promote products derived from this
X * software without specific prior written permission. This software
X * is provided ``as is'' without express or implied warranty.
X */
X
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
X All rights reserved.\n";
#endif /* not lint */
X
#ifndef lint
static char sccsid[] = "@(#)query.c	5.9 (Berkeley) 6/11/88";
#endif /* not lint */
X
#include <sys/param.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <errno.h>
#include <stdio.h>
#include <netdb.h>
#include <protocols/routed.h>
X
#define	WTIME	5		/* Time to wait for all responses */
#define	STIME	500000		/* usec to wait for another response */
X
int	s;
int	timedout, timeout();
char	packet[MAXPACKETSIZE];
extern int errno;
int	nflag;
X
main(argc, argv)
X	int argc;
X	char *argv[];
{
X	int cc, count, bits;
X	struct sockaddr from;
X	int fromlen = sizeof(from), size = 32*1024;
X	struct timeval shorttime;
X	
X	if (argc < 2) {
usage:
X		printf("usage: query [ -n ] hosts...\n");
X		exit(1);
X	}
X	s = socket(AF_INET, SOCK_DGRAM, 0);
X	if (s < 0) {
X		perror("socket");
X		exit(2);
X	}
X	if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)) < 0)
X		perror("setsockopt SO_RCVBUF");
X
X	argv++, argc--;
X	if (*argv[0] == '-') {
X		switch (argv[0][1]) {
X		case 'n':
X			nflag++;
X			break;
X		default:
X			goto usage;
X		}
X		argc--, argv++;
X	}
X	while (argc > 0) {
X		query(*argv);
X		count++;
X		argv++, argc--;
X	}
X
X	/*
X	 * Listen for returning packets;
X	 * may be more than one packet per host.
X	 */
X	bits = 1 << s;
X	bzero(&shorttime, sizeof(shorttime));
X	shorttime.tv_usec = STIME;
X	signal(SIGALRM, timeout);
X	alarm(WTIME);
X	while ((count > 0 && !timedout) ||
X	    select(20, &bits, 0, 0, &shorttime) > 0) {
X		cc = recvfrom(s, packet, sizeof (packet), 0,
X		  &from, &fromlen);
X		if (cc <= 0) {
X			if (cc < 0) {
X				if (errno == EINTR)
X					continue;
X				perror("recvfrom");
X				(void) close(s);
X				exit(1);
X			}
X			continue;
X		}
X		rip_input(&from, cc);
X		count--;
X	}
X	exit (count > 0 ? count : 0);
}
X
query(host)
X	char *host;
{
X	struct sockaddr_in router;
X	register struct rip *msg = (struct rip *)packet;
X	struct hostent *hp;
X	struct servent *sp;
X
X	bzero((char *)&router, sizeof (router));
X	router.sin_family = AF_INET;
X	router.sin_addr.s_addr = inet_addr(host);
X	if (router.sin_addr.s_addr == -1) {
X		hp = gethostbyname(host);
X		if (hp == 0) {
X			printf("%s: unknown\n", host);
X			exit(1);
X		}
X		bcopy(hp->h_addr, &router.sin_addr, hp->h_length);
X	}
X	sp = getservbyname("router", "udp");
X	if (sp == 0) {
X		printf("udp/router: service unknown\n");
X		exit(1);
X	}
X	router.sin_port = sp->s_port;
X	msg->rip_cmd = RIPCMD_REQUEST;
X	msg->rip_vers = RIPVERSION;
X	msg->rip_nets[0].rip_dst.sa_family = htons(AF_UNSPEC);
X	msg->rip_nets[0].rip_metric = htonl(HOPCNT_INFINITY);
X	if (sendto(s, packet, sizeof (struct rip), 0,
X	  &router, sizeof(router)) < 0)
X		perror(host);
}
X
/*
X * Handle an incoming routing packet.
X */
rip_input(from, size)
X	struct sockaddr_in *from;
X	int size;
{
X	register struct rip *msg = (struct rip *)packet;
X	register struct netinfo *n;
X	char *name;
X	int lna, net, subnet;
X	struct hostent *hp;
X	struct netent *np;
X
X	if (msg->rip_cmd != RIPCMD_RESPONSE)
X		return;
X	printf("%d bytes from ", size);
X	if (nflag)
X		printf("%s:\n", inet_ntoa(from->sin_addr));
X	else {
X		hp = gethostbyaddr(&from->sin_addr, sizeof (struct in_addr),
X			AF_INET);
X		name = hp == 0 ? "???" : hp->h_name;
X		printf("%s(%s):\n", name, inet_ntoa(from->sin_addr));
X	}
X	size -= sizeof (int);
X	n = msg->rip_nets;
X	while (size > 0) {
X	    if (size < sizeof (struct netinfo))
X		    break;
X	    if (msg->rip_vers > 0) {
X		    n->rip_dst.sa_family =
X			    ntohs(n->rip_dst.sa_family);
X		    n->rip_metric = ntohl(n->rip_metric);
X	    }
X	    switch (n->rip_dst.sa_family) {
X
X	    case AF_INET:
X		{ register struct sockaddr_in *sin;
X
X		sin = (struct sockaddr_in *)&n->rip_dst;
X		net = inet_netof(sin->sin_addr);
X		subnet = inet_subnetof(sin->sin_addr);
X		lna = inet_lnaof(sin->sin_addr);
X		name = "???";
X		if (!nflag) {
X			if (sin->sin_addr.s_addr == 0)
X				name = "default";
X			else if (lna == INADDR_ANY) {
X				np = getnetbyaddr(net, AF_INET);
X				if (np)
X					name = np->n_name;
X				else if (net == 0)
X					name = "default";
X			} else if ((lna & 0xff) == 0 &&
X			    (np = getnetbyaddr(subnet, AF_INET))) {
X				struct in_addr subnaddr, inet_makeaddr();
X
X				subnaddr = inet_makeaddr(subnet, INADDR_ANY);
X				if (bcmp(&sin->sin_addr, &subnaddr,
X				    sizeof(subnaddr)) == 0)
X					name = np->n_name;
X				else
X					goto host;
X			} else {
X	host:
X				hp = gethostbyaddr(&sin->sin_addr,
X				    sizeof (struct in_addr), AF_INET);
X				if (hp)
X					name = hp->h_name;
X			}
X			printf("\t%-17s metric %2d name %s\n",
X				inet_ntoa(sin->sin_addr), n->rip_metric, name);
X		} else
X			printf("\t%-17s metric %2d\n",
X				inet_ntoa(sin->sin_addr), n->rip_metric);
X		break;
X		}
X
X	    default:
X		{ u_short *p = (u_short *)n->rip_dst.sa_data;
X
X		printf("\t(af %d) %x %x %x %x %x %x %x, metric %d\n",
X		    p[0], p[1], p[2], p[3], p[4], p[5], p[6],
X		    n->rip_dst.sa_family,
X		    n->rip_metric);
X		break;
X		}
X			
X	    }
X	    size -= sizeof (struct netinfo), n++;
X	}
}
X
timeout()
{
X	timedout = 1;
}
X
/*
X * Return the possible subnetwork number from an internet address.
X * SHOULD FIND OUT WHETHER THIS IS A LOCAL NETWORK BEFORE LOOKING
X * INSIDE OF THE HOST PART.  We can only believe this if we have other
X * information (e.g., we can find a name for this number).
X */
inet_subnetof(in)
X	struct in_addr in;
{
X	register u_long i = ntohl(in.s_addr);
X
X	if (IN_CLASSA(i))
X		return ((i & IN_CLASSB_NET) >> IN_CLASSB_NSHIFT);
X	else if (IN_CLASSB(i))
X		return ((i & IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
X	else
X		return ((i & 0xffffffc0) >> 28);
}
SHAR_EOF
  $shar_touch -am 0611192588 'vxrouted_5.1.1/BSDrouted/tools/query.c' &&
  chmod 0444 'vxrouted_5.1.1/BSDrouted/tools/query.c' ||
  echo 'restore of vxrouted_5.1.1/BSDrouted/tools/query.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/BSDrouted/tools/query.c'`"
  test 6112 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/BSDrouted/tools/query.c: original size 6112, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/BSDrouted/tools/trace.c ==============
if test -f 'vxrouted_5.1.1/BSDrouted/tools/trace.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/BSDrouted/tools/trace.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/BSDrouted/tools/trace.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/BSDrouted/tools/trace.c' &&
/*
X * Copyright (c) 1983 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that this notice is preserved and that due credit is given
X * to the University of California at Berkeley. The name of the University
X * may not be used to endorse or promote products derived from this
X * software without specific prior written permission. This software
X * is provided ``as is'' without express or implied warranty.
X */
X
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1983 Regents of the University of California.\n\
X All rights reserved.\n";
#endif /* not lint */
X
#ifndef lint
static char sccsid[] = "@(#)trace.c	5.4 (Berkeley) 2/16/88";
#endif /* not lint */
X
#include <sys/param.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include <stdio.h>
#include <netdb.h>
#include <protocols/routed.h>
X
struct	sockaddr_in myaddr = { AF_INET, IPPORT_RESERVED-1 };
char	packet[MAXPACKETSIZE];
X
main(argc, argv)
X	int argc;
X	char *argv[];
{
X	int size, s;
X	struct sockaddr from;
X	struct sockaddr_in router;
X	register struct rip *msg = (struct rip *)packet;
X	struct hostent *hp;
X	struct servent *sp;
X	
X	if (argc < 3) {
usage:
X		printf("usage: trace cmd machines,\n");
X		printf("cmd either \"on filename\", or \"off\"\n");
X		exit(1);
X	}
X	s = socket(AF_INET, SOCK_DGRAM, 0);
X	if (s < 0) {
X		perror("socket");
X		exit(2);
X	}
#ifdef vax || pdp11
X	myaddr.sin_port = htons(myaddr.sin_port);
#endif
X	if (bind(s, &myaddr, sizeof(myaddr)) < 0) {
X		perror("bind");
X		exit(2);
X	}
X
X	argv++, argc--;
X	msg->rip_cmd = strcmp(*argv, "on") == 0 ?
X		RIPCMD_TRACEON : RIPCMD_TRACEOFF;
X	msg->rip_vers = RIPVERSION;
X	argv++, argc--;
X	size = sizeof (int);
X	if (msg->rip_cmd == RIPCMD_TRACEON) {
X		strcpy(msg->rip_tracefile, *argv);
X		size += strlen(*argv);
X		argv++, argc--;
X	}
X	if (argc == 0)
X		goto usage;
X	bzero((char *)&router, sizeof (router));
X	router.sin_family = AF_INET;
X	sp = getservbyname("router", "udp");
X	if (sp == 0) {
X		printf("udp/router: service unknown\n");
X		exit(1);
X	}
X	router.sin_port = sp->s_port;
X	while (argc > 0) {
X		router.sin_family = AF_INET;
X		router.sin_addr.s_addr = inet_addr(*argv);
X		if (router.sin_addr.s_addr == -1) {
X			hp = gethostbyname(*argv);
X			if (hp == 0) {
X				printf("%s: unknown\n", *argv);
X				exit(1);
X			}
X			bcopy(hp->h_addr, &router.sin_addr, hp->h_length);
X		}
X		if (sendto(s, packet, size, 0, &router, sizeof(router)) < 0)
X			perror(*argv);
X		argv++, argc--;
X	}
}
SHAR_EOF
  $shar_touch -am 0216193988 'vxrouted_5.1.1/BSDrouted/tools/trace.c' &&
  chmod 0444 'vxrouted_5.1.1/BSDrouted/tools/trace.c' ||
  echo 'restore of vxrouted_5.1.1/BSDrouted/tools/trace.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/BSDrouted/tools/trace.c'`"
  test 2529 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/BSDrouted/tools/trace.c: original size 2529, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/BSDrouted/tools/Makefile ==============
if test -f 'vxrouted_5.1.1/BSDrouted/tools/Makefile' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/BSDrouted/tools/Makefile (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/BSDrouted/tools/Makefile (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/BSDrouted/tools/Makefile' &&
#
# Copyright (c) 1987 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that this notice is preserved and that due credit is given
# to the University of California at Berkeley. The name of the University
# may not be used to endorse or promote products derived from this
# software without specific written prior permission. This software
# is provided ``as is'' without express or implied warranty.
#
#	@(#)Makefile	5.3 (Berkeley) 6/11/88
#
CFLAGS=	-O
SRCS=	query.c trace.c
X
all: query trace
X
# test programs and utilities
query:
X	${CC} ${CFLAGS} -o $@ query.c
X
trace:
X	${CC} ${CFLAGS} -o $@ trace.c
X
install: FRC
X
clean: FRC
X	rm -f core query trace tags
X
depend: FRC
X	mkdep -p ${SRCS}
X
tags: FRC
X	ctags ${SRCS}
X
FRC:
X
# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
X
query: query.c /usr/include/sys/param.h /usr/include/sys/types.h
query: /usr/include/signal.h /usr/include/machine/trap.h
query: /usr/include/machine/machparam.h /usr/include/machine/endian.h
query: /usr/include/sys/protosw.h /usr/include/sys/socket.h
query: /usr/include/sys/time.h /usr/include/time.h /usr/include/netinet/in.h
query: /usr/include/errno.h /usr/include/stdio.h /usr/include/netdb.h
query: /usr/include/protocols/routed.h
trace: trace.c /usr/include/sys/param.h /usr/include/sys/types.h
trace: /usr/include/signal.h /usr/include/machine/trap.h
trace: /usr/include/machine/machparam.h /usr/include/machine/endian.h
trace: /usr/include/sys/protosw.h /usr/include/sys/socket.h
trace: /usr/include/netinet/in.h /usr/include/errno.h /usr/include/stdio.h
trace: /usr/include/netdb.h /usr/include/protocols/routed.h
X
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
SHAR_EOF
  $shar_touch -am 0714191488 'vxrouted_5.1.1/BSDrouted/tools/Makefile' &&
  chmod 0444 'vxrouted_5.1.1/BSDrouted/tools/Makefile' ||
  echo 'restore of vxrouted_5.1.1/BSDrouted/tools/Makefile failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/BSDrouted/tools/Makefile'`"
  test 1785 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/BSDrouted/tools/Makefile: original size 1785, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/BSDrouted/defs.h ==============
if test -f 'vxrouted_5.1.1/BSDrouted/defs.h' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/BSDrouted/defs.h (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/BSDrouted/defs.h (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/BSDrouted/defs.h' &&
/*
X * Copyright (c) 1983, 1988 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley.  The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X *
X *	@(#)defs.h	5.7 (Berkeley) 2/18/89
X */
X
/*
X * Internal data structure definitions for
X * user routing process.  Based on Xerox NS
X * protocol specs with mods relevant to more
X * general addressing scheme.
X */
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/time.h>
X
#include <net/route.h>
#include <netinet/in.h>
#include <protocols/routed.h>
X
#include <stdio.h>
#include <netdb.h>
X
#include "trace.h"
#include "interface.h"
#include "table.h"
#include "af.h"
X
/*
X * When we find any interfaces marked down we rescan the
X * kernel every CHECK_INTERVAL seconds to see if they've
X * come up.
X */
#define	CHECK_INTERVAL	(1*60)
X
#define equal(a1, a2) \
X	(bcmp((caddr_t)(a1), (caddr_t)(a2), sizeof (struct sockaddr)) == 0)
X
struct	sockaddr_in addr;	/* address of daemon's socket */
X
int	s;			/* source and sink of all data */
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 /vmunix has changed */
int	externalinterfaces;	/* # of remote and local interfaces */
struct	timeval now;		/* current idea of time */
struct	timeval lastbcast;	/* last time all/changes broadcast */
struct	timeval lastfullupdate;	/* last time full table broadcast */
struct	timeval nextbcast;	/* time to wait before changes broadcast */
int	needupdate;		/* true if we need update at nextbcast */
X
char	packet[MAXPACKETSIZE+1];
struct	rip *msg;
X
char	**argv0;
struct	servent *sp;
X
extern	char *sys_errlist[];
extern	int errno;
X
struct	in_addr inet_makeaddr();
int	inet_addr();
SHAR_EOF
  : || echo 'restore of vxrouted_5.1.1/BSDrouted/defs.h failed'
fi
echo 'End of archive part 5'
echo 'File vxrouted_5.1.1/BSDrouted/defs.h is continued in part 6'
echo 6 > _sharseq.tmp
exit 0
