Add a stub for IKE event counters in stroke

This commit is contained in:
Martin Willi 2012-10-08 10:31:36 +02:00
parent b2265a2738
commit 8554895b95
4 changed files with 112 additions and 0 deletions

View File

@ -22,6 +22,7 @@ libstrongswan_stroke_la_SOURCES = \
stroke_ca.h stroke_ca.c \
stroke_attribute.h stroke_attribute.c \
stroke_handler.h stroke_handler.c \
stroke_counter.h stroke_counter.c \
stroke_list.h stroke_list.c
libstrongswan_stroke_la_LDFLAGS = -module -avoid-version

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2012 Martin Willi
* Copyright (C) 2012 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 "stroke_counter.h"
typedef struct private_stroke_counter_t private_stroke_counter_t;
/**
* Private data of an stroke_counter_t object.
*/
struct private_stroke_counter_t {
/**
* Public stroke_counter_t interface.
*/
stroke_counter_t public;
};
METHOD(stroke_counter_t, destroy, void,
private_stroke_counter_t *this)
{
free(this);
}
/**
* See header
*/
stroke_counter_t *stroke_counter_create()
{
private_stroke_counter_t *this;
INIT(this,
.public = {
.destroy = _destroy,
},
);
return &this->public;
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (C) 2012 Martin Willi
* Copyright (C) 2012 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 stroke_counter stroke_counter
* @{ @ingroup stroke
*/
#ifndef STROKE_COUNTER_H_
#define STROKE_COUNTER_H_
#include <bus/listeners/listener.h>
typedef struct stroke_counter_t stroke_counter_t;
/**
* Collection of counter values for different IKE events.
*/
struct stroke_counter_t {
/**
* Implements listener_t.
*/
listener_t listener;
/**
* Destroy a stroke_counter_t.
*/
void (*destroy)(stroke_counter_t *this);
};
/**
* Create a stroke_counter instance.
*/
stroke_counter_t *stroke_counter_create();
#endif /** STROKE_COUNTER_H_ @}*/

View File

@ -39,6 +39,7 @@
#include "stroke_attribute.h"
#include "stroke_handler.h"
#include "stroke_list.h"
#include "stroke_counter.h"
/**
* To avoid clogging the thread pool with (blocking) jobs, we limit the number
@ -123,6 +124,11 @@ struct private_stroke_socket_t {
* status information logging
*/
stroke_list_t *list;
/**
* Counter values for IKE events
*/
stroke_counter_t *counter;
};
/**
@ -781,6 +787,7 @@ METHOD(stroke_socket_t, destroy, void,
charon->backends->remove_backend(charon->backends, &this->config->backend);
hydra->attributes->remove_provider(hydra->attributes, &this->attribute->provider);
hydra->attributes->remove_handler(hydra->attributes, &this->handler->handler);
charon->bus->remove_listener(charon->bus, &this->counter->listener);
this->cred->destroy(this->cred);
this->ca->destroy(this->ca);
this->config->destroy(this->config);
@ -788,6 +795,7 @@ METHOD(stroke_socket_t, destroy, void,
this->handler->destroy(this->handler);
this->control->destroy(this->control);
this->list->destroy(this->list);
this->counter->destroy(this->counter);
free(this);
}
@ -817,6 +825,7 @@ stroke_socket_t *stroke_socket_create()
this->config = stroke_config_create(this->ca, this->cred, this->attribute);
this->control = stroke_control_create();
this->list = stroke_list_create(this->attribute);
this->counter = stroke_counter_create();
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
@ -830,6 +839,7 @@ stroke_socket_t *stroke_socket_create()
charon->backends->add_backend(charon->backends, &this->config->backend);
hydra->attributes->add_provider(hydra->attributes, &this->attribute->provider);
hydra->attributes->add_handler(hydra->attributes, &this->handler->handler);
charon->bus->add_listener(charon->bus, &this->counter->listener);
lib->processor->queue_job(lib->processor,
(job_t*)callback_job_create_with_prio((callback_job_cb_t)receive, this,