2 * ---------------------------------------------------------------------------
6 * Handlers for ioctls from iwconfig.
7 * These provide the control plane operations.
9 * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd.
11 * Refer to LICENSE.txt included with this source code for details on
14 * ---------------------------------------------------------------------------
16 #include <linux/types.h>
17 #include <linux/etherdevice.h>
18 #include <linux/if_arp.h>
19 #include <asm/uaccess.h>
20 #include <linux/ctype.h>
21 #include "unifi_priv.h"
22 #include <linux/rtnetlink.h>
24 #define CHECK_INITED(_priv) \
26 if (_priv->init_progress != UNIFI_INIT_COMPLETED) { \
27 unifi_trace(_priv, UDBG2, "%s unifi not ready, failing wext call\n", __FUNCTION__); \
32 /* Workaround for the wpa_supplicant hanging issue - disabled on Android */
34 #define CSR_WIFI_WEXT_HANG_WORKAROUND
37 #ifdef CSR_WIFI_WEXT_HANG_WORKAROUND
38 # define UF_RTNL_LOCK() rtnl_lock()
39 # define UF_RTNL_UNLOCK() rtnl_unlock()
41 # define UF_RTNL_LOCK()
42 # define UF_RTNL_UNLOCK()
47 * ---------------------------------------------------------------------------
49 * ---------------------------------------------------------------------------
53 * ---------------------------------------------------------------------------
54 * wext_freq_to_channel
57 * These functions convert between channel number and frequency.
60 * ch Channel number, as defined in 802.11 specs
61 * m, e Mantissa and exponent as provided by wireless extension.
64 * channel or frequency (in MHz) value
65 * ---------------------------------------------------------------------------
68 wext_freq_to_channel(int m
, int e
)
83 return ((mhz
- 5000) / 5);
91 return ((mhz
- 2407) / 5);
95 } /* wext_freq_to_channel() */
98 channel_to_mhz(int ch
, int dot11a
)
101 if (ch
== 0) return 0;
102 if (ch
> 200) return 0;
106 return (5000 + (5 * ch
));
114 if ((ch
< 14) && (ch
> 0)) {
115 return (2407 + (5 * ch
));
120 #ifdef CSR_SUPPORT_WEXT_AP
121 void uf_sme_wext_ap_set_defaults(unifi_priv_t
*priv
)
123 memcpy(priv
->ap_config
.ssid
.ssid
, "defaultssid", sizeof("defaultssid"));
125 priv
->ap_config
.ssid
.length
= 8;
126 priv
->ap_config
.channel
= 6;
127 priv
->ap_config
.if_index
= 1;
128 priv
->ap_config
.credentials
.authType
= 0;
129 priv
->ap_config
.max_connections
=8;
131 priv
->group_sec_config
.apGroupkeyTimeout
= 0;
132 priv
->group_sec_config
.apStrictGtkRekey
= 0;
133 priv
->group_sec_config
.apGmkTimeout
= 0;
134 priv
->group_sec_config
.apResponseTimeout
= 100; /* Default*/
135 priv
->group_sec_config
.apRetransLimit
= 3; /* Default*/
136 /* Set default params even if they may not be used*/
139 priv
->ap_mac_config
.preamble
= CSR_WIFI_SME_USE_LONG_PREAMBLE
;
140 priv
->ap_mac_config
.shortSlotTimeEnabled
= FALSE
;
141 priv
->ap_mac_config
.ctsProtectionType
=CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC
;
143 priv
->ap_mac_config
.wmmEnabled
= TRUE
;
144 priv
->ap_mac_config
.wmmApParams
[0].cwMin
=4;
145 priv
->ap_mac_config
.wmmApParams
[0].cwMax
=10;
146 priv
->ap_mac_config
.wmmApParams
[0].aifs
=3;
147 priv
->ap_mac_config
.wmmApParams
[0].txopLimit
=0;
148 priv
->ap_mac_config
.wmmApParams
[0].admissionControlMandatory
=FALSE
;
149 priv
->ap_mac_config
.wmmApParams
[1].cwMin
=4;
150 priv
->ap_mac_config
.wmmApParams
[1].cwMax
=10;
151 priv
->ap_mac_config
.wmmApParams
[1].aifs
=7;
152 priv
->ap_mac_config
.wmmApParams
[1].txopLimit
=0;
153 priv
->ap_mac_config
.wmmApParams
[1].admissionControlMandatory
=FALSE
;
154 priv
->ap_mac_config
.wmmApParams
[2].cwMin
=3;
155 priv
->ap_mac_config
.wmmApParams
[2].cwMax
=4;
156 priv
->ap_mac_config
.wmmApParams
[2].aifs
=1;
157 priv
->ap_mac_config
.wmmApParams
[2].txopLimit
=94;
158 priv
->ap_mac_config
.wmmApParams
[2].admissionControlMandatory
=FALSE
;
159 priv
->ap_mac_config
.wmmApParams
[3].cwMin
=2;
160 priv
->ap_mac_config
.wmmApParams
[3].cwMax
=3;
161 priv
->ap_mac_config
.wmmApParams
[3].aifs
=1;
162 priv
->ap_mac_config
.wmmApParams
[3].txopLimit
=47;
163 priv
->ap_mac_config
.wmmApParams
[3].admissionControlMandatory
=FALSE
;
165 priv
->ap_mac_config
.wmmApBcParams
[0].cwMin
=4;
166 priv
->ap_mac_config
.wmmApBcParams
[0].cwMax
=10;
167 priv
->ap_mac_config
.wmmApBcParams
[0].aifs
=3;
168 priv
->ap_mac_config
.wmmApBcParams
[0].txopLimit
=0;
169 priv
->ap_mac_config
.wmmApBcParams
[0].admissionControlMandatory
=FALSE
;
170 priv
->ap_mac_config
.wmmApBcParams
[1].cwMin
=4;
171 priv
->ap_mac_config
.wmmApBcParams
[1].cwMax
=10;
172 priv
->ap_mac_config
.wmmApBcParams
[1].aifs
=7;
173 priv
->ap_mac_config
.wmmApBcParams
[1].txopLimit
=0;
174 priv
->ap_mac_config
.wmmApBcParams
[1].admissionControlMandatory
=FALSE
;
175 priv
->ap_mac_config
.wmmApBcParams
[2].cwMin
=3;
176 priv
->ap_mac_config
.wmmApBcParams
[2].cwMax
=4;
177 priv
->ap_mac_config
.wmmApBcParams
[2].aifs
=2;
178 priv
->ap_mac_config
.wmmApBcParams
[2].txopLimit
=94;
179 priv
->ap_mac_config
.wmmApBcParams
[2].admissionControlMandatory
=FALSE
;
180 priv
->ap_mac_config
.wmmApBcParams
[3].cwMin
=2;
181 priv
->ap_mac_config
.wmmApBcParams
[3].cwMax
=3;
182 priv
->ap_mac_config
.wmmApBcParams
[3].aifs
=2;
183 priv
->ap_mac_config
.wmmApBcParams
[3].txopLimit
=47;
184 priv
->ap_mac_config
.wmmApBcParams
[3].admissionControlMandatory
=FALSE
;
186 priv
->ap_mac_config
.accessType
=CSR_WIFI_AP_ACCESS_TYPE_NONE
;
187 priv
->ap_mac_config
.macAddressListCount
=0;
188 priv
->ap_mac_config
.macAddressList
=NULL
;
190 priv
->ap_mac_config
.apHtParams
.rxStbc
=1;
191 priv
->ap_mac_config
.apHtParams
.rifsModeAllowed
=TRUE
;
192 priv
->ap_mac_config
.apHtParams
.greenfieldSupported
=FALSE
;
193 priv
->ap_mac_config
.apHtParams
.shortGi20MHz
=TRUE
;
194 priv
->ap_mac_config
.apHtParams
.htProtection
=0;
195 priv
->ap_mac_config
.apHtParams
.dualCtsProtection
=FALSE
;
197 priv
->ap_mac_config
.phySupportedBitmap
=
198 (CSR_WIFI_SME_AP_PHY_SUPPORT_B
|CSR_WIFI_SME_AP_PHY_SUPPORT_G
|CSR_WIFI_SME_AP_PHY_SUPPORT_N
);
199 priv
->ap_mac_config
.beaconInterval
= 100;
200 priv
->ap_mac_config
.dtimPeriod
=3;
201 priv
->ap_mac_config
.maxListenInterval
=0x00ff;/* Set it to a large value
202 to enable different types of
203 devices to join us */
204 priv
->ap_mac_config
.supportedRatesCount
=
205 uf_configure_supported_rates(priv
->ap_mac_config
.supportedRates
, priv
->ap_mac_config
.phySupportedBitmap
);
209 * ---------------------------------------------------------------------------
210 * uf_sme_wext_set_defaults
212 * Set up power-on defaults for driver config.
214 * Note: The SME Management API *cannot* be used in this function.
217 * priv Pointer to device private context struct
221 * ---------------------------------------------------------------------------
224 uf_sme_wext_set_defaults(unifi_priv_t
*priv
)
226 memset(&priv
->connection_config
, 0, sizeof(CsrWifiSmeConnectionConfig
));
228 priv
->connection_config
.bssType
= CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE
;
229 priv
->connection_config
.authModeMask
= CSR_WIFI_SME_AUTH_MODE_80211_OPEN
;
230 priv
->connection_config
.encryptionModeMask
= CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE
;
231 priv
->connection_config
.privacyMode
= CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED
;
232 priv
->connection_config
.wmmQosInfo
= 0xFF;
233 priv
->connection_config
.ifIndex
= CSR_WIFI_SME_RADIO_IF_BOTH
;
234 priv
->connection_config
.adhocJoinOnly
= FALSE
;
235 priv
->connection_config
.adhocChannel
= 6;
237 priv
->wep_tx_key_index
= 0;
239 priv
->wext_wireless_stats
.qual
.qual
= 0;
240 priv
->wext_wireless_stats
.qual
.level
= 0;
241 priv
->wext_wireless_stats
.qual
.noise
= 0;
242 priv
->wext_wireless_stats
.qual
.updated
= 0x70;
243 #ifdef CSR_SUPPORT_WEXT_AP
244 /* Initialize the default configuration for AP */
245 uf_sme_wext_ap_set_defaults(priv
);
249 } /* uf_sme_wext_set_defaults() */
253 * ---------------------------------------------------------------------------
255 * ---------------------------------------------------------------------------
259 * ---------------------------------------------------------------------------
260 * unifi_giwname - handler for SIOCGIWNAME
261 * unifi_siwfreq - handler for SIOCSIWFREQ
262 * unifi_giwfreq - handler for SIOCGIWFREQ
263 * unifi_siwmode - handler for SIOCSIWMODE
264 * unifi_giwmode - handler for SIOCGIWMODE
265 * unifi_giwrange - handler for SIOCGIWRANGE
266 * unifi_siwap - handler for SIOCSIWAP
267 * unifi_giwap - handler for SIOCGIWAP
268 * unifi_siwscan - handler for SIOCSIWSCAN
269 * unifi_giwscan - handler for SIOCGIWSCAN
270 * unifi_siwessid - handler for SIOCSIWESSID
271 * unifi_giwessid - handler for SIOCGIWESSID
272 * unifi_siwencode - handler for SIOCSIWENCODE
273 * unifi_giwencode - handler for SIOCGIWENCODE
275 * Handler functions for IW extensions.
276 * These are registered via the unifi_iw_handler_def struct below
277 * and called by the generic IW driver support code.
278 * See include/net/iw_handler.h.
285 * ---------------------------------------------------------------------------
288 iwprivsdefs(struct net_device
*dev
, struct iw_request_info
*info
,
289 union iwreq_data
*wrqu
, char *extra
)
292 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
293 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
294 CsrWifiSmeMibConfig mibConfig
;
295 CsrWifiSmePowerConfig powerConfig
;
297 unifi_trace(priv
, UDBG1
, "iwprivs80211defaults: reload defaults\n");
299 uf_sme_wext_set_defaults(priv
);
301 /* Get, modify and set the MIB data */
302 r
= sme_mgt_mib_config_get(priv
, &mibConfig
);
304 unifi_error(priv
, "iwprivs80211defaults: Get CsrWifiSmeMibConfigValue failed.\n");
307 mibConfig
.dot11RtsThreshold
= 2347;
308 mibConfig
.dot11FragmentationThreshold
= 2346;
309 r
= sme_mgt_mib_config_set(priv
, &mibConfig
);
311 unifi_error(priv
, "iwprivs80211defaults: Set CsrWifiSmeMibConfigValue failed.\n");
315 powerConfig
.powerSaveLevel
= CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW
;
316 powerConfig
.listenIntervalTu
= 100;
317 powerConfig
.rxDtims
= 1;
319 r
= sme_mgt_power_config_set(priv
, &powerConfig
);
321 unifi_error(priv
, "iwprivs80211defaults: Set unifi_PowerConfigValue failed.\n");
326 } /* iwprivsdefs() */
329 iwprivs80211ps(struct net_device
*dev
, struct iw_request_info
*info
,
330 union iwreq_data
*wrqu
, char *extra
)
333 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
334 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
336 int ps_mode
= (int)(*extra
);
337 CsrWifiSmePowerConfig powerConfig
;
339 unifi_trace(priv
, UDBG1
, "iwprivs80211ps: power save mode = %d\n", ps_mode
);
341 r
= sme_mgt_power_config_get(priv
, &powerConfig
);
343 unifi_error(priv
, "iwprivs80211ps: Get unifi_PowerConfigValue failed.\n");
348 case CSR_PMM_ACTIVE_MODE
:
349 powerConfig
.powerSaveLevel
= CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW
;
351 case CSR_PMM_POWER_SAVE
:
352 powerConfig
.powerSaveLevel
= CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH
;
354 case CSR_PMM_FAST_POWER_SAVE
:
355 powerConfig
.powerSaveLevel
= CSR_WIFI_SME_POWER_SAVE_LEVEL_MED
;
358 powerConfig
.powerSaveLevel
= CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO
;
362 r
= sme_mgt_power_config_set(priv
, &powerConfig
);
364 unifi_error(priv
, "iwprivs80211ps: Set unifi_PowerConfigValue failed.\n");
371 iwprivg80211ps(struct net_device
*dev
, struct iw_request_info
*info
,
372 union iwreq_data
*wrqu
, char *extra
)
374 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
375 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
377 CsrWifiSmePowerConfig powerConfig
;
380 r
= sme_mgt_power_config_get(priv
, &powerConfig
);
382 unifi_error(priv
, "iwprivg80211ps: Get 802.11 power mode failed.\n");
386 switch (powerConfig
.powerSaveLevel
) {
387 case CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW
:
388 snprintf(extra
, IWPRIV_POWER_SAVE_MAX_STRING
,
389 "Power save mode: %d (Active)",
390 powerConfig
.powerSaveLevel
);
392 case CSR_WIFI_SME_POWER_SAVE_LEVEL_MED
:
393 snprintf(extra
, IWPRIV_POWER_SAVE_MAX_STRING
,
394 "Power save mode: %d (Fast)",
395 powerConfig
.powerSaveLevel
);
397 case CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH
:
398 snprintf(extra
, IWPRIV_POWER_SAVE_MAX_STRING
,
399 "Power save mode: %d (Full)",
400 powerConfig
.powerSaveLevel
);
402 case CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO
:
403 snprintf(extra
, IWPRIV_POWER_SAVE_MAX_STRING
,
404 "Power save mode: %d (Auto)",
405 powerConfig
.powerSaveLevel
);
408 snprintf(extra
, IWPRIV_POWER_SAVE_MAX_STRING
,
409 "Power save mode: %d (Unknown)",
410 powerConfig
.powerSaveLevel
);
414 wrqu
->data
.length
= strlen(extra
) + 1;
420 iwprivssmedebug(struct net_device
*dev
, struct iw_request_info
*info
,
421 union iwreq_data
*wrqu
, char *extra
)
423 /* No longer supported on the API */
424 #if defined (CSR_WIFI_HIP_DEBUG_OFFLINE)
425 unifi_debug_buf_dump();
431 #ifdef CSR_SUPPORT_WEXT_AP
432 #define PARAM_TYPE_INT 0
433 #define PARAM_TYPE_STRING 1
434 #define CSR_WIFI_MAX_SSID_LEN 32
435 #define CSR_WIFI_MAX_SEC_LEN 16
436 #define CSR_WIFI_MAX_KEY_LEN 65
438 static int hex_look_up(char x
)
442 if(x
>= 'a' && x
<= 'f')
447 static int power (int a
, int b
)
456 static int decode_parameter_from_string(unifi_priv_t
* priv
, char **str_ptr
,
457 const char *token
, int param_type
,
458 void *dst
, int param_max_len
)
462 u8
*param_str_begin
, *param_str_end
;
463 u8
*orig_str
= *str_ptr
;
465 if (!strncmp(*str_ptr
, token
, strlen(token
))) {
466 strsep(str_ptr
, "=,");
467 param_str_begin
= *str_ptr
;
468 strsep(str_ptr
, "=,");
469 if (*str_ptr
== NULL
) {
470 param_str_len
= strlen(param_str_begin
);
472 param_str_end
= *str_ptr
-1;
473 param_str_len
= param_str_end
- param_str_begin
;
475 unifi_trace(priv
, UDBG2
, "'token:%s', len:%d, ", token
, param_str_len
);
476 if (param_str_len
> param_max_len
) {
477 unifi_notice(priv
, "extracted param len:%d is > MAX:%d\n", param_str_len
, param_max_len
);
478 param_str_len
= param_max_len
;
480 switch (param_type
) {
483 u32
*pdst_int
= dst
, num
=0;
485 if (param_str_len
> sizeof(int_str
)) {
486 param_str_len
= sizeof(int_str
);
488 memcpy(int_str
, param_str_begin
, param_str_len
);
489 for(i
= param_str_len
; i
>0;i
--) {
490 if(int_str
[i
-1] >= '0' && int_str
[i
-1] <='9') {
491 num
+= ((int_str
[i
-1]-'0')*power(10, j
));
494 unifi_error(priv
, "decode_parameter_from_string:not a number %c\n", (int_str
[i
-1]));
499 unifi_trace(priv
, UDBG2
, "decode_parameter_from_string:decoded int = %d\n", *pdst_int
);
503 memcpy(dst
, param_str_begin
, param_str_len
);
504 *((char *)dst
+ param_str_len
) = 0;
505 unifi_trace(priv
, UDBG2
, "decode_parameter_from_string:decoded string = %s\n", (char *)dst
);
509 unifi_error(priv
, "decode_parameter_from_string: Token:%s not found in %s \n", token
, orig_str
);
514 static int store_ap_advanced_config_from_string(unifi_priv_t
*priv
, char *param_str
)
516 char * str_ptr
=param_str
;
517 int ret
= 0, tmp_var
;
519 CsrWifiSmeApMacConfig
* ap_mac_config
= &priv
->ap_mac_config
;
522 ret
= decode_parameter_from_string(priv
, &str_ptr
, "BI=",
523 PARAM_TYPE_INT
, &tmp_var
, 5);
525 unifi_error(priv
, "store_ap_advanced_config_from_string: BI not found\n");
528 ap_mac_config
->beaconInterval
= tmp_var
;
529 ret
= decode_parameter_from_string(priv
, &str_ptr
, "DTIM_PER=",
530 PARAM_TYPE_INT
, &tmp_var
, 5);
532 unifi_error(priv
, "store_ap_advanced_config_from_string: DTIM_PER not found\n");
535 ap_mac_config
->dtimPeriod
= tmp_var
;
536 ret
= decode_parameter_from_string(priv
, &str_ptr
, "WMM=",
537 PARAM_TYPE_INT
, &tmp_var
, 5);
539 unifi_error(priv
, "store_ap_advanced_config_from_string: WMM not found\n");
542 ap_mac_config
->wmmEnabled
= tmp_var
;
543 ret
= decode_parameter_from_string(priv
, &str_ptr
, "PHY=",
544 PARAM_TYPE_STRING
, phy_mode
, 5);
546 unifi_error(priv
, "store_ap_advanced_config_from_string: PHY not found\n");
548 if(strstr(phy_mode
, "b")){
549 ap_mac_config
->phySupportedBitmap
= CSR_WIFI_SME_AP_PHY_SUPPORT_B
;
551 if(strstr(phy_mode
, "g")) {
552 ap_mac_config
->phySupportedBitmap
|= CSR_WIFI_SME_AP_PHY_SUPPORT_G
;
554 if(strstr(phy_mode
, "n")) {
555 ap_mac_config
->phySupportedBitmap
|= CSR_WIFI_SME_AP_PHY_SUPPORT_N
;
557 ap_mac_config
->supportedRatesCount
=
558 uf_configure_supported_rates(ap_mac_config
->supportedRates
, ap_mac_config
->phySupportedBitmap
);
563 static int store_ap_config_from_string( unifi_priv_t
* priv
, char *param_str
)
566 char *str_ptr
= param_str
;
568 char sec
[CSR_WIFI_MAX_SEC_LEN
];
569 char key
[CSR_WIFI_MAX_KEY_LEN
];
570 int ret
= 0, tmp_var
;
571 CsrWifiSmeApConfig_t
*ap_config
= &priv
->ap_config
;
572 CsrWifiSmeApMacConfig
* ap_mac_config
= &priv
->ap_mac_config
;
573 memset(sub_cmd
, 0, sizeof(sub_cmd
));
574 if(!strstr(param_str
, "END")) {
575 unifi_error(priv
, "store_ap_config_from_string:Invalid config string:%s\n", param_str
);
578 if (decode_parameter_from_string(priv
, &str_ptr
, "ASCII_CMD=",
579 PARAM_TYPE_STRING
, sub_cmd
, 6) != 0) {
582 if (strncmp(sub_cmd
, "AP_CFG", 6)) {
584 if(!strncmp(sub_cmd
, "ADVCFG", 6)) {
585 return store_ap_advanced_config_from_string(priv
, str_ptr
);
587 unifi_error(priv
, "store_ap_config_from_string: sub_cmd:%s != 'AP_CFG or ADVCFG'!\n", sub_cmd
);
590 memset(ap_config
, 0, sizeof(CsrWifiSmeApConfig_t
));
591 ret
= decode_parameter_from_string(priv
, &str_ptr
, "SSID=",
592 PARAM_TYPE_STRING
, ap_config
->ssid
.ssid
,
593 CSR_WIFI_MAX_SSID_LEN
);
595 unifi_error(priv
, "store_ap_config_from_string: SSID not found\n");
598 ap_config
->ssid
.length
= strlen(ap_config
->ssid
.ssid
);
600 ret
= decode_parameter_from_string(priv
, &str_ptr
, "SEC=",
601 PARAM_TYPE_STRING
, sec
, CSR_WIFI_MAX_SEC_LEN
);
603 unifi_error(priv
, "store_ap_config_from_string: SEC not found\n");
606 ret
= decode_parameter_from_string(priv
, &str_ptr
, "KEY=",
607 PARAM_TYPE_STRING
, key
, CSR_WIFI_MAX_KEY_LEN
);
608 if(!strcasecmp(sec
, "open")) {
609 unifi_trace(priv
, UDBG2
, "store_ap_config_from_string: security open");
610 ap_config
->credentials
.authType
= CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM
;
612 unifi_notice(priv
, "store_ap_config_from_string: KEY not found:fine with Open\n");
615 else if(!strcasecmp(sec
, "wpa2-psk")) {
617 CsrWifiNmeApAuthPers
*pers
=
618 ((CsrWifiNmeApAuthPers
*)&(ap_config
->credentials
.nmeAuthType
.authTypePersonal
));
619 u8
*psk
= pers
->authPers_credentials
.psk
.psk
;
621 unifi_trace(priv
, UDBG2
, "store_ap_config_from_string: security WPA2");
623 unifi_error(priv
, "store_ap_config_from_string: KEY not found for WPA2\n");
626 ap_config
->credentials
.authType
= CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL
;
627 pers
->authSupport
= CSR_WIFI_SME_RSN_AUTH_WPA2PSK
;
628 pers
->rsnCapabilities
=0;
629 pers
->wapiCapabilities
=0;
630 pers
->pskOrPassphrase
=CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK
;
631 pers
->authPers_credentials
.psk
.encryptionMode
=
632 (CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP
|CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP
) ;
634 psk
[i
] = (16*hex_look_up(key
[j
]))+hex_look_up(key
[j
+1]);
639 unifi_notice(priv
, "store_ap_config_from_string: Unknown security: Assuming Open");
640 ap_config
->credentials
.authType
= CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM
;
643 /* Get the decoded value in a temp int variable to ensure that other fields within the struct
644 which are of type other than int are not over written */
645 ret
= decode_parameter_from_string(priv
, &str_ptr
, "CHANNEL=", PARAM_TYPE_INT
, &tmp_var
, 5);
648 ap_config
->channel
= tmp_var
;
649 ret
= decode_parameter_from_string(priv
, &str_ptr
, "PREAMBLE=", PARAM_TYPE_INT
, &tmp_var
, 5);
652 ap_mac_config
->preamble
= tmp_var
;
653 ret
= decode_parameter_from_string(priv
, &str_ptr
, "MAX_SCB=", PARAM_TYPE_INT
, &tmp_var
, 5);
654 ap_config
->max_connections
= tmp_var
;
659 iwprivsapstart(struct net_device
*dev
, struct iw_request_info
*info
,
660 union iwreq_data
*wrqu
, char *extra
)
662 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
663 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
666 unifi_trace(priv
, UDBG1
, "iwprivsapstart\n" );
667 r
= sme_ap_start(priv
, interfacePriv
->InterfaceTag
, &priv
->ap_config
);
669 unifi_error(priv
, "iwprivsapstart AP START failed : %d\n", -r
);
675 iwprivsapconfig(struct net_device
*dev
, struct iw_request_info
*info
,
676 union iwreq_data
*wrqu
, char *extra
)
678 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
679 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
680 char *cfg_str
= NULL
;
683 unifi_trace(priv
, UDBG1
, "iwprivsapconfig\n" );
684 if (wrqu
->data
.length
!= 0) {
686 if (!(cfg_str
= kmalloc(wrqu
->data
.length
+1, GFP_KERNEL
)))
690 if (copy_from_user(cfg_str
, wrqu
->data
.pointer
, wrqu
->data
.length
)) {
694 cfg_str
[wrqu
->data
.length
] = 0;
695 unifi_trace(priv
, UDBG2
, "length:%d\n", wrqu
->data
.length
);
696 unifi_trace(priv
, UDBG2
, "AP configuration string:%s\n", cfg_str
);
698 if ((r
= store_ap_config_from_string(priv
, str
))) {
699 unifi_error(priv
, "iwprivsapconfig:Failed to decode the string %d\n", r
);
705 unifi_error(priv
, "iwprivsapconfig argument length = 0 \n");
708 r
= sme_ap_config(priv
, &priv
->ap_mac_config
, &priv
->group_sec_config
);
710 unifi_error(priv
, "iwprivsapstop AP Config failed : %d\n", -r
);
711 } else if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
712 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
713 unifi_trace(priv
, UDBG1
, "iwprivsapconfig: Starting the AP");
714 r
= sme_ap_start(priv
, interfacePriv
->InterfaceTag
, &priv
->ap_config
);
716 unifi_error(priv
, "iwprivsapstart AP START failed : %d\n", -r
);
724 iwprivsapstop(struct net_device
*dev
, struct iw_request_info
*info
,
725 union iwreq_data
*wrqu
, char *extra
)
727 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
728 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
730 u16 interface_tag
= interfacePriv
->InterfaceTag
;
732 unifi_trace(priv
, UDBG1
, "iwprivsapstop\n" );
733 r
= sme_ap_stop(priv
, interface_tag
);
735 unifi_error(priv
, "iwprivsapstop AP STOP failed : %d\n", -r
);
742 iwprivsapfwreload(struct net_device
*dev
, struct iw_request_info
*info
,
743 union iwreq_data
*wrqu
, char *extra
)
745 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
746 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
748 unifi_trace(priv
, UDBG1
, "iwprivsapfwreload\n" );
753 iwprivsstackstart(struct net_device
*dev
, struct iw_request_info
*info
,
754 union iwreq_data
*wrqu
, char *extra
)
756 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
757 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
758 unifi_trace(priv
, UDBG1
, "iwprivsstackstart\n" );
763 iwprivsstackstop(struct net_device
*dev
, struct iw_request_info
*info
,
764 union iwreq_data
*wrqu
, char *extra
)
766 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
767 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
769 u16 interface_tag
= interfacePriv
->InterfaceTag
;
771 unifi_trace(priv
, UDBG1
, "iwprivsstackstop\n" );
773 switch(interfacePriv
->interfaceMode
) {
774 case CSR_WIFI_ROUTER_CTRL_MODE_STA
:
775 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI
:
776 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS
:
777 r
= sme_mgt_disconnect(priv
);
779 case CSR_WIFI_ROUTER_CTRL_MODE_AP
:
780 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
:
781 r
= sme_ap_stop(priv
, interface_tag
);
788 unifi_error(priv
, "iwprivsstackstop Stack stop failed : %d\n", -r
);
792 #endif /* ANDROID_BUILD */
793 #endif /* CSR_SUPPORT_WEXT_AP */
795 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
797 iwprivsconfwapi(struct net_device
*dev
, struct iw_request_info
*info
,
798 union iwreq_data
*wrqu
, char *extra
)
801 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
802 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
804 unifi_trace(priv
, UDBG1
, "iwprivsconfwapi\n" );
806 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
807 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
808 unifi_error(priv
, "iwprivsconfwapi: not permitted in Mode %d\n",
809 interfacePriv
->interfaceMode
);
813 enable
= *(u8
*)(extra
);
816 priv
->connection_config
.authModeMask
= CSR_WIFI_SME_AUTH_MODE_80211_OPEN
;
817 priv
->connection_config
.authModeMask
|= (CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK
| CSR_WIFI_SME_AUTH_MODE_WAPI_WAI
);
818 priv
->connection_config
.encryptionModeMask
|=
819 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4
| CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4
;
821 priv
->connection_config
.authModeMask
&= ~(CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK
| CSR_WIFI_SME_AUTH_MODE_WAPI_WAI
);
822 priv
->connection_config
.encryptionModeMask
&=
823 ~(CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4
| CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4
);
830 iwprivswpikey(struct net_device
*dev
, struct iw_request_info
*info
,
831 union iwreq_data
*wrqu
, char *extra
)
835 unifiio_wapi_key_t inKey
;
836 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
837 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
839 unifi_trace(priv
, UDBG1
, "iwprivswpikey\n" );
841 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
842 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
843 unifi_error(priv
, "iwprivswpikey: not permitted in Mode %d\n",
844 interfacePriv
->interfaceMode
);
848 inKey
= *(unifiio_wapi_key_t
*)(extra
);
850 if (inKey
.unicastKey
) {
851 key
.keyType
= CSR_WIFI_SME_KEY_TYPE_PAIRWISE
;
853 key
.keyType
= CSR_WIFI_SME_KEY_TYPE_GROUP
;
856 key
.keyIndex
= inKey
.keyIndex
;
858 /* memcpy(key.keyRsc, inKey.keyRsc, 16); */
859 for (i
= 0; i
< 16; i
+= 2)
861 key
.keyRsc
[i
/2] = inKey
.keyRsc
[i
+1] << 8 | inKey
.keyRsc
[i
];
864 memcpy(key
.address
.a
, inKey
.address
, 6);
866 memcpy(key
.key
, inKey
.key
, 32);
867 key
.authenticator
= 0;
870 unifi_trace(priv
, UDBG1
, "keyType = %d, keyIndex = %d, wepTxKey = %d, keyRsc = %x:%x, auth = %d, address = %x:%x, "
871 "keylength = %d, key = %x:%x\n", key
.keyType
, key
.keyIndex
, key
.wepTxKey
,
872 key
.keyRsc
[0], key
.keyRsc
[7], key
.authenticator
,
873 key
.address
.a
[0], key
.address
.a
[5], key
.keyLength
, key
.key
[0],
876 r
= sme_mgt_key(priv
, &key
, CSR_WIFI_SME_LIST_ACTION_ADD
);
878 unifi_error(priv
, "SETKEYS request was rejected with result %d\n", r
);
879 return convert_sme_error(r
);
888 unifi_giwname(struct net_device
*dev
, struct iw_request_info
*info
,
889 union iwreq_data
*wrqu
, char *extra
)
891 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
892 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
893 char *name
= wrqu
->name
;
894 unifi_trace(priv
, UDBG2
, "unifi_giwname\n");
896 if (priv
->if_index
== CSR_INDEX_5G
) {
897 strcpy(name
, "IEEE 802.11-a");
899 strcpy(name
, "IEEE 802.11-bgn");
902 } /* unifi_giwname() */
906 unifi_siwfreq(struct net_device
*dev
, struct iw_request_info
*info
,
907 union iwreq_data
*wrqu
, char *extra
)
909 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
910 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
911 struct iw_freq
*freq
= (struct iw_freq
*)wrqu
;
913 unifi_trace(priv
, UDBG2
, "unifi_siwfreq\n");
915 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
916 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
917 unifi_error(priv
, "unifi_siwfreq: not permitted in Mode %d\n",
918 interfacePriv
->interfaceMode
);
924 * Channel is stored in the connection configuration,
925 * and set later when ask for a connection.
927 if ((freq
->e
== 0) && (freq
->m
<= 1000)) {
928 priv
->connection_config
.adhocChannel
= freq
->m
;
930 priv
->connection_config
.adhocChannel
= wext_freq_to_channel(freq
->m
, freq
->e
);
934 } /* unifi_siwfreq() */
938 unifi_giwfreq(struct net_device
*dev
, struct iw_request_info
*info
,
939 union iwreq_data
*wrqu
, char *extra
)
941 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
942 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
943 struct iw_freq
*freq
= (struct iw_freq
*)wrqu
;
945 CsrWifiSmeConnectionInfo connectionInfo
;
947 unifi_trace(priv
, UDBG2
, "unifi_giwfreq\n");
950 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
951 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
952 unifi_error(priv
, "unifi_giwfreq: not permitted in Mode %d\n",
953 interfacePriv
->interfaceMode
);
959 err
= sme_mgt_connection_info_get(priv
, &connectionInfo
);
962 freq
->m
= channel_to_mhz(connectionInfo
.channelNumber
,
963 (connectionInfo
.networkType80211
== CSR_WIFI_SME_RADIO_IF_GHZ_5_0
));
966 return convert_sme_error(err
);
967 } /* unifi_giwfreq() */
971 unifi_siwmode(struct net_device
*dev
, struct iw_request_info
*info
,
972 union iwreq_data
*wrqu
, char *extra
)
974 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
975 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
977 unifi_trace(priv
, UDBG2
, "unifi_siwmode\n");
979 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
980 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
981 unifi_error(priv
, "unifi_siwmode: not permitted in Mode %d\n",
982 interfacePriv
->interfaceMode
);
989 priv
->connection_config
.bssType
= CSR_WIFI_SME_BSS_TYPE_ADHOC
;
992 priv
->connection_config
.bssType
= CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE
;
995 priv
->connection_config
.bssType
= CSR_WIFI_SME_BSS_TYPE_ANY_BSS
;
998 unifi_notice(priv
, "Unknown IW MODE value.\n");
1001 /* Clear the SSID and BSSID configuration */
1002 priv
->connection_config
.ssid
.length
= 0;
1003 memset(priv
->connection_config
.bssid
.a
, 0xFF, ETH_ALEN
);
1006 } /* unifi_siwmode() */
1011 unifi_giwmode(struct net_device
*dev
, struct iw_request_info
*info
,
1012 union iwreq_data
*wrqu
, char *extra
)
1015 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1016 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1017 CsrWifiSmeConnectionConfig connectionConfig
;
1019 unifi_trace(priv
, UDBG2
, "unifi_giwmode\n");
1022 unifi_trace(priv
, UDBG2
, "unifi_giwmode: Exisitng mode = 0x%x\n",
1023 interfacePriv
->interfaceMode
);
1024 switch(interfacePriv
->interfaceMode
) {
1025 case CSR_WIFI_ROUTER_CTRL_MODE_STA
:
1026 case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI
:
1027 wrqu
->mode
= IW_MODE_INFRA
;
1029 case CSR_WIFI_ROUTER_CTRL_MODE_AP
:
1030 case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
:
1031 wrqu
->mode
= IW_MODE_MASTER
;
1033 case CSR_WIFI_ROUTER_CTRL_MODE_IBSS
:
1034 wrqu
->mode
= IW_MODE_ADHOC
;
1036 case CSR_WIFI_ROUTER_CTRL_MODE_P2P
:
1037 case CSR_WIFI_ROUTER_CTRL_MODE_NONE
:
1039 r
= sme_mgt_connection_config_get(priv
, &connectionConfig
);
1042 switch(connectionConfig
.bssType
) {
1043 case CSR_WIFI_SME_BSS_TYPE_ADHOC
:
1044 wrqu
->mode
= IW_MODE_ADHOC
;
1046 case CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE
:
1047 wrqu
->mode
= IW_MODE_INFRA
;
1050 wrqu
->mode
= IW_MODE_AUTO
;
1051 unifi_notice(priv
, "Unknown IW MODE value.\n");
1056 wrqu
->mode
= IW_MODE_AUTO
;
1057 unifi_notice(priv
, "Unknown IW MODE value.\n");
1060 unifi_trace(priv
, UDBG4
, "unifi_giwmode: mode = 0x%x\n", wrqu
->mode
);
1062 } /* unifi_giwmode() */
1067 unifi_giwrange(struct net_device
*dev
, struct iw_request_info
*info
,
1068 union iwreq_data
*wrqu
, char *extra
)
1070 struct iw_point
*dwrq
= &wrqu
->data
;
1071 struct iw_range
*range
= (struct iw_range
*) extra
;
1074 unifi_trace(NULL
, UDBG2
, "unifi_giwrange\n");
1076 dwrq
->length
= sizeof(struct iw_range
);
1077 memset(range
, 0, sizeof(*range
));
1078 range
->min_nwid
= 0x0000;
1079 range
->max_nwid
= 0x0000;
1082 * Don't report the frequency/channel table, then the channel
1083 * number returned elsewhere will be printed as a channel number.
1086 /* Ranges of values reported in quality structs */
1087 range
->max_qual
.qual
= 40; /* Max expected qual value */
1088 range
->max_qual
.level
= -120; /* Noise floor in dBm */
1089 range
->max_qual
.noise
= -120; /* Noise floor in dBm */
1092 /* space for IW_MAX_BITRATES (8 up to WE15, 32 later) */
1094 #if WIRELESS_EXT > 15
1095 range
->bitrate
[i
++] = 2 * 500000;
1096 range
->bitrate
[i
++] = 4 * 500000;
1097 range
->bitrate
[i
++] = 11 * 500000;
1098 range
->bitrate
[i
++] = 22 * 500000;
1099 range
->bitrate
[i
++] = 12 * 500000;
1100 range
->bitrate
[i
++] = 18 * 500000;
1101 range
->bitrate
[i
++] = 24 * 500000;
1102 range
->bitrate
[i
++] = 36 * 500000;
1103 range
->bitrate
[i
++] = 48 * 500000;
1104 range
->bitrate
[i
++] = 72 * 500000;
1105 range
->bitrate
[i
++] = 96 * 500000;
1106 range
->bitrate
[i
++] = 108 * 500000;
1108 range
->bitrate
[i
++] = 2 * 500000;
1109 range
->bitrate
[i
++] = 4 * 500000;
1110 range
->bitrate
[i
++] = 11 * 500000;
1111 range
->bitrate
[i
++] = 22 * 500000;
1112 range
->bitrate
[i
++] = 24 * 500000;
1113 range
->bitrate
[i
++] = 48 * 500000;
1114 range
->bitrate
[i
++] = 96 * 500000;
1115 range
->bitrate
[i
++] = 108 * 500000;
1116 #endif /* WIRELESS_EXT < 16 */
1117 range
->num_bitrates
= i
;
1119 range
->max_encoding_tokens
= NUM_WEPKEYS
;
1120 range
->num_encoding_sizes
= 2;
1121 range
->encoding_size
[0] = 5;
1122 range
->encoding_size
[1] = 13;
1124 range
->we_version_source
= 20;
1125 range
->we_version_compiled
= WIRELESS_EXT
;
1127 /* Number of channels available in h/w */
1128 range
->num_channels
= 14;
1129 /* Number of entries in freq[] array */
1130 range
->num_frequency
= 14;
1131 for (i
= 0; (i
< range
->num_frequency
) && (i
< IW_MAX_FREQUENCIES
); i
++) {
1133 range
->freq
[i
].i
= chan
;
1134 range
->freq
[i
].m
= channel_to_mhz(chan
, 0);
1135 range
->freq
[i
].e
= 6;
1137 if ((i
+3) < IW_MAX_FREQUENCIES
) {
1138 range
->freq
[i
].i
= 36;
1139 range
->freq
[i
].m
= channel_to_mhz(36, 1);
1140 range
->freq
[i
].e
= 6;
1141 range
->freq
[i
+1].i
= 40;
1142 range
->freq
[i
+1].m
= channel_to_mhz(40, 1);
1143 range
->freq
[i
+1].e
= 6;
1144 range
->freq
[i
+2].i
= 44;
1145 range
->freq
[i
+2].m
= channel_to_mhz(44, 1);
1146 range
->freq
[i
+2].e
= 6;
1147 range
->freq
[i
+3].i
= 48;
1148 range
->freq
[i
+3].m
= channel_to_mhz(48, 1);
1149 range
->freq
[i
+3].e
= 6;
1152 #if WIRELESS_EXT > 16
1153 /* Event capability (kernel + driver) */
1154 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
1155 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY
) |
1156 IW_EVENT_CAPA_MASK(SIOCGIWAP
) |
1157 IW_EVENT_CAPA_MASK(SIOCGIWSCAN
));
1158 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
1159 range
->event_capa
[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP
) |
1160 IW_EVENT_CAPA_MASK(IWEVCUSTOM
) |
1161 IW_EVENT_CAPA_MASK(IWEVREGISTERED
) |
1162 IW_EVENT_CAPA_MASK(IWEVEXPIRED
));
1163 #endif /* WIRELESS_EXT > 16 */
1165 #if WIRELESS_EXT > 17
1166 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
1167 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
1168 #endif /* WIRELESS_EXT > 17 */
1172 } /* unifi_giwrange() */
1176 unifi_siwap(struct net_device
*dev
, struct iw_request_info
*info
,
1177 union iwreq_data
*wrqu
, char *extra
)
1179 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1180 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1185 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
1186 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
1187 unifi_error(priv
, "unifi_siwap: not permitted in Mode %d\n",
1188 interfacePriv
->interfaceMode
);
1193 if (wrqu
->ap_addr
.sa_family
!= ARPHRD_ETHER
) {
1197 unifi_trace(priv
, UDBG1
, "unifi_siwap: asked for %pM\n",
1198 wrqu
->ap_addr
.sa_data
);
1200 if (is_zero_ether_addr(wrqu
->ap_addr
.sa_data
)) {
1201 priv
->ignore_bssid_join
= FALSE
;
1202 err
= sme_mgt_disconnect(priv
);
1204 unifi_trace(priv
, UDBG4
, "unifi_siwap: Disconnect failed, status %d\n", err
);
1209 if (priv
->ignore_bssid_join
) {
1210 unifi_trace(priv
, UDBG4
, "unifi_siwap: ignoring second join\n");
1211 priv
->ignore_bssid_join
= FALSE
;
1213 memcpy(priv
->connection_config
.bssid
.a
, wrqu
->ap_addr
.sa_data
, ETH_ALEN
);
1214 unifi_trace(priv
, UDBG1
, "unifi_siwap: Joining %X:%X:%X:%X:%X:%X\n",
1215 priv
->connection_config
.bssid
.a
[0],
1216 priv
->connection_config
.bssid
.a
[1],
1217 priv
->connection_config
.bssid
.a
[2],
1218 priv
->connection_config
.bssid
.a
[3],
1219 priv
->connection_config
.bssid
.a
[4],
1220 priv
->connection_config
.bssid
.a
[5]);
1221 err
= sme_mgt_connect(priv
);
1223 unifi_error(priv
, "unifi_siwap: Join failed, status %d\n", err
);
1224 return convert_sme_error(err
);
1229 } /* unifi_siwap() */
1233 unifi_giwap(struct net_device
*dev
, struct iw_request_info
*info
,
1234 union iwreq_data
*wrqu
, char *extra
)
1236 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1237 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1238 CsrWifiSmeConnectionInfo connectionInfo
;
1243 unifi_trace(priv
, UDBG2
, "unifi_giwap\n");
1245 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
1246 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
1247 unifi_error(priv
, "iwprivswpikey: not permitted in Mode %d\n",
1248 interfacePriv
->interfaceMode
);
1253 r
= sme_mgt_connection_info_get(priv
, &connectionInfo
);
1257 bssid
= connectionInfo
.bssid
.a
;
1258 wrqu
->ap_addr
.sa_family
= ARPHRD_ETHER
;
1259 unifi_trace(priv
, UDBG4
, "unifi_giwap: BSSID = %pM\n", bssid
);
1261 memcpy(wrqu
->ap_addr
.sa_data
, bssid
, ETH_ALEN
);
1263 memset(wrqu
->ap_addr
.sa_data
, 0, ETH_ALEN
);
1267 } /* unifi_giwap() */
1271 unifi_siwscan(struct net_device
*dev
, struct iw_request_info
*info
,
1272 union iwreq_data
*wrqu
, char *extra
)
1274 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1275 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1277 CsrWifiSsid scan_ssid
;
1278 unsigned char *channel_list
= NULL
;
1280 #if WIRELESS_EXT > 17
1281 struct iw_point
*data
= &wrqu
->data
;
1282 struct iw_scan_req
*req
= (struct iw_scan_req
*) extra
;
1287 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
1288 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
1289 unifi_error(priv
, "unifi_siwscan: not permitted in Mode %d\n",
1290 interfacePriv
->interfaceMode
);
1295 #if WIRELESS_EXT > 17
1296 /* Providing a valid channel list will force an active scan */
1298 if ((req
->num_channels
> 0) && (req
->num_channels
< IW_MAX_FREQUENCIES
)) {
1299 channel_list
= kmalloc(req
->num_channels
, GFP_KERNEL
);
1302 for (i
= 0; i
< req
->num_channels
; i
++) {
1303 /* Convert frequency to channel number */
1304 int ch
= wext_freq_to_channel(req
->channel_list
[i
].m
,
1305 req
->channel_list
[i
].e
);
1307 channel_list
[chans_good
++] = ch
;
1310 unifi_trace(priv
, UDBG1
,
1311 "SIWSCAN: Scanning %d channels\n", chans_good
);
1313 /* Fall back to scanning all */
1314 unifi_error(priv
, "SIWSCAN: Can't alloc channel_list (%d)\n",
1320 if (req
&& (data
->flags
& IW_SCAN_THIS_ESSID
)) {
1321 memcpy(scan_ssid
.ssid
, req
->essid
, req
->essid_len
);
1322 scan_ssid
.length
= req
->essid_len
;
1323 unifi_trace(priv
, UDBG1
,
1324 "SIWSCAN: Scanning for %.*s\n",
1325 scan_ssid
.length
, scan_ssid
.ssid
);
1329 unifi_trace(priv
, UDBG1
, "SIWSCAN: Scanning for all APs\n");
1330 scan_ssid
.length
= 0;
1333 r
= sme_mgt_scan_full(priv
, &scan_ssid
, chans_good
, channel_list
);
1335 unifi_error(priv
, "SIWSCAN: Scan returned error %d\n", r
);
1337 unifi_trace(priv
, UDBG1
, "SIWSCAN: Scan done\n");
1338 wext_send_scan_results_event(priv
);
1342 kfree(channel_list
);
1347 } /* unifi_siwscan() */
1350 static const unsigned char *
1351 unifi_find_info_element(int id
, const unsigned char *info
, int len
)
1353 const unsigned char *ie
= info
;
1361 /* Return if we find a match */
1372 } /* unifi_find_info_element() */
1376 * Translate scan data returned from the card to a card independent
1377 * format that the Wireless Tools will understand - Jean II
1380 unifi_translate_scan(struct net_device
*dev
,
1381 struct iw_request_info
*info
,
1382 char *current_ev
, char *end_buf
,
1383 CsrWifiSmeScanResult
*scan_data
,
1386 struct iw_event iwe
; /* Temporary buffer */
1387 unsigned char *info_elems
;
1389 const unsigned char *elem
;
1391 int signal
, noise
, snr
;
1392 char *start_buf
= current_ev
;
1393 char *current_val
; /* For rates */
1396 info_elems
= scan_data
->informationElements
;
1397 info_elem_len
= scan_data
->informationElementsLength
;
1399 if (!scan_data
->informationElementsLength
|| !scan_data
->informationElements
) {
1400 unifi_error(NULL
, "*** NULL SCAN IEs ***\n");
1404 /* get capinfo bits */
1405 capabilities
= scan_data
->capabilityInformation
;
1407 unifi_trace(NULL
, UDBG5
, "Capabilities: 0x%x\n", capabilities
);
1409 /* First entry *MUST* be the AP MAC address */
1410 memset(&iwe
, 0, sizeof(iwe
));
1411 iwe
.cmd
= SIOCGIWAP
;
1412 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1413 memcpy(iwe
.u
.ap_addr
.sa_data
, scan_data
->bssid
.a
, ETH_ALEN
);
1414 iwe
.len
= IW_EV_ADDR_LEN
;
1415 r
= uf_iwe_stream_add_event(info
, start_buf
, end_buf
, &iwe
, IW_EV_ADDR_LEN
);
1421 /* Other entries will be displayed in the order we give them */
1424 /* find SSID in Info Elems */
1425 elem
= unifi_find_info_element(IE_SSID_ID
, info_elems
, info_elem_len
);
1427 int e_len
= elem
[1];
1428 const unsigned char *e_ptr
= elem
+ 2;
1429 unsigned char buf
[33];
1431 memset(&iwe
, 0, sizeof(iwe
));
1432 iwe
.cmd
= SIOCGIWESSID
;
1433 iwe
.u
.essid
.length
= e_len
;
1434 if (iwe
.u
.essid
.length
> 32) {
1435 iwe
.u
.essid
.length
= 32;
1437 iwe
.u
.essid
.flags
= scan_index
;
1438 memcpy(buf
, e_ptr
, iwe
.u
.essid
.length
);
1439 buf
[iwe
.u
.essid
.length
] = '\0';
1440 r
= uf_iwe_stream_add_point(info
, start_buf
, end_buf
, &iwe
, buf
);
1449 memset(&iwe
, 0, sizeof(iwe
));
1450 iwe
.cmd
= SIOCGIWMODE
;
1451 if (scan_data
->bssType
== CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE
) {
1452 iwe
.u
.mode
= IW_MODE_INFRA
;
1454 iwe
.u
.mode
= IW_MODE_ADHOC
;
1456 iwe
.len
= IW_EV_UINT_LEN
;
1457 r
= uf_iwe_stream_add_event(info
, start_buf
, end_buf
, &iwe
, IW_EV_UINT_LEN
);
1463 /* Add frequency. iwlist will convert to channel using table given in giwrange */
1464 memset(&iwe
, 0, sizeof(iwe
));
1465 iwe
.cmd
= SIOCGIWFREQ
;
1466 iwe
.u
.freq
.m
= scan_data
->channelFrequency
;
1468 r
= uf_iwe_stream_add_event(info
, start_buf
, end_buf
, &iwe
, IW_EV_FREQ_LEN
);
1475 /* Add quality statistics */
1478 * level and noise below are mapped into an unsigned 8 bit number,
1479 * ranging from [-192; 63]. The way this is achieved is simply to
1480 * add 0x100 onto the number if it is negative,
1481 * once clipped to the correct range.
1483 signal
= scan_data
->rssi
; /* This value is in dBm */
1484 /* Clip range of snr */
1485 snr
= (scan_data
->snr
> 0) ? scan_data
->snr
: 0; /* In dB relative, from 0 - 255 */
1486 snr
= (snr
< 255) ? snr
: 255;
1487 noise
= signal
- snr
;
1489 /* Clip range of signal */
1490 signal
= (signal
< 63) ? signal
: 63;
1491 signal
= (signal
> -192) ? signal
: -192;
1493 /* Clip range of noise */
1494 noise
= (noise
< 63) ? noise
: 63;
1495 noise
= (noise
> -192) ? noise
: -192;
1498 signal
= ( signal
< 0 ) ? signal
+ 0x100 : signal
;
1499 noise
= ( noise
< 0 ) ? noise
+ 0x100 : noise
;
1501 iwe
.u
.qual
.level
= (u8
)signal
; /* -192 : 63 */
1502 iwe
.u
.qual
.noise
= (u8
)noise
; /* -192 : 63 */
1503 iwe
.u
.qual
.qual
= snr
; /* 0 : 255 */
1504 iwe
.u
.qual
.updated
= 0;
1505 #if WIRELESS_EXT > 16
1506 iwe
.u
.qual
.updated
|= IW_QUAL_LEVEL_UPDATED
| IW_QUAL_NOISE_UPDATED
|
1507 IW_QUAL_QUAL_UPDATED
;
1508 #if WIRELESS_EXT > 18
1509 iwe
.u
.qual
.updated
|= IW_QUAL_DBM
;
1512 r
= uf_iwe_stream_add_event(info
, start_buf
, end_buf
, &iwe
, IW_EV_QUAL_LEN
);
1518 /* Add encryption capability */
1519 iwe
.cmd
= SIOCGIWENCODE
;
1520 if (capabilities
& SIG_CAP_PRIVACY
) {
1521 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
1523 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
1525 iwe
.u
.data
.length
= 0;
1526 iwe
.len
= IW_EV_POINT_LEN
+ iwe
.u
.data
.length
;
1527 r
= uf_iwe_stream_add_point(info
, start_buf
, end_buf
, &iwe
, "");
1535 * Rate : stuffing multiple values in a single event require a bit
1536 * more of magic - Jean II
1538 current_val
= start_buf
+ IW_EV_LCP_LEN
;
1540 iwe
.cmd
= SIOCGIWRATE
;
1541 /* Those two flags are ignored... */
1542 iwe
.u
.bitrate
.fixed
= iwe
.u
.bitrate
.disabled
= 0;
1544 elem
= unifi_find_info_element(IE_SUPPORTED_RATES_ID
,
1545 info_elems
, info_elem_len
);
1547 int e_len
= elem
[1];
1548 const unsigned char *e_ptr
= elem
+ 2;
1551 * Count how many rates we have.
1552 * Zero marks the end of the list, if the list is not truncated.
1555 for (i
= 0; i
< e_len
; i
++) {
1556 if (e_ptr
[i
] == 0) {
1559 /* Bit rate given in 500 kb/s units (+ 0x80) */
1560 iwe
.u
.bitrate
.value
= ((e_ptr
[i
] & 0x7f) * 500000);
1561 /* Add new value to event */
1562 r
= uf_iwe_stream_add_value(info
, start_buf
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
1570 elem
= unifi_find_info_element(IE_EXTENDED_SUPPORTED_RATES_ID
,
1571 info_elems
, info_elem_len
);
1573 int e_len
= elem
[1];
1574 const unsigned char *e_ptr
= elem
+ 2;
1577 * Count how many rates we have.
1578 * Zero marks the end of the list, if the list is not truncated.
1581 for (i
= 0; i
< e_len
; i
++) {
1582 if (e_ptr
[i
] == 0) {
1585 /* Bit rate given in 500 kb/s units (+ 0x80) */
1586 iwe
.u
.bitrate
.value
= ((e_ptr
[i
] & 0x7f) * 500000);
1587 /* Add new value to event */
1588 r
= uf_iwe_stream_add_value(info
, start_buf
, current_val
, end_buf
, &iwe
, IW_EV_PARAM_LEN
);
1595 /* Check if we added any rates event */
1596 if ((current_val
- start_buf
) > IW_EV_LCP_LEN
) {
1597 start_buf
= current_val
;
1601 #if WIRELESS_EXT > 17
1602 memset(&iwe
, 0, sizeof(iwe
));
1603 iwe
.cmd
= IWEVGENIE
;
1604 iwe
.u
.data
.length
= info_elem_len
;
1606 r
= uf_iwe_stream_add_point(info
, start_buf
, end_buf
, &iwe
, info_elems
);
1612 #endif /* WE > 17 */
1614 return (start_buf
- current_ev
);
1615 } /* unifi_translate_scan() */
1620 unifi_giwscan(struct net_device
*dev
, struct iw_request_info
*info
,
1621 union iwreq_data
*wrqu
, char *extra
)
1623 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1624 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1625 struct iw_point
*dwrq
= &wrqu
->data
;
1630 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
1631 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
1632 unifi_error(priv
, "unifi_giwscan: not permitted in Mode %d\n",
1633 interfacePriv
->interfaceMode
);
1638 unifi_trace(priv
, UDBG1
,
1639 "unifi_giwscan: buffer (%d bytes) \n",
1642 r
= sme_mgt_scan_results_get_async(priv
, info
, extra
, dwrq
->length
);
1645 unifi_trace(priv
, UDBG1
,
1646 "unifi_giwscan: buffer (%d bytes) not big enough.\n",
1655 } /* unifi_giwscan() */
1659 * ---------------------------------------------------------------------------
1662 * Request to join a network or start and AdHoc.
1665 * dev Pointer to network device struct.
1666 * info Pointer to broken-out ioctl request.
1667 * data Pointer to argument data.
1668 * essid Pointer to string giving name of network to join
1672 * 0 on success and everything complete
1673 * -EINPROGRESS to have the higher level call the commit method.
1674 * ---------------------------------------------------------------------------
1677 unifi_siwessid(struct net_device
*dev
, struct iw_request_info
*info
,
1678 struct iw_point
*data
, char *essid
)
1680 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1681 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1687 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
1688 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
1689 unifi_error(priv
, "unifi_siwessid: not permitted in Mode %d\n",
1690 interfacePriv
->interfaceMode
);
1696 if (data
->flags
& 1) {
1699 if (len
> UNIFI_MAX_SSID_LEN
) {
1700 len
= UNIFI_MAX_SSID_LEN
;
1706 char essid_str
[UNIFI_MAX_SSID_LEN
+1];
1709 for (i
= 0; i
< len
; i
++) {
1710 essid_str
[i
] = (isprint(essid
[i
]) ? essid
[i
] : '?');
1712 essid_str
[i
] = '\0';
1714 unifi_trace(priv
, UDBG1
, "unifi_siwessid: asked for '%*s' (%d)\n", len
, essid_str
, len
);
1715 unifi_trace(priv
, UDBG2
, " with authModeMask = %d", priv
->connection_config
.authModeMask
);
1719 memset(priv
->connection_config
.bssid
.a
, 0xFF, ETH_ALEN
);
1721 if (essid
[len
- 1] == 0) {
1725 memcpy(priv
->connection_config
.ssid
.ssid
, essid
, len
);
1726 priv
->connection_config
.ssid
.length
= len
;
1729 priv
->connection_config
.ssid
.length
= 0;
1733 err
= sme_mgt_connect(priv
);
1736 unifi_error(priv
, "unifi_siwessid: Join failed, status %d\n", err
);
1737 return convert_sme_error(err
);
1741 } /* unifi_siwessid() */
1745 unifi_giwessid(struct net_device
*dev
, struct iw_request_info
*info
,
1746 union iwreq_data
*wrqu
, char *essid
)
1748 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1749 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1750 struct iw_point
*data
= &wrqu
->essid
;
1751 CsrWifiSmeConnectionInfo connectionInfo
;
1754 unifi_trace(priv
, UDBG2
, "unifi_giwessid\n");
1757 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
1758 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
1759 unifi_error(priv
, "unifi_giwessid: not permitted in Mode %d\n",
1760 interfacePriv
->interfaceMode
);
1765 r
= sme_mgt_connection_info_get(priv
, &connectionInfo
);
1769 data
->length
= connectionInfo
.ssid
.length
;
1771 connectionInfo
.ssid
.ssid
,
1773 data
->flags
= 1; /* active */
1775 unifi_trace(priv
, UDBG2
, "unifi_giwessid: %.*s\n",
1776 data
->length
, essid
);
1781 } /* unifi_giwessid() */
1785 unifi_siwrate(struct net_device
*dev
, struct iw_request_info
*info
,
1786 union iwreq_data
*wrqu
, char *extra
)
1788 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1789 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1790 struct iw_param
*args
= &wrqu
->bitrate
;
1791 CsrWifiSmeMibConfig mibConfig
;
1795 unifi_trace(priv
, UDBG2
, "unifi_siwrate\n");
1798 * If args->fixed == 0, value is max rate or -1 for best
1799 * If args->fixed == 1, value is rate to set or -1 for best
1800 * args->disabled and args->flags are not used in SIOCSIWRATE
1803 /* Get, modify and set the MIB data */
1805 r
= sme_mgt_mib_config_get(priv
, &mibConfig
);
1808 unifi_error(priv
, "unifi_siwrate: Get CsrWifiSmeMibConfigValue failed.\n");
1812 /* Default to auto rate algorithm */
1813 /* in 500Kbit/s, 0 means auto */
1814 mibConfig
.unifiFixTxDataRate
= 0;
1816 if (args
->value
!= -1) {
1817 mibConfig
.unifiFixTxDataRate
= args
->value
/ 500000;
1820 /* 1 means rate is a maximum, 2 means rate is a set value */
1821 if (args
->fixed
== 1) {
1822 mibConfig
.unifiFixMaxTxDataRate
= 0;
1824 mibConfig
.unifiFixMaxTxDataRate
= 1;
1827 r
= sme_mgt_mib_config_set(priv
, &mibConfig
);
1830 unifi_error(priv
, "unifi_siwrate: Set CsrWifiSmeMibConfigValue failed.\n");
1836 } /* unifi_siwrate() */
1841 unifi_giwrate(struct net_device
*dev
, struct iw_request_info
*info
,
1842 union iwreq_data
*wrqu
, char *extra
)
1844 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1845 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1846 struct iw_param
*args
= &wrqu
->bitrate
;
1849 CsrWifiSmeMibConfig mibConfig
;
1850 CsrWifiSmeConnectionStats connectionStats
;
1852 unifi_trace(priv
, UDBG2
, "unifi_giwrate\n");
1858 r
= sme_mgt_mib_config_get(priv
, &mibConfig
);
1861 unifi_error(priv
, "unifi_giwrate: Get CsrWifiSmeMibConfigValue failed.\n");
1865 bitrate
= mibConfig
.unifiFixTxDataRate
;
1866 flag
= mibConfig
.unifiFixMaxTxDataRate
;
1868 /* Used the value returned by the SME if MIB returns 0 */
1871 r
= sme_mgt_connection_stats_get(priv
, &connectionStats
);
1873 /* Ignore errors, we may be disconnected */
1875 bitrate
= connectionStats
.unifiTxDataRate
;
1879 args
->value
= bitrate
* 500000;
1880 args
->fixed
= !flag
;
1883 } /* unifi_giwrate() */
1887 unifi_siwrts(struct net_device
*dev
, struct iw_request_info
*info
,
1888 union iwreq_data
*wrqu
, char *extra
)
1890 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1891 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1892 int val
= wrqu
->rts
.value
;
1894 CsrWifiSmeMibConfig mibConfig
;
1896 unifi_trace(priv
, UDBG2
, "unifi_siwrts\n");
1899 if (wrqu
->rts
.disabled
) {
1903 if ( (val
< 0) || (val
> 2347) )
1908 /* Get, modify and set the MIB data */
1910 r
= sme_mgt_mib_config_get(priv
, &mibConfig
);
1913 unifi_error(priv
, "unifi_siwrts: Get CsrWifiSmeMibConfigValue failed.\n");
1916 mibConfig
.dot11RtsThreshold
= val
;
1918 r
= sme_mgt_mib_config_set(priv
, &mibConfig
);
1921 unifi_error(priv
, "unifi_siwrts: Set CsrWifiSmeMibConfigValue failed.\n");
1930 unifi_giwrts(struct net_device
*dev
, struct iw_request_info
*info
,
1931 union iwreq_data
*wrqu
, char *extra
)
1933 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1934 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1937 CsrWifiSmeMibConfig mibConfig
;
1939 unifi_trace(priv
, UDBG2
, "unifi_giwrts\n");
1943 r
= sme_mgt_mib_config_get(priv
, &mibConfig
);
1946 unifi_error(priv
, "unifi_giwrts: Get CsrWifiSmeMibConfigValue failed.\n");
1950 rts_thresh
= mibConfig
.dot11RtsThreshold
;
1951 if (rts_thresh
> 2347) {
1955 wrqu
->rts
.value
= rts_thresh
;
1956 wrqu
->rts
.disabled
= (rts_thresh
== 2347);
1957 wrqu
->rts
.fixed
= 1;
1964 unifi_siwfrag(struct net_device
*dev
, struct iw_request_info
*info
,
1965 union iwreq_data
*wrqu
, char *extra
)
1967 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
1968 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
1969 int val
= wrqu
->frag
.value
;
1971 CsrWifiSmeMibConfig mibConfig
;
1973 unifi_trace(priv
, UDBG2
, "unifi_siwfrag\n");
1976 if (wrqu
->frag
.disabled
)
1979 if ( (val
< 256) || (val
> 2347) )
1982 /* Get, modify and set the MIB data */
1984 r
= sme_mgt_mib_config_get(priv
, &mibConfig
);
1987 unifi_error(priv
, "unifi_siwfrag: Get CsrWifiSmeMibConfigValue failed.\n");
1990 /* Fragmentation Threashold must be even */
1991 mibConfig
.dot11FragmentationThreshold
= (val
& ~0x1);
1993 r
= sme_mgt_mib_config_set(priv
, &mibConfig
);
1996 unifi_error(priv
, "unifi_siwfrag: Set CsrWifiSmeMibConfigValue failed.\n");
2005 unifi_giwfrag(struct net_device
*dev
, struct iw_request_info
*info
,
2006 union iwreq_data
*wrqu
, char *extra
)
2008 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
2009 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
2012 CsrWifiSmeMibConfig mibConfig
;
2014 unifi_trace(priv
, UDBG2
, "unifi_giwfrag\n");
2018 r
= sme_mgt_mib_config_get(priv
, &mibConfig
);
2021 unifi_error(priv
, "unifi_giwfrag: Get CsrWifiSmeMibConfigValue failed.\n");
2025 frag_thresh
= mibConfig
.dot11FragmentationThreshold
;
2027 /* Build the return structure */
2028 wrqu
->frag
.value
= frag_thresh
;
2029 wrqu
->frag
.disabled
= (frag_thresh
>= 2346);
2030 wrqu
->frag
.fixed
= 1;
2037 unifi_siwencode(struct net_device
*dev
, struct iw_request_info
*info
,
2038 union iwreq_data
*wrqu
, char *extra
)
2040 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
2041 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
2042 struct iw_point
*erq
= &wrqu
->encoding
;
2046 CsrWifiSmeKey sme_key
;
2048 unifi_trace(priv
, UDBG2
, "unifi_siwencode\n");
2052 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
2053 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
2054 unifi_error(priv
, "unifi_siwencode: not permitted in Mode %d\n",
2055 interfacePriv
->interfaceMode
);
2061 * Key index is encoded in the flags.
2062 * 0 - use current default,
2063 * 1-4 - if a key value is given set that key
2064 * if not use that key
2066 index
= (erq
->flags
& IW_ENCODE_INDEX
); /* key number, 1-4 */
2067 if ((index
< 0) || (index
> 4)) {
2068 unifi_error(priv
, "unifi_siwencode: Request to set an invalid key (index:%d)", index
);
2073 * Basic checking: do we have a key to set ?
2074 * The IW_ENCODE_NOKEY flag is set when no key is present (only change flags),
2075 * but older versions rely on sending a key id 1-4.
2077 if (erq
->length
> 0) {
2079 /* Check the size of the key */
2080 if ((erq
->length
> LARGE_KEY_SIZE
) || (erq
->length
< SMALL_KEY_SIZE
)) {
2081 unifi_error(priv
, "unifi_siwencode: Request to set an invalid key (length:%d)",
2086 /* Check the index (none (i.e. 0) means use current) */
2087 if ((index
< 1) || (index
> 4)) {
2088 /* If we do not have a previous key, use 1 as default */
2089 if (!priv
->wep_tx_key_index
) {
2090 priv
->wep_tx_key_index
= 1;
2092 index
= priv
->wep_tx_key_index
;
2095 /* If we didn't have a key and a valid index is set, we want to remember it*/
2096 if (!priv
->wep_tx_key_index
) {
2097 priv
->wep_tx_key_index
= index
;
2100 unifi_trace(priv
, UDBG1
, "Tx key Index is %d\n", priv
->wep_tx_key_index
);
2104 /* Check if the key is not marked as invalid */
2105 if ((erq
->flags
& IW_ENCODE_NOKEY
) == 0) {
2107 unifi_trace(priv
, UDBG1
, "New %s key (len=%d, index=%d)\n",
2108 (priv
->wep_tx_key_index
== index
) ? "tx" : "",
2109 erq
->length
, index
);
2111 sme_key
.wepTxKey
= (priv
->wep_tx_key_index
== index
);
2112 if (priv
->wep_tx_key_index
== index
) {
2113 sme_key
.keyType
= CSR_WIFI_SME_KEY_TYPE_PAIRWISE
;
2115 sme_key
.keyType
= CSR_WIFI_SME_KEY_TYPE_GROUP
;
2117 /* Key index is zero based in SME but 1 based in wext */
2118 sme_key
.keyIndex
= (index
- 1);
2119 sme_key
.keyLength
= erq
->length
;
2120 sme_key
.authenticator
= 0;
2121 memset(sme_key
.address
.a
, 0xFF, ETH_ALEN
);
2122 memcpy(sme_key
.key
, extra
, erq
->length
);
2125 rc
= sme_mgt_key(priv
, &sme_key
, CSR_WIFI_SME_LIST_ACTION_ADD
);
2128 unifi_error(priv
, "unifi_siwencode: Set key failed (%d)", rc
);
2129 return convert_sme_error(rc
);
2132 /* Store the key to be reported by the SIOCGIWENCODE handler */
2133 priv
->wep_keys
[index
- 1].len
= erq
->length
;
2134 memcpy(priv
->wep_keys
[index
- 1].key
, extra
, erq
->length
);
2138 * No additional key data, so it must be a request to change the
2142 unifi_trace(priv
, UDBG1
, "Tx key Index is %d\n", index
- 1);
2144 /* Store the index to be reported by the SIOCGIWENCODE handler */
2145 priv
->wep_tx_key_index
= index
;
2147 sme_key
.wepTxKey
= 1;
2148 sme_key
.keyType
= CSR_WIFI_SME_KEY_TYPE_PAIRWISE
;
2150 /* Key index is zero based in SME but 1 based in wext */
2151 sme_key
.keyIndex
= (index
- 1);
2152 sme_key
.keyLength
= 0;
2153 sme_key
.authenticator
= 0;
2155 rc
= sme_mgt_key(priv
, &sme_key
, CSR_WIFI_SME_LIST_ACTION_ADD
);
2158 unifi_error(priv
, "unifi_siwencode: Set key failed (%d)", rc
);
2159 return convert_sme_error(rc
);
2162 /* Turn on encryption */
2167 /* Read the flags */
2168 if (erq
->flags
& IW_ENCODE_DISABLED
) {
2169 /* disable encryption */
2170 unifi_trace(priv
, UDBG1
, "disable WEP encryption\n");
2173 priv
->wep_tx_key_index
= 0;
2175 unifi_trace(priv
, UDBG1
, "IW_ENCODE_DISABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
2176 priv
->connection_config
.authModeMask
= CSR_WIFI_SME_AUTH_MODE_80211_OPEN
;
2179 if (erq
->flags
& IW_ENCODE_RESTRICTED
) {
2180 /* Use shared key auth */
2181 unifi_trace(priv
, UDBG1
, "IW_ENCODE_RESTRICTED: CSR_WIFI_SME_AUTH_MODE_80211_SHARED\n");
2182 priv
->connection_config
.authModeMask
= CSR_WIFI_SME_AUTH_MODE_80211_SHARED
;
2184 /* Turn on encryption */
2187 if (erq
->flags
& IW_ENCODE_OPEN
) {
2188 unifi_trace(priv
, UDBG1
, "IW_ENCODE_OPEN: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
2189 priv
->connection_config
.authModeMask
= CSR_WIFI_SME_AUTH_MODE_80211_OPEN
;
2192 /* Commit the changes to flags if needed */
2193 if (privacy
!= -1) {
2194 priv
->connection_config
.privacyMode
= privacy
? CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED
: CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED
;
2195 priv
->connection_config
.encryptionModeMask
= privacy
? (CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40
|
2196 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104
|
2197 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40
|
2198 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104
) :
2199 CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE
;
2202 return convert_sme_error(rc
);
2204 } /* unifi_siwencode() */
2209 unifi_giwencode(struct net_device
*dev
, struct iw_request_info
*info
,
2210 union iwreq_data
*wrqu
, char *extra
)
2212 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
2213 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
2214 struct iw_point
*erq
= &wrqu
->encoding
;
2216 unifi_trace(priv
, UDBG2
, "unifi_giwencode\n");
2220 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
2221 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
2222 unifi_error(priv
, "unifi_giwencode: not permitted in Mode %d\n",
2223 interfacePriv
->interfaceMode
);
2228 if (priv
->connection_config
.authModeMask
== CSR_WIFI_SME_AUTH_MODE_80211_SHARED
) {
2229 erq
->flags
= IW_ENCODE_RESTRICTED
;
2232 if (priv
->connection_config
.privacyMode
== CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED
) {
2233 erq
->flags
= IW_ENCODE_DISABLED
;
2235 erq
->flags
= IW_ENCODE_OPEN
;
2241 if (erq
->flags
!= IW_ENCODE_DISABLED
) {
2242 int index
= priv
->wep_tx_key_index
;
2244 if ((index
> 0) && (index
<= NUM_WEPKEYS
)) {
2245 erq
->flags
|= (index
& IW_ENCODE_INDEX
);
2246 erq
->length
= priv
->wep_keys
[index
- 1].len
;
2247 memcpy(extra
, priv
->wep_keys
[index
- 1].key
, erq
->length
);
2249 unifi_notice(priv
, "unifi_giwencode: Surprise, do not have a valid key index (%d)\n",
2255 } /* unifi_giwencode() */
2259 unifi_siwpower(struct net_device
*dev
, struct iw_request_info
*info
,
2260 union iwreq_data
*wrqu
, char *extra
)
2262 struct iw_param
*args
= &wrqu
->power
;
2263 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
2264 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
2265 int listen_interval
, wake_for_dtim
;
2267 CsrWifiSmePowerConfig powerConfig
;
2269 unifi_trace(priv
, UDBG2
, "unifi_siwpower\n");
2273 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
2274 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
2275 unifi_error(priv
, "unifi_siwpower: not permitted in Mode %d\n",
2276 interfacePriv
->interfaceMode
);
2281 r
= sme_mgt_power_config_get(priv
, &powerConfig
);
2284 unifi_error(priv
, "unifi_siwpower: Get unifi_PowerConfigValue failed.\n");
2288 listen_interval
= -1;
2290 if (args
->disabled
) {
2291 powerConfig
.powerSaveLevel
= CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW
;
2295 powerConfig
.powerSaveLevel
= CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH
;
2297 switch (args
->flags
& IW_POWER_TYPE
) {
2301 case IW_POWER_PERIOD
:
2302 listen_interval
= args
->value
/ 1000;
2308 switch (args
->flags
& IW_POWER_MODE
) {
2312 case IW_POWER_UNICAST_R
:
2313 /* not interested in broadcast packets */
2316 case IW_POWER_ALL_R
:
2317 /* yes, we are interested in broadcast packets */
2325 if (listen_interval
> 0) {
2326 powerConfig
.listenIntervalTu
= listen_interval
;
2327 unifi_trace(priv
, UDBG4
, "unifi_siwpower: new Listen Interval = %d.\n",
2328 powerConfig
.listenIntervalTu
);
2331 if (wake_for_dtim
>= 0) {
2332 powerConfig
.rxDtims
= wake_for_dtim
;
2335 r
= sme_mgt_power_config_set(priv
, &powerConfig
);
2338 unifi_error(priv
, "unifi_siwpower: Set unifi_PowerConfigValue failed.\n");
2343 } /* unifi_siwpower() */
2347 unifi_giwpower(struct net_device
*dev
, struct iw_request_info
*info
,
2348 union iwreq_data
*wrqu
, char *extra
)
2350 struct iw_param
*args
= &wrqu
->power
;
2351 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
2352 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
2353 CsrWifiSmePowerConfig powerConfig
;
2356 unifi_trace(priv
, UDBG2
, "unifi_giwpower\n");
2360 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
2361 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
2362 unifi_error(priv
, "unifi_giwpower: not permitted in Mode %d\n",
2363 interfacePriv
->interfaceMode
);
2370 r
= sme_mgt_power_config_get(priv
, &powerConfig
);
2373 unifi_error(priv
, "unifi_giwpower: Get unifi_PowerConfigValue failed.\n");
2377 unifi_trace(priv
, UDBG4
, "unifi_giwpower: mode=%d\n",
2378 powerConfig
.powerSaveLevel
);
2380 args
->disabled
= (powerConfig
.powerSaveLevel
== CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW
);
2381 if (args
->disabled
) {
2386 args
->value
= powerConfig
.listenIntervalTu
* 1000;
2387 args
->flags
|= IW_POWER_PERIOD
;
2389 if (powerConfig
.rxDtims
) {
2390 args
->flags
|= IW_POWER_ALL_R
;
2392 args
->flags
|= IW_POWER_UNICAST_R
;
2396 } /* unifi_giwpower() */
2400 * ---------------------------------------------------------------------------
2401 * unifi_siwcommit - handler for SIOCSIWCOMMIT
2403 * Apply all the parameters that have been set.
2404 * In practice this means:
2406 * - join a network or start an AdHoc
2407 * - authenticate and associate.
2414 * ---------------------------------------------------------------------------
2417 unifi_siwcommit(struct net_device
*dev
, struct iw_request_info
*info
,
2418 union iwreq_data
*wrqu
, char *extra
)
2421 } /* unifi_siwcommit() */
2426 unifi_siwmlme(struct net_device
*dev
, struct iw_request_info
*info
,
2427 union iwreq_data
*wrqu
, char *extra
)
2429 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
2430 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
2431 struct iw_mlme
*mlme
= (struct iw_mlme
*)extra
;
2433 unifi_trace(priv
, UDBG2
, "unifi_siwmlme\n");
2436 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
2437 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
2438 unifi_error(priv
, "unifi_siwmlme: not permitted in Mode %d\n",
2439 interfacePriv
->interfaceMode
);
2444 switch (mlme
->cmd
) {
2445 case IW_MLME_DEAUTH
:
2446 case IW_MLME_DISASSOC
:
2448 sme_mgt_disconnect(priv
);
2456 } /* unifi_siwmlme() */
2460 * ---------------------------------------------------------------------------
2464 * WPA : Generic IEEE 802.11 information element (e.g., for WPA/RSN/WMM).
2465 * Handlers for SIOCSIWGENIE, SIOCGIWGENIE - set/get generic IE
2467 * The host program (e.g. wpa_supplicant) uses this call to set the
2468 * additional IEs to accompany the next (Associate?) request.
2477 * This ioctl uses struct iw_point and data buffer that includes IE id
2478 * and len fields. More than one IE may be included in the
2479 * request. Setting the generic IE to empty buffer (len=0) removes the
2480 * generic IE from the driver.
2481 * ---------------------------------------------------------------------------
2484 unifi_siwgenie(struct net_device
*dev
, struct iw_request_info
*info
,
2485 union iwreq_data
*wrqu
, char *extra
)
2487 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
2488 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
2491 unifi_trace(priv
, UDBG2
, "unifi_siwgenie\n");
2493 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
2494 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
2495 unifi_error(priv
, "unifi_siwgenie: not permitted in Mode %d\n",
2496 interfacePriv
->interfaceMode
);
2501 if ( priv
->connection_config
.mlmeAssociateReqInformationElements
) {
2502 kfree( priv
->connection_config
.mlmeAssociateReqInformationElements
);
2504 priv
->connection_config
.mlmeAssociateReqInformationElementsLength
= 0;
2505 priv
->connection_config
.mlmeAssociateReqInformationElements
= NULL
;
2507 len
= wrqu
->data
.length
;
2512 priv
->connection_config
.mlmeAssociateReqInformationElements
= kmalloc(len
, GFP_KERNEL
);
2513 if (priv
->connection_config
.mlmeAssociateReqInformationElements
== NULL
) {
2517 priv
->connection_config
.mlmeAssociateReqInformationElementsLength
= len
;
2518 memcpy( priv
->connection_config
.mlmeAssociateReqInformationElements
, extra
, len
);
2521 } /* unifi_siwgenie() */
2525 unifi_giwgenie(struct net_device
*dev
, struct iw_request_info
*info
,
2526 union iwreq_data
*wrqu
, char *extra
)
2528 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
2529 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
2532 unifi_trace(priv
, UDBG2
, "unifi_giwgenie\n");
2534 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
2535 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
2536 unifi_error(priv
, "unifi_giwgenie: not permitted in Mode %d\n",
2537 interfacePriv
->interfaceMode
);
2542 len
= priv
->connection_config
.mlmeAssociateReqInformationElementsLength
;
2545 wrqu
->data
.length
= 0;
2549 if (wrqu
->data
.length
< len
) {
2553 wrqu
->data
.length
= len
;
2554 memcpy(extra
, priv
->connection_config
.mlmeAssociateReqInformationElements
, len
);
2557 } /* unifi_giwgenie() */
2561 * ---------------------------------------------------------------------------
2565 * Handlers for SIOCSIWAUTH, SIOCGIWAUTH
2566 * Set/get various authentication parameters.
2573 * ---------------------------------------------------------------------------
2576 _unifi_siwauth(struct net_device
*dev
, struct iw_request_info
*info
,
2577 union iwreq_data
*wrqu
, char *extra
)
2579 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
2580 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
2581 CsrWifiSmeAuthModeMask new_auth
;
2583 unifi_trace(priv
, UDBG2
, "unifi_siwauth\n");
2585 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
2586 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
2587 unifi_error(priv
, "unifi_siwauth: not permitted in Mode %d\n",
2588 interfacePriv
->interfaceMode
);
2594 * This ioctl is safe to call even when UniFi is powered off.
2595 * wpa_supplicant calls it to test whether we support WPA.
2598 switch (wrqu
->param
.flags
& IW_AUTH_INDEX
) {
2600 case IW_AUTH_WPA_ENABLED
:
2601 unifi_trace(priv
, UDBG1
, "IW_AUTH_WPA_ENABLED: %d\n", wrqu
->param
.value
);
2603 if (wrqu
->param
.value
== 0) {
2604 unifi_trace(priv
, UDBG5
, "IW_AUTH_WPA_ENABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
2605 priv
->connection_config
.authModeMask
= CSR_WIFI_SME_AUTH_MODE_80211_OPEN
;
2609 case IW_AUTH_PRIVACY_INVOKED
:
2610 unifi_trace(priv
, UDBG1
, "IW_AUTH_PRIVACY_INVOKED: %d\n", wrqu
->param
.value
);
2612 priv
->connection_config
.privacyMode
= wrqu
->param
.value
? CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED
: CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED
;
2613 if (wrqu
->param
.value
== CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED
)
2615 priv
->connection_config
.encryptionModeMask
= CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE
;
2619 case IW_AUTH_80211_AUTH_ALG
:
2621 IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
2622 IW_AUTH_ALG_SHARED_KEY 0x00000002
2623 IW_AUTH_ALG_LEAP 0x00000004
2626 if (wrqu
->param
.value
& IW_AUTH_ALG_OPEN_SYSTEM
) {
2627 unifi_trace(priv
, UDBG1
, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_OPEN_SYSTEM)\n", wrqu
->param
.value
);
2628 new_auth
|= CSR_WIFI_SME_AUTH_MODE_80211_OPEN
;
2630 if (wrqu
->param
.value
& IW_AUTH_ALG_SHARED_KEY
) {
2631 unifi_trace(priv
, UDBG1
, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_SHARED_KEY)\n", wrqu
->param
.value
);
2632 new_auth
|= CSR_WIFI_SME_AUTH_MODE_80211_SHARED
;
2634 if (wrqu
->param
.value
& IW_AUTH_ALG_LEAP
) {
2635 /* Initial exchanges using open-system to set EAP */
2636 unifi_trace(priv
, UDBG1
, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_LEAP)\n", wrqu
->param
.value
);
2637 new_auth
|= CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X
;
2639 if (new_auth
== 0) {
2640 unifi_trace(priv
, UDBG1
, "IW_AUTH_80211_AUTH_ALG: invalid value %d\n",
2644 priv
->connection_config
.authModeMask
= new_auth
;
2648 case IW_AUTH_WPA_VERSION
:
2649 unifi_trace(priv
, UDBG1
, "IW_AUTH_WPA_VERSION: %d\n", wrqu
->param
.value
);
2650 priv
->ignore_bssid_join
= TRUE
;
2652 IW_AUTH_WPA_VERSION_DISABLED 0x00000001
2653 IW_AUTH_WPA_VERSION_WPA 0x00000002
2654 IW_AUTH_WPA_VERSION_WPA2 0x00000004
2657 if (!(wrqu
->param
.value
& IW_AUTH_WPA_VERSION_DISABLED
)) {
2659 priv
->connection_config
.authModeMask
= CSR_WIFI_SME_AUTH_MODE_80211_OPEN
;
2661 if (wrqu
->param
.value
& IW_AUTH_WPA_VERSION_WPA
) {
2662 unifi_trace(priv
, UDBG4
, "IW_AUTH_WPA_VERSION: WPA, WPA-PSK\n");
2663 priv
->connection_config
.authModeMask
|= (CSR_WIFI_SME_AUTH_MODE_8021X_WPA
| CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK
);
2665 if (wrqu
->param
.value
& IW_AUTH_WPA_VERSION_WPA2
) {
2666 unifi_trace(priv
, UDBG4
, "IW_AUTH_WPA_VERSION: WPA2, WPA2-PSK\n");
2667 priv
->connection_config
.authModeMask
|= (CSR_WIFI_SME_AUTH_MODE_8021X_WPA2
| CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK
);
2672 case IW_AUTH_CIPHER_PAIRWISE
:
2673 unifi_trace(priv
, UDBG1
, "IW_AUTH_CIPHER_PAIRWISE: %d\n", wrqu
->param
.value
);
2676 IW_AUTH_CIPHER_NONE 0x00000001
2677 IW_AUTH_CIPHER_WEP40 0x00000002
2678 IW_AUTH_CIPHER_TKIP 0x00000004
2679 IW_AUTH_CIPHER_CCMP 0x00000008
2680 IW_AUTH_CIPHER_WEP104 0x00000010
2683 priv
->connection_config
.encryptionModeMask
= CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE
;
2685 if (wrqu
->param
.value
& IW_AUTH_CIPHER_WEP40
) {
2686 priv
->connection_config
.encryptionModeMask
|=
2687 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40
| CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40
;
2689 if (wrqu
->param
.value
& IW_AUTH_CIPHER_WEP104
) {
2690 priv
->connection_config
.encryptionModeMask
|=
2691 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104
| CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104
;
2693 if (wrqu
->param
.value
& IW_AUTH_CIPHER_TKIP
) {
2694 priv
->connection_config
.encryptionModeMask
|=
2695 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP
| CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP
;
2697 if (wrqu
->param
.value
& IW_AUTH_CIPHER_CCMP
) {
2698 priv
->connection_config
.encryptionModeMask
|=
2699 CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP
| CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP
;
2704 case IW_AUTH_CIPHER_GROUP
:
2705 unifi_trace(priv
, UDBG1
, "IW_AUTH_CIPHER_GROUP: %d\n", wrqu
->param
.value
);
2707 * Use the WPA version and the group cipher suite to set the permitted
2708 * group key in the MIB. f/w uses this value to validate WPA and RSN IEs
2709 * in the probe responses from the desired BSS(ID)
2712 priv
->connection_config
.encryptionModeMask
&= ~(CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40
|
2713 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104
|
2714 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP
|
2715 CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP
);
2716 if (wrqu
->param
.value
& IW_AUTH_CIPHER_WEP40
) {
2717 priv
->connection_config
.encryptionModeMask
|= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40
;
2719 if (wrqu
->param
.value
& IW_AUTH_CIPHER_WEP104
) {
2720 priv
->connection_config
.encryptionModeMask
|= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104
;
2722 if (wrqu
->param
.value
& IW_AUTH_CIPHER_TKIP
) {
2723 priv
->connection_config
.encryptionModeMask
|= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP
;
2725 if (wrqu
->param
.value
& IW_AUTH_CIPHER_CCMP
) {
2726 priv
->connection_config
.encryptionModeMask
|= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP
;
2731 case IW_AUTH_KEY_MGMT
:
2732 unifi_trace(priv
, UDBG1
, "IW_AUTH_KEY_MGMT: %d\n", wrqu
->param
.value
);
2734 IW_AUTH_KEY_MGMT_802_1X 1
2735 IW_AUTH_KEY_MGMT_PSK 2
2737 if (priv
->connection_config
.authModeMask
& (CSR_WIFI_SME_AUTH_MODE_8021X_WPA
| CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK
)) {
2738 /* Check for explicitly set mode. */
2739 if (wrqu
->param
.value
== IW_AUTH_KEY_MGMT_802_1X
) {
2740 priv
->connection_config
.authModeMask
&= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK
;
2742 if (wrqu
->param
.value
== IW_AUTH_KEY_MGMT_PSK
) {
2743 priv
->connection_config
.authModeMask
&= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA
;
2745 unifi_trace(priv
, UDBG5
, "IW_AUTH_KEY_MGMT: WPA: %d\n",
2746 priv
->connection_config
.authModeMask
);
2748 if (priv
->connection_config
.authModeMask
& (CSR_WIFI_SME_AUTH_MODE_8021X_WPA2
| CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK
)) {
2749 /* Check for explicitly set mode. */
2750 if (wrqu
->param
.value
== IW_AUTH_KEY_MGMT_802_1X
) {
2751 priv
->connection_config
.authModeMask
&= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK
;
2753 if (wrqu
->param
.value
== IW_AUTH_KEY_MGMT_PSK
) {
2754 priv
->connection_config
.authModeMask
&= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA2
;
2756 unifi_trace(priv
, UDBG5
, "IW_AUTH_KEY_MGMT: WPA2: %d\n",
2757 priv
->connection_config
.authModeMask
);
2761 case IW_AUTH_TKIP_COUNTERMEASURES
:
2763 * Set to true at the start of the 60 second backup-off period
2764 * following 2 MichaelMIC failures within 60s.
2766 unifi_trace(priv
, UDBG1
, "IW_AUTH_TKIP_COUNTERMEASURES: %d\n", wrqu
->param
.value
);
2769 case IW_AUTH_DROP_UNENCRYPTED
:
2771 * Set to true on init.
2772 * Set to false just before associate if encryption will not be
2775 * Note this is not the same as the 802.1X controlled port
2777 unifi_trace(priv
, UDBG1
, "IW_AUTH_DROP_UNENCRYPTED: %d\n", wrqu
->param
.value
);
2780 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
2782 * This is set by wpa_supplicant to allow unencrypted EAPOL messages
2783 * even if pairwise keys are set when not using WPA. IEEE 802.1X
2784 * specifies that these frames are not encrypted, but WPA encrypts
2785 * them when pairwise keys are in use.
2786 * I think the UniFi f/w handles this decision for us.
2788 unifi_trace(priv
, UDBG1
, "IW_AUTH_RX_UNENCRYPTED_EAPOL: %d\n", wrqu
->param
.value
);
2791 case IW_AUTH_ROAMING_CONTROL
:
2792 unifi_trace(priv
, UDBG1
, "IW_AUTH_ROAMING_CONTROL: %d\n", wrqu
->param
.value
);
2796 unifi_trace(priv
, UDBG1
, "Unsupported auth param %d to 0x%X\n",
2797 wrqu
->param
.flags
& IW_AUTH_INDEX
,
2802 unifi_trace(priv
, UDBG2
, "authModeMask = %d", priv
->connection_config
.authModeMask
);
2805 } /* _unifi_siwauth() */
2809 unifi_siwauth(struct net_device
*dev
, struct iw_request_info
*info
,
2810 union iwreq_data
*wrqu
, char *extra
)
2815 err
= _unifi_siwauth(dev
, info
, wrqu
, extra
);
2819 } /* unifi_siwauth() */
2823 unifi_giwauth(struct net_device
*dev
, struct iw_request_info
*info
,
2824 union iwreq_data
*wrqu
, char *extra
)
2826 unifi_trace(NULL
, UDBG2
, "unifi_giwauth\n");
2828 } /* unifi_giwauth() */
2831 * ---------------------------------------------------------------------------
2832 * unifi_siwencodeext
2833 * unifi_giwencodeext
2835 * Handlers for SIOCSIWENCODEEXT, SIOCGIWENCODEEXT - set/get
2836 * encoding token & mode
2845 * For WPA/WPA2 we don't take note of the IW_ENCODE_EXT_SET_TX_KEY flag.
2846 * This flag means "use this key to encode transmissions"; we just
2847 * assume only one key will be set and that is the one to use.
2848 * ---------------------------------------------------------------------------
2851 _unifi_siwencodeext(struct net_device
*dev
, struct iw_request_info
*info
,
2852 union iwreq_data
*wrqu
, char *extra
)
2854 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
2855 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
2856 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
2858 unsigned char *keydata
;
2859 unsigned char tkip_key
[32];
2861 unsigned char *a
= (unsigned char *)ext
->addr
.sa_data
;
2862 CsrWifiSmeKey sme_key
;
2863 CsrWifiSmeKeyType key_type
;
2867 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
2868 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
2869 unifi_error(priv
, "unifi_siwencodeext: not permitted in Mode %d\n",
2870 interfacePriv
->interfaceMode
);
2875 unifi_trace(priv
, UDBG1
, "siwencodeext: flags=0x%X, alg=%d, ext_flags=0x%X, len=%d, index=%d,\n",
2876 wrqu
->encoding
.flags
, ext
->alg
, ext
->ext_flags
,
2877 ext
->key_len
, (wrqu
->encoding
.flags
& IW_ENCODE_INDEX
));
2878 unifi_trace(priv
, UDBG3
, " addr=%pM\n", a
);
2880 if ((ext
->key_len
== 0) && (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)) {
2881 /* This means use a different key (given by key_idx) for Tx. */
2883 unifi_trace(priv
, UDBG1
, KERN_ERR
"unifi_siwencodeext: NYI should change tx key id here!!\n");
2887 memset(&sme_key
, 0, sizeof(sme_key
));
2889 keydata
= (unsigned char *)(ext
+ 1);
2890 keyid
= (wrqu
->encoding
.flags
& IW_ENCODE_INDEX
);
2893 * Check for request to delete keys for an address.
2895 /* Pick out request for no privacy. */
2896 if (ext
->alg
== IW_ENCODE_ALG_NONE
) {
2898 unifi_trace(priv
, UDBG1
, "Deleting %s key %d\n",
2899 (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
) ? "GROUP" : "PAIRWISE",
2902 if (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
) {
2903 sme_key
.keyType
= CSR_WIFI_SME_KEY_TYPE_GROUP
;
2905 sme_key
.keyType
= CSR_WIFI_SME_KEY_TYPE_PAIRWISE
;
2907 sme_key
.keyIndex
= (keyid
- 1);
2908 sme_key
.keyLength
= 0;
2909 sme_key
.authenticator
= 0;
2910 memcpy(sme_key
.address
.a
, a
, ETH_ALEN
);
2912 r
= sme_mgt_key(priv
, &sme_key
, CSR_WIFI_SME_LIST_ACTION_REMOVE
);
2915 unifi_error(priv
, "Delete key request was rejected with result %d\n", r
);
2916 return convert_sme_error(r
);
2923 * Request is to set a key, not delete
2926 /* Pick out WEP and use set_wep_key(). */
2927 if (ext
->alg
== IW_ENCODE_ALG_WEP
) {
2928 /* WEP-40, WEP-104 */
2930 /* Check for valid key length */
2931 if (!((ext
->key_len
== 5) || (ext
->key_len
== 13))) {
2932 unifi_trace(priv
, UDBG1
, KERN_ERR
"Invalid length for WEP key: %d\n", ext
->key_len
);
2936 unifi_trace(priv
, UDBG1
, "Setting WEP key %d tx:%d\n",
2937 keyid
, ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
);
2939 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) {
2940 sme_key
.wepTxKey
= TRUE
;
2941 sme_key
.keyType
= CSR_WIFI_SME_KEY_TYPE_PAIRWISE
;
2943 sme_key
.wepTxKey
= FALSE
;
2944 sme_key
.keyType
= CSR_WIFI_SME_KEY_TYPE_GROUP
;
2946 sme_key
.keyIndex
= (keyid
- 1);
2947 sme_key
.keyLength
= ext
->key_len
;
2948 sme_key
.authenticator
= 0;
2949 memset(sme_key
.address
.a
, 0xFF, ETH_ALEN
);
2950 memcpy(sme_key
.key
, keydata
, ext
->key_len
);
2952 r
= sme_mgt_key(priv
, &sme_key
, CSR_WIFI_SME_LIST_ACTION_ADD
);
2955 unifi_error(priv
, "siwencodeext: Set key failed (%d)", r
);
2956 return convert_sme_error(r
);
2964 * If we reach here, we are dealing with a WPA/WPA2 key
2967 if (ext
->key_len
> 32) {
2972 * TKIP keys from wpa_supplicant need swapping.
2973 * What about other supplicants (when they come along)?
2975 if ((ext
->alg
== IW_ENCODE_ALG_TKIP
) && (ext
->key_len
== 32)) {
2976 memcpy(tkip_key
, keydata
, 16);
2977 memcpy(tkip_key
+ 16, keydata
+ 24, 8);
2978 memcpy(tkip_key
+ 24, keydata
+ 16, 8);
2982 key_type
= (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
) ?
2983 CSR_WIFI_SME_KEY_TYPE_GROUP
: /* Group Key */
2984 CSR_WIFI_SME_KEY_TYPE_PAIRWISE
; /* Pairwise Key */
2986 sme_key
.keyType
= key_type
;
2987 sme_key
.keyIndex
= (keyid
- 1);
2988 sme_key
.keyLength
= ext
->key_len
;
2989 sme_key
.authenticator
= 0;
2990 memcpy(sme_key
.address
.a
, ext
->addr
.sa_data
, ETH_ALEN
);
2991 if (ext
->ext_flags
& IW_ENCODE_EXT_RX_SEQ_VALID
) {
2993 unifi_trace(priv
, UDBG5
, "RSC first 6 bytes = %*phC\n",
2996 /* memcpy((u8*)(&sme_key.keyRsc), ext->rx_seq, 8); */
2997 sme_key
.keyRsc
[0] = ext
->rx_seq
[1] << 8 | ext
->rx_seq
[0];
2998 sme_key
.keyRsc
[1] = ext
->rx_seq
[3] << 8 | ext
->rx_seq
[2];
2999 sme_key
.keyRsc
[2] = ext
->rx_seq
[5] << 8 | ext
->rx_seq
[4];
3000 sme_key
.keyRsc
[3] = ext
->rx_seq
[7] << 8 | ext
->rx_seq
[6];
3004 memcpy(sme_key
.key
, keydata
, ext
->key_len
);
3006 r
= sme_mgt_key(priv
, &sme_key
, CSR_WIFI_SME_LIST_ACTION_ADD
);
3009 unifi_error(priv
, "SETKEYS request was rejected with result %d\n", r
);
3010 return convert_sme_error(r
);
3014 } /* _unifi_siwencodeext() */
3018 unifi_siwencodeext(struct net_device
*dev
, struct iw_request_info
*info
,
3019 union iwreq_data
*wrqu
, char *extra
)
3023 err
= _unifi_siwencodeext(dev
, info
, wrqu
, extra
);
3026 } /* unifi_siwencodeext() */
3030 unifi_giwencodeext(struct net_device
*dev
, struct iw_request_info
*info
,
3031 union iwreq_data
*wrqu
, char *extra
)
3034 } /* unifi_giwencodeext() */
3038 * ---------------------------------------------------------------------------
3041 * SIOCSIWPMKSA - PMKSA cache operation
3042 * The caller passes a pmksa structure:
3043 * - cmd one of ADD, REMOVE, FLUSH
3044 * - bssid MAC address
3045 * - pmkid ID string (16 bytes)
3054 * This is not needed since we provide a siwgenie method.
3055 * ---------------------------------------------------------------------------
3057 #define UNIFI_PMKID_KEY_SIZE 16
3059 unifi_siwpmksa(struct net_device
*dev
, struct iw_request_info
*info
,
3060 union iwreq_data
*wrqu
, char *extra
)
3062 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
3063 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
3064 struct iw_pmksa
*pmksa
= (struct iw_pmksa
*)extra
;
3066 CsrWifiSmePmkidList pmkid_list
;
3067 CsrWifiSmePmkid pmkid
;
3068 CsrWifiSmeListAction action
;
3072 if(interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_AP
||
3073 interfacePriv
->interfaceMode
== CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
) {
3074 unifi_error(priv
, "unifi_siwpmksa: not permitted in Mode %d\n",
3075 interfacePriv
->interfaceMode
);
3080 unifi_trace(priv
, UDBG1
, "SIWPMKSA: cmd %d, %pM\n", pmksa
->cmd
,
3081 pmksa
->bssid
.sa_data
);
3083 pmkid_list
.pmkids
= NULL
;
3084 switch (pmksa
->cmd
) {
3086 pmkid_list
.pmkids
= &pmkid
;
3087 action
= CSR_WIFI_SME_LIST_ACTION_ADD
;
3088 pmkid_list
.pmkidsCount
= 1;
3089 memcpy(pmkid
.bssid
.a
, pmksa
->bssid
.sa_data
, ETH_ALEN
);
3090 memcpy(pmkid
.pmkid
, pmksa
->pmkid
, UNIFI_PMKID_KEY_SIZE
);
3092 case IW_PMKSA_REMOVE
:
3093 pmkid_list
.pmkids
= &pmkid
;
3094 action
= CSR_WIFI_SME_LIST_ACTION_REMOVE
;
3095 pmkid_list
.pmkidsCount
= 1;
3096 memcpy(pmkid
.bssid
.a
, pmksa
->bssid
.sa_data
, ETH_ALEN
);
3097 memcpy(pmkid
.pmkid
, pmksa
->pmkid
, UNIFI_PMKID_KEY_SIZE
);
3099 case IW_PMKSA_FLUSH
:
3100 /* Replace current PMKID's with an empty list */
3101 pmkid_list
.pmkidsCount
= 0;
3102 action
= CSR_WIFI_SME_LIST_ACTION_FLUSH
;
3105 unifi_notice(priv
, "SIWPMKSA: Unknown command (0x%x)\n", pmksa
->cmd
);
3109 /* Set the Value the pmkid's will have 1 added OR 1 removed OR be cleared at this point */
3111 r
= sme_mgt_pmkid(priv
, action
, &pmkid_list
);
3114 unifi_error(priv
, "SIWPMKSA: Set PMKID's Failed.\n");
3119 } /* unifi_siwpmksa() */
3123 * ---------------------------------------------------------------------------
3124 * unifi_get_wireless_stats
3126 * get_wireless_stats method for Linux wireless extensions.
3129 * dev Pointer to associated netdevice.
3132 * Pointer to iw_statistics struct.
3133 * ---------------------------------------------------------------------------
3135 struct iw_statistics
*
3136 unifi_get_wireless_stats(struct net_device
*dev
)
3138 netInterface_priv_t
*interfacePriv
= (netInterface_priv_t
*)netdev_priv(dev
);
3139 unifi_priv_t
*priv
= interfacePriv
->privPtr
;
3141 if (priv
->init_progress
!= UNIFI_INIT_COMPLETED
) {
3145 return &priv
->wext_wireless_stats
;
3146 } /* unifi_get_wireless_stats() */
3150 * Structures to export the Wireless Handlers
3153 static const struct iw_priv_args unifi_private_args
[] = {
3154 /*{ cmd, set_args, get_args, name } */
3155 { SIOCIWS80211POWERSAVEPRIV
, IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1,
3156 IW_PRIV_TYPE_NONE
, "iwprivs80211ps" },
3157 { SIOCIWG80211POWERSAVEPRIV
, IW_PRIV_TYPE_NONE
,
3158 IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_FIXED
| IWPRIV_POWER_SAVE_MAX_STRING
, "iwprivg80211ps" },
3159 { SIOCIWS80211RELOADDEFAULTSPRIV
, IW_PRIV_TYPE_NONE
,
3160 IW_PRIV_TYPE_NONE
, "iwprivsdefs" },
3161 { SIOCIWSSMEDEBUGPRIV
, IW_PRIV_TYPE_CHAR
| IWPRIV_SME_DEBUG_MAX_STRING
, IW_PRIV_TYPE_NONE
, "iwprivssmedebug" },
3162 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3163 { SIOCIWSCONFWAPIPRIV
, IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1,
3164 IW_PRIV_TYPE_NONE
, "iwprivsconfwapi" },
3165 { SIOCIWSWAPIKEYPRIV
, IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| sizeof(unifiio_wapi_key_t
),
3166 IW_PRIV_TYPE_NONE
, "iwprivswpikey" },
3168 #ifdef CSR_SUPPORT_WEXT_AP
3169 { SIOCIWSAPCFGPRIV
, IW_PRIV_TYPE_CHAR
| 256, IW_PRIV_TYPE_NONE
, "AP_SET_CFG" },
3170 { SIOCIWSAPSTARTPRIV
, 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_FIXED
|IWPRIV_SME_MAX_STRING
, "AP_BSS_START" },
3171 { SIOCIWSAPSTOPPRIV
, IW_PRIV_TYPE_CHAR
|IW_PRIV_SIZE_FIXED
|0,
3172 IW_PRIV_TYPE_CHAR
|IW_PRIV_SIZE_FIXED
|0, "AP_BSS_STOP" },
3173 #ifdef ANDROID_BUILD
3174 { SIOCIWSFWRELOADPRIV
, IW_PRIV_TYPE_CHAR
|256,
3175 IW_PRIV_TYPE_CHAR
|IW_PRIV_SIZE_FIXED
|0, "WL_FW_RELOAD" },
3176 { SIOCIWSSTACKSTART
, 0,
3177 IW_PRIV_TYPE_CHAR
|IW_PRIV_SIZE_FIXED
|IWPRIV_SME_MAX_STRING
, "START" },
3178 { SIOCIWSSTACKSTOP
, 0,
3179 IW_PRIV_TYPE_CHAR
|IW_PRIV_SIZE_FIXED
|IWPRIV_SME_MAX_STRING
, "STOP" },
3180 #endif /* ANDROID_BUILD */
3181 #endif /* CSR_SUPPORT_WEXT_AP */
3184 static const iw_handler unifi_handler
[] =
3186 (iw_handler
) unifi_siwcommit
, /* SIOCSIWCOMMIT */
3187 (iw_handler
) unifi_giwname
, /* SIOCGIWNAME */
3188 (iw_handler
) NULL
, /* SIOCSIWNWID */
3189 (iw_handler
) NULL
, /* SIOCGIWNWID */
3190 (iw_handler
) unifi_siwfreq
, /* SIOCSIWFREQ */
3191 (iw_handler
) unifi_giwfreq
, /* SIOCGIWFREQ */
3192 (iw_handler
) unifi_siwmode
, /* SIOCSIWMODE */
3193 (iw_handler
) unifi_giwmode
, /* SIOCGIWMODE */
3194 (iw_handler
) NULL
, /* SIOCSIWSENS */
3195 (iw_handler
) NULL
, /* SIOCGIWSENS */
3196 (iw_handler
) NULL
, /* SIOCSIWRANGE */
3197 (iw_handler
) unifi_giwrange
, /* SIOCGIWRANGE */
3198 (iw_handler
) NULL
, /* SIOCSIWPRIV */
3199 (iw_handler
) NULL
, /* SIOCGIWPRIV */
3200 (iw_handler
) NULL
, /* SIOCSIWSTATS */
3201 (iw_handler
) NULL
, /* SIOCGIWSTATS */
3202 (iw_handler
) NULL
, /* SIOCSIWSPY */
3203 (iw_handler
) NULL
, /* SIOCGIWSPY */
3204 (iw_handler
) NULL
, /* SIOCSIWTHRSPY */
3205 (iw_handler
) NULL
, /* SIOCGIWTHRSPY */
3206 (iw_handler
) unifi_siwap
, /* SIOCSIWAP */
3207 (iw_handler
) unifi_giwap
, /* SIOCGIWAP */
3208 #if WIRELESS_EXT > 17
3209 /* WPA : IEEE 802.11 MLME requests */
3210 unifi_siwmlme
, /* SIOCSIWMLME, request MLME operation */
3212 (iw_handler
) NULL
, /* -- hole -- */
3214 (iw_handler
) NULL
, /* SIOCGIWAPLIST */
3215 (iw_handler
) unifi_siwscan
, /* SIOCSIWSCAN */
3216 (iw_handler
) unifi_giwscan
, /* SIOCGIWSCAN */
3217 (iw_handler
) unifi_siwessid
, /* SIOCSIWESSID */
3218 (iw_handler
) unifi_giwessid
, /* SIOCGIWESSID */
3219 (iw_handler
) NULL
, /* SIOCSIWNICKN */
3220 (iw_handler
) NULL
, /* SIOCGIWNICKN */
3221 (iw_handler
) NULL
, /* -- hole -- */
3222 (iw_handler
) NULL
, /* -- hole -- */
3223 unifi_siwrate
, /* SIOCSIWRATE */
3224 unifi_giwrate
, /* SIOCGIWRATE */
3225 unifi_siwrts
, /* SIOCSIWRTS */
3226 unifi_giwrts
, /* SIOCGIWRTS */
3227 unifi_siwfrag
, /* SIOCSIWFRAG */
3228 unifi_giwfrag
, /* SIOCGIWFRAG */
3229 (iw_handler
) NULL
, /* SIOCSIWTXPOW */
3230 (iw_handler
) NULL
, /* SIOCGIWTXPOW */
3231 (iw_handler
) NULL
, /* SIOCSIWRETRY */
3232 (iw_handler
) NULL
, /* SIOCGIWRETRY */
3233 unifi_siwencode
, /* SIOCSIWENCODE */
3234 unifi_giwencode
, /* SIOCGIWENCODE */
3235 unifi_siwpower
, /* SIOCSIWPOWER */
3236 unifi_giwpower
, /* SIOCGIWPOWER */
3237 #if WIRELESS_EXT > 17
3238 (iw_handler
) NULL
, /* -- hole -- */
3239 (iw_handler
) NULL
, /* -- hole -- */
3241 /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM). */
3242 unifi_siwgenie
, /* SIOCSIWGENIE */ /* set generic IE */
3243 unifi_giwgenie
, /* SIOCGIWGENIE */ /* get generic IE */
3245 /* WPA : Authentication mode parameters */
3246 unifi_siwauth
, /* SIOCSIWAUTH */ /* set authentication mode params */
3247 unifi_giwauth
, /* SIOCGIWAUTH */ /* get authentication mode params */
3249 /* WPA : Extended version of encoding configuration */
3250 unifi_siwencodeext
, /* SIOCSIWENCODEEXT */ /* set encoding token & mode */
3251 unifi_giwencodeext
, /* SIOCGIWENCODEEXT */ /* get encoding token & mode */
3253 /* WPA2 : PMKSA cache management */
3254 unifi_siwpmksa
, /* SIOCSIWPMKSA */ /* PMKSA cache operation */
3255 (iw_handler
) NULL
, /* -- hole -- */
3256 #endif /* WIRELESS_EXT > 17 */
3260 static const iw_handler unifi_private_handler
[] =
3262 iwprivs80211ps
, /* SIOCIWFIRSTPRIV */
3263 iwprivg80211ps
, /* SIOCIWFIRSTPRIV + 1 */
3264 iwprivsdefs
, /* SIOCIWFIRSTPRIV + 2 */
3266 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3267 iwprivsconfwapi
, /* SIOCIWFIRSTPRIV + 4 */
3268 (iw_handler
) NULL
, /* SIOCIWFIRSTPRIV + 5 */
3269 iwprivswpikey
, /* SIOCIWFIRSTPRIV + 6 */
3276 iwprivssmedebug
, /* SIOCIWFIRSTPRIV + 8 */
3277 #ifdef CSR_SUPPORT_WEXT_AP
3285 #ifdef ANDROID_BUILD
3297 #endif /* ANDROID_BUILD */
3311 #endif /* CSR_SUPPORT_WEXT_AP */
3314 struct iw_handler_def unifi_iw_handler_def
=
3316 .num_standard
= sizeof(unifi_handler
) / sizeof(iw_handler
),
3317 .num_private
= sizeof(unifi_private_handler
) / sizeof(iw_handler
),
3318 .num_private_args
= sizeof(unifi_private_args
) / sizeof(struct iw_priv_args
),
3319 .standard
= (iw_handler
*) unifi_handler
,
3320 .private = (iw_handler
*) unifi_private_handler
,
3321 .private_args
= (struct iw_priv_args
*) unifi_private_args
,
3322 #if IW_HANDLER_VERSION >= 6
3323 .get_wireless_stats
= unifi_get_wireless_stats
,