Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2003-2005 Devicescape Software, Inc. |
| 3 | * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz> |
| 4 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kobject.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 13 | #include "ieee80211_i.h" |
Johannes Berg | 2c8dccc | 2008-04-08 15:14:40 -0400 | [diff] [blame] | 14 | #include "key.h" |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 15 | #include "debugfs.h" |
| 16 | #include "debugfs_key.h" |
| 17 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 18 | #define KEY_READ(name, prop, buflen, format_string) \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 19 | static ssize_t key_##name##_read(struct file *file, \ |
| 20 | char __user *userbuf, \ |
| 21 | size_t count, loff_t *ppos) \ |
| 22 | { \ |
| 23 | char buf[buflen]; \ |
| 24 | struct ieee80211_key *key = file->private_data; \ |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 25 | int res = scnprintf(buf, buflen, format_string, key->prop); \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 26 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ |
| 27 | } |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 28 | #define KEY_READ_D(name) KEY_READ(name, name, 20, "%d\n") |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 29 | #define KEY_READ_X(name) KEY_READ(name, name, 20, "0x%x\n") |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 30 | |
| 31 | #define KEY_OPS(name) \ |
| 32 | static const struct file_operations key_ ##name## _ops = { \ |
| 33 | .read = key_##name##_read, \ |
| 34 | .open = mac80211_open_file_generic, \ |
| 35 | } |
| 36 | |
| 37 | #define KEY_FILE(name, format) \ |
| 38 | KEY_READ_##format(name) \ |
| 39 | KEY_OPS(name) |
| 40 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 41 | #define KEY_CONF_READ(name, buflen, format_string) \ |
| 42 | KEY_READ(conf_##name, conf.name, buflen, format_string) |
| 43 | #define KEY_CONF_READ_D(name) KEY_CONF_READ(name, 20, "%d\n") |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 44 | |
| 45 | #define KEY_CONF_OPS(name) \ |
| 46 | static const struct file_operations key_ ##name## _ops = { \ |
| 47 | .read = key_conf_##name##_read, \ |
| 48 | .open = mac80211_open_file_generic, \ |
| 49 | } |
| 50 | |
| 51 | #define KEY_CONF_FILE(name, format) \ |
| 52 | KEY_CONF_READ_##format(name) \ |
| 53 | KEY_CONF_OPS(name) |
| 54 | |
| 55 | KEY_CONF_FILE(keylen, D); |
| 56 | KEY_CONF_FILE(keyidx, D); |
| 57 | KEY_CONF_FILE(hw_key_idx, D); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 58 | KEY_FILE(flags, X); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 59 | KEY_FILE(tx_rx_count, D); |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 60 | KEY_READ(ifindex, sdata->name, IFNAMSIZ + 2, "%s\n"); |
Johannes Berg | e7a64f1 | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 61 | KEY_OPS(ifindex); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 62 | |
| 63 | static ssize_t key_algorithm_read(struct file *file, |
| 64 | char __user *userbuf, |
| 65 | size_t count, loff_t *ppos) |
| 66 | { |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 67 | char buf[15]; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 68 | struct ieee80211_key *key = file->private_data; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 69 | u32 c = key->conf.cipher; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 70 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 71 | sprintf(buf, "%.2x-%.2x-%.2x:%d\n", |
| 72 | c >> 24, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff); |
| 73 | return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf)); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 74 | } |
| 75 | KEY_OPS(algorithm); |
| 76 | |
| 77 | static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf, |
| 78 | size_t count, loff_t *ppos) |
| 79 | { |
| 80 | const u8 *tpn; |
| 81 | char buf[20]; |
| 82 | int len; |
| 83 | struct ieee80211_key *key = file->private_data; |
| 84 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 85 | switch (key->conf.cipher) { |
| 86 | case WLAN_CIPHER_SUITE_WEP40: |
| 87 | case WLAN_CIPHER_SUITE_WEP104: |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 88 | len = scnprintf(buf, sizeof(buf), "\n"); |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 89 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 90 | case WLAN_CIPHER_SUITE_TKIP: |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 91 | len = scnprintf(buf, sizeof(buf), "%08x %04x\n", |
Harvey Harrison | b0f76b3 | 2008-05-14 16:26:19 -0700 | [diff] [blame] | 92 | key->u.tkip.tx.iv32, |
| 93 | key->u.tkip.tx.iv16); |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 94 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 95 | case WLAN_CIPHER_SUITE_CCMP: |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 96 | tpn = key->u.ccmp.tx_pn; |
| 97 | len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n", |
| 98 | tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], tpn[5]); |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 99 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 100 | case WLAN_CIPHER_SUITE_AES_CMAC: |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 101 | tpn = key->u.aes_cmac.tx_pn; |
| 102 | len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n", |
| 103 | tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], |
| 104 | tpn[5]); |
| 105 | break; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 106 | default: |
| 107 | return 0; |
| 108 | } |
| 109 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); |
| 110 | } |
| 111 | KEY_OPS(tx_spec); |
| 112 | |
| 113 | static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf, |
| 114 | size_t count, loff_t *ppos) |
| 115 | { |
| 116 | struct ieee80211_key *key = file->private_data; |
| 117 | char buf[14*NUM_RX_DATA_QUEUES+1], *p = buf; |
| 118 | int i, len; |
| 119 | const u8 *rpn; |
| 120 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 121 | switch (key->conf.cipher) { |
| 122 | case WLAN_CIPHER_SUITE_WEP40: |
| 123 | case WLAN_CIPHER_SUITE_WEP104: |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 124 | len = scnprintf(buf, sizeof(buf), "\n"); |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 125 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 126 | case WLAN_CIPHER_SUITE_TKIP: |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 127 | for (i = 0; i < NUM_RX_DATA_QUEUES; i++) |
| 128 | p += scnprintf(p, sizeof(buf)+buf-p, |
| 129 | "%08x %04x\n", |
Harvey Harrison | b0f76b3 | 2008-05-14 16:26:19 -0700 | [diff] [blame] | 130 | key->u.tkip.rx[i].iv32, |
| 131 | key->u.tkip.rx[i].iv16); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 132 | len = p - buf; |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 133 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 134 | case WLAN_CIPHER_SUITE_CCMP: |
Jouni Malinen | 9190252 | 2010-06-11 10:27:33 -0700 | [diff] [blame] | 135 | for (i = 0; i < NUM_RX_DATA_QUEUES + 1; i++) { |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 136 | rpn = key->u.ccmp.rx_pn[i]; |
| 137 | p += scnprintf(p, sizeof(buf)+buf-p, |
| 138 | "%02x%02x%02x%02x%02x%02x\n", |
| 139 | rpn[0], rpn[1], rpn[2], |
| 140 | rpn[3], rpn[4], rpn[5]); |
| 141 | } |
| 142 | len = p - buf; |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 143 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 144 | case WLAN_CIPHER_SUITE_AES_CMAC: |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 145 | rpn = key->u.aes_cmac.rx_pn; |
| 146 | p += scnprintf(p, sizeof(buf)+buf-p, |
| 147 | "%02x%02x%02x%02x%02x%02x\n", |
| 148 | rpn[0], rpn[1], rpn[2], |
| 149 | rpn[3], rpn[4], rpn[5]); |
| 150 | len = p - buf; |
| 151 | break; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 152 | default: |
| 153 | return 0; |
| 154 | } |
| 155 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); |
| 156 | } |
| 157 | KEY_OPS(rx_spec); |
| 158 | |
| 159 | static ssize_t key_replays_read(struct file *file, char __user *userbuf, |
| 160 | size_t count, loff_t *ppos) |
| 161 | { |
| 162 | struct ieee80211_key *key = file->private_data; |
| 163 | char buf[20]; |
| 164 | int len; |
| 165 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 166 | switch (key->conf.cipher) { |
| 167 | case WLAN_CIPHER_SUITE_CCMP: |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 168 | len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays); |
| 169 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 170 | case WLAN_CIPHER_SUITE_AES_CMAC: |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 171 | len = scnprintf(buf, sizeof(buf), "%u\n", |
| 172 | key->u.aes_cmac.replays); |
| 173 | break; |
| 174 | default: |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 175 | return 0; |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 176 | } |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 177 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); |
| 178 | } |
| 179 | KEY_OPS(replays); |
| 180 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 181 | static ssize_t key_icverrors_read(struct file *file, char __user *userbuf, |
| 182 | size_t count, loff_t *ppos) |
| 183 | { |
| 184 | struct ieee80211_key *key = file->private_data; |
| 185 | char buf[20]; |
| 186 | int len; |
| 187 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 188 | switch (key->conf.cipher) { |
| 189 | case WLAN_CIPHER_SUITE_AES_CMAC: |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 190 | len = scnprintf(buf, sizeof(buf), "%u\n", |
| 191 | key->u.aes_cmac.icverrors); |
| 192 | break; |
| 193 | default: |
| 194 | return 0; |
| 195 | } |
| 196 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); |
| 197 | } |
| 198 | KEY_OPS(icverrors); |
| 199 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 200 | static ssize_t key_key_read(struct file *file, char __user *userbuf, |
| 201 | size_t count, loff_t *ppos) |
| 202 | { |
| 203 | struct ieee80211_key *key = file->private_data; |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 204 | int i, res, bufsize = 2 * key->conf.keylen + 2; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 205 | char *buf = kmalloc(bufsize, GFP_KERNEL); |
| 206 | char *p = buf; |
| 207 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 208 | for (i = 0; i < key->conf.keylen; i++) |
| 209 | p += scnprintf(p, bufsize + buf - p, "%02x", key->conf.key[i]); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 210 | p += scnprintf(p, bufsize+buf-p, "\n"); |
| 211 | res = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); |
| 212 | kfree(buf); |
| 213 | return res; |
| 214 | } |
| 215 | KEY_OPS(key); |
| 216 | |
| 217 | #define DEBUGFS_ADD(name) \ |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 218 | debugfs_create_file(#name, 0400, key->debugfs.dir, \ |
| 219 | key, &key_##name##_ops); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 220 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 221 | void ieee80211_debugfs_key_add(struct ieee80211_key *key) |
| 222 | { |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 223 | static int keycount; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 224 | char buf[50]; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 225 | struct sta_info *sta; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 226 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 227 | if (!key->local->debugfs.keys) |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 228 | return; |
| 229 | |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 230 | sprintf(buf, "%d", keycount); |
Johannes Berg | d9c58f3 | 2008-04-08 16:46:36 -0400 | [diff] [blame] | 231 | key->debugfs.cnt = keycount; |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 232 | keycount++; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 233 | key->debugfs.dir = debugfs_create_dir(buf, |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 234 | key->local->debugfs.keys); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 235 | |
| 236 | if (!key->debugfs.dir) |
| 237 | return; |
| 238 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 239 | rcu_read_lock(); |
| 240 | sta = rcu_dereference(key->sta); |
| 241 | if (sta) |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 242 | sprintf(buf, "../../stations/%pM", sta->sta.addr); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 243 | rcu_read_unlock(); |
| 244 | |
| 245 | /* using sta as a boolean is fine outside RCU lock */ |
| 246 | if (sta) |
| 247 | key->debugfs.stalink = |
| 248 | debugfs_create_symlink("station", key->debugfs.dir, buf); |
| 249 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 250 | DEBUGFS_ADD(keylen); |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 251 | DEBUGFS_ADD(flags); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 252 | DEBUGFS_ADD(keyidx); |
| 253 | DEBUGFS_ADD(hw_key_idx); |
| 254 | DEBUGFS_ADD(tx_rx_count); |
| 255 | DEBUGFS_ADD(algorithm); |
| 256 | DEBUGFS_ADD(tx_spec); |
| 257 | DEBUGFS_ADD(rx_spec); |
| 258 | DEBUGFS_ADD(replays); |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 259 | DEBUGFS_ADD(icverrors); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 260 | DEBUGFS_ADD(key); |
Johannes Berg | e7a64f1 | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 261 | DEBUGFS_ADD(ifindex); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 262 | }; |
| 263 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 264 | void ieee80211_debugfs_key_remove(struct ieee80211_key *key) |
| 265 | { |
| 266 | if (!key) |
| 267 | return; |
| 268 | |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 269 | debugfs_remove_recursive(key->debugfs.dir); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 270 | key->debugfs.dir = NULL; |
| 271 | } |
| 272 | void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata) |
| 273 | { |
| 274 | char buf[50]; |
Johannes Berg | 78520ca | 2008-05-03 01:04:47 +0200 | [diff] [blame] | 275 | struct ieee80211_key *key; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 276 | |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 277 | if (!sdata->debugfs.dir) |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 278 | return; |
| 279 | |
Johannes Berg | 78520ca | 2008-05-03 01:04:47 +0200 | [diff] [blame] | 280 | /* this is running under the key lock */ |
| 281 | |
| 282 | key = sdata->default_key; |
| 283 | if (key) { |
| 284 | sprintf(buf, "../keys/%d", key->debugfs.cnt); |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 285 | sdata->debugfs.default_key = |
Johannes Berg | 78520ca | 2008-05-03 01:04:47 +0200 | [diff] [blame] | 286 | debugfs_create_symlink("default_key", |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 287 | sdata->debugfs.dir, buf); |
Johannes Berg | 78520ca | 2008-05-03 01:04:47 +0200 | [diff] [blame] | 288 | } else |
| 289 | ieee80211_debugfs_key_remove_default(sdata); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 290 | } |
Johannes Berg | 78520ca | 2008-05-03 01:04:47 +0200 | [diff] [blame] | 291 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 292 | void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata) |
| 293 | { |
| 294 | if (!sdata) |
| 295 | return; |
| 296 | |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 297 | debugfs_remove(sdata->debugfs.default_key); |
| 298 | sdata->debugfs.default_key = NULL; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 299 | } |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 300 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 301 | void ieee80211_debugfs_key_add_mgmt_default(struct ieee80211_sub_if_data *sdata) |
| 302 | { |
| 303 | char buf[50]; |
| 304 | struct ieee80211_key *key; |
| 305 | |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 306 | if (!sdata->debugfs.dir) |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 307 | return; |
| 308 | |
| 309 | /* this is running under the key lock */ |
| 310 | |
| 311 | key = sdata->default_mgmt_key; |
| 312 | if (key) { |
| 313 | sprintf(buf, "../keys/%d", key->debugfs.cnt); |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 314 | sdata->debugfs.default_mgmt_key = |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 315 | debugfs_create_symlink("default_mgmt_key", |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 316 | sdata->debugfs.dir, buf); |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 317 | } else |
| 318 | ieee80211_debugfs_key_remove_mgmt_default(sdata); |
| 319 | } |
| 320 | |
| 321 | void ieee80211_debugfs_key_remove_mgmt_default(struct ieee80211_sub_if_data *sdata) |
| 322 | { |
| 323 | if (!sdata) |
| 324 | return; |
| 325 | |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 326 | debugfs_remove(sdata->debugfs.default_mgmt_key); |
| 327 | sdata->debugfs.default_mgmt_key = NULL; |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 328 | } |
| 329 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 330 | void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key, |
| 331 | struct sta_info *sta) |
| 332 | { |
| 333 | debugfs_remove(key->debugfs.stalink); |
| 334 | key->debugfs.stalink = NULL; |
| 335 | } |