Permalink
Browse files

Import of Mats O Jansson's MOP boot program for DEC machines.

  • Loading branch information...
1 parent a2bca40 commit f894dea1335d45ea8221818e7b89598974d50435 cjs committed Mar 16, 1997
Showing with 6,875 additions and 0 deletions.
  1. +5 −0 usr.sbin/mopd/Makefile
  2. +4 −0 usr.sbin/mopd/Makefile.inc
  3. +1 −0 usr.sbin/mopd/common/VERSION
  4. +41 −0 usr.sbin/mopd/common/cmp.c
  5. +44 −0 usr.sbin/mopd/common/cmp.h
  6. +92 −0 usr.sbin/mopd/common/common.h
  7. +331 −0 usr.sbin/mopd/common/device.c
  8. +52 −0 usr.sbin/mopd/common/device.h
  9. +315 −0 usr.sbin/mopd/common/dl.c
  10. +44 −0 usr.sbin/mopd/common/dl.h
  11. +843 −0 usr.sbin/mopd/common/file.c
  12. +67 −0 usr.sbin/mopd/common/file.h
  13. +148 −0 usr.sbin/mopd/common/get.c
  14. +58 −0 usr.sbin/mopd/common/get.h
  15. +179 −0 usr.sbin/mopd/common/loop-bsd.c
  16. +49 −0 usr.sbin/mopd/common/mopdef.c
  17. +196 −0 usr.sbin/mopd/common/mopdef.h
  18. +224 −0 usr.sbin/mopd/common/nma.c
  19. +46 −0 usr.sbin/mopd/common/nma.h
  20. +181 −0 usr.sbin/mopd/common/nmadef.h
  21. +57 −0 usr.sbin/mopd/common/os.h
  22. +279 −0 usr.sbin/mopd/common/pf.c
  23. +56 −0 usr.sbin/mopd/common/pf.h
  24. +703 −0 usr.sbin/mopd/common/print.c
  25. +62 −0 usr.sbin/mopd/common/print.h
  26. +186 −0 usr.sbin/mopd/common/put.c
  27. +56 −0 usr.sbin/mopd/common/put.h
  28. +316 −0 usr.sbin/mopd/common/rc.c
  29. +44 −0 usr.sbin/mopd/common/rc.h
  30. +10 −0 usr.sbin/mopd/mopa.out/Makefile
  31. +59 −0 usr.sbin/mopd/mopa.out/mopa.out.1
  32. +154 −0 usr.sbin/mopd/mopa.out/mopa.out.c
  33. +18 −0 usr.sbin/mopd/mopchk/Makefile
  34. +65 −0 usr.sbin/mopd/mopchk/mopchk.1
  35. +177 −0 usr.sbin/mopd/mopchk/mopchk.c
  36. +20 −0 usr.sbin/mopd/mopd/Makefile
  37. +1 −0 usr.sbin/mopd/mopd/TODO
  38. +113 −0 usr.sbin/mopd/mopd/mopd.8
  39. +241 −0 usr.sbin/mopd/mopd/mopd.c
  40. +637 −0 usr.sbin/mopd/mopd/process.c
  41. +50 −0 usr.sbin/mopd/mopd/process.h
  42. +17 −0 usr.sbin/mopd/mopprobe/Makefile
  43. +70 −0 usr.sbin/mopd/mopprobe/mopprobe.1
  44. +292 −0 usr.sbin/mopd/mopprobe/mopprobe.c
  45. +20 −0 usr.sbin/mopd/moptrace/Makefile
  46. +83 −0 usr.sbin/mopd/moptrace/moptrace.1
  47. +169 −0 usr.sbin/mopd/moptrace/moptrace.c
