Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2002-2005, Instant802 Networks, Inc. |
| 3 | * Copyright 2005-2006, Devicescape Software, Inc. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/netdevice.h> |
| 13 | #include <linux/types.h> |
| 14 | #include <linux/slab.h> |
| 15 | #include <linux/skbuff.h> |
| 16 | #include <linux/etherdevice.h> |
| 17 | #include <linux/if_arp.h> |
| 18 | #include <linux/wireless.h> |
| 19 | #include <net/iw_handler.h> |
| 20 | #include <asm/uaccess.h> |
| 21 | |
| 22 | #include <net/mac80211.h> |
| 23 | #include "ieee80211_i.h" |
| 24 | #include "hostapd_ioctl.h" |
| 25 | #include "ieee80211_rate.h" |
| 26 | #include "wpa.h" |
| 27 | #include "aes_ccm.h" |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 28 | |
Johannes Berg | b708e61 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 29 | |
| 30 | /* |
| 31 | * Wow. This ioctl interface is such crap, it's tied |
| 32 | * to internal definitions. I hope it dies soon. |
| 33 | */ |
| 34 | static int mode_to_hostapd_mode(enum ieee80211_phymode mode) |
| 35 | { |
| 36 | switch (mode) { |
| 37 | case MODE_IEEE80211A: |
| 38 | return 0; |
| 39 | case MODE_IEEE80211B: |
| 40 | return 1; |
| 41 | case MODE_IEEE80211G: |
| 42 | return 3; |
| 43 | case NUM_IEEE80211_MODES: |
| 44 | WARN_ON(1); |
| 45 | break; |
| 46 | } |
| 47 | WARN_ON(1); |
| 48 | return -1; |
| 49 | } |
| 50 | |
| 51 | static enum ieee80211_phymode hostapd_mode_to_mode(int hostapd_mode) |
| 52 | { |
| 53 | switch (hostapd_mode) { |
| 54 | case 0: |
| 55 | return MODE_IEEE80211A; |
| 56 | case 1: |
| 57 | return MODE_IEEE80211B; |
| 58 | case 3: |
| 59 | return MODE_IEEE80211G; |
| 60 | } |
| 61 | return NUM_IEEE80211_MODES; |
| 62 | } |
| 63 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 64 | static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr, |
| 65 | int idx, int alg, int set_tx_key, |
| 66 | const u8 *_key, size_t key_len) |
| 67 | { |
| 68 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 69 | int ret = 0; |
| 70 | struct sta_info *sta; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 71 | struct ieee80211_key *key; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 72 | struct ieee80211_sub_if_data *sdata; |
| 73 | |
| 74 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 75 | |
Volker Braun | 139c3a0 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 76 | if (idx < 0 || idx >= NUM_DEFAULT_KEYS) { |
| 77 | printk(KERN_DEBUG "%s: set_encrypt - invalid idx=%d\n", |
| 78 | dev->name, idx); |
| 79 | return -EINVAL; |
| 80 | } |
| 81 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 82 | if (is_broadcast_ether_addr(sta_addr)) { |
| 83 | sta = NULL; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 84 | key = sdata->keys[idx]; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 85 | } else { |
| 86 | set_tx_key = 0; |
Volker Braun | 139c3a0 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 87 | /* |
| 88 | * According to the standard, the key index of a pairwise |
| 89 | * key must be zero. However, some AP are broken when it |
| 90 | * comes to WEP key indices, so we work around this. |
| 91 | */ |
| 92 | if (idx != 0 && alg != ALG_WEP) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 93 | printk(KERN_DEBUG "%s: set_encrypt - non-zero idx for " |
| 94 | "individual key\n", dev->name); |
| 95 | return -EINVAL; |
| 96 | } |
| 97 | |
| 98 | sta = sta_info_get(local, sta_addr); |
| 99 | if (!sta) { |
| 100 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 101 | DECLARE_MAC_BUF(mac); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 102 | printk(KERN_DEBUG "%s: set_encrypt - unknown addr " |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 103 | "%s\n", |
| 104 | dev->name, print_mac(mac, sta_addr)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 105 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
| 106 | |
| 107 | return -ENOENT; |
| 108 | } |
| 109 | |
| 110 | key = sta->key; |
| 111 | } |
| 112 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 113 | if (alg == ALG_NONE) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 114 | ieee80211_key_free(key); |
| 115 | key = NULL; |
| 116 | } else { |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 117 | /* |
Johannes Berg | d4e46a3 | 2007-09-14 11:10:24 -0400 | [diff] [blame] | 118 | * Automatically frees any old key if present. |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 119 | */ |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 120 | key = ieee80211_key_alloc(sdata, sta, alg, idx, key_len, _key); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 121 | if (!key) { |
| 122 | ret = -ENOMEM; |
| 123 | goto err_out; |
| 124 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 125 | } |
| 126 | |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 127 | if (set_tx_key || (!sta && !sdata->default_key && key)) |
| 128 | ieee80211_set_default_key(sdata, idx); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 129 | |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 130 | ret = 0; |
| 131 | err_out: |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 132 | if (sta) |
| 133 | sta_info_put(sta); |
| 134 | return ret; |
| 135 | } |
| 136 | |
| 137 | static int ieee80211_ioctl_siwgenie(struct net_device *dev, |
| 138 | struct iw_request_info *info, |
| 139 | struct iw_point *data, char *extra) |
| 140 | { |
| 141 | struct ieee80211_sub_if_data *sdata; |
| 142 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 143 | |
| 144 | if (local->user_space_mlme) |
| 145 | return -EOPNOTSUPP; |
| 146 | |
| 147 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 148 | if (sdata->type == IEEE80211_IF_TYPE_STA || |
| 149 | sdata->type == IEEE80211_IF_TYPE_IBSS) { |
| 150 | int ret = ieee80211_sta_set_extra_ie(dev, extra, data->length); |
| 151 | if (ret) |
| 152 | return ret; |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 153 | sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 154 | ieee80211_sta_req_auth(dev, &sdata->u.sta); |
| 155 | return 0; |
| 156 | } |
| 157 | |
| 158 | if (sdata->type == IEEE80211_IF_TYPE_AP) { |
| 159 | kfree(sdata->u.ap.generic_elem); |
| 160 | sdata->u.ap.generic_elem = kmalloc(data->length, GFP_KERNEL); |
| 161 | if (!sdata->u.ap.generic_elem) |
| 162 | return -ENOMEM; |
| 163 | memcpy(sdata->u.ap.generic_elem, extra, data->length); |
| 164 | sdata->u.ap.generic_elem_len = data->length; |
| 165 | return ieee80211_if_config(dev); |
| 166 | } |
| 167 | return -EOPNOTSUPP; |
| 168 | } |
| 169 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 170 | static int ieee80211_ioctl_giwname(struct net_device *dev, |
| 171 | struct iw_request_info *info, |
| 172 | char *name, char *extra) |
| 173 | { |
| 174 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 175 | |
| 176 | switch (local->hw.conf.phymode) { |
| 177 | case MODE_IEEE80211A: |
| 178 | strcpy(name, "IEEE 802.11a"); |
| 179 | break; |
| 180 | case MODE_IEEE80211B: |
| 181 | strcpy(name, "IEEE 802.11b"); |
| 182 | break; |
| 183 | case MODE_IEEE80211G: |
| 184 | strcpy(name, "IEEE 802.11g"); |
| 185 | break; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 186 | default: |
| 187 | strcpy(name, "IEEE 802.11"); |
| 188 | break; |
| 189 | } |
| 190 | |
| 191 | return 0; |
| 192 | } |
| 193 | |
| 194 | |
| 195 | static int ieee80211_ioctl_giwrange(struct net_device *dev, |
| 196 | struct iw_request_info *info, |
| 197 | struct iw_point *data, char *extra) |
| 198 | { |
| 199 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 200 | struct iw_range *range = (struct iw_range *) extra; |
Hong Liu | 333af2f | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 201 | struct ieee80211_hw_mode *mode = NULL; |
| 202 | int c = 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 203 | |
| 204 | data->length = sizeof(struct iw_range); |
| 205 | memset(range, 0, sizeof(struct iw_range)); |
| 206 | |
| 207 | range->we_version_compiled = WIRELESS_EXT; |
| 208 | range->we_version_source = 21; |
| 209 | range->retry_capa = IW_RETRY_LIMIT; |
| 210 | range->retry_flags = IW_RETRY_LIMIT; |
| 211 | range->min_retry = 0; |
| 212 | range->max_retry = 255; |
| 213 | range->min_rts = 0; |
| 214 | range->max_rts = 2347; |
| 215 | range->min_frag = 256; |
| 216 | range->max_frag = 2346; |
| 217 | |
| 218 | range->encoding_size[0] = 5; |
| 219 | range->encoding_size[1] = 13; |
| 220 | range->num_encoding_sizes = 2; |
| 221 | range->max_encoding_tokens = NUM_DEFAULT_KEYS; |
| 222 | |
| 223 | range->max_qual.qual = local->hw.max_signal; |
| 224 | range->max_qual.level = local->hw.max_rssi; |
| 225 | range->max_qual.noise = local->hw.max_noise; |
| 226 | range->max_qual.updated = local->wstats_flags; |
| 227 | |
| 228 | range->avg_qual.qual = local->hw.max_signal/2; |
| 229 | range->avg_qual.level = 0; |
| 230 | range->avg_qual.noise = 0; |
| 231 | range->avg_qual.updated = local->wstats_flags; |
| 232 | |
| 233 | range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | |
| 234 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; |
| 235 | |
Hong Liu | 333af2f | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 236 | list_for_each_entry(mode, &local->modes_list, list) { |
| 237 | int i = 0; |
| 238 | |
| 239 | if (!(local->enabled_modes & (1 << mode->mode)) || |
| 240 | (local->hw_modes & local->enabled_modes & |
| 241 | (1 << MODE_IEEE80211G) && mode->mode == MODE_IEEE80211B)) |
| 242 | continue; |
| 243 | |
| 244 | while (i < mode->num_channels && c < IW_MAX_FREQUENCIES) { |
| 245 | struct ieee80211_channel *chan = &mode->channels[i]; |
| 246 | |
| 247 | if (chan->flag & IEEE80211_CHAN_W_SCAN) { |
| 248 | range->freq[c].i = chan->chan; |
| 249 | range->freq[c].m = chan->freq * 100000; |
| 250 | range->freq[c].e = 1; |
| 251 | c++; |
| 252 | } |
| 253 | i++; |
| 254 | } |
| 255 | } |
| 256 | range->num_channels = c; |
| 257 | range->num_frequency = c; |
| 258 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 259 | IW_EVENT_CAPA_SET_KERNEL(range->event_capa); |
| 260 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWTHRSPY); |
| 261 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP); |
| 262 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); |
| 263 | |
| 264 | return 0; |
| 265 | } |
| 266 | |
| 267 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 268 | static int ieee80211_ioctl_siwmode(struct net_device *dev, |
| 269 | struct iw_request_info *info, |
| 270 | __u32 *mode, char *extra) |
| 271 | { |
| 272 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 273 | int type; |
| 274 | |
| 275 | if (sdata->type == IEEE80211_IF_TYPE_VLAN) |
| 276 | return -EOPNOTSUPP; |
| 277 | |
| 278 | switch (*mode) { |
| 279 | case IW_MODE_INFRA: |
| 280 | type = IEEE80211_IF_TYPE_STA; |
| 281 | break; |
| 282 | case IW_MODE_ADHOC: |
| 283 | type = IEEE80211_IF_TYPE_IBSS; |
| 284 | break; |
| 285 | case IW_MODE_MONITOR: |
| 286 | type = IEEE80211_IF_TYPE_MNTR; |
| 287 | break; |
| 288 | default: |
| 289 | return -EINVAL; |
| 290 | } |
| 291 | |
| 292 | if (type == sdata->type) |
| 293 | return 0; |
| 294 | if (netif_running(dev)) |
| 295 | return -EBUSY; |
| 296 | |
| 297 | ieee80211_if_reinit(dev); |
| 298 | ieee80211_if_set_type(dev, type); |
| 299 | |
| 300 | return 0; |
| 301 | } |
| 302 | |
| 303 | |
| 304 | static int ieee80211_ioctl_giwmode(struct net_device *dev, |
| 305 | struct iw_request_info *info, |
| 306 | __u32 *mode, char *extra) |
| 307 | { |
| 308 | struct ieee80211_sub_if_data *sdata; |
| 309 | |
| 310 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 311 | switch (sdata->type) { |
| 312 | case IEEE80211_IF_TYPE_AP: |
| 313 | *mode = IW_MODE_MASTER; |
| 314 | break; |
| 315 | case IEEE80211_IF_TYPE_STA: |
| 316 | *mode = IW_MODE_INFRA; |
| 317 | break; |
| 318 | case IEEE80211_IF_TYPE_IBSS: |
| 319 | *mode = IW_MODE_ADHOC; |
| 320 | break; |
| 321 | case IEEE80211_IF_TYPE_MNTR: |
| 322 | *mode = IW_MODE_MONITOR; |
| 323 | break; |
| 324 | case IEEE80211_IF_TYPE_WDS: |
| 325 | *mode = IW_MODE_REPEAT; |
| 326 | break; |
| 327 | case IEEE80211_IF_TYPE_VLAN: |
| 328 | *mode = IW_MODE_SECOND; /* FIXME */ |
| 329 | break; |
| 330 | default: |
| 331 | *mode = IW_MODE_AUTO; |
| 332 | break; |
| 333 | } |
| 334 | return 0; |
| 335 | } |
| 336 | |
| 337 | int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq) |
| 338 | { |
| 339 | struct ieee80211_hw_mode *mode; |
| 340 | int c, set = 0; |
| 341 | int ret = -EINVAL; |
| 342 | |
| 343 | list_for_each_entry(mode, &local->modes_list, list) { |
| 344 | if (!(local->enabled_modes & (1 << mode->mode))) |
| 345 | continue; |
| 346 | for (c = 0; c < mode->num_channels; c++) { |
| 347 | struct ieee80211_channel *chan = &mode->channels[c]; |
| 348 | if (chan->flag & IEEE80211_CHAN_W_SCAN && |
| 349 | ((chan->chan == channel) || (chan->freq == freq))) { |
| 350 | /* Use next_mode as the mode preference to |
| 351 | * resolve non-unique channel numbers. */ |
| 352 | if (set && mode->mode != local->next_mode) |
| 353 | continue; |
| 354 | |
| 355 | local->oper_channel = chan; |
| 356 | local->oper_hw_mode = mode; |
| 357 | set++; |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | if (set) { |
| 363 | if (local->sta_scanning) |
| 364 | ret = 0; |
| 365 | else |
| 366 | ret = ieee80211_hw_config(local); |
| 367 | |
| 368 | rate_control_clear(local); |
| 369 | } |
| 370 | |
| 371 | return ret; |
| 372 | } |
| 373 | |
| 374 | static int ieee80211_ioctl_siwfreq(struct net_device *dev, |
| 375 | struct iw_request_info *info, |
| 376 | struct iw_freq *freq, char *extra) |
| 377 | { |
| 378 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 379 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 380 | |
| 381 | if (sdata->type == IEEE80211_IF_TYPE_STA) |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 382 | sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_CHANNEL_SEL; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 383 | |
| 384 | /* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */ |
| 385 | if (freq->e == 0) { |
| 386 | if (freq->m < 0) { |
| 387 | if (sdata->type == IEEE80211_IF_TYPE_STA) |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 388 | sdata->u.sta.flags |= |
| 389 | IEEE80211_STA_AUTO_CHANNEL_SEL; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 390 | return 0; |
| 391 | } else |
| 392 | return ieee80211_set_channel(local, freq->m, -1); |
| 393 | } else { |
| 394 | int i, div = 1000000; |
| 395 | for (i = 0; i < freq->e; i++) |
| 396 | div /= 10; |
| 397 | if (div > 0) |
| 398 | return ieee80211_set_channel(local, -1, freq->m / div); |
| 399 | else |
| 400 | return -EINVAL; |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | |
| 405 | static int ieee80211_ioctl_giwfreq(struct net_device *dev, |
| 406 | struct iw_request_info *info, |
| 407 | struct iw_freq *freq, char *extra) |
| 408 | { |
| 409 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 410 | |
| 411 | /* TODO: in station mode (Managed/Ad-hoc) might need to poll low-level |
| 412 | * driver for the current channel with firmware-based management */ |
| 413 | |
| 414 | freq->m = local->hw.conf.freq; |
| 415 | freq->e = 6; |
| 416 | |
| 417 | return 0; |
| 418 | } |
| 419 | |
| 420 | |
| 421 | static int ieee80211_ioctl_siwessid(struct net_device *dev, |
| 422 | struct iw_request_info *info, |
| 423 | struct iw_point *data, char *ssid) |
| 424 | { |
| 425 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 426 | struct ieee80211_sub_if_data *sdata; |
| 427 | size_t len = data->length; |
| 428 | |
| 429 | /* iwconfig uses nul termination in SSID.. */ |
| 430 | if (len > 0 && ssid[len - 1] == '\0') |
| 431 | len--; |
| 432 | |
| 433 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 434 | if (sdata->type == IEEE80211_IF_TYPE_STA || |
| 435 | sdata->type == IEEE80211_IF_TYPE_IBSS) { |
| 436 | int ret; |
| 437 | if (local->user_space_mlme) { |
| 438 | if (len > IEEE80211_MAX_SSID_LEN) |
| 439 | return -EINVAL; |
| 440 | memcpy(sdata->u.sta.ssid, ssid, len); |
| 441 | sdata->u.sta.ssid_len = len; |
| 442 | return 0; |
| 443 | } |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 444 | if (data->flags) |
| 445 | sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_SSID_SEL; |
| 446 | else |
| 447 | sdata->u.sta.flags |= IEEE80211_STA_AUTO_SSID_SEL; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 448 | ret = ieee80211_sta_set_ssid(dev, ssid, len); |
| 449 | if (ret) |
| 450 | return ret; |
| 451 | ieee80211_sta_req_auth(dev, &sdata->u.sta); |
| 452 | return 0; |
| 453 | } |
| 454 | |
| 455 | if (sdata->type == IEEE80211_IF_TYPE_AP) { |
| 456 | memcpy(sdata->u.ap.ssid, ssid, len); |
| 457 | memset(sdata->u.ap.ssid + len, 0, |
| 458 | IEEE80211_MAX_SSID_LEN - len); |
| 459 | sdata->u.ap.ssid_len = len; |
| 460 | return ieee80211_if_config(dev); |
| 461 | } |
| 462 | return -EOPNOTSUPP; |
| 463 | } |
| 464 | |
| 465 | |
| 466 | static int ieee80211_ioctl_giwessid(struct net_device *dev, |
| 467 | struct iw_request_info *info, |
| 468 | struct iw_point *data, char *ssid) |
| 469 | { |
| 470 | size_t len; |
| 471 | |
| 472 | struct ieee80211_sub_if_data *sdata; |
| 473 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 474 | if (sdata->type == IEEE80211_IF_TYPE_STA || |
| 475 | sdata->type == IEEE80211_IF_TYPE_IBSS) { |
| 476 | int res = ieee80211_sta_get_ssid(dev, ssid, &len); |
| 477 | if (res == 0) { |
| 478 | data->length = len; |
| 479 | data->flags = 1; |
| 480 | } else |
| 481 | data->flags = 0; |
| 482 | return res; |
| 483 | } |
| 484 | |
| 485 | if (sdata->type == IEEE80211_IF_TYPE_AP) { |
| 486 | len = sdata->u.ap.ssid_len; |
| 487 | if (len > IW_ESSID_MAX_SIZE) |
| 488 | len = IW_ESSID_MAX_SIZE; |
| 489 | memcpy(ssid, sdata->u.ap.ssid, len); |
| 490 | data->length = len; |
| 491 | data->flags = 1; |
| 492 | return 0; |
| 493 | } |
| 494 | return -EOPNOTSUPP; |
| 495 | } |
| 496 | |
| 497 | |
| 498 | static int ieee80211_ioctl_siwap(struct net_device *dev, |
| 499 | struct iw_request_info *info, |
| 500 | struct sockaddr *ap_addr, char *extra) |
| 501 | { |
| 502 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 503 | struct ieee80211_sub_if_data *sdata; |
| 504 | |
| 505 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 506 | if (sdata->type == IEEE80211_IF_TYPE_STA || |
| 507 | sdata->type == IEEE80211_IF_TYPE_IBSS) { |
| 508 | int ret; |
| 509 | if (local->user_space_mlme) { |
| 510 | memcpy(sdata->u.sta.bssid, (u8 *) &ap_addr->sa_data, |
| 511 | ETH_ALEN); |
| 512 | return 0; |
| 513 | } |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 514 | if (is_zero_ether_addr((u8 *) &ap_addr->sa_data)) |
| 515 | sdata->u.sta.flags |= IEEE80211_STA_AUTO_BSSID_SEL | |
| 516 | IEEE80211_STA_AUTO_CHANNEL_SEL; |
| 517 | else if (is_broadcast_ether_addr((u8 *) &ap_addr->sa_data)) |
| 518 | sdata->u.sta.flags |= IEEE80211_STA_AUTO_BSSID_SEL; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 519 | else |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 520 | sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 521 | ret = ieee80211_sta_set_bssid(dev, (u8 *) &ap_addr->sa_data); |
| 522 | if (ret) |
| 523 | return ret; |
| 524 | ieee80211_sta_req_auth(dev, &sdata->u.sta); |
| 525 | return 0; |
| 526 | } else if (sdata->type == IEEE80211_IF_TYPE_WDS) { |
| 527 | if (memcmp(sdata->u.wds.remote_addr, (u8 *) &ap_addr->sa_data, |
| 528 | ETH_ALEN) == 0) |
| 529 | return 0; |
| 530 | return ieee80211_if_update_wds(dev, (u8 *) &ap_addr->sa_data); |
| 531 | } |
| 532 | |
| 533 | return -EOPNOTSUPP; |
| 534 | } |
| 535 | |
| 536 | |
| 537 | static int ieee80211_ioctl_giwap(struct net_device *dev, |
| 538 | struct iw_request_info *info, |
| 539 | struct sockaddr *ap_addr, char *extra) |
| 540 | { |
| 541 | struct ieee80211_sub_if_data *sdata; |
| 542 | |
| 543 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 544 | if (sdata->type == IEEE80211_IF_TYPE_STA || |
| 545 | sdata->type == IEEE80211_IF_TYPE_IBSS) { |
| 546 | ap_addr->sa_family = ARPHRD_ETHER; |
| 547 | memcpy(&ap_addr->sa_data, sdata->u.sta.bssid, ETH_ALEN); |
| 548 | return 0; |
| 549 | } else if (sdata->type == IEEE80211_IF_TYPE_WDS) { |
| 550 | ap_addr->sa_family = ARPHRD_ETHER; |
| 551 | memcpy(&ap_addr->sa_data, sdata->u.wds.remote_addr, ETH_ALEN); |
| 552 | return 0; |
| 553 | } |
| 554 | |
| 555 | return -EOPNOTSUPP; |
| 556 | } |
| 557 | |
| 558 | |
| 559 | static int ieee80211_ioctl_siwscan(struct net_device *dev, |
| 560 | struct iw_request_info *info, |
| 561 | struct iw_point *data, char *extra) |
| 562 | { |
| 563 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 564 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 565 | u8 *ssid = NULL; |
| 566 | size_t ssid_len = 0; |
| 567 | |
| 568 | if (!netif_running(dev)) |
| 569 | return -ENETDOWN; |
| 570 | |
Daniel Drake | f27b62d | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 571 | switch (sdata->type) { |
| 572 | case IEEE80211_IF_TYPE_STA: |
| 573 | case IEEE80211_IF_TYPE_IBSS: |
| 574 | if (local->scan_flags & IEEE80211_SCAN_MATCH_SSID) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 575 | ssid = sdata->u.sta.ssid; |
| 576 | ssid_len = sdata->u.sta.ssid_len; |
Daniel Drake | f27b62d | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 577 | } |
| 578 | break; |
| 579 | case IEEE80211_IF_TYPE_AP: |
| 580 | if (local->scan_flags & IEEE80211_SCAN_MATCH_SSID) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 581 | ssid = sdata->u.ap.ssid; |
| 582 | ssid_len = sdata->u.ap.ssid_len; |
Daniel Drake | f27b62d | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 583 | } |
| 584 | break; |
| 585 | default: |
| 586 | return -EOPNOTSUPP; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 587 | } |
Daniel Drake | f27b62d | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 588 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 589 | return ieee80211_sta_req_scan(dev, ssid, ssid_len); |
| 590 | } |
| 591 | |
| 592 | |
| 593 | static int ieee80211_ioctl_giwscan(struct net_device *dev, |
| 594 | struct iw_request_info *info, |
| 595 | struct iw_point *data, char *extra) |
| 596 | { |
| 597 | int res; |
| 598 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 599 | if (local->sta_scanning) |
| 600 | return -EAGAIN; |
| 601 | res = ieee80211_sta_scan_results(dev, extra, data->length); |
| 602 | if (res >= 0) { |
| 603 | data->length = res; |
| 604 | return 0; |
| 605 | } |
| 606 | data->length = 0; |
| 607 | return res; |
| 608 | } |
| 609 | |
| 610 | |
Larry Finger | 1fd5e58 | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 611 | static int ieee80211_ioctl_siwrate(struct net_device *dev, |
| 612 | struct iw_request_info *info, |
| 613 | struct iw_param *rate, char *extra) |
| 614 | { |
| 615 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 616 | struct ieee80211_hw_mode *mode; |
| 617 | int i; |
| 618 | u32 target_rate = rate->value / 100000; |
| 619 | struct ieee80211_sub_if_data *sdata; |
| 620 | |
| 621 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 622 | if (!sdata->bss) |
| 623 | return -ENODEV; |
| 624 | mode = local->oper_hw_mode; |
| 625 | /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates |
| 626 | * target_rate = X, rate->fixed = 1 means only rate X |
| 627 | * target_rate = X, rate->fixed = 0 means all rates <= X */ |
| 628 | sdata->bss->max_ratectrl_rateidx = -1; |
| 629 | sdata->bss->force_unicast_rateidx = -1; |
| 630 | if (rate->value < 0) |
| 631 | return 0; |
| 632 | for (i=0; i< mode->num_rates; i++) { |
| 633 | struct ieee80211_rate *rates = &mode->rates[i]; |
| 634 | int this_rate = rates->rate; |
| 635 | |
Larry Finger | 1fd5e58 | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 636 | if (target_rate == this_rate) { |
| 637 | sdata->bss->max_ratectrl_rateidx = i; |
| 638 | if (rate->fixed) |
| 639 | sdata->bss->force_unicast_rateidx = i; |
| 640 | break; |
| 641 | } |
| 642 | } |
| 643 | return 0; |
| 644 | } |
| 645 | |
Larry Finger | b3d88ad | 2007-06-10 17:57:33 -0700 | [diff] [blame] | 646 | static int ieee80211_ioctl_giwrate(struct net_device *dev, |
| 647 | struct iw_request_info *info, |
| 648 | struct iw_param *rate, char *extra) |
| 649 | { |
| 650 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 651 | struct sta_info *sta; |
| 652 | struct ieee80211_sub_if_data *sdata; |
| 653 | |
| 654 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 655 | if (sdata->type == IEEE80211_IF_TYPE_STA) |
| 656 | sta = sta_info_get(local, sdata->u.sta.bssid); |
| 657 | else |
| 658 | return -EOPNOTSUPP; |
| 659 | if (!sta) |
| 660 | return -ENODEV; |
| 661 | if (sta->txrate < local->oper_hw_mode->num_rates) |
| 662 | rate->value = local->oper_hw_mode->rates[sta->txrate].rate * 100000; |
| 663 | else |
| 664 | rate->value = 0; |
| 665 | sta_info_put(sta); |
| 666 | return 0; |
| 667 | } |
| 668 | |
Larry Finger | fe6aa30 | 2007-08-10 11:23:20 -0500 | [diff] [blame] | 669 | static int ieee80211_ioctl_giwtxpower(struct net_device *dev, |
| 670 | struct iw_request_info *info, |
| 671 | union iwreq_data *data, char *extra) |
| 672 | { |
| 673 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 674 | |
| 675 | data->txpower.fixed = 1; |
| 676 | data->txpower.disabled = !(local->hw.conf.radio_enabled); |
| 677 | data->txpower.value = local->hw.conf.power_level; |
| 678 | data->txpower.flags = IW_TXPOW_DBM; |
| 679 | |
| 680 | return 0; |
| 681 | } |
| 682 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 683 | static int ieee80211_ioctl_siwrts(struct net_device *dev, |
| 684 | struct iw_request_info *info, |
| 685 | struct iw_param *rts, char *extra) |
| 686 | { |
| 687 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 688 | |
| 689 | if (rts->disabled) |
| 690 | local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; |
| 691 | else if (rts->value < 0 || rts->value > IEEE80211_MAX_RTS_THRESHOLD) |
| 692 | return -EINVAL; |
| 693 | else |
| 694 | local->rts_threshold = rts->value; |
| 695 | |
| 696 | /* If the wlan card performs RTS/CTS in hardware/firmware, |
| 697 | * configure it here */ |
| 698 | |
| 699 | if (local->ops->set_rts_threshold) |
| 700 | local->ops->set_rts_threshold(local_to_hw(local), |
| 701 | local->rts_threshold); |
| 702 | |
| 703 | return 0; |
| 704 | } |
| 705 | |
| 706 | static int ieee80211_ioctl_giwrts(struct net_device *dev, |
| 707 | struct iw_request_info *info, |
| 708 | struct iw_param *rts, char *extra) |
| 709 | { |
| 710 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 711 | |
| 712 | rts->value = local->rts_threshold; |
| 713 | rts->disabled = (rts->value >= IEEE80211_MAX_RTS_THRESHOLD); |
| 714 | rts->fixed = 1; |
| 715 | |
| 716 | return 0; |
| 717 | } |
| 718 | |
| 719 | |
| 720 | static int ieee80211_ioctl_siwfrag(struct net_device *dev, |
| 721 | struct iw_request_info *info, |
| 722 | struct iw_param *frag, char *extra) |
| 723 | { |
| 724 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 725 | |
| 726 | if (frag->disabled) |
| 727 | local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD; |
| 728 | else if (frag->value < 256 || |
| 729 | frag->value > IEEE80211_MAX_FRAG_THRESHOLD) |
| 730 | return -EINVAL; |
| 731 | else { |
| 732 | /* Fragment length must be even, so strip LSB. */ |
| 733 | local->fragmentation_threshold = frag->value & ~0x1; |
| 734 | } |
| 735 | |
| 736 | /* If the wlan card performs fragmentation in hardware/firmware, |
| 737 | * configure it here */ |
| 738 | |
| 739 | if (local->ops->set_frag_threshold) |
| 740 | local->ops->set_frag_threshold( |
| 741 | local_to_hw(local), |
| 742 | local->fragmentation_threshold); |
| 743 | |
| 744 | return 0; |
| 745 | } |
| 746 | |
| 747 | static int ieee80211_ioctl_giwfrag(struct net_device *dev, |
| 748 | struct iw_request_info *info, |
| 749 | struct iw_param *frag, char *extra) |
| 750 | { |
| 751 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 752 | |
| 753 | frag->value = local->fragmentation_threshold; |
| 754 | frag->disabled = (frag->value >= IEEE80211_MAX_RTS_THRESHOLD); |
| 755 | frag->fixed = 1; |
| 756 | |
| 757 | return 0; |
| 758 | } |
| 759 | |
| 760 | |
| 761 | static int ieee80211_ioctl_siwretry(struct net_device *dev, |
| 762 | struct iw_request_info *info, |
| 763 | struct iw_param *retry, char *extra) |
| 764 | { |
| 765 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 766 | |
| 767 | if (retry->disabled || |
| 768 | (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) |
| 769 | return -EINVAL; |
| 770 | |
| 771 | if (retry->flags & IW_RETRY_MAX) |
| 772 | local->long_retry_limit = retry->value; |
| 773 | else if (retry->flags & IW_RETRY_MIN) |
| 774 | local->short_retry_limit = retry->value; |
| 775 | else { |
| 776 | local->long_retry_limit = retry->value; |
| 777 | local->short_retry_limit = retry->value; |
| 778 | } |
| 779 | |
| 780 | if (local->ops->set_retry_limit) { |
| 781 | return local->ops->set_retry_limit( |
| 782 | local_to_hw(local), |
| 783 | local->short_retry_limit, |
| 784 | local->long_retry_limit); |
| 785 | } |
| 786 | |
| 787 | return 0; |
| 788 | } |
| 789 | |
| 790 | |
| 791 | static int ieee80211_ioctl_giwretry(struct net_device *dev, |
| 792 | struct iw_request_info *info, |
| 793 | struct iw_param *retry, char *extra) |
| 794 | { |
| 795 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 796 | |
| 797 | retry->disabled = 0; |
| 798 | if (retry->flags == 0 || retry->flags & IW_RETRY_MIN) { |
| 799 | /* first return min value, iwconfig will ask max value |
| 800 | * later if needed */ |
| 801 | retry->flags |= IW_RETRY_LIMIT; |
| 802 | retry->value = local->short_retry_limit; |
| 803 | if (local->long_retry_limit != local->short_retry_limit) |
| 804 | retry->flags |= IW_RETRY_MIN; |
| 805 | return 0; |
| 806 | } |
| 807 | if (retry->flags & IW_RETRY_MAX) { |
| 808 | retry->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; |
| 809 | retry->value = local->long_retry_limit; |
| 810 | } |
| 811 | |
| 812 | return 0; |
| 813 | } |
| 814 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 815 | static int ieee80211_ioctl_prism2_param(struct net_device *dev, |
| 816 | struct iw_request_info *info, |
| 817 | void *wrqu, char *extra) |
| 818 | { |
| 819 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 820 | struct ieee80211_sub_if_data *sdata; |
| 821 | int *i = (int *) extra; |
| 822 | int param = *i; |
| 823 | int value = *(i + 1); |
| 824 | int ret = 0; |
Johannes Berg | b708e61 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 825 | int mode; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 826 | |
| 827 | if (!capable(CAP_NET_ADMIN)) |
| 828 | return -EPERM; |
| 829 | |
| 830 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 831 | |
| 832 | switch (param) { |
| 833 | case PRISM2_PARAM_IEEE_802_1X: |
| 834 | if (local->ops->set_ieee8021x) |
| 835 | ret = local->ops->set_ieee8021x(local_to_hw(local), |
| 836 | value); |
| 837 | if (ret) |
| 838 | printk(KERN_DEBUG "%s: failed to set IEEE 802.1X (%d) " |
| 839 | "for low-level driver\n", dev->name, value); |
| 840 | else |
| 841 | sdata->ieee802_1x = value; |
| 842 | break; |
| 843 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 844 | case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES: |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 845 | if (sdata->type == IEEE80211_IF_TYPE_AP) { |
Jiri Slaby | 13262ff | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 846 | if (value) |
| 847 | sdata->flags |= IEEE80211_SDATA_USE_PROTECTION; |
| 848 | else |
| 849 | sdata->flags &= ~IEEE80211_SDATA_USE_PROTECTION; |
| 850 | ieee80211_erp_info_change_notify(dev, |
| 851 | IEEE80211_ERP_CHANGE_PROTECTION); |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 852 | } else { |
Daniel Drake | 63fc33c | 2007-07-10 19:32:11 +0200 | [diff] [blame] | 853 | ret = -ENOENT; |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 854 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 855 | break; |
| 856 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 857 | case PRISM2_PARAM_PREAMBLE: |
Johannes Berg | b63bde7 | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 858 | if (sdata->type == IEEE80211_IF_TYPE_AP) { |
Jiri Slaby | 13262ff | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 859 | if (value) |
| 860 | sdata->flags |= IEEE80211_SDATA_SHORT_PREAMBLE; |
| 861 | else |
| 862 | sdata->flags &= ~IEEE80211_SDATA_SHORT_PREAMBLE; |
| 863 | ieee80211_erp_info_change_notify(dev, |
| 864 | IEEE80211_ERP_CHANGE_PREAMBLE); |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 865 | } else { |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 866 | ret = -ENOENT; |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 867 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 868 | break; |
| 869 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 870 | case PRISM2_PARAM_SHORT_SLOT_TIME: |
| 871 | if (value) |
| 872 | local->hw.conf.flags |= IEEE80211_CONF_SHORT_SLOT_TIME; |
| 873 | else |
| 874 | local->hw.conf.flags &= ~IEEE80211_CONF_SHORT_SLOT_TIME; |
| 875 | if (ieee80211_hw_config(local)) |
| 876 | ret = -EINVAL; |
| 877 | break; |
| 878 | |
| 879 | case PRISM2_PARAM_NEXT_MODE: |
Johannes Berg | b708e61 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 880 | local->next_mode = hostapd_mode_to_mode(value); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 881 | break; |
| 882 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 883 | case PRISM2_PARAM_KEY_TX_RX_THRESHOLD: |
| 884 | local->key_tx_rx_threshold = value; |
| 885 | break; |
| 886 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 887 | case PRISM2_PARAM_WIFI_WME_NOACK_TEST: |
| 888 | local->wifi_wme_noack_test = value; |
| 889 | break; |
| 890 | |
| 891 | case PRISM2_PARAM_SCAN_FLAGS: |
| 892 | local->scan_flags = value; |
| 893 | break; |
| 894 | |
| 895 | case PRISM2_PARAM_MIXED_CELL: |
| 896 | if (sdata->type != IEEE80211_IF_TYPE_STA && |
| 897 | sdata->type != IEEE80211_IF_TYPE_IBSS) |
| 898 | ret = -EINVAL; |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 899 | else { |
| 900 | if (value) |
| 901 | sdata->u.sta.flags |= IEEE80211_STA_MIXED_CELL; |
| 902 | else |
| 903 | sdata->u.sta.flags &= ~IEEE80211_STA_MIXED_CELL; |
| 904 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 905 | break; |
| 906 | |
| 907 | case PRISM2_PARAM_HW_MODES: |
Johannes Berg | b708e61 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 908 | mode = 1; |
| 909 | local->enabled_modes = 0; |
| 910 | while (value) { |
| 911 | if (value & 1) |
| 912 | local->enabled_modes |= |
| 913 | hostapd_mode_to_mode(mode); |
| 914 | mode <<= 1; |
| 915 | value >>= 1; |
| 916 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 917 | break; |
| 918 | |
| 919 | case PRISM2_PARAM_CREATE_IBSS: |
| 920 | if (sdata->type != IEEE80211_IF_TYPE_IBSS) |
| 921 | ret = -EINVAL; |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 922 | else { |
| 923 | if (value) |
| 924 | sdata->u.sta.flags |= IEEE80211_STA_CREATE_IBSS; |
| 925 | else |
| 926 | sdata->u.sta.flags &= ~IEEE80211_STA_CREATE_IBSS; |
| 927 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 928 | break; |
| 929 | case PRISM2_PARAM_WMM_ENABLED: |
| 930 | if (sdata->type != IEEE80211_IF_TYPE_STA && |
| 931 | sdata->type != IEEE80211_IF_TYPE_IBSS) |
| 932 | ret = -EINVAL; |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 933 | else { |
| 934 | if (value) |
| 935 | sdata->u.sta.flags |= IEEE80211_STA_WMM_ENABLED; |
| 936 | else |
| 937 | sdata->u.sta.flags &= ~IEEE80211_STA_WMM_ENABLED; |
| 938 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 939 | break; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 940 | default: |
| 941 | ret = -EOPNOTSUPP; |
| 942 | break; |
| 943 | } |
| 944 | |
| 945 | return ret; |
| 946 | } |
| 947 | |
| 948 | |
| 949 | static int ieee80211_ioctl_get_prism2_param(struct net_device *dev, |
| 950 | struct iw_request_info *info, |
| 951 | void *wrqu, char *extra) |
| 952 | { |
| 953 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 954 | struct ieee80211_sub_if_data *sdata; |
| 955 | int *param = (int *) extra; |
| 956 | int ret = 0; |
Johannes Berg | b708e61 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 957 | int mode; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 958 | |
| 959 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 960 | |
| 961 | switch (*param) { |
| 962 | case PRISM2_PARAM_IEEE_802_1X: |
| 963 | *param = sdata->ieee802_1x; |
| 964 | break; |
| 965 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 966 | case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES: |
Jiri Slaby | 13262ff | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 967 | *param = !!(sdata->flags & IEEE80211_SDATA_USE_PROTECTION); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 968 | break; |
| 969 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 970 | case PRISM2_PARAM_PREAMBLE: |
Jiri Slaby | 13262ff | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 971 | *param = !!(sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 972 | break; |
| 973 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 974 | case PRISM2_PARAM_SHORT_SLOT_TIME: |
| 975 | *param = !!(local->hw.conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME); |
| 976 | break; |
| 977 | |
| 978 | case PRISM2_PARAM_NEXT_MODE: |
| 979 | *param = local->next_mode; |
| 980 | break; |
| 981 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 982 | case PRISM2_PARAM_KEY_TX_RX_THRESHOLD: |
| 983 | *param = local->key_tx_rx_threshold; |
| 984 | break; |
| 985 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 986 | case PRISM2_PARAM_WIFI_WME_NOACK_TEST: |
| 987 | *param = local->wifi_wme_noack_test; |
| 988 | break; |
| 989 | |
| 990 | case PRISM2_PARAM_SCAN_FLAGS: |
| 991 | *param = local->scan_flags; |
| 992 | break; |
| 993 | |
| 994 | case PRISM2_PARAM_HW_MODES: |
Johannes Berg | b708e61 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 995 | mode = 0; |
| 996 | *param = 0; |
| 997 | while (mode < NUM_IEEE80211_MODES) { |
| 998 | if (local->enabled_modes & (1<<mode)) |
| 999 | *param |= mode_to_hostapd_mode(1<<mode); |
| 1000 | mode++; |
| 1001 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1002 | break; |
| 1003 | |
| 1004 | case PRISM2_PARAM_CREATE_IBSS: |
| 1005 | if (sdata->type != IEEE80211_IF_TYPE_IBSS) |
| 1006 | ret = -EINVAL; |
| 1007 | else |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 1008 | *param = !!(sdata->u.sta.flags & |
| 1009 | IEEE80211_STA_CREATE_IBSS); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1010 | break; |
| 1011 | |
| 1012 | case PRISM2_PARAM_MIXED_CELL: |
| 1013 | if (sdata->type != IEEE80211_IF_TYPE_STA && |
| 1014 | sdata->type != IEEE80211_IF_TYPE_IBSS) |
| 1015 | ret = -EINVAL; |
| 1016 | else |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 1017 | *param = !!(sdata->u.sta.flags & |
| 1018 | IEEE80211_STA_MIXED_CELL); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1019 | break; |
Johannes Berg | 3c3b00c | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 1020 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1021 | case PRISM2_PARAM_WMM_ENABLED: |
| 1022 | if (sdata->type != IEEE80211_IF_TYPE_STA && |
| 1023 | sdata->type != IEEE80211_IF_TYPE_IBSS) |
| 1024 | ret = -EINVAL; |
| 1025 | else |
Jiri Slaby | d6f2da5 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 1026 | *param = !!(sdata->u.sta.flags & |
| 1027 | IEEE80211_STA_WMM_ENABLED); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1028 | break; |
| 1029 | default: |
| 1030 | ret = -EOPNOTSUPP; |
| 1031 | break; |
| 1032 | } |
| 1033 | |
| 1034 | return ret; |
| 1035 | } |
| 1036 | |
| 1037 | static int ieee80211_ioctl_siwmlme(struct net_device *dev, |
| 1038 | struct iw_request_info *info, |
| 1039 | struct iw_point *data, char *extra) |
| 1040 | { |
| 1041 | struct ieee80211_sub_if_data *sdata; |
| 1042 | struct iw_mlme *mlme = (struct iw_mlme *) extra; |
| 1043 | |
| 1044 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1045 | if (sdata->type != IEEE80211_IF_TYPE_STA && |
| 1046 | sdata->type != IEEE80211_IF_TYPE_IBSS) |
| 1047 | return -EINVAL; |
| 1048 | |
| 1049 | switch (mlme->cmd) { |
| 1050 | case IW_MLME_DEAUTH: |
| 1051 | /* TODO: mlme->addr.sa_data */ |
| 1052 | return ieee80211_sta_deauthenticate(dev, mlme->reason_code); |
| 1053 | case IW_MLME_DISASSOC: |
| 1054 | /* TODO: mlme->addr.sa_data */ |
| 1055 | return ieee80211_sta_disassociate(dev, mlme->reason_code); |
| 1056 | default: |
| 1057 | return -EOPNOTSUPP; |
| 1058 | } |
| 1059 | } |
| 1060 | |
| 1061 | |
| 1062 | static int ieee80211_ioctl_siwencode(struct net_device *dev, |
| 1063 | struct iw_request_info *info, |
| 1064 | struct iw_point *erq, char *keybuf) |
| 1065 | { |
| 1066 | struct ieee80211_sub_if_data *sdata; |
| 1067 | int idx, i, alg = ALG_WEP; |
| 1068 | u8 bcaddr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 1069 | |
| 1070 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1071 | |
| 1072 | idx = erq->flags & IW_ENCODE_INDEX; |
| 1073 | if (idx == 0) { |
| 1074 | if (sdata->default_key) |
| 1075 | for (i = 0; i < NUM_DEFAULT_KEYS; i++) { |
| 1076 | if (sdata->default_key == sdata->keys[i]) { |
| 1077 | idx = i; |
| 1078 | break; |
| 1079 | } |
| 1080 | } |
| 1081 | } else if (idx < 1 || idx > 4) |
| 1082 | return -EINVAL; |
| 1083 | else |
| 1084 | idx--; |
| 1085 | |
| 1086 | if (erq->flags & IW_ENCODE_DISABLED) |
| 1087 | alg = ALG_NONE; |
| 1088 | else if (erq->length == 0) { |
| 1089 | /* No key data - just set the default TX key index */ |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 1090 | ieee80211_set_default_key(sdata, idx); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1091 | return 0; |
| 1092 | } |
| 1093 | |
| 1094 | return ieee80211_set_encryption( |
| 1095 | dev, bcaddr, |
| 1096 | idx, alg, |
| 1097 | !sdata->default_key, |
| 1098 | keybuf, erq->length); |
| 1099 | } |
| 1100 | |
| 1101 | |
| 1102 | static int ieee80211_ioctl_giwencode(struct net_device *dev, |
| 1103 | struct iw_request_info *info, |
| 1104 | struct iw_point *erq, char *key) |
| 1105 | { |
| 1106 | struct ieee80211_sub_if_data *sdata; |
| 1107 | int idx, i; |
| 1108 | |
| 1109 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1110 | |
| 1111 | idx = erq->flags & IW_ENCODE_INDEX; |
| 1112 | if (idx < 1 || idx > 4) { |
| 1113 | idx = -1; |
| 1114 | if (!sdata->default_key) |
| 1115 | idx = 0; |
| 1116 | else for (i = 0; i < NUM_DEFAULT_KEYS; i++) { |
| 1117 | if (sdata->default_key == sdata->keys[i]) { |
| 1118 | idx = i; |
| 1119 | break; |
| 1120 | } |
| 1121 | } |
| 1122 | if (idx < 0) |
| 1123 | return -EINVAL; |
| 1124 | } else |
| 1125 | idx--; |
| 1126 | |
| 1127 | erq->flags = idx + 1; |
| 1128 | |
| 1129 | if (!sdata->keys[idx]) { |
| 1130 | erq->length = 0; |
| 1131 | erq->flags |= IW_ENCODE_DISABLED; |
| 1132 | return 0; |
| 1133 | } |
| 1134 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 1135 | memcpy(key, sdata->keys[idx]->conf.key, |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 1136 | min_t(int, erq->length, sdata->keys[idx]->conf.keylen)); |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 1137 | erq->length = sdata->keys[idx]->conf.keylen; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1138 | erq->flags |= IW_ENCODE_ENABLED; |
| 1139 | |
| 1140 | return 0; |
| 1141 | } |
| 1142 | |
| 1143 | static int ieee80211_ioctl_siwauth(struct net_device *dev, |
| 1144 | struct iw_request_info *info, |
| 1145 | struct iw_param *data, char *extra) |
| 1146 | { |
| 1147 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 1148 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1149 | int ret = 0; |
| 1150 | |
| 1151 | switch (data->flags & IW_AUTH_INDEX) { |
| 1152 | case IW_AUTH_WPA_VERSION: |
| 1153 | case IW_AUTH_CIPHER_PAIRWISE: |
| 1154 | case IW_AUTH_CIPHER_GROUP: |
| 1155 | case IW_AUTH_WPA_ENABLED: |
| 1156 | case IW_AUTH_RX_UNENCRYPTED_EAPOL: |
| 1157 | break; |
| 1158 | case IW_AUTH_KEY_MGMT: |
| 1159 | if (sdata->type != IEEE80211_IF_TYPE_STA) |
| 1160 | ret = -EINVAL; |
| 1161 | else { |
| 1162 | /* |
Johannes Berg | 808718c | 2007-08-28 17:01:53 -0400 | [diff] [blame] | 1163 | * Key management was set by wpa_supplicant, |
| 1164 | * we only need this to associate to a network |
| 1165 | * that has privacy enabled regardless of not |
| 1166 | * having a key. |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1167 | */ |
Johannes Berg | 808718c | 2007-08-28 17:01:53 -0400 | [diff] [blame] | 1168 | sdata->u.sta.key_management_enabled = !!data->value; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1169 | } |
| 1170 | break; |
| 1171 | case IW_AUTH_80211_AUTH_ALG: |
| 1172 | if (sdata->type == IEEE80211_IF_TYPE_STA || |
| 1173 | sdata->type == IEEE80211_IF_TYPE_IBSS) |
| 1174 | sdata->u.sta.auth_algs = data->value; |
| 1175 | else |
| 1176 | ret = -EOPNOTSUPP; |
| 1177 | break; |
| 1178 | case IW_AUTH_PRIVACY_INVOKED: |
| 1179 | if (local->ops->set_privacy_invoked) |
| 1180 | ret = local->ops->set_privacy_invoked( |
| 1181 | local_to_hw(local), data->value); |
| 1182 | break; |
| 1183 | default: |
| 1184 | ret = -EOPNOTSUPP; |
| 1185 | break; |
| 1186 | } |
| 1187 | return ret; |
| 1188 | } |
| 1189 | |
| 1190 | /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */ |
| 1191 | static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev) |
| 1192 | { |
| 1193 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 1194 | struct iw_statistics *wstats = &local->wstats; |
| 1195 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1196 | struct sta_info *sta = NULL; |
| 1197 | |
| 1198 | if (sdata->type == IEEE80211_IF_TYPE_STA || |
| 1199 | sdata->type == IEEE80211_IF_TYPE_IBSS) |
| 1200 | sta = sta_info_get(local, sdata->u.sta.bssid); |
| 1201 | if (!sta) { |
| 1202 | wstats->discard.fragment = 0; |
| 1203 | wstats->discard.misc = 0; |
| 1204 | wstats->qual.qual = 0; |
| 1205 | wstats->qual.level = 0; |
| 1206 | wstats->qual.noise = 0; |
| 1207 | wstats->qual.updated = IW_QUAL_ALL_INVALID; |
| 1208 | } else { |
| 1209 | wstats->qual.level = sta->last_rssi; |
| 1210 | wstats->qual.qual = sta->last_signal; |
| 1211 | wstats->qual.noise = sta->last_noise; |
| 1212 | wstats->qual.updated = local->wstats_flags; |
| 1213 | sta_info_put(sta); |
| 1214 | } |
| 1215 | return wstats; |
| 1216 | } |
| 1217 | |
| 1218 | static int ieee80211_ioctl_giwauth(struct net_device *dev, |
| 1219 | struct iw_request_info *info, |
| 1220 | struct iw_param *data, char *extra) |
| 1221 | { |
| 1222 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1223 | int ret = 0; |
| 1224 | |
| 1225 | switch (data->flags & IW_AUTH_INDEX) { |
| 1226 | case IW_AUTH_80211_AUTH_ALG: |
| 1227 | if (sdata->type == IEEE80211_IF_TYPE_STA || |
| 1228 | sdata->type == IEEE80211_IF_TYPE_IBSS) |
| 1229 | data->value = sdata->u.sta.auth_algs; |
| 1230 | else |
| 1231 | ret = -EOPNOTSUPP; |
| 1232 | break; |
| 1233 | default: |
| 1234 | ret = -EOPNOTSUPP; |
| 1235 | break; |
| 1236 | } |
| 1237 | return ret; |
| 1238 | } |
| 1239 | |
| 1240 | |
| 1241 | static int ieee80211_ioctl_siwencodeext(struct net_device *dev, |
| 1242 | struct iw_request_info *info, |
| 1243 | struct iw_point *erq, char *extra) |
| 1244 | { |
| 1245 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1246 | struct iw_encode_ext *ext = (struct iw_encode_ext *) extra; |
| 1247 | int alg, idx, i; |
| 1248 | |
| 1249 | switch (ext->alg) { |
| 1250 | case IW_ENCODE_ALG_NONE: |
| 1251 | alg = ALG_NONE; |
| 1252 | break; |
| 1253 | case IW_ENCODE_ALG_WEP: |
| 1254 | alg = ALG_WEP; |
| 1255 | break; |
| 1256 | case IW_ENCODE_ALG_TKIP: |
| 1257 | alg = ALG_TKIP; |
| 1258 | break; |
| 1259 | case IW_ENCODE_ALG_CCMP: |
| 1260 | alg = ALG_CCMP; |
| 1261 | break; |
| 1262 | default: |
| 1263 | return -EOPNOTSUPP; |
| 1264 | } |
| 1265 | |
| 1266 | if (erq->flags & IW_ENCODE_DISABLED) |
| 1267 | alg = ALG_NONE; |
| 1268 | |
| 1269 | idx = erq->flags & IW_ENCODE_INDEX; |
| 1270 | if (idx < 1 || idx > 4) { |
| 1271 | idx = -1; |
| 1272 | if (!sdata->default_key) |
| 1273 | idx = 0; |
| 1274 | else for (i = 0; i < NUM_DEFAULT_KEYS; i++) { |
| 1275 | if (sdata->default_key == sdata->keys[i]) { |
| 1276 | idx = i; |
| 1277 | break; |
| 1278 | } |
| 1279 | } |
| 1280 | if (idx < 0) |
| 1281 | return -EINVAL; |
| 1282 | } else |
| 1283 | idx--; |
| 1284 | |
| 1285 | return ieee80211_set_encryption(dev, ext->addr.sa_data, idx, alg, |
| 1286 | ext->ext_flags & |
| 1287 | IW_ENCODE_EXT_SET_TX_KEY, |
| 1288 | ext->key, ext->key_len); |
| 1289 | } |
| 1290 | |
| 1291 | |
| 1292 | static const struct iw_priv_args ieee80211_ioctl_priv[] = { |
| 1293 | { PRISM2_IOCTL_PRISM2_PARAM, |
| 1294 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "param" }, |
| 1295 | { PRISM2_IOCTL_GET_PRISM2_PARAM, |
| 1296 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1297 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_param" }, |
| 1298 | }; |
| 1299 | |
| 1300 | /* Structures to export the Wireless Handlers */ |
| 1301 | |
| 1302 | static const iw_handler ieee80211_handler[] = |
| 1303 | { |
| 1304 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ |
| 1305 | (iw_handler) ieee80211_ioctl_giwname, /* SIOCGIWNAME */ |
| 1306 | (iw_handler) NULL, /* SIOCSIWNWID */ |
| 1307 | (iw_handler) NULL, /* SIOCGIWNWID */ |
| 1308 | (iw_handler) ieee80211_ioctl_siwfreq, /* SIOCSIWFREQ */ |
| 1309 | (iw_handler) ieee80211_ioctl_giwfreq, /* SIOCGIWFREQ */ |
| 1310 | (iw_handler) ieee80211_ioctl_siwmode, /* SIOCSIWMODE */ |
| 1311 | (iw_handler) ieee80211_ioctl_giwmode, /* SIOCGIWMODE */ |
| 1312 | (iw_handler) NULL, /* SIOCSIWSENS */ |
| 1313 | (iw_handler) NULL, /* SIOCGIWSENS */ |
| 1314 | (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */ |
| 1315 | (iw_handler) ieee80211_ioctl_giwrange, /* SIOCGIWRANGE */ |
| 1316 | (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */ |
| 1317 | (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */ |
| 1318 | (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */ |
| 1319 | (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */ |
Johannes Berg | 5d4ecd9 | 2007-09-14 11:10:24 -0400 | [diff] [blame] | 1320 | (iw_handler) NULL, /* SIOCSIWSPY */ |
| 1321 | (iw_handler) NULL, /* SIOCGIWSPY */ |
| 1322 | (iw_handler) NULL, /* SIOCSIWTHRSPY */ |
| 1323 | (iw_handler) NULL, /* SIOCGIWTHRSPY */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1324 | (iw_handler) ieee80211_ioctl_siwap, /* SIOCSIWAP */ |
| 1325 | (iw_handler) ieee80211_ioctl_giwap, /* SIOCGIWAP */ |
| 1326 | (iw_handler) ieee80211_ioctl_siwmlme, /* SIOCSIWMLME */ |
| 1327 | (iw_handler) NULL, /* SIOCGIWAPLIST */ |
| 1328 | (iw_handler) ieee80211_ioctl_siwscan, /* SIOCSIWSCAN */ |
| 1329 | (iw_handler) ieee80211_ioctl_giwscan, /* SIOCGIWSCAN */ |
| 1330 | (iw_handler) ieee80211_ioctl_siwessid, /* SIOCSIWESSID */ |
| 1331 | (iw_handler) ieee80211_ioctl_giwessid, /* SIOCGIWESSID */ |
| 1332 | (iw_handler) NULL, /* SIOCSIWNICKN */ |
| 1333 | (iw_handler) NULL, /* SIOCGIWNICKN */ |
| 1334 | (iw_handler) NULL, /* -- hole -- */ |
| 1335 | (iw_handler) NULL, /* -- hole -- */ |
Larry Finger | 1fd5e58 | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 1336 | (iw_handler) ieee80211_ioctl_siwrate, /* SIOCSIWRATE */ |
Larry Finger | b3d88ad | 2007-06-10 17:57:33 -0700 | [diff] [blame] | 1337 | (iw_handler) ieee80211_ioctl_giwrate, /* SIOCGIWRATE */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1338 | (iw_handler) ieee80211_ioctl_siwrts, /* SIOCSIWRTS */ |
| 1339 | (iw_handler) ieee80211_ioctl_giwrts, /* SIOCGIWRTS */ |
| 1340 | (iw_handler) ieee80211_ioctl_siwfrag, /* SIOCSIWFRAG */ |
| 1341 | (iw_handler) ieee80211_ioctl_giwfrag, /* SIOCGIWFRAG */ |
| 1342 | (iw_handler) NULL, /* SIOCSIWTXPOW */ |
Larry Finger | fe6aa30 | 2007-08-10 11:23:20 -0500 | [diff] [blame] | 1343 | (iw_handler) ieee80211_ioctl_giwtxpower, /* SIOCGIWTXPOW */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1344 | (iw_handler) ieee80211_ioctl_siwretry, /* SIOCSIWRETRY */ |
| 1345 | (iw_handler) ieee80211_ioctl_giwretry, /* SIOCGIWRETRY */ |
| 1346 | (iw_handler) ieee80211_ioctl_siwencode, /* SIOCSIWENCODE */ |
| 1347 | (iw_handler) ieee80211_ioctl_giwencode, /* SIOCGIWENCODE */ |
| 1348 | (iw_handler) NULL, /* SIOCSIWPOWER */ |
| 1349 | (iw_handler) NULL, /* SIOCGIWPOWER */ |
| 1350 | (iw_handler) NULL, /* -- hole -- */ |
| 1351 | (iw_handler) NULL, /* -- hole -- */ |
| 1352 | (iw_handler) ieee80211_ioctl_siwgenie, /* SIOCSIWGENIE */ |
| 1353 | (iw_handler) NULL, /* SIOCGIWGENIE */ |
| 1354 | (iw_handler) ieee80211_ioctl_siwauth, /* SIOCSIWAUTH */ |
| 1355 | (iw_handler) ieee80211_ioctl_giwauth, /* SIOCGIWAUTH */ |
| 1356 | (iw_handler) ieee80211_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */ |
| 1357 | (iw_handler) NULL, /* SIOCGIWENCODEEXT */ |
| 1358 | (iw_handler) NULL, /* SIOCSIWPMKSA */ |
| 1359 | (iw_handler) NULL, /* -- hole -- */ |
| 1360 | }; |
| 1361 | |
| 1362 | static const iw_handler ieee80211_private_handler[] = |
| 1363 | { /* SIOCIWFIRSTPRIV + */ |
| 1364 | (iw_handler) ieee80211_ioctl_prism2_param, /* 0 */ |
| 1365 | (iw_handler) ieee80211_ioctl_get_prism2_param, /* 1 */ |
| 1366 | }; |
| 1367 | |
| 1368 | const struct iw_handler_def ieee80211_iw_handler_def = |
| 1369 | { |
| 1370 | .num_standard = ARRAY_SIZE(ieee80211_handler), |
| 1371 | .num_private = ARRAY_SIZE(ieee80211_private_handler), |
| 1372 | .num_private_args = ARRAY_SIZE(ieee80211_ioctl_priv), |
| 1373 | .standard = (iw_handler *) ieee80211_handler, |
| 1374 | .private = (iw_handler *) ieee80211_private_handler, |
| 1375 | .private_args = (struct iw_priv_args *) ieee80211_ioctl_priv, |
| 1376 | .get_wireless_stats = ieee80211_get_wireless_stats, |
| 1377 | }; |