libertas: clean up scan.c, remove zeromac and bcastmac

Should be purely cosmetic apart from the removal of the two pointless
MAC addresses.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Acked-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
David Woodhouse 2008-03-03 12:18:59 +01:00 committed by John W. Linville
parent fa62f99cf8
commit f137e05468
1 changed files with 181 additions and 234 deletions

View File

@ -61,9 +61,6 @@
//! Scan time specified in the channel TLV for each channel for active scans //! Scan time specified in the channel TLV for each channel for active scans
#define MRVDRV_ACTIVE_SCAN_CHAN_TIME 100 #define MRVDRV_ACTIVE_SCAN_CHAN_TIME 100
static const u8 zeromac[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const u8 bcastmac[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy, static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy,
struct cmd_header *resp); struct cmd_header *resp);
@ -90,7 +87,7 @@ static void lbs_unset_basic_rate_flags(u8 *rates, size_t len)
} }
static inline void clear_bss_descriptor (struct bss_descriptor * bss) static inline void clear_bss_descriptor(struct bss_descriptor *bss)
{ {
/* Don't blow away ->list, just BSS data */ /* Don't blow away ->list, just BSS data */
memset(bss, 0, offsetof(struct bss_descriptor, list)); memset(bss, 0, offsetof(struct bss_descriptor, list));
@ -104,7 +101,8 @@ static inline void clear_bss_descriptor (struct bss_descriptor * bss)
* *
* @return 0: ssid is same, otherwise is different * @return 0: ssid is same, otherwise is different
*/ */
int lbs_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len) int lbs_ssid_cmp(uint8_t *ssid1, uint8_t ssid1_len, uint8_t *ssid2,
uint8_t ssid2_len)
{ {
if (ssid1_len != ssid2_len) if (ssid1_len != ssid2_len)
return -1; return -1;
@ -113,72 +111,65 @@ int lbs_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len)
} }
static inline int match_bss_no_security(struct lbs_802_11_security *secinfo, static inline int match_bss_no_security(struct lbs_802_11_security *secinfo,
struct bss_descriptor * match_bss) struct bss_descriptor *match_bss)
{ {
if ( !secinfo->wep_enabled if (!secinfo->wep_enabled && !secinfo->WPAenabled
&& !secinfo->WPAenabled
&& !secinfo->WPA2enabled && !secinfo->WPA2enabled
&& match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC && match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC
&& match_bss->rsn_ie[0] != MFIE_TYPE_RSN && match_bss->rsn_ie[0] != MFIE_TYPE_RSN
&& !(match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { && !(match_bss->capability & WLAN_CAPABILITY_PRIVACY))
return 1; return 1;
} else
return 0; return 0;
} }
static inline int match_bss_static_wep(struct lbs_802_11_security *secinfo, static inline int match_bss_static_wep(struct lbs_802_11_security *secinfo,
struct bss_descriptor * match_bss) struct bss_descriptor *match_bss)
{ {
if ( secinfo->wep_enabled if (secinfo->wep_enabled && !secinfo->WPAenabled
&& !secinfo->WPAenabled
&& !secinfo->WPA2enabled && !secinfo->WPA2enabled
&& (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { && (match_bss->capability & WLAN_CAPABILITY_PRIVACY))
return 1; return 1;
} else
return 0; return 0;
} }
static inline int match_bss_wpa(struct lbs_802_11_security *secinfo, static inline int match_bss_wpa(struct lbs_802_11_security *secinfo,
struct bss_descriptor * match_bss) struct bss_descriptor *match_bss)
{ {
if ( !secinfo->wep_enabled if (!secinfo->wep_enabled && secinfo->WPAenabled
&& secinfo->WPAenabled
&& (match_bss->wpa_ie[0] == MFIE_TYPE_GENERIC) && (match_bss->wpa_ie[0] == MFIE_TYPE_GENERIC)
/* privacy bit may NOT be set in some APs like LinkSys WRT54G /* privacy bit may NOT be set in some APs like LinkSys WRT54G
&& (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { && (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */
*/ )
) {
return 1; return 1;
} else
return 0; return 0;
} }
static inline int match_bss_wpa2(struct lbs_802_11_security *secinfo, static inline int match_bss_wpa2(struct lbs_802_11_security *secinfo,
struct bss_descriptor * match_bss) struct bss_descriptor *match_bss)
{ {
if ( !secinfo->wep_enabled if (!secinfo->wep_enabled && secinfo->WPA2enabled
&& secinfo->WPA2enabled
&& (match_bss->rsn_ie[0] == MFIE_TYPE_RSN) && (match_bss->rsn_ie[0] == MFIE_TYPE_RSN)
/* privacy bit may NOT be set in some APs like LinkSys WRT54G /* privacy bit may NOT be set in some APs like LinkSys WRT54G
&& (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { && (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */
*/ )
) {
return 1; return 1;
} else
return 0; return 0;
} }
static inline int match_bss_dynamic_wep(struct lbs_802_11_security *secinfo, static inline int match_bss_dynamic_wep(struct lbs_802_11_security *secinfo,
struct bss_descriptor * match_bss) struct bss_descriptor *match_bss)
{ {
if ( !secinfo->wep_enabled if (!secinfo->wep_enabled && !secinfo->WPAenabled
&& !secinfo->WPAenabled
&& !secinfo->WPA2enabled && !secinfo->WPA2enabled
&& (match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC) && (match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC)
&& (match_bss->rsn_ie[0] != MFIE_TYPE_RSN) && (match_bss->rsn_ie[0] != MFIE_TYPE_RSN)
&& (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { && (match_bss->capability & WLAN_CAPABILITY_PRIVACY))
return 1; return 1;
} else
return 0; return 0;
} }
@ -214,7 +205,7 @@ static inline int is_same_network(struct bss_descriptor *src,
* @return Index in scantable, or error code if negative * @return Index in scantable, or error code if negative
*/ */
static int is_network_compatible(struct lbs_private *priv, static int is_network_compatible(struct lbs_private *priv,
struct bss_descriptor * bss, u8 mode) struct bss_descriptor *bss, uint8_t mode)
{ {
int matched = 0; int matched = 0;
@ -228,8 +219,7 @@ static int is_network_compatible(struct lbs_private *priv,
} else if ((matched = match_bss_static_wep(&priv->secinfo, bss))) { } else if ((matched = match_bss_static_wep(&priv->secinfo, bss))) {
goto done; goto done;
} else if ((matched = match_bss_wpa(&priv->secinfo, bss))) { } else if ((matched = match_bss_wpa(&priv->secinfo, bss))) {
lbs_deb_scan( lbs_deb_scan("is_network_compatible() WPA: wpa_ie 0x%x "
"is_network_compatible() WPA: wpa_ie 0x%x "
"wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s "
"privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0],
priv->secinfo.wep_enabled ? "e" : "d", priv->secinfo.wep_enabled ? "e" : "d",
@ -238,8 +228,7 @@ static int is_network_compatible(struct lbs_private *priv,
(bss->capability & WLAN_CAPABILITY_PRIVACY)); (bss->capability & WLAN_CAPABILITY_PRIVACY));
goto done; goto done;
} else if ((matched = match_bss_wpa2(&priv->secinfo, bss))) { } else if ((matched = match_bss_wpa2(&priv->secinfo, bss))) {
lbs_deb_scan( lbs_deb_scan("is_network_compatible() WPA2: wpa_ie 0x%x "
"is_network_compatible() WPA2: wpa_ie 0x%x "
"wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s "
"privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0],
priv->secinfo.wep_enabled ? "e" : "d", priv->secinfo.wep_enabled ? "e" : "d",
@ -248,8 +237,7 @@ static int is_network_compatible(struct lbs_private *priv,
(bss->capability & WLAN_CAPABILITY_PRIVACY)); (bss->capability & WLAN_CAPABILITY_PRIVACY));
goto done; goto done;
} else if ((matched = match_bss_dynamic_wep(&priv->secinfo, bss))) { } else if ((matched = match_bss_dynamic_wep(&priv->secinfo, bss))) {
lbs_deb_scan( lbs_deb_scan("is_network_compatible() dynamic WEP: "
"is_network_compatible() dynamic WEP: "
"wpa_ie 0x%x wpa2_ie 0x%x privacy 0x%x\n", "wpa_ie 0x%x wpa2_ie 0x%x privacy 0x%x\n",
bss->wpa_ie[0], bss->rsn_ie[0], bss->wpa_ie[0], bss->rsn_ie[0],
(bss->capability & WLAN_CAPABILITY_PRIVACY)); (bss->capability & WLAN_CAPABILITY_PRIVACY));
@ -257,8 +245,7 @@ static int is_network_compatible(struct lbs_private *priv,
} }
/* bss security settings don't match those configured on card */ /* bss security settings don't match those configured on card */
lbs_deb_scan( lbs_deb_scan("is_network_compatible() FAILED: wpa_ie 0x%x "
"is_network_compatible() FAILED: wpa_ie 0x%x "
"wpa2_ie 0x%x WEP %s WPA %s WPA2 %s privacy 0x%x\n", "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s privacy 0x%x\n",
bss->wpa_ie[0], bss->rsn_ie[0], bss->wpa_ie[0], bss->rsn_ie[0],
priv->secinfo.wep_enabled ? "e" : "d", priv->secinfo.wep_enabled ? "e" : "d",
@ -311,16 +298,15 @@ void lbs_scan_worker(struct work_struct *work)
* @return void * @return void
*/ */
static int lbs_scan_create_channel_list(struct lbs_private *priv, static int lbs_scan_create_channel_list(struct lbs_private *priv,
struct chanscanparamset * scanchanlist, struct chanscanparamset *scanchanlist,
u8 filteredscan) uint8_t filteredscan)
{ {
struct region_channel *scanregion; struct region_channel *scanregion;
struct chan_freq_power *cfp; struct chan_freq_power *cfp;
int rgnidx; int rgnidx;
int chanidx; int chanidx;
int nextchan; int nextchan;
u8 scantype; uint8_t scantype;
chanidx = 0; chanidx = 0;
@ -331,9 +317,8 @@ static int lbs_scan_create_channel_list(struct lbs_private *priv,
scantype = CMD_SCAN_TYPE_ACTIVE; scantype = CMD_SCAN_TYPE_ACTIVE;
for (rgnidx = 0; rgnidx < ARRAY_SIZE(priv->region_channel); rgnidx++) { for (rgnidx = 0; rgnidx < ARRAY_SIZE(priv->region_channel); rgnidx++) {
if (priv->enable11d && if (priv->enable11d && (priv->connect_status != LBS_CONNECTED)
(priv->connect_status != LBS_CONNECTED) && && (priv->mesh_connect_status != LBS_CONNECTED)) {
(priv->mesh_connect_status != LBS_CONNECTED)) {
/* Scan all the supported chan for the first scan */ /* Scan all the supported chan for the first scan */
if (!priv->universal_channel[rgnidx].valid) if (!priv->universal_channel[rgnidx].valid)
continue; continue;
@ -348,45 +333,30 @@ static int lbs_scan_create_channel_list(struct lbs_private *priv,
scanregion = &priv->region_channel[rgnidx]; scanregion = &priv->region_channel[rgnidx];
} }
for (nextchan = 0; for (nextchan = 0; nextchan < scanregion->nrcfp; nextchan++, chanidx++) {
nextchan < scanregion->nrcfp; nextchan++, chanidx++) { struct chanscanparamset *chan = &scanchanlist[chanidx];
cfp = scanregion->CFP + nextchan; cfp = scanregion->CFP + nextchan;
if (priv->enable11d) { if (priv->enable11d)
scantype = scantype = lbs_get_scan_type_11d(cfp->channel,
lbs_get_scan_type_11d(cfp->channel, &priv->parsed_region_chan);
&priv->
parsed_region_chan);
}
switch (scanregion->band) { if (scanregion->band == BAND_B || scanregion->band == BAND_G)
case BAND_B: chan->radiotype = CMD_SCAN_RADIO_TYPE_BG;
case BAND_G:
default:
scanchanlist[chanidx].radiotype =
CMD_SCAN_RADIO_TYPE_BG;
break;
}
if (scantype == CMD_SCAN_TYPE_PASSIVE) { if (scantype == CMD_SCAN_TYPE_PASSIVE) {
scanchanlist[chanidx].maxscantime = chan->maxscantime = cpu_to_le16(MRVDRV_PASSIVE_SCAN_CHAN_TIME);
cpu_to_le16(MRVDRV_PASSIVE_SCAN_CHAN_TIME); chan->chanscanmode.passivescan = 1;
scanchanlist[chanidx].chanscanmode.passivescan =
1;
} else { } else {
scanchanlist[chanidx].maxscantime = chan->maxscantime = cpu_to_le16(MRVDRV_ACTIVE_SCAN_CHAN_TIME);
cpu_to_le16(MRVDRV_ACTIVE_SCAN_CHAN_TIME); chan->chanscanmode.passivescan = 0;
scanchanlist[chanidx].chanscanmode.passivescan =
0;
} }
scanchanlist[chanidx].channumber = cfp->channel; chan->channumber = cfp->channel;
if (filteredscan) { if (filteredscan)
scanchanlist[chanidx].chanscanmode. chan->chanscanmode.disablechanfilt = 1;
disablechanfilt = 1;
}
} }
} }
return chanidx; return chanidx;
@ -400,11 +370,11 @@ static int lbs_scan_create_channel_list(struct lbs_private *priv,
* length 06 00 * length 06 00
* ssid 4d 4e 54 45 53 54 * ssid 4d 4e 54 45 53 54
*/ */
static int lbs_scan_add_ssid_tlv(u8 *tlv, static int lbs_scan_add_ssid_tlv(uint8_t *tlv,
const struct lbs_ioctl_user_scan_cfg *user_cfg) const struct lbs_ioctl_user_scan_cfg *user_cfg)
{ {
struct mrvlietypes_ssidparamset *ssid_tlv = struct mrvlietypes_ssidparamset *ssid_tlv = (void *)tlv;
(struct mrvlietypes_ssidparamset *)tlv;
ssid_tlv->header.type = cpu_to_le16(TLV_TYPE_SSID); ssid_tlv->header.type = cpu_to_le16(TLV_TYPE_SSID);
ssid_tlv->header.len = cpu_to_le16(user_cfg->ssid_len); ssid_tlv->header.len = cpu_to_le16(user_cfg->ssid_len);
memcpy(ssid_tlv->ssid, user_cfg->ssid, user_cfg->ssid_len); memcpy(ssid_tlv->ssid, user_cfg->ssid, user_cfg->ssid_len);
@ -437,13 +407,12 @@ static int lbs_scan_add_ssid_tlv(u8 *tlv,
* channel 13 00 0d 00 00 00 64 00 * channel 13 00 0d 00 00 00 64 00
* *
*/ */
static int lbs_scan_add_chanlist_tlv(u8 *tlv, static int lbs_scan_add_chanlist_tlv(uint8_t *tlv,
struct chanscanparamset *chan_list, struct chanscanparamset *chan_list,
int chan_count) int chan_count)
{ {
size_t size = sizeof(struct chanscanparamset) * chan_count; size_t size = sizeof(struct chanscanparamset) *chan_count;
struct mrvlietypes_chanlistparamset *chan_tlv = struct mrvlietypes_chanlistparamset *chan_tlv = (void *)tlv;
(struct mrvlietypes_chanlistparamset *) tlv;
chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST); chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST);
memcpy(chan_tlv->chanscanparam, chan_list, size); memcpy(chan_tlv->chanscanparam, chan_list, size);
@ -462,11 +431,10 @@ static int lbs_scan_add_chanlist_tlv(u8 *tlv,
* The rates are in lbs_bg_rates[], but for the 802.11b * The rates are in lbs_bg_rates[], but for the 802.11b
* rates the high bit isn't set. * rates the high bit isn't set.
*/ */
static int lbs_scan_add_rates_tlv(u8 *tlv) static int lbs_scan_add_rates_tlv(uint8_t *tlv)
{ {
int i; int i;
struct mrvlietypes_ratesparamset *rate_tlv = struct mrvlietypes_ratesparamset *rate_tlv = (void *)tlv;
(struct mrvlietypes_ratesparamset *) tlv;
rate_tlv->header.type = cpu_to_le16(TLV_TYPE_RATES); rate_tlv->header.type = cpu_to_le16(TLV_TYPE_RATES);
tlv += sizeof(rate_tlv->header); tlv += sizeof(rate_tlv->header);
@ -561,7 +529,7 @@ int lbs_scan_networks(struct lbs_private *priv,
struct chanscanparamset *chan_list; struct chanscanparamset *chan_list;
struct chanscanparamset *curr_chans; struct chanscanparamset *curr_chans;
int chan_count; int chan_count;
u8 bsstype = CMD_BSS_TYPE_ANY; uint8_t bsstype = CMD_BSS_TYPE_ANY;
int numchannels = MRVDRV_CHANNELS_PER_SCAN_CMD; int numchannels = MRVDRV_CHANNELS_PER_SCAN_CMD;
int filteredscan = 0; int filteredscan = 0;
union iwreq_data wrqu; union iwreq_data wrqu;
@ -571,8 +539,7 @@ int lbs_scan_networks(struct lbs_private *priv,
DECLARE_MAC_BUF(mac); DECLARE_MAC_BUF(mac);
#endif #endif
lbs_deb_enter_args(LBS_DEB_SCAN, "full_scan %d", lbs_deb_enter_args(LBS_DEB_SCAN, "full_scan %d", full_scan);
full_scan);
/* Cancel any partial outstanding partial scans if this scan /* Cancel any partial outstanding partial scans if this scan
* is a full scan. * is a full scan.
@ -584,13 +551,12 @@ int lbs_scan_networks(struct lbs_private *priv,
if (user_cfg) { if (user_cfg) {
if (user_cfg->bsstype) if (user_cfg->bsstype)
bsstype = user_cfg->bsstype; bsstype = user_cfg->bsstype;
if (compare_ether_addr(user_cfg->bssid, &zeromac[0]) != 0) { if (!is_zero_ether_addr(user_cfg->bssid)) {
numchannels = MRVDRV_MAX_CHANNELS_PER_SCAN; numchannels = MRVDRV_MAX_CHANNELS_PER_SCAN;
filteredscan = 1; filteredscan = 1;
} }
} }
lbs_deb_scan("numchannels %d, bsstype %d, " lbs_deb_scan("numchannels %d, bsstype %d, filteredscan %d\n",
"filteredscan %d\n",
numchannels, bsstype, filteredscan); numchannels, bsstype, filteredscan);
/* Create list of channels to scan */ /* Create list of channels to scan */
@ -602,8 +568,7 @@ int lbs_scan_networks(struct lbs_private *priv,
} }
/* We want to scan all channels */ /* We want to scan all channels */
chan_count = lbs_scan_create_channel_list(priv, chan_list, chan_count = lbs_scan_create_channel_list(priv, chan_list, filteredscan);
filteredscan);
netif_stop_queue(priv->dev); netif_stop_queue(priv->dev);
netif_carrier_off(priv->dev); netif_carrier_off(priv->dev);
@ -641,8 +606,7 @@ int lbs_scan_networks(struct lbs_private *priv,
chan_count -= to_scan; chan_count -= to_scan;
/* somehow schedule the next part of the scan */ /* somehow schedule the next part of the scan */
if (chan_count && if (chan_count && !full_scan &&
!full_scan &&
!priv->surpriseremoved) { !priv->surpriseremoved) {
/* -1 marks just that we're currently scanning */ /* -1 marks just that we're currently scanning */
if (priv->scan_channel < 0) if (priv->scan_channel < 0)
@ -666,7 +630,7 @@ int lbs_scan_networks(struct lbs_private *priv,
lbs_deb_scan("scan table:\n"); lbs_deb_scan("scan table:\n");
list_for_each_entry(iter, &priv->network_list, list) list_for_each_entry(iter, &priv->network_list, list)
lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n", lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n",
i++, print_mac(mac, iter->bssid), (s32) iter->rssi, i++, print_mac(mac, iter->bssid), (int)iter->rssi,
escape_essid(iter->ssid, iter->ssid_len)); escape_essid(iter->ssid, iter->ssid_len));
mutex_unlock(&priv->lock); mutex_unlock(&priv->lock);
#endif #endif
@ -712,7 +676,7 @@ out:
* @return 0 or -1 * @return 0 or -1
*/ */
static int lbs_process_bss(struct bss_descriptor *bss, static int lbs_process_bss(struct bss_descriptor *bss,
u8 ** pbeaconinfo, int *bytesleft) uint8_t **pbeaconinfo, int *bytesleft)
{ {
struct ieeetypes_fhparamset *pFH; struct ieeetypes_fhparamset *pFH;
struct ieeetypes_dsparamset *pDS; struct ieeetypes_dsparamset *pDS;
@ -720,9 +684,9 @@ static int lbs_process_bss(struct bss_descriptor *bss,
struct ieeetypes_ibssparamset *pibss; struct ieeetypes_ibssparamset *pibss;
DECLARE_MAC_BUF(mac); DECLARE_MAC_BUF(mac);
struct ieeetypes_countryinfoset *pcountryinfo; struct ieeetypes_countryinfoset *pcountryinfo;
u8 *pos, *end, *p; uint8_t *pos, *end, *p;
u8 n_ex_rates = 0, got_basic_rates = 0, n_basic_rates = 0; uint8_t n_ex_rates = 0, got_basic_rates = 0, n_basic_rates = 0;
u16 beaconsize = 0; uint16_t beaconsize = 0;
int ret; int ret;
lbs_deb_enter(LBS_DEB_SCAN); lbs_deb_enter(LBS_DEB_SCAN);
@ -794,8 +758,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
/* process variable IE */ /* process variable IE */
while (pos <= end - 2) { while (pos <= end - 2) {
struct ieee80211_info_element * elem = struct ieee80211_info_element * elem = (void *)pos;
(struct ieee80211_info_element *) pos;
if (pos + elem->len > end) { if (pos + elem->len > end) {
lbs_deb_scan("process_bss: error in processing IE, " lbs_deb_scan("process_bss: error in processing IE, "
@ -813,7 +776,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
break; break;
case MFIE_TYPE_RATES: case MFIE_TYPE_RATES:
n_basic_rates = min_t(u8, MAX_RATES, elem->len); n_basic_rates = min_t(uint8_t, MAX_RATES, elem->len);
memcpy(bss->rates, elem->data, n_basic_rates); memcpy(bss->rates, elem->data, n_basic_rates);
got_basic_rates = 1; got_basic_rates = 1;
lbs_deb_scan("got RATES IE\n"); lbs_deb_scan("got RATES IE\n");
@ -854,19 +817,16 @@ static int lbs_process_bss(struct bss_descriptor *bss,
lbs_deb_scan("got COUNTRY IE\n"); lbs_deb_scan("got COUNTRY IE\n");
if (pcountryinfo->len < sizeof(pcountryinfo->countrycode) if (pcountryinfo->len < sizeof(pcountryinfo->countrycode)
|| pcountryinfo->len > 254) { || pcountryinfo->len > 254) {
lbs_deb_scan("process_bss: 11D- Err " lbs_deb_scan("process_bss: 11D- Err CountryInfo len %d, min %zd, max 254\n",
"CountryInfo len %d, min %zd, max 254\n", pcountryinfo->len, sizeof(pcountryinfo->countrycode));
pcountryinfo->len,
sizeof(pcountryinfo->countrycode));
ret = -1; ret = -1;
goto done; goto done;
} }
memcpy(&bss->countryinfo, memcpy(&bss->countryinfo, pcountryinfo, pcountryinfo->len + 2);
pcountryinfo, pcountryinfo->len + 2);
lbs_deb_hex(LBS_DEB_SCAN, "process_bss: 11d countryinfo", lbs_deb_hex(LBS_DEB_SCAN, "process_bss: 11d countryinfo",
(u8 *) pcountryinfo, (uint8_t *) pcountryinfo,
(u32) (pcountryinfo->len + 2)); (int) (pcountryinfo->len + 2));
break; break;
case MFIE_TYPE_RATES_EX: case MFIE_TYPE_RATES_EX:
@ -890,26 +850,19 @@ static int lbs_process_bss(struct bss_descriptor *bss,
case MFIE_TYPE_GENERIC: case MFIE_TYPE_GENERIC:
if (elem->len >= 4 && if (elem->len >= 4 &&
elem->data[0] == 0x00 && elem->data[0] == 0x00 && elem->data[1] == 0x50 &&
elem->data[1] == 0x50 && elem->data[2] == 0xf2 && elem->data[3] == 0x01) {
elem->data[2] == 0xf2 && bss->wpa_ie_len = min(elem->len + 2, MAX_WPA_IE_LEN);
elem->data[3] == 0x01) {
bss->wpa_ie_len = min(elem->len + 2,
MAX_WPA_IE_LEN);
memcpy(bss->wpa_ie, elem, bss->wpa_ie_len); memcpy(bss->wpa_ie, elem, bss->wpa_ie_len);
lbs_deb_scan("got WPA IE\n"); lbs_deb_scan("got WPA IE\n");
lbs_deb_hex(LBS_DEB_SCAN, "WPA IE", bss->wpa_ie, lbs_deb_hex(LBS_DEB_SCAN, "WPA IE", bss->wpa_ie, elem->len);
elem->len);
} else if (elem->len >= MARVELL_MESH_IE_LENGTH && } else if (elem->len >= MARVELL_MESH_IE_LENGTH &&
elem->data[0] == 0x00 && elem->data[0] == 0x00 && elem->data[1] == 0x50 &&
elem->data[1] == 0x50 && elem->data[2] == 0x43 && elem->data[3] == 0x04) {
elem->data[2] == 0x43 &&
elem->data[3] == 0x04) {
lbs_deb_scan("got mesh IE\n"); lbs_deb_scan("got mesh IE\n");
bss->mesh = 1; bss->mesh = 1;
} else { } else {
lbs_deb_scan("got generiec IE: " lbs_deb_scan("got generic IE: %02x:%02x:%02x:%02x, len %d\n",
"%02x:%02x:%02x:%02x, len %d\n",
elem->data[0], elem->data[1], elem->data[0], elem->data[1],
elem->data[2], elem->data[3], elem->data[2], elem->data[3],
elem->len); elem->len);
@ -956,18 +909,17 @@ done:
* @return index in BSSID list, or error return code (< 0) * @return index in BSSID list, or error return code (< 0)
*/ */
struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_private *priv, struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_private *priv,
u8 * bssid, u8 mode) uint8_t *bssid, uint8_t mode)
{ {
struct bss_descriptor * iter_bss; struct bss_descriptor *iter_bss;
struct bss_descriptor * found_bss = NULL; struct bss_descriptor *found_bss = NULL;
lbs_deb_enter(LBS_DEB_SCAN); lbs_deb_enter(LBS_DEB_SCAN);
if (!bssid) if (!bssid)
goto out; goto out;
lbs_deb_hex(LBS_DEB_SCAN, "looking for", lbs_deb_hex(LBS_DEB_SCAN, "looking for", bssid, ETH_ALEN);
bssid, ETH_ALEN);
/* Look through the scan table for a compatible match. The loop will /* Look through the scan table for a compatible match. The loop will
* continue past a matched bssid that is not compatible in case there * continue past a matched bssid that is not compatible in case there
@ -1009,10 +961,11 @@ out:
* @return index in BSSID list * @return index in BSSID list
*/ */
struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_private *priv, struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_private *priv,
u8 *ssid, u8 ssid_len, u8 * bssid, u8 mode, uint8_t *ssid, uint8_t ssid_len,
uint8_t *bssid, uint8_t mode,
int channel) int channel)
{ {
u8 bestrssi = 0; uint8_t bestrssi = 0;
struct bss_descriptor * iter_bss = NULL; struct bss_descriptor * iter_bss = NULL;
struct bss_descriptor * found_bss = NULL; struct bss_descriptor * found_bss = NULL;
struct bss_descriptor * tmp_oldest = NULL; struct bss_descriptor * tmp_oldest = NULL;
@ -1077,13 +1030,12 @@ out:
* *
* @return index in BSSID list * @return index in BSSID list
*/ */
static struct bss_descriptor *lbs_find_best_ssid_in_list( static struct bss_descriptor *lbs_find_best_ssid_in_list(struct lbs_private *priv,
struct lbs_private *priv, uint8_t mode)
u8 mode)
{ {
u8 bestrssi = 0; uint8_t bestrssi = 0;
struct bss_descriptor * iter_bss; struct bss_descriptor *iter_bss;
struct bss_descriptor * best_bss = NULL; struct bss_descriptor *best_bss = NULL;
lbs_deb_enter(LBS_DEB_SCAN); lbs_deb_enter(LBS_DEB_SCAN);
@ -1125,11 +1077,12 @@ static struct bss_descriptor *lbs_find_best_ssid_in_list(
* *
* @return 0--success, otherwise--fail * @return 0--success, otherwise--fail
*/ */
int lbs_find_best_network_ssid(struct lbs_private *priv, int lbs_find_best_network_ssid(struct lbs_private *priv, uint8_t *out_ssid,
u8 *out_ssid, u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode) uint8_t *out_ssid_len, uint8_t preferred_mode,
uint8_t *out_mode)
{ {
int ret = -1; int ret = -1;
struct bss_descriptor * found; struct bss_descriptor *found;
lbs_deb_enter(LBS_DEB_SCAN); lbs_deb_enter(LBS_DEB_SCAN);
@ -1164,8 +1117,8 @@ out:
* *
* @return 0-success, otherwise fail * @return 0-success, otherwise fail
*/ */
int lbs_send_specific_ssid_scan(struct lbs_private *priv, int lbs_send_specific_ssid_scan(struct lbs_private *priv, uint8_t *ssid,
u8 *ssid, u8 ssid_len, u8 clear_ssid) uint8_t ssid_len, uint8_t clear_ssid)
{ {
struct lbs_ioctl_user_scan_cfg scancfg; struct lbs_ioctl_user_scan_cfg scancfg;
int ret = 0; int ret = 0;
@ -1212,10 +1165,10 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
char *current_val; /* For rates */ char *current_val; /* For rates */
struct iw_event iwe; /* Temporary buffer */ struct iw_event iwe; /* Temporary buffer */
int j; int j;
#define PERFECT_RSSI ((u8)50) #define PERFECT_RSSI ((uint8_t)50)
#define WORST_RSSI ((u8)0) #define WORST_RSSI ((uint8_t)0)
#define RSSI_DIFF ((u8)(PERFECT_RSSI - WORST_RSSI)) #define RSSI_DIFF ((uint8_t)(PERFECT_RSSI - WORST_RSSI))
u8 rssi; uint8_t rssi;
lbs_deb_enter(LBS_DEB_SCAN); lbs_deb_enter(LBS_DEB_SCAN);
@ -1235,7 +1188,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
/* SSID */ /* SSID */
iwe.cmd = SIOCGIWESSID; iwe.cmd = SIOCGIWESSID;
iwe.u.data.flags = 1; iwe.u.data.flags = 1;
iwe.u.data.length = min((u32) bss->ssid_len, (u32) IW_ESSID_MAX_SIZE); iwe.u.data.length = min((uint32_t) bss->ssid_len, (uint32_t) IW_ESSID_MAX_SIZE);
start = iwe_stream_add_point(start, stop, &iwe, bss->ssid); start = iwe_stream_add_point(start, stop, &iwe, bss->ssid);
/* Mode */ /* Mode */
@ -1265,16 +1218,14 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) { if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
iwe.u.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE; iwe.u.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
} else { } else {
iwe.u.qual.noise = iwe.u.qual.noise = CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
} }
/* Locally created ad-hoc BSSs won't have beacons if this is the /* Locally created ad-hoc BSSs won't have beacons if this is the
* only station in the adhoc network; so get signal strength * only station in the adhoc network; so get signal strength
* from receive statistics. * from receive statistics.
*/ */
if ((priv->mode == IW_MODE_ADHOC) if ((priv->mode == IW_MODE_ADHOC) && priv->adhoccreate
&& priv->adhoccreate
&& !lbs_ssid_cmp(priv->curbssparams.ssid, && !lbs_ssid_cmp(priv->curbssparams.ssid,
priv->curbssparams.ssid_len, priv->curbssparams.ssid_len,
bss->ssid, bss->ssid_len)) { bss->ssid, bss->ssid_len)) {
@ -1308,11 +1259,10 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
current_val = iwe_stream_add_value(start, current_val, current_val = iwe_stream_add_value(start, current_val,
stop, &iwe, IW_EV_PARAM_LEN); stop, &iwe, IW_EV_PARAM_LEN);
} }
if ((bss->mode == IW_MODE_ADHOC) if ((bss->mode == IW_MODE_ADHOC) && priv->adhoccreate
&& !lbs_ssid_cmp(priv->curbssparams.ssid, && !lbs_ssid_cmp(priv->curbssparams.ssid,
priv->curbssparams.ssid_len, priv->curbssparams.ssid_len,
bss->ssid, bss->ssid_len) bss->ssid, bss->ssid_len)) {
&& priv->adhoccreate) {
iwe.u.bitrate.value = 22 * 500000; iwe.u.bitrate.value = 22 * 500000;
current_val = iwe_stream_add_value(start, current_val, current_val = iwe_stream_add_value(start, current_val,
stop, &iwe, IW_EV_PARAM_LEN); stop, &iwe, IW_EV_PARAM_LEN);
@ -1344,8 +1294,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
char *p = custom; char *p = custom;
iwe.cmd = IWEVCUSTOM; iwe.cmd = IWEVCUSTOM;
p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), p += snprintf(p, MAX_CUSTOM_LEN, "mesh-type: olpc");
"mesh-type: olpc");
iwe.u.data.length = p - custom; iwe.u.data.length = p - custom;
if (iwe.u.data.length) if (iwe.u.data.length)
start = iwe_stream_add_point(start, stop, &iwe, custom); start = iwe_stream_add_point(start, stop, &iwe, custom);
@ -1422,8 +1371,8 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
int err = 0; int err = 0;
char *ev = extra; char *ev = extra;
char *stop = ev + dwrq->length; char *stop = ev + dwrq->length;
struct bss_descriptor * iter_bss; struct bss_descriptor *iter_bss;
struct bss_descriptor * safe; struct bss_descriptor *safe;
lbs_deb_enter(LBS_DEB_SCAN); lbs_deb_enter(LBS_DEB_SCAN);
@ -1432,14 +1381,13 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
return -EAGAIN; return -EAGAIN;
/* Update RSSI if current BSS is a locally created ad-hoc BSS */ /* Update RSSI if current BSS is a locally created ad-hoc BSS */
if ((priv->mode == IW_MODE_ADHOC) && priv->adhoccreate) { if ((priv->mode == IW_MODE_ADHOC) && priv->adhoccreate)
lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0, lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
CMD_OPTION_WAITFORRSP, 0, NULL); CMD_OPTION_WAITFORRSP, 0, NULL);
}
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
list_for_each_entry_safe (iter_bss, safe, &priv->network_list, list) { list_for_each_entry_safe (iter_bss, safe, &priv->network_list, list) {
char * next_ev; char *next_ev;
unsigned long stale_time; unsigned long stale_time;
if (stop - ev < SCAN_ITEM_SIZE) { if (stop - ev < SCAN_ITEM_SIZE) {
@ -1454,8 +1402,7 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
/* Prune old an old scan result */ /* Prune old an old scan result */
stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE; stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE;
if (time_after(jiffies, stale_time)) { if (time_after(jiffies, stale_time)) {
list_move_tail (&iter_bss->list, list_move_tail(&iter_bss->list, &priv->network_free_list);
&priv->network_free_list);
clear_bss_descriptor(iter_bss); clear_bss_descriptor(iter_bss);
continue; continue;
} }
@ -1515,8 +1462,8 @@ static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy,
struct cmd_header *resp) struct cmd_header *resp)
{ {
struct cmd_ds_802_11_scan_rsp *scanresp = (void *)resp; struct cmd_ds_802_11_scan_rsp *scanresp = (void *)resp;
struct bss_descriptor * iter_bss; struct bss_descriptor *iter_bss;
struct bss_descriptor * safe; struct bss_descriptor *safe;
uint8_t *bssinfo; uint8_t *bssinfo;
uint16_t scanrespsize; uint16_t scanrespsize;
int bytesleft; int bytesleft;