This commit is contained in:
lukem 1998-03-14 04:39:53 +00:00
parent 2b0e1bd9bd
commit 9493bb7939
42 changed files with 352 additions and 100 deletions

View File

@ -1,7 +1,6 @@
# bootpd/Makefile
# $NetBSD: Makefile,v 1.4 1997/10/25 06:57:55 lukem Exp $
# $NetBSD: Makefile,v 1.5 1998/03/14 04:39:53 lukem Exp $
WARNS?= 0
PROG= bootpd
CPPFLAGS+= -DETC_ETHERS -DSYSLOG -DDEBUG -DVEND_CMU

View File

@ -20,8 +20,9 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: bootpd.c,v 1.7 1997/10/18 04:36:55 lukem Exp $";
__RCSID("$NetBSD: bootpd.c,v 1.8 1998/03/14 04:39:53 lukem Exp $");
#endif
/*
@ -126,6 +127,7 @@ PRIVATE void handle_reply P((void));
PRIVATE void handle_request P((void));
PRIVATE void sendreply P((int forward, int32 dest_override));
PRIVATE void usage P((void));
int main P((int, char **));
#undef P
@ -911,7 +913,9 @@ HW addr type is IEEE 802. convert to %s and check again\n",
if (debug > 2)
report(LOG_INFO, "bootfile=\"%s\"", clntpath);
#ifdef CHECK_FILE_ACCESS
null_file_name:
#endif /* CHECK_FILE_ACCESS */
/*
@ -1206,7 +1210,6 @@ dovend_rfc1048(bp, hp, bootsize)
{
int bytesleft, len;
byte *vp;
char *tmpstr;
static char noroom[] = "%s: No room for \"%s\" option";

View File

@ -20,8 +20,9 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: bootpef.c,v 1.3 1997/10/18 04:36:56 lukem Exp $";
__RCSID("$NetBSD: bootpef.c,v 1.4 1998/03/14 04:39:53 lukem Exp $");
#endif
@ -97,9 +98,9 @@ static char rcsid[] = "$NetBSD: bootpef.c,v 1.3 1997/10/18 04:36:56 lukem Exp $"
#define P(args) ()
#endif
static void dovend_rfc1048 P((struct bootp *, struct host *, int32));
static void mktagfile P((struct host *));
static void usage P((void));
int main P((int, char **));
#undef P
@ -139,7 +140,7 @@ usage()
* Initialization such as command-line processing is done and then the
* main server loop is started.
*/
void
int
main(argc, argv)
int argc;
char **argv;
@ -275,6 +276,7 @@ main(argc, argv)
mktagfile(hp);
hp = (struct host *) hash_NextEntry(nmhashtable);
}
exit(0);
}
@ -291,7 +293,6 @@ mktagfile(hp)
FILE *fp;
int bytesleft, len;
byte *vp;
char *tmpstr;
if (!hp->flags.exten_file)
return;
@ -332,7 +333,7 @@ mktagfile(hp)
}
fclose(fp);
} /* dovend_rfc1048 */
} /* mktagfile */
/*
* Local Variables:

View File

@ -25,8 +25,9 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: bootpgw.c,v 1.6 1997/10/18 04:36:58 lukem Exp $";
__RCSID("$NetBSD: bootpgw.c,v 1.7 1998/03/14 04:39:53 lukem Exp $");
#endif
/*
@ -98,6 +99,7 @@ static char rcsid[] = "$NetBSD: bootpgw.c,v 1.6 1997/10/18 04:36:58 lukem Exp $"
static void usage P((void));
static void handle_reply P((void));
static void handle_request P((void));
int main P((int, char **));
#undef P
@ -513,7 +515,9 @@ static void
handle_request()
{
struct bootp *bp = (struct bootp *) pktbuf;
#if 0
struct ifreq *ifr;
#endif
u_short secs, hops;
/* XXX - SLIP init: Set bp_ciaddr = clnt_addr here? */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bootptest.c,v 1.4 1998/01/09 08:09:03 perry Exp $ */
/* $NetBSD: bootptest.c,v 1.5 1998/03/14 04:39:53 lukem Exp $ */
/*
* bootptest.c - Test out a bootp server.
@ -34,6 +34,11 @@
* 09/93 Original developed by Gordon W. Ross <gwr@mc.com>
*/
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: bootptest.c,v 1.5 1998/03/14 04:39:53 lukem Exp $");
#endif
char *usage = "bootptest [-h] server-name [vendor-data-template-file]";
#include <sys/types.h>
@ -55,10 +60,12 @@ char *usage = "bootptest [-h] server-name [vendor-data-template-file]";
#include <ctype.h>
#include <netdb.h>
#include <assert.h>
#include <unistd.h>
#include "bootp.h"
#include "bootptest.h"
#include "getif.h"
#include "report.h"
#include "patchlevel.h"
#define LOG_ERR 1
@ -108,14 +115,25 @@ unsigned char vm_cmu[4] = VM_CMU;
unsigned char vm_rfc1048[4] = VM_RFC1048;
short secs; /* How long client has waited */
char *get_errmsg();
extern void bootp_print();
#ifdef __STDC__
#define P(args) args
#else
#define P(args) ()
#endif
extern int getether P((char *, char *));
int main P((int, char **));
void send_request P((int));
#undef P
/*
* Initialization such as command-line processing is done, then
* the receiver loop is started. Die when interrupted.
*/
int
main(argc, argv)
int argc;
char **argv;
@ -128,7 +146,7 @@ main(argc, argv)
char *vendor_file = NULL;
char *bp_file = NULL;
int s; /* Socket file descriptor */
int n, tolen, fromlen, recvcnt;
int n, fromlen, recvcnt;
int use_hwa = 0;
int32 vend_magic;
int32 xid;
@ -408,7 +426,7 @@ main(argc, argv)
/* set globals needed by bootp_print() */
snaplen = n;
snapend = (unsigned char *) rcvbuf + snaplen;
bootp_print(rcvbuf, n, sin_from.sin_port, 0);
bootp_print((struct bootp *)rcvbuf, n, sin_from.sin_port, 0);
putchar('\n');
/*
* This no longer exits immediately after receiving
@ -421,12 +439,13 @@ main(argc, argv)
exit(1);
}
void
send_request(s)
int s;
{
/* Print the request packet. */
printf("Sending to %s", inet_ntoa(sin_server.sin_addr));
bootp_print(sndbuf, snaplen, sin_from.sin_port, 0);
bootp_print((struct bootp *)sndbuf, snaplen, sin_from.sin_port, 0);
putchar('\n');
/* Send the request packet. */
@ -450,7 +469,7 @@ printfn(s, ep)
register u_char c;
putchar('"');
while (c = *s++) {
while ((c = *s++) != 0) {
if (s > ep) {
putchar('"');
return (1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: bootptest.h,v 1.2 1998/01/09 08:09:04 perry Exp $ */
/* $NetBSD: bootptest.h,v 1.3 1998/03/14 04:39:54 lukem Exp $ */
/* bootptest.h */
/*
@ -27,6 +27,8 @@ extern unsigned char *snapend;
#define P(args) ()
#endif
extern void bootp_print P((struct bootp *, int, u_short, u_short));
extern char *ipaddr_string P((struct in_addr *));
extern int printfn P((u_char *, u_char *));
#undef P

View File

@ -1,4 +1,9 @@
/* $NetBSD: getether.c,v 1.2 1998/01/09 08:09:08 perry Exp $ */
/* $NetBSD: getether.c,v 1.3 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: getether.c,v 1.3 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* getether.c : get the ethernet address of an interface
@ -14,11 +19,23 @@
#include <sys/socket.h>
#include <ctype.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include "report.h"
#define EALEN 6
#ifdef __STDC__
#define P(args) args
#else
#define P(args) ()
#endif
extern int getether P((char *, char *));
#undef P
#if defined(ultrix) || (defined(__osf__) && defined(__alpha))
/*
* This is really easy on Ultrix! Thanks to
@ -32,6 +49,7 @@
#include <sys/ioctl.h>
#include <net/if.h> /* struct ifdevea */
int
getether(ifname, eap)
char *ifname, *eap;
{
@ -110,13 +128,14 @@ getether(ifname, eap)
#include <net/if_dl.h>
#include <net/if_types.h>
int
getether(ifname, eap)
char *ifname; /* interface name from ifconfig structure */
char *eap; /* Ether address (output) */
{
int fd, rc = -1;
register int n;
struct ifreq ibuf[16], ifr;
struct ifreq ibuf[16];
struct ifconf ifc;
register struct ifreq *ifrp, *ifend;

View File

@ -23,8 +23,10 @@
* This file was copied from tcpdump-2.1.1 and modified.
* There is an e-mail list for tcpdump: <tcpdump@ee.lbl.gov>
*/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: print-bootp.c,v 1.3 1997/10/18 04:37:03 lukem Exp $";
__RCSID("$NetBSD: print-bootp.c,v 1.4 1998/03/14 04:39:54 lukem Exp $");
/* 93/10/10 <gwr@mc.com> New data-driven option print routine. */
#endif
@ -41,11 +43,19 @@ static char rcsid[] = "$NetBSD: print-bootp.c,v 1.3 1997/10/18 04:37:03 lukem Ex
#include "bootp.h"
#include "bootptest.h"
#ifdef __STDC__
#define P(args) args
#else
#define P(args) ()
#endif
/* These decode the vendor data. */
static void rfc1048_print();
static void cmu_print();
static void other_print();
static void dump_hex();
static void cmu_print P((u_char *, int));
static void dump_hex P((u_char *, int));
static void other_print P((u_char *, int));
static void rfc1048_print P((u_char *, int));
#undef P
/*
* Print bootp requests
@ -271,8 +281,6 @@ rfc1048_opts[] = {
};
#define KNOWN_OPTIONS (sizeof(rfc1048_opts) / sizeof(rfc1048_opts[0]))
static void print_string();
static void
rfc1048_print(bp, length)
register u_char *bp;
@ -280,7 +288,7 @@ rfc1048_print(bp, length)
{
u_char tag;
u_char *ep;
register int len, j;
register int len;
u_int32 ul;
u_short us;
struct in_addr ia;
@ -433,7 +441,6 @@ other_print(bp, length)
{
u_char *ep; /* end pointer */
u_char *zp; /* points one past last non-zero byte */
register int i, j;
/* Setup end pointer */
ep = bp + length;

View File

@ -1,4 +1,9 @@
/* $NetBSD: trygetea.c,v 1.2 1998/01/09 08:09:16 perry Exp $ */
/* $NetBSD: trygetea.c,v 1.3 1998/03/14 04:39:55 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: trygetea.c,v 1.3 1998/03/14 04:39:55 lukem Exp $");
#endif
/*
* trygetea.c - test program for getether.c

View File

@ -1,4 +1,9 @@
/* $NetBSD: dovend.c,v 1.2 1998/01/09 08:09:06 perry Exp $ */
/* $NetBSD: dovend.c,v 1.3 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: dovend.c,v 1.3 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* dovend.c : Inserts all but the first few vendor options.
@ -58,7 +63,9 @@ dovend_rfc1497(hp, buf, len)
{
int bytesleft = len;
byte *vp = buf;
#if 0
char *tmpstr;
#endif
static char noroom[] = "%s: No room for \"%s\" option";
#define NEED(LEN, MSG) do \

View File

@ -1,4 +1,9 @@
/* $NetBSD: dumptab.c,v 1.4 1998/01/09 08:09:07 perry Exp $ */
/* $NetBSD: dumptab.c,v 1.5 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: dumptab.c,v 1.5 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* dumptab.c - handles dumping the database
@ -37,6 +42,7 @@
static void dump_generic P((FILE *, struct shared_bindata *));
static void dump_host P((FILE *, struct host *));
static void list_ipaddresses P((FILE *, struct in_addr_list *));
void dumptab P((char *));
#undef P
@ -262,7 +268,7 @@ dump_host(fp, hp)
/* NetBSD: domainname (see above) */
/* NetBSD: dumpfile (see above) */
if (hp->flags.time_offset) {
fprintf(fp, "\\\n\t:to=%ld:", hp->time_offset);
fprintf(fp, "\\\n\t:to=%ld:", (long)hp->time_offset);
}
if (hp->flags.time_server) {
fprintf(fp, "\\\n\t:ts=");

View File

@ -1,4 +1,9 @@
/* $NetBSD: getif.c,v 1.3 1998/01/09 08:09:08 perry Exp $ */
/* $NetBSD: getif.c,v 1.4 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: getif.c,v 1.4 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* getif.c : get an interface structure
@ -36,7 +41,15 @@
static struct ifreq ifreq[10]; /* Holds interface configuration */
static struct ifconf ifconf; /* points to ifreq */
static int nmatch();
#ifdef __STDC__
#define P(args) args
#else
#define P(args) ()
#endif
static int nmatch P((u_char *, u_char *));
#undef P
/* Return a pointer to the interface struct for the passed address. */
struct ifreq *
@ -86,7 +99,7 @@ getif(s, addrp)
while (len > 0) {
ifrq = (struct ifreq *) p;
sip = (struct sockaddr_in *) &ifrq->ifr_addr;
m = nmatch(addrp, &(sip->sin_addr));
m = nmatch((u_char *)addrp, (u_char *)&(sip->sin_addr));
if (m > maxmatch) {
maxmatch = m;
ifrmax = ifrq;

View File

@ -20,8 +20,9 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: hash.c,v 1.3 1997/10/18 04:37:01 lukem Exp $";
__RCSID("$NetBSD: hash.c,v 1.4 1998/03/14 04:39:54 lukem Exp $");
#endif

View File

@ -1,4 +1,9 @@
/* $NetBSD: hwaddr.c,v 1.3 1998/01/09 08:09:10 perry Exp $ */
/* $NetBSD: hwaddr.c,v 1.4 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: hwaddr.c,v 1.4 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* hwaddr.c - routines that deal with hardware addresses.
@ -22,10 +27,12 @@
#include <net/if_arp.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef NO_UNISTD
#include <unistd.h>
#endif
#include <syslog.h>
#include <arpa/inet.h>
#ifndef USE_BFUNCS
/* Yes, memcpy is OK here (no overlapped copies). */
@ -132,7 +139,6 @@ setarp(s, ia, ha, len)
int status;
char buf[256];
char *a;
extern char *inet_ntoa();
a = inet_ntoa(*ia);
sprintf(buf, "arp -d %s; arp -s %s %s temp",

View File

@ -1,4 +1,9 @@
/* $NetBSD: lookup.c,v 1.3 1998/01/09 08:09:12 perry Exp $ */
/* $NetBSD: lookup.c,v 1.4 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: lookup.c,v 1.4 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* lookup.c - Lookup IP address, HW address, netmask
@ -12,7 +17,6 @@
#ifdef ETC_ETHERS
#include <net/if_ether.h>
extern int ether_hostton();
#endif
#include <netdb.h>

View File

@ -20,8 +20,9 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: readfile.c,v 1.4 1997/10/18 04:37:05 lukem Exp $";
__RCSID("$NetBSD: readfile.c,v 1.5 1998/03/14 04:39:55 lukem Exp $");
#endif
@ -235,7 +236,6 @@ PRIVATE struct htypename htnamemap[] = {
#define P(args) ()
#endif
extern boolean iplookcmp();
boolean nmcmp P((hash_datum *, hash_datum *));
PRIVATE void

View File

@ -1,4 +1,9 @@
/* $NetBSD: report.c,v 1.2 1998/01/09 08:09:15 perry Exp $ */
/* $NetBSD: report.c,v 1.3 1998/03/14 04:39:55 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: report.c,v 1.3 1998/03/14 04:39:55 lukem Exp $");
#endif
/*
* report() - calls syslog
@ -11,6 +16,7 @@
#endif
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include "report.h"
@ -138,7 +144,6 @@ char *
get_errmsg()
{
extern int errno;
extern char *strerror();
return strerror(errno);
}

View File

@ -1,4 +1,9 @@
/* $NetBSD: trygetif.c,v 1.3 1998/01/09 08:09:17 perry Exp $ */
/* $NetBSD: trygetif.c,v 1.4 1998/03/14 04:39:55 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: trygetif.c,v 1.4 1998/03/14 04:39:55 lukem Exp $");
#endif
/*
* trygetif.c - test program for getif.c

View File

@ -1,4 +1,9 @@
/* $NetBSD: trylook.c,v 1.2 1998/01/09 08:09:17 perry Exp $ */
/* $NetBSD: trylook.c,v 1.3 1998/03/14 04:39:55 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: trylook.c,v 1.3 1998/03/14 04:39:55 lukem Exp $");
#endif
/*
* trylook.c - test program for lookup.c

View File

@ -1,4 +1,9 @@
/* $NetBSD: tzone.c,v 1.3 1998/01/09 08:09:18 perry Exp $ */
/* $NetBSD: tzone.c,v 1.4 1998/03/14 04:39:55 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: tzone.c,v 1.4 1998/03/14 04:39:55 lukem Exp $");
#endif
/*
* tzone.c - get the timezone

View File

@ -1,5 +1,15 @@
/* $NetBSD: tzone.h,v 1.2 1998/01/09 08:09:19 perry Exp $ */
/* $NetBSD: tzone.h,v 1.3 1998/03/14 04:39:55 lukem Exp $ */
/* tzone.h */
extern int32 secondswest;
extern void tzone_init();
#ifdef __STDC__
#define P(args) args
#else
#define P(args) ()
#endif
extern void tzone_init P((void));
#undef P

View File

@ -1,7 +1,6 @@
# bootpd/Makefile
# $NetBSD: Makefile,v 1.4 1997/10/25 06:57:55 lukem Exp $
# $NetBSD: Makefile,v 1.5 1998/03/14 04:39:53 lukem Exp $
WARNS?= 0
PROG= bootpd
CPPFLAGS+= -DETC_ETHERS -DSYSLOG -DDEBUG -DVEND_CMU

View File

@ -20,8 +20,9 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: bootpd.c,v 1.7 1997/10/18 04:36:55 lukem Exp $";
__RCSID("$NetBSD: bootpd.c,v 1.8 1998/03/14 04:39:53 lukem Exp $");
#endif
/*
@ -126,6 +127,7 @@ PRIVATE void handle_reply P((void));
PRIVATE void handle_request P((void));
PRIVATE void sendreply P((int forward, int32 dest_override));
PRIVATE void usage P((void));
int main P((int, char **));
#undef P
@ -911,7 +913,9 @@ HW addr type is IEEE 802. convert to %s and check again\n",
if (debug > 2)
report(LOG_INFO, "bootfile=\"%s\"", clntpath);
#ifdef CHECK_FILE_ACCESS
null_file_name:
#endif /* CHECK_FILE_ACCESS */
/*
@ -1206,7 +1210,6 @@ dovend_rfc1048(bp, hp, bootsize)
{
int bytesleft, len;
byte *vp;
char *tmpstr;
static char noroom[] = "%s: No room for \"%s\" option";

View File

@ -20,8 +20,9 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: bootpef.c,v 1.3 1997/10/18 04:36:56 lukem Exp $";
__RCSID("$NetBSD: bootpef.c,v 1.4 1998/03/14 04:39:53 lukem Exp $");
#endif
@ -97,9 +98,9 @@ static char rcsid[] = "$NetBSD: bootpef.c,v 1.3 1997/10/18 04:36:56 lukem Exp $"
#define P(args) ()
#endif
static void dovend_rfc1048 P((struct bootp *, struct host *, int32));
static void mktagfile P((struct host *));
static void usage P((void));
int main P((int, char **));
#undef P
@ -139,7 +140,7 @@ usage()
* Initialization such as command-line processing is done and then the
* main server loop is started.
*/
void
int
main(argc, argv)
int argc;
char **argv;
@ -275,6 +276,7 @@ main(argc, argv)
mktagfile(hp);
hp = (struct host *) hash_NextEntry(nmhashtable);
}
exit(0);
}
@ -291,7 +293,6 @@ mktagfile(hp)
FILE *fp;
int bytesleft, len;
byte *vp;
char *tmpstr;
if (!hp->flags.exten_file)
return;
@ -332,7 +333,7 @@ mktagfile(hp)
}
fclose(fp);
} /* dovend_rfc1048 */
} /* mktagfile */
/*
* Local Variables:

View File

@ -25,8 +25,9 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: bootpgw.c,v 1.6 1997/10/18 04:36:58 lukem Exp $";
__RCSID("$NetBSD: bootpgw.c,v 1.7 1998/03/14 04:39:53 lukem Exp $");
#endif
/*
@ -98,6 +99,7 @@ static char rcsid[] = "$NetBSD: bootpgw.c,v 1.6 1997/10/18 04:36:58 lukem Exp $"
static void usage P((void));
static void handle_reply P((void));
static void handle_request P((void));
int main P((int, char **));
#undef P
@ -513,7 +515,9 @@ static void
handle_request()
{
struct bootp *bp = (struct bootp *) pktbuf;
#if 0
struct ifreq *ifr;
#endif
u_short secs, hops;
/* XXX - SLIP init: Set bp_ciaddr = clnt_addr here? */

View File

@ -1,4 +1,4 @@
/* $NetBSD: bootptest.c,v 1.4 1998/01/09 08:09:03 perry Exp $ */
/* $NetBSD: bootptest.c,v 1.5 1998/03/14 04:39:53 lukem Exp $ */
/*
* bootptest.c - Test out a bootp server.
@ -34,6 +34,11 @@
* 09/93 Original developed by Gordon W. Ross <gwr@mc.com>
*/
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: bootptest.c,v 1.5 1998/03/14 04:39:53 lukem Exp $");
#endif
char *usage = "bootptest [-h] server-name [vendor-data-template-file]";
#include <sys/types.h>
@ -55,10 +60,12 @@ char *usage = "bootptest [-h] server-name [vendor-data-template-file]";
#include <ctype.h>
#include <netdb.h>
#include <assert.h>
#include <unistd.h>
#include "bootp.h"
#include "bootptest.h"
#include "getif.h"
#include "report.h"
#include "patchlevel.h"
#define LOG_ERR 1
@ -108,14 +115,25 @@ unsigned char vm_cmu[4] = VM_CMU;
unsigned char vm_rfc1048[4] = VM_RFC1048;
short secs; /* How long client has waited */
char *get_errmsg();
extern void bootp_print();
#ifdef __STDC__
#define P(args) args
#else
#define P(args) ()
#endif
extern int getether P((char *, char *));
int main P((int, char **));
void send_request P((int));
#undef P
/*
* Initialization such as command-line processing is done, then
* the receiver loop is started. Die when interrupted.
*/
int
main(argc, argv)
int argc;
char **argv;
@ -128,7 +146,7 @@ main(argc, argv)
char *vendor_file = NULL;
char *bp_file = NULL;
int s; /* Socket file descriptor */
int n, tolen, fromlen, recvcnt;
int n, fromlen, recvcnt;
int use_hwa = 0;
int32 vend_magic;
int32 xid;
@ -408,7 +426,7 @@ main(argc, argv)
/* set globals needed by bootp_print() */
snaplen = n;
snapend = (unsigned char *) rcvbuf + snaplen;
bootp_print(rcvbuf, n, sin_from.sin_port, 0);
bootp_print((struct bootp *)rcvbuf, n, sin_from.sin_port, 0);
putchar('\n');
/*
* This no longer exits immediately after receiving
@ -421,12 +439,13 @@ main(argc, argv)
exit(1);
}
void
send_request(s)
int s;
{
/* Print the request packet. */
printf("Sending to %s", inet_ntoa(sin_server.sin_addr));
bootp_print(sndbuf, snaplen, sin_from.sin_port, 0);
bootp_print((struct bootp *)sndbuf, snaplen, sin_from.sin_port, 0);
putchar('\n');
/* Send the request packet. */
@ -450,7 +469,7 @@ printfn(s, ep)
register u_char c;
putchar('"');
while (c = *s++) {
while ((c = *s++) != 0) {
if (s > ep) {
putchar('"');
return (1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: bootptest.h,v 1.2 1998/01/09 08:09:04 perry Exp $ */
/* $NetBSD: bootptest.h,v 1.3 1998/03/14 04:39:54 lukem Exp $ */
/* bootptest.h */
/*
@ -27,6 +27,8 @@ extern unsigned char *snapend;
#define P(args) ()
#endif
extern void bootp_print P((struct bootp *, int, u_short, u_short));
extern char *ipaddr_string P((struct in_addr *));
extern int printfn P((u_char *, u_char *));
#undef P

View File

@ -1,4 +1,9 @@
/* $NetBSD: dovend.c,v 1.2 1998/01/09 08:09:06 perry Exp $ */
/* $NetBSD: dovend.c,v 1.3 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: dovend.c,v 1.3 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* dovend.c : Inserts all but the first few vendor options.
@ -58,7 +63,9 @@ dovend_rfc1497(hp, buf, len)
{
int bytesleft = len;
byte *vp = buf;
#if 0
char *tmpstr;
#endif
static char noroom[] = "%s: No room for \"%s\" option";
#define NEED(LEN, MSG) do \

View File

@ -1,4 +1,9 @@
/* $NetBSD: dumptab.c,v 1.4 1998/01/09 08:09:07 perry Exp $ */
/* $NetBSD: dumptab.c,v 1.5 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: dumptab.c,v 1.5 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* dumptab.c - handles dumping the database
@ -37,6 +42,7 @@
static void dump_generic P((FILE *, struct shared_bindata *));
static void dump_host P((FILE *, struct host *));
static void list_ipaddresses P((FILE *, struct in_addr_list *));
void dumptab P((char *));
#undef P
@ -262,7 +268,7 @@ dump_host(fp, hp)
/* NetBSD: domainname (see above) */
/* NetBSD: dumpfile (see above) */
if (hp->flags.time_offset) {
fprintf(fp, "\\\n\t:to=%ld:", hp->time_offset);
fprintf(fp, "\\\n\t:to=%ld:", (long)hp->time_offset);
}
if (hp->flags.time_server) {
fprintf(fp, "\\\n\t:ts=");

View File

@ -1,4 +1,9 @@
/* $NetBSD: getether.c,v 1.2 1998/01/09 08:09:08 perry Exp $ */
/* $NetBSD: getether.c,v 1.3 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: getether.c,v 1.3 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* getether.c : get the ethernet address of an interface
@ -14,11 +19,23 @@
#include <sys/socket.h>
#include <ctype.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include "report.h"
#define EALEN 6
#ifdef __STDC__
#define P(args) args
#else
#define P(args) ()
#endif
extern int getether P((char *, char *));
#undef P
#if defined(ultrix) || (defined(__osf__) && defined(__alpha))
/*
* This is really easy on Ultrix! Thanks to
@ -32,6 +49,7 @@
#include <sys/ioctl.h>
#include <net/if.h> /* struct ifdevea */
int
getether(ifname, eap)
char *ifname, *eap;
{
@ -110,13 +128,14 @@ getether(ifname, eap)
#include <net/if_dl.h>
#include <net/if_types.h>
int
getether(ifname, eap)
char *ifname; /* interface name from ifconfig structure */
char *eap; /* Ether address (output) */
{
int fd, rc = -1;
register int n;
struct ifreq ibuf[16], ifr;
struct ifreq ibuf[16];
struct ifconf ifc;
register struct ifreq *ifrp, *ifend;

View File

@ -1,4 +1,9 @@
/* $NetBSD: getif.c,v 1.3 1998/01/09 08:09:08 perry Exp $ */
/* $NetBSD: getif.c,v 1.4 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: getif.c,v 1.4 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* getif.c : get an interface structure
@ -36,7 +41,15 @@
static struct ifreq ifreq[10]; /* Holds interface configuration */
static struct ifconf ifconf; /* points to ifreq */
static int nmatch();
#ifdef __STDC__
#define P(args) args
#else
#define P(args) ()
#endif
static int nmatch P((u_char *, u_char *));
#undef P
/* Return a pointer to the interface struct for the passed address. */
struct ifreq *
@ -86,7 +99,7 @@ getif(s, addrp)
while (len > 0) {
ifrq = (struct ifreq *) p;
sip = (struct sockaddr_in *) &ifrq->ifr_addr;
m = nmatch(addrp, &(sip->sin_addr));
m = nmatch((u_char *)addrp, (u_char *)&(sip->sin_addr));
if (m > maxmatch) {
maxmatch = m;
ifrmax = ifrq;

View File

@ -20,8 +20,9 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: hash.c,v 1.3 1997/10/18 04:37:01 lukem Exp $";
__RCSID("$NetBSD: hash.c,v 1.4 1998/03/14 04:39:54 lukem Exp $");
#endif

View File

@ -1,4 +1,9 @@
/* $NetBSD: hwaddr.c,v 1.3 1998/01/09 08:09:10 perry Exp $ */
/* $NetBSD: hwaddr.c,v 1.4 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: hwaddr.c,v 1.4 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* hwaddr.c - routines that deal with hardware addresses.
@ -22,10 +27,12 @@
#include <net/if_arp.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef NO_UNISTD
#include <unistd.h>
#endif
#include <syslog.h>
#include <arpa/inet.h>
#ifndef USE_BFUNCS
/* Yes, memcpy is OK here (no overlapped copies). */
@ -132,7 +139,6 @@ setarp(s, ia, ha, len)
int status;
char buf[256];
char *a;
extern char *inet_ntoa();
a = inet_ntoa(*ia);
sprintf(buf, "arp -d %s; arp -s %s %s temp",

View File

@ -1,4 +1,9 @@
/* $NetBSD: lookup.c,v 1.3 1998/01/09 08:09:12 perry Exp $ */
/* $NetBSD: lookup.c,v 1.4 1998/03/14 04:39:54 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: lookup.c,v 1.4 1998/03/14 04:39:54 lukem Exp $");
#endif
/*
* lookup.c - Lookup IP address, HW address, netmask
@ -12,7 +17,6 @@
#ifdef ETC_ETHERS
#include <net/if_ether.h>
extern int ether_hostton();
#endif
#include <netdb.h>

View File

@ -23,8 +23,10 @@
* This file was copied from tcpdump-2.1.1 and modified.
* There is an e-mail list for tcpdump: <tcpdump@ee.lbl.gov>
*/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: print-bootp.c,v 1.3 1997/10/18 04:37:03 lukem Exp $";
__RCSID("$NetBSD: print-bootp.c,v 1.4 1998/03/14 04:39:54 lukem Exp $");
/* 93/10/10 <gwr@mc.com> New data-driven option print routine. */
#endif
@ -41,11 +43,19 @@ static char rcsid[] = "$NetBSD: print-bootp.c,v 1.3 1997/10/18 04:37:03 lukem Ex
#include "bootp.h"
#include "bootptest.h"
#ifdef __STDC__
#define P(args) args
#else
#define P(args) ()
#endif
/* These decode the vendor data. */
static void rfc1048_print();
static void cmu_print();
static void other_print();
static void dump_hex();
static void cmu_print P((u_char *, int));
static void dump_hex P((u_char *, int));
static void other_print P((u_char *, int));
static void rfc1048_print P((u_char *, int));
#undef P
/*
* Print bootp requests
@ -271,8 +281,6 @@ rfc1048_opts[] = {
};
#define KNOWN_OPTIONS (sizeof(rfc1048_opts) / sizeof(rfc1048_opts[0]))
static void print_string();
static void
rfc1048_print(bp, length)
register u_char *bp;
@ -280,7 +288,7 @@ rfc1048_print(bp, length)
{
u_char tag;
u_char *ep;
register int len, j;
register int len;
u_int32 ul;
u_short us;
struct in_addr ia;
@ -433,7 +441,6 @@ other_print(bp, length)
{
u_char *ep; /* end pointer */
u_char *zp; /* points one past last non-zero byte */
register int i, j;
/* Setup end pointer */
ep = bp + length;

View File

@ -20,8 +20,9 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[] = "$NetBSD: readfile.c,v 1.4 1997/10/18 04:37:05 lukem Exp $";
__RCSID("$NetBSD: readfile.c,v 1.5 1998/03/14 04:39:55 lukem Exp $");
#endif
@ -235,7 +236,6 @@ PRIVATE struct htypename htnamemap[] = {
#define P(args) ()
#endif
extern boolean iplookcmp();
boolean nmcmp P((hash_datum *, hash_datum *));
PRIVATE void

View File

@ -1,4 +1,9 @@
/* $NetBSD: report.c,v 1.2 1998/01/09 08:09:15 perry Exp $ */
/* $NetBSD: report.c,v 1.3 1998/03/14 04:39:55 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: report.c,v 1.3 1998/03/14 04:39:55 lukem Exp $");
#endif
/*
* report() - calls syslog
@ -11,6 +16,7 @@
#endif
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include "report.h"
@ -138,7 +144,6 @@ char *
get_errmsg()
{
extern int errno;
extern char *strerror();
return strerror(errno);
}

View File

@ -1,4 +1,9 @@
/* $NetBSD: trygetea.c,v 1.2 1998/01/09 08:09:16 perry Exp $ */
/* $NetBSD: trygetea.c,v 1.3 1998/03/14 04:39:55 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: trygetea.c,v 1.3 1998/03/14 04:39:55 lukem Exp $");
#endif
/*
* trygetea.c - test program for getether.c

View File

@ -1,4 +1,9 @@
/* $NetBSD: trygetif.c,v 1.3 1998/01/09 08:09:17 perry Exp $ */
/* $NetBSD: trygetif.c,v 1.4 1998/03/14 04:39:55 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: trygetif.c,v 1.4 1998/03/14 04:39:55 lukem Exp $");
#endif
/*
* trygetif.c - test program for getif.c

View File

@ -1,4 +1,9 @@
/* $NetBSD: trylook.c,v 1.2 1998/01/09 08:09:17 perry Exp $ */
/* $NetBSD: trylook.c,v 1.3 1998/03/14 04:39:55 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: trylook.c,v 1.3 1998/03/14 04:39:55 lukem Exp $");
#endif
/*
* trylook.c - test program for lookup.c

View File

@ -1,4 +1,9 @@
/* $NetBSD: tzone.c,v 1.3 1998/01/09 08:09:18 perry Exp $ */
/* $NetBSD: tzone.c,v 1.4 1998/03/14 04:39:55 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: tzone.c,v 1.4 1998/03/14 04:39:55 lukem Exp $");
#endif
/*
* tzone.c - get the timezone

View File

@ -1,5 +1,15 @@
/* $NetBSD: tzone.h,v 1.2 1998/01/09 08:09:19 perry Exp $ */
/* $NetBSD: tzone.h,v 1.3 1998/03/14 04:39:55 lukem Exp $ */
/* tzone.h */
extern int32 secondswest;
extern void tzone_init();
#ifdef __STDC__
#define P(args) args
#else
#define P(args) ()
#endif
extern void tzone_init P((void));
#undef P