Migrated endpoint_notify to INIT/METHOD macros
This commit is contained in:
@@ -216,10 +216,8 @@ static chunk_t build_notification_data(private_endpoint_notify_t *this)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(endpoint_notify_t, build_notify, notify_payload_t*,
|
||||||
* Implementation of endpoint_notify_t.build_notify
|
private_endpoint_notify_t *this)
|
||||||
*/
|
|
||||||
static notify_payload_t *build_notify(private_endpoint_notify_t *this)
|
|
||||||
{
|
{
|
||||||
chunk_t data;
|
chunk_t data;
|
||||||
notify_payload_t *notify;
|
notify_payload_t *notify;
|
||||||
@@ -233,64 +231,53 @@ static notify_payload_t *build_notify(private_endpoint_notify_t *this)
|
|||||||
return notify;
|
return notify;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of endpoint_notify_t.get_priority.
|
METHOD(endpoint_notify_t, get_priority, u_int32_t,
|
||||||
*/
|
private_endpoint_notify_t *this)
|
||||||
static u_int32_t get_priority(private_endpoint_notify_t *this)
|
|
||||||
{
|
{
|
||||||
return this->priority;
|
return this->priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(endpoint_notify_t, set_priority, void,
|
||||||
* Implementation of endpoint_notify_t.set_priority.
|
private_endpoint_notify_t *this, u_int32_t priority)
|
||||||
*/
|
|
||||||
static void set_priority(private_endpoint_notify_t *this, u_int32_t priority)
|
|
||||||
{
|
{
|
||||||
this->priority = priority;
|
this->priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(endpoint_notify_t, get_type, me_endpoint_type_t,
|
||||||
* Implementation of endpoint_notify_t.get_type.
|
private_endpoint_notify_t *this)
|
||||||
*/
|
|
||||||
static me_endpoint_type_t get_type(private_endpoint_notify_t *this)
|
|
||||||
{
|
{
|
||||||
return this->type;
|
return this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(endpoint_notify_t, get_family, me_endpoint_family_t,
|
||||||
* Implementation of endpoint_notify_t.get_family.
|
private_endpoint_notify_t *this)
|
||||||
*/
|
|
||||||
static me_endpoint_family_t get_family(private_endpoint_notify_t *this)
|
|
||||||
{
|
{
|
||||||
return this->family;
|
return this->family;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(endpoint_notify_t, get_host, host_t*,
|
||||||
* Implementation of endpoint_notify_t.get_host.
|
private_endpoint_notify_t *this)
|
||||||
*/
|
|
||||||
static host_t *get_host(private_endpoint_notify_t *this)
|
|
||||||
{
|
{
|
||||||
return this->endpoint;
|
return this->endpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(endpoint_notify_t, get_base, host_t*,
|
||||||
* Implementation of endpoint_notify_t.get_base.
|
private_endpoint_notify_t *this)
|
||||||
*/
|
|
||||||
static host_t *get_base(private_endpoint_notify_t *this)
|
|
||||||
{
|
{
|
||||||
return (!this->base) ? this->endpoint : this->base;
|
return (!this->base) ? this->endpoint : this->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(endpoint_notify_t, clone_, endpoint_notify_t*,
|
||||||
* Implementation of endpoint_notify_t.clone.
|
private_endpoint_notify_t *this)
|
||||||
*/
|
|
||||||
static endpoint_notify_t *_clone(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->priority = this->priority;
|
||||||
clone->type = this->type;
|
clone->type = this->type;
|
||||||
clone->family = this->family;
|
clone->family = this->family;
|
||||||
|
|
||||||
if (this->endpoint)
|
if (this->endpoint)
|
||||||
{
|
{
|
||||||
clone->endpoint = this->endpoint->clone(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;
|
return &clone->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(endpoint_notify_t, destroy, void,
|
||||||
* Implementation of endpoint_notify_t.destroy.
|
private_endpoint_notify_t *this)
|
||||||
*/
|
|
||||||
static status_t destroy(private_endpoint_notify_t *this)
|
|
||||||
{
|
{
|
||||||
DESTROY_IF(this->endpoint);
|
DESTROY_IF(this->endpoint);
|
||||||
DESTROY_IF(this->base);
|
DESTROY_IF(this->base);
|
||||||
free(this);
|
free(this);
|
||||||
return SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -320,27 +304,25 @@ static status_t destroy(private_endpoint_notify_t *this)
|
|||||||
*/
|
*/
|
||||||
endpoint_notify_t *endpoint_notify_create()
|
endpoint_notify_t *endpoint_notify_create()
|
||||||
{
|
{
|
||||||
private_endpoint_notify_t *this = malloc_thing(private_endpoint_notify_t);
|
private_endpoint_notify_t *this;
|
||||||
|
|
||||||
/* public functions */
|
INIT(this,
|
||||||
this->public.get_priority = (u_int32_t (*) (endpoint_notify_t *)) get_priority;
|
.public = {
|
||||||
this->public.set_priority = (void (*) (endpoint_notify_t *, u_int32_t)) set_priority;
|
.get_priority = _get_priority,
|
||||||
this->public.get_type = (me_endpoint_type_t (*) (endpoint_notify_t *)) get_type;
|
.set_priority = _set_priority,
|
||||||
this->public.get_family = (me_endpoint_family_t (*) (endpoint_notify_t *)) get_family;
|
.get_type = _get_type,
|
||||||
this->public.get_host = (host_t *(*) (endpoint_notify_t *)) get_host;
|
.get_family = _get_family,
|
||||||
this->public.get_base = (host_t *(*) (endpoint_notify_t *)) get_base;
|
.get_host = _get_host,
|
||||||
this->public.build_notify = (notify_payload_t *(*) (endpoint_notify_t *)) build_notify;
|
.get_base = _get_base,
|
||||||
this->public.clone = (endpoint_notify_t *(*) (endpoint_notify_t *)) _clone;
|
.build_notify = _build_notify,
|
||||||
this->public.destroy = (void (*) (endpoint_notify_t *)) destroy;
|
.clone = _clone_,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.family = NO_FAMILY,
|
||||||
|
.type = NO_TYPE,
|
||||||
|
);
|
||||||
|
|
||||||
/* set default values of the fields */
|
return this;
|
||||||
this->priority = 0;
|
|
||||||
this->family = NO_FAMILY;
|
|
||||||
this->type = NO_TYPE;
|
|
||||||
this->endpoint = NULL;
|
|
||||||
this->base = NULL;
|
|
||||||
|
|
||||||
return &this->public;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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)
|
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;
|
this->type = type;
|
||||||
|
|
||||||
switch(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)
|
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)
|
if (notify->get_notify_type(notify) != ME_ENDPOINT)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private_endpoint_notify_t *this = (private_endpoint_notify_t*)endpoint_notify_create();
|
this = endpoint_notify_create();
|
||||||
chunk_t data = notify->get_notification_data(notify);
|
data = notify->get_notification_data(notify);
|
||||||
|
|
||||||
if (parse_notification_data(this, data) != SUCCESS)
|
if (parse_notification_data(this, data) != SUCCESS)
|
||||||
{
|
{
|
||||||
destroy(this);
|
destroy(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user