From 7f1a29a5161b26e302185113d64d0df311b07ce1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 14 Jun 2014 14:58:33 +0200 Subject: peer_hashtable: fix address hashing on systems with holes in sockaddr definitions --- src/peer_hashtable.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/peer_hashtable.c b/src/peer_hashtable.c index b191f63..100e8a3 100644 --- a/src/peer_hashtable.c +++ b/src/peer_hashtable.c @@ -66,11 +66,15 @@ static size_t peer_address_bucket(const fastd_peer_address_t *addr) { switch(addr->sa.sa_family) { case AF_INET: - fastd_hash(&hash, &addr->in, sizeof(addr->in)); + fastd_hash(&hash, &addr->in.sin_addr.s_addr, sizeof(addr->in.sin_addr.s_addr)); + fastd_hash(&hash, &addr->in.sin_port, sizeof(addr->in.sin_port)); break; case AF_INET6: - fastd_hash(&hash, &addr->in6, sizeof(addr->in6)); + fastd_hash(&hash, &addr->in6.sin6_addr, sizeof(addr->in6.sin6_addr)); + fastd_hash(&hash, &addr->in6.sin6_port, sizeof(addr->in6.sin6_port)); + if (IN6_IS_ADDR_LINKLOCAL(&addr->in6.sin6_addr)) + fastd_hash(&hash, &addr->in6.sin6_scope_id, sizeof(addr->in6.sin6_scope_id)); break; default: -- cgit v1.2.3