diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-02-27 04:23:50 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-02-27 04:23:50 +0100 |
commit | 3fb7af313fbfef9e0b8195cc44b176dd3fccb15e (patch) | |
tree | 7ddebbfa2e83bb1cb47e08fc6e4a450826e974c0 /src | |
parent | 0b2285d57012111b16eca820fef59c46662b59b3 (diff) | |
download | fastd-3fb7af313fbfef9e0b8195cc44b176dd3fccb15e.tar fastd-3fb7af313fbfef9e0b8195cc44b176dd3fccb15e.zip |
Refactor fastd_peer_claim_address
Diffstat (limited to 'src')
-rw-r--r-- | src/peer.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -292,6 +292,13 @@ void fastd_peer_address_simplify(fastd_peer_address_t *addr) { } +static inline void reset_peer_address(fastd_context_t *ctx, fastd_peer_t *peer) { + if (fastd_peer_is_established(peer)) + fastd_peer_reset(ctx, peer); + + memset(&peer->address, 0, sizeof(fastd_peer_address_t)); +} + bool fastd_peer_claim_address(fastd_context_t *ctx, fastd_peer_t *new_peer, fastd_socket_t *sock, const fastd_peer_address_t *addr) { if (addr->sa.sa_family == AF_UNSPEC) { if (fastd_peer_is_established(new_peer)) @@ -307,17 +314,11 @@ bool fastd_peer_claim_address(fastd_context_t *ctx, fastd_peer_t *new_peer, fast 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_t)); + reset_peer_address(ctx, new_peer); return false; } - if (fastd_peer_is_established(peer)) - fastd_peer_reset(ctx, peer); - - memset(&peer->address, 0, sizeof(fastd_peer_address_t)); + reset_peer_address(ctx, peer); break; } } |