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.
|
|
|
|
*/
|
|
|
|
|
2008-03-13 14:14:44 +00:00
|
|
|
/**
|
|
|
|
* @defgroup controller_i controller
|
|
|
|
* @{ @ingroup control
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONTROLLER_H_
|
|
|
|
#define CONTROLLER_H_
|
2007-04-11 13:01:08 +00:00
|
|
|
|
2007-04-16 12:52:49 +00:00
|
|
|
#include <bus/bus.h>
|
|
|
|
|
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* callback to log things triggered by controller.
|
2007-04-16 12:52:49 +00:00
|
|
|
*
|
|
|
|
* @param param echoed parameter supplied when function invoked
|
2008-10-14 08:52:13 +00:00
|
|
|
* @param group debugging group
|
2007-04-16 12:52:49 +00:00
|
|
|
* @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
|
|
|
|
*/
|
2008-10-14 08:52:13 +00:00
|
|
|
typedef bool(*controller_cb_t)(void* param, debug_t group, level_t level,
|
|
|
|
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
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Empty callback function for controller_t functions.
|
2007-10-03 08:10:03 +00:00
|
|
|
*
|
2008-11-11 13:11:44 +00:00
|
|
|
* If you want to do a synchronous call, but don't need a callback, pass
|
2008-03-13 14:14:44 +00:00
|
|
|
* this function to the controllers methods.
|
2007-10-03 08:10:03 +00:00
|
|
|
*/
|
2008-10-14 08:52:13 +00:00
|
|
|
bool controller_cb_empty(void *param, debug_t group, level_t level,
|
|
|
|
ike_sa_t *ike_sa, char *format, va_list args);
|
2007-10-03 08:10:03 +00:00
|
|
|
|
2008-03-13 14:14:44 +00:00
|
|
|
typedef struct controller_t controller_t;
|
2007-04-11 13:01:08 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* The controller provides a simple interface to run actions.
|
2007-04-16 12:52:49 +00:00
|
|
|
*
|
2008-03-13 14:14:44 +00:00
|
|
|
* The controller 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.
|
2008-11-11 13:11:44 +00:00
|
|
|
* If a callback is specified, they are called synchronously. There is a default
|
2008-03-13 14:14:44 +00:00
|
|
|
* callback "controller_cb_empty" if you wan't to call a function
|
2007-10-03 08:10:03 +00:00
|
|
|
* synchronously, but don't need a callback.
|
2007-04-11 13:01:08 +00:00
|
|
|
*/
|
2008-03-13 14:14:44 +00:00
|
|
|
struct controller_t {
|
2007-04-16 12:52:49 +00:00
|
|
|
|
2007-05-03 14:22:52 +00:00
|
|
|
/**
|
2008-04-14 11:37:46 +00:00
|
|
|
* Create an enumerator for all IKE_SAs.
|
2007-05-03 14:22:52 +00:00
|
|
|
*
|
2008-04-14 11:37:46 +00:00
|
|
|
* The enumerator blocks the IKE_SA manager until it gets destroyed. Do
|
2007-05-03 14:22:52 +00:00
|
|
|
* not call another interface/manager method while the iterator is alive.
|
|
|
|
*
|
2008-04-14 11:37:46 +00:00
|
|
|
* @return enumerator, locks IKE_SA manager until destroyed
|
2007-05-03 14:22:52 +00:00
|
|
|
*/
|
2008-04-14 11:37:46 +00:00
|
|
|
enumerator_t* (*create_ike_sa_enumerator)(controller_t *this);
|
2007-05-03 14:22:52 +00:00
|
|
|
|
2007-04-16 12:52:49 +00:00
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Initiate a CHILD_SA, and if required, an IKE_SA.
|
2007-04-16 12:52:49 +00:00
|
|
|
*
|
2008-11-11 13:11:44 +00:00
|
|
|
* The initiate() function is synchronous and thus blocks until the
|
2007-05-23 09:08:13 +00:00
|
|
|
* 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 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
|
|
|
|
*/
|
2008-03-13 14:14:44 +00:00
|
|
|
status_t (*initiate)(controller_t *this,
|
2007-04-16 12:52:49 +00:00
|
|
|
peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
|
2008-03-13 14:14:44 +00:00
|
|
|
controller_cb_t callback, void *param);
|
2007-05-03 14:22:52 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Terminate an IKE_SA and all of its CHILD_SAs.
|
2007-05-03 14:22:52 +00:00
|
|
|
*
|
2007-05-23 09:08:13 +00:00
|
|
|
* The terminate() function is synchronous and thus blocks until the
|
2009-09-04 11:46:09 +00:00
|
|
|
* IKE_SA is properly deleted, or the delete timed out.
|
2007-05-23 09:08:13 +00:00
|
|
|
* The terminate() function contains a thread cancellation point.
|
|
|
|
*
|
2007-05-03 14:22:52 +00:00
|
|
|
* @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
|
|
|
|
*/
|
2009-09-04 11:46:09 +00:00
|
|
|
status_t (*terminate_ike)(controller_t *this, u_int32_t unique_id,
|
2008-03-13 14:14:44 +00:00
|
|
|
controller_cb_t callback, void *param);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2007-05-03 14:22:52 +00:00
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Terminate a CHILD_SA.
|
2007-05-03 14:22:52 +00:00
|
|
|
*
|
|
|
|
* @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
|
|
|
|
*/
|
2009-09-04 11:46:09 +00:00
|
|
|
status_t (*terminate_child)(controller_t *this, u_int32_t reqid,
|
2008-03-13 14:14:44 +00:00
|
|
|
controller_cb_t callback, void *param);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2007-04-11 13:01:08 +00:00
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Destroy a controller_t instance.
|
2007-04-11 13:01:08 +00:00
|
|
|
*/
|
2008-03-13 14:14:44 +00:00
|
|
|
void (*destroy) (controller_t *this);
|
2007-04-11 13:01:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-03-13 14:14:44 +00:00
|
|
|
* Creates a controller instance.
|
2009-09-04 11:46:09 +00:00
|
|
|
*
|
2008-03-13 14:14:44 +00:00
|
|
|
* @return controller_t object
|
2007-04-11 13:01:08 +00:00
|
|
|
*/
|
2008-03-13 14:14:44 +00:00
|
|
|
controller_t *controller_create(void);
|
2007-04-11 13:01:08 +00:00
|
|
|
|
2009-03-24 17:43:01 +00:00
|
|
|
#endif /** CONTROLLER_H_ @}*/
|