]> git.saurik.com Git - apple/ipsec.git/blob - ipsec-tools/racoon/schedule.h
ipsec-317.220.1.tar.gz
[apple/ipsec.git] / ipsec-tools / racoon / schedule.h
1 /* $NetBSD: schedule.h,v 1.4.6.1 2007/03/21 14:29:48 vanhu Exp $ */
2
3 /* Id: schedule.h,v 1.5 2006/05/03 21:53:42 vanhu Exp */
4
5 /*
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34 #ifndef _SCHEDULE_H
35 #define _SCHEDULE_H
36
37 #include <sys/queue.h>
38 #include <dispatch/dispatch.h>
39
40 typedef int schedule_ref;
41
42 /* scheduling table */
43 /* the head is the nearest event. */
44 struct sched {
45 schedule_ref ref;
46 time_t xtime; /* event time which is as time(3). */
47 void (*func) (void *); /* call this function when timeout. */
48 void *param; /* pointer to parameter */
49 int dead; /* dead or alive */
50 TAILQ_ENTRY(sched) chain;
51 };
52
53 /* cancel schedule */
54 #define SCHED_KILL(s) \
55 do { \
56 if(s != 0){ \
57 sched_kill(s); \
58 s = 0; \
59 } \
60 } while(0)
61
62 void timer_handler (struct sched *);
63 schedule_ref sched_new (time_t, void (*func) (void *), void *);
64 int sched_is_dead(schedule_ref ref);
65 int sched_get_time(schedule_ref ref, time_t *time);
66 void sched_kill (schedule_ref);
67 void sched_killall(void);
68 void sched_init (void);
69 void sched_scrub_param (void *);
70 time_t current_time (void);
71
72 #endif /* _SCHEDULE_H */