summaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-10-29 20:28:26 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-10-29 20:28:26 +0100
commit8df7ea375df1ca8868763e30e90120e13af2b808 (patch)
treef8e5986c16cd7b13a3dbfcdb579122c8bd9847bd /src/config.c
parent96a14063ce55023878fe4d7509b08cc5d9c4b919 (diff)
downloadfastd-8df7ea375df1ca8868763e30e90120e13af2b808.tar
fastd-8df7ea375df1ca8868763e30e90120e13af2b808.zip
Generate method list automagically
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c32
1 files changed, 2 insertions, 30 deletions
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;