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