Skip to content

Commit

Permalink
sd-dhcp6-client: introduce direct getter and setter of DUID
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwata committed Dec 22, 2023
1 parent 97c3506 commit ce9bd20
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/libsystemd-network/sd-dhcp6-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,26 @@ int sd_dhcp6_client_set_duid_raw(sd_dhcp6_client *client, uint16_t duid_type, co
return 0;
}

int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, const sd_dhcp_duid *duid) {
assert_return(client, -EINVAL);
assert_return(!sd_dhcp6_client_is_running(client), -EBUSY);
assert_return(sd_dhcp_duid_is_set(duid), -EINVAL);

client->duid = *duid;
return 0;
}

int sd_dhcp6_client_get_duid(sd_dhcp6_client *client, const sd_dhcp_duid **ret) {
assert_return(client, -EINVAL);
assert_return(ret, -EINVAL);

if (!sd_dhcp_duid_is_set(&client->duid))
return -ENODATA;

*ret = &client->duid;
return 0;
}

int sd_dhcp6_client_duid_as_string(
sd_dhcp6_client *client,
char **duid) {
Expand Down
3 changes: 3 additions & 0 deletions src/systemd/sd-dhcp6-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <sys/types.h>

#include "sd-device.h"
#include "sd-dhcp-duid.h"
#include "sd-dhcp6-lease.h"
#include "sd-dhcp6-option.h"
#include "sd-event.h"
Expand Down Expand Up @@ -68,6 +69,8 @@ int sd_dhcp6_client_set_duid_ll(sd_dhcp6_client *client);
int sd_dhcp6_client_set_duid_en(sd_dhcp6_client *client);
int sd_dhcp6_client_set_duid_uuid(sd_dhcp6_client *client);
int sd_dhcp6_client_set_duid_raw(sd_dhcp6_client *client, uint16_t duid_type, const uint8_t *duid, size_t duid_len);
int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, const sd_dhcp_duid *duid);
int sd_dhcp6_client_get_duid(sd_dhcp6_client *client, const sd_dhcp_duid **ret);
int sd_dhcp6_client_set_iaid(
sd_dhcp6_client *client,
uint32_t iaid);
Expand Down

0 comments on commit ce9bd20

Please sign in to comment.