32 if (
peer->timers[timer_id] != ~0)
34 tw_timer_stop_16t_2w_512sl (
peer->timer_wheel,
peer->timers[timer_id]);
35 peer->timers[timer_id] = ~0;
44 if (
peer->timers[timer_id] == ~0)
46 peer->timers[timer_id] =
48 timer_id, interval_ticks);
75 .interval_ticks = interval_ticks,
87 static const int32_t rounding = (int32_t) (
WHZ / 2);
91 return (ticks_remain > rounding) ? (
u32) ticks_remain : 0;
97 if (
peer->rehandshake_started == ~0)
101 peer->rehandshake_interval_tick);
120 ++
peer->timer_handshake_attempts;
128 if (
peer->last_sent_packet <
peer->last_received_packet)
139 if (
peer->timer_need_another_keepalive)
141 peer->timer_need_another_keepalive =
false;
151 if (
peer->persistent_keepalive_interval)
153 f64 latest_time =
peer->last_sent_packet >
peer->last_received_packet
154 ?
peer->last_sent_packet :
peer->last_received_packet;
157 peer->persistent_keepalive_interval *
173 peer->new_handshake_interval_tick);
203 if (
peer->persistent_keepalive_interval)
206 WG_TIMER_PERSISTENT_KEEPALIVE,
207 peer->persistent_keepalive_interval *
WHZ);
221 peer->rehandshake_interval_tick =
225 peer->rehandshake_interval_tick);
241 peer->new_handshake_interval_tick =
246 peer->new_handshake_interval_tick);
253 if (
peer->timers[WG_TIMER_SEND_KEEPALIVE] == ~0)
259 peer->timer_need_another_keepalive =
true;
268 peer->rehandshake_started = ~0;
269 peer->timer_handshake_attempts = 0;
293 for (
i = 0;
i <
vec_len (expired_timers);
i++)
295 pool_index = expired_timers[
i] & 0x0FFFFFFF;
296 timer_id = expired_timers[
i] >> 28;
299 peer->timers[timer_id] = ~0;
302 peer->timers_dispatched[timer_id] = 0;
305 for (
i = 0;
i <
vec_len (expired_timers);
i++)
307 pool_index = expired_timers[
i] & 0x0FFFFFFF;
308 timer_id = expired_timers[
i] >> 28;
313 case WG_TIMER_RETRANSMIT_HANDSHAKE:
316 case WG_TIMER_PERSISTENT_KEEPALIVE:
319 case WG_TIMER_SEND_KEEPALIVE:
322 case WG_TIMER_NEW_HANDSHAKE:
325 case WG_TIMER_KEY_ZEROING:
338 tw_timer_wheel_16t_2w_512sl_t *tw = &wmp->
timer_wheel;
339 tw_timer_wheel_init_16t_2w_512sl (tw,
349 uword event_type = 0;
376 tw_timer_expire_timers_16t_2w_512sl (&wmp->
timer_wheel,
387 if (
peer->timer_wheel)