#!/bin/sh
# this is vxrouted_5.1.1-shar.02 (part 2 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file vxrouted_5.1.1/query.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" != 2; 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/query.c'
else
  echo 'x - continuing file vxrouted_5.1.1/query.c'
  sed 's/^X//' << 'SHAR_EOF' >> 'vxrouted_5.1.1/query.c' &&
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:
/*				hp = gethostbyaddr(&sin->sin_addr,
X				    sizeof (struct in_addr), AF_INET);
X				if (hp)
X					name = hp->h_name; */
X				if(hostGetByAddr(sin->sin_addr,hname) == ERROR)
X					name = hname;
X			}
X			inet_ntoa_b(sin->sin_addr,ntoa);
X			printf("\t%-17s metric %2d name %s\n",
X				ntoa, n->rip_metric, name);
X		} else {
X			inet_ntoa_b(sin->sin_addr,ntoa);
X			printf("\t%-17s metric %2d\n",
X				ntoa, n->rip_metric);
X		  }
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
  echo 'File vxrouted_5.1.1/query.c is complete' &&
  $shar_touch -am 0712065594 'vxrouted_5.1.1/query.c' &&
  chmod 0644 'vxrouted_5.1.1/query.c' ||
  echo 'restore of vxrouted_5.1.1/query.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/query.c'`"
  test 7499 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/query.c: original size 7499, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/inet.c ==============
if test -f 'vxrouted_5.1.1/inet.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/inet.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/inet.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/inet.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
#ifndef lint
static char sccsid[] = "@(#)inet.c	5.7 (Berkeley) 6/18/88";
#endif /* not lint */
X
/*
X * Temporarily, copy these routines from the kernel,
X * as we need to know about subnets.
X */
#include "defs.h"
X
extern struct interface *rd_ifnet;
X
/*
X * Formulate an Internet address from network + host.
X */
struct in_addr
inet_makeaddr(net, host)
X	u_long net, host;
{
X	register struct interface *ifp;
X	register u_long mask;
X	u_long addr;
X
X	if (IN_CLASSA(net))
X		mask = IN_CLASSA_HOST;
X	else if (IN_CLASSB(net))
X		mask = IN_CLASSB_HOST;
X	else
X		mask = IN_CLASSC_HOST;
X	for (ifp = rd_ifnet; ifp; ifp = ifp->int_next)
X		if ((ifp->int_netmask & net) == ifp->int_net) {
X			mask = ~ifp->int_subnetmask;
X			break;
X		}
X	addr = net | (host & mask);
X	addr = htonl(addr);
X	return (*(struct in_addr *)&addr);
}
X
/*
X * Return the network number from an internet address.
X */
#ifdef	DONT_USE_THIS_ONE
inet_netof(in)
X	struct in_addr in;
{
X	register u_long i = ntohl(in.s_addr);
X	register u_long net;
X	register struct interface *ifp;
X
X	if (IN_CLASSA(i))
X		net = i & IN_CLASSA_NET;
X	else if (IN_CLASSB(i))
X		net = i & IN_CLASSB_NET;
X	else
X		net = i & IN_CLASSC_NET;
X
X	/*
X	 * Check whether network is a subnet;
X	 * if so, return subnet number.
X	 */
X	for (ifp = rd_ifnet; ifp; ifp = ifp->int_next)
X		if ((ifp->int_netmask & net) == ifp->int_net)
X			return (i & ifp->int_subnetmask);
X	return (net);
} 
#endif	 /* DONT_USE_THIS_ONE */
X
/*
X * Return the host portion of an internet address.
X */
rd_inet_lnaof(in)
X	struct in_addr in;
{
X	register u_long i = ntohl(in.s_addr);
X	register u_long net, host;
X	register struct interface *ifp;
X
X	if (IN_CLASSA(i)) {
X		net = i & IN_CLASSA_NET;
X		host = i & IN_CLASSA_HOST;
X	} else if (IN_CLASSB(i)) {
X		net = i & IN_CLASSB_NET;
X		host = i & IN_CLASSB_HOST;
X	} else {
X		net = i & IN_CLASSC_NET;
X		host = i & IN_CLASSC_HOST;
X	}
X
X	/*
X	 * Check whether network is a subnet;
X	 * if so, use the modified interpretation of `host'.
X	 */
X	for (ifp = rd_ifnet; ifp; ifp = ifp->int_next)
X		if ((ifp->int_netmask & net) == ifp->int_net)
X			return (host &~ ifp->int_subnetmask);
X	return (host);
}
X
/*
X * Return RTF_HOST if the address is
X * for an Internet host, RTF_SUBNET for a subnet,
X * 0 for a network.
X */
inet_rtflags(sin)
X	struct sockaddr_in *sin;
{
X	register u_long i = ntohl(sin->sin_addr.s_addr);
X	register u_long net, host;
X	register struct interface *ifp;
X
X	if (IN_CLASSA(i)) {
X		net = i & IN_CLASSA_NET;
X		host = i & IN_CLASSA_HOST;
X	} else if (IN_CLASSB(i)) {
X		net = i & IN_CLASSB_NET;
X		host = i & IN_CLASSB_HOST;
X	} else {
X		net = i & IN_CLASSC_NET;
X		host = i & IN_CLASSC_HOST;
X	}
X
X	/*
X	 * Check whether this network is subnetted;
X	 * if so, check whether this is a subnet or a host.
X	 */
X	for (ifp = rd_ifnet; ifp; ifp = ifp->int_next)
X		if (net == ifp->int_net) {
X			if (host &~ ifp->int_subnetmask)
X				return (RTF_HOST);
X			else if (ifp->int_subnetmask != ifp->int_netmask)
X				return (RTF_SUBNET);
X			else
X				return (0);		/* network */
X		}
X	if (host == 0)
X		return (0);	/* network */
X	else
X		return (RTF_HOST);
}
X
/*
X * Return true if a route to subnet/host of route rt should be sent to dst.
X * Send it only if dst is on the same logical network if not "internal",
X * otherwise only if the route is the "internal" route for the logical net.
X */
inet_sendroute(rt, dst)
X	struct rt_entry *rt;
X	struct sockaddr_in *dst;
{
X	register u_long r =
X	    ntohl(((struct sockaddr_in *)&rt->rt_dst)->sin_addr.s_addr);
X	register u_long d = ntohl(dst->sin_addr.s_addr);
X
X	if (IN_CLASSA(r)) {
X		if ((r & IN_CLASSA_NET) == (d & IN_CLASSA_NET)) {
X			if ((r & IN_CLASSA_HOST) == 0)
X				return ((rt->rt_state & RTS_INTERNAL) == 0);
X			return (1);
X		}
X		if (r & IN_CLASSA_HOST)
X			return (0);
X		return ((rt->rt_state & RTS_INTERNAL) != 0);
X	} else if (IN_CLASSB(r)) {
X		if ((r & IN_CLASSB_NET) == (d & IN_CLASSB_NET)) {
X			if ((r & IN_CLASSB_HOST) == 0)
X				return ((rt->rt_state & RTS_INTERNAL) == 0);
X			return (1);
X		}
X		if (r & IN_CLASSB_HOST)
X			return (0);
X		return ((rt->rt_state & RTS_INTERNAL) != 0);
X	} else {
X		if ((r & IN_CLASSC_NET) == (d & IN_CLASSC_NET)) {
X			if ((r & IN_CLASSC_HOST) == 0)
X				return ((rt->rt_state & RTS_INTERNAL) == 0);
X			return (1);
X		}
X		if (r & IN_CLASSC_HOST)
X			return (0);
X		return ((rt->rt_state & RTS_INTERNAL) != 0);
X	}
}
SHAR_EOF
  $shar_touch -am 1116155393 'vxrouted_5.1.1/inet.c' &&
  chmod 0644 'vxrouted_5.1.1/inet.c' ||
  echo 'restore of vxrouted_5.1.1/inet.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/inet.c'`"
  test 5102 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/inet.c: original size 5102, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/input.c ==============
if test -f 'vxrouted_5.1.1/input.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/input.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/input.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/input.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[] = "@(#)input.c	5.20 (Berkeley) 2/20/89";
#endif /* not lint */
X
/*
X * Routing Table Management Daemon
X */
#include "defs.h"
/* #include <sys/syslog.h> */
X
/*
X * Process a newly received packet.
X */
rd_rip_input(from, rip, size)
X	struct sockaddr *from;
X	register struct rip *rip;
X	int size;
{
X	register struct rt_entry *rt;
X	register struct netinfo *n;
X	register struct interface *ifp;
X	struct interface *if_ifwithdstaddr();
X	int count, changes = 0;
X	register struct rd_afswitch *afp;
X	static struct sockaddr badfrom, badfrom2;
X
X	ifp = 0;
X	TRACE_INPUT(ifp, from, (char *)rip, size);
X	if (from->sa_family >= af_max ||
X	    (afp = &rd_afswitch[from->sa_family])->af_hash == (int (*)())0) {
X		logMsg(" LOG_INFO, from address in unsupported address family (%d), cmd %d\n",
X		    from->sa_family, rip->rip_cmd);
X		return;
X	}
X	if (rip->rip_vers == 0) {
X		logMsg(" LOG_ERR, RIP version 0 packet received from %s! (cmd %d)",
X		    (*rd_afswitch[from->sa_family].af_format)(from), rip->rip_cmd);
X		return;
X	}
X	switch (rip->rip_cmd) {
X
X	case RIPCMD_REQUEST:
X		n = rip->rip_nets;
X		count = size - ((char *)n - (char *)rip);
X		if (count < sizeof (struct netinfo))
X			return;
X		for (; count > 0; n++) {
X			if (count < sizeof (struct netinfo))
X				break;
X			count -= sizeof (struct netinfo);
X
#if BSD < 198810
X			if (sizeof(n->rip_dst.sa_family) > 1)/* XXX */
X				n->rip_dst.sa_family =
X					ntohs(n->rip_dst.sa_family);
#endif
X			n->rip_metric = ntohl(n->rip_metric);
X			/* 
X			 * A single entry with sa_family == AF_UNSPEC and
X			 * metric ``infinity'' means ``all routes''.
X			 * We respond to routers only if we are acting
X			 * as a supplier, or to anyone other than a router
X			 * (eg, query).
X			 */
X			if (n->rip_dst.sa_family == AF_UNSPEC &&
X			    n->rip_metric == HOPCNT_INFINITY && count == 0) {
X			    	if (supplier || (*afp->af_portmatch)(from) == 0)
X					supply(from, 0, 0, 0);
X				return;
X			}
X			if (n->rip_dst.sa_family < af_max &&
X			    rd_afswitch[n->rip_dst.sa_family].af_hash)
X				rt = rtlookup(&n->rip_dst);
X			else
X				rt = 0;
X			n->rip_metric = rt == 0 ? HOPCNT_INFINITY :
X				min(rt->rt_metric + 1, HOPCNT_INFINITY);
#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(n->rip_metric);
X		}
X		rip->rip_cmd = RIPCMD_RESPONSE;
X		bcopy((char *)rip, packet, size);
X		(*afp->af_output)(rs, 0, from, size);
X		return;
X
X	case RIPCMD_TRACEON:
X	case RIPCMD_TRACEOFF:
X		/* verify message came from a privileged port */
X		if ((*afp->af_portcheck)(from) == 0)
X			return;
X		if ((ifp = if_iflookup(from)) == 0 || (ifp->int_flags &
X		    (IFF_BROADCAST | IFF_POINTOPOINT | IFF_REMOTE)) == 0 ||
X		    ifp->int_flags & IFF_PASSIVE) {
X			logMsg(" LOG_ERR, trace command from unknown router, %s",
X			    (*rd_afswitch[from->sa_family].af_format)(from));
X			return;
X		}
X		((char *)rip)[size] = '\0';
X		if (rip->rip_cmd == RIPCMD_TRACEON)
X			traceon(rip->rip_tracefile);
X		else
X			traceoff();
X		return;
X
X	case RIPCMD_RESPONSE:
X		/* verify message came from a router */
X		if ((*afp->af_portmatch)(from) == 0)
X			return;
X		(*afp->af_canon)(from);
X		/* are we talking to ourselves? */
X		ifp = if_ifwithaddr(from);
X		if (ifp) {
X			if (ifp->int_flags & IFF_PASSIVE) {
X				logMsg(" LOG_ERR, bogus input (from passive interface, %s)",
X				  (*rd_afswitch[from->sa_family].af_format)(from));
X				return;
X			}
X			rt = rtfind(from);
X			if (rt == 0 || ((rt->rt_state & RTS_INTERFACE) == 0) &&
X			    rt->rt_metric >= ifp->int_metric) 
X				addrouteforif(ifp);
X			else
X				rt->rt_timer = 0;
X			return;
X		}
X		/*
X		 * Update timer for interface on which the packet arrived.
X		 * If from other end of a point-to-point link that isn't
X		 * in the routing tables, (re-)add the route.
X		 */
X		if ((rt = rtfind(from)) &&
X		    (rt->rt_state & (RTS_INTERFACE | RTS_REMOTE)))
X			rt->rt_timer = 0;
X		else if ((ifp = if_ifwithdstaddr(from)) &&
X		    (rt == 0 || rt->rt_metric >= ifp->int_metric))
X			addrouteforif(ifp);
X		/*
X		 * "Authenticate" router from which message originated.
X		 * We accept routing packets from routers directly connected
X		 * via broadcast or point-to-point networks,
X		 * and from those listed in /etc/gateways.
X		 */
X		if ((ifp = if_iflookup(from)) == 0 || (ifp->int_flags &
X		    (IFF_BROADCAST | IFF_POINTOPOINT | IFF_REMOTE)) == 0 ||
X		    ifp->int_flags & IFF_PASSIVE) {
X			if (bcmp((char *)from, (char *)&badfrom,
X			    sizeof(badfrom)) != 0) {
X				logMsg(" LOG_ERR, packet from unknown router, %s",
X				  (*rd_afswitch[from->sa_family].af_format)(from));
X				badfrom = *from;
X			}
X			return;
X		}
X		size -= 4 * sizeof (char);
X		n = rip->rip_nets;
X		for (; size > 0; size -= sizeof (struct netinfo), n++) {
X			if (size < sizeof (struct netinfo))
X				break;
#if BSD < 198810
X			if (sizeof(n->rip_dst.sa_family) > 1)	/* XXX */
X				n->rip_dst.sa_family =
X					ntohs(n->rip_dst.sa_family);
#endif
X			n->rip_metric = ntohl(n->rip_metric);
X			if (n->rip_dst.sa_family >= af_max ||
X			    (afp = &rd_afswitch[n->rip_dst.sa_family])->af_hash ==
X			    (int (*)())0) {
X				logMsg(" LOG_INFO, route in unsupported address family (%d), from %s (af %d)\n",
X				   n->rip_dst.sa_family,
X				   (*rd_afswitch[from->sa_family].af_format)(from),
X				   from->sa_family);
X				continue;
X			}
X			if (((*afp->af_checkhost)(&n->rip_dst)) == 0) {
X				logMsg(" LOG_DEBUG, bad host in route from %s (af %d)\n",
X				   (*rd_afswitch[from->sa_family].af_format)(from),
X				   from->sa_family);
X				continue;
X			}
X			if (n->rip_metric == 0 ||
X			    (unsigned) n->rip_metric > HOPCNT_INFINITY) {
X				if (bcmp((char *)from, (char *)&badfrom2,
X				    sizeof(badfrom2)) != 0) {
X					logMsg("LOG_ERR, bad metric (%d) from %s\n",
X					    n->rip_metric,
X				  (*rd_afswitch[from->sa_family].af_format)(from));
X					badfrom2 = *from;
X				}
X				continue;
X			}
X			/*
X			 * Adjust metric according to incoming interface.
X			 */
X			if ((unsigned) n->rip_metric < HOPCNT_INFINITY)
X				n->rip_metric += ifp->int_metric;
X			if ((unsigned) n->rip_metric > HOPCNT_INFINITY)
X				n->rip_metric = HOPCNT_INFINITY;
X			rt = rtlookup(&n->rip_dst);
X			if (rt == 0 ||
X			    (rt->rt_state & (RTS_INTERNAL|RTS_INTERFACE)) ==
X			    (RTS_INTERNAL|RTS_INTERFACE)) {
X				/*
X				 * If we're hearing a logical network route
X				 * back from a peer to which we sent it,
X				 * ignore it.
X				 */
X				if (rt && rt->rt_state & RTS_SUBNET &&
X				    (*afp->af_sendroute)(rt, from))
X					continue;
X				if ((unsigned)n->rip_metric < HOPCNT_INFINITY) {
X				    /*
X				     * Look for an equivalent route that
X				     * includes this one before adding
X				     * this route.
X				     */
X				    rt = rtfind(&n->rip_dst);
X				    if (rt && equal(from, &rt->rt_router))
X					    continue;
X				    rtadd(&n->rip_dst, from, n->rip_metric, 0);
X				    changes++;
X				}
X				continue;
X			}
X
X			/*
X			 * Update if from gateway and different,
X			 * shorter, or equivalent but old route
X			 * is getting stale.
X			 */
X			if (equal(from, &rt->rt_router)) {
X				if (n->rip_metric != rt->rt_metric) {
X					rtchange(rt, from, n->rip_metric);
X					changes++;
X					rt->rt_timer = 0;
X					if (rt->rt_metric >= HOPCNT_INFINITY)
X						rt->rt_timer =
X						    GARBAGE_TIME - EXPIRE_TIME;
X				} else if (rt->rt_metric < HOPCNT_INFINITY)
X					rt->rt_timer = 0;
X			} else if ((unsigned) n->rip_metric < rt->rt_metric ||
X			    (rt->rt_metric == n->rip_metric &&
X			    rt->rt_timer > (EXPIRE_TIME/2) &&
X			    (unsigned) n->rip_metric < HOPCNT_INFINITY)) {
X				rtchange(rt, from, n->rip_metric);
X				changes++;
X				rt->rt_timer = 0;
X			}
X		}
X		break;
X	}
X
X	/*
X	 * If changes have occurred, and if we have not sent a broadcast
X	 * recently, send a dynamic update.  This update is sent only
X	 * on interfaces other than the one on which we received notice
X	 * of the change.  If we are within MIN_WAITTIME of a full update,
X	 * don't bother sending; if we just sent a dynamic update
X	 * and set a timer (nextbcast), delay until that time.
X	 * If we just sent a full update, delay the dynamic update.
X	 * Set a timer for a randomized value to suppress additional
X	 * dynamic updates until it expires; if we delayed sending
X	 * the current changes, set needupdate.
X	 */
X	if (changes && supplier &&
X	   now.tv_sec - lastfullupdate.tv_sec < SUPPLY_INTERVAL-MAX_WAITTIME) {
X		u_long delay;
X		extern long random();
X
X		if (now.tv_sec - lastbcast.tv_sec >= MIN_WAITTIME &&
X		    timercmp(&nextbcast, &now)) {
X			if (traceactions)
X				fprintf(ftrace, "send dynamic update\n");
X			toall(supply, RTS_CHANGED, ifp);
X			lastbcast = now;
X			needupdate = 0;
X			nextbcast.tv_sec = 0;
X		} else {
X			needupdate++;
X			if (traceactions)
X				fprintf(ftrace, "delay dynamic update\n");
X		}
#define RANDOMDELAY()	(MIN_WAITTIME * 1000000 + \
X		(u_long)random() % ((MAX_WAITTIME - MIN_WAITTIME) * 1000000))
X
X		if (nextbcast.tv_sec == 0) {
X			delay = RANDOMDELAY();
X			if (traceactions)
X				fprintf(ftrace,
X				    "inhibit dynamic update for %d usec\n",
X				    delay);
X			nextbcast.tv_sec = delay / 1000000;
X			nextbcast.tv_usec = delay % 1000000;
X			timevaladd(&nextbcast, &now);
X			/*
X			 * If the next possibly dynamic update
X			 * is within MIN_WAITTIME of the next full update,
X			 * force the delay past the full update,
X			 * or we might send a dynamic update just before
X			 * the full update.
X			 */
X			if (nextbcast.tv_sec > lastfullupdate.tv_sec +
X			    SUPPLY_INTERVAL - MIN_WAITTIME)
X				nextbcast.tv_sec = lastfullupdate.tv_sec +
X				    SUPPLY_INTERVAL + 1;
X		}
X	}
}
SHAR_EOF
  $shar_touch -am 1116154293 'vxrouted_5.1.1/input.c' &&
  chmod 0644 'vxrouted_5.1.1/input.c' ||
  echo 'restore of vxrouted_5.1.1/input.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/input.c'`"
  test 10337 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/input.c: original size 10337, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/insque.c ==============
