summaryrefslogtreecommitdiff
path: root/src/libcharon/plugins/nm/nm_handler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcharon/plugins/nm/nm_handler.c')
-rw-r--r--src/libcharon/plugins/nm/nm_handler.c61
1 files changed, 27 insertions, 34 deletions
diff --git a/src/libcharon/plugins/nm/nm_handler.c b/src/libcharon/plugins/nm/nm_handler.c
index eacb54dda..408129ebe 100644
--- a/src/libcharon/plugins/nm/nm_handler.c
+++ b/src/libcharon/plugins/nm/nm_handler.c
@@ -40,11 +40,9 @@ struct private_nm_handler_t {
linked_list_t *nbns;
};
-/**
- * Implementation of attribute_handler_t.handle
- */
-static bool handle(private_nm_handler_t *this, identification_t *server,
- configuration_attribute_type_t type, chunk_t data)
+METHOD(attribute_handler_t, handle, bool,
+ private_nm_handler_t *this, identification_t *server,
+ configuration_attribute_type_t type, chunk_t data)
{
linked_list_t *list;
@@ -93,11 +91,8 @@ static bool enumerate_dns(enumerator_t *this,
return TRUE;
}
-/**
- * Implementation of attribute_handler_t.create_attribute_enumerator
- */
-static enumerator_t* create_attribute_enumerator(private_nm_handler_t *this,
- identification_t *server, host_t *vip)
+METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
+ private_nm_handler_t *this, identification_t *server, host_t *vip)
{
if (vip && vip->get_family(vip) == AF_INET)
{ /* no IPv6 attributes yet */
@@ -120,11 +115,8 @@ static bool filter_chunks(void* null, char **in, chunk_t *out)
return TRUE;
}
-/**
- * Implementation of nm_handler_t.create_enumerator
- */
-static enumerator_t* create_enumerator(private_nm_handler_t *this,
- configuration_attribute_type_t type)
+METHOD(nm_handler_t, create_enumerator, enumerator_t*,
+ private_nm_handler_t *this, configuration_attribute_type_t type)
{
linked_list_t *list;
@@ -143,10 +135,8 @@ static enumerator_t* create_enumerator(private_nm_handler_t *this,
(void*)filter_chunks, NULL, NULL);
}
-/**
- * Implementation of nm_handler_t.reset
- */
-static void reset(private_nm_handler_t *this)
+METHOD(nm_handler_t, reset, void,
+ private_nm_handler_t *this)
{
void *data;
@@ -160,10 +150,8 @@ static void reset(private_nm_handler_t *this)
}
}
-/**
- * Implementation of nm_handler_t.destroy.
- */
-static void destroy(private_nm_handler_t *this)
+METHOD(nm_handler_t, destroy, void,
+ private_nm_handler_t *this)
{
reset(this);
this->dns->destroy(this->dns);
@@ -176,17 +164,22 @@ static void destroy(private_nm_handler_t *this)
*/
nm_handler_t *nm_handler_create()
{
- private_nm_handler_t *this = malloc_thing(private_nm_handler_t);
-
- 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))nop;
- this->public.handler.create_attribute_enumerator = (enumerator_t*(*)(attribute_handler_t*, identification_t *server, host_t *vip))create_attribute_enumerator;
- this->public.create_enumerator = (enumerator_t*(*)(nm_handler_t*, configuration_attribute_type_t type))create_enumerator;
- this->public.reset = (void(*)(nm_handler_t*))reset;
- this->public.destroy = (void(*)(nm_handler_t*))destroy;
-
- this->dns = linked_list_create();
- this->nbns = linked_list_create();
+ private_nm_handler_t *this;
+
+ INIT(this,
+ .public = {
+ .handler = {
+ .handle = _handle,
+ .release = nop,
+ .create_attribute_enumerator = _create_attribute_enumerator,
+ },
+ .create_enumerator = _create_enumerator,
+ .reset = _reset,
+ .destroy = _destroy,
+ },
+ .dns = linked_list_create(),
+ .nbns = linked_list_create(),
+ );
return &this->public;
}