Imported start of brand new codebase for tinc 2.0.
[tinc] / rt / edge.h
1 /*
2     edge.h -- edge 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 __EDGE_H__
25 #define __EDGE_H__
26
27 #include "rt/node.h"
28 #include "support/avl.h"
29
30 typedef struct edge_status {
31         int visited:1;
32         int mst:1;
33 } edge_status_t;
34
35 typedef struct edge {
36         struct node *from;
37         struct node *to;
38         struct sockaddr_storage address;
39
40         int weight;
41
42         struct edge *reverse;
43
44         edge_status_t status;
45         node_options_t options;
46 } edge_t;
47
48 extern avl_tree_t *edges;
49
50 extern bool edge_init(void);
51 extern bool edge_exit(void);
52 extern struct edge *edge_new(void) __attribute__ ((__malloc__));
53 extern void edge_free(struct edge *);
54 extern avl_tree_t *edge_tree_new(void) __attribute__ ((__malloc__));
55 extern void edge_tree_free(avl_tree_t *);
56 extern void edge_add(struct edge *);
57 extern void edge_del(struct edge *);
58 extern struct edge *edge_get(struct node *, struct node *);
59
60 #endif