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"
27 #include "nm-setting-wireless-security.h"
28 #include "nm-setting-8021x.h"
30 #include "nm-utils-private.h"
31 #include "nm-setting-private.h"
32 #include "nm-setting-wireless.h"
35 * SECTION:nm-setting-wireless-security
36 * @short_description: Describes connection properties for Wi-Fi networks that
37 * use WEP, LEAP, WPA or WPA2/RSN security
39 * The #NMSettingWirelessSecurity object is a #NMSetting subclass that describes
40 * properties necessary for connection to encrypted Wi-Fi networks.
42 * It's a good idea to read up on wpa_supplicant configuration before using this
43 * setting extensively, since most of the options here correspond closely with
44 * the relevant wpa_supplicant configuration options. To get a better overview
45 * of how Wi-Fi security works, you may want to get copies of the following books.
47 * 802.11 Wireless Networks: The Definitive Guide, Second Edition
48 * Author: Matthew Gast
49 * ISBN: 978-0596100520
51 * Cisco Wireless LAN Security
52 * Authors: Krishna Sankar, Sri Sundaralingam, Darrin Miller, and Andrew Balinsky
53 * ISBN: 978-1587051548
56 G_DEFINE_TYPE_WITH_CODE (NMSettingWirelessSecurity, nm_setting_wireless_security, NM_TYPE_SETTING,
57 _nm_register_setting (WIRELESS_SECURITY, 2))
58 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS_SECURITY)
60 #define NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS_SECURITY, NMSettingWirelessSecurityPrivate))
65 GSList *proto; /* GSList of strings */
66 GSList *pairwise; /* GSList of strings */
67 GSList *group; /* GSList of strings */
72 NMSettingSecretFlags leap_password_flags;
79 NMSettingSecretFlags wep_key_flags;
80 NMWepKeyType wep_key_type;
81 guint32 wep_tx_keyidx;
85 NMSettingSecretFlags psk_flags;
86 } NMSettingWirelessSecurityPrivate;
106 PROP_LEAP_PASSWORD_FLAGS,
112 * nm_setting_wireless_security_new:
114 * Creates a new #NMSettingWirelessSecurity object with default values.
116 * Returns: (transfer full): the new empty #NMSettingWirelessSecurity object
119 nm_setting_wireless_security_new (void)
121 return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIRELESS_SECURITY, NULL);
125 * nm_setting_wireless_security_get_key_mgmt:
126 * @setting: the #NMSettingWirelessSecurity
128 * Returns: the #NMSettingWirelessSecurity:key-mgmt property of the setting
131 nm_setting_wireless_security_get_key_mgmt (NMSettingWirelessSecurity *setting)
133 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
135 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->key_mgmt;
139 * nm_setting_wireless_security_get_num_protos:
140 * @setting: the #NMSettingWirelessSecurity
142 * Returns: the number of security protocols this connection allows when
143 * connecting to secure Wi-Fi networks
146 nm_setting_wireless_security_get_num_protos (NMSettingWirelessSecurity *setting)
148 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
150 return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->proto);
154 * nm_setting_wireless_security_get_proto:
155 * @setting: the #NMSettingWirelessSecurity
156 * @i: an index into the protocol list
158 * Returns: the protocol at index @i
161 nm_setting_wireless_security_get_proto (NMSettingWirelessSecurity *setting, guint32 i)
163 NMSettingWirelessSecurityPrivate *priv;
165 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
167 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
168 g_return_val_if_fail (i <= g_slist_length (priv->proto), NULL);
170 return (const char *) g_slist_nth_data (priv->proto, i);
174 * nm_setting_wireless_security_add_proto:
175 * @setting: the #NMSettingWirelessSecurity
176 * @proto: the protocol to add, one of "wpa" or "rsn"
178 * Adds a Wi-Fi security protocol (one of "wpa" or "rsn") to the allowed list;
179 * only protocols in this list will be used when finding and connecting to
180 * the Wi-Fi network specified by this connection. For example, if the
181 * protocol list contains only "wpa" but the access point for the SSID specified
182 * by this connection only supports WPA2/RSN, the connection cannot be used
183 * with the access point.
185 * Returns: %TRUE if the protocol was new and and was added to the allowed
186 * protocol list, or %FALSE if it was already in the list
189 nm_setting_wireless_security_add_proto (NMSettingWirelessSecurity *setting, const char *proto)
191 NMSettingWirelessSecurityPrivate *priv;
194 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
195 g_return_val_if_fail (proto != NULL, FALSE);
197 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
198 for (iter = priv->proto; iter; iter = g_slist_next (iter)) {
199 if (strcasecmp (proto, (char *) iter->data) == 0)
203 priv->proto = g_slist_append (priv->proto, g_ascii_strdown (proto, -1));
204 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
209 * nm_setting_wireless_security_remove_proto:
210 * @setting: the #NMSettingWirelessSecurity
211 * @i: index of the protocol to remove
213 * Removes a protocol from the allowed protocol list.
216 nm_setting_wireless_security_remove_proto (NMSettingWirelessSecurity *setting, guint32 i)
218 NMSettingWirelessSecurityPrivate *priv;
221 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
223 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
224 elt = g_slist_nth (priv->proto, i);
225 g_return_if_fail (elt != NULL);
228 priv->proto = g_slist_delete_link (priv->proto, elt);
229 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
233 * nm_setting_wireless_security_remove_proto_by_value:
234 * @setting: the #NMSettingWirelessSecurity
235 * @proto: the protocol to remove, one of "wpa" or "rsn"
237 * Removes a protocol from the allowed protocol list.
239 * Returns: %TRUE if the protocol was found and removed; %FALSE it it was not.
242 nm_setting_wireless_security_remove_proto_by_value (NMSettingWirelessSecurity *setting,
245 NMSettingWirelessSecurityPrivate *priv;
248 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
249 g_return_val_if_fail (proto != NULL, FALSE);
251 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
252 for (iter = priv->proto; iter; iter = g_slist_next (iter)) {
253 if (strcasecmp (proto, (char *) iter->data) == 0) {
254 priv->proto = g_slist_delete_link (priv->proto, iter);
255 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
263 * nm_setting_wireless_security_clear_protos:
264 * @setting: the #NMSettingWirelessSecurity
266 * Removes all protocols from the allowed list. If there are no protocols
267 * specified then all protocols are allowed.
270 nm_setting_wireless_security_clear_protos (NMSettingWirelessSecurity *setting)
272 NMSettingWirelessSecurityPrivate *priv;
274 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
276 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
277 g_slist_free_full (priv->proto, g_free);
279 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PROTO);
283 * nm_setting_wireless_security_get_num_pairwise:
284 * @setting: the #NMSettingWirelessSecurity
286 * Returns: the number of pairwise encryption algorithms in the allowed list
289 nm_setting_wireless_security_get_num_pairwise (NMSettingWirelessSecurity *setting)
291 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
293 return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->pairwise);
297 * nm_setting_wireless_security_get_pairwise:
298 * @setting: the #NMSettingWirelessSecurity
299 * @i: index of an item in the allowed pairwise encryption algorithm list
301 * Returns the allowed pairwise encryption algorithm from allowed algorithm
304 * Returns: the pairwise encryption algorithm at index @i
307 nm_setting_wireless_security_get_pairwise (NMSettingWirelessSecurity *setting, guint32 i)
309 NMSettingWirelessSecurityPrivate *priv;
311 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
313 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
314 g_return_val_if_fail (i <= g_slist_length (priv->pairwise), NULL);
316 return (const char *) g_slist_nth_data (priv->pairwise, i);
320 * nm_setting_wireless_security_add_pairwise:
321 * @setting: the #NMSettingWirelessSecurity
322 * @pairwise: the encryption algorithm to add, one of "tkip" or "ccmp"
324 * Adds an encryption algorithm to the list of allowed pairwise encryption
325 * algorithms. If the list is not empty, then only access points that support
326 * one or more of the encryption algorithms in the list will be considered
327 * compatible with this connection.
329 * Returns: %TRUE if the algorithm was added to the list, %FALSE if it was
330 * already in the list
333 nm_setting_wireless_security_add_pairwise (NMSettingWirelessSecurity *setting, const char *pairwise)
335 NMSettingWirelessSecurityPrivate *priv;
338 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
339 g_return_val_if_fail (pairwise != NULL, FALSE);
341 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
342 for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) {
343 if (strcasecmp (pairwise, (char *) iter->data) == 0)
347 priv->pairwise = g_slist_append (priv->pairwise, g_ascii_strdown (pairwise, -1));
348 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
353 * nm_setting_wireless_security_remove_pairwise:
354 * @setting: the #NMSettingWirelessSecurity
355 * @i: the index of an item in the allowed pairwise encryption algorithm list
357 * Removes an encryption algorithm from the allowed pairwise encryption
361 nm_setting_wireless_security_remove_pairwise (NMSettingWirelessSecurity *setting, guint32 i)
363 NMSettingWirelessSecurityPrivate *priv;
366 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
368 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
369 elt = g_slist_nth (priv->pairwise, i);
370 g_return_if_fail (elt != NULL);
373 priv->pairwise = g_slist_delete_link (priv->pairwise, elt);
374 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
378 * nm_setting_wireless_security_remove_pairwise_by_value:
379 * @setting: the #NMSettingWirelessSecurity
380 * @pairwise: the encryption algorithm to remove, one of "tkip" or "ccmp"
382 * Removes an encryption algorithm from the allowed pairwise encryption
385 * Returns: %TRUE if the encryption algorith was found and removed; %FALSE it it was not.
388 nm_setting_wireless_security_remove_pairwise_by_value (NMSettingWirelessSecurity *setting,
389 const char *pairwise)
391 NMSettingWirelessSecurityPrivate *priv;
394 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
395 g_return_val_if_fail (pairwise != NULL, FALSE);
397 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
398 for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) {
399 if (strcasecmp (pairwise, (char *) iter->data) == 0) {
400 priv->pairwise = g_slist_delete_link (priv->pairwise, iter);
401 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
409 * nm_setting_wireless_security_clear_pairwise:
410 * @setting: the #NMSettingWirelessSecurity
412 * Removes all algorithms from the allowed list. If there are no algorithms
413 * specified then all pairwise encryption algorithms are allowed.
416 nm_setting_wireless_security_clear_pairwise (NMSettingWirelessSecurity *setting)
418 NMSettingWirelessSecurityPrivate *priv;
420 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
422 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
423 g_slist_free_full (priv->pairwise, g_free);
424 priv->pairwise = NULL;
425 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
429 * nm_setting_wireless_security_get_num_groups:
430 * @setting: the #NMSettingWirelessSecurity
432 * Returns: the number of groupwise encryption algorithms in the allowed list
435 nm_setting_wireless_security_get_num_groups (NMSettingWirelessSecurity *setting)
437 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
439 return g_slist_length (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->group);
443 * nm_setting_wireless_security_get_group:
444 * @setting: the #NMSettingWirelessSecurity
445 * @i: index of an item in the allowed groupwise encryption algorithm list
447 * Returns the allowed groupwise encryption algorithm from allowed algorithm
450 * Returns: the groupwise encryption algorithm at index @i
453 nm_setting_wireless_security_get_group (NMSettingWirelessSecurity *setting, guint32 i)
455 NMSettingWirelessSecurityPrivate *priv;
457 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
459 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
460 g_return_val_if_fail (i <= g_slist_length (priv->group), NULL);
462 return (const char *) g_slist_nth_data (priv->group, i);
466 * nm_setting_wireless_security_add_group:
467 * @setting: the #NMSettingWirelessSecurity
468 * @group: the encryption algorithm to add, one of "wep40", "wep104",
471 * Adds an encryption algorithm to the list of allowed groupwise encryption
472 * algorithms. If the list is not empty, then only access points that support
473 * one or more of the encryption algorithms in the list will be considered
474 * compatible with this connection.
476 * Returns: %TRUE if the algorithm was added to the list, %FALSE if it was
477 * already in the list
480 nm_setting_wireless_security_add_group (NMSettingWirelessSecurity *setting, const char *group)
482 NMSettingWirelessSecurityPrivate *priv;
485 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
486 g_return_val_if_fail (group != NULL, FALSE);
488 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
489 for (iter = priv->group; iter; iter = g_slist_next (iter)) {
490 if (strcasecmp (group, (char *) iter->data) == 0)
494 priv->group = g_slist_append (priv->group, g_ascii_strdown (group, -1));
495 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
500 * nm_setting_wireless_security_remove_group:
501 * @setting: the #NMSettingWirelessSecurity
502 * @i: the index of an item in the allowed groupwise encryption algorithm list
504 * Removes an encryption algorithm from the allowed groupwise encryption
508 nm_setting_wireless_security_remove_group (NMSettingWirelessSecurity *setting, guint32 i)
510 NMSettingWirelessSecurityPrivate *priv;
513 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
515 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
516 elt = g_slist_nth (priv->group, i);
517 g_return_if_fail (elt != NULL);
520 priv->group = g_slist_delete_link (priv->group, elt);
521 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
525 * nm_setting_wireless_security_remove_group_by_value:
526 * @setting: the #NMSettingWirelessSecurity
527 * @group: the encryption algorithm to remove, one of "wep40", "wep104",
530 * Removes an encryption algorithm from the allowed groupwise encryption
533 * Returns: %TRUE if the algorithm was found and removed; %FALSE it it was not.
536 nm_setting_wireless_security_remove_group_by_value (NMSettingWirelessSecurity *setting,
539 NMSettingWirelessSecurityPrivate *priv;
542 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), FALSE);
543 g_return_val_if_fail (group != NULL, FALSE);
545 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
546 for (iter = priv->group; iter; iter = g_slist_next (iter)) {
547 if (strcasecmp (group, (char *) iter->data) == 0) {
548 priv->group = g_slist_delete_link (priv->group, iter);
549 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
557 * nm_setting_wireless_security_clear_groups:
558 * @setting: the #NMSettingWirelessSecurity
560 * Removes all algorithms from the allowed list. If there are no algorithms
561 * specified then all groupwise encryption algorithms are allowed.
564 nm_setting_wireless_security_clear_groups (NMSettingWirelessSecurity *setting)
566 NMSettingWirelessSecurityPrivate *priv;
568 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
570 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
571 g_slist_free_full (priv->group, g_free);
573 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_GROUP);
577 * nm_setting_wireless_security_get_psk:
578 * @setting: the #NMSettingWirelessSecurity
580 * Returns: the #NMSettingWirelessSecurity:psk property of the setting
583 nm_setting_wireless_security_get_psk (NMSettingWirelessSecurity *setting)
585 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
587 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->psk;
591 * nm_setting_wireless_security_get_psk_flags:
592 * @setting: the #NMSettingWirelessSecurity
594 * Returns: the #NMSettingSecretFlags pertaining to the
595 * #NMSettingWirelessSecurity:psk
598 nm_setting_wireless_security_get_psk_flags (NMSettingWirelessSecurity *setting)
600 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
602 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->psk_flags;
606 * nm_setting_wireless_security_get_leap_username:
607 * @setting: the #NMSettingWirelessSecurity
609 * Returns: the #NMSettingWirelessSecurity:leap-username property of the setting
612 nm_setting_wireless_security_get_leap_username (NMSettingWirelessSecurity *setting)
614 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
616 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_username;
620 * nm_setting_wireless_security_get_leap_password:
621 * @setting: the #NMSettingWirelessSecurity
623 * Returns: the #NMSettingWirelessSecurity:leap-password property of the setting
626 nm_setting_wireless_security_get_leap_password (NMSettingWirelessSecurity *setting)
628 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
630 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_password;
634 * nm_setting_wireless_security_get_leap_password_flags:
635 * @setting: the #NMSettingWirelessSecurity
637 * Returns: the #NMSettingSecretFlags pertaining to the
638 * #NMSettingWirelessSecurity:leap-password
641 nm_setting_wireless_security_get_leap_password_flags (NMSettingWirelessSecurity *setting)
643 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
645 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->leap_password_flags;
649 * nm_setting_wireless_security_get_wep_key:
650 * @setting: the #NMSettingWirelessSecurity
651 * @idx: the WEP key index (0..3 inclusive)
653 * Returns: the WEP key at the given index
656 nm_setting_wireless_security_get_wep_key (NMSettingWirelessSecurity *setting, guint32 idx)
658 NMSettingWirelessSecurityPrivate *priv;
660 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
661 g_return_val_if_fail (idx < 4, NULL);
663 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
665 return priv->wep_key0;
667 return priv->wep_key1;
669 return priv->wep_key2;
671 return priv->wep_key3;
673 g_assert_not_reached ();
678 * nm_setting_wireless_security_set_wep_key:
679 * @setting: the #NMSettingWirelessSecurity
680 * @idx: the index of the key (0..3 inclusive)
681 * @key: the WEP key as a string, in either hexadecimal, ASCII, or passphrase
682 * form as determiend by the value of the #NMSettingWirelessSecurity:wep-key-type
685 * Sets a WEP key in the given index.
688 nm_setting_wireless_security_set_wep_key (NMSettingWirelessSecurity *setting, guint32 idx, const char *key)
690 NMSettingWirelessSecurityPrivate *priv;
692 g_return_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting));
693 g_return_if_fail (idx < 4);
695 priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
698 g_free (priv->wep_key0);
699 priv->wep_key0 = g_strdup (key);
700 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
703 g_free (priv->wep_key1);
704 priv->wep_key1 = g_strdup (key);
705 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY1);
708 g_free (priv->wep_key2);
709 priv->wep_key2 = g_strdup (key);
710 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY2);
713 g_free (priv->wep_key3);
714 priv->wep_key3 = g_strdup (key);
715 g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
718 g_assert_not_reached ();
723 * nm_setting_wireless_security_get_wep_tx_keyidx:
724 * @setting: the #NMSettingWirelessSecurity
726 * Returns: the #NMSettingWirelessSecurity:wep-tx-keyidx property of the setting
729 nm_setting_wireless_security_get_wep_tx_keyidx (NMSettingWirelessSecurity *setting)
731 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
733 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_tx_keyidx;
737 * nm_setting_wireless_security_get_auth_alg:
738 * @setting: the #NMSettingWirelessSecurity
740 * Returns: the #NMSettingWirelessSecurity:auth-alg property of the setting
743 nm_setting_wireless_security_get_auth_alg (NMSettingWirelessSecurity *setting)
745 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NULL);
747 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->auth_alg;
751 * nm_setting_wireless_security_get_wep_key_flags:
752 * @setting: the #NMSettingWirelessSecurity
754 * Returns: the #NMSettingSecretFlags pertaining to the all WEP keys
757 nm_setting_wireless_security_get_wep_key_flags (NMSettingWirelessSecurity *setting)
759 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), NM_SETTING_SECRET_FLAG_NONE);
761 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_key_flags;
765 * nm_setting_wireless_security_get_wep_key_type:
766 * @setting: the #NMSettingWirelessSecurity
768 * Returns: the #NMSettingWirelessSecurity:wep-key-type property of the setting
771 nm_setting_wireless_security_get_wep_key_type (NMSettingWirelessSecurity *setting)
773 g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (setting), 0);
775 return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->wep_key_type;
779 need_secrets (NMSetting *setting)
781 NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting);
782 NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
785 secrets = g_ptr_array_sized_new (4);
787 g_assert (priv->key_mgmt);
790 if (strcmp (priv->key_mgmt, "none") == 0) {
791 if ((priv->wep_tx_keyidx == 0) && !nm_utils_wep_key_valid (priv->wep_key0, priv->wep_key_type)) {
792 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
795 if ((priv->wep_tx_keyidx == 1) && !nm_utils_wep_key_valid (priv->wep_key1, priv->wep_key_type)) {
796 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1);
799 if ((priv->wep_tx_keyidx == 2) && !nm_utils_wep_key_valid (priv->wep_key2, priv->wep_key_type)) {
800 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2);
803 if ((priv->wep_tx_keyidx == 3) && !nm_utils_wep_key_valid (priv->wep_key3, priv->wep_key_type)) {
804 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
810 /* WPA-PSK infrastructure and adhoc */
811 if ( (strcmp (priv->key_mgmt, "wpa-none") == 0)
812 || (strcmp (priv->key_mgmt, "wpa-psk") == 0)) {
813 if (!nm_utils_wpa_psk_valid (priv->psk)) {
814 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_PSK);
822 && !strcmp (priv->auth_alg, "leap")
823 && !strcmp (priv->key_mgmt, "ieee8021x")) {
824 if (!priv->leap_password || !*priv->leap_password) {
825 g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD);
831 if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0)
832 || (strcmp (priv->key_mgmt, "wpa-eap") == 0)) {
833 /* Let caller check the 802.1x setting for secrets */
837 g_assert_not_reached ();
842 g_ptr_array_free (secrets, TRUE);
847 verify (NMSetting *setting, NMConnection *connection, GError **error)
849 NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting);
850 NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
851 const char *valid_key_mgmt[] = { "none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap", NULL };
852 const char *valid_auth_algs[] = { "open", "shared", "leap", NULL };
853 const char *valid_protos[] = { "wpa", "rsn", NULL };
854 const char *valid_pairwise[] = { "tkip", "ccmp", NULL };
855 const char *valid_groups[] = { "wep40", "wep104", "tkip", "ccmp", NULL };
857 if (!priv->key_mgmt) {
858 g_set_error_literal (error,
860 NM_CONNECTION_ERROR_MISSING_PROPERTY,
861 _("property is missing"));
862 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
866 if (!_nm_utils_string_in_list (priv->key_mgmt, valid_key_mgmt)) {
869 NM_CONNECTION_ERROR_INVALID_PROPERTY,
870 _("'%s' is not a valid value for the property"),
872 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
876 if (priv->auth_alg && !strcmp (priv->auth_alg, "leap")) {
877 /* LEAP must use ieee8021x key management */
878 if (strcmp (priv->key_mgmt, "ieee8021x")) {
881 NM_CONNECTION_ERROR_INVALID_PROPERTY,
882 _("'%s' security requires '%s=%s'"),
883 "leap", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x");
884 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
887 if (!priv->leap_username) {
888 g_set_error_literal (error,
890 NM_CONNECTION_ERROR_MISSING_PROPERTY,
891 _("property is empty"));
892 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
896 if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0)
897 || (strcmp (priv->key_mgmt, "wpa-eap") == 0)) {
898 /* Need an 802.1x setting too */
899 if (connection && !nm_connection_get_setting_802_1x (connection)) {
902 NM_CONNECTION_ERROR_MISSING_SETTING,
903 _("'%s' security requires '%s' setting presence"),
904 priv->key_mgmt, NM_SETTING_802_1X_SETTING_NAME);
905 g_prefix_error (error, "%s: ", NM_SETTING_802_1X_SETTING_NAME);
911 if (priv->leap_username && !strlen (priv->leap_username)) {
912 g_set_error_literal (error,
914 NM_CONNECTION_ERROR_INVALID_PROPERTY,
915 _("property is empty"));
916 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
920 if (priv->wep_tx_keyidx > 3) {
923 NM_CONNECTION_ERROR_INVALID_PROPERTY,
924 _("'%d' value is out of range <0-3>"),
925 priv->wep_tx_keyidx);
926 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX);
930 if (priv->wep_key_type > NM_WEP_KEY_TYPE_LAST) {
931 g_set_error_literal (error,
933 NM_CONNECTION_ERROR_INVALID_PROPERTY,
934 _("property is invalid"));
935 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE);
939 if (priv->auth_alg && !_nm_utils_string_in_list (priv->auth_alg, valid_auth_algs)) {
940 g_set_error_literal (error,
942 NM_CONNECTION_ERROR_INVALID_PROPERTY,
943 _("property is invalid"));
944 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
948 if (priv->proto && !_nm_utils_string_slist_validate (priv->proto, valid_protos)) {
949 g_set_error_literal (error,
951 NM_CONNECTION_ERROR_INVALID_PROPERTY,
952 _("property is invalid"));
953 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PROTO);
957 if (priv->pairwise) {
958 const char *wpa_none[] = { "wpa-none", NULL };
960 /* For ad-hoc connections, pairwise must be "none" */
961 if (_nm_utils_string_in_list (priv->key_mgmt, wpa_none)) {
963 gboolean found = FALSE;
965 for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) {
966 if (!strcmp ((char *) iter->data, "none")) {
972 /* pairwise cipher list didn't contain "none", which is invalid
973 * for WPA adhoc connections.
978 NM_CONNECTION_ERROR_INVALID_PROPERTY,
979 _("'%s' connections require '%s' in this property"),
980 NM_SETTING_WIRELESS_MODE_ADHOC, "none");
981 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
984 } else if (!_nm_utils_string_slist_validate (priv->pairwise, valid_pairwise)) {
985 g_set_error_literal (error,
987 NM_CONNECTION_ERROR_INVALID_PROPERTY,
988 _("property is invalid"));
989 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PAIRWISE);
994 if (priv->group && !_nm_utils_string_slist_validate (priv->group, valid_groups)) {
995 g_set_error_literal (error,
997 NM_CONNECTION_ERROR_INVALID_PROPERTY,
998 _("property is invalid"));
999 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_GROUP);
1003 /* Shared Key auth can only be used with WEP */
1004 if (priv->auth_alg && !strcmp (priv->auth_alg, "shared")) {
1005 if (priv->key_mgmt && strcmp (priv->key_mgmt, "none")) {
1007 NM_CONNECTION_ERROR,
1008 NM_CONNECTION_ERROR_INVALID_PROPERTY,
1009 _("'%s' can only be used with '%s=%s' (WEP)"),
1010 "shared", NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none");
1011 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG);
1020 _verify_wep_key (const char *wep_key,
1021 NMWepKeyType wep_key_type,
1022 const char *property,
1025 if (wep_key && !nm_utils_wep_key_valid (wep_key, wep_key_type)) {
1026 g_set_error_literal (error,
1027 NM_CONNECTION_ERROR,
1028 NM_CONNECTION_ERROR_INVALID_PROPERTY,
1029 _("property is invalid"));
1030 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, property);
1037 verify_secrets (NMSetting *setting, NMConnection *connection, GError **error)
1039 NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting);
1040 NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
1044 && !strcmp (priv->auth_alg, "leap")
1045 && !strcmp (priv->key_mgmt, "ieee8021x")) {
1046 if (!_nm_setting_verify_secret_string (priv->leap_password,
1047 NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
1048 NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD,
1054 if (!_verify_wep_key (priv->wep_key0, priv->wep_key_type, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, error))
1056 if (!_verify_wep_key (priv->wep_key1, priv->wep_key_type, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, error))
1058 if (!_verify_wep_key (priv->wep_key2, priv->wep_key_type, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, error))
1060 if (!_verify_wep_key (priv->wep_key3, priv->wep_key_type, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, error))
1064 if (priv->psk && !nm_utils_wpa_psk_valid (priv->psk)) {
1065 g_set_error_literal (error,
1066 NM_CONNECTION_ERROR,
1067 NM_CONNECTION_ERROR_INVALID_PROPERTY,
1068 _("property is invalid"));
1069 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PSK);
1077 get_secret_flags (NMSetting *setting,
1078 const char *secret_name,
1079 gboolean verify_secret,
1080 NMSettingSecretFlags *out_flags,
1083 NMSettingClass *setting_class;
1084 gboolean verify_override = verify_secret;
1086 /* There's only one 'flags' property for WEP keys, so alias all the WEP key
1087 * property names to that flags property.
1089 if ( !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)
1090 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)
1091 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)
1092 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)) {
1093 secret_name = "wep-key";
1094 verify_override = FALSE; /* Already know it's a secret */
1097 /* Chain up to superclass with modified key name */
1098 setting_class = NM_SETTING_CLASS (nm_setting_wireless_security_parent_class);
1099 return setting_class->get_secret_flags (setting, secret_name, verify_override, out_flags, error);
1103 set_secret_flags (NMSetting *setting,
1104 const char *secret_name,
1105 gboolean verify_secret,
1106 NMSettingSecretFlags flags,
1109 NMSettingClass *setting_class;
1110 gboolean verify_override = verify_secret;
1112 /* There's only one 'flags' property for WEP keys, so alias all the WEP key
1113 * property names to that flags property.
1115 if ( !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)
1116 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)
1117 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)
1118 || !g_strcmp0 (secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)) {
1119 secret_name = "wep-key";
1120 verify_override = FALSE; /* Already know it's a secret */
1123 /* Chain up to superclass with modified key name */
1124 setting_class = NM_SETTING_CLASS (nm_setting_wireless_security_parent_class);
1125 return setting_class->set_secret_flags (setting, secret_name, verify_override, flags, error);
1129 nm_setting_wireless_security_init (NMSettingWirelessSecurity *setting)
1134 finalize (GObject *object)
1136 NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (object);
1137 NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self);
1139 /* Strings first. g_free() already checks for NULLs so we don't have to */
1141 g_free (priv->key_mgmt);
1142 g_free (priv->auth_alg);
1143 g_free (priv->leap_username);
1144 g_free (priv->wep_key0);
1145 g_free (priv->wep_key1);
1146 g_free (priv->wep_key2);
1147 g_free (priv->wep_key3);
1149 g_free (priv->leap_password);
1151 g_slist_free_full (priv->proto, g_free);
1152 g_slist_free_full (priv->pairwise, g_free);
1153 g_slist_free_full (priv->group, g_free);
1155 G_OBJECT_CLASS (nm_setting_wireless_security_parent_class)->finalize (object);
1158 /* NMSettingWirelessSecurity:wep-key-type is an enum, but needs to be marshalled
1159 * as 'u', not 'i', for backward-compatibility.
1162 wep_key_type_to_dbus (const GValue *from)
1164 return g_variant_new_uint32 (g_value_get_enum (from));
1168 set_property (GObject *object, guint prop_id,
1169 const GValue *value, GParamSpec *pspec)
1171 NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY (object);
1172 NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
1177 g_free (priv->key_mgmt);
1178 str = g_value_get_string (value);
1179 priv->key_mgmt = str ? g_ascii_strdown (str, -1) : NULL;
1181 case PROP_WEP_TX_KEYIDX:
1182 priv->wep_tx_keyidx = g_value_get_uint (value);
1185 g_free (priv->auth_alg);
1186 str = g_value_get_string (value);
1187 priv->auth_alg = str ? g_ascii_strdown (str, -1) : NULL;
1190 g_slist_free_full (priv->proto, g_free);
1191 priv->proto = _nm_utils_strv_to_slist (g_value_get_boxed (value), TRUE);
1194 g_slist_free_full (priv->pairwise, g_free);
1195 priv->pairwise = _nm_utils_strv_to_slist (g_value_get_boxed (value), TRUE);
1198 g_slist_free_full (priv->group, g_free);
1199 priv->group = _nm_utils_strv_to_slist (g_value_get_boxed (value), TRUE);
1201 case PROP_LEAP_USERNAME:
1202 g_free (priv->leap_username);
1203 priv->leap_username = g_value_dup_string (value);
1206 g_free (priv->wep_key0);
1207 priv->wep_key0 = g_value_dup_string (value);
1210 g_free (priv->wep_key1);
1211 priv->wep_key1 = g_value_dup_string (value);
1214 g_free (priv->wep_key2);
1215 priv->wep_key2 = g_value_dup_string (value);
1218 g_free (priv->wep_key3);
1219 priv->wep_key3 = g_value_dup_string (value);
1221 case PROP_WEP_KEY_FLAGS:
1222 priv->wep_key_flags = g_value_get_flags (value);
1226 priv->psk = g_value_dup_string (value);
1228 case PROP_PSK_FLAGS:
1229 priv->psk_flags = g_value_get_flags (value);
1231 case PROP_LEAP_PASSWORD:
1232 g_free (priv->leap_password);
1233 priv->leap_password = g_value_dup_string (value);
1235 case PROP_LEAP_PASSWORD_FLAGS:
1236 priv->leap_password_flags = g_value_get_flags (value);
1238 case PROP_WEP_KEY_TYPE:
1239 priv->wep_key_type = g_value_get_enum (value);
1242 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1248 get_property (GObject *object, guint prop_id,
1249 GValue *value, GParamSpec *pspec)
1251 NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY (object);
1252 NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting);
1256 g_value_set_string (value, priv->key_mgmt);
1258 case PROP_WEP_TX_KEYIDX:
1259 g_value_set_uint (value, priv->wep_tx_keyidx);
1262 g_value_set_string (value, priv->auth_alg);
1265 g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->proto, TRUE));
1268 g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->pairwise, TRUE));
1271 g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->group, TRUE));
1273 case PROP_LEAP_USERNAME:
1274 g_value_set_string (value, priv->leap_username);
1277 g_value_set_string (value, priv->wep_key0);
1280 g_value_set_string (value, priv->wep_key1);
1283 g_value_set_string (value, priv->wep_key2);
1286 g_value_set_string (value, priv->wep_key3);
1288 case PROP_WEP_KEY_FLAGS:
1289 g_value_set_flags (value, priv->wep_key_flags);
1292 g_value_set_string (value, priv->psk);
1294 case PROP_PSK_FLAGS:
1295 g_value_set_flags (value, priv->psk_flags);
1297 case PROP_LEAP_PASSWORD:
1298 g_value_set_string (value, priv->leap_password);
1300 case PROP_LEAP_PASSWORD_FLAGS:
1301 g_value_set_flags (value, priv->leap_password_flags);
1303 case PROP_WEP_KEY_TYPE:
1304 g_value_set_enum (value, priv->wep_key_type);
1307 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1313 nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting_class)
1315 GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
1316 NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
1318 g_type_class_add_private (setting_class, sizeof (NMSettingWirelessSecurityPrivate));
1320 /* virtual methods */
1321 object_class->set_property = set_property;
1322 object_class->get_property = get_property;
1323 object_class->finalize = finalize;
1325 parent_class->verify = verify;
1326 parent_class->verify_secrets = verify_secrets;
1327 parent_class->need_secrets = need_secrets;
1328 parent_class->get_secret_flags = get_secret_flags;
1329 parent_class->set_secret_flags = set_secret_flags;
1333 * NMSettingWirelessSecurity:key-mgmt:
1335 * Key management used for the connection. One of "none" (WEP), "ieee8021x"
1336 * (Dynamic WEP), "wpa-none" (Ad-Hoc WPA-PSK), "wpa-psk" (infrastructure
1337 * WPA-PSK), or "wpa-eap" (WPA-Enterprise). This property must be set for
1338 * any Wi-Fi connection that uses security.
1341 * property: key-mgmt
1342 * variable: KEY_MGMT(+)
1343 * values: IEEE8021X, WPA-PSK, WPA-EAP
1344 * description: Key management menthod.
1347 g_object_class_install_property
1348 (object_class, PROP_KEY_MGMT,
1349 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "", "",
1352 NM_SETTING_PARAM_REQUIRED |
1353 G_PARAM_STATIC_STRINGS));
1356 * NMSettingWirelessSecurity:wep-tx-keyidx:
1358 * When static WEP is used (ie, key-mgmt = "none") and a non-default WEP key
1359 * index is used by the AP, put that WEP key index here. Valid values are 0
1360 * (default key) through 3. Note that some consumer access points (like the
1361 * Linksys WRT54G) number the keys 1 - 4.
1364 * property: wep-tx-keyidx
1365 * variable: DEFAULTKEY
1366 * values: 1, 2, 3, 4
1368 * description: Index of active WEP key.
1371 g_object_class_install_property
1372 (object_class, PROP_WEP_TX_KEYIDX,
1373 g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, "", "",
1377 G_PARAM_STATIC_STRINGS));
1380 * NMSettingWirelessSecurity:auth-alg:
1382 * When WEP is used (ie, key-mgmt = "none" or "ieee8021x") indicate the
1383 * 802.11 authentication algorithm required by the AP here. One of "open"
1384 * for Open System, "shared" for Shared Key, or "leap" for Cisco LEAP. When
1385 * using Cisco LEAP (ie, key-mgmt = "ieee8021x" and auth-alg = "leap") the
1386 * "leap-username" and "leap-password" properties must be specified.
1389 * property: auth-alg
1390 * variable: SECURITYMODE(+)
1391 * values: restricted, open, leap
1392 * description: Authentication algorithm for WEP.
1395 g_object_class_install_property
1396 (object_class, PROP_AUTH_ALG,
1397 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "", "",
1400 G_PARAM_STATIC_STRINGS));
1403 * NMSettingWirelessSecurity:proto:
1405 * List of strings specifying the allowed WPA protocol versions to use.
1406 * Each element may be one "wpa" (allow WPA) or "rsn" (allow WPA2/RSN). If
1407 * not specified, both WPA and RSN connections are allowed.
1411 * variable: WPA_ALLOW_WPA(+), WPA_ALLOW_WPA2(+)
1414 * description: Allowed WPA protocols, WPA and WPA2 (RSN).
1417 g_object_class_install_property
1418 (object_class, PROP_PROTO,
1419 g_param_spec_boxed (NM_SETTING_WIRELESS_SECURITY_PROTO, "", "",
1422 G_PARAM_STATIC_STRINGS));
1425 * NMSettingWirelessSecurity:pairwise:
1427 * A list of pairwise encryption algorithms which prevents connections to
1428 * Wi-Fi networks that do not utilize one of the algorithms in the list.
1429 * For maximum compatibility leave this property empty. Each list element
1430 * may be one of "tkip" or "ccmp".
1433 * property: pairwise
1434 * variable: CIPHER_PAIRWISE(+)
1435 * values: CCMP, TKIP
1436 * description: Restrict pairwise encryption algorithms, specified as a space
1440 g_object_class_install_property
1441 (object_class, PROP_PAIRWISE,
1442 g_param_spec_boxed (NM_SETTING_WIRELESS_SECURITY_PAIRWISE, "", "",
1445 G_PARAM_STATIC_STRINGS));
1448 * NMSettingWirelessSecurity:group:
1450 * A list of group/broadcast encryption algorithms which prevents
1451 * connections to Wi-Fi networks that do not utilize one of the algorithms
1452 * in the list. For maximum compatibility leave this property empty. Each
1453 * list element may be one of "wep40", "wep104", "tkip", or "ccmp".
1457 * variable: CIPHER_GROUP(+)
1458 * values: CCMP, TKIP, WEP40, WEP104
1459 * description: Restrict group/broadcast encryption algorithms, specified as a space
1463 g_object_class_install_property
1464 (object_class, PROP_GROUP,
1465 g_param_spec_boxed (NM_SETTING_WIRELESS_SECURITY_GROUP, "", "",
1468 G_PARAM_STATIC_STRINGS));
1471 * NMSettingWirelessSecurity:leap-username:
1473 * The login username for legacy LEAP connections (ie, key-mgmt =
1474 * "ieee8021x" and auth-alg = "leap").
1477 * property: leap-username
1478 * variable: IEEE_8021X_IDENTITY(+)
1479 * description: Login name for LEAP.
1482 g_object_class_install_property
1483 (object_class, PROP_LEAP_USERNAME,
1484 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, "", "",
1487 G_PARAM_STATIC_STRINGS));
1490 * NMSettingWirelessSecurity:wep-key0:
1492 * Index 0 WEP key. This is the WEP key used in most networks. See the
1493 * "wep-key-type" property for a description of how this key is interpreted.
1496 * property: wep-key0
1497 * variable: KEY1, KEY_PASSPHRASE1(+)
1498 * description: The first WEP key (used in most networks). See also DEFAULTKEY for key index.
1501 g_object_class_install_property
1502 (object_class, PROP_WEP_KEY0,
1503 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, "", "",
1506 NM_SETTING_PARAM_SECRET |
1507 G_PARAM_STATIC_STRINGS));
1510 * NMSettingWirelessSecurity:wep-key1:
1512 * Index 1 WEP key. This WEP index is not used by most networks. See the
1513 * "wep-key-type" property for a description of how this key is interpreted.
1516 * property: wep-key1
1517 * variable: KEY2, KEY_PASSPHRASE2(+)
1518 * description: WEP key with index 1. See also DEFAULTKEY for key index.
1521 g_object_class_install_property
1522 (object_class, PROP_WEP_KEY1,
1523 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, "", "",
1526 NM_SETTING_PARAM_SECRET |
1527 G_PARAM_STATIC_STRINGS));
1530 * NMSettingWirelessSecurity:wep-key2:
1532 * Index 2 WEP key. This WEP index is not used by most networks. See the
1533 * "wep-key-type" property for a description of how this key is interpreted.
1536 * property: wep-key2
1537 * variable: KEY3, KEY_PASSPHRASE3(+)
1538 * description: WEP key with index 2. See also DEFAULTKEY for key index.
1541 g_object_class_install_property
1542 (object_class, PROP_WEP_KEY2,
1543 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, "", "",
1546 NM_SETTING_PARAM_SECRET |
1547 G_PARAM_STATIC_STRINGS));
1550 * NMSettingWirelessSecurity:wep-key3:
1552 * Index 3 WEP key. This WEP index is not used by most networks. See the
1553 * "wep-key-type" property for a description of how this key is interpreted.
1556 * property: wep-key3
1557 * variable: KEY4, KEY_PASSPHRASE4(+)
1558 * description: WEP key with index 3. See also DEFAULTKEY for key index.
1561 g_object_class_install_property
1562 (object_class, PROP_WEP_KEY3,
1563 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, "", "",
1566 NM_SETTING_PARAM_SECRET |
1567 G_PARAM_STATIC_STRINGS));
1570 * NMSettingWirelessSecurity:wep-key-flags:
1572 * Flags indicating how to handle the #NMSettingWirelessSecurity:wep-key0,
1573 * #NMSettingWirelessSecurity:wep-key1, #NMSettingWirelessSecurity:wep-key2,
1574 * and #NMSettingWirelessSecurity:wep-key3 properties.
1577 * property: wep-key-flags
1578 * variable: WEP_KEY_FLAGS(+)
1579 * format: NMSettingSecretFlags
1580 * description: Password flags for KEY<i>, KEY_PASSPHRASE<i> password.
1583 g_object_class_install_property
1584 (object_class, PROP_WEP_KEY_FLAGS,
1585 g_param_spec_flags (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, "", "",
1586 NM_TYPE_SETTING_SECRET_FLAGS,
1587 NM_SETTING_SECRET_FLAG_NONE,
1589 G_PARAM_STATIC_STRINGS));
1592 * NMSettingWirelessSecurity:psk:
1594 * Pre-Shared-Key for WPA networks. If the key is 64-characters long, it
1595 * must contain only hexadecimal characters and is interpreted as a
1596 * hexadecimal WPA key. Otherwise, the key must be between 8 and 63 ASCII
1597 * characters (as specified in the 802.11i standard) and is interpreted as a
1598 * WPA passphrase, and is hashed to derive the actual WPA-PSK used when
1599 * connecting to the Wi-Fi network.
1604 * description: Pre-Shared-Key for WPA networks.
1607 g_object_class_install_property
1608 (object_class, PROP_PSK,
1609 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_PSK, "", "",
1612 NM_SETTING_PARAM_SECRET |
1613 G_PARAM_STATIC_STRINGS));
1616 * NMSettingWirelessSecurity:psk-flags:
1618 * Flags indicating how to handle the #NMSettingWirelessSecurity:psk
1622 * property: psk-flags
1623 * variable: WPA_PSK_FLAGS(+)
1624 * format: NMSettingSecretFlags
1625 * description: Password flags for WPA_PSK_FLAGS.
1626 * example: WPA_PSK_FLAGS=user
1629 g_object_class_install_property
1630 (object_class, PROP_PSK_FLAGS,
1631 g_param_spec_flags (NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, "", "",
1632 NM_TYPE_SETTING_SECRET_FLAGS,
1633 NM_SETTING_SECRET_FLAG_NONE,
1635 G_PARAM_STATIC_STRINGS));
1638 * NMSettingWirelessSecurity:leap-password:
1640 * The login password for legacy LEAP connections (ie, key-mgmt =
1641 * "ieee8021x" and auth-alg = "leap").
1644 * property: leap-password
1645 * variable: IEEE_8021X_PASSWORD(+)
1646 * description: Password for LEAP. It can also go to "key-"
1647 * lookaside file, or it can be owned by a secret agent.
1650 g_object_class_install_property
1651 (object_class, PROP_LEAP_PASSWORD,
1652 g_param_spec_string (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, "", "",
1655 NM_SETTING_PARAM_SECRET |
1656 G_PARAM_STATIC_STRINGS));
1659 * NMSettingWirelessSecurity:leap-password-flags:
1661 * Flags indicating how to handle the
1662 * #NMSettingWirelessSecurity:leap-password property.
1665 * property: leap-password-flags
1666 * variable: IEEE_8021X_PASSWORD_FLAGS(+)
1667 * format: NMSettingSecretFlags
1668 * description: Password flags for IEEE_8021X_PASSWORD_FLAGS.
1671 g_object_class_install_property
1672 (object_class, PROP_LEAP_PASSWORD_FLAGS,
1673 g_param_spec_flags (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS, "", "",
1674 NM_TYPE_SETTING_SECRET_FLAGS,
1675 NM_SETTING_SECRET_FLAG_NONE,
1677 G_PARAM_STATIC_STRINGS));
1680 * NMSettingWirelessSecurity:wep-key-type:
1682 * Controls the interpretation of WEP keys. Allowed values are
1683 * %NM_WEP_KEY_TYPE_KEY, in which case the key is either a 10- or
1684 * 26-character hexadecimal string, or a 5- or 13-character ASCII password;
1685 * or %NM_WEP_KEY_TYPE_PASSPHRASE, in which case the passphrase is provided
1686 * as a string and will be hashed using the de-facto MD5 method to derive
1687 * the actual WEP key.
1690 * property: wep-key-type
1691 * variable: KEY<i> or KEY_PASSPHRASE<i>(+)
1692 * description: KEY is used for "key" type (10 or 26 hexadecimal characters,
1693 * or 5 or 13 character string prefixed with "s:"). KEY_PASSPHRASE is used
1694 * for WEP passphrases.
1695 * example: KEY1=s:ahoj, KEY1=0a1c45bc02, KEY_PASSPHRASE1=mysupersecretkey
1698 g_object_class_install_property
1699 (object_class, PROP_WEP_KEY_TYPE,
1700 g_param_spec_enum (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, "", "",
1701 NM_TYPE_WEP_KEY_TYPE,
1702 NM_WEP_KEY_TYPE_UNKNOWN,
1705 G_PARAM_STATIC_STRINGS));
1706 _nm_setting_class_transform_property (parent_class,
1707 NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE,
1708 G_VARIANT_TYPE_UINT32,
1709 wep_key_type_to_dbus,