1998-2005 Ivo Timmermans
2000 Cris van Pelt
2010-2011 Julien Muchembled <jm@jmuchemb.eu>
- 2000-2015 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2021 Guus Sliepen <guus@tinc-vpn.org>
2013 Florent Clairambault <florent@clairambault.fr>
This program is free software; you can redistribute it and/or modify
#include "names.h"
#include "netutl.h" /* for str2address */
#include "protocol.h"
-#include "utils.h" /* for cp */
#include "xalloc.h"
-splay_tree_t *config_tree;
+splay_tree_t *config_tree = NULL;
int pinginterval = 0; /* seconds between pings */
int pingtimeout = 0; /* seconds to wait for response */
}
void free_config(config_t *cfg) {
- if(cfg->variable) {
- free(cfg->variable);
- }
-
- if(cfg->value) {
- free(cfg->value);
- }
-
- if(cfg->file) {
- free(cfg->file);
- }
-
+ free(cfg->variable);
+ free(cfg->value);
+ free(cfg->file);
free(cfg);
}
return false;
}
-bool get_config_subnet(const config_t *cfg, subnet_t **result) {
- subnet_t subnet = {NULL};
-
- if(!cfg) {
- return false;
- }
-
- if(!str2net(&subnet, cfg->value)) {
- logger(DEBUG_ALWAYS, LOG_ERR, "Subnet expected for configuration variable %s in %s line %d",
- cfg->variable, cfg->file, cfg->line);
- return false;
- }
-
- /* Teach newbies what subnets are... */
-
- if(((subnet.type == SUBNET_IPV4)
- && !maskcheck(&subnet.net.ipv4.address, subnet.net.ipv4.prefixlength, sizeof(subnet.net.ipv4.address)))
- || ((subnet.type == SUBNET_IPV6)
- && !maskcheck(&subnet.net.ipv6.address, subnet.net.ipv6.prefixlength, sizeof(subnet.net.ipv6.address)))) {
- logger(DEBUG_ALWAYS, LOG_ERR, "Network address and prefix length do not match for configuration variable %s in %s line %d",
- cfg->variable, cfg->file, cfg->line);
- return false;
- }
-
- *(*result = new_subnet()) = subnet;
-
- return true;
-}
-
/*
Read exactly one line and strip the trailing newline if any.
*/
}
void read_config_options(splay_tree_t *config_tree, const char *prefix) {
+ if(!cmdline_conf) {
+ return;
+ }
+
size_t prefix_len = prefix ? strlen(prefix) : 0;
for(const list_node_t *node = cmdline_conf->tail; node; node = node->prev) {
}
}
-bool read_server_config(void) {
+bool read_server_config(splay_tree_t *config_tree) {
char fname[PATH_MAX];
bool x;
// And we try to read the ones that end with ".conf"
if(l > 5 && !strcmp(".conf", & ep->d_name[ l - 5 ])) {
- if(snprintf(fname, sizeof(fname), "%s" SLASH "%s", dname, ep->d_name) >= sizeof(fname)) {
+ if((size_t)snprintf(fname, sizeof(fname), "%s" SLASH "%s", dname, ep->d_name) >= sizeof(fname)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Pathname too long: %s/%s", dname, ep->d_name);
return false;
}