diff options
Diffstat (limited to 'libexec/bootpd/tools/bootptest')
-rw-r--r-- | libexec/bootpd/tools/bootptest/bootptest.c | 28 | ||||
-rw-r--r-- | libexec/bootpd/tools/bootptest/print-bootp.c | 15 |
2 files changed, 30 insertions, 13 deletions
diff --git a/libexec/bootpd/tools/bootptest/bootptest.c b/libexec/bootpd/tools/bootptest/bootptest.c index bc235ac..c4e38d4 100644 --- a/libexec/bootpd/tools/bootptest/bootptest.c +++ b/libexec/bootpd/tools/bootptest/bootptest.c @@ -40,11 +40,16 @@ char *usage = "bootptest [-h] server-name [vendor-data-template-file]"; #include <sys/file.h> #include <sys/time.h> #include <sys/stat.h> +#include <sys/utsname.h> #include <net/if.h> #include <netinet/in.h> #include <arpa/inet.h> /* inet_ntoa */ +#ifndef NO_UNISTD +#include <unistd.h> +#endif + #include <stdlib.h> #include <signal.h> #include <stdio.h> @@ -57,8 +62,12 @@ char *usage = "bootptest [-h] server-name [vendor-data-template-file]"; #include "bootp.h" #include "bootptest.h" #include "getif.h" +#include "getether.h" + #include "patchlevel.h" +static void send_request(); + #define LOG_ERR 1 #define BUFLEN 1024 #define WAITSECS 1 @@ -94,10 +103,12 @@ u_char eaddr[16]; /* Ethernet address */ */ int debug = 1; /* Debugging flag (level) */ -char hostname[64]; char *sndbuf; /* Send packet buffer */ char *rcvbuf; /* Receive packet buffer */ +struct utsname my_uname; +char *hostname; + /* * Vendor magic cookies for CMU and RFC1048 */ @@ -114,6 +125,7 @@ extern void bootp_print(); * the receiver loop is started. Die when interrupted. */ +void main(argc, argv) int argc; char **argv; @@ -127,7 +139,7 @@ main(argc, argv) char *bp_file = NULL; int32 server_addr; /* inet addr, network order */ int s; /* Socket file descriptor */ - int n, tolen, fromlen, recvcnt; + int n, fromlen, recvcnt; int use_hwa = 0; int32 vend_magic; int32 xid; @@ -149,6 +161,12 @@ main(argc, argv) */ assert(sizeof(struct bootp) == BP_MINPKTSZ); + if (uname(&my_uname) < 0) { + fprintf(stderr, "%s: can't get hostname\n", argv[0]); + exit(1); + } + hostname = my_uname.nodename; + sndbuf = malloc(BUFLEN); rcvbuf = malloc(BUFLEN); if (!sndbuf || !rcvbuf) { @@ -302,7 +320,7 @@ main(argc, argv) printf("No interface for %s\n", servername); exit(1); } - if (getether(ifr->ifr_name, eaddr)) { + if (getether(ifr->ifr_name, (char*)eaddr)) { printf("Can not get ether addr for %s\n", ifr->ifr_name); exit(1); } @@ -312,7 +330,6 @@ main(argc, argv) bcopy(eaddr, bp->bp_chaddr, bp->bp_hlen); } else { /* Fill in the client IP address. */ - gethostname(hostname, sizeof(hostname)); hep = gethostbyname(hostname); if (!hep) { printf("Can not get my IP address\n"); @@ -422,6 +439,7 @@ main(argc, argv) exit(1); } +static void send_request(s) int s; { @@ -451,7 +469,7 @@ printfn(s, ep) register u_char c; putchar('"'); - while (c = *s++) { + while ((c = *s++) != '\0') { if (s > ep) { putchar('"'); return (1); diff --git a/libexec/bootpd/tools/bootptest/print-bootp.c b/libexec/bootpd/tools/bootptest/print-bootp.c index f416998..ff31670 100644 --- a/libexec/bootpd/tools/bootptest/print-bootp.c +++ b/libexec/bootpd/tools/bootptest/print-bootp.c @@ -23,18 +23,19 @@ * This file was copied from tcpdump-2.1.1 and modified. * There is an e-mail list for tcpdump: <tcpdump@ee.lbl.gov> */ -#ifndef lint -static char rcsid[] = "$Id: print-bootp.c,v 1.1.1.1 1994/09/10 14:44:55 csgr Exp $"; -/* 93/10/10 <gwr@mc.com> New data-driven option print routine. */ -#endif #include <stdio.h> #include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> + +#ifdef _AIX32 +#include <sys/time.h> /* for struct timeval in net/if.h */ +#endif #include <net/if.h> #include <netinet/in.h> + #include <string.h> #include <ctype.h> @@ -42,6 +43,7 @@ static char rcsid[] = "$Id: print-bootp.c,v 1.1.1.1 1994/09/10 14:44:55 csgr Exp #include "bootptest.h" /* These decode the vendor data. */ +extern int printfn(); static void rfc1048_print(); static void cmu_print(); static void other_print(); @@ -271,8 +273,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 +280,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 +433,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; |