diff options
author | Tobias Brunner <tobias@strongswan.org> | 2013-06-07 18:38:16 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-06-11 11:18:18 +0200 |
commit | 21d094f4022800bb560f3c26c53b62df492fb307 (patch) | |
tree | e7ef97cbb2445eecab82493c04980b5aada70b2d /src | |
parent | 82d3f5122bb3da6923b52e4320ab8cf982573773 (diff) | |
download | strongswan-21d094f4022800bb560f3c26c53b62df492fb307.tar.bz2 strongswan-21d094f4022800bb560f3c26c53b62df492fb307.tar.xz |
ipseckey: Allow en-/disabling at runtime using plugin reload feature
Diffstat (limited to 'src')
-rw-r--r-- | src/libcharon/plugins/ipseckey/ipseckey_plugin.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/libcharon/plugins/ipseckey/ipseckey_plugin.c b/src/libcharon/plugins/ipseckey/ipseckey_plugin.c index a62a9747e..2fd820f94 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; |