diff options
author | Antonio Cardace <acardace@redhat.com> | 2020-08-24 18:15:01 +0200 |
---|---|---|
committer | Antonio Cardace <acardace@redhat.com> | 2020-08-25 18:47:33 +0200 |
commit | 11fb56cd0ec0a1ee30669201aef28107ea1945ce (patch) | |
tree | bfd224f57803e4a72a3d2137a052acb3cf107425 | |
parent | 3c44d3cf373265c7efd8d1083b362e0c904b0b40 (diff) | |
download | NetworkManager-ac/dhcp_vendor_class_opt.tar.gz |
dhcp: implement dhcp-vendor-class-identifier option for systemd's DHCPac/dhcp_vendor_class_opt
client
https://bugzilla.redhat.com/show_bug.cgi?id=1871042
Signed-off-by: Antonio Cardace <acardace@redhat.com>
-rw-r--r-- | src/dhcp/nm-dhcp-systemd.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c index 737faad937..737ccacc48 100644 --- a/src/dhcp/nm-dhcp-systemd.c +++ b/src/dhcp/nm-dhcp-systemd.c @@ -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"); |