d5497258aa0af048b4b78b9356f8d39c9f6c5903
[strongswan.git] / src / libstrongswan / library.h
1 /*
2 * Copyright (C) 2008 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 libstrongswan libstrongswan
18 *
19 * @defgroup asn1 asn1
20 * @ingroup libstrongswan
21 *
22 * @defgroup bio bio
23 * @ingroup libstrongswan
24 *
25 * @defgroup collections collections
26 * @ingroup libstrongswan
27 *
28 * @defgroup credentials credentials
29 * @ingroup libstrongswan
30 *
31 * @defgroup keys keys
32 * @ingroup credentials
33 *
34 * @defgroup certificates certificates
35 * @ingroup credentials
36 *
37 * @defgroup containers containers
38 * @ingroup credentials
39 *
40 * @defgroup sets sets
41 * @ingroup credentials
42 *
43 * @defgroup crypto crypto
44 * @ingroup libstrongswan
45 *
46 * @defgroup database database
47 * @ingroup libstrongswan
48 *
49 * @defgroup fetcher fetcher
50 * @ingroup libstrongswan
51 *
52 * @defgroup resolver resolver
53 * @ingroup libstrongswan
54 *
55 * @defgroup ipsec ipsec
56 * @ingroup libstrongswan
57 *
58 * @defgroup networking networking
59 * @ingroup libstrongswan
60 *
61 * @defgroup plugins plugins
62 * @ingroup libstrongswan
63 *
64 * @defgroup processing processing
65 * @ingroup libstrongswan
66 *
67 * @defgroup jobs jobs
68 * @ingroup processing
69 *
70 * @defgroup threading threading
71 * @ingroup libstrongswan
72 *
73 * @defgroup utils utils
74 * @ingroup libstrongswan
75 */
76
77 /**
78 * @defgroup library library
79 * @{ @ingroup libstrongswan
80 */
81
82 #ifndef LIBRARY_H_
83 #define LIBRARY_H_
84
85 #ifndef CONFIG_H_INCLUDED
86 # error config.h not included, pass "-include [...]/config.h" to gcc
87 #endif
88
89 /* make sure we include printf_hook.h and utils.h first */
90 #include "utils/printf_hook.h"
91 #include "utils/utils.h"
92 #include "networking/host_resolver.h"
93 #include "processing/processor.h"
94 #include "processing/scheduler.h"
95 #include "processing/watcher.h"
96 #include "crypto/crypto_factory.h"
97 #include "crypto/proposal/proposal_keywords.h"
98 #include "fetcher/fetcher_manager.h"
99 #include "resolver/resolver_manager.h"
100 #include "database/database_factory.h"
101 #include "credentials/credential_factory.h"
102 #include "credentials/credential_manager.h"
103 #include "credentials/cred_encoding.h"
104 #include "utils/chunk.h"
105 #include "utils/capabilities.h"
106 #include "utils/integrity_checker.h"
107 #include "utils/leak_detective.h"
108 #include "utils/settings.h"
109 #include "plugins/plugin_loader.h"
110
111 typedef struct library_t library_t;
112
113 /**
114 * Libstrongswan library context, contains library relevant globals.
115 */
116 struct library_t {
117
118 /**
119 * Get an arbitrary object registered by name.
120 *
121 * @param name name of the object to get
122 * @return object, NULL if none found
123 */
124 void* (*get)(library_t *this, char *name);
125
126 /**
127 * (Un-)Register an arbitrary object using the given name.
128 *
129 * @param name name to register object under
130 * @param object object to register, NULL to unregister
131 * @return TRUE if registered, FALSE if name already taken
132 */
133 bool (*set)(library_t *this, char *name, void *object);
134
135 /**
136 * Printf hook registering facility
137 */
138 printf_hook_t *printf_hook;
139
140 /**
141 * Proposal keywords registry
142 */
143 proposal_keywords_t *proposal;
144
145 /**
146 * POSIX capability dropping
147 */
148 capabilities_t *caps;
149
150 /**
151 * crypto algorithm registry and factory
152 */
153 crypto_factory_t *crypto;
154
155 /**
156 * credential constructor registry and factory
157 */
158 credential_factory_t *creds;
159
160 /**
161 * Manager for the credential set backends
162 */
163 credential_manager_t *credmgr;
164
165 /**
166 * Credential encoding registry and factory
167 */
168 cred_encoding_t *encoding;
169
170 /**
171 * URL fetching facility
172 */
173 fetcher_manager_t *fetcher;
174
175 /**
176 * Manager for DNS resolvers
177 */
178 resolver_manager_t *resolver;
179
180 /**
181 * database construction factory
182 */
183 database_factory_t *db;
184
185 /**
186 * plugin loading facility
187 */
188 plugin_loader_t *plugins;
189
190 /**
191 * process jobs using a thread pool
192 */
193 processor_t *processor;
194
195 /**
196 * schedule jobs
197 */
198 scheduler_t *scheduler;
199
200 /**
201 * File descriptor monitoring
202 */
203 watcher_t *watcher;
204
205 /**
206 * resolve hosts by DNS name
207 */
208 host_resolver_t *hosts;
209
210 /**
211 * various settings loaded from settings file
212 */
213 settings_t *settings;
214
215 /**
216 * integrity checker to verify code integrity
217 */
218 integrity_checker_t *integrity;
219
220 /**
221 * Leak detective, if built and enabled
222 */
223 leak_detective_t *leak_detective;
224 };
225
226 /**
227 * Initialize library, creates "lib" instance.
228 *
229 * library_init() may be called multiple times in a single process, but each
230 * caller should call library_deinit() for each call to library_init().
231 *
232 * @param settings file to read settings from, may be NULL for default
233 * @return FALSE if integrity check failed
234 */
235 bool library_init(char *settings);
236
237 /**
238 * Deinitialize library, destroys "lib" instance.
239 */
240 void library_deinit();
241
242 /**
243 * Library instance, set after library_init() and before library_deinit() calls.
244 */
245 extern library_t *lib;
246
247 #endif /** LIBRARY_H_ @}*/