16 #include <linux/types.h>
18 #include <linux/if_arp.h>
19 #include <asm/uaccess.h>
20 #include <linux/ctype.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__); \
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()
68 wext_freq_to_channel(
int m,
int e)
83 return ((mhz - 5000) / 5);
91 return ((mhz - 2407) / 5);
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
123 memcpy(priv->ap_config.ssid.ssid,
"defaultssid",
sizeof(
"defaultssid"));
125 priv->ap_config.ssid.length = 8;
126 priv->ap_config.channel = 6;
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;
135 priv->group_sec_config.apRetransLimit = 3;
140 priv->ap_mac_config.shortSlotTimeEnabled =
FALSE;
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;
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 =
199 priv->ap_mac_config.beaconInterval= 100;
200 priv->ap_mac_config.dtimPeriod=3;
201 priv->ap_mac_config.maxListenInterval=0x00ff;
204 priv->ap_mac_config.supportedRatesCount =
205 uf_configure_supported_rates(priv->ap_mac_config.supportedRates,priv->ap_mac_config.phySupportedBitmap);
232 priv->connection_config.wmmQosInfo = 0xFF;
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
245 uf_sme_wext_ap_set_defaults(priv);
302 r = sme_mgt_mib_config_get(priv, &mibConfig);
304 unifi_error(priv,
"iwprivs80211defaults: Get CsrWifiSmeMibConfigValue failed.\n");
309 r = sme_mgt_mib_config_set(priv, &mibConfig);
311 unifi_error(priv,
"iwprivs80211defaults: Set CsrWifiSmeMibConfigValue failed.\n");
321 unifi_error(priv,
"iwprivs80211defaults: Set unifi_PowerConfigValue failed.\n");
336 int ps_mode = (
int)(*extra);
339 unifi_trace(priv,
UDBG1,
"iwprivs80211ps: power save mode = %d\n", ps_mode);
343 unifi_error(priv,
"iwprivs80211ps: Get unifi_PowerConfigValue failed.\n");
364 unifi_error(priv,
"iwprivs80211ps: Set unifi_PowerConfigValue failed.\n");
382 unifi_error(priv,
"iwprivg80211ps: Get 802.11 power mode failed.\n");
389 "Power save mode: %d (Active)",
394 "Power save mode: %d (Fast)",
399 "Power save mode: %d (Full)",
404 "Power save mode: %d (Auto)",
409 "Power save mode: %d (Unknown)",
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,
458 void *
dst,
int param_max_len)
462 u8 *param_str_begin,*param_str_end;
463 u8 *orig_str = *str_ptr;
467 param_str_begin = *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;
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;
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");
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");
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");
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");
551 if(
strstr(phy_mode,
"g")) {
554 if(
strstr(phy_mode,
"n")) {
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];
571 CsrWifiSmeApConfig_t *ap_config = &priv->ap_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);
612 unifi_notice(priv,
"store_ap_config_from_string: KEY not found:fine with Open\n");
623 unifi_error(priv,
"store_ap_config_from_string: KEY not found for WPA2\n");
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");
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);
653 ret = decode_parameter_from_string(priv,&str_ptr,
"MAX_SCB=", PARAM_TYPE_INT, &tmp_var, 5);
654 ap_config->max_connections = tmp_var;
667 r = sme_ap_start(priv,interfacePriv->
InterfaceTag,&priv->ap_config);
669 unifi_error(priv,
"iwprivsapstart AP START failed : %d\n",-r);
680 char *cfg_str =
NULL;
684 if (wrqu->
data.length != 0) {
694 cfg_str[wrqu->
data.length] = 0;
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);
714 r = sme_ap_start(priv,interfacePriv->
InterfaceTag,&priv->ap_config);
716 unifi_error(priv,
"iwprivsapstart AP START failed : %d\n",-r);
733 r = sme_ap_stop(priv,interface_tag);
735 unifi_error(priv,
"iwprivsapstop AP STOP failed : %d\n",-r);
777 r = sme_mgt_disconnect(priv);
781 r = sme_ap_stop(priv,interface_tag);
788 unifi_error(priv,
"iwprivsstackstop Stack stop failed : %d\n",-r);
795 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
809 unifi_error(priv,
"iwprivsconfwapi: not permitted in Mode %d\n",
814 enable = *(
u8*)(extra);
819 priv->connection_config.encryptionModeMask |=
823 priv->connection_config.encryptionModeMask &=
846 unifi_error(priv,
"iwprivswpikey: not permitted in Mode %d\n",
862 for (i = 0; i < 16; i+= 2)
873 unifi_trace(priv,
UDBG1,
"keyType = %d, keyIndex = %d, wepTxKey = %d, keyRsc = %x:%x, auth = %d, address = %x:%x, "
881 unifi_error(priv,
"SETKEYS request was rejected with result %d\n", r);
901 strcpy(name,
"IEEE 802.11-a");
903 strcpy(name,
"IEEE 802.11-bgn");
922 unifi_error(priv,
"unifi_siwfreq: not permitted in Mode %d\n",
932 if ((freq->
e == 0) && (freq->
m <= 1000)) {
933 priv->connection_config.adhocChannel = freq->
m;
935 priv->connection_config.adhocChannel = wext_freq_to_channel(freq->
m, freq->
e);
959 unifi_error(priv,
"unifi_giwfreq: not permitted in Mode %d\n",
966 err = sme_mgt_connection_info_get(priv, &connectionInfo);
990 unifi_error(priv,
"unifi_siwmode: not permitted in Mode %d\n",
1011 priv->connection_config.ssid.length = 0;
1050 r = sme_mgt_connection_config_get(priv, &connectionConfig);
1053 switch(connectionConfig.
bssType) {
1089 memset(range, 0,
sizeof(*range));
1106 #if WIRELESS_EXT > 15
1107 range->
bitrate[i++] = 2 * 500000;
1108 range->
bitrate[i++] = 4 * 500000;
1109 range->
bitrate[i++] = 11 * 500000;
1110 range->
bitrate[i++] = 22 * 500000;
1111 range->
bitrate[i++] = 12 * 500000;
1112 range->
bitrate[i++] = 18 * 500000;
1113 range->
bitrate[i++] = 24 * 500000;
1114 range->
bitrate[i++] = 36 * 500000;
1115 range->
bitrate[i++] = 48 * 500000;
1116 range->
bitrate[i++] = 72 * 500000;
1117 range->
bitrate[i++] = 96 * 500000;
1118 range->
bitrate[i++] = 108 * 500000;
1120 range->
bitrate[i++] = 2 * 500000;
1121 range->
bitrate[i++] = 4 * 500000;
1122 range->
bitrate[i++] = 11 * 500000;
1123 range->
bitrate[i++] = 22 * 500000;
1124 range->
bitrate[i++] = 24 * 500000;
1125 range->
bitrate[i++] = 48 * 500000;
1126 range->
bitrate[i++] = 96 * 500000;
1127 range->
bitrate[i++] = 108 * 500000;
1145 range->
freq[
i].i = chan;
1146 range->
freq[
i].m = channel_to_mhz(chan, 0);
1147 range->
freq[
i].e = 6;
1150 range->
freq[
i].i = 36;
1151 range->
freq[
i].m = channel_to_mhz(36, 1);
1152 range->
freq[
i].e = 6;
1153 range->
freq[i+1].i = 40;
1154 range->
freq[i+1].m = channel_to_mhz(40, 1);
1155 range->
freq[i+1].e = 6;
1156 range->
freq[i+2].i = 44;
1157 range->
freq[i+2].m = channel_to_mhz(44, 1);
1158 range->
freq[i+2].e = 6;
1159 range->
freq[i+3].i = 48;
1160 range->
freq[i+3].m = channel_to_mhz(48, 1);
1161 range->
freq[i+3].e = 6;
1164 #if WIRELESS_EXT > 16
1177 #if WIRELESS_EXT > 17
1201 unifi_error(priv,
"unifi_siwap: not permitted in Mode %d\n",
1214 if (is_zero_ether_addr(wrqu->
ap_addr.sa_data)) {
1215 priv->ignore_bssid_join =
FALSE;
1216 err = sme_mgt_disconnect(priv);
1218 unifi_trace(priv,
UDBG4,
"unifi_siwap: Disconnect failed, status %d\n", err);
1223 if (priv->ignore_bssid_join) {
1225 priv->ignore_bssid_join =
FALSE;
1229 priv->connection_config.bssid.a[0],
1230 priv->connection_config.bssid.a[1],
1231 priv->connection_config.bssid.a[2],
1232 priv->connection_config.bssid.a[3],
1233 priv->connection_config.bssid.a[4],
1234 priv->connection_config.bssid.a[5]);
1235 err = sme_mgt_connect(priv);
1237 unifi_error(priv,
"unifi_siwap: Join failed, status %d\n", err);
1265 unifi_error(priv,
"iwprivswpikey: not permitted in Mode %d\n",
1271 r = sme_mgt_connection_info_get(priv, &connectionInfo);
1275 bssid = connectionInfo.
bssid.
a;
1300 #if WIRELESS_EXT > 17
1311 unifi_error(priv,
"unifi_siwscan: not permitted in Mode %d\n",
1319 #if WIRELESS_EXT > 17
1331 channel_list[chans_good++] = ch;
1335 "SIWSCAN: Scanning %d channels\n", chans_good);
1338 unifi_error(priv,
"SIWSCAN: Can't alloc channel_list (%d)\n",
1348 "SIWSCAN: Scanning for %.*s\n",
1357 r = sme_mgt_scan_full(priv, &scan_ssid, chans_good, channel_list);
1359 unifi_error(priv,
"SIWSCAN: Scan returned error %d\n", r);
1366 kfree(channel_list);
1375 static const unsigned char *
1378 const unsigned char *ie =
info;
1407 char *current_ev,
char *end_buf,
1412 unsigned char *info_elems;
1414 const unsigned char *
elem;
1416 int signal, noise,
snr;
1417 char *start_buf = current_ev;
1435 memset(&iwe, 0,
sizeof(iwe));
1440 r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe,
IW_EV_ADDR_LEN);
1452 int e_len = elem[1];
1453 const unsigned char *e_ptr = elem + 2;
1454 unsigned char buf[33];
1456 memset(&iwe, 0,
sizeof(iwe));
1458 iwe.
u.
essid.length = e_len;
1459 if (iwe.
u.
essid.length > 32) {
1462 iwe.
u.
essid.flags = scan_index;
1464 buf[iwe.
u.
essid.length] =
'\0';
1465 r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, buf);
1474 memset(&iwe, 0,
sizeof(iwe));
1482 r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe,
IW_EV_UINT_LEN);
1489 memset(&iwe, 0,
sizeof(iwe));
1493 r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe,
IW_EV_FREQ_LEN);
1508 signal = scan_data->
rssi;
1510 snr = (scan_data->
snr > 0) ? scan_data->
snr : 0;
1511 snr = (snr < 255) ? snr : 255;
1512 noise = signal -
snr;
1515 signal = (signal < 63) ? signal : 63;
1516 signal = (signal > -192) ? signal : -192;
1519 noise = (noise < 63) ? noise : 63;
1520 noise = (noise > -192) ? noise : -192;
1523 signal = ( signal < 0 ) ? signal + 0x100 : signal;
1524 noise = ( noise < 0 ) ? noise + 0x100 : noise;
1526 iwe.
u.
qual.level = (
u8)signal;
1529 iwe.
u.
qual.updated = 0;
1530 #if WIRELESS_EXT > 16
1533 #if WIRELESS_EXT > 18
1537 r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe,
IW_EV_QUAL_LEN);
1550 iwe.
u.
data.length = 0;
1552 r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe,
"");
1570 info_elems, info_elem_len);
1572 int e_len = elem[1];
1573 const unsigned char *e_ptr = elem + 2;
1580 for (i = 0; i < e_len; i++) {
1581 if (e_ptr[i] == 0) {
1585 iwe.
u.
bitrate.value = ((e_ptr[
i] & 0x7f) * 500000);
1587 r = uf_iwe_stream_add_value(info, start_buf, current_val, end_buf, &iwe,
IW_EV_PARAM_LEN);
1596 info_elems, info_elem_len);
1598 int e_len = elem[1];
1599 const unsigned char *e_ptr = elem + 2;
1606 for (i = 0; i < e_len; i++) {
1607 if (e_ptr[i] == 0) {
1611 iwe.
u.
bitrate.value = ((e_ptr[
i] & 0x7f) * 500000);
1613 r = uf_iwe_stream_add_value(info, start_buf, current_val, end_buf, &iwe,
IW_EV_PARAM_LEN);
1621 if ((current_val - start_buf) > IW_EV_LCP_LEN) {
1622 start_buf = current_val;
1626 #if WIRELESS_EXT > 17
1627 memset(&iwe, 0,
sizeof(iwe));
1629 iwe.
u.
data.length = info_elem_len;
1631 r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, info_elems);
1639 return (start_buf - current_ev);
1657 unifi_error(priv,
"unifi_giwscan: not permitted in Mode %d\n",
1664 "unifi_giwscan: buffer (%d bytes) \n",
1667 r = sme_mgt_scan_results_get_async(priv, info, extra, dwrq->
length);
1671 "unifi_giwscan: buffer (%d bytes) not big enough.\n",
1703 struct iw_point *data,
char *essid)
1715 unifi_error(priv,
"unifi_siwessid: not permitted in Mode %d\n",
1722 if (data->
flags & 1) {
1735 for (i = 0; i < len; i++) {
1736 essid_str[
i] = (
isprint(essid[i]) ? essid[
i] :
'?');
1738 essid_str[
i] =
'\0';
1740 unifi_trace(priv,
UDBG1,
"unifi_siwessid: asked for '%*s' (%d)\n", len, essid_str, len);
1741 unifi_trace(priv,
UDBG2,
" with authModeMask = %d", priv->connection_config.authModeMask);
1747 if (essid[len - 1] == 0) {
1751 memcpy(priv->connection_config.ssid.ssid, essid, len);
1752 priv->connection_config.ssid.length = len;
1755 priv->connection_config.ssid.length = 0;
1759 err = sme_mgt_connect(priv);
1762 unifi_error(priv,
"unifi_siwessid: Join failed, status %d\n", err);
1788 unifi_error(priv,
"unifi_giwessid: not permitted in Mode %d\n",
1794 r = sme_mgt_connection_info_get(priv, &connectionInfo);
1837 r = sme_mgt_mib_config_get(priv, &mibConfig);
1840 unifi_error(priv,
"unifi_siwrate: Get CsrWifiSmeMibConfigValue failed.\n");
1848 if (args->
value != -1) {
1853 if (args->
fixed == 1) {
1859 r = sme_mgt_mib_config_set(priv, &mibConfig);
1862 unifi_error(priv,
"unifi_siwrate: Set CsrWifiSmeMibConfigValue failed.\n");
1892 r = sme_mgt_mib_config_get(priv, &mibConfig);
1895 unifi_error(priv,
"unifi_giwrate: Get CsrWifiSmeMibConfigValue failed.\n");
1905 r = sme_mgt_connection_stats_get(priv, &connectionStats);
1913 args->
value = bitrate * 500000;
1928 int val = wrqu->
rts.value;
1935 if (wrqu->
rts.disabled) {
1939 if ( (val < 0) || (val > 2347) )
1946 r = sme_mgt_mib_config_get(priv, &mibConfig);
1949 unifi_error(priv,
"unifi_siwrts: Get CsrWifiSmeMibConfigValue failed.\n");
1954 r = sme_mgt_mib_config_set(priv, &mibConfig);
1957 unifi_error(priv,
"unifi_siwrts: Set CsrWifiSmeMibConfigValue failed.\n");
1979 r = sme_mgt_mib_config_get(priv, &mibConfig);
1982 unifi_error(priv,
"unifi_giwrts: Get CsrWifiSmeMibConfigValue failed.\n");
1987 if (rts_thresh > 2347) {
1991 wrqu->
rts.value = rts_thresh;
1992 wrqu->
rts.disabled = (rts_thresh == 2347);
1993 wrqu->
rts.fixed = 1;
2005 int val = wrqu->
frag.value;
2012 if (wrqu->
frag.disabled)
2015 if ( (val < 256) || (val > 2347) )
2020 r = sme_mgt_mib_config_get(priv, &mibConfig);
2023 unifi_error(priv,
"unifi_siwfrag: Get CsrWifiSmeMibConfigValue failed.\n");
2029 r = sme_mgt_mib_config_set(priv, &mibConfig);
2032 unifi_error(priv,
"unifi_siwfrag: Set CsrWifiSmeMibConfigValue failed.\n");
2054 r = sme_mgt_mib_config_get(priv, &mibConfig);
2057 unifi_error(priv,
"unifi_giwfrag: Get CsrWifiSmeMibConfigValue failed.\n");
2064 wrqu->
frag.value = frag_thresh;
2065 wrqu->
frag.disabled = (frag_thresh >= 2346);
2066 wrqu->
frag.fixed = 1;
2091 unifi_error(priv,
"unifi_siwencode: not permitted in Mode %d\n",
2104 if ((index < 0) || (index > 4)) {
2105 unifi_error(priv,
"unifi_siwencode: Request to set an invalid key (index:%d)", index);
2118 unifi_error(priv,
"unifi_siwencode: Request to set an invalid key (length:%d)",
2124 if ((index < 1) || (index > 4)) {
2126 if (!priv->wep_tx_key_index) {
2127 priv->wep_tx_key_index = 1;
2129 index = priv->wep_tx_key_index;
2133 if (!priv->wep_tx_key_index) {
2134 priv->wep_tx_key_index =
index;
2145 (priv->wep_tx_key_index == index) ?
"tx" :
"",
2149 if (priv->wep_tx_key_index == index) {
2165 unifi_error(priv,
"unifi_siwencode: Set key failed (%d)", rc);
2170 priv->wep_keys[index - 1].len = erq->
length;
2171 memcpy(priv->wep_keys[index - 1].key, extra, erq->
length);
2182 priv->wep_tx_key_index =
index;
2195 unifi_error(priv,
"unifi_siwencode: Set key failed (%d)", rc);
2210 priv->wep_tx_key_index = 0;
2212 unifi_trace(priv,
UDBG1,
"IW_ENCODE_DISABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
2218 unifi_trace(priv,
UDBG1,
"IW_ENCODE_RESTRICTED: CSR_WIFI_SME_AUTH_MODE_80211_SHARED\n");
2225 unifi_trace(priv,
UDBG1,
"IW_ENCODE_OPEN: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
2230 if (privacy != -1) {
2260 unifi_error(priv,
"unifi_giwencode: not permitted in Mode %d\n",
2280 int index = priv->wep_tx_key_index;
2284 erq->
length = priv->wep_keys[index - 1].len;
2285 memcpy(extra, priv->wep_keys[index - 1].key, erq->
length);
2287 unifi_notice(priv,
"unifi_giwencode: Surprise, do not have a valid key index (%d)\n",
2313 unifi_error(priv,
"unifi_siwpower: not permitted in Mode %d\n",
2322 unifi_error(priv,
"unifi_siwpower: Get unifi_PowerConfigValue failed.\n");
2326 listen_interval = -1;
2340 listen_interval = args->
value / 1000;
2363 if (listen_interval > 0) {
2369 if (wake_for_dtim >= 0) {
2370 powerConfig.
rxDtims = wake_for_dtim;
2376 unifi_error(priv,
"unifi_siwpower: Set unifi_PowerConfigValue failed.\n");
2400 unifi_error(priv,
"unifi_giwpower: not permitted in Mode %d\n",
2411 unifi_error(priv,
"unifi_giwpower: Get unifi_PowerConfigValue failed.\n");
2477 unifi_error(priv,
"unifi_siwmlme: not permitted in Mode %d\n",
2483 switch (mlme->
cmd) {
2487 sme_mgt_disconnect(priv);
2537 unifi_error(priv,
"unifi_siwgenie: not permitted in Mode %d\n",
2543 if ( priv->connection_config.mlmeAssociateReqInformationElements) {
2544 kfree( priv->connection_config.mlmeAssociateReqInformationElements);
2546 priv->connection_config.mlmeAssociateReqInformationElementsLength = 0;
2547 priv->connection_config.mlmeAssociateReqInformationElements =
NULL;
2549 len = wrqu->
data.length;
2555 priv->connection_config.mlmeAssociateReqInformationElements =
kmalloc(len,
GFP_KERNEL);
2556 if (priv->connection_config.mlmeAssociateReqInformationElements ==
NULL) {
2561 priv->connection_config.mlmeAssociateReqInformationElementsLength = len;
2562 memcpy( priv->connection_config.mlmeAssociateReqInformationElements, extra, len);
2582 unifi_error(priv,
"unifi_giwgenie: not permitted in Mode %d\n",
2588 len = priv->connection_config.mlmeAssociateReqInformationElementsLength;
2591 wrqu->
data.length = 0;
2595 if (wrqu->
data.length < len) {
2599 wrqu->
data.length = len;
2600 memcpy(extra, priv->connection_config.mlmeAssociateReqInformationElements, len);
2635 unifi_error(priv,
"unifi_siwauth: not permitted in Mode %d\n",
2651 if (wrqu->
param.value == 0) {
2652 unifi_trace(priv,
UDBG5,
"IW_AUTH_WPA_ENABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
2675 unifi_trace(priv,
UDBG1,
"IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_OPEN_SYSTEM)\n", wrqu->
param.value);
2679 unifi_trace(priv,
UDBG1,
"IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_SHARED_KEY)\n", wrqu->
param.value);
2687 if (new_auth == 0) {
2692 priv->connection_config.authModeMask = new_auth;
2698 priv->ignore_bssid_join =
TRUE;
2734 priv->connection_config.encryptionModeMask |=
2738 priv->connection_config.encryptionModeMask |=
2742 priv->connection_config.encryptionModeMask |=
2746 priv->connection_config.encryptionModeMask |=
2794 priv->connection_config.authModeMask);
2805 priv->connection_config.authModeMask);
2850 unifi_trace(priv,
UDBG2,
"authModeMask = %d", priv->connection_config.authModeMask);
2864 err = _unifi_siwauth(dev, info, wrqu, extra);
2907 unsigned char *keydata;
2910 unsigned char *a = (
unsigned char *)ext->
addr.sa_data;
2920 unifi_error(priv,
"unifi_siwencodeext: not permitted in Mode %d\n",
2926 unifi_trace(priv,
UDBG1,
"siwencodeext: flags=0x%X, alg=%d, ext_flags=0x%X, len=%d, index=%d,\n",
2938 memset(&sme_key, 0,
sizeof(sme_key));
2940 keydata = (
unsigned char *)(ext + 1);
2966 unifi_error(priv,
"Delete key request was rejected with result %d\n", r);
3006 unifi_error(priv,
"siwencodeext: Set key failed (%d)", r);
3027 memcpy(tkip_key, keydata, 16);
3028 memcpy(tkip_key + 16, keydata + 24, 8);
3029 memcpy(tkip_key + 24, keydata + 16, 8);
3060 unifi_error(priv,
"SETKEYS request was rejected with result %d\n", r);
3075 err = _unifi_siwencodeext(dev, info, wrqu, extra);
3109 #define UNIFI_PMKID_KEY_SIZE 16
3126 unifi_error(priv,
"unifi_siwpmksa: not permitted in Mode %d\n",
3133 pmksa->
bssid.sa_data);
3136 switch (pmksa->
cmd) {
3163 r = sme_mgt_pmkid(priv, action, &pmkid_list);
3166 unifi_error(priv,
"SIWPMKSA: Set PMKID's Failed.\n");
3197 return &priv->wext_wireless_stats;
3205 static const struct iw_priv_args unifi_private_args[] = {
3214 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3220 #ifdef CSR_SUPPORT_WEXT_AP
3225 #ifdef ANDROID_BUILD
3260 #if WIRELESS_EXT > 17
3289 #if WIRELESS_EXT > 17
3312 static const iw_handler unifi_private_handler[] =
3318 #ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
3329 #ifdef CSR_SUPPORT_WEXT_AP
3337 #ifdef ANDROID_BUILD
3368 .num_standard =
sizeof(unifi_handler) /
sizeof(
iw_handler),
3369 .num_private =
sizeof(unifi_private_handler) /
sizeof(
iw_handler),
3370 .num_private_args =
sizeof(unifi_private_args) /
sizeof(
struct iw_priv_args),
3372 .
private = (
iw_handler *) unifi_private_handler,
3373 .private_args = (
struct iw_priv_args *) unifi_private_args,