From: Guus Sliepen Date: Mon, 20 Nov 2000 19:41:13 +0000 (+0000) Subject: - Proper initialization of rbltree structures. X-Git-Tag: release-1.0pre4~155 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=1857b3c97c261dda9978a67d07b315bb3ca68841;p=tinc - Proper initialization of rbltree structures. --- diff --git a/src/connection.c b/src/connection.c index dee0472a..46d82d2c 100644 --- a/src/connection.c +++ b/src/connection.c @@ -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: connection.c,v 1.1.2.1 2000/11/20 19:12:11 guus Exp $ + $Id: connection.c,v 1.1.2.2 2000/11/20 19:41:10 guus Exp $ */ #include "config.h" @@ -32,6 +32,7 @@ #include "config.h" #include "conf.h" #include +#include "subnet.h" #include "xalloc.h" #include "system.h" @@ -61,6 +62,8 @@ connection_t *new_connection(void) cp /* initialise all those stupid pointers at once */ memset(p, '\0', sizeof(*p)); + + p->subnet_tree = new_rbltree((rbl_compare_t)subnet_compare, NULL); cp return p; } diff --git a/src/net.c b/src/net.c index adad4105..86223b94 100644 --- a/src/net.c +++ b/src/net.c @@ -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.c,v 1.35.4.77 2000/11/20 19:12:12 guus Exp $ + $Id: net.c,v 1.35.4.78 2000/11/20 19:41:10 guus Exp $ */ #include "config.h" @@ -852,6 +852,9 @@ int setup_network_connections(void) { config_t const *cfg; cp + init_connections(); + init_subnets(); + if((cfg = get_config_val(config, config_pingtimeout)) == NULL) timeout = 60; else diff --git a/src/subnet.c b/src/subnet.c index b2ced415..fcbc45af 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -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: subnet.c,v 1.1.2.12 2000/11/20 19:12:17 guus Exp $ + $Id: subnet.c,v 1.1.2.13 2000/11/20 19:41:13 guus Exp $ */ #include "config.h" @@ -37,8 +37,14 @@ /* lists type of subnet */ -rbltree_t _subnet_tree = { NULL }; -rbltree_t *subnet_tree = &_subnet_tree; +rbltree_t *subnet_tree; + +void init_subnets(void) +{ +cp + subnet_tree = new_rbltree((rbl_compare_t)subnet_compare, (rbl_action_t)free_subnet); +cp +} /* Subnet comparison */ @@ -132,7 +138,7 @@ cp void subnet_del(subnet_t *subnet) { cp - free_rbl(rbl_unlink(subnet->owner->subnet_tree, subnet)); + rbl_delete(subnet->owner->subnet_tree, subnet); rbl_delete(subnet_tree, subnet); cp } diff --git a/src/subnet.h b/src/subnet.h index b409fd46..1aab681a 100644 --- a/src/subnet.h +++ b/src/subnet.h @@ -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: subnet.h,v 1.1.2.6 2000/11/20 19:12:17 guus Exp $ + $Id: subnet.h,v 1.1.2.7 2000/11/20 19:41:13 guus Exp $ */ #ifndef __TINC_SUBNET_H__ @@ -77,10 +77,12 @@ typedef struct subnet_t { extern subnet_t *new_subnet(void); extern void free_subnet(subnet_t *); +extern void init_subnets(void); extern void subnet_add(struct connection_t *, subnet_t *); extern void subnet_del(subnet_t *); extern char *net2str(subnet_t *); extern subnet_t *str2net(char *); +extern int subnet_compare(subnet_t *, subnet_t *); extern subnet_t *lookup_subnet_mac(mac_t); extern subnet_t *lookup_subnet_ipv4(ipv4_t); extern subnet_t *lookup_subnet_ipv6(ipv6_t);