summaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-07-25 15:17:54 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-07-25 15:17:54 +0200
commit900ac61351cabc78b5126adbe9c9936d1c3b5ca6 (patch)
treeaf2c93deb9cdeec30aa5d7f79cc69519cb5b3217 /src/config.c
parentc3dee51736841587b2f81adc54c1949276ab5de0 (diff)
downloadfastd-900ac61351cabc78b5126adbe9c9936d1c3b5ca6.tar
fastd-900ac61351cabc78b5126adbe9c9936d1c3b5ca6.zip
Move send functions out of fastd.c
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index ec04726..6296209 100644
--- a/src/config.c
+++ b/src/config.c
@@ -845,7 +845,31 @@ static void configure_user(fastd_context_t *ctx, fastd_config_t *conf) {
conf->n_groups = ngroups;
}
}
+}
+
+static void configure_method_parameters(fastd_context_t *ctx, fastd_config_t *conf) {
+ conf->max_packet_size = 0;
+ conf->min_encrypt_head_space = 0;
+ conf->min_decrypt_head_space = 0;
+ conf->min_encrypt_tail_space = 0;
+ conf->min_decrypt_tail_space = 0;
+
+ int i;
+ for (i = 0; i < MAX_METHODS; i++) {
+ if (!conf->methods[i])
+ break;
+
+ conf->max_packet_size = max_size_t(conf->max_packet_size, conf->methods[i]->max_packet_size(ctx));
+ conf->min_encrypt_head_space = max_size_t(conf->min_encrypt_head_space, conf->methods[i]->min_encrypt_head_space(ctx));
+ conf->min_decrypt_head_space = max_size_t(conf->min_decrypt_head_space, conf->methods[i]->min_decrypt_head_space(ctx));
+ conf->min_encrypt_tail_space = max_size_t(conf->min_encrypt_tail_space, conf->methods[i]->min_encrypt_tail_space(ctx));
+ conf->min_decrypt_tail_space = max_size_t(conf->min_decrypt_tail_space, conf->methods[i]->min_decrypt_tail_space(ctx));
+ }
+ conf->min_encrypt_head_space = alignto(conf->min_encrypt_head_space, 16);
+
+ /* ugly hack to get alignment right for aes128-gcm, which needs data aligned to 16 and has a 24 byte header */
+ conf->min_decrypt_head_space = alignto(conf->min_decrypt_head_space, 16) + 8;
}
void fastd_configure(fastd_context_t *ctx, fastd_config_t *conf, int argc, char *const argv[]) {
@@ -902,6 +926,9 @@ void fastd_configure(fastd_context_t *ctx, fastd_config_t *conf, int argc, char
exit_error(ctx, "config error: neither fixed peers nor peer dirs have been configured");
configure_user(ctx, conf);
+
+ ctx->conf = conf;
+ configure_method_parameters(ctx, conf);
}
static void peer_dirs_read_peer_group(fastd_context_t *ctx, fastd_config_t *new_conf) {