diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-11-05 10:11:17 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-11-05 10:11:17 +0100 |
commit | 0c2f5da1650a295c29001e50384ec2f605055aed (patch) | |
tree | a40f81576efd9b8d2a9944fdb6c754f83eb4685a /src/peer.c | |
parent | 51aa24d4a2825a050a6c048d69c24a10d98d4993 (diff) | |
download | fastd-0c2f5da1650a295c29001e50384ec2f605055aed.tar fastd-0c2f5da1650a295c29001e50384ec2f605055aed.zip |
Fix some more bugs in fastd_peer_claim_address
Diffstat (limited to 'src/peer.c')
-rw-r--r-- | src/peer.c | 33 |
1 files changed, 18 insertions, 15 deletions
@@ -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; } } |