if test -f 'vxrouted_5.1.1/insque.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/insque.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/insque.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/insque.c' &&
/* 
X * insque.c --
X *
X *	Source code for the "insque" 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 * insque --
X *
X *	Insert a new element into a queue after a given predecessor.
X *
X * Results:
X *	None.
X *
X * Side effects:
X *	Elem is linked in after pred.
X *
X *----------------------------------------------------------------------
X */
X
insque(elem, pred)
X    register struct qelem *elem;
X    register struct qelem *pred;
{
X    elem->q_forw = pred->q_forw;
X    elem->q_back = pred;
X    pred->q_forw = elem;
X    elem->q_forw->q_back = elem;
}
SHAR_EOF
  $shar_touch -am 0609072194 'vxrouted_5.1.1/insque.c' &&
  chmod 0644 'vxrouted_5.1.1/insque.c' ||
  echo 'restore of vxrouted_5.1.1/insque.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/insque.c'`"
  test 1220 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/insque.c: original size 1220, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/interface.h ==============
if test -f 'vxrouted_5.1.1/interface.h' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/interface.h (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/interface.h (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/interface.h' &&
/*
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 *	@(#)interface.h	5.5 (Berkeley) 6/18/88
X */
X
/*
X * Routing table management daemon.
X */
X
/*
X * An ``interface'' is similar to an ifnet structure,
X * except it doesn't contain q'ing info, and it also
X * handles ``logical'' interfaces (remote gateways
X * that we want to keep polling even if they go down).
X * The list of interfaces which we maintain is used
X * in supplying the gratuitous routing table updates.
X */
struct interface {
X	struct	interface *int_next;
X	struct	sockaddr int_addr;		/* address on this host */
X	union {
X		struct	sockaddr intu_broadaddr;
X		struct	sockaddr intu_dstaddr;
X	} 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 */
X	int	int_metric;			/* init's routing entry */
X	int	int_flags;			/* see below */
X	/* START INTERNET SPECIFIC */
X	u_long	int_net;			/* network # */
X	u_long	int_netmask;			/* net mask for addr */
X	u_long	int_subnet;			/* subnet # */
X	u_long	int_subnetmask;			/* subnet mask for addr */
X	/* END INTERNET SPECIFIC */
X	struct	ifdebug int_input, int_output;	/* packet tracing stuff */
X	int	int_ipackets;			/* input packets received */
X	int	int_opackets;			/* output packets sent */
X	char	*int_name;			/* from kernel if structure */
X	u_short	int_transitions;		/* times gone up-down */
};
X
/*
X * 0x1 to 0x10 are reused from the kernel's ifnet definitions,
X * the others agree with the RTS_ flags defined elsewhere.
X */
#define	IFF_UP		0x1		/* interface is up */
#define	IFF_BROADCAST	0x2		/* broadcast address valid */
#define	IFF_DEBUG	0x4		/* turn on debugging */
#define	IFF_LOOPBACK	0x8		/* software loopback net */
#define	IFF_POINTOPOINT	0x10		/* interface is point-to-point link */
X
#define	IFF_SUBNET	0x1000		/* interface on subnetted network */
#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 */
X
struct	interface *if_ifwithaddr();
struct	interface *if_ifwithdstaddr();
struct	interface *if_ifwithnet();
struct	interface *if_iflookup();
SHAR_EOF
  $shar_touch -am 0726103088 'vxrouted_5.1.1/interface.h' &&
  chmod 0644 'vxrouted_5.1.1/interface.h' ||
  echo 'restore of vxrouted_5.1.1/interface.h failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/interface.h'`"
  test 2933 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/interface.h: original size 2933, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/main.c ==============
