[][MAC80211][hostapd][Refactor MBO patches and remove upstream patches]

[Description]
Fix build error after sync hostapd version to hostapd-2022-05-08-b859b9bc.
1. Fix MBO patches
2. Remove 912 patch which was already merged into hostapd

[Release-log]
N/A

Change-Id: I6d358320c7605322091cf00c8d8e14656262ff69
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6092329
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/905-master-Support-configuring-BSS-Termination-TSF-by-using-hos.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/905-master-Support-configuring-BSS-Termination-TSF-by-using-hos.patch
index f6832e3..ad9c926 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/905-master-Support-configuring-BSS-Termination-TSF-by-using-hos.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/905-master-Support-configuring-BSS-Termination-TSF-by-using-hos.patch
@@ -1,31 +1,21 @@
-From 56613ad9b568a3ac7467105beaa162c68ffbbf70 Mon Sep 17 00:00:00 2001
-From: "howard.hsu" <howard-yh.hsu@mediatek.com>
-Date: Wed, 19 Jan 2022 20:20:03 +0800
-Subject: [PATCH 4/9] Support configuring BSS Termination TSF by using
+From 6a949f8644546d689b7271228d19b1b1ad80632f Mon Sep 17 00:00:00 2001
+From: Howard Hsu <howard-yh.hsu@mediatek.com>
+Date: Thu, 9 Jun 2022 19:56:18 +0800
+Subject: [PATCH 1/6] Support configuring BSS Termination TSF by using
  hostapd_cli command
 
 ---
- hostapd/ctrl_iface.c | 9 +++++++++
- src/ap/ap_config.c   | 1 +
- src/ap/ap_config.h   | 1 +
- 3 files changed, 11 insertions(+)
+ hostapd/ctrl_iface.c   | 5 +++++
+ src/ap/ap_config.c     | 1 +
+ src/ap/ap_config.h     | 1 +
+ src/ap/ctrl_iface_ap.c | 4 ++++
+ 4 files changed, 11 insertions(+)
 
 diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
-index f50fafb..1b5a091 100644
+index 4718368..e0a7e4f 100644
 --- a/hostapd/ctrl_iface.c
 +++ b/hostapd/ctrl_iface.c
