diff options
author | Clavister OpenSource <opensource@clavister.com> | 2011-11-24 16:35:22 +0100 |
---|---|---|
committer | Clavister OpenSource <opensource@clavister.com> | 2012-03-20 17:30:52 +0100 |
commit | 46897273d76c9f1cfa4fa6f2184adb5e84f01836 (patch) | |
tree | 73c0d93fac195685552f04a17514e44663e8ab57 | |
parent | cc50df9e6c951318955df7d95786c7dbe79d9489 (diff) | |
download | strongswan-46897273d76c9f1cfa4fa6f2184adb5e84f01836.tar.bz2 strongswan-46897273d76c9f1cfa4fa6f2184adb5e84f01836.tar.xz |
IKEv1 XAuth: Added new "swap_initiator" method to the standard task_t interface. This is needed for when we move a task from the passive queue to the active one. I'm not a huge fan of this method of doing things. Perhaps we should change task_t to have build_i, build_r, process_i, and process_r methods, and call the appropriate one from the task manager, since we have these methods for most tasks anyways.
-rw-r--r-- | src/libcharon/sa/tasks/task.h | 5 | ||||
-rw-r--r-- | src/libcharon/sa/tasks/xauth_request.c | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/libcharon/sa/tasks/task.h b/src/libcharon/sa/tasks/task.h index ad41bae7f..eebfb7a57 100644 --- a/src/libcharon/sa/tasks/task.h +++ b/src/libcharon/sa/tasks/task.h @@ -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_ @}*/ diff --git a/src/libcharon/sa/tasks/xauth_request.c b/src/libcharon/sa/tasks/xauth_request.c index 09ddb90f4..0a35889e1 100644 --- a/src/libcharon/sa/tasks/xauth_request.c +++ b/src/libcharon/sa/tasks/xauth_request.c @@ -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, |