handling of CHILD_SA rekeying collisions

This commit is contained in:
Martin Willi
2007-03-21 09:25:36 +00:00
parent 403f8fd300
commit 195ada0b4b
6 changed files with 175 additions and 47 deletions
+51 -2
View File
@@ -433,6 +433,56 @@ static status_t process_response(private_task_manager_t *this,
return build_request(this);
}
/**
* handle exchange collisions
*/
static void handle_collisions(private_task_manager_t *this, task_t *task)
{
iterator_t *iterator;
task_t *active;
task_type_t type;
type = task->get_type(task);
/* check if we have initiated rekeying ourself */
if (this->initiating.type != CREATE_CHILD_SA ||
(type != IKE_REKEY && type != CHILD_REKEY && type != CHILD_DELETE))
{
task->destroy(task);
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)
{
//ike_rekey_t *rekey = (ike_rekey_t*)active;
//rekey->collide(rekey, (ike_rekey_t*)task);
break;
}
continue;
case CHILD_REKEY:
/* TODO: check if it is the SAME child we are talking about! */
if (type == CHILD_REKEY || type == CHILD_DELETE)
{
child_rekey_t *rekey = (child_rekey_t*)active;
rekey->collide(rekey, task);
break;
}
continue;
default:
continue;
}
break;
}
iterator->destroy(iterator);
}
/**
* build a response depending on the "passive" task list
*/
@@ -458,8 +508,7 @@ static status_t build_response(private_task_manager_t *this,
case SUCCESS:
/* task completed, remove it */
iterator->remove(iterator);
task->destroy(task);
break;
handle_collisions(this, task);
case NEED_MORE:
/* processed, but task needs another exchange */
break;