1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA.
19 * Copyright 2007 - 2014 Red Hat, Inc.
20 * Copyright 2007 - 2008 Novell, Inc.
23 #include "nm-default.h"
26 #include <dbus/dbus-glib.h>
28 #include "nm-setting-wireless-security.h"
29 #include "nm-setting-8021x.h"
30 #include "nm-param-spec-specialized.h"
32 #include "nm-dbus-glib-types.h"
33 #include "nm-utils-private.h"
34 #include "nm-setting-private.h"
37 * SECTION:nm-setting-wireless-security
38 * @short_description: Describes connection properties for Wi-Fi networks that
39 * use WEP, LEAP, WPA or WPA2/RSN security
40 * @include: nm-setting-wireless-security.h
42 * The #NMSettingWirelessSecurity object is a #NMSetting subclass that describes
43 * properties necessary for connection to encrypted Wi-Fi networks.
45 * It's a good idea to read up on wpa_supplicant configuration before using this
46 * setting extensively, since most of the options here correspond closely with
47 * the relevant wpa_supplicant configuration options. To get a better overview
48 * of how Wi-Fi security works, you may want to get copies of the following books.
50 * 802.11 Wireless Networks: The Definitive Guide, Second Edition
51 * Author: Matthew Gast
52 * ISBN: 978-0596100520
54 * Cisco Wireless LAN Security
55 * Authors: Krishna Sankar, Sri Sundaralingam, Darrin Miller, and Andrew Balinsky
56 * ISBN: 978-1587051548
60 * nm_setting_wireless_security_error_quark:
62 * Registers an error quark for #NMSettingWired if necessary.
64 * Returns: the error quark used for #NMSettingWired errors.
67 nm_setting_wireless_security_error_quark (void)
71 if (G_UNLIKELY (!quark))
72 quark = g_quark_from_static_string ("nm-setting-wireless-security-error-quark");
77 G_DEFINE_TYPE_WITH_CODE (NMSettingWirelessSecurity, nm_setting_wireless_security, NM_TYPE_SETTING,
78 _nm_register_setting (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
81 NM_SETTING_WIRELESS_SECURITY_ERROR))
82 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS_SECURITY)
84 #define NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS_SECURITY, NMSettingWirelessSecurityPrivate))
89 GSList *proto; /* GSList of strings */
90 GSList *pairwise; /* GSList of strings */
91 GSList *group; /* GSList of strings */
96 NMSettingSecretFlags leap_password_flags;
103 NMSettingSecretFlags wep_key_flags;
104 NMWepKeyType wep_key_type;
105 guint32 wep_tx_keyidx;
109 NMSettingSecretFlags psk_flags;
110 } NMSettingWirelessSecurityPrivate;
130 PROP_LEAP_PASSWORD_FLAGS,
136 * nm_setting_wireless_security_new:
138 * Creates a new #NMSettingWirelessSecurity object with default values.
140 * Returns: (transfer full): the new empty #NMSettingWirelessSecurity object
143 nm_setting_wireless_security_new (void)
145 return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIRELESS_SECURITY, NULL);
149 * nm_setting_wireless_security_get_key_mgmt:
150 * @setting: the #NMSettingWirelessSecurity
152 * Returns: the #NMSettingWirelessSecurity:key-mgmt property of the setting
155 nm_setting_wireless_security_get_key_mgmt (NMSettingWirelessSecurity *setting)
157 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
159 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->key_mgmt;
163 * nm_setting_wireless_security_get_num_protos:
164 * @setting: the #NMSettingWirelessSecurity
166 * Returns: the number of security protocols this connection allows when
167 * connecting to secure Wi-Fi networks
170 nm_setting_wireless_security_get_num_protos (NMSettingWirelessSecurity *setting)
172 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
174 return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->proto);
178 * nm_setting_wireless_security_get_proto:
179 * @setting: the #NMSettingWirelessSecurity
180 * @i: an index into the protocol list
182 * Returns: the protocol at index @i
185 nm_setting_wireless_security_get_proto (NMSettingWirelessSecurity *setting, guint32 i)
187 NMSettingWirelessSecurityPrivate *priv;
189 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
191 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
192 g_return_val_if_fail (i <= g_slist_length (priv->proto), NULL);
194 return (const char *) g_slist_nth_data (priv->proto, i);
198 * nm_setting_wireless_security_add_proto:
199 * @setting: the #NMSettingWirelessSecurity
200 * @proto: the protocol to add, one of "wpa" or "rsn"
202 * Adds a Wi-Fi security protocol (one of "wpa" or "rsn") to the allowed list;
203 * only protocols in this list will be used when finding and connecting to
204 * the Wi-Fi network specified by this connection. For example, if the
205 * protocol list contains only "wpa" but the access point for the SSID specified
206 * by this connection only supports WPA2/RSN, the connection cannot be used
207 * with the access point.
209 * Returns: %TRUE if the protocol was new and and was added to the allowed
210 * protocol list, or %FALSE if it was already in the list
213 nm_setting_wireless_security_add_proto (NMSettingWirelessSecurity *setting, const char *proto)
215 NMSettingWirelessSecurityPrivate *priv;
218 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
219 g_return_val_if_fail (proto != NULL, FALSE);
221 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
222 for (iter = priv->proto; iter; iter = g_slist_next (iter)) {
223 if (strcasecmp (proto, (char *) iter->data) == 0)
227 priv->proto = g_slist_append (priv->proto, g_ascii_strdown (proto, -1));
228 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
233 * nm_setting_wireless_security_remove_proto:
234 * @setting: the #NMSettingWirelessSecurity
235 * @i: index of the protocol to remove
237 * Removes a protocol from the allowed protocol list.
240 nm_setting_wireless_security_remove_proto (NMSettingWirelessSecurity *setting, guint32 i)
242 NMSettingWirelessSecurityPrivate *priv;
245 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
247 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
248 elt = g_slist_nth (priv->proto, i);
249 g_return_if_fail (elt != NULL);
252 priv->proto = g_slist_delete_link (priv->proto, elt);
253 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
257 * nm_setting_wireless_security_remove_proto_by_value:
258 * @setting: the #NMSettingWirelessSecurity
259 * @proto: the protocol to remove, one of "wpa" or "rsn"
261 * Removes a protocol from the allowed protocol list.
263 * Returns: %TRUE if the protocol was found and removed; %FALSE it it was not.
268 nm_setting_wireless_security_remove_proto_by_value (NMSettingWirelessSecurity *setting,
271 NMSettingWirelessSecurityPrivate *priv;
274 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
275 g_return_val_if_fail (proto != NULL, FALSE);
277 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
278 for (iter = priv->proto; iter; iter = g_slist_next (iter)) {
279 if (strcasecmp (proto, (char *) iter->data) == 0) {
280 priv->proto = g_slist_delete_link (priv->proto, iter);
281 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
289 * nm_setting_wireless_security_clear_protos:
290 * @setting: the #NMSettingWirelessSecurity
292 * Removes all protocols from the allowed list. If there are no protocols
293 * specified then all protocols are allowed.
296 nm_setting_wireless_security_clear_protos (NMSettingWirelessSecurity *setting)
298 NMSettingWirelessSecurityPrivate *priv;
300 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
302 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
303 g_slist_free_full (priv->proto, g_free);
305 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
309 * nm_setting_wireless_security_get_num_pairwise:
310 * @setting: the #NMSettingWirelessSecurity
312 * Returns: the number of pairwise encryption algorithms in the allowed list
315 nm_setting_wireless_security_get_num_pairwise (NMSettingWirelessSecurity *setting)
317 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
319 return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->pairwise);
323 * nm_setting_wireless_security_get_pairwise:
324 * @setting: the #NMSettingWirelessSecurity
325 * @i: index of an item in the allowed pairwise encryption algorithm list
327 * Returns the allowed pairwise encryption algorithm from allowed algorithm
330 * Returns: the pairwise encryption algorithm at index @i
333 nm_setting_wireless_security_get_pairwise (NMSettingWirelessSecurity *setting, guint32 i)
335 NMSettingWirelessSecurityPrivate *priv;
337 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
339 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
340 g_return_val_if_fail (i <= g_slist_length (priv->pairwise), NULL);
342 return (const char *) g_slist_nth_data (priv->pairwise, i);
346 * nm_setting_wireless_security_add_pairwise:
347 * @setting: the #NMSettingWirelessSecurity
348 * @pairwise: the encryption algorithm to add, one of "tkip" or "ccmp"
350 * Adds an encryption algorithm to the list of allowed pairwise encryption
351 * algorithms. If the list is not empty, then only access points that support
352 * one or more of the encryption algorithms in the list will be considered
353 * compatible with this connection.
355 * Returns: %TRUE if the algorithm was added to the list, %FALSE if it was
356 * already in the list
359 nm_setting_wireless_security_add_pairwise (NMSettingWirelessSecurity *setting, const char *pairwise)
361 NMSettingWirelessSecurityPrivate *priv;
364 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
365 g_return_val_if_fail (pairwise != NULL, FALSE);
367 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
368 for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) {
369 if (strcasecmp (pairwise, (char *) iter->data) == 0)
373 priv->pairwise = g_slist_append (priv->pairwise, g_ascii_strdown (pairwise, -1));
374 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
379 * nm_setting_wireless_security_remove_pairwise:
380 * @setting: the #NMSettingWirelessSecurity
381 * @i: the index of an item in the allowed pairwise encryption algorithm list
383 * Removes an encryption algorithm from the allowed pairwise encryption
387 nm_setting_wireless_security_remove_pairwise (NMSettingWirelessSecurity *setting, guint32 i)
389 NMSettingWirelessSecurityPrivate *priv;
392 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
394 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
395 elt = g_slist_nth (priv->pairwise, i);
396 g_return_if_fail (elt != NULL);
399 priv->pairwise = g_slist_delete_link (priv->pairwise, elt);
400 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
404 * nm_setting_wireless_security_remove_pairwise_by_value:
405 * @setting: the #NMSettingWirelessSecurity
406 * @pairwise: the encryption algorithm to remove, one of "tkip" or "ccmp"
408 * Removes an encryption algorithm from the allowed pairwise encryption
411 * Returns: %TRUE if the encryption algorith was found and removed; %FALSE it it was not.
416 nm_setting_wireless_security_remove_pairwise_by_value (NMSettingWirelessSecurity *setting,
417 const char *pairwise)
419 NMSettingWirelessSecurityPrivate *priv;
422 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
423 g_return_val_if_fail (pairwise != NULL, FALSE);
425 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
426 for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) {
427 if (strcasecmp (pairwise, (char *) iter->data) == 0) {
428 priv->pairwise = g_slist_delete_link (priv->pairwise, iter);
429 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
437 * nm_setting_wireless_security_clear_pairwise:
438 * @setting: the #NMSettingWirelessSecurity
440 * Removes all algorithms from the allowed list. If there are no algorithms
441 * specified then all pairwise encryption algorithms are allowed.
444 nm_setting_wireless_security_clear_pairwise (NMSettingWirelessSecurity *setting)
446 NMSettingWirelessSecurityPrivate *priv;
448 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
450 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
451 g_slist_free_full (priv->pairwise, g_free);
452 priv->pairwise = NULL;
453 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
457 * nm_setting_wireless_security_get_num_groups:
458 * @setting: the #NMSettingWirelessSecurity
460 * Returns: the number of groupwise encryption algorithms in the allowed list
463 nm_setting_wireless_security_get_num_groups (NMSettingWirelessSecurity *setting)
465 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
467 return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->group);
471 * nm_setting_wireless_security_get_group:
472 * @setting: the #NMSettingWirelessSecurity
473 * @i: index of an item in the allowed groupwise encryption algorithm list
475 * Returns the allowed groupwise encryption algorithm from allowed algorithm
478 * Returns: the groupwise encryption algorithm at index @i
481 nm_setting_wireless_security_get_group (NMSettingWirelessSecurity *setting, guint32 i)
483 NMSettingWirelessSecurityPrivate *priv;
485 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
487 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
488 g_return_val_if_fail (i <= g_slist_length (priv->group), NULL);
490 return (const char *) g_slist_nth_data (priv->group, i);
494 * nm_setting_wireless_security_add_group:
495 * @setting: the #NMSettingWirelessSecurity
496 * @group: the encryption algorithm to add, one of "wep40", "wep104",
499 * Adds an encryption algorithm to the list of allowed groupwise encryption
500 * algorithms. If the list is not empty, then only access points that support
501 * one or more of the encryption algorithms in the list will be considered
502 * compatible with this connection.
504 * Returns: %TRUE if the algorithm was added to the list, %FALSE if it was
505 * already in the list
508 nm_setting_wireless_security_add_group (NMSettingWirelessSecurity *setting, const char *group)
510 NMSettingWirelessSecurityPrivate *priv;
513 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
514 g_return_val_if_fail (group != NULL, FALSE);
516 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
517 for (iter = priv->group; iter; iter = g_slist_next (iter)) {
518 if (strcasecmp (group, (char *) iter->data) == 0)
522 priv->group = g_slist_append (priv->group, g_ascii_strdown (group, -1));
523 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
528 * nm_setting_wireless_security_remove_group:
529 * @setting: the #NMSettingWirelessSecurity
530 * @i: the index of an item in the allowed groupwise encryption algorithm list
532 * Removes an encryption algorithm from the allowed groupwise encryption
536 nm_setting_wireless_security_remove_group (NMSettingWirelessSecurity *setting, guint32 i)
538 NMSettingWirelessSecurityPrivate *priv;
541 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
543 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
544 elt = g_slist_nth (priv->group, i);
545 g_return_if_fail (elt != NULL);
548 priv->group = g_slist_delete_link (priv->group, elt);
549 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
553 * nm_setting_wireless_security_remove_group_by_value:
554 * @setting: the #NMSettingWirelessSecurity
555 * @group: the encryption algorithm to remove, one of "wep40", "wep104",
558 * Removes an encryption algorithm from the allowed groupwise encryption
561 * Returns: %TRUE if the algorithm was found and removed; %FALSE it it was not.
566 nm_setting_wireless_security_remove_group_by_value (NMSettingWirelessSecurity *setting,
569 NMSettingWirelessSecurityPrivate *priv;
572 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
573 g_return_val_if_fail (group != NULL, FALSE);
575 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
576 for (iter = priv->group; iter; iter = g_slist_next (iter)) {
577 if (strcasecmp (group, (char *) iter->data) == 0) {
578 priv->group = g_slist_delete_link (priv->group, iter);
579 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
587 * nm_setting_wireless_security_clear_groups:
588 * @setting: the #NMSettingWirelessSecurity
590 * Removes all algorithms from the allowed list. If there are no algorithms
591 * specified then all groupwise encryption algorithms are allowed.
594 nm_setting_wireless_security_clear_groups (NMSettingWirelessSecurity *setting)
596 NMSettingWirelessSecurityPrivate *priv;
598 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
600 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
601 g_slist_free_full (priv->group, g_free);
603 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
607 * nm_setting_wireless_security_get_psk:
608 * @setting: the #NMSettingWirelessSecurity
610 * Returns: the #NMSettingWirelessSecurity:psk property of the setting
613 nm_setting_wireless_security_get_psk (NMSettingWirelessSecurity *setting)
615 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
617 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->psk;
621 * nm_setting_wireless_security_get_psk_flags:
622 * @setting: the #NMSettingWirelessSecurity
624 * Returns: the #NMSettingSecretFlags pertaining to the
625 * #NMSettingWirelessSecurity:psk
628 nm_setting_wireless_security_get_psk_flags (NMSettingWirelessSecurity *setting)
630 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
632 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->psk_flags;
636 * nm_setting_wireless_security_get_leap_username:
637 * @setting: the #NMSettingWirelessSecurity
639 * Returns: the #NMSettingWirelessSecurity:leap-username property of the setting
642 nm_setting_wireless_security_get_leap_username (NMSettingWirelessSecurity *setting)
644 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
646 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_username;
650 * nm_setting_wireless_security_get_leap_password:
651 * @setting: the #NMSettingWirelessSecurity
653 * Returns: the #NMSettingWirelessSecurity:leap-password property of the setting
656 nm_setting_wireless_security_get_leap_password (NMSettingWirelessSecurity *setting)
658 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
660 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_password;
664 * nm_setting_wireless_security_get_leap_password_flags:
665 * @setting: the #NMSettingWirelessSecurity
667 * Returns: the #NMSettingSecretFlags pertaining to the
668 * #NMSettingWirelessSecurity:leap-password
671 nm_setting_wireless_security_get_leap_password_flags (NMSettingWirelessSecurity *setting)
673 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
675 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_password_flags;
679 * nm_setting_wireless_security_get_wep_key:
680 * @setting: the #NMSettingWirelessSecurity
681 * @idx: the WEP key index (0..3 inclusive)
683 * Returns: the WEP key at the given index
686 nm_setting_wireless_security_get_wep_key (NMSettingWirelessSecurity *setting, guint32 idx)
688 NMSettingWirelessSecurityPrivate *priv;
690 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
691 g_return_val_if_fail (idx < 4, NULL);
693 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
695 return priv->wep_key0;
697 return priv->wep_key1;
699 return priv->wep_key2;
701 return priv->wep_key3;
703 g_assert_not_reached ();
708 * nm_setting_wireless_security_set_wep_key:
709 * @setting: the #NMSettingWirelessSecurity
710 * @idx: the index of the key (0..3 inclusive)
711 * @key: the WEP key as a string, in either hexadecimal, ASCII, or passphrase
712 * form as determiend by the value of the #NMSettingWirelessSecurity:wep-key-type
715 * Sets a WEP key in the given index.
718 nm_setting_wireless_security_set_wep_key (NMSettingWirelessSecurity *setting, guint32 idx, const char *key)
720 NMSettingWirelessSecurityPrivate *priv;
722 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
723 g_return_if_fail (idx < 4);
725 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
728 g_free (priv->wep_key0);
729 priv->wep_key0 = g_strdup (key);
730 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
733 g_free (priv->wep_key1);
734 priv->wep_key1 = g_strdup (key);
735 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY1);
738 g_free (priv->wep_key2);
739 priv->wep_key2 = g_strdup (key);
740 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY2);
743 g_free (priv->wep_key3);
744 priv->wep_key3 = g_strdup (key);
745 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
748 g_assert_not_reached ();
753 * nm_setting_wireless_security_get_wep_tx_keyidx:
754 * @setting: the #NMSettingWirelessSecurity
756 * Returns: the #NMSettingWirelessSecurity:wep-tx-keyidx property of the setting
759 nm_setting_wireless_security_get_wep_tx_keyidx (NMSettingWirelessSecurity *setting)
761 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
763 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_tx_keyidx;
767 * nm_setting_wireless_security_get_auth_alg:
768 * @setting: the #NMSettingWirelessSecurity
770 * Returns: the #NMSettingWirelessSecurity:auth-alg property of the setting
773 nm_setting_wireless_security_get_auth_alg (NMSettingWirelessSecurity *setting)
775 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
777 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->auth_alg;
781 * nm_setting_wireless_security_get_wep_key_flags:
782 * @setting: the #NMSettingWirelessSecurity
784 * Returns: the #NMSettingSecretFlags pertaining to the all WEP keys
787 nm_setting_wireless_security_get_wep_key_flags (NMSettingWirelessSecurity *setting)
789 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
791 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_key_flags;
795 * nm_setting_wireless_security_get_wep_key_type:
796 * @setting: the #NMSettingWirelessSecurity
798 * Returns: the #NMSettingWirelessSecurity:wep-key-type property of the setting
801 nm_setting_wireless_security_get_wep_key_type (NMSettingWirelessSecurity *setting)
803 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
805 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_key_type;
809 need_secrets (NMSetting *setting)
811 NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting);
812 NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
815 secrets = g_ptr_array_sized_new (4);
817 g_assert (priv->key_mgmt);
820 if (strcmp (priv->key_mgmt, "none") == 0) {
821 if ((priv->wep_tx_keyidx == 0) && !nm_utils_wep_key_valid (priv->wep_key0, priv->wep_key_type)) {
822 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
825 if ((priv->wep_tx_keyidx == 1) && !nm_utils_wep_key_valid (priv->wep_key1, priv->wep_key_type)) {
826 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1);
829 if ((priv->wep_tx_keyidx == 2) && !nm_utils_wep_key_valid (priv->wep_key2, priv->wep_key_type)) {
830 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2);
833 if ((priv->wep_tx_keyidx == 3) && !nm_utils_wep_key_valid (priv->wep_key3, priv->wep_key_type)) {
834 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
840 /* WPA-PSK infrastructure and adhoc */
841 if ( (strcmp (priv->key_mgmt, "wpa-none") == 0)
842 || (strcmp (priv->key_mgmt, "wpa-psk") == 0)) {
843 if (!nm_utils_wpa_psk_valid (priv->psk)) {
844 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_PSK);
852 && !strcmp (priv->auth_alg, "leap")
853 && !strcmp (priv->key_mgmt, "ieee8021x")) {
854 if (!priv->leap_password || !*priv->leap_password) {
855 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD);
861 if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0)
862 || (strcmp (priv->key_mgmt, "wpa-eap") == 0)) {
863 /* Let caller check the 802.1x setting for secrets */
867 g_assert_not_reached ();
872 g_ptr_array_free (secrets, TRUE);
877 verify (NMSetting *setting, GSList *all_settings, GError **error)
879 NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting);
880 NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
881 const char *valid_key_mgmt[] = { "none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap", NULL };
882 const char *valid_auth_algs[] = { "open", "shared", "leap", NULL };
883 const char *valid_protos[] = { "wpa", "rsn", NULL };
884 const char *valid_pairwise[] = { "tkip", "ccmp", NULL };
885 const char *valid_groups[] = { "wep40", "wep104", "tkip", "ccmp", NULL };
887 if (!priv->key_mgmt) {
888 g_set_error_literal (error,
889 NM_SETTING_WIRELESS_SECURITY_ERROR,
890 NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_PROPERTY,
891 _("property is missing"));
892 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
896 if (!_nm_utils_string_in_list (priv->key_mgmt, valid_key_mgmt)) {
898 NM_SETTING_WIRELESS_SECURITY_ERROR,
899 NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
900 _("'%s' is not a valid value for the property"),
902 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
906 if (priv->auth_alg && !strcmp (priv->auth_alg, "leap")) {
907 /* LEAP must use ieee8021x key management */
908 if (strcmp (priv->key_mgmt, "ieee8021x")) {
910 NM_SETTING_WIRELESS_SECURITY_ERROR,
911 NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X,
912 _("'%s' security requires '%s=%s'"),
913 "leap", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x");
914 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
917 if (!priv->leap_username) {
918 g_set_error_literal (error,
919 NM_SETTING_WIRELESS_SECURITY_ERROR,
920 NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME,
921 _("property is empty"));
922 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
926 if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0)
927 || (strcmp (priv->key_mgmt, "wpa-eap") == 0)) {
928 /* Need an 802.1x setting too */
929 if (!nm_setting_find_in_list (all_settings, NM_SETTING_802_1X_SETTING_NAME)) {
931 NM_SETTING_WIRELESS_SECURITY_ERROR,
932 NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING,
933 _("'%s' security requires '%s' setting presence"),
934 priv->key_mgmt, NM_SETTING_802_1X_SETTING_NAME);
935 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
941 if (priv->leap_username && !strlen (priv->leap_username)) {
942 g_set_error_literal (error,
943 NM_SETTING_WIRELESS_SECURITY_ERROR,
944 NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
945 _("property is empty"));
946 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
950 if (priv->wep_tx_keyidx > 3) {
952 NM_SETTING_WIRELESS_SECURITY_ERROR,
953 NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
954 _("'%d' value is out of range <0-3>"),
955 priv->wep_tx_keyidx);
956 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX);
960 if (priv->wep_key_type > NM_WEP_KEY_TYPE_LAST) {
961 g_set_error_literal (error,
962 NM_SETTING_WIRELESS_SECURITY_ERROR,
963 NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
964 _("property is invalid"));
965 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE);
969 if (priv->auth_alg && !_nm_utils_string_in_list (priv->auth_alg, valid_auth_algs)) {
970 g_set_error_literal (error,
971 NM_SETTING_WIRELESS_SECURITY_ERROR,
972 NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
973 _("property is invalid"));
974 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
978 if (priv->proto && !_nm_utils_string_slist_validate (priv->proto, valid_protos)) {
979 g_set_error_literal (error,
980 NM_SETTING_WIRELESS_SECURITY_ERROR,
981 NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
982 _("property is invalid"));
983 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PROTO);
987 if (priv->pairwise) {
988 const char *wpa_none[] = { "wpa-none", NULL };
990 /* For ad-hoc connections, pairwise must be "none" */
991 if (_nm_utils_string_in_list (priv->key_mgmt, wpa_none)) {
993 gboolean found = FALSE;
995 for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) {
996 if (!strcmp ((char *) iter->data, "none")) {
1002 /* pairwise cipher list didn't contain "none", which is invalid
1003 * for WPA adhoc connections.
1007 NM_SETTING_WIRELESS_SECURITY_ERROR,
1008 NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
1009 _("'%s' connections require '%s' in this property"),
1010 NM_SETTING_WIRELESS_MODE_ADHOC, "none");
1011 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
1014 } else if (!_nm_utils_string_slist_validate (priv->pairwise, valid_pairwise)) {
1015 g_set_error_literal (error,
1016 NM_SETTING_WIRELESS_SECURITY_ERROR,
1017 NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
1018 _("property is invalid"));
1019 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
1024 if (priv->group && !_nm_utils_string_slist_validate (priv->group, valid_groups)) {
1025 g_set_error_literal (error,
1026 NM_SETTING_WIRELESS_SECURITY_ERROR,
1027 NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
1028 _("property is invalid"));
1029 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_GROUP);
1033 /* Shared Key auth can only be used with WEP */
1034 if (priv->auth_alg && !strcmp (priv->auth_alg, "shared")) {
1035 if (priv->key_mgmt && strcmp (priv->key_mgmt, "none")) {
1037 NM_SETTING_WIRELESS_SECURITY_ERROR,
1038 NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP,
1039 _("'%s' can only be used with '%s=%s' (WEP)"),
1040 "shared", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none");
1041 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
1050 get_secret_flags (NMSetting *setting,
1051 const char *secret_name,
1052 gboolean verify_secret,
1053 NMSettingSecretFlags *out_flags,
1056 NMSettingClass *setting_class;
1057 gboolean verify_override = verify_secret;
1059 /* There's only one 'flags' property for WEP keys, so alias all the WEP key
1060 * property names to that flags property.
1062 if ( !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)
1063 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)
1064 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)
1065 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)) {
1066 secret_name = "wep-key";
1067 verify_override = FALSE; /* Already know it's a secret */
1070 /* Chain up to superclass with modified key name */
1071 setting_class = NM_SETTING_CLASS (nm_setting_wireless_security_parent_class);
1072 return setting_class->get_secret_flags (setting, secret_name, verify_override, out_flags, error);
1076 set_secret_flags (NMSetting *setting,
1077 const char *secret_name,
1078 gboolean verify_secret,
1079 NMSettingSecretFlags flags,
1082 NMSettingClass *setting_class;
1083 gboolean verify_override = verify_secret;
1085 /* There's only one 'flags' property for WEP keys, so alias all the WEP key
1086 * property names to that flags property.
1088 if ( !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)
1089 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)
1090 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)
1091 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)) {
1092 secret_name = "wep-key";
1093 verify_override = FALSE; /* Already know it's a secret */
1096 /* Chain up to superclass with modified key name */
1097 setting_class = NM_SETTING_CLASS (nm_setting_wireless_security_parent_class);
1098 return setting_class->set_secret_flags (setting, secret_name, verify_override, flags, error);
1102 nm_setting_wireless_security_init (NMSettingWirelessSecurity *setting)
1107 finalize (GObject *object)
1109 NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (object);
1110 NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
1112 /* Strings first. g_free() already checks for NULLs so we don't have to */
1114 g_free (priv->key_mgmt);
1115 g_free (priv->auth_alg);
1116 g_free (priv->leap_username);
1117 g_free (priv->wep_key0);
1118 g_free (priv->wep_key1);
1119 g_free (priv->wep_key2);
1120 g_free (priv->wep_key3);
1122 g_free (priv->leap_password);
1124 g_slist_free_full (priv->proto, g_free);
1125 g_slist_free_full (priv->pairwise, g_free);
1126 g_slist_free_full (priv->group, g_free);
1128 G_OBJECT_CLASS (nm_setting_wireless_security_parent_class)->finalize (object);
1132 set_property (GObject *object, guint prop_id,
1133 const GValue *value, GParamSpec *pspec)
1135 NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY (object);
1136 NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
1141 g_free (priv->key_mgmt);
1142 str = g_value_get_string (value);
1143 priv->key_mgmt = str ? g_ascii_strdown (str, -1) : NULL;
1145 case PROP_WEP_TX_KEYIDX:
1146 priv->wep_tx_keyidx = g_value_get_uint (value);
1149 g_free (priv->auth_alg);
1150 str = g_value_get_string (value);
1151 priv->auth_alg = str ? g_ascii_strdown (str, -1) : NULL;
1154 g_slist_free_full (priv->proto, g_free);
1155 priv->proto = g_value_dup_boxed (value);
1158 g_slist_free_full (priv->pairwise, g_free);
1159 priv->pairwise = g_value_dup_boxed (value);
1162 g_slist_free_full (priv->group, g_free);
1163 priv->group = g_value_dup_boxed (value);
1165 case PROP_LEAP_USERNAME:
1166 g_free (priv->leap_username);
1167 priv->leap_username = g_value_dup_string (value);
1170 g_free (priv->wep_key0);
1171 priv->wep_key0 = g_value_dup_string (value);
1174 g_free (priv->wep_key1);
1175 priv->wep_key1 = g_value_dup_string (value);
1178 g_free (priv->wep_key2);
1179 priv->wep_key2 = g_value_dup_string (value);
1182 g_free (priv->wep_key3);
1183 priv->wep_key3 = g_value_dup_string (value);
1185 case PROP_WEP_KEY_FLAGS:
1186 priv->wep_key_flags = g_value_get_uint (value);
1190 priv->psk = g_value_dup_string (value);
1192 case PROP_PSK_FLAGS:
1193 priv->psk_flags = g_value_get_uint (value);
1195 case PROP_LEAP_PASSWORD:
1196 g_free (priv->leap_password);
1197 priv->leap_password = g_value_dup_string (value);
1199 case PROP_LEAP_PASSWORD_FLAGS:
1200 priv->leap_password_flags = g_value_get_uint (value);
1202 case PROP_WEP_KEY_TYPE:
1203 priv->wep_key_type = g_value_get_uint (value);
1206 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1212 get_property (GObject *object, guint prop_id,
1213 GValue *value, GParamSpec *pspec)
1215 NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY (object);
1216 NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
1220 g_value_set_string (value, priv->key_mgmt);
1222 case PROP_WEP_TX_KEYIDX:
1223 g_value_set_uint (value, priv->wep_tx_keyidx);
1226 g_value_set_string (value, priv->auth_alg);
1229 g_value_set_boxed (value, priv->proto);
1232 g_value_set_boxed (value, priv->pairwise);
1235 g_value_set_boxed (value, priv->group);
1237 case PROP_LEAP_USERNAME:
1238 g_value_set_string (value, priv->leap_username);
1241 g_value_set_string (value, priv->wep_key0);
1244 g_value_set_string (value, priv->wep_key1);
1247 g_value_set_string (value, priv->wep_key2);
1250 g_value_set_string (value, priv->wep_key3);
1252 case PROP_WEP_KEY_FLAGS:
1253 g_value_set_uint (value, priv->wep_key_flags);
1256 g_value_set_string (value, priv->psk);
1258 case PROP_PSK_FLAGS:
1259 g_value_set_uint (value, priv->psk_flags);
1261 case PROP_LEAP_PASSWORD:
1262 g_value_set_string (value, priv->leap_password);
1264 case PROP_LEAP_PASSWORD_FLAGS:
1265 g_value_set_uint (value, priv->leap_password_flags);
1267 case PROP_WEP_KEY_TYPE:
1268 g_value_set_uint (value, priv->wep_key_type);
1271 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1277 nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting_class)
1279 GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
1280 NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
1282 g_type_class_add_private (setting_class, sizeof (NMSettingWirelessSecurityPrivate));
1284 /* virtual methods */
1285 object_class->set_property = set_property;
1286 object_class->get_property = get_property;
1287 object_class->finalize = finalize;
1289 parent_class->verify = verify;
1290 parent_class->need_secrets = need_secrets;
1291 parent_class->get_secret_flags = get_secret_flags;
1292 parent_class->set_secret_flags = set_secret_flags;
1296 * NMSettingWirelessSecurity:key-mgmt:
1298 * Key management used for the connection. One of "none" (WEP), "ieee8021x"
1299 * (Dynamic WEP), "wpa-none" (Ad-Hoc WPA-PSK), "wpa-psk" (infrastructure
1300 * WPA-PSK), or "wpa-eap" (WPA-Enterprise). This property must be set for
1301 * any Wi-Fi connection that uses security.
1303 g_object_class_install_property
1304 (object_class, PROP_KEY_MGMT,
1305 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "", "",
1308 NM_SETTING_PARAM_REQUIRED |
1309 G_PARAM_STATIC_STRINGS));
1312 * NMSettingWirelessSecurity:wep-tx-keyidx:
1314 * When static WEP is used (ie, key-mgmt = "none") and a non-default WEP key
1315 * index is used by the AP, put that WEP key index here. Valid values are 0
1316 * (default key) through 3. Note that some consumer access points (like the
1317 * Linksys WRT54G) number the keys 1 - 4.
1319 g_object_class_install_property
1320 (object_class, PROP_WEP_TX_KEYIDX,
1321 g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, "", "",
1325 G_PARAM_STATIC_STRINGS));
1328 * NMSettingWirelessSecurity:auth-alg:
1330 * When WEP is used (ie, key-mgmt = "none" or "ieee8021x") indicate the
1331 * 802.11 authentication algorithm required by the AP here. One of "open"
1332 * for Open System, "shared" for Shared Key, or "leap" for Cisco LEAP. When
1333 * using Cisco LEAP (ie, key-mgmt = "ieee8021x" and auth-alg = "leap") the
1334 * "leap-username" and "leap-password" properties must be specified.
1336 g_object_class_install_property
1337 (object_class, PROP_AUTH_ALG,
1338 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "", "",
1341 G_PARAM_STATIC_STRINGS));
1344 * NMSettingWirelessSecurity:proto:
1346 * List of strings specifying the allowed WPA protocol versions to use.
1347 * Each element may be one "wpa" (allow WPA) or "rsn" (allow WPA2/RSN). If
1348 * not specified, both WPA and RSN connections are allowed.
1350 g_object_class_install_property
1351 (object_class, PROP_PROTO,
1352 _nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_PROTO, "", "",
1353 DBUS_TYPE_G_LIST_OF_STRING,
1355 G_PARAM_STATIC_STRINGS));
1358 * NMSettingWirelessSecurity:pairwise:
1360 * A list of pairwise encryption algorithms which prevents connections to
1361 * Wi-Fi networks that do not utilize one of the algorithms in the list.
1362 * For maximum compatibility leave this property empty. Each list element
1363 * may be one of "tkip" or "ccmp".
1365 g_object_class_install_property
1366 (object_class, PROP_PAIRWISE,
1367 _nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_PAIRWISE, "", "",
1368 DBUS_TYPE_G_LIST_OF_STRING,
1370 G_PARAM_STATIC_STRINGS));
1373 * NMSettingWirelessSecurity:group:
1375 * A list of group/broadcast encryption algorithms which prevents
1376 * connections to Wi-Fi networks that do not utilize one of the algorithms
1377 * in the list. For maximum compatibility leave this property empty. Each
1378 * list element may be one of "wep40", "wep104", "tkip", or "ccmp".
1380 g_object_class_install_property
1381 (object_class, PROP_GROUP,
1382 _nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_GROUP, "", "",
1383 DBUS_TYPE_G_LIST_OF_STRING,
1385 G_PARAM_STATIC_STRINGS));
1388 * NMSettingWirelessSecurity:leap-username:
1390 * The login username for legacy LEAP connections (ie, key-mgmt =
1391 * "ieee8021x" and auth-alg = "leap").
1393 g_object_class_install_property
1394 (object_class, PROP_LEAP_USERNAME,
1395 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, "", "",
1398 G_PARAM_STATIC_STRINGS));
1401 * NMSettingWirelessSecurity:wep-key0:
1403 * Index 0 WEP key. This is the WEP key used in most networks. See the
1404 * "wep-key-type" property for a description of how this key is interpreted.
1406 g_object_class_install_property
1407 (object_class, PROP_WEP_KEY0,
1408 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, "", "",
1411 NM_SETTING_PARAM_SECRET |
1412 G_PARAM_STATIC_STRINGS));
1415 * NMSettingWirelessSecurity:wep-key1:
1417 * Index 1 WEP key. This WEP index is not used by most networks. See the
1418 * "wep-key-type" property for a description of how this key is interpreted.
1420 g_object_class_install_property
1421 (object_class, PROP_WEP_KEY1,
1422 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, "", "",
1425 NM_SETTING_PARAM_SECRET |
1426 G_PARAM_STATIC_STRINGS));
1429 * NMSettingWirelessSecurity:wep-key2:
1431 * Index 2 WEP key. This WEP index is not used by most networks. See the
1432 * "wep-key-type" property for a description of how this key is interpreted.
1434 g_object_class_install_property
1435 (object_class, PROP_WEP_KEY2,
1436 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, "", "",
1439 NM_SETTING_PARAM_SECRET |
1440 G_PARAM_STATIC_STRINGS));
1443 * NMSettingWirelessSecurity:wep-key3:
1445 * Index 3 WEP key. This WEP index is not used by most networks. See the
1446 * "wep-key-type" property for a description of how this key is interpreted.
1448 g_object_class_install_property
1449 (object_class, PROP_WEP_KEY3,
1450 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, "", "",
1453 NM_SETTING_PARAM_SECRET |
1454 G_PARAM_STATIC_STRINGS));
1457 * NMSettingWirelessSecurity:wep-key-flags:
1459 * Flags indicating how to handle the #NMSettingWirelessSecurity:wep-key0,
1460 * #NMSettingWirelessSecurity:wep-key1, #NMSettingWirelessSecurity:wep-key2,
1461 * and #NMSettingWirelessSecurity:wep-key3 properties.
1463 g_object_class_install_property
1464 (object_class, PROP_WEP_KEY_FLAGS,
1465 g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, "", "",
1466 NM_SETTING_SECRET_FLAG_NONE,
1467 NM_SETTING_SECRET_FLAGS_ALL,
1468 NM_SETTING_SECRET_FLAG_NONE,
1470 G_PARAM_STATIC_STRINGS));
1473 * NMSettingWirelessSecurity:psk:
1475 * Pre-Shared-Key for WPA networks. If the key is 64-characters long, it
1476 * must contain only hexadecimal characters and is interpreted as a
1477 * hexadecimal WPA key. Otherwise, the key must be between 8 and 63 ASCII
1478 * characters (as specified in the 802.11i standard) and is interpreted as a
1479 * WPA passphrase, and is hashed to derive the actual WPA-PSK used when
1480 * connecting to the Wi-Fi network.
1482 g_object_class_install_property
1483 (object_class, PROP_PSK,
1484 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_PSK, "", "",
1487 NM_SETTING_PARAM_SECRET |
1488 G_PARAM_STATIC_STRINGS));
1491 * NMSettingWirelessSecurity:psk-flags:
1493 * Flags indicating how to handle the #NMSettingWirelessSecurity:psk
1496 g_object_class_install_property
1497 (object_class, PROP_PSK_FLAGS,
1498 g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, "", "",
1499 NM_SETTING_SECRET_FLAG_NONE,
1500 NM_SETTING_SECRET_FLAGS_ALL,
1501 NM_SETTING_SECRET_FLAG_NONE,
1503 G_PARAM_STATIC_STRINGS));
1506 * NMSettingWirelessSecurity:leap-password:
1508 * The login password for legacy LEAP connections (ie, key-mgmt =
1509 * "ieee8021x" and auth-alg = "leap").
1511 g_object_class_install_property
1512 (object_class, PROP_LEAP_PASSWORD,
1513 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, "", "",
1516 NM_SETTING_PARAM_SECRET |
1517 G_PARAM_STATIC_STRINGS));
1520 * NMSettingWirelessSecurity:leap-password-flags:
1522 * Flags indicating how to handle the
1523 * #NMSettingWirelessSecurity:leap-password property.
1525 g_object_class_install_property
1526 (object_class, PROP_LEAP_PASSWORD_FLAGS,
1527 g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS, "", "",
1528 NM_SETTING_SECRET_FLAG_NONE,
1529 NM_SETTING_SECRET_FLAGS_ALL,
1530 NM_SETTING_SECRET_FLAG_NONE,
1532 G_PARAM_STATIC_STRINGS));
1535 * NMSettingWirelessSecurity:wep-key-type:
1537 * Controls the interpretation of WEP keys. Allowed values are
1538 * %NM_WEP_KEY_TYPE_KEY, in which case the key is either a 10- or
1539 * 26-character hexadecimal string, or a 5- or 13-character ASCII password;
1540 * or %NM_WEP_KEY_TYPE_PASSPHRASE, in which case the passphrase is provided
1541 * as a string and will be hashed using the de-facto MD5 method to derive
1542 * the actual WEP key.
1544 g_object_class_install_property
1545 (object_class, PROP_WEP_KEY_TYPE,
1546 g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, "", "",
1547 NM_WEP_KEY_TYPE_UNKNOWN,
1548 NM_WEP_KEY_TYPE_LAST,
1549 NM_WEP_KEY_TYPE_UNKNOWN,
1552 G_PARAM_STATIC_STRINGS));