config: add macros NM_CONFIG_GET_DATA and NM_CONFIG_GET_DATA_ORIG

This commit is contained in:
Thomas Haller
2015-06-09 08:47:41 +02:00
parent a5f7abb842
commit 2c46003e99
5 changed files with 12 additions and 8 deletions

View File

@@ -805,7 +805,7 @@ _get_ipx_route_metric (NMDevice *self,
/* use the current NMConfigData, which makes this configuration reloadable. /* use the current NMConfigData, which makes this configuration reloadable.
* Note that that means that the route-metric might change between SIGHUP. * Note that that means that the route-metric might change between SIGHUP.
* You must cache the returned value if that is a problem. */ * You must cache the returned value if that is a problem. */
value = nm_config_data_get_connection_default (nm_config_get_data (nm_config_get ()), value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
is_v4 ? "ipv4.route-metric" : "ipv6.route-metric", self); is_v4 ? "ipv4.route-metric" : "ipv6.route-metric", self);
if (value) { if (value) {
route_metric = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, -1); route_metric = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, -1);
@@ -2329,7 +2329,7 @@ nm_device_generate_connection (NMDevice *self, NMDevice *master)
&& g_strcmp0 (ip6_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0 && g_strcmp0 (ip6_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0
&& !nm_setting_connection_get_master (NM_SETTING_CONNECTION (s_con)) && !nm_setting_connection_get_master (NM_SETTING_CONNECTION (s_con))
&& !priv->slaves && !priv->slaves
&& !nm_config_data_get_assume_ipv6ll_only (nm_config_get_data (nm_config_get ()), self)) { && !nm_config_data_get_assume_ipv6ll_only (NM_CONFIG_GET_DATA, self)) {
_LOGD (LOGD_DEVICE, "ignoring generated connection (IPv6LL-only and not in master-slave relationship)"); _LOGD (LOGD_DEVICE, "ignoring generated connection (IPv6LL-only and not in master-slave relationship)");
g_object_unref (connection); g_object_unref (connection);
connection = NULL; connection = NULL;
@@ -4902,7 +4902,7 @@ _ip6_privacy_get (NMDevice *self)
} }
} }
value = nm_config_data_get_connection_default (nm_config_get_data (nm_config_get ()), value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
"ipv6.ip6-privacy", self); "ipv6.ip6-privacy", self);
/* 2.) use the default value from the configuration. */ /* 2.) use the default value from the configuration. */
@@ -8454,7 +8454,7 @@ _set_state_full (NMDevice *self,
if (nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) { if (nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) {
/* We cache the ignore_carrier state to not react on config-reloads while the connection /* We cache the ignore_carrier state to not react on config-reloads while the connection
* is active. But on deactivating, reset the ignore-carrier flag to the current state. */ * is active. But on deactivating, reset the ignore-carrier flag to the current state. */
priv->ignore_carrier = nm_config_data_get_ignore_carrier (nm_config_get_data (nm_config_get ()), self); priv->ignore_carrier = nm_config_data_get_ignore_carrier (NM_CONFIG_GET_DATA, self);
} }
if (quitting) { if (quitting) {

View File

@@ -69,6 +69,10 @@ char *nm_config_change_flags_to_string (NMConfigChangeFlags flags);
NMConfigData *nm_config_get_data (NMConfig *config); NMConfigData *nm_config_get_data (NMConfig *config);
NMConfigData *nm_config_get_data_orig (NMConfig *config); NMConfigData *nm_config_get_data_orig (NMConfig *config);
#define NM_CONFIG_GET_DATA (nm_config_get_data (nm_config_get ()))
#define NM_CONFIG_GET_DATA_ORIG (nm_config_get_data_orig (nm_config_get ()))
const char **nm_config_get_plugins (NMConfig *config); const char **nm_config_get_plugins (NMConfig *config);
gboolean nm_config_get_monitor_connection_files (NMConfig *config); gboolean nm_config_get_monitor_connection_files (NMConfig *config);
gboolean nm_config_get_auth_polkit (NMConfig *config); gboolean nm_config_get_auth_polkit (NMConfig *config);

View File

@@ -2472,7 +2472,7 @@ should_connect_slaves (NMConnection *connection, NMDevice *device)
goto out; goto out;
/* Check configuration default for autoconnect-slaves property */ /* Check configuration default for autoconnect-slaves property */
value = nm_config_data_get_connection_default (nm_config_get_data (nm_config_get ()), value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
"connection.autoconnect-slaves", device); "connection.autoconnect-slaves", device);
if (value) if (value)
autoconnect_slaves = _nm_utils_ascii_str_to_int64 (value, 10, 0, 1, -1); autoconnect_slaves = _nm_utils_ascii_str_to_int64 (value, 10, 0, 1, -1);

View File

@@ -84,7 +84,7 @@ is_managed_plugin (void)
{ {
char *result = NULL; char *result = NULL;
result = nm_config_data_get_value (nm_config_get_data_orig (nm_config_get ()), result = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
IFNET_KEY_FILE_GROUP, IFNET_KEY_FILE_KEY_MANAGED); IFNET_KEY_FILE_GROUP, IFNET_KEY_FILE_KEY_MANAGED);
if (result) { if (result) {
gboolean ret = is_true (result); gboolean ret = is_true (result);
@@ -217,7 +217,7 @@ reload_connections (NMSystemConfigInterface *config)
nm_log_info (LOGD_SETTINGS, "Loading connections"); nm_log_info (LOGD_SETTINGS, "Loading connections");
str_auto_refresh = nm_config_data_get_value (nm_config_get_data_orig (nm_config_get ()), str_auto_refresh = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
IFNET_KEY_FILE_GROUP, "auto_refresh"); IFNET_KEY_FILE_GROUP, "auto_refresh");
if (str_auto_refresh && is_true (str_auto_refresh)) if (str_auto_refresh && is_true (str_auto_refresh))
auto_refresh = TRUE; auto_refresh = TRUE;

View File

@@ -419,7 +419,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
g_hash_table_destroy (auto_ifaces); g_hash_table_destroy (auto_ifaces);
/* Check the config file to find out whether to manage interfaces */ /* Check the config file to find out whether to manage interfaces */
value = nm_config_data_get_value (nm_config_get_data_orig (nm_config_get ()), value = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
IFUPDOWN_KEY_FILE_GROUP, IFUPDOWN_KEY_FILE_KEY_MANAGED); IFUPDOWN_KEY_FILE_GROUP, IFUPDOWN_KEY_FILE_KEY_MANAGED);
if (value) { if (value) {
gboolean manage_well_known; gboolean manage_well_known;