Introducing new function for edge weight update

This commit is contained in:
thorkill 2015-07-06 01:49:45 +02:00
parent b7820caf03
commit 7c85db5421
2 changed files with 11 additions and 0 deletions

View file

@ -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) {

View file

@ -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__ */