diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index b133d0384..4f895f34c 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -214,6 +214,13 @@ static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s, if (wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf)) return -1; + if (ssid->pbss > 1) { + wpa_printf(MSG_ERROR, "Invalid pbss value(%d) for AP mode", + ssid->pbss); + return -1; + } + bss->pbss = ssid->pbss; + #ifdef CONFIG_ACS if (ssid->acs) { /* Setting channel to 0 in order to enable ACS */ @@ -453,8 +460,6 @@ no_wps: wpabuf_dup(wpa_s->conf->ap_vendor_elements); } - bss->pbss = ssid->pbss; - return 0; } diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index c167f09b2..7ecc5b09d 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2048,7 +2048,7 @@ static const struct parse_data ssid_fields[] = { { INT(update_identifier) }, #endif /* CONFIG_HS20 */ { INT_RANGE(mac_addr, 0, 2) }, - { INT_RANGE(pbss, 0, 1) }, + { INT_RANGE(pbss, 0, 2) }, }; #undef OFFSET diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h index eb7b87be3..c2af91df0 100644 --- a/wpa_supplicant/config_ssid.h +++ b/wpa_supplicant/config_ssid.h @@ -361,10 +361,14 @@ struct wpa_ssid { /** * pbss - Whether to use PBSS. Relevant to DMG networks only. + * 0 = do not use PBSS + * 1 = use PBSS + * 2 = don't care (not allowed in AP mode) * Used together with mode configuration. When mode is AP, it * means to start a PCP instead of a regular AP. When mode is INFRA it - * means connect to a PCP instead of AP. P2P_GO and P2P_GROUP_FORMATION - * modes must use PBSS in DMG network. + * means connect to a PCP instead of AP. In this mode you can also + * specify 2 (don't care) meaning connect to either AP or PCP. + * P2P_GO and P2P_GROUP_FORMATION modes must use PBSS in DMG network. */ int pbss; diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index eb330ddad..4c1bf7b8d 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1006,7 +1006,7 @@ struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, continue; } - if (ssid->pbss != bss_is_pbss(bss)) { + if (ssid->pbss != 2 && ssid->pbss != bss_is_pbss(bss)) { wpa_dbg(wpa_s, MSG_DEBUG, " skip - PBSS mismatch (ssid %d bss %d)", ssid->pbss, bss_is_pbss(bss)); continue; diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 51bb2457e..3f1d08b83 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -2414,7 +2414,7 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit) } else { params.ssid = ssid->ssid; params.ssid_len = ssid->ssid_len; - params.pbss = ssid->pbss; + params.pbss = (ssid->pbss != 2) ? ssid->pbss : 0; } if (ssid->mode == WPAS_MODE_IBSS && ssid->bssid_set && diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index e55b380fe..a385694e5 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -717,10 +717,14 @@ fast_reauth=1 # the network will be used instead of this configured value. # # pbss: Whether to use PBSS. Relevant to IEEE 802.11ad networks only. +# 0 = do not use PBSS +# 1 = use PBSS +# 2 = don't care (not allowed in AP mode) # Used together with mode configuration. When mode is AP, it means to start a # PCP instead of a regular AP. When mode is infrastructure it means connect -# to a PCP instead of AP. P2P_GO and P2P_GROUP_FORMATION modes must use PBSS -# in IEEE 802.11ad network. +# to a PCP instead of AP. In this mode you can also specify 2 (don't care) +# which means connect to either PCP or AP. +# P2P_GO and P2P_GROUP_FORMATION modes must use PBSS in IEEE 802.11ad network. # For more details, see IEEE Std 802.11ad-2012. # # scan_freq: List of frequencies to scan diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index 0860eb40b..74a420c67 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -1142,6 +1142,13 @@ int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid, return -1; ssid->temporary = 1; ssid->p2p_group = p2p_group; + /* + * When starting a regular WPS process (not P2P group formation) + * the registrar/final station can be either AP or PCP + * so use a "don't care" value for the pbss flag. + */ + if (!p2p_group) + ssid->pbss = 2; #ifdef CONFIG_P2P if (p2p_group && wpa_s->go_params && wpa_s->go_params->ssid_len) { ssid->ssid = os_zalloc(wpa_s->go_params->ssid_len + 1); @@ -1197,6 +1204,13 @@ static int wpas_wps_start_dev_pw(struct wpa_supplicant *wpa_s, } ssid->temporary = 1; ssid->p2p_group = p2p_group; + /* + * When starting a regular WPS process (not P2P group formation) + * the registrar/final station can be either AP or PCP + * so use a "don't care" value for the pbss flag. + */ + if (!p2p_group) + ssid->pbss = 2; if (ssid_val) { ssid->ssid = os_malloc(ssid_len); if (ssid->ssid) {