ifcfg-rh/trivial: move code

This commit is contained in:
Beniamino Galvani 2017-10-27 21:58:20 +02:00
parent 6d21711445
commit 44ffa57c5d

View file

@ -89,6 +89,60 @@ get_uint (const char *str, guint32 *value)
return TRUE;
}
static void
check_if_bond_slave (shvarFile *ifcfg,
NMSettingConnection *s_con)
{
gs_free char *value = NULL;
const char *v;
v = svGetValueStr (ifcfg, "MASTER_UUID", &value);
if (!v)
v = svGetValueStr (ifcfg, "MASTER", &value);
if (v) {
g_object_set (s_con,
NM_SETTING_CONNECTION_MASTER, v,
NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_BOND_SETTING_NAME,
NULL);
}
/* We should be checking for SLAVE=yes as well, but NM used to not set that,
* so for backward-compatibility, we don't check.
*/
}
static gboolean
check_if_team_slave (shvarFile *ifcfg,
NMSettingConnection *s_con)
{
gs_free char *value = NULL;
const char *v;
v = svGetValueStr (ifcfg, "TEAM_MASTER_UUID", &value);
if (!v)
v = svGetValueStr (ifcfg, "TEAM_MASTER", &value);
if (!v)
return FALSE;
g_object_set (s_con,
NM_SETTING_CONNECTION_MASTER, v,
NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_TEAM_SETTING_NAME,
NULL);
return TRUE;
}
static void
check_if_slave (shvarFile *ifcfg,
NMSettingConnection *s_con)
{
g_return_if_fail (NM_IS_SETTING_CONNECTION (s_con));
if (check_if_team_slave (ifcfg, s_con))
return;
check_if_bond_slave (ifcfg, s_con);
}
static char *
make_connection_name (shvarFile *ifcfg,
const char *ifcfg_name,
@ -1897,60 +1951,6 @@ error:
return NULL;
}
static void
check_if_bond_slave (shvarFile *ifcfg,
NMSettingConnection *s_con)
{
gs_free char *value = NULL;
const char *v;
v = svGetValueStr (ifcfg, "MASTER_UUID", &value);
if (!v)
v = svGetValueStr (ifcfg, "MASTER", &value);
if (v) {
g_object_set (s_con,
NM_SETTING_CONNECTION_MASTER, v,
NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_BOND_SETTING_NAME,
NULL);
}
/* We should be checking for SLAVE=yes as well, but NM used to not set that,
* so for backward-compatibility, we don't check.
*/
}
static gboolean
check_if_team_slave (shvarFile *ifcfg,
NMSettingConnection *s_con)
{
gs_free char *value = NULL;
const char *v;
v = svGetValueStr (ifcfg, "TEAM_MASTER_UUID", &value);
if (!v)
v = svGetValueStr (ifcfg, "TEAM_MASTER", &value);
if (!v)
return FALSE;
g_object_set (s_con,
NM_SETTING_CONNECTION_MASTER, v,
NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_TEAM_SETTING_NAME,
NULL);
return TRUE;
}
static void
check_if_slave (shvarFile *ifcfg,
NMSettingConnection *s_con)
{
g_return_if_fail (NM_IS_SETTING_CONNECTION (s_con));
if (check_if_team_slave (ifcfg, s_con))
return;
check_if_bond_slave (ifcfg, s_con);
}
typedef struct {
const char *enable_key;
const char *advertise_key;