aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/plugins/resolve/resolve_handler.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2009-11-17 14:51:50 +0100
committerMartin Willi <martin@strongswan.org>2009-11-17 14:51:50 +0100
commitb5a2055fb1b88ea4abb97334d89e311c9ceaa7d4 (patch)
treeeb71f0e63c8859e6fd7d7d59559984feda61a441 /src/charon/plugins/resolve/resolve_handler.c
parente6cf06027572382cc8d326ee3ccd265ff7e522e0 (diff)
downloadstrongswan-b5a2055fb1b88ea4abb97334d89e311c9ceaa7d4.tar.bz2
strongswan-b5a2055fb1b88ea4abb97334d89e311c9ceaa7d4.tar.xz
Give plugins more control of which configuration attributes to request, and pass received attributes back to the requesting handler
Diffstat (limited to 'src/charon/plugins/resolve/resolve_handler.c')
-rw-r--r--src/charon/plugins/resolve/resolve_handler.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/charon/plugins/resolve/resolve_handler.c b/src/charon/plugins/resolve/resolve_handler.c
index 7c7d52a05..ff0e5943e 100644
--- a/src/charon/plugins/resolve/resolve_handler.c
+++ b/src/charon/plugins/resolve/resolve_handler.c
@@ -164,6 +164,59 @@ static void release(private_resolve_handler_t *this, identification_t *server,
}
/**
+ * Attribute enumerator implementation
+ */
+typedef struct {
+ /** implements enumerator_t interface */
+ enumerator_t public;
+ /** virtual IP we are requesting */
+ host_t *vip;
+} attribute_enumerator_t;
+
+/**
+ * Implementation of create_attribute_enumerator().enumerate()
+ */
+static bool attribute_enumerate(attribute_enumerator_t *this,
+ configuration_attribute_type_t *type, chunk_t *data)
+{
+ switch (this->vip->get_family(this->vip))
+ {
+ case AF_INET:
+ *type = INTERNAL_IP4_DNS;
+ break;
+ case AF_INET6:
+ *type = INTERNAL_IP6_DNS;
+ break;
+ default:
+ return FALSE;
+ }
+ *data = chunk_empty;
+ /* enumerate only once */
+ this->public.enumerate = (void*)return_false;
+ return TRUE;
+}
+
+/**
+ * Implementation of attribute_handler_t.create_attribute_enumerator
+ */
+static enumerator_t* create_attribute_enumerator(private_resolve_handler_t *this,
+ identification_t *server, host_t *vip)
+{
+ if (vip)
+ {
+ attribute_enumerator_t *enumerator;
+
+ enumerator = malloc_thing(attribute_enumerator_t);
+ enumerator->public.enumerate = (void*)attribute_enumerate;
+ enumerator->public.destroy = (void*)free;
+ enumerator->vip = vip;
+
+ return &enumerator->public;
+ }
+ return enumerator_create_empty();
+}
+
+/**
* Implementation of resolve_handler_t.destroy.
*/
static void destroy(private_resolve_handler_t *this)
@@ -181,6 +234,7 @@ resolve_handler_t *resolve_handler_create()
this->public.handler.handle = (bool(*)(attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))handle;
this->public.handler.release = (void(*)(attribute_handler_t*, identification_t*, configuration_attribute_type_t, chunk_t))release;
+ this->public.handler.create_attribute_enumerator = (enumerator_t*(*)(attribute_handler_t*, identification_t *server, host_t *vip))create_attribute_enumerator;
this->public.destroy = (void(*)(resolve_handler_t*))destroy;
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);