summaryrefslogtreecommitdiffstats
path: root/src/peer.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-07-25 13:49:01 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-07-25 13:49:01 +0200
commitfcc5bcad1add369b7b9e0a25cc63b88dfb83e5fe (patch)
tree87c22a602541d499d2a416e42facaa2a74ea4aae /src/peer.h
parent530c6eaf60cb76ab79b326c348b2039ed396e687 (diff)
downloadfastd-fcc5bcad1add369b7b9e0a25cc63b88dfb83e5fe.tar
fastd-fcc5bcad1add369b7b9e0a25cc63b88dfb83e5fe.zip
Improve handling of similar remote resolves
Diffstat (limited to 'src/peer.h')
-rw-r--r--src/peer.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/peer.h b/src/peer.h
index 1b6303e..7d85c39 100644
--- a/src/peer.h
+++ b/src/peer.h
@@ -82,6 +82,8 @@ struct fastd_peer_eth_addr {
struct fastd_remote {
fastd_remote_t *next;
+ unsigned ref;
+
fastd_remote_config_t *config;
fastd_peer_address_t address;
struct timespec last_resolve;
@@ -143,7 +145,7 @@ static inline bool fastd_peer_config_is_floating(const fastd_peer_config_t *conf
return (!config->remotes || config->floating);
}
-bool fastd_peer_remote_matches_dynamic(const fastd_remote_config_t *remote, const fastd_peer_address_t *addr);
+bool fastd_remote_matches_dynamic(const fastd_remote_config_t *remote, const fastd_peer_address_t *addr);
static inline bool fastd_peer_is_floating(const fastd_peer_t *peer) {
return peer->config ? fastd_peer_config_is_floating(peer->config) : true;
@@ -163,7 +165,16 @@ static inline bool fastd_peer_is_established(const fastd_peer_t *peer) {
}
}
-static inline bool fastd_peer_remote_is_dynamic(const fastd_remote_t *remote) {
+static inline void fastd_remote_ref(fastd_remote_t *remote) {
+ remote->ref++;
+}
+
+static inline void fastd_remote_unref(fastd_remote_t *remote) {
+ if(!--remote->ref)
+ free(remote);
+}
+
+static inline bool fastd_remote_is_dynamic(const fastd_remote_t *remote) {
return remote->config->hostname;
}