7157499cee3b42cdd9f78f34abfa2846aa971891
[strongswan.git] / src / charon / config / backend_manager.h
1 /*
2 * Copyright (C) 2007 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * $Id$
16 */
17
18 /**
19 * @defgroup backend_manager backend_manager
20 * @{ @ingroup config
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/backend.h>
34
35
36 /**
37 * A loader and multiplexer to use multiple backends.
38 *
39 * Charon allows the use of multiple configuration backends simultaneously. To
40 * access all this backends by a single call, this class wraps multiple
41 * backends behind a single object.
42 * @verbatim
43
44 +---------+ +-----------+ +--------------+ |
45 | | | | +--------------+ | |
46 | daemon |----->| backend_- | +--------------+ |-+ <==|==> IPC
47 | core | | manager |---->| backends |-+ |
48 | |----->| | +--------------+ |
49 | | | | |
50 +---------+ +-----------+ |
51
52 @endverbatim
53 */
54 struct backend_manager_t {
55
56 /**
57 * Get an ike_config identified by two hosts.
58 *
59 * @param my_host address of own host
60 * @param other_host address of remote host
61 * @return matching ike_config, or NULL if none found
62 */
63 ike_cfg_t* (*get_ike_cfg)(backend_manager_t *this,
64 host_t *my_host, host_t *other_host);
65
66 /**
67 * Get a peer_config identified by two IDs and authorization info.
68 *
69 * @param me own address
70 * @param other peer address
71 * @param my_id own ID
72 * @param other_id peer ID
73 * @param auth_info authorization info
74 * @return matching peer_config, or NULL if none found
75 */
76 peer_cfg_t* (*get_peer_cfg)(backend_manager_t *this, host_t *me,
77 host_t *other, identification_t *my_id,
78 identification_t *other_id, auth_info_t *auth);
79
80 /**
81 * Get a peer_config identified by it's name.
82 *
83 * @param name name of the peer_config
84 * @return matching peer_config, or NULL if none found
85 */
86 peer_cfg_t* (*get_peer_cfg_by_name)(backend_manager_t *this, char *name);
87
88 /**
89 * Create an enumerator over all peer configs.
90 *
91 * @return enumerator over peer configs
92 */
93 enumerator_t* (*create_peer_cfg_enumerator)(backend_manager_t *this);
94
95 /**
96 * Register a backend on the manager.
97 *
98 * @param backend backend to register
99 */
100 void (*add_backend)(backend_manager_t *this, backend_t *backend);
101
102 /**
103 * Unregister a backend.
104 *
105 * @param backend backend to unregister
106 */
107 void (*remove_backend)(backend_manager_t *this, backend_t *backend);
108
109 /**
110 * Destroys a backend_manager_t object.
111 */
112 void (*destroy) (backend_manager_t *this);
113 };
114
115 /**
116 * Create an instance of the backend manager
117 *
118 * @return backend_manager instance
119 */
120 backend_manager_t* backend_manager_create(void);
121
122 #endif /*BACKEND_MANAGER_H_ @} */
123