diff -crN dhcp-3.1.0a3.org/Makefile.conf dhcp-3.1.0a3/Makefile.conf
*** dhcp-3.1.0a3.org/Makefile.conf	2005-07-08 01:39:07.000000000 +0900
--- dhcp-3.1.0a3/Makefile.conf	2008-05-28 13:21:33.000000000 +0900
***************
*** 46,52 ****
  INCDIR=/usr/local/include
  LIBS =
  COPTS = $(BINDDEF) $(CC_OPTIONS)
! DEBUG = -g
  #WARNERR = -Werror
  RANLIB = ranlib
  MKDEP = mkdep
--- 46,52 ----
  INCDIR=/usr/local/include
  LIBS =
  COPTS = $(BINDDEF) $(CC_OPTIONS)
! #DEBUG = -g
  #WARNERR = -Werror
  RANLIB = ranlib
  MKDEP = mkdep
diff -crN dhcp-3.1.0a3.org/client/dhclient.c dhcp-3.1.0a3/client/dhclient.c
*** dhcp-3.1.0a3.org/client/dhclient.c	2006-08-23 00:11:56.000000000 +0900
--- dhcp-3.1.0a3/client/dhclient.c	2008-05-28 13:21:33.000000000 +0900
***************
*** 37,42 ****
--- 37,44 ----
  
  #include "dhcpd.h"
  #include "version.h"
+ #include <sys/ioctl.h>
+ #include "gettime.h"
  
  TIME default_lease_time = 43200; /* 12 hours... */
  TIME max_lease_time = 86400; /* 24 hours... */
***************
*** 61,66 ****
--- 63,71 ----
     assert (state_is == state_shouldbe). */
  #define ASSERT_STATE(state_is, state_shouldbe) {}
  
+ #define AUTOIP_ADDR 0xFEA9
+ #define PRIVATE_ADDR 0xA8C0
+ 
  static char copyright[] = "Copyright 2004-2006 Internet Systems Consortium.";
  static char arr [] = "All rights reserved.";
  static char message [] = "Internet Systems Consortium DHCP Client";
***************
*** 316,322 ****
  		remote_port = htons (ntohs (local_port) - 1);	/* XXX */
  
  	/* Get the current time... */
! 	GET_TIME (&cur_time);
  
  	sockaddr_broadcast.sin_family = AF_INET;
  	sockaddr_broadcast.sin_port = remote_port;
--- 321,329 ----
  		remote_port = htons (ntohs (local_port) - 1);	/* XXX */
  
  	/* Get the current time... */
! 
! 	/* GET_TIME() is changed to get_time2() */
! 	cur_time = get_time2();
  
  	sockaddr_broadcast.sin_family = AF_INET;
  	sockaddr_broadcast.sin_port = remote_port;
