dhcp: nettools: export broadcast and server-id options

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/426
(cherry picked from commit 020a2707c4)
This commit is contained in:
Beniamino Galvani 2021-02-09 21:24:59 +01:00
parent 221547bc21
commit 086452e9ab

View file

@ -518,6 +518,38 @@ lease_parse_address_list(NDhcp4ClientLease * lease,
nm_dhcp_option_add_option(options, _nm_dhcp_option_dhcp4_options, option, str->str);
}
static void
lease_parse_server_id(NDhcp4ClientLease *lease, NMIP4Config *ip4_config, GHashTable *options)
{
struct in_addr addr;
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
if (n_dhcp4_client_lease_get_server_identifier(lease, &addr))
return;
_nm_utils_inet4_ntop(addr.s_addr, addr_str);
nm_dhcp_option_add_option(options,
_nm_dhcp_option_dhcp4_options,
NM_DHCP_OPTION_DHCP4_SERVER_ID,
addr_str);
}
static void
lease_parse_broadcast(NDhcp4ClientLease *lease, NMIP4Config *ip4_config, GHashTable *options)
{
struct in_addr addr;
char addr_str[NM_UTILS_INET_ADDRSTRLEN];
if (!lease_get_in_addr(lease, NM_DHCP_OPTION_DHCP4_BROADCAST, &addr))
return;
_nm_utils_inet4_ntop(addr.s_addr, addr_str);
nm_dhcp_option_add_option(options,
_nm_dhcp_option_dhcp4_options,
NM_DHCP_OPTION_DHCP4_BROADCAST,
addr_str);
}
static void
lease_parse_routes(NDhcp4ClientLease *lease,
NMIP4Config * ip4_config,
@ -976,6 +1008,8 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx,
if (!lease_parse_address(lease, ip4_config, options, error))
return NULL;
lease_parse_server_id(lease, ip4_config, options);
lease_parse_broadcast(lease, ip4_config, options);
lease_parse_routes(lease, ip4_config, options, route_table, route_metric);
lease_parse_address_list(lease, ip4_config, NM_DHCP_OPTION_DHCP4_DOMAIN_NAME_SERVER, options);
lease_parse_domainname(lease, ip4_config, options);