diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-04-16 07:29:55 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-04-16 07:29:55 +0200 |
commit | 872e0dfa86417e89022f84ac78b2d90236cb97d4 (patch) | |
tree | 640c04570466a9cf2d06eece32fdb5c07afde6cb /src/peer.c | |
parent | 3a87d747a015b2ff2150ed163ad56b1bc677e6b0 (diff) | |
download | fastd-872e0dfa86417e89022f84ac78b2d90236cb97d4.tar fastd-872e0dfa86417e89022f84ac78b2d90236cb97d4.zip |
Lots of fixes and improvements on the resolver code
Diffstat (limited to 'src/peer.c')
-rw-r--r-- | src/peer.c | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -251,7 +251,7 @@ void fastd_peer_config_purge(fastd_context *ctx, fastd_peer_config *conf) { fastd_peer_config_free(conf); } -static bool fastd_peer_addr_equal(const fastd_peer_address *addr1, const fastd_peer_address *addr2) { +bool fastd_peer_addr_equal(const fastd_peer_address *addr1, const fastd_peer_address *addr2) { if (addr1->sa.sa_family != addr2->sa.sa_family) return false; @@ -330,9 +330,6 @@ fastd_peer* fastd_peer_add(fastd_context *ctx, fastd_peer_config *peer_conf) { fastd_peer* fastd_peer_add_temp(fastd_context *ctx, const fastd_peer_address *address) { fastd_peer *peer = add_peer(ctx); - if (!ctx->conf->n_floating) - exit_bug(ctx, "tried to add a temporary peer with no floating remotes defined"); - peer->config = NULL; peer->address = *address; peer->state = STATE_TEMP; @@ -409,6 +406,26 @@ const fastd_eth_addr* fastd_get_dest_address(const fastd_context *ctx, fastd_buf } } +bool fastd_peer_config_matches_dynamic(const fastd_peer_config *config, const fastd_peer_address *addr) { + if (!config->hostname) + return false; + + if (config->address.sa.sa_family != AF_UNSPEC && + config->address.sa.sa_family != addr->sa.sa_family) + return false; + + if (addr->sa.sa_family == AF_INET6) { + if (config->address.in.sin_port != addr->in6.sin6_port) + return false; + } + else { + if (config->address.in.sin_port != addr->in.sin_port) + return false; + } + + return true; +} + static inline int fastd_eth_addr_cmp(const fastd_eth_addr *addr1, const fastd_eth_addr *addr2) { return memcmp(addr1->data, addr2->data, ETH_ALEN); } |