home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.unix
- From: gwr@mc.com (Gordon W. Ross)
- Subject: v27i078: bootptest - utility for testing a bootp server, Patch01
- Sender: unix-sources-moderator@gw.home.vix.com
- Approved: vixie@gw.home.vix.com
-
- Submitted-By: gwr@mc.com (Gordon W. Ross)
- Posting-Number: Volume 27, Issue 78
- Archive-Name: bootptest-1.1/patch01
-
- Here is a patch to add Solaris support to the bootptest program.
- Applying this patch makes it version 1.2 (sorry no patchlevel.h).
-
- Gordon W. Ross Mercury Computer Systems
- gwr@mc.com 199 Riverneck Road
- 508-256-1300 Chelmsford, MA 01824-2820
-
- diff -rc bootptest-1.1/Makefile bootptest-1.2/Makefile
- *** bootptest-1.1/Makefile Mon Oct 11 12:26:25 1993
- --- bootptest-1.2/Makefile Thu Oct 14 16:20:21 1993
- ***************
- *** 1,4 ****
- --- 1,8 ----
-
- + # Uncomment these for SVR4 (or Solaris 2.X)
- + # LIBS=-lsocket -lnsl
- + # CC=gcc -traditional
- +
- CFLAGS=-g
-
- all: bootptest vdstd
- ***************
- *** 5,11 ****
-
- OBJS= bootptest.o print-bootp.o util.o
- bootptest: $(OBJS)
- ! $(CC) -o $@ $(OBJS)
-
- $(OBJS) : interface.h bootp.h
-
- --- 9,15 ----
-
- OBJS= bootptest.o print-bootp.o util.o
- bootptest: $(OBJS)
- ! $(CC) -o $@ $(OBJS) $(LIBS)
-
- $(OBJS) : interface.h bootp.h
-
- diff -rc bootptest-1.1/bootptest.c bootptest-1.2/bootptest.c
- *** bootptest-1.1/bootptest.c Fri Oct 8 17:59:13 1993
- --- bootptest-1.2/bootptest.c Thu Oct 14 16:18:00 1993
- ***************
- *** 18,26 ****
- #endif
- #include <netinet/in.h>
- #include <netinet/if_ether.h>
- #include <signal.h>
- #include <stdio.h>
- ! #include <strings.h>
- #include <errno.h>
- #include <ctype.h>
- #include <netdb.h>
- --- 18,27 ----
- #endif
- #include <netinet/in.h>
- #include <netinet/if_ether.h>
- + #include <stdlib.h>
- #include <signal.h>
- #include <stdio.h>
- ! #include <string.h>
- #include <errno.h>
- #include <ctype.h>
- #include <netdb.h>
- ***************
- *** 70,76 ****
- int debug = 0; /* Debugging flag (level) */
- int s; /* Socket file descriptor */
- char hostname[64];
- ! unsigned char buf[BUFLEN]; /* Receive packet buffer */
- struct timezone tzp; /* Time zone offset for clients */
- struct timeval tp; /* Time (extra baggage) */
- long secondswest; /* Time zone offset in seconds */
- --- 71,77 ----
- int debug = 0; /* Debugging flag (level) */
- int s; /* Socket file descriptor */
- char hostname[64];
- ! unsigned char *buf; /* Receive packet buffer */
- struct timezone tzp; /* Time zone offset for clients */
- struct timeval tp; /* Time (extra baggage) */
- long secondswest; /* Time zone offset in seconds */
- ***************
- *** 97,103 ****
- char **argv;
- {
- struct timeval timenow;
- ! struct bootp *bp = (struct bootp *) buf;
- struct servent *sep;
- struct hostent *hep;
-
- --- 98,104 ----
- char **argv;
- {
- struct timeval timenow;
- ! struct bootp *bp;
- struct servent *sep;
- struct hostent *hep;
-
- ***************
- *** 108,114 ****
- long server_addr = INADDR_ANY;
-
- program_name = argv[0];
- !
- /* Get my Ethernet address for the query. */
- gethostname(hostname, sizeof(hostname));
- if (ether_hostton(hostname, &eaddr)) {
- --- 109,120 ----
- long server_addr = INADDR_ANY;
-
- program_name = argv[0];
- ! buf = malloc(BUFLEN);
- ! if (!buf) {
- ! printf("malloc failed\n");
- ! exit(1);
- ! }
- !
- /* Get my Ethernet address for the query. */
- gethostname(hostname, sizeof(hostname));
- if (ether_hostton(hostname, &eaddr)) {
- ***************
- *** 166,172 ****
- if (servername) {
- hep = gethostbyname(servername);
- if (!hep) {
- ! report(LOG_ERR, "gethostbyname(%s)", servername);
- exit(1);
- }
- bcopy(hep->h_addr, &sin_server.sin_addr, sizeof(struct in_addr));
- --- 172,178 ----
- if (servername) {
- hep = gethostbyname(servername);
- if (!hep) {
- ! report(LOG_ERR, "gethostbyname(%s)\n", servername);
- exit(1);
- }
- bcopy(hep->h_addr, &sin_server.sin_addr, sizeof(struct in_addr));
- ***************
- *** 210,215 ****
- --- 216,222 ----
- /*
- * Build a request.
- */
- + bp = (struct bootp *) buf;
- bzero(bp, sizeof(*bp));
- bp->bp_op = BOOTREQUEST;
- bp->bp_htype = 1;
- ***************
- *** 275,281 ****
- while (1) {
-
- fromlen = sizeof(sin_from);
- ! n = recvfrom(s, buf, sizeof(buf), 0, &sin_from, &fromlen);
- if (n <= 0) {
- continue;
- }
- --- 282,288 ----
- while (1) {
-
- fromlen = sizeof(sin_from);
- ! n = recvfrom(s, buf, BUFLEN, 0, &sin_from, &fromlen);
- if (n <= 0) {
- continue;
- }
- diff -rc bootptest-1.1/interface.h bootptest-1.2/interface.h
- *** bootptest-1.1/interface.h Thu Jun 10 14:20:14 1993
- --- bootptest-1.2/interface.h Wed Oct 13 18:05:03 1993
- ***************
- *** 16,28 ****
-
- #define inline /*sorry*/
-
- ! #define getname(p) inet_ntoa(p)
- ! #define etheraddr_string(p) ether_ntoa(p)
-
- /* We do not really have both Ethernet addresses. */
- #define ESRC(p) (p)
- #define EDST(p) (p)
-
- extern int vflag, tflag;
- extern int thiszone;
-
- --- 16,35 ----
-
- #define inline /*sorry*/
-
- ! #define getname inet_ntoa
- ! #define etheraddr_string ether_ntoa
-
- /* We do not really have both Ethernet addresses. */
- #define ESRC(p) (p)
- #define EDST(p) (p)
-
- + /* Use str functions */
- + #define bcopy(a,b,c) memcpy(b,a,c)
- + #define bzero(p,l) memset(p,0,l)
- + #define bcmp(a,b,c) memcmp(a,b,c)
- + #define index strchr
- + #define rindex strrchr
- +
- extern int vflag, tflag;
- extern int thiszone;
-
- ***************
- *** 33,37 ****
- /* global pointers to beginning and end of current packet (during printing) */
- extern unsigned char *packetp;
- extern unsigned char *snapend;
- -
- - extern char *malloc();
- --- 40,42 ----
- diff -rc bootptest-1.1/print-bootp.c bootptest-1.2/print-bootp.c
- *** bootptest-1.1/print-bootp.c Fri Oct 8 17:47:41 1993
- --- bootptest-1.2/print-bootp.c Wed Oct 13 17:54:31 1993
- ***************
- *** 33,39 ****
- #include <net/if.h>
- #include <netinet/in.h>
- #include <netinet/if_ether.h>
- ! #include <strings.h>
- #include <ctype.h>
-
- #include "interface.h"
- --- 33,39 ----
- #include <net/if.h>
- #include <netinet/in.h>
- #include <netinet/if_ether.h>
- ! #include <string.h>
- #include <ctype.h>
-
- #include "interface.h"
- diff -rc bootptest-1.1/util.c bootptest-1.2/util.c
- *** bootptest-1.1/util.c Fri Oct 9 18:50:09 1992
- --- bootptest-1.2/util.c Wed Oct 13 18:00:03 1993
- ***************
- *** 32,38 ****
- #include <sys/time.h>
- #include <ctype.h>
- #include <varargs.h>
- ! #include <sys/file.h>
- #include <sys/stat.h>
-
- #include "interface.h"
- --- 32,38 ----
- #include <sys/time.h>
- #include <ctype.h>
- #include <varargs.h>
- ! #include <sys/fcntl.h>
- #include <sys/stat.h>
-
- #include "interface.h"
-