1 diff -rc bootp-2.4.2/Announce bootp-2.4.3/Announce
2 *** bootp-2.4.2/Announce Thu Feb 16 21:18:17 1995
3 --- bootp-2.4.3/Announce Thu Mar 16 08:58:23 1995
8 New features in version 2.4 include:
10 + Added static DHCP allocation capabilities.
11 + Use: :dl=leasetime for DHCP leasetime handouts
12 Added a simple BOOTP gateway program: bootpgw
13 Allow host name anywhere IP address is expected.
14 Automatically lookup the IP address when the name of a
17 SunOS 4.X (Solaris 1.X)
18 SunOS 5.X (Solaris 2.X)
21 Systems on which others say this code works:
22 CDC EP/IX (1.4.3, 2.1.1)
27 Please direct questions, comments, and bug reports to:
28 <bootp@andrew.cmu.edu>
30 SunOS 4.X (Solaris 1.X)
31 SunOS 5.X (Solaris 2.X)
35 Systems on which others say this code works:
36 CDC EP/IX (1.4.3, 2.1.1)
41 + How to get the latest version:
42 + ftp firewall.mc.com (anonymous)
45 + get bootp-2.4.2.tar.Z
47 Please direct questions, comments, and bug reports to:
48 <bootp@andrew.cmu.edu>
49 diff -rc bootp-2.4.2/Changes bootp-2.4.3/Changes
50 *** bootp-2.4.2/Changes Thu Feb 16 17:52:06 1995
51 --- bootp-2.4.3/Changes Thu Mar 16 08:24:18 1995
55 Date, <email> Real Name
60 + 08/07/95 middelin@polyware.iaf.nl (Pauline Middelink)
61 + Fixed problem while reporting duplicate hardware address in
62 + readfile.c (kerry@maine.maine.edu)
63 + Changed some code to allow the giaddr to pass through. Needed
64 + when the client request is forwarded to us through a gateway.
65 + (Broadcasting to the gateway will not reach the client)
67 + 01/26/95 Phil.Packer@bbc.co.uk (Phil.Packer)
68 + Added dl tag for DHCP lease and rejigged Pauline's codes
69 + at the end of bootpd.c to allow the setting of explicit leases.
70 + Added "sco" Makefile target.
74 01/14/95 middelin@polyware.iaf.nl (Pauline Middelink)
75 Corrected support for the Linux networking code.
76 Fixed lots of warnings (gcc -Wall)
77 Added "linux" Makefile target.
78 + Written code for DHCP static IP allocation.
80 01/02/95 Jukka Ukkonen <ukkonen@csc.fi>
81 Allow bootptab syntax: ha="0:0:c0:80:e8:a7"
82 diff -rc bootp-2.4.2/Makefile bootp-2.4.3/Makefile
83 *** bootp-2.4.2/Makefile Thu Feb 16 16:25:19 1995
84 --- bootp-2.4.3/Makefile Thu Mar 16 08:52:30 1995
88 # Remove the -DVEND_CMU if you don't wish to support the "CMU vendor format"
89 # in addition to the RFC1048 format. Leaving out DEBUG saves little.
90 ! OPTDEFS= -DSYSLOG -DVEND_CMU -DDEBUG
92 # Uncomment and edit this to choose the facility code used for syslog.
93 # LOG_FACILITY= "-DLOG_BOOTP=LOG_LOCAL2"
96 # Remove the -DVEND_CMU if you don't wish to support the "CMU vendor format"
97 # in addition to the RFC1048 format. Leaving out DEBUG saves little.
98 ! # Remove the -DDHCP if you don't need DHCP support.
99 ! OPTDEFS= -DSYSLOG -DVEND_CMU -DDHCP -DDEBUG
101 # Uncomment and edit this to choose the facility code used for syslog.
102 # LOG_FACILITY= "-DLOG_BOOTP=LOG_LOCAL2"
106 SYSLIBS="-lsocket -lnsl"
108 ! # Linux 1.1.80+ on [34]86
110 ! $(MAKE) SYSDEFS="-O6 -Wall -fomit-frame-pointer"
116 SYSLIBS="-lsocket -lnsl"
120 ! $(MAKE) SYSDEFS="-O6 -Wall -fomit-frame-pointer" \
122 ! FILEDEFS='-DCONFIG_FILE=\"/etc/bootptab\" \
123 ! -DDUMPTAB_FILE=\"/tmp/bootpd.dump\"'
125 ! # SCO (pah!) SYSV rel 3.2
127 ! $(MAKE) CC="cc" SYSLIBS="-lsocket"
131 diff -rc bootp-2.4.2/bootp.h bootp-2.4.3/bootp.h
132 *** bootp-2.4.2/bootp.h Mon Aug 22 18:49:17 1994
133 --- bootp-2.4.3/bootp.h Thu Mar 16 08:17:22 1995
136 #define TAG_NIS_SERVER ((unsigned char) 41)
137 #define TAG_NTP_SERVER ((unsigned char) 42)
138 /* DHCP maximum message size. */
139 #define TAG_MAX_MSGSZ ((unsigned char) 57)
141 /* XXX - Add new tags here */
145 #define TAG_NIS_SERVER ((unsigned char) 41)
146 #define TAG_NTP_SERVER ((unsigned char) 42)
147 /* DHCP maximum message size. */
148 + #define TAG_DHCP_IPLEASE ((unsigned char) 51)
149 + #define TAG_DHCP_MSG ((unsigned char) 53)
150 + #define TAG_DHCP_SERVERID ((unsigned char) 54)
151 #define TAG_MAX_MSGSZ ((unsigned char) 57)
152 ! #define TAG_DHCP_IPRENEW ((unsigned char) 58) /* PeP hic facet */
153 ! #define TAG_DHCP_IPREBIND ((unsigned char) 59)
154 /* XXX - Add new tags here */
157 diff -rc bootp-2.4.2/bootpd.c bootp-2.4.3/bootpd.c
158 *** bootp-2.4.2/bootpd.c Wed Feb 15 22:21:58 1995
159 --- bootp-2.4.3/bootpd.c Thu Mar 16 08:31:12 1995
163 # define bzero(p,l) memset(p,0,l)
164 # define bcmp(a,b,c) memcmp(a,b,c)
167 + /* Use sigaction to make signal last... */
168 + inline void (*signal(int sig,void (*handler)(int)))(int) {
169 + struct sigaction so,sa = {NULL,0,SA_NOMASK|SA_RESTART,NULL};
170 + sa.sa_handler = handler;
171 + if (sigaction(sig,&sa,&so)<0) return NULL;
172 + return so.sa_handler;
181 PRIVATE void dovend_cmu P((struct bootp *, struct host *));
183 ! PRIVATE void dovend_rfc1048 P((struct bootp *, struct host *, int32));
184 PRIVATE void handle_reply P((void));
185 PRIVATE void handle_request P((void));
186 PRIVATE void sendreply P((int forward, int32 dest_override));
187 PRIVATE void usage P((void));
194 PRIVATE void dovend_cmu P((struct bootp *, struct host *));
196 ! PRIVATE int dovend_rfc1048 P((struct bootp *, struct host *, int32));
197 PRIVATE void handle_reply P((void));
198 PRIVATE void handle_request P((void));
199 PRIVATE void sendreply P((int forward, int32 dest_override));
200 PRIVATE void usage P((void));
203 + PRIVATE int dhcp_discover P((struct bootp *, struct host *, byte *, int));
204 + PRIVATE int dhcp_request P((struct bootp *, struct host *, byte *, int));
205 + PRIVATE int dhcp_decline P((struct bootp *, struct host *, byte *, int));
206 + PRIVATE int dhcp_release P((struct bootp *, struct host *, byte *, int));
207 + PRIVATE int dhcp_offer P((struct bootp *, struct host *, byte *, int));
208 + PRIVATE int dhcp_ack P((struct bootp *, struct host *, byte *, int));
209 + PRIVATE int dhcp_lease P((struct bootp *, struct host *, byte **));
218 bootpc_port = (u_short) IPPORT_BOOTPC;
223 + * Maybe we have to broadcast, so enable it.
226 + if (setsockopt(s,SOL_SOCKET,SO_BROADCAST,&n,sizeof(n))<0) {
227 + report(LOG_ERR, "setsockopt: %s\n", get_errmsg());
233 * Set up signals to read or dump the table.
237 haddrtoa(bp->bp_chaddr, bp->bp_hlen));
238 return; /* not found */
240 - (bp->bp_yiaddr).s_addr = hp->iaddr.s_addr;
251 + (bp->bp_yiaddr).s_addr = hp->iaddr.s_addr;
254 report(LOG_INFO, "found %s (%s)", inet_ntoa(hp->iaddr),
258 if (!bcmp(bp->bp_vend, vm_rfc1048, 4)) {
259 /* RFC1048 conformant bootp client */
260 ! dovend_rfc1048(bp, hp, bootsize);
262 report(LOG_INFO, "sending reply (with RFC1048 options)");
266 if (!bcmp(bp->bp_vend, vm_rfc1048, 4)) {
267 /* RFC1048 conformant bootp client */
268 ! if (!dovend_rfc1048(bp, hp, bootsize))
271 report(LOG_INFO, "sending reply (with RFC1048 options)");
276 /* Finally, set the server address field. */
277 bp->bp_siaddr = siaddr;
281 + * This code is placed here, because otherwise the siaddr
282 + * will not be found...
284 + if (ntohs(bp->bp_flags) & 0x8000 && bp->bp_giaddr.s_addr==0)
285 + dst.s_addr = INADDR_BROADCAST;
287 /* Set up socket address for send. */
288 send_addr.sin_family = AF_INET;
289 send_addr.sin_port = htons(port);
292 if (bytesleft < (LEN)) { \
293 report(LOG_NOTICE, noroom, \
294 hp->hostname->string, MSG); \
298 dovend_rfc1048(bp, hp, bootsize)
302 if (bytesleft < (LEN)) { \
303 report(LOG_NOTICE, noroom, \
304 hp->hostname->string, MSG); \
308 dovend_rfc1048(bp, hp, bootsize)
319 + int isme = TRUE; /* DHCP uses this for not-mine-requests */
322 static char noroom[] = "%s: No room for \"%s\" option";
326 case TAG_SUBNET_MASK:
327 /* XXX - Should preserve this if given... */
334 case TAG_SUBNET_MASK:
335 /* XXX - Should preserve this if given... */
340 ! case TAG_DHCP_SERVERID:
341 ! isme = (len==4) && my_ip_addr.s_addr == ((struct in_addr *)p)->s_addr;
351 bytesleft -= len + 3;
352 ! return; /* no more options here. */
355 ! * The remaining options are inserted by the following
356 ! * function (which is shared with bootpef.c).
357 ! * Keep back one byte for the TAG_END.
359 ! len = dovend_rfc1497(hp, vp, bytesleft - 1);
363 /* There should be at least one byte left. */
368 bytesleft -= len + 3;
369 ! return 1; /* no more options here. */
374 ! * Check if this is a DHCP request.
378 ! return 0; /* Not mine, discard! */
381 ! case 1 : len = dhcp_discover(bp,hp,vp,bytesleft-1); break;
382 ! case 3 : len = dhcp_request(bp,hp,vp,bytesleft-1); break;
383 ! case 4 : len = dhcp_decline(bp,hp,vp,bytesleft-1); break;
384 ! case 7 : len = dhcp_release(bp,hp,vp,bytesleft-1); break;
385 ! default : report(LOG_NOTICE,"Unknown DHCP request (%d)",dhcp);
388 ! /* Is there a DHCP reply at all? */
397 ! * The remaining options are inserted by the following
398 ! * function (which is shared with bootpef.c).
399 ! * Keep back one byte for the TAG_END.
401 ! len = dovend_rfc1497(hp, vp, bytesleft - 1);
408 /* There should be at least one byte left. */
414 bzero(vp, bytesleft);
416 + return 1; /* sent reply */
417 } /* dovend_rfc1048 */
425 /* get_errmsg() - now in report.c */
432 + * Stuff the packet with the Lease info, We need to do this on the Offer and
433 + * the ack so separated out here
436 + int dhcp_lease(bp, hp, vp)
441 + *(*vp)++ = TAG_DHCP_IPRENEW; /* DHCP Renewal time 50% of lease */
442 + *(*vp)++ = 4; /* Length */
443 + insert_u_long(htonl(hp->dhcp_lease/2),vp);
445 + *(*vp)++ = TAG_DHCP_IPREBIND; /* DHCP Rebinding time 85% of lease */
447 + insert_u_long(htonl(hp->dhcp_lease*7/8),vp);
449 + *(*vp)++ = TAG_DHCP_IPLEASE; /* IP address lease time */
450 + *(*vp)++ = 4; /* Length */
451 + insert_u_long(htonl(hp->dhcp_lease),vp); /* PeP hic facet, lets see if this works */
458 + * Formulate an DHCP_DISCOVER reply
461 + int dhcp_discover(bp, hp, vp, bytesleft)
468 + report(LOG_INFO, "Received: DHCPDISCOVER");
469 + return(dhcp_offer(bp,hp,vp,bytesleft));
473 + * formulate an DHCP_RELEASE reply
476 + int dhcp_release(bp, hp, vp, bytesleft)
483 + report(LOG_INFO, "Received: DHCPRELEASE (discarded)");
488 + int dhcp_offer(bp, hp, vp, bytesleft)
496 + report(LOG_INFO, "Sent: DHCPOFFER");
498 + bp->bp_secs = bp->bp_hops = 0;
499 + bp->bp_ciaddr.s_addr = 0;
501 + *vp++ = TAG_DHCP_MSG; /* DHCP */
502 + *vp++ = 1; /* length */
503 + *vp++ = 2; /* DHCPOFFER */
506 + len += dhcp_lease(bp,hp,&vp);
508 + *vp++ = TAG_DHCP_SERVERID;
510 + insert_u_long(my_ip_addr.s_addr,&vp);
513 + return len + dovend_rfc1497(hp, vp, bytesleft - len);
517 + * Formulate an DHCP_REQUEST reply
520 + int dhcp_request(bp, hp, vp, bytesleft)
526 + bp->bp_secs = bp->bp_hops = 0;
529 + report(LOG_INFO,"Received: DHCPREQUEST");
531 + * Make absolutely sure that if the client requests an address,
532 + * it is its own address, and also make sure the hardware
533 + * addresses match perfectly. We want to minimize spoofing!
535 + if ((bp->bp_ciaddr.s_addr && bp->bp_ciaddr.s_addr!=bp->bp_yiaddr.s_addr) ||
536 + bp->bp_htype != hp->htype ||
537 + bcmp(bp->bp_chaddr, hp->haddr, haddrlength(hp->htype))) {
539 + report(LOG_INFO, "Sent: DHCPNAK");
541 + *vp++ = TAG_DHCP_MSG; /* DHCPNAK */
547 + return(dhcp_ack(bp,hp,vp,bytesleft));
551 + int dhcp_ack(bp, hp, vp, bytesleft)
559 + report(LOG_INFO, "Sent: DHCPACK");
561 + *vp++ = TAG_DHCP_MSG; /* DHCPACK */
566 + len += dhcp_lease(bp,hp,&vp);
568 + *vp++ = TAG_DHCP_SERVERID; /* Server id */
570 + insert_u_long(my_ip_addr.s_addr,&vp);
573 + return len + dovend_rfc1497(hp, vp, bytesleft - len);
577 + * formulate an DHCP_DECLINE reply
580 + int dhcp_decline(bp, hp, vp, bytesleft)
587 + report(LOG_INFO, "Recived: DHCPDECLINE (ignored)");
594 diff -rc bootp-2.4.2/bootpd.h bootp-2.4.3/bootpd.h
595 *** bootp-2.4.2/bootpd.h Thu Jul 28 00:30:29 1994
596 --- bootp-2.4.3/bootpd.h Thu Mar 16 08:17:23 1995
604 + dhcp_lease :1, /* PeP hic facet */
606 /* XXX - Add new tags here */
612 unsigned int32 bootsize,
616 + unsigned int32 dhcp_lease; /* PeP hic facet */
618 struct in_addr bootserver,
621 diff -rc bootp-2.4.2/bootptest.c bootp-2.4.3/bootptest.c
622 *** bootp-2.4.2/bootptest.c Thu Feb 16 16:36:25 1995
623 --- bootp-2.4.3/bootptest.c Thu Mar 16 08:17:36 1995
631 + #include <unistd.h>
640 #include "patchlevel.h"
642 + static void send_request();
644 + extern int getether();
645 static void send_request();
648 diff -rc bootp-2.4.2/print-bootp.c bootp-2.4.3/print-bootp.c
649 *** bootp-2.4.2/print-bootp.c Wed Feb 15 23:21:13 1995
650 --- bootp-2.4.3/print-bootp.c Thu Mar 16 08:41:15 1995
653 "iXW-FS", /* 48: X Window System Font Servers */
654 "iXW-DM", /* 49: X Window System Display Managers */
656 ! /* DHCP extensions (RFC-1533, sect. 9) */
659 #define KNOWN_OPTIONS (sizeof(rfc1048_opts) / sizeof(rfc1048_opts[0]))
661 "iXW-FS", /* 48: X Window System Font Servers */
662 "iXW-DM", /* 49: X Window System Display Managers */
664 ! /* DHCP extensions (RFC-1533, sect. 9) PeP hic facet */
665 ! "iDHCPreq", /* 50: DHCP requested IP address */
666 ! "lDHCPlease", /* 51: DHCP lease time */
667 ! "bDHCPooptol", /* 52: DHCP option overload */
668 ! "bDHCPtype", /* 53: DHCP message type */
669 ! "iDHCPSid", /* 54: DHCP server ID */
672 #define KNOWN_OPTIONS (sizeof(rfc1048_opts) / sizeof(rfc1048_opts[0]))
673 diff -rc bootp-2.4.2/readfile.c bootp-2.4.3/readfile.c
674 *** bootp-2.4.2/readfile.c Wed Feb 15 21:45:25 1995
675 --- bootp-2.4.3/readfile.c Thu Mar 16 08:46:17 1995
679 #define SYM_EXEC_FILE 33 /* YORK_EX_OPTION */
680 #define SYM_MSG_SIZE 34
681 #define SYM_MIN_WAIT 35
682 + #define SYM_DHCP_LEASE 36 /* RFC 1533 PeP hic facet */
683 + #define SYM_DHCP_IPRENEW 37
684 + #define SYM_DHCP_IPREBIND 38
685 /* XXX - Add new tags here */
687 #define OP_ADDITION 1 /* Operations on tags */
691 {"df", SYM_DUMP_FILE},
692 {"dn", SYM_DOMAIN_NAME},
693 {"ds", SYM_DOMAIN_SERVER},
695 + {"dl", SYM_DHCP_LEASE}, /* PeP hic facet */
697 {"ef", SYM_EXTEN_FILE},
698 {"ex", SYM_EXEC_FILE}, /* YORK_EX_OPTION */
702 PARSE_UINT(min_wait);
705 ! /* XXX - Add new tags here */
708 return E_UNKNOWN_SYMBOL;
710 PARSE_UINT(min_wait);
714 ! /* PeP hic facet. */
715 ! case SYM_DHCP_LEASE:
716 ! PARSE_UINT(dhcp_lease);
719 ! /* XXX - Add new DHCP tags here */
722 ! /* XXX - Add new tags here */
725 return E_UNKNOWN_SYMBOL;
731 /* XXX - Add new tags here */
732 + DUP_COPY(dhcp_lease); /* PeP hic facet */