07cd9c541331e8cee85e8966095825ac18516313
[strongswan.git] / src / charon / config / backend_manager.h
1 /**
2 * @file backend_manager.h
3 *
4 * @brief Interface backend_manager_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef BACKEND_MANAGER_H_
24 #define BACKEND_MANAGER_H_
25
26 typedef struct backend_manager_t backend_manager_t;
27
28 #include <library.h>
29 #include <utils/host.h>
30 #include <utils/identification.h>
31 #include <config/ike_cfg.h>
32 #include <config/peer_cfg.h>
33 #include <config/backends/backend.h>
34
35
36 /**
37 * @brief A multiplexer to use multiple backends.
38 *
39 * Charon allows the use of multiple backend_manager backends simultaneously. To
40 * access all this backends by a single call, this class wraps multiple
41 * backends behind a single object.
42 * Backends may be registered and unregister at runtime dynamically.
43 * @verbatim
44
45 +---------+ +-----------+ +--------------+ |
46 | | | | +--------------+ | |
47 | daemon |----->| backend_- | +--------------+ |-+ <==|==> IPC
48 | core | | manager |---->| backends |-+ |
49 | |----->| | +--------------+ |
50 | | | | |
51 +---------+ +-----------+ |
52
53 @endverbatim
54 *
55 * @b Constructors:
56 * - backend_manager_create()
57 *
58 * @ingroup config
59 */
60 struct backend_manager_t {
61
62 /**
63 * @brief Get an ike_config identified by two hosts.
64 *
65 * @param this calling object
66 * @param my_host address of own host
67 * @param other_host address of remote host
68 * @return matching ike_config, or NULL if none found
69 */
70 ike_cfg_t *(*get_ike_cfg)(backend_manager_t *this,
71 host_t *my_host, host_t *other_host);
72
73 /**
74 * @brief Get a peer_config identified by two IDs.
75 *
76 * @param this calling object
77 * @param my_id own ID
78 * @param other_id peers ID
79 * @return matching peer_config, or NULL if none found
80 */
81 peer_cfg_t *(*get_peer_cfg)(backend_manager_t *this, identification_t *my_id,
82 identification_t *other_id);
83
84 /**
85 * @brief Add a peer_config to the first found writable backend.
86 *
87 * @param this calling object
88 * @param config peer_config to add to the backend
89 */
90 void (*add_peer_cfg)(backend_manager_t *this, peer_cfg_t *config);
91
92 /**
93 * @brief Create an iterator over all peer configs of the writable backend.
94 *
95 * @param this calling object
96 * @return iterator over peer configs
97 */
98 iterator_t* (*create_iterator)(backend_manager_t *this);
99
100 /**
101 * @brief Destroys a backend_manager_t object.
102 *
103 * @param this calling object
104 */
105 void (*destroy) (backend_manager_t *this);
106 };
107
108 /**
109 * @brief Create a new instance of the manager and loads all backends.
110 *
111 * @return backend_manager instance
112 *
113 * @ingroup config
114 */
115 backend_manager_t *backend_manager_create(void);
116
117 #endif /*BACKEND_MANAGER_H_*/
118