- WARNsify

- KNFify (a bit)
- use int32_t & u_int32_t instead of long and u_long
- clean up man pages a bit
This commit is contained in:
lukem
1997-10-16 23:24:50 +00:00
parent 770ac80056
commit 334438cb6a
22 changed files with 293 additions and 424 deletions

View File

@@ -1,4 +1,4 @@
.\" $NetBSD: mopd.8,v 1.2 1997/03/25 03:07:48 thorpej Exp $
.\" $NetBSD: mopd.8,v 1.3 1997/10/16 23:25:16 lukem Exp $
.\"
.\" Copyright (c) 1993-96 Mats O Jansson. All rights reserved.
.\"
@@ -33,25 +33,25 @@
.Nm mopd
.Nd MOP Loader Daemon
.Sh SYNOPSIS
.Nm mopd
.Nm
.Op Fl adf
.Op Ar interface
.Sh DESCRIPTION
.Nm Mopd
.Nm
services MOP Load requests on the Ethernet connected to
.Ar interface
or all interfaces if
.Sq Fl a
is given.
In a load request received by
.Nm mopd
.Nm
a filename can be given. This is the normal case for e.g. terminal servers.
If a filename isn't given
.Nm mopd
.Nm
must know what image to load.
.Pp
Upon receiving a request,
.Nm mopd
.Nm
checks if the requested file exists in
.Pa /tftpboot/mop ,
the filename is normaly uppercase and with an extension of
@@ -61,14 +61,14 @@ filename, e.g.
.Pa 08002b09f4de.SYS
and it might be a soft link to another file.
.Pp
.Nm Mopd
.Nm
supports two kinds of files. The first type that is check is if the file is
in
.Xr a.out 5
format. If not, a couple of Digital's formats are checked.
.Pp
In normal operation,
.Nm mopd
.Nm
forks a copy of itself and runs in
the background. Anomalies and errors are reported via
.Xr syslog 3 .
@@ -85,9 +85,6 @@ the foreground.
.It Fl f
Run in the foreground.
.El
.Sh BUGS
.Xr a.out 5
isn't supported yet non bsd implementations (otherOS).
.Sh FILES
.Bl -tag -width Pa -compact
.It Pa /tftpboot/mop

View File

