]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
socket-util: socket_address_equal_unix()
authorIvan Kruglov <mail@ikruglov.com>
Mon, 12 May 2025 11:17:38 +0000 (04:17 -0700)
committerIvan Kruglov <mail@ikruglov.com>
Tue, 13 May 2025 08:55:15 +0000 (01:55 -0700)
src/basic/socket-util.c
src/basic/socket-util.h

index 5e6195e108e5fec21cfe74f4a418c8e0be1dcfac..2c003106c9f7716883419455b883c33b6eb445da 100644 (file)
@@ -1797,6 +1797,24 @@ int socket_address_parse_unix(SocketAddress *ret_address, const char *s) {
         return 0;
 }
 
+int socket_address_equal_unix(const char *a, const char *b) {
+        SocketAddress socket_a, socket_b;
+        int r;
+
+        assert(a);
+        assert(b);
+
+        r = socket_address_parse_unix(&socket_a, a);
+        if (r < 0)
+                return r;
+
+        r = socket_address_parse_unix(&socket_b, b);
+        if (r < 0)
+                return r;
+
+        return sockaddr_equal(&socket_a.sockaddr, &socket_b.sockaddr);
+}
+
 int vsock_parse_port(const char *s, unsigned *ret) {
         int r;
 
index e9671c38333b87d7ea388566811253d681f605e2..830b48e435f1989faec091034de8c97bbaec4b25 100644 (file)
@@ -342,6 +342,7 @@ int vsock_parse_cid(const char *s, unsigned *ret);
  * protocol mismatch. */
 int socket_address_parse_unix(SocketAddress *ret_address, const char *s);
 int socket_address_parse_vsock(SocketAddress *ret_address, const char *s);
+int socket_address_equal_unix(const char *a, const char *b);
 
 /* libc's SOMAXCONN is defined to 128 or 4096 (at least on glibc). But actually, the value can be much
  * larger. In our codebase we want to set it to the max usually, since nowadays socket memory is properly