libnm-core: extract NMSettingIPConfig superclass out of IP4, IP6 classes

Split a base NMSettingIPConfig class out of NMSettingIP4Config and
NMSettingIP6Config, and update things accordingly.

Further simplifications of now-redundant IPv4-vs-IPv6 code are
possible, and should happen in the future.
This commit is contained in:
Dan Winship
2014-10-19 17:30:10 -04:00
parent 39709fdc2e
commit 3f30c6f1c2
53 changed files with 2992 additions and 3911 deletions

View File

@@ -1212,8 +1212,7 @@ nm_utils_get_ip_config_method (NMConnection *connection,
GType ip_setting_type)
{
NMSettingConnection *s_con;
NMSettingIP4Config *s_ip4;
NMSettingIP6Config *s_ip6;
NMSettingIPConfig *s_ip4, *s_ip6;
const char *method;
s_con = nm_connection_get_setting_connection (connection);
@@ -1226,7 +1225,7 @@ nm_utils_get_ip_config_method (NMConnection *connection,
else {
s_ip4 = nm_connection_get_setting_ip4_config (connection);
g_return_val_if_fail (s_ip4 != NULL, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
method = nm_setting_ip4_config_get_method (s_ip4);
method = nm_setting_ip_config_get_method (s_ip4);
g_return_val_if_fail (method != NULL, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
return method;
@@ -1240,7 +1239,7 @@ nm_utils_get_ip_config_method (NMConnection *connection,
else {
s_ip6 = nm_connection_get_setting_ip6_config (connection);
g_return_val_if_fail (s_ip6 != NULL, NM_SETTING_IP6_CONFIG_METHOD_AUTO);
method = nm_setting_ip6_config_get_method (s_ip6);
method = nm_setting_ip_config_get_method (s_ip6);
g_return_val_if_fail (method != NULL, NM_SETTING_IP6_CONFIG_METHOD_AUTO);
return method;
@@ -1387,12 +1386,12 @@ check_ip6_method (NMConnection *orig,
{
GHashTable *props;
const char *orig_ip6_method, *candidate_ip6_method;
NMSettingIP6Config *candidate_ip6;
NMSettingIPConfig *candidate_ip6;
gboolean allow = FALSE;
props = check_property_in_hash (settings,
NM_SETTING_IP6_CONFIG_SETTING_NAME,
NM_SETTING_IP6_CONFIG_METHOD);
NM_SETTING_IP_CONFIG_METHOD);
if (!props)
return TRUE;
@@ -1408,7 +1407,7 @@ check_ip6_method (NMConnection *orig,
if ( strcmp (orig_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0
&& strcmp (candidate_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0
&& (!candidate_ip6 || nm_setting_ip6_config_get_may_fail (candidate_ip6))) {
&& (!candidate_ip6 || nm_setting_ip_config_get_may_fail (candidate_ip6))) {
allow = TRUE;
}
@@ -1425,7 +1424,7 @@ check_ip6_method (NMConnection *orig,
if (allow) {
remove_from_hash (settings, props,
NM_SETTING_IP6_CONFIG_SETTING_NAME,
NM_SETTING_IP6_CONFIG_METHOD);
NM_SETTING_IP_CONFIG_METHOD);
}
return allow;
}
@@ -1438,11 +1437,11 @@ check_ip4_method (NMConnection *orig,
{
GHashTable *props;
const char *orig_ip4_method, *candidate_ip4_method;
NMSettingIP4Config *candidate_ip4;
NMSettingIPConfig *candidate_ip4;
props = check_property_in_hash (settings,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_METHOD);
NM_SETTING_IP_CONFIG_METHOD);
if (!props)
return TRUE;
@@ -1457,11 +1456,11 @@ check_ip4_method (NMConnection *orig,
if ( strcmp (orig_ip4_method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0
&& strcmp (candidate_ip4_method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0
&& (!candidate_ip4 || nm_setting_ip4_config_get_may_fail (candidate_ip4))
&& (!candidate_ip4 || nm_setting_ip_config_get_may_fail (candidate_ip4))
&& (device_has_carrier == FALSE)) {
remove_from_hash (settings, props,
NM_SETTING_IP4_CONFIG_SETTING_NAME,
NM_SETTING_IP4_CONFIG_METHOD);
NM_SETTING_IP_CONFIG_METHOD);
return TRUE;
}
return FALSE;