sd-dhcp-client: introduce sd_dhcp_client_attach_device()
It will be used later.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user