blob: e71f7d0856219fccc32234cdc80fde42748388a0 [file] [log] [blame]
John W. Linville7e272fc2008-09-24 18:13:14 -04001/*
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>
John W. Linville2819f8a2008-09-30 17:50:31 -04009#include <linux/ctype.h>
John W. Linville7e272fc2008-09-24 18:13:14 -040010#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
18MODULE_DESCRIPTION(DRV_DESCRIPTION);
19MODULE_AUTHOR("John W. Linville <linville@tuxdriver.com>");
20MODULE_LICENSE("GPL");
21
John W. Linville9387b7c2008-09-30 20:59:05 -040022const char *print_ssid(char *buf, const char *ssid, u8 ssid_len)
John W. Linville7e272fc2008-09-24 18:13:14 -040023{
John W. Linville7e272fc2008-09-24 18:13:14 -040024 const char *s = ssid;
John W. Linville9387b7c2008-09-30 20:59:05 -040025 char *d = buf;
John W. Linville7e272fc2008-09-24 18:13:14 -040026
John W. Linville7e272fc2008-09-24 18:13:14 -040027 ssid_len = min_t(u8, ssid_len, IEEE80211_MAX_SSID_LEN);
28 while (ssid_len--) {
John W. Linville2819f8a2008-09-30 17:50:31 -040029 if (isprint(*s)) {
John W. Linville7e272fc2008-09-24 18:13:14 -040030 *d++ = *s++;
John W. Linville2819f8a2008-09-30 17:50:31 -040031 continue;
John W. Linville7e272fc2008-09-24 18:13:14 -040032 }
John W. Linville2819f8a2008-09-30 17:50:31 -040033
34 *d++ = '\\';
35 if (*s == '\0')
36 *d++ = '0';
37 else if (*s == '\n')
38 *d++ = 'n';
39 else if (*s == '\r')
40 *d++ = 'r';
41 else if (*s == '\t')
42 *d++ = 't';
43 else if (*s == '\\')
44 *d++ = '\\';
45 else
46 d += snprintf(d, 3, "%03o", *s);
47 s++;
John W. Linville7e272fc2008-09-24 18:13:14 -040048 }
49 *d = '\0';
John W. Linville9387b7c2008-09-30 20:59:05 -040050 return buf;
John W. Linville7e272fc2008-09-24 18:13:14 -040051}
John W. Linville9387b7c2008-09-30 20:59:05 -040052EXPORT_SYMBOL(print_ssid);
John W. Linville7e272fc2008-09-24 18:13:14 -040053
54static int __init ieee80211_init(void)
55{
56 printk(KERN_INFO DRV_NAME ": " DRV_DESCRIPTION "\n");
57 return 0;
58}
59
60static void __exit ieee80211_exit(void)
61{
62}
63
64module_init(ieee80211_init);
65module_exit(ieee80211_exit);