From 86184b93c52c21ad3bd56d185634a4704f9e98c9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 24 Jun 2014 15:03:55 +0200 Subject: [PATCH] staging: rtl8723au: rtw_restruct_wmm_ie23a(): Use cfg80211_find_vendor_ie() Rewrite rtw_restruct_wmm_ie23a() using cfg80211_find_vendor_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- 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; -- 2.7.4