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