12 #include <linux/slab.h>
18 #define KEY_READ(name, prop, format_string) \
19 static ssize_t key_##name##_read(struct file *file, \
20 char __user *userbuf, \
21 size_t count, loff_t *ppos) \
23 struct ieee80211_key *key = file->private_data; \
24 return mac80211_format_buffer(userbuf, count, ppos, \
25 format_string, key->prop); \
27 #define KEY_READ_D(name) KEY_READ(name, name, "%d\n")
28 #define KEY_READ_X(name) KEY_READ(name, name, "0x%x\n")
30 #define KEY_OPS(name) \
31 static const struct file_operations key_ ##name## _ops = { \
32 .read = key_##name##_read, \
33 .open = simple_open, \
34 .llseek = generic_file_llseek, \
37 #define KEY_FILE(name, format) \
38 KEY_READ_##format(name) \
41 #define KEY_CONF_READ(name, format_string) \
42 KEY_READ(conf_##name, conf.name, format_string)
43 #define KEY_CONF_READ_D(name) KEY_CONF_READ(name, "%d\n")
45 #define KEY_CONF_OPS(name) \
46 static const struct file_operations key_ ##name## _ops = { \
47 .read = key_conf_##name##_read, \
48 .open = simple_open, \
49 .llseek = generic_file_llseek, \
52 #define KEY_CONF_FILE(name, format) \
53 KEY_CONF_READ_##format(name) \
66 size_t count, loff_t *ppos)
72 sprintf(buf,
"%.2x-%.2x-%.2x:%d\n",
73 c >> 24, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff);
78 static ssize_t key_tx_spec_read(
struct file *file,
char __user *userbuf,
79 size_t count, loff_t *ppos)
86 switch (key->
conf.cipher) {
92 len =
scnprintf(buf,
sizeof(buf),
"%08x %04x\n",
98 len =
scnprintf(buf,
sizeof(buf),
"%02x%02x%02x%02x%02x%02x\n",
99 (
u8)(pn >> 40), (
u8)(pn >> 32), (
u8)(pn >> 24),
100 (
u8)(pn >> 16), (
u8)(pn >> 8), (
u8)pn);
104 len =
scnprintf(buf,
sizeof(buf),
"%02x%02x%02x%02x%02x%02x\n",
105 (
u8)(pn >> 40), (
u8)(pn >> 32), (
u8)(pn >> 24),
106 (
u8)(pn >> 16), (
u8)(pn >> 8), (
u8)pn);
115 static ssize_t key_rx_spec_read(
struct file *file,
char __user *userbuf,
116 size_t count, loff_t *ppos)
123 switch (key->
conf.cipher) {
132 key->
u.
tkip.rx[i].iv32,
133 key->
u.
tkip.rx[i].iv16);
137 for (i = 0; i < NUM_RX_DATA_QUEUES + 1; i++) {
138 rpn = key->
u.
ccmp.rx_pn[
i];
140 "%02x%02x%02x%02x%02x%02x\n",
141 rpn[0], rpn[1], rpn[2],
142 rpn[3], rpn[4], rpn[5]);
149 "%02x%02x%02x%02x%02x%02x\n",
150 rpn[0], rpn[1], rpn[2],
151 rpn[3], rpn[4], rpn[5]);
161 static ssize_t key_replays_read(
struct file *file,
char __user *userbuf,
162 size_t count, loff_t *ppos)
168 switch (key->
conf.cipher) {
173 len =
scnprintf(buf,
sizeof(buf),
"%u\n",
183 static ssize_t key_icverrors_read(
struct file *file,
char __user *userbuf,
184 size_t count, loff_t *ppos)
190 switch (key->
conf.cipher) {
192 len =
scnprintf(buf,
sizeof(buf),
"%u\n",
202 static ssize_t key_key_read(
struct file *file,
char __user *userbuf,
203 size_t count, loff_t *ppos)
214 for (i = 0; i < key->
conf.keylen; i++)
215 p +=
scnprintf(p, bufsize + buf - p,
"%02x", key->
conf.key[i]);
223 #define DEBUGFS_ADD(name) \
224 debugfs_create_file(#name, 0400, key->debugfs.dir, \
225 key, &key_##name##_ops);
233 if (!key->
local->debugfs.keys)
237 key->debugfs.cnt = keycount;
240 key->
local->debugfs.keys);
242 if (!key->debugfs.dir)
247 sprintf(buf,
"../../netdev:%s/stations/%pM",
249 key->debugfs.stalink =
273 key->debugfs.dir =
NULL;
281 if (!sdata->debugfs.dir)
294 sprintf(buf,
"../keys/%d", key->debugfs.cnt);
297 sdata->debugfs.dir, buf);
308 sprintf(buf,
"../keys/%d", key->debugfs.cnt);
311 sdata->debugfs.dir, buf);
320 if (!sdata->debugfs.dir)
326 sprintf(buf,
"../keys/%d", key->debugfs.cnt);
329 sdata->debugfs.dir, buf);
347 key->debugfs.stalink =
NULL;