1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 01:55:22 +03:00

sd-device-monitor: introduce device_monitor_get_address()

Currently it is used internally, but will be used later at other places.
This commit is contained in:
Yu Watanabe 2024-05-27 12:31:33 +09:00
parent 1f267e77ed
commit 7abc0201d0
2 changed files with 12 additions and 3 deletions

View 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);

View 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) {