if test -f 'vxrouted_5.1.1/main.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/main.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/main.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/main.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
char copyright[] =
"@(#) Copyright (c) 1983, 1988 Regents of the University of California.\n\
X All rights reserved.\n";
#endif /* not lint */
X
#ifndef lint
static char sccsid[] = "@(#)main.c	5.17 (Berkeley) 2/20/89";
#endif /* not lint */
X
/*
X * Routing Table Management Daemon
X */
#include "defs.h"
#include <ioctl.h>
/* #include <sys/file.h> */
X
#include <net/if.h>
X
#include <errno.h>
#include <sigLib.h>
/* #include <sys/syslog.h> */
X
X
int	supplier = -1;		/* process should supply updates */
int	gateway = 0;		/* 1 if we are a gateway to parts beyond */
int	debug = 0;
int	bufspace = 127*1024;	/* max. input buffer size to request */
X
struct	rip *msg = (struct rip *)packet;
int	hup(), rtdeleteall(), sigtrace();
X
struct  itimerval {
X        struct  timeval it_interval;    /* timer interval */
X        struct  timeval it_value;       /* current value */
};
#define	ITIMER_REAL	0
#define F_SETFL         4       /* Set file flags */
#define _FNDELAY        0x0004  /* non blocking I/O (4.2 style) */
#define FNDELAY         _FNDELAY
X
void RitimerTask();
int in_routed();
int _in_routed();
X
#define MAX_ARGS 9
char *xargv[MAX_ARGS];
/* "in_routed","-d","-g","-s","-q","-t","-t","-t","\0" */
int xargc = 0;
char a0x[10] = "in_routed";
char a1x[10] = "\0";
char a2x[10] = "\0";
char a3x[10] = "\0";
char a4x[10] = "\0";
char a5x[10] = "\0";
char a6x[10] = "\0";
char a7x[10] = "\0";
char a8x[10] = "\0";
X
/* default parameters startup (normal operation) */
in_routed() {
X	routed("-q","\0","\0","\0","\0","\0","\0","\0");
}
X
/* default parameters startup tracing enabled (for use when debugging) */
/* change tty port for console device */
in_routedd() {
X	routed("-q","-d","-t","-t","-t","/tyCo/2","\0","\0");
}
X
routed(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)
X	char *arg1;
X	char *arg2;
X	char *arg3;
X	char *arg4;
X	char *arg5;
X	char *arg6;
X	char *arg7;
X	char *arg8;
{
X	xargc = 1;
X	xargv[0] = a0x;
X
X	if(*arg1 != '\0') {
X		strcpy(a1x,arg1);
X		xargv[xargc] = a1x;
X		xargc++;
X	}
X	if(*arg2 != '\0') {
X		strcpy(a2x,arg2);
X		xargv[xargc] = a2x;
X		xargc++;
X	}
X	if(*arg3 != '\0') {
X		strcpy(a3x,arg3);
X		xargv[xargc] = a3x;
X		xargc++;
X	}
X	if(*arg4 != '\0') {
X		strcpy(a4x,arg4);
X		xargv[xargc] = a4x;
X		xargc++;
X	}
X	if(*arg5 != '\0') {
X		strcpy(a5x,arg5);
X		xargv[xargc] = a5x;
X		xargc++;
X	}
X	if(*arg6 != '\0') {
X		strcpy(a6x,arg6);
X		xargv[xargc] = a6x;
X		xargc++;
X	}
X	if(*arg7 != '\0') {
X		strcpy(a7x,arg7);
X		xargv[xargc] = a7x;
X		xargc++;
X	}
X	if(*arg8 != '\0') {
X		strcpy(a8x,arg8);
X		xargv[xargc] = a8x;
X		xargc++;
X	}
X
X	taskSpawn("trouted",250,VX_STDIO,5000,_in_routed,xargc,xargv);
}
X
_in_routed(argc, argv)
X	int argc;
X	char *argv[];
{
X	int n, cc, nfd, omask, tflags = 0;
X	struct sockaddr from;
X	struct timeval *tvp, waittime;
X	struct itimerval itval;
X	fd_set ibits;
X	u_char retry;
X	
/*	printf(" routed_ argc = %d  argv = 0x%x\n",argc,argv);
X	for(;argc;argc--)
X		printf(" in_routed cmd %s\n",*argv++);
X	taskDelay(sysClkRateGet()*2);
X	return; */
X
/*	argv0 = argv; */
/* #if BSD >= 43
X	openlog("routed", LOG_PID | LOG_ODELAY, LOG_DAEMON);
X	setlogmask(LOG_UPTO(LOG_WARNING));
#else
X	openlog("routed", LOG_PID);
#define LOG_UPTO(x) (x)
#define setlogmask(x) (x)
#endif */
/*	svsp = getservbyname("router", "udp");
X	if (svsp == NULL) {
X		fprintf(stderr, "routed: router/udp: unknown service\n");
X		exit(1);
X	} */
X	addr.sin_family = AF_INET;
X	addr.sin_port = htons(520);
X	rs = getsocket(AF_INET, SOCK_DGRAM, &addr);
X	if (rs < 0)
X		exit(1);
X	argv++, argc--;
X	while (argc > 0 && **argv == '-') {
X		if (strcmp(*argv, "-s") == 0) {
X			supplier = 1;
X			argv++, argc--;
X			continue;
X		}
X		if (strcmp(*argv, "-q") == 0) {
X			supplier = 0;
X			argv++, argc--;
X			continue;
X		}
X		if (strcmp(*argv, "-t") == 0) {
X			tflags++;
/*			setlogmask(LOG_UPTO(LOG_DEBUG)); */
X			argv++, argc--;
X			continue;
X		}
X		if (strcmp(*argv, "-d") == 0) {
X			debug++;
/*			setlogmask(LOG_UPTO(LOG_DEBUG)); */
X			argv++, argc--;
X			continue;
X		}
X		if (strcmp(*argv, "-g") == 0) {
X			gateway = 1;
X			argv++, argc--;
X			continue;
X		}
X		fprintf(stderr,
X			"usage: routed [ -s ] [ -q ] [ -t ] [ -g ]\n");
X		exit(1);
X	}
X
/*	if (debug == 0) {
X		int t;
X
X		if (fork())
X			exit(0);
X		for (t = 0; t < 20; t++)
X			if (t != s)
X				(void) close(t);
X		(void) open("/", 0);
X		(void) dup2(0, 1);
X		(void) dup2(0, 2);
X		t = open("/dev/tty", 2);
X		if (t >= 0) {
X			ioctl(t, TIOCNOTTY, (char *)0);
X			(void) close(t);
X		}
X	} */
X	/*
X	 * Any extra argument is considered
X	 * a tracing log file.
X	 */
X	if (argc > 0)
X		traceon(*argv);
X	while (tflags-- > 0)
X		bumploglevel();
X
X	(void) gettimeofday(&now, (struct timezone *)NULL);
X	/*
X	 * Collect an initial view of the world by
X	 * checking the interface configuration and the gateway kludge
X	 * file.  Then, send a request packet on all
X	 * directly connected networks to find out what
X	 * everyone else thinks.
X	 */
X	rd_rtinit();
X	rd_ifinit();
X	gwkludge();
X	if (gateway > 0)
X		rtdefault();
X	if (supplier < 0)
X		supplier = 0;
X	msg->rip_cmd = RIPCMD_REQUEST;
X	msg->rip_vers = RIPVERSION;
X	if (sizeof(msg->rip_nets[0].rip_dst.sa_family) > 1)	/* XXX */
X		msg->rip_nets[0].rip_dst.sa_family = htons((u_short)AF_UNSPEC);
X	else
X		msg->rip_nets[0].rip_dst.sa_family = AF_UNSPEC;
X	msg->rip_nets[0].rip_metric = htonl((u_long)HOPCNT_INFINITY);
X	toall(rd_sendmsg);
/*	signal(SIGALRM, timer); */
X	signal(SIGHUP, hup);
X	signal(SIGTERM, hup);
X	signal(SIGINT, rtdeleteall);
X	signal(SIGUSR1, sigtrace);
X	signal(SIGUSR2, sigtrace);
X	itval.it_interval.tv_sec = TIMER_RATE;
X	itval.it_value.tv_sec = TIMER_RATE;
X	itval.it_interval.tv_usec = 0;
X	itval.it_value.tv_usec = 0;
X	srandom(taskIdSelf());
/*	if (setitimer(ITIMER_REAL, &itval, (struct itimerval *)NULL) < 0) */
X	if(taskSpawn("tRtimer",250,VX_STDIO,1500,RitimerTask,itval.it_interval.tv_sec,
X							itval.it_value.tv_sec) == ERROR)
X		logMsg(" LOG_ERR, setitimer: %m\n");
X
X	FD_ZERO(&ibits);
X	nfd = rs + 1;			/* 1 + max(fd's) */
X	for (;;) {
X		FD_SET(rs, &ibits);
X		/*
X		 * If we need a dynamic update that was held off,
X		 * needupdate will be set, and nextbcast is the time
X		 * by which we want select to return.  Compute time
X		 * until dynamic update should be sent, and select only
X		 * until then.  If we have already passed nextbcast,
X		 * just poll.
X		 */
X		if (needupdate) {
X			waittime = nextbcast;
X			timevalsub(&waittime, &now);
X			if (waittime.tv_sec < 0) {
X				waittime.tv_sec = 0;
X				waittime.tv_usec = 0;
X			}
X			if (traceactions)
X				fprintf(ftrace,
X				 "select until dynamic update %d/%d sec/usec\n",
X				    waittime.tv_sec, waittime.tv_usec);
X			tvp = &waittime;
X		} else
X			tvp = (struct timeval *)NULL;
X		n = select(nfd, &ibits, 0, 0, tvp);
X		if (n <= 0) {
X			/*
X			 * Need delayed dynamic update if select returned
X			 * nothing and we timed out.  Otherwise, ignore
X			 * errors (e.g. EINTR).
X			 */
X			if (n < 0) {
X				if (errno == EINTR)
X					continue;
X				logMsg(" LOG_ERR, select: %m");
X			}
X			omask = sigblock(sigmask(SIGALRM));
X			if (n == 0 && needupdate) {
X				if (traceactions)
X					fprintf(ftrace,
X					    "send delayed dynamic update\n");
X				(void) gettimeofday(&now,
X					    (struct timezone *)NULL);
X				toall(supply, RTS_CHANGED,
X				    (struct interface *)NULL);
X				lastbcast = now;
X				needupdate = 0;
X				nextbcast.tv_sec = 0;
X			}
X			sigsetmask(omask);
X			continue;
X		}
X		(void) gettimeofday(&now, (struct timezone *)NULL);
X		omask = sigblock(sigmask(SIGALRM));
#ifdef doesntwork
/*
printf("s %d, ibits %x index %d, mod %d, sh %x, or %x &ibits %x\n",
X	s,
X	ibits.fds_bits[0],
X	(s)/(sizeof(fd_mask) * 8),
X	((s) % (sizeof(fd_mask) * 8)),
X	(1 << ((s) % (sizeof(fd_mask) * 8))),
X	ibits.fds_bits[(s)/(sizeof(fd_mask) * 8)] & (1 << ((s) % (sizeof(fd_mask) * 8))),
X	&ibits
X	);
*/
X		if (FD_ISSET(s, &ibits))
#else
X		if (ibits.fds_bits[rs/32] & (1 << rs))
#endif
X			process(rs);
X		/* handle ICMP redirects */
X		sigsetmask(omask);
X	}
}
X
timevaladd(t1, t2)
X	struct timeval *t1, *t2;
{
X
X	t1->tv_sec += t2->tv_sec;
X	if ((t1->tv_usec += t2->tv_usec) > 1000000) {
X		t1->tv_sec++;
X		t1->tv_usec -= 1000000;
X	}
}
X
timevalsub(t1, t2)
X	struct timeval *t1, *t2;
{
X
X	t1->tv_sec -= t2->tv_sec;
X	if ((t1->tv_usec -= t2->tv_usec) < 0) {
X		t1->tv_sec--;
X		t1->tv_usec += 1000000;
X	}
}
X
process(fd)
X	int fd;
{
X	struct sockaddr from;
X	int fromlen, cc;
X	union {
X		char	buf[MAXPACKETSIZE+1];
X		struct	rip rip;
X	} inbuf;
X
X	for (;;) {
X		fromlen = sizeof (from);
X		cc = recvfrom(fd, &inbuf, sizeof (inbuf), 0, &from, &fromlen);
X		if (cc <= 0) {
X			if (cc < 0 && errno != EWOULDBLOCK)
X				perror("recvfrom");
X			break;
X		}
X		if (fromlen != sizeof (struct sockaddr_in))
X			break;
X		rd_rip_input(&from, &inbuf.rip, cc);
X	}
}
X
getsocket(domain, type, sin)
X	int domain, type;
X	struct sockaddr_in *sin;
{
X	int sock, on = 1;
X
X	if ((sock = socket(domain, type, 0)) < 0) {
X		perror("socket");
X		logMsg(" LOG_ERR, socket: %m");
X		return (-1);
X	}
#ifdef SO_BROADCAST
X	if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) {
X		logMsg(" LOG_ERR, setsockopt SO_BROADCAST: %m");
X		close(sock);
X		return (-1);
X	}
#endif
#ifdef SO_RCVBUF
X	for (on = bufspace; ; on -= 1024) {
X		if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
X		    &on, sizeof (on)) == 0)
X			break;
X		if (on <= 8*1024) {
X			logMsg(" LOG_ERR, setsockopt SO_RCVBUF: %m");
X			break;
X		}
X	}
X	if (traceactions)
X		fprintf(ftrace, "recv buf %d\n", on);
#endif
X	if (bind(sock, sin, sizeof (*sin), 0) < 0) {
X		perror("bind");
X		logMsg(" LOG_ERR, bind: %m");
X		close(sock);
X		return (-1);
X	}
/*	if (fcntl(sock, F_SETFL, FNDELAY) == -1)
X		logMsg(" LOG_ERR, fcntl FNDELAY: %m\n"); */
X	return (sock);
}
X
void RitimerTask(idly, inval)
X	long idly, inval;
{
X	taskDelay(sysClkRateGet() * idly);	/* initial delay */
X	while(1) {
X		timer();
X		taskDelay(sysClkRateGet() * inval);
X	}
}
SHAR_EOF
  $shar_touch -am 0712073094 'vxrouted_5.1.1/main.c' &&
  chmod 0644 'vxrouted_5.1.1/main.c' ||
  echo 'restore of vxrouted_5.1.1/main.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/main.c'`"
  test 10504 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/main.c: original size 10504, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/misc.c ==============
if test -f 'vxrouted_5.1.1/misc.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/misc.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/misc.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/misc.c' &&
#define __PROTOTYPE_5_0
#define INCLUDE_ANSI_5_0
X
#include <vxWorks.h>
#include <stdioLib.h>
#include <systime.h>
#include <sigLib.h>
#include <types.h>
#include <taskLib.h>
X
IMPORT time_t sys_time_t;
IMPORT time_t sys_time_ut;
X
int timercmp(tv1,tv2)
X   struct timeval *tv1;
X   struct timeval *tv2;
{
X   if(tv1->tv_sec < tv2->tv_sec)
X      return 1;
X   return 0;
}
X
int gettimeofday(tp, tzp)
X	struct timeval *tp;
X	struct timezone *tzp;
{
X	tp->tv_sec = sys_time_t;
X	tp->tv_usec = sys_time_ut;
X
X	if(tzp != NULL) {
X		tzp->tz_minuteswest = (5 * 60);	/* Hours west of Greenwich */
X		tzp->tz_dsttime = 0;		/* No dst */
X	}
}
X
void sigAlarmTask();
void sigAlarmTask(taskid,sigtype,sectime)
X	int taskid;
X	int sigtype;
X	int sectime;
{
X	time_t itime;
X
X	/* Can't just do a taskDelay here because the signal routine */
X	/* will not work any more after a taskDelay(). Don't know why? */
X	itime = sys_time_t + sectime;
X		while(sys_time_t < itime);
X
X	if(kill(taskid,sigtype) == ERROR)
X		logMsg(" sigkill failed\n");
}
X
void alarm(sectime)
X	int sectime;
{
X	if(taskSpawn("tsigAT",200,VX_STDIO,2000,sigAlarmTask,taskIdSelf(),SIGALRM,sectime) == ERROR)
X		logMsg(" taskSpawn for sigalarm failed\n");
}
X
SHAR_EOF
  $shar_touch -am 0711151594 'vxrouted_5.1.1/misc.c' &&
  chmod 0644 'vxrouted_5.1.1/misc.c' ||
  echo 'restore of vxrouted_5.1.1/misc.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/misc.c'`"
  test 1182 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/misc.c: original size 1182, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/output.c ==============
if test -f 'vxrouted_5.1.1/output.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/output.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/output.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/output.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.
SHAR_EOF
  : || echo 'restore of vxrouted_5.1.1/output.c failed'
fi
echo 'End of archive part 2'
echo 'File vxrouted_5.1.1/output.c is continued in part 3'
echo 3 > _sharseq.tmp
exit 0
