edge.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. edge.h -- header for edge.c
  3. Copyright (C) 2001-2002 Guus Sliepen <guus@sliepen.warande.net>,
  4. 2001-2002 Ivo Timmermans <itimmermans@bigfoot.com>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. $Id: edge.h,v 1.1.2.5 2002/02/10 21:57:54 guus Exp $
  17. */
  18. #ifndef __TINC_EDGE_H__
  19. #define __TINC_EDGE_H__
  20. #include <avl_tree.h>
  21. #include "node.h"
  22. #include "connection.h"
  23. typedef struct halfconnection_t {
  24. struct node_t *node; /* node associated with this end of the connection */
  25. ipv4_t address; /* real (internet) ip on this end of the meta connection */
  26. port_t port; /* port number of this end of the meta connection */
  27. } halfconnection_t;
  28. typedef struct edge_t {
  29. struct halfconnection_t from;
  30. struct halfconnection_t to;
  31. long int options; /* options turned on for this edge */
  32. int weight; /* weight of this edge */
  33. struct connection_t *connection; /* connection associated with this edge, if available */
  34. } edge_t;
  35. extern avl_tree_t *edge_tree; /* Tree with all known edges (replaces active_tree) */
  36. extern avl_tree_t *edge_weight_tree; /* Tree with all known edges sorted on weight */
  37. extern void init_edges(void);
  38. extern void exit_edges(void);
  39. extern edge_t *new_edge(void);
  40. extern void free_edge(edge_t *);
  41. extern avl_tree_t *new_edge_tree(void);
  42. extern void free_edge_tree(avl_tree_t *);
  43. extern void edge_add(edge_t *);
  44. extern void edge_del(edge_t *);
  45. extern edge_t *lookup_edge(struct node_t *, struct node_t *);
  46. extern void dump_edges(void);
  47. #endif /* __TINC_EDGE_H__ */