diff options
Diffstat (limited to 'ctdb/protocol')
-rw-r--r-- | ctdb/protocol/protocol_util.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c index 3c8c21a472a..b42cf47fbc3 100644 --- a/ctdb/protocol/protocol_util.c +++ b/ctdb/protocol/protocol_util.c @@ -328,11 +328,9 @@ void ctdb_sock_addr_set_port(ctdb_sock_addr *addr, unsigned int port) } } -int ctdb_sock_addr_cmp_ip(const ctdb_sock_addr *addr1, - const ctdb_sock_addr *addr2) +static int ctdb_sock_addr_cmp_family(const ctdb_sock_addr *addr1, + const ctdb_sock_addr *addr2) { - int ret = 0; - /* This is somewhat arbitrary. However, when used for sorting * it just needs to be consistent. */ @@ -343,6 +341,19 @@ int ctdb_sock_addr_cmp_ip(const ctdb_sock_addr *addr1, return 1; } + return 0; +} + +int ctdb_sock_addr_cmp_ip(const ctdb_sock_addr *addr1, + const ctdb_sock_addr *addr2) +{ + int ret; + + ret = ctdb_sock_addr_cmp_family(addr1, addr2); + if (ret != 0) { + return ret; + } + switch (addr1->sa.sa_family) { case AF_INET: ret = memcmp(&addr1->ip.sin_addr.s_addr, |