Moved CHILD_SA delete task creation to protocol specific task manager
authorMartin Willi <martin@revosec.ch>
Mon, 19 Dec 2011 13:25:14 +0000 (14:25 +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 7026608..d3465ac 100644 (file)
@@ -1272,17 +1272,7 @@ METHOD(ike_sa_t, rekey_child_sa, status_t,
 METHOD(ike_sa_t, delete_child_sa, status_t,
        private_ike_sa_t *this, protocol_id_t protocol, u_int32_t spi)
 {
-       task_t *task;
-
-       if (this->version == IKEV1)
-       {
-               task = (task_t*)quick_delete_create(&this->public, protocol, spi, FALSE);
-       }
-       else
-       {
-               task = (task_t*)child_delete_create(&this->public, protocol, spi);
-       }
-       this->task_manager->queue_task(this->task_manager, task);
+       this->task_manager->queue_child_delete(this->task_manager, protocol, spi);
        return this->task_manager->initiate(this->task_manager);
 }
 
index a4509e6..82c5c31 100644 (file)
@@ -21,6 +21,7 @@
 #include <daemon.h>
 #include <sa/ikev1/tasks/main_mode.h>
 #include <sa/ikev1/tasks/quick_mode.h>
+#include <sa/ikev1/tasks/quick_delete.h>
 #include <sa/ikev1/tasks/xauth.h>
 #include <sa/ikev1/tasks/mode_config.h>
 #include <sa/ikev1/tasks/informational.h>
@@ -1034,6 +1035,13 @@ METHOD(task_manager_t, queue_child_rekey, void,
        /* TODO-IKEv1: CHILD rekeying */
 }
 
+METHOD(task_manager_t, queue_child_delete, void,
+       private_task_manager_t *this, protocol_id_t protocol, u_int32_t spi)
+{
+       queue_task(this, (task_t*)quick_delete_create(this->ike_sa, protocol,
+                                                                                                 spi, FALSE));
+}
+
 METHOD(task_manager_t, queue_dpd, void,
        private_task_manager_t *this)
 {
@@ -1119,6 +1127,7 @@ task_manager_v1_t *task_manager_v1_create(ike_sa_t *ike_sa)
                                .queue_ike = _queue_ike,
                                .queue_child = _queue_child,
                                .queue_child_rekey = _queue_child_rekey,
+                               .queue_child_delete = _queue_child_delete,
                                .queue_dpd = _queue_dpd,
                                .initiate = _initiate,
                                .retransmit = _retransmit,
index d8dc9b8..ee2d536 100644 (file)
@@ -1220,6 +1220,12 @@ METHOD(task_manager_t, queue_child_rekey, void,
        queue_task(this, (task_t*)child_rekey_create(this->ike_sa, protocol, spi));
 }
 
+METHOD(task_manager_t, queue_child_delete, void,
+       private_task_manager_t *this, protocol_id_t protocol, u_int32_t spi)
+{
+       queue_task(this, (task_t*)child_delete_create(this->ike_sa, protocol, spi));
+}
+
 METHOD(task_manager_t, queue_dpd, void,
        private_task_manager_t *this)
 {
@@ -1347,6 +1353,7 @@ task_manager_v2_t *task_manager_v2_create(ike_sa_t *ike_sa)
                                .queue_ike = _queue_ike,
                                .queue_child = _queue_child,
                                .queue_child_rekey = _queue_child_rekey,
+                               .queue_child_delete = _queue_child_delete,
                                .queue_dpd = _queue_dpd,
                                .initiate = _initiate,
                                .retransmit = _retransmit,
index e2e797c..cfec427 100644 (file)
@@ -150,6 +150,15 @@ struct task_manager_t {
                                                          u_int32_t spi);
 
        /**
+        * Queue CHILD_SA delete tasks.
+        *
+        * @param protocol              CHILD_SA protocol, AH|ESP
+        * @param spi                   CHILD_SA SPI to rekey
+        */
+       void (*queue_child_delete)(task_manager_t *this, protocol_id_t protocol,
+                                                          u_int32_t spi);
+
+       /**
         * Queue liveness checking tasks.
         */
        void (*queue_dpd)(task_manager_t *this);