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

libnm-util: add access functions for 'mac-address-blacklist' to wired/wireless

nm_setting_wire(d/less)_get_num_mac_blacklist_items()
nm_setting_wire(d/less)_get_mac_blacklist_item()
nm_setting_wire(d/less)_add_mac_blacklist_item()
nm_setting_wire(d/less)_remove_mac_blacklist_item()
parent 440223fa
......@@ -451,6 +451,7 @@ global:
nm_setting_wimax_get_network_name;
nm_setting_wimax_get_type;
nm_setting_wimax_new;
nm_setting_wired_add_mac_blacklist_item;
nm_setting_wired_add_s390_option;
nm_setting_wired_error_get_type;
nm_setting_wired_error_quark;
......@@ -459,7 +460,9 @@ global:
nm_setting_wired_get_duplex;
nm_setting_wired_get_mac_address;
nm_setting_wired_get_mac_address_blacklist;
nm_setting_wired_get_mac_blacklist_item;
nm_setting_wired_get_mtu;
nm_setting_wired_get_num_mac_blacklist_items;
nm_setting_wired_get_num_s390_options;
nm_setting_wired_get_port;
nm_setting_wired_get_s390_nettype;
......@@ -470,7 +473,9 @@ global:
nm_setting_wired_get_type;
nm_setting_wired_get_valid_s390_options;
nm_setting_wired_new;
nm_setting_wired_remove_mac_blacklist_item;
nm_setting_wired_remove_s390_option;
nm_setting_wireless_add_mac_blacklist_item;
nm_setting_wireless_add_seen_bssid;
nm_setting_wireless_ap_security_compatible;
nm_setting_wireless_error_get_type;
......@@ -482,8 +487,10 @@ global:
nm_setting_wireless_get_hidden;
nm_setting_wireless_get_mac_address;
nm_setting_wireless_get_mac_address_blacklist;
nm_setting_wireless_get_mac_blacklist_item;
nm_setting_wireless_get_mode;
nm_setting_wireless_get_mtu;
nm_setting_wireless_get_num_mac_blacklist_items;
nm_setting_wireless_get_num_seen_bssids;
nm_setting_wireless_get_rate;
nm_setting_wireless_get_security;
......@@ -492,6 +499,7 @@ global:
nm_setting_wireless_get_tx_power;
nm_setting_wireless_get_type;
nm_setting_wireless_new;
nm_setting_wireless_remove_mac_blacklist_item;
nm_setting_wireless_security_add_group;
nm_setting_wireless_security_add_pairwise;
nm_setting_wireless_security_add_proto;
......
......@@ -225,6 +225,106 @@ nm_setting_wired_get_mac_address_blacklist (NMSettingWired *setting)
return NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist;
}
/**
* nm_setting_wired_get_num_mac_blacklist_items:
* @setting: the #NMSettingWired
*
* Returns: the number of blacklisted MAC addresses
*
* Since: 0.9.10
**/
guint32
nm_setting_wired_get_num_mac_blacklist_items (NMSettingWired *setting)
{
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0);
return g_slist_length (NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist);
}
/**
* nm_setting_wired_get_mac_blacklist_item:
* @setting: the #NMSettingWired
* @idx: the zero-based index of the MAC address entry
*
* Returns: the blacklisted MAC address string (hex-digits-and-colons notation)
* at index @idx
*
* Since: 0.9.10
**/
const char *
nm_setting_wired_get_mac_blacklist_item (NMSettingWired *setting, guint32 idx)
{
NMSettingWiredPrivate *priv;
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
g_return_val_if_fail (idx <= g_slist_length (priv->mac_address_blacklist), NULL);
return (const char *) g_slist_nth_data (priv->mac_address_blacklist, idx);
}
/**
* nm_setting_wired_add_mac_blacklist_item:
* @setting: the #NMSettingWired
* @mac: the MAC address string (hex-digits-and-colons notation) to blacklist
*
* Adds a new MAC address to the #NMSettingWired:mac-address-blacklist property.
*
* Returns: %TRUE if the MAC address was added; %FALSE if the MAC address
* is invalid or was already present
*
* Since: 0.9.10
**/
gboolean
nm_setting_wired_add_mac_blacklist_item (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))
return FALSE;
}
priv->mac_address_blacklist = g_slist_append (priv->mac_address_blacklist,
g_ascii_strup (mac, -1));
return TRUE;
}
/**
* nm_setting_wired_remove_mac_blacklist_item:
* @setting: the #NMSettingWired
* @idx: index number of the MAC address
*
* Removes the MAC address at index @idx from the blacklist.
*
* Since: 0.9.10
**/
void
nm_setting_wired_remove_mac_blacklist_item (NMSettingWired *setting, guint32 idx)
{
NMSettingWiredPrivate *priv;
GSList *elt;
g_return_if_fail (NM_IS_SETTING_WIRED (setting));
priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
elt = g_slist_nth (priv->mac_address_blacklist, idx);
g_return_if_fail (elt != NULL);
g_free (elt->data);
priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, elt);
}
/**
* nm_setting_wired_get_mtu:
* @setting: the #NMSettingWired
......
......@@ -90,7 +90,16 @@ const char * nm_setting_wired_get_duplex (NMSettingWired *setting
gboolean nm_setting_wired_get_auto_negotiate (NMSettingWired *setting);
const GByteArray *nm_setting_wired_get_mac_address (NMSettingWired *setting);
const GByteArray *nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting);
const GSList *nm_setting_wired_get_mac_address_blacklist (NMSettingWired *setting);
const GSList *nm_setting_wired_get_mac_address_blacklist (NMSettingWired *setting);
guint32 nm_setting_wired_get_num_mac_blacklist_items (NMSettingWired *setting);
const char * nm_setting_wired_get_mac_blacklist_item (NMSettingWired *setting,
guint32 idx);
gboolean nm_setting_wired_add_mac_blacklist_item (NMSettingWired *setting,
const char *mac);
void nm_setting_wired_remove_mac_blacklist_item (NMSettingWired *setting,
guint32 idx);
guint32 nm_setting_wired_get_mtu (NMSettingWired *setting);
const GPtrArray * nm_setting_wired_get_s390_subchannels (NMSettingWired *setting);
......
......@@ -469,6 +469,106 @@ nm_setting_wireless_get_mac_address_blacklist (NMSettingWireless *setting)
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mac_address_blacklist;
}
/**
* nm_setting_wireless_get_num_mac_blacklist_items:
* @setting: the #NMSettingWireless
*
* Returns: the number of blacklisted MAC addresses
*
* Since: 0.9.10
**/
guint32
nm_setting_wireless_get_num_mac_blacklist_items (NMSettingWireless *setting)
{
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
return g_slist_length (NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mac_address_blacklist);
}
/**
* nm_setting_wireless_get_mac_blacklist_item:
* @setting: the #NMSettingWireless
* @idx: the zero-based index of the MAC address entry
*
* Returns: the blacklisted MAC address string (hex-digits-and-colons notation)
* at index @idx
*
* Since: 0.9.10
**/
const char *
nm_setting_wireless_get_mac_blacklist_item (NMSettingWireless *setting, guint32 idx)
{
NMSettingWirelessPrivate *priv;
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
g_return_val_if_fail (idx <= g_slist_length (priv->mac_address_blacklist), NULL);
return (const char *) g_slist_nth_data (priv->mac_address_blacklist, idx);
}
/**
* nm_setting_wireless_add_mac_blacklist_item:
* @setting: the #NMSettingWireless
* @mac: the MAC address string (hex-digits-and-colons notation) to blacklist
*
* Adds a new MAC address to the #NMSettingWireless:mac-address-blacklist property.
*
* Returns: %TRUE if the MAC address was added; %FALSE if the MAC address
* is invalid or was already present
*
* Since: 0.9.10
**/
gboolean
nm_setting_wireless_add_mac_blacklist_item (NMSettingWireless *setting, const char *mac)
{
NMSettingWirelessPrivate *priv;
GSList *iter;
guint8 buf[32];
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), FALSE);
g_return_val_if_fail (mac != NULL, FALSE);
if (!nm_utils_hwaddr_aton (mac, ARPHRD_ETHER, buf))
return FALSE;
priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
for (iter = priv->mac_address_blacklist; iter; iter = g_slist_next (iter)) {
if (!strcasecmp (mac, (char *) iter->data))
return FALSE;
}
priv->mac_address_blacklist = g_slist_append (priv->mac_address_blacklist,
g_ascii_strup (mac, -1));
return TRUE;
}
/**
* nm_setting_wireless_remove_mac_blacklist_item:
* @setting: the #NMSettingWireless
* @idx: index number of the MAC address
*
* Removes the MAC address at index @idx from the blacklist.
*
* Since: 0.9.10
**/
void
nm_setting_wireless_remove_mac_blacklist_item (NMSettingWireless *setting, guint32 idx)
{
NMSettingWirelessPrivate *priv;
GSList *elt;
g_return_if_fail (NM_IS_SETTING_WIRELESS (setting));
priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
elt = g_slist_nth (priv->mac_address_blacklist, idx);
g_return_if_fail (elt != NULL);
g_free (elt->data);
priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, elt);
}
/**
* nm_setting_wireless_get_mtu:
* @setting: the #NMSettingWireless
......
......@@ -130,7 +130,16 @@ guint32 nm_setting_wireless_get_rate (NMSettingWireless
guint32 nm_setting_wireless_get_tx_power (NMSettingWireless *setting);
const GByteArray *nm_setting_wireless_get_mac_address (NMSettingWireless *setting);
const GByteArray *nm_setting_wireless_get_cloned_mac_address (NMSettingWireless *setting);
const GSList *nm_setting_wireless_get_mac_address_blacklist (NMSettingWireless *setting);
const GSList *nm_setting_wireless_get_mac_address_blacklist (NMSettingWireless *setting);
guint32 nm_setting_wireless_get_num_mac_blacklist_items (NMSettingWireless *setting);
const char * nm_setting_wireless_get_mac_blacklist_item (NMSettingWireless *setting,
guint32 idx);
gboolean nm_setting_wireless_add_mac_blacklist_item (NMSettingWireless *setting,
const char *mac);
void nm_setting_wireless_remove_mac_blacklist_item (NMSettingWireless *setting,
guint32 idx);
guint32 nm_setting_wireless_get_mtu (NMSettingWireless *setting);
const char *nm_setting_wireless_get_security (NMSettingWireless *setting);
gboolean nm_setting_wireless_get_hidden (NMSettingWireless *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