***************
*** 371,376 ****
--- 378,440 ----
  		}
  	} else if (!release_mode) {
  		/* Call the script with the list of interfaces. */
+ #ifndef AUTOIP_PREINIT_NOSKIP
+ 		{ /* AutoIP mode Skip */
+ 			struct ifreq tIfr;
+ 			struct sockaddr_in *pSin;
+ 			int iSock = 0;
+ 			int iRet = 0;
+ 			unsigned long uiAddr = 0;
+ 			
+ 			memset( &tIfr, 0, sizeof(struct ifreq));
+ 			strncpy(tIfr.ifr_name, "eth0", sizeof(tIfr.ifr_name));
+ 			pSin = (struct sockaddr_in *) &tIfr.ifr_addr;
+ 			pSin->sin_family = AF_INET;
+ 			pSin->sin_addr.s_addr = INADDR_ANY;
+ 			
+ 		        if ((iSock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+ 			{
+        		         	log_info ("Can't create socket");
+ 			}
+ 			else
+ 			{
+ 				iRet = ioctl(iSock, SIOCGIFADDR, &tIfr);
+ 				if( iRet < 0 )
+ 				{
+        		         		log_info ("Can't ioctl SIOCGIFADDR");
+ 				}
+ 				else
+ 				{
+ 					memcpy(&uiAddr,&pSin->sin_addr,4); 
+ 					if( AUTOIP_ADDR == (uiAddr & 0xffff))
+ //					if( PRIVATE_ADDR == (uiAddr & 0xffff))
+ 					{ /* AutoIP Address */
+ 						log_info("AutoIP:%s",inet_ntoa(((struct sockaddr_in *)&tIfr.ifr_addr)->sin_addr));
+ 					}
+ 					else
+ 					{
+ 						log_info("IP:%s",inet_ntoa(((struct sockaddr_in *)&tIfr.ifr_addr)->sin_addr));
+ 						for (ip = interfaces; ip; ip = ip -> next) {
+ 							/* If interfaces were specified, don't configure
+ 							   interfaces that weren't specified! */
+ 							if (interfaces_requested &&
+ 							    ((ip -> flags & (INTERFACE_REQUESTED |
+ 									     INTERFACE_AUTOMATIC)) !=
+ 							     INTERFACE_REQUESTED))
+ 								continue;
+ 							script_init (ip -> client,
+ 								     "PREINIT", (struct string_list *)0);
+ 							if (ip -> client -> alias)
+ 								script_write_params (ip -> client, "alias_",
+ 										     ip -> client -> alias);
+ 							script_go (ip -> client);
+ 						}
+ 					}
+ 				}
+ 				close(iSock);
+ 			}
+ 		}
+ #else
  		for (ip = interfaces; ip; ip = ip -> next) {
  			/* If interfaces were specified, don't configure
  			   interfaces that weren't specified! */
***************
*** 386,391 ****
--- 450,456 ----
  						     ip -> client -> alias);
  			script_go (ip -> client);
  		}
+ #endif
  	}
  
  	/* At this point, all the interfaces that the script thinks
***************
*** 1467,1473 ****
  		if (!client->interval)
  			client->interval = client->config->initial_interval;
  		else
! 			client->interval += random() % (2 * client->interval);
  
  		/* Don't backoff past cutoff. */
  		if (client->interval > client->config->backoff_cutoff)
--- 1532,1538 ----
  		if (!client->interval)
  			client->interval = client->config->initial_interval;
  		else
! 			client->interval = 3 + (random() % 3);
  
  		/* Don't backoff past cutoff. */
  		if (client->interval > client->config->backoff_cutoff)
***************
*** 1903,1914 ****
  		if (!buffer_allocate (&bp, i, MDL))
  			log_error ("can't make parameter list buffer.");
  		else {
  			for (i = 0; prl [i]; i++)
  				bp -> data [i] = prl [i];
- 			i = DHO_DHCP_PARAMETER_REQUEST_LIST;
  			if (!(option_code_hash_lookup(&option,
  						      dhcp_universe.code_hash,
! 						      &i, 0, MDL) &&
  			      make_const_option_cache(&oc, &bp, NULL, i,
  						      option, MDL)))
  				log_error ("can't make option cache");
--- 1968,1979 ----
  		if (!buffer_allocate (&bp, i, MDL))
  			log_error ("can't make parameter list buffer.");
  		else {
+ 			unsigned code = DHO_DHCP_PARAMETER_REQUEST_LIST;
  			for (i = 0; prl [i]; i++)
  				bp -> data [i] = prl [i];
  			if (!(option_code_hash_lookup(&option,
  						      dhcp_universe.code_hash,
! 						      &code, 0, MDL) &&
  			      make_const_option_cache(&oc, &bp, NULL, i,
  						      option, MDL)))
  				log_error ("can't make option cache");
***************
*** 2664,2670 ****
  		client -> envc = 0;
  	}
  	dfree (envp, MDL);
! 	GET_TIME (&cur_time);
  	return (WIFEXITED (wstatus) ?
  		WEXITSTATUS (wstatus) : -WTERMSIG (wstatus));
  }
--- 2729,2738 ----
  		client -> envc = 0;
  	}
  	dfree (envp, MDL);
! 
! 	/* GET_TIME() is changed to get_time2() */
! 	cur_time = get_time2();
! 
  	return (WIFEXITED (wstatus) ?
  		WEXITSTATUS (wstatus) : -WTERMSIG (wstatus));
  }
diff -crN dhcp-3.1.0a3.org/common/lpf.c dhcp-3.1.0a3/common/lpf.c
*** dhcp-3.1.0a3.org/common/lpf.c	2005-03-18 05:14:59.000000000 +0900
--- dhcp-3.1.0a3/common/lpf.c	2008-09-12 11:12:06.000000000 +0900
***************
*** 65,70 ****
--- 65,71 ----
     Opens a packet filter for each interface and adds it to the select
     mask. */
  
