c4c6d80d2f0f272d4f920b102b52574718406c87
[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 crypto crypto
32 * @ingroup libstrongswan
33 *
34 * @defgroup database database
35 * @ingroup libstrongswan
36 *
37 * @defgroup fetcher fetcher
38 * @ingroup libstrongswan
39 *
40 * @defgroup plugins plugins
41 * @ingroup libstrongswan
42 *
43 * @defgroup utils utils
44 * @ingroup libstrongswan
45 */
46
47 /**
48 * @defgroup library library
49 * @{ @ingroup libstrongswan
50 */
51
52 #ifndef LIBRARY_H_
53 #define LIBRARY_H_
54
55 #include <printf_hook.h>
56 #include <utils.h>
57 #include <chunk.h>
58 #include <settings.h>
59 #include <integrity_checker.h>
60 #include <plugins/plugin_loader.h>
61 #include <crypto/crypto_factory.h>
62 #include <fetcher/fetcher_manager.h>
63 #include <database/database_factory.h>
64 #include <credentials/credential_factory.h>
65 #include <credentials/keys/key_encoding.h>
66
67 typedef struct library_t library_t;
68
69 /**
70 * Libstrongswan library context, contains library relevant globals.
71 */
72 struct library_t {
73
74 /**
75 * Printf hook registering facility
76 */
77 printf_hook_t *printf_hook;
78
79 /**
80 * crypto algorithm registry and factory
81 */
82 crypto_factory_t *crypto;
83
84 /**
85 * credential constructor registry and factory
86 */
87 credential_factory_t *creds;
88
89 /**
90 * key encoding registry and factory
91 */
92 key_encoding_t *encoding;
93
94 /**
95 * URL fetching facility
96 */
97 fetcher_manager_t *fetcher;
98
99 /**
100 * database construction factory
101 */
102 database_factory_t *db;
103
104 /**
105 * plugin loading facility
106 */
107 plugin_loader_t *plugins;
108
109 /**
110 * various settings loaded from settings file
111 */
112 settings_t *settings;
113
114 /**
115 * integrity checker to verify code integrity
116 */
117 integrity_checker_t *integrity;
118
119 /**
120 * is leak detective running?
121 */
122 bool leak_detective;
123 };
124
125 /**
126 * Initialize library, creates "lib" instance.
127 *
128 * @param settings file to read settings from, may be NULL for none
129 * @return FALSE if integrity check failed
130 */
131 bool library_init(char *settings);
132
133 /**
134 * Deinitialize library, destroys "lib" instance.
135 */
136 void library_deinit();
137
138 /**
139 * Library instance, set after between library_init() and library_deinit() calls.
140 */
141 extern library_t *lib;
142
143 #endif /** LIBRARY_H_ @}*/