aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/encoding/payloads/endpoint_notify.c
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2011-10-03 21:30:49 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2011-10-03 21:30:49 +0200
commit6b44a99f9e0770e3432c9febe0367872250b5402 (patch)
treee98e0807b197dfb1dfc85f399031f4288915fc4c /src/libcharon/encoding/payloads/endpoint_notify.c
parent8107d9f480988fdce6d8c1ea5a6c64f1749abdf4 (diff)
downloadstrongswan-6b44a99f9e0770e3432c9febe0367872250b5402.tar.bz2
strongswan-6b44a99f9e0770e3432c9febe0367872250b5402.tar.xz
Migrated endpoint_notify to INIT/METHOD macros
Diffstat (limited to 'src/libcharon/encoding/payloads/endpoint_notify.c')
-rw-r--r--src/libcharon/encoding/payloads/endpoint_notify.c111
1 files changed, 49 insertions, 62 deletions
diff --git a/src/libcharon/encoding/payloads/endpoint_notify.c b/src/libcharon/encoding/payloads/endpoint_notify.c
index faec1ea71..37164780b 100644
--- a/src/libcharon/encoding/payloads/endpoint_notify.c
+++ b/src/libcharon/encoding/payloads/endpoint_notify.c
@@ -216,10 +216,8 @@ static chunk_t build_notification_data(private_endpoint_notify_t *this)
return data;
}
-/**
- * Implementation of endpoint_notify_t.build_notify
- */
-static notify_payload_t *build_notify(private_endpoint_notify_t *this)
+METHOD(endpoint_notify_t, build_notify, notify_payload_t*,
+ private_endpoint_notify_t *this)
{
chunk_t data;
notify_payload_t *notify;
@@ -233,64 +231,53 @@ static notify_payload_t *build_notify(private_endpoint_notify_t *this)
return notify;
}
-/**
- * Implementation of endpoint_notify_t.get_priority.
- */
-static u_int32_t get_priority(private_endpoint_notify_t *this)
+
+METHOD(endpoint_notify_t, get_priority, u_int32_t,
+ private_endpoint_notify_t *this)
{
return this->priority;
}
-/**
- * Implementation of endpoint_notify_t.set_priority.
- */
-static void set_priority(private_endpoint_notify_t *this, u_int32_t priority)
+METHOD(endpoint_notify_t, set_priority, void,
+ private_endpoint_notify_t *this, u_int32_t priority)
{
this->priority = priority;
}
-/**
- * Implementation of endpoint_notify_t.get_type.
- */
-static me_endpoint_type_t get_type(private_endpoint_notify_t *this)
+METHOD(endpoint_notify_t, get_type, me_endpoint_type_t,
+ private_endpoint_notify_t *this)
{
return this->type;
}
-/**
- * Implementation of endpoint_notify_t.get_family.
- */
-static me_endpoint_family_t get_family(private_endpoint_notify_t *this)
+METHOD(endpoint_notify_t, get_family, me_endpoint_family_t,
+ private_endpoint_notify_t *this)
{
return this->family;
}
-/**
- * Implementation of endpoint_notify_t.get_host.
- */
-static host_t *get_host(private_endpoint_notify_t *this)
+METHOD(endpoint_notify_t, get_host, host_t*,
+ private_endpoint_notify_t *this)
{
return this->endpoint;
}
-/**
- * Implementation of endpoint_notify_t.get_base.
- */
-static host_t *get_base(private_endpoint_notify_t *this)
+METHOD(endpoint_notify_t, get_base, host_t*,
+ private_endpoint_notify_t *this)
{
return (!this->base) ? this->endpoint : this->base;
}
-/**
- * Implementation of endpoint_notify_t.clone.
- */
-static endpoint_notify_t *_clone(private_endpoint_notify_t *this)
+METHOD(endpoint_notify_t, clone_, endpoint_notify_t*,
+ private_endpoint_notify_t *this)
{
- private_endpoint_notify_t *clone = (private_endpoint_notify_t*)endpoint_notify_create();
+ private_endpoint_notify_t *clone;
+ clone = endpoint_notify_create();
clone->priority = this->priority;
clone->type = this->type;
clone->family = this->family;
+
if (this->endpoint)
{
clone->endpoint = this->endpoint->clone(this->endpoint);
@@ -304,15 +291,12 @@ static endpoint_notify_t *_clone(private_endpoint_notify_t *this)
return &clone->public;
}
-/**
- * Implementation of endpoint_notify_t.destroy.
- */
-static status_t destroy(private_endpoint_notify_t *this)
+METHOD(endpoint_notify_t, destroy, void,
+ private_endpoint_notify_t *this)
{
DESTROY_IF(this->endpoint);
DESTROY_IF(this->base);
free(this);
- return SUCCESS;
}
/*
@@ -320,27 +304,25 @@ static status_t destroy(private_endpoint_notify_t *this)
*/
endpoint_notify_t *endpoint_notify_create()
{
- private_endpoint_notify_t *this = malloc_thing(private_endpoint_notify_t);
-
- /* public functions */
- this->public.get_priority = (u_int32_t (*) (endpoint_notify_t *)) get_priority;
- this->public.set_priority = (void (*) (endpoint_notify_t *, u_int32_t)) set_priority;
- this->public.get_type = (me_endpoint_type_t (*) (endpoint_notify_t *)) get_type;
- this->public.get_family = (me_endpoint_family_t (*) (endpoint_notify_t *)) get_family;
- this->public.get_host = (host_t *(*) (endpoint_notify_t *)) get_host;
- this->public.get_base = (host_t *(*) (endpoint_notify_t *)) get_base;
- this->public.build_notify = (notify_payload_t *(*) (endpoint_notify_t *)) build_notify;
- this->public.clone = (endpoint_notify_t *(*) (endpoint_notify_t *)) _clone;
- this->public.destroy = (void (*) (endpoint_notify_t *)) destroy;
-
- /* set default values of the fields */
- this->priority = 0;
- this->family = NO_FAMILY;
- this->type = NO_TYPE;
- this->endpoint = NULL;
- this->base = NULL;
-
- return &this->public;
+ private_endpoint_notify_t *this;
+
+ INIT(this,
+ .public = {
+ .get_priority = _get_priority,
+ .set_priority = _set_priority,
+ .get_type = _get_type,
+ .get_family = _get_family,
+ .get_host = _get_host,
+ .get_base = _get_base,
+ .build_notify = _build_notify,
+ .clone = _clone_,
+ .destroy = _destroy,
+ },
+ .family = NO_FAMILY,
+ .type = NO_TYPE,
+ );
+
+ return this;
}
/**
@@ -348,8 +330,9 @@ endpoint_notify_t *endpoint_notify_create()
*/
endpoint_notify_t *endpoint_notify_create_from_host(me_endpoint_type_t type, host_t *host, host_t *base)
{
- private_endpoint_notify_t *this = (private_endpoint_notify_t*)endpoint_notify_create();
+ private_endpoint_notify_t *this;
+ this = endpoint_notify_create();
this->type = type;
switch(type)
@@ -406,13 +389,17 @@ endpoint_notify_t *endpoint_notify_create_from_host(me_endpoint_type_t type, hos
*/
endpoint_notify_t *endpoint_notify_create_from_payload(notify_payload_t *notify)
{
+ private_endpoint_notify_t *this;
+ chunk_t data;
+
if (notify->get_notify_type(notify) != ME_ENDPOINT)
{
return NULL;
}
- private_endpoint_notify_t *this = (private_endpoint_notify_t*)endpoint_notify_create();
- chunk_t data = notify->get_notification_data(notify);
+ this = endpoint_notify_create();
+ data = notify->get_notification_data(notify);
+
if (parse_notification_data(this, data) != SUCCESS)
{
destroy(this);