sd-dhcp-client: introduce sd_dhcp_client_attach_device()

It will be used later.
This commit is contained in:
Yu Watanabe
2022-10-26 08:08:35 +09:00
parent 4a7b90f8a2
commit be615f7c14
2 changed files with 15 additions and 0 deletions
+13
View File
@@ -14,6 +14,7 @@
#include "sd-dhcp-client.h"
#include "alloc-util.h"
#include "device-util.h"
#include "dhcp-identifier.h"
#include "dhcp-internal.h"
#include "dhcp-lease-internal.h"
@@ -77,8 +78,12 @@ struct sd_dhcp_client {
sd_event *event;
int event_priority;
sd_event_source *timeout_resend;
int ifindex;
char *ifname;
sd_device *dev;
int fd;
uint16_t port;
union sockaddr_union link;
@@ -2153,6 +2158,12 @@ sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client) {
return client->event;
}
int sd_dhcp_client_attach_device(sd_dhcp_client *client, sd_device *dev) {
assert_return(client, -EINVAL);
return device_unref_and_replace(client->dev, dev);
}
static sd_dhcp_client *dhcp_client_free(sd_dhcp_client *client) {
if (!client)
return NULL;
@@ -2168,6 +2179,8 @@ static sd_dhcp_client *dhcp_client_free(sd_dhcp_client *client) {
sd_dhcp_client_detach_event(client);
sd_device_unref(client->dev);
set_free(client->req_opts);
free(client->hostname);
free(client->vendor_class_identifier);
+2
View File
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <stdbool.h>
#include "sd-device.h"
#include "sd-dhcp-lease.h"
#include "sd-dhcp-option.h"
#include "sd-event.h"
@@ -337,6 +338,7 @@ int sd_dhcp_client_attach_event(
int64_t priority);
int sd_dhcp_client_detach_event(sd_dhcp_client *client);
sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
int sd_dhcp_client_attach_device(sd_dhcp_client *client, sd_device *dev);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_client, sd_dhcp_client_unref);