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_logger.h"
27 typedef struct private_vici_plugin_t private_vici_plugin_t
;
30 * Private members of vici_plugin_t
32 struct private_vici_plugin_t
{
40 * Dispatcher, creating socket
42 vici_dispatcher_t
*dispatcher
;
52 vici_control_t
*control
;
60 * Configuration backend
62 vici_config_t
*config
;
65 * Generic debug logger
67 vici_logger_t
*logger
;
70 METHOD(plugin_t
, get_name
, char*,
71 private_vici_plugin_t
*this)
77 * Register vici plugin features
79 static bool register_vici(private_vici_plugin_t
*this,
80 plugin_feature_t
*feature
, bool reg
, void *data
)
86 uri
= lib
->settings
->get_str(lib
->settings
, "%s.plugins.vici.socket",
87 VICI_DEFAULT_URI
, lib
->ns
);
88 this->dispatcher
= vici_dispatcher_create(uri
);
91 this->query
= vici_query_create(this->dispatcher
);
92 this->control
= vici_control_create(this->dispatcher
);
93 this->cred
= vici_cred_create(this->dispatcher
);
94 this->config
= vici_config_create(this->dispatcher
);
95 this->logger
= vici_logger_create(this->dispatcher
);
97 charon
->backends
->add_backend(charon
->backends
,
98 &this->config
->backend
);
99 charon
->bus
->add_logger(charon
->bus
, &this->logger
->logger
);
106 charon
->bus
->remove_logger(charon
->bus
, &this->logger
->logger
);
107 charon
->backends
->remove_backend(charon
->backends
,
108 &this->config
->backend
);
110 this->logger
->destroy(this->logger
);
111 this->config
->destroy(this->config
);
112 this->cred
->destroy(this->cred
);
113 this->control
->destroy(this->control
);
114 this->query
->destroy(this->query
);
115 this->dispatcher
->destroy(this->dispatcher
);
120 METHOD(plugin_t
, get_features
, int,
121 private_vici_plugin_t
*this, plugin_feature_t
*features
[])
123 static plugin_feature_t f
[] = {
124 PLUGIN_CALLBACK((plugin_feature_callback_t
)register_vici
, NULL
),
125 PLUGIN_PROVIDE(CUSTOM
, "vici"),
131 METHOD(plugin_t
, destroy
, void,
132 private_vici_plugin_t
*this)
140 plugin_t
*vici_plugin_create()
142 private_vici_plugin_t
*this;
147 .get_name
= _get_name
,
148 .reload
= (void*)return_false
,
149 .get_features
= _get_features
,
155 return &this->public.plugin
;