diff options
author | Tobias Brunner <tobias@strongswan.org> | 2013-06-07 18:52:33 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-06-11 11:18:18 +0200 |
commit | 44d5e10d9e1e2e80c19fd2917c9d2d99bf301b7d (patch) | |
tree | 9fa56addc9395a9f7a9df50e97e371ceda4b405e | |
parent | 21d094f4022800bb560f3c26c53b62df492fb307 (diff) | |
download | strongswan-44d5e10d9e1e2e80c19fd2917c9d2d99bf301b7d.tar.bz2 strongswan-44d5e10d9e1e2e80c19fd2917c9d2d99bf301b7d.tar.xz |
attr: Use plugin features to register attribute provider
-rw-r--r-- | src/libhydra/plugins/attr/attr_plugin.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/libhydra/plugins/attr/attr_plugin.c b/src/libhydra/plugins/attr/attr_plugin.c index cb14495af..7d719d0f8 100644 --- a/src/libhydra/plugins/attr/attr_plugin.c +++ b/src/libhydra/plugins/attr/attr_plugin.c @@ -42,6 +42,36 @@ METHOD(plugin_t, get_name, char*, return "attr"; } +/** + * Register provider + */ +static bool plugin_cb(private_attr_plugin_t *this, + plugin_feature_t *feature, bool reg, void *cb_data) +{ + if (reg) + { + hydra->attributes->add_provider(hydra->attributes, + &this->provider->provider); + } + else + { + hydra->attributes->remove_provider(hydra->attributes, + &this->provider->provider); + } + return TRUE; +} + +METHOD(plugin_t, get_features, int, + private_attr_plugin_t *this, plugin_feature_t *features[]) +{ + static plugin_feature_t f[] = { + PLUGIN_CALLBACK((plugin_feature_callback_t)plugin_cb, NULL), + PLUGIN_PROVIDE(CUSTOM, "attr"), + }; + *features = f; + return countof(f); +} + METHOD(plugin_t, reload, bool, private_attr_plugin_t *this) { @@ -52,7 +82,6 @@ METHOD(plugin_t, reload, bool, METHOD(plugin_t, destroy, void, private_attr_plugin_t *this) { - hydra->attributes->remove_provider(hydra->attributes, &this->provider->provider); this->provider->destroy(this->provider); free(this); } @@ -68,13 +97,13 @@ plugin_t *attr_plugin_create() .public = { .plugin = { .get_name = _get_name, + .get_features = _get_features, .reload = _reload, .destroy = _destroy, }, }, .provider = attr_provider_create(), ); - hydra->attributes->add_provider(hydra->attributes, &this->provider->provider); return &this->public.plugin; } |