Properly initialize cached address map in kernel-pfroute plugin
[strongswan.git] / src / libhydra / plugins / kernel_pfroute / kernel_pfroute_plugin.c
index 5f351bd..09068b3 100644 (file)
@@ -32,13 +32,26 @@ struct private_kernel_pfroute_plugin_t {
        kernel_pfroute_plugin_t public;
 };
 
-/**
- * Implementation of plugin_t.destroy
- */
-static void destroy(private_kernel_pfroute_plugin_t *this)
+METHOD(plugin_t, get_name, char*,
+       private_kernel_pfroute_plugin_t *this)
+{
+       return "kernel-pfroute";
+}
+
+METHOD(plugin_t, get_features, int,
+       private_kernel_pfroute_plugin_t *this, plugin_feature_t *features[])
+{
+       static plugin_feature_t f[] = {
+               PLUGIN_CALLBACK(kernel_net_register, kernel_pfroute_net_create),
+                       PLUGIN_PROVIDE(CUSTOM, "kernel-net"),
+       };
+       *features = f;
+       return countof(f);
+}
+
+METHOD(plugin_t, destroy, void,
+       private_kernel_pfroute_plugin_t *this)
 {
-       hydra->kernel_interface->remove_net_interface(hydra->kernel_interface,
-                                               (kernel_net_constructor_t)kernel_pfroute_net_create);
        free(this);
 }
 
@@ -47,12 +60,17 @@ static void destroy(private_kernel_pfroute_plugin_t *this)
  */
 plugin_t *kernel_pfroute_plugin_create()
 {
-       private_kernel_pfroute_plugin_t *this = malloc_thing(private_kernel_pfroute_plugin_t);
-
-       this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+       private_kernel_pfroute_plugin_t *this;
 
-       hydra->kernel_interface->add_net_interface(hydra->kernel_interface,
-                                               (kernel_net_constructor_t)kernel_pfroute_net_create);
+       INIT(this,
+               .public = {
+                       .plugin = {
+                               .get_name = _get_name,
+                               .get_features = _get_features,
+                               .destroy = _destroy,
+                       },
+               },
+       );
 
        return &this->public.plugin;
 }