Queue Mode Config tasks when required
authorMartin Willi <martin@revosec.ch>
Fri, 9 Dec 2011 15:19:37 +0000 (16:19 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:31:16 +0000 (17:31 +0100)
src/libcharon/sa/task_manager_v1.c
src/libcharon/sa/tasks/main_mode.c

index 7fda51e..e899b06 100755 (executable)
@@ -23,6 +23,7 @@
 #include <sa/tasks/main_mode.h>
 #include <sa/tasks/quick_mode.h>
 #include <sa/tasks/xauth.h>
+#include <sa/tasks/mode_config.h>
 #include <sa/tasks/ike_delete.h>
 #include <sa/tasks/ike_natd_v1.h>
 #include <sa/tasks/ike_vendor_v1.h>
@@ -287,6 +288,12 @@ METHOD(task_manager_t, initiate, status_t,
                                }
                                break;
                        case IKE_ESTABLISHED:
+                               if (activate_task(this, TASK_MODE_CONFIG))
+                               {
+                                       exchange = TRANSACTION;
+                                       new_mid = TRUE;
+                                       break;
+                               }
                                if (activate_task(this, TASK_QUICK_MODE))
                                {
                                        exchange = QUICK_MODE;
@@ -400,15 +407,11 @@ METHOD(task_manager_t, initiate, status_t,
        {
                return retransmit(this, this->initiating.seqnr);
        }
-       else
-       {
-               charon->sender->send(charon->sender,
-                                       this->initiating.packet->clone(this->initiating.packet));
-
-               this->initiating.packet->destroy(this->initiating.packet);
-               this->initiating.packet = NULL;
-               return SUCCESS;
-       }
+       charon->sender->send(charon->sender,
+                               this->initiating.packet->clone(this->initiating.packet));
+       this->initiating.packet->destroy(this->initiating.packet);
+       this->initiating.packet = NULL;
+       return SUCCESS;
 }
 
 /**
@@ -654,7 +657,14 @@ static status_t process_request(private_task_manager_t *this,
                                enumerator->destroy(enumerator);
                                break;
                        case TRANSACTION:
-                               task = (task_t *)xauth_create(this->ike_sa, FALSE);
+                               if (this->ike_sa->get_state(this->ike_sa) == IKE_ESTABLISHED)
+                               {
+                                       task = (task_t *)mode_config_create(this->ike_sa, FALSE);
+                               }
+                               else
+                               {
+                                       task = (task_t *)xauth_create(this->ike_sa, FALSE);
+                               }
                                this->passive_tasks->insert_last(this->passive_tasks, task);
                                break;
                        default:
index d31458b..cea0631 100755 (executable)
@@ -29,6 +29,7 @@
 #include <encoding/payloads/id_payload.h>
 #include <encoding/payloads/hash_payload.h>
 #include <sa/tasks/xauth.h>
+#include <sa/tasks/mode_config.h>
 
 typedef struct private_main_mode_t private_main_mode_t;
 
@@ -824,6 +825,12 @@ METHOD(task_t, build_r, status_t,
                                return FAILED;
                        }
 
+                       if (this->peer_cfg->get_virtual_ip(this->peer_cfg))
+                       {
+                               this->ike_sa->queue_task(this->ike_sa,
+                                                       (task_t*)mode_config_create(this->ike_sa, TRUE));
+                       }
+
                        switch (this->auth_method)
                        {
                                case AUTH_XAUTH_INIT_PSK: