aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-05-15 16:34:12 +0200
committerMartin Willi <martin@revosec.ch>2013-06-11 15:54:26 +0200
commitfe20f752f1bd1cecdc0b71a91f605f590bc6c404 (patch)
treed2f9c6af57711b9a603a8521388988b65e883aa2 /src
parent0adfffb6dd098f7f868a611b3cffc605377ffdf6 (diff)
downloadstrongswan-fe20f752f1bd1cecdc0b71a91f605f590bc6c404.tar.bz2
strongswan-fe20f752f1bd1cecdc0b71a91f605f590bc6c404.tar.xz
curl: add an option to fetch bound to a local source address
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/fetcher/fetcher.h6
-rw-r--r--src/libstrongswan/fetcher/fetcher_manager.c8
-rw-r--r--src/libstrongswan/plugins/curl/curl_fetcher.c9
3 files changed, 23 insertions, 0 deletions
diff --git a/src/libstrongswan/fetcher/fetcher.h b/src/libstrongswan/fetcher/fetcher.h
index 58451aef2..890258c3c 100644
--- a/src/libstrongswan/fetcher/fetcher.h
+++ b/src/libstrongswan/fetcher/fetcher.h
@@ -90,6 +90,12 @@ enum fetcher_option_t {
FETCH_CALLBACK,
/**
+ * Source IP address to bind for a fetch.
+ * Additional argument is a host_t*, which may be NULL.
+ */
+ FETCH_SOURCEIP,
+
+ /**
* end of fetching options
*/
FETCH_END,
diff --git a/src/libstrongswan/fetcher/fetcher_manager.c b/src/libstrongswan/fetcher/fetcher_manager.c
index 47d4f9bde..21cd1aff4 100644
--- a/src/libstrongswan/fetcher/fetcher_manager.c
+++ b/src/libstrongswan/fetcher/fetcher_manager.c
@@ -73,6 +73,7 @@ METHOD(fetcher_manager_t, fetch, status_t,
fetcher_option_t opt;
fetcher_t *fetcher;
bool good = TRUE;
+ host_t *host;
va_list args;
/* check URL support of fetcher */
@@ -112,6 +113,13 @@ METHOD(fetcher_manager_t, fetch, status_t,
good = fetcher->set_option(fetcher, opt,
va_arg(args, fetcher_callback_t));
continue;
+ case FETCH_SOURCEIP:
+ host = va_arg(args, host_t*);
+ if (host && !host->is_anyaddr(host))
+ {
+ good = fetcher->set_option(fetcher, opt, host);
+ }
+ continue;
case FETCH_END:
break;
}
diff --git a/src/libstrongswan/plugins/curl/curl_fetcher.c b/src/libstrongswan/plugins/curl/curl_fetcher.c
index b49961a90..a8cca98da 100644
--- a/src/libstrongswan/plugins/curl/curl_fetcher.c
+++ b/src/libstrongswan/plugins/curl/curl_fetcher.c
@@ -177,6 +177,15 @@ METHOD(fetcher_t, set_option, bool,
this->cb = va_arg(args, fetcher_callback_t);
break;
}
+ case FETCH_SOURCEIP:
+ {
+ char buf[64];
+
+ snprintf(buf, sizeof(buf), "%H", va_arg(args, host_t*));
+ supported = curl_easy_setopt(this->curl, CURLOPT_INTERFACE,
+ buf) == CURLE_OK;
+ break;
+ }
default:
supported = FALSE;
break;