home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / samba / contributed / DHCP.patch next >
Encoding:
Text File  |  1995-03-20  |  20.1 KB  |  790 lines

  1. Hi Andrew,
  2.  
  3. > If you've done a later version of your DHCP patch, can you let me
  4. > know? I sometimes get questions about DHCP, so I point people to you
  5. > and your patch on nimbus.
  6.  
  7. Sure, I made a new version of the patch for bootp-2.4.2
  8. which also integrates lots of comments I got on the previous
  9. one :)
  10.  
  11. I will include the patch below...
  12.  
  13. Could you please add a remark that bootp-related questions
  14. should be forwarded to the bootp-list, and not me?
  15. Oh, and that the latest version of bootp can be found at
  16.     firewall.mc.com:/pub
  17.  
  18.     Met vriendelijke groet,
  19.         Pauline Middelink
  20. +------------------------------+-------------------------------------+
  21. | Jeanette Pauline Middelink   | email    : middelin@polyware.iaf.nl |
  22. | Boterkorfhoek 34             | zakelijk : 053-780020               |
  23. | 7546 JA  Enschede, Holland   | fax/data : 053-780021 (ook ISDN)    |
  24. +------------------------------+-------------------------------------+
  25. diff -rc bootp-2.4.2/Announce bootp-2.4.3/Announce
  26. *** bootp-2.4.2/Announce    Thu Feb 16 21:18:17 1995
  27. --- bootp-2.4.3/Announce    Thu Mar 16 08:58:23 1995
  28. ***************
  29. *** 6,11 ****
  30. --- 6,13 ----
  31.   
  32.   New features in version 2.4 include:
  33.   
  34. +     Added static DHCP allocation capabilities.
  35. +         Use: :dl=leasetime for DHCP leasetime handouts
  36.       Added a simple BOOTP gateway program: bootpgw
  37.       Allow host name anywhere IP address is expected.
  38.       Automatically lookup the IP address when the name of a
  39. ***************
  40. *** 49,60 ****
  41.       SunOS 4.X (Solaris 1.X)
  42.       SunOS 5.X (Solaris 2.X)
  43.       System V/386 Rel. 4.0
  44.   
  45.   Systems on which others say this code works:
  46.       CDC EP/IX (1.4.3, 2.1.1)
  47.       DEC Ultrix (4.2, 4.3)
  48. -     Linux 1.1.81
  49.       OSF/1 (DEC Alpha CPU)
  50.   
  51.   Please direct questions, comments, and bug reports to:
  52.       <bootp@andrew.cmu.edu>
  53. --- 51,69 ----
  54.       SunOS 4.X (Solaris 1.X)
  55.       SunOS 5.X (Solaris 2.X)
  56.       System V/386 Rel. 4.0
  57. +     Linux 1.1.81
  58.   
  59.   Systems on which others say this code works:
  60.       CDC EP/IX (1.4.3, 2.1.1)
  61.       DEC Ultrix (4.2, 4.3)
  62.       OSF/1 (DEC Alpha CPU)
  63. +     HP 9000
  64. + How to get the latest version:
  65. +     ftp firewall.mc.com (anonymous)
  66. +     cd /pub
  67. +     binary
  68. +     get bootp-2.4.2.tar.Z
  69.   
  70.   Please direct questions, comments, and bug reports to:
  71.       <bootp@andrew.cmu.edu>
  72. diff -rc bootp-2.4.2/Changes bootp-2.4.3/Changes
  73. *** bootp-2.4.2/Changes    Thu Feb 16 17:52:06 1995
  74. --- bootp-2.4.3/Changes    Thu Mar 16 08:24:18 1995
  75. ***************
  76. *** 2,13 ****
  77. --- 2,28 ----
  78.   Date, <email> Real Name
  79.       what...
  80.   
  81. + --> bootp-2.4.3
  82. + 08/07/95  middelin@polyware.iaf.nl (Pauline Middelink)
  83. +     Fixed problem while reporting duplicate hardware address in
  84. +     readfile.c (kerry@maine.maine.edu)
  85. +     Changed some code to allow the giaddr to pass through. Needed
  86. +     when the client request is forwarded to us through a gateway.
  87. +     (Broadcasting to the gateway will not reach the client)
  88. +     
  89. + 01/26/95  Phil.Packer@bbc.co.uk (Phil.Packer)
  90. +     Added dl tag for DHCP lease and rejigged Pauline's codes
  91. +     at the end of bootpd.c to allow the setting of explicit leases.
  92. +     Added "sco" Makefile target.
  93. +     
  94.   --> bootp-2.4.2
  95.   
  96.   01/14/95  middelin@polyware.iaf.nl (Pauline Middelink)
  97.       Corrected support for the Linux networking code.
  98.       Fixed lots of warnings (gcc -Wall)
  99.       Added "linux" Makefile target.
  100. +     Written code for DHCP static IP allocation.
  101.   
  102.   01/02/95  Jukka Ukkonen <ukkonen@csc.fi>
  103.       Allow bootptab syntax: ha="0:0:c0:80:e8:a7"
  104. diff -rc bootp-2.4.2/Makefile bootp-2.4.3/Makefile
  105. *** bootp-2.4.2/Makefile    Thu Feb 16 16:25:19 1995
  106. --- bootp-2.4.3/Makefile    Thu Mar 16 08:52:30 1995
  107. ***************
  108. *** 9,15 ****
  109.   # OPTion DEFinitions:
  110.   # Remove the -DVEND_CMU if you don't wish to support the "CMU vendor format"
  111.   # in addition to the RFC1048 format.  Leaving out DEBUG saves little.
  112. ! OPTDEFS= -DSYSLOG -DVEND_CMU -DDEBUG
  113.   
  114.   # Uncomment and edit this to choose the facility code used for syslog.
  115.   # LOG_FACILITY= "-DLOG_BOOTP=LOG_LOCAL2"
  116. --- 9,16 ----
  117.   # OPTion DEFinitions:
  118.   # Remove the -DVEND_CMU if you don't wish to support the "CMU vendor format"
  119.   # in addition to the RFC1048 format.  Leaving out DEBUG saves little.
  120. ! # Remove the -DDHCP if you don't need DHCP support.
  121. ! OPTDEFS= -DSYSLOG -DVEND_CMU -DDHCP -DDEBUG
  122.   
  123.   # Uncomment and edit this to choose the facility code used for syslog.
  124.   # LOG_FACILITY= "-DLOG_BOOTP=LOG_LOCAL2"
  125. ***************
  126. *** 37,43 ****
  127.   
  128.   INSTALL=/usr/bin/install
  129.   DESTDIR=
  130. ! BINDIR=/usr/etc
  131.   MANDIR=/usr/local/man
  132.   
  133.   CFLAGS= $(OPTDEFS) $(SYSDEFS) $(FILEDEFS) $(MOREDEFS)
  134. --- 38,44 ----
  135.   
  136.   INSTALL=/usr/bin/install
  137.   DESTDIR=
  138. ! BINDIR=/usr/sbin
  139.   MANDIR=/usr/local/man
  140.   
  141.   CFLAGS= $(OPTDEFS) $(SYSDEFS) $(FILEDEFS) $(MOREDEFS)
  142. ***************
  143. *** 95,103 ****
  144.           SYSDEFS="-DSVR4" \
  145.           SYSLIBS="-lsocket -lnsl"
  146.   
  147. ! # Linux 1.1.80+ on [34]86
  148.   linux:
  149. !     $(MAKE) SYSDEFS="-O6 -Wall -fomit-frame-pointer"
  150.   
  151.   # SunOS 4.X
  152.   sunos4:
  153. --- 96,111 ----
  154.           SYSDEFS="-DSVR4" \
  155.           SYSLIBS="-lsocket -lnsl"
  156.   
  157. ! # Linux 1.1.80+
  158.   linux:
  159. !     $(MAKE) SYSDEFS="-O6 -Wall -fomit-frame-pointer" \
  160. !         SYSLIBS="" \
  161. !         FILEDEFS='-DCONFIG_FILE=\"/etc/bootptab\" \
  162. !               -DDUMPTAB_FILE=\"/tmp/bootpd.dump\"'
  163. ! # SCO (pah!) SYSV rel 3.2
  164. ! sco:
  165. !     $(MAKE) CC="cc" SYSLIBS="-lsocket"
  166.   
  167.   # SunOS 4.X
  168.   sunos4:
  169. diff -rc bootp-2.4.2/bootp.h bootp-2.4.3/bootp.h
  170. *** bootp-2.4.2/bootp.h    Mon Aug 22 18:49:17 1994
  171. --- bootp-2.4.3/bootp.h    Thu Mar 16 08:17:22 1995
  172. ***************
  173. *** 122,129 ****
  174.   #define TAG_NIS_SERVER        ((unsigned char)  41)
  175.   #define TAG_NTP_SERVER        ((unsigned char)  42)
  176.   /* DHCP maximum message size. */
  177.   #define TAG_MAX_MSGSZ        ((unsigned char)  57)
  178.   /* XXX - Add new tags here */
  179.   
  180.   
  181. --- 122,133 ----
  182.   #define TAG_NIS_SERVER        ((unsigned char)  41)
  183.   #define TAG_NTP_SERVER        ((unsigned char)  42)
  184.   /* DHCP maximum message size. */
  185. + #define TAG_DHCP_IPLEASE    ((unsigned char)  51)
  186. + #define TAG_DHCP_MSG           ((unsigned char)  53)
  187. + #define TAG_DHCP_SERVERID    ((unsigned char)  54)
  188.   #define TAG_MAX_MSGSZ        ((unsigned char)  57)
  189. ! #define TAG_DHCP_IPRENEW    ((unsigned char)  58)    /* PeP hic facet */
  190. ! #define TAG_DHCP_IPREBIND    ((unsigned char)  59)
  191.   /* XXX - Add new tags here */
  192.   
  193.   
  194. diff -rc bootp-2.4.2/bootpd.c bootp-2.4.3/bootpd.c
  195. *** bootp-2.4.2/bootpd.c    Wed Feb 15 22:21:58 1995
  196. --- bootp-2.4.3/bootpd.c    Thu Mar 16 08:31:12 1995
  197. ***************
  198. *** 76,81 ****
  199. --- 76,90 ----
  200.   # define bzero(p,l)      memset(p,0,l)
  201.   # define bcmp(a,b,c)     memcmp(a,b,c)
  202.   #endif
  203. + #ifdef __linux__
  204. + /* Use sigaction to make signal last... */
  205. + inline void (*signal(int sig,void (*handler)(int)))(int) {
  206. +     struct sigaction so,sa = {NULL,0,SA_NOMASK|SA_RESTART,NULL};
  207. +     sa.sa_handler = handler;
  208. +     if (sigaction(sig,&sa,&so)<0) return NULL;
  209. +     return so.sa_handler;
  210. + }
  211. + #endif
  212.   
  213.   #include "bootp.h"
  214.   #include "hash.h"
  215. ***************
  216. *** 114,125 ****
  217.   #ifdef VEND_CMU
  218.   PRIVATE void dovend_cmu P((struct bootp *, struct host *));
  219.   #endif
  220. ! PRIVATE void dovend_rfc1048 P((struct bootp *, struct host *, int32));
  221.   PRIVATE void handle_reply P((void));
  222.   PRIVATE void handle_request P((void));
  223.   PRIVATE void sendreply P((int forward, int32 dest_override));
  224.   PRIVATE void usage P((void));
  225.   
  226.   #undef    P
  227.   
  228.   /*
  229. --- 123,144 ----
  230.   #ifdef VEND_CMU
  231.   PRIVATE void dovend_cmu P((struct bootp *, struct host *));
  232.   #endif
  233. ! PRIVATE int  dovend_rfc1048 P((struct bootp *, struct host *, int32));
  234.   PRIVATE void handle_reply P((void));
  235.   PRIVATE void handle_request P((void));
  236.   PRIVATE void sendreply P((int forward, int32 dest_override));
  237.   PRIVATE void usage P((void));
  238.   
  239. + #ifdef DHCP
  240. + PRIVATE int dhcp_discover P((struct bootp *, struct host *, byte *, int));
  241. + PRIVATE int dhcp_request P((struct bootp *, struct host *, byte *, int));
  242. + PRIVATE int dhcp_decline P((struct bootp *, struct host *, byte *, int));
  243. + PRIVATE int dhcp_release P((struct bootp *, struct host *, byte *, int));
  244. + PRIVATE int dhcp_offer P((struct bootp *, struct host *, byte *, int));
  245. + PRIVATE int dhcp_ack P((struct bootp *, struct host *, byte *, int));
  246. + PRIVATE int dhcp_lease P((struct bootp *, struct host *, byte **));
  247. + #endif
  248.   #undef    P
  249.   
  250.   /*
  251. ***************
  252. *** 477,482 ****
  253. --- 496,512 ----
  254.           bootpc_port = (u_short) IPPORT_BOOTPC;
  255.       }
  256.   
  257. + #ifdef DHCP
  258. +     /*
  259. +      * Maybe we have to broadcast, so enable it.
  260. +      */
  261. +     n = 1;
  262. +     if (setsockopt(s,SOL_SOCKET,SO_BROADCAST,&n,sizeof(n))<0) {
  263. +         report(LOG_ERR, "setsockopt: %s\n", get_errmsg());
  264. +         exit(1);
  265. +     }
  266. + #endif
  267.       /*
  268.        * Set up signals to read or dump the table.
  269.        */
  270. ***************
  271. *** 701,707 ****
  272.                          haddrtoa(bp->bp_chaddr, bp->bp_hlen));
  273.               return; /* not found */
  274.           }
  275. -         (bp->bp_yiaddr).s_addr = hp->iaddr.s_addr;
  276.   
  277.       } else {
  278.   
  279. --- 731,736 ----
  280. ***************
  281. *** 724,729 ****
  282. --- 753,759 ----
  283.               return;
  284.           }
  285.       }
  286. +     (bp->bp_yiaddr).s_addr = hp->iaddr.s_addr;
  287.   
  288.       if (debug) {
  289.           report(LOG_INFO, "found %s (%s)", inet_ntoa(hp->iaddr),
  290. ***************
  291. *** 961,967 ****
  292.        */
  293.       if (!bcmp(bp->bp_vend, vm_rfc1048, 4)) {
  294.           /* RFC1048 conformant bootp client */
  295. !         dovend_rfc1048(bp, hp, bootsize);
  296.           if (debug > 1) {
  297.               report(LOG_INFO, "sending reply (with RFC1048 options)");
  298.           }
  299. --- 991,998 ----
  300.        */
  301.       if (!bcmp(bp->bp_vend, vm_rfc1048, 4)) {
  302.           /* RFC1048 conformant bootp client */
  303. !         if (!dovend_rfc1048(bp, hp, bootsize))
  304. !             return;
  305.           if (debug > 1) {
  306.               report(LOG_INFO, "sending reply (with RFC1048 options)");
  307.           }
  308. ***************
  309. *** 1093,1098 ****
  310. --- 1124,1137 ----
  311.           /* Finally, set the server address field. */
  312.           bp->bp_siaddr = siaddr;
  313.       }
  314. + #ifdef DHCP
  315. +     /*
  316. +      * This code is placed here, because otherwise the siaddr
  317. +      * will not be found...
  318. +      */
  319. +     if (ntohs(bp->bp_flags) & 0x8000 && bp->bp_giaddr.s_addr==0)
  320. +         dst.s_addr = INADDR_BROADCAST;
  321. + #endif
  322.       /* Set up socket address for send. */
  323.       send_addr.sin_family = AF_INET;
  324.       send_addr.sin_port = htons(port);
  325. ***************
  326. *** 1220,1228 ****
  327.       if (bytesleft < (LEN)) { \
  328.           report(LOG_NOTICE, noroom, \
  329.                  hp->hostname->string, MSG); \
  330. !         return; \
  331.       } while (0)
  332. ! PRIVATE void
  333.   dovend_rfc1048(bp, hp, bootsize)
  334.       struct bootp *bp;
  335.       struct host *hp;
  336. --- 1259,1267 ----
  337.       if (bytesleft < (LEN)) { \
  338.           report(LOG_NOTICE, noroom, \
  339.                  hp->hostname->string, MSG); \
  340. !         return 0; \
  341.       } while (0)
  342. ! PRIVATE int
  343.   dovend_rfc1048(bp, hp, bootsize)
  344.       struct bootp *bp;
  345.       struct host *hp;
  346. ***************
  347. *** 1230,1235 ****
  348. --- 1269,1278 ----
  349.   {
  350.       int bytesleft, len;
  351.       byte *vp;
  352. + #ifdef DHCP
  353. +     int dhcp = 0;
  354. +     int isme = TRUE;    /* DHCP uses this for not-mine-requests */
  355. + #endif
  356.   
  357.       static char noroom[] = "%s: No room for \"%s\" option";
  358.   
  359. ***************
  360. *** 1280,1286 ****
  361.                   case TAG_SUBNET_MASK:
  362.                       /* XXX - Should preserve this if given... */
  363.                       break;
  364. !                 } /* swtich */
  365.                   p += len;
  366.               }
  367.   
  368. --- 1323,1335 ----
  369.                   case TAG_SUBNET_MASK:
  370.                       /* XXX - Should preserve this if given... */
  371.                       break;
  372. !                 case TAG_DHCP_MSG:
  373. !                     dhcp = *p;
  374. !                     break;
  375. !                 case TAG_DHCP_SERVERID:
  376. !                     isme = (len==4) && my_ip_addr.s_addr == ((struct in_addr *)p)->s_addr;
  377. !                     break;
  378. !                 } /* switch */
  379.                   p += len;
  380.               }
  381.   
  382. ***************
  383. *** 1347,1362 ****
  384.           vp += len;
  385.           *vp++ = TAG_END;
  386.           bytesleft -= len + 3;
  387. !         return;                    /* no more options here. */
  388.       }
  389.       /*
  390. !      * The remaining options are inserted by the following
  391. !      * function (which is shared with bootpef.c).
  392. !      * Keep back one byte for the TAG_END.
  393.        */
  394. !     len = dovend_rfc1497(hp, vp, bytesleft - 1);
  395. !     vp += len;
  396. !     bytesleft -= len;
  397.   
  398.       /* There should be at least one byte left. */
  399.       NEED(1, "(end)");
  400. --- 1396,1439 ----
  401.           vp += len;
  402.           *vp++ = TAG_END;
  403.           bytesleft -= len + 3;
  404. !         return 1;                /* no more options here. */
  405.       }
  406. + #ifdef DHCP
  407.       /*
  408. !      * Check if this is a DHCP request.
  409.        */
  410. !     if (dhcp!=0) {
  411. !         if (!isme)
  412. !             return 0;    /* Not mine, discard! */
  413. !         switch (dhcp) {
  414. !          case 1 : len = dhcp_discover(bp,hp,vp,bytesleft-1); break;
  415. !          case 3 : len = dhcp_request(bp,hp,vp,bytesleft-1); break;
  416. !          case 4 : len = dhcp_decline(bp,hp,vp,bytesleft-1); break;
  417. !          case 7 : len = dhcp_release(bp,hp,vp,bytesleft-1); break;
  418. !          default : report(LOG_NOTICE,"Unknown DHCP request (%d)",dhcp);
  419. !                return 0;
  420. !         }
  421. !         /* Is there a DHCP reply at all? */
  422. !         if (len==0)
  423. !             return 0;
  424. !         vp += len;
  425. !         bytesleft -= len;
  426. !     }
  427. !     else {
  428. ! #endif
  429. !         /*
  430. !          * The remaining options are inserted by the following
  431. !          * function (which is shared with bootpef.c).
  432. !          * Keep back one byte for the TAG_END.
  433. !          */
  434. !         len = dovend_rfc1497(hp, vp, bytesleft - 1);
  435. !         vp += len;
  436. !         bytesleft -= len;
  437. ! #ifdef DHCP
  438. !     }
  439. ! #endif
  440.   
  441.       /* There should be at least one byte left. */
  442.       NEED(1, "(end)");
  443. ***************
  444. *** 1370,1375 ****
  445. --- 1447,1453 ----
  446.            */
  447.           bzero(vp, bytesleft);
  448.       }
  449. +     return 1;    /* sent reply */
  450.   } /* dovend_rfc1048 */
  451.   #undef    NEED
  452.   
  453. ***************
  454. *** 1389,1394 ****
  455. --- 1467,1637 ----
  456.    */
  457.   
  458.   /* get_errmsg() - now in report.c */
  459. + #ifdef DHCP
  460. + /*
  461. +  * PeP hic facet
  462. +  * Stuff the packet with the Lease info, We need to do this on the Offer and
  463. +  * the ack so separated out here
  464. +  */
  465. + PRIVATE
  466. + int dhcp_lease(bp, hp, vp)
  467. +     struct bootp *bp;
  468. +     struct host *hp;
  469. +     byte **vp;
  470. + {
  471. +     *(*vp)++ = TAG_DHCP_IPRENEW;    /* DHCP Renewal time 50% of lease */
  472. +     *(*vp)++ = 4;            /* Length */
  473. +     insert_u_long(htonl(hp->dhcp_lease/2),vp);
  474. +     *(*vp)++ = TAG_DHCP_IPREBIND;    /* DHCP Rebinding time 85% of lease */
  475. +     *(*vp)++ = 4;
  476. +     insert_u_long(htonl(hp->dhcp_lease*7/8),vp);
  477. +     
  478. +     *(*vp)++ = TAG_DHCP_IPLEASE;    /* IP address lease time */
  479. +     *(*vp)++ = 4;            /* Length */
  480. +     insert_u_long(htonl(hp->dhcp_lease),vp); /* PeP hic facet, lets see if this works */
  481. +     return(19);
  482. + }
  483. + /*
  484. +  * Formulate an DHCP_DISCOVER reply
  485. +  */
  486. + PRIVATE
  487. + int dhcp_discover(bp, hp, vp, bytesleft)
  488. +     struct bootp *bp;
  489. +     struct host *hp;
  490. +     byte *vp;
  491. +     int bytesleft;
  492. + {
  493. +     if(debug)
  494. +         report(LOG_INFO, "Received: DHCPDISCOVER");
  495. +     return(dhcp_offer(bp,hp,vp,bytesleft));
  496. + }
  497. + /*
  498. +  * formulate an DHCP_RELEASE reply
  499. +  */
  500. + PRIVATE
  501. + int dhcp_release(bp, hp, vp, bytesleft)
  502. +     struct bootp *bp;
  503. +     struct host *hp;
  504. +     byte *vp;
  505. +     int bytesleft;
  506. + {
  507. +     if (debug)
  508. +         report(LOG_INFO, "Received: DHCPRELEASE (discarded)");
  509. +     return 0;
  510. + }
  511. + PRIVATE
  512. + int dhcp_offer(bp, hp, vp, bytesleft)
  513. +     struct bootp *bp;
  514. +     struct host *hp;
  515. +     byte *vp;
  516. +     int bytesleft;
  517. + {
  518. +     int len=0;
  519. +     if (debug)
  520. +         report(LOG_INFO, "Sent: DHCPOFFER");
  521. +     bp->bp_secs = bp->bp_hops = 0;
  522. +     bp->bp_ciaddr.s_addr = 0;
  523. +     *vp++ = TAG_DHCP_MSG;        /* DHCP */
  524. +     *vp++ = 1;            /* length */
  525. +     *vp++ = 2;            /* DHCPOFFER */
  526. +     len +=  3;    
  527. +     len += dhcp_lease(bp,hp,&vp);
  528. +     *vp++ = TAG_DHCP_SERVERID;
  529. +     *vp++ = 4;
  530. +     insert_u_long(my_ip_addr.s_addr,&vp);
  531. +     len += 6;
  532. +     return len + dovend_rfc1497(hp, vp, bytesleft - len);
  533. + }
  534. + /*
  535. +  * Formulate an DHCP_REQUEST reply
  536. +  */
  537. + PRIVATE
  538. + int dhcp_request(bp, hp, vp, bytesleft)
  539. +     struct bootp *bp;
  540. +     struct host *hp;
  541. +     byte *vp;
  542. +     int bytesleft;
  543. + {
  544. +     bp->bp_secs = bp->bp_hops = 0;
  545. +     if(debug)
  546. +         report(LOG_INFO,"Received: DHCPREQUEST");
  547. +     /*
  548. +      * Make absolutely sure that if the client requests an address,
  549. +      * it is its own address, and also make sure the hardware
  550. +      * addresses match perfectly. We want to minimize spoofing!
  551. +      */
  552. +     if ((bp->bp_ciaddr.s_addr && bp->bp_ciaddr.s_addr!=bp->bp_yiaddr.s_addr) ||
  553. +         bp->bp_htype != hp->htype ||
  554. +             bcmp(bp->bp_chaddr, hp->haddr, haddrlength(hp->htype))) {
  555. +         if (debug)
  556. +             report(LOG_INFO, "Sent: DHCPNAK");
  557. +         *vp++ = TAG_DHCP_MSG;    /* DHCPNAK */
  558. +         *vp++ = 1;
  559. +         *vp++ = 6;
  560. +         return 3;
  561. +     }
  562. +     else 
  563. +         return(dhcp_ack(bp,hp,vp,bytesleft));    
  564. + }
  565. + PRIVATE
  566. + int dhcp_ack(bp, hp, vp, bytesleft)
  567. +     struct bootp *bp;
  568. +     struct host *hp;
  569. +     byte *vp;
  570. +     int bytesleft;
  571. + {
  572. +     int len=0;
  573. +     if (debug)
  574. +         report(LOG_INFO, "Sent: DHCPACK");
  575. +     *vp++ = TAG_DHCP_MSG;    /* DHCPACK */
  576. +     *vp++ = 1;
  577. +     *vp++ = 5;
  578. +     len += 3;
  579. +     len += dhcp_lease(bp,hp,&vp);
  580. +     *vp++ = TAG_DHCP_SERVERID;    /* Server id */
  581. +     *vp++ = 4;
  582. +     insert_u_long(my_ip_addr.s_addr,&vp);
  583. +     len += 6;
  584. +     return len + dovend_rfc1497(hp, vp, bytesleft - len);
  585. + }
  586. + /*
  587. +  * formulate an DHCP_DECLINE reply
  588. +  */
  589. + PRIVATE
  590. + int dhcp_decline(bp, hp, vp, bytesleft)
  591. +     struct bootp *bp;
  592. +     struct host *hp;
  593. +     byte *vp;
  594. +     int bytesleft;
  595. + {
  596. +     if (debug)
  597. +         report(LOG_INFO, "Recived: DHCPDECLINE (ignored)");
  598. +     return 0;
  599. + }
  600. + #endif
  601.   
  602.   /*
  603.    * Local Variables:
  604. diff -rc bootp-2.4.2/bootpd.h bootp-2.4.3/bootpd.h
  605. *** bootp-2.4.2/bootpd.h    Thu Jul 28 00:30:29 1994
  606. --- bootp-2.4.3/bootpd.h    Thu Mar 16 08:17:23 1995
  607. ***************
  608. *** 126,131 ****
  609. --- 126,134 ----
  610.           exec_file    :1,
  611.           msg_size    :1,
  612.           min_wait    :1,
  613. + #ifdef DHCP
  614. +         dhcp_lease    :1,    /* PeP hic facet */
  615. + #endif
  616.           /* XXX - Add new tags here */
  617.           vm_cookie    :1;
  618.   };
  619. ***************
  620. *** 184,189 ****
  621. --- 187,195 ----
  622.       unsigned int32        bootsize,
  623.                   msg_size,
  624.                   min_wait;
  625. + #ifdef DHCP
  626. +     unsigned int32        dhcp_lease; /* PeP hic facet */
  627. + #endif
  628.       struct in_addr        bootserver,
  629.                   iaddr,
  630.                   swap_server,
  631. diff -rc bootp-2.4.2/bootptest.c bootp-2.4.3/bootptest.c
  632. *** bootp-2.4.2/bootptest.c    Thu Feb 16 16:36:25 1995
  633. --- bootp-2.4.3/bootptest.c    Thu Mar 16 08:17:36 1995
  634. ***************
  635. *** 50,55 ****
  636. --- 50,58 ----
  637.   #include <unistd.h>
  638.   #endif
  639.   
  640. + #ifndef    NO_UNISTD
  641. + #include <unistd.h>
  642. + #endif
  643.   #include <stdlib.h>
  644.   #include <signal.h>
  645.   #include <stdio.h>
  646. ***************
  647. *** 66,71 ****
  648. --- 69,77 ----
  649.   
  650.   #include "patchlevel.h"
  651.   
  652. + static void send_request();
  653. + extern int getether();
  654.   static void send_request();
  655.   
  656.   #define LOG_ERR 1
  657. diff -rc bootp-2.4.2/patchlevel.h bootp-2.4.3/patchlevel.h
  658. *** bootp-2.4.2/patchlevel.h    Thu Feb 16 16:42:20 1995
  659. --- bootp-2.4.3/patchlevel.h    Thu Mar 16 08:24:26 1995
  660. ***************
  661. *** 1,3 ****
  662.   /* patchlevel.h */
  663.   #define VERSION     "2.4"
  664. ! #define PATCHLEVEL    2
  665. --- 1,3 ----
  666.   /* patchlevel.h */
  667.   #define VERSION     "2.4"
  668. ! #define PATCHLEVEL    3
  669. diff -rc bootp-2.4.2/print-bootp.c bootp-2.4.3/print-bootp.c
  670. *** bootp-2.4.2/print-bootp.c    Wed Feb 15 23:21:13 1995
  671. --- bootp-2.4.3/print-bootp.c    Thu Mar 16 08:41:15 1995
  672. ***************
  673. *** 268,274 ****
  674.       "iXW-FS",            /* 48: X Window System Font Servers */
  675.       "iXW-DM",            /* 49: X Window System Display Managers */
  676.   
  677. !     /* DHCP extensions (RFC-1533, sect. 9) */
  678.   #endif
  679.   };
  680.   #define    KNOWN_OPTIONS (sizeof(rfc1048_opts) / sizeof(rfc1048_opts[0]))
  681. --- 268,279 ----
  682.       "iXW-FS",            /* 48: X Window System Font Servers */
  683.       "iXW-DM",            /* 49: X Window System Display Managers */
  684.   
  685. !     /* DHCP extensions (RFC-1533, sect. 9) PeP hic facet */
  686. !     "iDHCPreq",            /* 50: DHCP requested IP address */
  687. !     "lDHCPlease",            /* 51: DHCP lease time */ 
  688. !     "bDHCPooptol",            /* 52: DHCP option overload */
  689. !     "bDHCPtype",            /* 53: DHCP message type */
  690. !     "iDHCPSid",            /* 54: DHCP server ID */
  691.   #endif
  692.   };
  693.   #define    KNOWN_OPTIONS (sizeof(rfc1048_opts) / sizeof(rfc1048_opts[0]))
  694. diff -rc bootp-2.4.2/readfile.c bootp-2.4.3/readfile.c
  695. *** bootp-2.4.2/readfile.c    Wed Feb 15 21:45:25 1995
  696. --- bootp-2.4.3/readfile.c    Thu Mar 16 08:46:17 1995
  697. ***************
  698. *** 113,118 ****
  699. --- 113,121 ----
  700.   #define SYM_EXEC_FILE         33    /* YORK_EX_OPTION */
  701.   #define SYM_MSG_SIZE          34
  702.   #define SYM_MIN_WAIT         35
  703. + #define SYM_DHCP_LEASE         36    /* RFC 1533 PeP hic facet */
  704. + #define SYM_DHCP_IPRENEW     37
  705. + #define SYM_DHCP_IPREBIND     38
  706.   /* XXX - Add new tags here */
  707.   
  708.   #define OP_ADDITION          1    /* Operations on tags */
  709. ***************
  710. *** 161,166 ****
  711. --- 164,172 ----
  712.       {"df", SYM_DUMP_FILE},
  713.       {"dn", SYM_DOMAIN_NAME},
  714.       {"ds", SYM_DOMAIN_SERVER},
  715. + #ifdef DHCP
  716. +     {"dl", SYM_DHCP_LEASE},        /* PeP hic facet */
  717. + #endif
  718.       {"ef", SYM_EXTEN_FILE},
  719.       {"ex", SYM_EXEC_FILE},        /* YORK_EX_OPTION */
  720.       {"gw", SYM_GATEWAY},
  721. ***************
  722. *** 1125,1131 ****
  723.           PARSE_UINT(min_wait);
  724.           break;
  725.   
  726. !         /* XXX - Add new tags here */
  727.   
  728.       default:
  729.           return E_UNKNOWN_SYMBOL;
  730. --- 1131,1146 ----
  731.           PARSE_UINT(min_wait);
  732.           break;
  733.   
  734. ! #ifdef DHCP        
  735. !     /* PeP hic facet. */            
  736. !     case SYM_DHCP_LEASE:
  737. !         PARSE_UINT(dhcp_lease);
  738. !         break;
  739. !         /* XXX - Add new DHCP tags here */
  740. ! #endif
  741. !     /* XXX - Add new tags here */
  742.   
  743.       default:
  744.           return E_UNKNOWN_SYMBOL;
  745. ***************
  746. *** 1506,1511 ****
  747. --- 1521,1527 ----
  748.       DUP_COPY(min_wait);
  749.   
  750.       /* XXX - Add new tags here */
  751. +     DUP_COPY(dhcp_lease); /* PeP hic facet */
  752.   
  753.       DUP_LINK(generic);
  754.   
  755.  
  756.