2008-09-24 23:04:38

by John W. Linville

[permalink] [raw]
Subject: [PATCH] wireless: consolidate on a single escape_essid implementation

This is also an excuse to create the long rumored lib80211 module...

Signed-off-by: John W. Linville <[email protected]>
---
Wtf...

drivers/net/wireless/Kconfig | 1 +
drivers/net/wireless/ipw2200.h | 1 +
drivers/net/wireless/iwlwifi/Kconfig | 2 +
drivers/net/wireless/iwlwifi/iwl-scan.c | 53 +++---------------------
drivers/net/wireless/iwlwifi/iwl3945-base.c | 48 ++--------------------
drivers/net/wireless/libertas/assoc.c | 2 +
drivers/net/wireless/libertas/cmd.c | 1 +
drivers/net/wireless/libertas/debugfs.c | 1 +
drivers/net/wireless/libertas/decl.h | 4 --
drivers/net/wireless/libertas/main.c | 27 ------------
drivers/net/wireless/libertas/scan.c | 3 +
drivers/net/wireless/libertas/wext.c | 1 +
include/net/ieee80211.h | 20 ---------
include/net/lib80211.h | 31 ++++++++++++++
net/ieee80211/Kconfig | 1 +
net/ieee80211/ieee80211_module.c | 26 ------------
net/ieee80211/ieee80211_rx.c | 9 ++--
net/wireless/Kconfig | 10 +++++
net/wireless/Makefile | 1 +
net/wireless/lib80211.c | 58 +++++++++++++++++++++++++++
20 files changed, 128 insertions(+), 172 deletions(-)
create mode 100644 include/net/lib80211.h
create mode 100644 net/wireless/lib80211.c

diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 1edbdc2..6a81a03 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -271,6 +271,7 @@ config LIBERTAS
tristate "Marvell 8xxx Libertas WLAN driver support"
depends on WLAN_80211
select WIRELESS_EXT
+ select LIB80211
select FW_LOADER
---help---
A library for Marvell Libertas 8xxx devices.
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index 0bad1ec..0a84d52 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -48,6 +48,7 @@
#include <linux/jiffies.h>
#include <asm/io.h>

+#include <net/lib80211.h>
#include <net/ieee80211.h>
#include <net/ieee80211_radiotap.h>

diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index b0ac0ce..47bee0e 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -4,6 +4,7 @@ config IWLWIFI
config IWLCORE
tristate "Intel Wireless Wifi Core"
depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
+ select LIB80211
select IWLWIFI
select MAC80211_LEDS if IWLWIFI_LEDS
select LEDS_CLASS if IWLWIFI_LEDS
@@ -105,6 +106,7 @@ config IWL3945
tristate "Intel PRO/Wireless 3945ABG/BG Network Connection"
depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
select FW_LOADER
+ select LIB80211
select IWLWIFI
select MAC80211_LEDS if IWL3945_LEDS
select LEDS_CLASS if IWL3945_LEDS
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index bf855c3..dd77eeb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -25,8 +25,10 @@
* Tomas Winkler <[email protected]>
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*****************************************************************************/
-#include <net/mac80211.h>
+#include <linux/types.h>
#include <linux/etherdevice.h>
+#include <net/lib80211.h>
+#include <net/mac80211.h>

#include "iwl-eeprom.h"
#include "iwl-dev.h"
@@ -69,49 +71,6 @@ static int scan_tx_ant[3] = {
};


-
-static int iwl_is_empty_essid(const char *essid, int essid_len)
-{
- /* Single white space is for Linksys APs */
- if (essid_len == 1 && essid[0] == ' ')
- return 1;
-
- /* Otherwise, if the entire essid is 0, we assume it is hidden */
- while (essid_len) {
- essid_len--;
- if (essid[essid_len] != '\0')
- return 0;
- }
-
- return 1;
-}
-
-
-
-static const char *iwl_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 (iwl_is_empty_essid(essid, essid_len)) {
- memcpy(escaped, "<hidden>", sizeof("<hidden>"));
- return escaped;
- }
-
- 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;
-}
-
/**
* iwl_scan_cancel - Cancel any currently executing HW scan
*
@@ -796,8 +755,8 @@ static void iwl_bg_request_scan(struct work_struct *data)
/* We should add the ability for user to lock to PASSIVE ONLY */
if (priv->one_direct_scan) {
IWL_DEBUG_SCAN("Start direct scan for '%s'\n",
- iwl_escape_essid(priv->direct_ssid,
- priv->direct_ssid_len));
+ escape_essid(priv->direct_ssid,
+ priv->direct_ssid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->direct_ssid_len;
memcpy(scan->direct_scan[0].ssid,
@@ -805,7 +764,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
n_probes++;
} else if (!iwl_is_associated(priv) && priv->essid_len) {
IWL_DEBUG_SCAN("Start direct scan for '%s' (not associated)\n",
- iwl_escape_essid(priv->essid, priv->essid_len));
+ escape_essid(priv->essid, priv->essid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->essid_len;
memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index d15a2c9..0dad24c 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -41,6 +41,7 @@
#include <linux/if_arp.h>

#include <net/ieee80211_radiotap.h>
+#include <net/lib80211.h>
#include <net/mac80211.h>

#include <asm/div64.h>
@@ -107,46 +108,6 @@ static const struct ieee80211_supported_band *iwl3945_get_band(
return priv->hw->wiphy->bands[band];
}

-static int iwl3945_is_empty_essid(const char *essid, int essid_len)
-{
- /* Single white space is for Linksys APs */
- if (essid_len == 1 && essid[0] == ' ')
- return 1;
-
- /* Otherwise, if the entire essid is 0, we assume it is hidden */
- while (essid_len) {
- essid_len--;
- if (essid[essid_len] != '\0')
- return 0;
- }
-
- return 1;
-}
-
-static const char *iwl3945_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 (iwl3945_is_empty_essid(essid, essid_len)) {
- memcpy(escaped, "<hidden>", sizeof("<hidden>"));
- return escaped;
- }
-
- 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;
-}
-
/*************** DMA-QUEUE-GENERAL-FUNCTIONS *****
* DMA services
*
@@ -6202,8 +6163,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
if (priv->one_direct_scan) {
IWL_DEBUG_SCAN
("Kicking off one direct scan for '%s'\n",
- iwl3945_escape_essid(priv->direct_ssid,
- priv->direct_ssid_len));
+ escape_essid(priv->direct_ssid, priv->direct_ssid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->direct_ssid_len;
memcpy(scan->direct_scan[0].ssid,
@@ -6212,7 +6172,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
} else if (!iwl3945_is_associated(priv) && priv->essid_len) {
IWL_DEBUG_SCAN
("Kicking off one direct scan for '%s' when not associated\n",
- iwl3945_escape_essid(priv->essid, priv->essid_len));
+ escape_essid(priv->essid, priv->essid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->essid_len;
memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
@@ -7031,7 +6991,7 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
}
if (len) {
IWL_DEBUG_SCAN("direct scan for %s [%d]\n ",
- iwl3945_escape_essid(ssid, len), (int)len);
+ escape_essid(ssid, len), (int)len);

priv->one_direct_scan = 1;
priv->direct_ssid_len = (u8)
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 92be604..0bf763d 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -1,6 +1,8 @@
/* Copyright (C) 2006, Red Hat, Inc. */

+#include <linux/types.h>
#include <linux/etherdevice.h>
+#include <net/lib80211.h>

#include "assoc.h"
#include "decl.h"
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index aee19fa..47f3dd4 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -4,6 +4,7 @@
*/

#include <net/iw_handler.h>
+#include <net/lib80211.h>
#include <net/ieee80211.h>
#include <linux/kfifo.h>
#include "host.h"
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 0aa0ce3..70b9e3e 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -5,6 +5,7 @@
#include <linux/mm.h>
#include <linux/string.h>
#include <net/iw_handler.h>
+#include <net/lib80211.h>

#include "dev.h"
#include "decl.h"
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h
index 1a8888c..0b84bdc 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -74,8 +74,4 @@ void lbs_host_to_card_done(struct lbs_private *priv);

int lbs_update_channel(struct lbs_private *priv);

-#ifndef CONFIG_IEEE80211
-const char *escape_essid(const char *essid, u8 essid_len);
-#endif
-
#endif
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 73dc8c7..b30e845 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -1647,33 +1647,6 @@ out:
return ret;
}

-#ifndef CONFIG_IEEE80211
-const char *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)) {
- memcpy(escaped, "<hidden>", sizeof("<hidden>"));
- return escaped;
- }
-
- 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;
-}
-#endif
-
module_init(lbs_init_module);
module_exit(lbs_exit_module);

diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 8f66903..6638e3f 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -4,9 +4,12 @@
* IOCTL handlers as well as command preperation and response routines
* for sending scan commands to the firmware.
*/
+#include <linux/types.h>
#include <linux/etherdevice.h>
#include <asm/unaligned.h>

+#include <net/lib80211.h>
+
#include "host.h"
#include "decl.h"
#include "dev.h"
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 6ebdd7f..7ecc2c7 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -8,6 +8,7 @@
#include <linux/wireless.h>
#include <linux/bitops.h>

+#include <net/lib80211.h>
#include <net/ieee80211.h>
#include <net/iw_handler.h>

diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index b31399e..c7daa1d 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -127,10 +127,6 @@ static inline bool ieee80211_ratelimit_debug(u32 level)
}
#endif /* CONFIG_IEEE80211_DEBUG */

-/* escape_essid() is intended to be used in debug (and possibly error)
- * messages. It should never be used for passing essid to user space. */
-const char *escape_essid(const char *essid, u8 essid_len);
-
/*
* To use the debug system:
*
@@ -1139,22 +1135,6 @@ static inline void *ieee80211_priv(struct net_device *dev)
return ((struct ieee80211_device *)netdev_priv(dev))->priv;
}

-static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
-{
- /* Single white space is for Linksys APs */
- if (essid_len == 1 && essid[0] == ' ')
- return 1;
-
- /* Otherwise, if the entire essid is 0, we assume it is hidden */
- while (essid_len) {
- essid_len--;
- if (essid[essid_len] != '\0')
- return 0;
- }
-
- return 1;
-}
-
static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee,
int mode)
{
diff --git a/include/net/lib80211.h b/include/net/lib80211.h
new file mode 100644
index 0000000..6be5a3d
--- /dev/null
+++ b/include/net/lib80211.h
@@ -0,0 +1,31 @@
+/*
+ * lib80211.h -- common bits for IEEE802.11 wireless drivers
+ *
+ * Copyright (c) 2008, John W. Linville <[email protected]>
+ *
+ */
+
+#ifndef LIB80211_H
+#define LIB80211_H
+
+/* escape_essid() is intended to be used in debug (and possibly error)
+ * messages. It should never be used for passing essid to user space. */
+const char *escape_essid(const char *essid, u8 essid_len);
+
+static inline int is_empty_essid(const char *essid, int essid_len)
+{
+ /* Single white space is for Linksys APs */
+ if (essid_len == 1 && essid[0] == ' ')
+ return 1;
+
+ /* Otherwise, if the entire essid is 0, we assume it is hidden */
+ while (essid_len) {
+ essid_len--;
+ if (essid[essid_len] != '\0')
+ return 0;
+ }
+
+ return 1;
+}
+
+#endif /* LIB80211_H */
diff --git a/net/ieee80211/Kconfig b/net/ieee80211/Kconfig
index 94ed7d3..dc3eeed 100644
--- a/net/ieee80211/Kconfig
+++ b/net/ieee80211/Kconfig
@@ -1,5 +1,6 @@
config IEEE80211
tristate "Generic IEEE 802.11 Networking Stack (DEPRECATED)"
+ select LIB80211
---help---
This option enables the hardware independent IEEE 802.11
networking stack. This component is deprecated in favor of the
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c
index 949772a..d34d4e7 100644
--- a/net/ieee80211/ieee80211_module.c
+++ b/net/ieee80211/ieee80211_module.c
@@ -308,31 +308,5 @@ MODULE_PARM_DESC(debug, "debug output mask");
module_exit(ieee80211_exit);
module_init(ieee80211_init);

-const char *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)) {
- memcpy(escaped, "<hidden>", sizeof("<hidden>"));
- return escaped;
- }
-
- 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;
-}
-
EXPORT_SYMBOL(alloc_ieee80211);
EXPORT_SYMBOL(free_ieee80211);
-EXPORT_SYMBOL(escape_essid);
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index 69dbc34..cea9090 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -32,6 +32,7 @@
#include <asm/uaccess.h>
#include <linux/ctype.h>

+#include <net/lib80211.h>
#include <net/ieee80211.h>

static void ieee80211_monitor_rx(struct ieee80211_device *ieee,
@@ -1166,8 +1167,8 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element

switch (info_element->id) {
case MFIE_TYPE_SSID:
- if (ieee80211_is_empty_essid(info_element->data,
- info_element->len)) {
+ if (is_empty_essid(info_element->data,
+ info_element->len)) {
network->flags |= NETWORK_EMPTY_ESSID;
break;
}
@@ -1411,7 +1412,7 @@ static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct iee
network->mode |= IEEE_B;
}

- if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
+ if (is_empty_essid(network->ssid, network->ssid_len))
network->flags |= NETWORK_EMPTY_ESSID;

memcpy(&network->stats, stats, sizeof(network->stats));
@@ -1485,7 +1486,7 @@ static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee8021
return 1;
}

- if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
+ if (is_empty_essid(network->ssid, network->ssid_len))
network->flags |= NETWORK_EMPTY_ESSID;

memcpy(&network->stats, stats, sizeof(network->stats));
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig
index b97bd9f..2efaa02 100644
--- a/net/wireless/Kconfig
+++ b/net/wireless/Kconfig
@@ -73,3 +73,13 @@ config WIRELESS_EXT_SYSFS

Say Y if you have programs using it, like old versions of
hal.
+
+config LIB80211
+ tristate "Common routines for IEEE802.11 drivers"
+ default n
+ help
+ This options enables a library of common routines used
+ by IEEE802.11 wireless LAN drivers.
+
+ Drivers should select this themselves if needed. Say Y if
+ you want this built into your kernel.
diff --git a/net/wireless/Makefile b/net/wireless/Makefile
index b9f943c..d2d848d 100644
--- a/net/wireless/Makefile
+++ b/net/wireless/Makefile
@@ -1,5 +1,6 @@
obj-$(CONFIG_WIRELESS_EXT) += wext.o
obj-$(CONFIG_CFG80211) += cfg80211.o
+obj-$(CONFIG_LIB80211) += lib80211.o

cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o
cfg80211-$(CONFIG_NL80211) += nl80211.o
diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c
new file mode 100644
index 0000000..44630b5
--- /dev/null
+++ b/net/wireless/lib80211.c
@@ -0,0 +1,58 @@
+/*
+ * lib80211 -- common bits for IEEE802.11 drivers
+ *
+ * Copyright(c) 2008 John W. Linville <[email protected]>
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/wireless.h>
+
+#include <net/lib80211.h>
+
+#define DRV_NAME "lib80211"
+
+#define DRV_DESCRIPTION "common routines for IEEE802.11 drivers"
+
+MODULE_DESCRIPTION(DRV_DESCRIPTION);
+MODULE_AUTHOR("John W. Linville <[email protected]>");
+MODULE_LICENSE("GPL");
+
+const char *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 (is_empty_essid(essid, essid_len)) {
+ memcpy(escaped, "<hidden>", sizeof("<hidden>"));
+ return escaped;
+ }
+
+ 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;
+}
+EXPORT_SYMBOL(escape_essid);
+
+static int __init ieee80211_init(void)
+{
+ printk(KERN_INFO DRV_NAME ": " DRV_DESCRIPTION "\n");
+ return 0;
+}
+
+static void __exit ieee80211_exit(void)
+{
+}
+
+module_init(ieee80211_init);
+module_exit(ieee80211_exit);
--
1.5.4.3



2008-09-26 14:57:25

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Thu, 2008-09-25 at 12:57 -0400, Dan Williams wrote:

Let me elaborate a bit on what my patch does

> 2) common GIWSCAN processing function that takes a list of common BSS
> structures that the driver stores internally. The common BSS structure
> would have a "void *driver_data" pointer in which the driver could keep
> driver-specific data items,

I actually am allocating space for it in the same struct, rather small
difference though.

> but the driver would be responsible for
> setting all available information in the common BSS structure when the
> firmware provides scan results. lib80211 provides common allocation,
> deallocation, bss entry aging, ref/unref, and free-list fetching.

What cfg80211 with my patch does is bind it to the wiphy, which you
really want to have anyway when taking advantage of the regulatory stuff
etc. It's currently not providing any deallocation function, but is
providing allocation (currently only based on a beacon/proberesp frame
but a new version can be provided), entry aging, ref/unref. List
fetching is notably absent, I was thinking an iterator function should
be provided if at all necessary, maybe the "find me an entry with these
characteristics" functions should just be expanded to have more optional
parameters. Then again, you may need to make decisions based on security
etc.

I have not so far thought about splitting out the information and
stuffed it all into an information element list that I'm internally
handling, for speed the SSID IE should probably be pointered explicitly
though.

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-09-25 04:50:09

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Thu, 2008-09-25 at 06:46 +0200, Johannes Berg wrote:

> > + 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;
> > +}
> > +EXPORT_SYMBOL(escape_essid);

Also, it seems like this should escape any non-printable characters, not
just NUL?

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-09-25 16:49:13

by Dan Williams

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Thu, 2008-09-25 at 06:46 +0200, Johannes Berg wrote:
> On Wed, 2008-09-24 at 18:15 -0400, John W. Linville wrote:
> > This is also an excuse to create the long rumored lib80211 module...
>
> Let's also take the chance to clean up the mess Intel has, once again,
> created here.
>
> > switch (info_element->id) {
> > case MFIE_TYPE_SSID:
> > - if (ieee80211_is_empty_essid(info_element->data,
> > - info_element->len)) {
> > + if (is_empty_essid(info_element->data,
> > + info_element->len)) {
> > network->flags |= NETWORK_EMPTY_ESSID;
> > break;
> > }
>
> You can remove the whole NETWORK_EMPTY_ESSID flag and this whole test;
> the code slightly below needs to take care to actually escape the SSID
> for the debug output.
>
> > @@ -1411,7 +1412,7 @@ static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct iee
> > network->mode |= IEEE_B;
> > }
> >
> > - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
> > + if (is_empty_essid(network->ssid, network->ssid_len))
> > network->flags |= NETWORK_EMPTY_ESSID;
>
> drop the whole if
>
> >
> > - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
> > + if (is_empty_essid(network->ssid, network->ssid_len))
> > network->flags |= NETWORK_EMPTY_ESSID;
>
> ditto.
>
> that leaves once place using the NETWORK_EMPTY_ESSID flag, in
> ieee80211_wx.c:
>
> /* Add the ESSID */
> iwe.cmd = SIOCGIWESSID;
> iwe.u.data.flags = 1;
> if (network->flags & NETWORK_EMPTY_ESSID) {
> iwe.u.data.length = sizeof("<hidden>");
> start = iwe_stream_add_point(info, start, stop,
> &iwe, "<hidden>");
> } else {
> iwe.u.data.length = min(network->ssid_len, (u8) 32);
> start = iwe_stream_add_point(info, start, stop,
> &iwe, network->ssid);
> }
>
> which is of course *completely* *wrong*. There's no excuse for messing
> up the values passed to userspace like that.
>
> > +const char *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 (is_empty_essid(essid, essid_len)) {
> > + memcpy(escaped, "<hidden>", sizeof("<hidden>"));
> > + return escaped;
> > + }
>
> Once you've done the above, is_empty_essid is only used here. I'll leave
> it to you whether you want to print <hidden> or not, I'd prefer if the
> function was to just escape the ASCII-NULs as normal since then you can
> actually distinguish the various forms of hidden SSIDs which might help.
> Maybe that needs quotes around the escaped SSID then.
>
> > + 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;
> > +}
> > +EXPORT_SYMBOL(escape_essid);
>
> Also, we could take the chance to stop making Jean's mistake in calling
> this thing the _E_SSID, there's no such thing, it's Jean's invention,
> based on his misguided thought that this might somehow be less confusing
> to the user.

