Use task manager as generic interface, renamed implementation to _v2.

This commit is contained in:
Martin Willi 2011-11-16 13:53:54 +00:00
parent 4ac22be0ec
commit e69f7dcddf
5 changed files with 64 additions and 24 deletions

View File

@ -66,7 +66,7 @@ sa/child_sa.c sa/child_sa.h \
sa/ike_sa.c sa/ike_sa.h \
sa/ike_sa_id.c sa/ike_sa_id.h \
sa/ike_sa_manager.c sa/ike_sa_manager.h \
sa/task_manager.c sa/task_manager.h \
sa/task_manager.h sa/task_manager_v2.c sa/task_manager_v2.h \
sa/keymat.c sa/keymat.h \
sa/shunt_manager.c sa/shunt_manager.h \
sa/trap_manager.c sa/trap_manager.h \

View File

@ -28,7 +28,7 @@
#include <daemon.h>
#include <utils/linked_list.h>
#include <utils/lexparser.h>
#include <sa/task_manager.h>
#include <sa/task_manager_v2.h>
#include <sa/tasks/ike_init.h>
#include <sa/tasks/ike_natd.h>
#include <sa/tasks/ike_mobike.h>
@ -2209,7 +2209,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
.keepalive_interval = lib->settings->get_time(lib->settings,
"charon.keep_alive", KEEPALIVE_INTERVAL),
);
this->task_manager = task_manager_create(&this->public);
this->task_manager = &(task_manager_v2_create(&this->public)->task_manager);
this->my_host->set_port(this->my_host, IKEV2_UDP_PORT);
return &this->public;

View File

@ -194,11 +194,4 @@ struct task_manager_t {
void (*destroy) (task_manager_t *this);
};
/**
* Create an instance of the task manager.
*
* @param ike_sa IKE_SA to manage.
*/
task_manager_t *task_manager_create(ike_sa_t *ike_sa);
#endif /** TASK_MANAGER_H_ @}*/

View File

@ -14,7 +14,7 @@
* for more details.
*/
#include "task_manager.h"
#include "task_manager_v2.h"
#include <math.h>
@ -69,7 +69,7 @@ struct private_task_manager_t {
/**
* public functions
*/
task_manager_t public;
task_manager_v2_t public;
/**
* associated IKE_SA we are serving
@ -1106,22 +1106,24 @@ METHOD(task_manager_t, destroy, void,
/*
* see header file
*/
task_manager_t *task_manager_create(ike_sa_t *ike_sa)
task_manager_v2_t *task_manager_v2_create(ike_sa_t *ike_sa)
{
private_task_manager_t *this;
INIT(this,
.public = {
.process_message = _process_message,
.queue_task = _queue_task,
.initiate = _initiate,
.retransmit = _retransmit,
.incr_mid = _incr_mid,
.reset = _reset,
.adopt_tasks = _adopt_tasks,
.busy = _busy,
.create_task_enumerator = _create_task_enumerator,
.destroy = _destroy,
.task_manager = {
.process_message = _process_message,
.queue_task = _queue_task,
.initiate = _initiate,
.retransmit = _retransmit,
.incr_mid = _incr_mid,
.reset = _reset,
.adopt_tasks = _adopt_tasks,
.busy = _busy,
.create_task_enumerator = _create_task_enumerator,
.destroy = _destroy,
},
},
.ike_sa = ike_sa,
.initiating.type = EXCHANGE_TYPE_UNDEFINED,
@ -1138,4 +1140,3 @@ task_manager_t *task_manager_create(ike_sa_t *ike_sa)
return &this->public;
}

View File

@ -0,0 +1,46 @@
/*
* 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 task_manager_v2 task_manager_v2
* @{ @ingroup sa
*/
#ifndef TASK_MANAGER_V2_H_
#define TASK_MANAGER_V2_H_
typedef struct task_manager_v2_t task_manager_v2_t;
#include <sa/task_manager.h>
/**
* Task manager, IKEv2 variant.
*/
struct task_manager_v2_t {
/**
* Implements task_manager_t.
*/
task_manager_t task_manager;
};
/**
* Create an instance of the task manager.
*
* @param ike_sa IKE_SA to manage.
*/
task_manager_v2_t *task_manager_v2_create(ike_sa_t *ike_sa);
#endif /** TASK_MANAGER_V2_H_ @}*/