#!/bin/sh
# this is vxrouted_5.1.1-shar.03 (part 3 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file vxrouted_5.1.1/output.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" != 3; 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/output.c'
else
  echo 'x - continuing file vxrouted_5.1.1/output.c'
  sed 's/^X//' << 'SHAR_EOF' >> 'vxrouted_5.1.1/output.c' &&
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
#ifndef lint
static char sccsid[] = "@(#)output.c	5.12 (Berkeley) 2/18/89";
#endif /* not lint */
X
/*
X * Routing Table Management Daemon
X */
#include "defs.h"
X
/*
X * Apply the function "f" to all non-passive
X * interfaces.  If the interface supports the
X * use of broadcasting use it, otherwise address
X * the output to the known router.
X */
toall(f, rtstate, skipif)
X	int (*f)();
X	int rtstate;
X	struct interface *skipif;
{
X	register struct interface *ifp;
X	register struct sockaddr *dst;
X	register int flags;
X	extern struct interface *rd_ifnet;
X
X	for (ifp = rd_ifnet; ifp; ifp = ifp->int_next) {
X		if (ifp->int_flags & IFF_PASSIVE || ifp == skipif)
X			continue;
X		dst = ifp->int_flags & IFF_BROADCAST ? &ifp->int_broadaddr :
X		      ifp->int_flags & IFF_POINTOPOINT ? &ifp->int_dstaddr :
X		      &ifp->int_addr;
X		flags = ifp->int_flags & IFF_INTERFACE ? MSG_DONTROUTE : 0;
X		(*f)(dst, flags, ifp, rtstate);
X	}
}
X
/*
X * Output a preformed packet.
X */
/*ARGSUSED*/
rd_sendmsg(dst, flags, ifp, rtstate)
X	struct sockaddr *dst;
X	int flags;
X	struct interface *ifp;
X	int rtstate;
{
X
X	(*rd_afswitch[dst->sa_family].af_output)(rs, flags,
X		dst, sizeof (struct rip));
X	TRACE_OUTPUT(ifp, dst, sizeof (struct rip));
}
X
/*
X * Supply dst with the contents of the routing tables.
X * If this won't fit in one packet, chop it up into several.
X */
supply(dst, flags, ifp, rtstate)
X	struct sockaddr *dst;
X	int flags;
X	register struct interface *ifp;
X	int rtstate;
{
X	register struct rt_entry *rt;
X	register struct netinfo *n = msg->rip_nets;
X	register struct rthash *rh;
X	struct rthash *base = hosthash;
X	int doinghost = 1, size;
X	int (*output)() = rd_afswitch[dst->sa_family].af_output;
X	int (*sendroute)() = rd_afswitch[dst->sa_family].af_sendroute;
X	int npackets = 0;
X
X	msg->rip_cmd = RIPCMD_RESPONSE;
X	msg->rip_vers = RIPVERSION;
X	bzero(msg->rip_res1, sizeof(msg->rip_res1));
again:
X	for (rh = base; rh < &base[ROUTEHASHSIZ]; rh++)
X	for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) {
X		/*
X		 * Don't resend the information on the network
X		 * from which it was received (unless sending
X		 * in response to a query).
X		 */
X		if (ifp && rt->rt_ifp == ifp &&
X		    (rt->rt_state & RTS_INTERFACE) == 0)
X			continue;
X		if (rt->rt_state & RTS_EXTERNAL)
X			continue;
X		/*
X		 * For dynamic updates, limit update to routes
X		 * with the specified state.
X		 */
X		if (rtstate && (rt->rt_state & rtstate) == 0)
X			continue;
X		/*
X		 * Limit the spread of subnet information
X		 * to those who are interested.
X		 */
X		if (doinghost == 0 && rt->rt_state & RTS_SUBNET) {
X			if (rt->rt_dst.sa_family != dst->sa_family)
X				continue;
X			if ((*sendroute)(rt, dst) == 0)
X				continue;
X		}
X		size = (char *)n - packet;
X		if (size > MAXPACKETSIZE - sizeof (struct netinfo)) {
X			TRACE_OUTPUT(ifp, dst, size);
X			(*output)(rs, flags, dst, size);
X			/*
X			 * If only sending to ourselves,
X			 * one packet is enough to monitor interface.
X			 */
X			if (ifp && (ifp->int_flags &
X			   (IFF_BROADCAST | IFF_POINTOPOINT | IFF_REMOTE)) == 0)
X				return;
X			n = msg->rip_nets;
X			npackets++;
X		}
X		n->rip_dst = rt->rt_dst;
#if BSD < 198810
X		if (sizeof(n->rip_dst.sa_family) > 1)	/* XXX */
X		n->rip_dst.sa_family = htons(n->rip_dst.sa_family);
#endif
X		n->rip_metric = htonl(rt->rt_metric);
X		n++;
X	}
X	if (doinghost) {
X		doinghost = 0;
X		base = nethash;
X		goto again;
X	}
X	if (n != msg->rip_nets || (npackets == 0 && rtstate == 0)) {
X		size = (char *)n - packet;
X		TRACE_OUTPUT(ifp, dst, size);
X		(*output)(rs, flags, dst, size);
X	}
}
SHAR_EOF
  echo 'File vxrouted_5.1.1/output.c is complete' &&
  $shar_touch -am 1116155393 'vxrouted_5.1.1/output.c' &&
  chmod 0644 'vxrouted_5.1.1/output.c' ||
  echo 'restore of vxrouted_5.1.1/output.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/output.c'`"
  test 4339 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/output.c: original size 4339, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/netdb.h ==============
if test -f 'vxrouted_5.1.1/netdb.h' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/netdb.h (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/netdb.h (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/netdb.h' &&
/*	@(#)netdb.h 1.11 88/08/19 SMI from UCB 5.9 4/5/88	*/
/*
X * Copyright (c) 1980,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 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
/*
X * Structures returned by network data base library.
X * All addresses are supplied in host order, and
X * returned in network order (suitable for use in system calls).
X */
X
#ifndef _netdb_h
#define _netdb_h
X
struct	hostent {
X	char	*h_name;	/* official name of host */
X	char	**h_aliases;	/* alias list */
X	int	h_addrtype;	/* host address type */
X	int	h_length;	/* length of address */
X	char	**h_addr_list;	/* list of addresses from name server */
#define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */
};
X
/*
X * Assumption here is that a network number
X * fits in 32 bits -- probably a poor one.
X */
struct	netent {
X	char		*n_name;	/* official name of net */
X	char		**n_aliases;	/* alias list */
X	int		n_addrtype;	/* net address type */
X	unsigned long	n_net;		/* network # */
};
X
struct	servent {
X	char	*s_name;	/* official service name */
X	char	**s_aliases;	/* alias list */
X	int	s_port;		/* port # */
X	char	*s_proto;	/* protocol to use */
};
X
struct	protoent {
X	char	*p_name;	/* official protocol name */
X	char	**p_aliases;	/* alias list */
X	int	p_proto;	/* protocol # */
};
X
struct rpcent {
X	char	*r_name;	/* name of server for this rpc program */
X	char	**r_aliases;	/* alias list */
X	int	r_number;	/* rpc program number */
};
X
struct hostent	*gethostbyname(), *gethostbyaddr(), *gethostent();
struct netent	*getnetbyname(), *getnetbyaddr(), *getnetent();
struct servent	*getservbyname(), *getservbyport(), *getservent();
struct protoent	*getprotobyname(), *getprotobynumber(), *getprotoent();
struct rpcent	*getrpcbyname(), *getrpcbynumber(), *getrpcent();
X
/*
X * Error return codes from gethostbyname() and gethostbyaddr()
X * (when using the resolver)
X */
X
extern  int h_errno;	
X
#define	HOST_NOT_FOUND	1 /* Authoritive Answer Host not found */
#define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
#define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
#define	NO_DATA		4 /* Valid name, no data record of requested type */
#define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
X
#endif /*!_netdb_h*/
SHAR_EOF
  $shar_touch -am 0712065494 'vxrouted_5.1.1/netdb.h' &&
  chmod 0644 'vxrouted_5.1.1/netdb.h' ||
  echo 'restore of vxrouted_5.1.1/netdb.h failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/netdb.h'`"
  test 2649 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/netdb.h: original size 2649, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/random.c ==============
