BadVPN – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /** |
2 | * @file |
||
3 | * Timer implementations |
||
4 | */ |
||
5 | |||
6 | /* |
||
7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. |
||
8 | * All rights reserved. |
||
9 | * |
||
10 | * Redistribution and use in source and binary forms, with or without modification, |
||
11 | * are permitted provided that the following conditions are met: |
||
12 | * |
||
13 | * 1. Redistributions of source code must retain the above copyright notice, |
||
14 | * this list of conditions and the following disclaimer. |
||
15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
||
16 | * this list of conditions and the following disclaimer in the documentation |
||
17 | * and/or other materials provided with the distribution. |
||
18 | * 3. The name of the author may not be used to endorse or promote products |
||
19 | * derived from this software without specific prior written permission. |
||
20 | * |
||
21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
||
22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||
23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||
24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
||
25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
||
26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
||
29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
||
30 | * OF SUCH DAMAGE. |
||
31 | * |
||
32 | * This file is part of the lwIP TCP/IP stack. |
||
33 | * |
||
34 | * Author: Adam Dunkels <adam@sics.se> |
||
35 | * Simon Goldschmidt |
||
36 | * |
||
37 | */ |
||
38 | #ifndef LWIP_HDR_TIMEOUTS_H |
||
39 | #define LWIP_HDR_TIMEOUTS_H |
||
40 | |||
41 | #include "lwip/opt.h" |
||
42 | #include "lwip/err.h" |
||
43 | #if !NO_SYS |
||
44 | #include "lwip/sys.h" |
||
45 | #endif |
||
46 | |||
47 | #ifdef __cplusplus |
||
48 | extern "C" { |
||
49 | #endif |
||
50 | |||
51 | #ifndef LWIP_DEBUG_TIMERNAMES |
||
52 | #ifdef LWIP_DEBUG |
||
53 | #define LWIP_DEBUG_TIMERNAMES SYS_DEBUG |
||
54 | #else /* LWIP_DEBUG */ |
||
55 | #define LWIP_DEBUG_TIMERNAMES 0 |
||
56 | #endif /* LWIP_DEBUG*/ |
||
57 | #endif |
||
58 | |||
59 | /** Function prototype for a stack-internal timer function that has to be |
||
60 | * called at a defined interval */ |
||
61 | typedef void (* lwip_cyclic_timer_handler)(void); |
||
62 | |||
63 | /** This struct contains information about a stack-internal timer function |
||
64 | that has to be called at a defined interval */ |
||
65 | struct lwip_cyclic_timer { |
||
66 | u32_t interval_ms; |
||
67 | lwip_cyclic_timer_handler handler; |
||
68 | #if LWIP_DEBUG_TIMERNAMES |
||
69 | const char* handler_name; |
||
70 | #endif /* LWIP_DEBUG_TIMERNAMES */ |
||
71 | }; |
||
72 | |||
73 | /** This array contains all stack-internal cyclic timers. To get the number of |
||
74 | * timers, use lwip_num_cyclic_timers */ |
||
75 | extern const struct lwip_cyclic_timer lwip_cyclic_timers[]; |
||
76 | /** Array size of lwip_cyclic_timers[] */ |
||
77 | extern const int lwip_num_cyclic_timers; |
||
78 | |||
79 | #if LWIP_TIMERS |
||
80 | |||
81 | /** Function prototype for a timeout callback function. Register such a function |
||
82 | * using sys_timeout(). |
||
83 | * |
||
84 | * @param arg Additional argument to pass to the function - set up by sys_timeout() |
||
85 | */ |
||
86 | typedef void (* sys_timeout_handler)(void *arg); |
||
87 | |||
88 | struct sys_timeo { |
||
89 | struct sys_timeo *next; |
||
90 | u32_t time; |
||
91 | sys_timeout_handler h; |
||
92 | void *arg; |
||
93 | #if LWIP_DEBUG_TIMERNAMES |
||
94 | const char* handler_name; |
||
95 | #endif /* LWIP_DEBUG_TIMERNAMES */ |
||
96 | }; |
||
97 | |||
98 | void sys_timeouts_init(void); |
||
99 | |||
100 | #if LWIP_DEBUG_TIMERNAMES |
||
101 | void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name); |
||
102 | #define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) |
||
103 | #else /* LWIP_DEBUG_TIMERNAMES */ |
||
104 | void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg); |
||
105 | #endif /* LWIP_DEBUG_TIMERNAMES */ |
||
106 | |||
107 | void sys_untimeout(sys_timeout_handler handler, void *arg); |
||
108 | void sys_restart_timeouts(void); |
||
109 | #if NO_SYS |
||
110 | void sys_check_timeouts(void); |
||
111 | u32_t sys_timeouts_sleeptime(void); |
||
112 | #else /* NO_SYS */ |
||
113 | void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg); |
||
114 | #endif /* NO_SYS */ |
||
115 | |||
116 | |||
117 | #endif /* LWIP_TIMERS */ |
||
118 | |||
119 | #ifdef __cplusplus |
||
120 | } |
||
121 | #endif |
||
122 | |||
123 | #endif /* LWIP_HDR_TIMEOUTS_H */ |