Merge branch 'multi-vip'
[strongswan.git] / src / libcharon / plugins / tnc_ifmap / tnc_ifmap_plugin.c
index 6e8393c..de4d12e 100644 (file)
@@ -42,11 +42,33 @@ METHOD(plugin_t, get_name, char*,
        return "tnc-ifmap";
 }
 
+METHOD(plugin_t, reload, bool,
+       private_tnc_ifmap_plugin_t *this)
+{
+       if (this->listener)
+       {
+               charon->bus->remove_listener(charon->bus, &this->listener->listener);
+               this->listener->destroy(this->listener);
+       }
+
+       this->listener = tnc_ifmap_listener_create(TRUE);
+       if (!this->listener)
+       {
+               return FALSE;
+       }
+
+       charon->bus->add_listener(charon->bus, &this->listener->listener);
+       return TRUE;
+}
+
 METHOD(plugin_t, destroy, void,
        private_tnc_ifmap_plugin_t *this)
 {
-       charon->bus->remove_listener(charon->bus, &this->listener->listener);
-       this->listener->destroy(this->listener);
+       if (this->listener)
+       {
+               charon->bus->remove_listener(charon->bus, &this->listener->listener);
+               this->listener->destroy(this->listener);
+       }
        free(this);
 }
 
@@ -61,15 +83,17 @@ plugin_t *tnc_ifmap_plugin_create()
                .public = {
                        .plugin = {
                                .get_name = _get_name,
-                               .reload = (void*)return_false,
+                               .reload = _reload,
                                .destroy = _destroy,
                        },
                },
-               .listener = tnc_ifmap_listener_create(),
+               .listener = tnc_ifmap_listener_create(FALSE),
        );
 
-       charon->bus->add_listener(charon->bus, &this->listener->listener);
-
+       if (this->listener)
+       {
+               charon->bus->add_listener(charon->bus, &this->listener->listener);
+       }
        return &this->public.plugin;
 }