acf20bc180782d85bd16e6034754034d781e4bda
[oweals/tinc.git] / rt / node.h
1 /*
2     node.h -- node management
3
4     Copyright (C) 2003-2004 Guus Sliepen <guus@tinc-vpn.org>,
5                   2003-2004 Ivo Timmermans <ivo@tinc-vpn.org>
6
7     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with this program; if not, write to the Free Software
19     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21     $Id$
22 */
23
24 #ifndef __NODE_H__
25 #define __NODE_H__
26
27 typedef int node_options_t;
28
29 #define NODE_OPTION_INDIRECT 1
30
31 #include "rt/edge.h"
32 #include "rt/subnet.h"
33 #include "support/avl.h"
34 #include "tnl/tnl.h"
35
36 typedef struct node_status {
37         int active:1;
38         int visited:1;
39         int reachable:1;
40         int indirect:1;
41 } node_status_t;
42
43 typedef struct node {
44         char *name;
45
46         avl_tree_t *queue;
47
48         struct node *nexthop;
49         struct node *via;
50
51         avl_tree_t *subnets;
52         avl_tree_t *edges;
53
54         struct tnl *tnl;
55
56         node_status_t status;
57         node_options_t options;
58
59         struct sockaddr_storage address;
60
61         avl_tree_t *cfg;
62 } node_t;
63
64 extern avl_tree_t *nodes;
65 extern struct node *myself;
66
67 extern bool node_init(void);
68 extern bool node_exit(void);
69 extern struct node *node_new(void) __attribute__ ((__malloc__));
70 extern void node_free(struct node *);
71 extern void node_add(struct node *);
72 extern void node_del(struct node *);
73 extern struct node *node_get(char *);
74
75 #endif