#!/bin/sh
# This is a shell archive (produced by shar 3.52.3)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 08/01/1994 18:59 UTC by thor@thor
# Source directory /thor/dt
#
# existing files will NOT be overwritten unless -c is specified
#
# This is part 1 of a multipart archive                                    
# do not concatenate these parts, unpack them in order with /bin/sh        
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   3889 -rw-r--r-- vxrouted_5.1.1/Makefile
#   3541 -rw-r--r-- vxrouted_5.1.1/af.c
#   1814 -rw-r--r-- vxrouted_5.1.1/af.h
#   9218 -rw-r--r-- vxrouted_5.1.1/ctime.c
#    527 -rw-r--r-- vxrouted_5.1.1/ctime.h
#   2882 -rw-r--r-- vxrouted_5.1.1/defs.h
#   3332 -rw-r--r-- vxrouted_5.1.1/if.c
#   7499 -rw-r--r-- vxrouted_5.1.1/query.c
#   5102 -rw-r--r-- vxrouted_5.1.1/inet.c
#  10337 -rw-r--r-- vxrouted_5.1.1/input.c
#   1220 -rw-r--r-- vxrouted_5.1.1/insque.c
#   2933 -rw-r--r-- vxrouted_5.1.1/interface.h
#  10504 -rw-r--r-- vxrouted_5.1.1/main.c
#   1182 -rw-r--r-- vxrouted_5.1.1/misc.c
#   4339 -rw-r--r-- vxrouted_5.1.1/output.c
#   2649 -rw-r--r-- vxrouted_5.1.1/netdb.h
#  12796 -rw-r--r-- vxrouted_5.1.1/random.c
#   1144 -rw-r--r-- vxrouted_5.1.1/remque.c
#   2291 -rw-r--r-- vxrouted_5.1.1/routed.h
#  10883 -rw-r--r-- vxrouted_5.1.1/routed.man
#  13884 -rw-r--r-- vxrouted_5.1.1/startup.c
#   2987 -rw-r--r-- vxrouted_5.1.1/table.h
#   8120 -rw-r--r-- vxrouted_5.1.1/tables.c
#   3059 -rw-r--r-- vxrouted_5.1.1/timer.c
#   9999 -rw-r--r-- vxrouted_5.1.1/trace.c
#   2608 -rw-r--r-- vxrouted_5.1.1/trace.h
#   3657 -rw-r--r-- vxrouted_5.1.1/tzfile.h
#   2040 -rw-r--r-- vxrouted_5.1.1/README
#   9633 -r--r--r-- vxrouted_5.1.1/BSDrouted/routed.8
#   6112 -r--r--r-- vxrouted_5.1.1/BSDrouted/tools/query.c
#   2529 -r--r--r-- vxrouted_5.1.1/BSDrouted/tools/trace.c
#   1785 -r--r--r-- vxrouted_5.1.1/BSDrouted/tools/Makefile
#   2540 -r--r--r-- vxrouted_5.1.1/BSDrouted/defs.h
#   3334 -r--r--r-- vxrouted_5.1.1/BSDrouted/af.c
#   1806 -r--r--r-- vxrouted_5.1.1/BSDrouted/af.h
#   3311 -r--r--r-- vxrouted_5.1.1/BSDrouted/if.c
#   5026 -r--r--r-- vxrouted_5.1.1/BSDrouted/inet.c
#  10333 -r--r--r-- vxrouted_5.1.1/BSDrouted/input.c
#   2933 -r--r--r-- vxrouted_5.1.1/BSDrouted/interface.h
#   8098 -r--r--r-- vxrouted_5.1.1/BSDrouted/main.c
#   4318 -r--r--r-- vxrouted_5.1.1/BSDrouted/output.c
#  13572 -r--r--r-- vxrouted_5.1.1/BSDrouted/startup.c
#   2987 -r--r--r-- vxrouted_5.1.1/BSDrouted/table.h
#   3056 -r--r--r-- vxrouted_5.1.1/BSDrouted/timer.c
#   9714 -r--r--r-- vxrouted_5.1.1/BSDrouted/trace.c
#   2608 -r--r--r-- vxrouted_5.1.1/BSDrouted/trace.h
#   8088 -r--r--r-- vxrouted_5.1.1/BSDrouted/tables.c
#   5252 -r--r--r-- vxrouted_5.1.1/BSDrouted/Makefile
#  36363 -rw-r--r-- vxrouted_5.1.1/in_routed
#
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 'Must unpack archives in sequence!'
  echo Please unpack part `cat _sharseq.tmp` next
  exit 1
fi
# ============= vxrouted_5.1.1/Makefile ==============
if test ! -d 'vxrouted_5.1.1'; then
  echo 'x - creating directory vxrouted_5.1.1'
  mkdir 'vxrouted_5.1.1'
