diff options
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-client.c')
-rw-r--r-- | src/libsystemd-network/sd-dhcp-client.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index b108e35386..287b6e26fa 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -298,8 +298,8 @@ int sd_dhcp_client_set_client_id(sd_dhcp_client *client, uint8_t type, return 0; } -int sd_dhcp_client_set_iaid_duid(sd_dhcp_client *client, be32_t iaid, - size_t duid_len, struct duid *duid) { +int sd_dhcp_client_set_iaid_duid(sd_dhcp_client *client, uint32_t iaid, + uint16_t duid_type, uint8_t *duid, size_t duid_len) { DHCP_CLIENT_DONT_DESTROY(client); int r; assert_return(client, -EINVAL); @@ -315,7 +315,7 @@ int sd_dhcp_client_set_iaid_duid(sd_dhcp_client *client, be32_t iaid, if (r < 0) return r; } else - client->client_id.ns.iaid = iaid; + client->client_id.ns.iaid = htobe32(iaid); /* If DUID is not configured, generate DUID-EN. */ if (duid_len == 0) { @@ -324,11 +324,12 @@ int sd_dhcp_client_set_iaid_duid(sd_dhcp_client *client, be32_t iaid, if (r < 0) return r; } else { - r = dhcp_validate_duid_len(client->client_id.type, - duid_len - sizeof(client->client_id.type)); + r = dhcp_validate_duid_len(client->client_id.type, duid_len); if (r < 0) return r; - memcpy(&client->client_id.ns.duid, duid, duid_len); + client->client_id.ns.duid.type = htobe16(duid_type); + memcpy(&client->client_id.ns.duid.raw.data, duid, duid_len); + duid_len += sizeof(client->client_id.ns.duid.type); } client->client_id_len = sizeof(client->client_id.type) + duid_len + @@ -514,6 +515,7 @@ static int client_message_init(sd_dhcp_client *client, DHCPPacket **ret, if (client->arp_type == ARPHRD_ETHER) memcpy(&packet->dhcp.chaddr, &client->mac_addr, ETH_ALEN); + /* If no client identifier exists, construct an RFC 4361-compliant one */ if (client->client_id_len == 0) { size_t duid_len; |