]> git.meshlink.io Git - meshlink/blobdiff - src/net_setup.c
Stop using global variable mesh in conf.[ch].
[meshlink] / src / net_setup.c
index 7fa7b98e975e56dbf7d91f7af290098dee4b569e..5390d80491296913f7090bcb83491054c7f7e376 100644 (file)
@@ -42,7 +42,7 @@ bool node_read_ecdsa_public_key(node_t *n) {
        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 */
@@ -65,7 +65,7 @@ bool read_ecdsa_public_key(connection_t *c) {
 
        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;
        }
 
@@ -243,8 +243,8 @@ static bool add_listen_address(char *address, bool bindto) {
                        continue;
                }
 
-               io_add(&mesh->listen_socket[mesh->listen_sockets].tcp, handle_new_meta_connection, &mesh->listen_socket[mesh->listen_sockets], tcp_fd, IO_READ);
-               io_add(&mesh->listen_socket[mesh->listen_sockets].udp, handle_incoming_vpn_data, &mesh->listen_socket[mesh->listen_sockets], udp_fd, IO_READ);
+               io_add(&mesh->loop, &mesh->listen_socket[mesh->listen_sockets].tcp, handle_new_meta_connection, &mesh->listen_socket[mesh->listen_sockets], tcp_fd, IO_READ);
+               io_add(&mesh->loop, &mesh->listen_socket[mesh->listen_sockets].udp, handle_incoming_vpn_data, &mesh->listen_socket[mesh->listen_sockets], udp_fd, IO_READ);
 
                if(mesh->debug_level >= DEBUG_CONNECTIONS) {
                        char *hostname = sockaddr2hostname((sockaddr_t *) aip->ai_addr);
@@ -278,7 +278,7 @@ bool setup_myself(void) {
        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");
@@ -322,7 +322,7 @@ bool setup_myself(void) {
        mesh->self->nexthop = mesh->self;
        mesh->self->via = mesh->self;
        mesh->self->status.reachable = true;
-       mesh->self->last_state_change = now.tv_sec;
+       mesh->self->last_state_change = mesh->loop.now.tv_sec;
        node_add(mesh->self);
 
        graph();
@@ -353,7 +353,7 @@ bool setup_myself(void) {
 
        /* Done. */
 
-       mesh->last_config_check = now.tv_sec;
+       mesh->last_config_check = mesh->loop.now.tv_sec;
 
        return true;
 }
@@ -397,8 +397,8 @@ void close_network_connections(void) {
        }
 
        for(int i = 0; i < mesh->listen_sockets; i++) {
-               io_del(&mesh->listen_socket[i].tcp);
-               io_del(&mesh->listen_socket[i].udp);
+               io_del(&mesh->loop, &mesh->listen_socket[i].tcp);
+               io_del(&mesh->loop, &mesh->listen_socket[i].udp);
                close(mesh->listen_socket[i].tcp.fd);
                close(mesh->listen_socket[i].udp.fd);
        }