Register a certexpire listener collecting trustchain information
[strongswan.git] / src / libcharon / plugins / certexpire / certexpire_plugin.c
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
20 #include <daemon.h>
21
22 typedef struct private_certexpire_plugin_t private_certexpire_plugin_t;
23
24 /**
25 * Private data of certexpire plugin
26 */
27 struct private_certexpire_plugin_t {
28
29 /**
30 * Implements plugin interface
31 */
32 certexpire_plugin_t public;
33
34 /**
35 * Listener collecting expire information
36 */
37 certexpire_listener_t *listener;
38 };
39
40 METHOD(plugin_t, get_name, char*,
41 private_certexpire_plugin_t *this)
42 {
43 return "certexpire";
44 }
45
46 METHOD(plugin_t, destroy, void,
47 private_certexpire_plugin_t *this)
48 {
49 charon->bus->remove_listener(charon->bus, &this->listener->listener);
50 this->listener->destroy(this->listener);
51 free(this);
52 }
53
54 /**
55 * Plugin constructor
56 */
57 plugin_t *certexpire_plugin_create()
58 {
59 private_certexpire_plugin_t *this;
60
61 INIT(this,
62 .public = {
63 .plugin = {
64 .get_name = _get_name,
65 .reload = (void*)return_false,
66 .destroy = _destroy,
67 },
68 },
69 .listener = certexpire_listener_create(),
70 );
71 charon->bus->add_listener(charon->bus, &this->listener->listener);
72
73 return &this->public.plugin;
74 }