From 8df7ea375df1ca8868763e30e90120e13af2b808 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 29 Oct 2013 20:28:26 +0100 Subject: Generate method list automagically --- src/config.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index 7958ffb..1d9df10 100644 --- a/src/config.c +++ b/src/config.c @@ -42,25 +42,6 @@ extern const fastd_protocol_t fastd_protocol_ec25519_fhmqvc; -extern const fastd_method_t fastd_method_null; -#ifdef WITH_METHOD_XSALSA20_POLY1305 -extern const fastd_method_t fastd_method_xsalsa20_poly1305; -#endif -#ifdef WITH_METHOD_AES128_GCM -extern const fastd_method_t fastd_method_aes128_gcm; -#endif - -static const fastd_method_t *const METHODS[] = { - &fastd_method_null, -#ifdef WITH_METHOD_XSALSA20_POLY1305 - &fastd_method_xsalsa20_poly1305, -#endif -#ifdef WITH_METHOD_AES128_GCM - &fastd_method_aes128_gcm, -#endif - NULL -}; - #ifdef USE_CRYPTO_AES128CTR #ifdef WITH_CRYPTO_AES128CTR_NACL @@ -142,16 +123,6 @@ bool fastd_config_protocol(fastd_context_t *ctx UNUSED, fastd_config_t *conf, co return true; } -const fastd_method_t* fastd_parse_method_name(const char *name) { - int i; - for (i = 0; METHODS[i]; i++) { - if (!strcmp(METHODS[i]->name, name)) - return METHODS[i]; - } - - return NULL; -} - bool fastd_config_method(fastd_context_t *ctx, fastd_config_t *conf, const char *name) { const fastd_method_t *parsed_method = fastd_parse_method_name(name); @@ -618,7 +589,8 @@ void fastd_configure(fastd_context_t *ctx, fastd_config_t *conf, int argc, char if (!conf->methods) { pr_warn(ctx, "no encryption method configured, falling back to method `null' (unencrypted)"); - conf->methods = fastd_string_stack_dup(fastd_method_null.name); + if (!fastd_config_method(ctx, conf, "null")) + exit_bug(ctx, "method `null' not supported"); } ctx->conf = conf; -- cgit v1.2.3