Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
make write_new_config a callback
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Oct 5, 2008
1 parent ce8f2b5 commit 08cda70
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions http.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions main.c
Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;

Expand All @@ -254,4 +257,3 @@ int write_new_config(struct openconnect_info *vpninfo, char *buf, int buflen)
write(config_fd, buf, buflen);
return 0;
}

3 changes: 2 additions & 1 deletion nm-auth-dialog.c
Expand Up @@ -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];
Expand Down Expand Up @@ -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();

Expand Down
3 changes: 2 additions & 1 deletion openconnect.h
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 08cda70

Please sign in to comment.