summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-12 14:54:32 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-12 14:54:32 +0200
commitf01e5736f1555eec9183e48448fa3454f265b73e (patch)
treec9ce2d138c46c0b51f5cff4e7af884d051c4664c
parentc0c743cb3df7197b51bb89cc3c8ca7ed16d06396 (diff)
timesyncd: move the generic sockaddr_equal() call to socket-util.h
-rw-r--r--src/shared/socket-util.c16
-rw-r--r--src/shared/socket-util.h2
-rw-r--r--src/timesync/timesyncd.c16
3 files changed, 18 insertions, 16 deletions
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index 0a0726d87d..1a04f323ab 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -711,3 +711,19 @@ static const char* const socket_address_bind_ipv6_only_table[_SOCKET_ADDRESS_BIN
};
DEFINE_STRING_TABLE_LOOKUP(socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
+
+bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b) {
+ assert(a);
+ assert(b);
+
+ if (a->sa.sa_family != b->sa.sa_family)
+ return false;
+
+ if (a->sa.sa_family == AF_INET)
+ return a->in.sin_addr.s_addr == b->in.sin_addr.s_addr;
+
+ if (a->sa.sa_family == AF_INET6)
+ return memcmp(&a->in6.sin6_addr, &b->in6.sin6_addr, sizeof(a->in6.sin6_addr)) == 0;
+
+ return false;
+}
diff --git a/src/shared/socket-util.h b/src/shared/socket-util.h
index 9883ab0328..0b4998d044 100644
--- a/src/shared/socket-util.h
+++ b/src/shared/socket-util.h
@@ -109,3 +109,5 @@ SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *
int netlink_family_to_string_alloc(int b, char **s);
int netlink_family_from_string(const char *s) _pure_;
+
+bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b);
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c
index e5a8a578cd..500f83f673 100644
--- a/src/timesync/timesyncd.c
+++ b/src/timesync/timesyncd.c
@@ -536,22 +536,6 @@ static void manager_adjust_poll(Manager *m, double offset, bool spike) {
}
}
-static bool sockaddr_equal(union sockaddr_union *a, union sockaddr_union *b) {
- assert(a);
- assert(b);
-
- if (a->sa.sa_family != b->sa.sa_family)
- return false;
-
- if (a->sa.sa_family == AF_INET)
- return a->in.sin_addr.s_addr == b->in.sin_addr.s_addr;
-
- if (a->sa.sa_family == AF_INET6)
- return memcmp(&a->in6.sin6_addr, &b->in6.sin6_addr, sizeof(a->in6.sin6_addr)) == 0;
-
- return false;
-}
-
static int manager_receive_response(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
Manager *m = userdata;
struct ntp_msg ntpmsg;