if test -f 'vxrouted_5.1.1/random.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/random.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/random.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/random.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 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
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)random.c	5.5 (Berkeley) 7/6/88";
#endif /* LIBC_SCCS and not lint */
X
#include <stdioLib.h>
X
/*
X * random.c:
X * An improved random number generation package.  In addition to the standard
X * rand()/srand() like interface, this package also has a special state info
X * interface.  The initstate() routine is called with a seed, an array of
X * bytes, and a count of how many bytes are being passed in; this array is then
X * initialized to contain information for random number generation with that
X * much state information.  Good sizes for the amount of state information are
X * 32, 64, 128, and 256 bytes.  The state can be switched by calling the
X * setstate() routine with the same array as was initiallized with initstate().
X * By default, the package runs with 128 bytes of state information and
X * generates far better random numbers than a linear congruential generator.
X * If the amount of state information is less than 32 bytes, a simple linear
X * congruential R.N.G. is used.
X * Internally, the state information is treated as an array of longs; the
X * zeroeth element of the array is the type of R.N.G. being used (small
X * integer); the remainder of the array is the state information for the
X * R.N.G.  Thus, 32 bytes of state information will give 7 longs worth of
X * state information, which will allow a degree seven polynomial.  (Note: the 
X * zeroeth word of state information also has some other information stored
X * in it -- see setstate() for details).
X * The random number generation technique is a linear feedback shift register
X * approach, employing trinomials (since there are fewer terms to sum up that
X * way).  In this approach, the least significant bit of all the numbers in
X * the state table will act as a linear feedback shift register, and will have
X * period 2^deg - 1 (where deg is the degree of the polynomial being used,
X * assuming that the polynomial is irreducible and primitive).  The higher
X * order bits will have longer periods, since their values are also influenced
X * by pseudo-random carries out of the lower bits.  The total period of the
X * generator is approximately deg*(2**deg - 1); thus doubling the amount of
X * state information has a vast influence on the period of the generator.
X * Note: the deg*(2**deg - 1) is an approximation only good for large deg,
X * when the period of the shift register is the dominant factor.  With deg
X * equal to seven, the period is actually much longer than the 7*(2**7 - 1)
X * predicted by this formula.
X */
X
X
X
/*
X * For each of the currently supported random number generators, we have a
X * break value on the amount of state information (you need at least this
X * many bytes of state info to support this random number generator), a degree
X * for the polynomial (actually a trinomial) that the R.N.G. is based on, and
X * the separation between the two lower order coefficients of the trinomial.
X */
X
#define		TYPE_0		0		/* linear congruential */
#define		BREAK_0		8
#define		DEG_0		0
#define		SEP_0		0
X
#define		TYPE_1		1		/* x**7 + x**3 + 1 */
#define		BREAK_1		32
#define		DEG_1		7
#define		SEP_1		3
X
#define		TYPE_2		2		/* x**15 + x + 1 */
#define		BREAK_2		64
#define		DEG_2		15
#define		SEP_2		1
X
#define		TYPE_3		3		/* x**31 + x**3 + 1 */
#define		BREAK_3		128
#define		DEG_3		31
#define		SEP_3		3
X
#define		TYPE_4		4		/* x**63 + x + 1 */
#define		BREAK_4		256
#define		DEG_4		63
#define		SEP_4		1
X
X
/*
X * Array versions of the above information to make code run faster -- relies
X * on fact that TYPE_i == i.
X */
X
#define		MAX_TYPES	5		/* max number of types above */
X
static  int		degrees[ MAX_TYPES ]	= { DEG_0, DEG_1, DEG_2,
X								DEG_3, DEG_4 };
X
static  int		seps[ MAX_TYPES ]	= { SEP_0, SEP_1, SEP_2,
X								SEP_3, SEP_4 };
X
X
X
/*
X * Initially, everything is set up as if from :
X *		initstate( 1, &randtbl, 128 );
X * Note that this initialization takes advantage of the fact that srandom()
X * advances the front and rear pointers 10*rand_deg times, and hence the
X * rear pointer which starts at 0 will also end up at zero; thus the zeroeth
X * element of the state information, which contains info about the current
X * position of the rear pointer is just
X *	MAX_TYPES*(rptr - state) + TYPE_3 == TYPE_3.
X */
X
static  long		randtbl[ DEG_3 + 1 ]	= { TYPE_3,
X			    0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 
X			    0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb, 
X			    0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd, 
X			    0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, 
X			    0xda672e2a, 0x1588ca88, 0xe369735d, 0x904f35f7, 
X			    0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc, 
X			    0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 
X					0xf5ad9d0e, 0x8999220b, 0x27fb47b9 };
X
/*
X * fptr and rptr are two pointers into the state info, a front and a rear
X * pointer.  These two pointers are always rand_sep places aparts, as they cycle
X * cyclically through the state information.  (Yes, this does mean we could get
X * away with just one pointer, but the code for random() is more efficient this
X * way).  The pointers are left positioned as they would be from the call
X *			initstate( 1, randtbl, 128 )
X * (The position of the rear pointer, rptr, is really 0 (as explained above
X * in the initialization of randtbl) because the state table pointer is set
X * to point to randtbl[1] (as explained below).
X */
X
static  long		*fptr			= &randtbl[ SEP_3 + 1 ];
static  long		*rptr			= &randtbl[ 1 ];
X
X
X
/*
X * The following things are the pointer to the state information table,
X * the type of the current generator, the degree of the current polynomial
X * being used, and the separation between the two pointers.
X * Note that for efficiency of random(), we remember the first location of
X * the state information, not the zeroeth.  Hence it is valid to access
X * state[-1], which is used to store the type of the R.N.G.
X * Also, we remember the last location, since this is more efficient than
X * indexing every time to find the address of the last element to see if
X * the front and rear pointers have wrapped.
X */
X
static  long		*state			= &randtbl[ 1 ];
X
static  int		rand_type		= TYPE_3;
static  int		rand_deg		= DEG_3;
static  int		rand_sep		= SEP_3;
X
static  long		*end_ptr		= &randtbl[ DEG_3 + 1 ];
X
X
X
/*
X * srandom:
X * Initialize the random number generator based on the given seed.  If the
X * type is the trivial no-state-information type, just remember the seed.
X * Otherwise, initializes state[] based on the given "seed" via a linear
X * congruential generator.  Then, the pointers are set to known locations
X * that are exactly rand_sep places apart.  Lastly, it cycles the state
X * information a given number of times to get rid of any initial dependencies
X * introduced by the L.C.R.N.G.
X * Note that the initialization of randtbl[] for default usage relies on
X * values produced by this routine.
X */
X
srandom( x )
X
X    unsigned		x;
{
X    	register  int		i, j;
X	long random();
X
X	if(  rand_type  ==  TYPE_0  )  {
X	    state[ 0 ] = x;
X	}
X	else  {
X	    j = 1;
X	    state[ 0 ] = x;
X	    for( i = 1; i < rand_deg; i++ )  {
X		state[i] = 1103515245*state[i - 1] + 12345;
X	    }
X	    fptr = &state[ rand_sep ];
X	    rptr = &state[ 0 ];
X	    for( i = 0; i < 10*rand_deg; i++ )  random();
X	}
}
X
X
X
/*
X * initstate:
X * Initialize the state information in the given array of n bytes for
X * future random number generation.  Based on the number of bytes we
X * are given, and the break values for the different R.N.G.'s, we choose
X * the best (largest) one we can and set things up for it.  srandom() is
X * then called to initialize the state information.
X * Note that on return from srandom(), we set state[-1] to be the type
X * multiplexed with the current value of the rear pointer; this is so
X * successive calls to initstate() won't lose this information and will
X * be able to restart with setstate().
X * Note: the first thing we do is save the current state, if any, just like
X * setstate() so that it doesn't matter when initstate is called.
X * Returns a pointer to the old state.
X */
X
char  *
initstate( seed, arg_state, n )
X
X    unsigned		seed;			/* seed for R. N. G. */
X    char		*arg_state;		/* pointer to state array */
X    int			n;			/* # bytes of state info */
{
X	register  char		*ostate		= (char *)( &state[ -1 ] );
X
X	if(  rand_type  ==  TYPE_0  )  state[ -1 ] = rand_type;
X	else  state[ -1 ] = MAX_TYPES*(rptr - state) + rand_type;
X	if(  n  <  BREAK_1  )  {
X	    if(  n  <  BREAK_0  )  {
X		fprintf( stderr, "initstate: not enough state (%d bytes) with which to do jack; ignored.\n", n );
X		return;
X	    }
X	    rand_type = TYPE_0;
X	    rand_deg = DEG_0;
X	    rand_sep = SEP_0;
X	}
X	else  {
X	    if(  n  <  BREAK_2  )  {
X		rand_type = TYPE_1;
X		rand_deg = DEG_1;
X		rand_sep = SEP_1;
X	    }
X	    else  {
X		if(  n  <  BREAK_3  )  {
X		    rand_type = TYPE_2;
X		    rand_deg = DEG_2;
X		    rand_sep = SEP_2;
X		}
X		else  {
X		    if(  n  <  BREAK_4  )  {
X			rand_type = TYPE_3;
X			rand_deg = DEG_3;
X			rand_sep = SEP_3;
X		    }
X		    else  {
X			rand_type = TYPE_4;
X			rand_deg = DEG_4;
X			rand_sep = SEP_4;
X		    }
X		}
X	    }
X	}
X	state = &(  ( (long *)arg_state )[1]  );	/* first location */
X	end_ptr = &state[ rand_deg ];	/* must set end_ptr before srandom */
X	srandom( seed );
X	if(  rand_type  ==  TYPE_0  )  state[ -1 ] = rand_type;
X	else  state[ -1 ] = MAX_TYPES*(rptr - state) + rand_type;
X	return( ostate );
}
X
X
X
/*
X * setstate:
X * Restore the state from the given state array.
X * Note: it is important that we also remember the locations of the pointers
X * in the current state information, and restore the locations of the pointers
X * from the old state information.  This is done by multiplexing the pointer
X * location into the zeroeth word of the state information.
X * Note that due to the order in which things are done, it is OK to call
X * setstate() with the same state as the current state.
X * Returns a pointer to the old state information.
X */
X
char  *
setstate( arg_state )
X
X    char		*arg_state;
{
X	register  long		*new_state	= (long *)arg_state;
X	register  int		type		= new_state[0]%MAX_TYPES;
X	register  int		rear		= new_state[0]/MAX_TYPES;
X	char			*ostate		= (char *)( &state[ -1 ] );
X
X	if(  rand_type  ==  TYPE_0  )  state[ -1 ] = rand_type;
X	else  state[ -1 ] = MAX_TYPES*(rptr - state) + rand_type;
X	switch(  type  )  {
X	    case  TYPE_0:
X	    case  TYPE_1:
X	    case  TYPE_2:
X	    case  TYPE_3:
X	    case  TYPE_4:
X		rand_type = type;
X		rand_deg = degrees[ type ];
X		rand_sep = seps[ type ];
X		break;
X
X	    default:
X		fprintf( stderr, "setstate: state info has been munged; not changed.\n" );
X	}
X	state = &new_state[ 1 ];
X	if(  rand_type  !=  TYPE_0  )  {
X	    rptr = &state[ rear ];
X	    fptr = &state[ (rear + rand_sep)%rand_deg ];
X	}
X	end_ptr = &state[ rand_deg ];		/* set end_ptr too */
X	return( ostate );
}
X
X
X
/*
X * random:
X * If we are using the trivial TYPE_0 R.N.G., just do the old linear
X * congruential bit.  Otherwise, we do our fancy trinomial stuff, which is the
X * same in all ther other cases due to all the global variables that have been
X * set up.  The basic operation is to add the number at the rear pointer into
X * the one at the front pointer.  Then both pointers are advanced to the next
X * location cyclically in the table.  The value returned is the sum generated,
X * reduced to 31 bits by throwing away the "least random" low bit.
X * Note: the code takes advantage of the fact that both the front and
X * rear pointers can't wrap on the same call by not testing the rear
X * pointer if the front one has wrapped.
X * Returns a 31-bit random number.
X */
X
long
random()
{
X	long		i;
X	
X	if(  rand_type  ==  TYPE_0  )  {
X	    i = state[0] = ( state[0]*1103515245 + 12345 )&0x7fffffff;
X	}
X	else  {
X	    *fptr += *rptr;
X	    i = (*fptr >> 1)&0x7fffffff;	/* chucking least random bit */
X	    if(  ++fptr  >=  end_ptr  )  {
X		fptr = state;
X		++rptr;
X	    }
X	    else  {
X		if(  ++rptr  >=  end_ptr  )  rptr = state;
X	    }
X	}
X	return( i );
}
X
SHAR_EOF
  $shar_touch -am 1111120493 'vxrouted_5.1.1/random.c' &&
  chmod 0644 'vxrouted_5.1.1/random.c' ||
  echo 'restore of vxrouted_5.1.1/random.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/random.c'`"
  test 12796 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/random.c: original size 12796, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/remque.c ==============
if test -f 'vxrouted_5.1.1/remque.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/remque.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/remque.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/remque.c' &&
/* 
X * remque.c --
X *
X *	Source code for the "remque" library procedure.
X *
X * Copyright 1988 Regents of the University of California
X * Permission to use, copy, modify, and distribute this
X * software and its documentation for any purpose and without
X * fee is hereby granted, provided that the above copyright
X * notice appear in all copies.  The University of California
X * makes no representations about the suitability of this
X * software for any purpose.  It is provided "as is" without
X * express or implied warranty.
X */
X
#ifndef lint
static char rcsid[] = "$ SPRITE (Berkeley)";
#endif not lint
X
struct qelem {
X    struct qelem *q_forw;
X    struct qelem *q_back;
X    char q_data[4];
};
X
X
/*
X *----------------------------------------------------------------------
X *
X * remque --
X *
X *	Remove an element from its queue.
X *
X * Results:
X *	None.
X *
X * Side effects:
X *	Elem is removed from the queue it used to be part of.
X *
X *----------------------------------------------------------------------
X */
X
remque(elem)
X    register struct qelem *elem;
{
X    elem->q_forw->q_back = elem->q_back;
X    elem->q_back->q_forw = elem->q_forw;
}
SHAR_EOF
  $shar_touch -am 0609072294 'vxrouted_5.1.1/remque.c' &&
  chmod 0644 'vxrouted_5.1.1/remque.c' ||
  echo 'restore of vxrouted_5.1.1/remque.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/remque.c'`"
  test 1144 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/remque.c: original size 1144, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/routed.h ==============
