Added a quick mode task stub

This commit is contained in:
Martin Willi 2011-11-21 11:20:34 +01:00
parent cbb6d765bc
commit 2b04aa46ea
5 changed files with 223 additions and 2 deletions

View File

@ -90,6 +90,7 @@ 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/quick_mode.c sa/tasks/quick_mode.h \
sa/tasks/task.c sa/tasks/task.h
daemon.lo : $(top_builddir)/config.status

View File

@ -0,0 +1,164 @@
/*
* 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 "quick_mode.h"
#include <string.h>
#include <daemon.h>
typedef struct private_quick_mode_t private_quick_mode_t;
/**
* Private members of a quick_mode_t task.
*/
struct private_quick_mode_t {
/**
* Public methods and task_t interface.
*/
quick_mode_t public;
/**
* Assigned IKE_SA.
*/
ike_sa_t *ike_sa;
/**
* Traffic selector of initiator
*/
traffic_selector_t *tsi;
/**
* Traffic selector of responder
*/
traffic_selector_t *tsr;
/**
* Initiators nonce
*/
chunk_t nonce_i;
/**
* Responder nonce
*/
chunk_t nonce_r;
/**
* selected CHILD_SA proposal
*/
proposal_t *proposal;
/**
* Config of CHILD_SA to establish
*/
child_cfg_t *config;
/**
* CHILD_SA we are about to establish
*/
child_sa_t *child_sa;
/** states of quick mode */
enum {
QM_INIT,
} state;
};
METHOD(task_t, build_i, status_t,
private_quick_mode_t *this, message_t *message)
{
return NEED_MORE;
}
METHOD(task_t, process_r, status_t,
private_quick_mode_t *this, message_t *message)
{
return NEED_MORE;
}
METHOD(task_t, build_r, status_t,
private_quick_mode_t *this, message_t *message)
{
return SUCCESS;
}
METHOD(task_t, process_i, status_t,
private_quick_mode_t *this, message_t *message)
{
return SUCCESS;
}
METHOD(task_t, get_type, task_type_t,
private_quick_mode_t *this)
{
return TASK_QUICK_MODE;
}
METHOD(task_t, migrate, void,
private_quick_mode_t *this, ike_sa_t *ike_sa)
{
this->ike_sa = ike_sa;
}
METHOD(task_t, destroy, void,
private_quick_mode_t *this)
{
chunk_free(&this->nonce_i);
chunk_free(&this->nonce_r);
DESTROY_IF(this->tsi);
DESTROY_IF(this->tsr);
DESTROY_IF(this->proposal);
DESTROY_IF(this->child_sa);
DESTROY_IF(this->config);
free(this);
}
/*
* Described in header.
*/
quick_mode_t *quick_mode_create(ike_sa_t *ike_sa, child_cfg_t *config,
traffic_selector_t *tsi, traffic_selector_t *tsr)
{
private_quick_mode_t *this;
INIT(this,
.public = {
.task = {
.get_type = _get_type,
.migrate = _migrate,
.destroy = _destroy,
},
},
.ike_sa = ike_sa,
.tsi = tsi ? tsi->clone(tsi) : NULL,
.tsr = tsr ? tsr->clone(tsr) : NULL,
.config = config,
.state = QM_INIT,
);
if (config)
{
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,52 @@
/*
* 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 quick_mode quick_mode
* @{ @ingroup tasks
*/
#ifndef QUICK_MODE_H_
#define QUICK_MODE_H_
typedef struct quick_mode_t quick_mode_t;
#include <library.h>
#include <sa/ike_sa.h>
#include <sa/tasks/task.h>
/**
* IKEv1 quick mode, establishes a CHILD_SA in IKEv1.
*/
struct quick_mode_t {
/**
* Implements the task_t interface
*/
task_t task;
};
/**
* Create a new quick_mode task.
*
* @param config child_cfg if task initiator, NULL if responder
* @param tsi source of triggering packet, or NULL
* @param tsr destination of triggering packet, or NULL
* @return task to handle by the task_manager
*/
quick_mode_t *quick_mode_create(ike_sa_t *ike_sa, child_cfg_t *config,
traffic_selector_t *tsi, traffic_selector_t *tsr);
#endif /** QUICK_MODE_H_ @}*/

View File

@ -17,7 +17,7 @@
#include "task.h"
#ifdef ME
ENUM(task_type_names, IKE_INIT, MAIN_MODE,
ENUM(task_type_names, IKE_INIT, TASK_QUICK_MODE,
"IKE_INIT",
"IKE_NATD",
"IKE_MOBIKE",
@ -36,9 +36,10 @@ ENUM(task_type_names, IKE_INIT, MAIN_MODE,
"CHILD_DELETE",
"CHILD_REKEY",
"MAIN_MODE",
"QUICK_MODE",
);
#else
ENUM(task_type_names, IKE_INIT, MAIN_MODE,
ENUM(task_type_names, IKE_INIT, TASK_QUICK_MODE,
"IKE_INIT",
"IKE_NATD",
"IKE_MOBIKE",
@ -56,5 +57,6 @@ ENUM(task_type_names, IKE_INIT, MAIN_MODE,
"CHILD_DELETE",
"CHILD_REKEY",
"MAIN_MODE",
"QUICK_MODE",
);
#endif /* ME */

View File

@ -71,6 +71,8 @@ enum task_type_t {
CHILD_REKEY,
/** IKEv1 main mode */
MAIN_MODE,
/** IKEv1 quick mode */
TASK_QUICK_MODE,
};
/**