Accumulative patch from commit 6d28fb9627155929012cda944aacd5a52ce7051a

nl80211: Fetch assoc_freq from scan table for connect event
nl80211: Filter out duplicated BSS table entries from scan results
Update BSS table entry if roaming event indicates frequency change
WPS: Remove obsolete note about lack for WPS ER support
P2P: Include operating class 124 (channels 149,153,157,161)
Include nl80211 driver wrapper in default configuration for hostapd
Better messages when channel cannot be used in AP mode
WPS: Add a workaround for Windows 7 capability discovery for PBC
WPS UPnP: Fix UPnP initialization for non-bridge case with some drivers
Fix regression in RSN pre-authentication candidate list generation
  commit 6d28fb9627155929012cda944aacd5a52ce7051a

Change-Id: I3c68dad5fe323b1d86aa585c564a75e4fc1a2ea1
diff --git a/wpa_supplicant/README-WPS b/wpa_supplicant/README-WPS
index 6aa3a7b..93184e4 100644
--- a/wpa_supplicant/README-WPS
+++ b/wpa_supplicant/README-WPS
@@ -47,9 +47,7 @@
 
 wpa_supplicant includes an optional WPS component that can be used as
 an Enrollee to enroll new network credential or as a Registrar to
-configure an AP. The current version of wpa_supplicant does not
-support operation as an external WLAN Management Registrar for adding
-new client devices or configuring the AP over UPnP.
+configure an AP.
 
 
 wpa_supplicant configuration
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index c540bd4..495f81d 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -757,28 +757,25 @@
 /* TODO: move the rsn_preauth_scan_result*() to be called from notify.c based
  * on BSS added and BSS changed events */
 static void wpa_supplicant_rsn_preauth_scan_results(
-	struct wpa_supplicant *wpa_s, struct wpa_scan_results *scan_res)
+	struct wpa_supplicant *wpa_s)
 {
-	int i;
+	struct wpa_bss *bss;
 
 	if (rsn_preauth_scan_results(wpa_s->wpa) < 0)
 		return;
 
-	for (i = scan_res->num - 1; i >= 0; i--) {
+	dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
 		const u8 *ssid, *rsn;
-		struct wpa_scan_res *r;
 
-		r = scan_res->res[i];
-
-		ssid = wpa_scan_get_ie(r, WLAN_EID_SSID);
+		ssid = wpa_bss_get_ie(bss, WLAN_EID_SSID);
 		if (ssid == NULL)
 			continue;
 
-		rsn = wpa_scan_get_ie(r, WLAN_EID_RSN);
+		rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
 		if (rsn == NULL)
 			continue;
 
-		rsn_preauth_scan_result(wpa_s->wpa, r->bssid, ssid, rsn);
+		rsn_preauth_scan_result(wpa_s->wpa, bss->bssid, ssid, rsn);
 	}
 
 }
@@ -946,8 +943,6 @@
 		return 0;
 	}
 
-	wpa_supplicant_rsn_preauth_scan_results(wpa_s, scan_res);
-
 	selected = wpa_supplicant_pick_network(wpa_s, scan_res, &ssid);
 
 	if (selected) {
@@ -958,6 +953,7 @@
 		if (skip)
 			return 0;
 		wpa_supplicant_connect(wpa_s, selected, ssid);
+		wpa_supplicant_rsn_preauth_scan_results(wpa_s);
 	} else {
 		wpa_scan_results_free(scan_res);
 		wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found");
@@ -965,6 +961,7 @@
 		if (ssid) {
 			wpa_dbg(wpa_s, MSG_DEBUG, "Setup a new network");
 			wpa_supplicant_associate(wpa_s, NULL, ssid);
+			wpa_supplicant_rsn_preauth_scan_results(wpa_s);
 		} else {
 			int timeout_sec = wpa_s->scan_interval;
 			int timeout_usec = 0;
@@ -1186,6 +1183,14 @@
 	if (wpa_found || rsn_found)
 		wpa_s->ap_ies_from_associnfo = 1;
 
+	if (wpa_s->assoc_freq && data->assoc_info.freq &&
+	    wpa_s->assoc_freq != data->assoc_info.freq) {
+		wpa_printf(MSG_DEBUG, "Operating frequency changed from "
+			   "%u to %u MHz",
+			   wpa_s->assoc_freq, data->assoc_info.freq);
+		wpa_supplicant_update_scan_results(wpa_s);
+	}
+
 	wpa_s->assoc_freq = data->assoc_info.freq;
 
 	return 0;
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index d7f7473..03d1672 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -3110,7 +3110,7 @@
 		wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on configured "
 			   "frequency %d MHz", params->freq);
 	} else if (wpa_s->conf->p2p_oper_reg_class == 115 ||
-		   wpa_s->conf->p2p_oper_reg_class == 118) {
+		   wpa_s->conf->p2p_oper_reg_class == 124) {
 		params->freq = 5000 + 5 * wpa_s->conf->p2p_oper_channel;
 		wpa_printf(MSG_DEBUG, "P2P: Set GO freq based on configured "
 			   "frequency %d MHz", params->freq);