-node_t *lookup_node_udp(meshlink_handle_t *mesh, const sockaddr_t *sa) {
- return hash_search(mesh->node_udp_cache, sa);
-}
-
-void update_node_udp(meshlink_handle_t *mesh, node_t *n, const sockaddr_t *sa) {
- if(n == mesh->self) {
- logger(mesh, MESHLINK_WARNING, "Trying to update UDP address of mesh->self!");
- return;
- }
-
- hash_insert(mesh->node_udp_cache, &n->address, NULL);
-
- if(sa) {
- n->address = *sa;
- n->sock = 0;
-
- for(int i = 0; i < mesh->listen_sockets; i++) {
- if(mesh->listen_socket[i].sa.sa.sa_family == sa->sa.sa_family) {
- n->sock = i;
- break;
- }
- }
-
- hash_insert(mesh->node_udp_cache, sa, n);
-
- node_add_recent_address(mesh, n, sa);
-
- if(mesh->log_level <= MESHLINK_DEBUG) {
- char *hostname = sockaddr2hostname(&n->address);
- logger(mesh, MESHLINK_DEBUG, "UDP address of %s set to %s", n->name, hostname);
- free(hostname);
- }
- }
-}
-