Annotation of embedaddon/strongswan/src/libcharon/plugins/certexpire/certexpire_plugin.c, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2011 Martin Willi
! 3: * Copyright (C) 2011 revosec AG
! 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: #include "certexpire_plugin.h"
! 17:
! 18: #include "certexpire_listener.h"
! 19: #include "certexpire_export.h"
! 20:
! 21: #include <daemon.h>
! 22:
! 23: typedef struct private_certexpire_plugin_t private_certexpire_plugin_t;
! 24:
! 25: /**
! 26: * Private data of certexpire plugin
! 27: */
! 28: struct private_certexpire_plugin_t {
! 29:
! 30: /**
! 31: * Implements plugin interface
! 32: */
! 33: certexpire_plugin_t public;
! 34:
! 35: /**
! 36: * Listener collecting expire information
! 37: */
! 38: certexpire_listener_t *listener;
! 39:
! 40: /**
! 41: * Cache and export trustchain expire information
! 42: */
! 43: certexpire_export_t *export;
! 44: };
! 45:
! 46: METHOD(plugin_t, get_name, char*,
! 47: private_certexpire_plugin_t *this)
! 48: {
! 49: return "certexpire";
! 50: }
! 51:
! 52: /**
! 53: * Register listener
! 54: */
! 55: static bool plugin_cb(private_certexpire_plugin_t *this,
! 56: plugin_feature_t *feature, bool reg, void *cb_data)
! 57: {
! 58: if (reg)
! 59: {
! 60: charon->bus->add_listener(charon->bus, &this->listener->listener);
! 61: }
! 62: else
! 63: {
! 64: charon->bus->remove_listener(charon->bus, &this->listener->listener);
! 65: }
! 66: return TRUE;
! 67: }
! 68:
! 69: METHOD(plugin_t, get_features, int,
! 70: private_certexpire_plugin_t *this, plugin_feature_t *features[])
! 71: {
! 72: static plugin_feature_t f[] = {
! 73: PLUGIN_CALLBACK((plugin_feature_callback_t)plugin_cb, NULL),
! 74: PLUGIN_PROVIDE(CUSTOM, "certexpire"),
! 75: };
! 76: *features = f;
! 77: return countof(f);
! 78: }
! 79:
! 80: METHOD(plugin_t, destroy, void,
! 81: private_certexpire_plugin_t *this)
! 82: {
! 83: this->listener->destroy(this->listener);
! 84: this->export->destroy(this->export);
! 85: free(this);
! 86: }
! 87:
! 88: /**
! 89: * Plugin constructor
! 90: */
! 91: plugin_t *certexpire_plugin_create()
! 92: {
! 93: private_certexpire_plugin_t *this;
! 94:
! 95: INIT(this,
! 96: .public = {
! 97: .plugin = {
! 98: .get_name = _get_name,
! 99: .get_features = _get_features,
! 100: .destroy = _destroy,
! 101: },
! 102: },
! 103: .export = certexpire_export_create(),
! 104: );
! 105: this->listener = certexpire_listener_create(this->export);
! 106:
! 107: return &this->public.plugin;
! 108: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>