* Some ntohs stuff.

* Etimer package only allows you to sleep half as many ticks as one
  would expect. Adjust for this.
This commit is contained in:
bg- 2006-08-17 12:51:07 +00:00
parent d16b9ad15d
commit f0a14fbeae

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* @(#)$Id: dhcpc.c,v 1.3 2006/08/09 16:13:39 bg- Exp $
* @(#)$Id: dhcpc.c,v 1.4 2006/08/17 12:51:07 bg- Exp $
*/
#include <stdio.h>
@ -344,11 +344,14 @@ PT_THREAD(handle_dhcp(process_event_t ev, void *data))
dhcpc_configured(&s);
if((s.lease_time[0]*65536ul + ntohs(s.lease_time[1]))*CLOCK_SECOND/2
<= (clock_time_t)~0ul) {
s.ticks = (s.lease_time[0]*65536ul +ntohs(s.lease_time[1]))*CLOCK_SECOND/2;
#define MAX_TICKS (~((clock_time_t)0) / 2)
if((ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1]))*CLOCK_SECOND/2
<= MAX_TICKS) {
s.ticks = (ntohs(s.lease_time[0])*65536ul
+ ntohs(s.lease_time[1]))*CLOCK_SECOND/2;
} else {
s.ticks = ~0u;
s.ticks = MAX_TICKS;
}
etimer_set(&s.etimer, s.ticks);