summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/rbootd/bpf.c32
-rw-r--r--usr.sbin/rbootd/parseconf.c48
-rw-r--r--usr.sbin/rbootd/rbootd.c50
-rw-r--r--usr.sbin/rbootd/rmp_var.h4
-rw-r--r--usr.sbin/rbootd/rmpproto.c185
-rw-r--r--usr.sbin/rbootd/utils.c157
6 files changed, 217 insertions, 259 deletions
diff --git a/usr.sbin/rbootd/bpf.c b/usr.sbin/rbootd/bpf.c
index f016ed12090..5812c354653 100644
--- a/usr.sbin/rbootd/bpf.c
+++ b/usr.sbin/rbootd/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.10 2002/05/29 18:39:00 deraadt Exp $ */
+/* $OpenBSD: bpf.c,v 1.11 2002/12/13 23:14:07 deraadt Exp $ */
/* $NetBSD: bpf.c,v 1.5.2.1 1995/11/14 08:45:42 thorpej Exp $ */
/*
@@ -49,7 +49,7 @@
#ifndef lint
/*static char sccsid[] = "@(#)bpf.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$OpenBSD: bpf.c,v 1.10 2002/05/29 18:39:00 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: bpf.c,v 1.11 2002/12/13 23:14:07 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -87,7 +87,7 @@ static u_int8_t *BpfPkt = NULL;
** If an error is encountered, the program terminates here.
*/
int
-BpfOpen()
+BpfOpen(void)
{
struct ifreq ifr;
char bpfdev[32];
@@ -125,7 +125,7 @@ BpfOpen()
}
if (n != DLT_EN10MB) {
syslog(LOG_ERR,"bpf: %s: data-link type %d unsupported",
- IntfName, n);
+ IntfName, n);
DoExit();
}
@@ -171,7 +171,7 @@ BpfOpen()
if (BpfPkt == NULL) {
syslog(LOG_ERR, "bpf: out of memory (%u bytes for bpfpkt)",
- BpfLen);
+ BpfLen);
DoExit();
}
@@ -193,7 +193,7 @@ BpfOpen()
};
#undef RMP
static struct bpf_program bpf_pgm = {
- sizeof(bpf_insn)/sizeof(bpf_insn[0]), bpf_insn
+ sizeof(bpf_insn)/sizeof(bpf_insn[0]), bpf_insn
};
if (ioctl(BpfFd, BIOCSETF, (caddr_t)&bpf_pgm) < 0) {
@@ -221,8 +221,7 @@ BpfOpen()
** None.
*/
char *
-BpfGetIntfName(errmsg)
- char **errmsg;
+BpfGetIntfName(char **errmsg)
{
struct ifreq ibuf[8], *ifrp, *ifend, *mp;
struct ifconf ifc;
@@ -259,7 +258,7 @@ BpfGetIntfName(errmsg)
#endif
ifrp = ibuf;
ifend = (struct ifreq *)((char *)ibuf + ifc.ifc_len);
-
+
mp = 0;
minunit = 666;
for (; ifrp < ifend; ++ifrp) {
@@ -315,9 +314,7 @@ BpfGetIntfName(errmsg)
** None.
*/
int
-BpfRead(rconn, doread)
- RMPCONN *rconn;
- int doread;
+BpfRead(RMPCONN *rconn, int doread)
{
int datlen, caplen, hdrlen;
static u_int8_t *bp = NULL, *ep = NULL;
@@ -349,15 +346,15 @@ BpfRead(rconn, doread)
if (caplen != datlen)
syslog(LOG_ERR,
- "bpf: short packet dropped (%d of %d bytes)",
- caplen, datlen);
+ "bpf: short packet dropped (%d of %d bytes)",
+ caplen, datlen);
else if (caplen > sizeof(struct rmp_packet))
syslog(LOG_ERR, "bpf: large packet dropped (%d bytes)",
- caplen);
+ caplen);
else {
rconn->rmplen = caplen;
bcopy((char *)&bhp->bh_tstamp, (char *)&rconn->tstamp,
- sizeof(struct timeval));
+ sizeof(struct timeval));
bcopy((char *)bp + hdrlen, (char *)&rconn->rmp, caplen);
}
bp += BPF_WORDALIGN(caplen + hdrlen);
@@ -381,8 +378,7 @@ BpfRead(rconn, doread)
** None.
*/
int
-BpfWrite(rconn)
- RMPCONN *rconn;
+BpfWrite(RMPCONN *rconn)
{
if (write(BpfFd, (char *)&rconn->rmp, rconn->rmplen) < 0) {
syslog(LOG_ERR, "write: %s: %m", EnetStr(rconn));
diff --git a/usr.sbin/rbootd/parseconf.c b/usr.sbin/rbootd/parseconf.c
index feca9ddd7e3..60d2a515d4d 100644
--- a/usr.sbin/rbootd/parseconf.c
+++ b/usr.sbin/rbootd/parseconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parseconf.c,v 1.6 2002/03/14 16:44:25 mpech Exp $ */
+/* $OpenBSD: parseconf.c,v 1.7 2002/12/13 23:14:07 deraadt Exp $ */
/* $NetBSD: parseconf.c,v 1.4 1995/10/06 05:12:16 thorpej Exp $ */
/*
@@ -49,7 +49,7 @@
#ifndef lint
/*static char sccsid[] = "@(#)parseconf.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$OpenBSD: parseconf.c,v 1.6 2002/03/14 16:44:25 mpech Exp $";
+static char rcsid[] = "$OpenBSD: parseconf.c,v 1.7 2002/12/13 23:14:07 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -82,16 +82,14 @@ static char rcsid[] = "$OpenBSD: parseconf.c,v 1.6 2002/03/14 16:44:25 mpech Exp
** to create a linked list of default boot files.
*/
int
-ParseConfig()
+ParseConfig(void)
{
- FILE *fp;
- CLIENT *client;
- u_int8_t *addr;
- char line[C_LINELEN];
- char *cp, *bcp;
- int i, j;
- int linecnt = 0;
+ char line[C_LINELEN], *cp, *bcp;
+ int i, j, linecnt = 0;
sigset_t mask, omask;
+ u_int8_t *addr;
+ CLIENT *client;
+ FILE *fp;
if (BootAny) /* ignore config file */
return(1);
@@ -100,7 +98,7 @@ ParseConfig()
if ((fp = fopen(ConfigFile, "r")) == NULL) {
syslog(LOG_ERR, "ParseConfig: can't open config file (%s)",
- ConfigFile);
+ ConfigFile);
return(0);
}
@@ -147,8 +145,8 @@ ParseConfig()
*/
if ((addr = ParseAddr(bcp)) == NULL) {
syslog(LOG_ERR,
- "ParseConfig: line %d: cant parse <%s>",
- linecnt, bcp);
+ "ParseConfig: line %d: cant parse <%s>",
+ linecnt, bcp);
continue;
}
@@ -163,10 +161,10 @@ ParseConfig()
* list of boot-able files.
*/
i = 0;
- if (bcp == cp) /* no files spec'd */
+ if (bcp == cp) { /* no files spec'd */
for (; i < C_MAXFILE && BootFiles[i] != NULL; i++)
client->files[i] = BootFiles[i];
- else {
+ } else {
do {
/*
* For each boot file spec'd, make sure it's
@@ -175,8 +173,9 @@ ParseConfig()
*/
for (j = 0; ; j++) {
if (j==C_MAXFILE||BootFiles[j]==NULL) {
- syslog(LOG_ERR, "ParseConfig: line %d: no boot file (%s)",
- linecnt, bcp);
+ syslog(LOG_ERR,
+ "ParseConfig: line %d: no boot file (%s)",
+ linecnt, bcp);
break;
}
if (STREQN(BootFiles[j], bcp)) {
@@ -199,7 +198,7 @@ ParseConfig()
* the entire record is invalidated.
*/
if (i == 0) {
- FreeClient(client);
+ FreeClient(client);
continue;
}
}
@@ -214,9 +213,7 @@ ParseConfig()
}
(void) fclose(fp); /* close config file */
-
sigprocmask(SIG_SETMASK, &omask, NULL); /* reset signal mask */
-
return(1); /* return success */
}
@@ -250,13 +247,12 @@ ParseConfig()
** be copied if it's to be saved.
*/
u_int8_t *
-ParseAddr(str)
- char *str;
+ParseAddr(char *str)
{
static u_int8_t addr[RMP_ADDRLEN];
- char *cp;
- unsigned int i;
int part, subpart;
+ unsigned int i;
+ char *cp;
bzero((char *)&addr[0], RMP_ADDRLEN); /* zero static buffer */
@@ -314,11 +310,11 @@ ParseAddr(str)
** called to re-order it's list of boot file pointers.
*/
int
-GetBootFiles()
+GetBootFiles(void)
{
- DIR *dfd;
struct stat statb;
struct dirent *dp;
+ DIR *dfd;
int i;
/*
diff --git a/usr.sbin/rbootd/rbootd.c b/usr.sbin/rbootd/rbootd.c
index 46364551b41..dde7cb3ce27 100644
--- a/usr.sbin/rbootd/rbootd.c
+++ b/usr.sbin/rbootd/rbootd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rbootd.c,v 1.15 2002/07/16 23:38:52 mickey Exp $ */
+/* $OpenBSD: rbootd.c,v 1.16 2002/12/13 23:14:07 deraadt Exp $ */
/* $NetBSD: rbootd.c,v 1.5 1995/10/06 05:12:17 thorpej Exp $ */
/*
@@ -55,7 +55,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "@(#)rbootd.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$OpenBSD: rbootd.c,v 1.15 2002/07/16 23:38:52 mickey Exp $";
+static char rcsid[] = "$OpenBSD: rbootd.c,v 1.16 2002/12/13 23:14:07 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -94,9 +94,7 @@ void DoTimeout(void);
CLIENT *FindClient(RMPCONN *);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int c, fd, maxfds;
fd_set rset;
@@ -120,14 +118,14 @@ main(argc, argv)
* Parse any arguments.
*/
while ((c = getopt(argc, argv, "adi:")) != -1)
- switch(c) {
- case 'a':
+ switch (c) {
+ case 'a':
BootAny++;
break;
- case 'd':
+ case 'd':
DebugFlg++;
break;
- case 'i':
+ case 'i':
IntfName = optarg;
break;
}
@@ -300,8 +298,8 @@ main(argc, argv)
client = NULL;
} else if ((client=FindClient(&rconn))==NULL) {
syslog(LOG_INFO,
- "%s: boot packet ignored",
- EnetStr(&rconn));
+ "%s: boot packet ignored",
+ EnetStr(&rconn));
sigprocmask(SIG_SETMASK, &omask, NULL);
continue;
}
@@ -327,7 +325,7 @@ main(argc, argv)
** - Timed out connections in `RmpConns' will be freed.
*/
void
-DoTimeout()
+DoTimeout(void)
{
RMPCONN *rtmp;
struct timeval now;
@@ -341,7 +339,7 @@ DoTimeout()
for (rtmp = RmpConns; rtmp != NULL; rtmp = rtmp->next)
if ((rtmp->tstamp.tv_sec + RMP_TIMEOUT) < now.tv_sec) {
syslog(LOG_WARNING, "%s: connection timed out (%u)",
- EnetStr(rtmp), rtmp->rmp.r_type);
+ EnetStr(rtmp), rtmp->rmp.r_type);
RemoveConn(rtmp);
}
}
@@ -362,16 +360,14 @@ DoTimeout()
** - This routine must be called with SIGHUP blocked since
** a reconfigure can invalidate the information returned.
*/
-
CLIENT *
-FindClient(rconn)
- RMPCONN *rconn;
+FindClient(RMPCONN *rconn)
{
CLIENT *ctmp;
for (ctmp = Clients; ctmp != NULL; ctmp = ctmp->next)
if (bcmp((char *)&rconn->rmp.hp_hdr.saddr[0],
- (char *)&ctmp->addr[0], RMP_ADDRLEN) == 0)
+ (char *)&ctmp->addr[0], RMP_ADDRLEN) == 0)
break;
return(ctmp);
@@ -390,8 +386,7 @@ FindClient(rconn)
** - This process ceases to exist.
*/
void
-Exit(sig)
- int sig;
+Exit(int sig)
{
struct syslog_data sdata = SYSLOG_DATA_INIT;
@@ -400,7 +395,7 @@ Exit(sig)
}
void
-DoExit()
+DoExit(void)
{
syslog(LOG_ERR, "going down on fatal error");
exit(1);
@@ -424,14 +419,13 @@ DoExit()
** - This routine must be called with SIGHUP blocked.
*/
void
-ReConfig(signo)
- int signo;
+ReConfig(int signo)
{
doreconfig = 1;
}
void
-DoReConfig()
+DoReConfig(void)
{
syslog(LOG_NOTICE, "reconfiguring boot server");
@@ -457,14 +451,13 @@ DoReConfig()
** - Debug file is closed.
*/
void
-DebugOff(signo)
- int signo;
+DebugOff(int signo)
{
dodebugoff = 1;
}
void
-DoDebugOff()
+DoDebugOff(void)
{
if (DbgFp != NULL)
(void) fclose(DbgFp);
@@ -486,14 +479,13 @@ DoDebugOff()
** otherwise do nothing.
*/
void
-DebugOn(signo)
- int signo;
+DebugOn(int signo)
{
dodebugon = 1;
}
void
-DoDebugOn()
+DoDebugOn(void)
{
if (DbgFp == NULL) {
if ((DbgFp = fopen(DbgFile, "w")) == NULL)
diff --git a/usr.sbin/rbootd/rmp_var.h b/usr.sbin/rbootd/rmp_var.h
index c2021b93e33..f5011d11db0 100644
--- a/usr.sbin/rbootd/rmp_var.h
+++ b/usr.sbin/rbootd/rmp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rmp_var.h,v 1.3 2001/01/17 00:33:04 pjanzen Exp $ */
+/* $OpenBSD: rmp_var.h,v 1.4 2002/12/13 23:14:07 deraadt Exp $ */
/* $NetBSD: rmp_var.h,v 1.7.2.1 1995/11/14 08:45:43 thorpej Exp $ */
/*
@@ -130,7 +130,7 @@ 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. Endianness is handled by use of ntohl/htonl
*/
#if defined(__vax__) || defined(__tahoe__) || defined(__m68k__)
diff --git a/usr.sbin/rbootd/rmpproto.c b/usr.sbin/rbootd/rmpproto.c
index b423d7da410..8536db967f7 100644
--- a/usr.sbin/rbootd/rmpproto.c
+++ b/usr.sbin/rbootd/rmpproto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rmpproto.c,v 1.7 2002/03/14 16:44:25 mpech Exp $ */
+/* $OpenBSD: rmpproto.c,v 1.8 2002/12/13 23:14:07 deraadt Exp $ */
/* $NetBSD: rmpproto.c,v 1.5.2.1 1995/11/14 08:45:44 thorpej Exp $ */
/*
@@ -49,7 +49,7 @@
#ifndef lint
/*static char sccsid[] = "@(#)rmpproto.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$OpenBSD: rmpproto.c,v 1.7 2002/03/14 16:44:25 mpech Exp $";
+static char rcsid[] = "$OpenBSD: rmpproto.c,v 1.8 2002/12/13 23:14:07 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -86,80 +86,75 @@ static char rcsid[] = "$OpenBSD: rmpproto.c,v 1.7 2002/03/14 16:44:25 mpech Exp
** sent to the host that sent the packet.
*/
void
-ProcessPacket(rconn, client)
- RMPCONN *rconn;
- CLIENT *client;
+ProcessPacket(RMPCONN *rconn, CLIENT *client)
{
- struct rmp_packet *rmp;
+ struct rmp_packet *rmp = &rconn->rmp;
RMPCONN *rconnout;
- rmp = &rconn->rmp; /* cache pointer to RMP packet */
-
- switch(rmp->r_type) { /* do what we came here to do */
- case RMP_BOOT_REQ: /* boot request */
- if ((rconnout = NewConn(rconn)) == NULL)
- return;
-
- /*
- * If the Session ID is 0xffff, this is a "probe"
- * packet and we do not want to add the connection
- * to the linked list of active connections. There
- * are two types of probe packets, if the Sequence
- * Number is 0 they want to know our host name, o/w
- * they want the name of the file associated with
- * the number spec'd by the Sequence Number.
- *
- * If this is an actual boot request, open the file
- * and send a reply. If SendBootRepl() does not
- * return 0, add the connection to the linked list
- * of active connections, otherwise delete it since
- * an error was encountered.
- */
- if (ntohs(rmp->r_brq.rmp_session) == RMP_PROBESID) {
- if (WORDZE(rmp->r_brq.rmp_seqno))
- (void) SendServerID(rconnout);
- else
- (void) SendFileNo(rmp, rconnout,
- client? client->files:
- BootFiles);
+ switch (rmp->r_type) { /* do what we came here to do */
+ case RMP_BOOT_REQ: /* boot request */
+ if ((rconnout = NewConn(rconn)) == NULL)
+ return;
+
+ /*
+ * If the Session ID is 0xffff, this is a "probe"
+ * packet and we do not want to add the connection
+ * to the linked list of active connections. There
+ * are two types of probe packets, if the Sequence
+ * Number is 0 they want to know our host name, o/w
+ * they want the name of the file associated with
+ * the number spec'd by the Sequence Number.
+ *
+ * If this is an actual boot request, open the file
+ * and send a reply. If SendBootRepl() does not
+ * return 0, add the connection to the linked list
+ * of active connections, otherwise delete it since
+ * an error was encountered.
+ */
+ if (ntohs(rmp->r_brq.rmp_session) == RMP_PROBESID) {
+ if (WORDZE(rmp->r_brq.rmp_seqno))
+ (void) SendServerID(rconnout);
+ else
+ (void) SendFileNo(rmp, rconnout,
+ client ? client->files : BootFiles);
+ FreeConn(rconnout);
+ } else {
+ if (SendBootRepl(rmp, rconnout,
+ client? client->files: BootFiles))
+ AddConn(rconnout);
+ else
FreeConn(rconnout);
- } else {
- if (SendBootRepl(rmp, rconnout,
- client? client->files: BootFiles))
- AddConn(rconnout);
- else
- FreeConn(rconnout);
- }
- break;
-
- case RMP_BOOT_REPL: /* boot reply (not valid) */
- syslog(LOG_WARNING, "%s: sent a boot reply",
- EnetStr(rconn));
- break;
-
- case RMP_READ_REQ: /* read request */
- /*
- * Send a portion of the boot file.
- */
- (void) SendReadRepl(rconn);
- break;
-
- case RMP_READ_REPL: /* read reply (not valid) */
- syslog(LOG_WARNING, "%s: sent a read reply",
- EnetStr(rconn));
- break;
-
- case RMP_BOOT_DONE: /* boot complete */
- /*
- * Remove the entry from the linked list of active
- * connections.
- */
- (void) BootDone(rconn);
- break;
-
- default: /* unknown RMP packet type */
- syslog(LOG_WARNING, "%s: unknown packet type (%u)",
- EnetStr(rconn), rmp->r_type);
+ }
+ break;
+
+ case RMP_BOOT_REPL: /* boot reply (not valid) */
+ syslog(LOG_WARNING, "%s: sent a boot reply",
+ EnetStr(rconn));
+ break;
+
+ case RMP_READ_REQ: /* read request */
+ /*
+ * Send a portion of the boot file.
+ */
+ (void) SendReadRepl(rconn);
+ break;
+
+ case RMP_READ_REPL: /* read reply (not valid) */
+ syslog(LOG_WARNING, "%s: sent a read reply",
+ EnetStr(rconn));
+ break;
+
+ case RMP_BOOT_DONE: /* boot complete */
+ /*
+ * Remove the entry from the linked list of active
+ * connections.
+ */
+ (void) BootDone(rconn);
+ break;
+
+ default: /* unknown RMP packet type */
+ syslog(LOG_WARNING, "%s: unknown packet type (%u)",
+ EnetStr(rconn), rmp->r_type);
}
}
@@ -176,8 +171,7 @@ ProcessPacket(rconn, client)
** none.
*/
int
-SendServerID(rconn)
- RMPCONN *rconn;
+SendServerID(RMPCONN *rconn)
{
struct rmp_packet *rpl;
char *src, *dst;
@@ -228,10 +222,7 @@ SendServerID(rconn)
** none.
*/
int
-SendFileNo(req, rconn, filelist)
- struct rmp_packet *req;
- RMPCONN *rconn;
- char *filelist[];
+SendFileNo(struct rmp_packet *req, RMPCONN *rconn, char *filelist[])
{
struct rmp_packet *rpl;
char *src, *dst;
@@ -291,10 +282,7 @@ SendFileNo(req, rconn, filelist)
** none.
*/
int
-SendBootRepl(req, rconn, filelist)
- struct rmp_packet *req;
- RMPCONN *rconn;
- char *filelist[];
+SendBootRepl(struct rmp_packet *req, RMPCONN *rconn, char *filelist[])
{
int retval;
char *filename, filepath[RMPBOOTDATA+1];
@@ -309,7 +297,7 @@ SendBootRepl(req, rconn, filelist)
*/
if ((oldconn = FindConn(rconn)) != NULL) {
syslog(LOG_WARNING, "%s: dropping existing connection",
- EnetStr(oldconn));
+ EnetStr(oldconn));
RemoveConn(oldconn);
}
@@ -389,7 +377,7 @@ match:
sendpkt:
syslog(LOG_INFO, "%s: request to boot %s (%s)",
- EnetStr(rconn), filename, retval? "granted": "denied");
+ EnetStr(rconn), filename, retval? "granted": "denied");
rconn->rmplen = RMPBOOTSIZE(rpl->r_brpl.rmp_flnmsize);
@@ -409,8 +397,7 @@ sendpkt:
** none.
*/
int
-SendReadRepl(rconn)
- RMPCONN *rconn;
+SendReadRepl(RMPCONN *rconn)
{
int retval = 0;
RMPCONN *oldconn;
@@ -426,7 +413,7 @@ SendReadRepl(rconn)
if ((oldconn = NewConn(rconn)) == NULL)
return(0);
syslog(LOG_ERR, "SendReadRepl: no active connection (%s)",
- EnetStr(rconn));
+ EnetStr(rconn));
madeconn++;
}
@@ -444,9 +431,9 @@ SendReadRepl(rconn)
*/
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))) {
+ ntohs(rpl->r_rrpl.rmp_session))) {
syslog(LOG_ERR, "SendReadRepl: bad session id (%s)",
- EnetStr(rconn));
+ EnetStr(rconn));
rpl->r_rrpl.rmp_retcode = RMP_E_BADSID;
retval = 1;
goto sendpkt;
@@ -469,7 +456,7 @@ SendReadRepl(rconn)
GETWORD(req->r_rrq.rmp_offset, size);
if (lseek(oldconn->bootfd, (off_t)size, SEEK_SET) < 0) {
syslog(LOG_ERR, "SendReadRepl: lseek: %m (%s)",
- EnetStr(rconn));
+ EnetStr(rconn));
rpl->r_rrpl.rmp_retcode = RMP_E_ABORT;
retval = 1;
goto sendpkt;
@@ -479,10 +466,10 @@ SendReadRepl(rconn)
* Read data directly into reply packet.
*/
if ((size = read(oldconn->bootfd, &rpl->r_rrpl.rmp_data,
- (int) ntohs(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));
+ EnetStr(rconn));
rpl->r_rrpl.rmp_retcode = RMP_E_ABORT;
} else {
rpl->r_rrpl.rmp_retcode = RMP_E_EOF;
@@ -527,8 +514,7 @@ sendpkt:
** none.
*/
int
-BootDone(rconn)
- RMPCONN *rconn;
+BootDone(RMPCONN *rconn)
{
RMPCONN *oldconn;
struct rmp_packet *rpl;
@@ -538,7 +524,7 @@ BootDone(rconn)
*/
if ((oldconn = FindConn(rconn)) == NULL) {
syslog(LOG_ERR, "BootDone: no existing connection (%s)",
- EnetStr(rconn));
+ EnetStr(rconn));
return(0);
}
@@ -549,9 +535,9 @@ BootDone(rconn)
*/
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))) {
+ ntohs(rpl->r_rrpl.rmp_session))) {
syslog(LOG_ERR, "BootDone: bad session id (%s)",
- EnetStr(rconn));
+ EnetStr(rconn));
return(0);
}
@@ -575,15 +561,14 @@ BootDone(rconn)
** none.
*/
int
-SendPacket(rconn)
- RMPCONN *rconn;
+SendPacket(RMPCONN *rconn)
{
/*
* Set Ethernet Destination address to Source (BPF and the enet
* driver will take care of getting our source address set).
*/
bcopy((char *)&rconn->rmp.hp_hdr.saddr[0],
- (char *)&rconn->rmp.hp_hdr.daddr[0], RMP_ADDRLEN);
+ (char *)&rconn->rmp.hp_hdr.daddr[0], RMP_ADDRLEN);
rconn->rmp.hp_hdr.len = htons(rconn->rmplen - sizeof(struct hp_hdr));
/*
diff --git a/usr.sbin/rbootd/utils.c b/usr.sbin/rbootd/utils.c
index 327073f7e45..fd822a87d4a 100644
--- a/usr.sbin/rbootd/utils.c
+++ b/usr.sbin/rbootd/utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utils.c,v 1.6 2002/05/29 18:39:00 deraadt Exp $ */
+/* $OpenBSD: utils.c,v 1.7 2002/12/13 23:14:07 deraadt Exp $ */
/* $NetBSD: utils.c,v 1.5.2.1 1995/11/14 08:45:46 thorpej Exp $ */
/*
@@ -49,7 +49,7 @@
#ifndef lint
/*static char sccsid[] = "@(#)utils.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$OpenBSD: utils.c,v 1.6 2002/05/29 18:39:00 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: utils.c,v 1.7 2002/12/13 23:14:07 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -78,9 +78,7 @@ static char rcsid[] = "$OpenBSD: utils.c,v 1.6 2002/05/29 18:39:00 deraadt Exp $
** None.
*/
void
-DispPkt(rconn, direct)
- RMPCONN *rconn;
- int direct;
+DispPkt(RMPCONN *rconn, int direct)
{
static char BootFmt[] = "\t\tRetCode:%u SeqNo:%lx SessID:%x Vers:%u";
static char ReadFmt[] = "\t\tRetCode:%u Offset:%lx SessID:%x\n";
@@ -107,7 +105,7 @@ DispPkt(rconn, direct)
/* display packet timestamp */
tmp = localtime((time_t *)&rconn->tstamp.tv_sec);
fprintf(DbgFp, "%02d:%02d:%02d.%06ld ", tmp->tm_hour, tmp->tm_min,
- tmp->tm_sec, rconn->tstamp.tv_usec);
+ tmp->tm_sec, rconn->tstamp.tv_usec);
/* display src or dst addr and information about network interface */
fprintf(DbgFp, "Addr: %s Intf: %s\n", EnetStr(rconn), IntfName);
@@ -116,68 +114,69 @@ 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, ntohs(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",
- ntohs(rmp->hp_llc.dxsap), ntohs(rmp->hp_llc.sxsap));
+ ntohs(rmp->hp_llc.dxsap), ntohs(rmp->hp_llc.sxsap));
/*
* Display information about RMP packet using type field to
* determine what kind of packet this is.
*/
- switch(rmp->r_type) {
- case RMP_BOOT_REQ: /* boot request */
- (void) fprintf(DbgFp, "\tBoot Request:");
- GETWORD(rmp->r_brq.rmp_seqno, t);
- if (ntohs(rmp->r_brq.rmp_session) == RMP_PROBESID) {
- if (WORDZE(rmp->r_brq.rmp_seqno))
- fputs(" (Send Server ID)", DbgFp);
- else
- fprintf(DbgFp," (Send Filename #%u)",t);
- }
- (void) fputc('\n', DbgFp);
- (void) fprintf(DbgFp, BootFmt, rmp->r_brq.rmp_retcode,
- 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);
- DspFlnm(rmp->r_brq.rmp_flnmsize, &rmp->r_brq.rmp_flnm);
- break;
- case RMP_BOOT_REPL: /* boot reply */
- fprintf(DbgFp, "\tBoot Reply:\n");
- GETWORD(rmp->r_brpl.rmp_seqno, t);
- (void) fprintf(DbgFp, BootFmt, rmp->r_brpl.rmp_retcode,
- 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, ntohs(rmp->r_rrq.rmp_session));
- (void) fprintf(DbgFp, "\t\tNoOfBytes: %u\n",
- 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, ntohs(rmp->r_rrpl.rmp_session));
- (void) fprintf(DbgFp, "\t\tNoOfBytesSent: %ld\n",
- (long)(rconn->rmplen - RMPREADSIZE(0)));
- break;
- case RMP_BOOT_DONE: /* boot complete */
- (void) fprintf(DbgFp, "\tBoot Complete:\n");
- (void) fprintf(DbgFp, "\t\tRetCode:%u SessID:%x\n",
- rmp->r_done.rmp_retcode,
- ntohs(rmp->r_done.rmp_session));
- break;
- default: /* ??? */
- (void) fprintf(DbgFp, "\tUnknown Type:(%d)\n",
- rmp->r_type);
+ switch (rmp->r_type) {
+ case RMP_BOOT_REQ: /* boot request */
+ (void) fprintf(DbgFp, "\tBoot Request:");
+ GETWORD(rmp->r_brq.rmp_seqno, t);
+ if (ntohs(rmp->r_brq.rmp_session) == RMP_PROBESID) {
+ if (WORDZE(rmp->r_brq.rmp_seqno))
+ fputs(" (Send Server ID)", DbgFp);
+ else
+ fprintf(DbgFp," (Send Filename #%u)",t);
+ }
+ (void) fputc('\n', DbgFp);
+ (void) fprintf(DbgFp, BootFmt, rmp->r_brq.rmp_retcode,
+ 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);
+ DspFlnm(rmp->r_brq.rmp_flnmsize, &rmp->r_brq.rmp_flnm);
+ break;
+ case RMP_BOOT_REPL: /* boot reply */
+ fprintf(DbgFp, "\tBoot Reply:\n");
+ GETWORD(rmp->r_brpl.rmp_seqno, t);
+ (void) fprintf(DbgFp, BootFmt, rmp->r_brpl.rmp_retcode,
+ 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, ntohs(rmp->r_rrq.rmp_session));
+ (void) fprintf(DbgFp, "\t\tNoOfBytes: %u\n",
+ 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, ntohs(rmp->r_rrpl.rmp_session));
+ (void) fprintf(DbgFp, "\t\tNoOfBytesSent: %ld\n",
+ (long)(rconn->rmplen - RMPREADSIZE(0)));
+ break;
+ case RMP_BOOT_DONE: /* boot complete */
+ (void) fprintf(DbgFp, "\tBoot Complete:\n");
+ (void) fprintf(DbgFp, "\t\tRetCode:%u SessID:%x\n",
+ rmp->r_done.rmp_retcode,
+ ntohs(rmp->r_done.rmp_session));
+ break;
+ default: /* ??? */
+ (void) fprintf(DbgFp, "\tUnknown Type:(%d)\n",
+ rmp->r_type);
+ break;
}
(void) fputc('\n', DbgFp);
(void) fflush(DbgFp);
@@ -207,8 +206,7 @@ DispPkt(rconn, direct)
** be copied if it's to be saved.
*/
char *
-GetEtherAddr(addr)
- u_int8_t *addr;
+GetEtherAddr(u_int8_t *addr)
{
static char Hex[] = "0123456789abcdef";
static char etherstr[RMP_ADDRLEN*3];
@@ -248,9 +246,7 @@ GetEtherAddr(addr)
** - Characters are sent to `DbgFp'.
*/
void
-DspFlnm(size, flnm)
- u_int size;
- char *flnm;
+DspFlnm(u_int size, char *flnm)
{
int i;
@@ -275,14 +271,13 @@ DspFlnm(size, flnm)
** - If malloc() fails, a log message will be generated.
*/
CLIENT *
-NewClient(addr)
- u_int8_t *addr;
+NewClient(u_int8_t *addr)
{
CLIENT *ctmp;
if ((ctmp = (CLIENT *) malloc(sizeof(CLIENT))) == NULL) {
syslog(LOG_ERR, "NewClient: out of memory (%s)",
- GetEtherAddr(addr));
+ GetEtherAddr(addr));
return(NULL);
}
@@ -308,7 +303,7 @@ NewClient(addr)
** - This routine must be called with SIGHUP blocked.
*/
void
-FreeClients()
+FreeClients(void)
{
CLIENT *ctmp;
@@ -333,8 +328,7 @@ FreeClients()
** - If malloc() fails, a log message will be generated.
*/
char *
-NewStr(str)
- char *str;
+NewStr(char *str)
{
char *stmp;
@@ -367,15 +361,14 @@ static RMPCONN *LastFree = NULL;
** - If malloc() fails, a log message will be generated.
*/
RMPCONN *
-NewConn(rconn)
- RMPCONN *rconn;
+NewConn(RMPCONN *rconn)
{
RMPCONN *rtmp;
if (LastFree == NULL) { /* nothing cached; make a new one */
if ((rtmp = (RMPCONN *) malloc(sizeof(RMPCONN))) == NULL) {
syslog(LOG_ERR, "NewConn: out of memory (%s)",
- EnetStr(rconn));
+ EnetStr(rconn));
return(NULL);
}
} else { /* use the cached RMPCONN */
@@ -408,8 +401,7 @@ NewConn(rconn)
** - File desc associated with `rtmp->bootfd' will be closed.
*/
void
-FreeConn(rtmp)
- RMPCONN *rtmp;
+FreeConn(RMPCONN *rtmp)
{
/*
* If the file descriptor is in use, close the file.
@@ -443,7 +435,7 @@ FreeConn(rtmp)
** - This routine must be called with SIGHUP blocked.
*/
void
-FreeConns()
+FreeConns(void)
{
RMPCONN *rtmp;
@@ -475,8 +467,7 @@ FreeConns()
** - This routine must be called with SIGHUP blocked.
*/
void
-AddConn(rconn)
- RMPCONN *rconn;
+AddConn(RMPCONN *rconn)
{
if (RmpConns != NULL)
rconn->next = RmpConns;
@@ -503,14 +494,13 @@ AddConn(rconn)
** - This routine must be called with SIGHUP blocked.
*/
RMPCONN *
-FindConn(rconn)
- RMPCONN *rconn;
+FindConn(RMPCONN *rconn)
{
RMPCONN *rtmp;
for (rtmp = RmpConns; rtmp != NULL; rtmp = rtmp->next)
if (bcmp((char *)&rconn->rmp.hp_hdr.saddr[0],
- (char *)&rtmp->rmp.hp_hdr.saddr[0], RMP_ADDRLEN) == 0)
+ (char *)&rtmp->rmp.hp_hdr.saddr[0], RMP_ADDRLEN) == 0)
break;
return(rtmp);
@@ -533,8 +523,7 @@ FindConn(rconn)
** - This routine must be called with SIGHUP blocked.
*/
void
-RemoveConn(rconn)
- RMPCONN *rconn;
+RemoveConn(RMPCONN *rconn)
{
RMPCONN *thisrconn, *lastrconn;