+1

Dan


2008-09-25 23:03:34

by Dave Kilroy

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

Luis R. Rodriguez wrote:
> Which reminds me, net/ieee80211/ should be ipw'ized now that the
> old softmac drivers are gone.
>
> mcgrof@tesla ~/wireless-testing/drivers/net/wireless (git::v2.6.27-rc6)$ grep -nHr "#include <net/ieee80211.h>" *
> orinoco.c:88:#include <net/ieee80211.h>
>
> Whatever these suckers are using can probably be slapped in there as
> well. But yea -- we just need to get it done huh.

Almost all of what orinoco uses can now be sourced from <linux/ieee80211.h> instead. However there are the following constants:

Missing:
MAX_WPA_IE_LEN (64)
WEP_KEYS (4)

Possible alternative, but change in value:
IEEE80211_FRAME_LEN (2334) != IEEE80211_MAX_FRAME_LEN (2352)

Obviously these can be defined locally if we're not sure if they should be global, or where they belong.



Regards,

Dave.

2008-09-26 14:52:10

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Fri, 2008-09-26 at 13:08 +0200, Johannes Berg wrote:

> > 2) common GIWSCAN processing function that takes a list of common BSS
> > structures that the driver stores internally. The common BSS structure
> > would have a "void *driver_data" pointer in which the driver could keep
> > driver-specific data items, but the driver would be responsible for
> > setting all available information in the common BSS structure when the
> > firmware provides scan results. lib80211 provides common allocation,
> > deallocation, bss entry aging, ref/unref, and free-list fetching.
>
> I had something like this option 2 in mind when I wrote my patch, can
> you take a look at it? The only thing missing now is
> quality/signal/noise handling. Here's the most recent version:
>
> http://johannes.sipsolutions.net/patches/kernel/all/2008-09-26-11%3a08/020-cfg80211-scan.patch

That version no longer applies; some rejects you can ignore safely
though for purposes of this thread, but here's a new version anyway:

http://johannes.sipsolutions.net/patches/kernel/all/2008-09-26-13%3a11/008-cfg80211-scan.patch

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-09-25 06:34:35

by Holger Schurig

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

> the libertas, ipw2100, and ipw2200 drivers don't use cfg80211
> (at least for now).

Yeah, Dan once spoke about using cfg80211 for libertas, but at
that time I didn't saw the point.

Hmm, I actually don't see the point now :-)


But libertas (with debug code compiled in) uses escape_essid()
and thus can easily be using the lib80211.

2008-09-24 23:24:58

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Wed, Sep 24, 2008 at 03:15:36PM -0700, John W. Linville wrote:
> This is also an excuse to create the long rumored lib80211 module...

How about stuffing it in something like:

include/linux/wlandevice.h

Is there a benefit to having a module for it as this time?

Which reminds me, net/ieee80211/ should be ipw'ized now that the
old softmac drivers are gone.

mcgrof@tesla ~/wireless-testing/drivers/net/wireless (git::v2.6.27-rc6)$ grep -nHr "#include <net/ieee80211.h>" *
airo.c:50:#include <net/ieee80211.h>
atmel.c:70:#include <net/ieee80211.h>
hostap/hostap_main.c:29:#include <net/ieee80211.h>
hostap/hostap_hw.c:49:#include <net/ieee80211.h>
ipw2100.h:42:#include <net/ieee80211.h>
ipw2200.h:51:#include <net/ieee80211.h>
libertas/types.h:10:#include <net/ieee80211.h>
libertas/main.c:17:#include <net/ieee80211.h>
libertas/dev.h:13:#include <net/ieee80211.h>
libertas/wext.c:11:#include <net/ieee80211.h>
libertas/cmd.c:7:#include <net/ieee80211.h>
orinoco.c:88:#include <net/ieee80211.h>
rndis_wlan.c:44:#include <net/ieee80211.h>
wl3501.h:5:#include <net/ieee80211.h>
zd1201.c:24:#include <net/ieee80211.h>

Whatever these suckers are using can probably be slapped in there as
well. But yea -- we just need to get it done huh.

Thoughts?

Luis

2008-09-25 00:38:25

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Wed, Sep 24, 2008 at 05:21:17PM -0700, Luis R. Rodriguez wrote:
> On Wed, Sep 24, 2008 at 04:32:34PM -0700, John W. Linville wrote:
> > On Wed, Sep 24, 2008 at 04:24:53PM -0700, Luis R. Rodriguez wrote:
> > > On Wed, Sep 24, 2008 at 03:15:36PM -0700, John W. Linville wrote:
> > > > This is also an excuse to create the long rumored lib80211 module...
> > >
> > > How about stuffing it in something like:
> > >
> > > include/linux/wlandevice.h
> > >
> > > Is there a benefit to having a module for it as this time?
> >
> > The escape_essid function is currently not inlined. Are you
> > arguing that it should be?
>
> Just an idea, yes, but that's just because it didn't seem
> that escape_essid() in itself was enough reason to create a
> shiny new module.

Is there some huge cost I'm overlooking? If you are afraid of wasting
a page then build it into the kernel. Hopefully this module eventually
gets bigger anyway.

> > Otherwise it needs to live _somewhere_.
> > The cfg80211 module might make sense, except that the libertas,
> > ipw2100, and ipw2200 drivers don't use cfg80211 (at least for now).
>
> If we want a framework for FullMAC drivers I think cfg80211
> can play that role just fine as I believe it was designed that way.
> We could potentialy just add non-wiphy helper routines in there for now
> as well if all we need is a home for them. What if we want to make
> use of some of these in other cfg80211 drivers or maybe mac80211?

Nothing stops that whether or not they are in a different module.

> > Besides, you have to start _somewhere_. I have a feeling that this
> > happened in the first place because there was nowhere for drivers to
> > share bits of code like this (other than mac80211 or iee80211).
>
> Agreed, although I do like to think cfg80211 can play this role
> as well, unless we want to remain strict about requiring a wiphy
> for all its callers.

Sure, it could. Does it make a difference?

<snip>

> > I figure there are probably other bits that can be shared, but most of
> > them probably require at least _some_ recoding. This is a no-brainer
> > and it "breaks the ice" for more follow-on work.
>
> Sure, my vote goes towards cfg80211 with helpers which are non wiphy specific.
> The reason being that these drivers *could* also potentially be ported
> to use cfg80211 eventually and in fact I think this should be encouraged
> to help cfg80211 move forward to support them and so eventually
> [if/once] we have a Linux 3.0 we can ditch Wireless Extensions
> completely.
>
> I think an lib80211 would provide for more excuses for people to stuff
> things in there and help them never cross the line into cfg80211.

I don't really see where this affects that. What are 'they' going
to stuff in there as an alternative to cfg80211 anyway? If drivers
suddenly find ways to share WEXT code, that would seem to make
migrating them to cfg80211 that much easier.

In the meantime, this is currently my bikeshed and I'd prefer to
paint it like this. :-)

John
--
John W. Linville Linux should be at the core
[email protected] of your literate lifestyle.

2008-09-25 01:52:12

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Wed, Sep 24, 2008 at 05:39:31PM -0700, John W. Linville wrote:
> Is there some huge cost I'm overlooking? If you are afraid of wasting
> a page then build it into the kernel. Hopefully this module eventually
> gets bigger anyway.

Like I said, just a thought, in general a module for just one routine
seems like complete overkill to me.

> > > Otherwise it needs to live _somewhere_.
> > > The cfg80211 module might make sense, except that the libertas,
> > > ipw2100, and ipw2200 drivers don't use cfg80211 (at least for now).
> >
> > If we want a framework for FullMAC drivers I think cfg80211
> > can play that role just fine as I believe it was designed that way.
> > We could potentialy just add non-wiphy helper routines in there for now
> > as well if all we need is a home for them. What if we want to make
> > use of some of these in other cfg80211 drivers or maybe mac80211?
>
> Nothing stops that whether or not they are in a different module.

Right, but my point was more towards that if it lives in cfg80211
you don't have to have yet another module loaded -- specially for this
just one routine.

> > > Besides, you have to start _somewhere_. I have a feeling that this
> > > happened in the first place because there was nowhere for drivers to
> > > share bits of code like this (other than mac80211 or iee80211).
> >
> > Agreed, although I do like to think cfg80211 can play this role
> > as well, unless we want to remain strict about requiring a wiphy
> > for all its callers.
>
> Sure, it could. Does it make a difference?

I don't see a point to a "lib80211" for just one routine for now.

> > > I figure there are probably other bits that can be shared, but most of
> > > them probably require at least _some_ recoding. This is a no-brainer
> > > and it "breaks the ice" for more follow-on work.
> >
> > Sure, my vote goes towards cfg80211 with helpers which are non wiphy specific.
> > The reason being that these drivers *could* also potentially be ported
> > to use cfg80211 eventually and in fact I think this should be encouraged
> > to help cfg80211 move forward to support them and so eventually
> > [if/once] we have a Linux 3.0 we can ditch Wireless Extensions
> > completely.
> >
> > I think an lib80211 would provide for more excuses for people to stuff
> > things in there and help them never cross the line into cfg80211.
>
> I don't really see where this affects that. What are 'they' going
> to stuff in there as an alternative to cfg80211 anyway? If drivers
> suddenly find ways to share WEXT code, that would seem to make
> migrating them to cfg80211 that much easier.

So what will lib80211 be then exactly? If its not some sort of
infrastructure for drivers then why not just stash useful generic
stuff into headers and where appropriate cfg80211? -- Why do we
need another module for this?

> In the meantime, this is currently my bikeshed and I'd prefer to
> paint it like this. :-)

Heh, this is why I said its just my vote.

Luis

2008-09-25 08:44:28

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Thu, 2008-09-25 at 08:34 +0200, Holger Schurig wrote:
> > the libertas, ipw2100, and ipw2200 drivers don't use cfg80211
> > (at least for now).
>
> Yeah, Dan once spoke about using cfg80211 for libertas, but at
> that time I didn't saw the point.
>
> Hmm, I actually don't see the point now :-)

Well, you'll want to take advantage of the regulatory code and the
scanning stuff I'm working on...

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-09-24 23:33:04

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Wed, Sep 24, 2008 at 04:24:53PM -0700, Luis R. Rodriguez wrote:
> On Wed, Sep 24, 2008 at 03:15:36PM -0700, John W. Linville wrote:
> > This is also an excuse to create the long rumored lib80211 module...
>
> How about stuffing it in something like:
>
> include/linux/wlandevice.h
>
> Is there a benefit to having a module for it as this time?

The escape_essid function is currently not inlined. Are you
arguing that it should be? Otherwise it needs to live _somewhere_.
The cfg80211 module might make sense, except that the libertas,
ipw2100, and ipw2200 drivers don't use cfg80211 (at least for now).

Besides, you have to start _somewhere_. I have a feeling that this
happened in the first place because there was nowhere for drivers to
share bits of code like this (other than mac80211 or iee80211).

> Which reminds me, net/ieee80211/ should be ipw'ized now that the
> old softmac drivers are gone.
>
> mcgrof@tesla ~/wireless-testing/drivers/net/wireless (git::v2.6.27-rc6)$ grep -nHr "#include <net/ieee80211.h>" *
> airo.c:50:#include <net/ieee80211.h>
> atmel.c:70:#include <net/ieee80211.h>
> hostap/hostap_main.c:29:#include <net/ieee80211.h>
> hostap/hostap_hw.c:49:#include <net/ieee80211.h>
> ipw2100.h:42:#include <net/ieee80211.h>
> ipw2200.h:51:#include <net/ieee80211.h>
> libertas/types.h:10:#include <net/ieee80211.h>
> libertas/main.c:17:#include <net/ieee80211.h>
> libertas/dev.h:13:#include <net/ieee80211.h>
> libertas/wext.c:11:#include <net/ieee80211.h>
> libertas/cmd.c:7:#include <net/ieee80211.h>
> orinoco.c:88:#include <net/ieee80211.h>
> rndis_wlan.c:44:#include <net/ieee80211.h>
> wl3501.h:5:#include <net/ieee80211.h>
> zd1201.c:24:#include <net/ieee80211.h>
>
> Whatever these suckers are using can probably be slapped in there as
> well. But yea -- we just need to get it done huh.
>
> Thoughts?

I figure there are probably other bits that can be shared, but most of
them probably require at least _some_ recoding. This is a no-brainer
and it "breaks the ice" for more follow-on work.

John
--
John W. Linville Linux should be at the core
[email protected] of your literate lifestyle.

2008-09-25 16:58:47

by Dan Williams

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Thu, 2008-09-25 at 10:43 +0200, Johannes Berg wrote:
> On Thu, 2008-09-25 at 08:34 +0200, Holger Schurig wrote:
> > > the libertas, ipw2100, and ipw2200 drivers don't use cfg80211
> > > (at least for now).
> >
> > Yeah, Dan once spoke about using cfg80211 for libertas, but at
> > that time I didn't saw the point.
> >
> > Hmm, I actually don't see the point now :-)
>
> Well, you'll want to take advantage of the regulatory code and the
> scanning stuff I'm working on...

Yes. I want common regulatory code, if nothing else then common
functions for:

channel <-> frequency conversion
common regulatory domains and their restrictions
common BSS structure for scan results
common scan result translation handlers

Two options for scan result handling:

--------------------------------------------------------------------------
1) common GIWSCAN processing function that takes a callback. This
callback would be executed until it returns FALSE to signify no further
scan results. Callback prototype:

bool scan_res_hook(struct common_bss *bss, void *user_data);

'bss' would simply be a _single_ common bss structure allocated at the
start of iteration, and zeroed each time before calling the hook. The
scan hook then fills that common BSS structure with information from its
own internal scan list. The GIWSCAN processor then handles translation
into the actual WEXT event stream or nl80211 formats.

--------------------------------------------------------------------------
2) common GIWSCAN processing function that takes a list of common BSS
structures that the driver stores internally. The common BSS structure
would have a "void *driver_data" pointer in which the driver could keep
driver-specific data items, but the driver would be responsible for
setting all available information in the common BSS structure when the
firmware provides scan results. lib80211 provides common allocation,
deallocation, bss entry aging, ref/unref, and free-list fetching.


This would remove a good chunk of code from airo, atmel, and libertas at
least, which are the drivers that I've converted to this sort of scan
results handling system in the past. Most of the old ieee80211's BSS
structure stuff was applicable, but it had too many Intel-specific bits
in it too (like the SECLEVEL stuff).

Thoughts?

Dan



2008-09-25 04:47:10

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Wed, 2008-09-24 at 18:15 -0400, John W. Linville wrote:
> This is also an excuse to create the long rumored lib80211 module...

Let's also take the chance to clean up the mess Intel has, once again,
created here.

