Skip to content

Commit

Permalink
[PATCH] libertas: remove structure WLAN_802_11_SSID and libertas_esca…
Browse files Browse the repository at this point in the history
…pe_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 <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Dan Williams authored and John W. Linville committed Jun 11, 2007
1 parent 785e8f2 commit d8efea2
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 160 deletions.
1 change: 1 addition & 0 deletions drivers/net/wireless/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
74 changes: 26 additions & 48 deletions drivers/net/wireless/libertas/assoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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" : "",
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand Down
23 changes: 13 additions & 10 deletions drivers/net/wireless/libertas/cmdresp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
9 changes: 3 additions & 6 deletions drivers/net/wireless/libertas/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions drivers/net/wireless/libertas/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions drivers/net/wireless/libertas/hostcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
48 changes: 27 additions & 21 deletions drivers/net/wireless/libertas/join.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, "
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions drivers/net/wireless/libertas/join.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit d8efea2

Please sign in to comment.