summaryrefslogtreecommitdiff
path: root/src/openvpn/occ.h
diff options
context:
space:
mode:
authorBernhard Schmidt <berni@debian.org>2020-08-15 21:29:50 +0200
committerBernhard Schmidt <berni@debian.org>2020-08-15 21:29:50 +0200
commit1079962e4c06f88a54e50d997c1b7e84303d30b4 (patch)
tree4d019426928435425214ccedd6f89b70dbdf035d /src/openvpn/occ.h
parent620785fe268a1221c1ba7a9cb5a70f3140a4f1ca (diff)
New upstream version 2.5~beta1upstream/2.5_beta1
Diffstat (limited to 'src/openvpn/occ.h')
-rw-r--r--src/openvpn/occ.h68
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 */