diff --git a/src/edge.c b/src/edge.c index c9252726..00ce6fef 100644 --- a/src/edge.c +++ b/src/edge.c @@ -118,6 +118,16 @@ void edge_del(edge_t *e) { splay_delete(e->from->edge_tree, e); } +bool edge_update_weigth(edge_t *e, int weight) { + splay_node_t *oldnode = splay_unlink(edge_weight_tree, e); + if (!oldnode) + return false; + + /* avg_rtt is in ms */ + e->weight = e->avg_rtt*10; + oldnode->data = e; + splay_insert_node(edge_weight_tree, oldnode); + return true; } edge_t *lookup_edge(node_t *from, node_t *to) { diff --git a/src/edge.h b/src/edge.h index e98ade88..aaf421ef 100644 --- a/src/edge.h +++ b/src/edge.h @@ -51,6 +51,7 @@ extern void free_edge_tree(splay_tree_t *); extern void edge_add(edge_t *); extern void edge_del(edge_t *); extern edge_t *lookup_edge(struct node_t *, struct node_t *); +extern bool edge_update_weigth(edge_t *, int); extern bool dump_edges(struct connection_t *); #endif /* __TINC_EDGE_H__ */