2007-04-11 13:01:08 +00:00
|
|
|
/**
|
2007-04-27 14:25:08 +00:00
|
|
|
* @file interface_manager.h
|
2007-04-11 13:01:08 +00:00
|
|
|
*
|
2007-04-27 14:25:08 +00:00
|
|
|
* @brief Interface of interface_manager_t.
|
2007-04-11 13:01:08 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 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.
|
|
|
|
*/
|
|
|
|
|
2007-04-27 14:25:08 +00:00
|
|
|
#ifndef INTERFACE_MANAGER_H_
|
|
|
|
#define INTERFACE_MANAGER_H_
|
2007-04-11 13:01:08 +00:00
|
|
|
|
2007-04-16 12:52:49 +00:00
|
|
|
#include <bus/bus.h>
|
|
|
|
|
|
|
|
/**
|
2007-04-30 10:23:01 +00:00
|
|
|
* callback to log things triggered by interface_manager.
|
2007-04-16 12:52:49 +00:00
|
|
|
*
|
|
|
|
* @param param echoed parameter supplied when function invoked
|
|
|
|
* @param signal type of signal
|
|
|
|
* @param level verbosity level if log
|
|
|
|
* @param ike_sa associated IKE_SA, if any
|
|
|
|
* @param format printf like format string
|
|
|
|
* @param args list of arguments to use for format
|
|
|
|
* @return FALSE to return from invoked function
|
|
|
|
* @ingroup control
|
|
|
|
*/
|
2007-04-27 14:25:08 +00:00
|
|
|
typedef bool(*interface_manager_cb_t)(void* param, signal_t signal, level_t level,
|
2007-04-16 12:52:49 +00:00
|
|
|
ike_sa_t* ike_sa, char* format, va_list args);
|
2007-04-11 13:01:08 +00:00
|
|
|
|
2007-10-03 08:10:03 +00:00
|
|
|
/**
|
|
|
|
* @brief Empty callback function for interface_manager_t functions.
|
|
|
|
*
|
|
|
|
* If you wan't to do a syncrhonous call, but don't need a callback, pass
|
|
|
|
* this function to the interface_managers methods.
|
|
|
|
*/
|
|
|
|
bool interface_manager_cb_empty(void *param, signal_t signal, level_t level,
|
|
|
|
ike_sa_t *ike_sa, char *format, va_list args);
|
|
|
|
|
2007-04-27 14:25:08 +00:00
|
|
|
typedef struct interface_manager_t interface_manager_t;
|
2007-04-11 13:01:08 +00:00
|
|
|
|
|
|
|
/**
|
2007-04-30 10:23:01 +00:00
|
|
|
* @brief The interface_manager loads control interfaces and has helper methods.
|
2007-04-16 12:52:49 +00:00
|
|
|
*
|
2007-04-30 10:23:01 +00:00
|
|
|
* One job of the interface manager is to load pluggable control interface
|
|
|
|
* modules, implemented as interface_t.
|
|
|
|
* @verbatim
|
|
|
|
|
|
|
|
+---------+ +------------+ +--------------+ |
|
|
|
|
| | | |<----- +--------------+ | |
|
|
|
|
| daemon |<-----| interface- | +--------------+ |-+ <==|==> IPC
|
|
|
|
| core | | manager |<----| interfaces |-+ |
|
|
|
|
| |<-----| | +--------------+ |
|
|
|
|
| | | | |
|
|
|
|
+---------+ +------------+ |
|
|
|
|
|
|
|
|
@endverbatim
|
|
|
|
* The manager does not really use the interfaces, instead, the interface
|
|
|
|
* use the manager to fullfill their tasks (initiating, terminating, ...).
|
2007-04-27 14:25:08 +00:00
|
|
|
* The interface_manager starts actions by creating jobs. It then tries to
|
2007-04-16 12:52:49 +00:00
|
|
|
* evaluate the result of the operation by listening on the bus.
|
2007-10-03 08:10:03 +00:00
|
|
|
*
|
|
|
|
* Passing NULL as callback to the managers function calls them asynchronously.
|
|
|
|
* If a callback is specified, they are called synchronoulsy. There is a default
|
|
|
|
* callback "interface_manager_cb_empty" if you wan't to call a function
|
|
|
|
* synchronously, but don't need a callback.
|
2007-04-11 13:01:08 +00:00
|
|
|
*
|
|
|
|
* @b Constructors:
|
2007-04-27 14:25:08 +00:00
|
|
|
* - interface_manager_create()
|
2007-04-11 13:01:08 +00:00
|
|
|
*
|
|
|
|
* @ingroup control
|
|
|
|
*/
|
2007-04-27 14:25:08 +00:00
|
|
|
struct interface_manager_t {
|
2007-04-16 12:52:49 +00:00
|
|
|
|
2007-05-03 14:22:52 +00:00
|
|
|
/**
|
|
|
|
* @brief Create an iterator for all IKE_SAs.
|
|
|
|
*
|
|
|
|
* The iterator blocks the IKE_SA manager until it gets destroyed. Do
|
|
|
|
* not call another interface/manager method while the iterator is alive.
|
|
|
|
*
|
|
|
|
* @param this calling object
|
|
|
|
* @return iterator, locks IKE_SA manager until destroyed
|
|
|
|
*/
|
|
|
|
iterator_t* (*create_ike_sa_iterator)(interface_manager_t *this);
|
|
|
|
|
2007-04-16 12:52:49 +00:00
|
|
|
/**
|
|
|
|
* @brief Initiate a CHILD_SA, and if required, an IKE_SA.
|
|
|
|
*
|
2007-05-23 09:08:13 +00:00
|
|
|
* The inititate() function is synchronous and thus blocks until the
|
|
|
|
* IKE_SA is established or failed. Because of this, the initiate() function
|
|
|
|
* contains a thread cancellation point.
|
|
|
|
*
|
2007-04-16 12:52:49 +00:00
|
|
|
* @param this calling object
|
|
|
|
* @param peer_cfg peer_cfg to use for IKE_SA setup
|
|
|
|
* @param child_cfg child_cfg to set up CHILD_SA from
|
|
|
|
* @param cb logging callback
|
|
|
|
* @param param parameter to include in each call of cb
|
|
|
|
* @return
|
|
|
|
* - SUCCESS, if CHILD_SA established
|
|
|
|
* - FAILED, if setup failed
|
|
|
|
* - NEED_MORE, if callback returned FALSE
|
|
|
|
*/
|
2007-04-27 14:25:08 +00:00
|
|
|
status_t (*initiate)(interface_manager_t *this,
|
2007-04-16 12:52:49 +00:00
|
|
|
peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
|
2007-04-27 14:25:08 +00:00
|
|
|
interface_manager_cb_t callback, void *param);
|
2007-05-03 14:22:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Terminate an IKE_SA and all of its CHILD_SAs.
|
|
|
|
*
|
2007-05-23 09:08:13 +00:00
|
|
|
* The terminate() function is synchronous and thus blocks until the
|
|
|
|
* IKE_SA is properly deleted, or the delete timed out.
|
|
|
|
* The terminate() function contains a thread cancellation point.
|
|
|
|
*
|
2007-05-03 14:22:52 +00:00
|
|
|
* @param this calling object
|
|
|
|
* @param unique_id unique id of the IKE_SA to terminate.
|
|
|
|
* @param cb logging callback
|
|
|
|
* @param param parameter to include in each call of cb
|
|
|
|
* @return
|
|
|
|
* - SUCCESS, if CHILD_SA terminated
|
|
|
|
* - NOT_FOUND, if no such CHILD_SA found
|
|
|
|
* - NEED_MORE, if callback returned FALSE
|
|
|
|
*/
|
|
|
|
status_t (*terminate_ike)(interface_manager_t *this, u_int32_t unique_id,
|
|
|
|
interface_manager_cb_t callback, void *param);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Terminate a CHILD_SA.
|
|
|
|
*
|
|
|
|
* @param this calling object
|
|
|
|
* @param reqid reqid of the CHILD_SA to terminate
|
|
|
|
* @param cb logging callback
|
|
|
|
* @param param parameter to include in each call of cb
|
|
|
|
* @return
|
|
|
|
* - SUCCESS, if CHILD_SA terminated
|
|
|
|
* - NOT_FOUND, if no such CHILD_SA found
|
|
|
|
* - NEED_MORE, if callback returned FALSE
|
|
|
|
*/
|
|
|
|
status_t (*terminate_child)(interface_manager_t *this, u_int32_t reqid,
|
|
|
|
interface_manager_cb_t callback, void *param);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Route a CHILD_SA (install triggering policies).
|
|
|
|
*
|
|
|
|
* @param this calling object
|
|
|
|
* @param peer_cfg peer_cfg to use for IKE_SA setup, if triggered
|
|
|
|
* @param child_cfg child_cfg to route
|
|
|
|
* @param cb logging callback
|
|
|
|
* @param param parameter to include in each call of cb
|
|
|
|
* @return
|
|
|
|
* - SUCCESS, if CHILD_SA routed
|
|
|
|
* - FAILED, if routing failed
|
|
|
|
* - NEED_MORE, if callback returned FALSE
|
|
|
|
*/
|
|
|
|
status_t (*route)(interface_manager_t *this,
|
|
|
|
peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
|
|
|
|
interface_manager_cb_t callback, void *param);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Unroute a routed CHILD_SA (uninstall triggering policies).
|
|
|
|
*
|
|
|
|
* Only the route is removed, not the CHILD_SAs the route triggered.
|
|
|
|
*
|
|
|
|
* @param this calling object
|
|
|
|
* @param reqid reqid of the CHILD_SA to unroute
|
|
|
|
* @param cb logging callback
|
|
|
|
* @param param parameter to include in each call of cb
|
|
|
|
* @return
|
|
|
|
* - SUCCESS, if CHILD_SA terminated
|
|
|
|
* - NOT_FOUND, if no such CHILD_SA routed
|
|
|
|
* - NEED_MORE, if callback returned FALSE
|
|
|
|
*/
|
|
|
|
status_t (*unroute)(interface_manager_t *this, u_int32_t reqid,
|
|
|
|
interface_manager_cb_t callback, void *param);
|
2007-04-11 13:01:08 +00:00
|
|
|
|
|
|
|
/**
|
2007-04-27 14:25:08 +00:00
|
|
|
* @brief Destroy a interface_manager_t instance.
|
2007-04-11 13:01:08 +00:00
|
|
|
*
|
2007-04-27 14:25:08 +00:00
|
|
|
* @param this interface_manager_t objec to destroy
|
2007-04-11 13:01:08 +00:00
|
|
|
*/
|
2007-04-27 14:25:08 +00:00
|
|
|
void (*destroy) (interface_manager_t *this);
|
2007-04-11 13:01:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-04-30 10:23:01 +00:00
|
|
|
* @brief Creates a interface_manager instance and loads all interface modules.
|
2007-04-11 13:01:08 +00:00
|
|
|
*
|
2007-04-27 14:25:08 +00:00
|
|
|
* @return interface_manager_t object
|
2007-04-11 13:01:08 +00:00
|
|
|
*
|
|
|
|
* @ingroup control
|
|
|
|
*/
|
2007-04-27 14:25:08 +00:00
|
|
|
interface_manager_t *interface_manager_create(void);
|
|
|
|
|
|
|
|
#endif /* INTERFACE_MANAGER_H_ */
|
2007-04-11 13:01:08 +00:00
|
|
|
|