Move all source code to src/.
[oweals/tinc.git] / src / 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 #include "tnl/tnl.h"
30
31 typedef struct edge_status {
32         int visited:1;
33         int mst:1;
34 } edge_status_t;
35
36 typedef struct edge {
37         struct node *from;
38         struct node *to;
39         struct sockaddr_storage address;
40
41         int weight;
42
43         struct edge *reverse;
44         struct tnl *tnl;
45
46         edge_status_t status;
47         node_options_t options;
48 } edge_t;
49
50 extern avl_tree_t *edges;
51
52 extern bool edge_init(void);
53 extern bool edge_exit(void);
54 extern struct edge *edge_new(void) __attribute__ ((__malloc__));
55 extern void edge_free(struct edge *);
56 extern avl_tree_t *edge_tree_new(void) __attribute__ ((__malloc__));
57 extern void edge_tree_free(avl_tree_t *);
58 extern void edge_add(struct edge *);
59 extern void edge_del(struct edge *);
60 extern struct edge *edge_get(struct node *, struct node *);
61
62 #endif