#include "splay_tree.h"
#include "edge.h"
#include "logger.h"
+#include "meshlink_internal.h"
#include "netutl.h"
#include "node.h"
#include "utils.h"
#include "xalloc.h"
-splay_tree_t *edge_weight_tree;
-
static int edge_compare(const edge_t *a, const edge_t *b) {
return strcmp(a->to->name, b->to->name);
}
}
void init_edges(void) {
- edge_weight_tree = splay_alloc_tree((splay_compare_t) edge_weight_compare, NULL);
+ mesh->edges = splay_alloc_tree((splay_compare_t) edge_weight_compare, NULL);
}
splay_tree_t *new_edge_tree(void) {
}
void exit_edges(void) {
- splay_delete_tree(edge_weight_tree);
+ splay_delete_tree(mesh->edges);
}
/* Creation and deletion of connection elements */
}
void edge_add(edge_t *e) {
- splay_insert(edge_weight_tree, e);
+ splay_insert(mesh->edges, e);
splay_insert(e->from->edge_tree, e);
e->reverse = lookup_edge(e->to, e->from);
if(e->reverse)
e->reverse->reverse = NULL;
- splay_delete(edge_weight_tree, e);
+ splay_delete(mesh->edges, e);
splay_delete(e->from->edge_tree, e);
}
struct edge_t *reverse; /* edge in the opposite direction, if available */
} edge_t;
-extern struct splay_tree_t *edge_weight_tree; /* Tree with all known edges sorted on weight */
-
extern void init_edges(void);
extern void exit_edges(void);
extern edge_t *new_edge(void) __attribute__ ((__malloc__));
/* Starting point */
- for splay_each(edge_t, e, edge_weight_tree) {
+ for splay_each(edge_t, e, mesh->edges) {
if(e->from->status.reachable) {
e->from->status.visited = true;
break;
bool skipped = false;
- for splay_each(edge_t, e, edge_weight_tree) {
+ for splay_each(edge_t, e, mesh->edges) {
if(!e->reverse || (e->from->status.visited == e->to->status.visited)) {
skipped = true;
continue;
if(skipped) {
skipped = false;
- next = edge_weight_tree->head;
+ next = mesh->edges->head;
}
}
}
for splay_each(node_t, n, node_tree) {
if(!n->status.reachable) {
- for splay_each(edge_t, e, edge_weight_tree)
+ for splay_each(edge_t, e, mesh->edges)
if(e->to == n)
return;
}
bool hard = false;
static time_t last_hard_try = 0;
- for splay_each(edge_t, e, edge_weight_tree) {
+ for splay_each(edge_t, e, mesh->edges) {
if(!e->to->status.reachable || e->to == mesh->self)
continue;