device: merge nm_device_get_dhcp[46]_config() to nm_device_get_dhcp_config()

This commit is contained in:
Thomas Haller 2020-02-20 15:06:47 +01:00
parent 26f208aec3
commit 121d446354
5 changed files with 12 additions and 17 deletions

View file

@ -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)
{

View file

@ -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,

View file

@ -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));
}

View file

@ -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");

View file

@ -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]) {