implemented periodic IF-MAP RenewSession request
This commit is contained in:
@@ -660,7 +660,10 @@ Path to private key file of IF-MAP client
|
|||||||
.BR charon.plugins.tnc-ifmap.device_name
|
.BR charon.plugins.tnc-ifmap.device_name
|
||||||
Unique name of strongSwan server as a PEP and/or PDP device
|
Unique name of strongSwan server as a PEP and/or PDP device
|
||||||
.TP
|
.TP
|
||||||
.BR charon.plugins.tnc-ifmap.server_uri " [https://localhost:8444/imap]
|
.BR charon.plugins.tnc-ifmap.renew_session_interval " [150]"
|
||||||
|
Interval in seconds between periodic IF-MAP RenewSession requests
|
||||||
|
.TP
|
||||||
|
.BR charon.plugins.tnc-ifmap.server_uri " [https://localhost:8444/imap]"
|
||||||
URI of the form [https://]servername[:port][/path]
|
URI of the form [https://]servername[:port][/path]
|
||||||
.TP
|
.TP
|
||||||
.BR charon.plugins.tnc-ifmap.server_cert
|
.BR charon.plugins.tnc-ifmap.server_cert
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ libstrongswan_tnc_ifmap_la_SOURCES = \
|
|||||||
tnc_ifmap_plugin.h tnc_ifmap_plugin.c \
|
tnc_ifmap_plugin.h tnc_ifmap_plugin.c \
|
||||||
tnc_ifmap_listener.h tnc_ifmap_listener.c \
|
tnc_ifmap_listener.h tnc_ifmap_listener.c \
|
||||||
tnc_ifmap_soap.h tnc_ifmap_soap.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
|
libstrongswan_tnc_ifmap_la_LDFLAGS = -module -avoid-version
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,14 @@
|
|||||||
|
|
||||||
#include "tnc_ifmap_listener.h"
|
#include "tnc_ifmap_listener.h"
|
||||||
#include "tnc_ifmap_soap.h"
|
#include "tnc_ifmap_soap.h"
|
||||||
|
#include "tnc_ifmap_renew_session_job.h"
|
||||||
|
|
||||||
#include <daemon.h>
|
#include <daemon.h>
|
||||||
#include <hydra.h>
|
#include <hydra.h>
|
||||||
#include <utils/debug.h>
|
#include <utils/debug.h>
|
||||||
|
|
||||||
|
#define IFMAP_RENEW_SESSION_INTERVAL 150
|
||||||
|
|
||||||
typedef struct private_tnc_ifmap_listener_t private_tnc_ifmap_listener_t;
|
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)
|
tnc_ifmap_listener_t *tnc_ifmap_listener_create(bool reload)
|
||||||
{
|
{
|
||||||
private_tnc_ifmap_listener_t *this;
|
private_tnc_ifmap_listener_t *this;
|
||||||
|
job_t *job;
|
||||||
|
u_int32_t reschedule;
|
||||||
|
|
||||||
INIT(this,
|
INIT(this,
|
||||||
.public = {
|
.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;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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_ @}*/
|
||||||
@@ -136,6 +136,26 @@ METHOD(tnc_ifmap_soap_t, newSession, bool,
|
|||||||
return this->session_id && this->ifmap_publisher_id;
|
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,
|
METHOD(tnc_ifmap_soap_t, purgePublisher, bool,
|
||||||
private_tnc_ifmap_soap_t *this)
|
private_tnc_ifmap_soap_t *this)
|
||||||
{
|
{
|
||||||
@@ -798,6 +818,7 @@ tnc_ifmap_soap_t *tnc_ifmap_soap_create()
|
|||||||
INIT(this,
|
INIT(this,
|
||||||
.public = {
|
.public = {
|
||||||
.newSession = _newSession,
|
.newSession = _newSession,
|
||||||
|
.renewSession = _renewSession,
|
||||||
.purgePublisher = _purgePublisher,
|
.purgePublisher = _purgePublisher,
|
||||||
.publish_ike_sa = _publish_ike_sa,
|
.publish_ike_sa = _publish_ike_sa,
|
||||||
.publish_device_ip = _publish_device_ip,
|
.publish_device_ip = _publish_device_ip,
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ struct tnc_ifmap_soap_t {
|
|||||||
*/
|
*/
|
||||||
bool (*newSession)(tnc_ifmap_soap_t *this);
|
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
|
* Purges all metadata published by this publisher
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user