return result;
}
-bool read_server_config(void) {
+bool read_server_config(meshlink_handle_t *mesh) {
char filename[PATH_MAX];
bool x;
return x;
}
-bool read_host_config(splay_tree_t *config_tree, const char *name) {
+bool read_host_config(meshlink_handle_t *mesh, splay_tree_t *config_tree, const char *name) {
char filename[PATH_MAX];
bool x;
return x;
}
-bool append_config_file(const char *name, const char *key, const char *value) {
+bool append_config_file(meshlink_handle_t *mesh, const char *name, const char *key, const char *value) {
char filename[PATH_MAX];
snprintf(filename,PATH_MAX, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
#ifndef __TINC_CONF_H__
#define __TINC_CONF_H__
-#include "splay_tree.h"
#include "list.h"
+#include "meshlink_internal.h"
+#include "splay_tree.h"
typedef struct config_t {
char *variable;
int line;
} config_t;
-
extern void init_configuration(struct splay_tree_t **);
extern void exit_configuration(struct splay_tree_t **);
extern config_t *new_config(void) __attribute__ ((__malloc__));
extern config_t *parse_config_line(char *, const char *, int);
extern bool read_config_file(struct splay_tree_t *, const char *);
-extern void read_config_options(struct splay_tree_t *, const char *);
-extern bool read_server_config(void);
-extern bool read_host_config(struct splay_tree_t *, const char *);
-extern bool append_config_file(const char *, const char *, const char *);
+
+extern bool read_server_config(struct meshlink_handle *mesh);
+extern bool read_host_config(struct meshlink_handle *mesh, struct splay_tree_t *, const char *);
+extern bool append_config_file(struct meshlink_handle *mesh, const char *, const char *, const char *);
#endif /* __TINC_CONF_H__ */
init_configuration(&mesh->config);
- if(!read_server_config())
+ if(!read_server_config(mesh))
return meshlink_close(mesh), NULL;
// Setup up everything
exit_configuration(&mesh->config);
init_configuration(&mesh->config);
- if(!read_server_config()) {
+ if(!read_server_config(mesh)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Unable to reread configuration file.");
return EINVAL;
}
char *p;
init_configuration(&config_tree);
- if(!read_host_config(config_tree, n->name))
+ if(!read_host_config(mesh, config_tree, n->name))
goto exit;
/* First, check for simple ECDSAPublicKey statement */
if(!c->config_tree) {
init_configuration(&c->config_tree);
- if(!read_host_config(c->config_tree, c->name))
+ if(!read_host_config(mesh, c->config_tree, c->name))
return false;
}
mesh->self->connection = new_connection();
mesh->self->name = name;
mesh->self->connection->name = xstrdup(name);
- read_host_config(mesh->config, name);
+ read_host_config(mesh, mesh->config, name);
if(!get_config_string(lookup_config(mesh->config, "Port"), &mesh->myport))
mesh->myport = xstrdup("655");
}
init_configuration(&outgoing->config_tree);
- read_host_config(outgoing->config_tree, outgoing->name);
+ read_host_config(mesh, outgoing->config_tree, outgoing->name);
outgoing->cfg = lookup_config(outgoing->config_tree, "Address");
if(!outgoing->cfg) {
if(!c->config_tree) {
init_configuration(&c->config_tree);
- if(!read_host_config(c->config_tree, c->name)) {
+ if(!read_host_config(mesh, c->config_tree, c->name)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s had unknown identity (%s)", c->hostname, c->name);
return false;
}
}
logger(DEBUG_PROTOCOL, LOG_INFO, "Learned ECDSA public key from %s (%s)", from->name, from->hostname);
- append_config_file(from->name, "ECDSAPublicKey", pubkey);
+ append_config_file(mesh, from->name, "ECDSAPublicKey", pubkey);
return true;
}