+
+bool node_add_recent_address(meshlink_handle_t *mesh, node_t *n, const sockaddr_t *sa) {
+ (void)mesh;
+ bool found = false;
+ int i;
+
+ /* Check if we already know this address */
+ for(i = 0; i < MAX_RECENT && n->recent[i].sa.sa_family; i++) {
+ if(!sockaddrcmp(&n->recent[i], sa)) {
+ found = true;
+ break;
+ }
+ }
+
+ if(found && i == 0) {
+ /* It's already the most recent address, nothing to do. */
+ return false;
+ }
+
+ if(i >= MAX_RECENT) {
+ i = MAX_RECENT - 1;
+ }
+
+ memmove(n->recent + 1, n->recent, i * sizeof(*n->recent));
+ memcpy(n->recent, sa, SALEN(sa->sa));
+
+ n->status.dirty = true;
+ return !found;
+}