> switch (info_element->id) {
> case MFIE_TYPE_SSID:
> - if (ieee80211_is_empty_essid(info_element->data,
> - info_element->len)) {
> + if (is_empty_essid(info_element->data,
> + info_element->len)) {
> network->flags |= NETWORK_EMPTY_ESSID;
> break;
> }

You can remove the whole NETWORK_EMPTY_ESSID flag and this whole test;
the code slightly below needs to take care to actually escape the SSID
for the debug output.

> @@ -1411,7 +1412,7 @@ static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct iee
> network->mode |= IEEE_B;
> }
>
> - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
> + if (is_empty_essid(network->ssid, network->ssid_len))
> network->flags |= NETWORK_EMPTY_ESSID;

drop the whole if

>
> - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
> + if (is_empty_essid(network->ssid, network->ssid_len))
> network->flags |= NETWORK_EMPTY_ESSID;

ditto.

that leaves once place using the NETWORK_EMPTY_ESSID flag, in
ieee80211_wx.c:

/* Add the ESSID */
iwe.cmd = SIOCGIWESSID;
iwe.u.data.flags = 1;
if (network->flags & NETWORK_EMPTY_ESSID) {
iwe.u.data.length = sizeof("<hidden>");
start = iwe_stream_add_point(info, start, stop,
&iwe, "<hidden>");
} else {
iwe.u.data.length = min(network->ssid_len, (u8) 32);
start = iwe_stream_add_point(info, start, stop,
&iwe, network->ssid);
}

which is of course *completely* *wrong*. There's no excuse for messing
up the values passed to userspace like that.

> +const char *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 (is_empty_essid(essid, essid_len)) {
> + memcpy(escaped, "<hidden>", sizeof("<hidden>"));
> + return escaped;
> + }

Once you've done the above, is_empty_essid is only used here. I'll leave
it to you whether you want to print <hidden> or not, I'd prefer if the
function was to just escape the ASCII-NULs as normal since then you can
actually distinguish the various forms of hidden SSIDs which might help.
Maybe that needs quotes around the escaped SSID then.

> + 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;
> +}
> +EXPORT_SYMBOL(escape_essid);

Also, we could take the chance to stop making Jean's mistake in calling
this thing the _E_SSID, there's no such thing, it's Jean's invention,
based on his misguided thought that this might somehow be less confusing
to the user.

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-09-25 21:01:07

by Dave Kilroy

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

John W. Linville wrote:
> This is also an excuse to create the long rumored lib80211 module...

> +++ b/net/wireless/lib80211.c
> @@ -0,0 +1,58 @@
> +/*
> + * lib80211 -- common bits for IEEE802.11 drivers
> + *
> + * Copyright(c) 2008 John W. Linville <[email protected]>
> + *
> + */
> +
> +#include <linux/module.h>
> +#include <linux/wireless.h>

Alternatively #include <linux/ieee80211.h>, and avoid the WE header/constants? Or would you expect WE helpers in this file as well?

> +const char *escape_essid(const char *essid, u8 essid_len)
> +{
> + static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
[IEEE80211_SSID_MAX_LEN * 2 + 1]

> + const char *s = essid;
> + char *d = escaped;
> +
> + if (is_empty_essid(essid, essid_len)) {
> + memcpy(escaped, "<hidden>", sizeof("<hidden>"));
> + return escaped;
> + }
> +
> + essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE);
IEEE80211_SSID_MAX_LEN

Also, are we worried about drivers interrupting each other and getting the others SSID? In which case maybe something like print_mac:

/* in lib80211.h */
#define DECLARE_SSID_BUF(x) char x[IEEE80211_SSID_MAX_LEN * 2 + 1]

const char *print_ssid(char *escaped, const char *ssid, u8 ssid_len);



Regards,

Dave.

2008-09-26 11:08:50

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Thu, 2008-09-25 at 12:57 -0400, Dan Williams wrote:

> channel <-> frequency conversion

have that in cfg80211

> common regulatory domains and their restrictions

that too

> common BSS structure for scan results
> common scan result translation handlers
>
> Two options for scan result handling:

Can you look at the RFC patch I posted?

> --------------------------------------------------------------------------
> 1) common GIWSCAN processing function that takes a callback. This
> callback would be executed until it returns FALSE to signify no further
> scan results. Callback prototype:
>
> bool scan_res_hook(struct common_bss *bss, void *user_data);
>
> 'bss' would simply be a _single_ common bss structure allocated at the
> start of iteration, and zeroed each time before calling the hook. The
> scan hook then fills that common BSS structure with information from its
> own internal scan list. The GIWSCAN processor then handles translation
> into the actual WEXT event stream or nl80211 formats.
>
> --------------------------------------------------------------------------
> 2) common GIWSCAN processing function that takes a list of common BSS
> structures that the driver stores internally. The common BSS structure
> would have a "void *driver_data" pointer in which the driver could keep
> driver-specific data items, but the driver would be responsible for
> setting all available information in the common BSS structure when the
> firmware provides scan results. lib80211 provides common allocation,
> deallocation, bss entry aging, ref/unref, and free-list fetching.

I had something like this option 2 in mind when I wrote my patch, can
you take a look at it? The only thing missing now is
quality/signal/noise handling. Here's the most recent version:

http://johannes.sipsolutions.net/patches/kernel/all/2008-09-26-11%3a08/020-cfg80211-scan.patch

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-09-25 00:21:24

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Wed, Sep 24, 2008 at 04:32:34PM -0700, John W. Linville wrote:
> On Wed, Sep 24, 2008 at 04:24:53PM -0700, Luis R. Rodriguez wrote:
> > On Wed, Sep 24, 2008 at 03:15:36PM -0700, John W. Linville wrote:
> > > This is also an excuse to create the long rumored lib80211 module...
> >
> > How about stuffing it in something like:
> >
> > include/linux/wlandevice.h
> >
> > Is there a benefit to having a module for it as this time?
>
> The escape_essid function is currently not inlined. Are you
> arguing that it should be?

Just an idea, yes, but that's just because it didn't seem
that escape_essid() in itself was enough reason to create a
shiny new module.

> Otherwise it needs to live _somewhere_.
> The cfg80211 module might make sense, except that the libertas,
> ipw2100, and ipw2200 drivers don't use cfg80211 (at least for now).

If we want a framework for FullMAC drivers I think cfg80211
can play that role just fine as I believe it was designed that way.
We could potentialy just add non-wiphy helper routines in there for now
as well if all we need is a home for them. What if we want to make
use of some of these in other cfg80211 drivers or maybe mac80211?

> Besides, you have to start _somewhere_. I have a feeling that this
> happened in the first place because there was nowhere for drivers to
> share bits of code like this (other than mac80211 or iee80211).

Agreed, although I do like to think cfg80211 can play this role
as well, unless we want to remain strict about requiring a wiphy
for all its callers.

> > Which reminds me, net/ieee80211/ should be ipw'ized now that the
> > old softmac drivers are gone.
> >
> > mcgrof@tesla ~/wireless-testing/drivers/net/wireless (git::v2.6.27-rc6)$ grep -nHr "#include <net/ieee80211.h>" *
> > airo.c:50:#include <net/ieee80211.h>
> > atmel.c:70:#include <net/ieee80211.h>
> > hostap/hostap_main.c:29:#include <net/ieee80211.h>
> > hostap/hostap_hw.c:49:#include <net/ieee80211.h>
> > ipw2100.h:42:#include <net/ieee80211.h>
> > ipw2200.h:51:#include <net/ieee80211.h>
> > libertas/types.h:10:#include <net/ieee80211.h>
> > libertas/main.c:17:#include <net/ieee80211.h>
> > libertas/dev.h:13:#include <net/ieee80211.h>
> > libertas/wext.c:11:#include <net/ieee80211.h>
> > libertas/cmd.c:7:#include <net/ieee80211.h>
> > orinoco.c:88:#include <net/ieee80211.h>
> > rndis_wlan.c:44:#include <net/ieee80211.h>
> > wl3501.h:5:#include <net/ieee80211.h>
> > zd1201.c:24:#include <net/ieee80211.h>
> >
> > Whatever these suckers are using can probably be slapped in there as
> > well. But yea -- we just need to get it done huh.
> >
> > Thoughts?
>
> I figure there are probably other bits that can be shared, but most of
> them probably require at least _some_ recoding. This is a no-brainer
> and it "breaks the ice" for more follow-on work.

Sure, my vote goes towards cfg80211 with helpers which are non wiphy specific.
The reason being that these drivers *could* also potentially be ported
to use cfg80211 eventually and in fact I think this should be encouraged
to help cfg80211 move forward to support them and so eventually
[if/once] we have a Linux 3.0 we can ditch Wireless Extensions
completely.

I think an lib80211 would provide for more excuses for people to stuff
things in there and help them never cross the line into cfg80211.

Luis

2008-09-25 16:49:10

by Dan Williams

[permalink] [raw]
Subject: Re: [PATCH] wireless: consolidate on a single escape_essid implementation

On Thu, 2008-09-25 at 06:49 +0200, Johannes Berg wrote:
> On Thu, 2008-09-25 at 06:46 +0200, Johannes Berg wrote:
>
> > > + 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;
> > > +}
> > > +EXPORT_SYMBOL(escape_essid);
>
> Also, it seems like this should escape any non-printable characters, not
> just NUL?

Yes, it should escape any _non-ASCII_ characters.

Dan



2008-10-01 02:23:53

by John W. Linville

[permalink] [raw]
Subject: [PATCH 1/5] wireless: consolidate on a single escape_essid implementation

Signed-off-by: John W. Linville <[email protected]>
---
drivers/net/wireless/Kconfig | 1 +
drivers/net/wireless/ipw2100.c | 10 +-
drivers/net/wireless/ipw2200.c | 126 +++++++++++++-------------
drivers/net/wireless/ipw2200.h | 1 +
drivers/net/wireless/iwlwifi/Kconfig | 2 +
drivers/net/wireless/iwlwifi/iwl-scan.c | 53 ++----------
drivers/net/wireless/iwlwifi/iwl3945-base.c | 48 +---------
drivers/net/wireless/libertas/assoc.c | 14 ++--
drivers/net/wireless/libertas/cmd.c | 3 +-
drivers/net/wireless/libertas/debugfs.c | 3 +-
drivers/net/wireless/libertas/decl.h | 4 -
drivers/net/wireless/libertas/main.c | 27 ------
drivers/net/wireless/libertas/scan.c | 11 ++-
drivers/net/wireless/libertas/wext.c | 3 +-
include/net/ieee80211.h | 20 ----
include/net/lib80211.h | 31 +++++++
net/ieee80211/Kconfig | 1 +
net/ieee80211/ieee80211_module.c | 26 ------
net/ieee80211/ieee80211_rx.c | 31 ++++---
net/ieee80211/ieee80211_wx.c | 6 +-
net/wireless/Kconfig | 10 ++
net/wireless/Makefile | 1 +
net/wireless/lib80211.c | 58 ++++++++++++
23 files changed, 223 insertions(+), 267 deletions(-)
create mode 100644 include/net/lib80211.h
create mode 100644 net/wireless/lib80211.c

diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 45bdf0b..42afaed 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -271,6 +271,7 @@ config LIBERTAS
tristate "Marvell 8xxx Libertas WLAN driver support"
depends on WLAN_80211
select WIRELESS_EXT
+ select LIB80211
select FW_LOADER
---help---
A library for Marvell Libertas 8xxx devices.
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index bca7481..df8d1b3 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -1977,7 +1977,7 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)

IPW_DEBUG_INFO("%s: Associated with '%s' at %s, channel %d (BSSID="
"%s)\n",
- priv->net_dev->name, escape_essid(essid, essid_len),
+ priv->net_dev->name, escape_ssid(essid, essid_len),
txratename, chan, print_mac(mac, bssid));

/* now we copy read ssid into dev */
@@ -2005,7 +2005,7 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid,
};
int err;

- IPW_DEBUG_HC("SSID: '%s'\n", escape_essid(essid, ssid_len));
+ IPW_DEBUG_HC("SSID: '%s'\n", escape_ssid(essid, ssid_len));

if (ssid_len)
memcpy(cmd.host_command_parameters, essid, ssid_len);
@@ -2050,7 +2050,7 @@ static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status)

IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
"disassociated: '%s' %s \n",
- escape_essid(priv->essid, priv->essid_len),
+ escape_ssid(priv->essid, priv->essid_len),
print_mac(mac, priv->bssid));

priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING);
@@ -7000,7 +7000,7 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
goto done;
}

- IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_essid(essid, length),
+ IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_ssid(essid, length),
length);

priv->essid_len = length;
@@ -7027,7 +7027,7 @@ static int ipw2100_wx_get_essid(struct net_device *dev,
* configured ESSID then return that; otherwise return ANY */
if (priv->config & CFG_STATIC_ESSID || priv->status & STATUS_ASSOCIATED) {
IPW_DEBUG_WX("Getting essid: '%s'\n",
- escape_essid(priv->essid, priv->essid_len));
+ escape_ssid(priv->essid, priv->essid_len));
memcpy(extra, priv->essid, priv->essid_len);
wrqu->essid.length = priv->essid_len;
wrqu->essid.flags = 1; /* active */
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index dcce354..41f9e46 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -4413,8 +4413,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
IPW_DL_ASSOC,
"associated: '%s' %s"
" \n",
- escape_essid(priv->essid,
- priv->essid_len),
+ escape_ssid(priv->essid,
+ priv->essid_len),
print_mac(mac, priv->bssid));

switch (priv->ieee->iw_mode) {
@@ -4494,10 +4494,10 @@ static void ipw_rx_notification(struct ipw_priv *priv,
"deauthenticated: '%s' "
"%s"
": (0x%04X) - %s \n",
- escape_essid(priv->
- essid,
- priv->
- essid_len),
+ escape_ssid(priv->
+ essid,
+ priv->
+ essid_len),
print_mac(mac, priv->bssid),
le16_to_cpu(auth->status),
ipw_get_status_code
@@ -4517,8 +4517,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
IPW_DL_ASSOC,
"authenticated: '%s' %s"
"\n",
- escape_essid(priv->essid,
- priv->essid_len),
+ escape_ssid(priv->essid,
+ priv->essid_len),
print_mac(mac, priv->bssid));
break;
}
@@ -4546,8 +4546,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
IPW_DL_ASSOC,
"disassociated: '%s' %s"
" \n",
- escape_essid(priv->essid,
- priv->essid_len),
+ escape_ssid(priv->essid,
+ priv->essid_len),
print_mac(mac, priv->bssid));

priv->status &=
@@ -4584,8 +4584,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
case CMAS_AUTHENTICATED:
IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
"authenticated: '%s' %s \n",
- escape_essid(priv->essid,
- priv->essid_len),
+ escape_ssid(priv->essid,
+ priv->essid_len),
print_mac(mac, priv->bssid));
priv->status |= STATUS_AUTH;
break;
@@ -4603,8 +4603,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
IPW_DL_ASSOC,
"deauthenticated: '%s' %s\n",
- escape_essid(priv->essid,
- priv->essid_len),
+ escape_ssid(priv->essid,
+ priv->essid_len),
print_mac(mac, priv->bssid));

priv->status &= ~(STATUS_ASSOCIATING |
@@ -5438,7 +5438,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
!(network->capability & WLAN_CAPABILITY_IBSS))) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded due to "
"capability mismatch.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5448,7 +5448,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
if (network->flags & NETWORK_EMPTY_ESSID) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of hidden ESSID.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5461,8 +5461,8 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
network->ssid_len)) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of non-network ESSID.\n",
- escape_essid(network->ssid,
- network->ssid_len),
+ escape_ssid(network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5476,13 +5476,13 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
char escaped[IW_ESSID_MAX_SIZE * 2 + 1];

strncpy(escaped,
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
sizeof(escaped));
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of ESSID mismatch: '%s'.\n",
escaped, print_mac(mac, network->bssid),
- escape_essid(priv->essid,
- priv->essid_len));
+ escape_ssid(priv->essid,
+ priv->essid_len));
return 0;
}
}
@@ -5493,14 +5493,14 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
if (network->time_stamp[0] < match->network->time_stamp[0]) {
IPW_DEBUG_MERGE("Network '%s excluded because newer than "
"current network.\n",
- escape_essid(match->network->ssid,
- match->network->ssid_len));
+ escape_ssid(match->network->ssid,
+ match->network->ssid_len));
return 0;
} else if (network->time_stamp[1] < match->network->time_stamp[1]) {
IPW_DEBUG_MERGE("Network '%s excluded because newer than "
"current network.\n",
- escape_essid(match->network->ssid,
- match->network->ssid_len));
+ escape_ssid(match->network->ssid,
+ match->network->ssid_len));
return 0;
}

@@ -5509,7 +5509,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of age: %ums.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid),
jiffies_to_msecs(jiffies -
network->last_scanned));
@@ -5520,7 +5520,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
(network->channel != priv->channel)) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of channel mismatch: %d != %d.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid),
network->channel, priv->channel);
return 0;
@@ -5531,7 +5531,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
((network->capability & WLAN_CAPABILITY_PRIVACY) ? 1 : 0)) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of privacy mismatch: %s != %s.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid),
priv->
capability & CAP_PRIVACY_ON ? "on" : "off",
@@ -5544,8 +5544,8 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
if (!memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of the same BSSID match: %s"
- ".\n", escape_essid(network->ssid,
- network->ssid_len),
+ ".\n", escape_ssid(network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid),
print_mac(mac2, priv->bssid));
return 0;
@@ -5556,7 +5556,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of invalid frequency/mode "
"combination.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5567,7 +5567,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because configured rate mask excludes "
"AP mandatory rate.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5575,7 +5575,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
if (rates.num_rates == 0) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of no compatible rates.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5588,7 +5588,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
ipw_copy_rates(&match->rates, &rates);
match->network = network;
IPW_DEBUG_MERGE("Network '%s (%s)' is a viable match.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));

return 1;
@@ -5626,8 +5626,8 @@ static void ipw_merge_adhoc_network(struct work_struct *work)
mutex_lock(&priv->mutex);
if ((priv->ieee->iw_mode == IW_MODE_ADHOC)) {
IPW_DEBUG_MERGE("remove network %s\n",
- escape_essid(priv->essid,
- priv->essid_len));
+ escape_ssid(priv->essid,
+ priv->essid_len));
ipw_remove_current_network(priv);
}

