summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2021-02-09 21:24:59 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2021-02-10 09:13:03 +0100
commit020a2707c44849077f0c30af6d800f8e5f930f7f (patch)
tree140dc8bb046968dc1391cd9f7d1d7a4ec8c961ee
parent5e6d6c0764ede63fcb3d89d5dfcf49829fdd3043 (diff)
downloadNetworkManager-bg/issue426.tar.gz
dhcp: nettools: export broadcast and server-id optionsbg/issue426
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/426
-rw-r--r--src/core/dhcp/nm-dhcp-nettools.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/core/dhcp/nm-dhcp-nettools.c b/src/core/dhcp/nm-dhcp-nettools.c
index d1451a5319..ae1aeadfa4 100644
--- a/src/core/dhcp/nm-dhcp-nettools.c
+++ b/src/core/dhcp/nm-dhcp-nettools.c
@@ -517,6 +517,38 @@ lease_parse_address_list(NDhcp4ClientLease * lease,
}
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,
GHashTable * options,
@@ -974,6 +1006,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);