From 08cda7048b66eef94c118582b549e8e3f962fd50 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sun, 5 Oct 2008 14:54:23 +0100 Subject: [PATCH] make write_new_config a callback --- http.c | 5 ++--- main.c | 6 ++++-- nm-auth-dialog.c | 3 ++- openconnect.h | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/http.c b/http.c index a8be4c1..b49f2d5 100644 --- a/http.c +++ b/http.c @@ -596,7 +596,7 @@ static int fetch_config(struct openconnect_info *vpninfo, char *fu, char *bu, return -EINVAL; } - return write_new_config(vpninfo, buf, buflen); + return vpninfo->write_new_config(vpninfo, buf, buflen); } int openconnect_obtain_cookie(struct openconnect_info *vpninfo) @@ -719,8 +719,7 @@ int openconnect_obtain_cookie(struct openconnect_info *vpninfo) if (!strcmp(opt->option, "webvpn")) vpninfo->cookie = opt->value; - else if (vpninfo->xmlsha1[0] && - !strcmp(opt->option, "webvpnc")) { + else if (vpninfo->write_new_config && !strcmp(opt->option, "webvpnc")) { char *tok = opt->value; char *bu = NULL, *fu = NULL, *sha = NULL; diff --git a/main.c b/main.c index 85e5249..526c82c 100644 --- a/main.c +++ b/main.c @@ -38,6 +38,8 @@ #include "openconnect.h" +static int write_new_config(struct openconnect_info *vpninfo, char *buf, int buflen); + int verbose = 0; static struct option long_options[] = { @@ -111,6 +113,7 @@ int main(int argc, char **argv) vpninfo->mtu = 1406; vpninfo->deflate = 1; vpninfo->dtls_attempt_period = 60; + vpninfo->write_new_config = write_new_config; if (RAND_bytes(vpninfo->dtls_secret, sizeof(vpninfo->dtls_secret)) != 1) { fprintf(stderr, "Failed to initialise DTLS secret\n"); @@ -239,7 +242,7 @@ int main(int argc, char **argv) exit(1); } -int write_new_config(struct openconnect_info *vpninfo, char *buf, int buflen) +static int write_new_config(struct openconnect_info *vpninfo, char *buf, int buflen) { int config_fd; @@ -254,4 +257,3 @@ int write_new_config(struct openconnect_info *vpninfo, char *buf, int buflen) write(config_fd, buf, buflen); return 0; } - diff --git a/nm-auth-dialog.c b/nm-auth-dialog.c index 66443aa..4e5e92f 100644 --- a/nm-auth-dialog.c +++ b/nm-auth-dialog.c @@ -172,7 +172,7 @@ static int get_config(char *vpn_uuid, struct openconnect_info *vpninfo) } lasthost = get_gconf_setting(gcl, config_path, "lasthost"); - vpninfo->xmlsha1[0] = '0'; + xmlconfig = get_gconf_setting(gcl, config_path, NM_OPENCONNECT_KEY_XMLCONFIG); if (xmlconfig) { unsigned char sha1[SHA_DIGEST_LENGTH]; @@ -365,6 +365,7 @@ int main (int argc, char **argv) vpninfo->mtu = 1406; vpninfo->useragent = openconnect_create_useragent("OpenConnect VPN Agent (NetworkManager)"); vpninfo->ssl_fd = -1; + vpninfo->write_new_config = write_new_config; set_openssl_ui(); diff --git a/openconnect.h b/openconnect.h index f7b4489..e605fab 100644 --- a/openconnect.h +++ b/openconnect.h @@ -138,6 +138,8 @@ struct openconnect_info { const char *useragent; char *quit_reason; + + int (*write_new_config) (struct openconnect_info *vpninfo, char *buf, int buflen); }; /* Packet types */ @@ -175,7 +177,6 @@ int openconnect_open_https(struct openconnect_info *vpninfo); /* main.c */ extern int verbose; -int write_new_config(struct openconnect_info *vpninfo, char *buf, int buflen); /* mainloop.c */ int vpn_add_pollfd(struct openconnect_info *vpninfo, int fd, short events); -- 2.7.4