Cancel active quick mode task when receiving INFORMATIONAL error
authorMartin Willi <martin@revosec.ch>
Mon, 21 May 2012 12:48:48 +0000 (14:48 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 21 May 2012 12:57:33 +0000 (14:57 +0200)
src/libcharon/sa/ikev1/tasks/informational.c

index 266d47f..8228d01 100644 (file)
@@ -49,6 +49,27 @@ struct private_informational_t {
        task_t *del;
 };
 
+/**
+ * Cancel active quick mode after receiving an error
+ */
+static void cancel_quick_mode(private_informational_t *this)
+{
+       enumerator_t *enumerator;
+       task_t *task;
+
+       enumerator = this->ike_sa->create_task_enumerator(this->ike_sa,
+                                                                                                         TASK_QUEUE_ACTIVE);
+       while (enumerator->enumerate(enumerator, &task))
+       {
+               if (task->get_type(task) == TASK_QUICK_MODE)
+               {
+                       this->ike_sa->flush_queue(this->ike_sa, TASK_QUEUE_ACTIVE);
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+}
+
 METHOD(task_t, build_i, status_t,
        private_informational_t *this, message_t *message)
 {
@@ -114,6 +135,15 @@ METHOD(task_t, process_r, status_t,
                                        {       /* only critical during main mode */
                                                status = FAILED;
                                        }
+                                       switch (type)
+                                       {
+                                               case INVALID_ID_INFORMATION:
+                                               case NO_PROPOSAL_CHOSEN:
+                                                       cancel_quick_mode(this);
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
                                        break;
                                }
                                else