From: Martin Willi Date: Tue, 13 Dec 2011 11:17:35 +0000 (+0100) Subject: Queue a TRANSACTION message for later processing if Main Mode not yet completed X-Git-Tag: 5.0.0~338^2~9^2~234 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f91b6ac77ae444c92078539b5db477594a6f4a10;p=thirdparty%2Fstrongswan.git Queue a TRANSACTION message for later processing if Main Mode not yet completed --- diff --git a/src/libcharon/sa/task_manager_v1.c b/src/libcharon/sa/task_manager_v1.c index b292934bca..e507370639 100755 --- a/src/libcharon/sa/task_manager_v1.c +++ b/src/libcharon/sa/task_manager_v1.c @@ -138,6 +138,11 @@ struct private_task_manager_t { */ linked_list_t *passive_tasks; + /** + * Queued messages not yet ready to process + */ + message_t *queued; + /** * Number of times we retransmit messages before giving up */ @@ -707,6 +712,7 @@ static status_t process_response(private_task_manager_t *this, message_t *message) { enumerator_t *enumerator; + status_t status; task_t *task; if (message->get_exchange_type(message) != this->initiating.type) @@ -753,6 +759,18 @@ static status_t process_response(private_task_manager_t *this, this->initiating.packet->destroy(this->initiating.packet); this->initiating.packet = NULL; + if (this->queued && this->active_tasks->get_count(this->active_tasks) == 0) + { + status = this->public.task_manager.process_message( + &this->public.task_manager, this->queued); + this->queued->destroy(this->queued); + this->queued = NULL; + if (status == DESTROY_ME) + { + return status; + } + } + return initiate(this); } @@ -848,6 +866,23 @@ METHOD(task_manager_t, process_message, status_t, this->responding.packet->clone(this->responding.packet)); return SUCCESS; } + + if (msg->get_exchange_type(msg) == TRANSACTION && + this->active_tasks->get_count(this->active_tasks) && + !this->queued) + { /* main mode not yet complete, queue XAuth/Mode config tasks */ + this->queued = message_create_from_packet(msg->get_packet(msg)); + if (this->queued->parse_header(this->queued) != SUCCESS) + { + this->queued->destroy(this->queued); + this->queued = NULL; + return FAILED; + } + DBG1(DBG_IKE, "queueing %N request as tasks still active", + exchange_type_names, TRANSACTION); + return SUCCESS; + } + msg->set_request(msg, TRUE); status = parse_message(this, msg); if (status != SUCCESS) @@ -958,6 +993,7 @@ METHOD(task_manager_t, destroy, void, this->queued_tasks->destroy(this->queued_tasks); this->passive_tasks->destroy(this->passive_tasks); + DESTROY_IF(this->queued); DESTROY_IF(this->responding.packet); DESTROY_IF(this->initiating.packet); DESTROY_IF(this->rng);