Annotation of embedaddon/strongswan/src/libcharon/plugins/save_keys/save_keys_plugin.c, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2016 Codrut Cristian Grosu (codrut.cristian.grosu@gmail.com)
3: * Copyright (C) 2016 IXIA (http://www.ixiacom.com)
4: *
5: * Permission is hereby granted, free of charge, to any person obtaining a copy
6: * of this software and associated documentation files (the "Software"), to deal
7: * in the Software without restriction, including without limitation the rights
8: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9: * copies of the Software, and to permit persons to whom the Software is
10: * furnished to do so, subject to the following conditions:
11: *
12: * The above copyright notice and this permission notice shall be included in
13: * all copies or substantial portions of the Software.
14: *
15: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21: * THE SOFTWARE.
22: */
23:
24: #include "save_keys_plugin.h"
25: #include "save_keys_listener.h"
26:
27: #include <daemon.h>
28:
29: typedef struct private_save_keys_plugin_t private_save_keys_plugin_t;
30:
31: /**
32: * Private data.
33: */
34: struct private_save_keys_plugin_t {
35:
36: /**
37: * Implements plugin interface.
38: */
39: save_keys_plugin_t public;
40:
41: /**
42: * Listener saving keys to file.
43: */
44: save_keys_listener_t *listener;
45: };
46:
47: METHOD(plugin_t, get_name, char*,
48: private_save_keys_plugin_t *this)
49: {
50: return "save-keys";
51: }
52:
53: /**
54: * Register listener.
55: */
56: static bool plugin_cb(private_save_keys_plugin_t *this,
57: plugin_feature_t *feature, bool reg, void *cb_data)
58: {
59: if (reg)
60: {
61: charon->bus->add_listener(charon->bus, &this->listener->listener);
62: }
63: else
64: {
65: charon->bus->remove_listener(charon->bus, &this->listener->listener);
66: }
67: return TRUE;
68: }
69:
70: METHOD(plugin_t, get_features, int,
71: private_save_keys_plugin_t *this, plugin_feature_t *features[])
72: {
73: static plugin_feature_t f[] = {
74: PLUGIN_CALLBACK((plugin_feature_callback_t)plugin_cb, NULL),
75: PLUGIN_PROVIDE(CUSTOM, "save-keys"),
76: };
77: *features = f;
78: return countof(f);
79: }
80:
81: METHOD(plugin_t, destroy, void,
82: private_save_keys_plugin_t *this)
83: {
84: this->listener->destroy(this->listener);
85: free(this);
86: }
87:
88: /**
89: * Plugin constructor.
90: */
91: plugin_t *save_keys_plugin_create()
92: {
93: private_save_keys_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: .listener = save_keys_listener_create(),
104: );
105:
106: return &this->public.plugin;
107: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>