summaryrefslogtreecommitdiffstats
path: root/src/peer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/peer.c')
-rw-r--r--src/peer.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/peer.c b/src/peer.c
index 54db531..e29e350 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -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;
}