dhcp: implement dhcp-vendor-class-identifier option for systemd's DHCP

client

https://bugzilla.redhat.com/show_bug.cgi?id=1871042
Signed-off-by: Antonio Cardace <acardace@redhat.com>
This commit is contained in:
Antonio Cardace 2020-08-24 18:15:01 +02:00
parent f8a7290153
commit 5da0939a3f
No known key found for this signature in database
GPG key ID: 6BF80ABD43E377D3

View file

@ -569,6 +569,7 @@ ip4_start (NMDhcpClient *client,
int arp_type;
GBytes *client_id;
gs_unref_bytes GBytes *client_id_new = NULL;
GBytes *vendor_class_identifier;
const uint8_t *client_id_arr;
size_t client_id_len;
struct in_addr last_addr = { 0 };
@ -698,6 +699,24 @@ ip4_start (NMDhcpClient *client,
}
}
vendor_class_identifier = nm_dhcp_client_get_vendor_class_identifier (client);
if (vendor_class_identifier) {
const char *option_data;
gsize len;
option_data = g_bytes_get_data (vendor_class_identifier, &len);
nm_assert (option_data);
nm_assert (len <= 255);
option_data = nm_strndup_a (300, option_data, len, NULL);
r = sd_dhcp_client_set_vendor_class_identifier (sd_client, option_data);
if (r < 0) {
nm_utils_error_set_errno (error, r, "failed to set DHCP vendor class identifier: %s");
return FALSE;
}
}
r = sd_dhcp_client_set_callback (sd_client, dhcp_event_cb, client);
if (r < 0) {
nm_utils_error_set_errno (error, r, "failed to set callback: %s");