diff --git a/lib/socket.c b/lib/socket.c index c98f0bd43..10eff94b1 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -19,8 +19,8 @@ static bool __ip6_addr_print(const sockaddr_t *a, char *buf, size_t len); static bool __ip6_addr_print_p(const sockaddr_t *a, char *buf, size_t len); static unsigned int __ip4_hash(const sockaddr_t *a); static unsigned int __ip6_hash(const sockaddr_t *a); -static int __ip4_eq(const sockaddr_t *a, const sockaddr_t *b); -static int __ip6_eq(const sockaddr_t *a, const sockaddr_t *b); +static bool __ip4_eq(const sockaddr_t *a, const sockaddr_t *b); +static bool __ip6_eq(const sockaddr_t *a, const sockaddr_t *b); static bool __ip4_is_specified(const sockaddr_t *a); static bool __ip6_is_specified(const sockaddr_t *a); static bool __ip_bind(socket_t *s, unsigned int, const sockaddr_t *); @@ -197,11 +197,11 @@ static unsigned int __ip4_hash(const sockaddr_t *a) { static unsigned int __ip6_hash(const sockaddr_t *a) { return in6_addr_hash(&a->ipv6); } -static int __ip4_eq(const sockaddr_t *a, const sockaddr_t *b) { - return !memcmp(&a->ipv4, &b->ipv4, sizeof(a->ipv4)); +static bool __ip4_eq(const sockaddr_t *a, const sockaddr_t *b) { + return memcmp(&a->ipv4, &b->ipv4, sizeof(a->ipv4)) == 0; } -static int __ip6_eq(const sockaddr_t *a, const sockaddr_t *b) { - return !memcmp(&a->ipv6, &b->ipv6, sizeof(a->ipv6)); +static bool __ip6_eq(const sockaddr_t *a, const sockaddr_t *b) { + return memcmp(&a->ipv6, &b->ipv6, sizeof(a->ipv6)) == 0; } static bool __ip4_is_specified(const sockaddr_t *a) { return a->ipv4.s_addr != 0; diff --git a/lib/socket.h b/lib/socket.h index e8a36dfa1..f6c23405a 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -61,7 +61,7 @@ struct socket_family { const char *rfc_name; /* "IP4" */ const char *unspec_string; /* 0.0.0.0 or :: */ unsigned int (*hash)(const sockaddr_t *); - int (*eq)(const sockaddr_t *, const sockaddr_t *); + bool (*eq)(const sockaddr_t *, const sockaddr_t *); bool (*addr_parse)(sockaddr_t *, const char *); bool (*addr_print)(const sockaddr_t *, char *, size_t); bool (*addr_print_p)(const sockaddr_t *, char *, size_t);