From f8a729015380b367bd2ecff66f31cb6253793e50 Mon Sep 17 00:00:00 2001 From: Antonio Cardace Date: Mon, 24 Aug 2020 18:14:04 +0200 Subject: [PATCH] dhcp: implement dhcp-vendor-class-identifier option for internal DHCP client https://bugzilla.redhat.com/show_bug.cgi?id=1871042 Signed-off-by: Antonio Cardace --- src/dhcp/nm-dhcp-nettools.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/dhcp/nm-dhcp-nettools.c b/src/dhcp/nm-dhcp-nettools.c index 2ceed09537..ec24a77f42 100644 --- a/src/dhcp/nm-dhcp-nettools.c +++ b/src/dhcp/nm-dhcp-nettools.c @@ -1333,6 +1333,7 @@ ip4_start (NMDhcpClient *client, struct in_addr last_addr = { 0 }; const char *hostname; const char *mud_url; + GBytes *vendor_class_identifier; int r, i; g_return_val_if_fail (!priv->probe, FALSE); @@ -1454,6 +1455,25 @@ ip4_start (NMDhcpClient *client, } } + vendor_class_identifier = nm_dhcp_client_get_vendor_class_identifier (client); + if (vendor_class_identifier) { + const void *option_data; + gsize option_size; + + option_data = g_bytes_get_data (vendor_class_identifier, &option_size); + nm_assert (option_data); + nm_assert (option_size <= 255); + + r = n_dhcp4_client_probe_config_append_option (config, + NM_DHCP_OPTION_DHCP4_VENDOR_CLASS_IDENTIFIER, + option_data, + option_size); + if (r) { + set_error_nettools (error, r, "failed to set vendor class identifier"); + return FALSE; + } + } + g_free (priv->lease_file); priv->lease_file = g_steal_pointer (&lease_file);