Migrated ike_config to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2011-10-03 23:55:15 +02:00
parent 2e89c3413b
commit 1bf77c8168
+31 -41
View File
@@ -230,10 +230,8 @@ static void process_payloads(private_ike_config_t *this, message_t *message)
enumerator->destroy(enumerator); enumerator->destroy(enumerator);
} }
/** METHOD(task_t, build_i, status_t,
* Implementation of task_t.process for initiator private_ike_config_t *this, message_t *message)
*/
static status_t build_i(private_ike_config_t *this, message_t *message)
{ {
if (message->get_message_id(message) == 1) if (message->get_message_id(message) == 1)
{ /* in first IKE_AUTH only */ { /* in first IKE_AUTH only */
@@ -292,10 +290,8 @@ static status_t build_i(private_ike_config_t *this, message_t *message)
return NEED_MORE; return NEED_MORE;
} }
/** METHOD(task_t, process_r, status_t,
* Implementation of task_t.process for responder private_ike_config_t *this, message_t *message)
*/
static status_t process_r(private_ike_config_t *this, message_t *message)
{ {
if (message->get_message_id(message) == 1) if (message->get_message_id(message) == 1)
{ /* in first IKE_AUTH only */ { /* in first IKE_AUTH only */
@@ -304,10 +300,8 @@ static status_t process_r(private_ike_config_t *this, message_t *message)
return NEED_MORE; return NEED_MORE;
} }
/** METHOD(task_t, build_r, status_t,
* Implementation of task_t.build for responder private_ike_config_t *this, message_t *message)
*/
static status_t build_r(private_ike_config_t *this, message_t *message)
{ {
if (this->ike_sa->get_state(this->ike_sa) == IKE_ESTABLISHED) if (this->ike_sa->get_state(this->ike_sa) == IKE_ESTABLISHED)
{ /* in last IKE_AUTH exchange */ { /* in last IKE_AUTH exchange */
@@ -371,10 +365,8 @@ static status_t build_r(private_ike_config_t *this, message_t *message)
return NEED_MORE; return NEED_MORE;
} }
/** METHOD(task_t, process_i, status_t,
* Implementation of task_t.process for initiator private_ike_config_t *this, message_t *message)
*/
static status_t process_i(private_ike_config_t *this, message_t *message)
{ {
if (this->ike_sa->get_state(this->ike_sa) == IKE_ESTABLISHED) if (this->ike_sa->get_state(this->ike_sa) == IKE_ESTABLISHED)
{ /* in last IKE_AUTH exchange */ { /* in last IKE_AUTH exchange */
@@ -390,18 +382,14 @@ static status_t process_i(private_ike_config_t *this, message_t *message)
return NEED_MORE; return NEED_MORE;
} }
/** METHOD(task_t, get_type, task_type_t,
* Implementation of task_t.get_type private_ike_config_t *this)
*/
static task_type_t get_type(private_ike_config_t *this)
{ {
return IKE_CONFIG; return IKE_CONFIG;
} }
/** METHOD(task_t, migrate, void,
* Implementation of task_t.migrate private_ike_config_t *this, ike_sa_t *ike_sa)
*/
static void migrate(private_ike_config_t *this, ike_sa_t *ike_sa)
{ {
DESTROY_IF(this->virtual_ip); DESTROY_IF(this->virtual_ip);
@@ -411,10 +399,8 @@ static void migrate(private_ike_config_t *this, ike_sa_t *ike_sa)
this->requested = linked_list_create(); this->requested = linked_list_create();
} }
/** METHOD(task_t, destroy, void,
* Implementation of task_t.destroy private_ike_config_t *this)
*/
static void destroy(private_ike_config_t *this)
{ {
DESTROY_IF(this->virtual_ip); DESTROY_IF(this->virtual_ip);
this->requested->destroy_function(this->requested, free); this->requested->destroy_function(this->requested, free);
@@ -426,26 +412,30 @@ static void destroy(private_ike_config_t *this)
*/ */
ike_config_t *ike_config_create(ike_sa_t *ike_sa, bool initiator) ike_config_t *ike_config_create(ike_sa_t *ike_sa, bool initiator)
{ {
private_ike_config_t *this = malloc_thing(private_ike_config_t); private_ike_config_t *this;
this->public.task.get_type = (task_type_t(*)(task_t*))get_type; INIT(this,
this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate; .public = {
this->public.task.destroy = (void(*)(task_t*))destroy; .task = {
.get_type = _get_type,
this->initiator = initiator; .migrate = _migrate,
this->ike_sa = ike_sa; .destroy = _destroy,
this->virtual_ip = NULL; },
this->requested = linked_list_create(); },
.initiator = initiator,
.ike_sa = ike_sa,
.requested = linked_list_create(),
);
if (initiator) if (initiator)
{ {
this->public.task.build = (status_t(*)(task_t*,message_t*))build_i; this->public.task.build = _build_i;
this->public.task.process = (status_t(*)(task_t*,message_t*))process_i; this->public.task.process = _process_i;
} }
else else
{ {
this->public.task.build = (status_t(*)(task_t*,message_t*))build_r; this->public.task.build = _build_r;
this->public.task.process = (status_t(*)(task_t*,message_t*))process_r; this->public.task.process = _process_r;
} }
return &this->public; return &this->public;