@@ -1,4 +1,4 @@
/* $NetBSD: mopd.c,v 1.4 1997/04/17 21:09:19 christos Exp $ */
/* $NetBSD: mopd.c,v 1.5 1997/10/16 23:25:17 lukem Exp $ */
/*
* Copyright (c) 1993-96 Mats O Jansson. All rights reserved.
@@ -29,8 +29,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LINT
static char rcsid[] = "$NetBSD: mopd.c,v 1.4 1997/04/17 21:09:19 christos Exp $";
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: mopd.c,v 1.5 1997/10/16 23:25:17 lukem Exp $");
#endif
/*
@@ -41,16 +42,16 @@ static char rcsid[] = "$NetBSD: mopd.c,v 1.4 1997/04/17 21:09:19 christos Exp $"
*/
#include "os.h"
#include "common/common.h"
#include "common/mopdef.h"
#include "common/device.h"
#include "common/print.h"
#include "common/pf.h"
#include "common/cmp.h"
#include "common/get.h"
#include "common/dl.h"
#include "common/rc.h"
#include "cmp.h"
#include "common.h"
#include "device.h"
#include "dl.h"
#include "get.h"
#include "mopdef.h"
#include "pf.h"
#include "print.h"
#include "process.h"
#include "rc.h"
/*
* The list of all interfaces that are being listened to.
@@ -58,15 +59,9 @@ static char rcsid[] = "$NetBSD: mopd.c,v 1.4 1997/04/17 21:09:19 christos Exp $"
*/
struct if_info *iflist;
#ifdef NO__P
void Loop (/* void */);
void Usage (/* void */);
void mopProcess (/* struct if_info *, u_char * */);
#else
void Loop __P((void));
void Usage __P((void));
void mopProcess __P((struct if_info *, u_char *));
#endif
void Usage __P((void));
int main __P((int, char **));
void mopProcess __P((struct if_info *, u_char *));
int AllFlag = 0; /* listen on "all" interfaces */
int DebugFlag = 0; /* print debugging messages */
@@ -75,28 +70,20 @@ int VersionFlag = 0; /* print version */
int Not3Flag = 0; /* Not MOP V3 messages. */
int Not4Flag = 0; /* Not MOP V4 messages. */
int promisc = 1; /* Need promisc mode */
char *Program;
void
extern char *__progname; /* from crt0.o */
int
main(argc, argv)
int argc;
char **argv;
{
int c, pid, devnull, f;
int c, pid;
char *interface;
extern int optind;
extern char version[];
if ((Program = strrchr(argv[0], '/')))
Program++;
else
Program = argv[0];
if (*Program == '-')
Program++;
while ((c = getopt(argc, argv, "34adfv")) != EOF)
while ((c = getopt(argc, argv, "34adfv")) != -1)
switch (c) {
case '3':
Not3Flag++;
@@ -122,7 +109,7 @@ main(argc, argv)
}
if (VersionFlag) {
fprintf(stdout,"%s: version %s\n", Program, version);
fprintf(stdout,"%s: version %s\n", __progname, version);
exit(0);
}
@@ -135,16 +122,13 @@ main(argc, argv)
Usage();
/* All error reporting is done through syslogs. */
openlog(Program, LOG_PID | LOG_CONS, LOG_DAEMON);
openlog(__progname, LOG_PID | LOG_CONS, LOG_DAEMON);
if ((!ForegroundFlag) && DebugFlag) {
if ((!ForegroundFlag) && DebugFlag)
fprintf(stdout,
"%s: not running as daemon, -d given.\n",
Program);
}
"%s: not running as daemon, -d given.\n", __progname);
if ((!ForegroundFlag) && (!DebugFlag)) {
pid = fork();
if (pid > 0)
/* Parent exits, leaving child in background. */
@@ -156,32 +140,10 @@ main(argc, argv)
}
/* Fade into the background */
f = open("/dev/tty", O_RDWR);
if (f >= 0) {
if (ioctl(f, TIOCNOTTY, 0) < 0) {
syslog(LOG_ERR, "TIOCNOTTY: %m");
exit(0);
}
(void) close(f);
}
(void) chdir("/");
#ifdef SETPGRP_NOPARAM
(void) setpgrp();
#else
(void) setpgrp(0, getpid());
#endif
devnull = open("/dev/null", O_RDWR);
if (devnull >= 0) {
(void) dup2(devnull, 0);
(void) dup2(devnull, 1);
(void) dup2(devnull, 2);
if (devnull > 2)
(void) close(devnull);
}
daemon(0, 0);
}
syslog(LOG_INFO, "%s %s started.", Program, version);
syslog(LOG_INFO, "%s %s started.", __progname, version);
if (AllFlag)
deviceInitAll();
@@ -189,13 +151,17 @@ main(argc, argv)
deviceInitOne(interface);
Loop();
/* NOTREACHED */
return (0);
}
void
Usage()
{
(void) fprintf(stderr, "usage: %s -a [ -d -f -v ] [ -3 | -4 ]\n",Program);
(void) fprintf(stderr, " %s [ -d -f -v ] [ -3 | -4 ] interface\n",Program);
(void) fprintf(stderr, "usage: %s -a [ -d -f -v ] [ -3 | -4 ]\n",
__progname);
(void) fprintf(stderr, " %s [ -d -f -v ] [ -3 | -4 ] interface\n",
__progname);
exit(1);
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: process.c,v 1.4 1997/04/17 21:09:21 christos Exp $ */
/* $NetBSD: process.c,v 1.5 1997/10/16 23:25:19 lukem Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -29,22 +29,23 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LINT
static char rcsid[] = "$NetBSD: process.c,v 1.4 1997/04/17 21:09:21 christos Exp $";
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: process.c,v 1.5 1997/10/16 23:25:19 lukem Exp $");
#endif
#include "os.h"
#include "common/common.h"
#include "common/mopdef.h"
#include "common/nmadef.h"
#include "common/get.h"
#include "common/put.h"
#include "common/print.h"
#include "common/pf.h"
#include "common/cmp.h"
#include "common/dl.h"
#include "common/rc.h"
#include "common/file.h"
#include "cmp.h"
#include "common.h"
#include "dl.h"
#include "file.h"
#include "get.h"
#include "mopdef.h"
#include "nmadef.h"
#include "pf.h"
#include "print.h"
#include "put.h"
#include "rc.h"
extern u_char buf[];
extern int DebugFlag;
@@ -53,12 +54,22 @@ struct dllist dllist[MAXDL]; /* dump/load list */
extern char dl_mcst[]; /* Dump/Load Multicast */
extern char rc_mcst[]; /* Remote Console Multicast */
void mopNextLoad __P((u_char *, u_char *, u_char, int));
void mopProcessDL __P((FILE *, struct if_info *, u_char *, int *,
u_char *, u_char *, int, u_short));
void mopProcessRC __P((FILE *, struct if_info *, u_char *, int *,
u_char *, u_char *, int, u_short));
void mopProcessInfo __P((u_char *, int *, u_short, struct dllist *, int));
void mopSendASV __P((u_char *, u_char *, struct if_info *, int));
void mopStartLoad __P((u_char *, u_char *, struct dllist *, int));
void
mopProcessInfo(pkt,index,moplen,dl_rpr,trans)
mopProcessInfo(pkt, index, moplen, dl_rpr, trans)
u_char *pkt;
int *index, trans;
int *index;
u_short moplen;
struct dllist *dl_rpr;
int trans;
{
u_short itype,tmps;
u_char ilen ,tmpc,device;
@@ -235,8 +246,8 @@ mopStartLoad(dst, src, dl_rpr, trans)
if (dllist[i].status == DL_STATUS_FREE) {
if (slot == -1) {
slot = i;
bcopy((char *)dst,
(char *)dllist[i].eaddr, 6);
memmove((char *)dst,
(char *)dllist[i].eaddr, 6);
}
}
}
@@ -432,8 +443,10 @@ void
mopProcessDL(fd, ii, pkt, index, dst, src, trans, len)
FILE *fd;
struct if_info *ii;
u_char *pkt, *dst, *src;
int *index, trans;
u_char *pkt;
int *index;
u_char *dst, *src;
int trans;
u_short len;
{
u_char tmpc;
@@ -508,9 +521,9 @@ mopProcessDL(fd, ii, pkt, index, dst, src, trans, len)
iindex = *index;
dl_rpr = &dl;
bzero(dl_rpr,sizeof(*dl_rpr));
memset(dl_rpr, 0, sizeof(*dl_rpr));
dl_rpr->ii = ii;
bcopy((char *)src, (char *)(dl_rpr->eaddr), 6);
memmove((char *)(dl_rpr->eaddr), (char *)src, 6);
mopProcessInfo(pkt,index,moplen,dl_rpr,trans);
sprintf(filename,"%s/%s.SYS", MOP_FILE_PATH, pfile);
@@ -570,8 +583,10 @@ void
mopProcessRC(fd, ii, pkt, index, dst, src, trans, len)
FILE *fd;
struct if_info *ii;
u_char *pkt, *dst, *src;
int *index, trans;
u_char *pkt;
int *index;
u_char *dst, *src;
int trans;
u_short len;
{
u_char tmpc;
@@ -614,9 +629,9 @@ mopProcessRC(fd, ii, pkt, index, dst, src, trans, len)
}
dl_rpr = &dl;
bzero(dl_rpr,sizeof(*dl_rpr));
memset(dl_rpr, 0, sizeof(*dl_rpr));
dl_rpr->ii = ii;
bcopy((char *)src, (char *)(dl_rpr->eaddr), 6);
memmove((char *)(dl_rpr->eaddr), (char *)src, 6);
mopProcessInfo(pkt,index,moplen,dl_rpr,trans);
break;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: process.h,v 1.2 1997/03/25 03:07:52 thorpej Exp $ */
/* $NetBSD: process.h,v 1.3 1997/10/16 23:25:21 lukem Exp $ */
/*
* Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
@@ -28,25 +28,18 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $NetBSD: process.h,v 1.2 1997/03/25 03:07:52 thorpej Exp $
* $NetBSD: process.h,v 1.3 1997/10/16 23:25:21 lukem Exp $
*
*/
#ifndef _PROCESS_H_
#define _PROCESS_H_
#ifdef NO__P
void mopProcessDL (/* FILE *, struct if_info *, u_char *, int *,
u_char *, u_char *, int, u_short */);
void mopProcessRC (/* FILE *, struct if_info *, u_char *, int *,
u_char *, u_char *, int, u_short */);
#else
__BEGIN_DECLS
void mopProcessDL __P((FILE *, struct if_info *, u_char *, int *,
u_char *, u_char *, int, u_short));
void mopProcessRC __P((FILE *, struct if_info *, u_char *, int *,
u_char *, u_char *, int, u_short));
__END_DECLS
#endif
#endif _PROCESS_H_