mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 08:56:15 +09:00
network: JSON - Export DHCPv4 client ID
Allow networkd to export the DHCP4 client ID which right now we don't support.
This commit is contained in:
committed by
Luca Boccassi
parent
14975aaef8
commit
09584d7afb
@@ -1220,6 +1220,29 @@ static int dhcp_client_private_options_append_json(Link *link, JsonVariant **v)
|
||||
return json_variant_set_field_non_null(v, "PrivateOptions", array);
|
||||
}
|
||||
|
||||
static int dhcp_client_id_append_json(Link *link, JsonVariant **v) {
|
||||
const sd_dhcp_client_id *client_id;
|
||||
const void *data;
|
||||
size_t l;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
assert(v);
|
||||
|
||||
if (!link->dhcp_client)
|
||||
return 0;
|
||||
|
||||
r = sd_dhcp_client_get_client_id(link->dhcp_client, &client_id);
|
||||
if (r < 0)
|
||||
return 0;
|
||||
|
||||
r = sd_dhcp_client_id_get_raw(client_id, &data, &l);
|
||||
if (r < 0)
|
||||
return 0;
|
||||
|
||||
return json_variant_merge_objectb(v, JSON_BUILD_OBJECT(JSON_BUILD_PAIR_BYTE_ARRAY("ClientIdentifier", data, l)));
|
||||
}
|
||||
|
||||
static int dhcp_client_append_json(Link *link, JsonVariant **v) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *w = NULL;
|
||||
int r;
|
||||
@@ -1242,6 +1265,10 @@ static int dhcp_client_append_json(Link *link, JsonVariant **v) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = dhcp_client_id_append_json(link, &w);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return json_variant_set_field_non_null(v, "DHCPv4Client", w);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user