]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp6-client: introduce sd_dhcp6_client_attach_device()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 25 Oct 2022 21:31:59 +0000 (06:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 25 Oct 2022 23:08:35 +0000 (08:08 +0900)
It will be used later.

src/libsystemd-network/dhcp6-internal.h
src/libsystemd-network/sd-dhcp6-client.c
src/systemd/sd-dhcp6-client.h

index 65f6cb057f4ad497832aae3ae4af0a42313b414c..13c31c24fcb7711033ab7ef066b6f502a716c87c 100644 (file)
@@ -48,6 +48,8 @@ struct sd_dhcp6_client {
         int event_priority;
         int fd;
 
+        sd_device *dev;
+
         DHCP6State state;
         bool information_request;
         usec_t information_request_time_usec;
index 375f984940c79095bb92ef2731e2273961f3fa62..8a435a5348fbb3dc2e80e779db6d53e4c9f17b1b 100644 (file)
@@ -11,6 +11,7 @@
 #include "sd-dhcp6-client.h"
 
 #include "alloc-util.h"
+#include "device-util.h"
 #include "dhcp-identifier.h"
 #include "dhcp6-internal.h"
 #include "dhcp6-lease-internal.h"
@@ -1446,6 +1447,12 @@ sd_event *sd_dhcp6_client_get_event(sd_dhcp6_client *client) {
         return client->event;
 }
 
+int sd_dhcp6_client_attach_device(sd_dhcp6_client *client, sd_device *dev) {
+        assert_return(client, -EINVAL);
+
+        return device_unref_and_replace(client->dev, dev);
+}
+
 static sd_dhcp6_client *dhcp6_client_free(sd_dhcp6_client *client) {
         if (!client)
                 return NULL;
@@ -1461,6 +1468,8 @@ static sd_dhcp6_client *dhcp6_client_free(sd_dhcp6_client *client) {
 
         client->fd = safe_close(client->fd);
 
+        sd_device_unref(client->dev);
+
         free(client->req_opts);
         free(client->fqdn);
         free(client->mudurl);
index 2c66c51b78ce036a60a5271f4a41cf84b9693665..497b2afb2f097f630b786ab477e8fcaba3282a34 100644 (file)
@@ -23,6 +23,7 @@
 #include <net/ethernet.h>
 #include <sys/types.h>
 
+#include "sd-device.h"
 #include "sd-dhcp6-lease.h"
 #include "sd-dhcp6-option.h"
 #include "sd-event.h"
@@ -279,6 +280,7 @@ int sd_dhcp6_client_attach_event(
                 int64_t priority);
 int sd_dhcp6_client_detach_event(sd_dhcp6_client *client);
 sd_event *sd_dhcp6_client_get_event(sd_dhcp6_client *client);
+int sd_dhcp6_client_attach_device(sd_dhcp6_client *client, sd_device *dev);
 sd_dhcp6_client *sd_dhcp6_client_ref(sd_dhcp6_client *client);
 sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client);
 int sd_dhcp6_client_new(sd_dhcp6_client **ret);