if test -f 'vxrouted_5.1.1/routed.h' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/routed.h (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/routed.h (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/routed.h' &&
/*      @(#)routed.h 1.9 88/08/19 SMI; from UCB 5.1 6/4/85	*/
/*
X * Copyright (c) 1983 Regents of the University of California.
X * All rights reserved.  The Berkeley software License Agreement
X * specifies the terms and conditions for redistribution.
X */
X
/*
X * Routing Information Protocol
X *
X * Derived from Xerox NS Routing Information Protocol
X * by changing 32-bit net numbers to sockaddr's and
X * padding stuff to 32-bit boundaries.
X */
X
#ifndef _protocols_routed_h
#define _protocols_routed_h
X
#define	RIPVERSION	1
X
struct netinfo {
X	struct	sockaddr rip_dst;	/* destination net/host */
X	int	rip_metric;		/* cost of route */
};
X
struct rip {
X	u_char	rip_cmd;		/* request/response */
X	u_char	rip_vers;		/* protocol version # */
X	u_char	rip_res1[2];		/* pad to 32-bit boundary */
X	union {
X		struct	netinfo ru_nets[1];	/* variable length... */
X		char	ru_tracefile[1];	/* ditto ... */
X	} ripun;
#define	rip_nets	ripun.ru_nets
#define	rip_tracefile	ripun.ru_tracefile
};
X 
struct entryinfo {
X	struct	sockaddr rtu_dst;
X	struct	sockaddr rtu_router;
X	short	rtu_flags;
X	short	rtu_state;
X	int	rtu_timer;
X	int	rtu_metric;
X	int	int_flags;
X	char	int_name[16];
};
X
/*
X * Packet types.
X */
#define	RIPCMD_REQUEST		1	/* want info - from suppliers */
#define	RIPCMD_RESPONSE		2	/* responding to request */
#define	RIPCMD_TRACEON		3	/* turn tracing on */
#define	RIPCMD_TRACEOFF		4	/* turn it off */
#define	RIPCMD_POLL		5	/* like request, but anyone answers */
#define	RIPCMD_POLLENTRY	6	/* like poll, but for entire entry */
X
#define	RIPCMD_MAX		7
#ifdef RIPCMDS
char *ripcmds[RIPCMD_MAX] =
X  { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF", "POLL", "POLLENTRY" };
#endif
X
#define	HOPCNT_INFINITY		16	/* per Xerox NS */
#define	MAXPACKETSIZE		512	/* max broadcast size */
X
/*
X * Timer values used in managing the routing table.
X * Every update forces an entry's timer to be reset.  After
X * EXPIRE_TIME without updates, the entry is marked invalid,
X * but held onto until GARBAGE_TIME so that others may
X * see it "be deleted".
X */
#define	TIMER_RATE		30	/* alarm clocks every 30 seconds */
X
#define	SUPPLY_INTERVAL		30	/* time to supply tables */
X
#define	EXPIRE_TIME		180	/* time to mark entry invalid */
#define	GARBAGE_TIME		240	/* time to garbage collect */
X
#endif /*!_protocols_routed_h*/
SHAR_EOF
  $shar_touch -am 1109140993 'vxrouted_5.1.1/routed.h' &&
  chmod 0644 'vxrouted_5.1.1/routed.h' ||
  echo 'restore of vxrouted_5.1.1/routed.h failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/routed.h'`"
  test 2291 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/routed.h: original size 2291, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/routed.man ==============
if test -f 'vxrouted_5.1.1/routed.man' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/routed.man (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/routed.man (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/routed.man' &&
X
X
X
ROUTED(8)             MAINTENANCE COMMANDS              ROUTED(8)
X
X
X
NAME
X     routed - network routing daemon
X
SYNOPSIS
X     /etc/routed [ -d ] [ -g ] [ -s ] [ -q ] [ -t ] [ _l_o_g_f_i_l_e ]
X
DESCRIPTION
X     _R_o_u_t_e_d is invoked at boot time to manage the network routing
X     tables.   The  routing daemon uses a variant of the Xerox NS
X     Routing Information Protocol in maintaining up to date  ker-
X     nel  routing  table entries.  It used a generalized protocol
X     capable of use with multiple address types, but is currently
X     used only for Internet routing within a cluster of networks.
X
X     In normal operation _r_o_u_t_e_d listens on the _u_d_p(4) socket  for
X     the  _r_o_u_t_e service (see _s_e_r_v_i_c_e_s(5)) for routing information
X     packets.  If the host is an internetwork router, it periodi-
X     cally  supplies copies of its routing tables to any directly
X     connected hosts and networks.
X
X     When _r_o_u_t_e_d is started, it uses  the  SIOCGIFCONF  _i_o_c_t_l  to
X     find those directly connected interfaces configured into the
X     system and marked ``up'' (the software loopback interface is
X     ignored).  If multiple interfaces are present, it is assumed
X     that the host will forward packets between networks.  _R_o_u_t_e_d
X     then  transmits  a _r_e_q_u_e_s_t packet on each interface (using a
X     broadcast packet if the interface supports it) and enters  a
X     loop,  listening for _r_e_q_u_e_s_t and _r_e_s_p_o_n_s_e packets from other
X     hosts.
X
X     When a _r_e_q_u_e_s_t packet is received, _r_o_u_t_e_d formulates a reply
X     based  on the information maintained in its internal tables.
X     The _r_e_s_p_o_n_s_e packet  generated  contains  a  list  of  known
X     routes,  each marked with a ``hop count'' metric (a count of
X     16, or greater, is  considered  ``infinite'').   The  metric
X     associated  with each route returned provides a metric _r_e_l_a_-
X     _t_i_v_e _t_o _t_h_e _s_e_n_d_e_r.
X
X     _R_e_s_p_o_n_s_e packets received by _r_o_u_t_e_d are used to  update  the
X     routing  tables if one of the following conditions is satis-
X     fied:
X
X     (1)  No routing table entry exists for the destination  net-
X          work  or host, and the metric indicates the destination
X          is ``reachable'' (i.e. the hop count is not infinite).
X
X     (2)  The source host of the packet is the same as the router
X          in  the existing routing table entry.  That is, updated
X          information is being received from the  very  internet-
X          work  router  through which packets for the destination
X          are being routed.
X
X
X
X
Sun Release 4.1  Last change: February 15, 1989                 1
X
X
X
X
X
X
ROUTED(8)             MAINTENANCE COMMANDS              ROUTED(8)
X
X
X
X     (3)  The existing entry in the routing table  has  not  been
X          updated  for  some  time (defined to be 90 seconds) and
X          the route is at least as cost effective as the  current
X          route.
X
X     (4)  The new route describes a shorter route to the destina-
X          tion  than  the  one  currently  stored  in the routing
X          tables; the metric of the new route is compared against
X          the one stored in the table to decide this.
X
X     When an update is applied, _r_o_u_t_e_d records the change in  its
X     internal  tables  and updates the kernel routing table.  The
X     change is reflected in the next _r_e_s_p_o_n_s_e packet sent.
X
X     In addition to  processing  incoming  packets,  _r_o_u_t_e_d  also
X     periodically  checks the routing table entries.  If an entry
X     has not been updated for 3 minutes, the  entry's  metric  is
X     set  to  infinity  and  marked  for deletion.  Deletions are
X     delayed an additional 60 seconds to insure the  invalidation
X     is propagated throughout the local internet.
X
X     Hosts acting as  internetwork  routers  gratuitously  supply
X     their  routing  tables every 30 seconds to all directly con-
X     nected hosts and networks.  The  response  is  sent  to  the
X     broadcast  address  on nets capable of that function, to the
X     destination address on  point-to-point  links,  and  to  the
X     router's  own address on other networks.  The normal routing
X     tables are bypassed when sending gratuitous responses.   The
X     reception  of responses on each network is used to determine
X     that the network and interface  are  functioning  correctly.
X     If  no  response  is received on an interface, another route
X     may be chosen to route around the interface,  or  the  route
X     may be dropped if no alternative is available.
X
X     _R_o_u_t_e_d _s_u_p_p_o_r_t_s _s_e_v_e_r_a_l _o_p_t_i_o_n_s:
X
X     -d   Enable additional debugging information to  be  logged,
X          such as bad packets received.
X
X     -g   This flag is used on internetwork routers  to  offer  a
X          route  to  the  ``default'' destination.  This is typi-
X          cally used on a gateway to the Internet, or on a  gate-
X          way that uses another routing protocol whose routes are
X          not reported to other local routers.
X
X     -s   Supplying this option forces _r_o_u_t_e_d to  supply  routing
X          information  whether  it  is  acting as an internetwork
X          router or not.  This is the default if multiple network
X          interfaces  are present, or if a point-to-point link is
X          in use.
X
X     -q   This is the opposite of the -s option.
X
X
X
Sun Release 4.1  Last change: February 15, 1989                 2
X
X
X
X
X
X
ROUTED(8)             MAINTENANCE COMMANDS              ROUTED(8)
X
X
X
X     -t   If the -t option is  specified,  all  packets  sent  or
X          received  are printed on the standard output.  In addi-
X          tion, _r_o_u_t_e_d will not divorce itself from the  control-
X          ling terminal so that interrupts from the keyboard will
X          kill the process.
X
X     Any other argument supplied is interpreted as  the  name  of
X     file  in  which _r_o_u_t_e_d's actions should be logged.  This log
X     contains information about any changes to the routing tables
X     and,  if  not  tracing all packets, a history of recent mes-
X     sages sent and received which are  related  to  the  changed
X     route.
X
X     In addition to the facilities described above,  _r_o_u_t_e_d  sup-
X     ports the notion of ``distant'' _p_a_s_s_i_v_e and _a_c_t_i_v_e gateways.
X     When _r_o_u_t_e_d is started up, it reads the  file  /_e_t_c/_g_a_t_e_w_a_y_s
X     to  find gateways which may not be located using only infor-
X     mation from the SIOGIFCONF  _i_o_c_t_l.   Gateways  specified  in
X     this  manner  should  be  marked  passive  if  they  are not
X     expected to exchange  routing  information,  while  gateways
X     marked active should be willing to exchange routing informa-
X     tion (i.e.  they should have a _r_o_u_t_e_d process running on the
X     machine).   Routes through passive gateways are installed in
X     the kernel's routing tables once upon startup.  Such  routes
X     are  not  included  in  any routing information transmitted.
X     Active gateways are treated equally to  network  interfaces.
X     Routing  information is distributed to the gateway and if no
X     routing information is received for a period  of  the  time,
X     the  associated  route is deleted.  Gateways marked _e_x_t_e_r_n_a_l
X     are also passive, but are not placed in the  kernel  routing
X     table  nor  are they included in routing updates.  The func-
X     tion of external entries is to inform  _r_o_u_t_e_d  that  another
X     routing  process  will install such a route, and that alter-
X     nate routes to that destination  should  not  be  installed.
X     Such  entries  are only required when both routers may learn
X     of routes to the same destination.
X
X     The /_e_t_c/_g_a_t_e_w_a_y_s is comprised of a series of lines, each in
X     the following format:
X
X     < net | host > _n_a_m_e_1 gateway _n_a_m_e_2 metric _v_a_l_u_e < passive | active | external >
X
X     The net or host keyword indicates if the route is to a  net-
X     work or specific host.
X
X     _N_a_m_e_1 is the name of the destination network or host.   This
X     may   be   a  symbolic  name  located  in  /_e_t_c/_n_e_t_w_o_r_k_s  or
X     /_e_t_c/_h_o_s_t_s (or, if started after _n_a_m_e_d(8), known to the name
X     server),  or  an Internet address specified in ``dot'' nota-
X     tion; see _i_n_e_t(3).
X
X
X
X
X
Sun Release 4.1  Last change: February 15, 1989                 3
X
X
X
X
X
X
ROUTED(8)             MAINTENANCE COMMANDS              ROUTED(8)
X
X
X
X     _N_a_m_e_2 is the name or address of the gateway  to  which  mes-
X     sages should be forwarded.
X
X     _V_a_l_u_e is a metric indicating the hop count to  the  destina-
X     tion host or network.
X
X     One of the keywords passive, active or external indicates if
X     the  gateway  should  be  treated  as  _p_a_s_s_i_v_e or _a_c_t_i_v_e (as
X     described above), or whether the gateway is _e_x_t_e_r_n_a_l to  the
X     scope of the _r_o_u_t_e_d protocol.
X
X     Internetwork routers  that  are  directly  attached  to  the
X     Arpanet  or  Milnet should use the Exterior Gateway Protocol
X     (EGP) to gather routing  information  rather  then  using  a
X     static  routing  table of passive gateways.  EGP is required
X     in order to provide routes for local networks to the rest of
X     the  Internet  system.   Sites  needing assistance with such
X     configurations should contact the Computer Systems  Research
X     Group at Berkeley.
X
FILES
X     /etc/gateways  for distant gateways
X
SEE ALSO
X     ``Internet Transport Protocols'', XSIS 028112, Xerox  System
X     Integration Standard.
X     udp(4), icmp(4), XNSrouted(8), htable(8)
X
BUGS
X     The kernel's routing tables may not correspond to  those  of
X     _r_o_u_t_e_d  when  redirects change or add routes.  _R_o_u_t_e_d should
X     note any redirects received  by  reading  the  ICMP  packets
X     received via a raw socket.
X
X     _R_o_u_t_e_d should incorporate other routing protocols,  such  as
X     Xerox  NS  (_X_N_S_r_o_u_t_e_d(8)) and EGP.  Using separate processes
X     for each requires configuration options to  avoid  redundant
X     or competing routes.
X
X     _R_o_u_t_e_d should listen to intelligent interfaces, such  as  an
X     IMP,  to gather more information.  It does not always detect
X     unidirectional failures in network  interfaces  (e.g.,  when
X     the output side fails).
X
X
X
X
X
X
X
X
X
X
X
X
Sun Release 4.1  Last change: February 15, 1989                 4
X
X
X
SHAR_EOF
  $shar_touch -am 1109125793 'vxrouted_5.1.1/routed.man' &&
  chmod 0644 'vxrouted_5.1.1/routed.man' ||
  echo 'restore of vxrouted_5.1.1/routed.man failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/routed.man'`"
  test 10883 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/routed.man: original size 10883, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/startup.c ==============
if test -f 'vxrouted_5.1.1/startup.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/startup.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/startup.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/startup.c' &&
/*
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
#ifndef lint
static char sccsid[] = "@(#)startup.c	5.15 (Berkeley) 2/18/89";
#endif /* not lint */
SHAR_EOF
  : || echo 'restore of vxrouted_5.1.1/startup.c failed'
fi
echo 'End of archive part 3'
echo 'File vxrouted_5.1.1/startup.c is continued in part 4'
echo 4 > _sharseq.tmp
exit 0
