Moved host_t and host_resolver_t to a new networking subfolder
[strongswan.git] / src / libcharon / 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
16 /**
17 * @defgroup backend_manager backend_manager
18 * @{ @ingroup config
19 */
20
21 #ifndef BACKEND_MANAGER_H_
22 #define BACKEND_MANAGER_H_
23
24 typedef struct backend_manager_t backend_manager_t;
25
26 #include <library.h>
27 #include <networking/host.h>
28 #include <utils/identification.h>
29 #include <config/ike_cfg.h>
30 #include <config/peer_cfg.h>
31 #include <config/backend.h>
32
33
34 /**
35 * A loader and multiplexer to use multiple backends.
36 *
37 * Charon allows the use of multiple configuration backends simultaneously. To
38 * access all this backends by a single call, this class wraps multiple
39 * backends behind a single object.
40 * @verbatim
41
42 +---------+ +-----------+ +--------------+ |
43 | | | | +--------------+ | |
44 | daemon |----->| backend_- | +--------------+ |-+ <==|==> IPC
45 | core | | manager |---->| backends |-+ |
46 | |----->| | +--------------+ |
47 | | | | |
48 +---------+ +-----------+ |
49
50 @endverbatim
51 */
52 struct backend_manager_t {
53
54 /**
55 * Get an ike_config identified by two hosts.
56 *
57 * @param my_host address of own host
58 * @param other_host address of remote host
59 * @param version IKE version to get a config for
60 * @return matching ike_config, or NULL if none found
61 */
62 ike_cfg_t* (*get_ike_cfg)(backend_manager_t *this,
63 host_t *my_host, host_t *other_host,
64 ike_version_t version);
65
66 /**
67 * Get a peer_config identified by it's name.
68 *
69 * @param name name of the peer_config
70 * @return matching peer_config, or NULL if none found
71 */
72 peer_cfg_t* (*get_peer_cfg_by_name)(backend_manager_t *this, char *name);
73
74 /**
75 * Create an enumerator over all matching peer configs.
76 *
77 * Pass NULL as parameters to match any. The enumerator enumerates over
78 * peer_cfgs, ordered by priority (best match first).
79 *
80 * @param me local address
81 * @param other remote address
82 * @param my_id IDr in first authentication round
83 * @param other_id IDi in first authentication round
84 * @param version IKE version to get a config for
85 * @return enumerator over peer_cfg_t
86 */
87 enumerator_t* (*create_peer_cfg_enumerator)(backend_manager_t *this,
88 host_t *me, host_t *other, identification_t *my_id,
89 identification_t *other_id, ike_version_t version);
90 /**
91 * Register a backend on the manager.
92 *
93 * @param backend backend to register
94 */
95 void (*add_backend)(backend_manager_t *this, backend_t *backend);
96
97 /**
98 * Unregister a backend.
99 *
100 * @param backend backend to unregister
101 */
102 void (*remove_backend)(backend_manager_t *this, backend_t *backend);
103
104 /**
105 * Destroys a backend_manager_t object.
106 */
107 void (*destroy) (backend_manager_t *this);
108 };
109
110 /**
111 * Create an instance of the backend manager
112 *
113 * @return backend_manager instance
114 */
115 backend_manager_t* backend_manager_create(void);
116
117 #endif /** BACKEND_MANAGER_H_ @}*/