home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume27 / bootptest-1.1 / patch01 < prev    next >
Text File  |  1993-10-19  |  7KB  |  261 lines

  1. Newsgroups: comp.sources.unix
  2. From: gwr@mc.com (Gordon W. Ross)
  3. Subject: v27i078: bootptest - utility for testing a bootp server, Patch01
  4. Sender: unix-sources-moderator@gw.home.vix.com
  5. Approved: vixie@gw.home.vix.com
  6.  
  7. Submitted-By: gwr@mc.com (Gordon W. Ross)
  8. Posting-Number: Volume 27, Issue 78
  9. Archive-Name: bootptest-1.1/patch01
  10.  
  11. Here is a patch to add Solaris support to the bootptest program.
  12. Applying this patch makes it version 1.2 (sorry no patchlevel.h).
  13.  
  14. Gordon W. Ross          Mercury Computer Systems
  15. gwr@mc.com              199 Riverneck Road
  16. 508-256-1300            Chelmsford, MA 01824-2820
  17.  
  18. diff -rc bootptest-1.1/Makefile bootptest-1.2/Makefile
  19. *** bootptest-1.1/Makefile    Mon Oct 11 12:26:25 1993
  20. --- bootptest-1.2/Makefile    Thu Oct 14 16:20:21 1993
  21. ***************
  22. *** 1,4 ****
  23. --- 1,8 ----
  24.   
  25. + # Uncomment these for SVR4 (or Solaris 2.X)
  26. + # LIBS=-lsocket -lnsl
  27. + # CC=gcc -traditional
  28.   CFLAGS=-g
  29.   
  30.   all: bootptest vdstd
  31. ***************
  32. *** 5,11 ****
  33.   
  34.   OBJS= bootptest.o print-bootp.o util.o
  35.   bootptest: $(OBJS)
  36. !     $(CC) -o $@ $(OBJS)
  37.   
  38.   $(OBJS) : interface.h bootp.h
  39.   
  40. --- 9,15 ----
  41.   
  42.   OBJS= bootptest.o print-bootp.o util.o
  43.   bootptest: $(OBJS)
  44. !     $(CC) -o $@ $(OBJS) $(LIBS)
  45.   
  46.   $(OBJS) : interface.h bootp.h
  47.   
  48. diff -rc bootptest-1.1/bootptest.c bootptest-1.2/bootptest.c
  49. *** bootptest-1.1/bootptest.c    Fri Oct  8 17:59:13 1993
  50. --- bootptest-1.2/bootptest.c    Thu Oct 14 16:18:00 1993
  51. ***************
  52. *** 18,26 ****
  53.   #endif
  54.   #include <netinet/in.h>
  55.   #include <netinet/if_ether.h>
  56.   #include <signal.h>
  57.   #include <stdio.h>
  58. ! #include <strings.h>
  59.   #include <errno.h>
  60.   #include <ctype.h>
  61.   #include <netdb.h>
  62. --- 18,27 ----
  63.   #endif
  64.   #include <netinet/in.h>
  65.   #include <netinet/if_ether.h>
  66. + #include <stdlib.h>
  67.   #include <signal.h>
  68.   #include <stdio.h>
  69. ! #include <string.h>
  70.   #include <errno.h>
  71.   #include <ctype.h>
  72.   #include <netdb.h>
  73. ***************
  74. *** 70,76 ****
  75.   int debug = 0;                /* Debugging flag (level) */
  76.   int s;                    /* Socket file descriptor */
  77.   char hostname[64];
  78. ! unsigned char buf[BUFLEN];        /* Receive packet buffer */
  79.   struct timezone tzp;            /* Time zone offset for clients */
  80.   struct timeval tp;            /* Time (extra baggage) */
  81.   long secondswest;            /* Time zone offset in seconds */
  82. --- 71,77 ----
  83.   int debug = 0;                /* Debugging flag (level) */
  84.   int s;                    /* Socket file descriptor */
  85.   char hostname[64];
  86. ! unsigned char *buf;            /* Receive packet buffer */
  87.   struct timezone tzp;            /* Time zone offset for clients */
  88.   struct timeval tp;            /* Time (extra baggage) */
  89.   long secondswest;            /* Time zone offset in seconds */
  90. ***************
  91. *** 97,103 ****
  92.       char **argv;
  93.   {
  94.       struct timeval timenow;
  95. !     struct bootp *bp = (struct bootp *) buf;
  96.       struct servent *sep;
  97.       struct hostent *hep;
  98.       
  99. --- 98,104 ----
  100.       char **argv;
  101.   {
  102.       struct timeval timenow;
  103. !     struct bootp *bp;
  104.       struct servent *sep;
  105.       struct hostent *hep;
  106.       
  107. ***************
  108. *** 108,114 ****
  109.       long server_addr = INADDR_ANY;
  110.       
  111.       program_name = argv[0];
  112. !     
  113.       /* Get my Ethernet address for the query. */
  114.       gethostname(hostname, sizeof(hostname));
  115.       if (ether_hostton(hostname, &eaddr)) {
  116. --- 109,120 ----
  117.       long server_addr = INADDR_ANY;
  118.       
  119.       program_name = argv[0];
  120. !     buf = malloc(BUFLEN);
  121. !     if (!buf) {
  122. !     printf("malloc failed\n");
  123. !     exit(1);
  124. !     }
  125.       /* Get my Ethernet address for the query. */
  126.       gethostname(hostname, sizeof(hostname));
  127.       if (ether_hostton(hostname, &eaddr)) {
  128. ***************
  129. *** 166,172 ****
  130.       if (servername) {
  131.       hep = gethostbyname(servername);
  132.       if (!hep) {
  133. !         report(LOG_ERR, "gethostbyname(%s)", servername);
  134.           exit(1);
  135.       }
  136.       bcopy(hep->h_addr, &sin_server.sin_addr, sizeof(struct in_addr));
  137. --- 172,178 ----
  138.       if (servername) {
  139.       hep = gethostbyname(servername);
  140.       if (!hep) {
  141. !         report(LOG_ERR, "gethostbyname(%s)\n", servername);
  142.           exit(1);
  143.       }
  144.       bcopy(hep->h_addr, &sin_server.sin_addr, sizeof(struct in_addr));
  145. ***************
  146. *** 210,215 ****
  147. --- 216,222 ----
  148.       /*
  149.        * Build a request.
  150.        */
  151. +     bp = (struct bootp *) buf;
  152.       bzero(bp, sizeof(*bp));
  153.       bp->bp_op = BOOTREQUEST;
  154.       bp->bp_htype = 1;
  155. ***************
  156. *** 275,281 ****
  157.       while (1) {
  158.       
  159.       fromlen = sizeof(sin_from);
  160. !     n = recvfrom(s, buf, sizeof(buf), 0, &sin_from, &fromlen);
  161.       if (n <= 0) {
  162.           continue;
  163.       }
  164. --- 282,288 ----
  165.       while (1) {
  166.       
  167.       fromlen = sizeof(sin_from);
  168. !     n = recvfrom(s, buf, BUFLEN, 0, &sin_from, &fromlen);
  169.       if (n <= 0) {
  170.           continue;
  171.       }
  172. diff -rc bootptest-1.1/interface.h bootptest-1.2/interface.h
  173. *** bootptest-1.1/interface.h    Thu Jun 10 14:20:14 1993
  174. --- bootptest-1.2/interface.h    Wed Oct 13 18:05:03 1993
  175. ***************
  176. *** 16,28 ****
  177.   
  178.   #define inline /*sorry*/
  179.   
  180. ! #define getname(p) inet_ntoa(p)
  181. ! #define etheraddr_string(p) ether_ntoa(p)
  182.   
  183.   /* We do not really have both Ethernet addresses. */
  184.   #define ESRC(p) (p)
  185.   #define EDST(p) (p)
  186.   
  187.   extern int vflag, tflag;
  188.   extern int thiszone;
  189.   
  190. --- 16,35 ----
  191.   
  192.   #define inline /*sorry*/
  193.   
  194. ! #define getname inet_ntoa
  195. ! #define etheraddr_string ether_ntoa
  196.   
  197.   /* We do not really have both Ethernet addresses. */
  198.   #define ESRC(p) (p)
  199.   #define EDST(p) (p)
  200.   
  201. + /* Use str functions */
  202. + #define bcopy(a,b,c)    memcpy(b,a,c)
  203. + #define bzero(p,l)      memset(p,0,l)
  204. + #define bcmp(a,b,c)     memcmp(a,b,c)
  205. + #define    index        strchr
  206. + #define    rindex        strrchr
  207.   extern int vflag, tflag;
  208.   extern int thiszone;
  209.   
  210. ***************
  211. *** 33,37 ****
  212.   /* global pointers to beginning and end of current packet (during printing) */
  213.   extern unsigned char *packetp;
  214.   extern unsigned char *snapend;
  215. - extern char *malloc();
  216. --- 40,42 ----
  217. diff -rc bootptest-1.1/print-bootp.c bootptest-1.2/print-bootp.c
  218. *** bootptest-1.1/print-bootp.c    Fri Oct  8 17:47:41 1993
  219. --- bootptest-1.2/print-bootp.c    Wed Oct 13 17:54:31 1993
  220. ***************
  221. *** 33,39 ****
  222.   #include <net/if.h>
  223.   #include <netinet/in.h>
  224.   #include <netinet/if_ether.h>
  225. ! #include <strings.h>
  226.   #include <ctype.h>
  227.   
  228.   #include "interface.h"
  229. --- 33,39 ----
  230.   #include <net/if.h>
  231.   #include <netinet/in.h>
  232.   #include <netinet/if_ether.h>
  233. ! #include <string.h>
  234.   #include <ctype.h>
  235.   
  236.   #include "interface.h"
  237. diff -rc bootptest-1.1/util.c bootptest-1.2/util.c
  238. *** bootptest-1.1/util.c    Fri Oct  9 18:50:09 1992
  239. --- bootptest-1.2/util.c    Wed Oct 13 18:00:03 1993
  240. ***************
  241. *** 32,38 ****
  242.   #include <sys/time.h>
  243.   #include <ctype.h>
  244.   #include <varargs.h>
  245. ! #include <sys/file.h>
  246.   #include <sys/stat.h>
  247.   
  248.   #include "interface.h"
  249. --- 32,38 ----
  250.   #include <sys/time.h>
  251.   #include <ctype.h>
  252.   #include <varargs.h>
  253. ! #include <sys/fcntl.h>
  254.   #include <sys/stat.h>
  255.   
  256.   #include "interface.h"
  257.