diff -crN .\/Makefile.conf ..\dhcp-3.1-ESV.os2/Makefile.conf
*** .\/Makefile.conf	Thu Jul 23 15:43:02 2009
--- ..\dhcp-3.1-ESV.os2/Makefile.conf	Wed Oct 13 10:51:00 2010
***************
*** 486,488 ****
--- 486,494 ----
  #FFMANEXT = .5
  #MANINSTALL = install -i -m 444
  ##--hpux-gcc--
+ 
+ ## IBM OS/2
+ ##--os2--
+ #CF = cf/os2.h
+ #LFLAGS=-Zomf -Zexe -Zbin-files
+ ##--os2--
diff -crN .\/common/socket.c ..\dhcp-3.1-ESV.os2/common/socket.c
*** .\/common/socket.c	Thu Jul 23 15:43:04 2009
--- ..\dhcp-3.1-ESV.os2/common/socket.c	Wed Dec  8 10:45:24 2010
***************
*** 47,52 ****
--- 47,56 ----
  
  #include "dhcpd.h"
  
+ #ifdef USE_SOCKETS_ARP_HACK
+ #include <sys\ioctl.h>
+ #endif
+ 
  #ifdef USE_SOCKET_FALLBACK
  # if !defined (USE_SOCKET_SEND)
  #  define if_register_send if_register_fallback
***************
*** 130,135 ****
--- 134,146 ----
  			 (char *)&flag, sizeof flag) < 0))
  		log_fatal ("Can't set SO_BROADCAST option on dhcp socket: %m");
  
