04a4301bf402c2ab5fca464c8fe8b68c94dc4d32
[strongswan.git] / src / charon / config / cfg_store.h
1 /**
2 * @file cfg_store.h
3 *
4 * @brief Interface cfg_store_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 CFG_STORE_H_
24 #define CFG_STORE_H_
25
26 typedef struct cfg_store_t cfg_store_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 cfg_store backends.
38 *
39 * Charon allows the use of multiple cfg_store 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 *
44 * +---------+ +---------+ +--------------+ |
45 * | | | | +--------------+ | |
46 * | |----->| config | +--------------+ |-+ <==|==> IPC
47 * | | | |------>| backends |-+ |
48 * | daemon |----->| | +--------------+ |
49 * | core | +---------+ |
50 * | | |
51 * | | +---------+ +--------------+ |
52 * | |<-----| | +--------------+ | |
53 * | | | control-| +--------------+ |-+ <==|==> IPC
54 * | |<-----| ler |------>| controllers |-+ |
55 * | | | | +--------------+ |
56 * +---------+ +---------+ |
57 *
58 * The daemon core only knows the simple and single cfg_store interface.
59 * The cfg_store wraps two kind of objects, backends and trustchains.
60 * If the daemon needs something, it asks the cfg_store. cfg_store
61 * asks all of its backends if they can fullfil the request.
62 *
63 *
64 * @b Constructors:
65 * - stroke_create()
66 *
67 * @ingroup config
68 */
69 struct cfg_store_t {
70
71 /**
72 * @brief Get an ike_config identified by two hosts.
73 *
74 * @param this calling object
75 * @param my_host address of own host
76 * @param other_host address of remote host
77 * @return matching ike_config, or NULL if none found
78 */
79 ike_cfg_t *(*get_ike_cfg)(cfg_store_t *this,
80 host_t *my_host, host_t *other_host);
81
82 /**
83 * @brief Get a peer_config identified by two IDs.
84 *
85 * @param this calling object
86 * @param my_id own ID
87 * @param other_id peers ID
88 * @return matching peer_config, or NULL if none found
89 */
90 peer_cfg_t *(*get_peer_cfg)(cfg_store_t *this, identification_t *my_id,
91 identification_t *other_id);
92
93 /**
94 * @brief Register a backend to be queried by the calls above.
95 *
96 * The backend first added is the most preferred.
97 *
98 * @param this calling object
99 */
100 void (*register_backend) (cfg_store_t *this, backend_t *backend);
101
102 /**
103 * @brief Unregister a backend.
104 *
105 * @param this calling object
106 */
107 void (*unregister_backend) (cfg_store_t *this, backend_t *backend);
108
109 /**
110 * @brief Destroys a cfg_store_t object.
111 *
112 * @param this calling object
113 */
114 void (*destroy) (cfg_store_t *this);
115 };
116
117 /**
118 * @brief Create a new instance of the store.
119 *
120 * @return cfg_store instance
121 *
122 * @ingroup config
123 */
124 cfg_store_t *cfg_store_create(void);
125
126 #endif /*CFG_STORE_H_*/