diff options
| author | Tobias Brunner <tobias@strongswan.org> | 2013-06-07 15:45:02 +0200 |
|---|---|---|
| committer | Tobias Brunner <tobias@strongswan.org> | 2013-06-11 11:18:17 +0200 |
| commit | 94ca7252c13f86bd93d1c41427a949a4eabcacd7 (patch) | |
| tree | 4d934110d9c13dd43e3827fc14d77c4266db4106 /src/libcharon/plugins/addrblock | |
| parent | 12459a4dc8f6e7536d71f25c9d4febbb3031c1f3 (diff) | |
| download | strongswan-94ca7252c13f86bd93d1c41427a949a4eabcacd7.tar.bz2 strongswan-94ca7252c13f86bd93d1c41427a949a4eabcacd7.tar.xz | |
addrblock: Use plugin features with soft dependency on X.509 decoding
Diffstat (limited to 'src/libcharon/plugins/addrblock')
| -rw-r--r-- | src/libcharon/plugins/addrblock/addrblock_plugin.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/libcharon/plugins/addrblock/addrblock_plugin.c b/src/libcharon/plugins/addrblock/addrblock_plugin.c index 72c551f0f..723747d8e 100644 --- a/src/libcharon/plugins/addrblock/addrblock_plugin.c +++ b/src/libcharon/plugins/addrblock/addrblock_plugin.c @@ -16,6 +16,7 @@ #include "addrblock_plugin.h" #include <daemon.h> +#include <plugins/plugin_feature.h> #include "addrblock_validator.h" #include "addrblock_narrow.h" @@ -49,11 +50,41 @@ METHOD(plugin_t, get_name, char*, return "addrblock"; } +/** + * Register listener + */ +static bool plugin_cb(private_addrblock_plugin_t *this, + plugin_feature_t *feature, bool reg, void *cb_data) +{ + if (reg) + { + lib->credmgr->add_validator(lib->credmgr, &this->validator->validator); + charon->bus->add_listener(charon->bus, &this->narrower->listener); + } + else + { + charon->bus->remove_listener(charon->bus, &this->narrower->listener); + lib->credmgr->remove_validator(lib->credmgr, + &this->validator->validator); + } + return TRUE; +} + +METHOD(plugin_t, get_features, int, + private_addrblock_plugin_t *this, plugin_feature_t *features[]) +{ + static plugin_feature_t f[] = { + PLUGIN_CALLBACK((plugin_feature_callback_t)plugin_cb, NULL), + PLUGIN_PROVIDE(CUSTOM, "addrblock"), + PLUGIN_SDEPEND(CERT_DECODE, CERT_X509), + }; + *features = f; + return countof(f); +} + METHOD(plugin_t, destroy, void, private_addrblock_plugin_t *this) { - charon->bus->remove_listener(charon->bus, &this->narrower->listener); - lib->credmgr->remove_validator(lib->credmgr, &this->validator->validator); this->narrower->destroy(this->narrower); this->validator->destroy(this->validator); free(this); @@ -70,15 +101,13 @@ plugin_t *addrblock_plugin_create() .public = { .plugin = { .get_name = _get_name, - .reload = (void*)return_false, + .get_features = _get_features, .destroy = _destroy, }, }, .validator = addrblock_validator_create(), .narrower = addrblock_narrow_create(), ); - lib->credmgr->add_validator(lib->credmgr, &this->validator->validator); - charon->bus->add_listener(charon->bus, &this->narrower->listener); return &this->public.plugin; } |
