Allow IPv6 address entry in tools>ping - Loosens valid character check
[tomato/davidwu.git] / release / src / router / xl2tpd / scheduler.h
blob525305e65955e6268d2f994dfa487414e48eb16a
1 /*
2 * Layer Two Tunnelling Protocol Daemon
3 * Copyright (C) 1998 Adtran, Inc.
4 * Copyright (C) 2002 Jeff McAdams
6 * Mark Spencer
8 * This software is distributed under the terms
9 * of the GPL, which you should have received
10 * along with this source.
12 * Scheduler structures and functions
16 #ifndef _SCHEDULER_H
17 #define _SCHEDULER_H
18 #include <sys/time.h>
21 * The idea is to provide a general scheduler which can schedule
22 * events to be run periodically
25 struct schedule_entry
27 struct timeval tv; /* Scheduled time to execute */
28 void (*func) (void *); /* Function to execute */
29 void *data; /* Data to be passed to func */
30 struct schedule_entry *next; /* Next entry in queue */
33 extern struct schedule_entry *events;
35 /* Schedule func to be executed with argument data sometime
36 tv in the future. */
38 struct schedule_entry *schedule (struct timeval tv, void (*func) (void *),
39 void *data);
41 /* Like schedule() but tv represents an absolute time in the future */
43 struct schedule_entry *aschedule (struct timeval tv, void (*func) (void *),
44 void *data);
46 /* Remove a scheduled event from the queue */
48 void deschedule (struct schedule_entry *);
50 /* Initialization function */
51 void init_scheduler (void);
53 /* Scheduled event processor */
54 struct timeval *process_schedule(struct timeval *);
56 /* Compare two timeval functions and see if a <= b */
58 #define TVLESS(a,b) ((a).tv_sec == (b).tv_sec ? \
59 ((a).tv_usec < (b).tv_usec) : \
60 ((a).tv_sec < (b).tv_sec))
61 #define TVLESSEQ(a,b) ((a).tv_sec == (b).tv_sec ? \
62 ((a).tv_usec <= (b).tv_usec) : \
63 ((a).tv_sec <= (b).tv_sec))
64 #define TVGT(a,b) ((a).tv_sec == (b).tv_sec ? \
65 ((a).tv_usec > (b).tv_usec) : \
66 ((a).tv_sec > (b).tv_sec))
67 #endif