staging: rtl8723au: rtw_restruct_wmm_ie23a(): Use cfg80211_find_vendor_ie()
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 24 Jun 2014 13:03:55 +0000 (15:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Jun 2014 17:51:02 +0000 (13:51 -0400)
Rewrite rtw_restruct_wmm_ie23a() using cfg80211_find_vendor_ie()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_mlme.c

index b3db56ab3a6613aba578d177cc00176abc4e5714..d0e9b660844b5973a2260a63308063213297fb0e 100644 (file)
@@ -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;