summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-20 15:06:47 +0100
committerThomas Haller <thaller@redhat.com>2020-02-20 15:20:53 +0100
commit167e7a51d7a4533d46fcf60c236e50a876a97f6b (patch)
tree3923290d86e26cd75822c47234cac007e4849dfd
parented9d79faeeedb56bb6b3fea79015e2351b54339c (diff)
downloadNetworkManager-th/nm-dhcp-config-merge.tar.gz
device: merge nm_device_get_dhcp[46]_config() to nm_device_get_dhcp_config()th/nm-dhcp-config-merge
-rw-r--r--src/devices/nm-device.c16
-rw-r--r--src/devices/nm-device.h3
-rw-r--r--src/nm-dispatcher.c4
-rw-r--r--src/nm-manager.c2
-rw-r--r--src/nm-policy.c4
5 files changed, 12 insertions, 17 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 9e9d037fd8..d9d9eea280 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -12824,11 +12824,15 @@ nm_device_set_proxy_config (NMDevice *self, const char *pac_url)
/* IP Configuration stuff */
NMDhcpConfig *
-nm_device_get_dhcp4_config (NMDevice *self)
+nm_device_get_dhcp_config (NMDevice *self, int addr_family)
{
+ const gboolean IS_IPv4 = (addr_family == AF_INET);
+
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
- return NM_DEVICE_GET_PRIVATE (self)->dhcp_data_4.config;
+ nm_assert_addr_family (addr_family);
+
+ return NM_DEVICE_GET_PRIVATE (self)->dhcp_data_x[IS_IPv4].config;
}
NMIP4Config *
@@ -13082,14 +13086,6 @@ nm_device_replace_vpn6_config (NMDevice *self, NMIP6Config *old, NMIP6Config *co
_LOGW (LOGD_IP6, "failed to set VPN routes for device");
}
-NMDhcpConfig *
-nm_device_get_dhcp6_config (NMDevice *self)
-{
- g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
-
- return NM_DEVICE_GET_PRIVATE (self)->dhcp_data_6.config;
-}
-
NMIP6Config *
nm_device_get_ip6_config (NMDevice *self)
{
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index b00f2e6c30..28f86e825e 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -504,8 +504,7 @@ const char * nm_device_get_initial_hw_address (NMDevice *dev);
NMProxyConfig * nm_device_get_proxy_config (NMDevice *dev);
-NMDhcpConfig * nm_device_get_dhcp4_config (NMDevice *dev);
-NMDhcpConfig * nm_device_get_dhcp6_config (NMDevice *dev);
+NMDhcpConfig * nm_device_get_dhcp_config (NMDevice *dev, int addr_family);
NMIP4Config * nm_device_get_ip4_config (NMDevice *dev);
void nm_device_replace_vpn4_config (NMDevice *dev,
NMIP4Config *old,
diff --git a/src/nm-dispatcher.c b/src/nm-dispatcher.c
index 957f029f3a..e5584cd651 100644
--- a/src/nm-dispatcher.c
+++ b/src/nm-dispatcher.c
@@ -358,11 +358,11 @@ fill_device_props (NMDevice *device,
if (ip6_config)
dump_ip6_to_props (ip6_config, ip6_builder);
- dhcp_config = nm_device_get_dhcp4_config (device);
+ dhcp_config = nm_device_get_dhcp_config (device, AF_INET);
if (dhcp_config)
*dhcp4_props = nm_g_variant_ref (nm_dhcp_config_get_options (dhcp_config));
- dhcp_config = nm_device_get_dhcp6_config (device);
+ dhcp_config = nm_device_get_dhcp_config (device, AF_INET6);
if (dhcp_config)
*dhcp6_props = nm_g_variant_ref (nm_dhcp_config_get_options (dhcp_config));
}
diff --git a/src/nm-manager.c b/src/nm-manager.c
index b594b899d6..75bee452de 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -6534,7 +6534,7 @@ nm_manager_write_device_state (NMManager *self, NMDevice *device)
route_metric_default_effective = _device_route_metric_get (self, ifindex, NM_DEVICE_TYPE_UNKNOWN,
TRUE, &route_metric_default_aspired);
- dhcp_config = nm_device_get_dhcp4_config (device);
+ dhcp_config = nm_device_get_dhcp_config (device, AF_INET);
if (dhcp_config) {
root_path = nm_dhcp_config_get_option (dhcp_config, "root_path");
next_server = nm_dhcp_config_get_option (dhcp_config, "next_server");
diff --git a/src/nm-policy.c b/src/nm-policy.c
index 6f2cfa6020..914c965163 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -746,7 +746,7 @@ update_system_hostname (NMPolicy *self, const char *msg)
if (priv->default_ac4) {
/* Grab a hostname out of the device's DHCP4 config */
- dhcp_config = nm_device_get_dhcp4_config (get_default_device (self, AF_INET));
+ dhcp_config = nm_device_get_dhcp_config (get_default_device (self, AF_INET), AF_INET);
if (dhcp_config) {
dhcp_hostname = nm_dhcp_config_get_option (dhcp_config, "host_name");
if (dhcp_hostname && dhcp_hostname[0]) {
@@ -764,7 +764,7 @@ update_system_hostname (NMPolicy *self, const char *msg)
if (priv->default_ac6) {
/* Grab a hostname out of the device's DHCP6 config */
- dhcp_config = nm_device_get_dhcp6_config (get_default_device (self, AF_INET6));
+ dhcp_config = nm_device_get_dhcp_config (get_default_device (self, AF_INET6), AF_INET6);
if (dhcp_config) {
dhcp_hostname = nm_dhcp_config_get_option (dhcp_config, "host_name");
if (dhcp_hostname && dhcp_hostname[0]) {