+ static int socktmp[20];
  int if_register_lpf (info)
  	struct interface_info *info;
  {
***************
*** 72,81 ****
--- 73,99 ----
  	char filename[50];
  	int b;
  	struct sockaddr sa;
+ 	int i;
  
  	/* Make an LPF socket. */
+ #if 1
+ 	for(i = 0; i < 20; i++)
+ 	{
+ 
+ 		socktmp[i] = socket(PF_PACKET, SOCK_PACKET,htons((short)ETH_P_ALL));
+ 	}
+ 
+ 	printf("DHCP regist socket %d\n",socktmp[19]);
+ 	sock=socktmp[19];
+ 
+ 	if ((sock  < 0)) {
+ #else
+ 	sock= socket(PF_PACKET, SOCK_PACKET,htons((short)ETH_P_ALL));
+ 
  	if ((sock = socket(PF_PACKET, SOCK_PACKET,
  			   htons((short)ETH_P_ALL))) < 0) {
+ 
+ #endif 
  		if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
  		    errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
  		    errno == EAFNOSUPPORT || errno == EINVAL) {
diff -crN dhcp-3.1.0a3.org/common/tr.c dhcp-3.1.0a3/common/tr.c
*** dhcp-3.1.0a3.org/common/tr.c	2006-02-25 08:16:29.000000000 +0900
--- dhcp-3.1.0a3/common/tr.c	2008-05-28 13:21:29.000000000 +0900
***************
*** 32,37 ****
--- 32,38 ----
  #endif /* not lint */
  
  #include "dhcpd.h"
+ #include "gettime.h"
  
  #if defined (HAVE_TR_SUPPORT) && \
  	(defined (PACKET_ASSEMBLY) || defined (PACKET_DECODING))
***************
*** 137,143 ****
          struct timeval now;
  
          /* see whether any source routing information has expired */
!         gettimeofday(&now, NULL);
  
  	if (routing_timer.tv_sec == 0)
                  routing_timer.tv_sec = now.tv_sec + routing_timeout;
--- 138,144 ----
          struct timeval now;
  
          /* see whether any source routing information has expired */
!         gettimeofday2(&now, NULL);/* gettimeofday() is changed to gettimeofday2() */
  
  	if (routing_timer.tv_sec == 0)
                  routing_timer.tv_sec = now.tv_sec + routing_timeout;
***************
*** 199,205 ****
          struct timeval now;
          unsigned int route_len = 0;
  
!         gettimeofday(&now, NULL);
  
  	/* single route broadcasts as per rfc 1042 */
  	if (memcmp(trh->daddr, tr_broadcast,TR_ALEN) == 0) {
--- 200,206 ----
          struct timeval now;
          unsigned int route_len = 0;
  
!         gettimeofday2(&now, NULL);/* gettimeofday() is changed to gettimeofday2() */
  
  	/* single route broadcasts as per rfc 1042 */
  	if (memcmp(trh->daddr, tr_broadcast,TR_ALEN) == 0) {
***************
*** 256,262 ****
          unsigned char saddr[TR_ALEN];
          u_int16_t rcf = 0;
  
!         gettimeofday(&now, NULL);
  
          memcpy(saddr, trh->saddr, sizeof(saddr));
          saddr[0] &= 0x7f;   /* strip off source routing present flag */
--- 257,263 ----
          unsigned char saddr[TR_ALEN];
          u_int16_t rcf = 0;
  
!         gettimeofday2(&now, NULL);/* gettimeofday() is changed to gettimeofday2() */
  
          memcpy(saddr, trh->saddr, sizeof(saddr));
          saddr[0] &= 0x7f;   /* strip off source routing present flag */
***************
*** 317,323 ****
          struct routing_entry **prover = &routing_info;
          struct timeval now;
  
!         gettimeofday(&now, NULL);
  
          while((rover = *prover) != NULL) {
                  if ((now.tv_sec - rover->access_time) > routing_timeout) {
--- 318,324 ----
          struct routing_entry **prover = &routing_info;
          struct timeval now;
  
!         gettimeofday2(&now, NULL);/* gettimeofday() is changed to gettimeofday2() */
  
          while((rover = *prover) != NULL) {
                  if ((now.tv_sec - rover->access_time) > routing_timeout) {
diff -crN dhcp-3.1.0a3.org/dst/prandom.c dhcp-3.1.0a3/dst/prandom.c
*** dhcp-3.1.0a3.org/dst/prandom.c	2001-02-22 16:22:09.000000000 +0900
--- dhcp-3.1.0a3/dst/prandom.c	2008-05-28 13:21:29.000000000 +0900
***************
*** 36,42 ****
  #include "minires/minires.h"
  #include "dst_internal.h"
  #include "arpa/nameser.h"
! 
  
  #ifndef DST_NUM_HASHES
  #define DST_NUM_HASHES 4
--- 36,42 ----
  #include "minires/minires.h"
  #include "dst_internal.h"
  #include "arpa/nameser.h"
! #include "gettime.h"
  
  #ifndef DST_NUM_HASHES
  #define DST_NUM_HASHES 4
***************
*** 203,209 ****
  
  	zone = (struct timezone *) tmp;
  	mtime = (struct timeval *)(tmp + sizeof(struct timezone));
! 	gettimeofday(mtime, zone);
  	cnt = sizeof(tmp);
  	my_digest(work, tmp, sizeof(tmp));
  
--- 203,210 ----
  
  	zone = (struct timezone *) tmp;
  	mtime = (struct timeval *)(tmp + sizeof(struct timezone));
! 
! 	gettimeofday2(mtime, zone); /* gettimeofday() is changed to gettimeofday2() */
  	cnt = sizeof(tmp);
  	my_digest(work, tmp, sizeof(tmp));
  
***************
*** 252,258 ****
  	if (stat(dirs[i++], &buf))  /* directory does not exist */
  		return (0);
  
! 	gettimeofday(&tv,NULL);
  	if (d_round == 0) 
  		d_round = tv.tv_sec - MAX_OLD;
  	else if (i==1) /* if starting a new round cut what we accept */
--- 253,259 ----
  	if (stat(dirs[i++], &buf))  /* directory does not exist */
  		return (0);
  
! 	gettimeofday2(&tv,NULL);/* gettimeofday() is changed to gettimeofday2() */
  	if (d_round == 0) 
  		d_round = tv.tv_sec - MAX_OLD;
  	else if (i==1) /* if starting a new round cut what we accept */
***************
*** 358,364 ****
  	u_char buf[1024];
  
  	if (f_round == 0 || files[f_cnt] == NULL || work->file_digest == NULL) 
! 		if (gettimeofday(&tv, NULL)) /* only do this if needed */
  			return (0);
  	if (f_round == 0)   /* first time called set to one hour ago */
  		f_round = (tv.tv_sec - MAX_OLD); 
--- 359,366 ----
  	u_char buf[1024];
  
  	if (f_round == 0 || files[f_cnt] == NULL || work->file_digest == NULL) 
! 
! 		if (gettimeofday2(&tv, NULL)) /* only do this if needed */ /* gettimeofday() is changed to gettimeofday2() */
  			return (0);
  	if (f_round == 0)   /* first time called set to one hour ago */
  		f_round = (tv.tv_sec - MAX_OLD); 
***************
*** 530,536 ****
  		return (NULL);
  	/* do not memset the allocated memory to get random bytes there */
  	/* time of day is somewhat random  expecialy in the last bytes */
! 	gettimeofday((struct timeval *) &buff[n], NULL);
  	n += sizeof(struct timeval);
  
  /* get some semi random stuff in here stir it with micro seconds */
--- 532,538 ----
  		return (NULL);
  	/* do not memset the allocated memory to get random bytes there */
  	/* time of day is somewhat random  expecialy in the last bytes */
! 	gettimeofday2((struct timeval *) &buff[n], NULL);/* gettimeofday() is changed to gettimeofday2() */
  	n += sizeof(struct timeval);
  
  /* get some semi random stuff in here stir it with micro seconds */
diff -crN dhcp-3.1.0a3.org/includes/dhcpd.h dhcp-3.1.0a3/includes/dhcpd.h
*** dhcp-3.1.0a3.org/includes/dhcpd.h	2006-10-28 07:54:50.000000000 +0900
--- dhcp-3.1.0a3/includes/dhcpd.h	2008-05-28 13:21:32.000000000 +0900
***************
*** 55,60 ****
--- 55,61 ----
  
  #include "cdefs.h"
  #include "osdep.h"
+ #include "gettime.h"
  
  #include "arpa/nameser.h"
  #if defined (NSUPDATE)
diff -crN dhcp-3.1.0a3.org/includes/gettime.h dhcp-3.1.0a3/includes/gettime.h
*** dhcp-3.1.0a3.org/includes/gettime.h	1970-01-01 09:00:00.000000000 +0900
--- dhcp-3.1.0a3/includes/gettime.h	2008-05-28 13:21:32.000000000 +0900
***************
*** 0 ****
--- 1,16 ----
+ /* gettimeofday wrapper */
+ /** @file gettime.h
+  * Copyright (c) 2008 SHARP CORPORATION
+  *
+  * @author ikezawa@nwpf
+  */
+ #ifndef GETTIME_H
+ #define GETTIME_H
+ 
+ #include <time.h>
+ #include <sys/time.h>
+ 
+ time_t get_time2(void);
+ int gettimeofday2(struct timeval *tv, struct timezone *tz);
+ 
+ #endif /* GETTIME_H */
diff -crN dhcp-3.1.0a3.org/includes/version.h dhcp-3.1.0a3/includes/version.h
*** dhcp-3.1.0a3.org/includes/version.h	2007-01-12 01:36:52.000000000 +0900
--- dhcp-3.1.0a3/includes/version.h	2008-09-12 11:12:06.000000000 +0900
***************
*** 1,3 ****
  /* Current version of ISC DHCP Distribution. */
  
! #define DHCP_VERSION	"V3.1.0a3"
--- 1,3 ----
  /* Current version of ISC DHCP Distribution. */
  
! #define DHCP_VERSION	"V3.1.0a3-s1"
diff -crN dhcp-3.1.0a3.org/minires/ns_sign.c dhcp-3.1.0a3/minires/ns_sign.c
*** dhcp-3.1.0a3.org/minires/ns_sign.c	2005-03-18 05:15:18.000000000 +0900
--- dhcp-3.1.0a3/minires/ns_sign.c	2008-05-28 13:21:30.000000000 +0900
***************
*** 51,56 ****
--- 51,57 ----
  #include "arpa/nameser.h"
  
  #include <isc-dhcp/dst.h>
+ #include "gettime.h"
  
  #define BOUNDS_CHECK(ptr, count) \
  	do { \
***************
*** 131,137 ****
--- 132,142 ----
  	/* Time. */
  	BOUNDS_CHECK(cp, INT16SZ + INT32SZ + INT16SZ);
  	PUTSHORT(0, cp);
+ #if defined (TRACING)
  	timesigned = time(NULL);
+ #else
+ 	timesigned = get_time2();
+ #endif
  	if (error != ns_r_badtime)
  		PUTLONG(timesigned, cp);
  	else
***************
*** 314,320 ****
--- 319,329 ----
  	/* Time. */
  	BOUNDS_CHECK(cp, INT16SZ + INT32SZ + INT16SZ);
  	PUTSHORT(0, cp);
+ #if defined (TRACING)
  	timesigned = time(NULL);
+ #else
+ 	timesigned = get_time2();
+ #endif
  	PUTLONG(timesigned, cp);
  	PUTSHORT(NS_TSIG_FUDGE, cp);
  
diff -crN dhcp-3.1.0a3.org/minires/res_init.c dhcp-3.1.0a3/minires/res_init.c
*** dhcp-3.1.0a3.org/minires/res_init.c	2005-03-18 05:15:19.000000000 +0900
--- dhcp-3.1.0a3/minires/res_init.c	2008-05-28 13:21:30.000000000 +0900
***************
*** 487,492 ****
  res_randomid(void) {
  	struct timeval now;
  
! 	gettimeofday(&now, NULL);
  	return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
  }
--- 487,492 ----
  res_randomid(void) {
  	struct timeval now;
  
! 	gettimeofday2(&now, NULL); /* gettimeofday() is changed to gettimeofday2() */
  	return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
  }
diff -crN dhcp-3.1.0a3.org/omapip/Makefile.dist dhcp-3.1.0a3/omapip/Makefile.dist
*** dhcp-3.1.0a3.org/omapip/Makefile.dist	2005-03-18 05:15:20.000000000 +0900
--- dhcp-3.1.0a3/omapip/Makefile.dist	2008-05-28 13:21:28.000000000 +0900
***************
*** 27,38 ****
  SRC    = protocol.c buffer.c alloc.c result.c connection.c errwarn.c \
  	 listener.c dispatch.c generic.c support.c handle.c message.c \
  	 convert.c hash.c auth.c inet_addr.c array.c trace.c mrtrace.c \
! 	 toisc.c iscprint.c
  
  OBJ    = protocol.o buffer.o alloc.o result.o connection.o errwarn.o \
  	 listener.o dispatch.o generic.o support.o handle.o message.o \
  	 convert.o hash.o auth.o inet_addr.o array.o trace.o mrtrace.o \
! 	 toisc.o iscprint.o
  # XXX: iscprint.o above is a kludge.
  
  MAN    = omapi.3
--- 27,38 ----
  SRC    = protocol.c buffer.c alloc.c result.c connection.c errwarn.c \
  	 listener.c dispatch.c generic.c support.c handle.c message.c \
  	 convert.c hash.c auth.c inet_addr.c array.c trace.c mrtrace.c \
! 	 toisc.c iscprint.c gettime.c
  
  OBJ    = protocol.o buffer.o alloc.o result.o connection.o errwarn.o \
  	 listener.o dispatch.o generic.o support.o handle.o message.o \
  	 convert.o hash.o auth.o inet_addr.o array.o trace.o mrtrace.o \
! 	 toisc.o iscprint.o gettime.o
  # XXX: iscprint.o above is a kludge.
  
  MAN    = omapi.3
diff -crN dhcp-3.1.0a3.org/omapip/dispatch.c dhcp-3.1.0a3/omapip/dispatch.c
*** dhcp-3.1.0a3.org/omapip/dispatch.c	2005-03-18 05:15:21.000000000 +0900
--- dhcp-3.1.0a3/omapip/dispatch.c	2008-05-28 13:21:28.000000000 +0900
***************
*** 33,38 ****
--- 33,39 ----
   */
  
  #include <omapip/omapip_p.h>
+ #include "gettime.h"
  
  static omapi_io_object_t omapi_io_states;
  TIME cur_time;
***************
*** 223,229 ****
  
  	/* First, see if the timeout has expired, and if so return. */
  	if (t) {
! 		gettimeofday (&now, (struct timezone *)0);
  		cur_time = now.tv_sec;
  		if (now.tv_sec > t -> tv_sec ||
  		    (now.tv_sec == t -> tv_sec && now.tv_usec >= t -> tv_usec))
--- 224,231 ----
  
  	/* First, see if the timeout has expired, and if so return. */
  	if (t) {
! 		gettimeofday2 (&now, (struct timezone *)0); /* gettimeofday() is changed to gettimeofday2() */
! 
  		cur_time = now.tv_sec;
  		if (now.tv_sec > t -> tv_sec ||
  		    (now.tv_sec == t -> tv_sec && now.tv_usec >= t -> tv_usec))
***************
*** 292,298 ****
  	count = select (max + 1, &r, &w, &x, t ? &to : (struct timeval *)0);
  
  	/* Get the current time... */
! 	gettimeofday (&now, (struct timezone *)0);
  	cur_time = now.tv_sec;
  
  	/* We probably have a bad file descriptor.   Figure out which one.
--- 294,301 ----
  	count = select (max + 1, &r, &w, &x, t ? &to : (struct timeval *)0);
  
  	/* Get the current time... */
! 	gettimeofday2 (&now, (struct timezone *)0);/* gettimeofday() is changed to gettimeofday2() */
! 
  	cur_time = now.tv_sec;
  
  	/* We probably have a bad file descriptor.   Figure out which one.
diff -crN dhcp-3.1.0a3.org/omapip/gettime.c dhcp-3.1.0a3/omapip/gettime.c
*** dhcp-3.1.0a3.org/omapip/gettime.c	1970-01-01 09:00:00.000000000 +0900
--- dhcp-3.1.0a3/omapip/gettime.c	2008-05-28 13:21:28.000000000 +0900
***************
*** 0 ****
--- 1,50 ----
+ /* gettimeofday wrapper */
+ /** @file gettime.h
+  * Copyright (c) 2008 SHARP CORPORATION
+  *
+  * @author ikezawa@nwpf
+  */
+ #include <stdio.h>
+ #include <unistd.h>
+ #include <time.h>
+ #include <sys/time.h>
+ #include <sys/times.h>
+ #include <memory.h>
+ #include "gettime.h"
+ 
+ static struct timeval tRefTv;
+ static clock_t iRefClock  = 0;
+ static clock_t iPrevClock = 0;
+ static unsigned long uiRefTime = 0;
+ 
+ time_t get_time2(void)
+ {
+ 	struct timeval tNowTimeVal;
+ 
+ 	memset(&tNowTimeVal, 0, sizeof(struct timeval));
+ 	gettimeofday2(&tNowTimeVal,NULL);
+ 
+ 	return (time_t)tNowTimeVal.tv_sec;
+ }
+ 
+ int gettimeofday2(struct timeval *tv, struct timezone *tz)
+ {
+ 	int iRet;
+ 	struct tms tTms;
+ 	clock_t iNowClock;
+ 
+ 	iNowClock =  times(&tTms);
+ 
+ 	uiRefTime = uiRefTime + (iNowClock - iPrevClock) / sysconf(_SC_CLK_TCK) ;
+ 
+ 	iPrevClock = iNowClock;
+ 
+ 	if(NULL != tv)
+ 	{
+ 		tv->tv_sec  = uiRefTime;
+ 		tv->tv_usec = 0;
+ 	}
+ 
+ 	return 0;
+ }
+ 
diff -crN dhcp-3.1.0a3.org/omapip/mrtrace.c dhcp-3.1.0a3/omapip/mrtrace.c
*** dhcp-3.1.0a3.org/omapip/mrtrace.c	2005-03-18 05:15:22.000000000 +0900
--- dhcp-3.1.0a3/omapip/mrtrace.c	2008-05-28 13:21:28.000000000 +0900
***************
*** 373,378 ****
--- 373,379 ----
  
  time_t trace_mr_time (time_t *tp)
  {
+ 	time_t tRet;
  #if defined (TRACING)
  	if (trace_playback ()) {
  		if (tp)
***************
*** 380,386 ****
  		return cur_time;
  	}
  #endif
! 	return time (tp);
  }
  
  int trace_mr_select (int s, fd_set *r, fd_set *w, fd_set *x, struct timeval *t)
--- 381,392 ----
  		return cur_time;
  	}
  #endif
! 	tRet = get_time2();
! 	if(NULL != tp)
! 	{
! 		*tp = tRet;
! 	}
! 	return tRet;
  }
  
  int trace_mr_select (int s, fd_set *r, fd_set *w, fd_set *x, struct timeval *t)
diff -crN dhcp-3.1.0a3.org/omapip/trace.c dhcp-3.1.0a3/omapip/trace.c
*** dhcp-3.1.0a3.org/omapip/trace.c	2006-02-25 08:16:30.000000000 +0900
--- dhcp-3.1.0a3/omapip/trace.c	2008-05-28 13:21:28.000000000 +0900
***************
*** 38,43 ****
--- 38,44 ----
  #endif
  
  #include <omapip/omapip_p.h>
+ #include "gettime.h"
  
  #if defined (TRACING)
  void (*trace_set_time_hook) (TIME);
***************
*** 230,236 ****
  	/* We have to swap out the data, because it may be read back on a
  	   machine of different endianness. */
  	tmp.type_index = htonl (ttype -> index);
! 	tmp.when = htonl (time ((time_t *)0)); /* XXX */
  	tmp.length = htonl (length);
  
  	status = write (traceoutfile, &tmp, sizeof tmp);
--- 231,238 ----
  	/* We have to swap out the data, because it may be read back on a
  	   machine of different endianness. */
  	tmp.type_index = htonl (ttype -> index);
! 
! 	tmp.when = htonl(get_time2());
  	tmp.length = htonl (length);
  
  	status = write (traceoutfile, &tmp, sizeof tmp);
