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