2 * Copyright (C) 2010-2018 Tobias Brunner
3 * Copyright (C) 2008 Martin Willi
4 * HSR Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * @defgroup libstrongswan libstrongswan
21 * @ingroup libstrongswan
24 * @ingroup libstrongswan
26 * @defgroup collections collections
27 * @ingroup libstrongswan
29 * @defgroup credentials credentials
30 * @ingroup libstrongswan
33 * @ingroup credentials
35 * @defgroup certificates certificates
36 * @ingroup credentials
38 * @defgroup containers containers
39 * @ingroup credentials
42 * @ingroup credentials
44 * @defgroup crypto crypto
45 * @ingroup libstrongswan
47 * @defgroup database database
48 * @ingroup libstrongswan
50 * @defgroup fetcher fetcher
51 * @ingroup libstrongswan
53 * @defgroup resolver resolver
54 * @ingroup libstrongswan
56 * @defgroup ipsec ipsec
57 * @ingroup libstrongswan
59 * @defgroup networking networking
60 * @ingroup libstrongswan
62 * @defgroup streams streams
65 * @defgroup plugins plugins
66 * @ingroup libstrongswan
68 * @defgroup processing processing
69 * @ingroup libstrongswan
74 * @defgroup selectors selectors
75 * @ingroup libstrongswan
77 * @defgroup threading threading
78 * @ingroup libstrongswan
80 * @defgroup utils utils
81 * @ingroup libstrongswan
83 * @defgroup compat compat
88 * @defgroup library library
89 * @{ @ingroup libstrongswan
95 #ifndef CONFIG_H_INCLUDED
96 # error config.h not included, pass "-include [...]/config.h" to gcc
99 /* make sure we include printf_hook.h and utils.h first */
100 #include "utils/printf_hook/printf_hook.h"
101 #include "utils/utils.h"
102 #include "networking/host_resolver.h"
103 #include "networking/streams/stream_manager.h"
104 #include "processing/processor.h"
105 #include "processing/scheduler.h"
106 #include "processing/watcher.h"
107 #include "crypto/crypto_factory.h"
108 #include "crypto/proposal/proposal_keywords.h"
109 #include "fetcher/fetcher_manager.h"
110 #include "resolver/resolver_manager.h"
111 #include "database/database_factory.h"
112 #include "credentials/credential_factory.h"
113 #include "credentials/credential_manager.h"
114 #include "credentials/cred_encoding.h"
115 #include "metadata/metadata_factory.h"
116 #include "utils/chunk.h"
117 #include "utils/capabilities.h"
118 #include "utils/integrity_checker.h"
119 #include "utils/leak_detective.h"
120 #include "plugins/plugin_loader.h"
121 #include "settings/settings.h"
123 typedef struct library_t library_t
;
126 * Libstrongswan library context, contains library relevant globals.
131 * Get an arbitrary object registered by name.
133 * @param name name of the object to get
134 * @return object, NULL if none found
136 void* (*get
)(library_t
*this, char *name
);
139 * (Un-)Register an arbitrary object using the given name.
141 * @param name name to register object under
142 * @param object object to register, NULL to unregister
143 * @return TRUE if registered, FALSE if name already taken
145 bool (*set
)(library_t
*this, char *name
, void *object
);
148 * Namespace used for settings etc. (i.e. the name of the binary that uses
154 * Main configuration file passed to library_init(), the default, or NULL
159 * Printf hook registering facility
161 printf_hook_t
*printf_hook
;
164 * Proposal keywords registry
166 proposal_keywords_t
*proposal
;
169 * POSIX capability dropping
171 capabilities_t
*caps
;
174 * crypto algorithm registry and factory
176 crypto_factory_t
*crypto
;
179 * credential constructor registry and factory
181 credential_factory_t
*creds
;
184 * Manager for the credential set backends
186 credential_manager_t
*credmgr
;
189 * Credential encoding registry and factory
191 cred_encoding_t
*encoding
;
194 * Registry and factory for metadata creation
196 metadata_factory_t
*metadata
;
199 * URL fetching facility
201 fetcher_manager_t
*fetcher
;
204 * Manager for DNS resolvers
206 resolver_manager_t
*resolver
;
209 * database construction factory
211 database_factory_t
*db
;
214 * plugin loading facility
216 plugin_loader_t
*plugins
;
219 * process jobs using a thread pool
221 processor_t
*processor
;
226 scheduler_t
*scheduler
;
229 * File descriptor monitoring
234 * Streams and Services
236 stream_manager_t
*streams
;
239 * resolve hosts by DNS name
241 host_resolver_t
*hosts
;
244 * various settings loaded from settings file
246 settings_t
*settings
;
249 * integrity checker to verify code integrity
251 integrity_checker_t
*integrity
;
254 * Leak detective, if built and enabled
256 leak_detective_t
*leak_detective
;
260 * Initialize library, creates "lib" instance.
262 * library_init() may be called multiple times in a single process, but each
263 * caller must call library_deinit() for each call to library_init().
265 * The settings and namespace arguments are only used on the first call.
267 * @param settings file to read settings from, may be NULL for default or
268 * "" to not load any settings
269 * @param namespace name of the binary that uses the library, determines
270 * the first section name when reading config options.
271 * Defaults to libstrongswan if NULL.
272 * @return FALSE if integrity check failed or settings are invalid
274 bool library_init(char *settings
, const char *namespace);
277 * Deinitialize library, destroys "lib" instance.
279 void library_deinit();
282 * Library instance, set after library_init() and before library_deinit() calls.
284 extern library_t
*lib
;
287 * Add additional names used as alias for the namespace registered with
290 * To be called from __attribute__((constructor)) functions.
292 * @param ns additional namespace
294 void library_add_namespace(char *ns
);
296 #endif /** LIBRARY_H_ @}*/