Skip to content

Commit

Permalink
Add openconnect_set_cancel_fd() to library
Browse files Browse the repository at this point in the history
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed May 12, 2012
1 parent 328a953 commit 8eafe0b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Expand Up @@ -21,7 +21,7 @@ library_srcs = ssl.c http.c auth.c library.c compat.c
libopenconnect_la_SOURCES = version.c $(library_srcs)
libopenconnect_la_CFLAGS = $(OPENSSL_CFLAGS) $(LIBXML2_CFLAGS) $(LIBPROXY_CFLAGS)
libopenconnect_la_LIBADD = $(OPENSSL_LIBS) $(LIBXML2_LIBS) $(LIBPROXY_LIBS) $(LIBINTL)
libopenconnect_la_LDFLAGS = -version-number 1:2
libopenconnect_la_LDFLAGS = -version-number 1:4
noinst_HEADERS = openconnect-internal.h openconnect.h
include_HEADERS = openconnect.h

Expand Down
5 changes: 5 additions & 0 deletions library.c
Expand Up @@ -204,6 +204,11 @@ void openconnect_set_cert_expiry_warning (struct openconnect_info *vpninfo,
vpninfo->cert_expire_warning = seconds;
}

void openconnect_set_cancel_fd (struct openconnect_info *vpninfo, int fd)
{
vpninfo->cancel_fd = fd;
}

const char *openconnect_get_version (void)
{
return openconnect_version;
Expand Down
17 changes: 16 additions & 1 deletion openconnect.h
Expand Up @@ -31,9 +31,12 @@
#include <unistd.h>

#define OPENCONNECT_API_VERSION_MAJOR 1
#define OPENCONNECT_API_VERSION_MINOR 3
#define OPENCONNECT_API_VERSION_MINOR 4

/*
* API version 1.4:
* - Add openconnect_set_cancel_fd()
*
* API version 1.3:
* - Add openconnect_set_cert_expiry_warning() to change from default 60 days
*
Expand Down Expand Up @@ -138,6 +141,18 @@ void openconnect_reset_ssl (struct openconnect_info *vpninfo);
int openconnect_parse_url (struct openconnect_info *vpninfo, char *url);
void openconnect_set_cert_expiry_warning (struct openconnect_info *vpninfo,
int seconds);

/* If this is set, then openconnect_obtain_cookie() will abort and return
failure if the file descriptor is readable. Typically a user may create
a pair of pipes with the pipe(2) system call, hand the readable one to
this function, and then write a byte to the other end if it ever wants
to cancel the connection. This way, a multi-threaded UI (which will be
running openconnect_obtain_cookie() in a separate thread since it blocks)
has the ability to cancel that call, reap its thread and free the
vpninfo structure (or retry). An 'fd' argument of -1 will render the
cancellation mechanism inactive. */
void openconnect_set_cancel_fd (struct openconnect_info *vpninfo, int fd);

const char *openconnect_get_version(void);

/* The first (privdata) argument to each of these functions is either
Expand Down

0 comments on commit 8eafe0b

Please sign in to comment.