summaryrefslogtreecommitdiff
path: root/ctdb/protocol/protocol_util.c
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2017-09-13 16:18:29 +1000
committerMartin Schwenke <martins@samba.org>2017-09-19 13:30:26 +0200
commit285020360a4142fb982ad94bb21a0e87275cfed7 (patch)
treec9b2654c4836601d7bcba4f27eb0945f5da594e2 /ctdb/protocol/protocol_util.c
parent6f1b1a05fb821d49c44195c6ff91fbe21b1b10ef (diff)
downloadsamba-285020360a4142fb982ad94bb21a0e87275cfed7.tar.gz
ctdb-protocol: Factor out static function ctdb_sock_addr_cmp_family()
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/protocol/protocol_util.c')
-rw-r--r--ctdb/protocol/protocol_util.c19
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,