summaryrefslogtreecommitdiff
path: root/src/devices/wifi/nm-wifi-ap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/wifi/nm-wifi-ap.c')
-rw-r--r--src/devices/wifi/nm-wifi-ap.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c
index f4ad7e864..fe615be81 100644
--- a/src/devices/wifi/nm-wifi-ap.c
+++ b/src/devices/wifi/nm-wifi-ap.c
@@ -1232,7 +1232,7 @@ nm_wifi_ap_new_fake_from_connection (NMConnection *connection)
const char *mode, *band, *key_mgmt;
guint32 channel;
NM80211ApSecurityFlags flags;
- gboolean psk = FALSE, eap = FALSE;
+ gboolean psk = FALSE, eap = FALSE, adhoc = FALSE;
g_return_val_if_fail (connection != NULL, NULL);
@@ -1252,9 +1252,10 @@ nm_wifi_ap_new_fake_from_connection (NMConnection *connection)
if (mode) {
if (!strcmp (mode, "infrastructure"))
nm_wifi_ap_set_mode (ap, NM_802_11_MODE_INFRA);
- else if (!strcmp (mode, "adhoc"))
+ else if (!strcmp (mode, "adhoc")) {
nm_wifi_ap_set_mode (ap, NM_802_11_MODE_ADHOC);
- else if (!strcmp (mode, "mesh"))
+ adhoc = TRUE;
+ } else if (!strcmp (mode, "mesh"))
nm_wifi_ap_set_mode (ap, NM_802_11_MODE_MESH);
else if (!strcmp (mode, "ap")) {
nm_wifi_ap_set_mode (ap, NM_802_11_MODE_INFRA);
@@ -1293,7 +1294,7 @@ nm_wifi_ap_new_fake_from_connection (NMConnection *connection)
psk = !strcmp (key_mgmt, "wpa-psk");
eap = !strcmp (key_mgmt, "wpa-eap");
- if (psk || eap) {
+ if (!adhoc && (psk || eap)) {
if (has_proto (s_wireless_sec, PROTO_WPA)) {
flags = priv->wpa_flags | (eap ? NM_802_11_AP_SEC_KEY_MGMT_802_1X : NM_802_11_AP_SEC_KEY_MGMT_PSK);
nm_wifi_ap_set_wpa_flags (ap, flags);
@@ -1305,8 +1306,27 @@ nm_wifi_ap_new_fake_from_connection (NMConnection *connection)
add_pair_ciphers (ap, s_wireless_sec);
add_group_ciphers (ap, s_wireless_sec);
+ } else if (adhoc && psk) {
+ /* Ad-Hoc has special requirements: proto=RSN, pairwise=CCMP and
+ * group=CCMP.
+ */
+ flags = priv->wpa_flags | NM_802_11_AP_SEC_KEY_MGMT_PSK;
+
+ /* Clear ciphers; only CCMP is supported */
+ flags &= ~( NM_802_11_AP_SEC_PAIR_WEP40
+ | NM_802_11_AP_SEC_PAIR_WEP104
+ | NM_802_11_AP_SEC_PAIR_TKIP
+ | NM_802_11_AP_SEC_GROUP_WEP40
+ | NM_802_11_AP_SEC_GROUP_WEP104
+ | NM_802_11_AP_SEC_GROUP_TKIP);
+
+ flags |= NM_802_11_AP_SEC_PAIR_CCMP;
+ flags |= NM_802_11_AP_SEC_GROUP_CCMP;
+ nm_wifi_ap_set_rsn_flags (ap, flags);
+
+ /* Don't use Ad-Hoc WPA (WPA-none) anymore */
+ nm_wifi_ap_set_wpa_flags (ap, NM_802_11_AP_SEC_NONE);
}
-
done:
return ap;