int ret;
if (vpninfo->dtls_state == DTLS_SLEEPING) {
- int when = vpninfo->new_dtls_started + vpninfo->dtls_attempt_period - time(NULL);
- if (when <= 0 || vpninfo->dtls_need_reconnect) {
+ if (ka_check_deadline(timeout, time(NULL), vpninfo->new_dtls_started + vpninfo->dtls_attempt_period)
+ || vpninfo->dtls_need_reconnect) {
vpn_progress(vpninfo, PRG_DEBUG, _("Send ESP probes\n"));
if (vpninfo->proto->udp_send_probes)
vpninfo->proto->udp_send_probes(vpninfo);
- when = vpninfo->dtls_attempt_period;
}
- if (*timeout > when * 1000)
- *timeout = when * 1000;
}
if (vpninfo->dtls_fd == -1)
return 0;
return 0;
case DTLS_SECRET:
case DTLS_SLEEPING:
- if (time(NULL) < vpninfo->dtls_times.last_rekey + 5) {
+ if (!ka_check_deadline(timeout, time(NULL), vpninfo->dtls_times.last_rekey + 5)) {
/* Allow 5 seconds after configuration for ESP to start */
- if (*timeout > 5000)
- *timeout = 5000;
return 0;
} else if (!vpninfo->ssl_times.last_rekey) {
/* ... before we switch to HTTPS instead */
return ret < 0 ? ret : -EIO;
}
-static int ka_check_deadline(int *timeout, time_t now, time_t due)
+int ka_check_deadline(int *timeout, time_t now, time_t due)
{
if (now >= due)
return 1;
int queue_new_packet(struct pkt_q *q, void *buf, int len);
int keepalive_action(struct keepalive_info *ka, int *timeout);
int ka_stalled_action(struct keepalive_info *ka, int *timeout);
+int ka_check_deadline(int *timeout, time_t now, time_t due);
/* xml.c */
ssize_t read_file_into_string(struct openconnect_info *vpninfo, const char *fname,