diff options
Diffstat (limited to 'src/openvpn/occ.h')
-rw-r--r-- | src/openvpn/occ.h | 68 |
1 files changed, 65 insertions, 3 deletions
diff --git a/src/openvpn/occ.h b/src/openvpn/occ.h index f6ff5f9..504c8c4 100644 --- a/src/openvpn/occ.h +++ b/src/openvpn/occ.h @@ -24,8 +24,6 @@ #ifndef OCC_H #define OCC_H -#ifdef ENABLE_OCC - #include "forward.h" /* OCC_STRING_SIZE must be set to sizeof (occ_magic) */ @@ -90,5 +88,69 @@ is_occ_msg(const struct buffer *buf) void process_received_occ_msg(struct context *c); -#endif /* ifdef ENABLE_OCC */ +void check_send_occ_req_dowork(struct context *c); + +void check_send_occ_load_test_dowork(struct context *c); + +void check_send_occ_msg_dowork(struct context *c); + +/* + * Inline functions + */ + +static inline int +occ_reset_op(void) +{ + return -1; +} + +/* + * Should we send an OCC_REQUEST message? + */ +static inline void +check_send_occ_req(struct context *c) +{ + if (event_timeout_defined(&c->c2.occ_interval) + && event_timeout_trigger(&c->c2.occ_interval, + &c->c2.timeval, + (!TO_LINK_DEF(c) && c->c2.occ_op < 0) ? ETT_DEFAULT : 0)) + { + check_send_occ_req_dowork(c); + } +} + +/* + * Should we send an MTU load test? + */ +static inline void +check_send_occ_load_test(struct context *c) +{ + if (event_timeout_defined(&c->c2.occ_mtu_load_test_interval) + && event_timeout_trigger(&c->c2.occ_mtu_load_test_interval, + &c->c2.timeval, + (!TO_LINK_DEF(c) && c->c2.occ_op < 0) ? ETT_DEFAULT : 0)) + { + check_send_occ_load_test_dowork(c); + } +} + +/* + * Should we send an OCC message? + */ +static inline void +check_send_occ_msg(struct context *c) +{ + if (c->c2.occ_op >= 0) + { + if (!TO_LINK_DEF(c)) + { + check_send_occ_msg_dowork(c); + } + else + { + tv_clear(&c->c2.timeval); /* ZERO-TIMEOUT */ + } + } +} + #endif /* ifndef OCC_H */ |