IKEv1: Added basic support for INFORMATIONAL exchange types, and for NOTIFY_V1 messages in the 3rd message in quick_mode.

This commit is contained in:
Clavister OpenSource
2012-03-20 17:31:11 +01:00
parent f00ffe4dd2
commit 07abb470c6
4 changed files with 83 additions and 12 deletions
+40 -2
View File
@@ -489,6 +489,8 @@ static status_t process_request(private_task_manager_t *this,
enumerator_t *enumerator;
task_t *task = NULL;
bool send_response = FALSE;
payload_t *payload;
notify_payload_t *notify;
if (this->passive_tasks->get_count(this->passive_tasks) == 0)
{ /* create tasks depending on request type, if not already some queued */
@@ -511,8 +513,44 @@ static status_t process_request(private_task_manager_t *this,
this->passive_tasks->insert_last(this->passive_tasks, task);
break;
case INFORMATIONAL_V1:
/* TODO-IKEv1: informational */
return FAILED;
enumerator = message->create_payload_enumerator(message);
while (enumerator->enumerate(enumerator, &payload))
{
switch (payload->get_type(payload))
{
case NOTIFY_V1:
{
notify = (notify_payload_t*)payload;
switch (notify->get_notify_type(notify))
{
/* TODO-IKEv1: Add notification types here as needed */
case INITIAL_CONTACT_IKEV1:
break;
default:
if(notify->get_notify_type(notify) < 16384)
{
DBG1(DBG_IKE, "Received %N error notification.", notify_type_names, notify->get_notify_type(notify));
return FAILED;
}
break;
}
break;
}
case DELETE_V1:
{
/* TODO-IKEv1: Delete payload handling. */
break;
}
default:
break;
}
if (task)
{
break;
}
}
enumerator->destroy(enumerator);
break;
case TRANSACTION:
task = (task_t *)xauth_request_create(this->ike_sa, FALSE);
this->passive_tasks->insert_last(this->passive_tasks, task);
+29
View File
@@ -22,6 +22,7 @@
#include <encoding/payloads/sa_payload.h>
#include <encoding/payloads/nonce_payload.h>
#include <encoding/payloads/id_payload.h>
#include <encoding/payloads/payload.h>
typedef struct private_quick_mode_t private_quick_mode_t;
@@ -548,9 +549,24 @@ METHOD(task_t, build_i, status_t,
}
}
status_t process_notify(notify_payload_t *notify)
{
if(notify->get_notify_type(notify) < 16384)
{
DBG1(DBG_IKE, "Received %N error notification.", notify_type_names, notify->get_notify_type(notify));
return FAILED;
}
DBG1(DBG_IKE, "Received %N notification.", notify_type_names, notify->get_notify_type(notify));
return SUCCESS;
}
METHOD(task_t, process_r, status_t,
private_quick_mode_t *this, message_t *message)
{
enumerator_t *enumerator;
payload_t *payload;
status_t status;
switch (this->state)
{
case QM_INIT:
@@ -625,6 +641,19 @@ METHOD(task_t, process_r, status_t,
}
case QM_NEGOTIATED:
{
enumerator = message->create_payload_enumerator(message);
while(enumerator->enumerate(enumerator, &payload))
{
if(payload->get_type(payload) == NOTIFY_V1)
{
status = process_notify((notify_payload_t *)payload);
if(status != SUCCESS)
{
return status;
}
}
}
enumerator->destroy(enumerator);
if (!install(this))
{
return FAILED;