Implemented resetting of IKEv1 task manager, enabling additional keyingtries
authorMartin Willi <martin@revosec.ch>
Tue, 20 Dec 2011 17:02:01 +0000 (18:02 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:31:29 +0000 (17:31 +0100)
src/libcharon/sa/ike_sa.c
src/libcharon/sa/ikev1/task_manager_v1.c

index 5916116..78ffbe5 100644 (file)
@@ -1488,7 +1488,7 @@ METHOD(ike_sa_t, retransmit, status_t,
                {
                        case IKE_CONNECTING:
                        {
-                               /* retry IKE_SA_INIT if we have multiple keyingtries */
+                               /* retry IKE_SA_INIT/Main Mode if we have multiple keyingtries */
                                u_int32_t tries = this->peer_cfg->get_keyingtries(this->peer_cfg);
                                this->keyingtry++;
                                if (tries == 0 || tries > this->keyingtry)
index dfc9608..37c3f76 100644 (file)
@@ -1103,6 +1103,34 @@ METHOD(task_manager_t, incr_mid, void,
 METHOD(task_manager_t, reset, void,
        private_task_manager_t *this, u_int32_t initiate, u_int32_t respond)
 {
+       enumerator_t *enumerator;
+       task_t *task;
+
+       /* reset message counters and retransmit packets */
+       DESTROY_IF(this->responding.packet);
+       DESTROY_IF(this->initiating.packet);
+       this->responding.packet = NULL;
+       this->initiating.packet = NULL;
+       this->initiating.mid = 0;
+       this->initiating.seqnr = 0;
+       this->initiating.retransmitted = 0;
+       this->initiating.type = EXCHANGE_TYPE_UNDEFINED;
+
+       /* reset queued tasks */
+       enumerator = this->queued_tasks->create_enumerator(this->queued_tasks);
+       while (enumerator->enumerate(enumerator, &task))
+       {
+               task->migrate(task, this->ike_sa);
+       }
+       enumerator->destroy(enumerator);
+
+       /* reset active tasks */
+       while (this->active_tasks->remove_last(this->active_tasks,
+                                                                                  (void**)&task) == SUCCESS)
+       {
+               task->migrate(task, this->ike_sa);
+               this->queued_tasks->insert_first(this->queued_tasks, task);
+       }
 }
 
 METHOD(task_manager_t, create_task_enumerator, enumerator_t*,