@@ -5653,7 +5653,7 @@ static int ipw_best_network(struct ipw_priv *priv,
!(network->capability & WLAN_CAPABILITY_IBSS))) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded due to "
"capability mismatch.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5663,7 +5663,7 @@ static int ipw_best_network(struct ipw_priv *priv,
if (network->flags & NETWORK_EMPTY_ESSID) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of hidden ESSID.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5676,8 +5676,8 @@ static int ipw_best_network(struct ipw_priv *priv,
network->ssid_len)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of non-network ESSID.\n",
- escape_essid(network->ssid,
- network->ssid_len),
+ escape_ssid(network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5690,13 +5690,13 @@ static int ipw_best_network(struct ipw_priv *priv,
min(network->ssid_len, priv->essid_len)))) {
char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
strncpy(escaped,
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
sizeof(escaped));
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of ESSID mismatch: '%s'.\n",
escaped, print_mac(mac, network->bssid),
- escape_essid(priv->essid,
- priv->essid_len));
+ escape_ssid(priv->essid,
+ priv->essid_len));
return 0;
}
}
@@ -5706,13 +5706,13 @@ static int ipw_best_network(struct ipw_priv *priv,
if (match->network && match->network->stats.rssi > network->stats.rssi) {
char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
strncpy(escaped,
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
sizeof(escaped));
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded because "
"'%s (%s)' has a stronger signal.\n",
escaped, print_mac(mac, network->bssid),
- escape_essid(match->network->ssid,
- match->network->ssid_len),
+ escape_ssid(match->network->ssid,
+ match->network->ssid_len),
print_mac(mac, match->network->bssid));
return 0;
}
@@ -5724,7 +5724,7 @@ static int ipw_best_network(struct ipw_priv *priv,
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of storming (%ums since last "
"assoc attempt).\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid),
jiffies_to_msecs(jiffies -
network->last_associate));
@@ -5736,7 +5736,7 @@ static int ipw_best_network(struct ipw_priv *priv,
time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of age: %ums.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid),
jiffies_to_msecs(jiffies -
network->last_scanned));
@@ -5747,7 +5747,7 @@ static int ipw_best_network(struct ipw_priv *priv,
(network->channel != priv->channel)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of channel mismatch: %d != %d.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid),
network->channel, priv->channel);
return 0;
@@ -5758,7 +5758,7 @@ static int ipw_best_network(struct ipw_priv *priv,
((network->capability & WLAN_CAPABILITY_PRIVACY) ? 1 : 0)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of privacy mismatch: %s != %s.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid),
priv->capability & CAP_PRIVACY_ON ? "on" :
"off",
@@ -5771,7 +5771,7 @@ static int ipw_best_network(struct ipw_priv *priv,
memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of BSSID mismatch: %s.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid), print_mac(mac, priv->bssid));
return 0;
}
@@ -5781,7 +5781,7 @@ static int ipw_best_network(struct ipw_priv *priv,
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of invalid frequency/mode "
"combination.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5790,7 +5790,7 @@ static int ipw_best_network(struct ipw_priv *priv,
if (!ieee80211_is_valid_channel(priv->ieee, network->channel)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of invalid channel in current GEO\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5801,7 +5801,7 @@ static int ipw_best_network(struct ipw_priv *priv,
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because configured rate mask excludes "
"AP mandatory rate.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5809,7 +5809,7 @@ static int ipw_best_network(struct ipw_priv *priv,
if (rates.num_rates == 0) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of no compatible rates.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5823,7 +5823,7 @@ static int ipw_best_network(struct ipw_priv *priv,
match->network = network;

IPW_DEBUG_ASSOC("Network '%s (%s)' is a viable match.\n",
- escape_essid(network->ssid, network->ssid_len),
+ escape_ssid(network->ssid, network->ssid_len),
print_mac(mac, network->bssid));

return 1;
@@ -6075,7 +6075,7 @@ static void ipw_debug_config(struct ipw_priv *priv)
IPW_DEBUG_INFO("Channel unlocked.\n");
if (priv->config & CFG_STATIC_ESSID)
IPW_DEBUG_INFO("ESSID locked to '%s'\n",
- escape_essid(priv->essid, priv->essid_len));
+ escape_ssid(priv->essid, priv->essid_len));
else
IPW_DEBUG_INFO("ESSID unlocked.\n");
if (priv->config & CFG_STATIC_BSSID)
@@ -7364,7 +7364,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
IPW_DEBUG_ASSOC("%sssocation attempt: '%s', channel %d, "
"802.11%c [%d], %s[:%s], enc=%s%s%s%c%c\n",
roaming ? "Rea" : "A",
- escape_essid(priv->essid, priv->essid_len),
+ escape_ssid(priv->essid, priv->essid_len),
network->channel,
ipw_modes[priv->assoc_request.ieee_mode],
rates->num_rates,
@@ -7464,7 +7464,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
}

IPW_DEBUG(IPW_DL_STATE, "associating: '%s' %s \n",
- escape_essid(priv->essid, priv->essid_len),
+ escape_ssid(priv->essid, priv->essid_len),
print_mac(mac, priv->bssid));

return 0;
@@ -7617,8 +7617,8 @@ static int ipw_associate(void *data)
target = oldest;
IPW_DEBUG_ASSOC("Expired '%s' (%s) from "
"network list.\n",
- escape_essid(target->ssid,
- target->ssid_len),
+ escape_ssid(target->ssid,
+ target->ssid_len),
print_mac(mac, target->bssid));
list_add_tail(&target->list,
&priv->ieee->network_free_list);
@@ -9081,7 +9081,7 @@ static int ipw_wx_set_essid(struct net_device *dev,
return 0;
}

- IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_essid(extra, length),
+ IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_ssid(extra, length),
length);

priv->essid_len = length;
@@ -9108,7 +9108,7 @@ static int ipw_wx_get_essid(struct net_device *dev,
if (priv->config & CFG_STATIC_ESSID ||
priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
IPW_DEBUG_WX("Getting essid: '%s'\n",
- escape_essid(priv->essid, priv->essid_len));
+ escape_ssid(priv->essid, priv->essid_len));
memcpy(extra, priv->essid, priv->essid_len);
wrqu->essid.length = priv->essid_len;
wrqu->essid.flags = 1; /* active */
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index 0bad1ec..0a84d52 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -48,6 +48,7 @@
#include <linux/jiffies.h>
#include <asm/io.h>

+#include <net/lib80211.h>
#include <net/ieee80211.h>
#include <net/ieee80211_radiotap.h>

diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index b0ac0ce..47bee0e 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -4,6 +4,7 @@ config IWLWIFI
config IWLCORE
tristate "Intel Wireless Wifi Core"
depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
+ select LIB80211
select IWLWIFI
select MAC80211_LEDS if IWLWIFI_LEDS
select LEDS_CLASS if IWLWIFI_LEDS
@@ -105,6 +106,7 @@ config IWL3945
tristate "Intel PRO/Wireless 3945ABG/BG Network Connection"
depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
select FW_LOADER
+ select LIB80211
select IWLWIFI
select MAC80211_LEDS if IWL3945_LEDS
select LEDS_CLASS if IWL3945_LEDS
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index bf855c3..9488e50 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -25,8 +25,10 @@
* Tomas Winkler <[email protected]>
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*****************************************************************************/
-#include <net/mac80211.h>
+#include <linux/types.h>
#include <linux/etherdevice.h>
+#include <net/lib80211.h>
+#include <net/mac80211.h>

#include "iwl-eeprom.h"
#include "iwl-dev.h"
@@ -69,49 +71,6 @@ static int scan_tx_ant[3] = {
};


-
-static int iwl_is_empty_essid(const char *essid, int essid_len)
-{
- /* Single white space is for Linksys APs */
- if (essid_len == 1 && essid[0] == ' ')
- return 1;
-
- /* Otherwise, if the entire essid is 0, we assume it is hidden */
- while (essid_len) {
- essid_len--;
- if (essid[essid_len] != '\0')
- return 0;
- }
-
- return 1;
-}
-
-
-
-static const char *iwl_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 (iwl_is_empty_essid(essid, essid_len)) {
- memcpy(escaped, "<hidden>", sizeof("<hidden>"));
- return escaped;
- }
-
- 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;
-}
-
/**
* iwl_scan_cancel - Cancel any currently executing HW scan
*
@@ -796,8 +755,8 @@ static void iwl_bg_request_scan(struct work_struct *data)
/* We should add the ability for user to lock to PASSIVE ONLY */
if (priv->one_direct_scan) {
IWL_DEBUG_SCAN("Start direct scan for '%s'\n",
- iwl_escape_essid(priv->direct_ssid,
- priv->direct_ssid_len));
+ escape_ssid(priv->direct_ssid,
+ priv->direct_ssid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->direct_ssid_len;
memcpy(scan->direct_scan[0].ssid,
@@ -805,7 +764,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
n_probes++;
} else if (!iwl_is_associated(priv) && priv->essid_len) {
IWL_DEBUG_SCAN("Start direct scan for '%s' (not associated)\n",
- iwl_escape_essid(priv->essid, priv->essid_len));
+ escape_ssid(priv->essid, priv->essid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->essid_len;
memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index d15a2c9..c81b743 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -41,6 +41,7 @@
#include <linux/if_arp.h>

#include <net/ieee80211_radiotap.h>
+#include <net/lib80211.h>
#include <net/mac80211.h>

#include <asm/div64.h>
@@ -107,46 +108,6 @@ static const struct ieee80211_supported_band *iwl3945_get_band(
return priv->hw->wiphy->bands[band];
}

-static int iwl3945_is_empty_essid(const char *essid, int essid_len)
-{
- /* Single white space is for Linksys APs */
- if (essid_len == 1 && essid[0] == ' ')
- return 1;
-
- /* Otherwise, if the entire essid is 0, we assume it is hidden */
- while (essid_len) {
- essid_len--;
- if (essid[essid_len] != '\0')
- return 0;
- }
-
- return 1;
-}
-
-static const char *iwl3945_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 (iwl3945_is_empty_essid(essid, essid_len)) {
- memcpy(escaped, "<hidden>", sizeof("<hidden>"));
- return escaped;
- }
-
- 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;
-}
-
/*************** DMA-QUEUE-GENERAL-FUNCTIONS *****
* DMA services
*
@@ -6202,8 +6163,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
if (priv->one_direct_scan) {
IWL_DEBUG_SCAN
("Kicking off one direct scan for '%s'\n",
- iwl3945_escape_essid(priv->direct_ssid,
- priv->direct_ssid_len));
+ escape_ssid(priv->direct_ssid, priv->direct_ssid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->direct_ssid_len;
memcpy(scan->direct_scan[0].ssid,
@@ -6212,7 +6172,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
} else if (!iwl3945_is_associated(priv) && priv->essid_len) {
IWL_DEBUG_SCAN
("Kicking off one direct scan for '%s' when not associated\n",
- iwl3945_escape_essid(priv->essid, priv->essid_len));
+ escape_ssid(priv->essid, priv->essid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->essid_len;
memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
@@ -7031,7 +6991,7 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
}
if (len) {
IWL_DEBUG_SCAN("direct scan for %s [%d]\n ",
- iwl3945_escape_essid(ssid, len), (int)len);
+ escape_ssid(ssid, len), (int)len);

priv->one_direct_scan = 1;
priv->direct_ssid_len = (u8)
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 92be604..693d786 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -1,6 +1,8 @@
/* Copyright (C) 2006, Red Hat, Inc. */

+#include <linux/types.h>
#include <linux/etherdevice.h>
+#include <net/lib80211.h>

#include "assoc.h"
#include "decl.h"
@@ -158,11 +160,11 @@ static int lbs_adhoc_join(struct lbs_private *priv,
lbs_deb_enter(LBS_DEB_ASSOC);

lbs_deb_join("current SSID '%s', ssid length %u\n",
- escape_essid(priv->curbssparams.ssid,
+ escape_ssid(priv->curbssparams.ssid,
priv->curbssparams.ssid_len),
priv->curbssparams.ssid_len);
lbs_deb_join("requested ssid '%s', ssid length %u\n",
- escape_essid(bss->ssid, bss->ssid_len),
+ escape_ssid(bss->ssid, bss->ssid_len),
bss->ssid_len);

/* check if the requested SSID is already joined */
@@ -326,7 +328,7 @@ static int lbs_adhoc_start(struct lbs_private *priv,
memcpy(cmd.ssid, assoc_req->ssid, assoc_req->ssid_len);

lbs_deb_join("ADHOC_START: SSID '%s', ssid length %u\n",
- escape_essid(assoc_req->ssid, assoc_req->ssid_len),
+ escape_ssid(assoc_req->ssid, assoc_req->ssid_len),
assoc_req->ssid_len);

cmd.bsstype = CMD_BSS_TYPE_IBSS;
@@ -705,7 +707,7 @@ static int assoc_helper_essid(struct lbs_private *priv,
channel = assoc_req->channel;

lbs_deb_assoc("SSID '%s' requested\n",
- escape_essid(assoc_req->ssid, assoc_req->ssid_len));
+ escape_ssid(assoc_req->ssid, assoc_req->ssid_len));
if (assoc_req->mode == IW_MODE_INFRA) {
lbs_send_specific_ssid_scan(priv, assoc_req->ssid,
assoc_req->ssid_len);
@@ -1232,7 +1234,7 @@ void lbs_association_worker(struct work_struct *work)
" secinfo: %s%s%s\n"
" auth_mode: %d\n",
assoc_req->flags,
- escape_essid(assoc_req->ssid, assoc_req->ssid_len),
+ escape_ssid(assoc_req->ssid, assoc_req->ssid_len),
assoc_req->channel, assoc_req->band, assoc_req->mode,
print_mac(mac, assoc_req->bssid),
assoc_req->secinfo.WPAenabled ? " WPA" : "",
@@ -1820,7 +1822,7 @@ static int lbs_adhoc_post(struct lbs_private *priv, struct cmd_header *resp)
wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);

lbs_deb_join("ADHOC_RESP: Joined/started '%s', BSSID %s, channel %d\n",
- escape_essid(bss->ssid, bss->ssid_len),
+ escape_ssid(bss->ssid, bss->ssid_len),
print_mac(mac, priv->curbssparams.bssid),
priv->curbssparams.channel);

diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index a912fb6..c1048fd 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -4,6 +4,7 @@
*/

#include <net/iw_handler.h>
+#include <net/lib80211.h>
#include <net/ieee80211.h>
#include <linux/kfifo.h>
#include "host.h"
@@ -1091,7 +1092,7 @@ int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan)
}
lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n",
action, priv->mesh_tlv, chan,
- escape_essid(priv->mesh_ssid, priv->mesh_ssid_len));
+ escape_ssid(priv->mesh_ssid, priv->mesh_ssid_len));

return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv);
}
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 0aa0ce3..89f5d62 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -5,6 +5,7 @@
#include <linux/mm.h>
#include <linux/string.h>
#include <net/iw_handler.h>
+#include <net/lib80211.h>

#include "dev.h"
#include "decl.h"
@@ -87,7 +88,7 @@ static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
spectrum_mgmt ? 'S' : ' ');
pos += snprintf(buf+pos, len-pos, " %04d |", SCAN_RSSI(iter_bss->rssi));
pos += snprintf(buf+pos, len-pos, " %s\n",
- escape_essid(iter_bss->ssid, iter_bss->ssid_len));
+ escape_ssid(iter_bss->ssid, iter_bss->ssid_len));

numscansdone++;
}
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h
index 1a8888c..0b84bdc 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -74,8 +74,4 @@ void lbs_host_to_card_done(struct lbs_private *priv);

int lbs_update_channel(struct lbs_private *priv);

-#ifndef CONFIG_IEEE80211
-const char *escape_essid(const char *essid, u8 essid_len);
-#endif
-
#endif
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 73dc8c7..b30e845 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -1647,33 +1647,6 @@ out:
return ret;
}

-#ifndef CONFIG_IEEE80211
-const char *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)) {
- memcpy(escaped, "<hidden>", sizeof("<hidden>"));
- return escaped;
- }
-
- 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;
-}
-#endif
-
module_init(lbs_init_module);
module_exit(lbs_exit_module);

diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 8f66903..fd0f640 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -4,9 +4,12 @@
* IOCTL handlers as well as command preperation and response routines
* for sending scan commands to the firmware.
*/
+#include <linux/types.h>
#include <linux/etherdevice.h>
#include <asm/unaligned.h>

+#include <net/lib80211.h>
+
#include "host.h"
#include "decl.h"
#include "dev.h"
@@ -453,7 +456,7 @@ int lbs_scan_networks(struct lbs_private *priv, int full_scan)
list_for_each_entry(iter, &priv->network_list, list)
lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n",
i++, print_mac(mac, iter->bssid), iter->rssi,
- escape_essid(iter->ssid, iter->ssid_len));
+ escape_ssid(iter->ssid, iter->ssid_len));
mutex_unlock(&priv->lock);
#endif

@@ -601,7 +604,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
bss->ssid_len = elem->len;
memcpy(bss->ssid, elem->data, elem->len);
lbs_deb_scan("got SSID IE: '%s', len %u\n",
- escape_essid(bss->ssid, bss->ssid_len),
+ escape_ssid(bss->ssid, bss->ssid_len),
bss->ssid_len);
break;

@@ -744,7 +747,7 @@ int lbs_send_specific_ssid_scan(struct lbs_private *priv, uint8_t *ssid,
int ret = 0;

lbs_deb_enter_args(LBS_DEB_SCAN, "SSID '%s'\n",
- escape_essid(ssid, ssid_len));
+ escape_ssid(ssid, ssid_len));

