void dtls_close(struct openconnect_info *vpninfo) { if (vpninfo->dtls_ssl) { DTLS_FREE(vpninfo->dtls_ssl); closesocket(vpninfo->dtls_fd); unmonitor_read_fd(vpninfo, dtls); unmonitor_write_fd(vpninfo, dtls); unmonitor_except_fd(vpninfo, dtls); vpninfo->dtls_ssl = NULL; vpninfo->dtls_fd = -1; } }
void esp_close(struct openconnect_info *vpninfo) { /* We close and reopen the socket in case we roamed and our local IP address has changed. */ if (vpninfo->dtls_fd != -1) { closesocket(vpninfo->dtls_fd); unmonitor_read_fd(vpninfo, dtls); unmonitor_write_fd(vpninfo, dtls); unmonitor_except_fd(vpninfo, dtls); vpninfo->dtls_fd = -1; } vpninfo->dtls_state = DTLS_SLEEPING; }
int openconnect_setup_tun_fd(struct openconnect_info *vpninfo, int tun_fd) { set_fd_cloexec(tun_fd); if (vpninfo->tun_fd != -1) unmonitor_read_fd(vpninfo, tun); vpninfo->tun_fd = tun_fd; monitor_fd_new(vpninfo, tun); monitor_read_fd(vpninfo, tun); set_sock_nonblock(tun_fd); return 0; }