X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet_setup.c;h=edbcbf5426693af401c333f8c4c29a6813f72416;hp=d0d57daaa51a9c36e824dda1a470045a6f3f968f;hb=2af0bcc8fd39ca34a7ff856d539cdf38728a8c25;hpb=78e88521845ae3bdd963ae5a414cb9c251963fa2 diff --git a/src/net_setup.c b/src/net_setup.c index d0d57daa..edbcbf54 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -1,7 +1,7 @@ /* net_setup.c -- Setup. - Copyright (C) 1998-2002 Ivo Timmermans , - 2000-2002 Guus Sliepen + Copyright (C) 1998-2002 Ivo Timmermans , + 2000-2002 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net_setup.c,v 1.1.2.18 2002/06/08 14:08:57 guus Exp $ + $Id: net_setup.c,v 1.1.2.22 2002/09/03 20:43:25 guus Exp $ */ #include "config.h" @@ -67,7 +67,6 @@ #include "process.h" #include "protocol.h" #include "subnet.h" -#include "graph.h" #include "process.h" #include "route.h" #include "device.h" @@ -464,8 +463,6 @@ cp myself->status.reachable = 1; node_add(myself); - graph(); - cp /* Open sockets */ @@ -484,6 +481,8 @@ cp return -1; } + listen_sockets = 0; + for(aip = ai; aip; aip = aip->ai_next) { if((listen_socket[listen_sockets].tcp = setup_listen_socket((sockaddr_t *)aip->ai_addr)) < 0) @@ -521,13 +520,14 @@ cp */ int setup_network_connections(void) { + char *envp[4]; + int i; cp now = time(NULL); init_connections(); init_subnets(); init_nodes(); - init_edges(); init_events(); init_requests(); @@ -545,7 +545,15 @@ cp return -1; /* Run tinc-up script to further initialize the tap interface */ - execute_script("tinc-up"); + asprintf(&envp[0], "NETNAME=%s", netname?netname:""); + asprintf(&envp[1], "DEVICE=%s", device?device:""); + asprintf(&envp[2], "INTERFACE=%s", interface?interface:""); + envp[3] = NULL; + + execute_script("tinc-up", envp); + + for(i = 0; i < 4; i++) + free(envp[i]); if(setup_myself() < 0) return -1; @@ -562,6 +570,7 @@ void close_network_connections(void) { avl_node_t *node, *next; connection_t *c; + char *envp[4]; int i; cp for(node = connection_tree->head; node; node = next) @@ -584,12 +593,19 @@ cp exit_requests(); exit_events(); - exit_edges(); exit_subnets(); exit_nodes(); exit_connections(); - execute_script("tinc-down"); + asprintf(&envp[0], "NETNAME=%s", netname?netname:""); + asprintf(&envp[1], "DEVICE=%s", device?device:""); + asprintf(&envp[2], "INTERFACE=%s", interface?interface:""); + envp[3] = NULL; + + execute_script("tinc-down", envp); + + for(i = 0; i < 4; i++) + free(envp[i]); close_device(); cp