mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 02:20:14 +01:00
nmcli/connections: pass allow_reset to check_and_set() callback
Like the regular set_option() handler, the special ones also need to know whether to reset an option or keep the value.
This commit is contained in:
parent
fe82c3a37a
commit
0cb971d1d6
1 changed files with 16 additions and 1 deletions
|
|
@ -52,6 +52,7 @@ typedef struct _OptionInfo {
|
|||
NMConnection *connection,
|
||||
const struct _OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error);
|
||||
CompEntryFunc generator_func;
|
||||
} OptionInfo;
|
||||
|
|
@ -4375,7 +4376,7 @@ set_option(NmCli *nmc,
|
|||
NULL,
|
||||
NULL);
|
||||
if (option && option->check_and_set) {
|
||||
return option->check_and_set(nmc, connection, option, value, error);
|
||||
return option->check_and_set(nmc, connection, option, value, allow_reset, error);
|
||||
} else if (value || allow_reset) {
|
||||
return set_property(nmc->client,
|
||||
connection,
|
||||
|
|
@ -4506,6 +4507,7 @@ set_connection_type(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
const NMMetaSettingValidPartItem *const *type_settings;
|
||||
|
|
@ -4516,6 +4518,8 @@ set_connection_type(NmCli *nmc,
|
|||
|
||||
value = check_valid_name_toplevel(value, &slave_type, &local);
|
||||
if (!value) {
|
||||
if (!allow_reset)
|
||||
return TRUE;
|
||||
g_set_error(error,
|
||||
NMCLI_ERROR,
|
||||
NMC_RESULT_ERROR_USER_INPUT,
|
||||
|
|
@ -4570,12 +4574,15 @@ set_connection_iface(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
if (value) {
|
||||
/* Special value of '*' means no specific interface name */
|
||||
if (nm_streq(value, "*"))
|
||||
value = NULL;
|
||||
} else if (!allow_reset) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return set_property(nmc->client,
|
||||
|
|
@ -4592,6 +4599,7 @@ set_connection_master(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
const GPtrArray *connections;
|
||||
|
|
@ -4602,6 +4610,8 @@ set_connection_master(NmCli *nmc,
|
|||
g_return_val_if_fail(s_con, FALSE);
|
||||
|
||||
if (!value) {
|
||||
if (!allow_reset)
|
||||
return TRUE;
|
||||
g_set_error_literal(error,
|
||||
NMCLI_ERROR,
|
||||
NMC_RESULT_ERROR_USER_INPUT,
|
||||
|
|
@ -4637,6 +4647,7 @@ set_bond_option(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingBond *s_bond;
|
||||
|
|
@ -4681,6 +4692,7 @@ set_bond_monitoring_mode(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingBond *s_bond;
|
||||
|
|
@ -4721,6 +4733,7 @@ set_bluetooth_type(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
NMSetting *setting;
|
||||
|
|
@ -4769,6 +4782,7 @@ set_ip4_address(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingIPConfig *s_ip4;
|
||||
|
|
@ -4796,6 +4810,7 @@ set_ip6_address(NmCli *nmc,
|
|||
NMConnection *con,
|
||||
const OptionInfo *option,
|
||||
const char *value,
|
||||
gboolean allow_reset,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingIPConfig *s_ip6;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue