Reduce pointer indirection for global list_t variables
[tinc] / src / net.c
index 8447d04..dffe0b4 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -1,7 +1,7 @@
 /*
     net.c -- most of the network code
     Copyright (C) 1998-2005 Ivo Timmermans,
-                  2000-2017 Guus Sliepen <guus@tinc-vpn.org>
+                  2000-2021 Guus Sliepen <guus@tinc-vpn.org>
                   2006      Scott Lamb <slamb@slamb.org>
                   2011      Loïc Grenié <loic.grenie@gmail.com>
 
 #include "system.h"
 
 #include "autoconnect.h"
+#include "conf_net.h"
 #include "conf.h"
 #include "connection.h"
-#include "device.h"
 #include "graph.h"
 #include "logger.h"
 #include "meta.h"
 #include "names.h"
 #include "net.h"
-#include "netutl.h"
 #include "protocol.h"
 #include "subnet.h"
 #include "utils.h"
-#include "xalloc.h"
 
 int contradicting_add_edge = 0;
 int contradicting_del_edge = 0;
@@ -211,7 +209,7 @@ static void timeout_handler(void *data) {
 
        last_periodic_run_time = now;
 
-       for list_each(connection_t, c, connection_list) {
+       for list_each(connection_t, c, &connection_list) {
                // control connections (eg. tinc ctl) do not have any timeout
                if(c->status.control) {
                        continue;
@@ -340,7 +338,7 @@ int reload_configuration(void) {
        exit_configuration(&config_tree);
        init_configuration(&config_tree);
 
-       if(!read_server_config()) {
+       if(!read_server_config(config_tree)) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Unable to reread configuration file.");
                return EINVAL;
        }
@@ -436,7 +434,7 @@ int reload_configuration(void) {
 
        /* Close connections to hosts that have a changed or deleted host config file */
 
-       for list_each(connection_t, c, connection_list) {
+       for list_each(connection_t, c, &connection_list) {
                if(c->status.control) {
                        continue;
                }
@@ -457,7 +455,7 @@ int reload_configuration(void) {
 
 void retry(void) {
        /* Reset the reconnection timers for all outgoing connections */
-       for list_each(outgoing_t, outgoing, outgoing_list) {
+       for list_each(outgoing_t, outgoing, &outgoing_list) {
                outgoing->timeout = 0;
 
                if(outgoing->ev.cb)
@@ -467,7 +465,7 @@ void retry(void) {
        }
 
        /* Check for outgoing connections that are in progress, and reset their ping timers */
-       for list_each(connection_t, c, connection_list) {
+       for list_each(connection_t, c, &connection_list) {
                if(c->outgoing && !c->node) {
                        c->last_ping_time = 0;
                }