mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 14:20:16 +01:00
cli: move nmc_bond_validate_mode() to "clients/common/nm-client-utils.h"
"clients/common/nm-client-utils.h" already contains other nmc_* validation functions. It's the better place for nmc_bond_validate_mode()
This commit is contained in:
parent
d32590041f
commit
bb40abb3de
4 changed files with 24 additions and 24 deletions
|
|
@ -224,3 +224,24 @@ matches (const char *cmd, const char *pattern)
|
|||
return memcmp (pattern, cmd, len) == 0;
|
||||
}
|
||||
|
||||
const char *
|
||||
nmc_bond_validate_mode (const char *mode, GError **error)
|
||||
{
|
||||
unsigned long mode_int;
|
||||
static const char *valid_modes[] = { "balance-rr",
|
||||
"active-backup",
|
||||
"balance-xor",
|
||||
"broadcast",
|
||||
"802.3ad",
|
||||
"balance-tlb",
|
||||
"balance-alb",
|
||||
NULL };
|
||||
if (nmc_string_to_uint (mode, TRUE, 0, 6, &mode_int)) {
|
||||
/* Translate bonding mode numbers to mode names:
|
||||
* https://www.kernel.org/doc/Documentation/networking/bonding.txt
|
||||
*/
|
||||
return valid_modes[mode_int];
|
||||
} else
|
||||
return nmc_string_is_valid (mode, valid_modes, error);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,4 +60,7 @@ gboolean nmc_string_to_tristate (const char *str, NMCTriStateValue *val, GError
|
|||
|
||||
gboolean matches (const char *cmd, const char *pattern);
|
||||
|
||||
/* FIXME: don't expose this function on it's own, at least not from this file. */
|
||||
const char *nmc_bond_validate_mode (const char *mode, GError **error);
|
||||
|
||||
#endif /* __NM_CLIENT_UTILS_H__ */
|
||||
|
|
|
|||
|
|
@ -401,27 +401,6 @@ nmc_proxy_check_script (const char *script, char **out_script, GError **error)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
const char *
|
||||
nmc_bond_validate_mode (const char *mode, GError **error)
|
||||
{
|
||||
unsigned long mode_int;
|
||||
static const char *valid_modes[] = { "balance-rr",
|
||||
"active-backup",
|
||||
"balance-xor",
|
||||
"broadcast",
|
||||
"802.3ad",
|
||||
"balance-tlb",
|
||||
"balance-alb",
|
||||
NULL };
|
||||
if (nmc_string_to_uint (mode, TRUE, 0, 6, &mode_int)) {
|
||||
/* Translate bonding mode numbers to mode names:
|
||||
* https://www.kernel.org/doc/Documentation/networking/bonding.txt
|
||||
*/
|
||||
return valid_modes[mode_int];
|
||||
} else
|
||||
return nmc_string_is_valid (mode, valid_modes, error);
|
||||
}
|
||||
|
||||
/*
|
||||
* nmc_team_check_config:
|
||||
* @config: file name with team config, or raw team JSON config data
|
||||
|
|
|
|||
|
|
@ -196,7 +196,4 @@ struct _NMMetaEnvironment {
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* FIXME: don't expose this function on it's own, at least not from this file. */
|
||||
const char *nmc_bond_validate_mode (const char *mode, GError **error);
|
||||
|
||||
#endif /* __NM_META_SETTING_DESC_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue