From f0a14fbeae0947ec053eedbfc9c3d24798cb58e3 Mon Sep 17 00:00:00 2001 From: bg- Date: Thu, 17 Aug 2006 12:51:07 +0000 Subject: [PATCH] * Some ntohs stuff. * Etimer package only allows you to sleep half as many ticks as one would expect. Adjust for this. --- core/net/dhcpc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/net/dhcpc.c b/core/net/dhcpc.c index abb36842b..83671f60f 100644 --- a/core/net/dhcpc.c +++ b/core/net/dhcpc.c @@ -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 @@ -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);