Migrated child_rekey to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2011-10-04 07:10:46 +02:00
parent ad8f42e898
commit 0fc9dd1194
+35 -49
View File
@@ -128,10 +128,8 @@ static void find_child(private_child_rekey_t *this, message_t *message)
}
}
/**
* Implementation of task_t.build for initiator
*/
static status_t build_i(private_child_rekey_t *this, message_t *message)
METHOD(task_t, build_i, status_t,
private_child_rekey_t *this, message_t *message)
{
notify_payload_t *notify;
u_int32_t reqid;
@@ -175,10 +173,8 @@ static status_t build_i(private_child_rekey_t *this, message_t *message)
return NEED_MORE;
}
/**
* Implementation of task_t.process for initiator
*/
static status_t process_r(private_child_rekey_t *this, message_t *message)
METHOD(task_t, process_r, status_t,
private_child_rekey_t *this, message_t *message)
{
/* let the CHILD_CREATE task process the message */
this->child_create->task.process(&this->child_create->task, message);
@@ -188,10 +184,8 @@ static status_t process_r(private_child_rekey_t *this, message_t *message)
return NEED_MORE;
}
/**
* Implementation of task_t.build for responder
*/
static status_t build_r(private_child_rekey_t *this, message_t *message)
METHOD(task_t, build_r, status_t,
private_child_rekey_t *this, message_t *message)
{
u_int32_t reqid;
@@ -287,10 +281,8 @@ static child_sa_t *handle_collision(private_child_rekey_t *this)
return to_delete;
}
/**
* Implementation of task_t.process for initiator
*/
static status_t process_i(private_child_rekey_t *this, message_t *message)
METHOD(task_t, process_i, status_t,
private_child_rekey_t *this, message_t *message)
{
protocol_id_t protocol;
u_int32_t spi;
@@ -367,18 +359,14 @@ static status_t process_i(private_child_rekey_t *this, message_t *message)
return NEED_MORE;
}
/**
* Implementation of task_t.get_type
*/
static task_type_t get_type(private_child_rekey_t *this)
METHOD(task_t, get_type, task_type_t,
private_child_rekey_t *this)
{
return CHILD_REKEY;
}
/**
* Implementation of child_rekey_t.collide
*/
static void collide(private_child_rekey_t *this, task_t *other)
METHOD(child_rekey_t, collide, void,
private_child_rekey_t *this, task_t *other)
{
/* the task manager only detects exchange collision, but not if
* the collision is for the same child. we check it here. */
@@ -421,10 +409,8 @@ static void collide(private_child_rekey_t *this, task_t *other)
this->collision = other;
}
/**
* Implementation of task_t.migrate
*/
static void migrate(private_child_rekey_t *this, ike_sa_t *ike_sa)
METHOD(task_t, migrate, void,
private_child_rekey_t *this, ike_sa_t *ike_sa)
{
if (this->child_create)
{
@@ -440,10 +426,8 @@ static void migrate(private_child_rekey_t *this, ike_sa_t *ike_sa)
this->collision = NULL;
}
/**
* Implementation of task_t.destroy
*/
static void destroy(private_child_rekey_t *this)
METHOD(task_t, destroy, void,
private_child_rekey_t *this)
{
if (this->child_create)
{
@@ -463,34 +447,36 @@ static void destroy(private_child_rekey_t *this)
child_rekey_t *child_rekey_create(ike_sa_t *ike_sa, protocol_id_t protocol,
u_int32_t spi)
{
private_child_rekey_t *this = malloc_thing(private_child_rekey_t);
private_child_rekey_t *this;
this->public.collide = (void (*)(child_rekey_t*,task_t*))collide;
this->public.task.get_type = (task_type_t(*)(task_t*))get_type;
this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate;
this->public.task.destroy = (void(*)(task_t*))destroy;
INIT(this,
.public = {
.task = {
.get_type = _get_type,
.migrate = _migrate,
.destroy = _destroy,
},
.collide = _collide,
},
.ike_sa = ike_sa,
.protocol = protocol,
.spi = spi,
);
if (protocol != PROTO_NONE)
{
this->public.task.build = (status_t(*)(task_t*,message_t*))build_i;
this->public.task.process = (status_t(*)(task_t*,message_t*))process_i;
this->public.task.build = _build_i;
this->public.task.process = _process_i;
this->initiator = TRUE;
this->child_create = NULL;
}
else
{
this->public.task.build = (status_t(*)(task_t*,message_t*))build_r;
this->public.task.process = (status_t(*)(task_t*,message_t*))process_r;
this->public.task.build = _build_r;
this->public.task.process = _process_r;
this->initiator = FALSE;
this->child_create = child_create_create(ike_sa, NULL, TRUE, NULL, NULL);
}
this->ike_sa = ike_sa;
this->child_sa = NULL;
this->protocol = protocol;
this->spi = spi;
this->collision = NULL;
this->child_delete = NULL;
this->other_child_destroyed = FALSE;
return &this->public;
}