summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2014-02-25 10:19:07 +0100
committerJiří Klimeš <jklimes@redhat.com>2014-02-28 10:39:09 +0100
commit1e5370b4d23beb10e335f49a96090ade8ba28da4 (patch)
tree057a1c0c3a1cc3c207480689c27c93f04830f441
parentde646d95887fccfd3bfc8e4bc9c85a99c50f55dc (diff)
downloadNetworkManager-1e5370b4d23beb10e335f49a96090ade8ba28da4.tar.gz
libnm-util: add *_remove_*_by_value() functions for '802-11-wireless-security' setting
nm_setting_wireless_security_remove_proto_by_value() nm_setting_wireless_security_remove_pairwise_by_value() nm_setting_wireless_security_remove_group_by_value()
-rw-r--r--libnm-util/libnm-util.ver3
-rw-r--r--libnm-util/nm-setting-wireless-security.c101
-rw-r--r--libnm-util/nm-setting-wireless-security.h42
3 files changed, 127 insertions, 19 deletions
diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver
index f437415c7b..b2bec419a2 100644
--- a/libnm-util/libnm-util.ver
+++ b/libnm-util/libnm-util.ver
@@ -591,8 +591,11 @@ global:
nm_setting_wireless_security_get_wep_tx_keyidx;
nm_setting_wireless_security_new;
nm_setting_wireless_security_remove_group;
+ nm_setting_wireless_security_remove_group_by_value;
nm_setting_wireless_security_remove_pairwise;
+ nm_setting_wireless_security_remove_pairwise_by_value;
nm_setting_wireless_security_remove_proto;
+ nm_setting_wireless_security_remove_proto_by_value;
nm_setting_wireless_security_set_wep_key;
nm_utils_ap_mode_security_valid;
nm_utils_bin2hexstr;
diff --git a/libnm-util/nm-setting-wireless-security.c b/libnm-util/nm-setting-wireless-security.c
index 1bb7693d76..29c9150767 100644
--- a/libnm-util/nm-setting-wireless-security.c
+++ b/libnm-util/nm-setting-wireless-security.c
@@ -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.
*/
@@ -257,6 +257,38 @@ nm_setting_wireless_security_remove_proto (NMSettingWirelessSecurity *setting, g
}
/**
+ * nm_setting_wireless_security_remove_proto_by_value:
+ * @setting: the #NMSettingWirelessSecurity
+ * @proto: the protocol to remove, one of "wpa" or "rsn"
+ *
+ * Removes a protocol from the allowed protocol list.
+ *
+ * Returns: %TRUE if the protocol was found and removed; %FALSE it it was not.
+ *
+ * Since: 0.9.10
+ **/
+gboolean
+nm_setting_wireless_security_remove_proto_by_value (NMSettingWirelessSecurity *setting,
+ const char *proto)
+{
+ NMSettingWirelessSecurityPrivate *priv;
+ GSList *iter;
+
+ g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
+ g_return_val_if_fail (proto != NULL, FALSE);
+
+ priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
+ for (iter = priv->proto; iter; iter = g_slist_next (iter)) {
+ if (strcasecmp (proto, (char *) iter->data) == 0) {
+ priv->proto = g_slist_delete_link (priv->proto, iter);
+ g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
* nm_setting_wireless_security_clear_protos:
* @setting: the #NMSettingWirelessSecurity
*
@@ -372,6 +404,39 @@ nm_setting_wireless_security_remove_pairwise (NMSettingWirelessSecurity *setting
}
/**
+ * nm_setting_wireless_security_remove_pairwise_by_value:
+ * @setting: the #NMSettingWirelessSecurity
+ * @pairwise: the encryption algorithm to remove, one of "tkip" or "ccmp"
+ *
+ * Removes an encryption algorithm from the allowed pairwise encryption
+ * algorithm list.
+ *
+ * Returns: %TRUE if the encryption algorith was found and removed; %FALSE it it was not.
+ *
+ * Since: 0.9.10
+ **/
+gboolean
+nm_setting_wireless_security_remove_pairwise_by_value (NMSettingWirelessSecurity *setting,
+ const char *pairwise)
+{
+ NMSettingWirelessSecurityPrivate *priv;
+ GSList *iter;
+
+ g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
+ g_return_val_if_fail (pairwise != NULL, FALSE);
+
+ priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
+ for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) {
+ if (strcasecmp (pairwise, (char *) iter->data) == 0) {
+ priv->pairwise = g_slist_delete_link (priv->pairwise, iter);
+ g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
* nm_setting_wireless_security_clear_pairwise:
* @setting: the #NMSettingWirelessSecurity
*
@@ -488,6 +553,40 @@ nm_setting_wireless_security_remove_group (NMSettingWirelessSecurity *setting, g
}
/**
+ * nm_setting_wireless_security_remove_group_by_value:
+ * @setting: the #NMSettingWirelessSecurity
+ * @group: the encryption algorithm to remove, one of "wep40", "wep104",
+ * "tkip", or "ccmp"
+ *
+ * Removes an encryption algorithm from the allowed groupwise encryption
+ * algorithm list.
+ *
+ * Returns: %TRUE if the algorithm was found and removed; %FALSE it it was not.
+ *
+ * Since: 0.9.10
+ **/
+gboolean
+nm_setting_wireless_security_remove_group_by_value (NMSettingWirelessSecurity *setting,
+ const char *group)
+{
+ NMSettingWirelessSecurityPrivate *priv;
+ GSList *iter;
+
+ g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
+ g_return_val_if_fail (group != NULL, FALSE);
+
+ priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
+ for (iter = priv->group; iter; iter = g_slist_next (iter)) {
+ if (strcasecmp (group, (char *) iter->data) == 0) {
+ priv->group = g_slist_delete_link (priv->group, iter);
+ g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
* nm_setting_wireless_security_clear_groups:
* @setting: the #NMSettingWirelessSecurity
*
diff --git a/libnm-util/nm-setting-wireless-security.h b/libnm-util/nm-setting-wireless-security.h
index d9e972c049..eabbe66e39 100644
--- a/libnm-util/nm-setting-wireless-security.h
+++ b/libnm-util/nm-setting-wireless-security.h
@@ -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.
*/
@@ -137,23 +137,29 @@ NMSetting * nm_setting_wireless_security_new (void);
const char *nm_setting_wireless_security_get_key_mgmt (NMSettingWirelessSecurity *setting);
-guint32 nm_setting_wireless_security_get_num_protos (NMSettingWirelessSecurity *setting);
-const char *nm_setting_wireless_security_get_proto (NMSettingWirelessSecurity *setting, guint32 i);
-gboolean nm_setting_wireless_security_add_proto (NMSettingWirelessSecurity *setting, const char *proto);
-void nm_setting_wireless_security_remove_proto (NMSettingWirelessSecurity *setting, guint32 i);
-void nm_setting_wireless_security_clear_protos (NMSettingWirelessSecurity *setting);
-
-guint32 nm_setting_wireless_security_get_num_pairwise (NMSettingWirelessSecurity *setting);
-const char *nm_setting_wireless_security_get_pairwise (NMSettingWirelessSecurity *setting, guint32 i);
-gboolean nm_setting_wireless_security_add_pairwise (NMSettingWirelessSecurity *setting, const char *pairwise);
-void nm_setting_wireless_security_remove_pairwise (NMSettingWirelessSecurity *setting, guint32 i);
-void nm_setting_wireless_security_clear_pairwise (NMSettingWirelessSecurity *setting);
-
-guint32 nm_setting_wireless_security_get_num_groups (NMSettingWirelessSecurity *setting);
-const char *nm_setting_wireless_security_get_group (NMSettingWirelessSecurity *setting, guint32 i);
-gboolean nm_setting_wireless_security_add_group (NMSettingWirelessSecurity *setting, const char *group);
-void nm_setting_wireless_security_remove_group (NMSettingWirelessSecurity *setting, guint32 i);
-void nm_setting_wireless_security_clear_groups (NMSettingWirelessSecurity *setting);
+guint32 nm_setting_wireless_security_get_num_protos (NMSettingWirelessSecurity *setting);
+const char *nm_setting_wireless_security_get_proto (NMSettingWirelessSecurity *setting, guint32 i);
+gboolean nm_setting_wireless_security_add_proto (NMSettingWirelessSecurity *setting, const char *proto);
+void nm_setting_wireless_security_remove_proto (NMSettingWirelessSecurity *setting, guint32 i);
+NM_AVAILABLE_IN_0_9_10
+gboolean nm_setting_wireless_security_remove_proto_by_value (NMSettingWirelessSecurity *setting, const char *proto);
+void nm_setting_wireless_security_clear_protos (NMSettingWirelessSecurity *setting);
+
+guint32 nm_setting_wireless_security_get_num_pairwise (NMSettingWirelessSecurity *setting);
+const char *nm_setting_wireless_security_get_pairwise (NMSettingWirelessSecurity *setting, guint32 i);
+gboolean nm_setting_wireless_security_add_pairwise (NMSettingWirelessSecurity *setting, const char *pairwise);
+void nm_setting_wireless_security_remove_pairwise (NMSettingWirelessSecurity *setting, guint32 i);
+NM_AVAILABLE_IN_0_9_10
+gboolean nm_setting_wireless_security_remove_pairwise_by_value (NMSettingWirelessSecurity *setting, const char *proto);
+void nm_setting_wireless_security_clear_pairwise (NMSettingWirelessSecurity *setting);
+
+guint32 nm_setting_wireless_security_get_num_groups (NMSettingWirelessSecurity *setting);
+const char *nm_setting_wireless_security_get_group (NMSettingWirelessSecurity *setting, guint32 i);
+gboolean nm_setting_wireless_security_add_group (NMSettingWirelessSecurity *setting, const char *group);
+void nm_setting_wireless_security_remove_group (NMSettingWirelessSecurity *setting, guint32 i);
+NM_AVAILABLE_IN_0_9_10
+gboolean nm_setting_wireless_security_remove_group_by_value (NMSettingWirelessSecurity *setting, const char *proto);
+void nm_setting_wireless_security_clear_groups (NMSettingWirelessSecurity *setting);
const char *nm_setting_wireless_security_get_psk (NMSettingWirelessSecurity *setting);
NMSettingSecretFlags nm_setting_wireless_security_get_psk_flags (NMSettingWirelessSecurity *setting);