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