-@@ -954,6 +954,10 @@ static int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
- 			wpa_printf(MSG_DEBUG, "Invalid bss_term data");
- 			return -1;
- 		}
-+		if (hapd->conf->bss_termination_tsf) {
-+			WPA_PUT_LE64(&bss_term_dur[2], hapd->conf->bss_termination_tsf);
-+		}
-+
- 		end++;
- 		WPA_PUT_LE16(&bss_term_dur[10], atoi(end));
- 	}
-@@ -1589,6 +1593,11 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
+@@ -1326,6 +1326,11 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
  #endif /* CONFIG_DPP */
  	} else if (os_strcasecmp(cmd, "setband") == 0) {
  		ret = hostapd_ctrl_iface_set_band(hapd, value);
@@ -38,7 +28,7 @@
  		ret = hostapd_set_iface(hapd->iconf, hapd->conf, cmd, value);
  		if (ret)
 diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
-index 1f04686..078a3fc 100644
+index 23b67e1..f248281 100644
 --- a/src/ap/ap_config.c
 +++ b/src/ap/ap_config.c
 @@ -170,6 +170,7 @@ void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
@@ -50,10 +40,10 @@
  
  
 diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
-index f3aff36..7301bbb 100644
+index f795ee9..5dab8be 100644
 --- a/src/ap/ap_config.h
 +++ b/src/ap/ap_config.h
-@@ -549,6 +549,7 @@ struct hostapd_bss_config {
+@@ -557,6 +557,7 @@ struct hostapd_bss_config {
  	int wnm_sleep_mode;
  	int wnm_sleep_mode_no_keys;
  	int bss_transition;
@@ -61,6 +51,21 @@
  
  	/* IEEE 802.11u - Interworking */
  	int interworking;
+diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
+index c496e4f..aad5180 100644
+--- a/src/ap/ctrl_iface_ap.c
++++ b/src/ap/ctrl_iface_ap.c
+@@ -1202,6 +1202,10 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
+ 			wpa_printf(MSG_DEBUG, "Invalid bss_term data");
+ 			return -1;
+ 		}
++		if (hapd->conf->bss_termination_tsf) {
++			WPA_PUT_LE64(&bss_term_dur[2], hapd->conf->bss_termination_tsf);
++		}
++
+ 		end++;
+ 		WPA_PUT_LE16(&bss_term_dur[10], atoi(end));
+ 	}
 -- 
 2.18.0
 
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/908-master-Support-including-neighbor-report-elements-in-BTM-re.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/908-master-Support-including-neighbor-report-elements-in-BTM-re.patch
index 1bf102a..37f2d96 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/908-master-Support-including-neighbor-report-elements-in-BTM-re.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/908-master-Support-including-neighbor-report-elements-in-BTM-re.patch
@@ -1,17 +1,17 @@
-From 9043eff145701c6324ae48966301681adacb89c4 Mon Sep 17 00:00:00 2001
-From: "howard.hsu" <howard-yh.hsu@mediatek.com>
-Date: Wed, 19 Jan 2022 21:16:45 +0800
-Subject: [PATCH 7/9] Support including neighbor report elements in BTM request
+From e6f1c893d375aa952e1f9c8c1eb4ecacf588e4e2 Mon Sep 17 00:00:00 2001
+From: Howard Hsu <howard-yh.hsu@mediatek.com>
+Date: Thu, 9 Jun 2022 19:58:57 +0800
+Subject: [PATCH 4/6] Support including neighbor report elements in BTM request
 
 ---
- hostapd/ctrl_iface.c | 7 ++++++-
+ src/ap/ctrl_iface_ap.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
 
-diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
-index 1b5a091..5a82ae6 100644
---- a/hostapd/ctrl_iface.c
-+++ b/hostapd/ctrl_iface.c
-@@ -984,8 +984,13 @@ static int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
+diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
+index aad5180..fccc5f9 100644
+--- a/src/ap/ctrl_iface_ap.c
++++ b/src/ap/ctrl_iface_ap.c
+@@ -1232,8 +1232,13 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
  		req_mode |= WNM_BSS_TM_REQ_ESS_DISASSOC_IMMINENT;
  	}
  
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/909-master-Add-hostapd_neighbor_set_own_report_pref.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/909-master-Add-hostapd_neighbor_set_own_report_pref.patch
index 14571fe..f77deb2 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/909-master-Add-hostapd_neighbor_set_own_report_pref.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/909-master-Add-hostapd_neighbor_set_own_report_pref.patch
@@ -1,21 +1,19 @@
-From 6fc069a54efb892e486dfde59cb97e0023dbbf5d Mon Sep 17 00:00:00 2001
-From: "howard.hsu" <howard-yh.hsu@mediatek.com>
-Date: Wed, 19 Jan 2022 21:27:55 +0800
-Subject: [PATCH 8/9] Add hostapd_neighbor_set_own_report_pref()
+From 12b95b365372ca8167b8fdbfd192fcd4dcb11419 Mon Sep 17 00:00:00 2001
+From: Howard Hsu <howard-yh.hsu@mediatek.com>
+Date: Thu, 9 Jun 2022 20:00:49 +0800
+Subject: [PATCH 5/6] Add hostapd_neighbor_set_own_report_pref()
 
-If my own BSS is going to terminate itself, the preference value of neighbor
-report must be set to 0.
 ---
- hostapd/ctrl_iface.c |  5 ++++-
- src/ap/neighbor_db.c | 36 ++++++++++++++++++++++++++++++++++++
- src/ap/neighbor_db.h |  2 ++
- 3 files changed, 42 insertions(+), 1 deletion(-)
+ src/ap/ctrl_iface_ap.c |  6 +++++-
+ src/ap/neighbor_db.c   | 36 ++++++++++++++++++++++++++++++++++++
+ src/ap/neighbor_db.h   |  2 ++
+ 3 files changed, 43 insertions(+), 1 deletion(-)
 
-diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
-index 5a82ae6..3146a25 100644
---- a/hostapd/ctrl_iface.c
-+++ b/hostapd/ctrl_iface.c
-@@ -993,8 +993,11 @@ static int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
+diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
+index fccc5f9..d5d4e33 100644
+--- a/src/ap/ctrl_iface_ap.c
++++ b/src/ap/ctrl_iface_ap.c
+@@ -1241,8 +1241,12 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
  	}
  	if (os_strstr(cmd, " abridged=1"))
  		req_mode |= WNM_BSS_TM_REQ_ABRIDGED;
@@ -25,14 +23,15 @@
 +		/* Set own BSS neighbor report preference value as 0 */
 +		hostapd_neighbor_set_own_report_pref(hapd, nei_rep, nei_len, 0);
 +	}
++
  
  #ifdef CONFIG_MBO
  	pos = os_strstr(cmd, "mbo=");
 diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
-index ce6865d..bc1b163 100644
+index fabe64d..20a4417 100644
 --- a/src/ap/neighbor_db.c
 +++ b/src/ap/neighbor_db.c
-@@ -352,3 +352,39 @@ void hostapd_neighbor_set_own_report(struct hostapd_data *hapd)
+@@ -355,3 +355,39 @@ void hostapd_neighbor_set_own_report(struct hostapd_data *hapd)
  	wpabuf_free(nr);
  #endif /* NEED_AP_MLME */
  }
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/910-master-Add-hostapd_neighbor_set_pref_by_non_pref_chan.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/910-master-Add-hostapd_neighbor_set_pref_by_non_pref_chan.patch
index 632475c..8a9e47e 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/910-master-Add-hostapd_neighbor_set_pref_by_non_pref_chan.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/910-master-Add-hostapd_neighbor_set_pref_by_non_pref_chan.patch
@@ -1,22 +1,20 @@
-From 7aab6cf66cfb7dea480d16e312e0f0eb08e758ab Mon Sep 17 00:00:00 2001
-From: "howard.hsu" <howard-yh.hsu@mediatek.com>
-Date: Wed, 19 Jan 2022 21:32:17 +0800
-Subject: [PATCH 9/9] Add hostapd_neighbor_set_pref_by_non_pref_chan()
+From be49aa855a83b3bb0c6a96380960b54cbdabcb56 Mon Sep 17 00:00:00 2001
+From: Howard Hsu <howard-yh.hsu@mediatek.com>
+Date: Thu, 9 Jun 2022 20:02:06 +0800
+Subject: [PATCH 6/6] Add hostapd_neighbor_set_pref_by_non_pref_chan()
 
-The preference value of neighbor report shall be modified according to struct
-non_pref_chan_info.
 ---
- hostapd/ctrl_iface.c |  2 ++
- src/ap/neighbor_db.c | 51 ++++++++++++++++++++++++++++++++++++++++++++
- src/ap/neighbor_db.h |  4 ++++
+ src/ap/ctrl_iface_ap.c |  2 ++
+ src/ap/neighbor_db.c   | 51 ++++++++++++++++++++++++++++++++++++++++++
+ src/ap/neighbor_db.h   |  4 ++++
  3 files changed, 57 insertions(+)
 
-diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
-index 3146a25..974e5b9 100644
---- a/hostapd/ctrl_iface.c
-+++ b/hostapd/ctrl_iface.c
-@@ -1000,6 +1000,8 @@ static int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
- 	}
+diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
+index d5d4e33..a888b76 100644
+--- a/src/ap/ctrl_iface_ap.c
++++ b/src/ap/ctrl_iface_ap.c
+@@ -1249,6 +1249,8 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
+ 
  
  #ifdef CONFIG_MBO
 +	hostapd_neighbor_set_pref_by_non_pref_chan(hapd, sta, nei_rep, nei_len);
