summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/devices/nm-device-ethernet.c35
-rw-r--r--src/devices/nm-device.c193
-rw-r--r--src/devices/wifi/nm-device-wifi.c90
-rw-r--r--src/nm-config-data.c14
-rw-r--r--src/nm-config-data.h7
-rw-r--r--src/nm-manager.c21
-rw-r--r--src/vpn/nm-vpn-connection.c11
7 files changed, 175 insertions, 196 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index 4d4624b7f8..0fb8fea42c 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -1198,7 +1198,6 @@ wake_on_lan_enable (NMDevice *device)
NMSettingWiredWakeOnLan wol;
NMSettingWired *s_wired;
const char *password = NULL;
- gs_free char *value = NULL;
s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
if (s_wired) {
@@ -1208,27 +1207,25 @@ wake_on_lan_enable (NMDevice *device)
goto found;
}
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "ethernet.wake-on-lan",
- device);
-
- if (value) {
- wol = _nm_utils_ascii_str_to_int64 (value, 10,
- NM_SETTING_WIRED_WAKE_ON_LAN_NONE,
- G_MAXINT32,
- NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT);
-
- if ( NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
- && !nm_utils_is_power_of_two (wol)) {
- nm_log_dbg (LOGD_ETHER, "invalid default value %u for wake-on-lan", (guint) wol);
- wol = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT;
- }
- if (wol != NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT)
- goto found;
+ wol = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "ethernet.wake-on-lan",
+ device,
+ NM_SETTING_WIRED_WAKE_ON_LAN_NONE,
+ G_MAXINT32,
+ NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT);
+
+ if ( NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
+ && !nm_utils_is_power_of_two (wol)) {
+ nm_log_dbg (LOGD_ETHER, "invalid default value %u for wake-on-lan", (guint) wol);
+ wol = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT;
}
+ if (wol != NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT)
+ goto found;
wol = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE;
found:
- return nm_platform_ethtool_set_wake_on_lan (nm_device_get_platform (device), nm_device_get_ifindex (device), wol, password);
+ return nm_platform_ethtool_set_wake_on_lan (nm_device_get_platform (device),
+ nm_device_get_ifindex (device),
+ wol, password);
}
/*****************************************************************************/
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index c09a80da54..54dce5a844 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1101,15 +1101,19 @@ nm_device_assume_state_reset (NMDevice *self)
static void
init_ip_config_dns_priority (NMDevice *self, NMIPConfig *config)
{
- gs_free char *value = NULL;
+ const char *property;
int priority;
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- (nm_ip_config_get_addr_family (config) == AF_INET)
- ? "ipv4.dns-priority"
- : "ipv6.dns-priority",
- self);
- priority = _nm_utils_ascii_str_to_int64 (value, 10, G_MININT, G_MAXINT, 0);
+ property = (nm_ip_config_get_addr_family (config) == AF_INET)
+ ? "ipv4.dns-priority"
+ : "ipv6.dns-priority";
+
+ priority = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ property,
+ self,
+ G_MININT,
+ G_MAXINT,
+ 0);
nm_ip_config_set_dns_priority (config, priority ?: NM_DNS_PRIORITY_DEFAULT_NORMAL);
}
@@ -2108,10 +2112,10 @@ guint32
nm_device_get_route_metric (NMDevice *self,
int addr_family)
{
- char *value;
gint64 route_metric;
NMSettingIPConfig *s_ip;
NMConnection *connection;
+ const char *property;
g_return_val_if_fail (NM_IS_DEVICE (self), G_MAXUINT32);
g_return_val_if_fail (NM_IN_SET (addr_family, AF_INET, AF_INET6), G_MAXUINT32);
@@ -2136,15 +2140,13 @@ nm_device_get_route_metric (NMDevice *self,
/* use the current NMConfigData, which makes this configuration reloadable.
* Note that that means that the route-metric might change between SIGHUP.
* You must cache the returned value if that is a problem. */
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- addr_family == AF_INET ? "ipv4.route-metric" : "ipv6.route-metric", self);
- if (value) {
- route_metric = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, -1);
- g_free (value);
-
- if (route_metric >= 0)
- goto out;
- }
+ property = addr_family == AF_INET ? "ipv4.route-metric" : "ipv6.route-metric";
+ route_metric = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ property,
+ self,
+ 0, G_MAXUINT32, -1);
+ if (route_metric >= 0)
+ goto out;
route_metric = nm_manager_device_route_metric_reserve (nm_manager_get (),
nm_device_get_ip_ifindex (self),
@@ -2164,21 +2166,15 @@ _get_mdns (NMDevice *self)
connection = nm_device_get_applied_connection (self);
if (connection)
mdns = nm_setting_connection_get_mdns (nm_connection_get_setting_connection (connection));
+ if (mdns != NM_SETTING_CONNECTION_MDNS_DEFAULT)
+ return mdns;
- if (mdns == NM_SETTING_CONNECTION_MDNS_DEFAULT) {
- gs_free char *value = NULL;
-
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "connection.mdns",
- self);
- mdns = _nm_utils_ascii_str_to_int64 (value,
- 10,
- NM_SETTING_CONNECTION_MDNS_NO,
- NM_SETTING_CONNECTION_MDNS_YES,
- NM_SETTING_CONNECTION_MDNS_DEFAULT);
- }
-
- return mdns;
+ return nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "connection.mdns",
+ self,
+ NM_SETTING_CONNECTION_MDNS_NO,
+ NM_SETTING_CONNECTION_MDNS_YES,
+ NM_SETTING_CONNECTION_MDNS_DEFAULT);
}
guint32
@@ -2221,14 +2217,13 @@ nm_device_get_route_table (NMDevice *self,
* connection. Otherwise, the connection is not active, and the
* connection default doesn't matter. */
if (route_table == 0) {
- gs_free char *value = NULL;
-
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- addr_family == AF_INET
- ? "ipv4.route-table"
- : "ipv6.route-table",
- self);
- route_table = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, 0);
+ const char *property;
+
+ property = addr_family == AF_INET ? "ipv4.route-table" : "ipv6.route-table";
+ route_table = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ property,
+ self,
+ 0, G_MAXUINT32, 0);
}
}
@@ -6028,15 +6023,12 @@ lldp_rx_enabled (NMDevice *self)
lldp = nm_setting_connection_get_lldp (s_con);
if (lldp == NM_SETTING_CONNECTION_LLDP_DEFAULT) {
- gs_free char *value = NULL;
-
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "connection.lldp",
- self);
- lldp = _nm_utils_ascii_str_to_int64 (value, 10,
- NM_SETTING_CONNECTION_LLDP_DEFAULT,
- NM_SETTING_CONNECTION_LLDP_ENABLE_RX,
- NM_SETTING_CONNECTION_LLDP_DEFAULT);
+ lldp = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "connection.lldp",
+ self,
+ NM_SETTING_CONNECTION_LLDP_DEFAULT,
+ NM_SETTING_CONNECTION_LLDP_ENABLE_RX,
+ NM_SETTING_CONNECTION_LLDP_DEFAULT);
if (lldp == NM_SETTING_CONNECTION_LLDP_DEFAULT)
lldp = NM_SETTING_CONNECTION_LLDP_DISABLE;
}
@@ -6130,18 +6122,17 @@ act_stage1_prepare (NMDevice *self, NMDeviceStateReason *out_failure_reason)
&& (s_sriov = (NMSettingSriov *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_SRIOV))) {
nm_auto_freev NMPlatformVF **plat_vfs = NULL;
gs_free_error GError *error = NULL;
- gs_free const char *str = NULL;
NMSriovVF *vf;
int autoprobe;
autoprobe = nm_setting_sriov_get_autoprobe_drivers (s_sriov);
if (autoprobe == NM_TERNARY_DEFAULT) {
- str = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "sriov.autoprobe-drivers", self);
- autoprobe = _nm_utils_ascii_str_to_int64 (str, 10,
- NM_TERNARY_FALSE,
- NM_TERNARY_TRUE,
- NM_TERNARY_TRUE);
+ autoprobe = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "sriov.autoprobe-drivers",
+ self,
+ NM_TERNARY_FALSE,
+ NM_TERNARY_TRUE,
+ NM_TERNARY_TRUE);
}
num = nm_setting_sriov_get_num_vfs (s_sriov);
@@ -6496,27 +6487,22 @@ get_ipv4_dad_timeout (NMDevice *self)
{
NMConnection *connection;
NMSettingIPConfig *s_ip4 = NULL;
- gs_free char *value = NULL;
- int ret = 0;
+ int timeout = -1;
connection = nm_device_get_applied_connection (self);
if (connection)
s_ip4 = nm_connection_get_setting_ip4_config (connection);
+ if (s_ip4)
+ timeout = nm_setting_ip_config_get_dad_timeout (s_ip4);
+ if (timeout >= 0)
+ return timeout;
- if (s_ip4) {
- ret = nm_setting_ip_config_get_dad_timeout (s_ip4);
-
- if (ret < 0) {
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "ipv4.dad-timeout", self);
- ret = _nm_utils_ascii_str_to_int64 (value, 10, -1,
- NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX,
- -1);
- ret = ret < 0 ? 0 : ret;
- }
- }
-
- return ret;
+ return nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "ipv4.dad-timeout",
+ self,
+ 0,
+ NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX,
+ 0);
}
static void
@@ -7363,19 +7349,14 @@ get_dhcp_timeout (NMDevice *self, int addr_family)
if (timeout)
return timeout;
- {
- gs_free char *value = NULL;
-
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- addr_family == AF_INET
- ? "ipv4.dhcp-timeout"
- : "ipv6.dhcp-timeout",
- self);
- timeout = _nm_utils_ascii_str_to_int64 (value, 10,
- 0, G_MAXINT32, 0);
- if (timeout)
- return timeout;
- }
+ timeout = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ addr_family == AF_INET
+ ? "ipv4.dhcp-timeout"
+ : "ipv6.dhcp-timeout",
+ self,
+ 0, G_MAXINT32, 0);
+ if (timeout)
+ return timeout;
klass = NM_DEVICE_GET_CLASS (self);
if (klass->get_dhcp_timeout)
@@ -8747,10 +8728,10 @@ gint64
nm_device_get_configured_mtu_from_connection_default (NMDevice *self,
const char *property_name)
{
- gs_free char *str = NULL;
-
- str = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, property_name, self);
- return _nm_utils_ascii_str_to_int64 (str, 10, 0, G_MAXUINT32, -1);
+ return nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ property_name,
+ self,
+ 0, G_MAXUINT32, -1);
}
guint32
@@ -9447,7 +9428,6 @@ static NMSettingIP6ConfigPrivacy
_ip6_privacy_get (NMDevice *self)
{
NMSettingIP6ConfigPrivacy ip6_privacy;
- gs_free char *value = NULL;
NMConnection *connection;
g_return_val_if_fail (self, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
@@ -9466,14 +9446,13 @@ _ip6_privacy_get (NMDevice *self)
}
}
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "ipv6.ip6-privacy", self);
-
/* 2.) use the default value from the configuration. */
- ip6_privacy = _nm_utils_ascii_str_to_int64 (value, 10,
- NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN,
- NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR,
- NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
+ ip6_privacy = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "ipv6.ip6-privacy",
+ self,
+ NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN,
+ NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR,
+ NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
if (ip6_privacy != NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN)
return ip6_privacy;
@@ -15647,7 +15626,6 @@ nm_device_get_supplicant_timeout (NMDevice *self)
{
NMConnection *connection;
NMSetting8021x *s_8021x;
- gs_free char *value = NULL;
int timeout;
#define SUPPLICANT_DEFAULT_TIMEOUT 25
@@ -15662,11 +15640,12 @@ nm_device_get_supplicant_timeout (NMDevice *self)
return timeout;
}
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "802-1x.auth-timeout",
- self);
- return _nm_utils_ascii_str_to_int64 (value, 10, 1, G_MAXINT32,
- SUPPLICANT_DEFAULT_TIMEOUT);
+ return nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "802-1x.auth-timeout",
+ self,
+ 1,
+ G_MAXINT32,
+ SUPPLICANT_DEFAULT_TIMEOUT);
}
gboolean
@@ -15689,12 +15668,10 @@ nm_device_auth_retries_try_next (NMDevice *self)
auth_retries = nm_setting_connection_get_auth_retries (s_con);
if (auth_retries == -1) {
- gs_free char *value = NULL;
-
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "connection.auth-retries",
- self);
- auth_retries = _nm_utils_ascii_str_to_int64 (value, 10, -1, G_MAXINT32, -1);
+ auth_retries = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "connection.auth-retries",
+ self,
+ -1, G_MAXINT32, -1);
}
if (auth_retries == 0)
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index e4b105eb32..64ab82cb0c 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -2364,7 +2364,6 @@ build_supplicant_config (NMDeviceWifi *self,
NMSettingWirelessSecurity *s_wireless_sec;
NMSettingWirelessSecurityPmf pmf;
NMSettingWirelessSecurityFils fils;
- gs_free char *value = NULL;
g_return_val_if_fail (priv->sup_iface, NULL);
@@ -2406,25 +2405,23 @@ build_supplicant_config (NMDeviceWifi *self,
/* Configure PMF (802.11w) */
pmf = nm_setting_wireless_security_get_pmf (s_wireless_sec);
if (pmf == NM_SETTING_WIRELESS_SECURITY_PMF_DEFAULT) {
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "wifi-sec.pmf",
- NM_DEVICE (self));
- pmf = _nm_utils_ascii_str_to_int64 (value, 10,
- NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE,
- NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED,
- NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL);
+ pmf = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "wifi-sec.pmf",
+ NM_DEVICE (self),
+ NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE,
+ NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED,
+ NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL);
}
/* Configure FILS (802.11ai) */
fils = nm_setting_wireless_security_get_fils (s_wireless_sec);
if (fils == NM_SETTING_WIRELESS_SECURITY_FILS_DEFAULT) {
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "wifi-sec.fils",
- NM_DEVICE (self));
- fils = _nm_utils_ascii_str_to_int64 (value, 10,
- NM_SETTING_WIRELESS_SECURITY_FILS_DISABLE,
- NM_SETTING_WIRELESS_SECURITY_FILS_REQUIRED,
- NM_SETTING_WIRELESS_SECURITY_FILS_OPTIONAL);
+ fils = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "wifi-sec.fils",
+ NM_DEVICE (self),
+ NM_SETTING_WIRELESS_SECURITY_FILS_DISABLE,
+ NM_SETTING_WIRELESS_SECURITY_FILS_REQUIRED,
+ NM_SETTING_WIRELESS_SECURITY_FILS_OPTIONAL);
}
s_8021x = nm_connection_get_setting_802_1x (connection);
@@ -2461,7 +2458,6 @@ wake_on_wlan_enable (NMDeviceWifi *self)
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMSettingWirelessWakeOnWLan wowl;
NMSettingWireless *s_wireless;
- gs_free char *value = NULL;
s_wireless = (NMSettingWireless *) nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_WIRELESS);
if (s_wireless) {
@@ -2470,31 +2466,27 @@ wake_on_wlan_enable (NMDeviceWifi *self)
goto found;
}
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "wifi.wake-on-wlan",
- NM_DEVICE (self));
+ wowl = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "wifi.wake-on-wlan",
+ NM_DEVICE (self),
+ NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE,
+ G_MAXINT32,
+ NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT);
- if (value) {
- wowl = _nm_utils_ascii_str_to_int64 (value, 10,
- NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE,
- G_MAXINT32,
- NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT);
-
- if (NM_FLAGS_ANY (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS)) {
- if (!nm_utils_is_power_of_two (wowl)) {
- _LOGD (LOGD_WIFI, "invalid default value %u for wake-on-wlan: "
- "'default' and 'ignore' are exclusive flags", (guint) wowl);
- wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT;
- }
- } else if (NM_FLAGS_ANY (wowl, ~NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL)) {
- _LOGD (LOGD_WIFI, "invalid default value %u for wake-on-wlan", (guint) wowl);
+ if (NM_FLAGS_ANY (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS)) {
+ if (!nm_utils_is_power_of_two (wowl)) {
+ _LOGD (LOGD_WIFI, "invalid default value %u for wake-on-wlan: "
+ "'default' and 'ignore' are exclusive flags", (guint) wowl);
wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT;
}
- if (wowl != NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT)
- goto found;
+ } else if (NM_FLAGS_ANY (wowl, ~NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL)) {
+ _LOGD (LOGD_WIFI, "invalid default value %u for wake-on-wlan", (guint) wowl);
+ wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT;
}
- wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
+ if (wowl != NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT)
+ goto found;
+ wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
found:
if (wowl == NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE) {
priv->wowlan_restore = wowl;
@@ -2641,31 +2633,29 @@ set_powersave (NMDevice *device)
{
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
NMSettingWireless *s_wireless;
- NMSettingWirelessPowersave powersave;
- gs_free char *value = NULL;
+ NMSettingWirelessPowersave val;
s_wireless = (NMSettingWireless *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS);
g_return_if_fail (s_wireless);
- powersave = nm_setting_wireless_get_powersave (s_wireless);
- if (powersave == NM_SETTING_WIRELESS_POWERSAVE_DEFAULT) {
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "wifi.powersave",
- device);
- powersave = _nm_utils_ascii_str_to_int64 (value, 10,
- NM_SETTING_WIRELESS_POWERSAVE_IGNORE,
- NM_SETTING_WIRELESS_POWERSAVE_ENABLE,
- NM_SETTING_WIRELESS_POWERSAVE_IGNORE);
+ val = nm_setting_wireless_get_powersave (s_wireless);
+ if (val == NM_SETTING_WIRELESS_POWERSAVE_DEFAULT) {
+ val = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "wifi.powersave",
+ device,
+ NM_SETTING_WIRELESS_POWERSAVE_IGNORE,
+ NM_SETTING_WIRELESS_POWERSAVE_ENABLE,
+ NM_SETTING_WIRELESS_POWERSAVE_IGNORE);
}
- _LOGT (LOGD_WIFI, "powersave is set to %u", (unsigned) powersave);
+ _LOGT (LOGD_WIFI, "powersave is set to %u", (unsigned) val);
- if (powersave == NM_SETTING_WIRELESS_POWERSAVE_IGNORE)
+ if (val == NM_SETTING_WIRELESS_POWERSAVE_IGNORE)
return;
nm_platform_wifi_set_powersave (nm_device_get_platform (device),
nm_device_get_ifindex (device),
- powersave == NM_SETTING_WIRELESS_POWERSAVE_ENABLE);
+ val == NM_SETTING_WIRELESS_POWERSAVE_ENABLE);
}
static NMActStageReturn
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index d8ad07c054..8d84e74abc 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -1371,6 +1371,20 @@ nm_config_data_get_connection_default (const NMConfigData *self,
return value;
}
+gint64
+nm_config_data_get_connection_default_int64 (const NMConfigData *self,
+ const char *property,
+ NMDevice *device,
+ gint64 min,
+ gint64 max,
+ gint64 fallback)
+{
+ gs_free char *value = NULL;
+
+ value = nm_config_data_get_connection_default (self, property, device);
+ return _nm_utils_ascii_str_to_int64 (value, 10, min, max, fallback);
+}
+
static void
_get_connection_info_init (MatchSectionInfo *connection_info, GKeyFile *keyfile, char *group)
{
diff --git a/src/nm-config-data.h b/src/nm-config-data.h
index 43da96fdc8..b52ddcc4f8 100644
--- a/src/nm-config-data.h
+++ b/src/nm-config-data.h
@@ -181,6 +181,13 @@ char *nm_config_data_get_connection_default (const NMConfigData *self,
const char *property,
NMDevice *device);
+gint64 nm_config_data_get_connection_default_int64 (const NMConfigData *self,
+ const char *property,
+ NMDevice *device,
+ gint64 min,
+ gint64 max,
+ gint64 fallback);
+
char *nm_config_data_get_device_config (const NMConfigData *self,
const char *property,
NMDevice *device,
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 44be55164a..f8be6d3792 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -3959,27 +3959,24 @@ static gboolean
should_connect_slaves (NMConnection *connection, NMDevice *device)
{
NMSettingConnection *s_con;
- NMSettingConnectionAutoconnectSlaves autoconnect_slaves;
- gs_free char *value = NULL;
+ NMSettingConnectionAutoconnectSlaves val;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
- /* Check autoconnect-slaves property */
- autoconnect_slaves = nm_setting_connection_get_autoconnect_slaves (s_con);
- if (autoconnect_slaves != NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT)
+ val = nm_setting_connection_get_autoconnect_slaves (s_con);
+ if (val != NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT)
goto out;
- /* Check configuration default for autoconnect-slaves property */
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "connection.autoconnect-slaves", device);
- if (value)
- autoconnect_slaves = _nm_utils_ascii_str_to_int64 (value, 10, 0, 1, -1);
+ val = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "connection.autoconnect-slaves",
+ device,
+ 0, 1, -1);
out:
- if (autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO)
+ if (val == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO)
return FALSE;
- if (autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES)
+ if (val == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES)
return TRUE;
return FALSE;
}
diff --git a/src/vpn/nm-vpn-connection.c b/src/vpn/nm-vpn-connection.c
index f06d94a3a8..bbf6b9e99a 100644
--- a/src/vpn/nm-vpn-connection.c
+++ b/src/vpn/nm-vpn-connection.c
@@ -1876,13 +1876,10 @@ connect_success (NMVpnConnection *self)
* It is a configured value or 60 seconds */
timeout = nm_setting_vpn_get_timeout (s_vpn);
if (timeout == 0) {
- char *value;
-
- value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
- "vpn.timeout", NULL);
- timeout = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, 60);
- timeout = timeout == 0 ? 60 : timeout;
- g_free (value);
+ timeout = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
+ "vpn.timeout",
+ NULL,
+ 1, G_MAXUINT32, 60);
}
priv->connect_timeout = g_timeout_add_seconds (timeout, connect_timeout_cb, self);