Commit ca0aa813 authored by Jiří Klimeš's avatar Jiří Klimeš

libnm-util: add *_remove_*_by_value() functions for '802-3-ethernet' setting

nm_setting_wired_remove_mac_blacklist_item_by_value()
and missing
nm_setting_wired_clear_mac_blacklist_items()
parent b59bd759
......@@ -512,6 +512,7 @@ global:
nm_setting_wimax_new;
nm_setting_wired_add_mac_blacklist_item;
nm_setting_wired_add_s390_option;
nm_setting_wired_clear_mac_blacklist_items;
nm_setting_wired_error_get_type;
nm_setting_wired_error_quark;
nm_setting_wired_get_auto_negotiate;
......@@ -533,6 +534,7 @@ global:
nm_setting_wired_get_valid_s390_options;
nm_setting_wired_new;
nm_setting_wired_remove_mac_blacklist_item;
nm_setting_wired_remove_mac_blacklist_item_by_value;
nm_setting_wired_remove_s390_option;
nm_setting_wireless_add_mac_blacklist_item;
nm_setting_wireless_add_seen_bssid;
......
......@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2013 Red Hat, Inc.
* (C) Copyright 2007 - 2014 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
......@@ -297,6 +297,7 @@ nm_setting_wired_add_mac_blacklist_item (NMSettingWired *setting, const char *ma
priv->mac_address_blacklist = g_slist_append (priv->mac_address_blacklist,
g_ascii_strup (mac, -1));
g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
return TRUE;
}
......@@ -323,6 +324,61 @@ nm_setting_wired_remove_mac_blacklist_item (NMSettingWired *setting, guint32 idx
g_free (elt->data);
priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, elt);
g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
}
/**
* nm_setting_wired_remove_mac_blacklist_item_by_value:
* @setting: the #NMSettingWired
* @mac: the MAC address string (hex-digits-and-colons notation) to remove from
* the blacklist
*
* Removes the MAC address @mac from the blacklist.
*
* Returns: %TRUE if the MAC address was found and removed; %FALSE if it was not.
*
* Since: 0.9.10
**/
gboolean
nm_setting_wired_remove_mac_blacklist_item_by_value (NMSettingWired *setting, const char *mac)
{
NMSettingWiredPrivate *priv;
GSList *iter;
guint8 buf[32];
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE);
g_return_val_if_fail (mac != NULL, FALSE);
if (!nm_utils_hwaddr_aton (mac, ARPHRD_ETHER, buf))
return FALSE;
priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
for (iter = priv->mac_address_blacklist; iter; iter = g_slist_next (iter)) {
if (!strcasecmp (mac, (char *) iter->data)) {
priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, iter);
g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
return TRUE;
}
}
return FALSE;
}
/**
* nm_setting_wired_clear_mac_blacklist_items:
* @setting: the #NMSettingWired
*
* Removes all blacklisted MAC addresses.
*
* Since: 0.9.10
**/
void
nm_setting_wired_clear_mac_blacklist_items (NMSettingWired *setting)
{
g_return_if_fail (NM_IS_SETTING_WIRED (setting));
g_slist_free_full (NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist, g_free);
NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist = NULL;
g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST);
}
/**
......
......@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2011 Red Hat, Inc.
* (C) Copyright 2007 - 2014 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
......@@ -103,6 +103,11 @@ gboolean nm_setting_wired_add_mac_blacklist_item (NMSettingWired *
NM_AVAILABLE_IN_0_9_10
void nm_setting_wired_remove_mac_blacklist_item (NMSettingWired *setting,
guint32 idx);
NM_AVAILABLE_IN_0_9_10
gboolean nm_setting_wired_remove_mac_blacklist_item_by_value (NMSettingWired *setting,
const char *mac);
NM_AVAILABLE_IN_0_9_10
void nm_setting_wired_clear_mac_blacklist_items (NMSettingWired *setting);
guint32 nm_setting_wired_get_mtu (NMSettingWired *setting);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment