summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMats O Jansson <maja@cvs.openbsd.org>1999-03-27 14:31:24 +0000
committerMats O Jansson <maja@cvs.openbsd.org>1999-03-27 14:31:24 +0000
commitbdf0fa84baff8b71398e2760eb959d794df83839 (patch)
tree78765789cde5335291ef0143474ed35b3342c8ec /usr.sbin
parent2afff778427a17b38b9ebedd4bb658d36eee20c3 (diff)
Upgrade to 2.5.4. Mopprobe is working again, and some linux support. -moj
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/mopd/common/VERSION2
-rw-r--r--usr.sbin/mopd/common/device.c14
-rw-r--r--usr.sbin/mopd/common/file.c42
-rw-r--r--usr.sbin/mopd/common/print.c16
-rw-r--r--usr.sbin/mopd/mopprobe/Makefile5
-rw-r--r--usr.sbin/mopd/mopprobe/mopprobe.122
-rw-r--r--usr.sbin/mopd/mopprobe/mopprobe.c148
-rw-r--r--usr.sbin/mopd/otherOS/Makefile80
-rw-r--r--usr.sbin/mopd/otherOS/linux2/Makefile12
-rw-r--r--usr.sbin/mopd/otherOS/linux2/mopd-x.x.x.spec74
-rw-r--r--usr.sbin/mopd/otherOS/linux2/mopd.init50
-rw-r--r--usr.sbin/mopd/otherOS/loop-linux2.c168
-rw-r--r--usr.sbin/mopd/otherOS/mdtype26
-rw-r--r--usr.sbin/mopd/otherOS/os-linux2.h53
-rw-r--r--usr.sbin/mopd/otherOS/ostype12
-rw-r--r--usr.sbin/mopd/otherOS/pf-linux2.c318
16 files changed, 929 insertions, 113 deletions
diff --git a/usr.sbin/mopd/common/VERSION b/usr.sbin/mopd/common/VERSION
index aedc15bb0c6..fe16b348d97 100644
--- a/usr.sbin/mopd/common/VERSION
+++ b/usr.sbin/mopd/common/VERSION
@@ -1 +1 @@
-2.5.3
+2.5.4
diff --git a/usr.sbin/mopd/common/device.c b/usr.sbin/mopd/common/device.c
index 301cb5cdee7..7d653ec63fb 100644
--- a/usr.sbin/mopd/common/device.c
+++ b/usr.sbin/mopd/common/device.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: device.c,v 1.2 1996/09/21 19:11:23 maja Exp $ */
+/* $OpenBSD: device.c,v 1.3 1999/03/27 14:31:21 maja Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -30,7 +30,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: device.c,v 1.2 1996/09/21 19:11:23 maja Exp $";
+static char rcsid[] = "$OpenBSD: device.c,v 1.3 1999/03/27 14:31:21 maja Exp $";
#endif
#include "os.h"
@@ -158,6 +158,16 @@ deviceOpen(ifname, proto, trans)
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);
+
+ }
+#endif
}
}
diff --git a/usr.sbin/mopd/common/file.c b/usr.sbin/mopd/common/file.c
index 8a6938255fa..015c4d4187e 100644
--- a/usr.sbin/mopd/common/file.c
+++ b/usr.sbin/mopd/common/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.2 1996/09/21 19:11:31 maja Exp $ */
+/* $OpenBSD: file.c,v 1.3 1999/03/27 14:31:21 maja Exp $ */
/*
* Copyright (c) 1995-96 Mats O Jansson. All rights reserved.
@@ -30,7 +30,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: file.c,v 1.2 1996/09/21 19:11:31 maja Exp $";
+static char rcsid[] = "$OpenBSD: file.c,v 1.3 1999/03/27 14:31:21 maja Exp $";
#endif
#include "os.h"
@@ -47,6 +47,12 @@ static char rcsid[] = "$OpenBSD: file.c,v 1.2 1996/09/21 19:11:31 maja Exp $";
#if defined(__FreeBSD__)
#include <sys/imgact_aout.h>
#endif
+#if !defined(MID_I386)
+#define MID_I386 134
+#endif
+#if !defined(MID_SPARC)
+#define MID_SPARC 138
+#endif
#if !defined(MID_VAX)
#define MID_VAX 140
#endif
@@ -316,9 +322,6 @@ getMID(old_mid,new_mid)
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;
@@ -348,7 +351,7 @@ getMID(old_mid,new_mid)
break;
#endif
default:
-/*###352 [cc] syntax error before `}'%%%*/
+ break;
}
return(mid);
@@ -403,7 +406,6 @@ getCLBYTES(mid)
}
#endif
-/*###406 [cc] syntax error before `int'%%%*/
int
CheckAOutFile(fd)
int fd;
@@ -414,7 +416,6 @@ CheckAOutFile(fd)
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);
@@ -439,7 +440,6 @@ CheckAOutFile(fd)
#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)
@@ -525,7 +525,7 @@ GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
ex.a_drsize= mopFileGetBX((u_char *)&ex_swap, 28, 4);
break;
default:
-/*###525 [cc] syntax error before `}'%%%*/
+ break;
}
#ifdef INFO
@@ -609,22 +609,18 @@ GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
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);
@@ -636,12 +632,10 @@ GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
}
}
-/*###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);
@@ -653,12 +647,10 @@ GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
}
}
-/*###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);
@@ -674,7 +666,6 @@ GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
}
}
-/*###665 [cc] `aout' undeclared (first use this function)%%%*/
if (aout != NULL) {
*aout = mid;
}
@@ -683,7 +674,6 @@ GetAOutFileInfo(fd, load, xfr, a_text, a_text_fill,
#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)
@@ -722,7 +712,6 @@ GetFileInfo(fd, load, xfr, aout,
}
ssize_t
-/*###711 [cc] syntax error before `mopFileRead'%%%*/
mopFileRead(dlslot, buf)
struct dllist *dlslot;
u_char *buf;
@@ -731,9 +720,7 @@ mopFileRead(dlslot, buf)
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;
@@ -745,10 +732,8 @@ mopFileRead(dlslot, buf)
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;
@@ -765,7 +750,6 @@ mopFileRead(dlslot, buf)
} else {
outlen = bsz;
}
-/*###749 [cc] subscripted value is neither array nor pointer%%%*/
bzero(&buf[len],outlen);
len = len + outlen;
pos = pos + outlen;
@@ -777,10 +761,8 @@ mopFileRead(dlslot, buf)
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;
@@ -797,7 +779,6 @@ mopFileRead(dlslot, buf)
} else {
outlen = bsz;
}
-/*###778 [cc] subscripted value is neither array nor pointer%%%*/
bzero(&buf[len],outlen);
len = len + outlen;
pos = pos + outlen;
@@ -813,7 +794,6 @@ mopFileRead(dlslot, buf)
} else {
outlen = bsz;
}
-/*###793 [cc] subscripted value is neither array nor pointer%%%*/
bzero(&buf[len],outlen);
len = len + outlen;
pos = pos + outlen;
@@ -829,7 +809,6 @@ mopFileRead(dlslot, buf)
} else {
outlen = bsz;
}
-/*###808 [cc] subscripted value is neither array nor pointer%%%*/
bzero(&buf[len],outlen);
len = len + outlen;
pos = pos + outlen;
@@ -842,4 +821,3 @@ mopFileRead(dlslot, buf)
return(len);
}
-/*###820 [cc] syntax error at end of input%%%*/
diff --git a/usr.sbin/mopd/common/print.c b/usr.sbin/mopd/common/print.c
index cc08cb18ff5..8404c5b8c72 100644
--- a/usr.sbin/mopd/common/print.c
+++ b/usr.sbin/mopd/common/print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print.c,v 1.2 1996/09/21 19:11:57 maja Exp $ */
+/* $OpenBSD: print.c,v 1.3 1999/03/27 14:31:21 maja Exp $ */
/*
* Copyright (c) 1993-96 Mats O Jansson. All rights reserved.
@@ -30,7 +30,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: print.c,v 1.2 1996/09/21 19:11:57 maja Exp $";
+static char rcsid[] = "$OpenBSD: print.c,v 1.3 1999/03/27 14:31:21 maja Exp $";
#endif
#include <sys/types.h>
@@ -52,12 +52,12 @@ mopPrintHWA(fd, 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] < 10) (void)fprintf(fd, " ");
- if (ap[1] < 10) (void)fprintf(fd, " ");
- if (ap[2] < 10) (void)fprintf(fd, " ");
- if (ap[3] < 10) (void)fprintf(fd, " ");
- if (ap[4] < 10) (void)fprintf(fd, " ");
- if (ap[5] < 10) (void)fprintf(fd, " ");
+ 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, " ");
}
void
diff --git a/usr.sbin/mopd/mopprobe/Makefile b/usr.sbin/mopd/mopprobe/Makefile
index 51f3fc59410..e2c7260bbb1 100644
--- a/usr.sbin/mopd/mopprobe/Makefile
+++ b/usr.sbin/mopd/mopprobe/Makefile
@@ -1,7 +1,8 @@
-# $OpenBSD: Makefile,v 1.2 1996/09/21 19:12:32 maja Exp $
+# $OpenBSD: Makefile,v 1.3 1999/03/27 14:31:22 maja Exp $
PROG= mopprobe
-SRCS= mopprobe.c device.c get.c cmp.c mopdef.c version.c pf.c loop-bsd.c
+SRCS= mopprobe.c device.c get.c cmp.c mopdef.c version.c pf.c loop-bsd.c \
+ print.c nma.c
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/.. -I${.CURDIR}/../common -DNODL
CLEANFILES= version.c version.h
LDADD= -lkvm
diff --git a/usr.sbin/mopd/mopprobe/mopprobe.1 b/usr.sbin/mopd/mopprobe/mopprobe.1
index 9ff72f3d731..0e29ca8cc39 100644
--- a/usr.sbin/mopd/mopprobe/mopprobe.1
+++ b/usr.sbin/mopd/mopprobe/mopprobe.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mopprobe.1,v 1.2 1996/09/21 19:12:33 maja Exp $
+.\" $OpenBSD: mopprobe.1,v 1.3 1999/03/27 14:31:22 maja Exp $
.\"
.\" Copyright (c) 1996 Mats O Jansson. All rights reserved.
.\"
@@ -27,7 +27,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: mopprobe.1,v 1.2 1996/09/21 19:12:33 maja Exp $
+.\" @(#) $OpenBSD: mopprobe.1,v 1.3 1999/03/27 14:31:22 maja Exp $
.\"
.Dd October 2, 1995
.Dt MOPPROBE 1
@@ -38,18 +38,26 @@
.Nm mopprobe
.Fl a
.Op Fl 3 | 4
+.Op Fl o
+.Op Fl v
.Pp
.Nm mopprobe
.Op Fl 3 | 4
+.Op Fl o
+.Op Fl v
.Ar interface
.Sh DESCRIPTION
.Nm Mopprobe
-prints the ethernet address and nodename of MOP SID message on the Ethernet
-connected to
+prints the ethernet address and nodename of DECserver 100/200/250/300 on the
+Ethernet connected to
.Ar interface
or all known interfaces if
.Sq Fl a
-is given.
+is given. If
+.Sq Fl o
+inhibits all messages but the first from a node. With
+.Sq Fl v
+all MOP/RC SID messages will be shown (e.g. machines running DECnet).
.Sh OPTIONS
.Bl -tag -width indent
.It Fl a
@@ -61,6 +69,10 @@ is omitted, an interface must be specified.
Ignore MOP V3 messages (Ethernet II).
.It Fl 4
Ignore MOP V4 messages (Ethernet 802.3).
+.It Fl o
+Print a node just once.
+.It Fl v
+Show all nodes sending MOP/RC SID messages.
.El
.Sh SEE ALSO
.Xr mopa.out 1 ,
diff --git a/usr.sbin/mopd/mopprobe/mopprobe.c b/usr.sbin/mopd/mopprobe/mopprobe.c
index 258791726c5..ae3b6430705 100644
--- a/usr.sbin/mopd/mopprobe/mopprobe.c
+++ b/usr.sbin/mopd/mopprobe/mopprobe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mopprobe.c,v 1.4 1998/03/19 07:39:44 deraadt Exp $ */
+/* $OpenBSD: mopprobe.c,v 1.5 1999/03/27 14:31:22 maja Exp $ */
/*
* Copyright (c) 1993-96 Mats O Jansson. All rights reserved.
@@ -30,14 +30,14 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: mopprobe.c,v 1.4 1998/03/19 07:39:44 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mopprobe.c,v 1.5 1999/03/27 14:31:22 maja Exp $";
#endif
/*
* mopprobe - MOP Probe Utility
*
- * Usage: mopprobe -a [ -3 | -4 ]
- * mopprobe [ -3 | -4 ] interface
+ * Usage: mopprobe -a [ -3 | -4 ] [-v] [-o]
+ * mopprobe [ -3 | -4 ] [-v] [-o] interface
*/
#include "os.h"
@@ -66,13 +66,19 @@ void Usage __P((void));
void mopProcess __P((struct if_info *, u_char *));
#endif
+struct once {
+ u_char eaddr[6]; /* Ethernet addr */
+ struct once *next; /* Next one */
+};
+
int AllFlag = 0; /* listen on "all" interfaces */
-int DebugFlag = 0; /* print debugging messages */
int Not3Flag = 0; /* Not MOP V3 messages */
int Not4Flag = 0; /* Not MOP V4 messages */
-int oflag = 0; /* print only once */
+int VerboseFlag = 0; /* Print All Announces */
+int OnceFlag = 0; /* print only once */
int promisc = 1; /* Need promisc mode */
char *Program;
+struct once *root = NULL;
int
main(argc, argv)
@@ -95,7 +101,7 @@ main(argc, argv)
openlog(Program, LOG_PID | LOG_CONS, LOG_DAEMON);
opterr = 0;
- while ((op = getopt(argc, argv, "ado")) != -1) {
+ while ((op = getopt(argc, argv, "34aov")) != -1) {
switch (op) {
case '3':
Not3Flag++;
@@ -106,13 +112,12 @@ main(argc, argv)
case 'a':
AllFlag++;
break;
- case 'd':
- DebugFlag++;
- break;
case 'o':
- oflag++;
+ OnceFlag++;
+ break;
+ case 'v':
+ VerboseFlag++;
break;
-
default:
Usage();
/* NOTREACHED */
@@ -136,8 +141,8 @@ main(argc, argv)
void
Usage()
{
- (void) fprintf(stderr, "usage: %s -a [ -3 | -4 ]\n",Program);
- (void) fprintf(stderr, " %s [ -3 | -4 ] interface\n",Program);
+ (void) fprintf(stderr, "usage: %s -a [ -3 | -4 ] [-v] [-o]\n",Program);
+ (void) fprintf(stderr, " %s [ -3 | -4 ] [-v] [-o] interface\n",Program);
exit(1);
}
@@ -149,33 +154,27 @@ mopProcess(ii, pkt)
struct if_info *ii;
u_char *pkt;
{
- u_char *dst, *src, *p, mopcode, tmpc, ilen;
- u_short *ptype, moplen, tmps, itype, len;
- int index, i, device, trans;
-
- dst = pkt;
- src = pkt+6;
- ptype = (u_short *)(pkt+12);
- index = 0;
+ u_char *dst, *src, mopcode, tmpc, device, ilen;
+ u_short ptype, moplen = 0, tmps, itype;
+ int index, trans, len, i, hwa = 0;
+ struct once *o = NULL;
- if (*ptype < 1600) {
- len = *ptype;
- trans = TRANS_8023;
- ptype = (u_short *)(pkt+20);
- p = pkt+22;
- if (Not4Flag) return;
- } else {
- len = 0;
- trans = TRANS_ETHER;
- p = pkt+14;
- if (Not3Flag) return;
- }
-
- /* Ignore our own messages */
+ /* We don't known with transport, Guess! */
+
+ trans = mopGetTrans(pkt, 0);
- if (mopCmpEAddr(ii->eaddr,src) == 0) {
+ /* Ok, return if we don't wan't this message */
+
+ if ((trans == TRANS_ETHER) && Not3Flag) return;
+ if ((trans == TRANS_8023) && Not4Flag) return;
+
+ index = 0;
+ mopGetHeader(pkt, &index, &dst, &src, &ptype, &len, trans);
+
+ /* Ignore our own transmissions */
+
+ if (mopCmpEAddr(ii->eaddr,src) == 0)
return;
- }
/* Just check multicast */
@@ -183,14 +182,33 @@ mopProcess(ii, pkt)
return;
}
- switch (trans) {
- case TRANS_8023:
- moplen = len;
+ switch(ptype) {
+ case MOP_K_PROTO_RC:
break;
default:
- moplen = mopGetShort(pkt,&index);
+ return;
+ }
+
+ if (OnceFlag) {
+ o = root;
+ while (o != NULL) {
+ if (mopCmpEAddr(o->eaddr,src) == 0)
+ return;
+ o = o->next;
+ }
+ o = (struct once *)malloc(sizeof(*o));
+ o->eaddr[0] = src[0];
+ o->eaddr[1] = src[1];
+ o->eaddr[2] = src[2];
+ o->eaddr[3] = src[3];
+ o->eaddr[4] = src[4];
+ o->eaddr[5] = src[5];
+ o->next = root;
+ root = o;
}
- mopcode = mopGetChar(p,&index);
+
+ moplen = mopGetLength(pkt, trans);
+ mopcode = mopGetChar(pkt,&index);
/* Just process System Information */
@@ -198,21 +216,30 @@ mopProcess(ii, pkt)
return;
}
- tmpc = mopGetChar(pkt,&index); /* Reserved */
- tmps = mopGetShort(pkt,&index); /* Receipt # */
+ tmpc = mopGetChar(pkt,&index); /* Reserved */
+ tmps = mopGetShort(pkt,&index); /* Receipt # */
+
+ device = 0;
- device = 0; /* Unknown Device */
-
- itype = mopGetShort(pkt,&index);
+ switch(trans) {
+ case TRANS_ETHER:
+ moplen = moplen + 16;
+ break;
+ case TRANS_8023:
+ moplen = moplen + 14;
+ break;
+ }
- while (index < (int)(moplen + 2)) {
- ilen = mopGetChar(pkt,&index);
+ itype = mopGetShort(pkt,&index);
+
+ while (index < (int)(moplen)) {
+ ilen = mopGetChar(pkt,&index);
switch (itype) {
case 0:
tmpc = mopGetChar(pkt,&index);
index = index + tmpc;
break;
- case MOP_K_INFO_VER:
+ case MOP_K_INFO_VER:
index = index + 3;
break;
case MOP_K_INFO_MFCT:
@@ -231,6 +258,7 @@ mopProcess(ii, pkt)
index = index + 2;
break;
case MOP_K_INFO_HWA:
+ hwa = index;
index = index + 6;
break;
case MOP_K_INFO_TIME:
@@ -238,6 +266,19 @@ mopProcess(ii, pkt)
break;
case MOP_K_INFO_SOFD:
device = mopGetChar(pkt,&index);
+ if (VerboseFlag &&
+ (device != NMA_C_SOFD_LCS) && /* DECserver 100 */
+ (device != NMA_C_SOFD_DS2) && /* DECserver 200 */
+ (device != NMA_C_SOFD_DP2) && /* DECserver 250 */
+ (device != NMA_C_SOFD_DS3)) /* DECserver 300 */
+ {
+ mopPrintHWA(stdout, src);
+ (void)fprintf(stdout," # ");
+ mopPrintDevice(stdout, device);
+ (void)fprintf(stdout," ");
+ mopPrintHWA(stdout, &pkt[hwa]);
+ (void)fprintf(stdout,"\n");
+ }
break;
case MOP_K_INFO_SFID:
tmpc = mopGetChar(pkt,&index);
@@ -271,8 +312,8 @@ mopProcess(ii, pkt)
index = index + 2;
break;
case 105:
- (void)fprintf(stdout,"%x:%x:%x:%x:%x:%x\t",
- src[0],src[1],src[2],src[3],src[4],src[5]);
+ mopPrintHWA(stdout, src);
+ (void)fprintf(stdout," ");
for (i = 0; i < ilen; i++) {
(void)fprintf(stdout, "%c",pkt[index+i]);
}
@@ -289,6 +330,5 @@ mopProcess(ii, pkt)
}
itype = mopGetShort(pkt,&index);
}
-
}
diff --git a/usr.sbin/mopd/otherOS/Makefile b/usr.sbin/mopd/otherOS/Makefile
index 5d6294d0783..b47bcce59ce 100644
--- a/usr.sbin/mopd/otherOS/Makefile
+++ b/usr.sbin/mopd/otherOS/Makefile
@@ -1,12 +1,13 @@
# Copyright (c) 1993-1994 Mats O Jansson, Stockholm, Sweden
# All rights reserved.
#
-# @(#) $OpenBSD: Makefile,v 1.2 1996/09/21 19:12:42 maja Exp $
+# @(#) $OpenBSD: Makefile,v 1.3 1999/03/27 14:31:22 maja Exp $
# Script (or program) that returns the machine and os types,
# or jsut edit in the name yourself.
MD=`./mdtype`
OS=`./ostype`
+REL=`cat ../common/VERSION`
CCOPT = -O
INCLUDES = -I..
@@ -25,9 +26,21 @@ STANDARD_CFLAGS = $(CCOPT) $(SPEC_FLAGS) $(DEFINES) $(INCLUDES)
#sun4-sunos4#CFLAGS = $(STANDARD_CFLAGS) -DNO__P
#sun4-sunos5#CFLAGS = $(STANDARD_CFLAGS) -DNO__P -DDLPIPF
#rs6000-aix3#CFLAGS = $(STANDARD_CFLAGS)
+#alpha-linux2#CFLAGS = $(STANDARD_CFLAGS)
+#i386-linux2#CFLAGS = $(STANDARD_CFLAGS)
+#sparc-linux2#CFLAGS = $(STANDARD_CFLAGS)
#sun4-sunos5#LIB = -lsocket
+INSTBIN="#"
+INSTMAN="#"
+#alpha-linux2#INSTBIN= install -c -s -o root -g root -m 755
+#alpha-linux2#INSTMAN= install -c -o root -g root -m 644
+#i386-linux2#INSTBIN= install -c -s -o root -g root -m 755
+#i386-linux2#INSTMAN= install -c -o root -g root -m 644
+#sparc-linux2#INSTBIN= install -c -s -o root -g root -m 755
+#sparc-linux2#INSTMAN= install -c -o root -g root -m 644
+
# Change these to cc/lex/yacc if you don't have gcc, flex and/or bison.
CC = cc
LEX = lex
@@ -42,15 +55,19 @@ MAKE = make
DIRS= mopchk mopd mopprobe moptrace
+CHDOC= mopchk.1
CHFIL= mopchk.c
CHOBJ= mopchk.o
CHHDR=
+LDDOC= mopd.8
LDFIL= mopd.c process.c
LDOBJ= mopd.o process.o
LDHDR= process.h
+PBDOC= mopprobe.1
PBFIL= mopprobe.c
PBOBJ= mopprobe.o
PBHDR=
+TRDOC= moptrace.1
TRFIL= moptrace.c
TROBJ= moptrace.o
TRHDR=
@@ -67,21 +84,37 @@ TRHDR=
#rs6000-aix3#PFFIL= pf-aix3.c
#rs6000-aix3#LOOP= loop.c
+#alpha-linux2#OSHDR= os-linux2.h
+#alpha-linux2#PFFIL= pf-linux2.c
+#alpha-linux2#LOOP= loop-linux2.c
+
+#i386-linux2#OSHDR= os-linux2.h
+#i386-linux2#PFFIL= pf-linux2.c
+#i386-linux2#LOOP= loop-linux2.c
+
+#sparc-linux2#OSHDR= os-linux2.h
+#sparc-linux2#PFFIL= pf-linux2.c
+#sparc-linux2#LOOP= loop-linux2.c
+
#mopchk#COFIL= device.c file.c mopdef.c
#mopchk#COOBJ= device.o file.o mopdef.o
#mopchk#OTOBJ= pf.o loop.o
+#mopchk#MANDIR=man1
#mopd#COFIL= cmp.c device.c dl.c file.c get.c mopdef.c nma.c print.c put.c rc.c
#mopd#COOBJ= cmp.o device.o dl.o file.o get.o mopdef.o nma.o print.o put.o rc.o
#mopd#OTOBJ= pf.o loop.o
+#mopd#MANDIR=man8
-#mopprobe#COFIL= cmp.c device.c get.c mopdef.c
-#mopprobe#COOBJ= cmp.o device.o get.o mopdef.o
+#mopprobe#COFIL= cmp.c device.c get.c mopdef.c nma.c print.c
+#mopprobe#COOBJ= cmp.o device.o get.o mopdef.o nma.o print.o
#mopprobe#OTOBJ= pf.o loop.o
+#mopprobe#MANDIR=man1
#moptrace#COFIL= cmp.c device.c dl.c get.c mopdef.c nma.c print.c rc.c
#moptrace#COOBJ= cmp.o device.o dl.o get.o mopdef.o nma.o print.o rc.o
#moptrace#OTOBJ= pf.o loop.o
+#moptrace#MANDIR=man1
toplvl: osmake
@@ -109,44 +142,77 @@ submake: force
${MAKE} ${MFLAGS} files; cd ..; fi; done; \
for i in $(DIRS); do cd $$i; ${MAKE} ${MFLAGS}; cd ..; done
+osinstall: force
+ @os=$(OS); \
+ if [ -d $$os ]; then (cd $$os; ${MAKE} ${MFLAGS} INSTALL="$(INSTALL)" install); fi;
+
+install: osinstall
+ @dir=$(MD)-$(OS); cd $$dir; \
+ for i in $(DIRS); do cd $$i; ${MAKE} ${MFLAGS} INSTALL="$(INSTALL)" inst; cd ..; done;
+
config:
@md=$(MD); os=$(OS); dir=$$md-$$os; \
mkdir $$dir; chmod ug+w $$dir; \
sed -e "/^toplvl:/d" -e "s/^#$$dir#//" Makefile >$$dir/Makefile; \
chmod ug+w $$dir/Makefile
+tar:
+ @rel=$(REL); cd ..; \
+ tar -cf ../mopd-$$rel.tar [M]* c*/[Va-z]* m*/[MTa-np-z]* otherOS/*.[ch] otherOS/[M]* otherOS/*type otherOS/linux2/[Mm]*; \
+ gzip -9 ../mopd-$$rel.tar
+
#mopchk#files: force
#mopchk# echo "Adding files in mopchk"; \
#mopchk# ln -s ../../../common common; \
-#mopchk# for i in $(CHFIL) $(CHHDR); do ln -s ../../../mopchk/$$i $$i; done; \
+#mopchk# for i in $(CHFIL) $(CHHDR) $(CHDOC); do ln -s ../../../mopchk/$$i $$i; done; \
#mopchk# for i in $(COFIL); do ln -s ../../../common/$$i $$i; done; \
#mopchk# ln -s ../../$(OSHDR) os.h; ln -s ../../$(PFFIL) pf.c; \
#mopchk# ln -s ../../$(LOOP) loop.c
+#mopchk#inst: mopchk
+#mopchk# echo "Installing files in mopchk";
+#mopchk# $(INSTBIN) $< $(INSTALL)/usr/sbin
+#mopchk# $(INSTMAN) $(CHDOC) $(INSTALL)/usr/man/$(MANDIR)
+
#mopd#files: force
#mopd# echo "Adding files in mopd"; \
#mopd# ln -s ../../../common common; \
-#mopd# for i in $(LDFIL) $(LDHDR); do ln -s ../../../mopd/$$i $$i; done; \
+#mopd# for i in $(LDFIL) $(LDHDR) $(LDDOC); do ln -s ../../../mopd/$$i $$i; done; \
#mopd# for i in $(COFIL); do ln -s ../../../common/$$i $$i; done; \
#mopd# ln -s ../../$(OSHDR) os.h; ln -s ../../$(PFFIL) pf.c; \
#mopd# ln -s ../../$(LOOP) loop.c
+#mopd#inst: mopd
+#mopd# echo "Installing files in mopd";
+#mopd# $(INSTBIN) $< $(INSTALL)/usr/sbin
+#mopd# $(INSTMAN) $(LDDOC) $(INSTALL)/usr/man/$(MANDIR)
+
#mopprobe#files: force
#mopprobe# echo "Adding files in mopprobe"; \
#mopprobe# ln -s ../../../common common; \
-#mopprobe# for i in $(PBFIL) $(PBHDR); do ln -s ../../../mopprobe/$$i $$i; done; \
+#mopprobe# for i in $(PBFIL) $(PBHDR) $(PBDOC); do ln -s ../../../mopprobe/$$i $$i; done; \
#mopprobe# for i in $(COFIL); do ln -s ../../../common/$$i $$i; done; \
#mopprobe# ln -s ../../$(OSHDR) os.h; ln -s ../../$(PFFIL) pf.c; \
#mopprobe# ln -s ../../$(LOOP) loop.c
+#mopprobe#inst: mopprobe
+#mopprobe# echo "Installing files in mopprobe";
+#mopprobe# $(INSTBIN) $< $(INSTALL)/usr/sbin
+#mopprobe# $(INSTMAN) $(PBDOC) $(INSTALL)/usr/man/$(MANDIR)
+
#moptrace#files: force
#moptrace# echo "Adding files in moptrace"; \
#moptrace# ln -s ../../../common common; \
-#moptrace# for i in $(TRFIL) $(TRHDR); do ln -s ../../../moptrace/$$i $$i; done; \
+#moptrace# for i in $(TRFIL) $(TRHDR) $(TRDOC); do ln -s ../../../moptrace/$$i $$i; done; \
#moptrace# for i in $(COFIL); do ln -s ../../../common/$$i $$i; done; \
#moptrace# ln -s ../../$(OSHDR) os.h; ln -s ../../$(PFFIL) pf.c; \
#moptrace# ln -s ../../$(LOOP) loop.c
+#moptrace#inst: moptrace
+#moptrace# echo "Installing files in moptrace";
+#moptrace# $(INSTBIN) $< $(INSTALL)/usr/sbin
+#moptrace# $(INSTMAN) $(TRDOC) $(INSTALL)/usr/man/$(MANDIR)
+
mopchk: $(CHOBJ) $(COOBJ) $(OTOBJ) version.o
$(CC) $(CFLAGS) -o $@ $(CHOBJ) $(COOBJ) $(OTOBJ) version.o $(LIB)
diff --git a/usr.sbin/mopd/otherOS/linux2/Makefile b/usr.sbin/mopd/otherOS/linux2/Makefile
new file mode 100644
index 00000000000..1d4596fcf9f
--- /dev/null
+++ b/usr.sbin/mopd/otherOS/linux2/Makefile
@@ -0,0 +1,12 @@
+# Copyright (c) 1999 Mats O Jansson, Stockholm, Sweden
+# All rights reserved.
+#
+# @(#) $OpenBSD: Makefile,v 1.1 1999/03/27 14:31:23 maja Exp $
+
+INSTBIN= install -c -s -o root -g root -m 755
+INSTINIT= install -c -o root -g root -m 755
+
+install: mopd.init
+ echo "Installing files in linux2";
+ $(INSTINIT) $< $(INSTALL)/etc/rc.d/init.d/mopd
+
diff --git a/usr.sbin/mopd/otherOS/linux2/mopd-x.x.x.spec b/usr.sbin/mopd/otherOS/linux2/mopd-x.x.x.spec
new file mode 100644
index 00000000000..c5fdc87d6ab
--- /dev/null
+++ b/usr.sbin/mopd/otherOS/linux2/mopd-x.x.x.spec
@@ -0,0 +1,74 @@
+# $OpenBSD: mopd-x.x.x.spec,v 1.1 1999/03/27 14:31:23 maja Exp $
+Summary: MOP (Maintenance Operations Protocol) loader daemon
+Name: mopd
+Version: 2.5.4
+Release: 2
+Copyright: BSD
+Group: Networking
+Source: ftp://ftp.stacken.kth.se/pub/NetBSD/mopd/mopd-2.5.4.tar.gz
+BuildRoot: /var/tmp/mopd-2.5.4
+Packager: Mats O Jansson <moj@stacken.kth.se>
+
+%description
+Mopd services MOP Load requests on the Ethernet connected to interface or
+all interfaces if a `-a' is given. In a load request received by mopd a
+filename can be given. This is the normal case for e.g. terminal servers.
+If a filename isn't given mopd must know what image to load.
+
+Upon receiving a request, mopd checks if the requested file exists in
+/tftpboot/mop, the filename is normaly uppercase and with an extension of
+.SYS. If the filename isn't given, the ethernet address of the target is
+used as filename, e.g. 08002b09f4de.SYS and it might be a soft link to
+another file.
+
+Mopd supports two kinds of files. The first type that is check is if the
+file is in a.out(5) format. If not, a couple of Digital's formats are
+checked.
+
+%prep
+%setup -q -c mopd-2.5.4
+
+%build
+(cd otherOS && make)
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p -m 755 $RPM_BUILD_ROOT/etc/rc.d/init.d
+mkdir -p -m 755 $RPM_BUILD_ROOT/usr/man/man1
+mkdir -p -m 755 $RPM_BUILD_ROOT/usr/man/man8
+mkdir -p -m 755 $RPM_BUILD_ROOT/usr/sbin
+mkdir -p -m 755 $RPM_BUILD_ROOT/tftpboot/mop
+(cd otherOS && make INSTALL="$RPM_BUILD_ROOT" install)
+
+%clean
+cd ..
+rm -rf mopd-2.5.4
+rm -rf $RPM_BUILD_ROOT
+
+%post
+/sbin/chkconfig --add mopd
+
+%postun
+if [ $1 = 0 ]; then
+ /sbin/chkconfig --del mopd
+fi
+
+%files
+%attr(755, root, root) /tftpboot/mop
+%attr(755, root, root) /usr/sbin/mopchk
+%attr(644, root, root) /usr/man/man1/mopchk.1
+%attr(755, root, root) /usr/sbin/mopd
+%attr(644, root, root) /usr/man/man8/mopd.8
+%attr(755, root, root) /usr/sbin/mopprobe
+%attr(644, root, root) /usr/man/man1/mopprobe.1
+%attr(755, root, root) /usr/sbin/moptrace
+%attr(644, root, root) /usr/man/man1/moptrace.1
+%config %attr(755, root, root) /etc/rc.d/init.d/mopd
+
+%changelog
+* Fri Mar 26 1998 Mats O Jansson <moj@stacken.kth.se>
+- incorparated lots of ideas from <xenophon@irtnog.org> who had written
+ the mopd-linux-2.5.3 package.
+
+* Wed Mar 24 1998 Mats O Jansson <moj@stacken.kth.se>
+- initial build
diff --git a/usr.sbin/mopd/otherOS/linux2/mopd.init b/usr.sbin/mopd/otherOS/linux2/mopd.init
new file mode 100644
index 00000000000..e037db17e4f
--- /dev/null
+++ b/usr.sbin/mopd/otherOS/linux2/mopd.init
@@ -0,0 +1,50 @@
+#! /bin/sh
+# $OpenBSD: mopd.init,v 1.1 1999/03/27 14:31:23 maja Exp $
+#
+# chkconfig: - 60 20
+# description: The mopd server allows older DEC workstations to net boot \
+# from Linux boxes. It (along with rarp) is rarely used anymore; \
+# bootp and dhcp have mostly replaced both of them.
+# processname: mopd
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Get config.
+. /etc/sysconfig/network
+
+# Check that networking is up.
+if [ ${NETWORKING} = "no" ]
+then
+ exit 0
+fi
+
+# See how we were called.
+case "$1" in
+ start)
+ echo -n "Starting mopd services: "
+ daemon mopd -a
+
+ echo
+ touch /var/lock/subsys/mopd
+ ;;
+ stop)
+ echo -n "Stopping mopd services: "
+ killproc mopd
+
+ echo
+ rm -f /var/lock/subsys/mopd
+ ;;
+ status)
+ status mopd
+ ;;
+ restart|reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo "Usage: mopd {start|stop|status|restart|reload}"
+ exit 1
+esac
+
+exit 0
diff --git a/usr.sbin/mopd/otherOS/loop-linux2.c b/usr.sbin/mopd/otherOS/loop-linux2.c
new file mode 100644
index 00000000000..d726211726b
--- /dev/null
+++ b/usr.sbin/mopd/otherOS/loop-linux2.c
@@ -0,0 +1,168 @@
+/*
+ * 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-linux2.c,v 1.1 1999/03/27 14:31:22 maja Exp $";
+#endif
+
+#include <stdlib.h>
+#include <strings.h>
+#include <unistd.h>
+#if defined(__bsdi__) || defined(__FreeBSD__)
+#include <sys/time.h>
+#endif
+#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 = 1100, maxfd =0;
+ struct if_info *ii;
+
+/* FIXME : this is a hack, for some reason specifying an interface would
+ * cause it to fail because bufsize is an impossible number, so I added a
+ * sanity check because I'm too lazy to figure out why. -- Karl
+ */
+ if (bufsize > 1100)
+ bufsize = 64;
+
+ if (iflist == 0) {
+ syslog(LOG_ERR, "no interfaces");
+ 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, (fd_set *) 0,
+ (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;
+
+ bp = buf;
+ ep = bp + cc;
+
+if(bp < ep)
+ {
+ mopProcess(ii,buf);
+ }
+
+}
+
+}
+}
+
diff --git a/usr.sbin/mopd/otherOS/mdtype b/usr.sbin/mopd/otherOS/mdtype
index ea274963ed6..a74b48dee4b 100644
--- a/usr.sbin/mopd/otherOS/mdtype
+++ b/usr.sbin/mopd/otherOS/mdtype
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# @(#) $OpenBSD: mdtype,v 1.2 1996/09/21 19:12:45 maja Exp $
+# @(#) $OpenBSD: mdtype,v 1.3 1999/03/27 14:31:22 maja Exp $
#
# Determine machine type.
#
@@ -42,6 +42,30 @@ if [ -f /usr/bin/uname ]; then
fi
+if [ -f /bin/uname ]; then
+
+ os=`/bin/uname`
+
+ if [ $os = "Linux" ]; then
+
+ machine="`/bin/uname -m`"
+
+ if [ $machine = "i686" ]; then
+ machine="i386"
+ fi
+
+ if [ $machine = "i586" ]; then
+ machine="i386"
+ fi
+
+ if [ $machine = "i486" ]; then
+ machine="i386"
+ fi
+
+ fi
+
+fi
+
echo $machine
if [ $machine = "UNKNOWN" ]; then
diff --git a/usr.sbin/mopd/otherOS/os-linux2.h b/usr.sbin/mopd/otherOS/os-linux2.h
new file mode 100644
index 00000000000..d2658be2d5c
--- /dev/null
+++ b/usr.sbin/mopd/otherOS/os-linux2.h
@@ -0,0 +1,53 @@
+/* $OpenBSD: os-linux2.h,v 1.1 1999/03/27 14:31:22 maja Exp $ */
+
+/*
+ * 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.
+ *
+ * @(#) $OpenBSD: os-linux2.h,v 1.1 1999/03/27 14:31:22 maja Exp $
+ */
+
+#include <stdio.h>
+
+#include <syslog.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <time.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+
+#define LINUX2_PF
+#define SETPGRP_NOPARAM
+
diff --git a/usr.sbin/mopd/otherOS/ostype b/usr.sbin/mopd/otherOS/ostype
index c1359bed291..ebe2b365a37 100644
--- a/usr.sbin/mopd/otherOS/ostype
+++ b/usr.sbin/mopd/otherOS/ostype
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# @(#) $OpenBSD: ostype,v 1.2 1996/09/21 19:12:48 maja Exp $
+# @(#) $OpenBSD: ostype,v 1.3 1999/03/27 14:31:23 maja Exp $
#
# Determine os type.
#
@@ -24,6 +24,16 @@ if [ -f /usr/bin/uname ]; then
fi
+if [ -f /bin/uname ]; then
+
+ osname=`/bin/uname`
+
+ if [ $osname = "Linux" ]; then
+ os="linux`/bin/uname -r | /usr/bin/cut -d. -f1`"
+ fi
+
+fi
+
echo $os
if [ $os = "UNKNOWN" ]; then
diff --git a/usr.sbin/mopd/otherOS/pf-linux2.c b/usr.sbin/mopd/otherOS/pf-linux2.c
new file mode 100644
index 00000000000..de05c43e410
--- /dev/null
+++ b/usr.sbin/mopd/otherOS/pf-linux2.c
@@ -0,0 +1,318 @@
+/*
+ * General Purpose AppleTalk Packet Filter Interface
+ *
+ * Copyright (c) 1992-1995, The University of Melbourne.
+ * All Rights Reserved. Permission to redistribute or
+ * use any part of this software for any purpose must
+ * be obtained in writing from the copyright owner.
+ *
+ * This software is supplied "as is" without express
+ * or implied warranty.
+ *
+ * djh@munnari.OZ.AU
+ *
+ * Supports:
+ * Linux SOCK_PACKET
+ *
+ * $Author: maja $
+ * $Revision: 1.1 $
+ *
+ *
+ * Modified for use with the linux-mopd port by Karl Maftoum
+ * u963870@student.canberra.edu.au
+ *
+ */
+
+/*
+ * include header files
+ *
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/file.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <sys/errno.h>
+#include <linux/if_ether.h>
+#include <netdb.h>
+#include <ctype.h>
+#include <string.h>
+
+#define MOPDEF_SUPRESS_EXTERN
+#include "common/mopdef.h"
+
+/*
+ * definitions
+ *
+ */
+
+#define READBUFSIZ 4096
+#define NUMRDS 32
+
+struct RDS {
+ u_short dataLen;
+ u_char *dataPtr;
+};
+
+/*
+ * variables
+ *
+ */
+
+struct socklist {
+ int iflen;
+ struct sockaddr sa;
+} socklist[32];
+
+struct ifreq ifr;
+extern int errno;
+extern int promisc;
+
+struct RDS RDS[NUMRDS];
+
+/*
+ * Open and initialize packet filter
+ * for a particular protocol type.
+ *
+ */
+
+
+int
+pfInit(interface, mode, protocol, typ)
+char *interface;
+u_short protocol;
+int typ, mode;
+{
+ int s;
+ int ioarg;
+ char device[64];
+ unsigned long if_flags;
+
+
+ { u_short prot;
+
+ prot = ((typ == TRANS_8023) ? htons(ETH_P_802_2) : htons(protocol));
+ if ((s = socket(AF_INET, SOCK_PACKET, prot)) < 0) {
+ perror(interface);
+ return(-1);
+ }
+ if (s >= 32) {
+ close(s);
+ return(-1);
+ }
+ }
+
+ /*
+ * set filter for protocol and type (IPTalk, Phase 1/2)
+ *
+ */
+
+ if (setup_pf(s, protocol, typ) < 0)
+ return(-1);
+
+ /*
+ * set options, bind to underlying interface
+ *
+ */
+
+ strncpy(ifr.ifr_name, interface, sizeof(ifr.ifr_name));
+
+ /* record socket interface name and length */
+ strncpy(socklist[s].sa.sa_data, interface, sizeof(socklist[s].sa.sa_data));
+ socklist[s].iflen = strlen(interface);
+
+ return(s);
+}
+
+/*
+ * establish protocol filter
+ *
+ */
+
+int
+setup_pf(s, prot, typ)
+int s, typ;
+u_short prot;
+{
+ int ioarg;
+ u_short offset;
+ return(0);
+}
+
+/*
+ * get the interface ethernet address
+ *
+ */
+
+int
+pfEthAddr(s, interface, addr)
+int s;
+char *interface;
+u_char *addr;
+{
+ strcpy(ifr.ifr_name, interface);
+ ifr.ifr_addr.sa_family = AF_INET;
+ if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) {
+ perror("SIOCGIFHWADDR");
+ return(-1);
+ }
+ memcpy((char *)addr, ifr.ifr_hwaddr.sa_data, 6);
+ return(0);
+}
+
+/*
+ * add a multicast address to the interface
+ *
+ */
+
+int
+pfAddMulti(s, interface, addr)
+int s;
+char *interface;
+u_char *addr;
+{
+ int sock;
+
+ strcpy(ifr.ifr_name, interface);
+
+ ifr.ifr_addr.sa_family = AF_UNSPEC;
+ bcopy((char *)addr, ifr.ifr_addr.sa_data, 6);
+
+ /*
+ * open a socket, temporarily, to use for SIOC* ioctls
+ *
+ */
+ if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ perror("socket()");
+ return(-1);
+ }
+ if (ioctl(sock, SIOCADDMULTI, (caddr_t)&ifr) < 0) {
+ perror("SIOCADDMULTI");
+ close(sock);
+ return(-1);
+ }
+ close(sock);
+
+ return(0);
+}
+
+/*
+ * delete a multicast address from the interface
+ *
+ */
+
+int
+pfDelMulti(s, interface, addr)
+int s;
+char *interface;
+u_char *addr;
+{
+ int sock;
+
+ strcpy(ifr.ifr_name, interface);
+
+ ifr.ifr_addr.sa_family = AF_UNSPEC;
+ bcopy((char *)addr, ifr.ifr_addr.sa_data, 6);
+
+ /*
+ * open a socket, temporarily, to use for SIOC* ioctls
+ *
+ */
+ if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ perror("socket()");
+ return(-1);
+ }
+ if (ioctl(sock, SIOCDELMULTI, (caddr_t)&ifr) < 0) {
+ perror("SIOCDELMULTI");
+ close(sock);
+ return(-1);
+ }
+ close(sock);
+
+ return(0);
+}
+
+/*
+ * return 1 if ethernet interface capable of multiple opens
+ *
+ */
+
+int
+eth_mopen(phase)
+int phase;
+{
+ if (phase == 2)
+ return(0);
+ return(1);
+}
+
+/*
+ * read a packet
+ * Read Data Structure describes packet(s) received
+ *
+ */
+
+
+
+
+int
+pfRead(fd, buf, len)
+int fd, len;
+u_char *buf;
+{
+ int i, cc;
+
+ int fromlen;
+ struct sockaddr sa;
+
+ RDS[0].dataLen = 0;
+ fromlen = sizeof(struct sockaddr);
+
+ if ((cc = recvfrom(fd, (char *)buf, len, 0, &sa, &fromlen)) <= 0)
+ return(cc);
+
+ /* check if from right interface */
+ for (i = socklist[fd].iflen-1; i >= 0; i--)
+ if (sa.sa_data[i] != socklist[fd].sa.sa_data[i])
+ return(0);
+
+ RDS[0].dataLen = cc;
+ RDS[0].dataPtr = buf;
+ RDS[1].dataLen = 0;
+
+ return(cc);
+}
+
+/*
+ * write a packet
+ *
+ */
+
+int
+pfWrite(fd, buf, len)
+int fd, len;
+u_char *buf;
+{
+
+ if (sendto(fd, buf, len, 0, &socklist[fd].sa, sizeof(struct sockaddr)) == len)
+ return(len);
+
+ return(-1);
+}
+
+/*
+ * Return information to device.c how to open device.
+ * In this case the driver can handle both Ethernet type II and
+ * IEEE 802.3 frames (SNAP) in a single pfOpen.
+ */
+
+int
+pfTrans(interface)
+ char *interface;
+{
+ return TRANS_ETHER+TRANS_8023;
+}
+