
Part 1, which addresses the issue for simple properties that have a plain remove-by-value function. Rationale: Removing a value/index that does not exist should not be a failure. Woule you like: $ nmcli connection modify "$PROFILE" autoconnect no $ nmcli connection modify "$PROFILE" autoconnect no Error: autoconnect is already disabled So, why would it be a good idea to fail during $ nmcli connection modify "$PROFILE" -vpn.data ca $ nmcli connection modify "$PROFILE" -vpn.data ca Error: failed to remove a value from vpn.data: invalid option 'ca'. Generally, it should not be an error to remove an option, as long as the option itself is valid. For example, $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map bogus should fail, but $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map 1:5 should succeed even if there was nothing to remove.
84 lines
3.3 KiB
C
84 lines
3.3 KiB
C
/*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301 USA.
|
|
*/
|
|
|
|
#ifndef __NM_LIBNM_SHARED_UTILS_H__
|
|
#define __NM_LIBNM_SHARED_UTILS_H__
|
|
|
|
/****************************************************************************/
|
|
|
|
#include "nm-setting-connection.h"
|
|
#include "nm-setting-ip-config.h"
|
|
#include "nm-setting-sriov.h"
|
|
#include "nm-setting-team.h"
|
|
#include "nm-setting-vlan.h"
|
|
#include "nm-setting-wireguard.h"
|
|
|
|
/****************************************************************************/
|
|
|
|
#define nm_auto_unref_ip_address nm_auto (_nm_ip_address_unref)
|
|
NM_AUTO_DEFINE_FCN0 (NMIPAddress *, _nm_ip_address_unref, nm_ip_address_unref)
|
|
|
|
#define nm_auto_unref_ip_route nm_auto (_nm_auto_unref_ip_route)
|
|
NM_AUTO_DEFINE_FCN0 (NMIPRoute *, _nm_auto_unref_ip_route, nm_ip_route_unref)
|
|
|
|
#define nm_auto_unref_sriov_vf nm_auto (_nm_auto_unref_sriov_vf)
|
|
NM_AUTO_DEFINE_FCN0 (NMSriovVF *, _nm_auto_unref_sriov_vf, nm_sriov_vf_unref)
|
|
|
|
#define nm_auto_unref_tc_qdisc nm_auto (_nm_auto_unref_tc_qdisc)
|
|
NM_AUTO_DEFINE_FCN0 (NMTCQdisc *, _nm_auto_unref_tc_qdisc, nm_tc_qdisc_unref)
|
|
|
|
#define nm_auto_unref_tc_tfilter nm_auto (_nm_auto_unref_tc_tfilter)
|
|
NM_AUTO_DEFINE_FCN0 (NMTCTfilter *, _nm_auto_unref_tc_tfilter, nm_tc_tfilter_unref)
|
|
|
|
#define nm_auto_unref_team_link_watcher nm_auto (_nm_auto_unref_team_link_watcher)
|
|
NM_AUTO_DEFINE_FCN0 (NMTeamLinkWatcher *, _nm_auto_unref_team_link_watcher, nm_team_link_watcher_unref)
|
|
|
|
#define nm_auto_unref_wgpeer nm_auto (_nm_auto_unref_wgpeer)
|
|
NM_AUTO_DEFINE_FCN0 (NMWireGuardPeer *, _nm_auto_unref_wgpeer, nm_wireguard_peer_unref)
|
|
|
|
/****************************************************************************/
|
|
|
|
static inline guint32
|
|
nm_utils_vlan_priority_map_get_max_prio (NMVlanPriorityMap map, gboolean from)
|
|
{
|
|
if (map == NM_VLAN_INGRESS_MAP) {
|
|
return from
|
|
? 7u /* MAX_8021P_PRIO */
|
|
: (guint32) G_MAXUINT32 /* MAX_SKB_PRIO */;
|
|
}
|
|
nm_assert (map == NM_VLAN_EGRESS_MAP);
|
|
return from
|
|
? (guint32) G_MAXUINT32 /* MAX_SKB_PRIO */
|
|
: 7u /* MAX_8021P_PRIO */;
|
|
}
|
|
|
|
gboolean nm_utils_vlan_priority_map_parse_str (NMVlanPriorityMap map_type,
|
|
const char *str,
|
|
gboolean allow_wildcard_to,
|
|
guint32 *out_from,
|
|
guint32 *out_to,
|
|
gboolean *out_has_wildcard_to);
|
|
|
|
static inline void
|
|
nm_setting_connection_remove_permission_user (NMSettingConnection *setting,
|
|
const char *user)
|
|
{
|
|
nm_setting_connection_remove_permission_by_value (setting, "user", user, NULL);
|
|
}
|
|
|
|
#endif /* __NM_LIBNM_SHARED_UTILS_H__ */
|