summaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-04-05 13:17:02 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-04-05 13:17:02 +0200
commit7b2cfb422af6a957aa90e22bd6e9b19f16b30319 (patch)
treeaaa2fd85662309af45ab4fced6b332445bdf0f10 /src/config.c
parent329d15d50c54a69ce8e2be0865124744c0bf3428 (diff)
downloadfastd-7b2cfb422af6a957aa90e22bd6e9b19f16b30319.tar
fastd-7b2cfb422af6a957aa90e22bd6e9b19f16b30319.zip
Cleanly shutdown; add on-down command
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c
index 7725c40..0d9a62b 100644
--- a/src/config.c
+++ b/src/config.c
@@ -41,10 +41,10 @@
#include <sys/types.h>
-extern fastd_protocol fastd_protocol_null;
+extern const fastd_protocol fastd_protocol_null;
#ifdef WITH_PROTOCOL_ECFXP
-extern fastd_protocol fastd_protocol_ec25519_fhmqvc_xsalsa20_poly1305;
+extern const fastd_protocol fastd_protocol_ec25519_fhmqvc_xsalsa20_poly1305;
#endif
@@ -76,6 +76,9 @@ static void default_config(fastd_config *conf) {
conf->on_up = NULL;
conf->on_up_dir = NULL;
+
+ conf->on_down = NULL;
+ conf->on_down_dir = NULL;
}
static bool config_match(const char *opt, ...) {
@@ -493,6 +496,16 @@ void fastd_configure(fastd_context *ctx, fastd_config *conf, int argc, char *con
continue;
}
+ IF_OPTION_ARG("--on-down") {
+ free(conf->on_down);
+ free(conf->on_down_dir);
+
+ conf->on_down = strdup(arg);
+ conf->on_down_dir = get_current_dir_name();
+
+ continue;
+ }
+
IF_OPTION("--generate-key") {
keygen = true;
continue;
@@ -614,3 +627,18 @@ void fastd_reconfigure(fastd_context *ctx, fastd_config *conf) {
count_peers(ctx, conf);
}
+
+void fastd_config_release(fastd_context *ctx, fastd_config *conf) {
+ while (conf->peers)
+ fastd_peer_config_delete(ctx, conf);
+
+ fastd_string_stack_free(conf->peer_dirs);
+
+ free(conf->ifname);
+ free(conf->secret);
+ free(conf->on_up);
+ free(conf->on_up_dir);
+ free(conf->on_down);
+ free(conf->on_down_dir);
+ free(conf->protocol_config);
+}