make write_new_config a callback
authorDavid Woodhouse <David.Woodhouse@intel.com>
Sun, 5 Oct 2008 13:54:23 +0000 (14:54 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Sun, 5 Oct 2008 13:54:23 +0000 (14:54 +0100)
http.c
main.c
nm-auth-dialog.c
openconnect.h

diff --git a/http.c b/http.c
index a8be4c1..b49f2d5 100644 (file)
--- 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 (file)
--- 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;
 }
-
index 66443aa..4e5e92f 100644 (file)
@@ -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();
 
index f7b4489..e605fab 100644 (file)
@@ -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);