Migrated ike_delete to INIT/METHOD macros
authorAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 3 Oct 2011 21:49:44 +0000 (23:49 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 3 Oct 2011 21:49:44 +0000 (23:49 +0200)
src/libcharon/sa/tasks/ike_delete.c

index 1309488..8f253ce 100644 (file)
@@ -52,10 +52,8 @@ struct private_ike_delete_t {
        bool simultaneous;
 };
 
        bool simultaneous;
 };
 
-/**
- * Implementation of task_t.build for initiator
- */
-static status_t build_i(private_ike_delete_t *this, message_t *message)
+METHOD(task_t, build_i, status_t,
+       private_ike_delete_t *this, message_t *message)
 {
        delete_payload_t *delete_payload;
 
 {
        delete_payload_t *delete_payload;
 
@@ -83,10 +81,8 @@ static status_t build_i(private_ike_delete_t *this, message_t *message)
        return NEED_MORE;
 }
 
        return NEED_MORE;
 }
 
-/**
- * Implementation of task_t.process for initiator
- */
-static status_t process_i(private_ike_delete_t *this, message_t *message)
+METHOD(task_t, process_i, status_t,
+       private_ike_delete_t *this, message_t *message)
 {
        DBG0(DBG_IKE, "IKE_SA deleted");
        if (!this->rekeyed)
 {
        DBG0(DBG_IKE, "IKE_SA deleted");
        if (!this->rekeyed)
@@ -97,10 +93,8 @@ static status_t process_i(private_ike_delete_t *this, message_t *message)
        return DESTROY_ME;
 }
 
        return DESTROY_ME;
 }
 
-/**
- * Implementation of task_t.process for responder
- */
-static status_t process_r(private_ike_delete_t *this, message_t *message)
+METHOD(task_t, process_r, status_t,
+       private_ike_delete_t *this, message_t *message)
 {
        /* we don't even scan the payloads, as the message wouldn't have
         * come so far without being correct */
 {
        /* we don't even scan the payloads, as the message wouldn't have
         * come so far without being correct */
@@ -134,10 +128,8 @@ static status_t process_r(private_ike_delete_t *this, message_t *message)
        return NEED_MORE;
 }
 
        return NEED_MORE;
 }
 
-/**
- * Implementation of task_t.build for responder
- */
-static status_t build_r(private_ike_delete_t *this, message_t *message)
+METHOD(task_t, build_r, status_t,
+       private_ike_delete_t *this, message_t *message)
 {
        DBG0(DBG_IKE, "IKE_SA deleted");
 
 {
        DBG0(DBG_IKE, "IKE_SA deleted");
 
@@ -154,27 +146,21 @@ static status_t build_r(private_ike_delete_t *this, message_t *message)
        return DESTROY_ME;
 }
 
        return DESTROY_ME;
 }
 
-/**
- * Implementation of task_t.get_type
- */
-static task_type_t get_type(private_ike_delete_t *this)
+METHOD(task_t, get_type, task_type_t,
+       private_ike_delete_t *this)
 {
        return IKE_DELETE;
 }
 
 {
        return IKE_DELETE;
 }
 
-/**
- * Implementation of task_t.migrate
- */
-static void migrate(private_ike_delete_t *this, ike_sa_t *ike_sa)
+METHOD(task_t, migrate, void,
+       private_ike_delete_t *this, ike_sa_t *ike_sa)
 {
        this->ike_sa = ike_sa;
        this->simultaneous = FALSE;
 }
 
 {
        this->ike_sa = ike_sa;
        this->simultaneous = FALSE;
 }
 
-/**
- * Implementation of task_t.destroy
- */
-static void destroy(private_ike_delete_t *this)
+METHOD(task_t, destroy, void,
+       private_ike_delete_t *this)
 {
        free(this);
 }
 {
        free(this);
 }
@@ -184,27 +170,30 @@ static void destroy(private_ike_delete_t *this)
  */
 ike_delete_t *ike_delete_create(ike_sa_t *ike_sa, bool initiator)
 {
  */
 ike_delete_t *ike_delete_create(ike_sa_t *ike_sa, bool initiator)
 {
-       private_ike_delete_t *this = malloc_thing(private_ike_delete_t);
-
-       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;
+       private_ike_delete_t *this;
+
+       INIT(this,
+               .public = {
+                       .task = {
+                               .get_type = _get_type,
+                               .migrate = _migrate,
+                               .destroy = _destroy,
+                       },
+               },
+               .ike_sa = ike_sa,
+               .initiator = initiator,
+       );
 
        if (initiator)
        {
 
        if (initiator)
        {
-               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;
        }
        else
        {
        }
        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->ike_sa = ike_sa;
-       this->initiator = initiator;
-       this->rekeyed = FALSE;
-       this->simultaneous = FALSE;
-
        return &this->public;
 }
        return &this->public;
 }