diff options
Diffstat (limited to 'libnm-util/nm-setting-wireless.c')
| -rw-r--r-- | libnm-util/nm-setting-wireless.c | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/libnm-util/nm-setting-wireless.c b/libnm-util/nm-setting-wireless.c index f9ed3108..ace22cbc 100644 --- a/libnm-util/nm-setting-wireless.c +++ b/libnm-util/nm-setting-wireless.c @@ -34,6 +34,7 @@ #include "nm-utils.h" #include "nm-dbus-glib-types.h" #include "nm-utils-private.h" +#include "nm-setting-private.h" /** * SECTION:nm-setting-wireless @@ -62,7 +63,12 @@ nm_setting_wireless_error_quark (void) } -G_DEFINE_TYPE (NMSettingWireless, nm_setting_wireless, NM_TYPE_SETTING) +G_DEFINE_TYPE_WITH_CODE (NMSettingWireless, nm_setting_wireless, NM_TYPE_SETTING, + _nm_register_setting (NM_SETTING_WIRELESS_SETTING_NAME, + g_define_type_id, + 1, + NM_SETTING_WIRELESS_ERROR)) +NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS) #define NM_SETTING_WIRELESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS, NMSettingWirelessPrivate)) @@ -187,14 +193,21 @@ nm_setting_wireless_ap_security_compatible (NMSettingWireless *s_wireless, if (!strcmp (key_mgmt, "wpa-none")) { if (ap_mode != NM_802_11_MODE_ADHOC) return FALSE; - // FIXME: validate ciphers if the BSSID actually puts WPA/RSN IE in - // it's beacon + /* FIXME: validate ciphers if they're in the beacon */ return TRUE; } - /* Stuff after this point requires infrastructure */ - if (ap_mode != NM_802_11_MODE_INFRA) - return FALSE; + /* Adhoc WPA2 (ie, RSN IBSS) */ + if (ap_mode == NM_802_11_MODE_ADHOC) { + if (strcmp (key_mgmt, "wpa-psk")) + return FALSE; + + /* Ensure the AP has RSN PSK capability */ + if (!(ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_PSK)) + return FALSE; + + /* Fall through and check ciphers in generic WPA-PSK code */ + } /* Dynamic WEP or LEAP */ if (!strcmp (key_mgmt, "ieee8021x")) { @@ -502,15 +515,16 @@ nm_setting_wireless_get_hidden (NMSettingWireless *setting) * @setting: the #NMSettingWireless * @bssid: the new BSSID to add to the list * - * Adds a new WiFi AP's BSSID to the previously seen BSSID list of the setting. - * NetworkManager tracks previously seen BSSIDs internally so this function - * no longer has much use. + * Adds a new Wi-Fi AP's BSSID to the previously seen BSSID list of the setting. + * NetworkManager now tracks previously seen BSSIDs internally so this function + * no longer has much use. Actually, changes you make using this function will + * not be preserved. * * Returns: %TRUE if @bssid was already known, %FALSE if not **/ gboolean nm_setting_wireless_add_seen_bssid (NMSettingWireless *setting, - const char *bssid) + const char *bssid) { NMSettingWirelessPrivate *priv; char *lower_bssid; @@ -584,7 +598,7 @@ static gboolean verify (NMSetting *setting, GSList *all_settings, GError **error) { NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting); - const char *valid_modes[] = { NM_SETTING_WIRELESS_MODE_INFRA, NM_SETTING_WIRELESS_MODE_ADHOC, NULL }; + const char *valid_modes[] = { NM_SETTING_WIRELESS_MODE_INFRA, NM_SETTING_WIRELESS_MODE_ADHOC, NM_SETTING_WIRELESS_MODE_AP, NULL }; const char *valid_bands[] = { "a", "bg", NULL }; GSList *iter; @@ -881,15 +895,15 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class) /** * NMSettingWireless:mode: * - * WiFi network mode; one of 'infrastructure' or 'adhoc'. If blank, + * WiFi network mode; one of 'infrastructure', 'adhoc' or 'ap'. If blank, * infrastructure is assumed. **/ g_object_class_install_property (object_class, PROP_MODE, g_param_spec_string (NM_SETTING_WIRELESS_MODE, "Mode", - "WiFi network mode; one of 'infrastructure' or " - "'adhoc'. If blank, infrastructure is assumed.", + "WiFi network mode; one of 'infrastructure', " + "'adhoc' or 'ap'. If blank, infrastructure is assumed.", NULL, G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); @@ -1054,21 +1068,25 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class) * NMSettingWireless:seen-bssids: * * A list of BSSIDs (each BSSID formatted as a MAC address like - * '00:11:22:33:44:55') that have been detected as part of the WiFI network. - * NetworkManager internally tracks previously seen BSSIDs so this property - * is no longer of much use. + * '00:11:22:33:44:55') that have been detected as part of the Wi-FI network. + * NetworkManager internally tracks previously seen BSSIDs. The property is only + * meant for reading and reflects the BBSID list of NetworkManager. The changes you + * make to this property will not be preserved. **/ g_object_class_install_property (object_class, PROP_SEEN_BSSIDS, _nm_param_spec_specialized (NM_SETTING_WIRELESS_SEEN_BSSIDS, - "Seen BSSIDS", - "A list of BSSIDs (each BSSID formatted as a MAC " - "address like 00:11:22:33:44:55') that have been " - "detected as part of the WiFI network. " - "NetworkManager internally tracks previously seen " - "BSSIDs so this property is no longer of much use.", - DBUS_TYPE_G_LIST_OF_STRING, - G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE)); + "Seen BSSIDS", + "A list of BSSIDs (each BSSID formatted as a MAC " + "address like 00:11:22:33:44:55') that have been " + "detected as part of the WiFI network. " + "NetworkManager internally tracks previously seen " + "BSSIDs. The property is only meant for reading " + "and reflects the BBSID list of NetworkManager. " + "The changes you make to this property will not be " + "preserved.", + DBUS_TYPE_G_LIST_OF_STRING, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE)); /** * NMSettingWireless:mtu: |