Commit 62eb3b4c authored by Kevin Cernekee's avatar Kevin Cernekee

library: Rename cancel_fd to cmd_fd

Applications which use libopenconnect may need to interrupt the mainloop
for a couple of reasons:

 - Cancel/disconnect
 - Force reconnect: in case the IP configuration changed
 - Retrieving bytecounts or other internal information

The cancel_fd mechanism provides a convenient way to send these commands,
but first we need to make it more generic (while preserving backward
compatibility).
Signed-off-by: default avatarKevin Cernekee <cernekee@gmail.com>
parent c58cd771
......@@ -56,7 +56,7 @@ struct openconnect_info *openconnect_vpninfo_new(char *useragent,
vpninfo->process_auth_form = process_auth_form;
vpninfo->progress = progress;
vpninfo->cbdata = privdata ? : vpninfo;
vpninfo->cancel_fd = -1;
vpninfo->cmd_fd = -1;
vpninfo->xmlpost = 1;
openconnect_set_reported_os(vpninfo, NULL);
......@@ -279,7 +279,7 @@ void openconnect_set_cert_expiry_warning(struct openconnect_info *vpninfo,
void openconnect_set_cancel_fd(struct openconnect_info *vpninfo, int fd)
{
vpninfo->cancel_fd = fd;
vpninfo->cmd_fd = fd;
}
const char *openconnect_get_version(void)
......
......@@ -530,7 +530,7 @@ int main(int argc, char **argv)
vpninfo->cbdata = vpninfo;
vpninfo->cert_expire_warning = 60 * 86400;
vpninfo->vpnc_script = DEFAULT_VPNCSCRIPT;
vpninfo->cancel_fd = -1;
vpninfo->cmd_fd = -1;
vpninfo->xmlpost = 1;
if (!uname(&utsbuf))
......
......@@ -295,7 +295,7 @@ struct openconnect_info {
int ssl_fd;
int dtls_fd;
int new_dtls_fd;
int cancel_fd;
int cmd_fd;
struct pkt *incoming_queue;
struct pkt *outgoing_queue;
......
......@@ -523,14 +523,14 @@ int keystore_fetch(const char *key, unsigned char **result)
void cmd_fd_set(struct openconnect_info *vpninfo, fd_set *fds, int *maxfd)
{
if (vpninfo->cancel_fd != -1) {
FD_SET(vpninfo->cancel_fd, fds);
if (vpninfo->cancel_fd > *maxfd)
*maxfd = vpninfo->cancel_fd;
if (vpninfo->cmd_fd != -1) {
FD_SET(vpninfo->cmd_fd, fds);
if (vpninfo->cmd_fd > *maxfd)
*maxfd = vpninfo->cmd_fd;
}
}
int is_cancel_pending(struct openconnect_info *vpninfo, fd_set *fds)
{
return vpninfo->cancel_fd != -1 && FD_ISSET(vpninfo->cancel_fd, fds);
return vpninfo->cmd_fd != -1 && FD_ISSET(vpninfo->cmd_fd, fds);
}
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