Added an IKEv1 main mode task stub

This commit is contained in:
Martin Willi 2011-11-16 14:44:06 +00:00
parent 4a09d9ee7f
commit c73c832c5a
5 changed files with 191 additions and 24 deletions

View File

@ -86,6 +86,7 @@ sa/tasks/ike_rekey.c sa/tasks/ike_rekey.h \
sa/tasks/ike_reauth.c sa/tasks/ike_reauth.h \
sa/tasks/ike_auth_lifetime.c sa/tasks/ike_auth_lifetime.h \
sa/tasks/ike_vendor.c sa/tasks/ike_vendor.h \
sa/tasks/main_mode.c sa/tasks/main_mode.h \
sa/tasks/task.c sa/tasks/task.h
daemon.lo : $(top_builddir)/config.status

View File

@ -16,30 +16,8 @@
#include "task_manager_v1.h"
#include <math.h>
#include <daemon.h>
#include <sa/tasks/ike_init.h>
#include <sa/tasks/ike_natd.h>
#include <sa/tasks/ike_mobike.h>
#include <sa/tasks/ike_auth.h>
#include <sa/tasks/ike_auth_lifetime.h>
#include <sa/tasks/ike_cert_pre.h>
#include <sa/tasks/ike_cert_post.h>
#include <sa/tasks/ike_rekey.h>
#include <sa/tasks/ike_delete.h>
#include <sa/tasks/ike_config.h>
#include <sa/tasks/ike_dpd.h>
#include <sa/tasks/ike_vendor.h>
#include <sa/tasks/child_create.h>
#include <sa/tasks/child_rekey.h>
#include <sa/tasks/child_delete.h>
#include <encoding/payloads/delete_payload.h>
#include <processing/jobs/retransmit_job.h>
#ifdef ME
#include <sa/tasks/ike_me.h>
#endif
#include <sa/tasks/main_mode.h>
typedef struct exchange_t exchange_t;
@ -285,7 +263,8 @@ static status_t process_request(private_task_manager_t *this,
switch (message->get_exchange_type(message))
{
case ID_PROT:
/* TODO-IKEv1: handle mainmode */
task = (task_t *)main_mode_create(this->ike_sa, FALSE);
this->passive_tasks->insert_last(this->passive_tasks, task);
break;
case AGGRESSIVE:
/* TODO-IKEv1: agressive mode */

View File

@ -0,0 +1,136 @@
/*
* Copyright (C) 2011 Martin Willi
* Copyright (C) 2011 revosec AG
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "main_mode.h"
#include <string.h>
#include <daemon.h>
#include <crypto/diffie_hellman.h>
#include <encoding/payloads/sa_payload.h>
#include <encoding/payloads/ke_payload.h>
#include <encoding/payloads/nonce_payload.h>
typedef struct private_main_mode_t private_main_mode_t;
/**
* Private members of a main_mode_t task.
*/
struct private_main_mode_t {
/**
* Public methods and task_t interface.
*/
main_mode_t public;
/**
* Assigned IKE_SA.
*/
ike_sa_t *ike_sa;
/**
* Are we the initiator?
*/
bool initiator;
/**
* IKE config to establish
*/
ike_cfg_t *config;
};
METHOD(task_t, build_i, status_t,
private_main_mode_t *this, message_t *message)
{
/* TODO-IKEv1: initiate mainmode */
return FAILED;
}
METHOD(task_t, process_r, status_t,
private_main_mode_t *this, message_t *message)
{
this->config = this->ike_sa->get_ike_cfg(this->ike_sa);
DBG0(DBG_IKE, "%H is initiating a Main Mode", message->get_source(message));
this->ike_sa->set_state(this->ike_sa, IKE_CONNECTING);
/* TODO-IKEv1: process mainmode request */
return NEED_MORE;
}
METHOD(task_t, build_r, status_t,
private_main_mode_t *this, message_t *message)
{
/* TODO-IKEv1: build mainmode response */
return FAILED;
}
METHOD(task_t, process_i, status_t,
private_main_mode_t *this, message_t *message)
{
/* TODO-IKEv1: process main mode as initiator */
return FAILED;
}
METHOD(task_t, get_type, task_type_t,
private_main_mode_t *this)
{
return MAIN_MODE;
}
METHOD(task_t, migrate, void,
private_main_mode_t *this, ike_sa_t *ike_sa)
{
this->ike_sa = ike_sa;
}
METHOD(task_t, destroy, void,
private_main_mode_t *this)
{
free(this);
}
/*
* Described in header.
*/
main_mode_t *main_mode_create(ike_sa_t *ike_sa, bool initiator)
{
private_main_mode_t *this;
INIT(this,
.public = {
.task = {
.get_type = _get_type,
.migrate = _migrate,
.destroy = _destroy,
},
},
.ike_sa = ike_sa,
.initiator = initiator,
);
if (initiator)
{
this->public.task.build = _build_i;
this->public.task.process = _process_i;
}
else
{
this->public.task.build = _build_r;
this->public.task.process = _process_r;
}
return &this->public;
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (C) 2011 Martin Willi
* Copyright (C) 2011 revosec AG
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/**
* @defgroup main_mode main_mode
* @{ @ingroup tasks
*/
#ifndef MAIN_MODE_H_
#define MAIN_MODE_H_
typedef struct main_mode_t main_mode_t;
#include <library.h>
#include <sa/ike_sa.h>
#include <sa/tasks/task.h>
/**
* IKEv1 main mode, establishes a mainmode including authentication.
*/
struct main_mode_t {
/**
* Implements the task_t interface
*/
task_t task;
};
/**
* Create a new main_mode task.
*
* @param initiator TRUE if task initiated locally
* @return task to handle by the task_manager
*/
main_mode_t *main_mode_create(ike_sa_t *ike_sa, bool initiator);
#endif /** MAIN_MODE_H_ @}*/

View File

@ -69,6 +69,8 @@ enum task_type_t {
CHILD_DELETE,
/** rekey an CHILD_SA */
CHILD_REKEY,
/** IKEv1 main mode */
MAIN_MODE,
};
/**