From 3a2bbdb05ca6a6996e424c9fb225cb0d53804125 Mon Sep 17 00:00:00 2001 From: Alberto Gonzalez Iniesta Date: Tue, 27 Dec 2016 18:25:47 +0100 Subject: New upstream version 2.4.0 --- src/openvpn/schedule.h | 79 ++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 35 deletions(-) (limited to 'src/openvpn/schedule.h') 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. + * Copyright (C) 2002-2017 OpenVPN Technologies, Inc. * * 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 */ -- cgit v1.2.3