bobs@randvax.UUCP (Rober Schwartzkopf) (02/14/91)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 2 (of 2)." # Contents: aarpd.c getaa.c aarpd.8 kboot.8 aarpd.h appletalk.h # config.h kbox.h patchlevel.h cmdidx.h kboot.h Makefile README # Wrapped by bobs@chumley on Wed Feb 13 22:14:59 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'aarpd.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'aarpd.c'\" else echo shar: Extracting \"'aarpd.c'\" \(7348 characters\) sed "s/^X//" >'aarpd.c' <<'END_OF_FILE' X#ifndef lint Xstatic char *RCSid="$Header: /tmp_mnt/home/src/rand/etc/kboot/RCS/aarpd.c,v 1.1 91/01/29 17:36:55 root Exp $"; X#endif lint X X/* X * $Log: aarpd.c,v $ X * Revision 1.1 91/01/29 17:36:55 root X * Initial revision X * X */ X X/* X * aarpd - Appletalk ARP daemon. Obtain an appletalk protocol address, X * then listen forever, responding to any appletalk probes and X * requests sent to us. Depends on SunOS 4.x NIT interface. X * X * Author: Bob Schwartzkopf, The RAND Corporation. Based on an earlier X * version written by Dan Tappan at BBN that ran under SunOS 3.x. X * X * Comments, suggestions, patches, bug reports, etc. may be sent to X * bobs@rand.org. X */ X X#include <stdio.h> X#include <syslog.h> X#include <sys/types.h> X#include <sys/errno.h> X#include <sys/socket.h> X#include <sys/fcntl.h> X#include <sys/termios.h> X#include <net/if.h> X#include <netinet/in.h> X#include <netinet/if_ether.h> X#include <rpc/rpc.h> X#include <sys/time.h> X#include <sys/timeb.h> X#include "appletalk.h" X#include "aarpd.h" X#include "config.h" X#include "patchlevel.h" X Xextern char *rindex (); Xint aarp_read (); X Xextern struct ether_addr myether; /* Setup by nit_init */ Xextern int errno; Xextern char *sys_errlist[]; X X#define VERSION 2 X X/* X * Globals. X */ Xchar *progname; Xchar *interface = NULL; Xstruct ether_addr ebc = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; Xlong atalkaddr; /* Current appletalk address */ Xint haveaddr = 0; /* Have appletalk address */ Xint conflict; /* We're in confict with someone*/ Xint detached = 0; /* Detached from tty */ Xint debug = 0; /* Debugging */ Xstruct ether_header eh; /* Output ethernet header */ Xstruct ether_aarp ap; /* Output packet */ X Xmain (argc, argv) X Xint argc; Xchar **argv; X X{ X char c; X int i; X X if ((progname = rindex (argv[0], '/')) == NULL) X progname = *argv; X else X progname++; X while (--argc > 0) { X argv++; X c = (*argv)[0] == '-' ? (*argv)[1] : (*argv)[0]; X switch (c) { X case 'd' : X debug++; X break; X case 'i' : X if (argc <= 1) X usage (); X argv++; X argc--; X interface = *argv; X break; X case 'v' : X printf ("%s version number %d.%d\n", progname, VERSION, PATCHLEVEL); X exit (0); X default : X usage (); X } X } X if (!debug) { /* Detach ourselves */ X detached++; X if (fork ()) X exit (0); X if ((i = open ("/dev/tty", O_RDONLY)) >= 0) X ioctl (i, TIOCNOTTY, 0); X i = getdtablesize (); X while (--i >= 0) X close (i); X open ("/dev/null", 0); X dup2 (0, 1); X dup2 (0, 2); X openlog (progname, 0, LOG_DAEMON); X } X nit_init (interface); X nit_open (sizeof (ap) + sizeof (eh), AARP); X aarp_probe (); /* Get appletalk address */ X initrpc (); /* Prepare for RPC */ X ap.aarp_op = htons (AARPResp); /* Set up for sending replies */ X nit_dispatch (aarp_read, 0, &svc_fdset, svc_getreqset, NULL); X} X X/* X * usage - Print usage and die. X */ Xusage () X X{ X fprintf (stderr, "Usage: %s [-d] [-i interface]\n", progname); X exit (1); X} X X/* X * aarp_probe - Get unused appletalk address. Algorithm is to try each X * in turn, probing to see if anyone else is using each address. When X * no one answers a probe, we use that address. Note this routine X * initializes some global data structures (eh, ap), parts of which are X * used later by aarp_read (). X */ Xaarp_probe () X X{ X u_long spa; X int i; X struct timeval timeout; X struct timeb tstart; X struct timeb tcur; X int utotal; X int ucur; X X /* Init ether header */ X ether_copy (&ebc, &eh.ether_dhost); X ether_copy (&myether, &eh.ether_shost); X eh.ether_type = htons (AARP); X /* Init aarp header */ X ap.aarp_hrd = htons (H_Ethernet); X ap.aarp_pro = htons (P_AppleTalk); X ap.aarp_hln = HL_Ethernet; X ap.aarp_pln = PL_AppleTalk; X ap.aarp_op = htons (AARPProbe); X ether_copy (&myether, &ap.aarp_sha); X bzero (&ap.aarp_tha, HL_Ethernet); X nit_timeout (APrbTicks, &timeout); X utotal = timeout.tv_sec * 1000000 + timeout.tv_usec; X for (atalkaddr = 1; atalkaddr < 254; atalkaddr++) { X spa = htonl (atalkaddr); X bcopy (&spa, ap.aarp_spa, PL_AppleTalk); X bcopy (&spa, ap.aarp_tpa, PL_AppleTalk); X conflict = 0; X for (i = 0; !conflict && i < APrbTries; i++) { X nit_write ((caddr_t) &eh, (caddr_t) &ap, sizeof ap); X ftime (&tstart); X do { X nit_dispatch (aarp_read, 1, NULL, NULL, &timeout); X ftime (&tcur); X ucur = (tcur.time - tstart.time) * 1000000 + X (tcur.millitm - tstart.millitm) * 1000; X } while (!conflict && utotal > ucur); X } X if (!conflict) { X if (debug) X fprintf (stderr, "aarp_probe: Using appletalk address %d\n", X atalkaddr); X break; X } X } X if (conflict) { X logerr ("aarp_probe: Couldn't find appletalk address, exiting...\n"); X exit (1); X } X haveaddr++; X} X X/* X * aarp_read - Handle AARP response packets. X */ Xaarp_read (p, pl) X Xstruct aarp_packet *p; Xint pl; X X{ X int op; X long spa; X long tpa; X X if (pl != sizeof (*p)) { X if (debug) X fprintf (stderr, "aarp_read: Truncated packet len %d\n", pl); X return; X } X op = ntohs (p->ap_op); X bcopy ((caddr_t) p->ap_spa, &spa, PL_AppleTalk); X spa = ntohl (spa); X switch (op) { X case AARPProbe : X case AARPReq : X bcopy ((caddr_t) p->ap_tpa, &tpa, PL_AppleTalk); X tpa = ntohl (tpa); X if (haveaddr && tpa == atalkaddr) { X /* X * Most of the output header and packet (eh, ap) should already be X * set up since it was used for probing initially. Should only need X * to fill in destination addresses. X */ X ether_copy (&p->ap_sha, &eh.ether_dhost); X ether_copy (&p->ap_sha, &ap.aarp_tha); X bcopy (p->ap_spa, ap.aarp_tpa, PL_AppleTalk); X if (debug) { X fprintf (stderr, "aarp_read: Replying to %s from %d (%s)\n", X op == AARPProbe ? "probe" : "request", X spa, ether_ntoa (&p->ap_sha)); X } X nit_write ((caddr_t) &eh, (caddr_t) &ap, sizeof ap); X } X break; X X case AARPResp : X if (debug) X fprintf (stderr, "aarp_read: Reply from %d (%s)\n", X spa, ether_ntoa (&p->ap_sha)); X if (!haveaddr && spa == atalkaddr) X conflict++; X break; X X default : X logerr ("aarp_read: Unknown AARP operation %d\n", op); X } X} X X/* X * getaa - Return appletalk address for this host. X */ Xgetaa (request, xprt) X Xstruct svc_req *request; XSVCXPRT *xprt; X X{ X struct sockaddr_in *sa; X X if (debug) { X sa = svc_getcaller (xprt); X fprintf (stderr, "getaa: Returning %d to %s\n", X atalkaddr, inet_ntoa (sa->sin_addr)); X } X switch (request->rq_proc) { X case NULLPROC: X if (!svc_sendreply (xprt, xdr_void, 0)) { X logerr ("getaa(NULLPROC): svc_sendreply failed\n"); X exit (1); X } X break; X X case GETAAPROC: X if (!svc_sendreply (xprt, xdr_u_long, (caddr_t) &atalkaddr)) { X logerr ("getaa(GETAAPROC): svc_sendreply failed\n"); X exit (1); X } X break; X X default: X svcerr_noproc (xprt); X break; X } X} X X/* X * Initialize RPC stuff. X */ Xinitrpc () X X{ X SVCXPRT *xprt; X X if ((xprt = svcudp_create (RPC_ANYSOCK)) == NULL) { X logerr ("initrpc: svcudp_create failed\n"); X exit (1); X } X pmap_unset (GETAAPROG, GETAAVERS); X if (!svc_register (xprt, GETAAPROG, GETAAVERS, getaa, IPPROTO_UDP)) { X logerr ("initrpc: Can't register %d %d\n", GETAAPROG, GETAAVERS); X exit (1); X } X} END_OF_FILE if test 7348 -ne `wc -c <'aarpd.c'`; then echo shar: \"'aarpd.c'\" unpacked with wrong size! fi # end of 'aarpd.c' fi if test -f 'getaa.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getaa.c'\" else echo shar: Extracting \"'getaa.c'\" \(787 characters\) sed "s/^X//" >'getaa.c' <<'END_OF_FILE' X#ifndef lint Xstatic char *RCSid="$Header: /tmp_mnt/home/src/rand/etc/kboot/RCS/getaa.c,v 1.1 91/01/29 17:37:21 root Exp $"; X#endif lint X X/* X * $Log: getaa.c,v $ X * Revision 1.1 91/01/29 17:37:21 root X * Initial revision X * X */ X X#include <stdio.h> X#include <rpc/rpc.h> X#include "aarpd.h" X X/* X * getaa - Return appletalk address of "host". If host is NULL get X * local host address. Makes RPC call to aarpd on host. X */ Xint getaa (host, aa) X Xchar *host; Xint *aa; X X{ X int i; X int s; X X if (host == NULL) X host = "localhost"; X/* X * Give aarpd a chance to register with portmap... X */ X for (i = 0; i < 3; i++) X if ((s = callrpc (host, GETAAPROG, GETAAVERS, GETAAPROC, X xdr_void, 0, xdr_u_long, aa)) == 0) X break; X else X sleep (2); X return (s); X} END_OF_FILE if test 787 -ne `wc -c <'getaa.c'`; then echo shar: \"'getaa.c'\" unpacked with wrong size! fi # end of 'getaa.c' fi if test -f 'aarpd.8' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'aarpd.8'\" else echo shar: Extracting \"'aarpd.8'\" \(888 characters\) sed "s/^X//" >'aarpd.8' <<'END_OF_FILE' X.TH aarpd 8 "25 October 90" X.SH NAME Xaarpd \- Appletalk Arp daemon. X.SH SYNOPSIS X.I Xaarpd X.B [-d] X.B [-i interface] X.B [-v] X.SH DESCRIPTION X.I aarpd Ximplements the Appletalk Arp protocol on a unix host. It obtains an XAppletalk node number, and then listens and replies to other nodes Xtrying to find out if this node number is in use. X.LP XOther processes on the host (eg kboot) can obtain the node number for Xthis host via an RPC call. X.SH OPTIONS X.TP X.B \-d XTurn on debugging. X.TP X.B \-i interface XSpecify interface name (eg ie1). Defaults to first interface in kernel. X.TP X.B \-v XPrint aarpd version number. X.SH "SEE ALSO" Xkboot(8), nit(4) X.SH BUGS X.I aarpd Xdepends on the SunOS 4\.x NIT interface and probably isn't very portable. X.SH AUTHOR XBob Schwartzkopf, The RAND Corporation. Much credit is due Dan Tappan Xof BBN, who wrote the first version of X.I kboot Xthat ran on SunOS 3.x. END_OF_FILE if test 888 -ne `wc -c <'aarpd.8'`; then echo shar: \"'aarpd.8'\" unpacked with wrong size! fi # end of 'aarpd.8' fi if test -f 'kboot.8' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'kboot.8'\" else echo shar: Extracting \"'kboot.8'\" \(3803 characters\) sed "s/^X//" >'kboot.8' <<'END_OF_FILE' X.TH kboot 8 "25 October 90" X.SH NAME Xkboot - Monitor and reboot Fastpath 4 gateways. X.SH SYNOPSIS X.I kboot X.B [-bclrs fastpath] X.B [-d] X.B [-i interface] X.B [-p int] X.B [-t fastpath [server]] X.B [-v] X.B [-w] X.SH DESCRIPTION X.I kboot Xis a program that can monitor, load and configure Kinetics/Shiva Fastpath 4 Xgateways over an ethernet from a Sun running SunOS 4.x. X.LP X.I kboot Xwill only talk to fastpaths specified in the configuration file X/usr/local/etc/kbootcf. The format of this file is simply the hostname Xof each fastpath, followed by white space and the name of the KSTAR Xsoftware to be downloaded in the event that kboot reloads the fastpath. XThe KSTAR program filename in the configuration file should be relative to Xthe directory where the configuration file is, by default this is X/usr/local/etc. X.LP X.I kboot Xgets an appletalk node number from a separate daemon called aarpd(8) via Xan RPC call. aarpd must be running for X.I kboot Xto work. X.LP X.I kboot Xreads the fastpath's ethernet address from /etc/ethers (or equivalent XNIS map), each fastpath managed by X.I kboot Xmust have its correct ethernet address in that file. X.LP XEach configured fastpath should have a corresponding state file. These Xcan be obtained in one of two ways. They can be generated using the Xfastpath manager program on a Mac, in which case they should be transferred Xto the file /usr/local/etc/<fastpath>.config on the host X.I kboot Xis running on. Alternatively, the current state vector of a fastpath Xcan be read directly from the fastpath using the \-s option of X.I kboot. XIn this case the state will be saved as /usr/local/etc/<fastpath>.state. XIf both files exist, the file generated by the fastpath manager (.config) Xwill be used. X.LP XSending X.I kboot Xa HUP signal while it's in "watch" mode will cause X.I kboot Xto reread the configuration file kbootcf. This is useful after editing Xthe configuration file. X.SH OPTIONS X.TP X.B \-b fastpath XDownload KSTAR program and state to specified fastpath gateway. X.TP X.B \-c fastpath XDownload state to specified fastpath gateway. X.TP X.B \-d XTurn on debugging. X.TP X.B \-l fastpath XRead state from specified fastpath and print various fields. X.TP X.B \-i interface XSpecify interface name (eg ie1). Defaults to first interface in kernel. X.TP X.B \-p int XSet ping interval, in seconds. X.TP X.B \-r fastpath XReset specified fastpath. X.TP X.B \-s fastpath XRead state vector from specified fastpath and save to a file. This file Xcan be used for downloading later. X.TP X.B \-t fastpath [server] XAsk X.I kboot Xrunning in "watch" mode (see -w option below) on X.I server Xto reload the specified fastpath. Useful for forcing a reboot Xwithout killing a currently running kboot daemon, manually reloading Xwith -b, and restarting the daemon. X.TP X.B \-w XPut X.I kboot Xin "watch" mode. In this mode, X.I kboot Xwill periodically ping the fastpaths Xspecified in the config file, rebooting them if they don't answer. X.I kboot Xwill also listen for RPC requests sent by interactively run X.I kboot Xprocesses requesting reloads (see -t option). X.TP X.B \-v XPrint X.I kboot Xversion number. X.SH FILES X.TP X.B /usr/local/etc/kbootcf XConfiguration file. X.TP X.B /usr/local/etc/<fastpath>.config XAscii fastpath configuration as generated by fastpath manager. X.TP X.B /usr/local/etc/<fastpath>.state XBinary state vector read from fastpath. X.SH "SEE ALSO" Xaarpd(8), nit(4) X.SH BUGS X.I kboot Xdepends on the SunOS 4\.x NIT interface and probably isn't very portable. X.LP X.I kboot Xcan only download/configure fastpaths on the same ethernet Xthat the host X.I kboot Xis running on is attached to. X.SH AUTHOR XBob Schwartzkopf, The RAND Corporation. Much credit is due Dan Tappan Xof BBN, who wrote the first version of X.I kboot Xthat ran on SunOS 3.x, and Phil Budne of Shiva, who helped make it Xwork with KSTAR 8.0. END_OF_FILE if test 3803 -ne `wc -c <'kboot.8'`; then echo shar: \"'kboot.8'\" unpacked with wrong size! fi # end of 'kboot.8' fi if test -f 'aarpd.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'aarpd.h'\" else echo shar: Extracting \"'aarpd.h'\" \(259 characters\) sed "s/^X//" >'aarpd.h' <<'END_OF_FILE' X/* X * $Header: /tmp_mnt/home/src/rand/etc/kboot/RCS/aarpd.h,v 1.1 91/01/29 17:37:30 root Exp $ X * X * $Log: aarpd.h,v $ X * Revision 1.1 91/01/29 17:37:30 root X * Initial revision X * X */ X X#define GETAAPROG 0x20000001 X#define GETAAVERS 1 X#define GETAAPROC 1 END_OF_FILE if test 259 -ne `wc -c <'aarpd.h'`; then echo shar: \"'aarpd.h'\" unpacked with wrong size! fi # end of 'aarpd.h' fi if test -f 'appletalk.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'appletalk.h'\" else echo shar: Extracting \"'appletalk.h'\" \(2078 characters\) sed "s/^X//" >'appletalk.h' <<'END_OF_FILE' X/* X * $Header: /tmp_mnt/home/src/rand/etc/kboot/RCS/appletalk.h,v 1.1 91/01/29 17:37:31 root Exp $ X * X * $Log: appletalk.h,v $ X * Revision 1.1 91/01/29 17:37:31 root X * Initial revision X * X */ X X/* X * appletalk.h - Definitions for Appletalk protocols. X */ X#define AT_Broadcast 0xFF /* Broadcast appletalk address */ X#define AARP 0x80F3 /* AARP protocol type */ X#define H_Ethernet 1 /* Hardware type for ethernet */ X#define HL_Ethernet 6 /* Ethernet address length */ X#define P_AppleTalk 0x809B /* Protocol type for appletalk */ X#define PL_AppleTalk 4 /* Appletalk address length */ X#define AReqTicks 2 /* # of ticks between requests */ X#define AReqTries 6 /* # of tries on requests */ X/* X * Inside Appletalk suggests APrbTicks should be 2 and APrbTries 20. X * Our hosts don't always respond that fast, and that seems like way X * too many retries, so we'll slow down the timeout and decrease the X * retries. X */ X#define APrbTicks 20 /* # of ticks between probes */ X#define APrbTries 5 /* # of tries on probes */ X X/* X * Appletalk ARP header. X */ Xstruct ether_aarp { X u_short aarp_hrd; /* Hardware type */ X u_short aarp_pro; /* Protocol type */ X u_char aarp_hln; /* Hardware address length */ X u_char aarp_pln; /* Protocol address length */ X u_short aarp_op; /* Command */ X#define AARPReq 1 X#define AARPResp 2 X#define AARPProbe 3 X struct ether_addr aarp_sha; /* Sender hardware address */ X u_char aarp_spa[4]; /* Sender protocol address */ X struct ether_addr aarp_tha; /* Target hardware address */ X u_char aarp_tpa[4]; /* Target protocol address */ X}; X Xstruct aarp_packet { X struct ether_header ap_ehdr; X struct ether_aarp ap_ahdr; X}; X#define ap_dhost ap_ehdr.ether_dhost X#define ap_shost ap_ehdr.ether_shost X#define ap_type ap_ehdr.ether_type X#define ap_hrd ap_ahdr.aarp_hrd X#define ap_pro ap_ahdr.aarp_pro X#define ap_hln ap_ahdr.aarp_hln X#define ap_pln ap_ahdr.aarp_pln X#define ap_op ap_ahdr.aarp_op X#define ap_sha ap_ahdr.aarp_sha X#define ap_spa ap_ahdr.aarp_spa X#define ap_tha ap_ahdr.aarp_tha X#define ap_tpa ap_ahdr.aarp_tpa END_OF_FILE if test 2078 -ne `wc -c <'appletalk.h'`; then echo shar: \"'appletalk.h'\" unpacked with wrong size! fi # end of 'appletalk.h' fi if test -f 'config.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'config.h'\" else echo shar: Extracting \"'config.h'\" \(546 characters\) sed "s/^X//" >'config.h' <<'END_OF_FILE' X/* X * $Header: /tmp_mnt/home/src/rand/etc/kboot/RCS/config.h,v 1.1 91/01/29 17:37:42 root Exp $ X * X * $Log: config.h,v $ X * Revision 1.1 91/01/29 17:37:42 root X * Initial revision X * X */ X X/* X * config.h - Tunable stuff for kboot should all be here. X */ X X /* KSTAR images and fastpath config files live here */ X#define ETCDIR "/usr/local/etc" X /* Seconds between pings to make sure fastpaths are ok */ X#define PINGINTERVAL 120 X /* Number of ping retries */ X#define PINGRETRIES 5 X /* Timeout (seconds) for pings */ X#define PINGTIMEOUT 2 END_OF_FILE if test 546 -ne `wc -c <'config.h'`; then echo shar: \"'config.h'\" unpacked with wrong size! fi # end of 'config.h' fi if test -f 'kbox.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'kbox.h'\" else echo shar: Extracting \"'kbox.h'\" \(4880 characters\) sed "s/^X//" >'kbox.h' <<'END_OF_FILE' X/* X * $Header: /tmp_mnt/home/src/rand/etc/kboot/RCS/kbox.h,v 1.2 91/02/12 19:37:15 root Exp $ X * X * $Log: kbox.h,v $ X * Revision 1.2 91/02/12 19:37:15 root X * Remove unused commands. X * X * Revision 1.1 91/01/29 17:37:47 root X * Initial revision X * X */ X X#define FP_TYPE 'K' X#define FP_CMD 'C' X#define FP_ACK 'A' X#define FP_RESP 'R' X/* X * The fp_state structure declared in cmdmacro.h doesn't align all the X * fields properly when compiled on sparc machines, so kboot uses these X * offsets into an array to access interesting fields. X */ X#define O_ATNET 0 /* Net number appletalk side */ X#define O_ETNET 2 /* Net number ethertalk side */ X#define O_VALID 4 /* Appletalk node number valid */ X#define O_NODE 5 /* Appletalk node number */ X#define O_BRIDGE 7 /* Bridge number */ X#define O_ETHER 8 /* Ethernet address */ X#define O_NAME 14 /* Gateway name */ X#define O_FILE 35 /* Loadfile name */ X#define O_PFORCE 56 /* Force execution of prom loop */ X#define O_ATZONE 62 /* Localtalk zone */ X#define O_ETZONE 95 /* Ethertalk zone */ X#define O_ETVALID 128 /* Ethertalk node number valid */ X#define O_ETNODE 129 /* Ethertalk node number */ X#define O_AUTOCONFIG 130 /* Autoconfig switch */ X#define O_AUTOBOOT 132 /* Autoboot switch */ X#define O_OPTIONS 134 /* Options */ X#define O_OPTPARAM 138 /* Optional parameters */ X#define O_SN 170 /* Serial number */ X#define O_DATE 174 /* Configuration date */ X#define O_TYPE 178 /* Type */ X#define O_CONFIG 180 /* Name of config file */ X#define O_UDPZONE 214 /* UDP zone name */ X#define O_IPDEFROUTER 248 /* Default gateway */ X#define O_IPADDRESS 252 /* Ip address */ X#define O_ATIPADDRESS 256 /* Localtalk IP net */ X#define O_IPBROADCAST 260 /* Broadcast address */ X#define O_IPSUBMASK 264 /* Subnet mask */ X#define O_IPKIPSERVER 268 /* Admin host */ X#define O_UDPNET 272 /* UDP net number */ X#define O_UDPNODE 274 /* UDP node number */ X#define O_NAMESERVER 276 /* DNS host */ X#define O_FILESERVER 280 /* File server */ X#define O_LP1 284 /* Local parameter 1 */ X#define O_LP2 288 /* Local parameter 2 */ X#define O_LP3 292 /* Local parameter 3 */ X#define O_LP4 296 /* Local parameter 4 */ X#define O_NDYNAMICS 300 /* Number of dynamic ip addrs */ X#define O_NSTATICS 302 /* Number of static ip addrs */ X#define O_SIGNATURE 304 /* Signature */ X#define O_AREANODE 308 /* DECnet area and node */ X#define O_BACKTIMER 310 /* DECnet routing timer */ X#define O_HELLOTIMER 312 /* DECnet hello timer */ X#define O_RSTART 314 /* Range start for ET 2.0 */ X#define O_REND 316 /* Range end for ET 2.0 */ X#define O_ET2NET 318 /* Net number ET 2.0 side */ X#define O_ET2VALID 320 /* ET 2.0 node number valid */ X#define O_ET2NODE 321 /* ET 2.0 node number */ X#define O_ZONELIST 322 /* Zonelist */ X#define O_CONFIGTYPES 326 /* Reserved for FPM */ X#define O_DATATYPE 330 /* Define following data */ X#define O_DATALEN 332 /* Length of following data */ X#define O_ATAPOPTIONS 334 X#define O_ATAPRETRY 336 X X#define STATE_LENGTH 0x24A /* Length of state vector */ X#define FPCOPYSIZE 10 /* Copy structure size */ X#define PROMRAMSIZE 64 /* promram structure size */ X#define HTSIZE 32 X#define MAXHOSTNAME 64 X#define MAXKBOX 256 X#define MAXFN 256 X#define MAXZONELIST 256 X Xstruct kbox { X struct sockaddr_in ip; X int reload; X char name[MAXHOSTNAME]; X char bootfile[MAXFN]; X char conffile[MAXFN]; X struct ether_addr ea; X u_char aa; X struct kbox *nxt; X}; X X/* X * Send functions with no parameters. X */ X#define send_execute(kp) send_gen (kp, X_EXECUTE, 0) X#define send_promram(kp) send_gen (kp, X_PROMRAM, 5) X#define send_reset(kp) send_gen (kp, X_RESET, 0) X#define send_exprom(kp) send_gen (kp, X_EXPROM, 0) X X/* X * Packet used to talk to Kinetics Fastpaths. Does not include link X * level header (ether_header). X */ X#define MAXFPPKT 1024 Xstruct ether_fastpath { X unsigned char fastpath_lapdest; X unsigned char fastpath_lapsrc; X unsigned char fastpath_laptype; X unsigned char fastpath_len[2]; X unsigned char fastpath_cmd; X unsigned char fastpath_scmd; X unsigned char fastpath_data[MAXFPPKT]; X}; X Xstruct fp_packet { X struct ether_header fp_ehdr; X struct ether_fastpath fp_fphdr; X}; X#define fp_dhost fp_ehdr.ether_dhost X#define fp_shost fp_ehdr.ether_shost X#define fp_type fp_ehdr.ether_type X#define fp_lapdest fp_fphdr.fastpath_lapdest X#define fp_lapsrc fp_fphdr.fastpath_lapsrc X#define fp_laptype fp_fphdr.fastpath_laptype X#define fp_len fp_fphdr.fastpath_len X#define fp_cmd fp_fphdr.fastpath_cmd X#define fp_scmd fp_fphdr.fastpath_scmd X#define fp_data fp_fphdr.fastpath_data X Xtypedef struct { X short num_elements; /* Number of elements in following array */ X short type; /* Type of element (1 for zonelist) */ X short bytes; /* Length of element */ X} elemlist; X X#define NAMELEN 21 X#define CONFIGLEN 33 END_OF_FILE if test 4880 -ne `wc -c <'kbox.h'`; then echo shar: \"'kbox.h'\" unpacked with wrong size! fi # end of 'kbox.h' fi if test -f 'patchlevel.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'patchlevel.h'\" else echo shar: Extracting \"'patchlevel.h'\" \(296 characters\) sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE' X/* X * $Header: /tmp_mnt/home/src/rand/etc/kboot/RCS/patchlevel.h,v 1.2 91/02/12 19:38:43 root Exp $ X * X * $Log: patchlevel.h,v $ X * Revision 1.2 91/02/12 19:38:43 root X * *** empty log message *** X * X * Revision 1.1 91/01/29 17:37:51 root X * Initial revision X * X */ X X#define PATCHLEVEL 2 END_OF_FILE if test 296 -ne `wc -c <'patchlevel.h'`; then echo shar: \"'patchlevel.h'\" unpacked with wrong size! fi # end of 'patchlevel.h' fi if test -f 'cmdidx.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'cmdidx.h'\" else echo shar: Extracting \"'cmdidx.h'\" \(8803 characters\) sed "s/^X//" >'cmdidx.h' <<'END_OF_FILE' X/* X * Copyright (c) 1985, 1986 Kinetics, Inc. X * X * $Header: /usr/fp/include/fp/RCS/cmdidx.h,v 1.6 86/02/20 19:54:20 root Exp $ X * X * Indices into the jump table for PROM routines. X * Also, the command numbers for the routines when invoked X * from Kinetics LAP type command packets. X * The values of these constants are actually determined by X * their position in the jump table in .../proms/kfpx.s. X * See cmdmacro.h for the actual calls through the jump table. X * After the indices are defined, structure definitions for X * each call's pointer parameter are also defined.. X */ X X#define X_VERSION 0 X#define X_EXECUTE 1 X#define X_ACK 2 X#define X_REBOOT 3 X#define X_SET68 4 X#define X_SET86 5 X#define X_ATINIT 6 X#define X_ATWRITE 7 X#define X_WAIT 8 X#define X_WHEREIS 9 X#define X_GETMEM 10 X#define X_PROTECT 11 X#define X_COPYMEM 12 X#define X_CLRMEM 13 X#define X_PROMRAM 14 X#define X_RESET 15 X#define X_USER0 16 X#define X_USER1 17 X#define X_USER2 18 X#define X_USER3 19 X#define X_USER4 20 X#define X_USER5 21 X#define X_USER6 22 X#define X_USER7 23 X#define X_BUFINIT 24 X#define X_BUFGET 25 X#define X_BUFFREE 26 X#define X_BUFENQ 27 X#define X_BUFDEQ 28 X#define X_ERR 29 X#define X_IDLE 30 X#define X_KLAP 31 X#define X_WHO 32 X#define X_CA86 33 X#define X_RES86 34 X#define X_CLRINT 35 X#define X_RCSID 36 X#define X_EXPROM 37 X#define X_INIPROM 38 X#define X_RES8530 39 X#define X_DMTSERV 40 X#define X_SREC 41 X#define X_SPL 42 X#define X_NOTIMP 43 X X/* structures for the above commands */ X X/* X_VERSION */ Xstruct fp_version { X short fpv_entries; /* number of valid entries in jump table */ X short fpv_version; /* version of the prom code */ X long fpv_model; /* "KFPS", "KFPQ", or "KFPM" */ X}; X X/* X_EXECUTE */ X/* no parameters */ X X/* X_ACK */ X/* no parameters */ X X/* X_REBOOT */ X/* no parameters */ X X/* X_SET68 */ X/* no parameters */ X X/* X_SET86 */ X/* this structure is really defined in ie.h, but it should look like this */ X#ifdef NEVER Xstruct scb { X unsigned short sc_status; /* status */ X unsigned short sc_cmd; /* command */ X unsigned short sc_clist; /* command list */ X unsigned short sc_rlist; /* receive frame list */ X unsigned short sc_crcerrs; /* crc errors */ X unsigned short sc_alnerrs; /* alignment errors */ X unsigned short sc_rscerrs; /* resource errors (lack of rfd/rbd's) */ X unsigned short sc_ovrnerrs; /* overrun errors (mem bus not avail) */ X}; X#endif NEVER X X/* X_ATINIT */ X/* The parameter is a pointer to a short which is filled in with X the node number chosen by the AppleTalk initialization sequence */ X X/* X_ATWRITE */ Xstruct fp_atwrite { X short fpw_length; /* number of bytes in hte following string */ X unsigned char *fpw_str; /* string to be output onto the network */ X}; X X/* X_WAIT */ X/* The parameter is a long integer which indicates X the number of milliseconds to delay */ X X/* X_WHEREIS */ Xstruct fp_whereis { X char *fpw_rom0; /* first address of 1st ROM */ X char *fpw_rom1; /* first address of 2nd ROM */ X char *fpw_8530; /* address of Zilog 8530 chip */ X char *fpw_0port; /* address of 1st 8-bit port */ X char *fpw_1port; /* address of 2nd 8-bit port */ X char *fpw_ram2; /* address of 1st RAM location */ X char *fpw_ramtop; /* address of last RAM location */ X}; X X/* X_GETMEM and X_CLRMEM and X_BUFINIT */ Xstruct fp_mem { X short fpm_count; /* number of bytes */ X char *fpm_memp; /* addr of allocated or to be cleared memory */ X}; X X/* X_PROTECT */ Xstruct fp_proelem { /* protection array element */ X short fpp_count; /* number of bytes to protect */ X char *fpp_memp; /* address of memory to protect */ X short fpp_chksum; /* checksum of protected memory */ X}; X Xstruct fp_protect { X short fpt_oper; /* type of protection operation and result */ X short fpt_count; /* number of elements in protection array */ X struct fp_proelem *fpt_elem; /* addr 1st element in protection array */ X}; X X/* fpt_oper operations */ X#define PR_FAIL -1 /* result: check of checksums failed */ X#define PR_PASS 0 /* result: check of checksums passed */ X#define PR_PROTECT 1 /* operation: start protect via elem array */ X#define PR_CHECK 2 /* operation: verify protect via elem array */ X#define PR_CANCEL 3 /* operation: cancel protect via elem array */ X X/* X_COPYMEM */ Xstruct fp_copy { X char *fpc_from; /* location to copy bytes from */ X char *fpc_to; /* location to copy bytes to */ X short fpc_count; /* number of bytes to copy */ X}; X X/* X_PROMRAM */ Xstruct fp_bufinfo { X struct pbuf **fpb_pfree;/* beginning of the free list */ X struct pqueue *fpb_pq; /* received buffers queue (both networks) */ X struct pqueue *fpb_sendq;/* Ethernet transmit queue */ X short fpb_bsize; /* size of a buffer including header */ X short fpb_pbnfree; /* pbufs on our free list */ X short fpb_pbndrops; /* times failed to find space */ X short fpb_pbntypes[16];/* type specific pbuf allocations */ X}; X Xstruct fp_state { X unsigned short fps_atnet; /* current net number for AppleTalk side */ X unsigned short fps_etnet; /* current net number for Ethernet side */ X unsigned char fps_valid; /* following AppleTalk node number valid */ X unsigned char fps_node; /* current AppleTalk LAP node number */ X unsigned char fps_netw; /* network number (not used) */ X unsigned char fps_bridge; /* last known bridge num on net if any */ X unsigned char fps_ether[6]; /* current ethernet address */ X#define SNAMESIZE 21 /* extra char for null at end */ X char fps_name[SNAMESIZE];/* ascii name of the gateway */ X char fps_file[SNAMESIZE];/* ascii name of srec file last loaded */ X unsigned char fps_pforce; /* non-zero forces execution of prom loop */ X unsigned char fps_reserve; X unsigned char fps_unused[70]; X}; X Xstruct fp_abstats { X int fpa_interrupts; /* Appletalk interrupts */ X int fpa_ipackets; /* packets received */ X int fpa_opackets; /* packets transmitted */ X int fpa_crc; /* crc errors */ X int fpa_ovr; /* receive overrun errors */ X int fpa_iund; /* receive underrun errors */ X int fpa_xx; X int fpa_yy; X int fpa_bad; /* bad packets received */ X int fpa_coll; /* collisions */ X int fpa_defer; /* times deferred to other packets */ X int fpa_idleto; /* packets that timed out waiting for the end */ X int fpa_zz; X int fpa_nodata; /* packets without data (nothing after rts) */ X int fpa_ound; /* transmit underrun errors */ X int fpa_badddp; /* bad ddp packets */ X int fpa_spur; /* spurrious interrupts */ X}; X Xstruct fp_iestats { X struct scb *fpi_scbptr; /* status control block */ X int fpi_ipackets; /* input packets */ X int fpi_opackets; /* output packets */ X int fpi_ierrors; /* input errors */ X int fpi_oerrors; /* output errors */ X int fpi_cmdbusy; /* busy waits */ X}; X Xstruct fp_promram { X short fpr_count; /* number of valid ptrs that follow */ X char *fpr_jtable; /* jump table */ X struct fp_bufinfo *fpr_bufs; /* buffer manager vector */ X struct fp_state *fpr_state; /* Prompt program's state vector */ X struct fp_abstats *fpr_abstats; /* AppleTalk statistics vector */ X struct fp_iestats *fpr_iestats; /* Ethernet statistics vector */ X char *fpr_1debug; /* first level debug flag */ X char *fpr_2debug; /* second level debug flag */ X char *fpr_3debug; /* third level debug flag */ X char *fpr_unused[24]; /* remaining ptrs are not defined yet */ X}; X X/* X_RESET */ X/* no parameters */ X X/* X_USER0, X_USER1, X_USER2, X_USER3, X_USER4, X_USER5, X_USER6, X_USER7 */ X/* parameters (if any) defined by user */ X X/* X_BUFGET */ Xstruct fp_bget { X struct pbuf *fpg_buf; /* address of buffer returned */ X short fpg_type; /* type of buffer to be "gotten" */ X}; X X/* X_BUFFREE */ Xstruct fp_bfree { X struct pbuf *fpf_buf; /* address of buffer to be freed */ X struct pbuf *fpf_nxt; /* the freed buffer's link before it was freed*/ X}; X X/* X_BUFENQ and X_BUFDEQ */ Xstruct fp_bqueue { X struct pqueue *fpq_q; /* addr of queue to enqueue to / dequeue from */ X struct pbuf *fpq_buf; /* addr of buffer to be enqueued or dequeued */ X}; X X/* X_ERR */ X/* no parameters */ X X/* X_IDLE */ X/* no parameters */ X X/* X_KLAP */ X/* The parameter is the address of a pbuf structure. See pbuf.h. */ X X/* X_WHO */ X/* no parameters */ X X/* X_CA86 */ X/* no parameters */ X X/* X_RES86 */ X/* no parameters */ X X/* X_CLRINT */ X/* no parameters */ X X/* X_RCSID */ X/* The parameter is the address of a character array which is filled X in with the current RCS identification string of this PROM version. */ X X/* X_EXPROM */ X/* no parameters */ X X/* X_INIPROM */ X/* no parameters */ X X/* X_RES8530 */ X/* no parameters */ X X/* X_DMTSERV */ X/* no parameters */ X X/* X_SREC */ X/* The parameter is the address of a character array which contains X the S-record to be interpreted and used by the gateway */ X X/* X_SPL */ X/* The parameter is the address short which becomes the next processor priority X level. The previous priority level is returned at the same location */ X X/* X_NOTIMP */ X/* no parameters */ X END_OF_FILE if test 8803 -ne `wc -c <'cmdidx.h'`; then echo shar: \"'cmdidx.h'\" unpacked with wrong size! fi # end of 'cmdidx.h' fi if test -f 'kboot.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'kboot.h'\" else echo shar: Extracting \"'kboot.h'\" \(268 characters\) sed "s/^X//" >'kboot.h' <<'END_OF_FILE' X/* X * $Header: /tmp_mnt/home/src/rand/etc/kboot/RCS/kboot.h,v 1.1 91/02/12 19:38:26 root Exp $ X * X * $Log: kboot.h,v $ X * Revision 1.1 91/02/12 19:38:26 root X * Initial revision X * X */ X X#define KBOOTPROG 0x20000002 X#define KBOOTVERS 1 X#define KBOOTPROC_RELOAD 1 END_OF_FILE if test 268 -ne `wc -c <'kboot.h'`; then echo shar: \"'kboot.h'\" unpacked with wrong size! fi # end of 'kboot.h' fi if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(966 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' XKBOOT = kboot.o getaa.o nitlib.o cmd.o icmp.o XAARPD = aarpd.o nitlib.o XCFLAGS = -g XETCDIR = /usr/rand/etc XMANDIR = /usr/rand/man/man8 XSRCS1 = aarpd.c getaa.c XSRCS2 = cmd.c icmp.c kboot.c nitlib.c XINCS = aarpd.h appletalk.h config.h kbox.h patchlevel.h cmdidx.h kboot.h XMANS = aarpd.8 kboot.8 X Xall: aarpd kboot X Xkboot: $(KBOOT) X cc -o kboot $(KBOOT) X Xaarpd: $(AARPD) X cc -o aarpd $(AARPD) X Xinstall: X install -c kboot $(ETCDIR)/kboot X install -c aarpd $(ETCDIR)/aarpd X Xinstall.man: X install -c kboot.8 $(MANDIR)/kboot.8 X install -c aarpd.8 $(MANDIR)/aarpd.8 X Xclean: X rm -f aarpd kboot *.o core *~ X Xshar: $(SRCS1) $(SRCS2) $(INCS) $(MANS) Makefile README X shar -n1 -e2 $(SRCS2) > kboot1.shar X shar -n2 -e2 $(SRCS1) $(MANS) $(INCS) Makefile README > kboot2.shar X Xaarpd.o: appletalk.h aarpd.h config.h patchlevel.h Xkboot.o: appletalk.h kbox.h cmdidx.h config.h kboot.h patchlevel.h Xcmd.o: appletalk.h kbox.h cmdidx.h config.h Xicmp.o: kbox.h config.h Xnitlib.o: config.h END_OF_FILE if test 966 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(4134 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' XKboot is a program used to monitor, boot and configure Shiva Fastpaths Xfrom a sun running SunOS 4.x. It was originally written by Dan Tappan Xof BBN, and ran under SunOS 3.5. I've ported it to SunOS 4.x and Xadded support for KSTAR version 8.0 and up. Complaints, suggestions Xand bug fixes can be sent to me. X XBob Schwartzkopf XThe RAND Corporation X1700 Main Street XPO Box 2138 XSanta Monica, Ca. 90407-2138 Xbobs@rand.org X XThe kboot package consists of 2 separate programs, kboot and aarpd. Xkboot is the program that monitors, configures and downloads Shiva XFastpaths; aarpd implements some of the Appletalk ARP protocol. XAarpd obtains an Appletalk node number dynamically for the Xlocal host; kboot queries aarpd via an RPC call to learn the Xnode number it should use when communicating with Fastpaths. XPlease note that kboot and aarpd must be run on a sun on the same Xethernet as the Fastpaths it will be talking to, as it depends on Xbroadcasts to learn the Appeltalk addresses of each Fastpath specified Xin its configuration file. X XTo build kboot and aarpd: X X - Edit Makefile and set ETCDIR and MANDIR X X - Edit config.h as necessary X X - make X XTo install: X X - make install X X - make install.man X XOnce kboot and aarpd are installed you must create the following Xfiles in ETCDIR: X Xkbootcf - kboot configuration file. XKSTAR - KSTAR software, which comes with Fastpath Manager and is also X available via anonymous ftp from shiva.com. X XYou will also need a configuration file for each Fastpath. These Xfiles also are installed in ETCDIR with the name FASTPATH.config Xor FASTPATH.state, where FASTPATH is the hostname of the Fastpath. XThe .config files are ascii configuration files created by Fastpath XManager. The .state files are binary files created by kboot, which Xhas an option to read the state of a currently running Fastpath Xand save it to ETCDIR/FASTPATH.state. X XThe kboot configuration file (ETCDIR/kbootcf) contains a list of XFASTPATH hostnames followed by the name of the KSTAR image to download. XFor example, if you have 2 Fastpaths, one running 7.0.1 and the other Xrunning 8.0, you could copy the appropriate KSTAR software to XETCDIR/KSTAR-7.0.1 and ETCDIR/KSTAR-8.0. Your kbootcf file would Xthen look like: X X fastpath1 KSTAR-7.0.1 X fastpath2 KSTAR-8.0 X XKboot learns the ethernet address of each configured Fastpath by Xlooking at the ethernet header of the packets sent to it by each Fastpath. XIt verifies that address with the address in the ethers NIS map (or Xfile if you're not running NIS), so it is necessary that each Xconfigured Fastpath have its ethernet address entered in the ethers map. XKboot will complain about unknown Fastpaths if the ethers map Xis not correct. X XNOTE: The appletalk phase II zonelist (specified in Fastpath X Manager) is not included in the Fastpath configuration X structure. Hence it is not downloaded when a Fastpath X is configured. Instead, it is converted into s-records X and downloaded with the KSTAR software. Since a zonelist X is not part of the configuration structure, the configuration X read by kboot and stored in ETCDIR/FASTPATH.state will not X contain the zonelist in use by the Fastpath. X X The Fastpath Manager software does include the zonelist in X the ascii configuration file, and kboot knows how to read X it from there, convert it to s-records, and download it to X the Fastpath. Hence, if you're running Appletalk phase II, X and have a non empty zonelist, you cannot use the binary X state files generated by kboot. You must instead use X Fastpath manager to create an ascii configuration file which X includes the zonelist and copy it to ETCDIR. X X Since I have no documentation on the Fastpath I had to reverse X engineer the format of the s-records, the address where they're X stored in the Fastpath, and how they're encoded in the X configuration file. My thanks to Phil Budne of Shiva who X helped me with some of this stuff. I don't guarantee this X code is perfect (especially since we're not running phase II X yet), however the one test I ran did seem to work. Please X let me know if you have any problems with zonelists, or any X other part of kboot for that matter. END_OF_FILE if test 4134 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi echo shar: End of archive 2 \(of 2\). cp /dev/null ark2isdone MISSING="" for I in 1 2 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked both archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0