From: Tobias Brunner Date: Fri, 7 Jun 2013 16:38:16 +0000 (+0200) Subject: ipseckey: Allow en-/disabling at runtime using plugin reload feature X-Git-Tag: 5.1.0dr1~128^2~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=21d094f4022800bb560f3c26c53b62df492fb307;p=thirdparty%2Fstrongswan.git ipseckey: Allow en-/disabling at runtime using plugin reload feature --- diff --git a/src/libcharon/plugins/ipseckey/ipseckey_plugin.c b/src/libcharon/plugins/ipseckey/ipseckey_plugin.c index a62a9747e3..2fd820f94d 100644 --- a/src/libcharon/plugins/ipseckey/ipseckey_plugin.c +++ b/src/libcharon/plugins/ipseckey/ipseckey_plugin.c @@ -49,6 +49,28 @@ METHOD(plugin_t, get_name, char*, return "ipseckey"; } +METHOD(plugin_t, reload, bool, + private_ipseckey_plugin_t *this) +{ + bool enabled = lib->settings->get_bool(lib->settings, + "%s.plugins.ipseckey.enable", FALSE, charon->name); + + if (enabled != this->enabled) + { + if (enabled) + { + lib->credmgr->add_set(lib->credmgr, &this->cred->set); + } + else + { + lib->credmgr->remove_set(lib->credmgr, &this->cred->set); + } + this->enabled = enabled; + } + DBG1(DBG_CFG, "ipseckey plugin is %sabled", this->enabled ? "en" : "dis"); + return TRUE; +} + /** * Create resolver and register credential set */ @@ -66,23 +88,16 @@ static bool plugin_cb(private_ipseckey_plugin_t *this, return FALSE; } - if (this->enabled) - { - this->cred = ipseckey_cred_create(res); - lib->credmgr->add_set(lib->credmgr, &this->cred->set); - } - else - { - res->destroy(res); - } + this->cred = ipseckey_cred_create(res); + reload(this); } else { if (this->enabled) { lib->credmgr->remove_set(lib->credmgr, &this->cred->set); - this->cred->destroy(this->cred); } + this->cred->destroy(this->cred); } return TRUE; } @@ -117,11 +132,10 @@ plugin_t *ipseckey_plugin_create() .plugin = { .get_name = _get_name, .get_features = _get_features, + .reload = _reload, .destroy = _destroy, }, }, - .enabled = lib->settings->get_bool(lib->settings, - "%s.plugins.ipseckey.enable", FALSE, charon->name), ); return &this->public.plugin;