IKEv1 XAuth: Added new "swap_initiator" method to the standard task_t interface....
authorClavister OpenSource <opensource@clavister.com>
Thu, 24 Nov 2011 15:35:22 +0000 (16:35 +0100)
committerClavister OpenSource <opensource@clavister.com>
Tue, 20 Mar 2012 16:30:52 +0000 (17:30 +0100)
src/libcharon/sa/tasks/task.h
src/libcharon/sa/tasks/xauth_request.c

index ad41bae..eebfb7a 100644 (file)
@@ -151,6 +151,11 @@ struct task_t {
         * Destroys a task_t object.
         */
        void (*destroy) (task_t *this);
+
+       /**
+        * Swaps the initiator flag in a task (if applicable, NULL OK)
+        */
+       void (*swap_initiator) (task_t *this);
 };
 
 #endif /** TASK_H_ @}*/
index 09ddb90..0a35889 100644 (file)
@@ -221,6 +221,23 @@ METHOD(task_t, destroy, void,
        free(this);
 }
 
+METHOD(task_t, swap_initiator, void,
+       private_xauth_request_t *this)
+{
+       if(this->initiator)
+       {
+               this->public.task.build = _build_r;
+               this->public.task.process = _process_r;
+               this->initiator = FALSE;
+       }
+       else
+       {
+               this->public.task.build = _build_i;
+               this->public.task.process = _process_i;
+               this->initiator = TRUE;
+       }
+}
+
 /*
  * Described in header.
  */
@@ -234,6 +251,7 @@ xauth_request_t *xauth_request_create(ike_sa_t *ike_sa, bool initiator)
                                .get_type = _get_type,
                                .migrate = _migrate,
                                .destroy = _destroy,
+                               .swap_initiator = _swap_initiator,
                        },
                },
                .initiator = initiator,