From: Jouni Malinen Date: Sun, 18 Jul 2010 21:30:25 +0000 (-0700) Subject: P2P: Use config block with disabled==2 to store persistent groups X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=4dac02455a5aa9c96051b13fed555eb294f1e28d;p=libeap.git P2P: Use config block with disabled==2 to store persistent groups --- diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index fa0d22c..dbbf5eb 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -1495,7 +1495,7 @@ static const struct parse_data ssid_fields[] = { #endif /* IEEE8021X_EAPOL */ { INT_RANGE(mode, 0, 4) }, { INT_RANGE(proactive_key_caching, 0, 1) }, - { INT_RANGE(disabled, 0, 1) }, + { INT_RANGE(disabled, 0, 2) }, { STR(id_str) }, #ifdef CONFIG_IEEE80211W { INT_RANGE(ieee80211w, 0, 2) }, diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 60800ce..68973d3 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -677,10 +677,12 @@ static int wpa_supplicant_ctrl_iface_list_networks( if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret; - ret = os_snprintf(pos, end - pos, "\t%s%s", + ret = os_snprintf(pos, end - pos, "\t%s%s%s", ssid == wpa_s->current_ssid ? "[CURRENT]" : "", - ssid->disabled ? "[DISABLED]" : ""); + ssid->disabled ? "[DISABLED]" : "", + ssid->disabled == 2 ? "[P2P-PERSISTENT]" : + ""); if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret; @@ -988,6 +990,11 @@ static int wpa_supplicant_ctrl_iface_select_network( "network id=%d", id); return -1; } + if (ssid->disabled == 2) { + wpa_printf(MSG_DEBUG, "CTRL_IFACE: Cannot use " + "SELECT_NETWORK with persistent P2P group"); + return -1; + } } wpa_supplicant_select_network(wpa_s, ssid); @@ -1016,6 +1023,11 @@ static int wpa_supplicant_ctrl_iface_enable_network( "network id=%d", id); return -1; } + if (ssid->disabled == 2) { + wpa_printf(MSG_DEBUG, "CTRL_IFACE: Cannot use " + "ENABLE_NETWORK with persistent P2P group"); + return -1; + } } wpa_supplicant_enable_network(wpa_s, ssid); @@ -1043,6 +1055,12 @@ static int wpa_supplicant_ctrl_iface_disable_network( "network id=%d", id); return -1; } + if (ssid->disabled == 2) { + wpa_printf(MSG_DEBUG, "CTRL_IFACE: Cannot use " + "DISABLE_NETWORK with persistent P2P " + "group"); + return -1; + } } wpa_supplicant_disable_network(wpa_s, ssid); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index df11814..53fbb96 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1387,8 +1387,11 @@ void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s, int was_disabled; if (ssid == NULL) { - other_ssid = wpa_s->conf->ssid; - while (other_ssid) { + for (other_ssid = wpa_s->conf->ssid; other_ssid; + other_ssid = other_ssid->next) { + if (other_ssid->disabled == 2) + continue; /* do not change persistent P2P group + * data */ if (other_ssid == wpa_s->current_ssid && other_ssid->disabled) wpa_s->reassociate = 1; @@ -1400,12 +1403,10 @@ void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s, if (was_disabled != other_ssid->disabled) wpas_notify_network_enabled_changed( wpa_s, other_ssid); - - other_ssid = other_ssid->next; } if (wpa_s->reassociate) wpa_supplicant_req_scan(wpa_s, 0, 0); - } else if (ssid->disabled) { + } else if (ssid->disabled && ssid->disabled != 2) { if (wpa_s->current_ssid == NULL) { /* * Try to reassociate since there is no current @@ -1439,22 +1440,23 @@ void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s, int was_disabled; if (ssid == NULL) { - other_ssid = wpa_s->conf->ssid; - while (other_ssid) { + for (other_ssid = wpa_s->conf->ssid; other_ssid; + other_ssid = other_ssid->next) { was_disabled = other_ssid->disabled; + if (was_disabled == 2) + continue; /* do not change persistent P2P group + * data */ other_ssid->disabled = 1; if (was_disabled != other_ssid->disabled) wpas_notify_network_enabled_changed( wpa_s, other_ssid); - - other_ssid = other_ssid->next; } if (wpa_s->current_ssid) wpa_supplicant_disassociate( wpa_s, WLAN_REASON_DEAUTH_LEAVING); - } else { + } else if (ssid->disabled != 2) { if (ssid == wpa_s->current_ssid) wpa_supplicant_disassociate( wpa_s, WLAN_REASON_DEAUTH_LEAVING); @@ -1488,16 +1490,16 @@ void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s, * Mark all other networks disabled or mark all networks enabled if no * network specified. */ - other_ssid = wpa_s->conf->ssid; - while (other_ssid) { + for (other_ssid = wpa_s->conf->ssid; other_ssid; + other_ssid = other_ssid->next) { int was_disabled = other_ssid->disabled; + if (was_disabled == 2) + continue; /* do not change persistent P2P group data */ other_ssid->disabled = ssid ? (ssid->id != other_ssid->id) : 0; if (was_disabled != other_ssid->disabled) wpas_notify_network_enabled_changed(wpa_s, other_ssid); - - other_ssid = other_ssid->next; } wpa_s->disconnected = 0; wpa_s->reassociate = 1;