]>
Commit | Line | Data |
---|---|---|
7e272fcf JL |
1 | /* |
2 | * lib80211 -- common bits for IEEE802.11 drivers | |
3 | * | |
4 | * Copyright(c) 2008 John W. Linville <linville@tuxdriver.com> | |
5 | * | |
6 | */ | |
7 | ||
8 | #include <linux/module.h> | |
2819f8ad | 9 | #include <linux/ctype.h> |
7e272fcf JL |
10 | #include <linux/ieee80211.h> |
11 | ||
12 | #include <net/lib80211.h> | |
13 | ||
14 | #define DRV_NAME "lib80211" | |
15 | ||
16 | #define DRV_DESCRIPTION "common routines for IEEE802.11 drivers" | |
17 | ||
18 | MODULE_DESCRIPTION(DRV_DESCRIPTION); | |
19 | MODULE_AUTHOR("John W. Linville <linville@tuxdriver.com>"); | |
20 | MODULE_LICENSE("GPL"); | |
21 | ||
22 | const char *escape_ssid(const char *ssid, u8 ssid_len) | |
23 | { | |
2819f8ad | 24 | static char escaped[IEEE80211_MAX_SSID_LEN * 4 + 1]; |
7e272fcf JL |
25 | const char *s = ssid; |
26 | char *d = escaped; | |
27 | ||
7e272fcf JL |
28 | ssid_len = min_t(u8, ssid_len, IEEE80211_MAX_SSID_LEN); |
29 | while (ssid_len--) { | |
2819f8ad | 30 | if (isprint(*s)) { |
7e272fcf | 31 | *d++ = *s++; |
2819f8ad | 32 | continue; |
7e272fcf | 33 | } |
2819f8ad JL |
34 | |
35 | *d++ = '\\'; | |
36 | if (*s == '\0') | |
37 | *d++ = '0'; | |
38 | else if (*s == '\n') | |
39 | *d++ = 'n'; | |
40 | else if (*s == '\r') | |
41 | *d++ = 'r'; | |
42 | else if (*s == '\t') | |
43 | *d++ = 't'; | |
44 | else if (*s == '\\') | |
45 | *d++ = '\\'; | |
46 | else | |
47 | d += snprintf(d, 3, "%03o", *s); | |
48 | s++; | |
7e272fcf JL |
49 | } |
50 | *d = '\0'; | |
51 | return escaped; | |
52 | } | |
53 | EXPORT_SYMBOL(escape_ssid); | |
54 | ||
55 | static int __init ieee80211_init(void) | |
56 | { | |
57 | printk(KERN_INFO DRV_NAME ": " DRV_DESCRIPTION "\n"); | |
58 | return 0; | |
59 | } | |
60 | ||
61 | static void __exit ieee80211_exit(void) | |
62 | { | |
63 | } | |
64 | ||
65 | module_init(ieee80211_init); | |
66 | module_exit(ieee80211_exit); |