void check_add_routes_dowork (struct context *c) { if (test_routes (c->c1.route_list, c->c1.tuntap)) { check_add_routes_action (c, false); } else if (event_timeout_trigger (&c->c2.route_wakeup_expire, &c->c2.timeval, ETT_DEFAULT)) { check_add_routes_action (c, true); } else { msg (D_ROUTE, "Route: Waiting for TUN/TAP interface to come up..."); if (c->c1.tuntap) { if (!tun_standby (c->c1.tuntap)) { register_signal (c, SIGHUP, "ip-fail"); c->persist.restart_sleep_seconds = 10; #ifdef WIN32 show_routes (M_INFO|M_NOPREFIX); show_adapters (M_INFO|M_NOPREFIX); #endif } } update_time (); if (c->c2.route_wakeup.n != 1) event_timeout_init (&c->c2.route_wakeup, 1, now); event_timeout_reset (&c->c2.ping_rec_interval); } }
/* * Things that need to happen immediately after connection initiation should go here. */ void check_connection_established_dowork (struct context *c) { if (event_timeout_trigger (&c->c2.wait_for_connect, &c->c2.timeval, ETT_DEFAULT)) { if (CONNECTION_ESTABLISHED (c)) { #if P2MP /* if --pull was specified, send a push request to server */ if (c->c2.tls_multi && c->options.pull) { #ifdef ENABLE_MANAGEMENT if (management) { management_set_state (management, OPENVPN_STATE_GET_CONFIG, NULL, 0, 0); } #endif /* send push request in 1 sec */ event_timeout_init (&c->c2.push_request_interval, 1, now); reset_coarse_timers (c); } else #endif { do_up (c, false, 0); } event_timeout_clear (&c->c2.wait_for_connect); } } }
void pf_check_reload(struct context *c) { const int slow_wakeup = 15; const int fast_wakeup = 1; const int wakeup_transition = 60; bool reloaded = false; if (c->c2.pf.enabled && c->c2.pf.filename && event_timeout_trigger(&c->c2.pf.reload, &c->c2.timeval, ETT_DEFAULT)) { platform_stat_t s; if (!platform_stat(c->c2.pf.filename, &s)) { if (s.st_mtime > c->c2.pf.file_last_mod) { struct pf_set *pfs = pf_init_from_file(c->c2.pf.filename); if (pfs) { if (c->c2.pf.pfs) { pf_destroy(c->c2.pf.pfs); } c->c2.pf.pfs = pfs; reloaded = true; if (pf_kill_test(pfs)) { c->sig->signal_received = SIGTERM; c->sig->signal_text = "pf-kill"; } } c->c2.pf.file_last_mod = s.st_mtime; } } { int wakeup = slow_wakeup; if (!c->c2.pf.pfs && c->c2.pf.n_check_reload < wakeup_transition) { wakeup = fast_wakeup; } event_timeout_init(&c->c2.pf.reload, wakeup, now); reset_coarse_timers(c); c->c2.pf.n_check_reload++; } } #ifdef ENABLE_DEBUG if (reloaded && check_debug_level(D_PF_DEBUG)) { pf_context_print(&c->c2.pf, "pf_check_reload", D_PF_DEBUG); } #endif }
bool status_trigger_tv(struct status_output *so, struct timeval *tv) { if (so) { return event_timeout_trigger(&so->et, tv, ETT_DEFAULT); } else { return false; } }
bool status_trigger(struct status_output *so) { if (so) { struct timeval null; CLEAR(null); return event_timeout_trigger(&so->et, &null, ETT_DEFAULT); } else { return false; } }
void process_explicit_exit_notification_timer_wakeup(struct context *c) { if (event_timeout_trigger(&c->c2.explicit_exit_notification_interval, &c->c2.timeval, ETT_DEFAULT)) { ASSERT(c->c2.explicit_exit_notification_time_wait && c->options.ce.explicit_exit_notification); if (now >= c->c2.explicit_exit_notification_time_wait + c->options.ce.explicit_exit_notification) { event_timeout_clear(&c->c2.explicit_exit_notification_interval); c->sig->signal_received = SIGTERM; c->sig->signal_text = "exit-with-notification"; } else { c->c2.occ_op = OCC_EXIT; } } }