From c5c04993508d67ac2fdb0d95a838f10a10b2cc79 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 16 Jan 2015 09:41:18 -0800 Subject: [PATCH] Start separating protocol-specific methods from generic VPN support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It looks like we can understand the Juniper oNCP protocol and it fits fairly well with the OpenConnect model — you first authenticate and are rewarded with a cookie, and then you make the actual connection to the HTTPS server and *can* transport data over that, or ideally you have a UDP transport (in this case ESP) instead. So start factoring out the methods which are specific to the VPN protocol, with a view to making Juniper support possible too. Starting with cstp_bye(). Signed-off-by: David Woodhouse --- library.c | 2 ++ mainloop.c | 4 ++-- openconnect-internal.h | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/library.c b/library.c index 731a457b..c03f5608 100644 --- a/library.c +++ b/library.c @@ -91,6 +91,8 @@ struct openconnect_info *openconnect_vpninfo_new(const char *useragent, bindtextdomain("openconnect", LOCALEDIR); #endif + vpninfo->proto.vpn_close_session = cstp_bye; + return vpninfo; err: diff --git a/mainloop.c b/mainloop.c index 3ce2148b..6f563706 100644 --- a/mainloop.c +++ b/mainloop.c @@ -224,8 +224,8 @@ int openconnect_mainloop(struct openconnect_info *vpninfo, #endif } - if (vpninfo->quit_reason) - cstp_bye(vpninfo, vpninfo->quit_reason); + if (vpninfo->quit_reason && vpninfo->proto.vpn_close_session) + vpninfo->proto.vpn_close_session(vpninfo, vpninfo->quit_reason); os_shutdown_tun(vpninfo); return ret < 0 ? ret : -EIO; diff --git a/openconnect-internal.h b/openconnect-internal.h index 835bd6f0..c83eb2b3 100644 --- a/openconnect-internal.h +++ b/openconnect-internal.h @@ -201,7 +201,13 @@ struct proxy_auth_state { char *challenge; }; +struct vpn_proto { + int (*vpn_close_session)(struct openconnect_info *vpninfo, const char *reason); +}; + struct openconnect_info { + struct vpn_proto proto; + #ifdef HAVE_ICONV iconv_t ic_legacy_to_utf8; iconv_t ic_utf8_to_legacy;