mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-08 00:02:03 -04:00
ikev2: Allow tasks to do work after generating requests/responses
This commit is contained in:
parent
89ca791979
commit
1250917f79
@ -471,6 +471,7 @@ METHOD(task_manager_t, initiate, status_t,
|
|||||||
message_t *message;
|
message_t *message;
|
||||||
host_t *me, *other;
|
host_t *me, *other;
|
||||||
exchange_type_t exchange = 0;
|
exchange_type_t exchange = 0;
|
||||||
|
bool result;
|
||||||
|
|
||||||
if (this->initiating.type != EXCHANGE_TYPE_UNDEFINED)
|
if (this->initiating.type != EXCHANGE_TYPE_UNDEFINED)
|
||||||
{
|
{
|
||||||
@ -685,17 +686,47 @@ METHOD(task_manager_t, initiate, status_t,
|
|||||||
return initiate(this);
|
return initiate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!generate_message(this, message, &this->initiating.packets))
|
result = generate_message(this, message, &this->initiating.packets);
|
||||||
|
|
||||||
|
if (result)
|
||||||
{
|
{
|
||||||
/* message generation failed. There is nothing more to do than to
|
enumerator = array_create_enumerator(this->active_tasks);
|
||||||
* close the SA */
|
while (enumerator->enumerate(enumerator, &task))
|
||||||
message->destroy(message);
|
{
|
||||||
flush(this);
|
if (!task->post_build)
|
||||||
charon->bus->ike_updown(charon->bus, this->ike_sa, FALSE);
|
{
|
||||||
return DESTROY_ME;
|
continue;
|
||||||
|
}
|
||||||
|
switch (task->post_build(task, message))
|
||||||
|
{
|
||||||
|
case SUCCESS:
|
||||||
|
array_remove_at(this->active_tasks, enumerator);
|
||||||
|
task->destroy(task);
|
||||||
|
break;
|
||||||
|
case NEED_MORE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* critical failure, destroy IKE_SA */
|
||||||
|
result = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
enumerator->destroy(enumerator);
|
||||||
}
|
}
|
||||||
message->destroy(message);
|
message->destroy(message);
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{ /* message generation failed. There is nothing more to do than to
|
||||||
|
* close the SA */
|
||||||
|
flush(this);
|
||||||
|
if (this->ike_sa->get_state(this->ike_sa) != IKE_CONNECTING &&
|
||||||
|
this->ike_sa->get_state(this->ike_sa) != IKE_REKEYED)
|
||||||
|
{
|
||||||
|
charon->bus->ike_updown(charon->bus, this->ike_sa, FALSE);
|
||||||
|
}
|
||||||
|
return DESTROY_ME;
|
||||||
|
}
|
||||||
|
|
||||||
array_compress(this->active_tasks);
|
array_compress(this->active_tasks);
|
||||||
array_compress(this->queued_tasks);
|
array_compress(this->queued_tasks);
|
||||||
|
|
||||||
@ -946,7 +977,34 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
|
|||||||
/* message complete, send it */
|
/* message complete, send it */
|
||||||
clear_packets(this->responding.packets);
|
clear_packets(this->responding.packets);
|
||||||
result = generate_message(this, message, &this->responding.packets);
|
result = generate_message(this, message, &this->responding.packets);
|
||||||
|
|
||||||
|
if (result && !delete)
|
||||||
|
{
|
||||||
|
enumerator = array_create_enumerator(this->passive_tasks);
|
||||||
|
while (enumerator->enumerate(enumerator, &task))
|
||||||
|
{
|
||||||
|
if (!task->post_build)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch (task->post_build(task, message))
|
||||||
|
{
|
||||||
|
case SUCCESS:
|
||||||
|
array_remove_at(this->passive_tasks, enumerator);
|
||||||
|
task->destroy(task);
|
||||||
|
break;
|
||||||
|
case NEED_MORE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* critical failure, destroy IKE_SA */
|
||||||
|
result = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
enumerator->destroy(enumerator);
|
||||||
|
}
|
||||||
message->destroy(message);
|
message->destroy(message);
|
||||||
|
|
||||||
if (id)
|
if (id)
|
||||||
{
|
{
|
||||||
id->set_responder_spi(id, responder_spi);
|
id->set_responder_spi(id, responder_spi);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user