From: Guus Sliepen Date: Mon, 21 Apr 2014 19:11:58 +0000 (+0200) Subject: Move config_tree to mesh->config. X-Git-Url: http://git.meshlink.io/?p=meshlink;a=commitdiff_plain;h=8fc838f88fad6d6a632f9d4e6906e31931c765e3 Move config_tree to mesh->config. --- diff --git a/src/Makefile.am b/src/Makefile.am index 021d6b8e..6f7cd795 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -94,7 +94,6 @@ libmeshlink_la_SOURCES = \ splay_tree.c splay_tree.h \ sptps.c sptps.h \ system.h \ - tincd.c \ utils.c utils.h \ xalloc.h \ $(ed25519_SOURCES) \ diff --git a/src/conf.c b/src/conf.c index 207f6005..360053f9 100644 --- a/src/conf.c +++ b/src/conf.c @@ -24,13 +24,12 @@ #include "conf.h" #include "list.h" #include "logger.h" +#include "meshlink_internal.h" #include "netutl.h" /* for str2address */ #include "protocol.h" #include "utils.h" /* for cp */ #include "xalloc.h" -splay_tree_t *config_tree; - int pinginterval = 0; /* seconds between pings */ int pingtimeout = 0; /* seconds to wait for response */ @@ -50,11 +49,11 @@ static int config_compare(const config_t *a, const config_t *b) { return a->file ? strcmp(a->file, b->file) : 0; } -void init_configuration(splay_tree_t ** config_tree) { +void init_configuration(splay_tree_t **config_tree) { *config_tree = splay_alloc_tree((splay_compare_t) config_compare, (splay_action_t) free_config); } -void exit_configuration(splay_tree_t ** config_tree) { +void exit_configuration(splay_tree_t **config_tree) { splay_delete_tree(*config_tree); *config_tree = NULL; } @@ -300,7 +299,7 @@ bool read_server_config(void) { xasprintf(&fname, "%s" SLASH "tinc.conf", confbase); errno = 0; - x = read_config_file(config_tree, fname); + x = read_config_file(mesh->config, fname); if(!x && errno) logger(DEBUG_ALWAYS, LOG_ERR, "Failed to read `%s': %s", fname, strerror(errno)); diff --git a/src/conf.h b/src/conf.h index 63097c3f..015bba5b 100644 --- a/src/conf.h +++ b/src/conf.h @@ -30,8 +30,6 @@ typedef struct config_t { int line; } config_t; -extern struct splay_tree_t *config_tree; - extern int pinginterval; extern int pingtimeout; extern int maxtimeout; diff --git a/src/net.c b/src/net.c index 98cc8bed..7a176ef2 100644 --- a/src/net.c +++ b/src/net.c @@ -283,8 +283,8 @@ int reload_configuration(void) { /* Reread our own configuration file */ - exit_configuration(&config_tree); - init_configuration(&config_tree); + exit_configuration(&mesh->config); + init_configuration(&mesh->config); if(!read_server_config()) { logger(DEBUG_ALWAYS, LOG_ERR, "Unable to reread configuration file."); @@ -292,7 +292,7 @@ int reload_configuration(void) { } xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, mesh->self->name); - read_config_file(config_tree, fname); + read_config_file(mesh->config, fname); free(fname); /* Parse some options that are allowed to be changed while tinc is running */ diff --git a/src/net_setup.c b/src/net_setup.c index 1d2d4721..4c19e268 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -181,7 +181,7 @@ void load_all_nodes(void) { char *get_name(void) { char *name = NULL; - get_config_string(lookup_config(config_tree, "Name"), &name); + get_config_string(lookup_config(mesh->config, "Name"), &name); if(!name) return NULL; @@ -303,9 +303,9 @@ bool setup_myself(void) { mesh->self->connection = new_connection(); mesh->self->name = name; mesh->self->connection->name = xstrdup(name); - read_host_config(config_tree, name); + read_host_config(mesh->config, name); - if(!get_config_string(lookup_config(config_tree, "Port"), &myport)) + if(!get_config_string(lookup_config(mesh->config, "Port"), &myport)) myport = xstrdup("655"); else port_specified = true; diff --git a/src/net_socket.c b/src/net_socket.c index ecf2c26b..80fe84ca 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -654,7 +654,7 @@ void try_outgoing_connections(void) { /* Make sure there is one outgoing_t in the list for each ConnectTo. */ // TODO: Drop support for ConnectTo since AutoConnect is now always on? - for(config_t *cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) { + for(config_t *cfg = lookup_config(mesh->config, "ConnectTo"); cfg; cfg = lookup_config_next(mesh->config, cfg)) { char *name; get_config_string(cfg, &name);