aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-06-25 18:23:13 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-08-08 10:15:00 +0900
commit27eba50e76819c447f7bea8c33ba062c5fb996c6 (patch)
tree4cbb1d5303285e4cbe450ad194d3c4ec733b981b /src/libsystemd-network/sd-dhcp6-client.c
parenthostname: expose product UUID on bus (diff)
downloadsystemd-27eba50e76819c447f7bea8c33ba062c5fb996c6.tar.gz
systemd-27eba50e76819c447f7bea8c33ba062c5fb996c6.tar.bz2
systemd-27eba50e76819c447f7bea8c33ba062c5fb996c6.zip
sd-dhcp: use application specific machine ID when DUIDType=uuid but DUIDRawData= is not set
Diffstat (limited to 'src/libsystemd-network/sd-dhcp6-client.c')
-rw-r--r--src/libsystemd-network/sd-dhcp6-client.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index ff54d7e20..31382b543 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -187,8 +187,8 @@ int sd_dhcp6_client_set_duid(
uint16_t duid_type,
const void *duid,
size_t duid_len) {
-
int r;
+
assert_return(client, -EINVAL);
assert_return(duid_len == 0 || duid != NULL, -EINVAL);
assert_return(IN_SET(client->state, DHCP6_STATE_STOPPED), -EBUSY);
@@ -197,18 +197,25 @@ int sd_dhcp6_client_set_duid(
r = dhcp_validate_duid_len(duid_type, duid_len);
if (r < 0)
return r;
- }
- if (duid != NULL) {
client->duid.type = htobe16(duid_type);
memcpy(&client->duid.raw.data, duid, duid_len);
client->duid_len = sizeof(client->duid.type) + duid_len;
- } else if (duid_type == DUID_TYPE_EN) {
- r = dhcp_identifier_set_duid_en(&client->duid, &client->duid_len);
- if (r < 0)
- return r;
} else
- return -EOPNOTSUPP;
+ switch (duid_type) {
+ case DUID_TYPE_EN:
+ r = dhcp_identifier_set_duid_en(&client->duid, &client->duid_len);
+ if (r < 0)
+ return r;
+ break;
+ case DUID_TYPE_UUID:
+ r = dhcp_identifier_set_duid_uuid(&client->duid, &client->duid_len);
+ if (r < 0)
+ return r;
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
return 0;
}