Add features support to eap-aka plugin
authorMartin Willi <martin@revosec.ch>
Thu, 13 Oct 2011 11:02:42 +0000 (13:02 +0200)
committerMartin Willi <martin@revosec.ch>
Fri, 14 Oct 2011 08:05:48 +0000 (10:05 +0200)
src/libcharon/plugins/eap_aka/eap_aka_plugin.c

index 361ebbe..83805d7 100644 (file)
@@ -45,14 +45,34 @@ METHOD(plugin_t, get_name, char*,
        return "eap-aka";
 }
 
+METHOD(plugin_t, get_features, int,
+       private_eap_aka_plugin_t *this, plugin_feature_t *features[])
+{
+       static plugin_feature_t f[] = {
+               PLUGIN_PROVIDE(CUSTOM, "aka-manager"),
+               PLUGIN_CALLBACK(eap_method_register, eap_aka_server_create),
+                       PLUGIN_PROVIDE(EAP_SERVER, EAP_AKA),
+                               PLUGIN_DEPENDS(RNG, RNG_WEAK),
+                               PLUGIN_DEPENDS(HASHER, HASH_SHA1),
+                               PLUGIN_DEPENDS(PRF, PRF_FIPS_SHA1_160),
+                               PLUGIN_DEPENDS(SIGNER, AUTH_HMAC_SHA1_128),
+                               PLUGIN_DEPENDS(CRYPTER, ENCR_AES_CBC, 16),
+               PLUGIN_CALLBACK(eap_method_register, eap_aka_peer_create),
+                       PLUGIN_PROVIDE(EAP_PEER, EAP_AKA),
+                               PLUGIN_DEPENDS(RNG, RNG_WEAK),
+                               PLUGIN_DEPENDS(HASHER, HASH_SHA1),
+                               PLUGIN_DEPENDS(PRF, PRF_FIPS_SHA1_160),
+                               PLUGIN_DEPENDS(SIGNER, AUTH_HMAC_SHA1_128),
+                               PLUGIN_DEPENDS(CRYPTER, ENCR_AES_CBC, 16),
+       };
+       *features = f;
+       return countof(f);
+}
+
 METHOD(plugin_t, destroy, void,
        private_eap_aka_plugin_t *this)
 {
        lib->set(lib, "aka-manager", NULL);
-       charon->eap->remove_method(charon->eap,
-                                                          (eap_constructor_t)eap_aka_server_create);
-       charon->eap->remove_method(charon->eap,
-                                                          (eap_constructor_t)eap_aka_peer_create);
        this->mgr->destroy(this->mgr);
        free(this);
 }
@@ -68,17 +88,12 @@ plugin_t *eap_aka_plugin_create()
                .public = {
                        .plugin = {
                                .get_name = _get_name,
-                               .reload = (void*)return_false,
+                               .get_features = _get_features,
                                .destroy = _destroy,
                        },
                },
                .mgr = simaka_manager_create(),
        );
-
-       charon->eap->add_method(charon->eap, EAP_AKA, 0, EAP_SERVER,
-                                                       (eap_constructor_t)eap_aka_server_create);
-       charon->eap->add_method(charon->eap, EAP_AKA, 0, EAP_PEER,
-                                                       (eap_constructor_t)eap_aka_peer_create);
        lib->set(lib, "aka-manager", this->mgr);
 
        return &this->public.plugin;