core: remove nm_utils_normalize_connection function
This functionality is now provided by nm_connection_normalize(). Contrary to nm_utils_normalize_connection(), nm_connection_normalize() is in libnm-util and available to clients as well. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -453,70 +453,6 @@ get_new_connection_name (const GSList *existing,
|
||||
return cname;
|
||||
}
|
||||
|
||||
void
|
||||
nm_utils_normalize_connection (NMConnection *connection,
|
||||
gboolean default_enable_ipv6)
|
||||
{
|
||||
NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
|
||||
const char *default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
|
||||
const char *default_ip6_method =
|
||||
default_enable_ipv6 ? NM_SETTING_IP6_CONFIG_METHOD_AUTO : NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
|
||||
NMSettingIP4Config *s_ip4;
|
||||
NMSettingIP6Config *s_ip6;
|
||||
NMSetting *setting;
|
||||
const char *method;
|
||||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||
|
||||
if (nm_setting_connection_get_master (s_con)) {
|
||||
/* Slave connections don't have IP configuration. */
|
||||
|
||||
if (s_ip4) {
|
||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
||||
if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) != 0) {
|
||||
nm_log_warn (LOGD_SETTINGS, "ignoring IP4 config on slave '%s'",
|
||||
nm_connection_get_id (connection));
|
||||
}
|
||||
nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||
s_ip4 = NULL;
|
||||
}
|
||||
|
||||
if (s_ip6) {
|
||||
method = nm_setting_ip6_config_get_method (s_ip6);
|
||||
if (g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0) {
|
||||
nm_log_warn (LOGD_SETTINGS, "ignoring IP6 config on slave '%s'",
|
||||
nm_connection_get_id (connection));
|
||||
}
|
||||
nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
s_ip6 = NULL;
|
||||
}
|
||||
} else {
|
||||
/* Ensure all non-slave connections have IP4 and IP6 settings objects. If no
|
||||
* IP6 setting was specified, then assume that means IP6 config is allowed
|
||||
* to fail. But if no IP4 setting was specified, assume the caller was just
|
||||
* being lazy.
|
||||
*/
|
||||
if (!s_ip4) {
|
||||
setting = nm_setting_ip4_config_new ();
|
||||
nm_connection_add_setting (connection, setting);
|
||||
|
||||
g_object_set (setting,
|
||||
NM_SETTING_IP4_CONFIG_METHOD, default_ip4_method,
|
||||
NULL);
|
||||
}
|
||||
if (!s_ip6) {
|
||||
setting = nm_setting_ip6_config_new ();
|
||||
nm_connection_add_setting (connection, setting);
|
||||
|
||||
g_object_set (setting,
|
||||
NM_SETTING_IP6_CONFIG_METHOD, default_ip6_method,
|
||||
NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_utils_get_ip_config_method (NMConnection *connection,
|
||||
GType ip_setting_type)
|
||||
@@ -570,6 +506,10 @@ nm_utils_complete_generic (NMConnection *connection,
|
||||
{
|
||||
NMSettingConnection *s_con;
|
||||
char *id, *uuid;
|
||||
GHashTable *parameters = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
g_hash_table_insert (parameters, NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD,
|
||||
default_enable_ipv6 ? NM_SETTING_IP6_CONFIG_METHOD_AUTO : NM_SETTING_IP6_CONFIG_METHOD_IGNORE);
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
if (!s_con) {
|
||||
@@ -592,7 +532,9 @@ nm_utils_complete_generic (NMConnection *connection,
|
||||
}
|
||||
|
||||
/* Normalize */
|
||||
nm_utils_normalize_connection (connection, default_enable_ipv6);
|
||||
nm_connection_normalize (connection, parameters, NULL, NULL);
|
||||
|
||||
g_hash_table_destroy (parameters);
|
||||
}
|
||||
|
||||
char *
|
||||
|
Reference in New Issue
Block a user