diff -rcN dhcp-1.4.0p1/Copyright dhcp-1.4.0p2/Copyright
*** dhcp-1.4.0p1/Copyright	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/Copyright	Mon Feb  9 17:44:42 1998
***************
*** 1,6 ****
   * WIDE Project DHCP Implementation
!  * Copyright (c) 1995, 1996 Akihiro Tominaga
!  * Copyright (c) 1995, 1996 WIDE Project
   * All rights reserved.
   *
   * Permission to use, copy, modify and distribute this software and its
--- 1,6 ----
   * WIDE Project DHCP Implementation
!  * Copyright (c) 1995-1998 Akihiro Tominaga
!  * Copyright (c) 1995-1998 WIDE Project
   * All rights reserved.
   *
   * Permission to use, copy, modify and distribute this software and its
diff -rcN dhcp-1.4.0p1/README dhcp-1.4.0p2/README
*** dhcp-1.4.0p1/README	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/README	Wed Dec 24 18:58:00 1997
***************
*** 1,9 ****
! 		<< DHCP WIDE-Implementation, version 1.3.6 >>
  
  							April, 1997.
  
     This package is a distribution kit of DHCP WIDE-Implementation
!    version 1.3.6.  DHCP (Dynamic Host Configuration Protocol) is a
     protocol which provides informations to computer when it boots [1-4].
     This release includes DHCP server, relay agent, and client.
  
--- 1,9 ----
! 		<< DHCP WIDE-Implementation, version 1.4.0 >>
  
  							April, 1997.
  
     This package is a distribution kit of DHCP WIDE-Implementation
!    version 1.4.0.  DHCP (Dynamic Host Configuration Protocol) is a
     protocol which provides informations to computer when it boots [1-4].
     This release includes DHCP server, relay agent, and client.
  
***************
*** 20,26 ****
  <Package>
  
     You can get the latest version from;
! 	ftp://sh.wide.ad.jp/WIDE/free-ware/dhcp/
  
     You can find following files and directories, if you extract this
     package.
--- 20,26 ----
  <Package>
  
     You can get the latest version from;
! 	ftp://sh.wide.ad.jp/WIDE/free-ware/dhcp/dhcp-current.tar.gz
  
     You can find following files and directories, if you extract this
     package.
***************
*** 40,56 ****
       o tools		DHCP packet monitoring tool (this program
  			   is very dirty. Just for debugging)
  
!    Currently, we confirm operation on BSD/386 1.1, BSD/OS 2.0.1, NEWS-OS
!    4.2, SunOS 4.1.4 and FreeBSD 1.1.5.1. Also it will be very easy to
!    port them to another OS which has bpf (Berkeley Packet Filter).
  
     If you execute following command in the top directory, all modules
     are compiled with default settings.  Please refer to README of each
     directory about the more detail instruction of installation.
  
  	SONY NEWS-OS;		make OSTYPE=news
! 	BSD/386 1.1;		make OSTYPE=oldbsdi
! 	BSD/OS 2.0.1;		make OSTYPE=bsdos
  	SunOS 4.1.4;		make OSTYPE=sunos4
  	FreeBSD;		make OSTYPE=FreeBSD
  
--- 40,55 ----
       o tools		DHCP packet monitoring tool (this program
  			   is very dirty. Just for debugging)
  
!    Currently, we confirm operation on BSD/OS 3.1, NEWS-OS 4.2, SunOS
!    4.1.4 and FreeBSD 2.2.2. Also it will be very easy to port them to
!    another OS which has bpf (Berkeley Packet Filter).
  
     If you execute following command in the top directory, all modules
     are compiled with default settings.  Please refer to README of each
     directory about the more detail instruction of installation.
  
  	SONY NEWS-OS;		make OSTYPE=news
! 	BSD/OS 3.1;		make OSTYPE=bsdi
  	SunOS 4.1.4;		make OSTYPE=sunos4
  	FreeBSD;		make OSTYPE=FreeBSD
  
diff -rcN dhcp-1.4.0p1/README.jis dhcp-1.4.0p2/README.jis
*** dhcp-1.4.0p1/README.jis	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/README.jis	Wed Dec 24 18:56:39 1997
***************
*** 1,8 ****
! 	<< DHCP WIDE-Implementation, version 1.3.6 >>
  
