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>
|
|
|
|
|
|
|
|
/**
|
2012-01-23 12:51:21 +00:00
|
|
|
* Callback to log things triggered by controller.
|
2007-04-16 12:52:49 +00:00
|
|
|
*
|
2012-01-23 12:51:21 +00:00
|
|
|
* @param param parameter supplied when controller method was called
|
2008-10-14 08:52:13 +00:00
|
|
|
* @param group debugging group
|
2012-01-23 12:51:21 +00:00
|
|
|
* @param level verbosity level
|
2007-04-16 12:52:49 +00:00
|
|
|
* @param ike_sa associated IKE_SA, if any
|
2012-01-23 12:51:21 +00:00
|
|
|
* @param message log message
|
|
|
|
* @return FALSE to return from called controller method
|
2007-04-16 12:52:49 +00:00
|
|
|
*/
|
2011-12-22 12:54:30 +00:00
|
|
|
typedef bool (*controller_cb_t)(void* param, debug_t group, level_t level,
|
2012-07-13 13:42:14 +00:00
|
|
|
ike_sa_t* ike_sa, const char *message);
|
2007-04-11 13:01:08 +00:00
|
|
|
|
2007-10-03 08:10:03 +00:00
|
|
|
/**
|
2012-01-23 12:51:21 +00:00
|
|
|
* Empty callback function for controller_t methods.
|
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
|
2012-01-23 12:51:21 +00:00
|
|
|
* this function to the controller 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,
|
2012-07-13 13:42:14 +00:00
|
|
|
ike_sa_t *ike_sa, const char *message);
|
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
|
2011-05-06 07:50:02 +00:00
|
|
|
* callback "controller_cb_empty" if you want 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
|
2011-05-19 14:18:30 +00:00
|
|
|
* not call another interface/manager method while the enumerator is alive.
|
2007-05-03 14:22:52 +00:00
|
|
|
*
|
2011-05-02 13:28:33 +00:00
|
|
|
* @param wait TRUE to wait for checked out SAs, FALSE to skip
|
2008-04-14 11:37:46 +00:00
|
|
|
* @return enumerator, locks IKE_SA manager until destroyed
|
2007-05-03 14:22:52 +00:00
|
|
|
*/
|
2011-05-02 13:28:33 +00:00
|
|
|
enumerator_t* (*create_ike_sa_enumerator)(controller_t *this, bool wait);
|
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
|
|
|
*
|
2011-12-22 12:54:30 +00:00
|
|
|
* If a callback is provided the function is synchronous and thus blocks
|
|
|
|
* until the IKE_SA is established or failed.
|
2007-05-23 09:08:13 +00:00
|
|
|
*
|
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
|
2011-08-26 08:42:42 +00:00
|
|
|
* @param timeout timeout in ms to wait for callbacks, 0 to disable
|
2015-07-16 15:21:54 +00:00
|
|
|
* @param limits whether to check limits regarding IKE_SA initiation
|
2007-04-16 12:52:49 +00:00
|
|
|
* @return
|
|
|
|
* - SUCCESS, if CHILD_SA established
|
|
|
|
* - FAILED, if setup failed
|
|
|
|
* - NEED_MORE, if callback returned FALSE
|
2011-08-26 08:42:42 +00:00
|
|
|
* - OUT_OF_RES if timed out
|
2015-07-16 15:21:54 +00:00
|
|
|
* - INVALID_STATE if limits prevented initiation
|
2007-04-16 12:52:49 +00:00
|
|
|
*/
|
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,
|
2015-07-16 15:21:54 +00:00
|
|
|
controller_cb_t callback, void *param, u_int timeout,
|
|
|
|
bool limits);
|
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
|
|
|
*
|
2011-12-22 12:54:30 +00:00
|
|
|
* If a callback is provided the function is synchronous and thus blocks
|
|
|
|
* until the IKE_SA is properly deleted, or the call timed out.
|
2007-05-23 09:08:13 +00:00
|
|
|
*
|
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
|
2011-08-26 08:42:42 +00:00
|
|
|
* @param timeout timeout in ms to wait for callbacks, 0 to disable
|
2007-05-03 14:22:52 +00:00
|
|
|
* @return
|
|
|
|
* - SUCCESS, if CHILD_SA terminated
|
|
|
|
* - NOT_FOUND, if no such CHILD_SA found
|
|
|
|
* - NEED_MORE, if callback returned FALSE
|
2011-08-26 08:42:42 +00:00
|
|
|
* - OUT_OF_RES if timed out
|
2007-05-03 14:22:52 +00:00
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
status_t (*terminate_ike)(controller_t *this, uint32_t unique_id,
|
2011-08-26 08:42:42 +00:00
|
|
|
controller_cb_t callback, void *param,
|
|
|
|
u_int timeout);
|
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
|
|
|
*
|
2011-12-22 12:54:30 +00:00
|
|
|
* If a callback is provided the function is synchronous and thus blocks
|
|
|
|
* until the CHILD_SA is properly deleted, or the call timed out.
|
|
|
|
*
|
2014-10-27 13:03:32 +00:00
|
|
|
* @param unique_id CHILD_SA unique ID to terminate
|
2007-05-03 14:22:52 +00:00
|
|
|
* @param cb logging callback
|
|
|
|
* @param param parameter to include in each call of cb
|
2011-08-26 08:42:42 +00:00
|
|
|
* @param timeout timeout in ms to wait for callbacks, 0 to disable
|
2007-05-03 14:22:52 +00:00
|
|
|
* @return
|
|
|
|
* - SUCCESS, if CHILD_SA terminated
|
|
|
|
* - NOT_FOUND, if no such CHILD_SA found
|
|
|
|
* - NEED_MORE, if callback returned FALSE
|
2011-08-26 08:42:42 +00:00
|
|
|
* - OUT_OF_RES if timed out
|
2007-05-03 14:22:52 +00:00
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
status_t (*terminate_child)(controller_t *this, uint32_t unique_id,
|
2011-08-26 08:42:42 +00:00
|
|
|
controller_cb_t callback, void *param,
|
|
|
|
u_int timeout);
|
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
|
|
|
*/
|
2011-12-22 12:54:30 +00:00
|
|
|
controller_t *controller_create();
|
2007-04-11 13:01:08 +00:00
|
|
|
|
2009-03-24 17:43:01 +00:00
|
|
|
#endif /** CONTROLLER_H_ @}*/
|