edge.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef TINC_EDGE_H
  2. #define TINC_EDGE_H
  3. /*
  4. edge.h -- header for edge.c
  5. Copyright (C) 2001-2006 Guus Sliepen <guus@tinc-vpn.org>,
  6. 2001-2005 Ivo Timmermans
  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. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License along
  16. with this program; if not, write to the Free Software Foundation, Inc.,
  17. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. */
  19. #include "avl_tree.h"
  20. #include "connection.h"
  21. #include "net.h"
  22. #include "node.h"
  23. typedef struct edge_t {
  24. struct node_t *from;
  25. struct node_t *to;
  26. sockaddr_t address;
  27. uint32_t options; /* options turned on for this edge */
  28. int weight; /* weight of this edge */
  29. struct connection_t *connection; /* connection associated with this edge, if available */
  30. struct edge_t *reverse; /* edge in the opposite direction, if available */
  31. } edge_t;
  32. extern avl_tree_t *edge_weight_tree; /* Tree with all known edges sorted on weight */
  33. extern void init_edges(void);
  34. extern void exit_edges(void);
  35. extern edge_t *new_edge(void) __attribute__((__malloc__));
  36. extern void free_edge(edge_t *e);
  37. extern avl_tree_t *new_edge_tree(void) __attribute__((__malloc__));
  38. extern void free_edge_tree(avl_tree_t *edge_tree);
  39. extern void edge_add(edge_t *e);
  40. extern void edge_del(edge_t *e);
  41. extern edge_t *lookup_edge(struct node_t *from, struct node_t *to);
  42. extern void dump_edges(void);
  43. #endif