summaryrefslogtreecommitdiff
path: root/usr.sbin/mopd
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-04-14 20:37:29 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-04-14 20:37:29 +0000
commit15e91156d7954e0997e675eb88a2869eb2cfa2c6 (patch)
tree9473bfa5b87b1a44dc30849f48a6133dff445192 /usr.sbin/mopd
parent870c6104a921f8c58c7615b964d078d667429624 (diff)
4000 lines worth of cleanup, KNF, Knall&Rauch elemination and such
tested by hshoexer, "don't wait for me" miod@
Diffstat (limited to 'usr.sbin/mopd')
-rw-r--r--usr.sbin/mopd/common/cmp.c10
-rw-r--r--usr.sbin/mopd/common/cmp.h6
-rw-r--r--usr.sbin/mopd/common/common.h26
-rw-r--r--usr.sbin/mopd/common/device.c151
-rw-r--r--usr.sbin/mopd/common/device.h6
-rw-r--r--usr.sbin/mopd/common/dl.c333
-rw-r--r--usr.sbin/mopd/common/file.c491
-rw-r--r--usr.sbin/mopd/common/file.h10
-rw-r--r--usr.sbin/mopd/common/get.c90
-rw-r--r--usr.sbin/mopd/common/get.h6
-rw-r--r--usr.sbin/mopd/common/loop-bsd.c75
-rw-r--r--usr.sbin/mopd/common/mopdef.c11
-rw-r--r--usr.sbin/mopd/common/nma.c20
-rw-r--r--usr.sbin/mopd/common/pf.c161
-rw-r--r--usr.sbin/mopd/common/print.c534
-rw-r--r--usr.sbin/mopd/common/put.c121
-rw-r--r--usr.sbin/mopd/common/rc.c394
17 files changed, 1111 insertions, 1334 deletions
diff --git a/usr.sbin/mopd/common/cmp.c b/usr.sbin/mopd/common/cmp.c
index e603fd56ca9..7f504637b45 100644
--- a/usr.sbin/mopd/common/cmp.c
+++ b/usr.sbin/mopd/common/cmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmp.c,v 1.6 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: cmp.c,v 1.7 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -25,14 +25,14 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: cmp.c,v 1.6 2003/12/01 00:56:51 avsm Exp $";
+static const char rcsid[] =
+ "$OpenBSD: cmp.c,v 1.7 2004/04/14 20:37:28 henning Exp $";
#endif
#include "os.h"
int
-mopCmpEAddr(addr1, addr2)
- u_char *addr1, *addr2;
+mopCmpEAddr(u_char *addr1, u_char *addr2)
{
- return(bcmp((char *)addr1, (char *)addr2, 6));
+ return (bcmp(addr1, addr2, 6));
}
diff --git a/usr.sbin/mopd/common/cmp.h b/usr.sbin/mopd/common/cmp.h
index 353d6b12781..4780e63e760 100644
--- a/usr.sbin/mopd/common/cmp.h
+++ b/usr.sbin/mopd/common/cmp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmp.h,v 1.6 2003/06/02 21:38:39 maja Exp $ */
+/* $OpenBSD: cmp.h,v 1.7 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -23,13 +23,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $OpenBSD: cmp.h,v 1.6 2003/06/02 21:38:39 maja Exp $
+ * $OpenBSD: cmp.h,v 1.7 2004/04/14 20:37:28 henning Exp $
*
*/
#ifndef _CMP_H_
#define _CMP_H_
-int mopCmpEAddr(u_char *,u_char *);
+int mopCmpEAddr(u_char *, u_char *);
#endif /* _CMP_H_ */
diff --git a/usr.sbin/mopd/common/common.h b/usr.sbin/mopd/common/common.h
index f3af6f91216..fac258a1bbf 100644
--- a/usr.sbin/mopd/common/common.h
+++ b/usr.sbin/mopd/common/common.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.h,v 1.4 2003/06/02 21:38:39 maja Exp $ */
+/* $OpenBSD: common.h,v 1.5 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -23,25 +23,25 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $OpenBSD: common.h,v 1.4 2003/06/02 21:38:39 maja Exp $
+ * $OpenBSD: common.h,v 1.5 2004/04/14 20:37:28 henning Exp $
*
*/
#ifndef _COMMON_H_
#define _COMMON_H_
-#define MAXDL 16 /* maximum number concurrent load */
-#define IFNAME_SIZE 32 /* maximum size if interface name */
-#define BUFSIZE 1600 /* main receive buffer size */
-#define HDRSIZ 22 /* room for 803.2 header */
+#define MAXDL 16 /* maximum number concurrent load */
+#define IFNAME_SIZE 32 /* maximum size if interface name */
+#define BUFSIZE 1600 /* main receive buffer size */
+#define HDRSIZ 22 /* room for 803.2 header */
#ifndef MOP_FILE_PATH
#define MOP_FILE_PATH "/tftpboot/mop"
#endif
-#define DEBUG_ONELINE 1
-#define DEBUG_HEADER 2
-#define DEBUG_INFO 3
+#define DEBUG_ONELINE 1
+#define DEBUG_HEADER 2
+#define DEBUG_INFO 3
/*
* structure per interface
@@ -59,10 +59,10 @@ struct if_info {
struct if_info *next; /* Next Interface */
};
-#define DL_STATUS_FREE 0
-#define DL_STATUS_READ_IMGHDR 1
-#define DL_STATUS_SENT_MLD 2
-#define DL_STATUS_SENT_PLT 3
+#define DL_STATUS_FREE 0
+#define DL_STATUS_READ_IMGHDR 1
+#define DL_STATUS_SENT_MLD 2
+#define DL_STATUS_SENT_PLT 3
struct dllist {
u_char status; /* Status byte */
diff --git a/usr.sbin/mopd/common/device.c b/usr.sbin/mopd/common/device.c
index 3e5b6bfd431..cec4ffc18df 100644
--- a/usr.sbin/mopd/common/device.c
+++ b/usr.sbin/mopd/common/device.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: device.c,v 1.11 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: device.c,v 1.12 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -25,17 +25,18 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: device.c,v 1.11 2003/12/01 00:56:51 avsm Exp $";
+static const char rcsid[] =
+ "$OpenBSD: device.c,v 1.12 2004/04/14 20:37:28 henning Exp $";
#endif
#include "os.h"
#include "common/common.h"
#include "common/mopdef.h"
-struct if_info *iflist; /* Interface List */
+struct if_info *iflist; /* Interface List */
-void mopReadDL();
-void mopReadRC();
+void mopReadDL(void);
+void mopReadRC(void);
int mopOpenDL(struct if_info *, int);
int mopOpenRC(struct if_info *, int);
int pfTrans();
@@ -48,12 +49,10 @@ int pfWrite();
*/
void
-deviceEthAddr(ifname, eaddr)
- char *ifname;
- u_char *eaddr;
+deviceEthAddr(char *ifname, u_char *eaddr)
{
- struct sockaddr_dl *sdl;
- struct ifaddrs *ifap, *ifa;
+ struct sockaddr_dl *sdl;
+ struct ifaddrs *ifap, *ifa;
if (getifaddrs(&ifap) != 0) {
syslog(LOG_ERR, "deviceEthAddr: getifaddrs: %m");
@@ -66,7 +65,7 @@ deviceEthAddr(ifname, eaddr)
sdl->sdl_alen != 6)
continue;
if (!strcmp(ifa->ifa_name, ifname)) {
- bcopy((caddr_t)LLADDR(sdl), (caddr_t)eaddr, 6);
+ bcopy(LLADDR(sdl), eaddr, 6);
freeifaddrs(ifap);
return;
}
@@ -78,17 +77,14 @@ deviceEthAddr(ifname, eaddr)
#endif /* DEV_NEW_CONF */
void
-deviceOpen(ifname, proto, trans)
- char *ifname;
- u_short proto;
- int trans;
+deviceOpen(char *ifname, u_short proto, int trans)
{
- struct if_info *p, tmp;
+ struct if_info *p, tmp;
+
+ strncpy(tmp.if_name, ifname, sizeof(tmp.if_name) - 1);
+ tmp.if_name[sizeof(tmp.if_name) - 1] = 0;
+ tmp.iopen = pfInit;
- strncpy(tmp.if_name,ifname,sizeof(tmp.if_name) - 1);
- tmp.if_name[sizeof(tmp.if_name)-1] = 0;
- tmp.iopen = pfInit;
-
switch (proto) {
case MOP_K_PROTO_RC:
tmp.read = mopReadRC;
@@ -101,53 +97,49 @@ deviceOpen(ifname, proto, trans)
default:
break;
}
-
+
if (tmp.fd != -1) {
-
- p = (struct if_info *)malloc(sizeof(*p));
+ p = malloc(sizeof(*p));
if (p == 0) {
- syslog(LOG_ERR, "deviceOpen: malloc: %m");
- exit(1);
+ syslog(LOG_ERR, "deviceOpen: malloc: %m");
+ exit(1);
}
-
+
p->next = iflist;
iflist = p;
- strncpy(p->if_name,tmp.if_name, IFNAME_SIZE -1);
- p->if_name[IFNAME_SIZE -1] = 0;
+ strlcpy(p->if_name, tmp.if_name, IFNAME_SIZE);
p->iopen = tmp.iopen;
p->write = pfWrite;
p->read = tmp.read;
- bzero((char *)p->eaddr,sizeof(p->eaddr));
+ bzero(p->eaddr, sizeof(p->eaddr));
p->fd = tmp.fd;
#ifdef DEV_NEW_CONF
- deviceEthAddr(p->if_name,&p->eaddr[0]);
+ deviceEthAddr(p->if_name, &p->eaddr[0]);
#else
- p->eaddr[0]= tmp.eaddr[0];
- p->eaddr[1]= tmp.eaddr[1];
- p->eaddr[2]= tmp.eaddr[2];
- p->eaddr[3]= tmp.eaddr[3];
- p->eaddr[4]= tmp.eaddr[4];
- p->eaddr[5]= tmp.eaddr[5];
+ p->eaddr[0] = tmp.eaddr[0];
+ p->eaddr[1] = tmp.eaddr[1];
+ p->eaddr[2] = tmp.eaddr[2];
+ p->eaddr[3] = tmp.eaddr[3];
+ p->eaddr[4] = tmp.eaddr[4];
+ p->eaddr[5] = tmp.eaddr[5];
#endif /* DEV_NEW_CONF */
-
+
#ifdef LINUX2_PF
{
int s;
- s = socket(AF_INET,SOCK_DGRAM,0);
- pfEthAddr(s,p->if_name,&p->eaddr[0]);
- (void) close(s);
-
- }
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+ pfEthAddr(s, p->if_name, &p->eaddr[0]);
+ close(s);
+ }
#endif
}
}
void
-deviceInitOne(ifname)
- char *ifname;
+deviceInitOne(char *ifname)
{
char interface[IFNAME_SIZE];
struct if_info *p;
@@ -155,81 +147,72 @@ deviceInitOne(ifname)
#ifdef _AIX
char dev[IFNAME_SIZE];
int unit,j;
-
+
unit = 0;
for (j = 0; j < strlen(ifname); j++) {
- if (isalpha(ifname[j])) {
+ if (isalpha(ifname[j]))
dev[j] = ifname[j];
- } else {
+ else
if (isdigit(ifname[j])) {
- unit = unit*10 + ifname[j] - '0';
+ unit = unit * 10 + ifname[j] - '0';
dev[j] = '\0';
}
- }
- }
-
- if ((strlen(dev) == 2) &&
- (dev[0] == 'e') &&
- ((dev[1] == 'n') || (dev[1] == 't'))) {
- snprintf(interface,sizeof(interface),"ent%d\0",unit);
- } else {
- snprintf(interface,sizeof(interface),"%s%d\0",dev,unit);
}
+
+ if ((strlen(dev) == 2) && (dev[0] == 'e') &&
+ ((dev[1] == 'n') || (dev[1] == 't')))
+ snprintf(interface, sizeof(interface), "ent%d\0", unit);
+ else
+ snprintf(interface, sizeof(interface), "%s%d\0", dev, unit);
#else
- snprintf(interface,sizeof(interface),"%s",ifname);
+ snprintf(interface, sizeof(interface), "%s", ifname);
#endif /* _AIX */
- /* Ok, init it just once */
-
+ /* Ok, init it just once */
p = iflist;
- for (p = iflist; p; p = p->next) {
- if (strcmp(p->if_name,interface) == 0) {
+ for (p = iflist; p; p = p->next)
+ if (strcmp(p->if_name, interface) == 0)
return;
- }
- }
syslog(LOG_INFO, "Initialized %s", interface);
/* Ok, get transport information */
-
trans = pfTrans(interface);
#ifndef NORC
/* Start with MOP Remote Console */
-
switch (trans) {
case TRANS_ETHER:
- deviceOpen(interface,MOP_K_PROTO_RC,TRANS_ETHER);
+ deviceOpen(interface, MOP_K_PROTO_RC, TRANS_ETHER);
break;
case TRANS_8023:
- deviceOpen(interface,MOP_K_PROTO_RC,TRANS_8023);
+ deviceOpen(interface, MOP_K_PROTO_RC, TRANS_8023);
break;
- case TRANS_ETHER+TRANS_8023:
- deviceOpen(interface,MOP_K_PROTO_RC,TRANS_ETHER);
- deviceOpen(interface,MOP_K_PROTO_RC,TRANS_8023);
+ case TRANS_ETHER + TRANS_8023:
+ deviceOpen(interface, MOP_K_PROTO_RC, TRANS_ETHER);
+ deviceOpen(interface, MOP_K_PROTO_RC, TRANS_8023);
break;
- case TRANS_ETHER+TRANS_8023+TRANS_AND:
- deviceOpen(interface,MOP_K_PROTO_RC,TRANS_ETHER+TRANS_8023);
+ case TRANS_ETHER + TRANS_8023 + TRANS_AND:
+ deviceOpen(interface, MOP_K_PROTO_RC, TRANS_ETHER + TRANS_8023);
break;
}
#endif
#ifndef NODL
/* and next MOP Dump/Load */
-
switch (trans) {
case TRANS_ETHER:
- deviceOpen(interface,MOP_K_PROTO_DL,TRANS_ETHER);
+ deviceOpen(interface, MOP_K_PROTO_DL, TRANS_ETHER);
break;
case TRANS_8023:
- deviceOpen(interface,MOP_K_PROTO_DL,TRANS_8023);
+ deviceOpen(interface, MOP_K_PROTO_DL, TRANS_8023);
break;
- case TRANS_ETHER+TRANS_8023:
- deviceOpen(interface,MOP_K_PROTO_DL,TRANS_ETHER);
- deviceOpen(interface,MOP_K_PROTO_DL,TRANS_8023);
+ case TRANS_ETHER + TRANS_8023:
+ deviceOpen(interface, MOP_K_PROTO_DL, TRANS_ETHER);
+ deviceOpen(interface, MOP_K_PROTO_DL, TRANS_8023);
break;
- case TRANS_ETHER+TRANS_8023+TRANS_AND:
- deviceOpen(interface,MOP_K_PROTO_DL,TRANS_ETHER+TRANS_8023);
+ case TRANS_ETHER + TRANS_8023 + TRANS_AND:
+ deviceOpen(interface, MOP_K_PROTO_DL, TRANS_ETHER + TRANS_8023);
break;
}
#endif
@@ -245,8 +228,8 @@ void
deviceInitAll()
{
#ifdef DEV_NEW_CONF
- struct sockaddr_dl *sdl;
- struct ifaddrs *ifap, *ifa;
+ struct sockaddr_dl *sdl;
+ struct ifaddrs *ifap, *ifa;
if (getifaddrs(&ifap) != 0) {
syslog(LOG_ERR, "deviceInitAll: getifaddrs: %m");
@@ -265,7 +248,7 @@ deviceInitAll()
}
freeifaddrs(ifap);
#else
- struct ifaddrs *ifap, *ifa;
+ struct ifaddrs *ifap, *ifa;
if (getifaddrs(&ifap) != 0) {
syslog(LOG_ERR, "deviceInitAll: getifaddrs: %m");
diff --git a/usr.sbin/mopd/common/device.h b/usr.sbin/mopd/common/device.h
index a3e1a972cae..0af7b8abba8 100644
--- a/usr.sbin/mopd/common/device.h
+++ b/usr.sbin/mopd/common/device.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: device.h,v 1.6 2003/06/02 21:38:39 maja Exp $ */
+/* $OpenBSD: device.h,v 1.7 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $OpenBSD: device.h,v 1.6 2003/06/02 21:38:39 maja Exp $
+ * $OpenBSD: device.h,v 1.7 2004/04/14 20:37:28 henning Exp $
*
*/
@@ -31,7 +31,7 @@
#define _DEVICE_H_
#ifdef DEV_NEW_CONF
-void deviceEthAddr(char *,u_char *);
+void deviceEthAddr(char *, u_char *);
#endif
void deviceInitOne(char *);
void deviceInitAll(void);
diff --git a/usr.sbin/mopd/common/dl.c b/usr.sbin/mopd/common/dl.c
index 01e33f8ceac..1cd89027f71 100644
--- a/usr.sbin/mopd/common/dl.c
+++ b/usr.sbin/mopd/common/dl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dl.c,v 1.4 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: dl.c,v 1.5 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -15,9 +15,9 @@
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
@@ -25,7 +25,8 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: dl.c,v 1.4 2003/12/01 00:56:51 avsm Exp $";
+static const char rcsid[] =
+ "$OpenBSD: dl.c,v 1.5 2004/04/14 20:37:28 henning Exp $";
#endif
#include "os.h"
@@ -34,15 +35,12 @@ static const char rcsid[] = "$OpenBSD: dl.c,v 1.4 2003/12/01 00:56:51 avsm Exp $
#include "common/mopdef.h"
void
-mopDumpDL(fd, pkt, trans)
- FILE *fd;
- u_char *pkt;
- int trans;
+mopDumpDL(FILE *fd, u_char *pkt, int trans)
{
- int i,index = 0;
+ int i, index = 0;
long tmpl;
- u_char tmpc,c,program[17],code,*ucp;
- u_short len,tmps,moplen;
+ u_char tmpc, c, program[17], code, *ucp;
+ u_short len, tmps, moplen;
len = mopGetLength(pkt, trans);
@@ -55,254 +53,233 @@ mopDumpDL(fd, pkt, trans)
index = 16;
moplen = len;
}
- code = mopGetChar(pkt,&index);
-
+ code = mopGetChar(pkt, &index);
+
switch (code) {
case MOP_K_CODE_MLT:
-
- tmpc = mopGetChar(pkt,&index); /* Load Number */
- (void)fprintf(fd,"Load Number : %02x\n",tmpc);
-
+ tmpc = mopGetChar(pkt, &index); /* Load Number */
+ fprintf(fd, "Load Number : %02x\n", tmpc);
+
if (moplen > 6) {
- tmpl = mopGetLong(pkt,&index);/* Load Address */
- (void)fprintf(fd,"Load Address : %08lx\n",tmpl);
+ tmpl = mopGetLong(pkt, &index);/* Load Address */
+ fprintf(fd, "Load Address : %08lx\n", tmpl);
}
-
+
if (moplen > 10) {
#ifndef SHORT_PRINT
for (i = 0; i < (moplen - 10); i++) {
if ((i % 16) == 0) {
- if ((i / 16) == 0) {
- (void)fprintf(fd,
- "Image Data : %04x ",
- moplen-10);
- } else {
- (void)fprintf(fd,
- " ");
- }
+ if ((i / 16) == 0)
+ fprintf(fd,
+ "Image Data : %04x ",
+ moplen-10);
+ else
+ fprintf(fd,
+ " ");
}
-
- (void)fprintf(fd, "%02x ",
- mopGetChar(pkt,&index));
+
+ fprintf(fd, "%02x ", mopGetChar(pkt, &index));
if ((i % 16) == 15)
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
}
-
+
if ((i % 16) != 15)
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
#else
index = index + moplen - 10;
#endif
}
-
- tmpl = mopGetLong(pkt,&index); /* Load Address */
- (void)fprintf(fd,"Xfer Address : %08lx\n",tmpl);
-
+
+ tmpl = mopGetLong(pkt, &index); /* Load Address */
+ fprintf(fd, "Xfer Address : %08lx\n", tmpl);
break;
case MOP_K_CODE_DCM:
-
/* Empty Message */
-
break;
case MOP_K_CODE_MLD:
-
- tmpc = mopGetChar(pkt,&index); /* Load Number */
- (void)fprintf(fd,"Load Number : %02x\n",tmpc);
-
- tmpl = mopGetLong(pkt,&index); /* Load Address */
- (void)fprintf(fd,"Load Address : %08lx\n",tmpl);
-
+ tmpc = mopGetChar(pkt, &index); /* Load Number */
+ fprintf(fd, "Load Number : %02x\n", tmpc);
+
+ tmpl = mopGetLong(pkt, &index); /* Load Address */
+ fprintf(fd, "Load Address : %08lx\n", tmpl);
+
if (moplen > 6) {
#ifndef SHORT_PRINT
for (i = 0; i < (moplen - 6); i++) {
- if ((i % 16) == 0) {
- if ((i / 16) == 0) {
- (void)fprintf(fd,
- "Image Data : %04x ",
- moplen-6);
- } else {
- (void)fprintf(fd,
- " ");
- }
- }
- (void)fprintf(fd,"%02x ",
- mopGetChar(pkt,&index));
+ if ((i % 16) == 0)
+ if ((i / 16) == 0)
+ fprintf(fd,
+ "Image Data : %04x ",
+ moplen-6);
+ else
+ fprintf(fd,
+ " ");
+
+ fprintf(fd, "%02x ", mopGetChar(pkt, &index));
if ((i % 16) == 15)
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
}
if ((i % 16) != 15)
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
#else
index = index + moplen - 6;
#endif
}
-
break;
case MOP_K_CODE_ASV:
-
/* Empty Message */
-
break;
case MOP_K_CODE_RMD:
-
- tmpl = mopGetLong(pkt,&index); /* Memory Address */
- (void)fprintf(fd,"Mem Address : %08lx\n",tmpl);
-
- tmps = mopGetShort(pkt,&index); /* Count */
- (void)fprintf(fd,"Count : %04x (%d)\n",tmps,tmps);
-
+ tmpl = mopGetLong(pkt, &index); /* Memory Address */
+ fprintf(fd, "Mem Address : %08lx\n", tmpl);
+ tmps = mopGetShort(pkt, &index); /* Count */
+ fprintf(fd, "Count : %04x (%d)\n", tmps, tmps);
break;
case MOP_K_CODE_RPR:
-
- tmpc = mopGetChar(pkt,&index); /* Device Type */
- (void)fprintf(fd, "Device Type : %02x ",tmpc);
- mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n");
-
- tmpc = mopGetChar(pkt,&index); /* Format Version */
- (void)fprintf(fd,"Format : %02x\n",tmpc);
-
- tmpc = mopGetChar(pkt,&index); /* Program Type */
- (void)fprintf(fd,"Program Type : %02x ",tmpc);
- mopPrintPGTY(fd, tmpc); (void)fprintf(fd, "\n");
-
+ tmpc = mopGetChar(pkt, &index); /* Device Type */
+ fprintf(fd, "Device Type : %02x ", tmpc);
+ mopPrintDevice(fd, tmpc);
+ fprintf(fd, "\n");
+
+ tmpc = mopGetChar(pkt, &index); /* Format Version */
+ fprintf(fd, "Format : %02x\n", tmpc);
+
+ tmpc = mopGetChar(pkt, &index); /* Program Type */
+ fprintf(fd, "Program Type : %02x ", tmpc);
+ mopPrintPGTY(fd, tmpc);
+ fprintf(fd, "\n");
+
program[0] = 0;
- tmpc = mopGetChar(pkt,&index); /* Software ID Len */
+ tmpc = mopGetChar(pkt, &index); /* Software ID Len */
for (i = 0; i < tmpc; i++) {
- program[i] = mopGetChar(pkt,&index);
- program[i+1] = '\0';
+ program[i] = mopGetChar(pkt, &index);
+ program[i + 1] = '\0';
}
-
- (void)fprintf(fd,"Software : %02x '%s'\n",tmpc,program);
-
- tmpc = mopGetChar(pkt,&index); /* Processor */
- (void)fprintf(fd,"Processor : %02x ",tmpc);
- mopPrintBPTY(fd, tmpc); (void)fprintf(fd, "\n");
-
+
+ fprintf(fd, "Software : %02x '%s'\n", tmpc, program);
+
+ tmpc = mopGetChar(pkt, &index); /* Processor */
+ fprintf(fd, "Processor : %02x ", tmpc);
+ mopPrintBPTY(fd, tmpc);
+ fprintf(fd, "\n");
+
mopPrintInfo(fd, pkt, &index, moplen, code, trans);
-
+
break;
case MOP_K_CODE_RML:
-
- tmpc = mopGetChar(pkt,&index); /* Load Number */
- (void)fprintf(fd,"Load Number : %02x\n",tmpc);
-
- tmpc = mopGetChar(pkt,&index); /* Error */
- (void)fprintf(fd,"Error : %02x (",tmpc);
- if ((tmpc == 0)) {
- (void)fprintf(fd,"no error)\n");
- } else {
- (void)fprintf(fd,"error)\n");
- }
-
+
+ tmpc = mopGetChar(pkt, &index); /* Load Number */
+ fprintf(fd, "Load Number : %02x\n", tmpc);
+
+ tmpc = mopGetChar(pkt, &index); /* Error */
+ (void)fprintf(fd, "Error : %02x (", tmpc);
+ if ((tmpc == 0))
+ fprintf(fd, "no error)\n");
+ else
+ fprintf(fd, "error)\n");
+
break;
case MOP_K_CODE_RDS:
-
- tmpc = mopGetChar(pkt,&index); /* Device Type */
- (void)fprintf(fd, "Device Type : %02x ",tmpc);
- mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n");
-
- tmpc = mopGetChar(pkt,&index); /* Format Version */
- (void)fprintf(fd,"Format : %02x\n",tmpc);
-
- tmpl = mopGetLong(pkt,&index); /* Memory Size */
- (void)fprintf(fd,"Memory Size : %08lx\n",tmpl);
-
- tmpc = mopGetChar(pkt,&index); /* Bits */
- (void)fprintf(fd,"Bits : %02x\n",tmpc);
-
+
+ tmpc = mopGetChar(pkt, &index); /* Device Type */
+ fprintf(fd, "Device Type : %02x ", tmpc);
+ mopPrintDevice(fd, tmpc);
+ fprintf(fd, "\n");
+
+ tmpc = mopGetChar(pkt, &index); /* Format Version */
+ fprintf(fd, "Format : %02x\n", tmpc);
+
+ tmpl = mopGetLong(pkt, &index); /* Memory Size */
+ fprintf(fd, "Memory Size : %08lx\n", tmpl);
+
+ tmpc = mopGetChar(pkt, &index); /* Bits */
+ fprintf(fd, "Bits : %02x\n", tmpc);
+
mopPrintInfo(fd, pkt, &index, moplen, code, trans);
-
+
break;
case MOP_K_CODE_MDD:
-
- tmpl = mopGetLong(pkt,&index); /* Memory Address */
- (void)fprintf(fd,"Mem Address : %08lx\n",tmpl);
-
+
+ tmpl = mopGetLong(pkt, &index); /* Memory Address */
+ fprintf(fd, "Mem Address : %08lx\n", tmpl);
+
if (moplen > 5) {
#ifndef SHORT_PRINT
for (i = 0; i < (moplen - 5); i++) {
if ((i % 16) == 0) {
- if ((i / 16) == 0) {
- (void)fprintf(fd,
- "Image Data : %04x ",
- moplen-5);
- } else {
- (void)fprintf(fd,
- " ");
- }
+ if ((i / 16) == 0)
+ fprintf(fd,
+ "Image Data : %04x ",
+ moplen-5);
+ else
+ fprintf(fd,
+ " ");
}
- (void)fprintf(fd,"%02x ",
- mopGetChar(pkt,&index));
+ fprintf(fd, "%02x ", mopGetChar(pkt, &index));
if ((i % 16) == 15)
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
}
if ((i % 16) != 15)
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
#else
index = index + moplen - 5;
#endif
}
-
+
break;
case MOP_K_CODE_PLT:
-
- tmpc = mopGetChar(pkt,&index); /* Load Number */
- (void)fprintf(fd,"Load Number : %02x\n",tmpc);
-
- tmpc = mopGetChar(pkt,&index); /* Parameter Type */
+
+ tmpc = mopGetChar(pkt, &index); /* Load Number */
+ fprintf(fd, "Load Number : %02x\n", tmpc);
+
+ tmpc = mopGetChar(pkt, &index); /* Parameter Type */
while (tmpc != MOP_K_PLTP_END) {
- c = mopGetChar(pkt,&index); /* Parameter Length */
- switch(tmpc) {
+ c = mopGetChar(pkt, &index); /* Parameter Length */
+ switch (tmpc) {
case MOP_K_PLTP_TSN: /* Target Name */
- (void)fprintf(fd,"Target Name : %02x '",
- tmpc);
- for (i = 0; i < ((int) c); i++) {
- (void)fprintf(fd,"%c",
- mopGetChar(pkt,&index));
- }
- (void)fprintf(fd,"'\n");
+ fprintf(fd, "Target Name : %02x '", tmpc);
+ for (i = 0; i < c; i++)
+ fprintf(fd, "%c",
+ mopGetChar(pkt, &index));
+ fprintf(fd, "'\n");
break;
case MOP_K_PLTP_TSA: /* Target Address */
- (void)fprintf(fd,"Target Addr : %02x ",c);
- for (i = 0; i < ((int) c); i++) {
- (void)fprintf(fd,"%02x ",
- mopGetChar(pkt,&index));
- }
- (void)fprintf(fd,"\n");
+ fprintf(fd, "Target Addr : %02x ", c);
+ for (i = 0; i < c; i++)
+ fprintf(fd, "%02x ",
+ mopGetChar(pkt, &index));
+ fprintf(fd, "\n");
break;
case MOP_K_PLTP_HSN: /* Host Name */
- (void)fprintf(fd,"Host Name : %02x '",
- tmpc);
- for (i = 0; i < ((int) c); i++) {
- (void)fprintf(fd,"%c",
- mopGetChar(pkt,&index));
- }
- (void)fprintf(fd,"'\n");
+ fprintf(fd, "Host Name : %02x '", tmpc);
+ for (i = 0; i < c; i++)
+ fprintf(fd, "%c",
+ mopGetChar(pkt, &index));
+ fprintf(fd, "'\n");
break;
case MOP_K_PLTP_HSA: /* Host Address */
- (void)fprintf(fd,"Host Addr : %02x ",c);
- for (i = 0; i < ((int) c); i++) {
- (void)fprintf(fd,"%02x ",
- mopGetChar(pkt,&index));
- }
- (void)fprintf(fd,"\n");
+ fprintf(fd, "Host Addr : %02x ", c);
+ for (i = 0; i < c; i++)
+ fprintf(fd, "%02x ",
+ mopGetChar(pkt, &index));
+ fprintf(fd, "\n");
break;
case MOP_K_PLTP_HST: /* Host Time */
ucp = pkt + index; index = index + 10;
- (void)fprintf(fd,"Host Time : ");
+ fprintf(fd, "Host Time : ");
mopPrintTime(fd, ucp);
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
break;
default:
break;
}
- tmpc = mopGetChar(pkt,&index);/* Parameter Type */
+ tmpc = mopGetChar(pkt, &index); /* Parameter Type */
}
-
- tmpl = mopGetLong(pkt,&index); /* Transfer Address */
- (void)fprintf(fd,"Transfer Addr: %08lx\n",tmpl);
-
+
+ tmpl = mopGetLong(pkt, &index); /* Transfer Address */
+ (void)fprintf(fd, "Transfer Addr: %08lx\n", tmpl);
+
break;
default:
break;
diff --git a/usr.sbin/mopd/common/file.c b/usr.sbin/mopd/common/file.c
index cf6583edc2a..79a034a2470 100644
--- a/usr.sbin/mopd/common/file.c
+++ b/usr.sbin/mopd/common/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.7 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: file.c,v 1.8 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1995-96 Mats O Jansson. All rights reserved.
@@ -25,7 +25,8 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: file.c,v 1.7 2003/12/01 00:56:51 avsm Exp $";
+static const char rcsid[] =
+ "$OpenBSD: file.c,v 1.8 2004/04/14 20:37:28 henning Exp $";
#endif
#include "os.h"
@@ -54,93 +55,80 @@ static const char rcsid[] = "$OpenBSD: file.c,v 1.7 2003/12/01 00:56:51 avsm Exp
#endif
void
-mopFilePutLX(buf, index, value, cnt)
- u_char *buf;
- int index, cnt;
- u_long value;
+mopFilePutLX(u_char *buf, int index, u_long value, int cnt)
{
int i;
for (i = 0; i < cnt; i++) {
- buf[index+i] = value % 256;
+ buf[index + i] = value % 256;
value = value / 256;
}
}
void
-mopFilePutBX(buf, index, value, cnt)
- u_char *buf;
- int index, cnt;
- u_long value;
+mopFilePutBX(u_char *buf, int index, u_long value, int cnt)
{
int i;
for (i = 0; i < cnt; i++) {
- buf[index+cnt-1-i] = value % 256;
+ buf[index + cnt - 1 - i] = value % 256;
value = value / 256;
}
}
u_long
-mopFileGetLX(buf, index, cnt)
- u_char *buf;
- int index, cnt;
+mopFileGetLX(void *buffer, int index, int cnt)
{
- u_long ret = 0;
- int i;
+ u_long ret = 0;
+ int i;
+ u_char *buf = (u_char *)buffer;
- for (i = 0; i < cnt; i++) {
- ret = ret*256 + buf[index+cnt-1-i];
- }
+ for (i = 0; i < cnt; i++)
+ ret = ret*256 + buf[index+cnt - 1 - i];
- return(ret);
+ return (ret);
}
u_long
-mopFileGetBX(buf, index, cnt)
- u_char *buf;
- int index, cnt;
+mopFileGetBX(void *buffer, int index, int cnt)
{
- u_long ret = 0;
- int i;
+ u_long ret = 0;
+ int i;
+ u_char *buf = (u_char *)buffer;
- for (i = 0; i < cnt; i++) {
- ret = ret*256 + buf[index+i];
- }
+ for (i = 0; i < cnt; i++)
+ ret = ret*256 + buf[index + i];
- return(ret);
+ return (ret);
}
void
-mopFileSwapX(buf, index, cnt)
- u_char *buf;
- int index, cnt;
+mopFileSwapX(void *buffer, int index, int cnt)
{
- int i;
- u_char c;
+ int i;
+ u_char c;
+ u_char *buf = (u_char *)buffer;
for (i = 0; i < (cnt / 2); i++) {
- c = buf[index+i];
- buf[index+i] = buf[index+cnt-1-i];
- buf[index+cnt-1-i] = c;
+ c = buf[index + i];
+ buf[index + i] = buf[index + cnt - 1 - i];
+ buf[index + cnt - 1 - i] = c;
}
}
int
-CheckMopFile(fd)
- int fd;
+CheckMopFile(int fd)
{
u_char header[512];
short image_type;
if (read(fd, header, 512) != 512)
- return(-1);
+ return (-1);
- (void)lseek(fd, (off_t) 0, SEEK_SET);
+ lseek(fd, 0, SEEK_SET);
- image_type = (u_short)(header[IHD_W_ALIAS+1]*256 +
- header[IHD_W_ALIAS]);
+ image_type = header[IHD_W_ALIAS+1] * 256 + header[IHD_W_ALIAS];
- switch(image_type) {
+ switch (image_type) {
case IHD_C_NATIVE: /* Native mode image (VAX) */
case IHD_C_RSX: /* RSX image produced by TKB */
case IHD_C_BPA: /* BASIC plus analog */
@@ -150,149 +138,141 @@ CheckMopFile(fd)
case IHD_C_ALPHA: /* ALPHA system image */
break;
default:
- return(-1);
+ return (-1);
}
- return(0);
+ return (0);
}
int
-GetMopFileInfo(fd, load, xfr)
- int fd;
- u_long *load, *xfr;
+GetMopFileInfo(int fd, u_long *load, u_long *xfr)
{
u_char header[512];
short image_type;
u_long load_addr, xfr_addr, isd, iha, hbcnt, isize;
if (read(fd, header, 512) != 512)
- return(-1);
+ return (-1);
- image_type = (u_short)(header[IHD_W_ALIAS+1]*256 +
- header[IHD_W_ALIAS]);
+ image_type = header[IHD_W_ALIAS+1] * 256 + header[IHD_W_ALIAS];
- switch(image_type) {
+ switch (image_type) {
case IHD_C_NATIVE: /* Native mode image (VAX) */
- isd = (header[IHD_W_SIZE+1]*256 +
- header[IHD_W_SIZE]);
- iha = (header[IHD_W_ACTIVOFF+1]*256 +
- header[IHD_W_ACTIVOFF]);
- hbcnt = (header[IHD_B_HDRBLKCNT]);
- isize = (header[isd+ISD_W_PAGCNT+1]*256 +
- header[isd+ISD_W_PAGCNT]) * 512;
- load_addr = ((header[isd+ISD_V_VPN+1]*256 +
- header[isd+ISD_V_VPN]) & ISD_M_VPN)
- * 512;
- xfr_addr = (header[iha+IHA_L_TFRADR1+3]*0x1000000 +
- header[iha+IHA_L_TFRADR1+2]*0x10000 +
- header[iha+IHA_L_TFRADR1+1]*0x100 +
- header[iha+IHA_L_TFRADR1]) & 0x7fffffff;
+ isd = header[IHD_W_SIZE + 1] * 256 + header[IHD_W_SIZE];
+ iha = header[IHD_W_ACTIVOFF + 1] * 256 +
+ header[IHD_W_ACTIVOFF];
+ hbcnt = header[IHD_B_HDRBLKCNT];
+ isize = (header[isd + ISD_W_PAGCNT + 1] * 256 +
+ header[isd + ISD_W_PAGCNT]) * 512;
+ load_addr = ((header[isd + ISD_V_VPN + 1] * 256 +
+ header[isd+ISD_V_VPN]) & ISD_M_VPN) * 512;
+ xfr_addr = (header[iha + IHA_L_TFRADR1 + 3] * 0x1000000+
+ header[iha + IHA_L_TFRADR1 + 2] * 0x10000 +
+ header[iha + IHA_L_TFRADR1 + 1] * 0x100 +
+ header[iha + IHA_L_TFRADR1]) & 0x7fffffff;
#ifdef INFO
printf("Native Image (VAX)\n");
- printf("Header Block Count: %lu\n",hbcnt);
- printf("Image Size: %08lx\n",isize);
- printf("Load Address: %08lx\n",load_addr);
- printf("Transfer Address: %08lx\n",xfr_addr);
+ printf("Header Block Count: %lu\n", hbcnt);
+ printf("Image Size: %08lx\n", isize);
+ printf("Load Address: %08lx\n", load_addr);
+ printf("Transfer Address: %08lx\n", xfr_addr);
#endif
break;
case IHD_C_RSX: /* RSX image produced by TKB */
- hbcnt = header[L_BBLK+1]*256 + header[L_BBLK];
- isize = (header[L_BLDZ+1]*256 + header[L_BLDZ]) * 64;
- load_addr = header[L_BSA+1]*256 + header[L_BSA];
- xfr_addr = header[L_BXFR+1]*256 + header[L_BXFR];
+ hbcnt = header[L_BBLK + 1] * 256 + header[L_BBLK];
+ isize = (header[L_BLDZ + 1] * 256 + header[L_BLDZ]) *
+ 64;
+ load_addr = header[L_BSA+1] * 256 + header[L_BSA];
+ xfr_addr = header[L_BXFR+1] * 256 + header[L_BXFR];
#ifdef INFO
printf("RSX Image\n");
printf("Header Block Count: %lu\n",hbcnt);
- printf("Image Size: %08lx\n",isize);
- printf("Load Address: %08lx\n",load_addr);
- printf("Transfer Address: %08lx\n",xfr_addr);
+ printf("Image Size: %08lx\n", isize);
+ printf("Load Address: %08lx\n", load_addr);
+ printf("Transfer Address: %08lx\n", xfr_addr);
#endif
break;
case IHD_C_BPA: /* BASIC plus analog */
#ifdef INFO
printf("BASIC-Plus Image, not supported\n");
#endif
- return(-1);
+ return (-1);
break;
case IHD_C_ALIAS: /* Alias */
#ifdef INFO
printf("Alias, not supported\n");
#endif
- return(-1);
+ return (-1);
break;
case IHD_C_CLI: /* Image is CLI */
#ifdef INFO
printf("CLI, not supported\n");
#endif
- return(-1);
+ return (-1);
break;
case IHD_C_PMAX: /* PMAX system image */
- isd = (header[IHD_W_SIZE+1]*256 +
- header[IHD_W_SIZE]);
- iha = (header[IHD_W_ACTIVOFF+1]*256 +
- header[IHD_W_ACTIVOFF]);
- hbcnt = (header[IHD_B_HDRBLKCNT]);
- isize = (header[isd+ISD_W_PAGCNT+1]*256 +
- header[isd+ISD_W_PAGCNT]) * 512;
- load_addr = (header[isd+ISD_V_VPN+1]*256 +
- header[isd+ISD_V_VPN]) * 512;
- xfr_addr = (header[iha+IHA_L_TFRADR1+3]*0x1000000 +
- header[iha+IHA_L_TFRADR1+2]*0x10000 +
- header[iha+IHA_L_TFRADR1+1]*0x100 +
- header[iha+IHA_L_TFRADR1]);
+ isd = header[IHD_W_SIZE+1] * 256 + header[IHD_W_SIZE];
+ iha = header[IHD_W_ACTIVOFF+1] * 256 +
+ header[IHD_W_ACTIVOFF];
+ hbcnt = header[IHD_B_HDRBLKCNT];
+ isize = (header[isd + ISD_W_PAGCNT + 1] * 256 +
+ header[isd + ISD_W_PAGCNT]) * 512;
+ load_addr = (header[isd + ISD_V_VPN + 1] * 256 +
+ header[isd + ISD_V_VPN]) * 512;
+ xfr_addr = (header[iha + IHA_L_TFRADR1 + 3] * 0x1000000+
+ header[iha + IHA_L_TFRADR1 + 2] * 0x10000 +
+ header[iha + IHA_L_TFRADR1 + 1] * 0x100 +
+ header[iha + IHA_L_TFRADR1]);
#ifdef INFO
printf("PMAX Image \n");
- printf("Header Block Count: %lu\n",hbcnt);
- printf("Image Size: %08lx\n",isize);
- printf("Load Address: %08lx\n",load_addr);
- printf("Transfer Address: %08lx\n",xfr_addr);
+ printf("Header Block Count: %lu\n", hbcnt);
+ printf("Image Size: %08lx\n", isize);
+ printf("Load Address: %08lx\n", load_addr);
+ printf("Transfer Address: %08lx\n", xfr_addr);
#endif
break;
case IHD_C_ALPHA: /* ALPHA system image */
- isd = (header[EIHD_L_ISDOFF+3]*0x1000000 +
- header[EIHD_L_ISDOFF+2]*0x10000 +
- header[EIHD_L_ISDOFF+1]*0x100 +
+ isd = (header[EIHD_L_ISDOFF + 3] * 0x1000000 +
+ header[EIHD_L_ISDOFF + 2] * 0x10000 +
+ header[EIHD_L_ISDOFF + 1] * 0x100 +
header[EIHD_L_ISDOFF]);
- hbcnt = (header[EIHD_L_HDRBLKCNT+3]*0x1000000 +
- header[EIHD_L_HDRBLKCNT+2]*0x10000 +
- header[EIHD_L_HDRBLKCNT+1]*0x100 +
+ hbcnt = (header[EIHD_L_HDRBLKCNT + 3] * 0x1000000 +
+ header[EIHD_L_HDRBLKCNT + 2] * 0x10000 +
+ header[EIHD_L_HDRBLKCNT + 1] * 0x100 +
header[EIHD_L_HDRBLKCNT]);
- isize = (header[isd+EISD_L_SECSIZE+3]*0x1000000 +
- header[isd+EISD_L_SECSIZE+2]*0x10000 +
- header[isd+EISD_L_SECSIZE+1]*0x100 +
+ isize = (header[isd+EISD_L_SECSIZE + 3] * 0x1000000 +
+ header[isd+EISD_L_SECSIZE + 2] * 0x10000 +
+ header[isd+EISD_L_SECSIZE + 1] * 0x100 +
header[isd+EISD_L_SECSIZE]);
load_addr = 0;
xfr_addr = 0;
#ifdef INFO
printf("Alpha Image \n");
- printf("Header Block Count: %lu\n",hbcnt);
- printf("Image Size: %08lx\n",isize);
- printf("Load Address: %08lx\n",load_addr);
- printf("Transfer Address: %08lx\n",xfr_addr);
+ printf("Header Block Count: %lu\n", hbcnt);
+ printf("Image Size: %08lx\n", isize);
+ printf("Load Address: %08lx\n", load_addr);
+ printf("Transfer Address: %08lx\n", xfr_addr);
#endif
break;
default:
#ifdef INFO
- printf("Unknown Image (%d)\n",image_type);
+ printf("Unknown Image (%d)\n", image_type);
#endif
- return(-1);
+ return (-1);
}
- if (load != NULL) {
+ if (load != NULL)
*load = load_addr;
- }
- if (xfr != NULL) {
+ if (xfr != NULL)
*xfr = xfr_addr;
- }
- return(0);
+ return (0);
}
#ifndef NOAOUT
int
-getMID(old_mid,new_mid)
- int old_mid, new_mid;
+getMID(int old_mid, int new_mid)
{
int mid;
@@ -349,12 +329,11 @@ getMID(old_mid,new_mid)
break;
}
- return(mid);
+ return (mid);
}
int
-getCLBYTES(mid)
- int mid;
+getCLBYTES(int mid)
{
int clbytes;
@@ -397,84 +376,76 @@ getCLBYTES(mid)
clbytes = 0;
}
- return(clbytes);
+ return (clbytes);
}
#endif
int
-CheckAOutFile(fd)
- int fd;
+CheckAOutFile(int fd)
{
#ifdef NOAOUT
- return(-1);
+ return (-1);
#else
- struct exec ex, ex_swap;
- int mid = -1;
+ struct exec ex, ex_swap;
+ int mid = -1;
- if (read(fd, (char *)&ex, sizeof(ex)) != sizeof(ex))
- return(-1);
+ if (read(fd, &ex, sizeof(ex)) != sizeof(ex))
+ return (-1);
- (void)lseek(fd, (off_t) 0, SEEK_SET);
-
- if (read(fd, (char *)&ex_swap, sizeof(ex_swap)) != sizeof(ex_swap))
- return(-1);
+ lseek(fd, 0, SEEK_SET);
- (void)lseek(fd, (off_t) 0, SEEK_SET);
-
- mid = getMID(mid, N_GETMID (ex));
+ if (read(fd, &ex_swap, sizeof(ex_swap)) != sizeof(ex_swap))
+ return (-1);
- if (mid == -1) {
- mid = getMID(mid, N_GETMID (ex_swap));
- }
+ lseek(fd, 0, SEEK_SET);
- if (mid != -1) {
- return(0);
- } else {
- return(-1);
- }
+ mid = getMID(mid, N_GETMID(ex));
+
+ if (mid == -1)
+ mid = getMID(mid, N_GETMID(ex_swap));
+
+ if (mid != -1)
+ return (0);
+ else
+ return (-1);
#endif /* NOAOUT */
}
int
-GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
- a_data, a_data_fill, a_bss, a_bss_fill, aout)
- int fd, *aout;
- u_long *load, *xfr, *a_text, *a_text_fill;
- u_long *a_data, *a_data_fill, *a_bss, *a_bss_fill;
+GetAOutFileInfo(int fd, u_long *load, u_long *xfr, u_long *a_text,
+ u_long *a_text_fill, u_long *a_data, u_long *a_data_fill, u_long *a_bss,
+ u_long *a_bss_fill, int *aout)
{
#ifdef NOAOUT
- return(-1);
+ return (-1);
#else
- struct exec ex, ex_swap;
- int mid = -1;
- u_long magic, clbytes, clofset;
+ struct exec ex, ex_swap;
+ int mid = -1;
+ u_long magic, clbytes, clofset;
- if (read(fd, (char *)&ex, sizeof(ex)) != sizeof(ex))
- return(-1);
+ if (read(fd, &ex, sizeof(ex)) != sizeof(ex))
+ return (-1);
- (void)lseek(fd, (off_t) 0, SEEK_SET);
+ lseek(fd, 0, SEEK_SET);
- if (read(fd, (char *)&ex_swap, sizeof(ex_swap)) != sizeof(ex_swap))
- return(-1);
+ if (read(fd, &ex_swap, sizeof(ex_swap)) != sizeof(ex_swap))
+ return (-1);
- mopFileSwapX((u_char *)&ex_swap, 0, 4);
+ mopFileSwapX(&ex_swap, 0, 4);
- mid = getMID(mid, N_GETMID (ex));
+ mid = getMID(mid, N_GETMID(ex));
if (mid == -1) {
- mid = getMID(mid, N_GETMID (ex_swap));
- if (mid != -1) {
- mopFileSwapX((u_char *)&ex, 0, 4);
- }
+ mid = getMID(mid, N_GETMID(ex_swap));
+ if (mid != -1)
+ mopFileSwapX(&ex, 0, 4);
}
- if (mid == -1) {
- return(-1);
- }
+ if (mid == -1)
+ return (-1);
- if (N_BADMAG (ex)) {
- return(-1);
- }
+ if (N_BADMAG(ex))
+ return (-1);
switch (mid) {
case MID_I386:
@@ -493,13 +464,13 @@ GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
#ifdef MID_ARM6
case MID_ARM6:
#endif
- ex.a_text = mopFileGetLX((u_char *)&ex_swap, 4, 4);
- ex.a_data = mopFileGetLX((u_char *)&ex_swap, 8, 4);
- ex.a_bss = mopFileGetLX((u_char *)&ex_swap, 12, 4);
- ex.a_syms = mopFileGetLX((u_char *)&ex_swap, 16, 4);
- ex.a_entry = mopFileGetLX((u_char *)&ex_swap, 20, 4);
- ex.a_trsize= mopFileGetLX((u_char *)&ex_swap, 24, 4);
- ex.a_drsize= mopFileGetLX((u_char *)&ex_swap, 28, 4);
+ ex.a_text = mopFileGetLX(&ex_swap, 4, 4);
+ ex.a_data = mopFileGetLX(&ex_swap, 8, 4);
+ ex.a_bss = mopFileGetLX(&ex_swap, 12, 4);
+ ex.a_syms = mopFileGetLX(&ex_swap, 16, 4);
+ ex.a_entry = mopFileGetLX(&ex_swap, 20, 4);
+ ex.a_trsize = mopFileGetLX(&ex_swap, 24, 4);
+ ex.a_drsize = mopFileGetLX(&ex_swap, 28, 4);
break;
#ifdef MID_M68K
case MID_M68K:
@@ -511,13 +482,13 @@ GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
#ifdef MID_MIPS
case MID_MIPS:
#endif
- ex.a_text = mopFileGetBX((u_char *)&ex_swap, 4, 4);
- ex.a_data = mopFileGetBX((u_char *)&ex_swap, 8, 4);
- ex.a_bss = mopFileGetBX((u_char *)&ex_swap, 12, 4);
- ex.a_syms = mopFileGetBX((u_char *)&ex_swap, 16, 4);
- ex.a_entry = mopFileGetBX((u_char *)&ex_swap, 20, 4);
- ex.a_trsize= mopFileGetBX((u_char *)&ex_swap, 24, 4);
- ex.a_drsize= mopFileGetBX((u_char *)&ex_swap, 28, 4);
+ ex.a_text = mopFileGetBX(&ex_swap, 4, 4);
+ ex.a_data = mopFileGetBX(&ex_swap, 8, 4);
+ ex.a_bss = mopFileGetBX(&ex_swap, 12, 4);
+ ex.a_syms = mopFileGetBX(&ex_swap, 16, 4);
+ ex.a_entry = mopFileGetBX(&ex_swap, 20, 4);
+ ex.a_trsize= mopFileGetBX(&ex_swap, 24, 4);
+ ex.a_drsize= mopFileGetBX(&ex_swap, 28, 4);
break;
default:
break;
@@ -525,7 +496,7 @@ GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
#ifdef INFO
printf("a.out image (");
- switch (N_GETMID (ex)) {
+ switch (N_GETMID(ex)) {
case MID_I386:
printf("i386");
break;
@@ -593,145 +564,122 @@ GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
printf("Unknown %d",N_GETMAGIC (ex));
}
printf("\n");
- printf("Size of text: %08x\n",ex.a_text);
- printf("Size of data: %08x\n",ex.a_data);
- printf("Size of bss: %08x\n",ex.a_bss);
- printf("Size of symbol tab: %08x\n",ex.a_syms);
- printf("Transfer Address: %08x\n",ex.a_entry);
- printf("Size of reloc text: %08x\n",ex.a_trsize);
- printf("Size of reloc data: %08x\n",ex.a_drsize);
-#endif
- magic = N_GETMAGIC (ex);
+ printf("Size of text: %08x\n", ex.a_text);
+ printf("Size of data: %08x\n", ex.a_data);
+ printf("Size of bss: %08x\n", ex.a_bss);
+ printf("Size of symbol tab: %08x\n", ex.a_syms);
+ printf("Transfer Address: %08x\n", ex.a_entry);
+ printf("Size of reloc text: %08x\n", ex.a_trsize);
+ printf("Size of reloc data: %08x\n", ex.a_drsize);
+#endif
+ magic = N_GETMAGIC(ex);
clbytes = getCLBYTES(mid);
clofset = clbytes - 1;
- if (load != NULL) {
+ if (load != NULL)
*load = 0;
- }
- if (xfr != NULL) {
- *xfr = ex.a_entry;
- }
+ if (xfr != NULL)
+ *xfr = ex.a_entry;
- if (a_text != NULL) {
+ if (a_text != NULL)
*a_text = ex.a_text;
- }
if (a_text_fill != NULL) {
if (magic == ZMAGIC || magic == NMAGIC) {
*a_text_fill = clbytes - (ex.a_text & clofset);
- if (*a_text_fill == clbytes) {
+ if (*a_text_fill == clbytes)
*a_text_fill = 0;
- }
- } else {
+ } else
*a_text_fill = 0;
- }
}
- if (a_data != NULL) {
+ if (a_data != NULL)
*a_data = ex.a_data;
- }
if (a_data_fill != NULL) {
if (magic == ZMAGIC || magic == NMAGIC) {
*a_data_fill = clbytes - (ex.a_data & clofset);
- if (*a_data_fill == clbytes) {
+ if (*a_data_fill == clbytes)
*a_data_fill = 0;
- }
- } else {
+ } else
*a_data_fill = 0;
- }
}
- if (a_bss != NULL) {
+ if (a_bss != NULL)
*a_bss = ex.a_bss;
- }
if (a_bss_fill != NULL) {
if (magic == ZMAGIC || magic == NMAGIC) {
*a_bss_fill = clbytes - (ex.a_bss & clofset);
- if (*a_bss_fill == clbytes) {
+ if (*a_bss_fill == clbytes)
*a_bss_fill = 0;
- }
} else {
*a_bss_fill = clbytes -
- ((ex.a_text+ex.a_data+ex.a_bss) & clofset);
- if (*a_text_fill == clbytes) {
+ ((ex.a_text + ex.a_data + ex.a_bss) & clofset);
+ if (*a_text_fill == clbytes)
*a_text_fill = 0;
- }
}
}
- if (aout != NULL) {
+ if (aout != NULL)
*aout = mid;
- }
- return(0);
+ return (0);
#endif /* NOAOUT */
}
int
-GetFileInfo(fd, load, xfr, aout,
- a_text, a_text_fill, a_data, a_data_fill, a_bss, a_bss_fill)
- int fd, *aout;
- u_long *load, *xfr, *a_text, *a_text_fill;
- u_long *a_data, *a_data_fill, *a_bss, *a_bss_fill;
+GetFileInfo(int fd, u_long *load, u_long *xfr, int *aout, u_long *a_text,
+ u_long *a_text_fill, u_long *a_data, u_long *a_data_fill, u_long *a_bss,
+ u_long *a_bss_fill)
{
int err;
err = CheckAOutFile(fd);
if (err == 0) {
- err = GetAOutFileInfo(fd, load, xfr,
- a_text, a_text_fill,
- a_data, a_data_fill,
- a_bss, a_bss_fill,
- aout);
- if (err != 0) {
- return(-1);
- }
+ err = GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
+ a_data, a_data_fill, a_bss, a_bss_fill, aout);
+ if (err != 0)
+ return (-1);
} else {
err = CheckMopFile(fd);
-
+
if (err == 0) {
err = GetMopFileInfo(fd, load, xfr);
- if (err != 0) {
- return(-1);
- }
+ if (err != 0)
+ return (-1);
*aout = -1;
- } else {
- return(-1);
- }
+ } else
+ return (-1);
}
- return(0);
+ return (0);
}
ssize_t
-mopFileRead(dlslot, buf)
- struct dllist *dlslot;
- u_char *buf;
+mopFileRead(struct dllist *dlslot, u_char *buf)
{
ssize_t len, outlen;
int bsz;
long pos, notdone, total;
- if (dlslot->aout == -1) {
+ if (dlslot->aout == -1)
len = read(dlslot->ldfd,buf,dlslot->dl_bsz);
- } else {
+ else {
bsz = dlslot->dl_bsz;
pos = dlslot->a_lseek;
len = 0;
total = dlslot->a_text;
-
+
if (pos < total) {
notdone = total - pos;
- if (notdone <= bsz) {
+ if (notdone <= bsz)
outlen = read(dlslot->ldfd,&buf[len],notdone);
- } else {
+ else
outlen = read(dlslot->ldfd,&buf[len],bsz);
- }
len = len + outlen;
pos = pos + outlen;
bsz = bsz - outlen;
@@ -741,11 +689,10 @@ mopFileRead(dlslot, buf)
if ((bsz > 0) && (pos < total)) {
notdone = total - pos;
- if (notdone <= bsz) {
+ if (notdone <= bsz)
outlen = notdone;
- } else {
+ else
outlen = bsz;
- }
bzero(&buf[len],outlen);
len = len + outlen;
pos = pos + outlen;
@@ -753,14 +700,13 @@ mopFileRead(dlslot, buf)
}
total = total + dlslot->a_data;
-
+
if ((bsz > 0) && (pos < total)) {
notdone = total - pos;
- if (notdone <= bsz) {
+ if (notdone <= bsz)
outlen = read(dlslot->ldfd,&buf[len],notdone);
- } else {
+ else
outlen = read(dlslot->ldfd,&buf[len],bsz);
- }
len = len + outlen;
pos = pos + outlen;
bsz = bsz - outlen;
@@ -770,50 +716,47 @@ mopFileRead(dlslot, buf)
if ((bsz > 0) && (pos < total)) {
notdone = total - pos;
- if (notdone <= bsz) {
+ if (notdone <= bsz)
outlen = notdone;
- } else {
+ else
outlen = bsz;
- }
bzero(&buf[len],outlen);
len = len + outlen;
pos = pos + outlen;
bsz = bsz - outlen;
}
-
+
total = total + dlslot->a_bss;
if ((bsz > 0) && (pos < total)) {
notdone = total - pos;
- if (notdone <= bsz) {
+ if (notdone <= bsz)
outlen = notdone;
- } else {
+ else
outlen = bsz;
- }
bzero(&buf[len],outlen);
len = len + outlen;
pos = pos + outlen;
bsz = bsz - outlen;
}
-
+
total = total + dlslot->a_bss_fill;
if ((bsz > 0) && (pos < total)) {
notdone = total - pos;
- if (notdone <= bsz) {
+ if (notdone <= bsz)
outlen = notdone;
- } else {
+ else
outlen = bsz;
- }
bzero(&buf[len],outlen);
len = len + outlen;
pos = pos + outlen;
bsz = bsz - outlen;
}
-
+
dlslot->a_lseek = pos;
}
- return(len);
+ return (len);
}
diff --git a/usr.sbin/mopd/common/file.h b/usr.sbin/mopd/common/file.h
index 158b79bd073..cca0e122175 100644
--- a/usr.sbin/mopd/common/file.h
+++ b/usr.sbin/mopd/common/file.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.h,v 1.8 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: file.h,v 1.9 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $OpenBSD: file.h,v 1.8 2003/12/01 00:56:51 avsm Exp $
+ * $OpenBSD: file.h,v 1.9 2004/04/14 20:37:28 henning Exp $
*
*/
@@ -32,9 +32,9 @@
void mopFilePutLX(u_char *, int, u_long, int);
void mopFilePutBX(u_char *, int, u_long, int);
-u_long mopFileGetLX(u_char *, int, int);
-u_long mopFileGetBX(u_char *, int, int);
-void mopFileSwapX(u_char *, int, int);
+u_long mopFileGetLX(void *, int, int);
+u_long mopFileGetBX(void *, int, int);
+void mopFileSwapX(void *, int, int);
int CheckMopFile(int);
int GetMopFileInfo(int, u_long *, u_long *);
int CheckAOutFile(int);
diff --git a/usr.sbin/mopd/common/get.c b/usr.sbin/mopd/common/get.c
index ab3e7762d7e..55f1d75f50d 100644
--- a/usr.sbin/mopd/common/get.c
+++ b/usr.sbin/mopd/common/get.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: get.c,v 1.5 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: get.c,v 1.6 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -25,121 +25,103 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: get.c,v 1.5 2003/12/01 00:56:51 avsm Exp $";
+static const char rcsid[] =
+ "$OpenBSD: get.c,v 1.6 2004/04/14 20:37:28 henning Exp $";
#endif
#include <sys/types.h>
#include "common/mopdef.h"
u_char
-mopGetChar(pkt, index)
- u_char *pkt;
- int *index;
+mopGetChar(u_char *pkt, int *index)
{
- u_char ret;
+ u_char ret;
ret = pkt[*index];
*index = *index + 1;
- return(ret);
+ return (ret);
}
u_short
-mopGetShort(pkt, index)
- u_char *pkt;
- int *index;
+mopGetShort(u_char *pkt, int *index)
{
- u_short ret;
-
+ u_short ret;
+
ret = pkt[*index] + pkt[*index+1]*256;
*index = *index + 2;
- return(ret);
+ return (ret);
}
u_long
-mopGetLong(pkt, index)
- u_char *pkt;
- int *index;
+mopGetLong(u_char *pkt, int *index)
{
- u_long ret;
-
- ret = pkt[*index] +
- pkt[*index+1]*0x100 +
- pkt[*index+2]*0x10000 +
- pkt[*index+3]*0x1000000;
+ u_long ret;
+
+ ret = pkt[*index] + pkt[*index+1]*0x100 + pkt[*index+2]*0x10000 +
+ pkt[*index+3]*0x1000000;
*index = *index + 4;
- return(ret);
+ return (ret);
}
void
-mopGetMulti(pkt, index, dest, size)
- u_char *pkt,*dest;
- int *index,size;
+mopGetMulti(u_char *pkt, int *index, u_char *dest, int size)
{
int i;
- for (i = 0; i < size; i++) {
- dest[i] = pkt[*index+i];
- }
+ for (i = 0; i < size; i++)
+ dest[i] = pkt[*index+i];
*index = *index + size;
-
}
int
-mopGetTrans(pkt, trans)
- u_char *pkt;
- int trans;
+mopGetTrans(u_char *pkt, int trans)
{
u_short *ptype;
-
+
if (trans == 0) {
ptype = (u_short *)(pkt+12);
- if (ntohs(*ptype) < 1600) {
+ if (ntohs(*ptype) < 1600)
trans = TRANS_8023;
- } else {
+ else
trans = TRANS_ETHER;
- }
}
- return(trans);
+ return (trans);
}
void
-mopGetHeader(pkt, index, dst, src, proto, len, trans)
- u_char *pkt, **dst, **src;
- int *index, *len, trans;
- u_short *proto;
+mopGetHeader(u_char *pkt, int *index, u_char **dst, u_char **src,
+ u_short *proto, int *len, int trans)
{
*dst = pkt;
*src = pkt + 6;
*index = *index + 12;
- switch(trans) {
+ switch (trans) {
case TRANS_ETHER:
- *proto = (u_short)(pkt[*index]*256 + pkt[*index+1]);
+ *proto = (u_short)(pkt[*index] * 256 + pkt[*index + 1]);
*index = *index + 2;
- *len = (int)(pkt[*index+1]*256 + pkt[*index]);
+ *len = (int)(pkt[*index + 1] * 256 + pkt[*index]);
*index = *index + 2;
break;
case TRANS_8023:
- *len = (int)(pkt[*index]*256 + pkt[*index+1]);
+ *len = (int)(pkt[*index] * 256 + pkt[*index + 1]);
*index = *index + 8;
- *proto = (u_short)(pkt[*index]*256 + pkt[*index+1]);
+ *proto = (u_short)(pkt[*index] * 256 + pkt[*index + 1]);
*index = *index + 2;
break;
}
}
u_short
-mopGetLength(pkt, trans)
- u_char *pkt;
- int trans;
+mopGetLength(u_char *pkt, int trans)
{
- switch(trans) {
+ switch (trans) {
case TRANS_ETHER:
- return(pkt[15]*256 + pkt[14]);
+ return (pkt[15] * 256 + pkt[14]);
break;
case TRANS_8023:
- return(pkt[12]*256 + pkt[13]);
+ return (pkt[12] * 256 + pkt[13]);
break;
}
- return(0);
+ return (0);
}
diff --git a/usr.sbin/mopd/common/get.h b/usr.sbin/mopd/common/get.h
index 2e554c80e9e..e74c70b07ff 100644
--- a/usr.sbin/mopd/common/get.h
+++ b/usr.sbin/mopd/common/get.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: get.h,v 1.7 2003/06/02 21:38:39 maja Exp $ */
+/* $OpenBSD: get.h,v 1.8 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $OpenBSD: get.h,v 1.7 2003/06/02 21:38:39 maja Exp $
+ * $OpenBSD: get.h,v 1.8 2004/04/14 20:37:28 henning Exp $
*
*/
@@ -36,7 +36,7 @@ u_long mopGetLong(u_char *,int *);
void mopGetMulti(u_char *,int *,u_char *,int);
int mopGetTrans(u_char *, int);
void mopGetHeader(u_char *, int *, u_char **, u_char **, u_short *,
- int *, int);
+ int *, int);
u_short mopGetLength(u_char *, int);
#endif /* _GET_H_ */
diff --git a/usr.sbin/mopd/common/loop-bsd.c b/usr.sbin/mopd/common/loop-bsd.c
index 21132bbf2e9..51569ebfd70 100644
--- a/usr.sbin/mopd/common/loop-bsd.c
+++ b/usr.sbin/mopd/common/loop-bsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loop-bsd.c,v 1.8 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: loop-bsd.c,v 1.9 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -25,7 +25,8 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: loop-bsd.c,v 1.8 2003/12/01 00:56:51 avsm Exp $";
+static const char rcsid[] =
+ "$OpenBSD: loop-bsd.c,v 1.9 2004/04/14 20:37:28 henning Exp $";
#endif
#include <stdlib.h>
@@ -43,42 +44,32 @@ static const char rcsid[] = "$OpenBSD: loop-bsd.c,v 1.8 2003/12/01 00:56:51 avsm
#include "common/mopdef.h"
int
-mopOpenRC(p, trans)
- struct if_info *p;
- int trans;
+mopOpenRC(struct if_info *p, int trans)
{
#ifndef NORC
- return (*(p->iopen))(p->if_name,
- O_RDWR,
- MOP_K_PROTO_RC,
- trans);
+ return (*(p->iopen))(p->if_name, O_RDWR, MOP_K_PROTO_RC, trans);
#else
- return -1;
+ return (-1);
#endif
}
int
-mopOpenDL(p, trans)
- struct if_info *p;
- int trans;
+mopOpenDL(struct if_info *p, int trans)
{
#ifndef NODL
- return (*(p->iopen))(p->if_name,
- O_RDWR,
- MOP_K_PROTO_DL,
- trans);
+ return (*(p->iopen))(p->if_name, O_RDWR, MOP_K_PROTO_DL, trans);
#else
- return -1;
+ return (-1);
#endif
}
void
-mopReadRC()
+mopReadRC(void)
{
}
void
-mopReadDL()
+mopReadDL(void)
{
}
@@ -95,25 +86,25 @@ void mopProcess(struct if_info *, u_char *);
* interfaces in 'iflist'.
*/
void
-Loop()
+Loop(void)
{
- u_char *buf, *bp, *ep;
- int cc;
- fd_set fds, listeners;
- int bufsize, maxfd = 0;
- struct if_info *ii;
+ u_char *buf, *bp, *ep;
+ int cc;
+ fd_set fds, listeners;
+ int bufsize, maxfd = 0;
+ struct if_info *ii;
if (iflist == 0) {
syslog(LOG_ERR, "no interfaces");
exit(0);
}
- if (iflist->fd != -1) {
- if (ioctl(iflist->fd, BIOCGBLEN, (caddr_t) & bufsize) < 0) {
+ if (iflist->fd != -1)
+ if (ioctl(iflist->fd, BIOCGBLEN, (caddr_t)&bufsize) < 0) {
syslog(LOG_ERR, "BIOCGBLEN: %m");
exit(0);
- }
- }
- buf = (u_char *) malloc((unsigned) bufsize);
+ }
+
+ buf = malloc(bufsize);
if (buf == 0) {
syslog(LOG_ERR, "malloc: %m");
exit(0);
@@ -123,27 +114,25 @@ Loop()
* Initialize the set of descriptors to listen to.
*/
FD_ZERO(&fds);
- for (ii = iflist; ii; ii = ii->next) {
+ for (ii = iflist; ii; ii = ii->next)
if (ii->fd != -1) {
FD_SET(ii->fd, &fds);
if (ii->fd > maxfd)
maxfd = ii->fd;
- }
- }
+ }
+
while (1) {
listeners = fds;
- if (select(maxfd + 1, &listeners, (fd_set *) 0,
- (fd_set *) 0, (struct timeval *) 0) < 0) {
+ if (select(maxfd + 1, &listeners, NULL, NULL, NULL) < 0) {
syslog(LOG_ERR, "select: %m");
exit(0);
}
- for (ii = iflist; ii; ii = ii->next) {
+ for (ii = iflist; ii; ii = ii->next)
if (ii->fd != -1) {
if (!FD_ISSET(ii->fd, &listeners))
continue;
- }
- again:
- cc = read(ii->fd, (char *) buf, bufsize);
+again:
+ cc = read(ii->fd, buf, bufsize);
/* Don't choke when we get ptraced */
if (cc < 0 && errno == EINTR)
goto again;
@@ -151,9 +140,9 @@ Loop()
* offset overflows and read fails with EINVAL. The
* lseek() to 0 will fix things. */
if (cc < 0) {
- if (errno == EINVAL &&
- (lseek(ii->fd, 0, SEEK_CUR) + bufsize) < 0) {
- (void) lseek(ii->fd, 0, 0);
+ if (errno == EINVAL && (lseek(ii->fd, 0,
+ SEEK_CUR) + bufsize) < 0) {
+ lseek(ii->fd, 0, 0);
goto again;
}
syslog(LOG_ERR, "read: %m");
diff --git a/usr.sbin/mopd/common/mopdef.c b/usr.sbin/mopd/common/mopdef.c
index f60da40ab8b..f54855ed827 100644
--- a/usr.sbin/mopd/common/mopdef.c
+++ b/usr.sbin/mopd/common/mopdef.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mopdef.c,v 1.5 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: mopdef.c,v 1.6 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1995 Mats O Jansson. All rights reserved.
@@ -25,7 +25,8 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: mopdef.c,v 1.5 2003/12/01 00:56:51 avsm Exp $";
+static const char rcsid[] =
+ "$OpenBSD: mopdef.c,v 1.6 2004/04/14 20:37:28 henning Exp $";
#endif
#include <sys/types.h>
@@ -40,9 +41,9 @@ u_char rc_802_proto[5] = MOP_K_PROTO_802_RC; /* MOP Remote Console 802.2 */
u_char lp_802_proto[5] = MOP_K_PROTO_802_LP; /* Loopback 802.2 */
int
-mopdef_dummy()
+mopdef_dummy(void)
{
/* Just to keep them as variables */
- return(dl_mcst[0]-rc_mcst[0]-
- lp_802_proto[1]-rc_802_proto[1]-lp_802_proto[1]);
+ return (dl_mcst[0] - rc_mcst[0] - lp_802_proto[1] - rc_802_proto[1] -
+ lp_802_proto[1]);
}
diff --git a/usr.sbin/mopd/common/nma.c b/usr.sbin/mopd/common/nma.c
index 85bdd303020..4b9359b84b7 100644
--- a/usr.sbin/mopd/common/nma.c
+++ b/usr.sbin/mopd/common/nma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nma.c,v 1.4 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: nma.c,v 1.5 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1995 Mats O Jansson. All rights reserved.
@@ -25,7 +25,8 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: nma.c,v 1.4 2003/12/01 00:56:51 avsm Exp $";
+static const char rcsid[] =
+ "$OpenBSD: nma.c,v 1.5 2004/04/14 20:37:28 henning Exp $";
#endif
#include <stddef.h>
@@ -186,36 +187,33 @@ struct commDev nmaCommDev[] = {
};
char *
-nmaGetShort(devno)
- int devno;
+nmaGetShort(int devno)
{
struct commDev *current;
current = nmaCommDev;
-
+
while (current->sname != NULL) {
if (current->val == devno)
break;
current++;
}
- return(current->sname);
+ return (current->sname);
}
char *
-nmaGetDevice(devno)
- int devno;
+nmaGetDevice(int devno)
{
struct commDev *current;
current = nmaCommDev;
-
+
while (current->name != NULL) {
if (current->val == devno)
break;
current++;
}
- return(current->name);
+ return (current->name);
}
-
diff --git a/usr.sbin/mopd/common/pf.c b/usr.sbin/mopd/common/pf.c
index e24c9903944..ee72e04e0e0 100644
--- a/usr.sbin/mopd/common/pf.c
+++ b/usr.sbin/mopd/common/pf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf.c,v 1.9 2004/01/04 21:41:12 drahn Exp $ */
+/* $OpenBSD: pf.c,v 1.10 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -29,7 +29,8 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: pf.c,v 1.9 2004/01/04 21:41:12 drahn Exp $";
+static const char rcsid[] =
+ "$OpenBSD: pf.c,v 1.10 2004/04/14 20:37:28 henning Exp $";
#endif
#include <stdio.h>
@@ -51,6 +52,7 @@ static const char rcsid[] = "$OpenBSD: pf.c,v 1.9 2004/01/04 21:41:12 drahn Exp
#include <netdb.h>
#include <ctype.h>
#include <string.h>
+#include <err.h>
#include <syslog.h>
@@ -60,7 +62,6 @@ static const char rcsid[] = "$OpenBSD: pf.c,v 1.9 2004/01/04 21:41:12 drahn Exp
* Variables
*/
-extern int errno;
extern int promisc;
/*
@@ -70,28 +71,23 @@ extern int promisc;
*/
int
-pfTrans(interface)
- char *interface;
+pfTrans(char *interface)
{
- return TRANS_ETHER+TRANS_8023+TRANS_AND;
+ return (TRANS_ETHER + TRANS_8023 + TRANS_AND);
}
/*
* Open and initialize packet filter.
*/
-
int
-pfInit(interface, mode, protocol, typ)
- char *interface;
- u_short protocol;
- int typ, mode;
+pfInit(char *interface, int mode, u_short protocol, int typ)
{
- int fd;
- int n = 0;
- char device[sizeof "/dev/bpf000"];
- struct ifreq ifr;
- u_int dlt;
- int immediate;
+ int fd;
+ int n = 0;
+ char device[sizeof "/dev/bpf000"];
+ struct ifreq ifr;
+ u_int dlt;
+ int immediate;
static struct bpf_insn insns[] = {
BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12),
@@ -107,171 +103,158 @@ pfInit(interface, mode, protocol, typ)
sizeof insns / sizeof(insns[0]),
insns
};
-
- /* Go through all the minors and find one that isn't in use. */
+
+ /* Go through all the minors and find one that isn't in use. */
do {
- (void) snprintf(device, sizeof device, "/dev/bpf%d", n++);
+ snprintf(device, sizeof device, "/dev/bpf%d", n++);
fd = open(device, mode);
} while (fd < 0 && errno == EBUSY);
if (fd < 0) {
- syslog(LOG_ERR,"pfInit: open bpf %m");
- return(-1);
+ syslog(LOG_ERR,"pfInit: open bpf %m");
+ return (-1);
}
-
+
/* Set immediate mode so packets are processed as they arrive. */
immediate = 1;
if (ioctl(fd, BIOCIMMEDIATE, &immediate) < 0) {
- syslog(LOG_ERR,"pfInit: BIOCIMMEDIATE: %m");
- return(-1);
+ syslog(LOG_ERR,"pfInit: BIOCIMMEDIATE: %m");
+ return (-1);
}
- (void) strncpy(ifr.ifr_name, interface, sizeof ifr.ifr_name);
+ strncpy(ifr.ifr_name, interface, sizeof ifr.ifr_name);
if (ioctl(fd, BIOCSETIF, (caddr_t) & ifr) < 0) {
- syslog(LOG_ERR,"pfInit: BIOCSETIF: %m");
- return(-1);
+ syslog(LOG_ERR,"pfInit: BIOCSETIF: %m");
+ return (-1);
}
/* Check that the data link layer is an Ethernet; this code won't work
* with anything else. */
- if (ioctl(fd, BIOCGDLT, (caddr_t) & dlt) < 0) {
- syslog(LOG_ERR,"pfInit: BIOCGDLT: %m");
- return(-1);
+ if (ioctl(fd, BIOCGDLT, (caddr_t)&dlt) < 0) {
+ syslog(LOG_ERR,"pfInit: BIOCGDLT: %m");
+ return (-1);
}
if (dlt != DLT_EN10MB) {
- syslog(LOG_ERR,"pfInit: %s is not ethernet", device);
- return(-1);
+ syslog(LOG_ERR,"pfInit: %s is not ethernet", device);
+ return (-1);
}
- if (promisc) {
+ if (promisc)
/* Set promiscuous mode. */
if (ioctl(fd, BIOCPROMISC, (caddr_t)0) < 0) {
- syslog(LOG_ERR,"pfInit: BIOCPROMISC: %m");
- return(-1);
+ syslog(LOG_ERR,"pfInit: BIOCPROMISC: %m");
+ return (-1);
}
- }
+
/* Set filter program. */
insns[1].k = protocol;
insns[3].k = protocol;
if (ioctl(fd, BIOCSETF, (caddr_t) & filter) < 0) {
- syslog(LOG_ERR,"pfInit: BIOCSETF: %m");
- return(-1);
+ syslog(LOG_ERR,"pfInit: BIOCSETF: %m");
+ return (-1);
}
- return(fd);
+ return (fd);
}
/*
* Add a Multicast address to the interface
*/
-
int
-pfAddMulti(s, interface, addr)
- int s;
- char *interface, *addr;
+pfAddMulti(int s, char *interface, char *addr)
{
- struct ifreq ifr;
- int fd;
-
- strncpy(ifr.ifr_name, interface,sizeof(ifr.ifr_name) - 1);
- ifr.ifr_name[sizeof(ifr.ifr_name)-1] = 0;
+ struct ifreq ifr;
+ int fd;
+
+ strncpy(ifr.ifr_name, interface, sizeof(ifr.ifr_name) - 1);
+ ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = 0;
ifr.ifr_addr.sa_family = AF_UNSPEC;
bcopy(addr, ifr.ifr_addr.sa_data, 6);
-
+
/*
* open a socket, temporarily, to use for SIOC* ioctls
- *
*/
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
syslog(LOG_ERR, "pfAddMulti: socket: %m");
- return(-1);
+ return (-1);
}
if (ioctl(fd, SIOCADDMULTI, (caddr_t)&ifr) < 0) {
syslog(LOG_ERR, "pfAddMulti: SIOCADDMULTI: %m");
close(fd);
- return(-1);
+ return (-1);
}
close(fd);
-
- return(0);
+
+ return (0);
}
/*
* Delete a Multicast address from the interface
*/
-
int
-pfDelMulti(s, interface, addr)
- int s;
- char *interface, *addr;
+pfDelMulti(int s, char *interface, char *addr)
{
- struct ifreq ifr;
- int fd;
-
+ struct ifreq ifr;
+ int fd;
+
strncpy(ifr.ifr_name, interface, sizeof (ifr.ifr_name) - 1);
ifr.ifr_name[sizeof(ifr.ifr_name)-1] = 0;
-
+
ifr.ifr_addr.sa_family = AF_UNSPEC;
bcopy(addr, ifr.ifr_addr.sa_data, 6);
-
+
/*
* open a socket, temporarily, to use for SIOC* ioctls
*
*/
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
syslog(LOG_ERR, "pfDelMulti: socket: %m");
- return(-1);
+ return (-1);
}
if (ioctl(fd, SIOCDELMULTI, (caddr_t)&ifr) < 0) {
syslog(LOG_ERR, "pfAddMulti: SIOCDELMULTI: %m");
close(fd);
- return(-1);
+ return (-1);
}
close(fd);
-
- return(0);
+
+ return (0);
}
/*
* read a packet
*/
-
int
-pfRead(fd, buf, len)
- int fd, len;
- u_char *buf;
+pfRead(int fd, u_char *buf, int len)
{
- return(read(fd, buf, len));
+ return (read(fd, buf, len));
}
/*
* write a packet
*/
-
int
-pfWrite(fd, buf, len, trans)
- int fd, len, trans;
- u_char *buf;
+pfWrite(int fd, u_char *buf, int len, int trans)
{
-
- struct iovec iov[2];
-
+ struct iovec iov[2];
+
+ /* XXX */
switch (trans) {
case TRANS_8023:
- iov[0].iov_base = (caddr_t)buf;
+ iov[0].iov_base = buf;
iov[0].iov_len = 22;
- iov[1].iov_base = (caddr_t)buf+22;
- iov[1].iov_len = len-22;
+ iov[1].iov_base = buf + 22;
+ iov[1].iov_len = len - 22;
break;
default:
- iov[0].iov_base = (caddr_t)buf;
+ iov[0].iov_base = buf;
iov[0].iov_len = 14;
- iov[1].iov_base = (caddr_t)buf+14;
- iov[1].iov_len = len-14;
+ iov[1].iov_base = buf + 14;
+ iov[1].iov_len = len - 14;
break;
}
if (writev(fd, iov, 2) == len)
- return(len);
-
- return(-1);
+ return (len);
+
+ return (-1);
}
diff --git a/usr.sbin/mopd/common/print.c b/usr.sbin/mopd/common/print.c
index 49d578c4f82..a3c9f98bcc9 100644
--- a/usr.sbin/mopd/common/print.c
+++ b/usr.sbin/mopd/common/print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print.c,v 1.6 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: print.c,v 1.7 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-96 Mats O Jansson. All rights reserved.
@@ -25,7 +25,8 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: print.c,v 1.6 2003/12/01 00:56:51 avsm Exp $";
+static const char rcsid[] =
+ "$OpenBSD: print.c,v 1.7 2004/04/14 20:37:28 henning Exp $";
#endif
#include <sys/types.h>
@@ -41,67 +42,58 @@ static const char rcsid[] = "$OpenBSD: print.c,v 1.6 2003/12/01 00:56:51 avsm Ex
#define SHORT_PRINT
void
-mopPrintHWA(fd, ap)
- FILE *fd;
- u_char *ap;
+mopPrintHWA(FILE *fd, u_char *ap)
{
- (void)fprintf(fd, "%x:%x:%x:%x:%x:%x",
- ap[0],ap[1],ap[2],ap[3],ap[4],ap[5]);
- if (ap[0] < 16) (void)fprintf(fd, " ");
- if (ap[1] < 16) (void)fprintf(fd, " ");
- if (ap[2] < 16) (void)fprintf(fd, " ");
- if (ap[3] < 16) (void)fprintf(fd, " ");
- if (ap[4] < 16) (void)fprintf(fd, " ");
- if (ap[5] < 16) (void)fprintf(fd, " ");
+ fprintf(fd, "%x:%x:%x:%x:%x:%x", ap[0], ap[1], ap[2], ap[3], ap[4],
+ ap[5]);
+ if (ap[0] < 16) fprintf(fd, " ");
+ if (ap[1] < 16) fprintf(fd, " ");
+ if (ap[2] < 16) fprintf(fd, " ");
+ if (ap[3] < 16) fprintf(fd, " ");
+ if (ap[4] < 16) fprintf(fd, " ");
+ if (ap[5] < 16) fprintf(fd, " ");
}
void
-mopPrintBPTY(fd, bpty)
- FILE *fd;
- u_char bpty;
+mopPrintBPTY(FILE *fd, u_char bpty)
{
- switch(bpty) {
+ switch (bpty) {
case MOP_K_BPTY_SYS:
- (void)fprintf(fd, "System Processor");
+ fprintf(fd, "System Processor");
break;
case MOP_K_BPTY_COM:
- (void)fprintf(fd, "Communication Processor");
+ fprintf(fd, "Communication Processor");
break;
default:
- (void)fprintf(fd, "Unknown");
+ fprintf(fd, "Unknown");
break;
};
}
void
-mopPrintPGTY(fd, pgty)
- FILE *fd;
- u_char pgty;
+mopPrintPGTY(FILE *fd, u_char pgty)
{
- switch(pgty) {
+ switch (pgty) {
case MOP_K_PGTY_SECLDR:
- (void)fprintf(fd, "Secondary Loader");
+ fprintf(fd, "Secondary Loader");
break;
case MOP_K_PGTY_TERLDR:
- (void)fprintf(fd, "Tertiary Loader");
+ fprintf(fd, "Tertiary Loader");
break;
case MOP_K_PGTY_OPRSYS:
- (void)fprintf(fd, "Operating System");
+ fprintf(fd, "Operating System");
break;
case MOP_K_PGTY_MGNTFL:
- (void)fprintf(fd, "Management File");
+ fprintf(fd, "Management File");
break;
default:
- (void)fprintf(fd, "Unknown");
+ fprintf(fd, "Unknown");
break;
};
}
void
-mopPrintOneline(fd, pkt, trans)
- FILE *fd;
- u_char *pkt;
- int trans;
+mopPrintOneline(FILE *fd, u_char *pkt, int trans)
{
int index = 0;
u_char *dst, *src, code;
@@ -114,144 +106,139 @@ mopPrintOneline(fd, pkt, trans)
switch (proto) {
case MOP_K_PROTO_DL:
- (void)fprintf(fd, "MOP DL ");
+ fprintf(fd, "MOP DL ");
break;
case MOP_K_PROTO_RC:
- (void)fprintf(fd, "MOP RC ");
+ fprintf(fd, "MOP RC ");
break;
case MOP_K_PROTO_LP:
- (void)fprintf(fd, "MOP LP ");
+ fprintf(fd, "MOP LP ");
break;
default:
- switch((proto % 256)*256 + (proto / 256)) {
+ switch ((proto % 256) * 256 + (proto / 256)) {
case MOP_K_PROTO_DL:
- (void)fprintf(fd, "MOP DL ");
+ fprintf(fd, "MOP DL ");
proto = MOP_K_PROTO_DL;
break;
case MOP_K_PROTO_RC:
- (void)fprintf(fd, "MOP RC ");
+ fprintf(fd, "MOP RC ");
proto = MOP_K_PROTO_RC;
break;
case MOP_K_PROTO_LP:
- (void)fprintf(fd, "MOP LP ");
+ fprintf(fd, "MOP LP ");
proto = MOP_K_PROTO_LP;
break;
default:
- (void)fprintf(fd, "MOP ?? ");
+ fprintf(fd, "MOP ?? ");
break;
}
}
- if (trans == TRANS_8023) {
- (void)fprintf(fd, "802.3 ");
- }
+ if (trans == TRANS_8023)
+ fprintf(fd, "802.3 ");
- mopPrintHWA(fd, src); (void)fprintf(fd," > ");
+ mopPrintHWA(fd, src); fprintf(fd, " > ");
mopPrintHWA(fd, dst);
- if (len < 1600) {
- (void)fprintf(fd, " len %4d code %02x ",len,code);
- } else {
- (void)fprintf(fd, " len %4d code %02x ",
- (len % 256)*256 + (len /256), code);
- }
+ if (len < 1600)
+ fprintf(fd, " len %4d code %02x ", len, code);
+ else
+ fprintf(fd, " len %4d code %02x ",
+ (len % 256)*256 + (len /256), code);
switch (proto) {
case MOP_K_PROTO_DL:
- switch (code) {
+ switch (code) {
case MOP_K_CODE_MLT:
- (void)fprintf(fd, "MLT ");
+ fprintf(fd, "MLT ");
break;
case MOP_K_CODE_DCM:
- (void)fprintf(fd, "DCM ");
+ fprintf(fd, "DCM ");
break;
case MOP_K_CODE_MLD:
- (void)fprintf(fd, "MLD ");
+ fprintf(fd, "MLD ");
break;
case MOP_K_CODE_ASV:
- (void)fprintf(fd, "ASV ");
+ fprintf(fd, "ASV ");
break;
case MOP_K_CODE_RMD:
- (void)fprintf(fd, "RMD ");
+ fprintf(fd, "RMD ");
break;
case MOP_K_CODE_RPR:
- (void)fprintf(fd, "RPR ");
+ fprintf(fd, "RPR ");
break;
case MOP_K_CODE_RML:
- (void)fprintf(fd, "RML ");
+ fprintf(fd, "RML ");
break;
- case MOP_K_CODE_RDS:
- (void)fprintf(fd, "RDS ");
+ case MOP_K_CODE_RDS:
+ fprintf(fd, "RDS ");
break;
case MOP_K_CODE_MDD:
- (void)fprintf(fd, "MDD ");
+ fprintf(fd, "MDD ");
break;
case MOP_K_CODE_PLT:
- (void)fprintf(fd, "PLT ");
+ fprintf(fd, "PLT ");
break;
- default:
- (void)fprintf(fd, "??? ");
+ default:
+ fprintf(fd, "??? ");
break;
}
break;
case MOP_K_PROTO_RC:
switch (code) {
case MOP_K_CODE_RID:
- (void)fprintf(fd, "RID ");
+ fprintf(fd, "RID ");
break;
case MOP_K_CODE_BOT:
- (void)fprintf(fd, "BOT ");
+ fprintf(fd, "BOT ");
break;
case MOP_K_CODE_SID:
- (void)fprintf(fd, "SID ");
+ fprintf(fd, "SID ");
break;
case MOP_K_CODE_RQC:
- (void)fprintf(fd, "RQC ");
+ fprintf(fd, "RQC ");
break;
case MOP_K_CODE_CNT:
- (void)fprintf(fd, "CNT ");
+ fprintf(fd, "CNT ");
break;
case MOP_K_CODE_RVC:
- (void)fprintf(fd, "RVC ");
+ fprintf(fd, "RVC ");
break;
case MOP_K_CODE_RLC:
- (void)fprintf(fd, "RLC ");
+ fprintf(fd, "RLC ");
break;
case MOP_K_CODE_CCP:
- (void)fprintf(fd, "CCP ");
+ fprintf(fd, "CCP ");
break;
case MOP_K_CODE_CRA:
- (void)fprintf(fd, "CRA ");
+ fprintf(fd, "CRA ");
break;
default:
- (void)fprintf(fd, "??? ");
+ fprintf(fd, "??? ");
break;
}
break;
case MOP_K_PROTO_LP:
switch (code) {
case MOP_K_CODE_ALD:
- (void)fprintf(fd, "ALD ");
+ fprintf(fd, "ALD ");
break;
case MOP_K_CODE_PLD:
- (void)fprintf(fd, "PLD ");
+ fprintf(fd, "PLD ");
break;
default:
- (void)fprintf(fd, "??? ");
+ fprintf(fd, "??? ");
break;
}
break;
default:
- (void)fprintf(fd, "??? ");
+ fprintf(fd, "??? ");
break;
}
- (void)fprintf(fd, "\n");
+ fprintf(fd, "\n");
}
void
-mopPrintHeader(fd, pkt, trans)
- FILE *fd;
- u_char *pkt;
- int trans;
+mopPrintHeader(FILE *fd, u_char *pkt, int trans)
{
u_char *dst, *src;
u_short proto;
@@ -259,63 +246,58 @@ mopPrintHeader(fd, pkt, trans)
trans = mopGetTrans(pkt, trans);
mopGetHeader(pkt, &index, &dst, &src, &proto, &len, trans);
-
- (void)fprintf(fd,"\nDst : ");
+
+ fprintf(fd, "\nDst : ");
mopPrintHWA(fd, dst);
- if (mopCmpEAddr(dl_mcst,dst) == 0) {
- (void)fprintf(fd," MOP Dump/Load Multicast");
- };
- if (mopCmpEAddr(rc_mcst,dst) == 0) {
- (void)fprintf(fd," MOP Remote Console Multicast");
- };
- (void)fprintf(fd,"\n");
+ if (mopCmpEAddr(dl_mcst, dst) == 0)
+ fprintf(fd, " MOP Dump/Load Multicast");
+ if (mopCmpEAddr(rc_mcst, dst) == 0)
+ fprintf(fd, " MOP Remote Console Multicast");
+ fprintf(fd, "\n");
- (void)fprintf(fd,"Src : ");
+ fprintf(fd, "Src : ");
mopPrintHWA(fd, src);
- (void)fprintf(fd,"\n");
- (void)fprintf(fd,"Proto : %04x ",proto);
+ fprintf(fd, "\n");
+ fprintf(fd, "Proto : %04x ", proto);
+
switch (proto) {
case MOP_K_PROTO_DL:
switch (trans) {
case TRANS_8023:
- (void)fprintf(fd, "MOP Dump/Load (802.3)\n");
+ fprintf(fd, "MOP Dump/Load (802.3)\n");
break;
default:
- (void)fprintf(fd, "MOP Dump/Load\n");
+ fprintf(fd, "MOP Dump/Load\n");
}
break;
case MOP_K_PROTO_RC:
switch (trans) {
case TRANS_8023:
- (void)fprintf(fd, "MOP Remote Console (802.3)\n");
+ fprintf(fd, "MOP Remote Console (802.3)\n");
break;
default:
- (void)fprintf(fd, "MOP Remote Console\n");
+ fprintf(fd, "MOP Remote Console\n");
}
break;
case MOP_K_PROTO_LP:
switch (trans) {
case TRANS_8023:
- (void)fprintf(fd, "MOP Loopback (802.3)\n");
+ fprintf(fd, "MOP Loopback (802.3)\n");
break;
default:
- (void)fprintf(fd, "MOP Loopback\n");
+ fprintf(fd, "MOP Loopback\n");
}
break;
default:
- (void)fprintf(fd, "\n");
+ fprintf(fd, "\n");
break;
}
-
- (void)fprintf(fd,"Length : %04x (%d)\n",len,len);
+ fprintf(fd, "Length : %04x (%d)\n", len, len);
}
void
-mopPrintMopHeader(fd, pkt, trans)
- FILE *fd;
- u_char *pkt;
- int trans;
+mopPrintMopHeader(FILE *fd, u_char *pkt, int trans)
{
u_char *dst, *src;
u_short proto;
@@ -324,144 +306,133 @@ mopPrintMopHeader(fd, pkt, trans)
trans = mopGetTrans(pkt, trans);
mopGetHeader(pkt, &index, &dst, &src, &proto, &len, trans);
-
+
code = mopGetChar(pkt, &index);
- (void)fprintf(fd, "Code : %02x ",code);
+ fprintf(fd, "Code : %02x ", code);
switch (proto) {
case MOP_K_PROTO_DL:
switch (code) {
case MOP_K_CODE_MLT:
- (void)fprintf(fd,
- "Memory Load with transfer address\n");
+ fprintf(fd, "Memory Load with transfer address\n");
break;
case MOP_K_CODE_DCM:
- (void)fprintf(fd, "Dump Complete\n");
+ fprintf(fd, "Dump Complete\n");
break;
case MOP_K_CODE_MLD:
- (void)fprintf(fd, "Memory Load\n");
+ fprintf(fd, "Memory Load\n");
break;
case MOP_K_CODE_ASV:
- (void)fprintf(fd, "Assistance volunteer\n");
+ fprintf(fd, "Assistance volunteer\n");
break;
case MOP_K_CODE_RMD:
- (void)fprintf(fd, "Request memory dump\n");
+ fprintf(fd, "Request memory dump\n");
break;
case MOP_K_CODE_RPR:
- (void)fprintf(fd, "Request program\n");
+ fprintf(fd, "Request program\n");
break;
case MOP_K_CODE_RML:
- (void)fprintf(fd, "Request memory load\n");
+ fprintf(fd, "Request memory load\n");
break;
case MOP_K_CODE_RDS:
- (void)fprintf(fd, "Request Dump Service\n");
+ fprintf(fd, "Request Dump Service\n");
break;
case MOP_K_CODE_MDD:
- (void)fprintf(fd, "Memory dump data\n");
+ fprintf(fd, "Memory dump data\n");
break;
case MOP_K_CODE_PLT:
- (void)fprintf(fd,
- "Parameter load with transfer addres\n");
+ fprintf(fd, "Parameter load with transfer addres\n");
break;
default:
- (void)fprintf(fd, "(unknown)\n");
+ fprintf(fd, "(unknown)\n");
break;
}
break;
case MOP_K_PROTO_RC:
switch (code) {
case MOP_K_CODE_RID:
- (void)fprintf(fd, "Request ID\n");
+ fprintf(fd, "Request ID\n");
break;
case MOP_K_CODE_BOT:
- (void)fprintf(fd, "Boot\n");
+ fprintf(fd, "Boot\n");
break;
case MOP_K_CODE_SID:
- (void)fprintf(fd, "System ID\n");
+ fprintf(fd, "System ID\n");
break;
case MOP_K_CODE_RQC:
- (void)fprintf(fd, "Request Counters\n");
+ fprintf(fd, "Request Counters\n");
break;
case MOP_K_CODE_CNT:
- (void)fprintf(fd, "Counters\n");
+ fprintf(fd, "Counters\n");
break;
case MOP_K_CODE_RVC:
- (void)fprintf(fd, "Reserve Console\n");
+ fprintf(fd, "Reserve Console\n");
break;
case MOP_K_CODE_RLC:
- (void)fprintf(fd, "Release Console\n");
+ fprintf(fd, "Release Console\n");
break;
case MOP_K_CODE_CCP:
- (void)fprintf(fd, "Console Command and Poll\n");
+ fprintf(fd, "Console Command and Poll\n");
break;
case MOP_K_CODE_CRA:
- (void)fprintf(fd,
- "Console Response and Acknnowledge\n");
+ fprintf(fd, "Console Response and Acknnowledge\n");
break;
default:
- (void)fprintf(fd, "(unknown)\n");
+ fprintf(fd, "(unknown)\n");
break;
}
break;
case MOP_K_PROTO_LP:
switch (code) {
case MOP_K_CODE_ALD:
- (void)fprintf(fd, "Active loop data\n");
+ fprintf(fd, "Active loop data\n");
break;
case MOP_K_CODE_PLD:
- (void)fprintf(fd, "Passive looped data\n");
+ fprintf(fd, "Passive looped data\n");
break;
default:
- (void)fprintf(fd, "(unknown)\n");
+ fprintf(fd, "(unknown)\n");
break;
}
break;
default:
- (void)fprintf(fd, "(unknown)\n");
+ fprintf(fd, "(unknown)\n");
break;
}
}
void
-mopPrintDevice(fd, device)
- FILE *fd;
- u_char device;
+mopPrintDevice(FILE *fd, u_char device)
{
char *sname, *name;
sname = nmaGetShort((int) device);
- name = nmaGetDevice((int) device);
-
- (void)fprintf(fd, "%s '%s'",sname,name);
+ name = nmaGetDevice((int) device);
+
+ fprintf(fd, "%s '%s'", sname, name);
}
void
-mopPrintTime(fd, ap)
- FILE *fd;
- u_char *ap;
+mopPrintTime(FILE *fd, u_char *ap)
{
- (void)fprintf(fd,
- "%04d-%02d-%02d %02d:%02d:%02d.%02d %d:%02d",
- ap[0]*100 + ap[1],
- ap[2],ap[3],ap[4],ap[5],ap[6],ap[7],ap[8],ap[9]);
+ fprintf(fd, "%04d-%02d-%02d %02d:%02d:%02d.%02d %d:%02d",
+ ap[0] * 100 + ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7],
+ ap[8], ap[9]);
}
void
-mopPrintInfo(fd, pkt, index, moplen, mopcode, trans)
- FILE *fd;
- u_char *pkt, mopcode;
- int *index, trans;
- u_short moplen;
+mopPrintInfo(FILE *fd, u_char *pkt, int *index, u_short moplen, u_char mopcode,
+ int trans)
{
- u_short itype,tmps;
- u_char ilen ,tmpc,device;
- u_char uc1,uc2,uc3,*ucp;
+ u_short itype, tmps;
+ u_char ilen, tmpc, device;
+ u_char uc1, uc2, uc3, *ucp;
int i;
-
+
device = 0;
- switch(trans) {
+ switch (trans) {
case TRANS_ETHER:
moplen = moplen + 16;
break;
@@ -470,148 +441,143 @@ mopPrintInfo(fd, pkt, index, moplen, mopcode, trans)
break;
}
- itype = mopGetShort(pkt,index);
+ itype = mopGetShort(pkt, index);
- while (*index < (int)(moplen + 2)) {
- ilen = mopGetChar(pkt,index);
+ while (*index < (moplen + 2)) {
+ ilen = mopGetChar(pkt, index);
switch (itype) {
case 0:
- tmpc = mopGetChar(pkt,index);
+ tmpc = mopGetChar(pkt, index);
*index = *index + tmpc;
break;
case MOP_K_INFO_VER:
- uc1 = mopGetChar(pkt,index);
- uc2 = mopGetChar(pkt,index);
- uc3 = mopGetChar(pkt,index);
- (void)fprintf(fd,"Maint Version: %d.%d.%d\n",
- uc1,uc2,uc3);
+ uc1 = mopGetChar(pkt, index);
+ uc2 = mopGetChar(pkt, index);
+ uc3 = mopGetChar(pkt, index);
+ fprintf(fd, "Maint Version: %d.%d.%d\n", uc1, uc2, uc3);
break;
case MOP_K_INFO_MFCT:
- tmps = mopGetShort(pkt,index);
- (void)fprintf(fd,"Maint Funcion: %04x ( ",tmps);
- if (tmps & 1) (void)fprintf(fd, "Loop ");
- if (tmps & 2) (void)fprintf(fd, "Dump ");
- if (tmps & 4) (void)fprintf(fd, "Pldr ");
- if (tmps & 8) (void)fprintf(fd, "MLdr ");
- if (tmps & 16) (void)fprintf(fd, "Boot ");
- if (tmps & 32) (void)fprintf(fd, "CC ");
- if (tmps & 64) (void)fprintf(fd, "DLC ");
- if (tmps & 128) (void)fprintf(fd, "CCR ");
- (void)fprintf(fd, ")\n");
+ tmps = mopGetShort(pkt, index);
+ fprintf(fd, "Maint Funcion: %04x ( ", tmps);
+ if (tmps & 1) fprintf(fd, "Loop ");
+ if (tmps & 2) fprintf(fd, "Dump ");
+ if (tmps & 4) fprintf(fd, "Pldr ");
+ if (tmps & 8) fprintf(fd, "MLdr ");
+ if (tmps & 16) fprintf(fd, "Boot ");
+ if (tmps & 32) fprintf(fd, "CC ");
+ if (tmps & 64) fprintf(fd, "DLC ");
+ if (tmps & 128) fprintf(fd, "CCR ");
+ fprintf(fd, ")\n");
break;
case MOP_K_INFO_CNU:
- ucp = pkt + *index; *index = *index + 6;
- (void)fprintf(fd,"Console User : ");
+ ucp = pkt + *index;
+ *index = *index + 6;
+ fprintf(fd, "Console User : ");
mopPrintHWA(fd, ucp);
- (void)fprintf(fd, "\n");
+ fprintf(fd, "\n");
break;
case MOP_K_INFO_RTM:
- tmps = mopGetShort(pkt,index);
- (void)fprintf(fd,"Reserv Timer : %04x (%d)\n",
- tmps,tmps);
+ tmps = mopGetShort(pkt, index);
+ fprintf(fd, "Reserv Timer : %04x (%d)\n", tmps, tmps);
break;
case MOP_K_INFO_CSZ:
- tmps = mopGetShort(pkt,index);
- (void)fprintf(fd,"Cons Cmd Size: %04x (%d)\n",
- tmps,tmps);
+ tmps = mopGetShort(pkt, index);
+ fprintf(fd, "Cons Cmd Size: %04x (%d)\n", tmps, tmps);
break;
case MOP_K_INFO_RSZ:
- tmps = mopGetShort(pkt,index);
- (void)fprintf(fd,"Cons Res Size: %04x (%d)\n",
- tmps,tmps);
+ tmps = mopGetShort(pkt, index);
+ fprintf(fd, "Cons Res Size: %04x (%d)\n", tmps, tmps);
break;
case MOP_K_INFO_HWA:
- ucp = pkt + *index; *index = *index + 6;
- (void)fprintf(fd,"Hardware Addr: ");
+ ucp = pkt + *index;
+ *index = *index + 6;
+ fprintf(fd, "Hardware Addr: ");
mopPrintHWA(fd, ucp);
- (void)fprintf(fd, "\n");
+ fprintf(fd, "\n");
break;
case MOP_K_INFO_TIME:
- ucp = pkt + *index; *index = *index + 10;
- (void)fprintf(fd,"System Time: ");
+ ucp = pkt + *index;
+ *index = *index + 10;
+ fprintf(fd, "System Time: ");
mopPrintTime(fd, ucp);
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
break;
case MOP_K_INFO_SOFD:
- device = mopGetChar(pkt,index);
- (void)fprintf(fd,"Comm Device : %02x ",device);
+ device = mopGetChar(pkt, index);
+ fprintf(fd, "Comm Device : %02x ", device);
mopPrintDevice(fd, device);
- (void)fprintf(fd, "\n");
+ fprintf(fd, "\n");
break;
case MOP_K_INFO_SFID:
- tmpc = mopGetChar(pkt,index);
- (void)fprintf(fd,"Software ID : %02x ",tmpc);
- if ((tmpc == 0)) {
- (void)fprintf(fd,"No software id");
- }
+ tmpc = mopGetChar(pkt, index);
+ fprintf(fd, "Software ID : %02x ", tmpc);
+ if ((tmpc == 0))
+ fprintf(fd, "No software id");
if ((tmpc == 254)) {
- (void)fprintf(fd,"Maintenance system");
+ fprintf(fd, "Maintenance system");
tmpc = 0;
}
if ((tmpc == 255)) {
- (void)fprintf(fd,"Standard operating system");
+ fprintf(fd, "Standard operating system");
tmpc = 0;
}
if ((tmpc > 0)) {
- (void)fprintf(fd,"'");
- for (i = 0; i < ((int) tmpc); i++) {
- (void)fprintf(fd,"%c",
- mopGetChar(pkt,index));
- }
- (void)fprintf(fd,"'");
+ fprintf(fd, "'");
+ for (i = 0; i < ((int) tmpc); i++)
+ fprintf(fd, "%c",
+ mopGetChar(pkt, index));
+ fprintf(fd, "'");
}
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
break;
case MOP_K_INFO_PRTY:
- tmpc = mopGetChar(pkt,index);
- (void)fprintf(fd,"System Proc : %02x ",tmpc);
- switch (tmpc) {
+ tmpc = mopGetChar(pkt, index);
+ fprintf(fd, "System Proc : %02x ", tmpc);
+ switch (tmpc) {
case MOP_K_PRTY_11:
- (void)fprintf(fd, "PDP-11\n");
+ fprintf(fd, "PDP-11\n");
break;
case MOP_K_PRTY_CMSV:
- (void)fprintf(fd,
- "Communication Server\n");
+ fprintf(fd, "Communication Server\n");
break;
case MOP_K_PRTY_PRO:
- (void)fprintf(fd, "Professional\n");
+ fprintf(fd, "Professional\n");
break;
case MOP_K_PRTY_SCO:
- (void)fprintf(fd, "Scorpio\n");
+ fprintf(fd, "Scorpio\n");
break;
case MOP_K_PRTY_AMB:
- (void)fprintf(fd, "Amber\n");
+ fprintf(fd, "Amber\n");
break;
case MOP_K_PRTY_BRI:
- (void)fprintf(fd, "XLII Bridge\n");
+ fprintf(fd, "XLII Bridge\n");
break;
default:
- (void)fprintf(fd, "Unknown\n");
+ fprintf(fd, "Unknown\n");
break;
};
break;
case MOP_K_INFO_DLTY:
- tmpc = mopGetChar(pkt,index);
- (void)fprintf(fd,"Data Link Typ: %02x ",tmpc);
- switch (tmpc) {
+ tmpc = mopGetChar(pkt, index);
+ fprintf(fd, "Data Link Type: %02x ", tmpc);
+ switch (tmpc) {
case MOP_K_DLTY_NI:
- (void)fprintf(fd, "Ethernet\n");
+ fprintf(fd, "Ethernet\n");
break;
case MOP_K_DLTY_DDCMP:
- (void)fprintf(fd, "DDCMP\n");
+ fprintf(fd, "DDCMP\n");
break;
case MOP_K_DLTY_LAPB:
- (void)fprintf(fd, "LAPB (X.25)\n");
+ fprintf(fd, "LAPB (X.25)\n");
break;
default:
- (void)fprintf(fd, "Unknown\n");
+ fprintf(fd, "Unknown\n");
break;
};
break;
case MOP_K_INFO_DLBSZ:
- tmps = mopGetShort(pkt,index);
- (void)fprintf(fd,"DL Buff Size : %04x (%d)\n",
- tmps,tmps);
+ tmps = mopGetShort(pkt, index);
+ fprintf(fd, "DL Buff Size : %04x (%d)\n", tmps, tmps);
break;
default:
if (((device = NMA_C_SOFD_LCS) || /* DECserver 100 */
@@ -620,81 +586,67 @@ mopPrintInfo(fd, pkt, index, moplen, mopcode, trans)
(device = NMA_C_SOFD_DS3)) && /* DECserver 300 */
((itype > 101) && (itype < 107)))
{
- switch (itype) {
+ switch (itype) {
case 102:
ucp = pkt + *index;
*index = *index + ilen;
- (void)fprintf(fd,
- "ROM Sftwr Ver: %02x '",
- ilen);
- for (i = 0; i < ilen; i++) {
- (void)fprintf(fd,"%c",ucp[i]);
- }
- (void)fprintf(fd, "'\n");
+ fprintf(fd, "ROM Sftwr Ver: %02x '",
+ ilen);
+ for (i = 0; i < ilen; i++)
+ fprintf(fd, "%c", ucp[i]);
+ fprintf(fd, "'\n");
break;
case 103:
ucp = pkt + *index;
*index = *index + ilen;
- (void)fprintf(fd,
- "Software Ver : %02x '",
- ilen);
- for (i = 0; i < ilen; i++) {
- (void)fprintf(fd, "%c",ucp[i]);
- }
- (void)fprintf(fd, "'\n");
+ fprintf(fd, "Software Ver : %02x '",
+ ilen);
+ for (i = 0; i < ilen; i++)
+ fprintf(fd, "%c", ucp[i]);
+ fprintf(fd, "'\n");
break;
case 104:
- tmps = mopGetShort(pkt,index);
- (void)fprintf(fd,
- "DECnet Addr : %d.%d (%d)\n",
- tmps / 1024,
- tmps % 1024,
- tmps);
+ tmps = mopGetShort(pkt, index);
+ fprintf(fd,
+ "DECnet Addr : %d.%d (%d)\n",
+ tmps / 1024, tmps % 1024, tmps);
break;
case 105:
ucp = pkt + *index;
*index = *index + ilen;
- (void)fprintf(fd,
- "Node Name : %02x '",
- ilen);
- for (i = 0; i < ilen; i++) {
- (void)fprintf(fd, "%c",ucp[i]);
- }
- (void)fprintf(fd, "'\n");
+ fprintf(fd, "Node Name : %02x '",
+ ilen);
+ for (i = 0; i < ilen; i++)
+ fprintf(fd, "%c", ucp[i]);
+ fprintf(fd, "'\n");
break;
case 106:
ucp = pkt + *index;
*index = *index + ilen;
- (void)fprintf(fd,
- "Node Ident : %02x '",
- ilen);
- for (i = 0; i < ilen; i++) {
- (void)fprintf(fd, "%c",ucp[i]);
- }
- (void)fprintf(fd, "'\n");
+ fprintf(fd, "Node Ident : %02x '",
+ ilen);
+ for (i = 0; i < ilen; i++)
+ fprintf(fd, "%c", ucp[i]);
+ fprintf(fd, "'\n");
break;
- };
+ }
} else {
- ucp = pkt + *index; *index = *index + ilen;
- (void)fprintf(fd, "Info Type : %04x (%d)\n",
- itype,
- itype);
- (void)fprintf(fd, "Info Data : %02x ",
- ilen);
+ ucp = pkt + *index;
+ *index = *index + ilen;
+ fprintf(fd, "Info Type : %04x (%d)\n",
+ itype, itype);
+ fprintf(fd, "Info Data : %02x ", ilen);
for (i = 0; i < ilen; i++) {
- if ((i % 16) == 0) {
- if ((i / 16) == 0) {
- } else {
- (void)fprintf(fd,
+ if ((i % 16) == 0)
+ if ((i / 16) != 0)
+ fprintf(fd,
"\n ");
- };
- };
- (void)fprintf(fd, "%02x ",ucp[i]);
+ fprintf(fd, "%02x ", ucp[i]);
}
- (void)fprintf(fd, "\n");
- };
+ fprintf(fd, "\n");
+ }
}
- itype = mopGetShort(pkt,index);
- }
+ itype = mopGetShort(pkt, index);
+ }
}
diff --git a/usr.sbin/mopd/common/put.c b/usr.sbin/mopd/common/put.c
index 7fb73507e5a..01431278008 100644
--- a/usr.sbin/mopd/common/put.c
+++ b/usr.sbin/mopd/common/put.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: put.c,v 1.5 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: put.c,v 1.6 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -25,7 +25,8 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: put.c,v 1.5 2003/12/01 00:56:51 avsm Exp $";
+static const char rcsid[] =
+ "$OpenBSD: put.c,v 1.6 2004/04/14 20:37:28 henning Exp $";
#endif
#include <stddef.h>
@@ -34,105 +35,86 @@ static const char rcsid[] = "$OpenBSD: put.c,v 1.5 2003/12/01 00:56:51 avsm Exp
#include "common/mopdef.h"
void
-mopPutChar(pkt, index, value)
- u_char *pkt;
- int *index;
- u_char value;
+mopPutChar(u_char *pkt, int *index, u_char value)
{
pkt[*index] = value;
- *index = *index + 1;
+ (*index)++;
}
void
-mopPutShort(pkt, index, value)
- u_char *pkt;
- int *index;
- u_short value;
+mopPutShort(u_char *pkt, int *index, u_short value)
{
- int i;
+ int i;
+
for (i = 0; i < 2; i++) {
- pkt[*index+i] = value % 256;
- value = value / 256;
+ pkt[*index + i] = value % 256;
+ value /= 256;
}
- *index = *index + 2;
+ *index += 2;
}
void
-mopPutLong(pkt, index, value)
- u_char *pkt;
- int *index;
- u_long value;
+mopPutLong(u_char *pkt, int *index, u_long value)
{
- int i;
+ int i;
+
for (i = 0; i < 4; i++) {
- pkt[*index+i] = value % 256;
- value = value / 256;
+ pkt[*index + i] = value % 256;
+ value /= 256;
}
- *index = *index + 4;
+ *index += 4;
}
void
-mopPutMulti(pkt, index, value, size)
- u_char *pkt,*value;
- int *index,size;
+mopPutMulti(u_char *pkt, int *index, u_char *value, int size)
{
int i;
- for (i = 0; i < size; i++) {
- pkt[*index+i] = value[i];
- }
- *index = *index + size;
+ for (i = 0; i < size; i++)
+ pkt[*index + i] = value[i];
+ *index += size;
}
void
-mopPutTime(pkt, index, value)
- u_char *pkt;
- int *index;
- time_t value;
+mopPutTime(u_char *pkt, int *index, time_t value)
{
- time_t tnow;
- struct tm *timenow;
+ time_t tnow;
+ struct tm *timenow;
- if ((value == 0)) {
- tnow = time(NULL);
- } else {
- tnow = value;
- }
+ if ((value == 0))
+ tnow = time(NULL);
+ else
+ tnow = value;
timenow = localtime(&tnow);
- mopPutChar (pkt,index,10);
- mopPutChar (pkt,index,(timenow->tm_year / 100) + 19);
- mopPutChar (pkt,index,(timenow->tm_year % 100));
- mopPutChar (pkt,index,(timenow->tm_mon + 1));
- mopPutChar (pkt,index,(timenow->tm_mday));
- mopPutChar (pkt,index,(timenow->tm_hour));
- mopPutChar (pkt,index,(timenow->tm_min));
- mopPutChar (pkt,index,(timenow->tm_sec));
- mopPutChar (pkt,index,0x00);
- mopPutChar (pkt,index,0x00);
- mopPutChar (pkt,index,0x00);
+ mopPutChar(pkt, index, 10);
+ mopPutChar(pkt, index, (timenow->tm_year / 100) + 19);
+ mopPutChar(pkt, index, (timenow->tm_year % 100));
+ mopPutChar(pkt, index, (timenow->tm_mon + 1));
+ mopPutChar(pkt, index, (timenow->tm_mday));
+ mopPutChar(pkt, index, (timenow->tm_hour));
+ mopPutChar(pkt, index, (timenow->tm_min));
+ mopPutChar(pkt, index, (timenow->tm_sec));
+ mopPutChar(pkt, index, 0x00);
+ mopPutChar(pkt, index, 0x00);
+ mopPutChar(pkt, index, 0x00);
}
void
-mopPutHeader(pkt, index, dst, src, proto, trans)
- u_char *pkt;
- int *index;
- char dst[], src[];
- u_short proto;
- int trans;
+mopPutHeader(u_char *pkt, int *index, char dst[], char src[], u_short proto,
+ int trans)
{
-
mopPutMulti(pkt, index, dst, 6);
mopPutMulti(pkt, index, src, 6);
if (trans == TRANS_8023) {
mopPutShort(pkt, index, 0);
- mopPutChar (pkt, index, MOP_K_PROTO_802_DSAP);
- mopPutChar (pkt, index, MOP_K_PROTO_802_SSAP);
- mopPutChar (pkt, index, MOP_K_PROTO_802_CNTL);
- mopPutChar (pkt, index, 0x08);
- mopPutChar (pkt, index, 0x00);
- mopPutChar (pkt, index, 0x2b);
+ mopPutChar(pkt, index, MOP_K_PROTO_802_DSAP);
+ mopPutChar(pkt, index, MOP_K_PROTO_802_SSAP);
+ mopPutChar(pkt, index, MOP_K_PROTO_802_CNTL);
+ mopPutChar(pkt, index, 0x08);
+ mopPutChar(pkt, index, 0x00);
+ mopPutChar(pkt, index, 0x2b);
}
#if !defined(__FreeBSD__)
mopPutChar(pkt, index, (proto / 256));
@@ -152,14 +134,11 @@ mopPutHeader(pkt, index, dst, src, proto, trans)
}
void
-mopPutLength(pkt, trans, len)
- u_char *pkt;
- int trans;
- u_short len;
+mopPutLength(u_char *pkt, int trans, u_short len)
{
int index = 0;
-
- switch(trans) {
+
+ switch (trans) {
case TRANS_ETHER:
index = 14;
mopPutChar(pkt, &index, ((len - 16) % 256));
diff --git a/usr.sbin/mopd/common/rc.c b/usr.sbin/mopd/common/rc.c
index 9a67411c0bd..3c412741961 100644
--- a/usr.sbin/mopd/common/rc.c
+++ b/usr.sbin/mopd/common/rc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rc.c,v 1.4 2003/12/01 00:56:51 avsm Exp $ */
+/* $OpenBSD: rc.c,v 1.5 2004/04/14 20:37:28 henning Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -25,7 +25,8 @@
*/
#ifndef LINT
-static const char rcsid[] = "$OpenBSD: rc.c,v 1.4 2003/12/01 00:56:51 avsm Exp $";
+static const char rcsid[] =
+ "$OpenBSD: rc.c,v 1.5 2004/04/14 20:37:28 henning Exp $";
#endif
#include "os.h"
@@ -34,15 +35,12 @@ static const char rcsid[] = "$OpenBSD: rc.c,v 1.4 2003/12/01 00:56:51 avsm Exp $
#include "common/mopdef.h"
void
-mopDumpRC(fd, pkt, trans)
- FILE *fd;
- u_char *pkt;
- int trans;
+mopDumpRC(FILE *fd, u_char *pkt, int trans)
{
- int i,index = 0;
+ int i, index = 0;
long tmpl;
- u_char tmpc,code,control;
- u_short len,tmps,moplen;
+ u_char tmpc, code, control;
+ u_short len, tmps, moplen;
len = mopGetLength(pkt, trans);
@@ -55,256 +53,248 @@ mopDumpRC(fd, pkt, trans)
index = 16;
moplen = len;
}
- code = mopGetChar(pkt,&index);
-
+ code = mopGetChar(pkt, &index);
+
switch (code) {
case MOP_K_CODE_RID:
-
- tmpc = mopGetChar(pkt,&index);
- (void)fprintf(fd,"Reserved : %02x\n",tmpc);
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Receipt Nbr : %04x\n",tmps);
-
+
+ tmpc = mopGetChar(pkt, &index);
+ fprintf(fd, "Reserved : %02x\n", tmpc);
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Receipt Nbr : %04x\n", tmps);
+
break;
case MOP_K_CODE_BOT:
-
+
if ((moplen == 5)) {
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Verification : %04x\n",tmps);
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Verification : %04x\n", tmps);
} else {
-
- tmpl = mopGetLong(pkt,&index);
- (void)fprintf(fd,"Verification : %08lx\n",tmpl);
-
- tmpc = mopGetChar(pkt,&index); /* Processor */
- (void)fprintf(fd,"Processor : %02x ",tmpc);
- mopPrintBPTY(fd, tmpc); (void)fprintf(fd, "\n");
-
- control = mopGetChar(pkt,&index); /* Control */
- (void)fprintf(fd,"Control : %02x ",control);
- if ((control & (1>>MOP_K_BOT_CNTL_SERVER))) {
- (void)fprintf(fd,
- "Bootserver Requesting system ");
- } else {
- (void)fprintf(fd,
- "Bootserver System default ");
- }
- if ((control & (1>>MOP_K_BOT_CNTL_DEVICE))) {
- (void)fprintf(fd,
- "Bootdevice Specified device");
- } else {
- (void)fprintf(fd,
- "Bootdevice System default");
- }
- (void)fprintf(fd,"\n");
-
+
+ tmpl = mopGetLong(pkt, &index);
+ fprintf(fd, "Verification : %08lx\n", tmpl);
+
+ tmpc = mopGetChar(pkt, &index); /* Processor */
+ fprintf(fd, "Processor : %02x ", tmpc);
+ mopPrintBPTY(fd, tmpc); fprintf(fd, "\n");
+
+ control = mopGetChar(pkt, &index); /* Control */
+ fprintf(fd, "Control : %02x ", control);
+ if ((control & (1>>MOP_K_BOT_CNTL_SERVER)))
+ fprintf(fd, "Bootserver Requesting system ");
+ else
+ fprintf(fd, "Bootserver System default ");
+ if ((control & (1>>MOP_K_BOT_CNTL_DEVICE)))
+ fprintf(fd, "Bootdevice Specified device");
+ else
+ fprintf(fd, "Bootdevice System default");
+ fprintf(fd, "\n");
+
if ((control & (1>>MOP_K_BOT_CNTL_DEVICE))) {
- tmpc = mopGetChar(pkt,&index);/* Device ID */
- (void)fprintf(fd,
- "Device ID : %02x '",tmpc);
- for (i = 0; i < ((int) tmpc); i++) {
- (void)fprintf(fd,"%c",
- mopGetChar(pkt,&index));
- }
- (void)fprintf(fd,"'\n");
- }
-
- tmpc = mopGetChar(pkt,&index); /* Software ID */
- (void)fprintf(fd,"Software ID : %02x ",tmpc);
- if ((tmpc == 0)) {
- (void)fprintf(fd,"No software id");
+ tmpc = mopGetChar(pkt, &index);/* Device ID */
+ fprintf(fd, "Device ID : %02x '", tmpc);
+ for (i = 0; i < ((int) tmpc); i++)
+ fprintf(fd, "%c",
+ mopGetChar(pkt, &index));
+ fprintf(fd, "'\n");
}
+
+ tmpc = mopGetChar(pkt, &index); /* Software ID */
+ fprintf(fd, "Software ID : %02x ", tmpc);
+ if ((tmpc == 0))
+ fprintf(fd, "No software id");
if ((tmpc == 254)) {
- (void)fprintf(fd,"Maintenance system");
+ fprintf(fd, "Maintenance system");
tmpc = 0;
}
if ((tmpc == 255)) {
- (void)fprintf(fd,"Standard operating system");
+ fprintf(fd, "Standard operating system");
tmpc = 0;
}
if ((tmpc > 0)) {
- (void)fprintf(fd,"'");
- for (i = 0; i < ((int) tmpc); i++) {
- (void)fprintf(fd,"%c",
- mopGetChar(pkt,&index));
- }
- (void)fprintf(fd,"'");
+ fprintf(fd, "'");
+ for (i = 0; i < ((int) tmpc); i++)
+ fprintf(fd, "%c",
+ mopGetChar(pkt, &index));
+ fprintf(fd, "'");
}
- (void)fprintf(fd,"'\n");
-
+ fprintf(fd, "'\n");
+
}
break;
case MOP_K_CODE_SID:
-
- tmpc = mopGetChar(pkt,&index); /* Reserved */
- (void)fprintf(fd, "Reserved : %02x\n",tmpc);
-
- tmps = mopGetShort(pkt,&index); /* Receipt # */
- (void)fprintf(fd, "Receipt Nbr : %04x\n",tmpc);
-
+
+ tmpc = mopGetChar(pkt, &index); /* Reserved */
+ fprintf(fd, "Reserved : %02x\n", tmpc);
+
+ tmps = mopGetShort(pkt, &index); /* Receipt # */
+ fprintf(fd, "Receipt Nbr : %04x\n", tmpc);
+
mopPrintInfo(fd, pkt, &index, moplen, code, trans);
-
+
break;
case MOP_K_CODE_RQC:
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Receipt Nbr : %04x\n",tmps);
-
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Receipt Nbr : %04x\n", tmps);
+
break;
case MOP_K_CODE_CNT:
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Receipt Nbr : %04x %d\n",tmps,tmps);
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Last Zeroed : %04x %d\n",tmps,tmps);
-
- tmpl = mopGetLong(pkt,&index);
- (void)fprintf(fd,"Bytes rec : %08lx %ld\n",tmpl,tmpl);
-
- tmpl = mopGetLong(pkt,&index);
- (void)fprintf(fd,"Bytes snd : %08lx %ld\n",tmpl,tmpl);
-
- tmpl = mopGetLong(pkt,&index);
- (void)fprintf(fd,"Frames rec : %08lx %ld\n",tmpl,tmpl);
-
- tmpl = mopGetLong(pkt,&index);
- (void)fprintf(fd,"Frames snd : %08lx %ld\n",tmpl,tmpl);
-
- tmpl = mopGetLong(pkt,&index);
- (void)fprintf(fd,"Mcst Bytes re: %08lx %ld\n",tmpl,tmpl);
-
- tmpl = mopGetLong(pkt,&index);
- (void)fprintf(fd,"Mcst Frame re: %08lx %ld\n",tmpl,tmpl);
-
- tmpl = mopGetLong(pkt,&index);
- (void)fprintf(fd,"Frame snd,def: %08lx %ld\n",tmpl,tmpl);
-
- tmpl = mopGetLong(pkt,&index);
- (void)fprintf(fd,"Frame snd,col: %08lx %ld\n",tmpl,tmpl);
-
- tmpl = mopGetLong(pkt,&index);
- (void)fprintf(fd,"Frame snd,mcl: %08lx %ld\n",tmpl,tmpl);
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Snd failure : %04x %d\n",tmps,tmps);
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Snd fail reas: %04x ",tmps);
- if ((tmps & 1)) (void)fprintf(fd,"Excess col ");
- if ((tmps & 2)) (void)fprintf(fd,"Carrier chk fail ");
- if ((tmps & 4)) (void)fprintf(fd,"Short circ ");
- if ((tmps & 8)) (void)fprintf(fd,"Open circ ");
- if ((tmps & 16)) (void)fprintf(fd,"Frm to long ");
- if ((tmps & 32)) (void)fprintf(fd,"Rem fail to defer ");
- (void)fprintf(fd,"\n");
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Rec failure : %04x %d\n",tmps,tmps);
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Rec fail reas: %04x ",tmps);
- if ((tmps & 1)) (void)fprintf(fd,"Block chk err ");
- if ((tmps & 2)) (void)fprintf(fd,"Framing err ");
- if ((tmps & 4)) (void)fprintf(fd,"Frm to long ");
- (void)fprintf(fd,"\n");
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Unrec frm dst: %04x %d\n",tmps,tmps);
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Data overrun : %04x %d\n",tmps,tmps);
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Sys Buf Unava: %04x %d\n",tmps,tmps);
-
- tmps = mopGetShort(pkt,&index);
- (void)fprintf(fd,"Usr Buf Unava: %04x %d\n",tmps,tmps);
-
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Receipt Nbr : %04x %d\n", tmps, tmps);
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Last Zeroed : %04x %d\n", tmps, tmps);
+
+ tmpl = mopGetLong(pkt, &index);
+ fprintf(fd, "Bytes rec : %08lx %ld\n", tmpl, tmpl);
+
+ tmpl = mopGetLong(pkt, &index);
+ fprintf(fd, "Bytes snd : %08lx %ld\n", tmpl, tmpl);
+
+ tmpl = mopGetLong(pkt, &index);
+ fprintf(fd, "Frames rec : %08lx %ld\n", tmpl, tmpl);
+
+ tmpl = mopGetLong(pkt, &index);
+ fprintf(fd, "Frames snd : %08lx %ld\n", tmpl, tmpl);
+
+ tmpl = mopGetLong(pkt, &index);
+ fprintf(fd, "Mcst Bytes re: %08lx %ld\n", tmpl, tmpl);
+
+ tmpl = mopGetLong(pkt, &index);
+ fprintf(fd, "Mcst Frame re: %08lx %ld\n", tmpl, tmpl);
+
+ tmpl = mopGetLong(pkt, &index);
+ fprintf(fd, "Frame snd, def: %08lx %ld\n", tmpl, tmpl);
+
+ tmpl = mopGetLong(pkt, &index);
+ fprintf(fd, "Frame snd, col: %08lx %ld\n", tmpl, tmpl);
+
+ tmpl = mopGetLong(pkt, &index);
+ fprintf(fd, "Frame snd, mcl: %08lx %ld\n", tmpl, tmpl);
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Snd failure : %04x %d\n", tmps, tmps);
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Snd fail reas: %04x ", tmps);
+ if (tmps & 1)
+ fprintf(fd, "Excess col ");
+ if (tmps & 2)
+ fprintf(fd, "Carrier chk fail ");
+ if (tmps & 4)
+ fprintf(fd, "Short circ ");
+ if (tmps & 8)
+ fprintf(fd, "Open circ ");
+ if (tmps & 16)
+ fprintf(fd, "Frm to long ");
+ if (tmps & 32)
+ fprintf(fd, "Rem fail to defer ");
+ fprintf(fd, "\n");
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Rec failure : %04x %d\n", tmps, tmps);
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Rec fail reas: %04x ", tmps);
+ if (tmps & 1)
+ fprintf(fd, "Block chk err ");
+ if (tmps & 2)
+ fprintf(fd, "Framing err ");
+ if (tmps & 4)
+ fprintf(fd, "Frm to long ");
+ fprintf(fd, "\n");
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Unrec frm dst: %04x %d\n", tmps, tmps);
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Data overrun : %04x %d\n", tmps, tmps);
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Sys Buf Unava: %04x %d\n", tmps, tmps);
+
+ tmps = mopGetShort(pkt, &index);
+ fprintf(fd, "Usr Buf Unava: %04x %d\n", tmps, tmps);
+
break;
case MOP_K_CODE_RVC:
-
- tmpl = mopGetLong(pkt,&index);
- (void)fprintf(fd,"Verification : %08lx\n",tmpl);
-
+
+ tmpl = mopGetLong(pkt, &index);
+ fprintf(fd, "Verification : %08lx\n", tmpl);
+
break;
case MOP_K_CODE_RLC:
/* Empty message */
-
+
break;
case MOP_K_CODE_CCP:
-
- tmpc = mopGetChar(pkt,&index);
- (void)fprintf(fd,
- "Control Flags: %02x Message %d ",tmpc,tmpc & 1);
- if ((tmpc & 2))
- (void)fprintf(fd,"Break");
- (void)fprintf(fd,"\n");
-
+ tmpc = mopGetChar(pkt, &index);
+ fprintf(fd, "Control Flags: %02x Message %d ", tmpc, tmpc & 1);
+ if (tmpc & 2)
+ fprintf(fd, "Break");
+ fprintf(fd, "\n");
+
if (moplen > 2) {
#ifndef SHORT_PRINT
for (i = 0; i < (moplen - 2); i++) {
- if ((i % 16) == 0) {
- if ((i / 16) == 0) {
- (void)fprintf(fd,
- "Image Data : %04x ",
- moplen-2);
- } else {
- (void)fprintf(fd,
- " ");
- }
+ if ((i % 16) == 0) {
+ if ((i / 16) == 0)
+ fprintf(fd,
+ "Image Data : %04x ",
+ moplen-2);
+ else
+ fprintf(fd,
+ " ");
}
- (void)fprintf(fd,"%02x ",
- mopGetChar(pkt,&index));
+ fprintf(fd, "%02x ", mopGetChar(pkt, &index));
if ((i % 16) == 15)
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
}
if ((i % 16) != 15)
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
#else
index = index + moplen - 2;
#endif
}
-
+
break;
case MOP_K_CODE_CRA:
-
- tmpc = mopGetChar(pkt,&index);
- (void)fprintf(fd,
- "Control Flags: %02x Message %d ",tmpc,tmpc & 1);
- if ((tmpc & 2))
- (void)fprintf(fd,"Cmd Data Lost ");
- if ((tmpc & 4))
- (void)fprintf(fd,"Resp Data Lost ");
- (void)fprintf(fd,"\n");
-
+
+ tmpc = mopGetChar(pkt, &index);
+ fprintf(fd, "Control Flags: %02x Message %d ", tmpc, tmpc & 1);
+ if (tmpc & 2)
+ fprintf(fd, "Cmd Data Lost ");
+ if (tmpc & 4)
+ fprintf(fd, "Resp Data Lost ");
+ fprintf(fd, "\n");
+
if (moplen > 2) {
#ifndef SHORT_PRINT
for (i = 0; i < (moplen - 2); i++) {
if ((i % 16) == 0) {
- if ((i / 16) == 0) {
- (void)fprintf(fd,
- "Image Data : %04x ",
- moplen-2);
- } else {
- (void)fprintf(fd,
- " ");
- }
+ if ((i / 16) == 0)
+ fprintf(fd,
+ "Image Data : %04x ",
+ moplen-2);
+ else
+ fprintf(fd,
+ " ");
}
- (void)fprintf(fd,"%02x ",
- mopGetChar(pkt,&index));
+ fprintf(fd, "%02x ", mopGetChar(pkt, &index));
if ((i % 16) == 15)
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
}
if ((i % 16) != 15)
- (void)fprintf(fd,"\n");
+ fprintf(fd, "\n");
#else
index = index + moplen - 2;
#endif
}
-
+
break;
default:
break;