Moved MOBIKE task creation to protocol specific task manager
authorMartin Willi <martin@revosec.ch>
Mon, 19 Dec 2011 14:04:28 +0000 (15:04 +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 43e61ef..83d072c 100644 (file)
@@ -1621,8 +1621,6 @@ static bool is_any_path_valid(private_ike_sa_t *this)
 METHOD(ike_sa_t, roam, status_t,
        private_ike_sa_t *this, bool address)
 {
-       ike_mobike_t *mobike;
-
        switch (this->state)
        {
                case IKE_CREATED:
@@ -1644,10 +1642,7 @@ METHOD(ike_sa_t, roam, status_t,
                if (supports_extension(this, EXT_MOBIKE) && address)
                {       /* if any addresses changed, send an updated list */
                        DBG1(DBG_IKE, "sending address list update using MOBIKE");
-                       mobike = ike_mobike_create(&this->public, TRUE);
-                       mobike->addresses(mobike);
-                       this->task_manager->queue_task(this->task_manager,
-                                                                                  (task_t*)mobike);
+                       this->task_manager->queue_mobike(this->task_manager, FALSE, TRUE);
                        return this->task_manager->initiate(this->task_manager);
                }
                return SUCCESS;
@@ -1675,9 +1670,7 @@ METHOD(ike_sa_t, roam, status_t,
                {
                        DBG1(DBG_IKE, "requesting address change using MOBIKE");
                }
-               mobike = ike_mobike_create(&this->public, TRUE);
-               mobike->roam(mobike, address);
-               this->task_manager->queue_task(this->task_manager, (task_t*)mobike);
+               this->task_manager->queue_mobike(this->task_manager, TRUE, address);
                return this->task_manager->initiate(this->task_manager);
        }
 
index d23b237..dfc9608 100644 (file)
@@ -1041,6 +1041,12 @@ METHOD(task_manager_t, queue_ike_delete, void,
        queue_task(this, (task_t*)isakmp_delete_create(this->ike_sa, TRUE));
 }
 
+METHOD(task_manager_t, queue_mobike, void,
+       private_task_manager_t *this, bool roam, bool address)
+{
+       /* Not supported in IKEv1 */
+}
+
 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)
@@ -1147,6 +1153,7 @@ task_manager_v1_t *task_manager_v1_create(ike_sa_t *ike_sa)
                                .queue_ike_rekey = _queue_ike_rekey,
                                .queue_ike_reauth = _queue_ike_reauth,
                                .queue_ike_delete = _queue_ike_delete,
+                               .queue_mobike = _queue_mobike,
                                .queue_child = _queue_child,
                                .queue_child_rekey = _queue_child_rekey,
                                .queue_child_delete = _queue_child_delete,
index 91589b1..fe57669 100644 (file)
@@ -1248,6 +1248,23 @@ METHOD(task_manager_t, queue_ike_delete, void,
        queue_task(this, (task_t*)ike_delete_create(this->ike_sa, TRUE));
 }
 
+METHOD(task_manager_t, queue_mobike, void,
+       private_task_manager_t *this, bool roam, bool address)
+{
+       ike_mobike_t *mobike;
+
+       mobike = ike_mobike_create(this->ike_sa, TRUE);
+       if (roam)
+       {
+               mobike->roam(mobike, address);
+       }
+       else
+       {
+               mobike->addresses(mobike);
+       }
+       queue_task(this, &mobike->task);
+}
+
 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)
@@ -1293,7 +1310,6 @@ METHOD(task_manager_t, queue_dpd, void,
        }
 }
 
-
 METHOD(task_manager_t, adopt_tasks, void,
        private_task_manager_t *this, task_manager_t *other_public)
 {
@@ -1402,6 +1418,7 @@ task_manager_v2_t *task_manager_v2_create(ike_sa_t *ike_sa)
                                .queue_ike_rekey = _queue_ike_rekey,
                                .queue_ike_reauth = _queue_ike_reauth,
                                .queue_ike_delete = _queue_ike_delete,
+                               .queue_mobike = _queue_mobike,
                                .queue_child = _queue_child,
                                .queue_child_rekey = _queue_child_rekey,
                                .queue_child_delete = _queue_child_delete,
index 4087265..5602069 100644 (file)
@@ -140,6 +140,14 @@ struct task_manager_t {
        void (*queue_ike_reauth)(task_manager_t *this);
 
        /**
+        * Queue MOBIKE task
+        *
+        * @param roam                  TRUE to switch to new address
+        * @param address               TRUE to include address list update
+        */
+       void (*queue_mobike)(task_manager_t *this, bool roam, bool address);
+
+       /**
         * Queue IKE_SA delete tasks.
         */
        void (*queue_ike_delete)(task_manager_t *this);