Add features support to eap-gtc plugin
[strongswan.git] / src / libcharon / plugins / eap_gtc / eap_gtc_plugin.c
index 91ba84b..bd70b75 100644 (file)
 /* missing in cababilities.h */
 #define CAP_AUDIT_WRITE 29
 
-/**
- * Implementation of plugin_t.destroy
- */
-static void destroy(eap_gtc_plugin_t *this)
+METHOD(plugin_t, get_name, char*,
+       eap_gtc_plugin_t *this)
+{
+       return "eap-gtc";
+}
+
+METHOD(plugin_t, get_features, int,
+       eap_gtc_plugin_t *this, plugin_feature_t *features[])
+{
+       static plugin_feature_t f[] = {
+               PLUGIN_CALLBACK(eap_method_register, eap_gtc_create_server),
+                       PLUGIN_PROVIDE(EAP_SERVER, EAP_GTC),
+               PLUGIN_CALLBACK(eap_method_register, eap_gtc_create_peer),
+                       PLUGIN_PROVIDE(EAP_PEER, EAP_GTC),
+       };
+       *features = f;
+       return countof(f);
+}
+
+METHOD(plugin_t, destroy, void,
+       eap_gtc_plugin_t *this)
 {
-       charon->eap->remove_method(charon->eap,
-                                                          (eap_constructor_t)eap_gtc_create_server);
-       charon->eap->remove_method(charon->eap,
-                                                          (eap_constructor_t)eap_gtc_create_peer);
        free(this);
 }
 
@@ -39,9 +52,15 @@ static void destroy(eap_gtc_plugin_t *this)
  */
 plugin_t *eap_gtc_plugin_create()
 {
-       eap_gtc_plugin_t *this = malloc_thing(eap_gtc_plugin_t);
+       eap_gtc_plugin_t *this;
 
-       this->plugin.destroy = (void(*)(plugin_t*))destroy;
+       INIT(this,
+               .plugin = {
+                       .get_name = _get_name,
+                       .get_features = _get_features,
+                       .destroy = _destroy,
+               },
+       );
 
        /* required for PAM authentication */
        charon->keep_cap(charon, CAP_AUDIT_WRITE);