summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-02-27 04:23:50 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-02-27 04:23:50 +0100
commit3fb7af313fbfef9e0b8195cc44b176dd3fccb15e (patch)
tree7ddebbfa2e83bb1cb47e08fc6e4a450826e974c0 /src
parent0b2285d57012111b16eca820fef59c46662b59b3 (diff)
downloadfastd-3fb7af313fbfef9e0b8195cc44b176dd3fccb15e.tar
fastd-3fb7af313fbfef9e0b8195cc44b176dd3fccb15e.zip
Refactor fastd_peer_claim_address
Diffstat (limited to 'src')
-rw-r--r--src/peer.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/peer.c b/src/peer.c
index 88b61ef..e713cbe 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -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;
}
}