if (!ssid_len)
goto out;
@@ -968,7 +971,7 @@ int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
priv->scan_ssid_len = req->essid_len;
memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len);
lbs_deb_wext("set_scan, essid '%s'\n",
- escape_essid(priv->scan_ssid, priv->scan_ssid_len));
+ escape_ssid(priv->scan_ssid, priv->scan_ssid_len));
} else {
priv->scan_ssid_len = 0;
}
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 82c3e5a..12baf0d 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -8,6 +8,7 @@
#include <linux/wireless.h>
#include <linux/bitops.h>

+#include <net/lib80211.h>
#include <net/ieee80211.h>
#include <net/iw_handler.h>

@@ -2005,7 +2006,7 @@ static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
lbs_deb_wext("requested any SSID\n");
} else {
lbs_deb_wext("requested SSID '%s'\n",
- escape_essid(ssid, ssid_len));
+ escape_ssid(ssid, ssid_len));
}

out:
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index 6048579..c638239 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -127,10 +127,6 @@ static inline bool ieee80211_ratelimit_debug(u32 level)
}
#endif /* CONFIG_IEEE80211_DEBUG */

-/* escape_essid() is intended to be used in debug (and possibly error)
- * messages. It should never be used for passing essid to user space. */
-const char *escape_essid(const char *essid, u8 essid_len);
-
/*
* To use the debug system:
*
@@ -1135,22 +1131,6 @@ static inline void *ieee80211_priv(struct net_device *dev)
return ((struct ieee80211_device *)netdev_priv(dev))->priv;
}

-static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
-{
- /* Single white space is for Linksys APs */
- if (essid_len == 1 && essid[0] == ' ')
- return 1;
-
- /* Otherwise, if the entire essid is 0, we assume it is hidden */
- while (essid_len) {
- essid_len--;
- if (essid[essid_len] != '\0')
- return 0;
- }
-
- return 1;
-}
-
static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee,
int mode)
{
diff --git a/include/net/lib80211.h b/include/net/lib80211.h
new file mode 100644
index 0000000..91a64f3
--- /dev/null
+++ b/include/net/lib80211.h
@@ -0,0 +1,31 @@
+/*
+ * lib80211.h -- common bits for IEEE802.11 wireless drivers
+ *
+ * Copyright (c) 2008, John W. Linville <[email protected]>
+ *
+ */
+
+#ifndef LIB80211_H
+#define LIB80211_H
+
+/* escape_ssid() is intended to be used in debug (and possibly error)
+ * messages. It should never be used for passing ssid to user space. */
+const char *escape_ssid(const char *ssid, u8 ssid_len);
+
+static inline int is_empty_ssid(const char *ssid, int ssid_len)
+{
+ /* Single white space is for Linksys APs */
+ if (ssid_len == 1 && ssid[0] == ' ')
+ return 1;
+
+ /* Otherwise, if the entire ssid is 0, we assume it is hidden */
+ while (ssid_len) {
+ ssid_len--;
+ if (ssid[ssid_len] != '\0')
+ return 0;
+ }
+
+ return 1;
+}
+
+#endif /* LIB80211_H */
diff --git a/net/ieee80211/Kconfig b/net/ieee80211/Kconfig
index 94ed7d3..dc3eeed 100644
--- a/net/ieee80211/Kconfig
+++ b/net/ieee80211/Kconfig
@@ -1,5 +1,6 @@
config IEEE80211
tristate "Generic IEEE 802.11 Networking Stack (DEPRECATED)"
+ select LIB80211
---help---
This option enables the hardware independent IEEE 802.11
networking stack. This component is deprecated in favor of the
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c
index 949772a..d34d4e7 100644
--- a/net/ieee80211/ieee80211_module.c
+++ b/net/ieee80211/ieee80211_module.c
@@ -308,31 +308,5 @@ MODULE_PARM_DESC(debug, "debug output mask");
module_exit(ieee80211_exit);
module_init(ieee80211_init);

-const char *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)) {
- memcpy(escaped, "<hidden>", sizeof("<hidden>"));
- return escaped;
- }
-
- 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;
-}
-
EXPORT_SYMBOL(alloc_ieee80211);
EXPORT_SYMBOL(free_ieee80211);
-EXPORT_SYMBOL(escape_essid);
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index 69dbc34..34239db 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -32,6 +32,7 @@
#include <asm/uaccess.h>
#include <linux/ctype.h>

+#include <net/lib80211.h>
#include <net/ieee80211.h>

static void ieee80211_monitor_rx(struct ieee80211_device *ieee,
@@ -1166,8 +1167,8 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element

switch (info_element->id) {
case MFIE_TYPE_SSID:
- if (ieee80211_is_empty_essid(info_element->data,
- info_element->len)) {
+ if (is_empty_ssid(info_element->data,
+ info_element->len)) {
network->flags |= NETWORK_EMPTY_ESSID;
break;
}
@@ -1411,7 +1412,7 @@ static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct iee
network->mode |= IEEE_B;
}

- if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
+ if (is_empty_ssid(network->ssid, network->ssid_len))
network->flags |= NETWORK_EMPTY_ESSID;

memcpy(&network->stats, stats, sizeof(network->stats));
@@ -1479,13 +1480,13 @@ static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee8021
if (network->mode == 0) {
IEEE80211_DEBUG_SCAN("Filtered out '%s (%s)' "
"network.\n",
- escape_essid(network->ssid,
- network->ssid_len),
+ escape_ssid(network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 1;
}

- if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
+ if (is_empty_ssid(network->ssid, network->ssid_len))
network->flags |= NETWORK_EMPTY_ESSID;

memcpy(&network->stats, stats, sizeof(network->stats));
@@ -1601,7 +1602,7 @@ static void ieee80211_process_probe_response(struct ieee80211_device

IEEE80211_DEBUG_SCAN("'%s' (%s"
"): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
- escape_essid(info_element->data, info_element->len),
+ escape_ssid(info_element->data, info_element->len),
print_mac(mac, beacon->header.addr3),
(beacon->capability & cpu_to_le16(1 << 0xf)) ? '1' : '0',
(beacon->capability & cpu_to_le16(1 << 0xe)) ? '1' : '0',
@@ -1622,8 +1623,8 @@ static void ieee80211_process_probe_response(struct ieee80211_device

if (ieee80211_network_init(ieee, beacon, &network, stats)) {
IEEE80211_DEBUG_SCAN("Dropped '%s' (%s) via %s.\n",
- escape_essid(info_element->data,
- info_element->len),
+ escape_ssid(info_element->data,
+ info_element->len),
print_mac(mac, beacon->header.addr3),
is_beacon(beacon->header.frame_ctl) ?
"BEACON" : "PROBE RESPONSE");
@@ -1660,8 +1661,8 @@ static void ieee80211_process_probe_response(struct ieee80211_device
target = oldest;
IEEE80211_DEBUG_SCAN("Expired '%s' (%s) from "
"network list.\n",
- escape_essid(target->ssid,
- target->ssid_len),
+ escape_ssid(target->ssid,
+ target->ssid_len),
print_mac(mac, target->bssid));
ieee80211_network_reset(target);
} else {
@@ -1673,8 +1674,8 @@ static void ieee80211_process_probe_response(struct ieee80211_device

#ifdef CONFIG_IEEE80211_DEBUG
IEEE80211_DEBUG_SCAN("Adding '%s' (%s) via %s.\n",
- escape_essid(network.ssid,
- network.ssid_len),
+ escape_ssid(network.ssid,
+ network.ssid_len),
print_mac(mac, network.bssid),
is_beacon(beacon->header.frame_ctl) ?
"BEACON" : "PROBE RESPONSE");
@@ -1684,8 +1685,8 @@ static void ieee80211_process_probe_response(struct ieee80211_device
list_add_tail(&target->list, &ieee->network_list);
} else {
IEEE80211_DEBUG_SCAN("Updating '%s' (%s) via %s.\n",
- escape_essid(target->ssid,
- target->ssid_len),
+ escape_ssid(target->ssid,
+ target->ssid_len),
print_mac(mac, target->bssid),
is_beacon(beacon->header.frame_ctl) ?
"BEACON" : "PROBE RESPONSE");
diff --git a/net/ieee80211/ieee80211_wx.c b/net/ieee80211/ieee80211_wx.c
index 973832d..c338279 100644
--- a/net/ieee80211/ieee80211_wx.c
+++ b/net/ieee80211/ieee80211_wx.c
@@ -284,8 +284,8 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
else
IEEE80211_DEBUG_SCAN("Not showing network '%s ("
"%s)' due to age (%dms).\n",
- escape_essid(network->ssid,
- network->ssid_len),
+ escape_ssid(network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid),
jiffies_to_msecs(jiffies -
network->
@@ -409,7 +409,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
memset(sec.keys[key] + erq->length, 0,
len - erq->length);
IEEE80211_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n",
- key, escape_essid(sec.keys[key], len),
+ key, escape_ssid(sec.keys[key], len),
erq->length, len);
sec.key_sizes[key] = len;
if (*crypt)
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig
index b97bd9f..2efaa02 100644
--- a/net/wireless/Kconfig
+++ b/net/wireless/Kconfig
@@ -73,3 +73,13 @@ config WIRELESS_EXT_SYSFS

Say Y if you have programs using it, like old versions of
hal.
+
+config LIB80211
+ tristate "Common routines for IEEE802.11 drivers"
+ default n
+ help
+ This options enables a library of common routines used
+ by IEEE802.11 wireless LAN drivers.
+
+ Drivers should select this themselves if needed. Say Y if
+ you want this built into your kernel.
diff --git a/net/wireless/Makefile b/net/wireless/Makefile
index b9f943c..d2d848d 100644
--- a/net/wireless/Makefile
+++ b/net/wireless/Makefile
@@ -1,5 +1,6 @@
obj-$(CONFIG_WIRELESS_EXT) += wext.o
obj-$(CONFIG_CFG80211) += cfg80211.o
+obj-$(CONFIG_LIB80211) += lib80211.o

cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o
cfg80211-$(CONFIG_NL80211) += nl80211.o
diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c
new file mode 100644
index 0000000..b22d271
--- /dev/null
+++ b/net/wireless/lib80211.c
@@ -0,0 +1,58 @@
+/*
+ * lib80211 -- common bits for IEEE802.11 drivers
+ *
+ * Copyright(c) 2008 John W. Linville <[email protected]>
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/ieee80211.h>
+
+#include <net/lib80211.h>
+
+#define DRV_NAME "lib80211"
+
+#define DRV_DESCRIPTION "common routines for IEEE802.11 drivers"
+
+MODULE_DESCRIPTION(DRV_DESCRIPTION);
+MODULE_AUTHOR("John W. Linville <[email protected]>");
+MODULE_LICENSE("GPL");
+
+const char *escape_ssid(const char *ssid, u8 ssid_len)
+{
+ static char escaped[IEEE80211_MAX_SSID_LEN * 2 + 1];
+ const char *s = ssid;
+ char *d = escaped;
+
+ if (is_empty_ssid(ssid, ssid_len)) {
+ memcpy(escaped, "<hidden>", sizeof("<hidden>"));
+ return escaped;
+ }
+
+ ssid_len = min_t(u8, ssid_len, IEEE80211_MAX_SSID_LEN);
+ while (ssid_len--) {
+ if (*s == '\0') {
+ *d++ = '\\';
+ *d++ = '0';
+ s++;
+ } else {
+ *d++ = *s++;
+ }
+ }
+ *d = '\0';
+ return escaped;
+}
+EXPORT_SYMBOL(escape_ssid);
+
+static int __init ieee80211_init(void)
+{
+ printk(KERN_INFO DRV_NAME ": " DRV_DESCRIPTION "\n");
+ return 0;
+}
+
+static void __exit ieee80211_exit(void)
+{
+}
+
+module_init(ieee80211_init);
+module_exit(ieee80211_exit);
--
1.5.4.3


2008-10-01 02:23:53

by John W. Linville

[permalink] [raw]
Subject: [PATCH 4/5] wireless: use individual buffers for printing ssid values

Also change escape_ssid to print_ssid to match print_mac semantics.

Signed-off-by: John W. Linville <[email protected]>
---
drivers/net/wireless/ipw2100.c | 19 +++-
drivers/net/wireless/ipw2200.c | 153 ++++++++++++++++-----------
drivers/net/wireless/iwlwifi/iwl-scan.c | 7 +-
drivers/net/wireless/iwlwifi/iwl3945-base.c | 9 +-
drivers/net/wireless/libertas/assoc.c | 17 ++-
drivers/net/wireless/libertas/cmd.c | 3 +-
drivers/net/wireless/libertas/debugfs.c | 4 +-
drivers/net/wireless/libertas/scan.c | 12 ++-
drivers/net/wireless/libertas/wext.c | 3 +-
include/linux/ieee80211.h | 6 +-
include/net/lib80211.h | 5 +-
net/ieee80211/ieee80211_rx.c | 18 ++--
net/ieee80211/ieee80211_wx.c | 6 +-
net/wireless/lib80211.c | 9 +-
14 files changed, 165 insertions(+), 106 deletions(-)

diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index df8d1b3..1846bf1 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -163,6 +163,8 @@ that only one external action is invoked at a time.
#include <linux/ctype.h>
#include <linux/pm_qos_params.h>

+#include <net/lib80211.h>
+
#include "ipw2100.h"

#define IPW2100_VERSION "git-1.2.2"
@@ -1915,6 +1917,7 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)
char *txratename;
u8 bssid[ETH_ALEN];
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);

/*
* TBD: BSSID is usually 00:00:00:00:00:00 here and not
@@ -1977,7 +1980,7 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)

IPW_DEBUG_INFO("%s: Associated with '%s' at %s, channel %d (BSSID="
"%s)\n",
- priv->net_dev->name, escape_ssid(essid, essid_len),
+ priv->net_dev->name, print_ssid(ssid, essid, essid_len),
txratename, chan, print_mac(mac, bssid));

/* now we copy read ssid into dev */
@@ -2004,8 +2007,9 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid,
.host_command_length = ssid_len
};
int err;
+ DECLARE_SSID_BUF(ssid);

- IPW_DEBUG_HC("SSID: '%s'\n", escape_ssid(essid, ssid_len));
+ IPW_DEBUG_HC("SSID: '%s'\n", print_ssid(ssid, essid, ssid_len));

if (ssid_len)
memcpy(cmd.host_command_parameters, essid, ssid_len);
@@ -2047,10 +2051,11 @@ static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid,
static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status)
{
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);

IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC,
"disassociated: '%s' %s \n",
- escape_ssid(priv->essid, priv->essid_len),
+ print_ssid(ssid, priv->essid, priv->essid_len),
print_mac(mac, priv->bssid));

priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING);
@@ -6971,6 +6976,7 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
char *essid = ""; /* ANY */
int length = 0;
int err = 0;
+ DECLARE_SSID_BUF(ssid);

mutex_lock(&priv->action_mutex);
if (!(priv->status & STATUS_INITIALIZED)) {
@@ -7000,8 +7006,8 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
goto done;
}

- IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_ssid(essid, length),
- length);
+ IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n",
+ print_ssid(ssid, essid, length), length);

priv->essid_len = length;
memcpy(priv->essid, essid, priv->essid_len);
@@ -7022,12 +7028,13 @@ static int ipw2100_wx_get_essid(struct net_device *dev,
*/

struct ipw2100_priv *priv = ieee80211_priv(dev);
+ DECLARE_SSID_BUF(ssid);

/* If we are associated, trying to associate, or have a statically
* configured ESSID then return that; otherwise return ANY */
if (priv->config & CFG_STATIC_ESSID || priv->status & STATUS_ASSOCIATED) {
IPW_DEBUG_WX("Getting essid: '%s'\n",
- escape_ssid(priv->essid, priv->essid_len));
+ print_ssid(ssid, priv->essid, priv->essid_len));
memcpy(extra, priv->essid, priv->essid_len);
wrqu->essid.length = priv->essid_len;
wrqu->essid.flags = 1; /* active */
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index e6f77dd..4e4d3e3 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -4398,6 +4398,7 @@ static void ipw_rx_notification(struct ipw_priv *priv,
struct ipw_rx_notification *notif)
{
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);
u16 size = le16_to_cpu(notif->size);
notif->size = le16_to_cpu(notif->size);

@@ -4413,8 +4414,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
IPW_DL_ASSOC,
"associated: '%s' %s"
" \n",
- escape_ssid(priv->essid,
- priv->essid_len),
+ print_ssid(ssid, priv->essid,
+ priv->essid_len),
print_mac(mac, priv->bssid));

switch (priv->ieee->iw_mode) {
@@ -4494,10 +4495,11 @@ static void ipw_rx_notification(struct ipw_priv *priv,
"deauthenticated: '%s' "
"%s"
": (0x%04X) - %s \n",
- escape_ssid(priv->
- essid,
- priv->
- essid_len),
+ print_ssid(ssid,
+ priv->
+ essid,
+ priv->
+ essid_len),
print_mac(mac, priv->bssid),
le16_to_cpu(auth->status),
ipw_get_status_code
@@ -4517,8 +4519,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
IPW_DL_ASSOC,
"authenticated: '%s' %s"
"\n",
- escape_ssid(priv->essid,
- priv->essid_len),
+ print_ssid(ssid, priv->essid,
+ priv->essid_len),
print_mac(mac, priv->bssid));
break;
}
@@ -4546,8 +4548,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
IPW_DL_ASSOC,
"disassociated: '%s' %s"
" \n",
- escape_ssid(priv->essid,
- priv->essid_len),
+ print_ssid(ssid, priv->essid,
+ priv->essid_len),
print_mac(mac, priv->bssid));

priv->status &=
@@ -4584,8 +4586,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
case CMAS_AUTHENTICATED:
IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
"authenticated: '%s' %s \n",
- escape_ssid(priv->essid,
- priv->essid_len),
+ print_ssid(ssid, priv->essid,
+ priv->essid_len),
print_mac(mac, priv->bssid));
priv->status |= STATUS_AUTH;
break;
@@ -4603,8 +4605,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE |
IPW_DL_ASSOC,
"deauthenticated: '%s' %s\n",
- escape_ssid(priv->essid,
- priv->essid_len),
+ print_ssid(ssid, priv->essid,
+ priv->essid_len),
print_mac(mac, priv->bssid));

priv->status &= ~(STATUS_ASSOCIATING |
@@ -5431,6 +5433,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
struct ipw_supported_rates rates;
DECLARE_MAC_BUF(mac);
DECLARE_MAC_BUF(mac2);
+ DECLARE_SSID_BUF(ssid);

/* Verify that this network's capability is compatible with the
* current mode (AdHoc or Infrastructure) */
@@ -5438,7 +5441,8 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
!(network->capability & WLAN_CAPABILITY_IBSS))) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded due to "
"capability mismatch.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5451,8 +5455,8 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
network->ssid_len)) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of non-network ESSID.\n",
- escape_ssid(network->ssid,
- network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5466,13 +5470,14 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
char escaped[IW_ESSID_MAX_SIZE * 2 + 1];

strncpy(escaped,
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
sizeof(escaped));
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of ESSID mismatch: '%s'.\n",
escaped, print_mac(mac, network->bssid),
- escape_ssid(priv->essid,
- priv->essid_len));
+ print_ssid(ssid, priv->essid,
+ priv->essid_len));
return 0;
}
}
@@ -5483,14 +5488,14 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
if (network->time_stamp[0] < match->network->time_stamp[0]) {
IPW_DEBUG_MERGE("Network '%s excluded because newer than "
"current network.\n",
- escape_ssid(match->network->ssid,
- match->network->ssid_len));
+ print_ssid(ssid, match->network->ssid,
+ match->network->ssid_len));
return 0;
} else if (network->time_stamp[1] < match->network->time_stamp[1]) {
IPW_DEBUG_MERGE("Network '%s excluded because newer than "
"current network.\n",
- escape_ssid(match->network->ssid,
- match->network->ssid_len));
+ print_ssid(ssid, match->network->ssid,
+ match->network->ssid_len));
return 0;
}

