diff options
author | Dan Williams <dcbw@redhat.com> | 2012-10-12 14:38:49 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2012-10-17 14:07:37 -0500 |
commit | e6bdb8bc5592396f6c12167446a08854d368ed93 (patch) | |
tree | 84ddd04b4a771095699a6d45431b359db609795b /libnm-util/nm-utils.c | |
parent | 7c34a37e73104b8b529247fe7edb8ca7855dbd6d (diff) | |
download | NetworkManager-e6bdb8bc5592396f6c12167446a08854d368ed93.tar.gz |
libnm-util: add methods for AP-mode security filtering
Add a helper like nm_utils_security_valid() except for access point
mode. We can't use nm_utils_security_valid() without changing the
arguments, hence the new function. Plus in AP mode all you care about
are the device capabilities, not AP flags since the device *is*
the AP.
Diffstat (limited to 'libnm-util/nm-utils.c')
-rw-r--r-- | libnm-util/nm-utils.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c index 526e565540..f18d55d1b9 100644 --- a/libnm-util/nm-utils.c +++ b/libnm-util/nm-utils.c @@ -1203,6 +1203,42 @@ device_supports_ap_ciphers (guint32 dev_caps, } /** + * nm_utils_ap_mode_security_valid: + * @type: the security type to check AP flags and device capabilties against, + * e.g. #NMU_SEC_STATIC_WEP + * @wifi_caps: bitfield of the capabilities of the specific WiFi device, e.g. + * #NM_WIFI_DEVICE_CAP_CIPHER_WEP40 + * + * Given a set of device capabilities, and a desired security type to check + * against, determines whether the combination of device capabilities and + * desired security type are valid for AP/Hotspot connections. + * + * Returns: TRUE if the device capabilities are compatible with the desired + * @type, FALSE if they are not. + **/ +gboolean +nm_utils_ap_mode_security_valid (NMUtilsSecurityType type, + NMDeviceWifiCapabilities wifi_caps) +{ + if (!(wifi_caps & NM_WIFI_DEVICE_CAP_AP)) + return FALSE; + + /* Return TRUE for any security that wpa_supplicant's lightweight AP + * mode can handle: which is open, WEP, and WPA/WPA2 PSK. + */ + switch (type) { + case NMU_SEC_NONE: + case NMU_SEC_STATIC_WEP: + case NMU_SEC_WPA_PSK: + case NMU_SEC_WPA2_PSK: + return TRUE; + default: + break; + } + return FALSE; +} + +/** * nm_utils_security_valid: * @type: the security type to check AP flags and device capabilties against, * e.g. #NMU_SEC_STATIC_WEP @@ -1220,6 +1256,9 @@ device_supports_ap_ciphers (guint32 dev_caps, * against, determines whether the combination of device, desired security * type, and AP capabilities intersect. * + * NOTE: this function cannot handle checking security for AP/Hotspot mode; + * use nm_utils_wifi_ap_mode_security_valid() instead. + * * Returns: TRUE if the device capabilities and AP capabilties intersect and are * compatible with the desired @type, FALSE if they are not **/ |