summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2014-02-25 12:30:30 +0100
committerJiří Klimeš <jklimes@redhat.com>2014-02-28 10:39:09 +0100
commit642cfdeebfae3adbe52f9596f7996481d69045d1 (patch)
tree535d607d1fa9919affb2b69cdb9b2dd4c5d95951
parent1e5370b4d23beb10e335f49a96090ade8ba28da4 (diff)
downloadNetworkManager-642cfdeebfae3adbe52f9596f7996481d69045d1.tar.gz
libnm-util: add *_remove_*_by_value() functions for 'vlan' setting
nm_setting_vlan_remove_priority_by_value() nm_setting_vlan_remove_priority_str_by_value()
-rw-r--r--libnm-util/libnm-util.ver2
-rw-r--r--libnm-util/nm-setting-vlan.c74
-rw-r--r--libnm-util/nm-setting-vlan.h13
3 files changed, 87 insertions, 2 deletions
diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver
index b2bec419a2..09f7c58f69 100644
--- a/libnm-util/libnm-util.ver
+++ b/libnm-util/libnm-util.ver
@@ -488,6 +488,8 @@ global:
nm_setting_vlan_get_type;
nm_setting_vlan_new;
nm_setting_vlan_remove_priority;
+ nm_setting_vlan_remove_priority_by_value;
+ nm_setting_vlan_remove_priority_str_by_value;
nm_setting_vpn_add_data_item;
nm_setting_vpn_add_secret;
nm_setting_vpn_error_get_type;
diff --git a/libnm-util/nm-setting-vlan.c b/libnm-util/nm-setting-vlan.c
index 9a37ca8da5..ac1a4bae48 100644
--- a/libnm-util/nm-setting-vlan.c
+++ b/libnm-util/nm-setting-vlan.c
@@ -18,7 +18,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2011 - 2013 Red Hat, Inc.
+ * (C) Copyright 2011 - 2014 Red Hat, Inc.
*/
#include <stdlib.h>
@@ -422,6 +422,78 @@ nm_setting_vlan_remove_priority (NMSettingVlan *setting,
}
/**
+ * nm_setting_vlan_remove_priority_by_value:
+ * @setting: the #NMSettingVlan
+ * @map: the type of priority map
+ * @from: the priority to map to @to
+ * @to: the priority to map @from to
+ *
+ * Removes the priority map @form:@to from the #NMSettingVlan:ingress_priority_map
+ * or #NMSettingVlan:egress_priority_map (according to @map argument)
+ * properties.
+ *
+ * Returns: %TRUE if the priority mapping was found and removed; %FALSE if it was not.
+ *
+ * Since: 0.9.10
+ */
+gboolean
+nm_setting_vlan_remove_priority_by_value (NMSettingVlan *setting,
+ NMVlanPriorityMap map,
+ guint32 from,
+ guint32 to)
+{
+ GSList *list = NULL, *iter = NULL;
+ PriorityMap *item;
+
+ g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
+ g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
+
+ list = get_map (setting, map);
+ for (iter = list; iter; iter = g_slist_next (iter)) {
+ item = iter->data;
+ if (item->from == from && item->to == to) {
+ priority_map_free ((PriorityMap *) (iter->data));
+ set_map (setting, map, g_slist_delete_link (list, iter));
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
+ * nm_setting_vlan_remove_priority_str_by_value:
+ * @setting: the #NMSettingVlan
+ * @map: the type of priority map
+ * @str: the string which contains a priority map, like "3:7"
+ *
+ * Removes the priority map @str from the #NMSettingVlan:ingress_priority_map
+ * or #NMSettingVlan:egress_priority_map (according to @map argument)
+ * properties.
+ *
+ * Returns: %TRUE if the priority mapping was found and removed; %FALSE if it was not.
+ *
+ * Since: 0.9.10
+ */
+gboolean
+nm_setting_vlan_remove_priority_str_by_value (NMSettingVlan *setting,
+ NMVlanPriorityMap map,
+ const char *str)
+{
+ GSList *list;
+ PriorityMap *item;
+
+ g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
+ g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
+
+ list = get_map (setting, map);
+ item = priority_map_new_from_str (map, str);
+ if (!item)
+ return FALSE;
+
+ return nm_setting_vlan_remove_priority_by_value (setting, map, item->from, item->to);
+}
+
+/**
* nm_setting_vlan_clear_priorities:
* @setting: the #NMSettingVlan
* @map: the type of priority map
diff --git a/libnm-util/nm-setting-vlan.h b/libnm-util/nm-setting-vlan.h
index 019c6da071..e865cd4977 100644
--- a/libnm-util/nm-setting-vlan.h
+++ b/libnm-util/nm-setting-vlan.h
@@ -18,7 +18,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2011 Red Hat, Inc.
+ * (C) Copyright 2011 - 2014 Red Hat, Inc.
*/
#ifndef NM_SETTING_VLAN_H
@@ -136,6 +136,17 @@ void nm_setting_vlan_remove_priority (NMSettingVlan *setting,
NMVlanPriorityMap map,
guint32 idx);
+NM_AVAILABLE_IN_0_9_10
+gboolean nm_setting_vlan_remove_priority_by_value (NMSettingVlan *setting,
+ NMVlanPriorityMap map,
+ guint32 from,
+ guint32 to);
+
+NM_AVAILABLE_IN_0_9_10
+gboolean nm_setting_vlan_remove_priority_str_by_value (NMSettingVlan *setting,
+ NMVlanPriorityMap map,
+ const char *str);
+
void nm_setting_vlan_clear_priorities (NMSettingVlan *setting, NMVlanPriorityMap map);
gboolean nm_setting_vlan_add_priority_str (NMSettingVlan *setting,