daemon: Flush shunts before unloading plugins
[strongswan.git] / src / libstrongswan / fetcher / fetcher_manager.c
index 7e49be4..f36cfcf 100644 (file)
@@ -15,9 +15,9 @@
 
 #include "fetcher_manager.h"
 
-#include <debug.h>
+#include <utils/debug.h>
 #include <threading/rwlock.h>
-#include <utils/linked_list.h>
+#include <collections/linked_list.h>
 
 typedef struct private_fetcher_manager_t private_fetcher_manager_t;
 
@@ -43,7 +43,7 @@ struct private_fetcher_manager_t {
 };
 
 typedef struct {
-       /** assocaited fetcher construction function */
+       /** associated fetcher construction function */
        fetcher_constructor_t create;
        /** URL this fetcher support */
        char *url;
@@ -59,7 +59,7 @@ static void entry_destroy(entry_t *entry)
 }
 
 METHOD(fetcher_manager_t, fetch, status_t,
-       private_fetcher_manager_t *this, char *url, chunk_t *response, ...)
+       private_fetcher_manager_t *this, char *url, void *userdata, ...)
 {
        enumerator_t *enumerator;
        status_t status = NOT_SUPPORTED;
@@ -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 */
@@ -86,24 +87,42 @@ METHOD(fetcher_manager_t, fetch, status_t,
                {
                        continue;
                }
-               va_start(args, response);
+               va_start(args, userdata);
                while (good)
                {
                        opt = va_arg(args, int);
                        switch (opt)
                        {
                                case FETCH_REQUEST_DATA:
-                                       good = fetcher->set_option(fetcher, opt, va_arg(args, chunk_t));
+                                       good = fetcher->set_option(fetcher, opt,
+                                                                                       va_arg(args, chunk_t));
                                        continue;
                                case FETCH_REQUEST_TYPE:
                                case FETCH_REQUEST_HEADER:
-                                       good = fetcher->set_option(fetcher, opt, va_arg(args, char*));
+                                       good = fetcher->set_option(fetcher, opt,
+                                                                                       va_arg(args, char*));
                                        continue;
                                case FETCH_HTTP_VERSION_1_0:
                                        good = fetcher->set_option(fetcher, opt);
                                        continue;
                                case FETCH_TIMEOUT:
-                                       good = fetcher->set_option(fetcher, opt, va_arg(args, u_int));
+                                       good = fetcher->set_option(fetcher, opt,
+                                                                                       va_arg(args, u_int));
+                                       continue;
+                               case FETCH_CALLBACK:
+                                       good = fetcher->set_option(fetcher, opt,
+                                                                                       va_arg(args, fetcher_callback_t));
+                                       continue;
+                               case FETCH_RESPONSE_CODE:
+                                       good = fetcher->set_option(fetcher, opt,
+                                                                                       va_arg(args, u_int*));
+                                       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;
@@ -117,7 +136,7 @@ METHOD(fetcher_manager_t, fetch, status_t,
                        continue;
                }
 
-               status = fetcher->fetch(fetcher, url, response);
+               status = fetcher->fetch(fetcher, url, userdata);
                fetcher->destroy(fetcher);
                /* try another fetcher only if this one does not support that URL */
                if (status == NOT_SUPPORTED)
@@ -198,4 +217,3 @@ fetcher_manager_t *fetcher_manager_create()
 
        return &this->public;
 }
-