Cumulative patch from commit a05e236b11bfb4dacfc269938181104a6303247c

a05e236 P2P: Do not re-start invitation on Probe Req RX if already ack'ed
e8a1572 The hostap.git master branch is now used for 2.2 development
94ff22e Remove dead code from AP setup
0b5ff2a WPS: Remove unused Credential AP Channel processing
1536cb5 WPS: Remove unused 802.1X attribute parsing and processing
b37d582 Replace ieee802_11_print_ssid() with wpa_ssid_txt()
93ee302 Change version information for the 2.1 release
44f967c Update ChangeLog files to match current implementation

Change-Id: If2602b7bd484c957652d72b9bd80a3d830392fd5
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c
index 537aac3..3c14bb7 100644
--- a/wpa_supplicant/wps_supplicant.c
+++ b/wpa_supplicant/wps_supplicant.c
@@ -489,9 +489,6 @@
 
 	wpas_wps_security_workaround(wpa_s, ssid, cred);
 
-	if (cred->ap_channel)
-		wpa_s->wps_ap_channel = cred->ap_channel;
-
 	wpas_wps_remove_dup_network(wpa_s, ssid);
 
 #ifndef CONFIG_NO_CONFIG_WRITE
@@ -2197,8 +2194,6 @@
 static int wpas_wps_use_cred(struct wpa_supplicant *wpa_s,
 			     struct wps_parse_attr *attr)
 {
-	wpa_s->wps_ap_channel = 0;
-
 	/*
 	 * Disable existing networks temporarily to allow the newly learned
 	 * credential to be preferred. Enable the temporarily disabled networks
@@ -2214,18 +2209,8 @@
 	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
 		return 0;
 
-	if (!wpa_s->wps_ap_channel && attr->ap_channel) {
-		wpa_s->wps_ap_channel = WPA_GET_BE16(attr->ap_channel);
-		wpa_printf(MSG_DEBUG, "WPS: Credential container indicated AP Channel %d",
-			   wpa_s->wps_ap_channel);
-	}
-
-	wpa_printf(MSG_DEBUG, "WPS: Request reconnection with new network "
-		   "based on the received credential added");
-	wpa_s->normal_scans = 0;
-	wpa_supplicant_reinit_autoscan(wpa_s);
-	if (wpa_s->wps_ap_channel) {
-		u16 chan = wpa_s->wps_ap_channel;
+	if (attr->ap_channel) {
+		u16 chan = WPA_GET_BE16(attr->ap_channel);
 		int freq = 0;
 
 		if (chan >= 1 && chan <= 13)
@@ -2236,12 +2221,17 @@
 			freq = 5000 + 5 * chan;
 
 		if (freq) {
-			wpa_printf(MSG_DEBUG, "WPS: Credential indicated "
-				   "AP channel %u -> %u MHz", chan, freq);
+			wpa_printf(MSG_DEBUG, "WPS: Credential container indicated AP channel %u -> %u MHz",
+				   chan, freq);
 			wpa_s->after_wps = 5;
 			wpa_s->wps_freq = freq;
 		}
 	}
+
+	wpa_printf(MSG_DEBUG, "WPS: Request reconnection with new network "
+		   "based on the received credential added");
+	wpa_s->normal_scans = 0;
+	wpa_supplicant_reinit_autoscan(wpa_s);
 	wpa_s->disconnected = 0;
 	wpa_s->reassociate = 1;