Add features support to eap-mschapv2
authorMartin Willi <martin@revosec.ch>
Mon, 12 Sep 2011 11:46:50 +0000 (13:46 +0200)
committerMartin Willi <martin@revosec.ch>
Fri, 14 Oct 2011 08:05:45 +0000 (10:05 +0200)
src/libcharon/plugins/eap_mschapv2/eap_mschapv2_plugin.c

index e809b14..6fd9670 100644 (file)
@@ -25,13 +25,30 @@ METHOD(plugin_t, get_name, char*,
        return "eap-mschapv2";
 }
 
+METHOD(plugin_t, get_features, int,
+       eap_mschapv2_plugin_t *this, plugin_feature_t *features[])
+{
+       static plugin_feature_t f[] = {
+               PLUGIN_CALLBACK(eap_method_register, eap_mschapv2_create_server),
+                       PLUGIN_PROVIDE(EAP_SERVER, EAP_MSCHAPV2),
+                               PLUGIN_DEPENDS(CRYPTER, ENCR_DES_ECB, 8),
+                               PLUGIN_DEPENDS(HASHER, HASH_MD4),
+                               PLUGIN_DEPENDS(HASHER, HASH_SHA1),
+                               PLUGIN_DEPENDS(RNG, RNG_WEAK),
+               PLUGIN_CALLBACK(eap_method_register, eap_mschapv2_create_peer),
+                       PLUGIN_PROVIDE(EAP_PEER, EAP_MSCHAPV2),
+                               PLUGIN_DEPENDS(CRYPTER, ENCR_DES_ECB, 8),
+                               PLUGIN_DEPENDS(HASHER, HASH_MD4),
+                               PLUGIN_DEPENDS(HASHER, HASH_SHA1),
+                               PLUGIN_DEPENDS(RNG, RNG_WEAK),
+       };
+       *features = f;
+       return countof(f);
+}
+
 METHOD(plugin_t, destroy, void,
        eap_mschapv2_plugin_t *this)
 {
-       charon->eap->remove_method(charon->eap,
-                                                          (eap_constructor_t)eap_mschapv2_create_server);
-       charon->eap->remove_method(charon->eap,
-                                                          (eap_constructor_t)eap_mschapv2_create_peer);
        free(this);
 }
 
@@ -45,16 +62,11 @@ plugin_t *eap_mschapv2_plugin_create()
        INIT(this,
                .plugin = {
                        .get_name = _get_name,
-                       .reload = (void*)return_false,
+                       .get_features = _get_features,
                        .destroy = _destroy,
                },
        );
 
-       charon->eap->add_method(charon->eap, EAP_MSCHAPV2, 0, EAP_SERVER,
-                                                       (eap_constructor_t)eap_mschapv2_create_server);
-       charon->eap->add_method(charon->eap, EAP_MSCHAPV2, 0, EAP_PEER,
-                                                       (eap_constructor_t)eap_mschapv2_create_peer);
-
        return &this->plugin;
 }