Annotation of embedaddon/strongswan/src/libstrongswan/library.h, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2010-2018 Tobias Brunner
! 3: * Copyright (C) 2008 Martin Willi
! 4: * HSR Hochschule fuer Technik Rapperswil
! 5: *
! 6: * This program is free software; you can redistribute it and/or modify it
! 7: * under the terms of the GNU General Public License as published by the
! 8: * Free Software Foundation; either version 2 of the License, or (at your
! 9: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
! 10: *
! 11: * This program is distributed in the hope that it will be useful, but
! 12: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 13: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
! 14: * for more details.
! 15: */
! 16:
! 17: /**
! 18: * @defgroup libstrongswan libstrongswan
! 19: *
! 20: * @defgroup asn1 asn1
! 21: * @ingroup libstrongswan
! 22: *
! 23: * @defgroup bio bio
! 24: * @ingroup libstrongswan
! 25: *
! 26: * @defgroup collections collections
! 27: * @ingroup libstrongswan
! 28: *
! 29: * @defgroup credentials credentials
! 30: * @ingroup libstrongswan
! 31: *
! 32: * @defgroup keys keys
! 33: * @ingroup credentials
! 34: *
! 35: * @defgroup certificates certificates
! 36: * @ingroup credentials
! 37: *
! 38: * @defgroup containers containers
! 39: * @ingroup credentials
! 40: *
! 41: * @defgroup sets sets
! 42: * @ingroup credentials
! 43: *
! 44: * @defgroup crypto crypto
! 45: * @ingroup libstrongswan
! 46: *
! 47: * @defgroup database database
! 48: * @ingroup libstrongswan
! 49: *
! 50: * @defgroup fetcher fetcher
! 51: * @ingroup libstrongswan
! 52: *
! 53: * @defgroup resolver resolver
! 54: * @ingroup libstrongswan
! 55: *
! 56: * @defgroup ipsec ipsec
! 57: * @ingroup libstrongswan
! 58: *
! 59: * @defgroup networking networking
! 60: * @ingroup libstrongswan
! 61: *
! 62: * @defgroup streams streams
! 63: * @ingroup networking
! 64: *
! 65: * @defgroup plugins plugins
! 66: * @ingroup libstrongswan
! 67: *
! 68: * @defgroup processing processing
! 69: * @ingroup libstrongswan
! 70: *
! 71: * @defgroup jobs jobs
! 72: * @ingroup processing
! 73: *
! 74: * @defgroup selectors selectors
! 75: * @ingroup libstrongswan
! 76: *
! 77: * @defgroup threading threading
! 78: * @ingroup libstrongswan
! 79: *
! 80: * @defgroup utils utils
! 81: * @ingroup libstrongswan
! 82: *
! 83: * @defgroup compat compat
! 84: * @ingroup utils
! 85: */
! 86:
! 87: /**
! 88: * @defgroup library library
! 89: * @{ @ingroup libstrongswan
! 90: */
! 91:
! 92: #ifndef LIBRARY_H_
! 93: #define LIBRARY_H_
! 94:
! 95: #ifndef CONFIG_H_INCLUDED
! 96: # error config.h not included, pass "-include [...]/config.h" to gcc
! 97: #endif
! 98:
! 99: /* make sure we include printf_hook.h and utils.h first */
! 100: #include "utils/printf_hook/printf_hook.h"
! 101: #include "utils/utils.h"
! 102: #include "networking/host_resolver.h"
! 103: #include "networking/streams/stream_manager.h"
! 104: #include "processing/processor.h"
! 105: #include "processing/scheduler.h"
! 106: #include "processing/watcher.h"
! 107: #include "crypto/crypto_factory.h"
! 108: #include "crypto/proposal/proposal_keywords.h"
! 109: #include "fetcher/fetcher_manager.h"
! 110: #include "resolver/resolver_manager.h"
! 111: #include "database/database_factory.h"
! 112: #include "credentials/credential_factory.h"
! 113: #include "credentials/credential_manager.h"
! 114: #include "credentials/cred_encoding.h"
! 115: #include "utils/chunk.h"
! 116: #include "utils/capabilities.h"
! 117: #include "utils/integrity_checker.h"
! 118: #include "utils/leak_detective.h"
! 119: #include "plugins/plugin_loader.h"
! 120: #include "settings/settings.h"
! 121:
! 122: typedef struct library_t library_t;
! 123:
! 124: /**
! 125: * Libstrongswan library context, contains library relevant globals.
! 126: */
! 127: struct library_t {
! 128:
! 129: /**
! 130: * Get an arbitrary object registered by name.
! 131: *
! 132: * @param name name of the object to get
! 133: * @return object, NULL if none found
! 134: */
! 135: void* (*get)(library_t *this, char *name);
! 136:
! 137: /**
! 138: * (Un-)Register an arbitrary object using the given name.
! 139: *
! 140: * @param name name to register object under
! 141: * @param object object to register, NULL to unregister
! 142: * @return TRUE if registered, FALSE if name already taken
! 143: */
! 144: bool (*set)(library_t *this, char *name, void *object);
! 145:
! 146: /**
! 147: * Namespace used for settings etc. (i.e. the name of the binary that uses
! 148: * the library)
! 149: */
! 150: const char *ns;
! 151:
! 152: /**
! 153: * Main configuration file passed to library_init(), the default, or NULL
! 154: */
! 155: char *conf;
! 156:
! 157: /**
! 158: * Printf hook registering facility
! 159: */
! 160: printf_hook_t *printf_hook;
! 161:
! 162: /**
! 163: * Proposal keywords registry
! 164: */
! 165: proposal_keywords_t *proposal;
! 166:
! 167: /**
! 168: * POSIX capability dropping
! 169: */
! 170: capabilities_t *caps;
! 171:
! 172: /**
! 173: * crypto algorithm registry and factory
! 174: */
! 175: crypto_factory_t *crypto;
! 176:
! 177: /**
! 178: * credential constructor registry and factory
! 179: */
! 180: credential_factory_t *creds;
! 181:
! 182: /**
! 183: * Manager for the credential set backends
! 184: */
! 185: credential_manager_t *credmgr;
! 186:
! 187: /**
! 188: * Credential encoding registry and factory
! 189: */
! 190: cred_encoding_t *encoding;
! 191:
! 192: /**
! 193: * URL fetching facility
! 194: */
! 195: fetcher_manager_t *fetcher;
! 196:
! 197: /**
! 198: * Manager for DNS resolvers
! 199: */
! 200: resolver_manager_t *resolver;
! 201:
! 202: /**
! 203: * database construction factory
! 204: */
! 205: database_factory_t *db;
! 206:
! 207: /**
! 208: * plugin loading facility
! 209: */
! 210: plugin_loader_t *plugins;
! 211:
! 212: /**
! 213: * process jobs using a thread pool
! 214: */
! 215: processor_t *processor;
! 216:
! 217: /**
! 218: * schedule jobs
! 219: */
! 220: scheduler_t *scheduler;
! 221:
! 222: /**
! 223: * File descriptor monitoring
! 224: */
! 225: watcher_t *watcher;
! 226:
! 227: /**
! 228: * Streams and Services
! 229: */
! 230: stream_manager_t *streams;
! 231:
! 232: /**
! 233: * resolve hosts by DNS name
! 234: */
! 235: host_resolver_t *hosts;
! 236:
! 237: /**
! 238: * various settings loaded from settings file
! 239: */
! 240: settings_t *settings;
! 241:
! 242: /**
! 243: * integrity checker to verify code integrity
! 244: */
! 245: integrity_checker_t *integrity;
! 246:
! 247: /**
! 248: * Leak detective, if built and enabled
! 249: */
! 250: leak_detective_t *leak_detective;
! 251: };
! 252:
! 253: /**
! 254: * Initialize library, creates "lib" instance.
! 255: *
! 256: * library_init() may be called multiple times in a single process, but each
! 257: * caller must call library_deinit() for each call to library_init().
! 258: *
! 259: * The settings and namespace arguments are only used on the first call.
! 260: *
! 261: * @param settings file to read settings from, may be NULL for default or
! 262: * "" to not load any settings
! 263: * @param namespace name of the binary that uses the library, determines
! 264: * the first section name when reading config options.
! 265: * Defaults to libstrongswan if NULL.
! 266: * @return FALSE if integrity check failed or settings are invalid
! 267: */
! 268: bool library_init(char *settings, const char *namespace);
! 269:
! 270: /**
! 271: * Deinitialize library, destroys "lib" instance.
! 272: */
! 273: void library_deinit();
! 274:
! 275: /**
! 276: * Library instance, set after library_init() and before library_deinit() calls.
! 277: */
! 278: extern library_t *lib;
! 279:
! 280: /**
! 281: * Add additional names used as alias for the namespace registered with
! 282: * library_init().
! 283: *
! 284: * To be called from __attribute__((constructor)) functions.
! 285: *
! 286: * @param ns additional namespace
! 287: */
! 288: void library_add_namespace(char *ns);
! 289:
! 290: #endif /** LIBRARY_H_ @}*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>