@@ -5499,7 +5504,8 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of age: %ums.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid),
jiffies_to_msecs(jiffies -
network->last_scanned));
@@ -5510,7 +5516,8 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
(network->channel != priv->channel)) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of channel mismatch: %d != %d.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid),
network->channel, priv->channel);
return 0;
@@ -5521,7 +5528,8 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
((network->capability & WLAN_CAPABILITY_PRIVACY) ? 1 : 0)) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of privacy mismatch: %s != %s.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid),
priv->
capability & CAP_PRIVACY_ON ? "on" : "off",
@@ -5534,8 +5542,8 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
if (!memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of the same BSSID match: %s"
- ".\n", escape_ssid(network->ssid,
- network->ssid_len),
+ ".\n", print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid),
print_mac(mac2, priv->bssid));
return 0;
@@ -5546,7 +5554,8 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of invalid frequency/mode "
"combination.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5557,7 +5566,8 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because configured rate mask excludes "
"AP mandatory rate.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5565,7 +5575,8 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
if (rates.num_rates == 0) {
IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
"because of no compatible rates.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5578,7 +5589,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
ipw_copy_rates(&match->rates, &rates);
match->network = network;
IPW_DEBUG_MERGE("Network '%s (%s)' is a viable match.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid, network->ssid_len),
print_mac(mac, network->bssid));

return 1;
@@ -5586,6 +5597,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,

static void ipw_merge_adhoc_network(struct work_struct *work)
{
+ DECLARE_SSID_BUF(ssid);
struct ipw_priv *priv =
container_of(work, struct ipw_priv, merge_networks);
struct ieee80211_network *network = NULL;
@@ -5616,8 +5628,8 @@ static void ipw_merge_adhoc_network(struct work_struct *work)
mutex_lock(&priv->mutex);
if ((priv->ieee->iw_mode == IW_MODE_ADHOC)) {
IPW_DEBUG_MERGE("remove network %s\n",
- escape_ssid(priv->essid,
- priv->essid_len));
+ print_ssid(ssid, priv->essid,
+ priv->essid_len));
ipw_remove_current_network(priv);
}

@@ -5634,6 +5646,7 @@ static int ipw_best_network(struct ipw_priv *priv,
{
struct ipw_supported_rates rates;
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);

/* Verify that this network's capability is compatible with the
* current mode (AdHoc or Infrastructure) */
@@ -5643,7 +5656,8 @@ static int ipw_best_network(struct ipw_priv *priv,
!(network->capability & WLAN_CAPABILITY_IBSS))) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded due to "
"capability mismatch.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5656,8 +5670,8 @@ static int ipw_best_network(struct ipw_priv *priv,
network->ssid_len)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of non-network ESSID.\n",
- escape_ssid(network->ssid,
- network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5670,13 +5684,14 @@ static int ipw_best_network(struct ipw_priv *priv,
min(network->ssid_len, priv->essid_len)))) {
char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
strncpy(escaped,
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
sizeof(escaped));
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of ESSID mismatch: '%s'.\n",
escaped, print_mac(mac, network->bssid),
- escape_ssid(priv->essid,
- priv->essid_len));
+ print_ssid(ssid, priv->essid,
+ priv->essid_len));
return 0;
}
}
@@ -5686,13 +5701,13 @@ static int ipw_best_network(struct ipw_priv *priv,
if (match->network && match->network->stats.rssi > network->stats.rssi) {
char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
strncpy(escaped,
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid, network->ssid_len),
sizeof(escaped));
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded because "
"'%s (%s)' has a stronger signal.\n",
escaped, print_mac(mac, network->bssid),
- escape_ssid(match->network->ssid,
- match->network->ssid_len),
+ print_ssid(ssid, match->network->ssid,
+ match->network->ssid_len),
print_mac(mac, match->network->bssid));
return 0;
}
@@ -5704,7 +5719,8 @@ static int ipw_best_network(struct ipw_priv *priv,
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of storming (%ums since last "
"assoc attempt).\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid),
jiffies_to_msecs(jiffies -
network->last_associate));
@@ -5716,7 +5732,8 @@ static int ipw_best_network(struct ipw_priv *priv,
time_after(jiffies, network->last_scanned + priv->ieee->scan_age)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of age: %ums.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid),
jiffies_to_msecs(jiffies -
network->last_scanned));
@@ -5727,7 +5744,8 @@ static int ipw_best_network(struct ipw_priv *priv,
(network->channel != priv->channel)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of channel mismatch: %d != %d.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid),
network->channel, priv->channel);
return 0;
@@ -5738,7 +5756,8 @@ static int ipw_best_network(struct ipw_priv *priv,
((network->capability & WLAN_CAPABILITY_PRIVACY) ? 1 : 0)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of privacy mismatch: %s != %s.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid),
priv->capability & CAP_PRIVACY_ON ? "on" :
"off",
@@ -5751,7 +5770,8 @@ static int ipw_best_network(struct ipw_priv *priv,
memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of BSSID mismatch: %s.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid), print_mac(mac, priv->bssid));
return 0;
}
@@ -5761,7 +5781,8 @@ static int ipw_best_network(struct ipw_priv *priv,
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of invalid frequency/mode "
"combination.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5770,7 +5791,8 @@ static int ipw_best_network(struct ipw_priv *priv,
if (!ieee80211_is_valid_channel(priv->ieee, network->channel)) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of invalid channel in current GEO\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5781,7 +5803,8 @@ static int ipw_best_network(struct ipw_priv *priv,
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because configured rate mask excludes "
"AP mandatory rate.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5789,7 +5812,8 @@ static int ipw_best_network(struct ipw_priv *priv,
if (rates.num_rates == 0) {
IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
"because of no compatible rates.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len),
print_mac(mac, network->bssid));
return 0;
}
@@ -5803,7 +5827,7 @@ static int ipw_best_network(struct ipw_priv *priv,
match->network = network;

IPW_DEBUG_ASSOC("Network '%s (%s)' is a viable match.\n",
- escape_ssid(network->ssid, network->ssid_len),
+ print_ssid(ssid, network->ssid, network->ssid_len),
print_mac(mac, network->bssid));

return 1;
@@ -6047,6 +6071,7 @@ static void ipw_bg_adhoc_check(struct work_struct *work)
static void ipw_debug_config(struct ipw_priv *priv)
{
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);
IPW_DEBUG_INFO("Scan completed, no valid APs matched "
"[CFG 0x%08X]\n", priv->config);
if (priv->config & CFG_STATIC_CHANNEL)
@@ -6055,7 +6080,7 @@ static void ipw_debug_config(struct ipw_priv *priv)
IPW_DEBUG_INFO("Channel unlocked.\n");
if (priv->config & CFG_STATIC_ESSID)
IPW_DEBUG_INFO("ESSID locked to '%s'\n",
- escape_ssid(priv->essid, priv->essid_len));
+ print_ssid(ssid, priv->essid, priv->essid_len));
else
IPW_DEBUG_INFO("ESSID unlocked.\n");
if (priv->config & CFG_STATIC_BSSID)
@@ -7275,6 +7300,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
{
int err;
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);

if (priv->config & CFG_FIXED_RATE)
ipw_set_fixed_rate(priv, network->mode);
@@ -7343,7 +7369,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
IPW_DEBUG_ASSOC("%sssocation attempt: '%s', channel %d, "
"802.11%c [%d], %s[:%s], enc=%s%s%s%c%c\n",
roaming ? "Rea" : "A",
- escape_ssid(priv->essid, priv->essid_len),
+ print_ssid(ssid, priv->essid, priv->essid_len),
network->channel,
ipw_modes[priv->assoc_request.ieee_mode],
rates->num_rates,
@@ -7443,7 +7469,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
}

IPW_DEBUG(IPW_DL_STATE, "associating: '%s' %s \n",
- escape_ssid(priv->essid, priv->essid_len),
+ print_ssid(ssid, priv->essid, priv->essid_len),
print_mac(mac, priv->bssid));

return 0;
@@ -7534,6 +7560,7 @@ static int ipw_associate(void *data)
struct ipw_supported_rates *rates;
struct list_head *element;
unsigned long flags;
+ DECLARE_SSID_BUF(ssid);

if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
IPW_DEBUG_ASSOC("Not attempting association (monitor mode)\n");
@@ -7596,8 +7623,8 @@ static int ipw_associate(void *data)
target = oldest;
IPW_DEBUG_ASSOC("Expired '%s' (%s) from "
"network list.\n",
- escape_ssid(target->ssid,
- target->ssid_len),
+ print_ssid(ssid, target->ssid,
+ target->ssid_len),
print_mac(mac, target->bssid));
list_add_tail(&target->list,
&priv->ieee->network_free_list);
@@ -9036,6 +9063,7 @@ static int ipw_wx_set_essid(struct net_device *dev,
{
struct ipw_priv *priv = ieee80211_priv(dev);
int length;
+ DECLARE_SSID_BUF(ssid);

mutex_lock(&priv->mutex);

@@ -9060,8 +9088,8 @@ static int ipw_wx_set_essid(struct net_device *dev,
return 0;
}

- IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_ssid(extra, length),
- length);
+ IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n",
+ print_ssid(ssid, extra, length), length);

priv->essid_len = length;
memcpy(priv->essid, extra, priv->essid_len);
@@ -9080,6 +9108,7 @@ static int ipw_wx_get_essid(struct net_device *dev,
union iwreq_data *wrqu, char *extra)
{
struct ipw_priv *priv = ieee80211_priv(dev);
+ DECLARE_SSID_BUF(ssid);

/* If we are associated, trying to associate, or have a statically
* configured ESSID then return that; otherwise return ANY */
@@ -9087,7 +9116,7 @@ static int ipw_wx_get_essid(struct net_device *dev,
if (priv->config & CFG_STATIC_ESSID ||
priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) {
IPW_DEBUG_WX("Getting essid: '%s'\n",
- escape_ssid(priv->essid, priv->essid_len));
+ print_ssid(ssid, priv->essid, priv->essid_len));
memcpy(extra, priv->essid, priv->essid_len);
wrqu->essid.length = priv->essid_len;
wrqu->essid.flags = 1; /* active */
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 9488e50..a41b5f1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -663,6 +663,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
enum ieee80211_band band;
u8 n_probes = 2;
u8 rx_chain = 0x7; /* bitmap: ABC chains */
+ DECLARE_SSID_BUF(ssid);

conf = ieee80211_get_hw_conf(priv->hw);

@@ -755,8 +756,8 @@ static void iwl_bg_request_scan(struct work_struct *data)
/* We should add the ability for user to lock to PASSIVE ONLY */
if (priv->one_direct_scan) {
IWL_DEBUG_SCAN("Start direct scan for '%s'\n",
- escape_ssid(priv->direct_ssid,
- priv->direct_ssid_len));
+ print_ssid(ssid, priv->direct_ssid,
+ priv->direct_ssid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->direct_ssid_len;
memcpy(scan->direct_scan[0].ssid,
@@ -764,7 +765,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
n_probes++;
} else if (!iwl_is_associated(priv) && priv->essid_len) {
IWL_DEBUG_SCAN("Start direct scan for '%s' (not associated)\n",
- escape_ssid(priv->essid, priv->essid_len));
+ print_ssid(ssid, priv->essid, priv->essid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->essid_len;
memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index c81b743..764296c 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -6063,6 +6063,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
struct ieee80211_conf *conf = NULL;
u8 n_probes = 2;
enum ieee80211_band band;
+ DECLARE_SSID_BUF(ssid);

conf = ieee80211_get_hw_conf(priv->hw);

@@ -6163,7 +6164,8 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
if (priv->one_direct_scan) {
IWL_DEBUG_SCAN
("Kicking off one direct scan for '%s'\n",
- escape_ssid(priv->direct_ssid, priv->direct_ssid_len));
+ print_ssid(ssid, priv->direct_ssid,
+ priv->direct_ssid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->direct_ssid_len;
memcpy(scan->direct_scan[0].ssid,
@@ -6172,7 +6174,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
} else if (!iwl3945_is_associated(priv) && priv->essid_len) {
IWL_DEBUG_SCAN
("Kicking off one direct scan for '%s' when not associated\n",
- escape_ssid(priv->essid, priv->essid_len));
+ print_ssid(ssid, priv->essid, priv->essid_len));
scan->direct_scan[0].id = WLAN_EID_SSID;
scan->direct_scan[0].len = priv->essid_len;
memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len);
@@ -6958,6 +6960,7 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
int rc = 0;
unsigned long flags;
struct iwl3945_priv *priv = hw->priv;
+ DECLARE_SSID_BUF(ssid_buf);

IWL_DEBUG_MAC80211("enter\n");

@@ -6991,7 +6994,7 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
}
if (len) {
IWL_DEBUG_SCAN("direct scan for %s [%d]\n ",
- escape_ssid(ssid, len), (int)len);
+ print_ssid(ssid_buf, ssid, len), (int)len);

priv->one_direct_scan = 1;
priv->direct_ssid_len = (u8)
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 693d786..6cb13ad 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -154,17 +154,18 @@ static int lbs_adhoc_join(struct lbs_private *priv,
struct bss_descriptor *bss = &assoc_req->bss;
u8 preamble = RADIO_PREAMBLE_LONG;
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);
u16 ratesize = 0;
int ret = 0;

lbs_deb_enter(LBS_DEB_ASSOC);

lbs_deb_join("current SSID '%s', ssid length %u\n",
- escape_ssid(priv->curbssparams.ssid,
+ print_ssid(ssid, priv->curbssparams.ssid,
priv->curbssparams.ssid_len),
priv->curbssparams.ssid_len);
lbs_deb_join("requested ssid '%s', ssid length %u\n",
- escape_ssid(bss->ssid, bss->ssid_len),
+ print_ssid(ssid, bss->ssid, bss->ssid_len),
bss->ssid_len);

/* check if the requested SSID is already joined */
@@ -309,6 +310,7 @@ static int lbs_adhoc_start(struct lbs_private *priv,
size_t ratesize = 0;
u16 tmpcap = 0;
int ret = 0;
+ DECLARE_SSID_BUF(ssid);

lbs_deb_enter(LBS_DEB_ASSOC);

@@ -328,7 +330,7 @@ static int lbs_adhoc_start(struct lbs_private *priv,
memcpy(cmd.ssid, assoc_req->ssid, assoc_req->ssid_len);

lbs_deb_join("ADHOC_START: SSID '%s', ssid length %u\n",
- escape_ssid(assoc_req->ssid, assoc_req->ssid_len),
+ print_ssid(ssid, assoc_req->ssid, assoc_req->ssid_len),
assoc_req->ssid_len);

cmd.bsstype = CMD_BSS_TYPE_IBSS;
@@ -696,6 +698,7 @@ static int assoc_helper_essid(struct lbs_private *priv,
int ret = 0;
struct bss_descriptor * bss;
int channel = -1;
+ DECLARE_SSID_BUF(ssid);

lbs_deb_enter(LBS_DEB_ASSOC);

@@ -707,7 +710,7 @@ static int assoc_helper_essid(struct lbs_private *priv,
channel = assoc_req->channel;

lbs_deb_assoc("SSID '%s' requested\n",
- escape_ssid(assoc_req->ssid, assoc_req->ssid_len));
+ print_ssid(ssid, assoc_req->ssid, assoc_req->ssid_len));
if (assoc_req->mode == IW_MODE_INFRA) {
lbs_send_specific_ssid_scan(priv, assoc_req->ssid,
assoc_req->ssid_len);
@@ -1211,6 +1214,7 @@ void lbs_association_worker(struct work_struct *work)
int ret = 0;
int find_any_ssid = 0;
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);

lbs_deb_enter(LBS_DEB_ASSOC);

@@ -1234,7 +1238,7 @@ void lbs_association_worker(struct work_struct *work)
" secinfo: %s%s%s\n"
" auth_mode: %d\n",
assoc_req->flags,
- escape_ssid(assoc_req->ssid, assoc_req->ssid_len),
+ print_ssid(ssid, assoc_req->ssid, assoc_req->ssid_len),
assoc_req->channel, assoc_req->band, assoc_req->mode,
print_mac(mac, assoc_req->bssid),
assoc_req->secinfo.WPAenabled ? " WPA" : "",
@@ -1773,6 +1777,7 @@ static int lbs_adhoc_post(struct lbs_private *priv, struct cmd_header *resp)
union iwreq_data wrqu;
struct bss_descriptor *bss;
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);

lbs_deb_enter(LBS_DEB_JOIN);

@@ -1822,7 +1827,7 @@ static int lbs_adhoc_post(struct lbs_private *priv, struct cmd_header *resp)
wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);

lbs_deb_join("ADHOC_RESP: Joined/started '%s', BSSID %s, channel %d\n",
- escape_ssid(bss->ssid, bss->ssid_len),
+ print_ssid(ssid, bss->ssid, bss->ssid_len),
print_mac(mac, priv->curbssparams.bssid),
priv->curbssparams.channel);

diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index c1048fd..fd75326 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -1062,6 +1062,7 @@ int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan)
{
struct cmd_ds_mesh_config cmd;
struct mrvl_meshie *ie;
+ DECLARE_SSID_BUF(ssid);

memset(&cmd, 0, sizeof(cmd));
cmd.channel = cpu_to_le16(chan);
@@ -1092,7 +1093,7 @@ int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan)
}
lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n",
action, priv->mesh_tlv, chan,
- escape_ssid(priv->mesh_ssid, priv->mesh_ssid_len));
+ print_ssid(ssid, priv->mesh_ssid, priv->mesh_ssid_len));

return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv);
}
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 89f5d62..de3c6ed 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -67,6 +67,7 @@ static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
unsigned long addr = get_zeroed_page(GFP_KERNEL);
char *buf = (char *)addr;
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);
struct bss_descriptor * iter_bss;

pos += snprintf(buf+pos, len-pos,
@@ -88,7 +89,8 @@ static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
spectrum_mgmt ? 'S' : ' ');
pos += snprintf(buf+pos, len-pos, " %04d |", SCAN_RSSI(iter_bss->rssi));
pos += snprintf(buf+pos, len-pos, " %s\n",
- escape_ssid(iter_bss->ssid, iter_bss->ssid_len));
+ print_ssid(ssid, iter_bss->ssid,
+ iter_bss->ssid_len));

numscansdone++;
}
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index fd0f640..5b3b252 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -363,6 +363,7 @@ int lbs_scan_networks(struct lbs_private *priv, int full_scan)
struct bss_descriptor *iter;
int i = 0;
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);
#endif

