]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device-monitor: introduce device_monitor_get_address()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 27 May 2024 03:31:33 +0000 (12:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Aug 2024 02:16:33 +0000 (11:16 +0900)
Currently it is used internally, but will be used later at other places.

src/libsystemd/sd-device/device-monitor-private.h
src/libsystemd/sd-device/device-monitor.c

index 96513649ff8c778768abb570d5b0d4ea432d5778..43cc1914e01fa31ed92bb2c4dbfffdbf29b1d385 100644 (file)
@@ -5,6 +5,8 @@
 
 #include "sd-device.h"
 
+#include "socket-util.h"
+
 typedef enum MonitorNetlinkGroup {
         MONITOR_GROUP_NONE,
         MONITOR_GROUP_KERNEL,
@@ -15,6 +17,7 @@ typedef enum MonitorNetlinkGroup {
 
 int device_monitor_new_full(sd_device_monitor **ret, MonitorNetlinkGroup group, int fd);
 int device_monitor_disconnect(sd_device_monitor *m);
+int device_monitor_get_address(sd_device_monitor *m, union sockaddr_union *ret);
 int device_monitor_allow_unicast_sender(sd_device_monitor *m, sd_device_monitor *sender);
 int device_monitor_get_fd(sd_device_monitor *m);
 int device_monitor_send_device(sd_device_monitor *m, sd_device_monitor *destination, sd_device *device);
index 49167c69f5a6e7c76763dbc477e8cd18490e8caa..56f8836ef317452698333d554fac95c81129f1c4 100644 (file)
@@ -25,7 +25,6 @@
 #include "missing_socket.h"
 #include "mountpoint-util.h"
 #include "set.h"
-#include "socket-util.h"
 #include "stat-util.h"
 #include "string-util.h"
 #include "strv.h"
@@ -105,12 +104,19 @@ static int monitor_set_nl_address(sd_device_monitor *m) {
         return 0;
 }
 
+int device_monitor_get_address(sd_device_monitor *m, union sockaddr_union *ret) {
+        assert(m);
+        assert(ret);
+
+        *ret = m->snl;
+        return 0;
+}
+
 int device_monitor_allow_unicast_sender(sd_device_monitor *m, sd_device_monitor *sender) {
         assert(m);
         assert(sender);
 
-        m->snl_trusted_sender.nl.nl_pid = sender->snl.nl.nl_pid;
-        return 0;
+        return device_monitor_get_address(sender, &m->snl_trusted_sender);
 }
 
 _public_ int sd_device_monitor_set_receive_buffer_size(sd_device_monitor *m, size_t size) {