- Proper initialization of rbltree structures.

This commit is contained in:
Guus Sliepen 2000-11-20 19:41:13 +00:00
parent 408ca91766
commit 1857b3c97c
4 changed files with 21 additions and 7 deletions

View 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.
$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 <utils.h>
#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;
}

View 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.
$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

View 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.
$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
}

View 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.
$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);