Added possibility to register custom proposal keywords
[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 "crypto/proposal/proposal_keywords.h"
86 #include "fetcher/fetcher_manager.h"
87 #include "database/database_factory.h"
88 #include "credentials/credential_factory.h"
89 #include "credentials/credential_manager.h"
90 #include "credentials/cred_encoding.h"
91 #include "utils/leak_detective.h"
92 #include "plugins/plugin_loader.h"
93
94 typedef struct library_t library_t;
95
96 /**
97 * Libstrongswan library context, contains library relevant globals.
98 */
99 struct library_t {
100
101 /**
102 * Get an arbitrary object registered by name.
103 *
104 * @param name name of the object to get
105 * @return object, NULL if none found
106 */
107 void* (*get)(library_t *this, char *name);
108
109 /**
110 * (Un-)Register an arbitrary object using the given name.
111 *
112 * @param name name to register object under
113 * @param object object to register, NULL to unregister
114 * @return TRUE if registered, FALSE if name already taken
115 */
116 bool (*set)(library_t *this, char *name, void *object);
117
118 /**
119 * Printf hook registering facility
120 */
121 printf_hook_t *printf_hook;
122
123 /**
124 * Proposal keywords registry
125 */
126 proposal_keywords_t *proposal;
127
128 /**
129 * crypto algorithm registry and factory
130 */
131 crypto_factory_t *crypto;
132
133 /**
134 * credential constructor registry and factory
135 */
136 credential_factory_t *creds;
137
138 /**
139 * Manager for the credential set backends
140 */
141 credential_manager_t *credmgr;
142
143 /**
144 * Credential encoding registry and factory
145 */
146 cred_encoding_t *encoding;
147
148 /**
149 * URL fetching facility
150 */
151 fetcher_manager_t *fetcher;
152
153 /**
154 * database construction factory
155 */
156 database_factory_t *db;
157
158 /**
159 * plugin loading facility
160 */
161 plugin_loader_t *plugins;
162
163 /**
164 * process jobs using a thread pool
165 */
166 processor_t *processor;
167
168 /**
169 * schedule jobs
170 */
171 scheduler_t *scheduler;
172
173 /**
174 * various settings loaded from settings file
175 */
176 settings_t *settings;
177
178 /**
179 * integrity checker to verify code integrity
180 */
181 integrity_checker_t *integrity;
182
183 /**
184 * Leak detective, if built and enabled
185 */
186 leak_detective_t *leak_detective;
187 };
188
189 /**
190 * Initialize library, creates "lib" instance.
191 *
192 * @param settings file to read settings from, may be NULL for default
193 * @return FALSE if integrity check failed
194 */
195 bool library_init(char *settings);
196
197 /**
198 * Deinitialize library, destroys "lib" instance.
199 */
200 void library_deinit();
201
202 /**
203 * Library instance, set after library_init() and before library_deinit() calls.
204 */
205 extern library_t *lib;
206
207 #endif /** LIBRARY_H_ @}*/