HA sync plugin stub

This commit is contained in:
Martin Willi
2010-04-07 13:55:11 +02:00
committed by Martin Willi
parent e6e8eb09dd
commit e67f5136c0
4 changed files with 145 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
AM_CFLAGS = -rdynamic
plugin_LTLIBRARIES = libstrongswan-ha-sync.la
libstrongswan_ha_sync_la_SOURCES = ha_sync_plugin.h ha_sync_plugin.c
libstrongswan_ha_sync_la_LDFLAGS = -module
@@ -0,0 +1,84 @@
/*
* 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 "ha_sync_plugin.h"
#include <daemon.h>
#include <config/child_cfg.h>
typedef struct private_ha_sync_plugin_t private_ha_sync_plugin_t;
/**
* private data of ha_sync plugin
*/
struct private_ha_sync_plugin_t {
/**
* implements plugin interface
*/
ha_sync_plugin_t public;
/**
* Listener interface, listens to CHILD_SA state changes
*/
listener_t listener;
};
/**
* Listener implementation
*/
static bool child_state_change(listener_t *this, ike_sa_t *ike_sa,
child_sa_t *child_sa, child_sa_state_t state)
{
if (state == CHILD_INSTALLED)
{
chunk_t chunk;
chunk = child_sa->serialize(child_sa);
DBG1(DBG_IKE, "NEW CHILD: %B", &chunk);
chunk_clear(&chunk);
}
return TRUE;
}
/**
* Implementation of plugin_t.destroy
*/
static void destroy(private_ha_sync_plugin_t *this)
{
charon->bus->remove_listener(charon->bus, &this->listener);
free(this);
}
/*
* see header file
*/
plugin_t *plugin_create()
{
private_ha_sync_plugin_t *this = malloc_thing(private_ha_sync_plugin_t);
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
memset(&this->listener, 0, sizeof(listener_t));
this->listener.child_state_change = child_state_change;
charon->bus->add_listener(charon->bus, &this->listener);
return &this->public.plugin;
}
@@ -0,0 +1,49 @@
/*
* 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 ha_sync ha_sync
* @ingroup cplugins
*
* @defgroup ha_sync_plugin ha_sync_plugin
* @{ @ingroup ha_sync
*/
#ifndef HA_SYNC_PLUGIN_H_
#define HA_SYNC_PLUGIN_H_
#include <plugins/plugin.h>
typedef struct ha_sync_plugin_t ha_sync_plugin_t;
/**
* Plugin to synchronize state in a high availability cluster.
*/
struct ha_sync_plugin_t {
/**
* implements plugin interface
*/
plugin_t plugin;
};
/**
* Create a ha_sync_plugin instance.
*/
plugin_t *plugin_create();
#endif /* HA_SYNC_PLUGIN_H_ @}*/