From d8efea254887128d710cc1475505514da004932c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 28 May 2007 23:54:55 -0400 Subject: [PATCH] libertas: remove structure WLAN_802_11_SSID and libertas_escape_essid Replace WLAN_802_11_SSID with direct 'ssid' and 'ssid_len' members like ieee80211. In the process, remove private libertas_escape_essid and depend on the ieee80211 implementation of escape_essid instead. Signed-off-by: Dan Williams Signed-off-by: John W. Linville --- drivers/net/wireless/Kconfig | 1 + drivers/net/wireless/libertas/assoc.c | 74 ++++++++++++--------------------- drivers/net/wireless/libertas/cmdresp.c | 23 +++++----- drivers/net/wireless/libertas/debugfs.c | 9 ++-- drivers/net/wireless/libertas/dev.h | 11 +++-- drivers/net/wireless/libertas/hostcmd.h | 8 ---- drivers/net/wireless/libertas/join.c | 48 +++++++++++---------- drivers/net/wireless/libertas/join.h | 3 -- drivers/net/wireless/libertas/scan.c | 66 +++++++++++++++-------------- drivers/net/wireless/libertas/scan.h | 18 ++++---- drivers/net/wireless/libertas/wext.c | 42 +++++++++++-------- 11 files changed, 143 insertions(+), 160 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig index 89514f3e06c..fa2399cbd5c 100644 --- a/drivers/net/wireless/Kconfig +++ b/drivers/net/wireless/Kconfig @@ -269,6 +269,7 @@ config IPW2200_DEBUG config LIBERTAS tristate "Marvell 8xxx Libertas WLAN driver support" depends on WLAN_80211 + select IEEE80211 select FW_LOADER ---help--- A library for Marvell Libertas 8xxx devices. diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c index bf804d31142..c2029b39750 100644 --- a/drivers/net/wireless/libertas/assoc.c +++ b/drivers/net/wireless/libertas/assoc.c @@ -14,30 +14,6 @@ static const u8 bssid_any[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; static const u8 bssid_off[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -/* From ieee80211_module.c */ -static const char *libertas_escape_essid(const char *essid, u8 essid_len) -{ - static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; - const char *s = essid; - char *d = escaped; - - if (ieee80211_is_empty_essid(essid, essid_len)) - return ""; - - essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE); - while (essid_len--) { - if (*s == '\0') { - *d++ = '\\'; - *d++ = '0'; - s++; - } else { - *d++ = *s++; - } - } - *d = '\0'; - return escaped; -} - static void print_assoc_req(const char * extra, struct assoc_request * assoc_req) { lbs_deb_assoc( @@ -51,7 +27,7 @@ static void print_assoc_req(const char * extra, struct assoc_request * assoc_req " Encryption:%s%s%s\n" " auth: %d\n", extra, assoc_req->flags, - libertas_escape_essid(assoc_req->ssid.ssid, assoc_req->ssid.ssidlength), + escape_essid(assoc_req->ssid, assoc_req->ssid_len), assoc_req->channel, assoc_req->band, assoc_req->mode, MAC_ARG(assoc_req->bssid), assoc_req->secinfo.WPAenabled ? " WPA" : "", @@ -78,41 +54,43 @@ static int assoc_helper_essid(wlan_private *priv, if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) channel = assoc_req->channel; - lbs_deb_assoc("New SSID requested: %s\n", assoc_req->ssid.ssid); + lbs_deb_assoc("New SSID requested: '%s'\n", + escape_essid(assoc_req->ssid, assoc_req->ssid_len)); if (assoc_req->mode == IW_MODE_INFRA) { if (adapter->prescan) { - libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 0); + libertas_send_specific_SSID_scan(priv, assoc_req->ssid, + assoc_req->ssid_len, 0); } - bss = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, - NULL, IW_MODE_INFRA, channel); + bss = libertas_find_SSID_in_list(adapter, assoc_req->ssid, + assoc_req->ssid_len, NULL, IW_MODE_INFRA, channel); if (bss != NULL) { lbs_deb_assoc("SSID found in scan list, associating\n"); memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); ret = wlan_associate(priv, assoc_req); } else { - lbs_deb_assoc("SSID '%s' not found; cannot associate\n", - assoc_req->ssid.ssid); + lbs_deb_assoc("SSID not found; cannot associate\n"); } } else if (assoc_req->mode == IW_MODE_ADHOC) { /* Scan for the network, do not save previous results. Stale * scan data will cause us to join a non-existant adhoc network */ - libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 1); + libertas_send_specific_SSID_scan(priv, assoc_req->ssid, + assoc_req->ssid_len, 1); /* Search for the requested SSID in the scan table */ - bss = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL, - IW_MODE_ADHOC, channel); + bss = libertas_find_SSID_in_list(adapter, assoc_req->ssid, + assoc_req->ssid_len, NULL, IW_MODE_ADHOC, channel); if (bss != NULL) { - lbs_deb_assoc("SSID found joining\n"); + lbs_deb_assoc("SSID found, will join\n"); memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); libertas_join_adhoc_network(priv, assoc_req); } else { /* else send START command */ - lbs_deb_assoc("SSID not found in list, so creating adhoc" - " with SSID '%s'\n", assoc_req->ssid.ssid); + lbs_deb_assoc("SSID not found, creating adhoc network\n"); memcpy(&assoc_req->bss.ssid, &assoc_req->ssid, - sizeof(struct WLAN_802_11_SSID)); + IW_ESSID_MAX_SIZE); + assoc_req->bss.ssid_len = assoc_req->ssid_len; libertas_start_adhoc_network(priv, assoc_req); } } @@ -441,10 +419,9 @@ static int should_stop_adhoc(wlan_adapter *adapter, if (adapter->connect_status != libertas_connected) return 0; - if (adapter->curbssparams.ssid.ssidlength != assoc_req->ssid.ssidlength) - return 1; - if (memcmp(adapter->curbssparams.ssid.ssid, assoc_req->ssid.ssid, - adapter->curbssparams.ssid.ssidlength)) + if (libertas_SSID_cmp(adapter->curbssparams.ssid, + adapter->curbssparams.ssid_len, + assoc_req->ssid, assoc_req->ssid_len) != 0) return 1; /* FIXME: deal with 'auto' mode somehow */ @@ -485,7 +462,7 @@ void libertas_association_worker(struct work_struct *work) /* If 'any' SSID was specified, find an SSID to associate with */ if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags) - && !assoc_req->ssid.ssidlength) + && !assoc_req->ssid_len) find_any_ssid = 1; /* But don't use 'any' SSID if there's a valid locked BSSID to use */ @@ -498,8 +475,8 @@ void libertas_association_worker(struct work_struct *work) if (find_any_ssid) { u8 new_mode; - ret = libertas_find_best_network_SSID(priv, &assoc_req->ssid, - assoc_req->mode, &new_mode); + ret = libertas_find_best_network_SSID(priv, assoc_req->ssid, + &assoc_req->ssid_len, assoc_req->mode, &new_mode); if (ret) { lbs_deb_assoc("Could not find best network\n"); ret = -ENETUNREACH; @@ -613,8 +590,8 @@ lbs_deb_assoc("ASSOC(:%d) wpa_keys: ret = %d\n", __LINE__, ret); if (success) { lbs_deb_assoc("ASSOC: association attempt successful. " "Associated to '%s' (" MAC_FMT ")\n", - libertas_escape_essid(adapter->curbssparams.ssid.ssid, - adapter->curbssparams.ssid.ssidlength), + escape_essid(adapter->curbssparams.ssid, + adapter->curbssparams.ssid_len), MAC_ARG(adapter->curbssparams.bssid)); libertas_prepare_and_send_command(priv, cmd_802_11_rssi, @@ -667,7 +644,8 @@ struct assoc_request * wlan_get_association_request(wlan_adapter *adapter) assoc_req = adapter->pending_assoc_req; if (!test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { memcpy(&assoc_req->ssid, &adapter->curbssparams.ssid, - sizeof(struct WLAN_802_11_SSID)); + IW_ESSID_MAX_SIZE); + assoc_req->ssid_len = adapter->curbssparams.ssid_len; } if (!test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c index 9385df52d7a..ebedd630d72 100644 --- a/drivers/net/wireless/libertas/cmdresp.c +++ b/drivers/net/wireless/libertas/cmdresp.c @@ -61,25 +61,28 @@ void libertas_mac_event_disconnected(wlan_private * priv) adapter->nextSNRNF = 0; adapter->numSNRNF = 0; adapter->rxpd_rate = 0; - lbs_deb_cmd("Current SSID=%s, ssid length=%u\n", - adapter->curbssparams.ssid.ssid, - adapter->curbssparams.ssid.ssidlength); - lbs_deb_cmd("Previous SSID=%s, ssid length=%u\n", - adapter->previousssid.ssid, adapter->previousssid.ssidlength); + lbs_deb_cmd("Current SSID='%s', ssid length=%u\n", + escape_essid(adapter->curbssparams.ssid, + adapter->curbssparams.ssid_len), + adapter->curbssparams.ssid_len); + lbs_deb_cmd("Previous SSID='%s', ssid length=%u\n", + escape_essid(adapter->prev_ssid, adapter->prev_ssid_len), + adapter->prev_ssid_len); adapter->connect_status = libertas_disconnected; /* Save previous SSID and BSSID for possible reassociation */ - memcpy(&adapter->previousssid, - &adapter->curbssparams.ssid, sizeof(struct WLAN_802_11_SSID)); - memcpy(adapter->previousbssid, - adapter->curbssparams.bssid, ETH_ALEN); + memcpy(&adapter->prev_ssid, &adapter->curbssparams.ssid, + IW_ESSID_MAX_SIZE); + adapter->prev_ssid_len = adapter->curbssparams.ssid_len; + memcpy(adapter->prev_bssid, adapter->curbssparams.bssid, ETH_ALEN); /* Clear out associated SSID and BSSID since connection is * no longer valid. */ memset(&adapter->curbssparams.bssid, 0, ETH_ALEN); - memset(&adapter->curbssparams.ssid, 0, sizeof(struct WLAN_802_11_SSID)); + memset(&adapter->curbssparams.ssid, 0, IW_ESSID_MAX_SIZE); + adapter->curbssparams.ssid_len = 0; if (adapter->psstate != PS_STATE_FULL_POWER) { /* make firmware to exit PS mode */ diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c index b62ebca9ab6..902b4be19d4 100644 --- a/drivers/net/wireless/libertas/debugfs.c +++ b/drivers/net/wireless/libertas/debugfs.c @@ -84,7 +84,8 @@ static ssize_t libertas_getscantable(struct file *file, char __user *userbuf, iter_bss->cap.spectrummgmt ? 'S' : ' '); pos += snprintf(buf+pos, len-pos, " %08llx |", iter_bss->networktsf); pos += snprintf(buf+pos, len-pos, " %d |", SCAN_RSSI(iter_bss->rssi)); - pos += snprintf(buf+pos, len-pos, " %s\n", iter_bss->ssid.ssid); + pos += snprintf(buf+pos, len-pos, " %s\n", + escape_essid(iter_bss->ssid, iter_bss->ssid_len)); numscansdone++; } @@ -174,7 +175,6 @@ static ssize_t libertas_extscan(struct file *file, const char __user *userbuf, { wlan_private *priv = file->private_data; ssize_t res, buf_size; - struct WLAN_802_11_SSID extscan_ssid; union iwreq_data wrqu; unsigned long addr = get_zeroed_page(GFP_KERNEL); char *buf = (char *)addr; @@ -185,10 +185,7 @@ static ssize_t libertas_extscan(struct file *file, const char __user *userbuf, goto out_unlock; } - memcpy(&extscan_ssid.ssid, buf, strlen(buf)-1); - extscan_ssid.ssidlength = strlen(buf)-1; - - libertas_send_specific_SSID_scan(priv, &extscan_ssid, 0); + libertas_send_specific_SSID_scan(priv, buf, strlen(buf)-1, 0); memset(&wrqu, 0, sizeof(union iwreq_data)); wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL); diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h index 91ac744ab9b..d6c340aef68 100644 --- a/drivers/net/wireless/libertas/dev.h +++ b/drivers/net/wireless/libertas/dev.h @@ -66,7 +66,8 @@ struct current_bss_params { /** bssid */ u8 bssid[ETH_ALEN]; /** ssid */ - struct WLAN_802_11_SSID ssid; + u8 ssid[IW_ESSID_MAX_SIZE + 1]; + u8 ssid_len; /** band */ u8 band; @@ -178,7 +179,8 @@ struct assoc_request { #define ASSOC_FLAG_WPA_IE 11 unsigned long flags; - struct WLAN_802_11_SSID ssid; + u8 ssid[IW_ESSID_MAX_SIZE + 1]; + u8 ssid_len; u8 channel; u8 band; u8 mode; @@ -256,8 +258,9 @@ struct _wlan_adapter { /* IW_MODE_* */ u8 mode; - struct WLAN_802_11_SSID previousssid; - u8 previousbssid[ETH_ALEN]; + u8 prev_ssid[IW_ESSID_MAX_SIZE + 1]; + u8 prev_ssid_len; + u8 prev_bssid[ETH_ALEN]; /* Scan results list */ struct list_head network_list; diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h index dc66cf52533..0a3a89905e2 100644 --- a/drivers/net/wireless/libertas/hostcmd.h +++ b/drivers/net/wireless/libertas/hostcmd.h @@ -102,14 +102,6 @@ struct IE_WPA { __le16 version; }; -struct WLAN_802_11_SSID { - /* SSID length */ - __le32 ssidlength; - - /* SSID information field */ - u8 ssid[IW_ESSID_MAX_SIZE]; -}; - struct WPA_SUPPLICANT { u8 wpa_ie[256]; u8 wpa_ie_len; diff --git a/drivers/net/wireless/libertas/join.c b/drivers/net/wireless/libertas/join.c index b728f7fb9e3..1f866aa29a6 100644 --- a/drivers/net/wireless/libertas/join.c +++ b/drivers/net/wireless/libertas/join.c @@ -184,18 +184,20 @@ int libertas_join_adhoc_network(wlan_private * priv, struct assoc_request * asso struct bss_descriptor * bss = &assoc_req->bss; int ret = 0; - lbs_deb_join("libertas_join_adhoc_network: CurBss.ssid =%s\n", - adapter->curbssparams.ssid.ssid); - lbs_deb_join("libertas_join_adhoc_network: CurBss.ssid_len =%u\n", - adapter->curbssparams.ssid.ssidlength); - lbs_deb_join("libertas_join_adhoc_network: ssid = '%s'\n", - bss->ssid.ssid); - lbs_deb_join("libertas_join_adhoc_network: ssid len = %u\n", - bss->ssid.ssidlength); + lbs_deb_join("%s: Current SSID '%s', ssid length %u\n", + __func__, + escape_essid(adapter->curbssparams.ssid, + adapter->curbssparams.ssid_len), + adapter->curbssparams.ssid_len); + lbs_deb_join("%s: requested ssid '%s', ssid length %u\n", + __func__, escape_essid(bss->ssid, bss->ssid_len), + bss->ssid_len); /* check if the requested SSID is already joined */ - if (adapter->curbssparams.ssid.ssidlength - && !libertas_SSID_cmp(&bss->ssid, &adapter->curbssparams.ssid) + if (adapter->curbssparams.ssid_len + && !libertas_SSID_cmp(adapter->curbssparams.ssid, + adapter->curbssparams.ssid_len, + bss->ssid, bss->ssid_len) && (adapter->mode == IW_MODE_ADHOC)) { lbs_deb_join( "ADHOC_J_CMD: New ad-hoc SSID is the same as current, " @@ -362,9 +364,9 @@ int libertas_cmd_80211_associate(wlan_private * priv, ssid = (struct mrvlietypes_ssidparamset *) pos; ssid->header.type = cpu_to_le16(TLV_TYPE_SSID); - tmplen = bss->ssid.ssidlength; + tmplen = bss->ssid_len; ssid->header.len = cpu_to_le16(tmplen); - memcpy(ssid->ssid, bss->ssid.ssid, tmplen); + memcpy(ssid->ssid, bss->ssid, tmplen); pos += sizeof(ssid->header) + tmplen; phy = (struct mrvlietypes_phyparamset *) pos; @@ -482,9 +484,11 @@ int libertas_cmd_80211_ad_hoc_start(wlan_private * priv, */ memset(adhs->SSID, 0, IW_ESSID_MAX_SIZE); - memcpy(adhs->SSID, assoc_req->ssid.ssid, assoc_req->ssid.ssidlength); + memcpy(adhs->SSID, assoc_req->ssid, assoc_req->ssid_len); - lbs_deb_join("ADHOC_S_CMD: SSID = %s\n", adhs->SSID); + lbs_deb_join("ADHOC_S_CMD: SSID '%s', ssid length %u\n", + escape_essid(assoc_req->ssid, assoc_req->ssid_len), + assoc_req->ssid_len); /* set the BSS type */ adhs->bsstype = cmd_bss_type_ibss; @@ -600,7 +604,7 @@ int libertas_cmd_80211_ad_hoc_join(wlan_private * priv, padhocjoin->bssdescriptor.beaconperiod = cpu_to_le16(bss->beaconperiod); memcpy(&padhocjoin->bssdescriptor.BSSID, &bss->bssid, ETH_ALEN); - memcpy(&padhocjoin->bssdescriptor.SSID, &bss->ssid.ssid, bss->ssid.ssidlength); + memcpy(&padhocjoin->bssdescriptor.SSID, &bss->ssid, bss->ssid_len); memcpy(&padhocjoin->bssdescriptor.phyparamset, &bss->phyparamset, sizeof(union ieeetypes_phyparamset)); @@ -733,11 +737,12 @@ int libertas_ret_80211_associate(wlan_private * priv, /* Send a Media Connected event, according to the Spec */ adapter->connect_status = libertas_connected; - lbs_deb_join("ASSOC_RESP: %s\n", bss->ssid.ssid); + lbs_deb_join("ASSOC_RESP: assocated to '%s'\n", + escape_essid(bss->ssid, bss->ssid_len)); /* Update current SSID and BSSID */ - memcpy(&adapter->curbssparams.ssid, - &bss->ssid, sizeof(struct WLAN_802_11_SSID)); + memcpy(&adapter->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE); + adapter->curbssparams.ssid_len = bss->ssid_len; memcpy(adapter->curbssparams.bssid, bss->bssid, ETH_ALEN); lbs_deb_join("ASSOC_RESP: currentpacketfilter is %x\n", @@ -821,7 +826,8 @@ int libertas_ret_80211_ad_hoc_start(wlan_private * priv, * Now the join cmd should be successful * If BSSID has changed use SSID to compare instead of BSSID */ - lbs_deb_join("ADHOC_RESP: %s\n", bss->ssid.ssid); + lbs_deb_join("ADHOC_RESP: associated to '%s'\n", + escape_essid(bss->ssid, bss->ssid_len)); /* Send a Media Connected event, according to the Spec */ adapter->connect_status = libertas_connected; @@ -835,8 +841,8 @@ int libertas_ret_80211_ad_hoc_start(wlan_private * priv, memcpy(&adapter->curbssparams.bssid, bss->bssid, ETH_ALEN); /* Set the new SSID to current SSID */ - memcpy(&adapter->curbssparams.ssid, &bss->ssid, - sizeof(struct WLAN_802_11_SSID)); + memcpy(&adapter->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE); + adapter->curbssparams.ssid_len = bss->ssid_len; netif_carrier_on(priv->dev); netif_wake_queue(priv->dev); diff --git a/drivers/net/wireless/libertas/join.h b/drivers/net/wireless/libertas/join.h index c84e33cf875..d522630ff8c 100644 --- a/drivers/net/wireless/libertas/join.h +++ b/drivers/net/wireless/libertas/join.h @@ -40,9 +40,6 @@ extern int libertas_ret_80211_associate(wlan_private * priv, extern int libertas_reassociation_thread(void *data); -struct WLAN_802_11_SSID; -struct bss_descriptor; - extern int libertas_start_adhoc_network(wlan_private * priv, struct assoc_request * assoc_req); extern int libertas_join_adhoc_network(wlan_private * priv, diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c index 9799d87aaa3..5790e8bc1ae 100644 --- a/drivers/net/wireless/libertas/scan.c +++ b/drivers/net/wireless/libertas/scan.c @@ -232,6 +232,7 @@ static void wlan_scan_process_results(wlan_private * priv) { wlan_adapter *adapter = priv->adapter; struct bss_descriptor * iter_bss; + int i = 0; if (adapter->connect_status == libertas_connected) return; @@ -240,7 +241,7 @@ static void wlan_scan_process_results(wlan_private * priv) list_for_each_entry (iter_bss, &adapter->network_list, list) { lbs_deb_scan("Scan:(%02d) " MAC_FMT ", RSSI[%03d], SSID[%s]\n", i++, MAC_ARG(iter_bss->bssid), (s32) iter_bss->rssi, - iter_bss->ssid.ssid); + escape_essid(iter_bss->ssid, iter_bss->ssid_len)); } mutex_unlock(&adapter->lock); } @@ -747,8 +748,8 @@ clear_selected_scan_list_entries(wlan_adapter * adapter, /* Check for an SSID match */ if ( clear_ssid_flag - && (bss->ssid.ssidlength == scan_cfg->ssid_len) - && !memcmp(bss->ssid.ssid, scan_cfg->ssid, bss->ssid.ssidlength)) + && (bss->ssid_len == scan_cfg->ssid_len) + && !memcmp(bss->ssid, scan_cfg->ssid, bss->ssid_len)) clear = 1; /* Check for a BSSID match */ @@ -1048,9 +1049,11 @@ static int libertas_process_bss(struct bss_descriptor * bss, switch (elemID) { case SSID: - bss->ssid.ssidlength = elemlen; - memcpy(bss->ssid.ssid, (pcurrentptr + 2), elemlen); - lbs_deb_scan("ssid '%s'\n", bss->ssid.ssid); + bss->ssid_len = elemlen; + memcpy(bss->ssid, (pcurrentptr + 2), elemlen); + lbs_deb_scan("ssid '%s', ssid length %u\n", + escape_essid(bss->ssid, bss->ssid_len), + bss->ssid_len); break; case SUPPORTED_RATES: @@ -1194,15 +1197,12 @@ done: * * @return 0--ssid is same, otherwise is different */ -int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, struct WLAN_802_11_SSID *ssid2) +int libertas_SSID_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len) { - if (!ssid1 || !ssid2) + if (ssid1_len != ssid2_len) return -1; - if (ssid1->ssidlength != ssid2->ssidlength) - return -1; - - return memcmp(ssid1->ssid, ssid2->ssid, ssid1->ssidlength); + return memcmp(ssid1, ssid2, ssid1_len); } /** @@ -1262,7 +1262,7 @@ struct bss_descriptor * libertas_find_BSSID_in_list(wlan_adapter * adapter, * @return index in BSSID list */ struct bss_descriptor * libertas_find_SSID_in_list(wlan_adapter * adapter, - struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode, + u8 *ssid, u8 ssid_len, u8 * bssid, u8 mode, int channel) { u8 bestrssi = 0; @@ -1277,7 +1277,8 @@ struct bss_descriptor * libertas_find_SSID_in_list(wlan_adapter * adapter, || (iter_bss->last_scanned < tmp_oldest->last_scanned)) tmp_oldest = iter_bss; - if (libertas_SSID_cmp(&iter_bss->ssid, ssid) != 0) + if (libertas_SSID_cmp(iter_bss->ssid, iter_bss->ssid_len, + ssid, ssid_len) != 0) continue; /* ssid doesn't match */ if (bssid && compare_ether_addr(iter_bss->bssid, bssid) != 0) continue; /* bssid doesn't match */ @@ -1369,8 +1370,7 @@ struct bss_descriptor * libertas_find_best_SSID_in_list(wlan_adapter * adapter, * @return 0--success, otherwise--fail */ int libertas_find_best_network_SSID(wlan_private * priv, - struct WLAN_802_11_SSID *ssid, - u8 preferred_mode, u8 *out_mode) + u8 *out_ssid, u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode) { wlan_adapter *adapter = priv->adapter; int ret = -1; @@ -1378,8 +1378,6 @@ int libertas_find_best_network_SSID(wlan_private * priv, lbs_deb_enter(LBS_DEB_ASSOC); - memset(ssid, 0, sizeof(struct WLAN_802_11_SSID)); - wlan_scan_networks(priv, NULL, 1); if (adapter->surpriseremoved) return -1; @@ -1387,8 +1385,9 @@ int libertas_find_best_network_SSID(wlan_private * priv, wait_event_interruptible(adapter->cmd_pending, !adapter->nr_cmd_pending); found = libertas_find_best_SSID_in_list(adapter, preferred_mode); - if (found && (found->ssid.ssidlength > 0)) { - memcpy(ssid, &found->ssid, sizeof(struct WLAN_802_11_SSID)); + if (found && (found->ssid_len > 0)) { + memcpy(out_ssid, &found->ssid, IW_ESSID_MAX_SIZE); + *out_ssid_len = found->ssid_len; *out_mode = found->mode; ret = 0; } @@ -1434,8 +1433,7 @@ int libertas_set_scan(struct net_device *dev, struct iw_request_info *info, * @return 0-success, otherwise fail */ int libertas_send_specific_SSID_scan(wlan_private * priv, - struct WLAN_802_11_SSID *prequestedssid, - u8 clear_ssid) + u8 *ssid, u8 ssid_len, u8 clear_ssid) { wlan_adapter *adapter = priv->adapter; struct wlan_ioctl_user_scan_cfg scancfg; @@ -1443,12 +1441,12 @@ int libertas_send_specific_SSID_scan(wlan_private * priv, lbs_deb_enter(LBS_DEB_ASSOC); - if (prequestedssid == NULL) + if (!ssid_len) goto out; memset(&scancfg, 0x00, sizeof(scancfg)); - memcpy(scancfg.ssid, prequestedssid->ssid, prequestedssid->ssidlength); - scancfg.ssid_len = prequestedssid->ssidlength; + memcpy(scancfg.ssid, ssid, ssid_len); + scancfg.ssid_len = ssid_len; scancfg.clear_ssid = clear_ssid; wlan_scan_networks(priv, &scancfg, 1); @@ -1523,8 +1521,8 @@ static inline char *libertas_translate_scan(wlan_private *priv, /* SSID */ iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; - iwe.u.data.length = min(bss->ssid.ssidlength, (u32) IW_ESSID_MAX_SIZE); - start = iwe_stream_add_point(start, stop, &iwe, bss->ssid.ssid); + iwe.u.data.length = min((u32) bss->ssid_len, (u32) IW_ESSID_MAX_SIZE); + start = iwe_stream_add_point(start, stop, &iwe, bss->ssid); /* Mode */ iwe.cmd = SIOCGIWMODE; @@ -1563,7 +1561,9 @@ static inline char *libertas_translate_scan(wlan_private *priv, */ if ((adapter->mode == IW_MODE_ADHOC) && adapter->adhoccreate - && !libertas_SSID_cmp(&adapter->curbssparams.ssid, &bss->ssid)) { + && !libertas_SSID_cmp(adapter->curbssparams.ssid, + adapter->curbssparams.ssid_len, + bss->ssid, bss->ssid_len)) { int snr, nf; snr = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; nf = adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; @@ -1579,7 +1579,7 @@ static inline char *libertas_translate_scan(wlan_private *priv, iwe.u.data.flags = IW_ENCODE_DISABLED; } iwe.u.data.length = 0; - start = iwe_stream_add_point(start, stop, &iwe, bss->ssid.ssid); + start = iwe_stream_add_point(start, stop, &iwe, bss->ssid); current_val = start + IW_EV_LCP_LEN; @@ -1598,7 +1598,9 @@ static inline char *libertas_translate_scan(wlan_private *priv, stop, &iwe, IW_EV_PARAM_LEN); } if ((bss->mode == IW_MODE_ADHOC) - && !libertas_SSID_cmp(&adapter->curbssparams.ssid, &bss->ssid) + && !libertas_SSID_cmp(adapter->curbssparams.ssid, + adapter->curbssparams.ssid_len, + bss->ssid, bss->ssid_len) && adapter->adhoccreate) { iwe.u.bitrate.value = 22 * 500000; current_val = iwe_stream_add_value(start, current_val, @@ -1753,10 +1755,10 @@ static inline int is_same_network(struct bss_descriptor *src, /* A network is only a duplicate if the channel, BSSID, and ESSID * all match. We treat all with the same BSSID and channel * as one network */ - return ((src->ssid.ssidlength == dst->ssid.ssidlength) && + return ((src->ssid_len == dst->ssid_len) && (src->channel == dst->channel) && !compare_ether_addr(src->bssid, dst->bssid) && - !memcmp(src->ssid.ssid, dst->ssid.ssid, src->ssid.ssidlength)); + !memcmp(src->ssid, dst->ssid, src->ssid_len)); } /** diff --git a/drivers/net/wireless/libertas/scan.h b/drivers/net/wireless/libertas/scan.h index 60a09e347f4..9ace3478c62 100644 --- a/drivers/net/wireless/libertas/scan.h +++ b/drivers/net/wireless/libertas/scan.h @@ -137,7 +137,8 @@ struct wlan_ioctl_user_scan_cfg { struct bss_descriptor { u8 bssid[ETH_ALEN]; - struct WLAN_802_11_SSID ssid; + u8 ssid[IW_ESSID_MAX_SIZE + 1]; + u8 ssid_len; /* WEP encryption requirement */ u32 privacy; @@ -174,11 +175,10 @@ struct bss_descriptor { struct list_head list; }; -extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, - struct WLAN_802_11_SSID *ssid2); +extern int libertas_SSID_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len); struct bss_descriptor * libertas_find_SSID_in_list(wlan_adapter * adapter, - struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode, + u8 *ssid, u8 ssid_len, u8 * bssid, u8 mode, int channel); struct bss_descriptor * libertas_find_best_SSID_in_list(wlan_adapter * adapter, @@ -187,13 +187,11 @@ struct bss_descriptor * libertas_find_best_SSID_in_list(wlan_adapter * adapter, extern struct bss_descriptor * libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode); -int libertas_find_best_network_SSID(wlan_private * priv, - struct WLAN_802_11_SSID *pSSID, - u8 preferred_mode, u8 *out_mode); +int libertas_find_best_network_SSID(wlan_private * priv, u8 *out_ssid, + u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode); -extern int libertas_send_specific_SSID_scan(wlan_private * priv, - struct WLAN_802_11_SSID *prequestedssid, - u8 clear_ssid); +extern int libertas_send_specific_SSID_scan(wlan_private * priv, u8 *ssid, + u8 ssid_len, u8 clear_ssid); extern int libertas_send_specific_BSSID_scan(wlan_private * priv, u8 * bssid, u8 clear_bssid); diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c index 5b7e5f257d6..8939251a2f4 100644 --- a/drivers/net/wireless/libertas/wext.c +++ b/drivers/net/wireless/libertas/wext.c @@ -2163,12 +2163,12 @@ static int wlan_get_essid(struct net_device *dev, struct iw_request_info *info, * Get the current SSID */ if (adapter->connect_status == libertas_connected) { - memcpy(extra, adapter->curbssparams.ssid.ssid, - adapter->curbssparams.ssid.ssidlength); - extra[adapter->curbssparams.ssid.ssidlength] = '\0'; + memcpy(extra, adapter->curbssparams.ssid, + adapter->curbssparams.ssid_len); + extra[adapter->curbssparams.ssid_len] = '\0'; } else { memset(extra, 0, 32); - extra[adapter->curbssparams.ssid.ssidlength] = '\0'; + extra[adapter->curbssparams.ssid_len] = '\0'; } /* * If none, we may want to get the one that was set @@ -2176,10 +2176,10 @@ static int wlan_get_essid(struct net_device *dev, struct iw_request_info *info, /* To make the driver backward compatible with WPA supplicant v0.2.4 */ if (dwrq->length == 32) /* check with WPA supplicant buffer size */ - dwrq->length = min_t(size_t, adapter->curbssparams.ssid.ssidlength, + dwrq->length = min_t(size_t, adapter->curbssparams.ssid_len, IW_ESSID_MAX_SIZE); else - dwrq->length = adapter->curbssparams.ssid.ssidlength + 1; + dwrq->length = adapter->curbssparams.ssid_len + 1; dwrq->flags = 1; /* active */ @@ -2193,9 +2193,10 @@ static int wlan_set_essid(struct net_device *dev, struct iw_request_info *info, wlan_private *priv = dev->priv; wlan_adapter *adapter = priv->adapter; int ret = 0; - struct WLAN_802_11_SSID ssid; + u8 ssid[IW_ESSID_MAX_SIZE]; + u8 ssid_len = 0; struct assoc_request * assoc_req; - int ssid_len = dwrq->length; + int in_ssid_len = dwrq->length; lbs_deb_enter(LBS_DEB_WEXT); @@ -2204,27 +2205,31 @@ static int wlan_set_essid(struct net_device *dev, struct iw_request_info *info, * SSID length so it can be used like a string. WE-21 and later don't, * but some userspace tools aren't able to cope with the change. */ - if ((ssid_len > 0) && (extra[ssid_len - 1] == '\0')) - ssid_len--; + if ((in_ssid_len > 0) && (extra[in_ssid_len - 1] == '\0')) + in_ssid_len--; /* Check the size of the string */ - if (ssid_len > IW_ESSID_MAX_SIZE) { + if (in_ssid_len > IW_ESSID_MAX_SIZE) { ret = -E2BIG; goto out; } - memset(&ssid, 0, sizeof(struct WLAN_802_11_SSID)); + memset(&ssid, 0, sizeof(ssid)); - if (!dwrq->flags || !ssid_len) { + if (!dwrq->flags || !in_ssid_len) { /* "any" SSID requested; leave SSID blank */ } else { /* Specific SSID requested */ - memcpy(&ssid.ssid, extra, ssid_len); - ssid.ssidlength = ssid_len; + memcpy(&ssid, extra, in_ssid_len); + ssid_len = in_ssid_len; } - lbs_deb_wext("requested new SSID '%s'\n", - (ssid.ssidlength > 0) ? (char *)ssid.ssid : "any"); + if (!ssid_len) { + lbs_deb_wext("requested any SSID\n"); + } else { + lbs_deb_wext("requested SSID '%s'\n", + escape_essid(ssid, ssid_len)); + } out: mutex_lock(&adapter->lock); @@ -2235,7 +2240,8 @@ out: ret = -ENOMEM; } else { /* Copy the SSID to the association request */ - memcpy(&assoc_req->ssid, &ssid, sizeof(struct WLAN_802_11_SSID)); + memcpy(&assoc_req->ssid, &ssid, IW_ESSID_MAX_SIZE); + assoc_req->ssid_len = ssid_len; set_bit(ASSOC_FLAG_SSID, &assoc_req->flags); wlan_postpone_association_work(priv); } -- cgit v1.2.3