2008-10-24 08:06:22 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
2008-11-12 13:28:18 +00:00
|
|
|
#include "ha_sync_ike.h"
|
2008-10-24 12:42:06 +00:00
|
|
|
#include "ha_sync_child.h"
|
2008-11-12 13:28:18 +00:00
|
|
|
#include "ha_sync_socket.h"
|
2008-11-13 16:01:06 +00:00
|
|
|
#include "ha_sync_dispatcher.h"
|
2008-11-17 15:58:39 +00:00
|
|
|
#include "ha_sync_cache.h"
|
2008-11-27 09:57:31 +00:00
|
|
|
#include "ha_sync_ctl.h"
|
2008-10-24 08:06:22 +00:00
|
|
|
|
|
|
|
#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;
|
|
|
|
|
|
|
|
/**
|
2008-11-12 13:28:18 +00:00
|
|
|
* Communication socket
|
|
|
|
*/
|
|
|
|
ha_sync_socket_t *socket;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IKE_SA synchronization
|
|
|
|
*/
|
|
|
|
ha_sync_ike_t *ike;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CHILD_SA synchronization
|
2008-10-24 08:06:22 +00:00
|
|
|
*/
|
2008-10-24 12:42:06 +00:00
|
|
|
ha_sync_child_t *child;
|
2008-11-13 16:01:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatcher to process incoming messages
|
|
|
|
*/
|
|
|
|
ha_sync_dispatcher_t *dispatcher;
|
2008-11-17 15:58:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Local cache of a nodes synced SAs
|
|
|
|
*/
|
|
|
|
ha_sync_cache_t *cache;
|
2008-11-27 09:57:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Segment control interface via FIFO
|
|
|
|
*/
|
|
|
|
ha_sync_ctl_t *ctl;
|
2008-10-24 08:06:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of plugin_t.destroy
|
|
|
|
*/
|
|
|
|
static void destroy(private_ha_sync_plugin_t *this)
|
|
|
|
{
|
2008-11-12 13:28:18 +00:00
|
|
|
charon->bus->remove_listener(charon->bus, &this->ike->listener);
|
2008-10-24 12:42:06 +00:00
|
|
|
charon->bus->remove_listener(charon->bus, &this->child->listener);
|
2008-11-12 13:28:18 +00:00
|
|
|
this->ike->destroy(this->ike);
|
2008-10-24 12:42:06 +00:00
|
|
|
this->child->destroy(this->child);
|
2008-11-13 16:01:06 +00:00
|
|
|
this->dispatcher->destroy(this->dispatcher);
|
2008-11-27 09:57:31 +00:00
|
|
|
this->ctl->destroy(this->ctl);
|
2008-11-17 15:58:39 +00:00
|
|
|
this->cache->destroy(this->cache);
|
2008-11-12 13:28:18 +00:00
|
|
|
this->socket->destroy(this->socket);
|
2008-10-24 08:06:22 +00:00
|
|
|
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;
|
|
|
|
|
2008-11-12 13:28:18 +00:00
|
|
|
this->socket = ha_sync_socket_create();
|
|
|
|
if (!this->socket)
|
|
|
|
{
|
|
|
|
free(this);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-11-17 15:58:39 +00:00
|
|
|
this->cache = ha_sync_cache_create();
|
2008-11-27 09:57:31 +00:00
|
|
|
this->ctl = ha_sync_ctl_create(this->cache);
|
2008-11-17 15:58:39 +00:00
|
|
|
this->dispatcher = ha_sync_dispatcher_create(this->socket, this->cache);
|
2008-11-20 08:51:54 +00:00
|
|
|
this->ike = ha_sync_ike_create(this->socket, this->cache);
|
|
|
|
this->child = ha_sync_child_create(this->socket, this->cache);
|
2008-11-12 13:28:18 +00:00
|
|
|
charon->bus->add_listener(charon->bus, &this->ike->listener);
|
2008-10-24 12:42:06 +00:00
|
|
|
charon->bus->add_listener(charon->bus, &this->child->listener);
|
2008-10-24 08:06:22 +00:00
|
|
|
|
|
|
|
return &this->public.plugin;
|
|
|
|
}
|
|
|
|
|