Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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: Kevin Cernekee <cernekee@gmail.com>
  • Loading branch information
cernekee committed Jan 15, 2014
1 parent c58cd77 commit 62eb3b4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions library.c
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion main.c
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion openconnect-internal.h
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions ssl.c
Expand Up @@ -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);
}

0 comments on commit 62eb3b4

Please sign in to comment.