2 * $Id: timer.c,v 1.12 2011/02/22 00:20:40 reubenhwk Exp $
5 * Pedro Roque <roque@di.fc.ul.pt>
6 * Lars Fenneberg <lf@elemental.net>
8 * This software is Copyright 1996-2000 by the above mentioned author(s),
11 * The license which is distributed with this software in the file COPYRIGHT
12 * applies to this software. If your distribution is missing this file, you
13 * may request it from <pekkas@netcore.fi>.
20 next_timeval(double next
)
23 gettimeofday(&tv
, NULL
);
24 tv
.tv_sec
+= (int)next
;
25 tv
.tv_usec
+= 1000000 * (next
- (int)next
);
30 timevaldiff(struct timeval
const *a
, struct timeval
const *b
)
33 msec
= (a
->tv_sec
- b
->tv_sec
) * 1000;
34 msec
+= (a
->tv_usec
- b
->tv_usec
) / 1000;
39 /* Returns when the next time should expire in milliseconds. */
41 next_time_msec(struct Interface
const * iface
)
45 gettimeofday(&tv
, NULL
);
46 retval
= timevaldiff(&iface
->next_multicast
, &tv
);
47 return retval
>= 1 ? retval
: 1;
51 expired(struct Interface
const * iface
)
54 gettimeofday(&tv
, NULL
);
55 if(timevaldiff(&iface
->next_multicast
, &tv
) > 0)