-int read_host_config(nodet *n)
-{
- char *fname;
- int x;
-cp
- asprintf(&fname, "%s/hosts/%s", confbase, n->name);
- x = read_config_file(&n->config, fname);
- free(fname);
-cp
- return x;
+ for(node = n->edge_tree->head; node; node = next) {
+ next = node->next;
+ e = node->data;
+ edge_del(e);
+ }
+
+ avl_delete(node_udp_tree, n);
+ avl_delete(node_tree, n);
+}
+
+node_t *lookup_node(char *name) {
+ node_t n = {0};
+
+ n.name = name;
+
+ return avl_search(node_tree, &n);
+}
+
+node_t *lookup_node_udp(const sockaddr_t *sa) {
+ node_t n = {0};
+
+ n.address = *sa;
+ n.name = NULL;
+
+ return avl_search(node_udp_tree, &n);
+}
+
+void update_node_udp(node_t *n, const sockaddr_t *sa) {
+ avl_delete(node_udp_tree, n);
+
+ if(n->hostname)
+ free(n->hostname);
+
+ if(sa) {
+ n->address = *sa;
+ n->hostname = sockaddr2hostname(&n->address);
+ avl_insert(node_udp_tree, n);
+ ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s set to %s", n->name, n->hostname);
+ } else {
+ memset(&n->address, 0, sizeof n->address);
+ n->hostname = 0;
+ ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s cleared", n->name);
+ }