lbs_deb_enter_args(LBS_DEB_SCAN, "full_scan %d", full_scan);
@@ -456,7 +457,7 @@ int lbs_scan_networks(struct lbs_private *priv, int full_scan)
list_for_each_entry(iter, &priv->network_list, list)
lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n",
i++, print_mac(mac, iter->bssid), iter->rssi,
- escape_ssid(iter->ssid, iter->ssid_len));
+ print_ssid(ssid, iter->ssid, iter->ssid_len));
mutex_unlock(&priv->lock);
#endif

@@ -516,6 +517,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
struct ieeetypes_cfparamset *pCF;
struct ieeetypes_ibssparamset *pibss;
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);
struct ieeetypes_countryinfoset *pcountryinfo;
uint8_t *pos, *end, *p;
uint8_t n_ex_rates = 0, got_basic_rates = 0, n_basic_rates = 0;
@@ -604,7 +606,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
bss->ssid_len = elem->len;
memcpy(bss->ssid, elem->data, elem->len);
lbs_deb_scan("got SSID IE: '%s', len %u\n",
- escape_ssid(bss->ssid, bss->ssid_len),
+ print_ssid(ssid, bss->ssid, bss->ssid_len),
bss->ssid_len);
break;

@@ -744,10 +746,11 @@ done:
int lbs_send_specific_ssid_scan(struct lbs_private *priv, uint8_t *ssid,
uint8_t ssid_len)
{
+ DECLARE_SSID_BUF(ssid_buf);
int ret = 0;

lbs_deb_enter_args(LBS_DEB_SCAN, "SSID '%s'\n",
- escape_ssid(ssid, ssid_len));
+ print_ssid(ssid_buf, ssid, ssid_len));

if (!ssid_len)
goto out;
@@ -942,6 +945,7 @@ out:
int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
+ DECLARE_SSID_BUF(ssid);
struct lbs_private *priv = dev->priv;
int ret = 0;

@@ -971,7 +975,7 @@ int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
priv->scan_ssid_len = req->essid_len;
memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len);
lbs_deb_wext("set_scan, essid '%s'\n",
- escape_ssid(priv->scan_ssid, priv->scan_ssid_len));
+ print_ssid(ssid, priv->scan_ssid, priv->scan_ssid_len));
} else {
priv->scan_ssid_len = 0;
}
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 12baf0d..5f18bf8 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -1978,6 +1978,7 @@ static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
u8 ssid_len = 0;
struct assoc_request * assoc_req;
int in_ssid_len = dwrq->length;
+ DECLARE_SSID_BUF(ssid_buf);

lbs_deb_enter(LBS_DEB_WEXT);

@@ -2006,7 +2007,7 @@ static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
lbs_deb_wext("requested any SSID\n");
} else {
lbs_deb_wext("requested SSID '%s'\n",
- escape_ssid(ssid, ssid_len));
+ print_ssid(ssid_buf, ssid, ssid_len));
}

out:
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 14126bc..58e9fa1 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -12,8 +12,8 @@
* published by the Free Software Foundation.
*/

-#ifndef IEEE80211_H
-#define IEEE80211_H
+#ifndef LINUX_IEEE80211_H
+#define LINUX_IEEE80211_H

#include <linux/types.h>
#include <asm/byteorder.h>
@@ -1057,4 +1057,4 @@ static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
return hdr->addr1;
}

-#endif /* IEEE80211_H */
+#endif /* LINUX_IEEE80211_H */
diff --git a/include/net/lib80211.h b/include/net/lib80211.h
index ce49a30..d5f4e60 100644
--- a/include/net/lib80211.h
+++ b/include/net/lib80211.h
@@ -8,8 +8,9 @@
#ifndef LIB80211_H
#define LIB80211_H

-/* escape_ssid() is intended to be used in debug (and possibly error)
+/* print_ssid() is intended to be used in debug (and possibly error)
* messages. It should never be used for passing ssid to user space. */
-const char *escape_ssid(const char *ssid, u8 ssid_len);
+const char *print_ssid(char *buf, const char *ssid, u8 ssid_len);
+#define DECLARE_SSID_BUF(var) char var[32 * 4 + 1]

#endif /* LIB80211_H */
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index 15c65da..cf72ae4 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -1145,6 +1145,7 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
*info_element, u16 length,
struct ieee80211_network *network)
{
+ DECLARE_SSID_BUF(ssid);
u8 i;
#ifdef CONFIG_IEEE80211_DEBUG
char rates_str[64];
@@ -1176,7 +1177,8 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
IW_ESSID_MAX_SIZE - network->ssid_len);

IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
- escape_ssid(network->ssid),
+ print_ssid(ssid, network->ssid,
+ network->ssid_len);
network->ssid_len);
break;

@@ -1423,6 +1425,7 @@ static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee8021
struct ieee80211_rx_stats *stats)
{
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);

network->qos_data.active = 0;
network->qos_data.supported = 0;
@@ -1472,7 +1475,7 @@ static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee8021
if (network->mode == 0) {
IEEE80211_DEBUG_SCAN("Filtered out '%s (%s)' "
"network.\n",
- escape_ssid(network->ssid,
+ print_ssid(ssid, network->ssid,
network->ssid_len),
print_mac(mac, network->bssid));
return 1;
@@ -1588,10 +1591,11 @@ static void ieee80211_process_probe_response(struct ieee80211_device
#endif
unsigned long flags;
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);

IEEE80211_DEBUG_SCAN("'%s' (%s"
"): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
- escape_ssid(info_element->data, info_element->len),
+ print_ssid(ssid, info_element->data, info_element->len),
print_mac(mac, beacon->header.addr3),
(beacon->capability & cpu_to_le16(1 << 0xf)) ? '1' : '0',
(beacon->capability & cpu_to_le16(1 << 0xe)) ? '1' : '0',
@@ -1612,7 +1616,7 @@ static void ieee80211_process_probe_response(struct ieee80211_device

if (ieee80211_network_init(ieee, beacon, &network, stats)) {
IEEE80211_DEBUG_SCAN("Dropped '%s' (%s) via %s.\n",
- escape_ssid(info_element->data,
+ print_ssid(ssid, info_element->data,
info_element->len),
print_mac(mac, beacon->header.addr3),
is_beacon(beacon->header.frame_ctl) ?
@@ -1650,7 +1654,7 @@ static void ieee80211_process_probe_response(struct ieee80211_device
target = oldest;
IEEE80211_DEBUG_SCAN("Expired '%s' (%s) from "
"network list.\n",
- escape_ssid(target->ssid,
+ print_ssid(ssid, target->ssid,
target->ssid_len),
print_mac(mac, target->bssid));
ieee80211_network_reset(target);
@@ -1663,7 +1667,7 @@ static void ieee80211_process_probe_response(struct ieee80211_device

#ifdef CONFIG_IEEE80211_DEBUG
IEEE80211_DEBUG_SCAN("Adding '%s' (%s) via %s.\n",
- escape_ssid(network.ssid,
+ print_ssid(ssid, network.ssid,
network.ssid_len),
print_mac(mac, network.bssid),
is_beacon(beacon->header.frame_ctl) ?
@@ -1674,7 +1678,7 @@ static void ieee80211_process_probe_response(struct ieee80211_device
list_add_tail(&target->list, &ieee->network_list);
} else {
IEEE80211_DEBUG_SCAN("Updating '%s' (%s) via %s.\n",
- escape_ssid(target->ssid,
+ print_ssid(ssid, target->ssid,
target->ssid_len),
print_mac(mac, target->bssid),
is_beacon(beacon->header.frame_ctl) ?
diff --git a/net/ieee80211/ieee80211_wx.c b/net/ieee80211/ieee80211_wx.c
index db79e6c..698a856 100644
--- a/net/ieee80211/ieee80211_wx.c
+++ b/net/ieee80211/ieee80211_wx.c
@@ -34,6 +34,7 @@
#include <linux/module.h>
#include <linux/jiffies.h>

+#include <net/lib80211.h>
#include <net/ieee80211.h>
#include <linux/wireless.h>

@@ -259,6 +260,7 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
char *stop = ev + wrqu->data.length;
int i = 0;
DECLARE_MAC_BUF(mac);
+ DECLARE_SSID_BUF(ssid);

IEEE80211_DEBUG_WX("Getting scan\n");

@@ -278,7 +280,7 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
else
IEEE80211_DEBUG_SCAN("Not showing network '%s ("
"%s)' due to age (%dms).\n",
- escape_ssid(network->ssid,
+ print_ssid(ssid, network->ssid,
network->ssid_len),
print_mac(mac, network->bssid),
jiffies_to_msecs(jiffies -
@@ -403,7 +405,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
memset(sec.keys[key] + erq->length, 0,
len - erq->length);
IEEE80211_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n",
- key, escape_ssid(sec.keys[key], len),
+ key, print_ssid(ssid, sec.keys[key], len),
erq->length, len);
sec.key_sizes[key] = len;
if (*crypt)
diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c
index b8e34d3..e71f7d0 100644
--- a/net/wireless/lib80211.c
+++ b/net/wireless/lib80211.c
@@ -19,11 +19,10 @@ MODULE_DESCRIPTION(DRV_DESCRIPTION);
MODULE_AUTHOR("John W. Linville <[email protected]>");
MODULE_LICENSE("GPL");

-const char *escape_ssid(const char *ssid, u8 ssid_len)
+const char *print_ssid(char *buf, const char *ssid, u8 ssid_len)
{
- static char escaped[IEEE80211_MAX_SSID_LEN * 4 + 1];
const char *s = ssid;
- char *d = escaped;
+ char *d = buf;

ssid_len = min_t(u8, ssid_len, IEEE80211_MAX_SSID_LEN);
while (ssid_len--) {
@@ -48,9 +47,9 @@ const char *escape_ssid(const char *ssid, u8 ssid_len)
s++;
}
*d = '\0';
- return escaped;
+ return buf;
}
-EXPORT_SYMBOL(escape_ssid);
+EXPORT_SYMBOL(print_ssid);

static int __init ieee80211_init(void)
{
--
1.5.4.3


2008-10-01 02:23:53

by John W. Linville

[permalink] [raw]
Subject: [PATCH 2/5] wireless: remove NETWORK_EMPTY_ESSID flag

It is unnecessary and of questionable value. Also remove
is_empty_ssid, as it is also unnecessary.

Signed-off-by: John W. Linville <[email protected]>
---
drivers/net/wireless/ipw2200.c | 23 +----------------------
include/net/ieee80211.h | 1 -
include/net/lib80211.h | 16 ----------------
net/ieee80211/ieee80211_rx.c | 15 ++-------------
net/ieee80211/ieee80211_wx.c | 12 +++---------
net/wireless/lib80211.c | 5 -----
6 files changed, 6 insertions(+), 66 deletions(-)

diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 41f9e46..e6f77dd 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -5443,16 +5443,6 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
return 0;
}

- /* If we do not have an ESSID for this AP, we can not associate with
- * it */
- if (network->flags & NETWORK_EMPTY_ESSID) {
- IPW_DEBUG_MERGE("Network '%s (%s)' excluded "
- "because of hidden ESSID.\n",
- escape_ssid(network->ssid, network->ssid_len),
- print_mac(mac, network->bssid));
- return 0;
- }
-
if (unlikely(roaming)) {
/* If we are roaming, then ensure check if this is a valid
* network to try and roam to */
@@ -5658,16 +5648,6 @@ static int ipw_best_network(struct ipw_priv *priv,
return 0;
}

- /* If we do not have an ESSID for this AP, we can not associate with
- * it */
- if (network->flags & NETWORK_EMPTY_ESSID) {
- IPW_DEBUG_ASSOC("Network '%s (%s)' excluded "
- "because of hidden ESSID.\n",
- escape_ssid(network->ssid, network->ssid_len),
- print_mac(mac, network->bssid));
- return 0;
- }
-
if (unlikely(roaming)) {
/* If we are roaming, then ensure check if this is a valid
* network to try and roam to */
@@ -6892,8 +6872,7 @@ static int ipw_qos_handle_probe_response(struct ipw_priv *priv,
if ((priv->status & STATUS_ASSOCIATED) &&
(priv->ieee->iw_mode == IW_MODE_ADHOC) && (active_network == 0)) {
if (memcmp(network->bssid, priv->bssid, ETH_ALEN))
- if ((network->capability & WLAN_CAPABILITY_IBSS) &&
- !(network->flags & NETWORK_EMPTY_ESSID))
+ if (network->capability & WLAN_CAPABILITY_IBSS)
if ((network->ssid_len ==
priv->assoc_network->ssid_len) &&
!memcmp(network->ssid,
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index c638239..7b0a505 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -729,7 +729,6 @@ struct ieee80211_txb {

#define MAX_WPA_IE_LEN 64

-#define NETWORK_EMPTY_ESSID (1<<0)
#define NETWORK_HAS_OFDM (1<<1)
#define NETWORK_HAS_CCK (1<<2)

diff --git a/include/net/lib80211.h b/include/net/lib80211.h
index 91a64f3..ce49a30 100644
--- a/include/net/lib80211.h
+++ b/include/net/lib80211.h
@@ -12,20 +12,4 @@
* messages. It should never be used for passing ssid to user space. */
const char *escape_ssid(const char *ssid, u8 ssid_len);

-static inline int is_empty_ssid(const char *ssid, int ssid_len)
-{
- /* Single white space is for Linksys APs */
- if (ssid_len == 1 && ssid[0] == ' ')
- return 1;
-
- /* Otherwise, if the entire ssid is 0, we assume it is hidden */
- while (ssid_len) {
- ssid_len--;
- if (ssid[ssid_len] != '\0')
- return 0;
- }
-
- return 1;
-}
-
#endif /* LIB80211_H */
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index 34239db..15c65da 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -1167,12 +1167,6 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element

switch (info_element->id) {
case MFIE_TYPE_SSID:
- if (is_empty_ssid(info_element->data,
- info_element->len)) {
- network->flags |= NETWORK_EMPTY_ESSID;
- break;
- }
-
network->ssid_len = min(info_element->len,
(u8) IW_ESSID_MAX_SIZE);
memcpy(network->ssid, info_element->data,
@@ -1182,7 +1176,8 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
IW_ESSID_MAX_SIZE - network->ssid_len);

IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
- network->ssid, network->ssid_len);
+ escape_ssid(network->ssid),
+ network->ssid_len);
break;

case MFIE_TYPE_RATES:
@@ -1412,9 +1407,6 @@ static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct iee
network->mode |= IEEE_B;
}

- if (is_empty_ssid(network->ssid, network->ssid_len))
- network->flags |= NETWORK_EMPTY_ESSID;
-
memcpy(&network->stats, stats, sizeof(network->stats));

if (ieee->handle_assoc_response != NULL)
@@ -1486,9 +1478,6 @@ static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee8021
return 1;
}

- if (is_empty_ssid(network->ssid, network->ssid_len))
- network->flags |= NETWORK_EMPTY_ESSID;
-
memcpy(&network->stats, stats, sizeof(network->stats));

return 0;
diff --git a/net/ieee80211/ieee80211_wx.c b/net/ieee80211/ieee80211_wx.c
index c338279..db79e6c 100644
--- a/net/ieee80211/ieee80211_wx.c
+++ b/net/ieee80211/ieee80211_wx.c
@@ -65,15 +65,9 @@ static char *ieee80211_translate_scan(struct ieee80211_device *ieee,
/* Add the ESSID */
iwe.cmd = SIOCGIWESSID;
iwe.u.data.flags = 1;
- if (network->flags & NETWORK_EMPTY_ESSID) {
- iwe.u.data.length = sizeof("<hidden>");
- start = iwe_stream_add_point(info, start, stop,
- &iwe, "<hidden>");
- } else {
- iwe.u.data.length = min(network->ssid_len, (u8) 32);
- start = iwe_stream_add_point(info, start, stop,
- &iwe, network->ssid);
- }
+ iwe.u.data.length = min(network->ssid_len, (u8) 32);
+ start = iwe_stream_add_point(info, start, stop,
+ &iwe, network->ssid);

/* Add the protocol name */
iwe.cmd = SIOCGIWNAME;
diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c
index b22d271..872cc8d 100644
--- a/net/wireless/lib80211.c
+++ b/net/wireless/lib80211.c
@@ -24,11 +24,6 @@ const char *escape_ssid(const char *ssid, u8 ssid_len)
const char *s = ssid;
char *d = escaped;

- if (is_empty_ssid(ssid, ssid_len)) {
- memcpy(escaped, "<hidden>", sizeof("<hidden>"));
- return escaped;
- }
-
ssid_len = min_t(u8, ssid_len, IEEE80211_MAX_SSID_LEN);
while (ssid_len--) {
if (*s == '\0') {
--
1.5.4.3


2008-10-01 09:25:08

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 0/5] wireless: single escape_essid implementation and related cleanups

On Tue, 2008-09-30 at 22:15 -0400, John W. Linville wrote:
> This is a repost of my escape_essid consolidation. Also included are
> some suggested changes from the original post and a few cleanups. There
> is still plenty to be done -- of course, this isn't really high priority
> work either...
>
> [PATCH 1/5] wireless: consolidate on a single escape_essid implementation
> [PATCH 2/5] wireless: remove NETWORK_EMPTY_ESSID flag
> [PATCH 3/5] wireless: escape_ssid should handle non-printables
> [PATCH 4/5] wireless: use individual buffers for printing ssid values
> [PATCH 5/5] wireless: avoid some net/ieee80211.h vs. linux/ieee80211.h conflicts
>
> Comments welcome!

Looks good to me, thanks!

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-10-01 02:23:53

by John W. Linville

[permalink] [raw]
Subject: [PATCH 5/5] wireless: avoid some net/ieee80211.h vs. linux/ieee80211.h conflicts

There is quite a lot of overlap in definitions between these headers...

Signed-off-by: John W. Linville <[email protected]>
---
drivers/net/wireless/hostap/hostap_common.h | 13 ---
drivers/net/wireless/ipw2200.c | 24 +++---
include/net/ieee80211.h | 112 +--------------------------
include/net/lib80211.h | 4 +-
net/ieee80211/ieee80211_rx.c | 2 +-
5 files changed, 18 insertions(+), 137 deletions(-)

diff --git a/drivers/net/wireless/hostap/hostap_common.h b/drivers/net/wireless/hostap/hostap_common.h
index b470c74..90b64b0 100644
--- a/drivers/net/wireless/hostap/hostap_common.h
+++ b/drivers/net/wireless/hostap/hostap_common.h
@@ -6,19 +6,6 @@

/* IEEE 802.11 defines */

-/* Information Element IDs */
-#define WLAN_EID_SSID 0
-#define WLAN_EID_SUPP_RATES 1
-#define WLAN_EID_FH_PARAMS 2
-#define WLAN_EID_DS_PARAMS 3
-#define WLAN_EID_CF_PARAMS 4
-#define WLAN_EID_TIM 5
-#define WLAN_EID_IBSS_PARAMS 6
-#define WLAN_EID_CHALLENGE 16
-#define WLAN_EID_RSN 48
-#define WLAN_EID_GENERIC 221
-
-
/* HFA384X Configuration RIDs */
#define HFA384X_RID_CNFPORTTYPE 0xFC00
#define HFA384X_RID_CNFOWNMACADDR 0xFC01
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 4e4d3e3..534f3b9 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -4450,7 +4450,7 @@ static void ipw_rx_notification(struct ipw_priv *priv,

#ifdef CONFIG_IPW2200_QOS
#define IPW_GET_PACKET_STYPE(x) WLAN_FC_GET_STYPE( \
- le16_to_cpu(((struct ieee80211_hdr *)(x))->frame_ctl))
+ le16_to_cpu(((struct ieee80211_hdr *)(x))->frame_control))
if ((priv->status & STATUS_AUTH) &&
(IPW_GET_PACKET_STYPE(&notif->u.raw)
== IEEE80211_STYPE_ASSOC_RESP)) {
@@ -7678,12 +7678,12 @@ static void ipw_rebuild_decrypted_skb(struct ipw_priv *priv,
u16 fc;

hdr = (struct ieee80211_hdr *)skb->data;
- fc = le16_to_cpu(hdr->frame_ctl);
+ fc = le16_to_cpu(hdr->frame_control);
if (!(fc & IEEE80211_FCTL_PROTECTED))
return;

fc &= ~IEEE80211_FCTL_PROTECTED;
- hdr->frame_ctl = cpu_to_le16(fc);
+ hdr->frame_control = cpu_to_le16(fc);
switch (priv->ieee->sec.level) {
case SEC_LEVEL_3:
/* Remove CCMP HDR */
@@ -7995,17 +7995,17 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
}

hdr = (void *)rxb->skb->data + IPW_RX_FRAME_SIZE;
- if (ieee80211_is_management(le16_to_cpu(hdr->frame_ctl))) {
+ if (ieee80211_is_management(le16_to_cpu(hdr->frame_control))) {
if (filter & IPW_PROM_NO_MGMT)
return;
if (filter & IPW_PROM_MGMT_HEADER_ONLY)
hdr_only = 1;
- } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_ctl))) {
+ } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_control))) {
if (filter & IPW_PROM_NO_CTL)
return;
if (filter & IPW_PROM_CTL_HEADER_ONLY)
hdr_only = 1;
- } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_ctl))) {
+ } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_control))) {
if (filter & IPW_PROM_NO_DATA)
return;
if (filter & IPW_PROM_DATA_HEADER_ONLY)
@@ -8023,7 +8023,7 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
ipw_rt = (void *)skb->data;

if (hdr_only)
- len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+ len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control));

memcpy(ipw_rt->payload, hdr, len);

@@ -8243,7 +8243,7 @@ static int is_duplicate_packet(struct ipw_priv *priv,
/* Comment this line now since we observed the card receives
* duplicate packets but the FCTL_RETRY bit is not set in the
* IBSS mode with fragmentation enabled.
- BUG_ON(!(le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_RETRY)); */
+ BUG_ON(!(le16_to_cpu(header->frame_control) & IEEE80211_FCTL_RETRY)); */
return 1;
}

@@ -10407,17 +10407,17 @@ static void ipw_handle_promiscuous_tx(struct ipw_priv *priv,

/* Filtering of fragment chains is done agains the first fragment */
hdr = (void *)txb->fragments[0]->data;
- if (ieee80211_is_management(le16_to_cpu(hdr->frame_ctl))) {
+ if (ieee80211_is_management(le16_to_cpu(hdr->frame_control))) {
if (filter & IPW_PROM_NO_MGMT)
return;
if (filter & IPW_PROM_MGMT_HEADER_ONLY)
hdr_only = 1;
- } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_ctl))) {
+ } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_control))) {
if (filter & IPW_PROM_NO_CTL)
return;
if (filter & IPW_PROM_CTL_HEADER_ONLY)
hdr_only = 1;
- } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_ctl))) {
+ } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_control))) {
if (filter & IPW_PROM_NO_DATA)
return;
if (filter & IPW_PROM_DATA_HEADER_ONLY)
@@ -10432,7 +10432,7 @@ static void ipw_handle_promiscuous_tx(struct ipw_priv *priv,

if (hdr_only) {
hdr = (void *)src->data;
- len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+ len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control));
} else
len = src->len;

diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index 7b0a505..99bccd7 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -28,6 +28,7 @@
#include <linux/if_ether.h> /* ETH_ALEN */
#include <linux/kernel.h> /* ARRAY_SIZE */
#include <linux/wireless.h>
+#include <linux/ieee80211.h>

#define IEEE80211_VERSION "git-1.1.13"

@@ -214,94 +215,6 @@ struct ieee80211_snap_hdr {
#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)

-/* Authentication algorithms */
-#define WLAN_AUTH_OPEN 0
-#define WLAN_AUTH_SHARED_KEY 1
-#define WLAN_AUTH_LEAP 2
-
-#define WLAN_AUTH_CHALLENGE_LEN 128
-
-#define WLAN_CAPABILITY_ESS (1<<0)
-#define WLAN_CAPABILITY_IBSS (1<<1)
-#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
-#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
-#define WLAN_CAPABILITY_PRIVACY (1<<4)
-#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
-#define WLAN_CAPABILITY_PBCC (1<<6)
-#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
-#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
-#define WLAN_CAPABILITY_QOS (1<<9)
-#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
-#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
-
-/* 802.11g ERP information element */
-#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
-#define WLAN_ERP_USE_PROTECTION (1<<1)
-#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
-
-/* Status codes */
-enum ieee80211_statuscode {
- WLAN_STATUS_SUCCESS = 0,
- WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
- WLAN_STATUS_CAPS_UNSUPPORTED = 10,
- WLAN_STATUS_REASSOC_NO_ASSOC = 11,
- WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
- WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
- WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
- WLAN_STATUS_CHALLENGE_FAIL = 15,
- WLAN_STATUS_AUTH_TIMEOUT = 16,
- WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
- WLAN_STATUS_ASSOC_DENIED_RATES = 18,
- /* 802.11b */
- WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
- WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
- WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
- /* 802.11h */
- WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
- WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
- WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
- /* 802.11g */
- WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
- WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
- /* 802.11i */
- WLAN_STATUS_INVALID_IE = 40,
- WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
- WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
- WLAN_STATUS_INVALID_AKMP = 43,
- WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
- WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
- WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
-};
-
-/* Reason codes */
-enum ieee80211_reasoncode {
- WLAN_REASON_UNSPECIFIED = 1,
- WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
- WLAN_REASON_DEAUTH_LEAVING = 3,
- WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
- WLAN_REASON_DISASSOC_AP_BUSY = 5,
- WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
- WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
- WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
- WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
- /* 802.11h */
- WLAN_REASON_DISASSOC_BAD_POWER = 10,
- WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
- /* 802.11i */
- WLAN_REASON_INVALID_IE = 13,
- WLAN_REASON_MIC_FAILURE = 14,
- WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
- WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
- WLAN_REASON_IE_DIFFERENT = 17,
- WLAN_REASON_INVALID_GROUP_CIPHER = 18,
- WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
- WLAN_REASON_INVALID_AKMP = 20,
- WLAN_REASON_UNSUPP_RSN_VERSION = 21,
- WLAN_REASON_INVALID_RSN_IE_CAP = 22,
- WLAN_REASON_IEEE8021X_FAILED = 23,
- WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
-};
-
/* Action categories - 802.11h */
enum ieee80211_actioncategories {
WLAN_ACTION_SPECTRUM_MGMT = 0,
@@ -530,15 +443,6 @@ enum ieee80211_mfie {
MFIE_TYPE_QOS_PARAMETER = 222,
};

-/* Minimal header; can be used for passing 802.11 frames with sufficient
- * information to determine what type of underlying data type is actually
- * stored in the data. */
-struct ieee80211_hdr {
- __le16 frame_ctl;
- __le16 duration_id;
- u8 payload[0];
-} __attribute__ ((packed));
-
struct ieee80211_hdr_1addr {
__le16 frame_ctl;
__le16 duration_id;
@@ -586,18 +490,6 @@ struct ieee80211_hdr_3addrqos {
__le16 qos_ctl;
} __attribute__ ((packed));

-struct ieee80211_hdr_4addrqos {
- __le16 frame_ctl;
- __le16 duration_id;
- u8 addr1[ETH_ALEN];
- u8 addr2[ETH_ALEN];
- u8 addr3[ETH_ALEN];
- __le16 seq_ctl;
- u8 addr4[ETH_ALEN];
- u8 payload[0];
- __le16 qos_ctl;
-} __attribute__ ((packed));
-
struct ieee80211_info_element {
u8 id;
u8 len;
@@ -1187,7 +1079,7 @@ static inline int ieee80211_get_hdrlen(u16 fc)

static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
{
- switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
+ switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control))) {
case IEEE80211_1ADDR_LEN:
return ((struct ieee80211_hdr_1addr *)hdr)->payload;
case IEEE80211_2ADDR_LEN:
diff --git a/include/net/lib80211.h b/include/net/lib80211.h
index d5f4e60..e1558a1 100644
--- a/include/net/lib80211.h
+++ b/include/net/lib80211.h
@@ -8,9 +8,11 @@
#ifndef LIB80211_H
#define LIB80211_H

+#include <linux/ieee80211.h>
+
/* print_ssid() is intended to be used in debug (and possibly error)
* messages. It should never be used for passing ssid to user space. */
const char *print_ssid(char *buf, const char *ssid, u8 ssid_len);
-#define DECLARE_SSID_BUF(var) char var[32 * 4 + 1]
+#define DECLARE_SSID_BUF(var) char var[IEEE80211_MAX_SSID_LEN * 4 + 1] __maybe_unused

#endif /* LIB80211_H */
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index cf72ae4..b0bc39d 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -40,7 +40,7 @@ static void ieee80211_monitor_rx(struct ieee80211_device *ieee,
struct ieee80211_rx_stats *rx_stats)
{
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
- u16 fc = le16_to_cpu(hdr->frame_ctl);
+ u16 fc = le16_to_cpu(hdr->frame_control);

skb->dev = ieee->dev;
skb_reset_mac_header(skb);
--
1.5.4.3


2008-10-01 02:25:53

by John W. Linville

[permalink] [raw]
Subject: [PATCH 0/5] wireless: single escape_essid implementation and related cleanups

This is a repost of my escape_essid consolidation. Also included are
some suggested changes from the original post and a few cleanups. There
is still plenty to be done -- of course, this isn't really high priority
work either...

[PATCH 1/5] wireless: consolidate on a single escape_essid implementation
[PATCH 2/5] wireless: remove NETWORK_EMPTY_ESSID flag
[PATCH 3/5] wireless: escape_ssid should handle non-printables
[PATCH 4/5] wireless: use individual buffers for printing ssid values
[PATCH 5/5] wireless: avoid some net/ieee80211.h vs. linux/ieee80211.h conflicts

Comments welcome!

John
--
John W. Linville Linux should be at the core
[email protected] of your literate lifestyle.

2008-10-01 02:23:53

by John W. Linville

[permalink] [raw]
Subject: [PATCH 3/5] wireless: escape_ssid should handle non-printables

Also use common backslash sequences like \t, \n, \r, and \\ as well as \0.

Signed-off-by: John W. Linville <[email protected]>
---
net/wireless/lib80211.c | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c
index 872cc8d..b8e34d3 100644
--- a/net/wireless/lib80211.c
+++ b/net/wireless/lib80211.c
@@ -6,6 +6,7 @@
*/

#include <linux/module.h>
+#include <linux/ctype.h>
#include <linux/ieee80211.h>

#include <net/lib80211.h>
@@ -20,19 +21,31 @@ MODULE_LICENSE("GPL");

const char *escape_ssid(const char *ssid, u8 ssid_len)
{
- static char escaped[IEEE80211_MAX_SSID_LEN * 2 + 1];
+ static char escaped[IEEE80211_MAX_SSID_LEN * 4 + 1];
const char *s = ssid;
char *d = escaped;

ssid_len = min_t(u8, ssid_len, IEEE80211_MAX_SSID_LEN);
while (ssid_len--) {
- if (*s == '\0') {
- *d++ = '\\';
- *d++ = '0';
- s++;
- } else {
+ if (isprint(*s)) {
*d++ = *s++;
+ continue;
}
+
+ *d++ = '\\';
+ if (*s == '\0')
+ *d++ = '0';
+ else if (*s == '\n')
+ *d++ = 'n';
+ else if (*s == '\r')
+ *d++ = 'r';
+ else if (*s == '\t')
+ *d++ = 't';
+ else if (*s == '\\')
+ *d++ = '\\';
+ else
+ d += snprintf(d, 3, "%03o", *s);
+ s++;
}
*d = '\0';
return escaped;
--
1.5.4.3


2008-10-02 19:11:21

by Dan Williams

[permalink] [raw]
Subject: Re: [PATCH 0/5] wireless: single escape_essid implementation and related cleanups

On Tue, 2008-09-30 at 22:15 -0400, John W. Linville wrote:
> This is a repost of my escape_essid consolidation. Also included are
> some suggested changes from the original post and a few cleanups. There
> is still plenty to be done -- of course, this isn't really high priority
> work either...
>
> [PATCH 1/5] wireless: consolidate on a single escape_essid implementation
> [PATCH 2/5] wireless: remove NETWORK_EMPTY_ESSID flag
> [PATCH 3/5] wireless: escape_ssid should handle non-printables
> [PATCH 4/5] wireless: use individual buffers for printing ssid values
> [PATCH 5/5] wireless: avoid some net/ieee80211.h vs. linux/ieee80211.h conflicts
>
> Comments welcome!

I like it! Though for ipw2200, the bits of code that check
NETWORK_EMPTY_SSID before associating might still be valid? You can't
really associate with a network (or start an adhoc network) unless you
know the SSID, right?

Dan