diff options
author | Alberto Gonzalez Iniesta <agi@inittab.org> | 2016-12-27 18:25:47 +0100 |
---|---|---|
committer | Alberto Gonzalez Iniesta <agi@inittab.org> | 2016-12-27 18:25:47 +0100 |
commit | 79f3537f69e125f19f59c36aa090120a63186a54 (patch) | |
tree | 2089a3b7dac990841dbc2e4d9b2f535b82dbb0af /src/openvpn/schedule.h | |
parent | f2137fedb30cb87448eb03b2f288920df6187571 (diff) | |
parent | 3a2bbdb05ca6a6996e424c9fb225cb0d53804125 (diff) |
Merge tag 'upstream/2.4.0'
Upstream version 2.4.0
Diffstat (limited to 'src/openvpn/schedule.h')
-rw-r--r-- | src/openvpn/schedule.h | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/src/openvpn/schedule.h b/src/openvpn/schedule.h index 71c6d8c..f2a6813 100644 --- a/src/openvpn/schedule.h +++ b/src/openvpn/schedule.h @@ -5,7 +5,7 @@ * packet encryption, packet authentication, and * packet compression. * - * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net> + * Copyright (C) 2002-2017 OpenVPN Technologies, Inc. <sales@openvpn.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 @@ -46,27 +46,30 @@ struct schedule_entry { - struct timeval tv; /* wakeup time */ - unsigned int pri; /* random treap priority */ - struct schedule_entry *parent; /* treap (btree) links */ - struct schedule_entry *lt; - struct schedule_entry *gt; + struct timeval tv; /* wakeup time */ + unsigned int pri; /* random treap priority */ + struct schedule_entry *parent; /* treap (btree) links */ + struct schedule_entry *lt; + struct schedule_entry *gt; }; struct schedule { - struct schedule_entry *earliest_wakeup; /* cached earliest wakeup */ - struct schedule_entry *root; /* the root of the treap (btree) */ + struct schedule_entry *earliest_wakeup; /* cached earliest wakeup */ + struct schedule_entry *root; /* the root of the treap (btree) */ }; /* Public functions */ -struct schedule *schedule_init (void); -void schedule_free (struct schedule *s); -void schedule_remove_entry (struct schedule *s, struct schedule_entry *e); +struct schedule *schedule_init(void); + +void schedule_free(struct schedule *s); + +void schedule_remove_entry(struct schedule *s, struct schedule_entry *e); #ifdef SCHEDULE_TEST -void schedule_test (void); +void schedule_test(void); + #endif /* Private Functions */ @@ -74,9 +77,11 @@ void schedule_test (void); /* is node already in tree? */ #define IN_TREE(e) ((e)->pri) -struct schedule_entry *schedule_find_least (struct schedule_entry *e); -void schedule_add_modify (struct schedule *s, struct schedule_entry *e); -void schedule_remove_node (struct schedule *s, struct schedule_entry *e); +struct schedule_entry *schedule_find_least(struct schedule_entry *e); + +void schedule_add_modify(struct schedule *s, struct schedule_entry *e); + +void schedule_remove_node(struct schedule *s, struct schedule_entry *e); /* Public inline functions */ @@ -93,16 +98,16 @@ void schedule_remove_node (struct schedule *s, struct schedule_entry *e); * an opaque object. */ static inline void -schedule_add_entry (struct schedule *s, - struct schedule_entry *e, - const struct timeval *tv, - unsigned int sigma) +schedule_add_entry(struct schedule *s, + struct schedule_entry *e, + const struct timeval *tv, + unsigned int sigma) { - if (!IN_TREE (e) || !sigma || !tv_within_sigma (tv, &e->tv, sigma)) + if (!IN_TREE(e) || !sigma || !tv_within_sigma(tv, &e->tv, sigma)) { - e->tv = *tv; - schedule_add_modify (s, e); - s->earliest_wakeup = NULL; /* invalidate cache */ + e->tv = *tv; + schedule_add_modify(s, e); + s->earliest_wakeup = NULL; /* invalidate cache */ } } @@ -113,20 +118,24 @@ schedule_add_entry (struct schedule *s, * is randomized every time an entry is re-added). */ static inline struct schedule_entry * -schedule_get_earliest_wakeup (struct schedule *s, - struct timeval *wakeup) +schedule_get_earliest_wakeup(struct schedule *s, + struct timeval *wakeup) { - struct schedule_entry *ret; + struct schedule_entry *ret; - /* cache result */ - if (!s->earliest_wakeup) - s->earliest_wakeup = schedule_find_least (s->root); - ret = s->earliest_wakeup; - if (ret) - *wakeup = ret->tv; + /* cache result */ + if (!s->earliest_wakeup) + { + s->earliest_wakeup = schedule_find_least(s->root); + } + ret = s->earliest_wakeup; + if (ret) + { + *wakeup = ret->tv; + } - return ret; + return ret; } -#endif -#endif +#endif /* if P2MP_SERVER */ +#endif /* ifndef SCHEDULE_H */ |