! 						   1997$BG/(B   4$B7n(B
  
!    $BK\%Q%C%1!<%8$O(BWIDE$BHG(BDHCP$B%P!<%8%g%s(B1.3.6$B$NG[I[%-%C%H$G$9!#(BDHCP
     (Dynamic Host Configuration Protocol)$B$O!"%3%s%T%e!<%?$,5/F0;~$KI,MW(B
     $B$H$9$k>pJs$r<+F0E*$K3d$jEv$F$k%W%m%H%3%k$G$9(B[1-5]$B!#K\%j%j!<%9$K$O(B
     DHCP$B$N%5!<%P!"%j%l!<%(!<%8%'%s%H!"%/%i%$%"%s%H$,4^$^$l$F$$$^$9!#(B
--- 1,8 ----
! 	<< DHCP WIDE-Implementation, version 1.4.0 >>
  
! 						   1997$BG/(B   12$B7n(B
  
!    $BK\%Q%C%1!<%8$O(BWIDE$BHG(BDHCP$B%P!<%8%g%s(B1.4.0$B$NG[I[%-%C%H$G$9!#(BDHCP
     (Dynamic Host Configuration Protocol)$B$O!"%3%s%T%e!<%?$,5/F0;~$KI,MW(B
     $B$H$9$k>pJs$r<+F0E*$K3d$jEv$F$k%W%m%H%3%k$G$9(B[1-5]$B!#K\%j%j!<%9$K$O(B
     DHCP$B$N%5!<%P!"%j%l!<%(!<%8%'%s%H!"%/%i%$%"%s%H$,4^$^$l$F$$$^$9!#(B
***************
*** 19,25 ****
  <$B%Q%C%1!<%8(B>
  
    $B:G?7HG$O0J2<$N>l=j$+$iF~<j$G$-$^$9(B:
! 	ftp://sh.wide.ad.jp/WIDE/free-ware/dhcp/
  
    $BK\%Q%C%1!<%8$rE83+$9$k$H0J2<$N$h$&$J%U%!%$%k$H%G%#%l%/%H%j$,$G$-$^$9!#(B
  
--- 19,25 ----
  <$B%Q%C%1!<%8(B>
  
    $B:G?7HG$O0J2<$N>l=j$+$iF~<j$G$-$^$9(B:
! 	ftp://sh.wide.ad.jp/WIDE/free-ware/dhcp/dhcp-current.tar.gz
  
    $BK\%Q%C%1!<%8$rE83+$9$k$H0J2<$N$h$&$J%U%!%$%k$H%G%#%l%/%H%j$,$G$-$^$9!#(B
  
***************
*** 37,53 ****
      $B!&(Btools			DHCP$B%Q%1%C%H%b%K%?%D!<%k(B (this program is
  				very dirty. just for debugging)
  
!   $B8=:_$N=j!"(BBSD/386 1.1, BSD/OS 2.0.1, NEWS-OS 4.2, SunOS 4.1.3, FreeBSD
!   1.1.5.1$B$G$NF0:n$r3NG'$7$F$$$^$9$,!"(Bbpf(Berkeley Packet Filter)$B$r;}$D(B
!   OS$B$X$N0\?"$OMF0W$@$H;W$o$l$^$9!#(B
  
    $B%H%C%W%G%#%l%/%H%j$G0J2<$N%3%^%s%I$r<B9T$9$k$H!"I8=`@_Dj$GA4$F$N%b%8%e!<(B
    $B%k$,%3%s%Q%$%k$5$l$^$9!#>\$7$$%$%s%9%H!<%kJ}K!$J$I$K$D$$$F$O!"3F%G%#(B
    $B%l%/%H%j$N(BREADME$B$r;2>H$7$F2<$5$$!#(B
  
  	$B!&(B SONY NEWS$B$N>l9g(B;	make OSTYPE=news
! 	$B!&(B BSD/386 1.1$B$N>l9g(B;	make OSTYPE=oldbsdi
! 	$B!&(B BSD/OS 2.0.1$B$N>l9g(B;	make OSTYPE=bsdos
  	$B!&(B SunOS 4.1.4$B$N>l9g(B;	make OSTYPE=sunos4
  	$B!&(B FreeBSD$B$N>l9g(B;	make OSTYPE=FreeBSD
  
--- 37,52 ----
      $B!&(Btools			DHCP$B%Q%1%C%H%b%K%?%D!<%k(B (this program is
  				very dirty. just for debugging)
  
!   $B8=:_$N=j!"(BBSD/OS 3.1, NEWS-OS 4.2, SunOS 4.1.4, FreeBSD 2.2.2$B$G$NF0(B
!   $B:n$r3NG'$7$F$$$^$9$,!"(Bbpf(Berkeley Packet Filter)$B$r;}$D(BOS$B$X$N0\?"$O(B
!   $BMF0W$@$H;W$o$l$^$9!#(B
  
    $B%H%C%W%G%#%l%/%H%j$G0J2<$N%3%^%s%I$r<B9T$9$k$H!"I8=`@_Dj$GA4$F$N%b%8%e!<(B
    $B%k$,%3%s%Q%$%k$5$l$^$9!#>\$7$$%$%s%9%H!<%kJ}K!$J$I$K$D$$$F$O!"3F%G%#(B
    $B%l%/%H%j$N(BREADME$B$r;2>H$7$F2<$5$$!#(B
  
  	$B!&(B SONY NEWS$B$N>l9g(B;	make OSTYPE=news
! 	$B!&(B BSD/OS 3.1$B$N>l9g(B;	make OSTYPE=bsdi
  	$B!&(B SunOS 4.1.4$B$N>l9g(B;	make OSTYPE=sunos4
  	$B!&(B FreeBSD$B$N>l9g(B;	make OSTYPE=FreeBSD
  
diff -rcN dhcp-1.4.0p1/client/Makefile.FreeBSD dhcp-1.4.0p2/client/Makefile.FreeBSD
*** dhcp-1.4.0p1/client/Makefile.FreeBSD	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/client/Makefile.FreeBSD	Thu Sep 11 10:01:24 1997
***************
*** 1,26 ****
  INCLUDE = ../server/dhcp.h dhcpc.h common.h ../server/common_subr.h dhcpc_subr.h
  OBJ = dhcpc_subr.o flushroute.o getmac.o common_subr.o dhcpc.o
  
! CC = gcc
! CFLAGS = -Wall -g -I. -I../server -DRETRY_FOREVER #-DDEBUG
! #CC = cc
! #CFLAGS = -g -I. -I../server -DRETRY_FOREVER #-DDEBUG
  LDFLAGS = -lkvm
  
! BIN = 		/usr/local/sbin
  LIBEXEC =	/usr/local/libexec
  MAN =		/usr/local/man
  
  dhcpc: ${OBJ}
  	${CC} ${CFLAGS} -o dhcpc ${OBJ} ${LDFLAGS}
  
  install: dhcpc
! 	${INSTALL} -m 755 -s dhcpc ${SBIN}/dhcpc
! 	cp dhcpc.8 ${MAN}/man8/dhcpc.8
! 	gzip ${MAN}/man8/dhcpc.8
  
  clean:
! 	rm -f *~ *.o *core* dhcpc
  
  dhcpc.o:	dhcpc.c config.h ${INCLUDE}
  dhcpc_subr.o:	dhcpc_subr.c ${INCLUDE}
--- 1,27 ----
  INCLUDE = ../server/dhcp.h dhcpc.h common.h ../server/common_subr.h dhcpc_subr.h
  OBJ = dhcpc_subr.o flushroute.o getmac.o common_subr.o dhcpc.o
  
! CC = cc
! CFLAGS += -O -I. -I../server -DRETRY_FOREVER #-DDEBUG
  LDFLAGS = -lkvm
  
! SBIN = 		/usr/local/sbin
  LIBEXEC =	/usr/local/libexec
  MAN =		/usr/local/man
+ CP =		/bin/cp
+ RM =		/bin/rm
+ GZIP =		/usr/bin/gzip
  
  dhcpc: ${OBJ}
  	${CC} ${CFLAGS} -o dhcpc ${OBJ} ${LDFLAGS}
  
  install: dhcpc
! 	${INSTALL} -c -m 755 -s dhcpc ${SBIN}/dhcpc
! 	${CP} dhcpc.8 ${MAN}/man8/dhcpc.8
! 	${GZIP} ${MAN}/man8/dhcpc.8
  
  clean:
! 	${RM} -f *~ *.o *core* dhcpc
  
  dhcpc.o:	dhcpc.c config.h ${INCLUDE}
  dhcpc_subr.o:	dhcpc_subr.c ${INCLUDE}
diff -rcN dhcp-1.4.0p1/client/Makefile.bsdi dhcp-1.4.0p2/client/Makefile.bsdi
*** dhcp-1.4.0p1/client/Makefile.bsdi	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/client/Makefile.bsdi	Thu Sep 11 09:03:42 1997
***************
*** 2,11 ****
  OBJ = dhcpc_subr.o flushroute.o getmac.o common_subr.o dhcpc.o
  
  INSTALL = install
! CC = shlicc
! CFLAGS = -Wall -g -I. -I../server -DRETRY_FOREVER #-DVIP -DDEBUG
! #CC = cc
! #CFLAGS = -g -I. -I../server -DRETRY_FOREVER #-DVIP -DDEBUG
  LDFLAGS = -lkvm
  
  BIN =		/usr/contrib/bin
--- 2,9 ----
  OBJ = dhcpc_subr.o flushroute.o getmac.o common_subr.o dhcpc.o
  
  INSTALL = install
! CC = shlicc2
! CFLAGS = -O -I. -I../server -DRETRY_FOREVER #-DVIP -DDEBUG
  LDFLAGS = -lkvm
  
  BIN =		/usr/contrib/bin
diff -rcN dhcp-1.4.0p1/client/Makefile.news dhcp-1.4.0p2/client/Makefile.news
*** dhcp-1.4.0p1/client/Makefile.news	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/client/Makefile.news	Thu Sep 11 09:04:05 1997
***************
*** 3,11 ****
  LDFLAGS = -lmld
  
  CC = gcc
! CFLAGS = -Wall -g -I. -I../server -DRETRY_FOREVER #-DDEBUG
! #CC = cc
! #CFLAGS = -g -I. -I../server -DRETRY_FOREVER #-DDEBUG
  
  dhcpc: ${OBJ}
  	${CC} ${CFLAGS} -o dhcpc ${OBJ} ${LDFLAGS}
--- 3,9 ----
  LDFLAGS = -lmld
  
  CC = gcc
! CFLAGS = -O -I. -I../server -DRETRY_FOREVER #-DDEBUG
  
  dhcpc: ${OBJ}
  	${CC} ${CFLAGS} -o dhcpc ${OBJ} ${LDFLAGS}
diff -rcN dhcp-1.4.0p1/client/Makefile.osf1 dhcp-1.4.0p2/client/Makefile.osf1
*** dhcp-1.4.0p1/client/Makefile.osf1	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/client/Makefile.osf1	Thu Sep 11 09:04:10 1997
***************
*** 3,11 ****
  LDFLAGS = -lmld
  
  CC = gcc
! CFLAGS = -Wall -g -I. -I../server -DRETRY_FOREVER #-DDEBUG
! #CC = cc
! #CFLAGS = -g -I. -I../server -DRETRY_FOREVER #-DDEBUG
  
  dhcpc: ${OBJ}
  	${CC} ${CFLAGS} -o dhcpc ${OBJ} ${LDFLAGS}
--- 3,9 ----
  LDFLAGS = -lmld
  
  CC = gcc
! CFLAGS = -O -I. -I../server -DRETRY_FOREVER #-DDEBUG
  
  dhcpc: ${OBJ}
  	${CC} ${CFLAGS} -o dhcpc ${OBJ} ${LDFLAGS}
diff -rcN dhcp-1.4.0p1/client/Makefile.sunos4 dhcp-1.4.0p2/client/Makefile.sunos4
*** dhcp-1.4.0p1/client/Makefile.sunos4	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/client/Makefile.sunos4	Thu Sep 11 09:04:14 1997
***************
*** 3,11 ****
  LDFLAGS = -lkvm
  
  CC = gcc
! CFLAGS = -Wall -g -I. -I../server -DRETRY_FOREVER -DNOIPOPTION #-DDEBUG
! #CC = cc
! #CFLAGS = -g -I. -I../server -DRETRY_FOREVER -DNOIPOPTION #-DDEBUG
  
  dhcpc: ${OBJ}
  	${CC} ${CFLAGS} -o dhcpc ${OBJ} ${LDFLAGS}
--- 3,9 ----
  LDFLAGS = -lkvm
  
  CC = gcc
! CFLAGS = -O -I. -I../server -DRETRY_FOREVER -DNOIPOPTION #-DDEBUG
  
  dhcpc: ${OBJ}
  	${CC} ${CFLAGS} -o dhcpc ${OBJ} ${LDFLAGS}
diff -rcN dhcp-1.4.0p1/client/config.h dhcp-1.4.0p2/client/config.h
*** dhcp-1.4.0p1/client/config.h	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/client/config.h	Fri Nov 14 00:31:22 1997
***************
*** 37,46 ****
   * WIDE project has the rights to redistribute these changes.
   */
  
- #ifndef DHCP_CACHE
- #define DHCP_CACHE  "/etc/dhcp_cache"
- #endif
- 
  #define FIRSTTIMER          4
  #define MAXTIMER           64
  #define INIT_WAITING       10
--- 37,42 ----
diff -rcN dhcp-1.4.0p1/client/dhcpc.c dhcp-1.4.0p2/client/dhcpc.c
*** dhcp-1.4.0p1/client/dhcpc.c	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/client/dhcpc.c	Tue Apr 14 22:43:32 1998
***************
*** 83,88 ****
--- 83,89 ----
  struct if_info intface;
  struct dhcp_param *param_list;
  char pid_filename[MAXPATHLEN];
+ char cache_filename[MAXPATHLEN];
  
  int (*fsm[MAX_STATES])();
  
***************
*** 197,202 ****
--- 198,229 ----
  }
  
  
+ u_long
+ default_netmask(ipaddr)
+      struct in_addr *ipaddr;
+ {
+   int top = 0;
+   struct in_addr dfltnetmask;
+ 
+   top = ntohl(ipaddr->s_addr) >> 30;
+ 
+   switch (top) {
+   case 0:  /* class A */
+     dfltnetmask.s_addr = htonl(0xff000000);
+     break;
+   case 2:  /* class B */
+     dfltnetmask.s_addr = htonl(0xffff0000);
+     break;
+   case 3:  /* class C */
+   default:
+     dfltnetmask.s_addr = htonl(0xffffff00);
+     break;
+   }
+ 
+   return(dfltnetmask.s_addr);
+ }
+ 
+ 
  void
  use_parameter(paramp)
    struct dhcp_param *paramp;
***************
*** 211,227 ****
    if (paramp->subnet_mask != NULL) {
      mask.s_addr = paramp->subnet_mask->s_addr;
    } else {
!     mask.s_addr = 0;
    }
    if (paramp->brdcast_addr != NULL) {
      brdaddr.s_addr = paramp->brdcast_addr->s_addr;
    } else {
!     brdaddr.s_addr = 0;
    }
  
  #ifndef DEBUG
!   if (config_if(&intface, &addr, ((mask.s_addr != 0) ? &mask : NULL),
! 		((brdaddr.s_addr != 0) ? &brdaddr : NULL)) == 0) {
      set_route(paramp);
  #ifdef VIP
      (void) sndcamt();
--- 238,253 ----
    if (paramp->subnet_mask != NULL) {
      mask.s_addr = paramp->subnet_mask->s_addr;
    } else {
!     mask.s_addr = default_netmask(&addr);
    }
    if (paramp->brdcast_addr != NULL) {
      brdaddr.s_addr = paramp->brdcast_addr->s_addr;
    } else {
!     brdaddr.s_addr = (addr.s_addr | ~(mask.s_addr));
    }
  
  #ifndef DEBUG
!   if (config_if(&intface, &addr, &mask, &brdaddr) == 0) {
      set_route(paramp);
  #ifdef VIP
      (void) sndcamt();
***************
*** 384,390 ****
      if (param_list != NULL) {
        set_relinfo(&tmp_reqspec, param_list, errmsg);
        dhcp_release(&tmp_reqspec);
!       if ((fd = open(DHCP_CACHE, O_WRONLY, 0444)) >= 0) {
  	zero = 0;
  	write(fd, (void *) &zero, sizeof(zero));
  	close(fd);
--- 410,416 ----
      if (param_list != NULL) {
        set_relinfo(&tmp_reqspec, param_list, errmsg);
        dhcp_release(&tmp_reqspec);
!       if ((fd = open(cache_filename, O_WRONLY, 0444)) >= 0) {
  	zero = 0;
  	write(fd, (void *) &zero, sizeof(zero));
  	close(fd);
***************
*** 408,415 ****
  void
  finish()
  {
!   updown_if(&intface, DOWN);
! 
    unlink(pid_filename);
  
    exit(0);
--- 434,440 ----
  void
  finish()
  {
!   reset_if(&intface, DOWN);
    unlink(pid_filename);
  
    exit(0);
***************
*** 619,625 ****
    if (ether_write(dhcpif.fd, &sbuf.buf[QWOFF], sbuf.size) < sbuf.size) {
  #ifdef RETRY_FOREVER
      syslog(LOG_NOTICE, "Can't send DHCPDISCOVER: %m");
!     syslog(LOG_NOTICE, "(The client continues to try to use DHCP.)");
  #else
      syslog(LOG_WARNING, "Can't send DHCPDISCOVER: %m");
      return(-1);
--- 644,650 ----
    if (ether_write(dhcpif.fd, &sbuf.buf[QWOFF], sbuf.size) < sbuf.size) {
  #ifdef RETRY_FOREVER
      syslog(LOG_NOTICE, "Can't send DHCPDISCOVER: %m");
!     syslog(LOG_NOTICE, "(Continue to try to use DHCP.)");
  #else
      syslog(LOG_WARNING, "Can't send DHCPDISCOVER: %m");
      return(-1);
***************
*** 1035,1041 ****
    time_t curr_epoch = 0;
    bzero(sbuf.buf, sbuf.size + QWOFF);
  
!   if ((fd = open(DHCP_CACHE, O_WRONLY | O_CREAT | O_TRUNC, 0444)) >= 0) {
      length = ntohs(rcv.udp->uh_ulen) + rcv.ip->ip_hl * WORD + ETHERHL;
      write(fd, (void *) &param_list->lease_origin,
  	  sizeof(param_list->lease_origin));
--- 1060,1066 ----
    time_t curr_epoch = 0;
    bzero(sbuf.buf, sbuf.size + QWOFF);
  
!   if ((fd = open(cache_filename, O_WRONLY | O_CREAT | O_TRUNC, 0444)) >= 0) {
      length = ntohs(rcv.udp->uh_ulen) + rcv.ip->ip_hl * WORD + ETHERHL;
      write(fd, (void *) &param_list->lease_origin,
  	  sizeof(param_list->lease_origin));
***************
*** 1425,1433 ****
    int n = 0;
    time_t lease_origin = 0;
  
!   /* if DHCP_CACHE doesn't exist, this is the first time.
       So we start from INIT state */
!   if ((fd = open(DHCP_CACHE, O_RDONLY, 0)) < 0)
      return(INIT);
  
    /* read lease origin epoch */
--- 1450,1458 ----
    int n = 0;
    time_t lease_origin = 0;
  
!   /* if cache file doesn't exist, this is the first time.
       So we start from INIT state */
!   if ((fd = open(cache_filename, O_RDONLY, 0)) < 0)
      return(INIT);
  
    /* read lease origin epoch */
***************
*** 1450,1456 ****
    }
  
    if (dhcpif.rbufsize < length + QWOFF) {
!     syslog(LOG_WARNING, "%s is too long", DHCP_CACHE);
      close(fd);
      return(INIT);
    }
--- 1475,1481 ----
    }
  
    if (dhcpif.rbufsize < length + QWOFF) {
!     syslog(LOG_WARNING, "%s is too long", cache_filename);
      close(fd);
      return(INIT);
    }
***************
*** 1745,1751 ****
    while (1) {
      if ((next_state = (*fsm[curr_state])()) < 0) {
        syslog(LOG_WARNING, "Some exception occurs in finite state machine");
!       updown_if(ifp, DOWN);
        return(curr_state);
      }
      prev_state = curr_state;
--- 1770,1776 ----
    while (1) {
      if ((next_state = (*fsm[curr_state])()) < 0) {
        syslog(LOG_WARNING, "Some exception occurs in finite state machine");
!       reset_if(ifp, DOWN);
        return(curr_state);
      }
      prev_state = curr_state;
diff -rcN dhcp-1.4.0p1/client/dhcpc.h dhcp-1.4.0p2/client/dhcpc.h
*** dhcp-1.4.0p1/client/dhcpc.h	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/client/dhcpc.h	Fri Nov 14 02:21:26 1997
***************
*** 47,52 ****
--- 47,62 ----
  #endif
  #endif /*sony_news*/
  
+ #if defined(__bsdi__) || defined(__FreeBSD__)
+ #ifndef PATH_CACHE_PREFIX
+ #define PATH_CACHE_PREFIX	"/var/db/dhcpc_cache"
+ #endif
+ #else /* not BSD/OS nor FreeBSD */
+ #ifndef PATH_CACHE_PREFIX
+ #define PATH_CACHE_PREFIX	"/etc/dhcpc_cache"
+ #endif
+ #endif
+ 
  struct client_id {
    unsigned char   type,
                    len;
diff -rcN dhcp-1.4.0p1/client/dhcpc_subr.c dhcp-1.4.0p2/client/dhcpc_subr.c
*** dhcp-1.4.0p1/client/dhcpc_subr.c	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/client/dhcpc_subr.c	Fri Nov 14 00:39:55 1997
***************
*** 161,166 ****
--- 161,167 ----
  struct ps_udph spudph;
  struct bpf_hdr *rbpf;
  extern char pid_filename[];
+ extern char cache_filename[];
  
  int config_if();
  void set_route();
***************
*** 1112,1117 ****
--- 1113,1119 ----
    openlog("dhcpc", LOG_PID | LOG_CONS | LOG_PERROR, LOG_LOCAL0);
  
    sprintf(pid_filename, "%s.%s.pid", PATH_PID_PREFIX, ifp->name);
+   sprintf(cache_filename, "%s.%s", PATH_CACHE_PREFIX, ifp->name);
    for (n = 0; n < 5; n++) {
      if ((fd = open(pid_filename, O_RDWR|O_CREAT|O_EXCL, 0666)) > 0)
        break;
***************
*** 1315,1320 ****
--- 1317,1323 ----
    openlog("dhcpc", LOG_PID | LOG_CONS | LOG_PERROR, LOG_LOCAL0);
  
    sprintf(pid_filename, "%s.%s.pid", PATH_PID_PREFIX, ifp->name);
+   sprintf(cache_filename, "%s.%s", PATH_CACHE_PREFIX, ifp->name);
    for (n = 0; n < 5; n++) {
      if ((fd = open(pid_filename, O_RDWR|O_CREAT|O_EXCL, 0666)) > 0)
        break;
***************
*** 2528,2538 ****
    struct msghdr msg;
    struct iovec bufvec[1];
    int bufsize = DFLTDHCPLEN;
- #if 0
  #if defined(__bsdi__) || defined(__FreeBSD__)
    int on;
  #endif
- #endif
  
    if (sockfd == -1) {
      struct sockaddr_in myaddr;
--- 2531,2539 ----
***************
*** 2556,2569 ****
        return(-1);
      }
  
- #if 0
      on = 1;
      if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)) < 0) {
        close(sockfd);
        sockfd = -1;
        return(-1);
      }
- #endif
    }
  
    bzero(&dst, sizeof(dst));
--- 2557,2568 ----
***************
*** 3175,3181 ****
        return(-1);
      }
      for (i = 0; i < max; i++) {
!       param->mtu_plateau_table->shortnum[i] = GETHS(buf[i * 2 + 2]);
      }
    }
  
--- 3174,3180 ----
        return(-1);
      }
      for (i = 0; i < max; i++) {
!       param->mtu_plateau_table->shortnum[i] = GETHS(&buf[i * 2 + 2]);
      }
    }
  
diff -rcN dhcp-1.4.0p1/client/flushroute.c dhcp-1.4.0p2/client/flushroute.c
*** dhcp-1.4.0p1/client/flushroute.c	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/client/flushroute.c	Tue Apr 14 20:14:33 1998
***************
*** 34,147 ****
   * SUCH DAMAGE.
   */
  
! #if !defined(__bsdi__) && !defined(__FreeBSD__)
  
! #include <stdio.h>
! #include <nlist.h>
! #include <syslog.h>
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <sys/mbuf.h>
! #include <sys/ioctl.h>
! #include <net/route.h>
! #include <netinet/in.h>
! #include <rpc/types.h>
! 
! #ifdef __osf__
! #define rtentry ortentry
! #endif
! 
! /*
!  * from Berkeley's code (route.c 5.6 (Berkeley) 6/5/86)
!  */
! static struct nlist nl[] = {
! #define N_RTHOST        0
!         { "_rthost" },
! #define N_RTNET         1
!         { "_rtnet" },
! #define N_RTHASHSIZE    2
!         { "_rthashsize" },
!         { "" }
! };
! 
! int
! flushroutes(dummy)
!   char *dummy;
! {
!   static int first = 1;
!   int s = 0;
!   struct mbuf mb;
!   register struct rtentry *rt = NULL;
!   register struct mbuf *m = NULL;
!   struct mbuf **routehash = NULL;
!   int rthashsize = 0, i = 0, doinghost = 1, kmem = 0;
! 
!   bzero(&mb, sizeof(mb));
! 
!   if ((s = socket(AF_INET, SOCK_RAW, 0)) < 0) {
!     return(-1);
!   }
! 
!   if (first) {
!     first = 0;
!     nlist("/vmunix", nl);
!   }
!   if (nl[N_RTHOST].n_value == 0) {
!     syslog(LOG_LOCAL0|LOG_ERR, "\"rthost\", symbol not in namelist");
!     exit(1);
!   }
!   if (nl[N_RTNET].n_value == 0) {
!     syslog(LOG_LOCAL0|LOG_ERR, "\"rtnet\", symbol not in namelist");
!     exit(1);
!   }
!   if (nl[N_RTHASHSIZE].n_value == 0) {
!     syslog(LOG_LOCAL0|LOG_ERR,
! 	   "\"rthashsize\", symbol not in namelist");
!     exit(1);
!   }
!   kmem = open("/dev/kmem", 0);
!   if (kmem < 0) {
!     syslog(LOG_LOCAL0|LOG_ERR, "/dev/kmem: %m");
!     exit(1);
!   }
!   lseek(kmem, nl[N_RTHASHSIZE].n_value, 0);
!   read(kmem, &rthashsize, sizeof (rthashsize));
!   routehash = (struct mbuf **)calloc(1, rthashsize*sizeof (struct mbuf *));
! 
!   lseek(kmem, nl[N_RTHOST].n_value, 0);
!   read(kmem, routehash, rthashsize*sizeof (struct mbuf *));
! again:
!   for (i = 0; i < rthashsize; i++) {
!     if (routehash[i] == 0)
!       continue;
!     m = routehash[i];
!     while (m) {
!       lseek(kmem, m, 0);
!       read(kmem, &mb, sizeof (mb));
!       rt = mtod(&mb, struct rtentry *);
!       if (((struct sockaddr_in *)&rt->rt_dst)->sin_addr.s_addr
! 	  != INADDR_LOOPBACK) {
! 	ioctl(s, SIOCDELRT, (caddr_t)rt);
!       }
!       m = mb.m_next;
!     }
!   }
!   if (doinghost) {
!     lseek(kmem, nl[N_RTNET].n_value, 0);
!     read(kmem, routehash, rthashsize*sizeof (struct mbuf *));
!     doinghost = 0;
!     goto again;
!   }
!   close(kmem);
!   close(s);
!   free(routehash);
!   return(0);
! }
! 
! #else /* __bsdi__ */
! 
! /* It's BSD/OS 2.* or later or FreeBSD */
  
  /*
   * Modified by tomy@sfc.wide.ad.jp
--- 34,42 ----
   * SUCH DAMAGE.
   */
  
! #if defined(__bsdi__) || (__FreeBSD__ >= 2)
  
! /* It's BSD/OS or FreeBSD 2.x */
  
  /*
   * Modified by tomy@sfc.wide.ad.jp
***************
*** 216,221 ****
--- 111,117 ----
    for (n = 0; n < 10; n++) {
      if ((buf = (caddr_t) malloc(size)) == NULL) {
        syslog(LOG_ERR, "no more memory");
+       close(s);
        return(-1);
      }
      ifc.ifc_len = size;
***************
*** 224,229 ****
--- 120,126 ----
        break;
      if (errno != EINVAL) {
        syslog(LOG_ERR, "SIOCGIFCONF: %m");
+       close(s);
        return(-1);
      }
      free(buf);
***************
*** 232,237 ****
--- 129,135 ----
    }
    if (buf == NULL) {
      syslog(LOG_ERR, "SIOCGIFCONF: %m");
+     close(s);
      return(-1);
    }
    for (n = 0, sdl = NULL; n < ifc.ifc_len; ) {
***************
*** 249,254 ****
--- 147,153 ----
    }
    if (sdl == NULL) {
      syslog(LOG_ERR, "%s: I/F not found", ifname);
+     close(s);
      return(-1);
    }
    n = sdl->sdl_index;
***************
*** 256,261 ****
--- 155,162 ----
    syslog(LOG_ERR, "index for %s is %d", ifname, n);
  #endif
    free(buf);
+   close(s);
+ 
    return(n);
  }
  
***************
*** 338,341 ****
    close(s);
    return(0);
  }
! #endif /* __bsdi__ or FreeBSD*/
--- 239,348 ----
    close(s);
    return(0);
  }
! 
! #else /* __bsdi__ or FreeBSD 2.x */
! 
! #include <stdio.h>
! #include <nlist.h>
! #include <syslog.h>
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <sys/mbuf.h>
! #include <sys/ioctl.h>
! #include <net/route.h>
! #include <netinet/in.h>
! #include <rpc/types.h>
! 
! #ifdef __osf__
! #define rtentry ortentry
! #endif
! 
! /*
!  * from Berkeley's code (route.c 5.6 (Berkeley) 6/5/86)
!  */
! static struct nlist nl[] = {
! #define N_RTHOST        0
!         { "_rthost" },
! #define N_RTNET         1
!         { "_rtnet" },
! #define N_RTHASHSIZE    2
!         { "_rthashsize" },
!         { "" }
! };
! 
! int
! flushroutes(dummy)
!   char *dummy;
! {
!   static int first = 1;
!   int s = 0;
!   struct mbuf mb;
!   register struct rtentry *rt = NULL;
!   register struct mbuf *m = NULL;
!   struct mbuf **routehash = NULL;
!   int rthashsize = 0, i = 0, doinghost = 1, kmem = 0;
! 
!   bzero(&mb, sizeof(mb));
! 
!   if ((s = socket(AF_INET, SOCK_RAW, 0)) < 0) {
!     return(-1);
!   }
! 
!   if (first) {
!     first = 0;
!     nlist("/vmunix", nl);
!   }
!   if (nl[N_RTHOST].n_value == 0) {
!     syslog(LOG_LOCAL0|LOG_ERR, "\"rthost\", symbol not in namelist");
!     exit(1);
!   }
!   if (nl[N_RTNET].n_value == 0) {
!     syslog(LOG_LOCAL0|LOG_ERR, "\"rtnet\", symbol not in namelist");
!     exit(1);
!   }
!   if (nl[N_RTHASHSIZE].n_value == 0) {
!     syslog(LOG_LOCAL0|LOG_ERR,
! 	   "\"rthashsize\", symbol not in namelist");
!     exit(1);
!   }
!   kmem = open("/dev/kmem", 0);
!   if (kmem < 0) {
!     syslog(LOG_LOCAL0|LOG_ERR, "/dev/kmem: %m");
!     exit(1);
!   }
!   lseek(kmem, nl[N_RTHASHSIZE].n_value, 0);
!   read(kmem, &rthashsize, sizeof (rthashsize));
!   routehash = (struct mbuf **)calloc(1, rthashsize*sizeof (struct mbuf *));
! 
!   lseek(kmem, nl[N_RTHOST].n_value, 0);
!   read(kmem, routehash, rthashsize*sizeof (struct mbuf *));
! again:
!   for (i = 0; i < rthashsize; i++) {
!     if (routehash[i] == 0)
!       continue;
!     m = routehash[i];
!     while (m) {
!       lseek(kmem, m, 0);
!       read(kmem, &mb, sizeof (mb));
!       rt = mtod(&mb, struct rtentry *);
!       if (((struct sockaddr_in *)&rt->rt_dst)->sin_addr.s_addr
! 	  != INADDR_LOOPBACK) {
! 	ioctl(s, SIOCDELRT, (caddr_t)rt);
!       }
!       m = mb.m_next;
!     }
!   }
!   if (doinghost) {
!     lseek(kmem, nl[N_RTNET].n_value, 0);
!     read(kmem, routehash, rthashsize*sizeof (struct mbuf *));
!     doinghost = 0;
!     goto again;
!   }
!   close(kmem);
!   close(s);
!   free(routehash);
!   return(0);
! }
! 
! #endif /* __bsdi__ or FreeBSD 2.x */
diff -rcN dhcp-1.4.0p1/relay/Makefile.FreeBSD dhcp-1.4.0p2/relay/Makefile.FreeBSD
*** dhcp-1.4.0p1/relay/Makefile.FreeBSD	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/relay/Makefile.FreeBSD	Thu Sep 11 10:10:42 1997
***************
*** 1,22 ****
  OBJ = relay.o getmac.o common_subr.o interface.o
! CC = gcc
! CFLAGS = -g -Wall -I. -I../server
! #CC = cc
! #CFLAGS = -g -I. -I../server
  LDFLAGS = -lkvm
  SBIN =		/usr/local/sbin
  LIBEXEC = 	/usr/local/libexec
  MAN =		/usr/local/man
  
  relay: ${OBJ}
  	${CC} ${CFLAGS} -o relay ${OBJ} ${LDFLAGS}
  
  install: relay
  	${INSTALL} -m 755 -s relay ${SBIN}/relay
! 	cp relay.8 ${MAN}/man8/relay.8
! 	gzip ${MAN}/man8/relay.8
! 	cp dhcpdb.server.5 ${MAN}/man5/dhcpdb.server.5
! 	gzip ${MAN}/man5/dhcpdb.server.5
  
  relay.o:	relay.c common.h ../server/dhcp.h ../server/common_subr.h
  common_subr.o:	../server/common_subr.c ../server/dhcp.h common.h ../server/common_subr.h
--- 1,27 ----
  OBJ = relay.o getmac.o common_subr.o interface.o
! 
! CC = cc
! CFLAGS += -O -I. -I../server
  LDFLAGS = -lkvm
  SBIN =		/usr/local/sbin
  LIBEXEC = 	/usr/local/libexec
  MAN =		/usr/local/man
+ CP =		/bin/cp
+ RM =		/bin/rm
+ GZIP =		/usr/bin/gzip
  
  relay: ${OBJ}
  	${CC} ${CFLAGS} -o relay ${OBJ} ${LDFLAGS}
  
  install: relay
  	${INSTALL} -m 755 -s relay ${SBIN}/relay
! 	${CP} relay.8 ${MAN}/man8/relay.8
! 	${GZIP} ${MAN}/man8/relay.8
! 	${CP} dhcpdb.server.5 ${MAN}/man5/dhcpdb.server.5
! 	${GZIP} ${MAN}/man5/dhcpdb.server.5
! 
! clean:
! 	${RM} -f *~ *.o *core* relay
  
  relay.o:	relay.c common.h ../server/dhcp.h ../server/common_subr.h
  common_subr.o:	../server/common_subr.c ../server/dhcp.h common.h ../server/common_subr.h
***************
*** 27,32 ****
  
  getmac.o:	../server/getmac.c
  	${CC} ${CFLAGS} -c ../server/getmac.c
- 
- clean:
- 	rm -f *~ *.o *core* relay
--- 32,34 ----
diff -rcN dhcp-1.4.0p1/relay/Makefile.bsdi dhcp-1.4.0p2/relay/Makefile.bsdi
*** dhcp-1.4.0p1/relay/Makefile.bsdi	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/relay/Makefile.bsdi	Thu Sep 11 09:04:39 1997
***************
*** 1,8 ****
  OBJ = relay.o getmac.o common_subr.o interface.o
! CC = shlicc
! CFLAGS = -g -Wall -I. -I../server
! #CC = cc
! #CFLAGS = -g -I. -I../server
  LDFLAGS = -lkvm
  
  relay: ${OBJ}
--- 1,7 ----
  OBJ = relay.o getmac.o common_subr.o interface.o
! 
! CC = shlicc2
! CFLAGS = -O -I. -I../server
  LDFLAGS = -lkvm
  
  relay: ${OBJ}
diff -rcN dhcp-1.4.0p1/relay/Makefile.news dhcp-1.4.0p2/relay/Makefile.news
*** dhcp-1.4.0p1/relay/Makefile.news	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/relay/Makefile.news	Thu Sep 11 09:04:53 1997
***************
*** 1,8 ****
  OBJ = relay.o ../server/common_subr.o ../server/interface.o
  CC = gcc
! CFLAGS = -g -Wall -I. -I../server
! #CC = cc
! #CFLAGS = -g -I. -I../server
  LDFLAGS =
  
  relay: ${OBJ}
--- 1,7 ----
  OBJ = relay.o ../server/common_subr.o ../server/interface.o
+ 
  CC = gcc
! CFLAGS = -O -I. -I../server
  LDFLAGS =
  
  relay: ${OBJ}
diff -rcN dhcp-1.4.0p1/relay/Makefile.osf1 dhcp-1.4.0p2/relay/Makefile.osf1
*** dhcp-1.4.0p1/relay/Makefile.osf1	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/relay/Makefile.osf1	Thu Sep 11 09:05:13 1997
***************
*** 1,8 ****
  OBJ = relay.o common_subr.o interface.o
! #CC = gcc
! #CFLAGS = -g -Wall -I. -I../server
  CC = cc
! CFLAGS = -g -I. -I../server
  LDFLAGS =
  
  relay: ${OBJ}
--- 1,7 ----
  OBJ = relay.o common_subr.o interface.o
! 
  CC = cc
! CFLAGS = -O -I. -I../server
  LDFLAGS =
  
  relay: ${OBJ}
diff -rcN dhcp-1.4.0p1/relay/Makefile.sunos4 dhcp-1.4.0p2/relay/Makefile.sunos4
*** dhcp-1.4.0p1/relay/Makefile.sunos4	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/relay/Makefile.sunos4	Thu Sep 11 09:05:28 1997
***************
*** 1,8 ****
  OBJ = relay.o getmac.o common_subr.o interface.o
  CC = gcc
! CFLAGS = -g -Wall -I. -I../server -DNOIPOPTION
! #CC = cc
! #CFLAGS = -g -I. -I../server -DNOIPOPTION
  LDFLAGS = -lkvm
  
  relay: ${OBJ}
--- 1,7 ----
  OBJ = relay.o getmac.o common_subr.o interface.o
+ 
  CC = gcc
! CFLAGS = -O -I. -I../server -DNOIPOPTION
  LDFLAGS = -lkvm
  
  relay: ${OBJ}
diff -rcN dhcp-1.4.0p1/server/Makefile.FreeBSD dhcp-1.4.0p2/server/Makefile.FreeBSD
*** dhcp-1.4.0p1/server/Makefile.FreeBSD	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/Makefile.FreeBSD	Fri Jan 30 18:03:57 1998
***************
*** 1,28 ****
  OBJ = dhcps.o database.o hash.o getmac.o common_subr.o \
        interface.o delarp.o
  LDFLAGS = -lkvm
- CC = gcc
- CFLAGS = -g -Wall -I. #-DCOMPAT_RFC1541 #-DNOICMPCHK
- #CC = cc
- #CFLAGS = -g -I. #-DCOMPAT_RFC1541 #-DNOICMPCHK
  SBIN =		/usr/local/sbin
  LIBEXEC =	/usr/local/libexec
  MAN =		/usr/local/man
  
  dhcps: ${OBJ}
  	${CC} ${CFLAGS} -o dhcps ${OBJ} ${LDFLAGS}
  
  install: dhcps
  	${INSTALL} -m 755 -s dhcps ${SBIN}/dhcps
! 	cp dhcpdb.pool.5 ${MAN}/man5/dhcpdb.pool.5
! 	gzip ${MAN}/man5/dhcpdb.pool.5
! 	cp dhcpdb.relay.5 ${MAN}/man5/dhcpdb.relay.5
! 	gzip ${MAN}/man5/dhcpdb.relay.5
! 	cp dhcps.8 ${MAN}/man8/dhcps.8
! 	gzip ${MAN}/man8/dhcps.8
  
  clean:
! 	rm -f *~ *.o *core* dhcps
  
  dhcps.o:	dhcps.c dhcp.h common.h common_subr.h hash.h dhcps.h
  database.o:	database.c dhcp.h common.h hash.h database.h
--- 1,30 ----
  OBJ = dhcps.o database.o hash.o getmac.o common_subr.o \
        interface.o delarp.o
+ 
+ CC = cc
+ CFLAGS += -O -I. #-DMAC_FILTER #-DCOMPAT_RFC1541 #-DNOICMPCHK
  LDFLAGS = -lkvm
  SBIN =		/usr/local/sbin
  LIBEXEC =	/usr/local/libexec
  MAN =		/usr/local/man
+ CP =		/bin/cp
+ RM =		/bin/rm
+ GZIP =		/usr/bin/gzip
  
  dhcps: ${OBJ}
  	${CC} ${CFLAGS} -o dhcps ${OBJ} ${LDFLAGS}
  
  install: dhcps
  	${INSTALL} -m 755 -s dhcps ${SBIN}/dhcps
! 	${CP} dhcpdb.pool.5 ${MAN}/man5/dhcpdb.pool.5
! 	${GZIP} ${MAN}/man5/dhcpdb.pool.5
! 	${CP} dhcpdb.relay.5 ${MAN}/man5/dhcpdb.relay.5
! 	${GZIP} ${MAN}/man5/dhcpdb.relay.5
! 	${CP} dhcps.8 ${MAN}/man8/dhcps.8
! 	${GZIP} ${MAN}/man8/dhcps.8
  
  clean:
! 	${RM} -f *~ *.o *core* dhcps
  
  dhcps.o:	dhcps.c dhcp.h common.h common_subr.h hash.h dhcps.h
  database.o:	database.c dhcp.h common.h hash.h database.h
diff -rcN dhcp-1.4.0p1/server/Makefile.bsdi dhcp-1.4.0p2/server/Makefile.bsdi
*** dhcp-1.4.0p1/server/Makefile.bsdi	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/Makefile.bsdi	Mon Feb 16 21:23:04 1998
***************
*** 1,10 ****
  OBJ = dhcps.o database.o hash.o getmac.o common_subr.o \
        interface.o delarp.o
  LDFLAGS = -lkvm
- CC = shlicc
- CFLAGS = -g -Wall #-DCOMPAT_RFC1541 #-DNOICMPCHK
- #CC = cc
- #CFLAGS = -g #-DCOMPAT_RFC1541 #-DNOICMPCHK
  
  dhcps: ${OBJ}
  	${CC} ${CFLAGS} -o dhcps ${OBJ} ${LDFLAGS}
--- 1,9 ----
  OBJ = dhcps.o database.o hash.o getmac.o common_subr.o \
        interface.o delarp.o
+ 
+ CC = shlicc2
+ CFLAGS = -O #-DMAC_FILTER #-DCOMPAT_RFC1541 #-DNOICMPCHK
  LDFLAGS = -lkvm
  
  dhcps: ${OBJ}
  	${CC} ${CFLAGS} -o dhcps ${OBJ} ${LDFLAGS}
diff -rcN dhcp-1.4.0p1/server/Makefile.news dhcp-1.4.0p2/server/Makefile.news
*** dhcp-1.4.0p1/server/Makefile.news	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/Makefile.news	Fri Jan 30 18:04:13 1998
***************
*** 1,10 ****
  OBJ = dhcps.o database.o hash.o ctime.o common_subr.o \
        interface.o delarp.o
! LDFLAGS =
  CC = gcc
! CFLAGS = -g -Wall #-DCOMPAT_RFC1541 #-DNOICMPCHK
! #CC = cc
! #CFLAGS = -g #-DCOMPAT_RFC1541 #-DNOICMPCHK
  
  dhcps: ${OBJ}
  	${CC} ${CFLAGS} -o dhcps ${OBJ} ${LDFLAGS}
--- 1,9 ----
  OBJ = dhcps.o database.o hash.o ctime.o common_subr.o \
        interface.o delarp.o
! 
  CC = gcc
! CFLAGS = -O #-DMAC_FILTER #-DCOMPAT_RFC1541 #-DNOICMPCHK
! LDFLAGS =
  
  dhcps: ${OBJ}
  	${CC} ${CFLAGS} -o dhcps ${OBJ} ${LDFLAGS}
diff -rcN dhcp-1.4.0p1/server/Makefile.osf1 dhcp-1.4.0p2/server/Makefile.osf1
*** dhcp-1.4.0p1/server/Makefile.osf1	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/Makefile.osf1	Fri Jan 30 18:04:43 1998
***************
*** 1,10 ****
  OBJ = dhcps.o database.o hash.o ctime.o common_subr.o \
        interface.o delarp.o
! LDFLAGS =
! #CC = gcc
! #CFLAGS = -g -Wall #-DCOMPAT_RFC1541 #-DNOICMPCHK
  CC = cc
! CFLAGS = -g #-DCOMPAT_RFC1541 #-DNOICMPCHK
  
  dhcps: ${OBJ}
  	${CC} ${CFLAGS} -o dhcps ${OBJ} ${LDFLAGS}
--- 1,9 ----
  OBJ = dhcps.o database.o hash.o ctime.o common_subr.o \
        interface.o delarp.o
! 
  CC = cc
! CFLAGS = -O #-DMAC_FILTER #-DCOMPAT_RFC1541 #-DNOICMPCHK
! LDFLAGS =
  
  dhcps: ${OBJ}
  	${CC} ${CFLAGS} -o dhcps ${OBJ} ${LDFLAGS}
diff -rcN dhcp-1.4.0p1/server/Makefile.sunos4 dhcp-1.4.0p2/server/Makefile.sunos4
*** dhcp-1.4.0p1/server/Makefile.sunos4	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/Makefile.sunos4	Fri Jan 30 18:04:27 1998
***************
*** 1,10 ****
  OBJ = dhcps.o database.o hash.o ctime.o getmac.o common_subr.o \
        interface.o delarp.o
! LDFLAGS = -lkvm
  CC = gcc
! CFLAGS = -g -Wall -DNOIPOPTION #-DCOMPAT_RFC1541 #-DNOICMPCHK
! #CC = cc
! #CFLAGS = -g -DNOIPOPTION #-DCOMPAT_RFC1541 #-DNOICMPCHK
  
  dhcps: ${OBJ}
  	${CC} ${CFLAGS} -o dhcps ${OBJ} ${LDFLAGS}
--- 1,9 ----
  OBJ = dhcps.o database.o hash.o ctime.o getmac.o common_subr.o \
        interface.o delarp.o
! 
  CC = gcc
! CFLAGS = -O -DNOIPOPTION #-DMAC_FILTER #-DCOMPAT_RFC1541 #-DNOICMPCHK
! LDFLAGS = -lkvm
  
  dhcps: ${OBJ}
  	${CC} ${CFLAGS} -o dhcps ${OBJ} ${LDFLAGS}
diff -rcN dhcp-1.4.0p1/server/common.h dhcp-1.4.0p2/server/common.h
*** dhcp-1.4.0p1/server/common.h	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/common.h	Fri Jan 30 17:48:43 1998
***************
*** 291,296 ****
--- 291,300 ----
  #endif
  #define MAX_NBIND       50000   /* maximum number of dhcp_binding
  				 ( this is used in garbage_collect() ) */
+ #ifdef MAC_FILTER
+ #define MAX_CLIENTS     500     /* maximum number of clients which registered
+ 				   in dhcpdb.MAC database */
+ #endif
  
  #define	QWOFF    2                 /* to make dhcp long to 4w alignment */
  #define ETHERHL  sizeof(struct ether_header)  /* ethernet header length */
***************
*** 301,310 ****
--- 305,320 ----
  extern FILE *addrpool_dbfp;
  extern FILE *binding_dbfp;
  extern FILE *relay_dbfp;
+ #ifdef MAC_FILTER
+ extern FILE *mac_dbfp;
+ #endif
  extern FILE *dump_fp;
  extern char binding_db[MAXPATHLEN];
  extern char addrpool_db[MAXPATHLEN];
  extern char relay_db[MAXPATHLEN];
+ #ifdef MAC_FILTER
+ extern char mac_db[MAXPATHLEN];
+ #endif
  extern int nbind;
  extern u_short dhcps_port;     /* DHCP server port (network byte order) */
  extern u_short dhcpc_port;     /* DHCP server port (network byte order) */
***************
*** 319,324 ****
--- 329,337 ----
  void    read_bind_db();
  void    read_addrpool_db();
  void    read_relay_db();
+ #ifdef MAC_FILTER
+ void    read_mac_db();
+ #endif
  void    dump_bind_db();
  void    dump_addrpool_db();
  void    finish();
diff -rcN dhcp-1.4.0p1/server/common_subr.h dhcp-1.4.0p2/server/common_subr.h
*** dhcp-1.4.0p1/server/common_subr.h	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/common_subr.h	Fri Jan 30 18:06:10 1998
***************
*** 37,43 ****
   * WIDE project has the rights to redistribute these changes.
   */
  
! #define WIDEDHCP_VERS    "1.4.0p1"
  
  struct ps_udph {              /* pseudo udp header for checksum */
    struct in_addr srcip,
--- 37,43 ----
   * WIDE project has the rights to redistribute these changes.
   */
  
! #define WIDEDHCP_VERS    "1.4.0p2"
  
  struct ps_udph {              /* pseudo udp header for checksum */
    struct in_addr srcip,
diff -rcN dhcp-1.4.0p1/server/database.c dhcp-1.4.0p2/server/database.c
*** dhcp-1.4.0p1/server/database.c	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/database.c	Fri Feb 20 23:48:53 1998
***************
*** 2,8 ****
   * WIDE Project DHCP Implementation
   * Copyright (c) 1995, 1996 Akihiro Tominaga
   * Copyright (c) 1995, 1996 WIDE Project
!  * All rights reserved.
   *
   * Permission to use, copy, modify and distribute this software and its
   * documentation is hereby granted, provided the following conditions
--- 2,8 ----
   * WIDE Project DHCP Implementation
   * Copyright (c) 1995, 1996 Akihiro Tominaga
   * Copyright (c) 1995, 1996 WIDE Project
!  * All right reserved.
   *
   * Permission to use, copy, modify and distribute this software and its
   * documentation is hereby granted, provided the following conditions
***************
*** 97,103 ****
      return;
  
    fprintf(binding_dbfp, "%s:", cidtos(&bp->cid, 1));
!   fprintf(binding_dbfp, "%s:", haddrtos(&bp->haddr));
    if (bp->expire_epoch == 0xffffffff) {
      if (bp->flag & BOOTP_ENTRY)
        fprintf(binding_dbfp, "\"bootp\":");
--- 97,103 ----
      return;
  
    fprintf(binding_dbfp, "%s:", cidtos(&bp->cid, 1));
!   fprintf(binding_dbfp, "%s:", chaddrtos(&bp->haddr));
    if (bp->expire_epoch == 0xffffffff) {
      if (bp->flag & BOOTP_ENTRY)
        fprintf(binding_dbfp, "\"bootp\":");
***************
*** 599,605 ****
     *
     * idtype:id:subnet:htype:haddr:"expire_date":resource_name
     */
!   while(1) {
      buflen = sizeof(buffer);
      read_entry(buffer, &buflen, binding_dbfp);
      if (buflen == 0) {		/* More entries? */
--- 599,605 ----
     *
     * idtype:id:subnet:htype:haddr:"expire_date":resource_name
     */
!   while (1) {
      buflen = sizeof(buffer);
      read_entry(buffer, &buflen, binding_dbfp);
      if (buflen == 0) {		/* More entries? */
***************
*** 675,681 ****
  
      if (hash_ins(&cidhashtable, binding->cid.id, binding->cid.idlen,
  		 bindcidcmp, &binding->cid, binding) < 0) {
!       syslog(LOG_ERR, "hash_ins() with client identifier failed in read_bind_db()");
        exit(1);
      }
      if (add_bind(binding) != 0)
--- 675,683 ----
  
      if (hash_ins(&cidhashtable, binding->cid.id, binding->cid.idlen,
  		 bindcidcmp, &binding->cid, binding) < 0) {
!       errno = 0;
!       syslog(LOG_ERR,
! 	     "hash_ins() with client identifier failed in read_bind_db()");
        exit(1);
      }
      if (add_bind(binding) != 0)
***************
*** 704,710 ****
    /*
     * read pairs of relay agents' IP and subnet number
     */
!   while(1) {
      errno = 0;
      if (fgets(buffer, MAXENTRYLEN, relay_dbfp) == NULL) {
        if (errno != 0)
--- 706,712 ----
    /*
     * read pairs of relay agents' IP and subnet number
     */
!   while (1) {
      errno = 0;
      if (fgets(buffer, MAXENTRYLEN, relay_dbfp) == NULL) {
        if (errno != 0)
***************
*** 738,745 ****
--- 740,835 ----
  
    errno = 0;
    syslog(LOG_INFO, "read %d entries from relay agent database", nrelay);
+   fclose(relay_dbfp);
+   return;
+ }
+ 
+ 
+ #ifdef MAC_FILTER
+ char * 
+ haddrtos(haddr) 
+      u_char *haddr;
+ {       
+   int i;
+   char tmp[3];
+   static char result[MAX_HLEN*2+8];     /* it seems enough */
+ 
+   strcpy(result, "0x");
+   for (i = 0; i < 6; i++) {
+     sprintf(tmp, "%.2x", haddr[i]);
+     strcat(result, tmp);
+   }
+ 
+   return(result);
+ } 
+ 
+ 
+ /*
+  * called at once after read_relay_db()
+  */
+ void
+ read_mac_db()
+ {
+   char buffer[80], *cp;
+   int i, line, x;
+   extern int nmacaddr;
+   extern char allowed_haddr[MAX_CLIENTS][6];
+ 
+   line = nmacaddr = 0;
+   while (1) {
+     if (fgets(buffer, sizeof(buffer), mac_dbfp) == NULL) {
+       if (errno != 0)
+ 	syslog(LOG_WARNING, "fgets() error in read_mac_db()");
+       break;
+     }
+ 
+     line++;
+     if (buffer[0] == '\n')
+       continue;
+     if (buffer[0] == '#')
+       continue;
+ 
+     cp = buffer;
+     for (i = 0; i < 6; i++) {
+       x = 0;
+       while (isxdigit(*cp)) {
+ 	x *= 0x10;
+ 	if (isdigit(*cp)) {
+ 	  x += *cp - '0';
+ 	}
+ 	else if (isupper(*cp)) {
+ 	  x += *cp - 'A' + 0xa;
+ 	}
+ 	else if (islower(*cp)) {
+ 	  x += *cp - 'a' + 0xa;
+ 	}
+ 	cp++;
+       }
+       cp++;
+ 
+       if (0 <= x && x <= 255) {
+ 	allowed_haddr[nmacaddr][i] = (char) x;
+       } else {
+ 	errno = 0;
+ 	syslog(LOG_WARNING, "bad format at line %d of %s", line, mac_db);
+ 	goto skip;
+       }
+     }
+     if (++nmacaddr >= MAX_CLIENTS) {
+       errno = 0;
+       syslog(LOG_WARNING, "too many clients in %s", mac_db);
+       break;
+     }
+   skip:
+   }
+ 
+   errno = 0;
+   syslog(LOG_INFO, "read %d entries from mac address database", nmacaddr);
+   fclose(mac_dbfp);
+ 
    return;
  }
+ #endif
  
  
  /*
***************
*** 1846,1852 ****
    unsigned buflen = 0;
    int nresource = 0;
  
!   while(1) {
      buflen = sizeof(buffer);
      read_entry(buffer, &buflen, addrpool_dbfp);
      if (buflen == 0) {		/* More entries? */
--- 1936,1942 ----
    unsigned buflen = 0;
    int nresource = 0;
  
!   while (1) {
      buflen = sizeof(buffer);
      read_entry(buffer, &buflen, addrpool_dbfp);
      if (buflen == 0) {		/* More entries? */
diff -rcN dhcp-1.4.0p1/server/delarp.c dhcp-1.4.0p2/server/delarp.c
*** dhcp-1.4.0p1/server/delarp.c	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/delarp.c	Thu Sep 11 10:28:58 1997
***************
*** 60,66 ****
  #include <syslog.h>
  
  
! #if defined(__bsdi__) || defined(__FreeBSD__)
  /*
   * delarp for BSD/OS 2.*
   */
--- 60,66 ----
  #include <syslog.h>
  
  
! #if defined(__bsdi__) || (__FreeBSD__ >= 2)
  /*
   * delarp for BSD/OS 2.*
   */
diff -rcN dhcp-1.4.0p1/server/dhcps.c dhcp-1.4.0p2/server/dhcps.c
*** dhcp-1.4.0p1/server/dhcps.c	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/dhcps.c	Sun Jul 19 11:16:53 1998
***************
*** 117,130 ****
--- 117,140 ----
  FILE *binding_dbfp;
  FILE *relay_dbfp;
  FILE *dump_fp;
+ #ifdef MAC_FILTER
+ FILE *mac_dbfp;
+ #endif
  char binding_db[MAXPATHLEN];
  char addrpool_db[MAXPATHLEN];
  char relay_db[MAXPATHLEN];
+ #ifdef MAC_FILTER
+ char mac_db[MAXPATHLEN];
+ #endif
  int nbind;
  struct msg rcv;
  struct bpf_hdr *rbpf;
  
  char **argv_orig;
+ #ifdef MAC_FILTER
+ char allowed_haddr[MAX_CLIENTS][6];
+ int  nmacaddr;
+ #endif
  
  void
  main(argc, argv)
***************
*** 139,145 ****
    struct sockaddr_in my_addr, any_addr;
    struct ifreq ifreq;
  
-   bzero(&any_addr, sizeof(any_addr));
    bzero(&ifreq, sizeof(ifreq));
  
    debug = 0;                           /* debug flag */
--- 149,154 ----
***************
*** 174,185 ****
--- 183,202 ----
  	if (argc <= 0) usage();
  	else strcpy(relay_db, argv[0]);
  	break;
+ #ifdef MAC_FILTER
+       case 'm':              /* option which specify the MAC address db file */
+ 	--argc,	++argv;
+ 	if (argc <= 0) usage();
+ 	else strcpy(mac_db, argv[0]);
+ 	break;
+ #endif
        case 'd':               /* debug option */
  	debug = 1;
  	break;
        case 'v':
  	version();
  	break;
+       case 'h':
        default:
  	usage();
  	break;
***************
*** 220,225 ****
--- 237,245 ----
    read_addrpool_db();      /* read address pool database */
    read_bind_db();          /* read binding database */
    read_relay_db();         /* read relay agents database */
+ #ifdef MAC_FILTER
+   read_mac_db();           /* read MAC address database */
+ #endif
    set_sighand();           /* Set up signal handlers */
    set_srvport();           /* determine dhcp port */
  
***************
*** 270,276 ****
        syslog(LOG_ERR, "calloc error in main()");
        exit(1);
      }
!     /* get space for ETHER, IP and UDP header */
      bzero(&my_addr, sizeof(my_addr));
      my_addr.sin_family = AF_INET;
      my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
--- 290,296 ----
        syslog(LOG_ERR, "calloc error in main()");
        exit(1);
      }
! 
      bzero(&my_addr, sizeof(my_addr));
      my_addr.sin_family = AF_INET;
      my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
***************
*** 296,302 ****
     * Main loop                *
     * Process incoming message *
     ****************************/
!   while(1) {
      garbage_collect();
  
      /* select and read from interfaces */
--- 316,322 ----
     * Main loop                *
     * Process incoming message *
     ****************************/
!   while (1) {
      garbage_collect();
  
      /* select and read from interfaces */
***************
*** 340,347 ****
  	  msgtype = *OPTBODY(option);
  	}
  
!         if (msgtype < BOOTP || msgtype > DHCPRELEASE)
  	  syslog(LOG_INFO, "unknown message");
  	else if (process_msg[(int) msgtype] != NULL)
  	  (*process_msg[(int) msgtype])(ifp);
        }
--- 360,369 ----
  	  msgtype = *OPTBODY(option);
  	}
  
!         if (msgtype < BOOTP || msgtype > DHCPRELEASE) {
! 	  errno = 0;
  	  syslog(LOG_INFO, "unknown message");
+ 	}
  	else if (process_msg[(int) msgtype] != NULL)
  	  (*process_msg[(int) msgtype])(ifp);
        }
***************
*** 356,363 ****
  	  msgtype = *OPTBODY(option);
  	}
  
! 	if (msgtype < BOOTP || msgtype > DHCPRELEASE)
  	  syslog(LOG_INFO, "unknown message");
  	else if (process_msg[(int) msgtype] != NULL)
  	  (*process_msg[(int) msgtype])(ifp);
        }
--- 378,387 ----
  	  msgtype = *OPTBODY(option);
  	}
  
! 	if (msgtype < BOOTP || msgtype > DHCPRELEASE) {
! 	  errno = 0;
  	  syslog(LOG_INFO, "unknown message");
+ 	}
  	else if (process_msg[(int) msgtype] != NULL)
  	  (*process_msg[(int) msgtype])(ifp);
        }
***************
*** 380,387 ****
  	    msgtype = *OPTBODY(option);
  	  }
  
! 	  if (msgtype < BOOTP || msgtype > DHCPRELEASE)
  	    syslog(LOG_INFO, "unknown message");
  	  else if (process_msg[(int) msgtype] != NULL)
  	    (*process_msg[(int) msgtype])(ifp);
  	}
--- 404,413 ----
  	    msgtype = *OPTBODY(option);
  	  }
  
! 	  if (msgtype < BOOTP || msgtype > DHCPRELEASE) {
! 	    errno = 0;
  	    syslog(LOG_INFO, "unknown message");
+ 	  }
  	  else if (process_msg[(int) msgtype] != NULL)
  	    (*process_msg[(int) msgtype])(ifp);
  	}
***************
*** 419,425 ****
--- 445,455 ----
  usage()
  {
    fprintf(stderr, "Usage: dhcps [-d] [-b binding_db] [-a addrpool_db] ");
+ #ifndef MAC_FILTER
    fprintf(stderr, "[-r relay_db] if_name [ifname] ... \n");
+ #else
+   fprintf(stderr, "[-r relay_db] [-m mac_db] if_name [ifname] ... \n");
+ #endif
    exit(1);
  }
  
***************
*** 520,531 ****
--- 550,569 ----
      syslog(LOG_ERR, "Cannot open the relay agent database \"%s\"", relay_db);
      exit(1);
    }
+ #ifdef MAC_FILTER
+   if (mac_db[0] == '\0') strcpy(mac_db, MAC_DB);
+   if ((mac_dbfp = fopen(mac_db, "r")) == NULL) {
+     syslog(LOG_ERR, "Cannot open the MAC address database \"%s\"", mac_db);
+     exit(1);
+   }
+ #endif
    if (binding_db[0] == '\0') strcpy(binding_db, BINDING_DB);
    if ((binding_dbfp = fopen(binding_db, "r+")) == NULL &&
        (binding_dbfp = fopen(binding_db, "w+")) == NULL) {
      syslog(LOG_ERR, "Cannot open the binding database \"%s\"", binding_db);
      exit(1);
    }
+   unlink(ADDRPOOL_DUMP);
    if ((dump_fp = fopen(ADDRPOOL_DUMP, "w+")) == NULL) {
      syslog(LOG_ERR, "Cannot open the resource dump file \"%s\"",ADDRPOOL_DUMP);
      exit(1);
***************
*** 560,578 ****
   * return strings which include the haddr in the form of "type:haddr...."
   */
  char *
! haddrtos(haddr)
!   struct chaddr *haddr;
  {
    int i, fin;
    char tmp[3];
    static char result[MAX_HLEN*2+8];     /* it seems enough */
  
    bzero(result, sizeof(result));
!   if ((fin = haddr->hlen) > MAX_HLEN)
      fin = MAX_HLEN;
!   sprintf(result, "%d:0x", haddr->htype);
    for (i = 0; i < fin; i++) {
!     sprintf(tmp, "%.2x", haddr->haddr[i] & 0xff);
      strcat(result, tmp);
    }
  
--- 598,616 ----
   * return strings which include the haddr in the form of "type:haddr...."
   */
  char *
! chaddrtos(chaddr)
!   struct chaddr *chaddr;
  {
    int i, fin;
    char tmp[3];
    static char result[MAX_HLEN*2+8];     /* it seems enough */
  
    bzero(result, sizeof(result));
!   if ((fin = chaddr->hlen) > MAX_HLEN)
      fin = MAX_HLEN;
!   sprintf(result, "%d:0x", chaddr->htype);
    for (i = 0; i < fin; i++) {
!     sprintf(tmp, "%.2x", chaddr->haddr[i] & 0xff);
      strcat(result, tmp);
    }
  
***************
*** 1246,1252 ****
  
    if ((hash_ins(&cidhashtable, binding->cid.id, binding->cid.idlen, bindcidcmp,
  		&binding->cid, binding) < 0)) {
!     syslog(LOG_WARNING, "hash_ins() with client identifier failed in update_db()");
      return(-1);
    }
    if (add_bind(binding) != 0)
--- 1284,1292 ----
  
    if ((hash_ins(&cidhashtable, binding->cid.id, binding->cid.idlen, bindcidcmp,
  		&binding->cid, binding) < 0)) {
!     errno = 0;
!     syslog(LOG_WARNING,
! 	   "hash_ins() with client identifier failed in update_db()");
      return(-1);
    }
    if (add_bind(binding) != 0)
***************
*** 1517,1522 ****
--- 1557,1584 ----
    reqlease = get_reqlease(rcv.dhcp, rdhcplen);
    maxoptlen = get_maxoptlen(rcv.dhcp, rdhcplen);
    get_cid(rcv.dhcp, rdhcplen, &cid);
+ #ifdef MAC_FILTER
+   {
+     int found = 0;
+     int i;
+     if (bcmp(allowed_haddr[0], "\0\0\0\0\0\0", 6) == 0) {
+       found = 1;
+     } else {
+       for (i = 0; i < nmacaddr; i++) {
+         if (bcmp(allowed_haddr[i], rcv.dhcp->chaddr, 6) == 0) {
+ 	  found = 1;
+ 	  break;
+         }
+       }
+     }
+     if (!found) {
+       errno = 0;
+       syslog(LOG_INFO, "DHCPDISCOVER from %s ignored",
+ 	     haddrtos(&rcv.dhcp->chaddr));
+       return(-1);
+     }
+   }
+ #endif
    if (get_subnet(rcv.dhcp, rdhcplen, &cid.subnet, ifp) != 0)
      return(-1);
    if ((offer_res = choose_res(&cid, curr_epoch, reqlease)) == NULL)
***************
*** 1573,1578 ****
--- 1635,1662 ----
    reqlease = get_reqlease(rcv.dhcp, rdhcplen);
    maxoptlen = get_maxoptlen(rcv.dhcp, rdhcplen);
    get_cid(rcv.dhcp, rdhcplen, &cid);
+ #ifdef MAC_FILTER
+   {
+     int found = 0;
+     int i;
+     if (bcmp(allowed_haddr[0], "\0\0\0\0\0\0", 6) == 0) {
+       found = 1;
+     } else {
+       for (i = 0; i < nmacaddr; i++) {
+         if (bcmp(allowed_haddr[i], rcv.dhcp->chaddr, 6) == 0) {
+ 	  found = 1;
+ 	  break;
+         }
+       }
+     }
+     if (!found) {
+       errno = 0;
+       syslog(LOG_INFO, "DHCPREQUEST from %s ignored",
+ 	     haddrtos(&rcv.dhcp->chaddr));
+       return(-1);
+     }
+   }
+ #endif
    if (get_subnet(rcv.dhcp, rdhcplen, &cid.subnet, ifp) != 0)
      return(-1);
  
***************
*** 1665,1676 ****
  
    res->binding->flag |= COMPLETE_ENTRY;    /* binding is made completely */
  
-   strcpy(datestr, ctime(&res->binding->expire_epoch));
-   datestr[strlen(datestr) - 1] = '\0';
-   strcpy(addrstr, inet_ntoa(*res->ip_addr));
    errno = 0;
!   syslog(LOG_INFO, "Assign %s to the client(cid is \"%s\") till \"%s\".",
! 	 addrstr, cidtos(&res->binding->cid, 1), datestr);
    return(0);
  
   nak:
--- 1749,1765 ----
  
    res->binding->flag |= COMPLETE_ENTRY;    /* binding is made completely */
  
    errno = 0;
!   if (res->binding->expire_epoch == 0xffffffff) {
!     syslog(LOG_INFO, "Assign %s to the client(cid is \"%s\") forever.",
! 	   addrstr, cidtos(&res->binding->cid, 1));
!   } else {
!     strcpy(datestr, ctime(&res->binding->expire_epoch));
!     datestr[strlen(datestr) - 1] = '\0';
!     strcpy(addrstr, inet_ntoa(*res->ip_addr));
!     syslog(LOG_INFO, "Assign %s to the client(cid is \"%s\") till \"%s\".",
! 	   addrstr, cidtos(&res->binding->cid, 1), datestr);
!   }
    return(0);
  
   nak:
***************
*** 2175,2183 ****
    struct if_info *ifp;
  {
    int i = 0, buflen = 0;
!   struct sockaddr_in srcaddr, dstaddr;
  
-   bzero(&srcaddr, sizeof(srcaddr));
    bzero(&dstaddr, sizeof(dstaddr));
  
    if (off_options < BOOTPOPTLEN) {
--- 2264,2271 ----
    struct if_info *ifp;
  {
    int i = 0, buflen = 0;
!   struct sockaddr_in dstaddr;
  
    bzero(&dstaddr, sizeof(dstaddr));
  
    if (off_options < BOOTPOPTLEN) {
***************
*** 2918,2923 ****
--- 3006,3012 ----
    pid = (short) getpid() & 0xffff;
  
    if ((protocol = getprotobyname("icmp")) == NULL) {
+     errno = 0;
      syslog(LOG_WARNING, "Can't get protocol \"icmp\" in icmp_check()");
      return(GOOD);
    }
***************
*** 2927,2933 ****
      return(GOOD);
    }
  
! #if defined(__bsdi__) || defined(__FreeBSD__)
    delarp(ip);
  #else
    delarp(ip, sockfd);
--- 3016,3022 ----
      return(GOOD);
    }
  
! #if defined(__bsdi__) || (__FreeBSD__ >= 2)
    delarp(ip);
  #else
    delarp(ip, sockfd);
diff -rcN dhcp-1.4.0p1/server/dhcps.h dhcp-1.4.0p2/server/dhcps.h
*** dhcp-1.4.0p1/server/dhcps.h	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/dhcps.h	Sat Feb 21 14:41:56 1998
***************
*** 63,68 ****
--- 63,73 ----
  #ifndef RELAY_DB
  #define RELAY_DB                "/etc/dhcpdb.relay"
  #endif
+ #ifdef MAC_FILTER
+ #ifndef MAC_DB
+ #define MAC_DB                  "/etc/dhcpdb.MAC"
+ #endif
+ #endif
  
  #define GC_INTERVAL    600      /* interval between garbage collections */
  
diff -rcN dhcp-1.4.0p1/server/getmac.c dhcp-1.4.0p2/server/getmac.c
*** dhcp-1.4.0p1/server/getmac.c	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/server/getmac.c	Thu Sep 11 10:27:06 1997
***************
*** 44,49 ****
--- 44,55 ----
  
  #include <sys/socket.h>
  #include <net/if.h>
+ #ifdef __FreeBSD__
+ #include <osreldate.h>
+ #if (__FreeBSD_version == 199702) || (__FreeBSD_version >= 300000)
+ #include <net/if_var.h>
+ #endif
+ #endif
  
  #include <netinet/in.h>
  #include <netinet/in_var.h>
diff -rcN dhcp-1.4.0p1/server/getmac.c.bsdi dhcp-1.4.0p2/server/getmac.c.bsdi
*** dhcp-1.4.0p1/server/getmac.c.bsdi	Thu Jan  1 09:00:00 1970
--- dhcp-1.4.0p2/server/getmac.c.bsdi	Sun Nov 16 10:33:19 1997
***************
*** 0 ****
--- 1,68 ----
+ /*
+  * Modified by Akihiro Tominaga. (tomy@sfc.wide.ad.jp)
+  */
+ /*
+  * Copyright (c) 1990, 1992 The Regents of the University of California.
+  * All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that: (1) source code distributions
+  * retain the above copyright notice and this paragraph in its entirety, (2)
+  * distributions including binary code include the above copyright notice and
+  * this paragraph in its entirety in the documentation or other materials
+  * provided with the distribution, and (3) all advertising materials mentioning
+  * features or use of this software display the following acknowledgement:
+  * ``This product includes software developed by the University of California,
+  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+  * the University nor the names of its contributors may be used to endorse
+  * or promote products derived from this software without specific prior
+  * written permission.
+  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+  */
+ #if !defined(sony_news) && !defined(__osf__)
+ 
+ #ifdef lint
+ static char rcsid[] =
+     "@(#) $Header: myetheraddr.c,v 1.6 92/03/17 18:43:30 leres Exp $ (LBL)";
+ #endif
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <ifaddrs.h>
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/socket.h>
+ #include <net/if.h>
+ #include <net/if_dl.h>
+ 
+ 
+ int
+ getmac(ifname, result)
+   char *ifname;
+   char *result;
+ {
+   struct ifaddrs *ifa; 
+   struct sockaddr_dl *sdl;
+   struct ifaddrs *ifaddrs;
+ 
+   getifaddrs(&ifaddrs);
+   for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
+ 
+     if (strcmp(ifa->ifa_name, ifname) != 0)
+       continue;
+ 
+     if (ifa->ifa_addr->sa_family == AF_LINK) {
+       sdl = (struct sockaddr_dl *)ifa->ifa_addr;
+         if (sdl->sdl_alen > 0) {       
+ 	  bcopy(LLADDR(sdl), result, sdl->sdl_alen);
+ 	  return(0);
+       }
+     }
+   }
+   /* not found */
+   return(-1);
+ }
+ #endif
diff -rcN dhcp-1.4.0p1/tools/Makefile.FreeBSD dhcp-1.4.0p2/tools/Makefile.FreeBSD
*** dhcp-1.4.0p1/tools/Makefile.FreeBSD	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/tools/Makefile.FreeBSD	Thu Sep 11 09:08:04 1997
***************
*** 1,7 ****
  CC = gcc
! CFLAGS = -g -Wall -I. -I../server
! #CC = cc
! #CFLAGS = -g -I. -I../server
  SBIN =		/usr/local/sbin
  LIBEXEC =	/usr/local/libexec
  MAN =		/usr/local/man
--- 1,5 ----
  CC = gcc
! CFLAGS = -O -I. -I../server
  SBIN =		/usr/local/sbin
  LIBEXEC =	/usr/local/libexec
  MAN =		/usr/local/man
diff -rcN dhcp-1.4.0p1/tools/Makefile.bsdi dhcp-1.4.0p2/tools/Makefile.bsdi
*** dhcp-1.4.0p1/tools/Makefile.bsdi	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/tools/Makefile.bsdi	Thu Sep 11 09:08:14 1997
***************
*** 1,7 ****
! CC = shlicc
! CFLAGS = -g -Wall -I. -I../server
! #CC = cc
! #CFLAGS = -g -I. -I../server
  
  dhcpm: dhcpm.c ../server/dhcp.h
  	$(CC) $(CFLAGS) dhcpm.c -o dhcpm
--- 1,5 ----
! CC = shlicc2
! CFLAGS = -O -I. -I../server
  
  dhcpm: dhcpm.c ../server/dhcp.h
  	$(CC) $(CFLAGS) dhcpm.c -o dhcpm
diff -rcN dhcp-1.4.0p1/tools/Makefile.news dhcp-1.4.0p2/tools/Makefile.news
*** dhcp-1.4.0p1/tools/Makefile.news	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/tools/Makefile.news	Thu Sep 11 09:08:22 1997
***************
*** 1,7 ****
  CC = gcc
! CFLAGS = -g -Wall -I. -I../server
! #CC = cc
! #CFLAGS = -g -I. -I../server
  
  dhcpm: dhcpm.c ../server/dhcp.h
  	$(CC) $(CFLAGS) dhcpm.c -o dhcpm
--- 1,5 ----
  CC = gcc
! CFLAGS = -O -I. -I../server
  
  dhcpm: dhcpm.c ../server/dhcp.h
  	$(CC) $(CFLAGS) dhcpm.c -o dhcpm
diff -rcN dhcp-1.4.0p1/tools/Makefile.osf1 dhcp-1.4.0p2/tools/Makefile.osf1
*** dhcp-1.4.0p1/tools/Makefile.osf1	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/tools/Makefile.osf1	Thu Sep 11 09:08:34 1997
***************
*** 1,7 ****
  CC = gcc
! CFLAGS = -g -Wall -I. -I../server
! #CC = cc
! #CFLAGS = -g -I. -I../server
  
  dhcpm: dhcpm.c ../server/dhcp.h
  	$(CC) $(CFLAGS) dhcpm.c -o dhcpm
--- 1,5 ----
  CC = gcc
! CFLAGS = -O -I. -I../server
  
  dhcpm: dhcpm.c ../server/dhcp.h
  	$(CC) $(CFLAGS) dhcpm.c -o dhcpm
diff -rcN dhcp-1.4.0p1/tools/Makefile.sunos4 dhcp-1.4.0p2/tools/Makefile.sunos4
*** dhcp-1.4.0p1/tools/Makefile.sunos4	Fri Aug 14 16:42:12 1998
--- dhcp-1.4.0p2/tools/Makefile.sunos4	Thu Sep 11 09:08:45 1997
***************
*** 1,7 ****
  CC = gcc
! CFLAGS = -g -Wall -I. -I../server -DNOIPOPTION
! #CC = cc
! #CFLAGS = -g -I. -I../server -DNOIPOPTION
  
  dhcpm: dhcpm_sun.c ../server/dhcp.h
  	$(CC) $(CFLAGS) dhcpm_sun.c -o dhcpm
--- 1,5 ----
  CC = gcc
! CFLAGS = -O -I. -I../server -DNOIPOPTION
  
  dhcpm: dhcpm_sun.c ../server/dhcp.h
  	$(CC) $(CFLAGS) dhcpm_sun.c -o dhcpm
