/*
node.c -- node tree management
- Copyright (C) 2001-2004 Guus Sliepen <guus@tinc-vpn.org>,
- 2001-2004 Ivo Timmermans <ivo@tinc-vpn.org>
+ Copyright (C) 2001-2006 Guus Sliepen <guus@tinc-vpn.org>,
+ 2001-2005 Ivo Timmermans
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
node_t *myself;
-static int node_compare(const node_t *a, const node_t *b)
-{
+static int node_compare(const node_t *a, const node_t *b) {
return strcmp(a->name, b->name);
}
-static int node_udp_compare(const node_t *a, const node_t *b)
-{
+static int node_udp_compare(const node_t *a, const node_t *b) {
int result;
cp();
return (a->name && b->name) ? strcmp(a->name, b->name) : 0;
}
-void init_nodes(void)
-{
+void init_nodes(void) {
cp();
node_tree = avl_alloc_tree((avl_compare_t) node_compare, (avl_action_t) free_node);
node_udp_tree = avl_alloc_tree((avl_compare_t) node_udp_compare, NULL);
}
-void exit_nodes(void)
-{
+void exit_nodes(void) {
cp();
avl_delete_tree(node_udp_tree);
avl_delete_tree(node_tree);
}
-node_t *new_node(void)
-{
+node_t *new_node(void) {
node_t *n = xmalloc_and_zero(sizeof(*n));
cp();
return n;
}
-void free_node(node_t *n)
-{
+void free_node(node_t *n) {
cp();
if(n->queue)
list_delete_list(n->queue);
- if(n->name)
- free(n->name);
-
- if(n->hostname)
- free(n->hostname);
-
if(n->key)
free(n->key);
EVP_CIPHER_CTX_cleanup(&n->packet_ctx);
- if(n->mtuevent)
- event_del(n->mtuevent);
+ event_del(&n->mtuevent);
+ if(n->hostname)
+ free(n->hostname);
+
+ if(n->name)
+ free(n->name);
+
free(n);
}
-void node_add(node_t *n)
-{
+void node_add(node_t *n) {
cp();
avl_insert(node_tree, n);
- avl_insert(node_udp_tree, n);
}
-void node_del(node_t *n)
-{
+void node_del(node_t *n) {
avl_node_t *node, *next;
edge_t *e;
subnet_t *s;
}
avl_delete(node_tree, n);
- avl_delete(node_udp_tree, n);
}
-node_t *lookup_node(char *name)
-{
+node_t *lookup_node(char *name) {
node_t n = {0};
cp();
return avl_search(node_tree, &n);
}
-node_t *lookup_node_udp(const sockaddr_t *sa)
-{
+node_t *lookup_node_udp(const sockaddr_t *sa) {
node_t n = {0};
cp();
return avl_search(node_udp_tree, &n);
}
-void dump_nodes(void)
-{
+void dump_nodes(void) {
avl_node_t *node;
node_t *n;