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