Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
[powerpc.git] / net / ieee80211 / ieee80211_module.c
index e4ca0da..553acb2 100644 (file)
@@ -40,7 +40,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
-#include <linux/pci.h>
 #include <linux/proc_fs.h>
 #include <linux/skbuff.h>
 #include <linux/slab.h>
@@ -194,17 +193,23 @@ static int show_debug_level(char *page, char **start, off_t offset,
        return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
 }
 
-static int store_debug_level(struct file *file, const char *buffer,
+static int store_debug_level(struct file *file, const char __user *buffer,
                             unsigned long count, void *data)
 {
        char buf[] = "0x00000000";
-       unsigned long len = min(sizeof(buf) - 1, (u32)count);
        char *p = (char *)buf;
        unsigned long val;
 
-       if (copy_from_user(buf, buffer, len))
+       if (count > sizeof(buf) - 1)
+               count = sizeof(buf) - 1;
+
+       if (copy_from_user(buf, buffer, count))
                return count;
-       buf[len] = 0;
+       buf[count] = 0;
+       /*
+        * what a FPOS...  What, sscanf(buf, "%i", &val) would be too
+        * scary?
+        */
        if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
                p++;
                if (p[0] == 'x' || p[0] == 'X')
@@ -218,7 +223,7 @@ static int store_debug_level(struct file *file, const char *buffer,
        else
                ieee80211_debug_level = val;
 
-       return strnlen(buf, count);
+       return strlen(buf);
 }
 
 static int __init ieee80211_init(void)
@@ -264,5 +269,31 @@ module_exit(ieee80211_exit);
 module_init(ieee80211_init);
 #endif
 
+
+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);