Import of NetBSD's rbootd version 19970629

This commit is contained in:
steve 1997-06-29 18:50:34 +00:00
parent bfb7bb3f17
commit 5454f4c230
12 changed files with 193 additions and 235 deletions

@ -1,11 +1,8 @@
# @(#)Makefile 8.1 (Berkeley) 6/4/93
# from: @(#)Makefile 8.1 (Berkeley) 6/4/93
# $NetBSD: Makefile,v 1.4 1995/08/21 17:05:08 thorpej Exp $
PROG= rbootd
SRCS= bpf.c conf.c parseconf.c rbootd.c rmpproto.c utils.c
MAN8= rbootd.0
afterinstall:
(cd ${.CURDIR}/bootdir && install -c -o ${BINOWN} -g ${BINGRP} \
-m 444 * ${DESTDIR}/usr/mdec/)
MAN= rbootd.8
.include <bsd.prog.mk>

@ -1,3 +1,5 @@
/* $NetBSD: bpf.c,v 1.7 1997/01/27 22:51:50 thorpej Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
* for Software Science (CSS).
@ -38,14 +40,15 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)bpf.c 8.1 (Berkeley) 6/4/93
* from: @(#)bpf.c 8.1 (Berkeley) 6/4/93
*
* Utah $Hdr: bpf.c 3.1 92/07/06$
* From: Utah Hdr: bpf.c 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
*/
#ifndef lint
static char sccsid[] = "@(#)bpf.c 8.1 (Berkeley) 6/4/93";
/*static char sccsid[] = "@(#)bpf.c 8.1 (Berkeley) 6/4/93";*/
static char rcsid[] = "$NetBSD: bpf.c,v 1.7 1997/01/27 22:51:50 thorpej Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -68,7 +71,7 @@ static char sccsid[] = "@(#)bpf.c 8.1 (Berkeley) 6/4/93";
static int BpfFd = -1;
static unsigned BpfLen = 0;
static u_char *BpfPkt = NULL;
static u_int8_t *BpfPkt = NULL;
/*
** BpfOpen -- Open and initialize a BPF device.
@ -145,14 +148,9 @@ BpfOpen()
#endif
ifr.ifr_addr.sa_family = AF_UNSPEC;
bcopy(&RmpMcastAddr[0], (char *)&ifr.ifr_addr.sa_data[0], RMP_ADDRLEN);
if (ioctl(BpfFd, SIOCADDMULTI, (caddr_t)&ifr) < 0) {
syslog(LOG_WARNING,
"bpf: can't add mcast addr (%m), setting promiscuous mode");
if (ioctl(BpfFd, BIOCPROMISC, (caddr_t)0) < 0) {
syslog(LOG_ERR, "bpf: can't set promiscuous mode: %m");
Exit(0);
}
if (ioctl(BpfFd, BIOCPROMISC, (caddr_t)0) < 0) {
syslog(LOG_ERR, "bpf: can't set promiscuous mode: %m");
Exit(0);
}
/*
@ -163,7 +161,7 @@ BpfOpen()
Exit(0);
}
if (BpfPkt == NULL)
BpfPkt = (u_char *)malloc(BpfLen);
BpfPkt = (u_int8_t *)malloc(BpfLen);
if (BpfPkt == NULL) {
syslog(LOG_ERR, "bpf: out of memory (%u bytes for bpfpkt)",
@ -312,7 +310,7 @@ BpfRead(rconn, doread)
int doread;
{
register int datlen, caplen, hdrlen;
static u_char *bp = NULL, *ep = NULL;
static u_int8_t *bp = NULL, *ep = NULL;
int cc;
/*

@ -1,3 +1,5 @@
/* $NetBSD: conf.c,v 1.5 1995/10/06 05:12:13 thorpej Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
* for Software Science (CSS).
@ -38,14 +40,15 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)conf.c 8.1 (Berkeley) 6/4/93
* from: @(#)conf.c 8.1 (Berkeley) 6/4/93
*
* Utah $Hdr: conf.c 3.1 92/07/06$
* From: Utah Hdr: conf.c 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
*/
#ifndef lint
static char sccsid[] = "@(#)conf.c 8.1 (Berkeley) 6/4/93";
/*static char sccsid[] = "@(#)conf.c 8.1 (Berkeley) 6/4/93";*/
static char rcsid[] = "$NetBSD: conf.c,v 1.5 1995/10/06 05:12:13 thorpej Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -65,9 +68,8 @@ static char sccsid[] = "@(#)conf.c 8.1 (Berkeley) 6/4/93";
** simplify the boot file search code.
*/
char *ProgName; /* path-stripped argv[0] */
char MyHost[MAXHOSTNAMELEN+1]; /* host name */
int MyPid; /* process id */
pid_t MyPid; /* process id */
int DebugFlg = 0; /* set true if debugging */
int BootAny = 0; /* set true if we boot anyone */
@ -80,11 +82,11 @@ char *DbgFile = _PATH_RBOOTDDBG; /* debug output file */
FILE *DbgFp = NULL; /* debug file pointer */
char *IntfName = NULL; /* intf we are attached to */
u_short SessionID = 0; /* generated session ID */
u_int16_t SessionID = 0; /* generated session ID */
char *BootFiles[C_MAXFILE]; /* list of boot files */
CLIENT *Clients = NULL; /* list of addrs we'll accept */
RMPCONN *RmpConns = NULL; /* list of active connections */
char RmpMcastAddr[RMP_ADDRLEN] = RMP_ADDR; /* RMP multicast address */
u_int8_t RmpMcastAddr[RMP_ADDRLEN] = RMP_ADDR; /* RMP multicast address */

@ -1,3 +1,5 @@
/* $NetBSD: defs.h,v 1.5 1995/10/06 05:12:14 thorpej Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
* for Software Science (CSS).
@ -38,9 +40,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)defs.h 8.1 (Berkeley) 6/4/93
* from: @(#)defs.h 8.1 (Berkeley) 6/4/93
*
* Utah $Hdr: defs.h 3.1 92/07/06$
* From: Utah Hdr: defs.h 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
*/
@ -107,7 +109,7 @@
* (unless there are no restrictions on who we can boot).
*/
typedef struct client_s {
u_char addr[RMP_ADDRLEN]; /* addr of machine */
u_int8_t addr[RMP_ADDRLEN]; /* addr of machine */
char *files[C_MAXFILE]; /* boot-able files */
struct client_s *next; /* ptr to next */
} CLIENT;
@ -126,9 +128,8 @@ typedef struct rmpconn_s {
/*
* All these variables are defined in "conf.c".
*/
extern char *ProgName; /* path-stripped argv[0] */
extern char MyHost[]; /* this hosts' name */
extern int MyPid; /* this processes' ID */
extern pid_t MyPid; /* this processes' ID */
extern int DebugFlg; /* set true if debugging */
extern int BootAny; /* set true if we can boot anyone */
@ -141,14 +142,14 @@ extern char *BootDir; /* directory w/boot files */
extern FILE *DbgFp; /* debug file pointer */
extern char *IntfName; /* interface we are attached to */
extern u_short SessionID; /* generated session ID */
extern u_int16_t SessionID; /* generated session ID */
extern char *BootFiles[]; /* list of boot files */
extern CLIENT *Clients; /* list of addrs we'll accept */
extern RMPCONN *RmpConns; /* list of active connections */
extern char RmpMcastAddr[]; /* RMP multicast address */
extern u_int8_t RmpMcastAddr[]; /* RMP multicast address */
void AddConn __P((RMPCONN *));
int BootDone __P((RMPCONN *));
@ -169,11 +170,11 @@ void FreeClients __P((void));
void FreeConn __P((RMPCONN *));
void FreeConns __P((void));
int GetBootFiles __P((void));
char *GetEtherAddr __P((u_char *));
CLIENT *NewClient __P((u_char *));
char *GetEtherAddr __P((u_int8_t *));
CLIENT *NewClient __P((u_int8_t *));
RMPCONN *NewConn __P((RMPCONN *));
char *NewStr __P((char *));
u_char *ParseAddr __P((char *));
u_int8_t *ParseAddr __P((char *));
int ParseConfig __P((void));
void ProcessPacket __P((RMPCONN *, CLIENT *));
void ReConfig __P((int));

@ -1,3 +1,5 @@
/* $NetBSD: parseconf.c,v 1.4 1995/10/06 05:12:16 thorpej Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
* for Software Science (CSS).
@ -38,14 +40,15 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)parseconf.c 8.1 (Berkeley) 6/4/93
* from: @(#)parseconf.c 8.1 (Berkeley) 6/4/93
*
* Utah $Hdr: parseconf.c 3.1 92/07/06$
* From: Utah Hdr: parseconf.c 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
*/
#ifndef lint
static char sccsid[] = "@(#)parseconf.c 8.1 (Berkeley) 6/4/93";
/*static char sccsid[] = "@(#)parseconf.c 8.1 (Berkeley) 6/4/93";*/
static char rcsid[] = "$NetBSD: parseconf.c,v 1.4 1995/10/06 05:12:16 thorpej Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -82,7 +85,7 @@ ParseConfig()
{
FILE *fp;
CLIENT *client;
u_char *addr;
u_int8_t *addr;
char line[C_LINELEN];
register char *cp, *bcp;
register int i, j;
@ -241,13 +244,12 @@ ParseConfig()
** Warnings:
** - The return value points to a static buffer; it must
** be copied if it's to be saved.
** - For speed, we assume a u_char consists of 8 bits.
*/
u_char *
u_int8_t *
ParseAddr(str)
char *str;
{
static u_char addr[RMP_ADDRLEN];
static u_int8_t addr[RMP_ADDRLEN];
register char *cp;
register unsigned i;
register int part, subpart;

@ -1,3 +1,5 @@
/* $NetBSD: pathnames.h,v 1.3 1995/08/21 17:05:15 thorpej Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
* for Software Science (CSS).
@ -38,9 +40,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)pathnames.h 8.1 (Berkeley) 6/4/93
* from: @(#)pathnames.h 8.1 (Berkeley) 6/4/93
*
* Utah $Hdr: pathnames.h 3.1 92/07/06$
* From: Utah Hdr: pathnames.h 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
*/

@ -1,3 +1,5 @@
.\" $NetBSD: rbootd.8,v 1.4 1997/05/29 01:48:46 cgd Exp $
.\"
.\" Copyright (c) 1988, 1992 The University of Utah and the Center
.\" for Software Science (CSS).
.\" Copyright (c) 1992, 1993
@ -37,12 +39,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)rbootd.8 8.2 (Berkeley) 12/11/93
.\" from: @(#)rbootd.8 8.2 (Berkeley) 12/11/93
.\"
.\" Utah $Hdr: rbootd.man 3.1 92/07/06$
.\" Utah Hdr: rbootd.man 3.1 92/07/06
.\" Author: Jeff Forys, University of Utah CSS
.\"
.Dd "December 11, 1993"
.Dd December 11, 1993
.Dt RBOOTD 8
.Os
.Sh NAME

@ -1,3 +1,5 @@
/* $NetBSD: rbootd.c,v 1.5 1995/10/06 05:12:17 thorpej Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
* for Software Science (CSS).
@ -38,9 +40,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)rbootd.c 8.2 (Berkeley) 2/22/94
* from: @(#)rbootd.c 8.1 (Berkeley) 6/4/93
*
* Utah $Hdr: rbootd.c 3.1 92/07/06$
* From: Utah Hdr: rbootd.c 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
*/
@ -51,14 +53,14 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)rbootd.c 8.2 (Berkeley) 2/22/94";
/*static char sccsid[] = "@(#)rbootd.c 8.1 (Berkeley) 6/4/93";*/
static char rcsid[] = "$NetBSD: rbootd.c,v 1.5 1995/10/06 05:12:17 thorpej Exp $";
#endif /* not lint */
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
@ -69,19 +71,7 @@ static char sccsid[] = "@(#)rbootd.c 8.2 (Berkeley) 2/22/94";
#include <unistd.h>
#include "defs.h"
/* fd mask macros (backward compatibility with 4.2BSD) */
#ifndef FD_SET
#ifdef notdef
typedef struct fd_set { /* this should already be in 4.2 */
int fds_bits[1];
} fd_set;
#endif
#define FD_ZERO(p) ((p)->fds_bits[0] = 0)
#define FD_SET(n, p) ((p)->fds_bits[0] |= (1 << (n)))
#define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1 << (n)))
#define FD_ISSET(n, p) ((p)->fds_bits[0] & (1 << (n)))
#endif
extern char *__progname; /* from crt0.o */
int
main(argc, argv)
@ -91,11 +81,6 @@ main(argc, argv)
int c, fd, omask, maxfds;
fd_set rset;
/*
* Find what name we are running under.
*/
ProgName = (ProgName = rindex(argv[0],'/')) ? ++ProgName : *argv;
/*
* Close any open file descriptors.
* Temporarily leave stdin & stdout open for `-d',
@ -129,9 +114,8 @@ main(argc, argv)
if (ConfigFile == NULL)
ConfigFile = argv[optind];
else {
fprintf(stderr,
"%s: too many config files (`%s' ignored)\n",
ProgName, argv[optind]);
warnx("too many config files (`%s' ignored)\n",
argv[optind]);
}
}
@ -143,57 +127,16 @@ main(argc, argv)
(void) signal(SIGUSR1, SIG_IGN); /* dont muck w/DbgFp */
(void) signal(SIGUSR2, SIG_IGN);
(void) fclose(stderr); /* finished with it */
} else {
(void) fclose(stdin); /* dont need these */
(void) fclose(stdout);
/*
* Fork off a child to do the work & exit.
*/
switch(fork()) {
case -1: /* fork failed */
fprintf(stderr, "%s: ", ProgName);
perror("fork");
Exit(0);
case 0: /* this is the CHILD */
break;
default: /* this is the PARENT */
_exit(0);
}
/*
* Try to disassociate from the current tty.
*/
{
char *devtty = "/dev/tty";
int i;
if ((i = open(devtty, O_RDWR)) < 0) {
/* probably already disassociated */
if (setpgrp(0, 0) < 0) {
fprintf(stderr, "%s: ", ProgName);
perror("setpgrp");
}
} else {
if (ioctl(i, (u_long)TIOCNOTTY, (char *)0) < 0){
fprintf(stderr, "%s: ", ProgName);
perror("ioctl");
}
(void) close(i);
}
}
if (daemon(0, 0))
err(1, "can't detach from terminal");
(void) signal(SIGUSR1, DebugOn);
(void) signal(SIGUSR2, DebugOff);
}
(void) fclose(stderr); /* finished with it */
#ifdef SYSLOG4_2
openlog(ProgName, LOG_PID);
#else
openlog(ProgName, LOG_PID, LOG_DAEMON);
#endif
openlog(__progname, LOG_PID, LOG_DAEMON);
/*
* If no interface was specified, get one now.
@ -237,7 +180,7 @@ main(argc, argv)
FILE *fp;
if ((fp = fopen(PidFile, "w")) != NULL) {
(void) fprintf(fp, "%d\n", MyPid);
(void) fprintf(fp, "%d\n", (int) MyPid);
(void) fclose(fp);
} else {
syslog(LOG_WARNING, "fopen: failed (%s)", PidFile);
@ -286,13 +229,11 @@ main(argc, argv)
r = rset;
if (RmpConns == NULL) { /* timeout isnt necessary */
nsel = select(maxfds, &r, (fd_set *)0, (fd_set *)0,
(struct timeval *)0);
nsel = select(maxfds, &r, NULL, NULL, NULL);
} else {
timeout.tv_sec = RMP_TIMEOUT;
timeout.tv_usec = 0;
nsel = select(maxfds, &r, (fd_set *)0, (fd_set *)0,
&timeout);
nsel = select(maxfds, &r, NULL, NULL, &timeout);
}
if (nsel < 0) {

@ -1,3 +1,5 @@
/* $NetBSD: rmp.h,v 1.4 1995/10/06 05:12:18 thorpej Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
* for Software Science (CSS).
@ -38,9 +40,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)rmp.h 8.1 (Berkeley) 6/4/93
* from: @(#)rmp.h 8.1 (Berkeley) 6/4/93
*
* Utah $Hdr: rmp.h 3.1 92/07/06$
* From: Utah Hdr: rmp.h 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
*/
@ -75,21 +77,21 @@
*/
struct hp_hdr {
u_char daddr[RMP_ADDRLEN];
u_char saddr[RMP_ADDRLEN];
u_short len;
u_int8_t daddr[RMP_ADDRLEN];
u_int8_t saddr[RMP_ADDRLEN];
u_int16_t len;
};
/*
* HP uses 802.2 LLC with their own local extensions. This struct makes
* sence out of this data (encapsulated in the above 802.3 packet).
* sense out of this data (encapsulated in the above 802.3 packet).
*/
struct hp_llc {
u_char dsap; /* 802.2 DSAP */
u_char ssap; /* 802.2 SSAP */
u_short cntrl; /* 802.2 control field */
u_short filler; /* HP filler (must be zero) */
u_short dxsap; /* HP extended DSAP */
u_short sxsap; /* HP extended SSAP */
u_int8_t dsap; /* 802.2 DSAP */
u_int8_t ssap; /* 802.2 SSAP */
u_int16_t cntrl; /* 802.2 control field */
u_int16_t filler; /* HP filler (must be zero) */
u_int16_t dxsap; /* HP extended DSAP */
u_int16_t sxsap; /* HP extended SSAP */
};

@ -1,3 +1,5 @@
/* $NetBSD: rmp_var.h,v 1.8 1995/11/14 08:41:44 thorpej Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
* for Software Science (CSS).
@ -38,9 +40,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)rmp_var.h 8.1 (Berkeley) 6/4/93
* from: @(#)rmp_var.h 8.1 (Berkeley) 6/4/93
*
* Utah $Hdr: rmp_var.h 3.1 92/07/06$
* from: Utah Hdr: rmp_var.h 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
*/
@ -100,12 +102,12 @@
sizeof(struct rmp_boot_repl) + s - sizeof(restofpkt))
#define RMPREADSIZE(s) (sizeof(struct hp_hdr) + sizeof(struct hp_llc) + \
sizeof(struct rmp_read_repl) + s - sizeof(restofpkt) \
- sizeof(u_char))
- sizeof(u_int8_t))
#define RMPDONESIZE (sizeof(struct hp_hdr) + sizeof(struct hp_llc) + \
sizeof(struct rmp_boot_done))
#define RMPBOOTDATA 255
#define RMPREADDATA (RMPDATALEN - \
(2*sizeof(u_char)+sizeof(u_short)+sizeof(u_word)))
(2*sizeof(u_int8_t)+sizeof(u_int16_t)+sizeof(u_word)))
/*
* This protocol defines some field sizes as "rest of ethernet packet".
@ -117,9 +119,9 @@ typedef char restofpkt;
/*
* Due to the RMP packet layout, we'll run into alignment problems
* on machines that cant access words on half-word boundaries. If
* you know that your machine does not suffer from this problem,
* add it to the hp300 #define below.
* on machines that can't access (or don't, by default, align) words
* on half-word boundaries. If you know that your machine does not suffer
* from this problem, add it to the vax/tahoe/m68k #define below.
*
* The following macros are used to deal with this problem:
* WORDZE(w) Return True if u_word `w' is zero, False otherwise.
@ -127,25 +129,25 @@ typedef char restofpkt;
* COPYWORD(w1,w2) Copy u_word `w1' to `w2'.
* GETWORD(w,i) Copy u_word `w' into int `i'.
* PUTWORD(i,w) Copy int `i' into u_word `w'.
*
* N.B. We do not support little endian alignment-challenged machines.
*
* N.B. Endianness is handled by use of ntohl/htonl
*/
#if defined(vax) || defined(tahoe) || defined(hp300)
#if defined(__vax__) || defined(__tahoe__) || defined(__m68k__)
typedef u_int u_word;
typedef u_int32_t u_word;
#define WORDZE(w) ((w) == 0)
#define ZEROWORD(w) (w) = 0
#define COPYWORD(w1,w2) (w2) = (w1)
#define GETWORD(w, i) (i) = (w)
#define PUTWORD(i, w) (w) = (i)
#define GETWORD(w, i) (i) = ntohl(w)
#define PUTWORD(i, w) (w) = htonl(i)
#else
#define _WORD_HIGHPART 0 /* XXX: assume Big Endian for now */
#define _WORD_HIGHPART 0
#define _WORD_LOWPART 1
typedef struct _uword { u_short val[2]; } u_word;
typedef struct _uword { u_int16_t val[2]; } u_word;
#define WORDZE(w) \
((w.val[_WORD_HIGHPART] == 0) && (w.val[_WORD_LOWPART] == 0))
@ -156,10 +158,10 @@ typedef struct _uword { u_short val[2]; } u_word;
(w2).val[_WORD_LOWPART] = (w1).val[_WORD_LOWPART]; \
}
#define GETWORD(w, i) \
(i) = (((u_int)(w).val[_WORD_HIGHPART]) << 16) | (w).val[_WORD_LOWPART]
(i) = (((u_int32_t)ntohs((w).val[_WORD_HIGHPART])) << 16) | ntohs((w).val[_WORD_LOWPART])
#define PUTWORD(i, w) \
{ (w).val[_WORD_HIGHPART] = (u_short) (((i) >> 16) & 0xffff); \
(w).val[_WORD_LOWPART] = (u_short) (i & 0xffff); \
{ (w).val[_WORD_HIGHPART] = htons((u_int16_t) ((i >> 16) & 0xffff)); \
(w).val[_WORD_LOWPART] = htons((u_int16_t) (i & 0xffff)); \
}
#endif
@ -169,53 +171,53 @@ typedef struct _uword { u_short val[2]; } u_word;
*/
struct rmp_raw { /* generic RMP packet */
u_char rmp_type; /* packet type */
u_char rmp_rawdata[RMPDATALEN-1];
u_int8_t rmp_type; /* packet type */
u_int8_t rmp_rawdata[RMPDATALEN-1];
};
struct rmp_boot_req { /* boot request */
u_char rmp_type; /* packet type (RMP_BOOT_REQ) */
u_char rmp_retcode; /* return code (0) */
u_word rmp_seqno; /* sequence number (real time clock) */
u_short rmp_session; /* session id (normally 0) */
u_short rmp_version; /* protocol version (RMP_VERSION) */
char rmp_machtype[RMP_MACHLEN]; /* machine type */
u_char rmp_flnmsize; /* length of rmp_flnm */
u_int8_t rmp_type; /* packet type (RMP_BOOT_REQ) */
u_int8_t rmp_retcode; /* return code (0) */
u_word rmp_seqno; /* sequence number (real time clock) */
u_int16_t rmp_session; /* session id (normally 0) */
u_int16_t rmp_version; /* protocol version (RMP_VERSION) */
char rmp_machtype[RMP_MACHLEN]; /* machine type */
u_int8_t rmp_flnmsize; /* length of rmp_flnm */
restofpkt rmp_flnm; /* name of file to be read */
};
struct rmp_boot_repl { /* boot reply */
u_char rmp_type; /* packet type (RMP_BOOT_REPL) */
u_char rmp_retcode; /* return code (normally 0) */
u_word rmp_seqno; /* sequence number (from boot req) */
u_short rmp_session; /* session id (generated) */
u_short rmp_version; /* protocol version (RMP_VERSION) */
u_char rmp_flnmsize; /* length of rmp_flnm */
u_int8_t rmp_type; /* packet type (RMP_BOOT_REPL) */
u_int8_t rmp_retcode; /* return code (normally 0) */
u_word rmp_seqno; /* sequence number (from boot req) */
u_int16_t rmp_session; /* session id (generated) */
u_int16_t rmp_version; /* protocol version (RMP_VERSION) */
u_int8_t rmp_flnmsize; /* length of rmp_flnm */
restofpkt rmp_flnm; /* name of file (from boot req) */
};
struct rmp_read_req { /* read request */
u_char rmp_type; /* packet type (RMP_READ_REQ) */
u_char rmp_retcode; /* return code (0) */
u_word rmp_offset; /* file relative byte offset */
u_short rmp_session; /* session id (from boot repl) */
u_short rmp_size; /* max no of bytes to send */
u_int8_t rmp_type; /* packet type (RMP_READ_REQ) */
u_int8_t rmp_retcode; /* return code (0) */
u_word rmp_offset; /* file relative byte offset */
u_int16_t rmp_session; /* session id (from boot repl) */
u_int16_t rmp_size; /* max no of bytes to send */
};
struct rmp_read_repl { /* read reply */
u_char rmp_type; /* packet type (RMP_READ_REPL) */
u_char rmp_retcode; /* return code (normally 0) */
u_word rmp_offset; /* byte offset (from read req) */
u_short rmp_session; /* session id (from read req) */
u_int8_t rmp_type; /* packet type (RMP_READ_REPL) */
u_int8_t rmp_retcode; /* return code (normally 0) */
u_word rmp_offset; /* byte offset (from read req) */
u_int16_t rmp_session; /* session id (from read req) */
restofpkt rmp_data; /* data (max size from read req) */
u_char rmp_unused; /* padding to 16-bit boundary */
u_int8_t rmp_unused; /* padding to 16-bit boundary */
};
struct rmp_boot_done { /* boot complete */
u_char rmp_type; /* packet type (RMP_BOOT_DONE) */
u_char rmp_retcode; /* return code (0) */
u_word rmp_unused; /* not used (0) */
u_short rmp_session; /* session id (from read repl) */
u_int8_t rmp_type; /* packet type (RMP_BOOT_DONE) */
u_int8_t rmp_retcode; /* return code (0) */
u_word rmp_unused; /* not used (0) */
u_int16_t rmp_session; /* session id (from read repl) */
};
struct rmp_packet {
@ -236,7 +238,7 @@ struct rmp_packet {
*/
#define r_type rmp_proto.rmp_raw.rmp_type
#define r_data rmp_proto.rmp_raw.rmp_data
#define r_data rmp_proto.rmp_raw.rmp_rawdata
#define r_brq rmp_proto.rmp_brq
#define r_brpl rmp_proto.rmp_brpl
#define r_rrq rmp_proto.rmp_rrq

@ -1,3 +1,5 @@
/* $NetBSD: rmpproto.c,v 1.7 1996/02/01 21:27:46 mycroft Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
* for Software Science (CSS).
@ -38,14 +40,15 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)rmpproto.c 8.1 (Berkeley) 6/4/93
* from: @(#)rmpproto.c 8.1 (Berkeley) 6/4/93
*
* Utah $Hdr: rmpproto.c 3.1 92/07/06$
* From: Utah Hdr: rmpproto.c 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
*/
#ifndef lint
static char sccsid[] = "@(#)rmpproto.c 8.1 (Berkeley) 6/4/93";
/*static char sccsid[] = "@(#)rmpproto.c 8.1 (Berkeley) 6/4/93";*/
static char rcsid[] = "$NetBSD: rmpproto.c,v 1.7 1996/02/01 21:27:46 mycroft Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -111,7 +114,7 @@ ProcessPacket(rconn, client)
* of active connections, otherwise delete it since
* an error was encountered.
*/
if (rmp->r_brq.rmp_session == RMP_PROBESID) {
if (ntohs(rmp->r_brq.rmp_session) == RMP_PROBESID) {
if (WORDZE(rmp->r_brq.rmp_seqno))
(void) SendServerID(rconnout);
else
@ -177,7 +180,7 @@ SendServerID(rconn)
{
register struct rmp_packet *rpl;
register char *src, *dst;
register u_char *size;
register u_int8_t *size;
rpl = &rconn->rmp; /* cache ptr to RMP packet */
@ -188,7 +191,7 @@ SendServerID(rconn)
rpl->r_brpl.rmp_retcode = RMP_E_OKAY;
ZEROWORD(rpl->r_brpl.rmp_seqno);
rpl->r_brpl.rmp_session = 0;
rpl->r_brpl.rmp_version = RMP_VERSION;
rpl->r_brpl.rmp_version = htons(RMP_VERSION);
size = &rpl->r_brpl.rmp_flnmsize; /* ptr to length of host name */
@ -231,7 +234,8 @@ SendFileNo(req, rconn, filelist)
{
register struct rmp_packet *rpl;
register char *src, *dst;
register u_char *size, i;
register u_int8_t *size;
register int i;
GETWORD(req->r_brpl.rmp_seqno, i); /* SeqNo is really FileNo */
rpl = &rconn->rmp; /* cache ptr to RMP packet */
@ -243,7 +247,7 @@ SendFileNo(req, rconn, filelist)
PUTWORD(i, rpl->r_brpl.rmp_seqno);
i--;
rpl->r_brpl.rmp_session = 0;
rpl->r_brpl.rmp_version = RMP_VERSION;
rpl->r_brpl.rmp_version = htons(RMP_VERSION);
size = &rpl->r_brpl.rmp_flnmsize; /* ptr to length of filename */
*size = 0; /* init length to zero */
@ -296,7 +300,7 @@ SendBootRepl(req, rconn, filelist)
RMPCONN *oldconn;
register struct rmp_packet *rpl;
register char *src, *dst1, *dst2;
register u_char i;
register u_int8_t i;
/*
* If another connection already exists, delete it since we
@ -315,8 +319,8 @@ SendBootRepl(req, rconn, filelist)
*/
rpl->r_brpl.rmp_type = RMP_BOOT_REPL;
COPYWORD(req->r_brq.rmp_seqno, rpl->r_brpl.rmp_seqno);
rpl->r_brpl.rmp_session = GenSessID();
rpl->r_brpl.rmp_version = RMP_VERSION;
rpl->r_brpl.rmp_session = htons(GenSessID());
rpl->r_brpl.rmp_version = htons(RMP_VERSION);
rpl->r_brpl.rmp_flnmsize = req->r_brq.rmp_flnmsize;
/*
@ -398,7 +402,7 @@ int
SendReadRepl(rconn)
RMPCONN *rconn;
{
int retval;
int retval = 0;
RMPCONN *oldconn;
register struct rmp_packet *rpl, *req;
register int size = 0;
@ -428,9 +432,9 @@ SendReadRepl(rconn)
/*
* Make sure Session ID's match.
*/
if (req->r_rrq.rmp_session !=
((rpl->r_type == RMP_BOOT_REPL)? rpl->r_brpl.rmp_session:
rpl->r_rrpl.rmp_session)) {
if (ntohs(req->r_rrq.rmp_session) !=
((rpl->r_type == RMP_BOOT_REPL)? ntohs(rpl->r_brpl.rmp_session):
ntohs(rpl->r_rrpl.rmp_session))) {
syslog(LOG_ERR, "SendReadRepl: bad session id (%s)",
EnetStr(rconn));
rpl->r_rrpl.rmp_retcode = RMP_E_BADSID;
@ -446,8 +450,8 @@ SendReadRepl(rconn)
* to work. This is necessary for bpfwrite() on machines
* with MCLBYTES less than 1514.
*/
if (req->r_rrq.rmp_size > RMPREADDATA)
req->r_rrq.rmp_size = RMPREADDATA;
if (ntohs(req->r_rrq.rmp_size) > RMPREADDATA)
req->r_rrq.rmp_size = htons(RMPREADDATA);
/*
* Position read head on file according to info in request packet.
@ -465,7 +469,7 @@ SendReadRepl(rconn)
* Read data directly into reply packet.
*/
if ((size = read(oldconn->bootfd, &rpl->r_rrpl.rmp_data,
(int) req->r_rrq.rmp_size)) <= 0) {
(int) ntohs(req->r_rrq.rmp_size))) <= 0) {
if (size < 0) {
syslog(LOG_ERR, "SendReadRepl: read: %m (%s)",
EnetStr(rconn));
@ -533,9 +537,9 @@ BootDone(rconn)
/*
* Make sure Session ID's match.
*/
if (rconn->rmp.r_rrq.rmp_session !=
((rpl->r_type == RMP_BOOT_REPL)? rpl->r_brpl.rmp_session:
rpl->r_rrpl.rmp_session)) {
if (ntohs(rconn->rmp.r_rrq.rmp_session) !=
((rpl->r_type == RMP_BOOT_REPL)? ntohs(rpl->r_brpl.rmp_session):
ntohs(rpl->r_rrpl.rmp_session))) {
syslog(LOG_ERR, "BootDone: bad session id (%s)",
EnetStr(rconn));
return(0);
@ -570,13 +574,18 @@ SendPacket(rconn)
*/
bcopy((char *)&rconn->rmp.hp_hdr.saddr[0],
(char *)&rconn->rmp.hp_hdr.daddr[0], RMP_ADDRLEN);
#ifdef __FreeBSD__
/* BPF (incorrectly) wants this in host order. */
rconn->rmp.hp_hdr.len = rconn->rmplen - sizeof(struct hp_hdr);
#else
rconn->rmp.hp_hdr.len = htons(rconn->rmplen - sizeof(struct hp_hdr));
#endif
/*
* Reverse 802.2/HP Extended Source & Destination Access Pts.
*/
rconn->rmp.hp_llc.dxsap = HPEXT_SXSAP;
rconn->rmp.hp_llc.sxsap = HPEXT_DXSAP;
rconn->rmp.hp_llc.dxsap = htons(HPEXT_SXSAP);
rconn->rmp.hp_llc.sxsap = htons(HPEXT_DXSAP);
/*
* Last time this connection was active.

@ -1,3 +1,5 @@
/* $NetBSD: utils.c,v 1.6 1995/11/14 08:41:47 thorpej Exp $ */
/*
* Copyright (c) 1988, 1992 The University of Utah and the Center
* for Software Science (CSS).
@ -38,18 +40,18 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)utils.c 8.2 (Berkeley) 2/22/94
* from: @(#)utils.c 8.1 (Berkeley) 6/4/93
*
* Utah $Hdr: utils.c 3.1 92/07/06$
* From: Utah Hdr: utils.c 3.1 92/07/06
* Author: Jeff Forys, University of Utah CSS
*/
#ifndef lint
static char sccsid[] = "@(#)utils.c 8.2 (Berkeley) 2/22/94";
/*static char sccsid[] = "@(#)utils.c 8.1 (Berkeley) 6/4/93";*/
static char rcsid[] = "$NetBSD: utils.c,v 1.6 1995/11/14 08:41:47 thorpej Exp $";
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <fcntl.h>
#include <signal.h>
@ -85,7 +87,7 @@ DispPkt(rconn, direct)
struct tm *tmp;
register struct rmp_packet *rmp;
int i, omask;
u_int t;
u_int32_t t;
/*
* Since we will be working with RmpConns as well as DbgFp, we
@ -113,11 +115,11 @@ DispPkt(rconn, direct)
/* display IEEE 802.2 Logical Link Control header */
(void) fprintf(DbgFp, "\t802.2 LLC: DSAP:%x SSAP:%x CTRL:%x\n",
rmp->hp_llc.dsap, rmp->hp_llc.ssap, rmp->hp_llc.cntrl);
rmp->hp_llc.dsap, rmp->hp_llc.ssap, ntohs(rmp->hp_llc.cntrl));
/* display HP extensions to 802.2 Logical Link Control header */
(void) fprintf(DbgFp, "\tHP Ext: DXSAP:%x SXSAP:%x\n",
rmp->hp_llc.dxsap, rmp->hp_llc.sxsap);
ntohs(rmp->hp_llc.dxsap), ntohs(rmp->hp_llc.sxsap));
/*
* Display information about RMP packet using type field to
@ -127,7 +129,7 @@ DispPkt(rconn, direct)
case RMP_BOOT_REQ: /* boot request */
(void) fprintf(DbgFp, "\tBoot Request:");
GETWORD(rmp->r_brq.rmp_seqno, t);
if (rmp->r_brq.rmp_session == RMP_PROBESID) {
if (ntohs(rmp->r_brq.rmp_session) == RMP_PROBESID) {
if (WORDZE(rmp->r_brq.rmp_seqno))
fputs(" (Send Server ID)", DbgFp);
else
@ -135,8 +137,8 @@ DispPkt(rconn, direct)
}
(void) fputc('\n', DbgFp);
(void) fprintf(DbgFp, BootFmt, rmp->r_brq.rmp_retcode,
t, rmp->r_brq.rmp_session,
rmp->r_brq.rmp_version);
t, ntohs(rmp->r_brq.rmp_session),
ntohs(rmp->r_brq.rmp_version));
(void) fprintf(DbgFp, "\n\t\tMachine Type: ");
for (i = 0; i < RMP_MACHLEN; i++)
(void) fputc(rmp->r_brq.rmp_machtype[i], DbgFp);
@ -146,23 +148,23 @@ DispPkt(rconn, direct)
fprintf(DbgFp, "\tBoot Reply:\n");
GETWORD(rmp->r_brpl.rmp_seqno, t);
(void) fprintf(DbgFp, BootFmt, rmp->r_brpl.rmp_retcode,
t, rmp->r_brpl.rmp_session,
rmp->r_brpl.rmp_version);
t, ntohs(rmp->r_brpl.rmp_session),
ntohs(rmp->r_brpl.rmp_version));
DspFlnm(rmp->r_brpl.rmp_flnmsize,&rmp->r_brpl.rmp_flnm);
break;
case RMP_READ_REQ: /* read request */
(void) fprintf(DbgFp, "\tRead Request:\n");
GETWORD(rmp->r_rrq.rmp_offset, t);
(void) fprintf(DbgFp, ReadFmt, rmp->r_rrq.rmp_retcode,
t, rmp->r_rrq.rmp_session);
t, ntohs(rmp->r_rrq.rmp_session));
(void) fprintf(DbgFp, "\t\tNoOfBytes: %u\n",
rmp->r_rrq.rmp_size);
ntohs(rmp->r_rrq.rmp_size));
break;
case RMP_READ_REPL: /* read reply */
(void) fprintf(DbgFp, "\tRead Reply:\n");
GETWORD(rmp->r_rrpl.rmp_offset, t);
(void) fprintf(DbgFp, ReadFmt, rmp->r_rrpl.rmp_retcode,
t, rmp->r_rrpl.rmp_session);
t, ntohs(rmp->r_rrpl.rmp_session));
(void) fprintf(DbgFp, "\t\tNoOfBytesSent: %d\n",
rconn->rmplen - RMPREADSIZE(0));
break;
@ -170,7 +172,7 @@ DispPkt(rconn, direct)
(void) fprintf(DbgFp, "\tBoot Complete:\n");
(void) fprintf(DbgFp, "\t\tRetCode:%u SessID:%x\n",
rmp->r_done.rmp_retcode,
rmp->r_done.rmp_session);
ntohs(rmp->r_done.rmp_session));
break;
default: /* ??? */
(void) fprintf(DbgFp, "\tUnknown Type:(%d)\n",
@ -202,32 +204,30 @@ DispPkt(rconn, direct)
** Warnings:
** - The return value points to a static buffer; it must
** be copied if it's to be saved.
** - For speed, we assume a u_char consists of 8 bits.
*/
char *
GetEtherAddr(addr)
u_char *addr;
u_int8_t *addr;
{
static char Hex[] = "0123456789abcdef";
static char etherstr[RMP_ADDRLEN*3];
register int i;
register char *cp1, *cp2;
register char *cp;
/*
* For each byte in `addr', convert it to "<hexchar><hexchar>:".
* The last byte does not get a trailing `:' appended.
*/
i = 0;
cp1 = (char *)addr;
cp2 = etherstr;
cp = etherstr;
for(;;) {
*cp2++ = Hex[*cp1 >> 4 & 0xf];
*cp2++ = Hex[*cp1++ & 0xf];
*cp++ = Hex[*addr >> 4 & 0xf];
*cp++ = Hex[*addr++ & 0xf];
if (++i == RMP_ADDRLEN)
break;
*cp2++ = ':';
*cp++ = ':';
}
*cp2 = '\0';
*cp = '\0';
return(etherstr);
}
@ -253,7 +253,7 @@ DspFlnm(size, flnm)
{
register int i;
(void) fprintf(DbgFp, "\n\t\tFile Name (%d): <", size);
(void) fprintf(DbgFp, "\n\t\tFile Name (%u): <", size);
for (i = 0; i < size; i++)
(void) fputc(*flnm++, DbgFp);
(void) fputs(">\n", DbgFp);
@ -275,7 +275,7 @@ DspFlnm(size, flnm)
*/
CLIENT *
NewClient(addr)
u_char *addr;
u_int8_t *addr;
{
CLIENT *ctmp;