@@ -25,10 +23,10 @@
  	if (pos) {
  		unsigned int mbo_reason, cell_pref, reassoc_delay;
 diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
-index bc1b163..75b6fcc 100644
+index 20a4417..8c27da9 100644
 --- a/src/ap/neighbor_db.c
 +++ b/src/ap/neighbor_db.c
-@@ -388,3 +388,54 @@ void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_b
+@@ -391,3 +391,54 @@ void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_b
  		}
  	}
  }
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/912-master-add-the-destination-address-of-unsolicited-Probe.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/912-master-add-the-destination-address-of-unsolicited-Probe.patch
deleted file mode 100644
index e9b630f..0000000
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/912-master-add-the-destination-address-of-unsolicited-Probe.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From 96a7f383290f78e15f1e7a5bc33099c81f104c5b Mon Sep 17 00:00:00 2001
-From: MeiChia Chiu <meichia.chiu@mediatek.com>
-Date: Fri, 6 May 2022 11:02:36 +0800
-Subject: hostapd: Add the destination address of unsolicited Probe Response
- frame
-
-Without this, hostapd generates Probe Response frames with the null
-destination address when hostapd enables unsolicited Probe Response
-frame transmission. Fix this to use the broadcast address instead.
-
-Fixes: 024b4b2a298f ("AP: Unsolicited broadcast Probe Response configuration")
-Signed-off-by: MeiChia Chiu <meichia.chiu@mediatek.com>
----
- src/ap/beacon.c | 13 +++++++++----
- 1 file changed, 9 insertions(+), 4 deletions(-)
-
-diff --git a/src/ap/beacon.c b/src/ap/beacon.c
-index eaa403326..58872bfda 100644
---- a/src/ap/beacon.c
-+++ b/src/ap/beacon.c
-@@ -464,7 +464,8 @@ static u8 * hostapd_eid_supported_op_classes(struct hostapd_data *hapd, u8 *eid)
- 
- static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
- 				   const struct ieee80211_mgmt *req,
--				   int is_p2p, size_t *resp_len)
-+				   int is_p2p, size_t *resp_len,
-+				   bool bcast_probe_resp)
- {
- 	struct ieee80211_mgmt *resp;
- 	u8 *pos, *epos, *csa_pos;
-@@ -531,6 +532,9 @@ static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
- 					   WLAN_FC_STYPE_PROBE_RESP);
- 	if (req)
- 		os_memcpy(resp->da, req->sa, ETH_ALEN);
-+	else if (bcast_probe_resp)
-+		os_memset(resp->da, 0xff, ETH_ALEN);
-+
- 	os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
- 
- 	os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
-@@ -1141,7 +1145,7 @@ void handle_probe_req(struct hostapd_data *hapd,
- 		     " signal=%d", MAC2STR(mgmt->sa), ssi_signal);
- 
- 	resp = hostapd_gen_probe_resp(hapd, mgmt, elems.p2p != NULL,
--				      &resp_len);
-+				      &resp_len, false);
- 	if (resp == NULL)
- 		return;
- 
-@@ -1210,7 +1214,7 @@ static u8 * hostapd_probe_resp_offloads(struct hostapd_data *hapd,
- 			   "this");
- 
- 	/* Generate a Probe Response template for the non-P2P case */
--	return hostapd_gen_probe_resp(hapd, NULL, 0, resp_len);
-+	return hostapd_gen_probe_resp(hapd, NULL, 0, resp_len, false);
- }
- 
- #endif /* NEED_AP_MLME */
-@@ -1228,7 +1232,8 @@ static u8 * hostapd_unsol_bcast_probe_resp(struct hostapd_data *hapd,
- 		hapd->conf->unsol_bcast_probe_resp_interval;
- 
- 	return hostapd_gen_probe_resp(hapd, NULL, 0,
--				      &params->unsol_bcast_probe_resp_tmpl_len);
-+				      &params->unsol_bcast_probe_resp_tmpl_len,
-+				      true);
- }
- #endif /* CONFIG_IEEE80211AX */
- 
--- 
-cgit v1.2.3-18-g5258
-