timers.h 1.0 KB

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