+ #if defined (HAVE_SO_L_BROADCAST)
+ 	if (info -> ifp &&
+ 	    (setsockopt (sock, SOL_SOCKET, SO_L_BROADCAST,
+ 			 (char *)&flag, sizeof flag) < 0))
+ 		log_fatal ("Can't set SO_L_BROADCAST option on dhcp socket: %m");
+ #endif
+ 
  	/* Bind the socket to this interface's IP address. */
  	if (bind (sock, (struct sockaddr *)&name, sizeof name) < 0) {
  		log_error ("Can't bind to dhcp address: %m");
***************
*** 249,256 ****
--- 260,290 ----
  	struct hardware *hto;
  {
  	int result;
+ 
  #ifdef IGNORE_HOSTUNREACH
  	int retry = 0;
+ #endif
+ 
+ #ifdef USE_SOCKETS_ARP_HACK
+ 	struct arpreq areq;
+ 
+ 	if (hto && hto -> hlen == 7) {
+ 		areq.arp_flags = 0;
+ 		areq.arp_pa.sa_len = sizeof(struct sockaddr);
+ 		areq.arp_pa.sa_family = AF_INET;
+ 		((struct sockaddr_in*)&areq.arp_pa) -> sin_addr.s_addr = to -> sin_addr.s_addr;
+ 		areq.arp_ha.sa_len = sizeof(struct sockaddr);
+ 		areq.arp_ha.sa_family = AF_UNSPEC;  
+ 		memcpy (areq.arp_ha.sa_data, &hto -> hbuf [1],
+ 			hto -> hlen);
+ 
+ 		if( ioctl( interface -> wfdesc, SIOCSARP, &areq ) != 0 ) {
+ 			log_error( "send_packet: unable to update ARP table." );
+ 		}
+ 	}
+ #endif
+ 
+ #ifdef IGNORE_HOSTUNREACH
  	do {
  #endif
  		result = sendto (interface -> wfdesc, (char *)raw, len, 0,
***************
*** 332,338 ****
--- 366,376 ----
  int can_unicast_without_arp (ip)
  	struct interface_info *ip;
  {
+ #ifdef USE_SOCKETS_ARP_HACK
+ 	return 1;
+ #else
  	return 0;
+ #endif
  }
  
  int can_receive_unicast_unconfigured (ip)
diff -crN .\/configure ..\dhcp-3.1-ESV.os2/configure
*** .\/configure	Thu Mar 17 13:14:46 2005
--- ..\dhcp-3.1-ESV.os2/configure	Wed Oct 13 11:33:04 2010
***************
*** 184,189 ****
--- 184,191 ----
        sysname=nextstep;;
      UnixWare)
        sysname=uw7;;
+     OS/2)
+       sysname=os2;;
    esac
  fi
  
***************
*** 212,218 ****
      echo "   hpux		HP-UX"
      echo "   qnx		QNX 4.2 or higher"
      echo "   NEXTSTEP     NeXTSTEP"
!     echo "   sco	SCO Open Server"
      exit 1;
    fi
  fi
--- 214,221 ----
      echo "   hpux		HP-UX"
      echo "   qnx		QNX 4.2 or higher"
      echo "   NEXTSTEP     NeXTSTEP"
!     echo "   sco		SCO Open Server"
!     echo "   os2		IBM OS/2"
      exit 1;
    fi
  fi
diff -crN .\/includes/cf/os2.h ..\dhcp-3.1-ESV.os2/includes/cf/os2.h
*** .\/includes/cf/os2.h	Thu Jan  1 00:00:00 1970
--- ..\dhcp-3.1-ESV.os2/includes/cf/os2.h	Thu Dec  2 13:59:10 2010
***************
*** 0 ****
--- 1,146 ----
+ /* os2.h
+ 
+    Configuration file for IBM's OS/2 operating system. */
+ 
+ #include <sys/types.h>
+ 
+ #include <syslog.h>
+ 
+ #include <string.h>
+ #include <errno.h>
+ #include <unistd.h>
+ #include <sys/wait.h>
+ #include <signal.h>
+ #include <setjmp.h>
+ #include <limits.h>
+ #include <stdio.h>
+ 
+ extern int h_errno;
+ 
+ #include <net/if.h>
+ #include <net/if_arp.h>
+ #include <net/if_dl.h>
+ 
+ #ifndef _PATH_DHCPD_PID
+ #define _PATH_DHCPD_PID    "/mptn/etc/dhcpd.pid"
+ #endif
+ #ifndef _PATH_DHCLIENT_PID
+ #define _PATH_DHCLIENT_PID "/mptn/etc/dhclient.pid"
+ #endif
+ #ifndef _PATH_DHCRELAY_PID
+ #define _PATH_DHCRELAY_PID "/mptn/etc/dhcrelay.pid"
+ #endif
+ 
+ /* Stdarg definitions for ANSI-compliant C compilers. */
+ #include <stdarg.h>
+ #define VA_DOTDOTDOT ...
+ #define VA_start(list, last) va_start (list, last)
+ #define va_dcl
+ 
+ #if defined (USE_DEFAULT_NETWORK)
+   #define USE_SOCKETS
+   #define USE_SOCKETS_ARP_HACK
+   #define HAVE_SO_L_BROADCAST
+ #endif
+ 
+ #define HAVE_SA_LEN
+ #define NEED_CLOSE_BEFORE_RENAME
+ 
+ /* Every operating system has its own way of separating lines in a
+    sequential text file.  Most modern systems use a single character,
+    either an ASCII Newline (10) or an ASCII Carriage Return (13).
+ 
+    The most notable exception is MS-DOS (and consequently, Windows),
+    which uses an ASCII Carriage Return followed by a Newline to
+    separate each line.  Fortunately, MS-DOS C compiler libraries
+    typically hide this from the programmer, returning just a Newline.
+ 
+    Define EOL to be whatever getc() returns for a newline. */
+ 
+ #define EOL '\n'
+ 
+ #define VOIDPTR void *
+ 
+ #include <time.h>
+ 
+ #define TIME time_t
+ #define GET_TIME(x) time ((x))
+ 
+ typedef __socklen_t socklen_t;
+ 
+ #ifdef NEED_PRAND_CONF
+ 
+ const char *cmds[] = {
+   "/bin/ps -axlw 2>&1",
+   "/usr/sbin/arp -an 2>&1",
+   "/usr/bin/netstat -an 2>&1",
+   "/bin/df  2>&1",
+   "/usr/bin/netstat -an 2>&1",
+   "/usr/sbin/iostat  2>&1",
+   "/usr/bin/vmstat  2>&1",
+   "/usr/bin/w  2>&1",
+   NULL
+ };
+ 
+ const char *dirs[] = {
+   "/tmp",
+   "/var/tmp",
+   ".",
+   "/",
+   "/var/spool",
+   "/dev",
+   "/var/mail",
+   "/home",
+   NULL
+ };
+ 
+ const char *files[] = {
+   "/var/log/messages",
+   "/var/log/wtmp",
+   "/var/log/lastlog",
+   NULL
+ };
+ 
+ #endif /* NEED_PRAND_CONF */
+ 
+ #define link(p1,p2) os2copy(p1,p2)
+ static __inline int os2copy( const char * path1, const char * path2 )
+ {
+   FILE* src = NULL;
+   FILE* dst = NULL;
+   char  buffer[1024];
+ 
+   if(( src = fopen( path1, "r" )) == NULL ) {
+     goto fail;
+   }
+   if(( dst = fopen( path2, "w" )) == NULL ) {
+     goto fail;
+   }
+ 
+   while( !feof( src )) {
+     int done = fread( buffer, 1, sizeof( buffer ), src );
+     if( ferror( src )) {
+       goto fail;
+     }
+     if( done ) {
+       if( fwrite( buffer, 1, done, dst ) != done ) {
+         goto fail;
+       }
+     }
+   }
+ 
+   fclose( src );
+   fclose( dst );
+   return  0;
+ 
+ fail:
+ 
+   if( src ) {
+     fclose( src );
+   }
+   if( dst ) {
+     fclose( dst );
+   }
+   return -1;
+ }
+ 
diff -crN .\/includes/osdep.h ..\dhcp-3.1-ESV.os2/includes/osdep.h
*** .\/includes/osdep.h	Thu Jul 23 15:43:04 2009
--- ..\dhcp-3.1-ESV.os2/includes/osdep.h	Fri Oct  8 11:25:56 2010
***************
*** 133,138 ****
--- 133,142 ----
  # endif
  #endif
  
+ #ifdef __OS2__
+ #  include "cf/os2.h"
+ #endif
+ 
  /* snprintf/vsnprintf hacks.  for systems with no libc versions only. */
  #ifdef NO_SNPRINTF
    extern int isc_print_snprintf(char *, size_t, const char *, ...);
diff -crN .\/makeos2docs.cmd ..\dhcp-3.1-ESV.os2/makeos2docs.cmd
*** .\/makeos2docs.cmd	Thu Jan  1 00:00:00 1970
--- ..\dhcp-3.1-ESV.os2/makeos2docs.cmd	Thu Oct 14 14:05:34 2010
***************
*** 0 ****
--- 1,5 ----
+ @for %%f in (client\dhclient.conf.5 client\dhclient.leases.5 client\dhclient-script.8 client\dhclient.8) do @echo %%f && nroff -man %%f | man2html > work.os2\%%f.html
+ @for %%f in (common\dhcp-eval.5 common\dhcp-options.5) do @echo %%f && nroff -man %%f | man2html > work.os2\%%f.html
+ @for %%f in (dhcpctl\omshell.1 dhcpctl\dhcpctl.3) do @echo %%f && nroff -man %%f | man2html > work.os2\%%f.html
+ @for %%f in (relay\dhcrelay.8) do @nroff -man %%f | man2html > work.os2\%%f.html
+ @for %%f in (server\dhcpd.conf.5 server\dhcpd.leases.5 server\dhcpd.8) do @echo %%f && nroff -man %%f | man2html > work.os2\%%f.html
diff -crN .\/server/db.c ..\dhcp-3.1-ESV.os2/server/db.c
*** .\/server/db.c	Thu Jul 23 15:43:06 2009
--- ..\dhcp-3.1-ESV.os2/server/db.c	Tue Oct 12 15:16:52 2010
***************
*** 918,931 ****
  #if defined (TRACING)
  	}
  #endif
! 	
  	/* Move in the new file... */
  	if (rename (newfname, path_dhcpd_db) < 0) {
  		log_error ("Can't install new lease database %s to %s: %m",
  			   newfname, path_dhcpd_db);
  		goto fail;
  	}
! 
  	counting = 1;
  	return 1;
  
--- 918,939 ----
  #if defined (TRACING)
  	}
  #endif
! 
! #if defined (NEED_CLOSE_BEFORE_RENAME)
! 	fclose(db_file);
! #endif	
  	/* Move in the new file... */
  	if (rename (newfname, path_dhcpd_db) < 0) {
  		log_error ("Can't install new lease database %s to %s: %m",
  			   newfname, path_dhcpd_db);
  		goto fail;
  	}
! #if defined (NEED_CLOSE_BEFORE_RENAME)
! 	if ((db_file = fopen(path_dhcpd_db, "a")) == NULL) {
! 		log_error("Can't reopen lease file: %m");
! 		goto fail;
! 	}
! #endif
  	counting = 1;
  	return 1;
  
