Commit f9df1ea1 authored by Jes Sorensen's avatar Jes Sorensen Committed by Greg Kroah-Hartman

staging: rtl8723au: process_80211d() use cfg80211_find_ie()

Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7ffdc3f5
...@@ -4721,7 +4721,8 @@ unsigned int receive_disconnect23a(struct rtw_adapter *padapter, unsigned char * ...@@ -4721,7 +4721,8 @@ unsigned int receive_disconnect23a(struct rtw_adapter *padapter, unsigned char *
return _SUCCESS; return _SUCCESS;
} }
static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *bssid) static void process_80211d(struct rtw_adapter *padapter,
struct wlan_bssid_ex *bssid)
{ {
struct registry_priv *pregistrypriv; struct registry_priv *pregistrypriv;
struct mlme_ext_priv *pmlmeext; struct mlme_ext_priv *pmlmeext;
...@@ -4734,10 +4735,8 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b ...@@ -4734,10 +4735,8 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
/* Adjust channel plan by AP Country IE */ /* Adjust channel plan by AP Country IE */
if (pregistrypriv->enable80211d && if (pregistrypriv->enable80211d &&
(!pmlmeext->update_channel_plan_by_ap_done)) !pmlmeext->update_channel_plan_by_ap_done) {
{ const u8 *ie, *p;
u8 *ie, *p;
u32 len;
struct rt_channel_plan chplan_ap; struct rt_channel_plan chplan_ap;
struct rt_channel_info chplan_sta[MAX_CHANNEL_NUM]; struct rt_channel_info chplan_sta[MAX_CHANNEL_NUM];
u8 country[4]; u8 country[4];
...@@ -4745,33 +4744,34 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b ...@@ -4745,33 +4744,34 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
u8 noc; /* number of channel */ u8 noc; /* number of channel */
u8 j, k; u8 j, k;
ie = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, ie = cfg80211_find_ie(WLAN_EID_COUNTRY,
WLAN_EID_COUNTRY, &len, bssid->IEs + _FIXED_IE_LENGTH_,
bssid->IELength - _FIXED_IE_LENGTH_); bssid->IELength - _FIXED_IE_LENGTH_);
if (!ie) return; if (!ie || ie[1] < IEEE80211_COUNTRY_IE_MIN_LEN)
if (len < 6) return; return;
ie += 2; ie += 2;
p = ie; p = ie;
ie += len; ie += ie[1];
memset(country, 0, 4);
memcpy(country, p, 3); memcpy(country, p, 3);
country[3] = '\0';
p += 3; p += 3;
RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
("%s: 802.11d country =%s\n", __func__, country)); ("%s: 802.11d country =%s\n", __func__, country));
i = 0; i = 0;
while ((ie - p) >= 3) while ((ie - p) >= 3) {
{
fcn = *(p++); fcn = *(p++);
noc = *(p++); noc = *(p++);
p++; p++;
for (j = 0; j < noc; j++) for (j = 0; j < noc; j++) {
{ if (fcn <= 14)
if (fcn <= 14) channel = fcn + j; /* 2.4 GHz */ channel = fcn + j; /* 2.4 GHz */
else channel = fcn + j*4; /* 5 GHz */ else
channel = fcn + j * 4; /* 5 GHz */
chplan_ap.Channel[i++] = channel; chplan_ap.Channel[i++] = channel;
} }
...@@ -4785,45 +4785,55 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b ...@@ -4785,45 +4785,55 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
i = j = k = 0; i = j = k = 0;
if (pregistrypriv->wireless_mode & WIRELESS_11G) { if (pregistrypriv->wireless_mode & WIRELESS_11G) {
do { do {
if ((i == MAX_CHANNEL_NUM) || if (i == MAX_CHANNEL_NUM ||
(chplan_sta[i].ChannelNum == 0) || chplan_sta[i].ChannelNum == 0 ||
(chplan_sta[i].ChannelNum > 14)) chplan_sta[i].ChannelNum > 14)
break; break;
if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] > 14)) if (j == chplan_ap.Len ||
chplan_ap.Channel[j] > 14)
break; break;
if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) { if (chplan_sta[i].ChannelNum ==
chplan_new[k].ChannelNum = chplan_ap.Channel[j]; chplan_ap.Channel[j]) {
chplan_new[k].ChannelNum =
chplan_ap.Channel[j];
chplan_new[k].ScanType = SCAN_ACTIVE; chplan_new[k].ScanType = SCAN_ACTIVE;
i++; i++;
j++; j++;
k++; k++;
} else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) { } else if (chplan_sta[i].ChannelNum <
chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; chplan_ap.Channel[j]) {
chplan_new[k].ScanType = SCAN_PASSIVE; chplan_new[k].ChannelNum =
chplan_sta[i].ChannelNum;
chplan_new[k].ScanType =
SCAN_PASSIVE;
i++; i++;
k++; k++;
} else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) { } else if (chplan_sta[i].ChannelNum >
chplan_new[k].ChannelNum = chplan_ap.Channel[j]; chplan_ap.Channel[j]) {
chplan_new[k].ScanType = SCAN_ACTIVE; chplan_new[k].ChannelNum =
chplan_ap.Channel[j];
chplan_new[k].ScanType =
SCAN_ACTIVE;
j++; j++;
k++; k++;
} }
} while (1); } while (1);
/* change AP not support channel to Passive scan */ /* change AP not support channel to Passive scan */
while ((i < MAX_CHANNEL_NUM) && while (i < MAX_CHANNEL_NUM &&
(chplan_sta[i].ChannelNum != 0) && chplan_sta[i].ChannelNum != 0 &&
(chplan_sta[i].ChannelNum <= 14)) { chplan_sta[i].ChannelNum <= 14) {
chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; chplan_new[k].ChannelNum =
chplan_sta[i].ChannelNum;
chplan_new[k].ScanType = SCAN_PASSIVE; chplan_new[k].ScanType = SCAN_PASSIVE;
i++; i++;
k++; k++;
} }
/* add channel AP supported */ /* add channel AP supported */
while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) { while (j < chplan_ap.Len && chplan_ap.Channel[j] <= 14){
chplan_new[k].ChannelNum = chplan_ap.Channel[j]; chplan_new[k].ChannelNum = chplan_ap.Channel[j];
chplan_new[k].ScanType = SCAN_ACTIVE; chplan_new[k].ScanType = SCAN_ACTIVE;
j++; j++;
...@@ -4831,49 +4841,50 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b ...@@ -4831,49 +4841,50 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
} }
} else { } else {
/* keep original STA 2.4G channel plan */ /* keep original STA 2.4G channel plan */
while ((i < MAX_CHANNEL_NUM) && while (i < MAX_CHANNEL_NUM &&
(chplan_sta[i].ChannelNum != 0) && chplan_sta[i].ChannelNum != 0 &&
(chplan_sta[i].ChannelNum <= 14)) { chplan_sta[i].ChannelNum <= 14) {
chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; chplan_new[k].ChannelNum =
chplan_sta[i].ChannelNum;
chplan_new[k].ScanType = chplan_sta[i].ScanType; chplan_new[k].ScanType = chplan_sta[i].ScanType;
i++; i++;
k++; k++;
} }
/* skip AP 2.4G channel plan */ /* skip AP 2.4G channel plan */
while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) { while (j < chplan_ap.Len && chplan_ap.Channel[j] <= 14)
j++; j++;
}
} }
if (pregistrypriv->wireless_mode & WIRELESS_11A) { if (pregistrypriv->wireless_mode & WIRELESS_11A) {
do { do {
if ((i == MAX_CHANNEL_NUM) || if (i == MAX_CHANNEL_NUM ||
(chplan_sta[i].ChannelNum == 0)) chplan_sta[i].ChannelNum == 0)
break; break;
if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] == 0)) if (j == chplan_ap.Len ||
chplan_ap.Channel[j] == 0)
break; break;
if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) if (chplan_sta[i].ChannelNum ==
{ chplan_ap.Channel[j]) {
chplan_new[k].ChannelNum = chplan_ap.Channel[j]; chplan_new[k].ChannelNum =
chplan_ap.Channel[j];
chplan_new[k].ScanType = SCAN_ACTIVE; chplan_new[k].ScanType = SCAN_ACTIVE;
i++; i++;
j++; j++;
k++; k++;
} } else if (chplan_sta[i].ChannelNum <
else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) chplan_ap.Channel[j]) {
{ chplan_new[k].ChannelNum =
chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; chplan_sta[i].ChannelNum;
/* chplan_new[k].ScanType = chplan_sta[i].ScanType; */
chplan_new[k].ScanType = SCAN_PASSIVE; chplan_new[k].ScanType = SCAN_PASSIVE;
i++; i++;
k++; k++;
} } else if (chplan_sta[i].ChannelNum >
else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) chplan_ap.Channel[j]) {
{ chplan_new[k].ChannelNum =
chplan_new[k].ChannelNum = chplan_ap.Channel[j]; chplan_ap.Channel[j];
chplan_new[k].ScanType = SCAN_ACTIVE; chplan_new[k].ScanType = SCAN_ACTIVE;
j++; j++;
k++; k++;
...@@ -4881,15 +4892,17 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b ...@@ -4881,15 +4892,17 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
} while (1); } while (1);
/* change AP not support channel to Passive scan */ /* change AP not support channel to Passive scan */
while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { while (i < MAX_CHANNEL_NUM &&
chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; chplan_sta[i].ChannelNum != 0) {
chplan_new[k].ChannelNum =
chplan_sta[i].ChannelNum;
chplan_new[k].ScanType = SCAN_PASSIVE; chplan_new[k].ScanType = SCAN_PASSIVE;
i++; i++;
k++; k++;
} }
/* add channel AP supported */ /* add channel AP supported */
while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] != 0)) { while (j < chplan_ap.Len && chplan_ap.Channel[j] != 0) {
chplan_new[k].ChannelNum = chplan_ap.Channel[j]; chplan_new[k].ChannelNum = chplan_ap.Channel[j];
chplan_new[k].ScanType = SCAN_ACTIVE; chplan_new[k].ScanType = SCAN_ACTIVE;
j++; j++;
...@@ -4897,8 +4910,10 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b ...@@ -4897,8 +4910,10 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
} }
} else { } else {
/* keep original STA 5G channel plan */ /* keep original STA 5G channel plan */
while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { while (i < MAX_CHANNEL_NUM &&
chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; chplan_sta[i].ChannelNum != 0) {
chplan_new[k].ChannelNum =
chplan_sta[i].ChannelNum;
chplan_new[k].ScanType = chplan_sta[i].ScanType; chplan_new[k].ScanType = chplan_sta[i].ScanType;
i++; i++;
k++; k++;
...@@ -4911,18 +4926,19 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b ...@@ -4911,18 +4926,19 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b
channel = bssid->Configuration.DSConfig; channel = bssid->Configuration.DSConfig;
chplan_new = pmlmeext->channel_set; chplan_new = pmlmeext->channel_set;
i = 0; i = 0;
while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) { while (i < MAX_CHANNEL_NUM && chplan_new[i].ChannelNum != 0) {
if (chplan_new[i].ChannelNum == channel) if (chplan_new[i].ChannelNum == channel) {
{
if (chplan_new[i].ScanType == SCAN_PASSIVE) { if (chplan_new[i].ScanType == SCAN_PASSIVE) {
/* 5G Bnad 2, 3 (DFS) doesn't change to active scan */ /* 5G Bnad 2, 3 (DFS) doesn't change
to active scan */
if (channel >= 52 && channel <= 144) if (channel >= 52 && channel <= 144)
break; break;
chplan_new[i].ScanType = SCAN_ACTIVE; chplan_new[i].ScanType = SCAN_ACTIVE;
RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
("%s: change channel %d scan type from passive to active\n", ("%s: change channel %d scan type "
__func__, channel)); "from passive to active\n",
__func__, channel));
} }
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment