summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-dhcp4.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-08-22 07:22:03 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-08-24 12:50:36 +0200
commit53488ea352b658e37eef06f958c3f8ca062a64d9 (patch)
tree5ff8ba71c912aaed25b1b813cc9cb95c9cfc8dc8 /src/network/networkd-dhcp4.c
parentRevert "network: DHCP6 client- Allow to send manual DUID" (diff)
downloadsystemd-53488ea352b658e37eef06f958c3f8ca062a64d9.tar.xz
systemd-53488ea352b658e37eef06f958c3f8ca062a64d9.zip
network: introduce per DUID type setters
No functional change, just refactoring.
Diffstat (limited to 'src/network/networkd-dhcp4.c')
-rw-r--r--src/network/networkd-dhcp4.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index eeb3585f29..9dcd37e11c 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -1326,20 +1326,42 @@ static int dhcp4_set_client_identifier(Link *link) {
/* If configured, apply user specified DUID and IAID */
const DUID *duid = link_get_dhcp4_duid(link);
- if (duid->type == DUID_TYPE_LLT && duid->raw_data_len == 0)
- r = sd_dhcp_client_set_iaid_duid_llt(link->dhcp_client,
+ if (duid->raw_data_len == 0)
+ switch (duid->type) {
+ case DUID_TYPE_LLT:
+ r = sd_dhcp_client_set_iaid_duid_llt(link->dhcp_client,
+ link->network->dhcp_iaid_set,
+ link->network->dhcp_iaid,
+ duid->llt_time);
+ break;
+ case DUID_TYPE_LL:
+ r = sd_dhcp_client_set_iaid_duid_ll(link->dhcp_client,
+ link->network->dhcp_iaid_set,
+ link->network->dhcp_iaid);
+ break;
+ case DUID_TYPE_EN:
+ r = sd_dhcp_client_set_iaid_duid_en(link->dhcp_client,
+ link->network->dhcp_iaid_set,
+ link->network->dhcp_iaid);
+ break;
+ case DUID_TYPE_UUID:
+ r = sd_dhcp_client_set_iaid_duid_uuid(link->dhcp_client,
+ link->network->dhcp_iaid_set,
+ link->network->dhcp_iaid);
+ break;
+ default:
+ r = sd_dhcp_client_set_iaid_duid_raw(link->dhcp_client,
+ link->network->dhcp_iaid_set,
+ link->network->dhcp_iaid,
+ duid->type, NULL, 0);
+ }
+ else
+ r = sd_dhcp_client_set_iaid_duid_raw(link->dhcp_client,
link->network->dhcp_iaid_set,
link->network->dhcp_iaid,
- duid->llt_time);
- else
- r = sd_dhcp_client_set_iaid_duid(link->dhcp_client,
- link->network->dhcp_iaid_set,
- link->network->dhcp_iaid,
- duid->type,
- duid->raw_data_len > 0 ? duid->raw_data : NULL,
- duid->raw_data_len);
+ duid->type, duid->raw_data, duid->raw_data_len);
if (r < 0)
- return log_link_debug_errno(link, r, "DHCPv4 CLIENT: Failed to set IAID+DUID: %m");
+ return r;
break;
}
case DHCP_CLIENT_ID_MAC: {