diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-10-29 22:21:47 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-10-29 22:21:47 +0100 |
commit | 078b835209bd22b5cf3f497f2b06f3fad0a078ca (patch) | |
tree | 2704129741073ce83345cc3305fbf51a988d2842 /src/peer.c | |
parent | f5462bd63a1f6fc8879341c3eacd60e9824dec24 (diff) | |
download | fastd-078b835209bd22b5cf3f497f2b06f3fad0a078ca.tar fastd-078b835209bd22b5cf3f497f2b06f3fad0a078ca.zip |
Add support for multiple binds
Diffstat (limited to 'src/peer.c')
-rw-r--r-- | src/peer.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -176,6 +176,19 @@ static inline void setup_peer(fastd_context *ctx, fastd_peer *peer) { peer->established = false; + switch (peer->address.sa.sa_family) { + case AF_INET: + peer->sock = ctx->sock_default_v4; + break; + + case AF_INET6: + peer->sock = ctx->sock_default_v6; + break; + + default: + peer->sock = NULL; + } + peer->last_resolve = (struct timespec){0, 0}; peer->last_resolve_return = (struct timespec){0, 0}; peer->seen = (struct timespec){0, 0}; @@ -280,7 +293,7 @@ bool fastd_peer_address_equal(const fastd_peer_address *addr1, const fastd_peer_ return true; } -bool fastd_peer_claim_address(fastd_context *ctx, fastd_peer *new_peer, const fastd_peer_address *addr) { +bool fastd_peer_claim_address(fastd_context *ctx, fastd_peer *new_peer, const fastd_socket *sock, const fastd_peer_address *addr) { if (addr->sa.sa_family != AF_UNSPEC) { fastd_peer *peer; for (peer = ctx->peers; peer; peer = peer->next) { @@ -304,6 +317,9 @@ bool fastd_peer_claim_address(fastd_context *ctx, fastd_peer *new_peer, const fa } new_peer->address = *addr; + if (sock) + new_peer->sock = sock; + return true; } |