summaryrefslogtreecommitdiffstats
path: root/src/peer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/peer.c')
-rw-r--r--src/peer.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/peer.c b/src/peer.c
index 47e863e..97c21ed 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -326,22 +326,25 @@ bool fastd_peer_claim_address(fastd_context *ctx, fastd_peer *new_peer, fastd_so
else {
fastd_peer *peer;
for (peer = ctx->peers; peer; peer = peer->next) {
- if (fastd_peer_address_equal(&peer->address, addr)) {
- if (peer == new_peer)
- break;
-
- if (fastd_peer_is_floating(peer) || fastd_peer_is_dynamic(peer)) {
- if (fastd_peer_is_established(peer))
- fastd_peer_reset(ctx, peer);
-
- memset(&peer->address, 0, sizeof(fastd_peer_address));
- break;
- }
- else {
- memset(&new_peer->address, 0, sizeof(fastd_peer_address));
- return false;
- }
+ if (!fastd_peer_address_equal(&peer->address, addr))
+ continue;
+
+ if (peer == new_peer)
+ break;
+
+ if (!fastd_peer_is_floating(peer)) {
+ if (fastd_peer_is_established(new_peer))
+ fastd_peer_reset(ctx, new_peer);
+
+ memset(&new_peer->address, 0, sizeof(fastd_peer_address));
+ return false;
}
+
+ if (fastd_peer_is_established(peer))
+ fastd_peer_reset(ctx, peer);
+
+ memset(&peer->address, 0, sizeof(fastd_peer_address));
+ break;
}
}