aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/plugins/load_tester
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-11-06 14:07:46 +0000
committerMartin Willi <martin@strongswan.org>2008-11-06 14:07:46 +0000
commita70df08c9b3a1bfeb4d89dccd8a2bcd9ce69b623 (patch)
tree98d8cf4c78119dcd75773bf66cdc9f07d35508b7 /src/charon/plugins/load_tester
parentebf0e20ae72691f9dc3863f1573e4f19e4f0d4b1 (diff)
downloadstrongswan-a70df08c9b3a1bfeb4d89dccd8a2bcd9ce69b623.tar.bz2
strongswan-a70df08c9b3a1bfeb4d89dccd8a2bcd9ce69b623.tar.xz
added delete_after_established option
Diffstat (limited to 'src/charon/plugins/load_tester')
-rw-r--r--src/charon/plugins/load_tester/Makefile.am3
-rw-r--r--src/charon/plugins/load_tester/load_tester_listener.c75
-rw-r--r--src/charon/plugins/load_tester/load_tester_listener.h53
-rw-r--r--src/charon/plugins/load_tester/load_tester_plugin.c10
4 files changed, 140 insertions, 1 deletions
diff --git a/src/charon/plugins/load_tester/Makefile.am b/src/charon/plugins/load_tester/Makefile.am
index 7e539dd78..88a6b688c 100644
--- a/src/charon/plugins/load_tester/Makefile.am
+++ b/src/charon/plugins/load_tester/Makefile.am
@@ -9,7 +9,8 @@ libstrongswan_load_tester_la_SOURCES = \
load_tester_plugin.c load_tester_plugin.h \
load_tester_config.c load_tester_config.h \
load_tester_creds.c load_tester_creds.h \
- load_tester_ipsec.c load_tester_ipsec.h
+ load_tester_ipsec.c load_tester_ipsec.h \
+ load_tester_listener.c load_tester_listener.h
libstrongswan_load_tester_la_LDFLAGS = -module
diff --git a/src/charon/plugins/load_tester/load_tester_listener.c b/src/charon/plugins/load_tester/load_tester_listener.c
new file mode 100644
index 000000000..991408a44
--- /dev/null
+++ b/src/charon/plugins/load_tester/load_tester_listener.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2008 Martin Willi
+ * Hochschule fuer Technik Rapperswil
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+#include "load_tester_listener.h"
+
+#include <daemon.h>
+#include <processing/jobs/delete_ike_sa_job.h>
+
+typedef struct private_load_tester_listener_t private_load_tester_listener_t;
+
+/**
+ * Private data of an load_tester_listener_t object
+ */
+struct private_load_tester_listener_t {
+ /**
+ * Public part
+ */
+ load_tester_listener_t public;
+
+ /**
+ * Delete IKE_SA after it has been established
+ */
+ bool delete_after_established;
+};
+
+/**
+ * Implementation of listener_t.ike_state_change
+ */
+static bool ike_state_change(private_load_tester_listener_t *this,
+ ike_sa_t *ike_sa, ike_sa_state_t state)
+{
+ if (this->delete_after_established && state == IKE_ESTABLISHED)
+ {
+ charon->processor->queue_job(charon->processor,
+ (job_t*)delete_ike_sa_job_create(ike_sa->get_id(ike_sa), TRUE));
+ }
+ return TRUE;
+}
+
+/**
+ * Implementation of load_tester_listener_t.destroy
+ */
+static void destroy(private_load_tester_listener_t *this)
+{
+ free(this);
+}
+
+load_tester_listener_t *load_tester_listener_create()
+{
+ private_load_tester_listener_t *this = malloc_thing(private_load_tester_listener_t);
+
+ memset(&this->public.listener, 0, sizeof(listener_t));
+ this->public.listener.ike_state_change = (void*)ike_state_change;
+ this->public.destroy = (void(*) (load_tester_listener_t*))destroy;
+
+ this->delete_after_established = lib->settings->get_bool(lib->settings,
+ "charon.plugins.load_tester.delete_after_established", FALSE);
+
+ return &this->public;
+}
+
diff --git a/src/charon/plugins/load_tester/load_tester_listener.h b/src/charon/plugins/load_tester/load_tester_listener.h
new file mode 100644
index 000000000..28bb57d05
--- /dev/null
+++ b/src/charon/plugins/load_tester/load_tester_listener.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2008 Martin Willi
+ * Hochschule fuer Technik Rapperswil
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+/**
+ * @defgroup load_tester_listener_t load_tester_listener
+ * @{ @ingroup load_tester
+ */
+
+#ifndef LOAD_TESTER_LISTENER_H_
+#define LOAD_TESTER_LISTENER_H_
+
+#include <bus/bus.h>
+
+typedef struct load_tester_listener_t load_tester_listener_t;
+
+/**
+ * Provide hard-coded credentials for load testing.
+ */
+struct load_tester_listener_t {
+
+ /**
+ * Implements listener set interface.
+ */
+ listener_t listener;
+
+ /**
+ * Destroy the backend.
+ */
+ void (*destroy)(load_tester_listener_t *this);
+};
+
+/**
+ * Create a listener to handle special events during load test
+ *
+ * @return listener
+ */
+load_tester_listener_t *load_tester_listener_create();
+
+#endif /* LOAD_TESTER_LISTENER_H_ @}*/
diff --git a/src/charon/plugins/load_tester/load_tester_plugin.c b/src/charon/plugins/load_tester/load_tester_plugin.c
index 9dbfcd609..88b240af5 100644
--- a/src/charon/plugins/load_tester/load_tester_plugin.c
+++ b/src/charon/plugins/load_tester/load_tester_plugin.c
@@ -19,6 +19,7 @@
#include "load_tester_config.h"
#include "load_tester_creds.h"
#include "load_tester_ipsec.h"
+#include "load_tester_listener.h"
#include <unistd.h>
@@ -48,6 +49,11 @@ struct private_load_tester_plugin_t {
load_tester_creds_t *creds;
/**
+ * event handler, listens on bus
+ */
+ load_tester_listener_t *listener;
+
+ /**
* number of iterations per thread
*/
int iterations;
@@ -122,8 +128,10 @@ static void destroy(private_load_tester_plugin_t *this)
(kernel_ipsec_constructor_t)load_tester_ipsec_create);
charon->backends->remove_backend(charon->backends, &this->config->backend);
charon->credentials->remove_set(charon->credentials, &this->creds->credential_set);
+ charon->bus->remove_listener(charon->bus, &this->listener->listener);
this->config->destroy(this->config);
this->creds->destroy(this->creds);
+ this->listener->destroy(this->listener);
free(this);
}
@@ -139,8 +147,10 @@ plugin_t *plugin_create()
this->config = load_tester_config_create();
this->creds = load_tester_creds_create();
+ this->listener = load_tester_listener_create();
charon->backends->add_backend(charon->backends, &this->config->backend);
charon->credentials->add_set(charon->credentials, &this->creds->credential_set);
+ charon->bus->add_listener(charon->bus, &this->listener->listener);
if (lib->settings->get_bool(lib->settings,
"charon.plugins.load_tester.fake_kernel", FALSE))