2008-07-27 20:03:46 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dan Williams <dcbw@redhat.com>
|
|
|
|
* Tambet Ingo <tambet@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2013-02-07 13:49:53 +00:00
|
|
|
* (C) Copyright 2007 - 2013 Red Hat, Inc.
|
2008-07-27 20:03:46 +00:00
|
|
|
* (C) Copyright 2007 - 2008 Novell, Inc.
|
|
|
|
*/
|
2007-11-07 16:06:43 +00:00
|
|
|
|
2010-10-09 03:45:35 +00:00
|
|
|
#include <config.h>
|
2007-11-07 16:06:43 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <dbus/dbus-glib.h>
|
2013-02-07 13:49:53 +00:00
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
2007-11-07 16:06:43 +00:00
|
|
|
#include "nm-setting-wireless-security.h"
|
2008-03-17 19:37:23 +00:00
|
|
|
#include "nm-setting-8021x.h"
|
2007-11-07 16:06:43 +00:00
|
|
|
#include "nm-param-spec-specialized.h"
|
|
|
|
#include "nm-utils.h"
|
2008-03-29 21:35:41 +00:00
|
|
|
#include "nm-dbus-glib-types.h"
|
2008-11-20 20:17:01 +00:00
|
|
|
#include "nm-utils-private.h"
|
2011-01-31 18:36:53 +00:00
|
|
|
#include "nm-setting-private.h"
|
2007-11-07 16:06:43 +00:00
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* SECTION:nm-setting-wireless-security
|
|
|
|
* @short_description: Describes connection properties for WiFi networks that
|
|
|
|
* use WEP, LEAP, WPA or WPA2/RSN security
|
|
|
|
* @include: nm-setting-wireless-security.h
|
|
|
|
*
|
|
|
|
* The #NMSettingWirelessSecurity object is a #NMSetting subclass that describes
|
2011-07-05 23:13:51 +00:00
|
|
|
* properties necessary for connection to encrypted WiFi networks.
|
2011-07-05 23:09:14 +00:00
|
|
|
*
|
|
|
|
* It's a good idea to read up on wpa_supplicant configuration before using this
|
|
|
|
* setting extensively, since most of the options here correspond closely with
|
|
|
|
* the relevant wpa_supplicant configuration options. To get a better overview
|
|
|
|
* of how WiFi security works, you may want to get copies of the following books.
|
|
|
|
*
|
|
|
|
* 802.11 Wireless Networks: The Definitive Guide, Second Edition
|
|
|
|
* Author: Matthew Gast
|
|
|
|
* ISBN: 978-0596100520
|
|
|
|
*
|
|
|
|
* Cisco Wireless LAN Security
|
|
|
|
* Authors: Krishna Sankar, Sri Sundaralingam, Darrin Miller, and Andrew Balinsky
|
|
|
|
* ISBN: 978-1587051548
|
|
|
|
**/
|
|
|
|
|
|
|
|
/**
|
2012-06-14 17:35:30 +00:00
|
|
|
* nm_setting_wireless_security_error_quark:
|
2011-07-05 23:09:14 +00:00
|
|
|
*
|
|
|
|
* Registers an error quark for #NMSettingWired if necessary.
|
|
|
|
*
|
|
|
|
* Returns: the error quark used for #NMSettingWired errors.
|
|
|
|
**/
|
2008-06-12 23:58:08 +00:00
|
|
|
GQuark
|
|
|
|
nm_setting_wireless_security_error_quark (void)
|
|
|
|
{
|
|
|
|
static GQuark quark;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!quark))
|
|
|
|
quark = g_quark_from_static_string ("nm-setting-wireless-security-error-quark");
|
|
|
|
return quark;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-22 17:36:09 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (NMSettingWirelessSecurity, nm_setting_wireless_security, NM_TYPE_SETTING,
|
|
|
|
_nm_register_setting (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
|
|
|
|
g_define_type_id,
|
|
|
|
2,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR))
|
|
|
|
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS_SECURITY)
|
2007-11-07 16:06:43 +00:00
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
#define NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS_SECURITY, NMSettingWirelessSecurityPrivate))
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *key_mgmt;
|
|
|
|
char *auth_alg;
|
|
|
|
GSList *proto; /* GSList of strings */
|
|
|
|
GSList *pairwise; /* GSList of strings */
|
|
|
|
GSList *group; /* GSList of strings */
|
2011-01-29 19:34:24 +00:00
|
|
|
|
|
|
|
/* LEAP */
|
2008-10-30 14:45:55 +00:00
|
|
|
char *leap_username;
|
2011-01-29 19:34:24 +00:00
|
|
|
char *leap_password;
|
|
|
|
NMSettingSecretFlags leap_password_flags;
|
|
|
|
|
|
|
|
/* WEP */
|
2008-10-30 14:45:55 +00:00
|
|
|
char *wep_key0;
|
|
|
|
char *wep_key1;
|
|
|
|
char *wep_key2;
|
|
|
|
char *wep_key3;
|
2011-01-29 19:34:24 +00:00
|
|
|
NMSettingSecretFlags wep_key_flags;
|
2009-05-10 02:34:35 +00:00
|
|
|
NMWepKeyType wep_key_type;
|
2011-01-29 19:34:24 +00:00
|
|
|
guint32 wep_tx_keyidx;
|
|
|
|
|
|
|
|
/* WPA-PSK */
|
|
|
|
char *psk;
|
|
|
|
NMSettingSecretFlags psk_flags;
|
2008-10-30 14:45:55 +00:00
|
|
|
} NMSettingWirelessSecurityPrivate;
|
|
|
|
|
2007-11-07 16:06:43 +00:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_KEY_MGMT,
|
|
|
|
PROP_WEP_TX_KEYIDX,
|
|
|
|
PROP_AUTH_ALG,
|
|
|
|
PROP_PROTO,
|
|
|
|
PROP_PAIRWISE,
|
|
|
|
PROP_GROUP,
|
2008-03-17 19:37:23 +00:00
|
|
|
PROP_LEAP_USERNAME,
|
2007-11-07 16:06:43 +00:00
|
|
|
PROP_WEP_KEY0,
|
|
|
|
PROP_WEP_KEY1,
|
|
|
|
PROP_WEP_KEY2,
|
|
|
|
PROP_WEP_KEY3,
|
2011-01-29 19:34:24 +00:00
|
|
|
PROP_WEP_KEY_FLAGS,
|
|
|
|
PROP_WEP_KEY_TYPE,
|
2007-11-07 16:06:43 +00:00
|
|
|
PROP_PSK,
|
2011-01-29 19:34:24 +00:00
|
|
|
PROP_PSK_FLAGS,
|
2008-03-17 19:37:23 +00:00
|
|
|
PROP_LEAP_PASSWORD,
|
2011-01-29 19:34:24 +00:00
|
|
|
PROP_LEAP_PASSWORD_FLAGS,
|
2007-11-07 16:06:43 +00:00
|
|
|
|
|
|
|
LAST_PROP
|
|
|
|
};
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_new:
|
|
|
|
*
|
|
|
|
* Creates a new #NMSettingWirelessSecurity object with default values.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): the new empty #NMSettingWirelessSecurity object
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
NMSetting *
|
|
|
|
nm_setting_wireless_security_new (void)
|
|
|
|
{
|
|
|
|
return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIRELESS_SECURITY, NULL);
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_key_mgmt:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingWirelessSecurity:key-mgmt property of the setting
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
const char *
|
|
|
|
nm_setting_wireless_security_get_key_mgmt (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
|
|
|
|
|
|
|
|
return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->key_mgmt;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_num_protos:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the number of security protocols this connection allows when
|
|
|
|
* connecting to secure WiFi networks
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
guint32
|
|
|
|
nm_setting_wireless_security_get_num_protos (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
|
|
|
|
|
|
|
|
return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->proto);
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_proto:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
* @i: an index into the protocol list
|
|
|
|
*
|
|
|
|
* Returns: the protocol at index @i
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
const char *
|
|
|
|
nm_setting_wireless_security_get_proto (NMSettingWirelessSecurity *setting, guint32 i)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurityPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
|
|
|
|
|
|
|
|
priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
g_return_val_if_fail (i <= g_slist_length (priv->proto), NULL);
|
|
|
|
|
|
|
|
return (const char *) g_slist_nth_data (priv->proto, i);
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_add_proto:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
* @proto: the protocol to add, one of "wpa" or "rsn"
|
|
|
|
*
|
|
|
|
* Adds a WiFi security protocol (one of "wpa" or "rsn") to the allowed list;
|
|
|
|
* only protocols in this list will be used when finding and connecting to
|
|
|
|
* the WiFi network specified by this connection. For example, if the
|
|
|
|
* protocol list contains only "wpa" but the access point for the SSID specified
|
|
|
|
* by this connection only supports WPA2/RSN, the connection cannot be used
|
|
|
|
* with the access point.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the protocol was new and and was added to the allowed
|
|
|
|
* protocol list, or %FALSE if it was already in the list
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
gboolean
|
|
|
|
nm_setting_wireless_security_add_proto (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)) {
|
2011-07-05 23:09:14 +00:00
|
|
|
if (strcasecmp (proto, (char *) iter->data) == 0)
|
2008-10-30 14:45:55 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->proto = g_slist_append (priv->proto, g_ascii_strdown (proto, -1));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_remove_proto:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
* @i: index of the protocol to remove
|
|
|
|
*
|
|
|
|
* Removes a protocol from the allowed protocol list.
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
void
|
|
|
|
nm_setting_wireless_security_remove_proto (NMSettingWirelessSecurity *setting, guint32 i)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurityPrivate *priv;
|
|
|
|
GSList *elt;
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
|
|
|
|
|
|
|
|
priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
elt = g_slist_nth (priv->proto, i);
|
|
|
|
g_return_if_fail (elt != NULL);
|
|
|
|
|
|
|
|
g_free (elt->data);
|
|
|
|
priv->proto = g_slist_delete_link (priv->proto, elt);
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_clear_protos:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Removes all protocols from the allowed list. If there are no protocols
|
|
|
|
* specified then all protocols are allowed.
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
void
|
|
|
|
nm_setting_wireless_security_clear_protos (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurityPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
|
|
|
|
|
|
|
|
priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
nm_utils_slist_free (priv->proto, g_free);
|
|
|
|
priv->proto = NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_num_pairwise:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the number of pairwise encryption algorithms in the allowed list
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
guint32
|
|
|
|
nm_setting_wireless_security_get_num_pairwise (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
|
|
|
|
|
|
|
|
return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->pairwise);
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_pairwise:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
* @i: index of an item in the allowed pairwise encryption algorithm list
|
|
|
|
*
|
|
|
|
* Returns the allowed pairwise encryption algorithm from allowed algorithm
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* Returns: the pairwise encryption algorithm at index @i
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
const char *
|
|
|
|
nm_setting_wireless_security_get_pairwise (NMSettingWirelessSecurity *setting, guint32 i)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurityPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
|
|
|
|
|
|
|
|
priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
g_return_val_if_fail (i <= g_slist_length (priv->pairwise), NULL);
|
|
|
|
|
|
|
|
return (const char *) g_slist_nth_data (priv->pairwise, i);
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_add_pairwise:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
2013-04-30 17:39:19 +00:00
|
|
|
* @pairwise: the encryption algorithm to add, one of "tkip" or "ccmp"
|
2011-07-05 23:09:14 +00:00
|
|
|
*
|
|
|
|
* Adds an encryption algorithm to the list of allowed pairwise encryption
|
|
|
|
* algorithms. If the list is not empty, then only access points that support
|
|
|
|
* one or more of the encryption algorithms in the list will be considered
|
|
|
|
* compatible with this connection.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the algorithm was added to the list, %FALSE if it was
|
|
|
|
* already in the list
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
gboolean
|
|
|
|
nm_setting_wireless_security_add_pairwise (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)) {
|
2011-07-05 23:09:14 +00:00
|
|
|
if (strcasecmp (pairwise, (char *) iter->data) == 0)
|
2008-10-30 14:45:55 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->pairwise = g_slist_append (priv->pairwise, g_ascii_strdown (pairwise, -1));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_remove_pairwise:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
* @i: the index of an item in the allowed pairwise encryption algorithm list
|
|
|
|
*
|
|
|
|
* Removes an encryption algorithm from the allowed pairwise encryption
|
|
|
|
* algorithm list.
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
void
|
|
|
|
nm_setting_wireless_security_remove_pairwise (NMSettingWirelessSecurity *setting, guint32 i)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurityPrivate *priv;
|
|
|
|
GSList *elt;
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
|
|
|
|
|
|
|
|
priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
elt = g_slist_nth (priv->pairwise, i);
|
|
|
|
g_return_if_fail (elt != NULL);
|
|
|
|
|
|
|
|
g_free (elt->data);
|
|
|
|
priv->pairwise = g_slist_delete_link (priv->pairwise, elt);
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_clear_pairwise:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Removes all algorithms from the allowed list. If there are no algorithms
|
|
|
|
* specified then all pairwise encryption algorithms are allowed.
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
void
|
|
|
|
nm_setting_wireless_security_clear_pairwise (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurityPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
|
|
|
|
|
|
|
|
priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
nm_utils_slist_free (priv->pairwise, g_free);
|
|
|
|
priv->pairwise = NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_num_groups:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the number of groupwise encryption algorithms in the allowed list
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
guint32
|
|
|
|
nm_setting_wireless_security_get_num_groups (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
|
|
|
|
|
|
|
|
return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->group);
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_group:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
* @i: index of an item in the allowed groupwise encryption algorithm list
|
|
|
|
*
|
|
|
|
* Returns the allowed groupwise encryption algorithm from allowed algorithm
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* Returns: the groupwise encryption algorithm at index @i
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
const char *
|
|
|
|
nm_setting_wireless_security_get_group (NMSettingWirelessSecurity *setting, guint32 i)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurityPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
|
|
|
|
|
|
|
|
priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
g_return_val_if_fail (i <= g_slist_length (priv->group), NULL);
|
|
|
|
|
|
|
|
return (const char *) g_slist_nth_data (priv->group, i);
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_add_group:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
* @group: the encryption algorithm to add, one of "wep40", "wep104",
|
|
|
|
* "tkip", or "ccmp"
|
|
|
|
*
|
|
|
|
* Adds an encryption algorithm to the list of allowed groupwise encryption
|
|
|
|
* algorithms. If the list is not empty, then only access points that support
|
|
|
|
* one or more of the encryption algorithms in the list will be considered
|
|
|
|
* compatible with this connection.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the algorithm was added to the list, %FALSE if it was
|
|
|
|
* already in the list
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
gboolean
|
|
|
|
nm_setting_wireless_security_add_group (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)) {
|
2011-07-05 23:09:14 +00:00
|
|
|
if (strcasecmp (group, (char *) iter->data) == 0)
|
2008-10-30 14:45:55 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->group = g_slist_append (priv->group, g_ascii_strdown (group, -1));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_remove_group:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
* @i: the index of an item in the allowed groupwise encryption algorithm list
|
|
|
|
*
|
|
|
|
* Removes an encryption algorithm from the allowed groupwise encryption
|
|
|
|
* algorithm list.
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
void
|
|
|
|
nm_setting_wireless_security_remove_group (NMSettingWirelessSecurity *setting, guint32 i)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurityPrivate *priv;
|
|
|
|
GSList *elt;
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
|
|
|
|
|
|
|
|
priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
elt = g_slist_nth (priv->group, i);
|
|
|
|
g_return_if_fail (elt != NULL);
|
|
|
|
|
|
|
|
g_free (elt->data);
|
|
|
|
priv->group = g_slist_delete_link (priv->group, elt);
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_clear_groups:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Removes all algorithms from the allowed list. If there are no algorithms
|
|
|
|
* specified then all groupwise encryption algorithms are allowed.
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
void
|
|
|
|
nm_setting_wireless_security_clear_groups (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurityPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
|
|
|
|
|
|
|
|
priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
nm_utils_slist_free (priv->group, g_free);
|
|
|
|
priv->group = NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_psk:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingWirelessSecurity:psk property of the setting
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
const char *
|
|
|
|
nm_setting_wireless_security_get_psk (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
|
|
|
|
|
|
|
|
return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->psk;
|
|
|
|
}
|
|
|
|
|
2011-01-29 19:34:24 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_psk_flags:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingSecretFlags pertaining to the
|
|
|
|
* #NMSettingWirelessSecurity:psk
|
|
|
|
**/
|
|
|
|
NMSettingSecretFlags
|
|
|
|
nm_setting_wireless_security_get_psk_flags (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
2011-02-07 05:37:39 +00:00
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
|
2011-01-29 19:34:24 +00:00
|
|
|
|
|
|
|
return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->psk_flags;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_leap_username:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingWirelessSecurity:leap-username property of the setting
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
const char *
|
|
|
|
nm_setting_wireless_security_get_leap_username (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
|
|
|
|
|
|
|
|
return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_username;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_leap_password:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingWirelessSecurity:leap-password property of the setting
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
const char *
|
|
|
|
nm_setting_wireless_security_get_leap_password (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
|
|
|
|
|
|
|
|
return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_password;
|
|
|
|
}
|
|
|
|
|
2011-01-29 19:34:24 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_leap_password_flags:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingSecretFlags pertaining to the
|
|
|
|
* #NMSettingWirelessSecurity:leap-password
|
|
|
|
**/
|
|
|
|
NMSettingSecretFlags
|
|
|
|
nm_setting_wireless_security_get_leap_password_flags (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
2011-02-07 05:37:39 +00:00
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
|
2011-01-29 19:34:24 +00:00
|
|
|
|
|
|
|
return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_password_flags;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_wep_key:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
* @idx: the WEP key index (0..3 inclusive)
|
|
|
|
*
|
|
|
|
* Returns: the WEP key at the given index
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
const char *
|
|
|
|
nm_setting_wireless_security_get_wep_key (NMSettingWirelessSecurity *setting, guint32 idx)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurityPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
|
|
|
|
g_return_val_if_fail (idx < 4, NULL);
|
|
|
|
|
|
|
|
priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
if (idx == 0)
|
|
|
|
return priv->wep_key0;
|
|
|
|
else if (idx == 1)
|
|
|
|
return priv->wep_key1;
|
|
|
|
else if (idx == 2)
|
|
|
|
return priv->wep_key2;
|
|
|
|
else if (idx == 3)
|
|
|
|
return priv->wep_key3;
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_set_wep_key:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
* @idx: the index of the key (0..3 inclusive)
|
|
|
|
* @key: the WEP key as a string, in either hexadecimal, ASCII, or passphrase
|
|
|
|
* form as determiend by the value of the #NMSettingWirelessSecurity:wep-key-type
|
|
|
|
* property.
|
|
|
|
*
|
|
|
|
* Sets a WEP key in the given index.
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
void
|
|
|
|
nm_setting_wireless_security_set_wep_key (NMSettingWirelessSecurity *setting, guint32 idx, const char *key)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurityPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
|
|
|
|
g_return_if_fail (idx < 4);
|
|
|
|
|
|
|
|
priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
switch (idx) {
|
|
|
|
case 0:
|
|
|
|
g_free (priv->wep_key0);
|
|
|
|
priv->wep_key0 = g_strdup (key);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
g_free (priv->wep_key1);
|
|
|
|
priv->wep_key1 = g_strdup (key);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
g_free (priv->wep_key2);
|
|
|
|
priv->wep_key2 = g_strdup (key);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
g_free (priv->wep_key3);
|
|
|
|
priv->wep_key3 = g_strdup (key);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_wep_tx_keyidx:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingWirelessSecurity:wep-tx-keyidx property of the setting
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
guint32
|
|
|
|
nm_setting_wireless_security_get_wep_tx_keyidx (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
|
|
|
|
|
|
|
|
return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_tx_keyidx;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_auth_alg:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingWirelessSecurity:auth-alg property of the setting
|
|
|
|
**/
|
2008-10-30 14:45:55 +00:00
|
|
|
const char *
|
|
|
|
nm_setting_wireless_security_get_auth_alg (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
|
|
|
|
|
|
|
|
return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->auth_alg;
|
|
|
|
}
|
|
|
|
|
2011-01-29 19:34:24 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_wep_key_flags:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingSecretFlags pertaining to the all WEP keys
|
|
|
|
**/
|
|
|
|
NMSettingSecretFlags
|
|
|
|
nm_setting_wireless_security_get_wep_key_flags (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
2011-02-07 05:37:39 +00:00
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
|
2011-01-29 19:34:24 +00:00
|
|
|
|
|
|
|
return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_key_flags;
|
|
|
|
}
|
|
|
|
|
2011-07-05 23:09:14 +00:00
|
|
|
/**
|
|
|
|
* nm_setting_wireless_security_get_wep_key_type:
|
|
|
|
* @setting: the #NMSettingWirelessSecurity
|
|
|
|
*
|
|
|
|
* Returns: the #NMSettingWirelessSecurity:wep-key-type property of the setting
|
|
|
|
**/
|
2009-05-10 02:34:35 +00:00
|
|
|
NMWepKeyType
|
|
|
|
nm_setting_wireless_security_get_wep_key_type (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
|
|
|
|
|
|
|
|
return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_key_type;
|
|
|
|
}
|
|
|
|
|
2007-11-07 16:06:43 +00:00
|
|
|
static GPtrArray *
|
|
|
|
need_secrets (NMSetting *setting)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting);
|
2008-10-30 14:45:55 +00:00
|
|
|
NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
|
2007-11-07 16:06:43 +00:00
|
|
|
GPtrArray *secrets;
|
|
|
|
|
|
|
|
secrets = g_ptr_array_sized_new (4);
|
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
g_assert (priv->key_mgmt);
|
2007-11-07 16:06:43 +00:00
|
|
|
|
|
|
|
/* Static WEP */
|
2008-10-30 14:45:55 +00:00
|
|
|
if (strcmp (priv->key_mgmt, "none") == 0) {
|
2013-02-04 10:36:10 +00:00
|
|
|
if ((priv->wep_tx_keyidx == 0) && !nm_utils_wep_key_valid (priv->wep_key0, priv->wep_key_type)) {
|
2007-11-13 02:16:00 +00:00
|
|
|
g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
|
2007-11-07 16:06:43 +00:00
|
|
|
return secrets;
|
|
|
|
}
|
2013-02-04 10:36:10 +00:00
|
|
|
if ((priv->wep_tx_keyidx == 1) && !nm_utils_wep_key_valid (priv->wep_key1, priv->wep_key_type)) {
|
2007-11-13 02:16:00 +00:00
|
|
|
g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1);
|
2007-11-07 16:06:43 +00:00
|
|
|
return secrets;
|
|
|
|
}
|
2013-02-04 10:36:10 +00:00
|
|
|
if ((priv->wep_tx_keyidx == 2) && !nm_utils_wep_key_valid (priv->wep_key2, priv->wep_key_type)) {
|
2007-11-13 02:16:00 +00:00
|
|
|
g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2);
|
2007-11-07 16:06:43 +00:00
|
|
|
return secrets;
|
|
|
|
}
|
2013-02-04 10:36:10 +00:00
|
|
|
if ((priv->wep_tx_keyidx == 3) && !nm_utils_wep_key_valid (priv->wep_key3, priv->wep_key_type)) {
|
2007-11-13 02:16:00 +00:00
|
|
|
g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
|
2007-11-07 16:06:43 +00:00
|
|
|
return secrets;
|
|
|
|
}
|
|
|
|
goto no_secrets;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* WPA-PSK infrastructure and adhoc */
|
2008-10-30 14:45:55 +00:00
|
|
|
if ( (strcmp (priv->key_mgmt, "wpa-none") == 0)
|
|
|
|
|| (strcmp (priv->key_mgmt, "wpa-psk") == 0)) {
|
2013-02-04 10:36:10 +00:00
|
|
|
if (!nm_utils_wpa_psk_valid (priv->psk)) {
|
2007-11-13 02:16:00 +00:00
|
|
|
g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_PSK);
|
2007-11-07 16:06:43 +00:00
|
|
|
return secrets;
|
|
|
|
}
|
|
|
|
goto no_secrets;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* LEAP */
|
2008-10-30 14:45:55 +00:00
|
|
|
if ( priv->auth_alg
|
|
|
|
&& !strcmp (priv->auth_alg, "leap")
|
|
|
|
&& !strcmp (priv->key_mgmt, "ieee8021x")) {
|
|
|
|
if (!priv->leap_password || !strlen (priv->leap_password)) {
|
2008-03-17 19:37:23 +00:00
|
|
|
g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD);
|
2007-11-07 16:06:43 +00:00
|
|
|
return secrets;
|
|
|
|
}
|
|
|
|
goto no_secrets;
|
|
|
|
}
|
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0)
|
|
|
|
|| (strcmp (priv->key_mgmt, "wpa-eap") == 0)) {
|
2008-03-17 19:37:23 +00:00
|
|
|
/* Let caller check the 802.1x setting for secrets */
|
2007-11-07 16:06:43 +00:00
|
|
|
goto no_secrets;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return secrets;
|
|
|
|
|
|
|
|
no_secrets:
|
|
|
|
if (secrets)
|
|
|
|
g_ptr_array_free (secrets, TRUE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-03-17 19:37:23 +00:00
|
|
|
static gint
|
|
|
|
find_setting_by_name (gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
NMSetting *setting = NM_SETTING (a);
|
|
|
|
const char *str = (const char *) b;
|
|
|
|
|
|
|
|
return strcmp (nm_setting_get_name (setting), str);
|
|
|
|
}
|
|
|
|
|
2007-11-19 18:13:48 +00:00
|
|
|
static gboolean
|
2008-06-12 23:58:08 +00:00
|
|
|
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
2007-11-19 18:13:48 +00:00
|
|
|
{
|
|
|
|
NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting);
|
2008-10-30 14:45:55 +00:00
|
|
|
NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
|
2007-11-19 18:13:48 +00:00
|
|
|
const char *valid_key_mgmt[] = { "none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap", NULL };
|
|
|
|
const char *valid_auth_algs[] = { "open", "shared", "leap", NULL };
|
|
|
|
const char *valid_protos[] = { "wpa", "rsn", NULL };
|
2013-04-30 17:39:19 +00:00
|
|
|
const char *valid_pairwise[] = { "tkip", "ccmp", NULL };
|
2007-11-19 18:13:48 +00:00
|
|
|
const char *valid_groups[] = { "wep40", "wep104", "tkip", "ccmp", NULL };
|
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
if (!priv->key_mgmt) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY,
|
|
|
|
_("property is missing"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
|
2008-06-12 23:58:08 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:17:01 +00:00
|
|
|
if (!_nm_utils_string_in_list (priv->key_mgmt, valid_key_mgmt)) {
|
2008-06-12 23:58:08 +00:00
|
|
|
g_set_error (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
2013-02-07 13:49:53 +00:00
|
|
|
_("'%s' is not a valid value for the property"),
|
|
|
|
priv->key_mgmt);
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
|
2007-11-19 18:13:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
if (priv->auth_alg && !strcmp (priv->auth_alg, "leap")) {
|
2008-03-17 19:37:23 +00:00
|
|
|
/* LEAP must use ieee8021x key management */
|
2008-10-30 14:45:55 +00:00
|
|
|
if (strcmp (priv->key_mgmt, "ieee8021x")) {
|
2008-06-12 23:58:08 +00:00
|
|
|
g_set_error (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X,
|
2013-02-07 13:49:53 +00:00
|
|
|
_("'%s' security requires '%s=%s'"),
|
|
|
|
"leap", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x");
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
|
2008-03-17 19:37:23 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-10-30 14:45:55 +00:00
|
|
|
if (!priv->leap_username) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME,
|
|
|
|
_("property is empty"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
|
2008-03-17 19:37:23 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-01-12 15:31:00 +00:00
|
|
|
if (priv->leap_password && !strlen (priv->leap_password)) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is empty"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD);
|
2009-01-12 15:31:00 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-03-17 19:37:23 +00:00
|
|
|
} else {
|
2008-10-30 14:45:55 +00:00
|
|
|
if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0)
|
|
|
|
|| (strcmp (priv->key_mgmt, "wpa-eap") == 0)) {
|
2008-03-17 19:37:23 +00:00
|
|
|
/* Need an 802.1x setting too */
|
|
|
|
if (!g_slist_find_custom (all_settings, NM_SETTING_802_1X_SETTING_NAME, find_setting_by_name)) {
|
2008-06-12 23:58:08 +00:00
|
|
|
g_set_error (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING,
|
2013-02-07 13:49:53 +00:00
|
|
|
_("'%s' security requires '%s' setting presence"),
|
|
|
|
priv->key_mgmt, NM_SETTING_802_1X_SETTING_NAME);
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
|
2008-03-17 19:37:23 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
if (priv->leap_username && !strlen (priv->leap_username)) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is empty"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
|
2008-06-12 23:58:08 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
if (priv->wep_tx_keyidx > 3) {
|
2008-06-12 23:58:08 +00:00
|
|
|
g_set_error (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
2013-02-07 13:49:53 +00:00
|
|
|
_("'%d' value is out of range <0-3>"),
|
|
|
|
priv->wep_tx_keyidx);
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX);
|
2007-11-19 18:13:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-05-10 02:34:35 +00:00
|
|
|
if (priv->wep_key_type > NM_WEP_KEY_TYPE_LAST) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is invalid"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE);
|
2009-05-10 02:34:35 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-02-04 10:36:10 +00:00
|
|
|
if (priv->wep_key0 && !nm_utils_wep_key_valid (priv->wep_key0, priv->wep_key_type)) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is invalid"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
|
2008-03-30 14:25:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2013-02-04 10:36:10 +00:00
|
|
|
if (priv->wep_key1 && !nm_utils_wep_key_valid (priv->wep_key1, priv->wep_key_type)) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is invalid"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_WEP_KEY1);
|
2008-03-30 14:25:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2013-02-04 10:36:10 +00:00
|
|
|
if (priv->wep_key2 && !nm_utils_wep_key_valid (priv->wep_key2, priv->wep_key_type)) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is invalid"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_WEP_KEY2);
|
2008-03-30 14:25:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2013-02-04 10:36:10 +00:00
|
|
|
if (priv->wep_key3 && !nm_utils_wep_key_valid (priv->wep_key3, priv->wep_key_type)) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is invalid"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
|
2008-03-30 14:25:54 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:17:01 +00:00
|
|
|
if (priv->auth_alg && !_nm_utils_string_in_list (priv->auth_alg, valid_auth_algs)) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is invalid"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
|
2007-11-19 18:13:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-02-04 10:36:10 +00:00
|
|
|
if (priv->psk && !nm_utils_wpa_psk_valid (priv->psk)) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is invalid"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_PSK);
|
2009-01-12 15:31:00 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:17:01 +00:00
|
|
|
if (priv->proto && !_nm_utils_string_slist_validate (priv->proto, valid_protos)) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is invalid"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_PROTO);
|
2007-11-19 18:13:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
if (priv->pairwise) {
|
2008-10-20 21:39:56 +00:00
|
|
|
const char *wpa_none[] = { "wpa-none", NULL };
|
|
|
|
|
|
|
|
/* For ad-hoc connections, pairwise must be "none" */
|
2008-11-20 20:17:01 +00:00
|
|
|
if (_nm_utils_string_in_list (priv->key_mgmt, wpa_none)) {
|
2008-10-20 21:39:56 +00:00
|
|
|
GSList *iter;
|
|
|
|
gboolean found = FALSE;
|
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) {
|
2008-10-20 21:39:56 +00:00
|
|
|
if (!strcmp ((char *) iter->data, "none")) {
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pairwise cipher list didn't contain "none", which is invalid
|
|
|
|
* for WPA adhoc connections.
|
|
|
|
*/
|
|
|
|
if (!found) {
|
|
|
|
g_set_error (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
2013-02-07 13:49:53 +00:00
|
|
|
_("'%s' connections require '%s' in this property"),
|
|
|
|
NM_SETTING_WIRELESS_MODE_ADHOC, "none");
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
|
2008-10-20 21:39:56 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-11-20 20:17:01 +00:00
|
|
|
} else if (!_nm_utils_string_slist_validate (priv->pairwise, valid_pairwise)) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is invalid"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
|
2008-10-20 21:39:56 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2007-11-19 18:13:48 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 20:17:01 +00:00
|
|
|
if (priv->group && !_nm_utils_string_slist_validate (priv->group, valid_groups)) {
|
2013-02-07 13:49:53 +00:00
|
|
|
g_set_error_literal (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
|
|
|
_("property is invalid"));
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_GROUP);
|
2007-11-19 18:13:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-17 19:37:23 +00:00
|
|
|
/* Shared Key auth can only be used with WEP */
|
2008-10-30 14:45:55 +00:00
|
|
|
if (priv->auth_alg && !strcmp (priv->auth_alg, "shared")) {
|
|
|
|
if (priv->key_mgmt && strcmp (priv->key_mgmt, "none")) {
|
2008-06-12 23:58:08 +00:00
|
|
|
g_set_error (error,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
|
|
|
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP,
|
2013-02-07 13:49:53 +00:00
|
|
|
_("'%s' can only be used with '%s=%s' (WEP)"),
|
|
|
|
"shared", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none");
|
|
|
|
g_prefix_error (error, "%s: ", NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
|
2007-11-19 18:13:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-02-01 01:57:48 +00:00
|
|
|
static gboolean
|
|
|
|
get_secret_flags (NMSetting *setting,
|
|
|
|
const char *secret_name,
|
|
|
|
gboolean verify_secret,
|
|
|
|
NMSettingSecretFlags *out_flags,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
NMSettingClass *setting_class;
|
|
|
|
gboolean verify_override = verify_secret;
|
|
|
|
|
|
|
|
/* There's only one 'flags' property for WEP keys, so alias all the WEP key
|
|
|
|
* property names to that flags property.
|
|
|
|
*/
|
|
|
|
if ( !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)
|
|
|
|
|| !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)
|
|
|
|
|| !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)
|
|
|
|
|| !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)) {
|
|
|
|
secret_name = "wep-key";
|
|
|
|
verify_override = FALSE; /* Already know it's a secret */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Chain up to superclass with modified key name */
|
|
|
|
setting_class = NM_SETTING_CLASS (nm_setting_wireless_security_parent_class);
|
|
|
|
return setting_class->get_secret_flags (setting, secret_name, verify_override, out_flags, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
set_secret_flags (NMSetting *setting,
|
|
|
|
const char *secret_name,
|
|
|
|
gboolean verify_secret,
|
|
|
|
NMSettingSecretFlags flags,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
NMSettingClass *setting_class;
|
|
|
|
gboolean verify_override = verify_secret;
|
|
|
|
|
|
|
|
/* There's only one 'flags' property for WEP keys, so alias all the WEP key
|
|
|
|
* property names to that flags property.
|
|
|
|
*/
|
|
|
|
if ( !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)
|
|
|
|
|| !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)
|
|
|
|
|| !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)
|
|
|
|
|| !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)) {
|
|
|
|
secret_name = "wep-key";
|
|
|
|
verify_override = FALSE; /* Already know it's a secret */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Chain up to superclass with modified key name */
|
|
|
|
setting_class = NM_SETTING_CLASS (nm_setting_wireless_security_parent_class);
|
|
|
|
return setting_class->set_secret_flags (setting, secret_name, verify_override, flags, error);
|
|
|
|
}
|
|
|
|
|
2007-11-07 16:06:43 +00:00
|
|
|
static void
|
|
|
|
nm_setting_wireless_security_init (NMSettingWirelessSecurity *setting)
|
|
|
|
{
|
2008-10-27 17:36:18 +00:00
|
|
|
g_object_set (setting, NM_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
|
2007-11-07 16:06:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
finalize (GObject *object)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (object);
|
2008-10-30 14:45:55 +00:00
|
|
|
NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
|
2007-11-07 16:06:43 +00:00
|
|
|
|
|
|
|
/* Strings first. g_free() already checks for NULLs so we don't have to */
|
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
g_free (priv->key_mgmt);
|
|
|
|
g_free (priv->auth_alg);
|
|
|
|
g_free (priv->leap_username);
|
|
|
|
g_free (priv->wep_key0);
|
|
|
|
g_free (priv->wep_key1);
|
|
|
|
g_free (priv->wep_key2);
|
|
|
|
g_free (priv->wep_key3);
|
|
|
|
g_free (priv->psk);
|
|
|
|
g_free (priv->leap_password);
|
2007-11-07 16:06:43 +00:00
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
nm_utils_slist_free (priv->proto, g_free);
|
|
|
|
nm_utils_slist_free (priv->pairwise, g_free);
|
|
|
|
nm_utils_slist_free (priv->group, g_free);
|
2007-11-07 16:06:43 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_setting_wireless_security_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY (object);
|
2008-10-30 14:45:55 +00:00
|
|
|
NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
|
|
|
const char *str;
|
2007-11-07 16:06:43 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_KEY_MGMT:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_free (priv->key_mgmt);
|
|
|
|
str = g_value_get_string (value);
|
|
|
|
priv->key_mgmt = str ? g_ascii_strdown (str, -1) : NULL;
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_WEP_TX_KEYIDX:
|
2008-10-30 14:45:55 +00:00
|
|
|
priv->wep_tx_keyidx = g_value_get_uint (value);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_AUTH_ALG:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_free (priv->auth_alg);
|
|
|
|
str = g_value_get_string (value);
|
|
|
|
priv->auth_alg = str ? g_ascii_strdown (str, -1) : NULL;
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_PROTO:
|
2008-10-30 14:45:55 +00:00
|
|
|
nm_utils_slist_free (priv->proto, g_free);
|
|
|
|
priv->proto = g_value_dup_boxed (value);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_PAIRWISE:
|
2008-10-30 14:45:55 +00:00
|
|
|
nm_utils_slist_free (priv->pairwise, g_free);
|
|
|
|
priv->pairwise = g_value_dup_boxed (value);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_GROUP:
|
2008-10-30 14:45:55 +00:00
|
|
|
nm_utils_slist_free (priv->group, g_free);
|
|
|
|
priv->group = g_value_dup_boxed (value);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
2008-03-17 19:37:23 +00:00
|
|
|
case PROP_LEAP_USERNAME:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_free (priv->leap_username);
|
2009-03-26 06:09:37 +00:00
|
|
|
priv->leap_username = g_value_dup_string (value);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_WEP_KEY0:
|
2008-10-30 14:45:55 +00:00
|
|
|
nm_setting_wireless_security_set_wep_key (setting, 0, g_value_get_string (value));
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_WEP_KEY1:
|
2008-10-30 14:45:55 +00:00
|
|
|
nm_setting_wireless_security_set_wep_key (setting, 1, g_value_get_string (value));
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_WEP_KEY2:
|
2008-10-30 14:45:55 +00:00
|
|
|
nm_setting_wireless_security_set_wep_key (setting, 2, g_value_get_string (value));
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_WEP_KEY3:
|
2008-10-30 14:45:55 +00:00
|
|
|
nm_setting_wireless_security_set_wep_key (setting, 3, g_value_get_string (value));
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
2011-01-29 19:34:24 +00:00
|
|
|
case PROP_WEP_KEY_FLAGS:
|
|
|
|
priv->wep_key_flags = g_value_get_uint (value);
|
|
|
|
break;
|
2007-11-07 16:06:43 +00:00
|
|
|
case PROP_PSK:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_free (priv->psk);
|
|
|
|
priv->psk = g_value_dup_string (value);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
2011-01-29 19:34:24 +00:00
|
|
|
case PROP_PSK_FLAGS:
|
|
|
|
priv->psk_flags = g_value_get_uint (value);
|
|
|
|
break;
|
2008-03-17 19:37:23 +00:00
|
|
|
case PROP_LEAP_PASSWORD:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_free (priv->leap_password);
|
|
|
|
priv->leap_password = g_value_dup_string (value);
|
2007-11-09 16:18:19 +00:00
|
|
|
break;
|
2011-01-29 19:34:24 +00:00
|
|
|
case PROP_LEAP_PASSWORD_FLAGS:
|
|
|
|
priv->leap_password_flags = g_value_get_uint (value);
|
|
|
|
break;
|
2009-05-10 02:34:35 +00:00
|
|
|
case PROP_WEP_KEY_TYPE:
|
|
|
|
priv->wep_key_type = g_value_get_uint (value);
|
|
|
|
break;
|
2007-11-07 16:06:43 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY (object);
|
2008-10-30 14:45:55 +00:00
|
|
|
NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
|
2007-11-07 16:06:43 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_KEY_MGMT:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_string (value, priv->key_mgmt);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_WEP_TX_KEYIDX:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_uint (value, priv->wep_tx_keyidx);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_AUTH_ALG:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_string (value, priv->auth_alg);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_PROTO:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_boxed (value, priv->proto);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_PAIRWISE:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_boxed (value, priv->pairwise);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_GROUP:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_boxed (value, priv->group);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
2008-03-17 19:37:23 +00:00
|
|
|
case PROP_LEAP_USERNAME:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_string (value, priv->leap_username);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_WEP_KEY0:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_string (value, priv->wep_key0);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_WEP_KEY1:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_string (value, priv->wep_key1);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_WEP_KEY2:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_string (value, priv->wep_key2);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
|
|
|
case PROP_WEP_KEY3:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_string (value, priv->wep_key3);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
2011-01-29 19:34:24 +00:00
|
|
|
case PROP_WEP_KEY_FLAGS:
|
|
|
|
g_value_set_uint (value, priv->wep_key_flags);
|
|
|
|
break;
|
2007-11-07 16:06:43 +00:00
|
|
|
case PROP_PSK:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_string (value, priv->psk);
|
2007-11-07 16:06:43 +00:00
|
|
|
break;
|
2011-01-29 19:34:24 +00:00
|
|
|
case PROP_PSK_FLAGS:
|
|
|
|
g_value_set_uint (value, priv->psk_flags);
|
|
|
|
break;
|
2008-03-17 19:37:23 +00:00
|
|
|
case PROP_LEAP_PASSWORD:
|
2008-10-30 14:45:55 +00:00
|
|
|
g_value_set_string (value, priv->leap_password);
|
2007-11-09 16:18:19 +00:00
|
|
|
break;
|
2011-01-29 19:34:24 +00:00
|
|
|
case PROP_LEAP_PASSWORD_FLAGS:
|
|
|
|
g_value_set_uint (value, priv->leap_password_flags);
|
|
|
|
break;
|
2009-05-10 02:34:35 +00:00
|
|
|
case PROP_WEP_KEY_TYPE:
|
|
|
|
g_value_set_uint (value, priv->wep_key_type);
|
|
|
|
break;
|
2007-11-07 16:06:43 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting_class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
|
|
|
|
NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
|
|
|
|
|
2008-10-30 14:45:55 +00:00
|
|
|
g_type_class_add_private (setting_class, sizeof (NMSettingWirelessSecurityPrivate));
|
|
|
|
|
2007-11-07 16:06:43 +00:00
|
|
|
/* virtual methods */
|
|
|
|
object_class->set_property = set_property;
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
object_class->finalize = finalize;
|
|
|
|
|
2011-02-01 01:57:48 +00:00
|
|
|
parent_class->verify = verify;
|
|
|
|
parent_class->need_secrets = need_secrets;
|
|
|
|
parent_class->get_secret_flags = get_secret_flags;
|
|
|
|
parent_class->set_secret_flags = set_secret_flags;
|
2007-11-07 16:06:43 +00:00
|
|
|
|
|
|
|
/* Properties */
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:key-mgmt:
|
|
|
|
*
|
|
|
|
* Key management used for the connection. One of 'none' (WEP), 'ieee8021x'
|
|
|
|
* (Dynamic WEP), 'wpa-none' (Ad-Hoc WPA-PSK), 'wpa-psk' (infrastructure
|
|
|
|
* WPA-PSK), or 'wpa-eap' (WPA-Enterprise). This property must be set for
|
|
|
|
* any WiFi connection that uses security.
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_KEY_MGMT,
|
|
|
|
g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_KEY_MGMT,
|
|
|
|
"Key management",
|
2009-11-11 22:08:15 +00:00
|
|
|
"Key management used for the connection. One of "
|
|
|
|
"'none' (WEP), 'ieee8021x' (Dynamic WEP), 'wpa-none' "
|
|
|
|
"(WPA-PSK Ad-Hoc), 'wpa-psk' (infrastructure WPA-PSK), "
|
|
|
|
"or 'wpa-eap' (WPA-Enterprise). This property must "
|
|
|
|
"be set for any WiFi connection that uses security.",
|
2007-11-07 16:06:43 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_REQUIRED));
|
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:wep-tx-keyidx:
|
|
|
|
*
|
|
|
|
* When static WEP is used (ie, key-mgmt = 'none') and a non-default WEP key
|
|
|
|
* index is used by the AP, put that WEP key index here. Valid values are 0
|
|
|
|
* (default key) through 3. Note that some consumer access points (like the
|
|
|
|
* Linksys WRT54G) number the keys 1 - 4.
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_WEP_TX_KEYIDX,
|
|
|
|
g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX,
|
|
|
|
"WEP TX key index",
|
2009-11-11 22:08:15 +00:00
|
|
|
"When static WEP is used (ie, key-mgmt = 'none') and a "
|
|
|
|
"non-default WEP key index is used by the AP, put that "
|
|
|
|
"WEP key index here. Valid values are 0 (default key) "
|
|
|
|
"through 3. Note that some consumer access points "
|
|
|
|
"(like the Linksys WRT54G) number the keys 1 - 4.",
|
2007-11-07 16:06:43 +00:00
|
|
|
0, 3, 0,
|
2009-02-02 01:18:21 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
2007-11-07 16:06:43 +00:00
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:auth-alg:
|
|
|
|
*
|
|
|
|
* When WEP is used (ie, key-mgmt = 'none' or 'ieee8021x') indicate the
|
|
|
|
* 802.11 authentication algorithm required by the AP here. One of 'open'
|
|
|
|
* for Open System, 'shared' for Shared Key, or 'leap' for Cisco LEAP.
|
|
|
|
* When using Cisco LEAP (ie, key-mgmt = 'ieee8021x' and auth-alg = 'leap')
|
|
|
|
* the 'leap-username' and 'leap-password' properties must be specified.
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_AUTH_ALG,
|
|
|
|
g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_AUTH_ALG,
|
|
|
|
"AuthAlg",
|
2009-11-11 22:08:15 +00:00
|
|
|
"When WEP is used (ie, key-mgmt = 'none' or "
|
|
|
|
"'ieee8021x') indicate the 802.11 authentication "
|
|
|
|
"algorithm required by the AP here. One of 'open' for "
|
|
|
|
"Open System, 'shared' for Shared Key, or 'leap' for "
|
|
|
|
"Cisco LEAP. When using Cisco LEAP (ie, key-mgmt = "
|
|
|
|
"'ieee8021x' and auth-alg = 'leap') the 'leap-username' "
|
|
|
|
"and 'leap-password' properties must be specified.",
|
2007-11-07 16:06:43 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:proto:
|
|
|
|
*
|
|
|
|
* List of strings specifying the allowed WPA protocol versions to use.
|
|
|
|
* Each element may be one 'wpa' (allow WPA) or 'rsn' (allow WPA2/RSN). If
|
|
|
|
* not specified, both WPA and RSN connections are allowed.
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_PROTO,
|
2008-08-26 09:34:31 +00:00
|
|
|
_nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_PROTO,
|
2007-11-07 16:06:43 +00:00
|
|
|
"Proto",
|
2009-11-11 22:08:15 +00:00
|
|
|
"List of strings specifying the allowed WPA "
|
|
|
|
"protocol versions to use. Each element may be "
|
|
|
|
"one 'wpa' (allow WPA) or 'rsn' (allow "
|
|
|
|
"WPA2/RSN). If not specified, both WPA and RSN "
|
|
|
|
"connections are allowed.",
|
2008-03-29 21:35:41 +00:00
|
|
|
DBUS_TYPE_G_LIST_OF_STRING,
|
2007-11-07 16:06:43 +00:00
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:pairwise:
|
|
|
|
*
|
2013-04-29 20:31:43 +00:00
|
|
|
* A list of pairwise encryption algorithms which prevents connections to
|
|
|
|
* Wi-Fi networks that do not utilize one of the algorithms in the list. For
|
|
|
|
* maximum compatibility leave this property empty. Each list element may
|
2013-04-30 17:39:19 +00:00
|
|
|
* be one of 'tkip' or 'ccmp'.
|
2009-11-11 22:08:15 +00:00
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_PAIRWISE,
|
2008-08-26 09:34:31 +00:00
|
|
|
_nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_PAIRWISE,
|
2013-04-29 20:31:43 +00:00
|
|
|
"Pairwise",
|
|
|
|
"A list of pairwise encryption algorithms which "
|
|
|
|
"prevents connections to Wi-Fi networks that do "
|
|
|
|
"not utilize one of the algorithms in the list. "
|
|
|
|
"For maximum compatibility leave this property "
|
2013-04-30 17:39:19 +00:00
|
|
|
"empty. Each list element may be one of 'tkip' "
|
|
|
|
"or 'ccmp'.",
|
2013-04-29 20:31:43 +00:00
|
|
|
DBUS_TYPE_G_LIST_OF_STRING,
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
2007-11-07 16:06:43 +00:00
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:group:
|
|
|
|
*
|
2013-04-29 20:31:43 +00:00
|
|
|
* A list of group/broadcast encryption algorithms which prevents
|
|
|
|
* connections to Wi-Fi networks that do not utilize one of the algorithms
|
|
|
|
* in the list. For maximum compatibility leave this property empty. Each
|
|
|
|
* list element may be one of 'wep40', 'wep104', 'tkip', or 'ccmp'.
|
2009-11-11 22:08:15 +00:00
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_GROUP,
|
2008-08-26 09:34:31 +00:00
|
|
|
_nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_GROUP,
|
2013-04-29 20:31:43 +00:00
|
|
|
"Group",
|
|
|
|
"A list of group/broadcast encryption algorithms "
|
|
|
|
"which prevents connections to Wi-Fi networks "
|
|
|
|
"that do not utilize one of the algorithms in "
|
|
|
|
"the list. For maximum compatibility leave this "
|
|
|
|
"property empty. Each list element may be one "
|
|
|
|
" of 'wep40', 'wep104', 'tkip', or 'ccmp'.",
|
|
|
|
DBUS_TYPE_G_LIST_OF_STRING,
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
2007-11-07 16:06:43 +00:00
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:leap-username:
|
|
|
|
*
|
|
|
|
* The login username for legacy LEAP connections (ie, key-mgmt =
|
|
|
|
* 'ieee8021x' and auth-alg = 'leap').
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
2008-03-17 19:37:23 +00:00
|
|
|
(object_class, PROP_LEAP_USERNAME,
|
|
|
|
g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME,
|
|
|
|
"LEAP Username",
|
2009-11-11 22:08:15 +00:00
|
|
|
"The login username for legacy LEAP connections "
|
|
|
|
"(ie, key-mgmt = 'ieee8021x' and auth-alg = 'leap').",
|
2007-11-07 16:06:43 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:wep-key0:
|
|
|
|
*
|
|
|
|
* Index 0 WEP key. This is the WEP key used in most networks. See the
|
|
|
|
* 'wep-key-type' property for a description of how this key is interpreted.
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_WEP_KEY0,
|
|
|
|
g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0,
|
|
|
|
"WEP key0",
|
2009-11-11 22:08:15 +00:00
|
|
|
"Index 0 WEP key. This is the WEP key used in most "
|
|
|
|
"networks. See the 'wep-key-type' property for a "
|
|
|
|
"description of how this key is interpreted.",
|
2007-11-07 16:06:43 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
|
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:wep-key1:
|
|
|
|
*
|
|
|
|
* Index 1 WEP key. This WEP index is not used by most networks. See the
|
|
|
|
* 'wep-key-type' property for a description of how this key is interpreted.
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_WEP_KEY1,
|
|
|
|
g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY1,
|
|
|
|
"WEP key1",
|
2009-11-11 22:08:15 +00:00
|
|
|
"Index 1 WEP key. This WEP index is not used by most "
|
|
|
|
"networks. See the 'wep-key-type' property for a "
|
|
|
|
"description of how this key is interpreted.",
|
2007-11-07 16:06:43 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
|
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:wep-key2:
|
|
|
|
*
|
|
|
|
* Index 2 WEP key. This WEP index is not used by most networks. See the
|
|
|
|
* 'wep-key-type' property for a description of how this key is interpreted.
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_WEP_KEY2,
|
|
|
|
g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY2,
|
|
|
|
"WEP key2",
|
2009-11-11 22:08:15 +00:00
|
|
|
"Index 2 WEP key. This WEP index is not used by most "
|
|
|
|
"networks. See the 'wep-key-type' property for a "
|
|
|
|
"description of how this key is interpreted.",
|
2007-11-07 16:06:43 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
|
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:wep-key3:
|
|
|
|
*
|
|
|
|
* Index 3 WEP key. This WEP index is not used by most networks. See the
|
|
|
|
* 'wep-key-type' property for a description of how this key is interpreted.
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_WEP_KEY3,
|
|
|
|
g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY3,
|
|
|
|
"WEP key3",
|
2009-11-11 22:08:15 +00:00
|
|
|
"Index 3 WEP key. This WEP index is not used by most "
|
|
|
|
"networks. See the 'wep-key-type' property for a "
|
|
|
|
"description of how this key is interpreted.",
|
2007-11-07 16:06:43 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
|
|
|
|
|
2011-01-29 19:34:24 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:wep-key-flags:
|
|
|
|
*
|
|
|
|
* Flags indicating how to handle #NMSettingWirelessSecurity WEP keys.
|
|
|
|
**/
|
|
|
|
g_object_class_install_property (object_class, PROP_WEP_KEY_FLAGS,
|
|
|
|
g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS,
|
|
|
|
"WEP Key Flags",
|
|
|
|
"Flags indicating how to handle the WEP keys.",
|
2011-02-07 05:37:39 +00:00
|
|
|
NM_SETTING_SECRET_FLAG_NONE,
|
2011-01-31 18:36:53 +00:00
|
|
|
NM_SETTING_SECRET_FLAGS_ALL,
|
2011-02-07 05:37:39 +00:00
|
|
|
NM_SETTING_SECRET_FLAG_NONE,
|
2011-01-29 19:34:24 +00:00
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:psk:
|
|
|
|
*
|
|
|
|
* Pre-Shared-Key for WPA networks. If the key is 64-characters long, it
|
|
|
|
* must contain only hexadecimal characters and is interpreted as a
|
|
|
|
* hexadecimal WPA key. Otherwise, the key must be between 8 and 63 ASCII
|
|
|
|
* characters (as specified in the 802.11i standard) and is interpreted as
|
|
|
|
* a WPA passphrase, and is hashed to derive the actual WPA-PSK used when
|
|
|
|
* connecting to the WiFi network.
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_PSK,
|
|
|
|
g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_PSK,
|
|
|
|
"PSK",
|
2009-11-11 22:08:15 +00:00
|
|
|
"Pre-Shared-Key for WPA networks. If the key is "
|
|
|
|
"64-characters long, it must contain only hexadecimal "
|
|
|
|
"characters and is interpreted as a hexadecimal WPA "
|
|
|
|
"key. Otherwise, the key must be between 8 and 63 "
|
|
|
|
"ASCII characters (as specified in the 802.11i standard) "
|
|
|
|
"and is interpreted as a WPA passphrase, and is hashed "
|
|
|
|
"to derive the actual WPA-PSK used when connecting to "
|
|
|
|
"the WiFi network.",
|
2007-11-07 16:06:43 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
|
|
|
|
|
2011-01-29 19:34:24 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:psk-flags:
|
|
|
|
*
|
|
|
|
* Flags indicating how to handle #NMSettingWirelessSecurity:psk
|
|
|
|
**/
|
|
|
|
g_object_class_install_property (object_class, PROP_PSK_FLAGS,
|
|
|
|
g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS,
|
|
|
|
"PSK Flags",
|
|
|
|
"Flags indicating how to handle the WPA PSK key.",
|
2011-02-07 05:37:39 +00:00
|
|
|
NM_SETTING_SECRET_FLAG_NONE,
|
2011-01-31 18:36:53 +00:00
|
|
|
NM_SETTING_SECRET_FLAGS_ALL,
|
2011-02-07 05:37:39 +00:00
|
|
|
NM_SETTING_SECRET_FLAG_NONE,
|
2011-01-29 19:34:24 +00:00
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:leap-password:
|
|
|
|
*
|
|
|
|
* The login password for legacy LEAP connections (ie, key-mgmt =
|
|
|
|
* 'ieee8021x' and auth-alg = 'leap').
|
|
|
|
**/
|
2007-11-07 16:06:43 +00:00
|
|
|
g_object_class_install_property
|
2008-03-17 19:37:23 +00:00
|
|
|
(object_class, PROP_LEAP_PASSWORD,
|
|
|
|
g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD,
|
|
|
|
"LEAP Password",
|
2009-11-11 22:08:15 +00:00
|
|
|
"The login password for legacy LEAP connections "
|
|
|
|
"(ie, key-mgmt = 'ieee8021x' and auth-alg = 'leap').",
|
2007-11-07 16:06:43 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
|
2009-05-10 02:34:35 +00:00
|
|
|
|
2011-01-29 19:34:24 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:leap-password-flags:
|
|
|
|
*
|
|
|
|
* Flags indicating how to handle #NMSettingWirelessSecurity:leap-password.
|
|
|
|
**/
|
|
|
|
g_object_class_install_property (object_class, PROP_LEAP_PASSWORD_FLAGS,
|
|
|
|
g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS,
|
|
|
|
"LEAP Password Flags",
|
|
|
|
"Flags indicating how to handle the LEAP password.",
|
2011-02-07 05:37:39 +00:00
|
|
|
NM_SETTING_SECRET_FLAG_NONE,
|
2011-01-31 18:36:53 +00:00
|
|
|
NM_SETTING_SECRET_FLAGS_ALL,
|
2011-02-07 05:37:39 +00:00
|
|
|
NM_SETTING_SECRET_FLAG_NONE,
|
2011-01-29 19:34:24 +00:00
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
|
|
|
|
2009-11-11 22:08:15 +00:00
|
|
|
/**
|
|
|
|
* NMSettingWirelessSecurity:wep-key-type:
|
|
|
|
*
|
2011-07-05 23:09:14 +00:00
|
|
|
* Controls the interpretation of WEP keys. Allowed values are those given
|
|
|
|
* by %NMWepKeyType. If set to 1 and the keys are hexadecimal, they must be
|
2009-11-11 22:08:15 +00:00
|
|
|
* either 10 or 26 characters in length. If set to 1 and the keys are
|
|
|
|
* ASCII keys, they must be either 5 or 13 characters in length. If set to
|
|
|
|
* 2, the passphrase is hashed using the de-facto MD5 method to derive the
|
|
|
|
* actual WEP key.
|
|
|
|
**/
|
2009-05-10 02:34:35 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(object_class, PROP_WEP_KEY_TYPE,
|
|
|
|
g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE,
|
|
|
|
"WEP Key Type",
|
2009-11-11 22:08:15 +00:00
|
|
|
"Controls the interpretation of WEP keys. Allowed values "
|
|
|
|
"are 1 (interpret WEP keys as hexadecimal or ASCII keys) "
|
|
|
|
"or 2 (interpret WEP keys as WEP Passphrases). If set to "
|
|
|
|
"1 and the keys are hexadecimal, they must be either 10 or "
|
|
|
|
"26 characters in length. If set to 1 and the keys are "
|
|
|
|
"ASCII keys, they must be either 5 or 13 characters in "
|
|
|
|
"length. If set to 2, the passphrase is hashed using "
|
|
|
|
" the de-facto MD5 method to derive the actual WEP key.",
|
2009-05-10 02:34:35 +00:00
|
|
|
NM_WEP_KEY_TYPE_UNKNOWN,
|
|
|
|
NM_WEP_KEY_TYPE_LAST,
|
|
|
|
NM_WEP_KEY_TYPE_UNKNOWN,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
2007-11-07 16:06:43 +00:00
|
|
|
}
|