summaryrefslogtreecommitdiffstats
path: root/usr.sbin/rbootd/utils.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2002-12-13 23:14:07 +0000
committerderaadt <deraadt@openbsd.org>2002-12-13 23:14:07 +0000
commit39883a76b7a1bca2c929461c9f45e23225550695 (patch)
tree3c8abb11f5ff7f0ad667e633257f5093877318ef /usr.sbin/rbootd/utils.c
parentReverse the order of a test in the loop invariant. It makes more (diff)
downloadwireguard-openbsd-39883a76b7a1bca2c929461c9f45e23225550695.tar.xz
wireguard-openbsd-39883a76b7a1bca2c929461c9f45e23225550695.zip
ansi & knf
Diffstat (limited to 'usr.sbin/rbootd/utils.c')
-rw-r--r--usr.sbin/rbootd/utils.c157
1 files changed, 73 insertions, 84 deletions
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;