fixed set_message_id() on IKE_SA

added missing bus->message() hook invocation
whitespace cleanups
This commit is contained in:
Martin Willi
2008-11-24 13:59:30 +00:00
parent b09ca74720
commit f1f09810fb
2 changed files with 132 additions and 129 deletions
+2 -2
View File
@@ -416,11 +416,11 @@ static void set_message_id(private_ike_sa_t *this, bool initiate, u_int32_t mid)
{
if (initiate)
{
this->task_manager->reset(this->task_manager, UINT_MAX, mid);
this->task_manager->reset(this->task_manager, mid, UINT_MAX);
}
else
{
this->task_manager->reset(this->task_manager, mid, UINT_MAX);
this->task_manager->reset(this->task_manager, UINT_MAX, mid);
}
}
+105 -102
View File
@@ -421,39 +421,42 @@ static status_t build_request(private_task_manager_t *this)
iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
while (iterator->iterate(iterator, (void*)&task))
{
switch (task->build(task, message))
{
case SUCCESS:
/* task completed, remove it */
iterator->remove(iterator);
task->destroy(task);
break;
case NEED_MORE:
/* processed, but task needs another exchange */
break;
case FAILED:
default:
/* critical failure, destroy IKE_SA */
iterator->destroy(iterator);
switch (task->build(task, message))
{
case SUCCESS:
/* task completed, remove it */
iterator->remove(iterator);
task->destroy(task);
break;
case NEED_MORE:
/* processed, but task needs another exchange */
break;
case FAILED:
default:
/* critical failure, destroy IKE_SA */
iterator->destroy(iterator);
message->destroy(message);
flush(this);
return DESTROY_ME;
}
return DESTROY_ME;
}
}
iterator->destroy(iterator);
DESTROY_IF(this->initiating.packet);
status = this->ike_sa->generate_message(this->ike_sa, message,
&this->initiating.packet);
message->destroy(message);
if (status != SUCCESS)
{
/* message generation failed. There is nothing more to do than to
/* message generation failed. There is nothing more to do than to
* close the SA */
message->destroy(message);
flush(this);
return DESTROY_ME;
return DESTROY_ME;
}
charon->bus->message(charon->bus, message, FALSE);
message->destroy(message);
return retransmit(this, this->initiating.mid);
}
@@ -479,26 +482,26 @@ static status_t process_response(private_task_manager_t *this,
iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
while (iterator->iterate(iterator, (void*)&task))
{
switch (task->process(task, message))
{
case SUCCESS:
/* task completed, remove it */
iterator->remove(iterator);
task->destroy(task);
break;
case NEED_MORE:
/* processed, but task needs another exchange */
break;
case FAILED:
default:
/* critical failure, destroy IKE_SA */
iterator->destroy(iterator);
return DESTROY_ME;
}
if (this->reset)
{ /* start all over again if we were reset */
this->reset = FALSE;
iterator->destroy(iterator);
switch (task->process(task, message))
{
case SUCCESS:
/* task completed, remove it */
iterator->remove(iterator);
task->destroy(task);
break;
case NEED_MORE:
/* processed, but task needs another exchange */
break;
case FAILED:
default:
/* critical failure, destroy IKE_SA */
iterator->destroy(iterator);
return DESTROY_ME;
}
if (this->reset)
{ /* start all over again if we were reset */
this->reset = FALSE;
iterator->destroy(iterator);
return build_request(this);
}
}
@@ -525,34 +528,34 @@ static void handle_collisions(private_task_manager_t *this, task_t *task)
if (type == IKE_REKEY || type == CHILD_REKEY ||
type == CHILD_DELETE || type == IKE_DELETE || type == IKE_REAUTH)
{
/* find an exchange collision, and notify these tasks */
iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
while (iterator->iterate(iterator, (void**)&active))
{
switch (active->get_type(active))
{
case IKE_REKEY:
if (type == IKE_REKEY || type == IKE_DELETE ||
type == IKE_REAUTH)
{
ike_rekey_t *rekey = (ike_rekey_t*)active;
rekey->collide(rekey, task);
break;
}
continue;
case CHILD_REKEY:
if (type == CHILD_REKEY || type == CHILD_DELETE)
{
child_rekey_t *rekey = (child_rekey_t*)active;
rekey->collide(rekey, task);
break;
}
continue;
default:
continue;
}
iterator->destroy(iterator);
return;
/* find an exchange collision, and notify these tasks */
iterator = this->active_tasks->create_iterator(this->active_tasks, TRUE);
while (iterator->iterate(iterator, (void**)&active))
{
switch (active->get_type(active))
{
case IKE_REKEY:
if (type == IKE_REKEY || type == IKE_DELETE ||
type == IKE_REAUTH)
{
ike_rekey_t *rekey = (ike_rekey_t*)active;
rekey->collide(rekey, task);
break;
}
continue;
case CHILD_REKEY:
if (type == CHILD_REKEY || type == CHILD_DELETE)
{
child_rekey_t *rekey = (child_rekey_t*)active;
rekey->collide(rekey, task);
break;
}
continue;
default:
continue;
}
iterator->destroy(iterator);
return;
}
iterator->destroy(iterator);
}
@@ -586,25 +589,25 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
iterator = this->passive_tasks->create_iterator(this->passive_tasks, TRUE);
while (iterator->iterate(iterator, (void*)&task))
{
switch (task->build(task, message))
{
case SUCCESS:
/* task completed, remove it */
iterator->remove(iterator);
switch (task->build(task, message))
{
case SUCCESS:
/* task completed, remove it */
iterator->remove(iterator);
handle_collisions(this, task);
case NEED_MORE:
/* processed, but task needs another exchange */
break;
case FAILED:
default:
/* destroy IKE_SA, but SEND response first */
delete = TRUE;
break;
}
if (delete)
{
break;
}
case NEED_MORE:
/* processed, but task needs another exchange */
break;
case FAILED:
default:
/* destroy IKE_SA, but SEND response first */
delete = TRUE;
break;
}
if (delete)
{
break;
}
}
iterator->destroy(iterator);
@@ -623,7 +626,7 @@ static status_t build_response(private_task_manager_t *this, message_t *request)
message->destroy(message);
if (status != SUCCESS)
{
return DESTROY_ME;
return DESTROY_ME;
}
charon->sender->send(charon->sender,
@@ -806,22 +809,22 @@ static status_t process_request(private_task_manager_t *this,
iterator = this->passive_tasks->create_iterator(this->passive_tasks, TRUE);
while (iterator->iterate(iterator, (void*)&task))
{
switch (task->process(task, message))
{
case SUCCESS:
/* task completed, remove it */
iterator->remove(iterator);
task->destroy(task);
break;
case NEED_MORE:
/* processed, but task needs at least another call to build() */
break;
case FAILED:
default:
/* critical failure, destroy IKE_SA */
iterator->destroy(iterator);
return DESTROY_ME;
}
switch (task->process(task, message))
{
case SUCCESS:
/* task completed, remove it */
iterator->remove(iterator);
task->destroy(task);
break;
case NEED_MORE:
/* processed, but task needs at least another call to build() */
break;
case FAILED:
default:
/* critical failure, destroy IKE_SA */
iterator->destroy(iterator);
return DESTROY_ME;
}
}
iterator->destroy(iterator);