-void dump_nodes(void)
-{
- avl_node_t *node;
- node_t *n;
-cp
- syslog(LOG_DEBUG, _("Nodes:"));
-
- for(node = node_tree->head; node; node = node->next)
- {
- n = (connection_t *)node->data;
- syslog(LOG_DEBUG, _(" %s at %s port %hd options %ld sockets %d, %d status %04x"),
- n->name, n->hostname, n->port, n->options,
- n->socket, n->meta_socket, n->status);
- }
-
- syslog(LOG_DEBUG, _("End of nodes."));
-cp
+node_t *lookup_node_udp(const sockaddr_t *sa) {
+ node_t n = {NULL};
+
+ n.address = *sa;
+ n.name = NULL;
+
+ return avl_search(node_udp_tree, &n);
+}
+
+void update_node_udp(node_t *n, const sockaddr_t *sa) {
+ if(n == myself) {
+ logger(LOG_WARNING, "Trying to update UDP address of myself!");
+ return;
+ }
+
+ 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 = NULL;
+ ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s cleared", n->name);
+ }
+}
+
+void dump_nodes(void) {
+ avl_node_t *node;
+ node_t *n;
+
+ logger(LOG_DEBUG, "Nodes:");
+
+ for(node = node_tree->head; node; node = node->next) {
+ n = node->data;
+ logger(LOG_DEBUG, " %s at %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s pmtu %d (min %d max %d)",
+ n->name, n->hostname, n->outcipher ? EVP_CIPHER_nid(n->outcipher) : 0,
+ n->outdigest ? EVP_MD_type(n->outdigest) : 0, n->outmaclength, n->outcompression,
+ n->options, bitfield_to_int(&n->status, sizeof(n->status)), n->nexthop ? n->nexthop->name : "-",
+ n->via ? n->via->name : "-", n->mtu, n->minmtu, n->maxmtu);
+ }
+
+ logger(LOG_DEBUG, "End of nodes.");