Migrated ike_dpd to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2011-10-03 22:37:44 +02:00
parent c73694e7fb
commit 6dab816eb2
+25 -30
View File
@@ -31,44 +31,33 @@ struct private_ike_dpd_t {
ike_dpd_t public; ike_dpd_t public;
}; };
/** METHOD(task_t, return_need_more, status_t,
* Implementation of task_t.build for initiator private_ike_dpd_t *this, message_t *message)
* Implementation of task_t.process for responder
*/
static status_t return_need_more(private_ike_dpd_t *this, message_t *message)
{ {
return NEED_MORE; return NEED_MORE;
} }
/** METHOD(task_t, return_success, status_t,
* Implementation of task_t.process for initiator private_ike_dpd_t *this, message_t *message)
* Implementation of task_t.build for responder
*/
static status_t return_success(private_ike_dpd_t *this, message_t *message)
{ {
return SUCCESS; return SUCCESS;
} }
/** METHOD(task_t, get_type, task_type_t,
* Implementation of task_t.get_type private_ike_dpd_t *this)
*/
static task_type_t get_type(private_ike_dpd_t *this)
{ {
return IKE_DPD; return IKE_DPD;
} }
/**
* Implementation of task_t.migrate METHOD(task_t, migrate, void,
*/ private_ike_dpd_t *this, ike_sa_t *ike_sa)
static void migrate(private_ike_dpd_t *this, ike_sa_t *ike_sa)
{ {
} }
/** METHOD(task_t, destroy, void,
* Implementation of task_t.destroy private_ike_dpd_t *this)
*/
static void destroy(private_ike_dpd_t *this)
{ {
free(this); free(this);
} }
@@ -78,21 +67,27 @@ static void destroy(private_ike_dpd_t *this)
*/ */
ike_dpd_t *ike_dpd_create(bool initiator) ike_dpd_t *ike_dpd_create(bool initiator)
{ {
private_ike_dpd_t *this = malloc_thing(private_ike_dpd_t); private_ike_dpd_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,
.migrate = _migrate,
.destroy = _destroy,
},
},
);
if (initiator) if (initiator)
{ {
this->public.task.build = (status_t(*)(task_t*,message_t*))return_need_more; this->public.task.build = _return_need_more;
this->public.task.process = (status_t(*)(task_t*,message_t*))return_success; this->public.task.process = _return_success;
} }
else else
{ {
this->public.task.build = (status_t(*)(task_t*,message_t*))return_success; this->public.task.build = _return_success;
this->public.task.process = (status_t(*)(task_t*,message_t*))return_need_more; this->public.task.process = _return_need_more;
} }
return &this->public; return &this->public;