fi
if test -f 'vxrouted_5.1.1/Makefile' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/Makefile (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/Makefile (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/Makefile' &&
#**************************************************************************
#*
#*     File: Makefile
#*
#*     Description: Makefile for building routed
#*
#*     Created by: Robert Barbrow
#*                 Project Engineer
#*                 LXE Inc.
#*                 125 Technology Parkway
#*                 Norcorss, GA. 30092
#*
#*                 Internet e-mail rcb0135@lxe6.lxe.com
#*                                 robert@crl.com
#*
#*                 Phone #(404)447-4224 ex.3365
#* 
#**************************************************************************
X
SHELL = /bin/sh
X
## rules
X
X.c.o :
X	$(CC) $(VERBOSE) $(CFLAGS) $(AFLAGS) \
X	$(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(WARN_FLAGS) \
X	$(K_AND_R_OR_ANSI) \
X	$(INCLUDES) -c $<
X
# This build rule gets you the assembly language version of any .c file
# the resulting file will be labled .s
# It also produces the preprocessor output version of the .c file
# the resulting file will be labled .cpp
# Type "build filename.s" where filename is any 'C' program file
X.c.s :
X	$(CC) $(VERBOSE) $(CFLAGS) $(AFLAGS) \
X	$(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(WARN_FLAGS) \
X	$(K_AND_R_OR_ANSI) \
X	$(INCLUDES) -E $< >$*.cpp
X
X	$(CC) $(VERBOSE) $(CFLAGS) $(AFLAGS) \
X	$(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(WARN_FLAGS) \
X	$(K_AND_R_OR_ANSI) \
X	$(INCLUDES) -S $<
X
DEBUG_FLAGS = #-g
VERBOSE = #-v
X
ANSI_ = -ansi -pedantic
K_AND_R_ = -traditional
X
# include paths for header files used by compiler added your own to this list
INCLUDES = -I. -I$(VWH)
X
# select warning level
WARN_FLAGS = -W #-Wtraditional -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings
X
# Select either ANSI_ or K_AND_R_
K_AND_R_OR_ANSI = $(K_AND_R_)
X
# Do not change any to the flags in the following area unless you read ALL of the Wind River
# documents on how to compile and link applications
# ---------------------------------------------------------------------------------------
CPU = 68000
AFLAGS = -m$(CPU)
CFLAGS = -DCPU=MC$(CPU) -DHOST_SUN -fvolatile -msoft-float
OPTIMIZE_FLAGS = -O -fno-builtin -fstrength-reduce
X
# default path for GNU compiler/linker tools
GTOOLS = $(VX_VW_BASE)/sun4.68k/bin/
X
CC  = $(GTOOLS)cc68k
LD  = $(GTOOLS)ld68k -r
AS  = $(GTOOLS)as68k
NM  = $(GTOOLS)nm68k
SZ  = $(GTOOLS)size68k
AR  = $(GTOOLS)ar68k cr
RAN = $(GTOOLS)ranlib68k
X
# default path for vxworks files
VW  = $(VX_VW_BASE)/
X
# vxWorks header file paths
VWH = $(VW)h/
X
# ---------------------------------------------------------------------------------------
X
#-----------------------------------------------------------------------------------------
# Place your build rules below this line to keep the top half of the build script generic.
#-----------------------------------------------------------------------------------------
#
# Copyright (c) 1987 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed
# by the University of California, Berkeley.  The name of the
# University may not be used to endorse or promote products derived
# from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
#	@(#)Makefile	5.7 (Berkeley) 7/9/88
#
all: in_routed
X
OBJS=	main.o query.o
X
LIBS=	af.o if.o input.o output.o startup.o tables.o timer.o \
X	trace.o inet.o random.o insque.o remque.o ctime.o misc.o
X
in_routed: ${OBJS} libs.a
X	${LD} -o $@ ${OBJS} libs.a
X
libs.a:	${LIBS}
X	${AR} $@ ${LIBS}
X	${RAN} $@
X
clean:
X	rm -f ${OBJS} ${LIBS} libs.a
SHAR_EOF
  $shar_touch -am 0713090694 'vxrouted_5.1.1/Makefile' &&
  chmod 0644 'vxrouted_5.1.1/Makefile' ||
  echo 'restore of vxrouted_5.1.1/Makefile failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/Makefile'`"
  test 3889 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/Makefile: original size 3889, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/af.c ==============
if test -f 'vxrouted_5.1.1/af.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/af.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/af.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/af.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[] = "@(#)af.c	5.8 (Berkeley) 6/18/88";
#endif /* not lint */
X
#include "defs.h"
#include <inetLib.h>
X
/*
X * Address family support routines
X */
int	inet_hash(), inet_netmatch(), inet_output(),
X	inet_portmatch(), inet_portcheck(),
X	inet_checkhost(), inet_rtflags(), inet_sendroute(), inet_canon();
char	*inet_format();
X
#define NIL	{ 0 }
#define	XINET \
X	{ inet_hash,		inet_netmatch,		inet_output, \
X	  inet_portmatch,	inet_portcheck,		inet_checkhost, \
X	  inet_rtflags,		inet_sendroute,		inet_canon, \
X	  inet_format \
X	}
X
struct rd_afswitch rd_afswitch[AF_MAX] = {
X	NIL,		/* 0- unused */
X	NIL,		/* 1- Unix domain, unused */
X	XINET,		/* Internet */
};
X
int af_max = sizeof(rd_afswitch) / sizeof(rd_afswitch[0]);
X
struct sockaddr_in inet_default = { AF_INET, INADDR_ANY };
X
int	af_max;			/* number of entries in table */
X
/* inet_hash(sin, hp)
X	register struct sockaddr_in *sin;
X	struct afhash *hp;
{
X	register u_long n;
X
X	n = inet_netof(sin->sin_addr);
X	if (n)
X	    while ((n & 0xff) == 0)
X		n >>= 8;
X	hp->afh_nethash = n;
X	hp->afh_hosthash = ntohl(sin->sin_addr.s_addr);
X	hp->afh_hosthash &= 0x7fffffff;
} */
X
/* inet_netmatch(sin1, sin2)
X	struct sockaddr_in *sin1, *sin2;
{
X
X	return (inet_netof(sin1->sin_addr) == inet_netof(sin2->sin_addr));
} */
X
/*
X * Verify the message is from the right port.
X */
inet_portmatch(sin)
X	register struct sockaddr_in *sin;
{
X	
/*	return (sin->sin_port == svsp->s_port); */
X	return (sin->sin_port == htons(520));
}
X
/*
X * Verify the message is from a "trusted" port.
X */
inet_portcheck(sin)
X	struct sockaddr_in *sin;
{
X
X	return (ntohs(sin->sin_port) <= IPPORT_RESERVED);
}
X
/*
X * Internet output routine.
X */
inet_output(s, flags, sin, size)
X	int s, flags;
X	struct sockaddr_in *sin;
X	int size;
{
X	struct sockaddr_in dst;
X
X	dst = *sin;
X	sin = &dst;
X	if (sin->sin_port == 0)
/*		sin->sin_port = svsp->s_port; */
X		sin->sin_port = htons(520);
X	if (sendto(s, packet, size, flags, sin, sizeof (*sin)) < 0)
X		perror("sendto");
}
X
/*
X * Return 1 if the address is believed
X * for an Internet host -- THIS IS A KLUDGE.
X */
inet_checkhost(sin)
X	struct sockaddr_in *sin;
{
X	u_long i = ntohl(sin->sin_addr.s_addr);
X
#ifndef IN_EXPERIMENTAL
#define	IN_EXPERIMENTAL(i)	(((long) (i) & 0xe0000000) == 0xe0000000)
#endif
X
X	if (IN_EXPERIMENTAL(i) || sin->sin_port != 0)
X		return (0);
X	if (i != 0 && (i & 0xff000000) == 0)
X		return (0);
X	for (i = 0; i < sizeof(sin->sin_zero)/sizeof(sin->sin_zero[0]); i++)
X		if (sin->sin_zero[i])
X			return (0);
X	return (1);
}
X
inet_canon(sin)
X	struct sockaddr_in *sin;
{
X
X	sin->sin_port = 0;
}
X
char	intabuf[INET_ADDR_LEN];
X
char *
inet_format(sin)
X	struct sockaddr_in *sin;
{
X	inet_ntoa_b(sin->sin_addr,intabuf);
X	return (intabuf);
}
SHAR_EOF
  $shar_touch -am 0624090294 'vxrouted_5.1.1/af.c' &&
  chmod 0644 'vxrouted_5.1.1/af.c' ||
  echo 'restore of vxrouted_5.1.1/af.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/af.c'`"
  test 3541 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/af.c: original size 3541, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/af.h ==============
if test -f 'vxrouted_5.1.1/af.h' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/af.h (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/af.h (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/af.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 *	@(#)af.h	5.6 (Berkeley) 6/18/88
X */
X
/*
X * Routing table management daemon.
X */
X
/*
X * Per address family routines.
X */
struct rd_afswitch {
X	int	(*af_hash)();		/* returns keys based on address */
X	int	(*af_netmatch)();	/* verifies net # matching */
X	int	(*af_output)();		/* interprets address for sending */
X	int	(*af_portmatch)();	/* packet from some other router? */
X	int	(*af_portcheck)();	/* packet from privileged peer? */
X	int	(*af_checkhost)();	/* tells if address is valid */
X	int	(*af_rtflags)();	/* get flags for route (host or net) */
X	int	(*af_sendroute)();	/* check bounds of subnet broadcast */
X	int	(*af_canon)();		/* canonicalize address for compares */
X	char	*(*af_format)();	/* convert address to string */
};
X
/*
X * Structure returned by af_hash routines.
X */
struct afhash {
X	u_int	afh_hosthash;		/* host based hash */
X	u_int	afh_nethash;		/* network based hash */
};
X
struct	rd_afswitch rd_afswitch[];	/* table proper */
int	af_max;				/* number of entries in table */
SHAR_EOF
  $shar_touch -am 1116154093 'vxrouted_5.1.1/af.h' &&
  chmod 0644 'vxrouted_5.1.1/af.h' ||
  echo 'restore of vxrouted_5.1.1/af.h failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/af.h'`"
  test 1814 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/af.h: original size 1814, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/ctime.c ==============
if test -f 'vxrouted_5.1.1/ctime.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/ctime.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/ctime.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/ctime.c' &&
/*
X * Copyright (c) 1987 Regents of the University of California.
X * All rights reserved.
X *
X * This code is derived from software contributed to Berkeley by
X * Arthur Olson.
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[] = "@(#)ctime.c	5.14 (Berkeley) 7/6/88";
#endif /* LIBC_SCCS and not lint */
X
#include <vxWorks.h>
#include <types.h>
#include "ctime.h"
/* #include "sys/param.h" */
#include <systime.h>
#include "tzfile.h"
X
#define     MAXPATHLEN      1024
X
char *
ctime(t)
time_t *t;
{
X	struct tm	*localtime();
X	char	*asctime();
X
X	return(asctime(localtime(t)));
}
X
/*
** A la X3J11
*/
X
char *
asctime(timeptr)
register struct tm *	timeptr;
{
X	static char	wday_name[DAYS_PER_WEEK][3] = {
X		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
X	};
X	static char	mon_name[MONS_PER_YEAR][3] = {
X		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
X		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
X	};
X	static char	result[26];
X
X	(void) sprintf(result, "%.3s %.3s%3d %02d:%02d:%02d %d\n",
X		wday_name[timeptr->tm_wday],
X		mon_name[timeptr->tm_mon],
X		timeptr->tm_mday, timeptr->tm_hour,
X		timeptr->tm_min, timeptr->tm_sec,
X		TM_YEAR_BASE + timeptr->tm_year);
X	return result;
}
X
#ifndef TRUE
#define TRUE		1
#define FALSE		0
#endif /* !TRUE */
X
extern char *		getenv();
extern char *		strcpy();
extern char *		strcat();
struct tm *		offtime();
X
struct ttinfo {				/* time type information */
X	long		tt_gmtoff;	/* GMT offset in seconds */
X	int		tt_isdst;	/* used to set tm_isdst */
X	int		tt_abbrind;	/* abbreviation list index */
};
X
struct state {
X	int		timecnt;
X	int		typecnt;
X	int		charcnt;
X	time_t		ats[TZ_MAX_TIMES];
X	unsigned char	types[TZ_MAX_TIMES];
X	struct ttinfo	ttis[TZ_MAX_TYPES];
X	char		chars[TZ_MAX_CHARS + 1];
};
X
static struct state	cs;
X
static int		tz_is_set;
X
char *			tzname[2] = {
X	"GMT",
X	"GMT"
};
X
#ifdef USG_COMPAT
time_t			timezone = 0;
int			daylight = 0;
#endif /* USG_COMPAT */
X
static long
detzcode(codep)
char *	codep;
{
X	register long	result;
X	register int	i;
X
X	result = 0;
X	for (i = 0; i < 4; ++i)
X		result = (result << 8) | (codep[i] & 0xff);
X	return result;
}
X
#ifdef	USE_TZ
static
tzload(name)
register char *	name;
{
X	register int	i;
X	register int	fid;
X
X	if (name == 0 && (name = TZDEFAULT) == 0)
X		return -1;
X	{
X		register char *	p;
X		register int	doaccess;
X		char		fullname[MAXPATHLEN];
X
X		doaccess = name[0] == '/';
X		if (!doaccess) {
X			if ((p = TZDIR) == 0)
X				return -1;
X			if ((strlen(p) + strlen(name) + 1) >= sizeof fullname)
X				return -1;
X			(void) strcpy(fullname, p);
X			(void) strcat(fullname, "/");
X			(void) strcat(fullname, name);
X			/*
X			** Set doaccess if '.' (as in "../") shows up in name.
X			*/
X			while (*name != '\0')
X				if (*name++ == '.')
X					doaccess = TRUE;
X			name = fullname;
X		}
/*		if (doaccess && access(name, 4) != 0) */
/*			return -1; */
X		if ((fid = open(name, 0)) == -1)
X			return -1;
X	}
X	{
X		register char *			p;
X		register struct tzhead *	tzhp;
X		char				buf[sizeof s];
X
X		i = read(fid, buf, sizeof buf);
X		if (close(fid) != 0 || i < sizeof *tzhp)
X			return -1;
X		tzhp = (struct tzhead *) buf;
X		cs.timecnt = (int) detzcode(tzhp->tzh_timecnt);
X		cs.typecnt = (int) detzcode(tzhp->tzh_typecnt);
X		cs.charcnt = (int) detzcode(tzhp->tzh_charcnt);
X		if (cs.timecnt > TZ_MAX_TIMES ||
X			cs.typecnt == 0 ||
X			cs.typecnt > TZ_MAX_TYPES ||
X			cs.charcnt > TZ_MAX_CHARS)
X				return -1;
X		if (i < sizeof *tzhp +
X			cs.timecnt * (4 + sizeof (char)) +
X			cs.typecnt * (4 + 2 * sizeof (char)) +
X			cs.charcnt * sizeof (char))
X				return -1;
X		p = buf + sizeof *tzhp;
X		for (i = 0; i < cs.timecnt; ++i) {
X			cs.ats[i] = detzcode(p);
X			p += 4;
X		}
X		for (i = 0; i < cs.timecnt; ++i)
X			cs.types[i] = (unsigned char) *p++;
X		for (i = 0; i < cs.typecnt; ++i) {
X			register struct ttinfo *	ttisp;
X
X			ttisp = &cs.ttis[i];
X			ttisp->tt_gmtoff = detzcode(p);
X			p += 4;
X			ttisp->tt_isdst = (unsigned char) *p++;
X			ttisp->tt_abbrind = (unsigned char) *p++;
X		}
X		for (i = 0; i < cs.charcnt; ++i)
X			cs.chars[i] = *p++;
X		cs.chars[i] = '\0';	/* ensure '\0' at end */
X	}
X	/*
X	** Check that all the local time type indices are valid.
X	*/
X	for (i = 0; i < cs.timecnt; ++i)
X		if (cs.types[i] >= cs.typecnt)
X			return -1;
X	/*
X	** Check that all abbreviation indices are valid.
X	*/
X	for (i = 0; i < cs.typecnt; ++i)
X		if (cs.ttis[i].tt_abbrind >= cs.charcnt)
X			return -1;
X	/*
X	** Set tzname elements to initial values.
X	*/
X	tzname[0] = tzname[1] = &cs.chars[0];
#ifdef USG_COMPAT
X	timezone = -cs.ttis[0].tt_gmtoff;
X	daylight = 0;
#endif /* USG_COMPAT */
X	for (i = 1; i < cs.typecnt; ++i) {
X		register struct ttinfo *	ttisp;
X
X		ttisp = &cs.ttis[i];
X		if (ttisp->tt_isdst) {
X			tzname[1] = &cs.chars[ttisp->tt_abbrind];
#ifdef USG_COMPAT
X			daylight = 1;
#endif /* USG_COMPAT */ 
X		} else {
X			tzname[0] = &cs.chars[ttisp->tt_abbrind];
#ifdef USG_COMPAT
X			timezone = -ttisp->tt_gmtoff;
#endif /* USG_COMPAT */ 
X		}
X	}
X	return 0;
}
X
static
tzsetkernel()
{
X	struct timeval	tv;
X	struct timezone	tz;
X	char	*_tztab();
X
X	if (gettimeofday(&tv, &tz))
X		return -1;
X	cs.timecnt = 0;		/* UNIX counts *west* of Greenwich */
X	cs.ttis[0].tt_gmtoff = tz.tz_minuteswest * -SECS_PER_MIN;
X	cs.ttis[0].tt_abbrind = 0;
X	(void)strcpy(cs.chars, _tztab(tz.tz_minuteswest, 0));
X	tzname[0] = tzname[1] = cs.chars;
#ifdef USG_COMPAT
X	timezone = tz.tz_minuteswest * 60;
X	daylight = tz.tz_dsttime;
#endif /* USG_COMPAT */
X	return 0;
}
X
static
tzsetgmt()
{
X	cs.timecnt = 0;
X	cs.ttis[0].tt_gmtoff = 0;
X	cs.ttis[0].tt_abbrind = 0;
X	(void) strcpy(cs.chars, "GMT");
X	tzname[0] = tzname[1] = cs.chars;
#ifdef USG_COMPAT
X	timezone = 0;
X	daylight = 0;
#endif /* USG_COMPAT */
}
X
void
tzset()
{
X	register char *	name;
X
X	tz_is_set = TRUE;
X	name = getenv("TZ");
X	if (!name || *name) {			/* did not request GMT */
X		if (name && !tzload(name))	/* requested name worked */
X			return;
X		if (!tzload((char *)0))		/* default name worked */
X			return;
X		if (!tzsetkernel())		/* kernel guess worked */
X			return;
X	}
X	tzsetgmt();				/* GMT is default */
}
#endif	USE_TZ
X
struct tm *
localtime(timep)
time_t *	timep;
{
X	register struct ttinfo *	ttisp;
X	register struct tm *		tmp;
X	register int			i;
X	time_t				t;
X
/*	if (!tz_is_set)
X		(void) tzset(); */
X	t = *timep;
X	if (cs.timecnt == 0 || t < cs.ats[0]) {
X		i = 0;
X		while (cs.ttis[i].tt_isdst)
X			if (++i >= cs.timecnt) {
X				i = 0;
X				break;
X			}
X	} else {
X		for (i = 1; i < cs.timecnt; ++i)
X			if (t < cs.ats[i])
X				break;
X		i = cs.types[i - 1];
X	}
X	ttisp = &cs.ttis[i];
X	/*
X	** To get (wrong) behavior that's compatible with System V Release 2.0
X	** you'd replace the statement below with
X	**	tmp = offtime((time_t) (t + ttisp->tt_gmtoff), 0L);
X	*/
X	tmp = offtime(&t, ttisp->tt_gmtoff);
X	tmp->tm_isdst = ttisp->tt_isdst;
X	tzname[tmp->tm_isdst] = &cs.chars[ttisp->tt_abbrind];
X	tmp->tm_zone = &cs.chars[ttisp->tt_abbrind];
X	return tmp;
}
X
struct tm *
gmtime(clock)
time_t *	clock;
{
X	register struct tm *	tmp;
X
X	tmp = offtime(clock, 0L);
X	tzname[0] = "GMT";
X	tmp->tm_zone = "GMT";		/* UCT ? */
X	return tmp;
}
X
static int	mon_lengths[2][MONS_PER_YEAR] = {
X	31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
X	31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
X
static int	year_lengths[2] = {
X	DAYS_PER_NYEAR, DAYS_PER_LYEAR
};
X
struct tm *
offtime(clock, offset)
time_t *	clock;
long		offset;
{
X	register struct tm *	tmp;
X	register long		days;
X	register long		rem;
X	register int		y;
X	register int		yleap;
X	register int *		ip;
X	static struct tm	tm;
X
X	tmp = &tm;
X	days = *clock / SECS_PER_DAY;
X	rem = *clock % SECS_PER_DAY;
X	rem += offset;
X	while (rem < 0) {
X		rem += SECS_PER_DAY;
X		--days;
X	}
X	while (rem >= SECS_PER_DAY) {
X		rem -= SECS_PER_DAY;
X		++days;
X	}
X	tmp->tm_hour = (int) (rem / SECS_PER_HOUR);
X	rem = rem % SECS_PER_HOUR;
X	tmp->tm_min = (int) (rem / SECS_PER_MIN);
X	tmp->tm_sec = (int) (rem % SECS_PER_MIN);
X	tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYS_PER_WEEK);
X	if (tmp->tm_wday < 0)
X		tmp->tm_wday += DAYS_PER_WEEK;
X	y = EPOCH_YEAR;
X	if (days >= 0)
X		for ( ; ; ) {
X			yleap = isleap(y);
X			if (days < (long) year_lengths[yleap])
X				break;
X			++y;
X			days = days - (long) year_lengths[yleap];
X		}
X	else do {
X		--y;
X		yleap = isleap(y);
X		days = days + (long) year_lengths[yleap];
X	} while (days < 0);
X	tmp->tm_year = y - TM_YEAR_BASE;
X	tmp->tm_yday = (int) days;
X	ip = mon_lengths[yleap];
X	for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon))
X		days = days - (long) ip[tmp->tm_mon];
X	tmp->tm_mday = (int) (days + 1);
X	tmp->tm_isdst = 0;
X	tmp->tm_zone = "";
X	tmp->tm_gmtoff = offset;
X	return tmp;
}
SHAR_EOF
  $shar_touch -am 1116144593 'vxrouted_5.1.1/ctime.c' &&
  chmod 0644 'vxrouted_5.1.1/ctime.c' ||
  echo 'restore of vxrouted_5.1.1/ctime.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/ctime.c'`"
  test 9218 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/ctime.c: original size 9218, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/ctime.h ==============
if test -f 'vxrouted_5.1.1/ctime.h' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/ctime.h (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/ctime.h (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/ctime.h' &&
/*	@(#)time.h 1.12 89/06/25 SMI; not from UCB */
X
#ifndef	__time_h
#define	__time_h
X
/*
X * Structure returned by gmtime and localtime calls (see ctime(3)).
X */
struct	tm {
X	int	tm_sec;
X	int	tm_min;
X	int	tm_hour;
X	int	tm_mday;
X	int	tm_mon;
X	int	tm_year;
X	int	tm_wday;
X	int	tm_yday;
X	int	tm_isdst;
X	char	*tm_zone;
X	long	tm_gmtoff;
};
X
extern	struct tm *gmtime(), *localtime();
extern	char *asctime(), *ctime();
extern	void tzset(), tzsetwall();
extern  int dysize();
extern  time_t timelocal(), timegm();
X
#endif	/* !__time_h */
SHAR_EOF
  $shar_touch -am 1111121693 'vxrouted_5.1.1/ctime.h' &&
  chmod 0644 'vxrouted_5.1.1/ctime.h' ||
  echo 'restore of vxrouted_5.1.1/ctime.h failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/ctime.h'`"
  test 527 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/ctime.h: original size 527, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/defs.h ==============
if test -f 'vxrouted_5.1.1/defs.h' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/defs.h (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/defs.h (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/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 */
#define __PROTOTYPE_5_0
#define INCLUDE_ANSI_5_0
X
#include <vxWorks.h>
/* #include <sys/param.h> */
#include <socket.h>
#include <systime.h>
#include <taskLib.h>
X
#include <net/route.h>
#include <in.h>
#include "routed.h"
X
#include <stdioLib.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	rs;			/* 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 *svsp; */
X
extern	char *sys_errlist[];
extern	int errno;
X
struct	in_addr inet_makeaddr();
/* int	inet_addr(); */
/* char	*malloc(); */
char	*ctime();
/* int	exit(); */
int	rd_sendmsg();
int	supply();
int	timer();
int	cleanup();
X
/* between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates */
#define MIN_WAITTIME            2       /* min. interval to broadcast changes */
#define MAX_WAITTIME            5       /* max. time to delay changes */
SHAR_EOF
  $shar_touch -am 0712065594 'vxrouted_5.1.1/defs.h' &&
  chmod 0644 'vxrouted_5.1.1/defs.h' ||
  echo 'restore of vxrouted_5.1.1/defs.h failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/defs.h'`"
  test 2882 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/defs.h: original size 2882, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/if.c ==============
if test -f 'vxrouted_5.1.1/if.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/if.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/if.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/if.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[] = "@(#)if.c	5.5 (Berkeley) 6/18/88";
#endif /* not lint */
X
/*
X * Routing Table Management Daemon
X */
#include "defs.h"
X
extern	struct interface *rd_ifnet;
X
/*
X * Find the interface with address addr.
X */
struct interface *
if_ifwithaddr(addr)
X	struct sockaddr *addr;
{
X	register struct interface *ifp;
X
#define	same(a1, a2) \
X	(bcmp((caddr_t)((a1)->sa_data), (caddr_t)((a2)->sa_data), 14) == 0)
X	for (ifp = rd_ifnet; ifp; ifp = ifp->int_next) {
X		if (ifp->int_flags & IFF_REMOTE)
X			continue;
X		if (ifp->int_addr.sa_family != addr->sa_family)
X			continue;
X		if (same(&ifp->int_addr, addr))
X			break;
X		if ((ifp->int_flags & IFF_BROADCAST) &&
X		    same(&ifp->int_broadaddr, addr))
X			break;
X	}
X	return (ifp);
}
X
/*
X * Find the point-to-point interface with destination address addr.
X */
struct interface *
if_ifwithdstaddr(addr)
X	struct sockaddr *addr;
{
X	register struct interface *ifp;
X
X	for (ifp = rd_ifnet; ifp; ifp = ifp->int_next) {
X		if ((ifp->int_flags & IFF_POINTOPOINT) == 0)
X			continue;
X		if (same(&ifp->int_dstaddr, addr))
X			break;
X	}
X	return (ifp);
}
X
/*
X * Find the interface on the network 
X * of the specified address.
X */
struct interface *
if_ifwithnet(addr)
X	register struct sockaddr *addr;
{
X	register struct interface *ifp;
X	register int af = addr->sa_family;
X	register int (*netmatch)();
X
X	if (af >= af_max)
X		return (0);
X	netmatch = rd_afswitch[af].af_netmatch;
X	for (ifp = rd_ifnet; ifp; ifp = ifp->int_next) {
X		if (ifp->int_flags & IFF_REMOTE)
X			continue;
X		if (af != ifp->int_addr.sa_family)
X			continue;
X		if ((*netmatch)(addr, &ifp->int_addr))
X			break;
X	}
X	return (ifp);
}
X
/*
X * Find an interface from which the specified address
X * should have come from.  Used for figuring out which
X * interface a packet came in on -- for tracing.
X */
struct interface *
if_iflookup(addr)
X	struct sockaddr *addr;
{
X	register struct interface *ifp, *maybe;
X	register int af = addr->sa_family;
X	register int (*netmatch)();
X
X	if (af >= af_max)
X		return (0);
X	maybe = 0;
X	netmatch = rd_afswitch[af].af_netmatch;
X	for (ifp = rd_ifnet; ifp; ifp = ifp->int_next) {
X		if (ifp->int_addr.sa_family != af)
X			continue;
X		if (same(&ifp->int_addr, addr))
X			break;
X		if ((ifp->int_flags & IFF_BROADCAST) &&
X		    same(&ifp->int_broadaddr, addr))
X			break;
X		if ((ifp->int_flags & IFF_POINTOPOINT) &&
X		    same(&ifp->int_dstaddr, addr))
X			break;
X		if (maybe == 0 && (*netmatch)(addr, &ifp->int_addr))
X			maybe = ifp;
X	}
X	if (ifp == 0)
X		ifp = maybe;
X	return (ifp);
}
SHAR_EOF
  $shar_touch -am 1116155393 'vxrouted_5.1.1/if.c' &&
  chmod 0644 'vxrouted_5.1.1/if.c' ||
  echo 'restore of vxrouted_5.1.1/if.c failed'
  shar_count="`wc -c < 'vxrouted_5.1.1/if.c'`"
  test 3332 -eq "$shar_count" ||
    echo "vxrouted_5.1.1/if.c: original size 3332, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= vxrouted_5.1.1/query.c ==============
if test -f 'vxrouted_5.1.1/query.c' && test X"$1" != X"-c"; then
  echo 'x - skipping vxrouted_5.1.1/query.c (File already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting vxrouted_5.1.1/query.c (Text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vxrouted_5.1.1/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
static char sccsid[] = "@(#)query.c	5.9 (Berkeley) 6/11/88";
#endif /* not lint */
X
#define __PROTOTYPE_5_0
#define INCLUDE_ANSI_5_0
X
#include <vxWorks.h>
/* #include <sys/param.h> */
#include <net/protosw.h>
#include <socket.h>
#include <systime.h>
#include <in.h>
#include <errno.h>
#include <stdioLib.h>
#include <netdb.h>
#include <routed.h>
#include <sigLib.h>
#include <hostLib.h>
#include <inetLib.h>
#include <taskLib.h>
X
#define	WTIME	5		/* Time to wait for all responses */
#define	STIME	500000		/* usec to wait for another response */
X
int	qs;
int	timedout, timeout();
char	packet[MAXPACKETSIZE];
extern int errno;
int	nflag;
X
char	ntoa[INET_ADDR_LEN];
X
#define MAX_ARGS 6
char *xqargv[MAX_ARGS];
/* "query_","-n","host1","host2","host3","host4","host5" */
int xqargc;
char a0qx[] = "query_";
char a1qx[5] = "\0";
char a2qx[30] = "\0";
char a3qx[30] = "\0";
char a4qx[30] = "\0";
char a5qx[30] = "\0";
X
query_();
X
query(arg1,arg2,arg3,arg4,arg5)
X	char *arg1;
X	char *arg2;
X	char *arg3;
X	char *arg4;
X	char *arg5;
{
X	xqargc = 1;
X	xqargv[0] = a0qx;
X
X	if(*arg1 != '\0') {
X		strcpy(a1qx,arg1);
X		xqargv[xqargc] = a1qx;
X		xqargc++;
X	}
X	if(*arg2 != '\0') {
X		strcpy(a2qx,arg2);
X		xqargv[xqargc] = a2qx;
X		xqargc++;
X	}
X	if(*arg3 != '\0') {
X		strcpy(a3qx,arg3);
X		xqargv[xqargc] = a3qx;
X		xqargc++;
X	}
X	if(*arg4 != '\0') {
X		strcpy(a4qx,arg4);
X		xqargv[xqargc] = a4qx;
X		xqargc++;
X	}
X	if(*arg5 != '\0') {
X		strcpy(a5qx,arg5);
X		xqargv[xqargc] = a5qx;
X		xqargc++;
X	}
X
X	taskSpawn("tquery",250,VX_STDIO,5000,query_,xqargc,xqargv);
}
X
query_(argc, argv)
X	int argc;
X	char *argv[];
{
X	int cc, count = 0, bits;
X	struct sockaddr from;
X	int fromlen = sizeof(from), size = 32*1024;
X	struct timeval shorttime;
X	
/*	printf(" query_ argc = %d  argv = 0x%x\n",argc,argv);
X	for(;argc;argc--)
X		printf(" query_ cmd %s\n",*argv++);
X	taskDelay(sysClkRateGet()*2);
X	return; */
X
X	if (argc < 2) {
usage:
X		printf("usage: query [ -n ] hosts...\n");
X		exit(1);
X	}
X	qs = socket(AF_INET, SOCK_DGRAM, 0);
X	if (qs < 0) {
X		perror("socket");
X		exit(2);
X	}
X	if (setsockopt(qs, 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 << qs;
X	bzero(&shorttime, sizeof(shorttime));
X	shorttime.tv_usec = STIME;
/*	signal(SIGALRM, timeout); */
X	alarm(WTIME);
X	while ((count > 0 && !timedout) ||
X	    select(20, &bits, 0, 0, &shorttime) > 0) {
X		cc = recvfrom(qs, 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(qs);
X				exit(1);
X			}
X			continue;
X		}
X		qrip_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;
/*	struct hostent *hp; */
X	int hp;
/*	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 = hostGetByName(host);
X		if (hp == ERROR) {
X			printf("%s: unknown\n", host);
X			exit(1);
X		}
X		bcopy((char *)&hp, &router.sin_addr, sizeof(hp));
X	}
/*	sp = getservbyname("router", "udp");
X	if (sp == 0) {
X		printf("udp/router: service unknown\n");
X		exit(1);
X	} */
X	router.sin_port = htons(520);
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(qs, packet, sizeof (struct rip), 0,
X	  &router, sizeof(router)) < 0)
X		perror(host);
}
X
/*
X * Handle an incoming routing packet.
X */
qrip_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 hname[MAXHOSTNAMELEN + 1];
X	char *name;
X	int lna, net, subnet;
/*	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		inet_ntoa_b(from->sin_addr,ntoa);
X		printf("%s:\n", ntoa);
X	}
X	else {
/*		hp = gethostbyaddr(&from->sin_addr, sizeof (struct in_addr),
X			AF_INET);
X		name = hp == 0 ? "???" : hp->h_name; */
X		if(hostGetByAddr(from->sin_addr,hname) == ERROR)
X			name = hname;
X		else
X			name = "???";
X		inet_ntoa_b(from->sin_addr,ntoa);
X		printf("%s(%s):\n", name, ntoa);
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 = rd_inet_lnaof(sin->sin_addr);
X		name = "???";
X		if (!nflag) {
X			if (sin->sin_addr.s_addr == 0)
X				name = "default";
/*			else if (lna == INADDR_ANY) {
X				np = getnetbyaddr(net, AF_INET);
SHAR_EOF
  : || echo 'restore of vxrouted_5.1.1/query.c failed'
fi
echo 'End of archive part 1'
echo 'File vxrouted_5.1.1/query.c is continued in part 2'
echo 2 > _sharseq.tmp
exit 0
