^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef _WG_TIMERS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define _WG_TIMERS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/ktime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct wg_peer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) void wg_timers_init(struct wg_peer *peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) void wg_timers_stop(struct wg_peer *peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) void wg_timers_data_sent(struct wg_peer *peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) void wg_timers_data_received(struct wg_peer *peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) void wg_timers_any_authenticated_packet_sent(struct wg_peer *peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) void wg_timers_any_authenticated_packet_received(struct wg_peer *peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) void wg_timers_handshake_initiated(struct wg_peer *peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) void wg_timers_handshake_complete(struct wg_peer *peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) void wg_timers_session_derived(struct wg_peer *peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) void wg_timers_any_authenticated_packet_traversal(struct wg_peer *peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static inline bool wg_birthdate_has_expired(u64 birthday_nanoseconds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) u64 expiration_seconds)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) return (s64)(birthday_nanoseconds + expiration_seconds * NSEC_PER_SEC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) <= (s64)ktime_get_coarse_boottime_ns();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #endif /* _WG_TIMERS_H */