summaryrefslogtreecommitdiffstats
path: root/src/peer.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-04-20 18:43:12 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-04-20 18:43:12 +0200
commit3fcb880682a02e1952eb710a5952a0d7f92f41e1 (patch)
treeab829de58a61a2e6b422979df2f352caf196f6bb /src/peer.h
parentdaf3d6e8db9ef39b50dce040f864fb409bd7044a (diff)
downloadfastd-3fcb880682a02e1952eb710a5952a0d7f92f41e1.tar
fastd-3fcb880682a02e1952eb710a5952a0d7f92f41e1.zip
Greatly improve handling of hosts with multiple IP addresses
Diffstat (limited to 'src/peer.h')
-rw-r--r--src/peer.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/peer.h b/src/peer.h
index dde19dd..4b57197 100644
--- a/src/peer.h
+++ b/src/peer.h
@@ -37,6 +37,7 @@ struct fastd_peer {
fastd_peer_group_t *group;
fastd_socket_t *sock;
+ fastd_peer_address_t local_address;
fastd_peer_address_t address;
bool established;
@@ -82,6 +83,19 @@ struct fastd_peer_eth_addr {
bool fastd_peer_address_equal(const fastd_peer_address_t *addr1, const fastd_peer_address_t *addr2);
void fastd_peer_address_simplify(fastd_peer_address_t *addr);
+static inline uint16_t fastd_peer_address_get_port(const fastd_peer_address_t *addr) {
+ switch (addr->sa.sa_family) {
+ case AF_INET:
+ return addr->in.sin_port;
+
+ case AF_INET6:
+ return addr->in6.sin6_port;
+
+ default:
+ return 0;
+ }
+}
+
fastd_peer_config_t* fastd_peer_config_new(fastd_context_t *ctx, fastd_config_t *conf);
void fastd_peer_config_free(fastd_peer_config_t *peer);
void fastd_peer_config_delete(fastd_context_t *ctx, fastd_config_t *conf);
@@ -96,7 +110,7 @@ bool fastd_peer_verify_temporary(fastd_context_t *ctx, fastd_peer_t *peer, const
void fastd_peer_enable_temporary(fastd_context_t *ctx, fastd_peer_t *peer);
void fastd_peer_set_established(fastd_context_t *ctx, fastd_peer_t *peer);
bool fastd_peer_may_connect(fastd_context_t *ctx, fastd_peer_t *peer);
-bool fastd_peer_claim_address(fastd_context_t *ctx, fastd_peer_t *peer, fastd_socket_t *sock, const fastd_peer_address_t *addr);
+bool fastd_peer_claim_address(fastd_context_t *ctx, fastd_peer_t *peer, fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr);
void fastd_peer_reset_socket(fastd_context_t *ctx, fastd_peer_t *peer);
const fastd_eth_addr_t* fastd_get_source_address(const fastd_context_t *ctx, fastd_buffer_t buffer);