Moved IKE_SA delete task creation to protocol specific task manager
authorMartin Willi <martin@revosec.ch>
Mon, 19 Dec 2011 13:29:57 +0000 (14:29 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:31:27 +0000 (17:31 +0100)
src/libcharon/sa/ike_sa.c
src/libcharon/sa/ikev1/task_manager_v1.c
src/libcharon/sa/ikev2/task_manager_v2.c
src/libcharon/sa/task_manager.h

index d3465ac..4747030 100644 (file)
@@ -1302,21 +1302,11 @@ METHOD(ike_sa_t, destroy_child_sa, status_t,
 METHOD(ike_sa_t, delete_, status_t,
        private_ike_sa_t *this)
 {
-       task_t *task;
-
        switch (this->state)
        {
                case IKE_ESTABLISHED:
                case IKE_REKEYING:
-                       if (this->version == IKEV1)
-                       {
-                               task = (task_t*)isakmp_delete_create(&this->public, TRUE);
-                       }
-                       else
-                       {
-                               task = (task_t*)ike_delete_create(&this->public, TRUE);
-                       }
-                       this->task_manager->queue_task(this->task_manager, task);
+                       this->task_manager->queue_ike_delete(this->task_manager);
                        return this->task_manager->initiate(this->task_manager);
                case IKE_CREATED:
                        DBG1(DBG_IKE, "deleting unestablished IKE_SA");
index 82c5c31..012890a 100644 (file)
@@ -29,6 +29,7 @@
 #include <sa/ikev1/tasks/isakmp_vendor.h>
 #include <sa/ikev1/tasks/isakmp_cert_pre.h>
 #include <sa/ikev1/tasks/isakmp_cert_post.h>
+#include <sa/ikev1/tasks/isakmp_delete.h>
 #include <processing/jobs/retransmit_job.h>
 #include <processing/jobs/delete_ike_sa_job.h>
 
@@ -1022,6 +1023,12 @@ METHOD(task_manager_t, queue_ike, void,
        queue_task(this, (task_t*)isakmp_natd_create(this->ike_sa, TRUE));
 }
 
+METHOD(task_manager_t, queue_ike_delete, void,
+       private_task_manager_t *this)
+{
+       queue_task(this, (task_t*)isakmp_delete_create(this->ike_sa, TRUE));
+}
+
 METHOD(task_manager_t, queue_child, void,
        private_task_manager_t *this, child_cfg_t *cfg, u_int32_t reqid,
        traffic_selector_t *tsi, traffic_selector_t *tsr)
@@ -1125,6 +1132,7 @@ task_manager_v1_t *task_manager_v1_create(ike_sa_t *ike_sa)
                                .process_message = _process_message,
                                .queue_task = _queue_task,
                                .queue_ike = _queue_ike,
+                               .queue_ike_delete = _queue_ike_delete,
                                .queue_child = _queue_child,
                                .queue_child_rekey = _queue_child_rekey,
                                .queue_child_delete = _queue_child_delete,
index ee2d536..5aa96cc 100644 (file)
@@ -1200,6 +1200,12 @@ METHOD(task_manager_t, queue_ike, void,
 #endif /* ME */
 }
 
+METHOD(task_manager_t, queue_ike_delete, void,
+       private_task_manager_t *this)
+{
+       queue_task(this, (task_t*)ike_delete_create(this->ike_sa, TRUE));
+}
+
 METHOD(task_manager_t, queue_child, void,
        private_task_manager_t *this, child_cfg_t *cfg, u_int32_t reqid,
        traffic_selector_t *tsi, traffic_selector_t *tsr)
@@ -1351,6 +1357,7 @@ task_manager_v2_t *task_manager_v2_create(ike_sa_t *ike_sa)
                                .process_message = _process_message,
                                .queue_task = _queue_task,
                                .queue_ike = _queue_ike,
+                               .queue_ike_delete = _queue_ike_delete,
                                .queue_child = _queue_child,
                                .queue_child_rekey = _queue_child_rekey,
                                .queue_child_delete = _queue_child_delete,
index cfec427..eeccb1a 100644 (file)
@@ -130,6 +130,11 @@ struct task_manager_t {
        void (*queue_ike)(task_manager_t *this);
 
        /**
+        * Queue IKE_SA delete tasks.
+        */
+       void (*queue_ike_delete)(task_manager_t *this);
+
+       /**
         * Queue CHILD_SA establishing tasks.
         *
         * @param cfg                   CHILD_SA config to establish