From: Jes Sorensen <jes.soren...@redhat.com>

Rewrite rtw_restruct_wmm_ie23a() using cfg80211_find_vendor_ie()

Signed-off-by: Jes Sorensen <jes.soren...@redhat.com>
---
 drivers/staging/rtl8723au/core/rtw_mlme.c | 34 ++++++++++++-------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c 
b/drivers/staging/rtl8723au/core/rtw_mlme.c
index b3db56a..d0e9b66 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme.c
@@ -1909,33 +1909,25 @@ exit:
 
 /* adjust IEs for rtw_joinbss_cmd23a in WMM */
 int rtw_restruct_wmm_ie23a(struct rtw_adapter *adapter, u8 *in_ie,
-                       u8 *out_ie, uint in_len, uint initial_out_len)
+                          u8 *out_ie, uint in_len, uint initial_out_len)
 {
-       unsigned int ielength = 0;
-       unsigned int i, j;
+       int ielength;
+       const u8 *p;
 
-       i = 0; /* after the fixed IE */
-       while (i < in_len) {
-               ielength = initial_out_len;
+       ielength = initial_out_len;
 
-               /* WMM element ID and OUI */
-               if (in_ie[i] == 0xDD && in_ie[i + 2] == 0x00 &&
-                   in_ie[i + 3] == 0x50 && in_ie[i + 4] == 0xF2 &&
-                   in_ie[i + 5] == 0x02 && i+5 < in_len) {
+       p = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
+                                   WLAN_OUI_TYPE_MICROSOFT_WMM,
+                                   in_ie, in_len);
 
-                       /* Append WMM IE to the last index of out_ie */
-                        for (j = i; j < i + 9; j++) {
-                               out_ie[ielength] = in_ie[j];
-                               ielength++;
-                        }
-                        out_ie[initial_out_len + 1] = 0x07;
-                        out_ie[initial_out_len + 6] = 0x00;
-                        out_ie[initial_out_len + 8] = 0x00;
+       if (p && p[1]) {
+               memcpy(out_ie + initial_out_len, p, 9);
 
-                       break;
-               }
+               out_ie[initial_out_len + 1] = 7;
+               out_ie[initial_out_len + 6] = 0;
+               out_ie[initial_out_len + 8] = 0;
 
-               i += (in_ie[i + 1] + 2); /*  to the next IE element */
+               ielength += 9;
        }
 
        return ielength;
-- 
1.9.3

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to