2 * Copyright (C) 2014 Martin Willi
3 * Copyright (C) 2014 revosec AG
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>.
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
16 #include "vici_plugin.h"
17 #include "vici_dispatcher.h"
18 #include "vici_query.h"
19 #include "vici_control.h"
20 #include "vici_cred.h"
21 #include "vici_config.h"
22 #include "vici_attribute.h"
23 #include "vici_logger.h"
29 typedef struct private_vici_plugin_t private_vici_plugin_t
;
32 * Private members of vici_plugin_t
34 struct private_vici_plugin_t
{
42 * Dispatcher, creating socket
44 vici_dispatcher_t
*dispatcher
;
54 vici_control_t
*control
;
62 * Configuration backend
64 vici_config_t
*config
;
67 * IKE attribute backend
69 vici_attribute_t
*attrs
;
72 * Generic debug logger
74 vici_logger_t
*logger
;
77 METHOD(plugin_t
, get_name
, char*,
78 private_vici_plugin_t
*this)
84 * Register vici plugin features
86 static bool register_vici(private_vici_plugin_t
*this,
87 plugin_feature_t
*feature
, bool reg
, void *data
)
93 uri
= lib
->settings
->get_str(lib
->settings
, "%s.plugins.vici.socket",
94 VICI_DEFAULT_URI
, lib
->ns
);
95 this->dispatcher
= vici_dispatcher_create(uri
);
98 this->query
= vici_query_create(this->dispatcher
);
99 this->control
= vici_control_create(this->dispatcher
);
100 this->cred
= vici_cred_create(this->dispatcher
);
101 this->config
= vici_config_create(this->dispatcher
);
102 this->attrs
= vici_attribute_create(this->dispatcher
);
103 this->logger
= vici_logger_create(this->dispatcher
);
105 charon
->backends
->add_backend(charon
->backends
,
106 &this->config
->backend
);
107 hydra
->attributes
->add_provider(hydra
->attributes
,
108 &this->attrs
->provider
);
109 charon
->bus
->add_logger(charon
->bus
, &this->logger
->logger
);
116 charon
->bus
->remove_logger(charon
->bus
, &this->logger
->logger
);
117 hydra
->attributes
->remove_provider(hydra
->attributes
,
118 &this->attrs
->provider
);
119 charon
->backends
->remove_backend(charon
->backends
,
120 &this->config
->backend
);
122 this->logger
->destroy(this->logger
);
123 this->attrs
->destroy(this->attrs
);
124 this->config
->destroy(this->config
);
125 this->cred
->destroy(this->cred
);
126 this->control
->destroy(this->control
);
127 this->query
->destroy(this->query
);
128 this->dispatcher
->destroy(this->dispatcher
);
133 METHOD(plugin_t
, get_features
, int,
134 private_vici_plugin_t
*this, plugin_feature_t
*features
[])
136 static plugin_feature_t f
[] = {
137 PLUGIN_CALLBACK((plugin_feature_callback_t
)register_vici
, NULL
),
138 PLUGIN_PROVIDE(CUSTOM
, "vici"),
144 METHOD(plugin_t
, destroy
, void,
145 private_vici_plugin_t
*this)
153 plugin_t
*vici_plugin_create()
155 private_vici_plugin_t
*this;
160 .get_name
= _get_name
,
161 .reload
= (void*)return_false
,
162 .get_features
= _get_features
,
168 return &this->public.plugin
;