- Proper initialization of rbltree structures.
authorGuus Sliepen <guus@tinc-vpn.org>
Mon, 20 Nov 2000 19:41:13 +0000 (19:41 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Mon, 20 Nov 2000 19:41:13 +0000 (19:41 +0000)
src/connection.c
src/net.c
src/subnet.c
src/subnet.h

index dee0472..46d82d2 100644 (file)
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
     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"
 */
 
 #include "config.h"
@@ -32,6 +32,7 @@
 #include "config.h"
 #include "conf.h"
 #include <utils.h>
 #include "config.h"
 #include "conf.h"
 #include <utils.h>
+#include "subnet.h"
 
 #include "xalloc.h"
 #include "system.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));
 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;
 }
 cp
   return p;
 }
index adad410..86223b9 100644 (file)
--- 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.
 
     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"
 */
 
 #include "config.h"
@@ -852,6 +852,9 @@ int setup_network_connections(void)
 {
   config_t const *cfg;
 cp
 {
   config_t const *cfg;
 cp
+  init_connections();
+  init_subnets();
+
   if((cfg = get_config_val(config, config_pingtimeout)) == NULL)
     timeout = 60;
   else
   if((cfg = get_config_val(config, config_pingtimeout)) == NULL)
     timeout = 60;
   else
index b2ced41..fcbc45a 100644 (file)
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
     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"
 */
 
 #include "config.h"
 
 /* lists type of subnet */
 
 
 /* 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 */
 
 
 /* Subnet comparison */
 
@@ -132,7 +138,7 @@ cp
 void subnet_del(subnet_t *subnet)
 {
 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
 }
   rbl_delete(subnet_tree, subnet);
 cp
 }
index b409fd4..1aab681 100644 (file)
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
     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__
 */
 
 #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 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 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);
 extern subnet_t *lookup_subnet_mac(mac_t);
 extern subnet_t *lookup_subnet_ipv4(ipv4_t);
 extern subnet_t *lookup_subnet_ipv6(ipv6_t);