View
5 usr.sbin/mopd/Makefile
@@ -0,0 +1,5 @@
+# $Id: Makefile,v 1.1.1.1 1997/03/16 22:23:34 cjs Exp $
+
+SUBDIR= mopd mopprobe moptrace mopchk mopa.out
+
+.include <bsd.subdir.mk>
View
4 usr.sbin/mopd/Makefile.inc
@@ -0,0 +1,4 @@
+# from: @(#)Makefile.inc 5.1 (Berkeley) 5/11/90
+# $Id: Makefile.inc,v 1.1.1.1 1997/03/16 22:23:35 cjs Exp $
+
+BINDIR?= /usr/sbin
View
1 usr.sbin/mopd/common/VERSION
@@ -0,0 +1 @@
+2.5.3
View
41 usr.sbin/mopd/common/cmp.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LINT
+static char rcsid[] = "$Id: cmp.c,v 1.1.1.1 1997/03/16 22:23:35 cjs Exp $";
+#endif
+
+#include "os.h"
+
+int
+mopCmpEAddr(addr1, addr2)
+ register u_char *addr1, *addr2;
+{
+ return(bcmp((char *)addr1, (char *)addr2, 6));
+}
View
44 usr.sbin/mopd/common/cmp.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: cmp.h,v 1.1.1.1 1997/03/16 22:23:35 cjs Exp $
+ *
+ */
+
+#ifndef _CMP_H_
+#define _CMP_H_
+
+#ifdef NO__P
+int mopCmpEAddr (/* u_char *,u_char * */);
+#else
+__BEGIN_DECLS
+int mopCmpEAddr __P((u_char *,u_char *));
+__END_DECLS
+#endif
+
+#endif _CMP_H_
View
92 usr.sbin/mopd/common/common.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: common.h,v 1.1.1.1 1997/03/16 22:23:35 cjs 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 */
+
+#ifndef MOP_FILE_PATH
+#define MOP_FILE_PATH "/tftpboot/mop"
+#endif
+
+#define DEBUG_ONELINE 1
+#define DEBUG_HEADER 2
+#define DEBUG_INFO 3
+
+/*
+ * structure per interface
+ *
+ */
+
+struct if_info {
+ int fd; /* File Descriptor */
+ int trans; /* Transport type Ethernet/802.3 */
+ u_char eaddr[6]; /* Ethernet addr of this interface */
+ char if_name[IFNAME_SIZE]; /* Interface Name */
+ int (*iopen)(); /* Interface Open Routine */
+ int (*write)(); /* Interface Write Routine */
+ void (*read)(); /* Interface Read Routine */
+ 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
+
+struct dllist {
+ u_char status; /* Status byte */
+ struct if_info *ii; /* interface pointer */
+ u_char eaddr[6]; /* targets ethernet addres */
+ int ldfd; /* filedescriptor for loadfile */
+ u_short dl_bsz; /* Data Link Buffer Size */
+ int timeout; /* Timeout counter */
+ u_char count; /* Packet Counter */
+ u_long loadaddr; /* Load Address */
+ u_long xferaddr; /* Transfer Address */
+ u_long nloadaddr; /* Next Load Address */
+ long lseek; /* Seek before last read */
+ int aout; /* Is it an a.out file */
+ u_long a_text; /* Size of text segment */
+ u_long a_text_fill; /* Size of text segment fill */
+ u_long a_data; /* Size of data segment */
+ u_long a_data_fill; /* Size of data segment fill */
+ u_long a_bss; /* Size of bss segment */
+ u_long a_bss_fill; /* Size of bss segment fill */
+ long a_lseek; /* Keep track of pos in newfile */
+};
+
+#endif _COMMON_H_
View
331 usr.sbin/mopd/common/device.c
@@ -0,0 +1,331 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LINT
+static char rcsid[] = "$Id: device.c,v 1.1.1.1 1997/03/16 22:23:35 cjs Exp $";
+#endif
+
+#include "os.h"
+#include "common/common.h"
+#include "common/mopdef.h"
+
+struct if_info *iflist; /* Interface List */
+
+void mopReadDL();
+void mopReadRC();
+#ifdef NO__P
+int mopOpenDL(/* struct if_info *, int */);
+int mopOpenRC(/* struct if_info *, int */);
+#else
+int mopOpenDL(struct if_info *, int);
+int mopOpenRC(struct if_info *, int);
+#endif
+int pfTrans();
+int pfInit();
+int pfWrite();
+
+#ifdef DEV_NEW_CONF
+/*
+ * Return ethernet adress for interface
+ */
+
+void
+deviceEthAddr(ifname, eaddr)
+ char *ifname;
+ u_char *eaddr;
+{
+ char inbuf[8192];
+ struct ifconf ifc;
+ struct ifreq *ifr;
+ struct sockaddr_dl *sdl;
+ int fd;
+ int i, len;
+
+ /* We cannot use SIOCGIFADDR on the BPF descriptor.
+ We must instead get all the interfaces with SIOCGIFCONF
+ and find the right one. */
+
+ /* Use datagram socket to get Ethernet address. */
+ if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ syslog(LOG_ERR, "deviceEthAddr: socket: %m");
+ exit(1);
+ }
+
+ ifc.ifc_len = sizeof(inbuf);
+ ifc.ifc_buf = inbuf;
+ if (ioctl(fd, SIOCGIFCONF, (caddr_t)&ifc) < 0 ||
+ ifc.ifc_len < sizeof(struct ifreq)) {
+ syslog(LOG_ERR, "deviceEthAddr: SIOGIFCONF: %m");
+ exit(1);
+ }
+ ifr = ifc.ifc_req;
+ for (i = 0; i < ifc.ifc_len;
+ i += len, ifr = (struct ifreq *)((caddr_t)ifr + len)) {
+ len = sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len;
+ sdl = (struct sockaddr_dl *)&ifr->ifr_addr;
+ if (sdl->sdl_family != AF_LINK || sdl->sdl_type != IFT_ETHER ||
+ sdl->sdl_alen != 6)
+ continue;
+ if (!strncmp(ifr->ifr_name, ifname, sizeof(ifr->ifr_name))) {
+ bcopy((caddr_t)LLADDR(sdl), (caddr_t)eaddr, 6);
+ return;
+ }
+ }
+
+ syslog(LOG_ERR, "deviceEthAddr: Never saw interface `%s'!", ifname);
+ exit(1);
+}
+#endif /* DEV_NEW_CONF */
+
+void
+deviceOpen(ifname, proto, trans)
+ char *ifname;
+ u_short proto;
+ int trans;
+{
+ struct if_info *p, tmp;
+
+ strcpy(tmp.if_name,ifname);
+ tmp.iopen = pfInit;
+
+ switch (proto) {
+ case MOP_K_PROTO_RC:
+ tmp.read = mopReadRC;
+ tmp.fd = mopOpenRC(&tmp, trans);
+ break;
+ case MOP_K_PROTO_DL:
+ tmp.read = mopReadDL;
+ tmp.fd = mopOpenDL(&tmp, trans);
+ break;
+ default:
+ break;
+ }
+
+ if (tmp.fd != -1) {
+
+ p = (struct if_info *)malloc(sizeof(*p));
+ if (p == 0) {
+ syslog(LOG_ERR, "deviceOpen: malloc: %m");
+ exit(1);
+ }
+
+ p->next = iflist;
+ iflist = p;
+
+ strcpy(p->if_name,tmp.if_name);
+ p->iopen = tmp.iopen;
+ p->write = pfWrite;
+ p->read = tmp.read;
+ bzero((char *)p->eaddr,sizeof(p->eaddr));
+ p->fd = tmp.fd;
+
+#ifdef DEV_NEW_CONF
+ 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];
+#endif /* DEV_NEW_CONF */
+
+ }
+}
+
+void
+deviceInitOne(ifname)
+ char *ifname;
+{
+ char interface[IFNAME_SIZE];
+ struct if_info *p;
+ int trans;
+#ifdef _AIX
+ char dev[IFNAME_SIZE];
+ int unit,j;
+
+ unit = 0;
+ for (j = 0; j < strlen(ifname); j++) {
+ if (isalpha(ifname[j])) {
+ dev[j] = ifname[j];
+ } else {
+ if (isdigit(ifname[j])) {
+ unit = unit*10 + ifname[j] - '0';
+ dev[j] = '\0';
+ }
+ }
+ }
+
+ if ((strlen(dev) == 2) &&
+ (dev[0] == 'e') &&
+ ((dev[1] == 'n') || (dev[1] == 't'))) {
+ sprintf(interface,"ent%d\0",unit);
+ } else {
+ sprintf(interface,"%s%d\0",dev,unit);
+ }
+#else
+ sprintf(interface,"%s",ifname);
+#endif /* _AIX */
+
+ /* Ok, init it just once */
+
+ p = iflist;
+ 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);
+ break;
+ case 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);
+ break;
+ 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);
+ break;
+ case 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);
+ break;
+ case TRANS_ETHER+TRANS_8023+TRANS_AND:
+ deviceOpen(interface,MOP_K_PROTO_DL,TRANS_ETHER+TRANS_8023);
+ break;
+ }
+#endif
+
+}
+
+/*
+ * Initialize all "candidate" interfaces that are in the system
+ * configuration list. A "candidate" is up, not loopback and not
+ * point to point.
+ */
+void
+deviceInitAll()
+{
+#ifdef DEV_NEW_CONF
+ char inbuf[8192];
+ struct ifconf ifc;
+ struct ifreq *ifr;
+ struct sockaddr_dl *sdl;
+ int fd;
+ int i, len;
+
+ if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ syslog(LOG_ERR, "deviceInitAll: socket: %m");
+ exit(1);
+ }
+
+ ifc.ifc_len = sizeof(inbuf);
+ ifc.ifc_buf = inbuf;
+ if (ioctl(fd, SIOCGIFCONF, (caddr_t)&ifc) < 0 ||
+ ifc.ifc_len < sizeof(struct ifreq)) {
+ syslog(LOG_ERR, "deviceInitAll: SIOCGIFCONF: %m");
+ exit(1);
+ }
+ ifr = ifc.ifc_req;
+ for (i = 0; i < ifc.ifc_len;
+ i += len, ifr = (struct ifreq *)((caddr_t)ifr + len)) {
+ len = sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len;
+ sdl = (struct sockaddr_dl *)&ifr->ifr_addr;
+ if (sdl->sdl_family != AF_LINK || sdl->sdl_type != IFT_ETHER ||
+ sdl->sdl_alen != 6)
+ continue;
+ if (ioctl(fd, SIOCGIFFLAGS, (caddr_t)ifr) < 0) {
+ syslog(LOG_ERR, "deviceInitAll: SIOCGIFFLAGS: %m");
+ continue;
+ }
+ if ((ifr->ifr_flags &
+ (IFF_UP | IFF_LOOPBACK | IFF_POINTOPOINT)) != IFF_UP)
+ continue;
+ deviceInitOne(ifr->ifr_name);
+ }
+ (void) close(fd);
+#else
+ int fd;
+ int n;
+ struct ifreq ibuf[8], *ifrp;
+ struct ifconf ifc;
+
+ if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ syslog(LOG_ERR, "deviceInitAll: old socket: %m");
+ exit(1);
+ }
+ ifc.ifc_len = sizeof ibuf;
+ ifc.ifc_buf = (caddr_t)ibuf;
+ if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0 ||
+ ifc.ifc_len < sizeof(struct ifreq)) {
+ syslog(LOG_ERR, "deviceInitAll: old SIOCGIFCONF: %m");
+ exit(1);
+ }
+ ifrp = ibuf;
+ n = ifc.ifc_len / sizeof(*ifrp);
+ for (; --n >= 0; ++ifrp) {
+ if (ioctl(fd, SIOCGIFFLAGS, (char *)ifrp) < 0) {
+ continue;
+ }
+ if (/*(ifrp->ifr_flags & IFF_UP) == 0 ||*/
+ ifrp->ifr_flags & IFF_LOOPBACK ||
+ ifrp->ifr_flags & IFF_POINTOPOINT)
+ continue;
+ deviceInitOne(ifrp->ifr_name);
+ }
+
+ (void) close(fd);
+#endif /* DEV_NEW_CONF */
+}
View
52 usr.sbin/mopd/common/device.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: device.h,v 1.1.1.1 1997/03/16 22:23:36 cjs Exp $
+ *
+ */
+
+#ifndef _DEVICE_H_
+#define _DEVICE_H_
+
+#ifdef NO__P
+#ifdef DEV_NEW_CONF
+void deviceEthAddr (/* char *,u_char * */);
+#endif
+void deviceInitOne (/* char * */);
+void deviceInitAll (/* void */);
+#else
+__BEGIN_DECLS
+#ifdef DEV_NEW_CONF
+void deviceEthAddr __P((char *,u_char *));
+#endif
+void deviceInitOne __P((char *));
+void deviceInitAll __P((void));
+__END_DECLS
+#endif
+
+#endif _DEVICE_H_
View
315 usr.sbin/mopd/common/dl.c
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LINT
+static char rcsid[] = "$Id: dl.c,v 1.1.1.1 1997/03/16 22:23:36 cjs Exp $";
+#endif
+
+#include "os.h"
+#include "common/get.h"
+#include "common/print.h"
+#include "common/mopdef.h"
+
+void
+mopDumpDL(fd, pkt, trans)
+ FILE *fd;
+ u_char *pkt;
+ int trans;
+{
+ int i,index = 0;
+ long tmpl;
+ u_char tmpc,c,program[17],code,*ucp;
+ u_short len,tmps,moplen;
+
+ len = mopGetLength(pkt, trans);
+
+ switch (trans) {
+ case TRANS_8023:
+ index = 22;
+ moplen = len - 8;
+ break;
+ default:
+ index = 16;
+ moplen = len;
+ }
+ 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);
+
+ if (moplen > 6) {
+ tmpl = mopGetLong(pkt,&index);/* Load Address */
+ (void)fprintf(fd,"Load Address : %08x\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,
+ " ");
+ }
+ }
+
+ (void)fprintf(fd, "%02x ",
+ mopGetChar(pkt,&index));
+ if ((i % 16) == 15)
+ (void)fprintf(fd,"\n");
+ }
+
+ if ((i % 16) != 15)
+ (void)fprintf(fd,"\n");
+#else
+ index = index + moplen - 10;
+#endif
+ }
+
+ tmpl = mopGetLong(pkt,&index); /* Load Address */
+ (void)fprintf(fd,"Xfer Address : %08x\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 : %08x\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) == 15)
+ (void)fprintf(fd,"\n");
+ }
+
+ if ((i % 16) != 15)
+ (void)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 : %08x\n",tmpl);
+
+ tmps = mopGetShort(pkt,&index); /* Count */
+ (void)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");
+
+ program[0] = 0;
+ tmpc = mopGetChar(pkt,&index); /* Software ID Len */
+ for (i = 0; i < tmpc; i++) {
+ 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");
+
+ 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");
+ }
+
+ 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 : %08x\n",tmpl);
+
+ tmpc = mopGetChar(pkt,&index); /* Bits */
+ (void)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 : %08x\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,
+ " ");
+ }
+ }
+ (void)fprintf(fd,"%02x ",
+ mopGetChar(pkt,&index));
+ if ((i % 16) == 15)
+ (void)fprintf(fd,"\n");
+ }
+ if ((i % 16) != 15)
+ (void)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 */
+ while (tmpc != MOP_K_PLTP_END) {
+ 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");
+ 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");
+ 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");
+ 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");
+ break;
+ case MOP_K_PLTP_HST: /* Host Time */
+ ucp = pkt + index; index = index + 10;
+ (void)fprintf(fd,"Host Time : ");
+ mopPrintTime(fd, ucp);
+ (void)fprintf(fd,"\n");
+ break;
+ default:
+ break;
+ }
+ tmpc = mopGetChar(pkt,&index);/* Parameter Type */
+ }
+
+ tmpl = mopGetLong(pkt,&index); /* Transfer Address */
+ (void)fprintf(fd,"Transfer Addr: %08x\n",tmpl);
+
+ break;
+ default:
+ break;
+ }
+}
+
+
View
44 usr.sbin/mopd/common/dl.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: dl.h,v 1.1.1.1 1997/03/16 22:23:36 cjs Exp $
+ *
+ */
+
+#ifndef _DL_H_
+#define _DL_H_
+
+#ifdef NO__P
+void mopDumpDL (/* FILE *, u_char *, int */);
+#else
+__BEGIN_DECLS
+void mopDumpDL __P((FILE *, u_char *, int));
+__END_DECLS
+#endif
+
+#endif _DL_H_
View
843 usr.sbin/mopd/common/file.c
@@ -0,0 +1,843 @@
+/*
+ * Copyright (c) 1995-96 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LINT
+static char rcsid[] = "$Id: file.c,v 1.1.1.1 1997/03/16 22:23:36 cjs Exp $";
+#endif
+
+#include "os.h"
+#include "common/common.h"
+#include "common/mopdef.h"
+
+#ifndef NOAOUT
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+#include <sys/exec_aout.h>
+#endif
+#if defined(__bsdi__)
+#define NOAOUT
+#endif
+#if defined(__FreeBSD__)
+#include <sys/imgact_aout.h>
+#endif
+#if !defined(MID_VAX)
+#define MID_VAX 140
+#endif
+#endif
+
+void
+mopFilePutLX(buf, index, value, cnt)
+ u_char *buf;
+ int index, cnt;
+ u_long value;
+{
+ int i;
+ for (i = 0; i < cnt; i++) {
+ buf[index+i] = value % 256;
+ value = value / 256;
+ }
+}
+
+void
+mopFilePutBX(buf, index, value, cnt)
+ u_char *buf;
+ int index, cnt;
+ u_long value;
+{
+ int i;
+ for (i = 0; i < cnt; i++) {
+ buf[index+cnt-1-i] = value % 256;
+ value = value / 256;
+ }
+}
+
+u_long
+mopFileGetLX(buf, index, cnt)
+ u_char *buf;
+ int index, cnt;
+{
+ u_long ret = 0;
+ int i;
+
+ for (i = 0; i < cnt; i++) {
+ ret = ret*256 + buf[index+cnt-1-i];
+ }
+
+ return(ret);
+}
+
+u_long
+mopFileGetBX(buf, index, cnt)
+ u_char *buf;
+ int index, cnt;
+{
+ u_long ret = 0;
+ int i;
+
+ for (i = 0; i < cnt; i++) {
+ ret = ret*256 + buf[index+i];
+ }
+
+ return(ret);
+}
+
+void
+mopFileSwapX(buf, index, cnt)
+ u_char *buf;
+ int index, cnt;
+{
+ int i;
+ u_char c;
+
+ 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;
+ }
+
+}
+
+int
+CheckMopFile(fd)
+ int fd;
+{
+ u_char header[512];
+ short image_type;
+
+ if (read(fd, header, 512) != 512)
+ return(-1);
+
+ (void)lseek(fd, (off_t) 0, SEEK_SET);
+
+ image_type = (u_short)(header[IHD_W_ALIAS+1]*256 +
+ header[IHD_W_ALIAS]);
+
+ 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 */
+ case IHD_C_ALIAS: /* Alias */
+ case IHD_C_CLI: /* Image is CLI */
+ case IHD_C_PMAX: /* PMAX system image */
+ case IHD_C_ALPHA: /* ALPHA system image */
+ break;
+ default:
+ return(-1);
+ }
+
+ return(0);
+}
+
+int
+GetMopFileInfo(fd, load, xfr)
+ int fd;
+ u_long *load, *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);
+
+ image_type = (u_short)(header[IHD_W_ALIAS+1]*256 +
+ header[IHD_W_ALIAS]);
+
+ 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;
+#ifdef INFO
+ printf("Native Image (VAX)\n");
+ printf("Header Block Count: %d\n",hbcnt);
+ printf("Image Size: %08x\n",isize);
+ printf("Load Address: %08x\n",load_addr);
+ printf("Transfer Address: %08x\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];
+#ifdef INFO
+ printf("RSX Image\n");
+ printf("Header Block Count: %d\n",hbcnt);
+ printf("Image Size: %08x\n",isize);
+ printf("Load Address: %08x\n",load_addr);
+ printf("Transfer Address: %08x\n",xfr_addr);
+#endif
+ break;
+ case IHD_C_BPA: /* BASIC plus analog */
+#ifdef INFO
+ printf("BASIC-Plus Image, not supported\n");
+#endif
+ return(-1);
+ break;
+ case IHD_C_ALIAS: /* Alias */
+#ifdef INFO
+ printf("Alias, not supported\n");
+#endif
+ return(-1);
+ break;
+ case IHD_C_CLI: /* Image is CLI */
+#ifdef INFO
+ printf("CLI, not supported\n");
+#endif
+ 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]);
+#ifdef INFO
+ printf("PMAX Image \n");
+ printf("Header Block Count: %d\n",hbcnt);
+ printf("Image Size: %08x\n",isize);
+ printf("Load Address: %08x\n",load_addr);
+ printf("Transfer Address: %08x\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 +
+ header[EIHD_L_ISDOFF]);
+ 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 +
+ header[isd+EISD_L_SECSIZE]);
+ load_addr = 0;
+ xfr_addr = 0;
+#ifdef INFO
+ printf("Alpha Image \n");
+ printf("Header Block Count: %d\n",hbcnt);
+ printf("Image Size: %08x\n",isize);
+ printf("Load Address: %08x\n",load_addr);
+ printf("Transfer Address: %08x\n",xfr_addr);
+#endif
+ break;
+ default:
+#ifdef INFO
+ printf("Unknown Image (%d)\n",image_type);
+#endif
+ return(-1);
+ }
+
+ if (load != NULL) {
+ *load = load_addr;
+ }
+
+ if (xfr != NULL) {
+ *xfr = xfr_addr;
+ }
+
+ return(0);
+}
+
+#ifndef NOAOUT
+int
+getMID(old_mid,new_mid)
+ int old_mid, new_mid;
+{
+ int mid;
+
+ mid = old_mid;
+
+ switch (new_mid) {
+ case MID_I386:
+ mid = MID_I386;
+ break;
+#ifdef MID_M68K
+ case MID_M68K:
+ mid = MID_M68K;
+ break;
+#endif
+#ifdef MID_M68K4K
+ case MID_M68K4K:
+ mid = MID_M68K4K;
+ break;
+#endif
+#ifdef MID_NS32532
+ case MID_NS32532:
+ mid = MID_NS32532;
+ break;
+#endif
+/*###323 [cc] for each function it appears in.)%%%*/
+/*###323 [cc] (Each undeclared identifier is reported only once%%%*/
+/*###323 [cc] `MID_SPARC' undeclared (first use this function)%%%*/
+ case MID_SPARC:
+ mid = MID_SPARC;
+ break;
+#ifdef MID_PMAX
+ case MID_PMAX:
+ mid = MID_PMAX;
+ break;
+#endif
+#ifdef MID_VAX
+ case MID_VAX:
+ mid = MID_VAX;
+ break;
+#endif
+#ifdef MID_ALPHA
+ case MID_ALPHA:
+ mid = MID_ALPHA;
+ break;
+#endif
+#ifdef MID_MIPS
+ case MID_MIPS:
+ mid = MID_MIPS;
+ break;
+#endif
+#ifdef MID_ARM6
+ case MID_ARM6:
+ mid = MID_ARM6;
+ break;
+#endif
+ default:
+/*###352 [cc] syntax error before `}'%%%*/
+ }
+
+ return(mid);
+}
+
+int
+getCLBYTES(mid)
+ int mid;
+{
+ int clbytes;
+
+ switch (mid) {
+#ifdef MID_VAX
+ case MID_VAX:
+ clbytes = 1024;
+ break;
+#endif
+ case MID_I386:
+#ifdef MID_M68K4K
+ case MID_M68K4K:
+#endif
+#ifdef MID_NS32532
+ case MID_NS32532:
+#endif
+ case MID_SPARC: /* It might be 8192 */
+#ifdef MID_PMAX
+ case MID_PMAX:
+#endif
+#ifdef MID_MIPS
+ case MID_MIPS:
+#endif
+#ifdef MID_ARM6
+ case MID_ARM6:
+#endif
+ clbytes = 4096;
+ break;
+#ifdef MID_M68K
+ case MID_M68K:
+#endif
+#ifdef MID_ALPHA
+ case MID_ALPHA:
+#endif
+#if defined(MID_M68K) || defined(MID_ALPHA)
+ clbytes = 8192;
+ break;
+#endif
+ default:
+ clbytes = 0;
+ }
+
+ return(clbytes);
+}
+#endif
+
+/*###406 [cc] syntax error before `int'%%%*/
+int
+CheckAOutFile(fd)
+ int fd;
+{
+#ifdef NOAOUT
+ return(-1);
+#else
+ struct exec ex, ex_swap;
+ int mid = -1;
+
+/*###416 [cc] `fd' undeclared (first use this function)%%%*/
+ if (read(fd, (char *)&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);
+
+ (void)lseek(fd, (off_t) 0, SEEK_SET);
+
+ 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
+}
+
+/*###440 [cc] syntax error before `int'%%%*/
+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;
+{
+#ifdef NOAOUT
+ return(-1);
+#else
+ struct exec ex, ex_swap;
+ int mid = -1;
+ u_long magic, clbytes, clofset;
+
+ if (read(fd, (char *)&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);
+
+ mopFileSwapX((u_char *)&ex_swap, 0, 4);
+
+ 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);
+ }
+ }
+
+ if (mid == -1) {
+ return(-1);
+ }
+
+ if (N_BADMAG (ex)) {
+ return(-1);
+ }
+
+ switch (mid) {
+ case MID_I386:
+#ifdef MID_NS32532
+ case MID_NS32532:
+#endif
+#ifdef MID_PMAX
+ case MID_PMAX:
+#endif
+#ifdef MID_VAX
+ case MID_VAX:
+#endif
+#ifdef MID_ALPHA
+ case MID_ALPHA:
+#endif
+#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);
+ break;
+#ifdef MID_M68K
+ case MID_M68K:
+#endif
+#ifdef MID_M68K4K
+ case MID_M68K4K:
+#endif
+ case MID_SPARC:
+#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);
+ break;
+ default:
+/*###525 [cc] syntax error before `}'%%%*/
+ }
+
+#ifdef INFO
+ printf("a.out image (");
+ switch (N_GETMID (ex)) {
+ case MID_I386:
+ printf("i386");
+ break;
+#ifdef MID_M68K
+ case MID_M68K:
+ printf("m68k");
+ break;
+#endif
+#ifdef MID_M68K4K
+ case MID_M68K4K:
+ printf("m68k 4k");
+ break;
+#endif
+#ifdef MID_NS32532
+ case MID_NS32532:
+ printf("pc532");
+ break;
+#endif
+ case MID_SPARC:
+ printf("sparc");
+ break;
+#ifdef MID_PMAX
+ case MID_PMAX:
+ printf("pmax");
+ break;
+#endif
+#ifdef MID_VAX
+ case MID_VAX:
+ printf("vax");
+ break;
+#endif
+#ifdef MID_ALPHA
+ case MID_ALPHA:
+ printf("alpha");
+ break;
+#endif
+#ifdef MID_MIPS
+ case MID_MIPS:
+ printf("mips");
+ break;
+#endif
+#ifdef MID_ARM6
+ case MID_ARM6:
+ printf("arm32");
+ break;
+#endif
+ default:
+ }
+ printf(") Magic: ");
+ switch (N_GETMAGIC (ex)) {
+ case OMAGIC:
+ printf("OMAGIC");
+ break;
+ case NMAGIC:
+ printf("NMAGIC");
+ break;
+ case ZMAGIC:
+ printf("ZMAGIC");
+ break;
+ case QMAGIC:
+ printf("QMAGIC");
+ break;
+ default:
+ 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);
+ clbytes = getCLBYTES(mid);
+ clofset = clbytes - 1;
+
+/*###608 [cc] `load' undeclared (first use this function)%%%*/
+ if (load != NULL) {
+ *load = 0;
+ }
+
+/*###612 [cc] `xfr' undeclared (first use this function)%%%*/
+ if (xfr != NULL) {
+ *xfr = ex.a_entry;
+ }
+
+/*###616 [cc] `a_text' undeclared (first use this function)%%%*/
+ if (a_text != NULL) {
+ *a_text = ex.a_text;
+ }
+
+/*###620 [cc] `a_text_fill' undeclared (first use this function)%%%*/
+ if (a_text_fill != NULL) {
+ if (magic == ZMAGIC || magic == NMAGIC) {
+ *a_text_fill = clbytes - (ex.a_text & clofset);
+ if (*a_text_fill == clbytes) {
+ *a_text_fill = 0;
+ }
+ } else {
+ *a_text_fill = 0;
+ }
+ }
+
+/*###631 [cc] `a_data' undeclared (first use this function)%%%*/
+ if (a_data != NULL) {
+ *a_data = ex.a_data;
+ }
+
+/*###635 [cc] `a_data_fill' undeclared (first use this function)%%%*/
+ if (a_data_fill != NULL) {
+ if (magic == ZMAGIC || magic == NMAGIC) {
+ *a_data_fill = clbytes - (ex.a_data & clofset);
+ if (*a_data_fill == clbytes) {
+ *a_data_fill = 0;
+ }
+ } else {
+ *a_data_fill = 0;
+ }
+ }
+
+/*###646 [cc] `a_bss' undeclared (first use this function)%%%*/
+ if (a_bss != NULL) {
+ *a_bss = ex.a_bss;
+ }
+
+/*###650 [cc] `a_bss_fill' undeclared (first use this function)%%%*/
+ if (a_bss_fill != NULL) {
+ if (magic == ZMAGIC || magic == NMAGIC) {
+ *a_bss_fill = clbytes - (ex.a_bss & clofset);
+ 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) {
+ *a_text_fill = 0;
+ }
+ }
+ }
+
+/*###665 [cc] `aout' undeclared (first use this function)%%%*/
+ if (aout != NULL) {
+ *aout = mid;
+ }
+
+ return(0);
+#endif NOAOUT
+}
+
+/*###673 [cc] syntax error before `int'%%%*/
+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;
+{
+ 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);
+ }
+ } else {
+ err = CheckMopFile(fd);
+
+ if (err == 0) {
+ err = GetMopFileInfo(fd, load, xfr);
+ if (err != 0) {
+ return(-1);
+ }
+ *aout = -1;
+ } else {
+ return(-1);
+ }
+ }
+
+ return(0);
+}
+
+ssize_t
+/*###711 [cc] syntax error before `mopFileRead'%%%*/
+mopFileRead(dlslot, buf)
+ struct dllist *dlslot;
+ u_char *buf;
+{
+ ssize_t len, outlen;
+ int bsz;
+ long pos, notdone, total;
+
+/*###719 [cc] `dlslot' undeclared (first use this function)%%%*/
+ if (dlslot->aout == -1) {
+/*###720 [cc] `buf' undeclared (first use this function)%%%*/
+ len = read(dlslot->ldfd,buf,dlslot->dl_bsz);
+ } else {
+ bsz = dlslot->dl_bsz;
+ pos = dlslot->a_lseek;
+ len = 0;
+
+ total = dlslot->a_text;
+
+ if (pos < total) {
+ notdone = total - pos;
+ if (notdone <= bsz) {
+/*###731 [cc] subscripted value is neither array nor pointer%%%*/
+ outlen = read(dlslot->ldfd,&buf[len],notdone);
+ } else {
+/*###733 [cc] subscripted value is neither array nor pointer%%%*/
+ outlen = read(dlslot->ldfd,&buf[len],bsz);
+ }
+ len = len + outlen;
+ pos = pos + outlen;
+ bsz = bsz - outlen;
+ }
+
+ total = total + dlslot->a_text_fill;
+
+ if ((bsz > 0) && (pos < total)) {
+ notdone = total - pos;
+ if (notdone <= bsz) {
+ outlen = notdone;
+ } else {
+ outlen = bsz;
+ }
+/*###749 [cc] subscripted value is neither array nor pointer%%%*/
+ bzero(&buf[len],outlen);
+ len = len + outlen;
+ pos = pos + outlen;
+ bsz = bsz - outlen;
+ }
+
+ total = total + dlslot->a_data;
+
+ if ((bsz > 0) && (pos < total)) {
+ notdone = total - pos;
+ if (notdone <= bsz) {
+/*###760 [cc] subscripted value is neither array nor pointer%%%*/
+ outlen = read(dlslot->ldfd,&buf[len],notdone);
+ } else {
+/*###762 [cc] subscripted value is neither array nor pointer%%%*/
+ outlen = read(dlslot->ldfd,&buf[len],bsz);
+ }
+ len = len + outlen;
+ pos = pos + outlen;
+ bsz = bsz - outlen;
+ }
+
+ total = total + dlslot->a_data_fill;
+
+ if ((bsz > 0) && (pos < total)) {
+ notdone = total - pos;
+ if (notdone <= bsz) {
+ outlen = notdone;
+ } else {
+ outlen = bsz;
+ }
+/*###778 [cc] subscripted value is neither array nor pointer%%%*/
+ 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) {
+ outlen = notdone;
+ } else {
+ outlen = bsz;
+ }
+/*###793 [cc] subscripted value is neither array nor pointer%%%*/
+ 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) {
+ outlen = notdone;
+ } else {
+ outlen = bsz;
+ }
+/*###808 [cc] subscripted value is neither array nor pointer%%%*/
+ bzero(&buf[len],outlen);
+ len = len + outlen;
+ pos = pos + outlen;
+ bsz = bsz - outlen;
+ }
+
+ dlslot->a_lseek = pos;
+
+ }
+
+ return(len);
+}
+/*###820 [cc] syntax error at end of input%%%*/
View
67 usr.sbin/mopd/common/file.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: file.h,v 1.1.1.1 1997/03/16 22:23:36 cjs Exp $
+ *
+ */
+
+#ifndef _FILE_H_
+#define _FILE_H_
+
+#ifdef NO__P
+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 */);
+int CheckMopFile (/* int */);
+int GetMopFileInfo (/* int, u_long *, u_long * */);
+int CheckAOutFile (/* int */);
+int GetAOutFileInfo(/* int, u_long *, u_long *, u_long *, u_long *,
+ u_long *, u_long *, u_long *, u_long * */);
+int GetFileInfo (/* int, u_long *, u_long *, int *, u_long *, u_long *,
+ u_long *, u_long *, u_long *, u_long * */);
+#else
+__BEGIN_DECLS
+void mopFilePutLX __P((u_char *, int, u_long, int));
+void mopFilePutBX __P((u_char *, int, u_long, int));
+u_long mopFileGetLX __P((u_char *, int, int));
+u_long mopFileGetBX __P((u_char *, int, int));
+void mopFileSwapX __P((u_char *, int, int));
+int CheckMopFile __P((int));
+int GetMopFileInfo __P((int, u_long *, u_long *));
+int CheckAOutFile __P((int));
+int GetAOutFileInfo __P((int, u_long *, u_long *, u_long *, u_long *,
+ u_long *, u_long *, u_long *, u_long *, int *));
+int GetFileInfo __P((int, u_long *, u_long *, int *,
+ u_long *, u_long *, u_long *, u_long *,
+ u_long *, u_long *));
+__END_DECLS
+#endif
+
+#endif _FILE_H_
View
148 usr.sbin/mopd/common/get.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LINT
+static char rcsid[] = "$Id: get.c,v 1.1.1.1 1997/03/16 22:23:36 cjs Exp $";
+#endif
+
+#include <sys/types.h>
+#include "common/mopdef.h"
+
+u_char
+mopGetChar(pkt, index)
+ register u_char *pkt;
+ register int *index;
+{
+ u_char ret;
+
+ ret = pkt[*index];
+ *index = *index + 1;
+ return(ret);
+}
+
+u_short
+mopGetShort(pkt, index)
+ register u_char *pkt;
+ register int *index;
+{
+ u_short ret;
+
+ ret = pkt[*index] + pkt[*index+1]*256;
+ *index = *index + 2;
+ return(ret);
+}
+
+u_long
+mopGetLong(pkt, index)
+ register u_char *pkt;
+ register int *index;
+{
+ u_long ret;
+
+ ret = pkt[*index] +
+ pkt[*index+1]*0x100 +
+ pkt[*index+2]*0x10000 +
+ pkt[*index+3]*0x1000000;
+ *index = *index + 4;
+ return(ret);
+}
+
+void
+mopGetMulti(pkt, index, dest, size)
+ register u_char *pkt,*dest;
+ register int *index,size;
+{
+ int i;
+
+ for (i = 0; i < size; i++) {
+ dest[i] = pkt[*index+i];
+ }
+ *index = *index + size;
+
+}
+
+int
+mopGetTrans(pkt, trans)
+ u_char *pkt;
+ int trans;
+{
+ u_short *ptype;
+
+ if (trans == 0) {
+ ptype = (u_short *)(pkt+12);
+ if (ntohs(*ptype) < 1600) {
+ trans = TRANS_8023;
+ } else {
+ trans = TRANS_ETHER;
+ }
+ }
+ return(trans);
+}
+
+void
+mopGetHeader(pkt, index, dst, src, proto, len, trans)
+ u_char *pkt, **dst, **src;
+ int *index, *len, trans;
+ u_short *proto;
+{
+ *dst = pkt;
+ *src = pkt + 6;
+ *index = *index + 12;
+
+ switch(trans) {
+ case TRANS_ETHER:
+ *proto = (u_short)(pkt[*index]*256 + pkt[*index+1]);
+ *index = *index + 2;
+ *len = (int)(pkt[*index+1]*256 + pkt[*index]);
+ *index = *index + 2;
+ break;
+ case TRANS_8023:
+ *len = (int)(pkt[*index]*256 + pkt[*index+1]);
+ *index = *index + 8;
+ *proto = (u_short)(pkt[*index]*256 + pkt[*index+1]);
+ *index = *index + 2;
+ break;
+ }
+}
+
+u_short
+mopGetLength(pkt, trans)
+ u_char *pkt;
+ int trans;
+{
+ switch(trans) {
+ case TRANS_ETHER:
+ return(pkt[15]*256 + pkt[14]);
+ break;
+ case TRANS_8023:
+ return(pkt[12]*256 + pkt[13]);
+ break;
+ }
+ return(0);
+}
View
58 usr.sbin/mopd/common/get.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: get.h,v 1.1.1.1 1997/03/16 22:23:36 cjs Exp $
+ *
+ */
+
+#ifndef _GET_H_
+#define _GET_H_
+
+#ifdef NO__P
+u_char mopGetChar (/* u_char *, int * */);
+u_short mopGetShort (/* u_char *, int * */);
+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 */);
+u_short mopGetLength (/* u_char *, int */);
+#else
+__BEGIN_DECLS
+u_char mopGetChar __P((u_char *,int *));
+u_short mopGetShort __P((u_char *,int *));
+u_long mopGetLong __P((u_char *,int *));
+void mopGetMulti __P((u_char *,int *,u_char *,int));
+int mopGetTrans __P((u_char *, int));
+void mopGetHeader __P((u_char *, int *, u_char **, u_char **, u_short *,
+ int *, int));
+u_short mopGetLength __P((u_char *, int));
+__END_DECLS
+#endif
+
+#endif _GET_H_
View
179 usr.sbin/mopd/common/loop-bsd.c
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LINT
+static char rcsid[] = "$Id: loop-bsd.c,v 1.1.1.1 1997/03/16 22:23:36 cjs Exp $";
+#endif
+
+#include <stdlib.h>
+#include <strings.h>
+#include <unistd.h>
+#if defined(__bsdi__) || defined(__FreeBSD__)
+#include <sys/time.h>
+#endif
+#include <net/bpf.h>
+#include <sys/ioctl.h>
+#include <sys/errno.h>
+
+#include "os.h"
+#include "common/common.h"
+#include "common/mopdef.h"
+
+int
+mopOpenRC(p, trans)
+ struct if_info *p;
+ int trans;
+{
+#ifndef NORC
+ return (*(p->iopen))(p->if_name,
+ O_RDWR,
+ MOP_K_PROTO_RC,
+ trans);
+#else
+ return -1;
+#endif
+}
+
+int
+mopOpenDL(p, trans)
+ struct if_info *p;
+ int trans;
+{
+#ifndef NODL
+ return (*(p->iopen))(p->if_name,
+ O_RDWR,
+ MOP_K_PROTO_DL,
+ trans);
+#else
+ return -1;
+#endif
+}
+
+void
+mopReadRC()
+{
+}
+
+void
+mopReadDL()
+{
+}
+
+/*
+ * The list of all interfaces that are being listened to. loop()
+ * "selects" on the descriptors in this list.
+ */
+struct if_info *iflist;
+
+void mopProcess __P((struct if_info *, u_char *));
+
+/*
+ * Loop indefinitely listening for MOP requests on the
+ * interfaces in 'iflist'.
+ */
+void
+Loop()
+{
+ 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) {
+ syslog(LOG_ERR, "BIOCGBLEN: %m");
+ exit(0);
+ }
+ }
+ buf = (u_char *) malloc((unsigned) bufsize);
+ if (buf == 0) {
+ syslog(LOG_ERR, "malloc: %m");
+ exit(0);
+ }
+ /*
+ * Find the highest numbered file descriptor for select().
+ * Initialize the set of descriptors to listen to.
+ */
+ FD_ZERO(&fds);
+ 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, (struct fd_set *) 0,
+ (struct fd_set *) 0, (struct timeval *) 0) < 0) {
+ syslog(LOG_ERR, "select: %m");
+ exit(0);
+ }
+ 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);
+ /* Don't choke when we get ptraced */
+ if (cc < 0 && errno == EINTR)
+ goto again;
+ /* Due to a SunOS bug, after 2^31 bytes, the file
+ * 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);
+ goto again;
+ }
+ syslog(LOG_ERR, "read: %m");
+ exit(0);
+ }
+ /* Loop through the packet(s) */
+#define bhp ((struct bpf_hdr *)bp)
+ bp = buf;
+ ep = bp + cc;
+ while (bp < ep) {
+ register int caplen, hdrlen;
+
+ caplen = bhp->bh_caplen;
+ hdrlen = bhp->bh_hdrlen;
+ mopProcess(ii, bp + hdrlen);
+ bp += BPF_WORDALIGN(hdrlen + caplen);
+ }
+ }
+ }
+}
View
49 usr.sbin/mopd/common/mopdef.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1995 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LINT
+static char rcsid[] = "$Id: mopdef.c,v 1.1.1.1 1997/03/16 22:23:36 cjs Exp $";
+#endif
+
+#define MOPDEF_SURPESS_EXTERN
+#include "common/mopdef.h"
+
+char dl_mcst[6] = MOP_DL_MULTICAST; /* Dump/Load Multicast */
+char rc_mcst[6] = MOP_RC_MULTICAST; /* Remote Console Multicast */
+char dl_802_proto[5] = MOP_K_PROTO_802_DL; /* MOP Dump/Load 802.2 */
+char rc_802_proto[5] = MOP_K_PROTO_802_RC; /* MOP Remote Console 802.2 */
+char lp_802_proto[5] = MOP_K_PROTO_802_LP; /* Loopback 802.2 */
+
+int
+mopdef_dummy()
+{
+ /* 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]);
+}
View
196 usr.sbin/mopd/common/mopdef.h
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * 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,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * 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
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: mopdef.h,v 1.1.1.1 1997/03/16 22:23:36 cjs Exp $
+ *
+ */
+
+#ifndef _MOPDEF_H_
+#define _MOPDEF_H_
+
+#define MOP_K_PROTO_DL 0x6001 /* MOP Load/Dump Protocol */
+#define MOP_K_PROTO_RC 0x6002 /* MOP Remote Console Protocol */
+#define MOP_K_PROTO_LP 0x9000 /* MOP Loopback Protocol */
+
+#define MOP_K_PROTO_802_DL { 0x08, 0x00, 0x2b, 0x60, 0x01 }
+#define MOP_K_PROTO_802_RC { 0x08, 0x00, 0x2b, 0x60, 0x02 }
+#define MOP_K_PROTO_802_LP { 0x08, 0x00, 0x2b, 0x90, 0x00 }
+
+#define MOP_K_PROTO_802_DSAP 0xaa
+#define MOP_K_PROTO_802_SSAP 0xaa
+#define MOP_K_PROTO_802_CNTL 0x03
+
+#define TRANS_ETHER 1 /* Packet in Ethernet format */
+#define TRANS_8023 2 /* Packet in 802.3 format */
+#define TRANS_AND 0x1000 /* Both Ethernet and 802.3 */
+
+/* The following constants are defined in module MOPDEF.SDL in MOM */
+
+#define MOP_K_CODE_MIN 0
+#define MOP_K_CODE_MLT 0 /* Memory Load with transfer address */
+#define MOP_K_CODE_DCM 1 /* Dump Complete */
+#define MOP_K_CODE_MLD 2 /* Memory Load */
+#define MOP_K_CODE_ASV 3 /* Assistance volunteer (NI only */
+#define MOP_K_CODE_RMD 4 /* Request memory dump */
+#define MOP_K_CODE_RID 5 /* Request ID */
+#define MOP_K_CODE_BOT 6 /* Boot */
+#define MOP_K_CODE_SID 7 /* System ID */
+#define MOP_K_CODE_RPR 8 /* Request program */
+#define MOP_K_CODE_RQC 9 /* Request Counters */
+#define MOP_K_CODE_RML 10 /* Request memory load */
+#define MOP_K_CODE_CNT 11 /* Counters */
+#define MOP_K_CODE_RDS 12 /* Request Dump Service */
+#define MOP_K_CODE_MMR 12 /* MOP Mode Running */
+#define MOP_K_CODE_RVC 13 /* Reserve Console */
+#define MOP_K_CODE_MDD 14 /* Memory dump data */
+#define MOP_K_CODE_RLC 15 /* Release Console */
+#define MOP_K_CODE_CCP 17 /* Console Command and Poll */
+#define MOP_K_CODE_CRA 19 /* Console Response and Acknnowledge */
+#define MOP_K_CODE_PLT 20 /* Parameter load with transfer address*/
+#define MOP_K_CODE_ALD 24 /* Active loop data */
+#define MOP_K_CODE_PLD 26 /* Passive looped data */
+#define MOP_K_CODE_MAX 26
+
+#define MOP_K_PGTY_MIN 0
+#define MOP_K_PGTY_SECLDR 0 /* Secondary Loader */
+#define MOP_K_PGTY_TERLDR 1 /* Tertiary Loader */
+#define MOP_K_PGTY_OPRSYS 2 /* Operating System */
+#define MOP_K_PGTY_MGNTFL 3 /* Management File */
+#define MOP_K_PGTY_MAX 3
+
+#define MOP_K_BPTY_MIN 0
+#define MOP_K_BPTY_SYS 0 /* System Processor */
+#define MOP_K_BPTY_COM 1 /* Communication Processor */
+#define MOP_K_BPTY_MAX 1
+
+#define MOP_K_RML_ERROR_MIN 0
+#define MOP_K_RML_ERROR_NONE 0 /* None */
+#define MOP_K_RML_ERROR_NO_LOAD 1 /* Image data not properly loaded */
+#define MOP_K_RML_ERROR_MAX 1
+
+#define MOP_K_PLTP_MIN 0
+#define MOP_K_PLTP_END 0 /* End Mark */
+#define MOP_K_PLTP_TSN 1 /* Target System Name */
+#define MOP_K_PLTP_TSA 2 /* Target System Address */
+#define MOP_K_PLTP_HSN 3 /* Host System Name */
+#define MOP_K_PLTP_HSA 4 /* Host System Address */
+#define MOP_K_PLTP_HST 5 /* Host System Time */
+#define MOP_K_PLTP_MAX 5
+
+#define MOP_K_BOT_CNTL_MIN 0
+#define MOP_K_BOT_CNTL_SERVER 0 /* Boot-Server */
+#define MOP_K_BOT_CNTL_DEVICE 1 /* Boot-Device */
+#define MOP_K_BOT_CNTL_MAX 1
+
+#define MOP_K_INFO_VER 1 /* Maintenance Version */
+#define MOP_K_INFO_MFCT 2 /* Maintenance Functions */
+#define MOP_K_INFO_CNU 3 /* Console User */
+#define MOP_K_INFO_RTM 4 /* Reservation Timer */
+#define MOP_K_INFO_CSZ 5 /* Console Command Size */
+#define MOP_K_INFO_RSZ 6 /* Console Response Size */
+#define MOP_K_INFO_HWA 7 /* Hardware Address */
+#define MOP_K_INFO_TIME 8 /* System Time */
+#define MOP_K_INFO_SOFD 100 /* Communication Device */
+#define MOP_K_INFO_SFID 200 /* Software ID */
+#define MOP_K_INFO_PRTY 300 /* System Processor */
+#define MOP_K_INFO_DLTY 400 /* Data Link Type */
+#define MOP_K_INFO_DLBSZ 401 /* Data Link Buffer Size */
+
+#define MOP_K_DLTY_MIN 1
+#define MOP_K_DLTY_NI 1 /* Ethernet */
+#define MOP_K_DLTY_DDCMP 2 /* DDCMP */
+#define MOP_K_DLTY_LAPB 3 /* LAPB (frame level of X.25) */
+#define MOP_K_DLTY_MAX 3
+
+#define MOP_K_PRTY_MIN 0
+#define MOP_K_PRTY_11 1 /* PDP-11 (UNIBUS) */
+#define MOP_K_PRTY_CMSV 2 /* Communication Server */
+#define MOP_K_PRTY_PRO 3 /* Professional */
+#define MOP_K_PRTY_SCO 4 /* Scorpio */
+#define MOP_K_PRTY_AMB 5 /* Amber */
+#define MOP_K_PRTY_BRI 6 /* XLII Bridge */
+#define MOP_K_PRTY_MAX 6
+
+#define MOP_K_SFID_FORM_MIN -2
+#define MOP_K_SFID_FORM_MAINT -2 /* Maintenance System */
+#define MOP_K_SFID_FORM_OPRSYS -1 /* Standard Operating System */