1 From 582a6ffea61c1f87b1d42f2db631470ca6876095 Mon Sep 17 00:00:00 2001
2 From: David-John Willis <John.Willis@Distant-earth.com>
3 Date: Fri, 28 Aug 2009 21:06:21 +0100
4 Subject: [PATCH 8/8] Update Wireless EXT with test code.
7 sta_dk_4_0_4_32/pform/linux/inc/iw_ioctl.h | 2 +-
8 sta_dk_4_0_4_32/pform/linux/src/iw_ioctl.c | 178 +++++++++++++---------------
9 2 files changed, 82 insertions(+), 98 deletions(-)
11 diff --git a/sta_dk_4_0_4_32/pform/linux/inc/iw_ioctl.h b/sta_dk_4_0_4_32/pform/linux/inc/iw_ioctl.h
12 index ff64523..4b4eb9d 100755
13 --- a/sta_dk_4_0_4_32/pform/linux/inc/iw_ioctl.h
14 +++ b/sta_dk_4_0_4_32/pform/linux/inc/iw_ioctl.h
15 @@ -26,6 +26,6 @@ extern ULONG UtilGetParam(
19 -extern void tiwlan_iwhandler_init(struct net_device *dev);
20 +//extern void tiwlan_iwhandler_init(struct net_device *dev);
22 #endif /* _IW_IOCTL_H_ */
23 diff --git a/sta_dk_4_0_4_32/pform/linux/src/iw_ioctl.c b/sta_dk_4_0_4_32/pform/linux/src/iw_ioctl.c
24 index a975afa..7245635 100755
25 --- a/sta_dk_4_0_4_32/pform/linux/src/iw_ioctl.c
26 +++ b/sta_dk_4_0_4_32/pform/linux/src/iw_ioctl.c
29 - * Copyright (C) 2009 John Willis
30 - * Copyright (C) 2008 Texas Instruments/Jorjin Technologies inc.
32 - * This program is free software; you can redistribute it and/or modify
33 - * it under the terms of the GNU General Public License as published by
34 - * the Free Software Foundation; either version 2 of the License, or
35 - * (at your option) any later version.
37 - * This program is distributed in the hope that it will be useful,
38 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
39 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 - * GNU General Public License for more details.
43 - * This file implements support for Linux Wireless Extensions for TI 1251 driver.
47 -#include <linux/ctype.h>
48 -#include <linux/delay.h>
49 -#include <linux/if.h>
50 +/* ioctl() (mostly Linux Wireless Extensions) routines for TI 1251 driver */
52 #include <linux/if_arp.h>
53 #include <linux/wireless.h>
54 -#include <linux/bitops.h>
56 #include <net/iw_handler.h>
57 #include <net/ieee80211.h>
59 #include "osAdapter.h"
63 #include "scanMngrTypes.h"
69 static const long freq_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442,
70 2447, 2452, 2457, 2462, 2467, 2472, 2484 };
71 @@ -119,11 +96,6 @@ void init_scan_params(void)
72 iw_scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.txPowerDbm = 1;
75 -static int iw_ioctl_commit(struct net_device *dev, struct iw_request_info *info, char *name, char *extra)
80 static int iw_get_name(struct net_device *dev,
81 struct iw_request_info *info,
82 char *name, char *extra)
83 @@ -131,7 +103,7 @@ static int iw_get_name(struct net_device *dev,
85 printk("%s Call\n", __FUNCTION__);
90 int len, i, over2 = 0;
92 @@ -156,7 +128,7 @@ static int iw_ioctl_siwencode(struct net_device *dev,
93 PTIWLN_ADAPTER_T pAdapter = &(((tiwlan_net_dev_t *)(dev->priv))->adapter);
100 printk("%s Call\n", __FUNCTION__);
101 @@ -175,7 +147,7 @@ static int iw_ioctl_siwencode(struct net_device *dev,
104 UtilWepStatusGet(pAdapter, (UINT8 *)&cipher, &len);
107 if (erq->flags & IW_ENCODE_DISABLED) {
108 cipherSuite_e val=RSN_CIPHER_NONE;
109 UtilWepStatusSet(pAdapter, (UINT8 *)&val, sizeof(val));
110 @@ -186,10 +158,10 @@ static int iw_ioctl_siwencode(struct net_device *dev,
111 if (erq->length > 0) {
113 int len = erq->length <= 5 ? 5 : 13;
116 cipherSuite_e val=RSN_CIPHER_WEP;
117 UtilWepStatusSet(pAdapter, (UINT8 *)&val, sizeof(val));
120 if (len > erq->length)
121 memset(keybuf + erq->length, 0, len - erq->length);
122 memcpy(wep.KeyMaterial, keybuf, len);
123 @@ -201,7 +173,7 @@ static int iw_ioctl_siwencode(struct net_device *dev,
124 /* No key data - just set the default TX key index */
129 memset(&key, 0, sizeof(securityKeys_t));
131 if (!UtilWepKeyGet(pAdapter, (UINT8 *)&key, sizeof(securityKeys_t)))
132 @@ -218,13 +190,13 @@ static int iw_ioctl_siwencode(struct net_device *dev,
145 if (erq->flags & IW_ENCODE_OPEN)
147 UINT8 MixedMode = true;
148 @@ -284,7 +256,7 @@ static int iw_ioctl_giwencode(struct net_device *dev,
150 if (!UtilWepKeyGet(pAdapter, (PUCHAR)&wkey, sizeof(securityKeys_t)))
152 - printk("iw_ioctl_giwencode KeyIndex %x , keyLength=%d\n",
153 + printk("iw_ioctl_giwencode KeyIndex %x , keyLength=%d\n",
154 wkey.keyIndex, wkey.encLen);
157 @@ -315,8 +287,8 @@ static int iw_ioctl_giwencode(struct net_device *dev,
158 erq->flags |= IW_ENCODE_OPEN;
160 erq->flags |= IW_ENCODE_RESTRICTED;
168 @@ -326,7 +298,7 @@ static int iw_ioctl_siwrate(struct net_device *dev,
170 PTIWLN_ADAPTER_T pAdapter = &(((tiwlan_net_dev_t *)(dev->priv))->adapter);
175 printk("%s Call\n", __FUNCTION__);
177 @@ -334,7 +306,7 @@ static int iw_ioctl_siwrate(struct net_device *dev,
180 val = (rrq->value*2/1000000);
183 return UtilDesiredRatesSet(pAdapter, (UINT8 *)&val, 4);
186 @@ -372,7 +344,7 @@ static int iw_ioctl_giwaplist(struct net_device *dev,
187 struct iw_request_info *info,
188 struct iw_point *data, char *extra)
193 PTIWLN_ADAPTER_T pAdapter = &(((tiwlan_net_dev_t *)(dev->priv))->adapter);
194 struct sockaddr addr[IW_MAX_AP];
195 @@ -382,7 +354,7 @@ static int iw_ioctl_giwaplist(struct net_device *dev,
196 OS_802_11_BSSID_EX *bssid;
197 OS_802_11_BSSID_LIST_EX *list;
202 printk("%s Call\n", __FUNCTION__);
204 @@ -395,9 +367,9 @@ static int iw_ioctl_giwaplist(struct net_device *dev,
205 printk("bssid 0x%x\n",bssid);
206 number_items = list->NumberOfItems;
207 printk("number_items 0x%x\n",number_items);
210 data->length = number_items;
213 for (i=0;i<number_items;i++)
215 addr[i].sa_family = ARPHRD_ETHER;
216 @@ -409,7 +381,7 @@ static int iw_ioctl_giwaplist(struct net_device *dev,
218 bssid = (OS_802_11_BSSID_EX *) (((char *) bssid) + bssid->Length);
222 memcpy(extra, &addr, sizeof(addr[0]) * data->length);
223 data->flags = 1; /* has quality information */
224 memcpy(extra + sizeof(addr[0]) * data->length, &qual,
225 @@ -438,7 +410,7 @@ static int iw_ioctl_siwrts(struct net_device *dev,
228 UtilRtsThresholdSet(pAdapter, (UINT8 *)&val, 4);
234 @@ -559,7 +531,7 @@ static int iw_ioctl_siwfreq(struct net_device *dev,
242 freq->m / 100000 >= freq_list[0] &&
243 @@ -607,7 +579,7 @@ static int iw_ioctl_giwfreq(struct net_device *dev,
244 static int iw_ioctl_siwessid(struct net_device *dev,
245 struct iw_request_info *info,
246 struct iw_point *data, char *ssid)
249 PTIWLN_ADAPTER_T pAdapter = &(((tiwlan_net_dev_t *)(dev->priv))->adapter);
250 OS_802_11_SSID essid;
251 OS_802_11_MAC_ADDRESS bssid = { 0xff,0xff,0xff,0xff,0xff,0xff };
252 @@ -645,7 +617,7 @@ static int iw_ioctl_giwessid(struct net_device *dev,
253 UtilGetSSID(pAdapter, (UINT8 *)&ssid, &len);
254 data->length = ssid.SsidLength;
255 memcpy(essid, ssid.Ssid, ssid.SsidLength);
261 @@ -676,9 +648,9 @@ static int iw_ioctl_siwmode(struct net_device *dev,
267 UtilInfrastructureModeSet(pAdapter, (UINT8 *)&val, 4);
273 @@ -845,7 +817,7 @@ static int iw_ioctl_siwpower(struct net_device *dev,
275 PTIWLN_ADAPTER_T pAdapter = &(((tiwlan_net_dev_t *)(dev->priv))->adapter);
276 UINT32 val=POWER_MODE_ACTIVE;
280 printk("%s Call\n", __FUNCTION__);
282 @@ -884,12 +856,12 @@ static int iw_ioctl_giwpower(struct net_device *dev,
284 PTIWLN_ADAPTER_T pAdapter = &(((tiwlan_net_dev_t *)(dev->priv))->adapter);
285 UINT32 val=POWER_MODE_ACTIVE, len;
289 printk("%s Call\n", __FUNCTION__);
291 UtilPowerModeGet(pAdapter, (UINT8 *)&val, &len);
294 if (val==POWER_MODE_ACTIVE) {
297 @@ -906,7 +878,7 @@ static int iw_ioctl_siwretry(struct net_device *dev,
298 struct iw_param *rrq, char *extra)
300 PTIWLN_ADAPTER_T pAdapter = &(((tiwlan_net_dev_t *)(dev->priv))->adapter);
304 printk("%s Call\n", __FUNCTION__);
306 @@ -935,11 +907,11 @@ static int iw_ioctl_giwretry(struct net_device *dev,
307 PTIWLN_ADAPTER_T pAdapter = &(((tiwlan_net_dev_t *)(dev->priv))->adapter);
308 u16 shortretry, longretry;
313 printk("%s Call\n", __FUNCTION__);
315 - if (UtilShortRetryGet(pAdapter, (UINT8 *)&shortretry, &len)!=0 ||
316 + if (UtilShortRetryGet(pAdapter, (UINT8 *)&shortretry, &len)!=0 ||
317 UtilLongRetryGet(pAdapter, (UINT8 *)&longretry, &len)!=0)
320 @@ -1001,12 +973,12 @@ static int iw_ioctl_siwscan(struct net_device *dev,
322 PTIWLN_ADAPTER_T pAdapter = &(((tiwlan_net_dev_t *)(dev->priv))->adapter);
326 scan_TimeStamp = jiffies;
330 ret = UtilStartAppScanSet(pAdapter, (PCHAR)&iw_appScanParams, sizeof(iw_appScanParams));
336 @@ -1031,7 +1003,7 @@ static inline int iw_scan_list(struct net_device *dev,
343 printk("%s Call\n", __FUNCTION__);
345 @@ -1041,7 +1013,7 @@ static inline int iw_scan_list(struct net_device *dev,
346 list = (OS_802_11_BSSID_LIST_EX *) list_buf;
347 bssid = &list->Bssid[0];
348 number_items = list->NumberOfItems;
352 for (i=0;i<number_items;i++)
354 @@ -1052,7 +1024,7 @@ static inline int iw_scan_list(struct net_device *dev,
355 iwe.len = IW_EV_ADDR_LEN;
356 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
360 memset(&iwe, 0, sizeof(iwe));
361 iwe.cmd = SIOCGIWESSID;
362 iwe.u.data.length = bssid->Ssid.SsidLength;
363 @@ -1060,7 +1032,7 @@ static inline int iw_scan_list(struct net_device *dev,
364 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
365 // printk("essid=%s len=%d\n", bssid->Ssid.Ssid, bssid->Ssid.SsidLength);
366 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, (char *)bssid->Ssid.Ssid);
369 memset(&iwe, 0, sizeof(iwe));
370 iwe.cmd = SIOCGIWMODE;
371 capabilities = bssid->Union.Capabilities;
372 @@ -1074,7 +1046,7 @@ static inline int iw_scan_list(struct net_device *dev,
373 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
378 memset(&iwe, 0, sizeof(iwe));
379 iwe.cmd = SIOCGIWFREQ;
380 chan = bssid->Configuration.Union.channel;
381 @@ -1085,7 +1057,7 @@ static inline int iw_scan_list(struct net_device *dev,
382 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
387 memset(&iwe, 0, sizeof(iwe));
389 iwe.u.qual.qual = bssid->Rssi;
390 @@ -1107,7 +1079,7 @@ static inline int iw_scan_list(struct net_device *dev,
391 iwe.u.data.length = 0;
392 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
393 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, "");
396 /* TODO: add SuppRates into BSS table */
397 memset(&iwe, 0, sizeof(iwe));
398 iwe.cmd = SIOCGIWRATE;
399 @@ -1125,7 +1097,7 @@ static inline int iw_scan_list(struct net_device *dev,
400 /* Check if we added any event */
401 if ((current_val - current_ev) > IW_EV_LCP_LEN)
402 current_ev = current_val;
405 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
406 memset(&iwe, 0, sizeof(iwe));
407 iwe.cmd = IWEVCUSTOM;
408 @@ -1143,14 +1115,14 @@ static inline int iw_scan_list(struct net_device *dev,
409 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
416 IELen += sizeof(OS_802_11_FIXED_IEs);
417 pVarIes = (OS_802_11_VARIABLE_IEs*)&bssid->IEs[IELen];
418 while (IELen < bssid->IELength)
420 -// printk("IELen=%d pVarIes->ElementID=%d\n", IELen, pVarIes->ElementID);
421 +// printk("IELen=%d pVarIes->ElementID=%d\n", IELen, pVarIes->ElementID);
422 if (pVarIes->ElementID == MFIE_TYPE_RSN || pVarIes->ElementID == MFIE_TYPE_GENERIC) {
423 memset(&iwe, 0, sizeof(iwe));
425 @@ -1158,11 +1130,11 @@ static inline int iw_scan_list(struct net_device *dev,
426 current_ev = iwe_stream_add_point(
427 info, current_ev, end_buf, &iwe, (char *)pVarIes);
430 - IELen += (pVarIes->Length + 2);
432 + IELen += (pVarIes->Length + 2);
433 pVarIes = (OS_802_11_VARIABLE_IEs*)&bssid->IEs[IELen];
437 if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
438 /* Ask user space to try again with a bigger buffer */
439 spin_unlock_bh(&lock);
440 @@ -1171,7 +1143,7 @@ static inline int iw_scan_list(struct net_device *dev,
441 // printk("current_ev=%x\n", current_ev);
442 bssid = (OS_802_11_BSSID_EX *) (((char *) bssid) + bssid->Length);
446 spin_unlock_bh(&lock);
447 return current_ev - extra;
449 @@ -1491,7 +1463,7 @@ static int iw_ioctl_siwauth(struct net_device *dev,
453 - return -EOPNOTSUPP;
454 + return -EOPNOTSUPP;
458 @@ -1534,7 +1506,7 @@ static int iw_ioctl_giwauth(struct net_device *dev,
462 - return -EOPNOTSUPP;
463 + return -EOPNOTSUPP;
467 @@ -1546,7 +1518,7 @@ static int iw_ioctl_siwencodeext(struct net_device *dev,
469 printk("%s Call\n", __FUNCTION__);
473 struct hostap_interface *iface = dev->priv;
474 local_info_t *local = iface->local;
475 struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
476 @@ -1712,7 +1684,7 @@ static int iw_ioctl_siwencodeext(struct net_device *dev,
480 - return -EOPNOTSUPP;
481 + return -EOPNOTSUPP;
485 @@ -1723,7 +1695,7 @@ static int iw_ioctl_giwencodeext(struct net_device *dev,
487 printk("%s Call\n", __FUNCTION__);
491 struct hostap_interface *iface = dev->priv;
492 local_info_t *local = iface->local;
493 struct prism2_crypt_data **crypt;
494 @@ -1788,7 +1760,7 @@ static int iw_ioctl_giwencodeext(struct net_device *dev,
498 - return -EOPNOTSUPP;
499 + return -EOPNOTSUPP;
501 #endif /* WIRELESS_EXT > 17 */
503 @@ -1832,7 +1804,7 @@ static int iw_ioctl_siwmlme(struct net_device *dev,
505 static const iw_handler ti_handler[] =
507 - (iw_handler) iw_ioctl_commit, /* SIOCSIWCOMMIT */
508 + (iw_handler) NULL, /* SIOCSIWCOMMIT */
509 (iw_handler) iw_get_name, /* SIOCGIWNAME */
510 (iw_handler) NULL, /* SIOCSIWNWID */
511 (iw_handler) NULL, /* SIOCGIWNWID */
512 @@ -1842,20 +1814,31 @@ static const iw_handler ti_handler[] =
513 (iw_handler) iw_ioctl_giwmode, /* SIOCGIWMODE */
514 (iw_handler) iw_ioctl_siwsens, /* SIOCSIWSENS */
515 (iw_handler) iw_ioctl_giwsens, /* SIOCGIWSENS */
516 - (iw_handler) NULL, /* SIOCSIWRANGE */
517 + (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
518 (iw_handler) iw_ioctl_giwrange, /* SIOCGIWRANGE */
519 - (iw_handler) NULL, /* SIOCSIWPRIV */
520 - (iw_handler) NULL, /* SIOCGIWPRIV */
521 - (iw_handler) NULL, /* SIOCSIWSTATS */
522 - (iw_handler) NULL, /* SIOCGIWSTATS */
523 - iw_handler_set_spy, /* SIOCSIWSPY */
524 - iw_handler_get_spy, /* SIOCGIWSPY */
525 - iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
526 - iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
527 + (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
528 + (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
529 + (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
530 + (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
531 +#if WIRELESS_EXT > 15
532 + (iw_handler) NULL, /* SIOCSIWSPY */
533 + (iw_handler) NULL, /* SIOCGIWSPY */
534 + (iw_handler) NULL, /* SIOCSIWTHRSPY */
535 + (iw_handler) NULL, /* SIOCGIWTHRSPY */
536 +#else /* WIRELESS_EXT > 15 */
537 + (iw_handler) NULL, /* SIOCSIWSPY */
538 + (iw_handler) NULL, /* SIOCGIWSPY */
539 + (iw_handler) NULL, /* -- hole -- */
540 + (iw_handler) NULL, /* -- hole -- */
541 +#endif /* WIRELESS_EXT > 15 */
542 (iw_handler) iw_ioctl_siwap, /* SIOCSIWAP */
543 (iw_handler) iw_ioctl_giwap, /* SIOCGIWAP */
544 +#if WIRELESS_EXT > 17
545 (iw_handler) iw_ioctl_siwmlme, /* SIOCSIWMLME */
546 - (iw_handler) iw_ioctl_giwaplist, /* SIOCGIWAPLIST - Deprecated */
547 +#else /* WIRELESS_EXT > 17 */
548 + (iw_handler) NULL, /* -- hole -- */
549 +#endif /* WIRELESS_EXT > 17 */
550 + (iw_handler) iw_ioctl_giwaplist, /* SIOCGIWAPLIST */
551 (iw_handler) iw_ioctl_siwscan, /* SIOCSIWSCAN */
552 (iw_handler) iw_ioctl_giwscan, /* SIOCGIWSCAN */
553 (iw_handler) iw_ioctl_siwessid, /* SIOCSIWESSID */
554 @@ -1878,6 +1861,7 @@ static const iw_handler ti_handler[] =
555 (iw_handler) iw_ioctl_giwencode, /* SIOCGIWENCODE */
556 (iw_handler) iw_ioctl_siwpower, /* SIOCSIWPOWER */
557 (iw_handler) iw_ioctl_giwpower, /* SIOCGIWPOWER */
558 +#if WIRELESS_EXT > 17
559 (iw_handler) NULL, /* -- hole -- */
560 (iw_handler) NULL, /* -- hole -- */
561 (iw_handler) iw_ioctl_siwgenie, /* SIOCSIWGENIE */
562 @@ -1888,6 +1872,7 @@ static const iw_handler ti_handler[] =
563 (iw_handler) iw_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
564 (iw_handler) NULL, /* SIOCSIWPMKSA */
565 (iw_handler) NULL, /* -- hole -- */
566 +#endif /* WIRELESS_EXT > 17 */
570 @@ -1918,6 +1903,5 @@ static const struct iw_handler_def ti_iw_handler_def =
572 void tiwlan_iwhandler_init(struct net_device *dev)
574 - dev->wireless_handlers = (struct iw_handler_def *) &ti_iw_handler_def;
575 - printk("TIWLAN :: Wireless Extentions Active");
576 + dev->wireless_handlers = (struct iw_handler_def *) &ti_iw_handler_def;