Commit 761832fd authored by David Woodhouse's avatar David Woodhouse

Split out os_shutdown_tun() for Windows vs. sane platforms

Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 4b3317e3
......@@ -219,7 +219,7 @@ int openconnect_mainloop(struct openconnect_info *vpninfo,
cstp_bye(vpninfo, vpninfo->quit_reason);
shutdown_tun(vpninfo);
os_shutdown_tun(vpninfo);
return ret < 0 ? ret : -EIO;
}
......
......@@ -454,7 +454,7 @@ void set_script_env(struct openconnect_info *vpninfo);
int script_config_tun(struct openconnect_info *vpninfo, const char *reason);
/* tun.c */
void shutdown_tun(struct openconnect_info *vpninfo);
void os_shutdown_tun(struct openconnect_info *vpninfo);
int os_read_tun(struct openconnect_info *vpninfo, struct pkt *pkt, int new_pkt);
int os_write_tun(struct openconnect_info *vpninfo, struct pkt *pkt);
......
......@@ -264,3 +264,12 @@ int os_write_tun(struct openconnect_info *vpninfo, struct pkt *pkt)
_("Failed to write to TAP device: %lx\n"), err);
return -1;
}
void os_shutdown_tun(struct openconnect_info *vpninfo)
{
script_config_tun(vpninfo, "disconnect");
CloseHandle(vpninfo->tun_fh);
vpninfo->tun_fh = NULL;
CloseHandle(vpninfo->tun_rd_overlap.hEvent);
vpninfo->tun_rd_overlap.hEvent = NULL;
}
......@@ -467,15 +467,9 @@ int openconnect_setup_tun_device(struct openconnect_info *vpninfo, char *vpnc_sc
return openconnect_setup_tun_fd(vpninfo, tun_fd);
}
void shutdown_tun(struct openconnect_info *vpninfo)
#ifndef _WIN32
void os_shutdown_tun(struct openconnect_info *vpninfo)
{
#ifdef _WIN32
script_config_tun(vpninfo, "disconnect");
CloseHandle(vpninfo->tun_fh);
vpninfo->tun_fh = NULL;
CloseHandle(vpninfo->tun_rd_overlap.hEvent);
vpninfo->tun_rd_overlap.hEvent = NULL;
#else
if (vpninfo->script_tun) {
/* nuke the whole process group */
kill(-vpninfo->script_tun, SIGHUP);
......@@ -494,5 +488,5 @@ void shutdown_tun(struct openconnect_info *vpninfo)
if (vpninfo->vpnc_script)
close(vpninfo->tun_fd);
vpninfo->tun_fd = -1;
#endif
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment