2008-09-25 06:13:14 +08:00
|
|
|
/*
|
|
|
|
* lib80211 -- common bits for IEEE802.11 drivers
|
|
|
|
*
|
|
|
|
* Copyright(c) 2008 John W. Linville <linville@tuxdriver.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
2008-10-01 05:50:31 +08:00
|
|
|
#include <linux/ctype.h>
|
2008-09-25 06:13:14 +08:00
|
|
|
#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 <linville@tuxdriver.com>");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
const char *escape_ssid(const char *ssid, u8 ssid_len)
|
|
|
|
{
|
2008-10-01 05:50:31 +08:00
|
|
|
static char escaped[IEEE80211_MAX_SSID_LEN * 4 + 1];
|
2008-09-25 06:13:14 +08:00
|
|
|
const char *s = ssid;
|
|
|
|
char *d = escaped;
|
|
|
|
|
|
|
|
ssid_len = min_t(u8, ssid_len, IEEE80211_MAX_SSID_LEN);
|
|
|
|
while (ssid_len--) {
|
2008-10-01 05:50:31 +08:00
|
|
|
if (isprint(*s)) {
|
2008-09-25 06:13:14 +08:00
|
|
|
*d++ = *s++;
|
2008-10-01 05:50:31 +08:00
|
|
|
continue;
|
2008-09-25 06:13:14 +08:00
|
|
|
}
|
2008-10-01 05:50:31 +08:00
|
|
|
|
|
|
|
*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++;
|
2008-09-25 06:13:14 +08:00
|
|
|
}
|
|
|
|
*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);
|