aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2013-04-02 16:49:53 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2013-04-03 21:38:04 +0200
commit1044710b04e328ed4b1a7801dbc927b94f41dbe0 (patch)
tree969c742ae7864992ee0b4aef893d23141e67ce1e /src/libcharon/plugins
parentbee8b5e38553fbd164573631018ea7f59ff641b9 (diff)
downloadstrongswan-1044710b04e328ed4b1a7801dbc927b94f41dbe0.tar.bz2
strongswan-1044710b04e328ed4b1a7801dbc927b94f41dbe0.tar.xz
implemented periodic IF-MAP RenewSession request
Diffstat (limited to 'src/libcharon/plugins')
-rw-r--r--src/libcharon/plugins/tnc_ifmap/Makefile.am3
-rw-r--r--src/libcharon/plugins/tnc_ifmap/tnc_ifmap_listener.c13
-rw-r--r--src/libcharon/plugins/tnc_ifmap/tnc_ifmap_renew_session_job.c87
-rw-r--r--src/libcharon/plugins/tnc_ifmap/tnc_ifmap_renew_session_job.h51
-rw-r--r--src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.c21
-rw-r--r--src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.h7
6 files changed, 181 insertions, 1 deletions
diff --git a/src/libcharon/plugins/tnc_ifmap/Makefile.am b/src/libcharon/plugins/tnc_ifmap/Makefile.am
index d055bbcbd..7d8b0f5b7 100644
--- a/src/libcharon/plugins/tnc_ifmap/Makefile.am
+++ b/src/libcharon/plugins/tnc_ifmap/Makefile.am
@@ -21,7 +21,8 @@ libstrongswan_tnc_ifmap_la_SOURCES = \
tnc_ifmap_plugin.h tnc_ifmap_plugin.c \
tnc_ifmap_listener.h tnc_ifmap_listener.c \
tnc_ifmap_soap.h tnc_ifmap_soap.c \
- tnc_ifmap_soap_msg.h tnc_ifmap_soap_msg.c
+ tnc_ifmap_soap_msg.h tnc_ifmap_soap_msg.c \
+ tnc_ifmap_renew_session_job.h tnc_ifmap_renew_session_job.c
libstrongswan_tnc_ifmap_la_LDFLAGS = -module -avoid-version
diff --git a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_listener.c b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_listener.c
index 0280b30d2..d20440553 100644
--- a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_listener.c
+++ b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_listener.c
@@ -15,11 +15,14 @@
#include "tnc_ifmap_listener.h"
#include "tnc_ifmap_soap.h"
+#include "tnc_ifmap_renew_session_job.h"
#include <daemon.h>
#include <hydra.h>
#include <utils/debug.h>
+#define IFMAP_RENEW_SESSION_INTERVAL 150
+
typedef struct private_tnc_ifmap_listener_t private_tnc_ifmap_listener_t;
/**
@@ -127,6 +130,8 @@ METHOD(tnc_ifmap_listener_t, destroy, void,
tnc_ifmap_listener_t *tnc_ifmap_listener_create(bool reload)
{
private_tnc_ifmap_listener_t *this;
+ job_t *job;
+ u_int32_t reschedule;
INIT(this,
.public = {
@@ -168,6 +173,14 @@ tnc_ifmap_listener_t *tnc_ifmap_listener_create(bool reload)
}
}
+ /* schedule periodic transmission of IF-MAP renewSession request */
+ reschedule = lib->settings->get_int(lib->settings,
+ "%s.plugins.tnc-ifmap.renew_session_interval",
+ IFMAP_RENEW_SESSION_INTERVAL, charon->name);
+
+ job = (job_t*)tnc_ifmap_renew_session_job_create(this->ifmap, reschedule);
+ lib->scheduler->schedule_job(lib->scheduler, job, reschedule);
+
return &this->public;
}
diff --git a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_renew_session_job.c b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_renew_session_job.c
new file mode 100644
index 000000000..eb20bb641
--- /dev/null
+++ b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_renew_session_job.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2013 Andreas Steffen
+ * HSR 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.
+ */
+
+#include <stdlib.h>
+
+#include "tnc_ifmap_renew_session_job.h"
+
+#include <daemon.h>
+
+
+typedef struct private_tnc_ifmap_renew_session_job_t private_tnc_ifmap_renew_session_job_t;
+
+/**
+ * Private data
+ */
+struct private_tnc_ifmap_renew_session_job_t {
+
+ /**
+ * public tnc_ifmap_renew_session_job_t interface
+ */
+ tnc_ifmap_renew_session_job_t public;
+
+ /**
+ * TNC IF-MAP 2.0 SOAP interface
+ */
+ tnc_ifmap_soap_t *ifmap;
+
+ /**
+ * Reschedule time interval in seconds
+ */
+ u_int32_t reschedule;
+};
+
+METHOD(job_t, destroy, void,
+ private_tnc_ifmap_renew_session_job_t *this)
+{
+ free(this);
+}
+
+METHOD(job_t, execute, job_requeue_t,
+ private_tnc_ifmap_renew_session_job_t *this)
+{
+ this->ifmap->renewSession(this->ifmap);
+
+ return JOB_RESCHEDULE(this->reschedule);
+}
+
+METHOD(job_t, get_priority, job_priority_t,
+ private_tnc_ifmap_renew_session_job_t *this)
+{
+ return JOB_PRIO_MEDIUM;
+}
+
+/*
+ * Described in header
+ */
+tnc_ifmap_renew_session_job_t *tnc_ifmap_renew_session_job_create(
+ tnc_ifmap_soap_t *ifmap, u_int32_t reschedule)
+{
+ private_tnc_ifmap_renew_session_job_t *this;
+
+ INIT(this,
+ .public = {
+ .job_interface = {
+ .execute = _execute,
+ .get_priority = _get_priority,
+ .destroy = _destroy,
+ },
+ },
+ .ifmap = ifmap,
+ .reschedule = reschedule,
+ );
+
+ return &this->public;
+}
diff --git a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_renew_session_job.h b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_renew_session_job.h
new file mode 100644
index 000000000..91e8fe404
--- /dev/null
+++ b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_renew_session_job.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2013 Andreas Steffen
+ * HSR 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.
+ */
+
+/**
+ * @defgroup tnc_ifmap_renew_session_job tnc_ifmap_renew_session_job
+ * @{ @ingroup cjobs
+ */
+
+#ifndef TNC_IFMAP_RENEW_SESSION_JOB_H_
+#define TNC_IFMAP_RENEW_SESSION_JOB_H_
+
+typedef struct tnc_ifmap_renew_session_job_t tnc_ifmap_renew_session_job_t;
+
+#include "tnc_ifmap_soap.h"
+
+#include <library.h>
+#include <processing/jobs/job.h>
+
+/**
+ * Job periodically sending an IF-MAP RenewSession request.
+ */
+struct tnc_ifmap_renew_session_job_t {
+
+ /**
+ * implements job_t interface
+ */
+ job_t job_interface;
+};
+
+/**
+ * Creates an tnc_ifmap_renew_session job.
+ *
+ * @param ifmap TNC IF-MAP object
+ * @param reschedule reschedule time in seconds
+ */
+tnc_ifmap_renew_session_job_t *tnc_ifmap_renew_session_job_create(
+ tnc_ifmap_soap_t *ifmap, u_int32_t reschedule);
+
+#endif /** TNC_IFMAP_RENEW_SESSION_JOB_H_ @}*/
diff --git a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.c b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.c
index 246b2af90..d189f6f3a 100644
--- a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.c
+++ b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.c
@@ -136,6 +136,26 @@ METHOD(tnc_ifmap_soap_t, newSession, bool,
return this->session_id && this->ifmap_publisher_id;
}
+METHOD(tnc_ifmap_soap_t, renewSession, bool,
+ private_tnc_ifmap_soap_t *this)
+{
+ tnc_ifmap_soap_msg_t *soap_msg;
+ xmlNodePtr request;
+ bool success;
+
+ /* build renewSession request */
+ request = xmlNewNode(NULL, "renewSession");
+ this->ns = xmlNewNs(request, IFMAP_NS, "ifmap");
+ xmlSetNs(request, this->ns);
+ xmlNewProp(request, "session-id", this->session_id);
+
+ soap_msg = tnc_ifmap_soap_msg_create(this->uri, this->user_pass, this->tls);
+ success = soap_msg->post(soap_msg, request, "renewSessionResult", NULL);
+ soap_msg->destroy(soap_msg);
+
+ return success;
+}
+
METHOD(tnc_ifmap_soap_t, purgePublisher, bool,
private_tnc_ifmap_soap_t *this)
{
@@ -798,6 +818,7 @@ tnc_ifmap_soap_t *tnc_ifmap_soap_create()
INIT(this,
.public = {
.newSession = _newSession,
+ .renewSession = _renewSession,
.purgePublisher = _purgePublisher,
.publish_ike_sa = _publish_ike_sa,
.publish_device_ip = _publish_device_ip,
diff --git a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.h b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.h
index 5ab31ef19..9c5a53b29 100644
--- a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.h
+++ b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.h
@@ -40,6 +40,13 @@ struct tnc_ifmap_soap_t {
bool (*newSession)(tnc_ifmap_soap_t *this);
/**
+ * Check if the IF-MAP session is still active
+ *
+ * @return TRUE if command was successful
+ */
+ bool (*renewSession)(tnc_ifmap_soap_t *this);
+
+ /**
* Purges all metadata published by this publisher
*
* @return TRUE if command was successful