-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcfg80211.c
1927 lines (1557 loc) · 48.5 KB
/
cfg80211.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2010, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************/
#define RTMP_MODULE_OS
/*#include "rt_config.h" */
#include "rtmp_comm.h"
#include "rt_os_util.h"
#include "rt_os_net.h"
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
#ifdef RT_CFG80211_SUPPORT
/* 36 ~ 64, 100 ~ 136, 140 ~ 161 */
#define CFG80211_NUM_OF_CHAN_5GHZ \
(sizeof(Cfg80211_Chan)-CFG80211_NUM_OF_CHAN_2GHZ)
#ifdef OS_ABL_FUNC_SUPPORT
/*
Array of bitrates the hardware can operate with
in this band. Must be sorted to give a valid "supported
rates" IE, i.e. CCK rates first, then OFDM.
For HT, assign MCS in another structure, ieee80211_sta_ht_cap.
*/
const struct ieee80211_rate Cfg80211_SupRate[12] = {
{
.flags = IEEE80211_RATE_SHORT_PREAMBLE,
.bitrate = 10,
.hw_value = 0,
.hw_value_short = 0,
},
{
.flags = IEEE80211_RATE_SHORT_PREAMBLE,
.bitrate = 20,
.hw_value = 1,
.hw_value_short = 1,
},
{
.flags = IEEE80211_RATE_SHORT_PREAMBLE,
.bitrate = 55,
.hw_value = 2,
.hw_value_short = 2,
},
{
.flags = IEEE80211_RATE_SHORT_PREAMBLE,
.bitrate = 110,
.hw_value = 3,
.hw_value_short = 3,
},
{
.flags = 0,
.bitrate = 60,
.hw_value = 4,
.hw_value_short = 4,
},
{
.flags = 0,
.bitrate = 90,
.hw_value = 5,
.hw_value_short = 5,
},
{
.flags = 0,
.bitrate = 120,
.hw_value = 6,
.hw_value_short = 6,
},
{
.flags = 0,
.bitrate = 180,
.hw_value = 7,
.hw_value_short = 7,
},
{
.flags = 0,
.bitrate = 240,
.hw_value = 8,
.hw_value_short = 8,
},
{
.flags = 0,
.bitrate = 360,
.hw_value = 9,
.hw_value_short = 9,
},
{
.flags = 0,
.bitrate = 480,
.hw_value = 10,
.hw_value_short = 10,
},
{
.flags = 0,
.bitrate = 540,
.hw_value = 11,
.hw_value_short = 11,
},
};
#endif /* OS_ABL_FUNC_SUPPORT */
/* all available channels */
static const UCHAR Cfg80211_Chan[] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
/* 802.11 UNI / HyperLan 2 */
36, 38, 40, 44, 46, 48, 52, 54, 56, 60, 62, 64,
/* 802.11 HyperLan 2 */
100, 104, 108, 112, 116, 118, 120, 124, 126, 128, 132, 134, 136,
/* 802.11 UNII */
140, 149, 151, 153, 157, 159, 161, 165, 167, 169, 171, 173,
/* Japan */
184, 188, 192, 196, 208, 212, 216,
};
static const UINT32 CipherSuites[] = {
WLAN_CIPHER_SUITE_WEP40,
WLAN_CIPHER_SUITE_WEP104,
WLAN_CIPHER_SUITE_TKIP,
WLAN_CIPHER_SUITE_CCMP,
};
/*
The driver's regulatory notification callback.
*/
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30))
static INT32 CFG80211_RegNotifier(
IN struct wiphy *pWiphy,
IN struct regulatory_request *pRequest);
#else
static INT32 CFG80211_RegNotifier(
IN struct wiphy *pWiphy,
IN enum reg_set_by Request);
#endif /* LINUX_VERSION_CODE */
/* =========================== Private Function ============================== */
/* get RALINK pAd control block in 80211 Ops */
#define MAC80211_PAD_GET(__pAd, __pWiphy) \
{ \
ULONG *__pPriv; \
__pPriv = (ULONG *)(wiphy_priv(__pWiphy)); \
__pAd = (VOID *)(*__pPriv); \
if (__pAd == NULL) \
{ \
DBGPRINT(RT_DEBUG_ERROR, \
("80211> %s but pAd = NULL!", __FUNCTION__)); \
return -EINVAL; \
} \
}
/*
========================================================================
Routine Description:
Set channel.
Arguments:
pWiphy - Wireless hardware description
pChan - Channel information
ChannelType - Channel type
Return Value:
0 - success
-x - fail
Note:
For iw utility: set channel, set freq
enum nl80211_channel_type {
NL80211_CHAN_NO_HT,
NL80211_CHAN_HT20,
NL80211_CHAN_HT40MINUS,
NL80211_CHAN_HT40PLUS
};
========================================================================
*/
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
static int CFG80211_OpsChannelSet(
IN struct wiphy *pWiphy,
IN struct net_device *pDev,
IN struct ieee80211_channel *pChan,
IN enum nl80211_channel_type ChannelType)
#else
static int CFG80211_OpsChannelSet(
IN struct wiphy *pWiphy,
IN struct ieee80211_channel *pChan,
IN enum nl80211_channel_type ChannelType)
#endif /* LINUX_VERSION_CODE */
{
VOID *pAd;
CFG80211_CB *p80211CB;
CMD_RTPRIV_IOCTL_80211_CHAN ChanInfo;
UINT32 ChanId;
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
MAC80211_PAD_GET(pAd, pWiphy);
/* get channel number */
ChanId = ieee80211_frequency_to_channel(pChan->center_freq);
CFG80211DBG(RT_DEBUG_ERROR, ("80211> Channel = %d\n", ChanId));
CFG80211DBG(RT_DEBUG_ERROR, ("80211> ChannelType = %d\n", ChannelType));
/* init */
memset(&ChanInfo, 0, sizeof(ChanInfo));
ChanInfo.ChanId = ChanId;
p80211CB = NULL;
RTMP_DRIVER_80211_CB_GET(pAd, &p80211CB);
if (p80211CB == NULL)
{
CFG80211DBG(RT_DEBUG_ERROR, ("80211> p80211CB == NULL!\n"));
return 0;
}
if (p80211CB->pCfg80211_Wdev->iftype == NL80211_IFTYPE_STATION)
ChanInfo.IfType = RT_CMD_80211_IFTYPE_STATION;
else if (p80211CB->pCfg80211_Wdev->iftype == NL80211_IFTYPE_ADHOC)
ChanInfo.IfType = RT_CMD_80211_IFTYPE_ADHOC;
else if (p80211CB->pCfg80211_Wdev->iftype == NL80211_IFTYPE_MONITOR)
ChanInfo.IfType = RT_CMD_80211_IFTYPE_MONITOR;
if (ChannelType == NL80211_CHAN_NO_HT)
ChanInfo.ChanType = RT_CMD_80211_CHANTYPE_NOHT;
else if (ChannelType == NL80211_CHAN_HT20)
ChanInfo.ChanType = RT_CMD_80211_CHANTYPE_HT20;
else if (ChannelType == NL80211_CHAN_HT40MINUS)
ChanInfo.ChanType = RT_CMD_80211_CHANTYPE_HT40MINUS;
else if (ChannelType == NL80211_CHAN_HT40PLUS)
ChanInfo.ChanType = RT_CMD_80211_CHANTYPE_HT40PLUS;
ChanInfo.MonFilterFlag = p80211CB->MonFilterFlag;
/* set channel */
RTMP_DRIVER_80211_CHAN_SET(pAd, &ChanInfo);
return 0;
} /* End of CFG80211_OpsChannelSet */
/*
========================================================================
Routine Description:
Change type/configuration of virtual interface.
Arguments:
pWiphy - Wireless hardware description
IfIndex - Interface index
Type - Interface type, managed/adhoc/ap/station, etc.
pFlags - Monitor flags
pParams - Mesh parameters
Return Value:
0 - success
-x - fail
Note:
For iw utility: set type, set monitor
========================================================================
*/
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
static int CFG80211_OpsVirtualInfChg(
IN struct wiphy *pWiphy,
IN struct net_device *pNetDevIn,
IN enum nl80211_iftype Type,
IN u32 *pFlags,
struct vif_params *pParams)
#else
static int CFG80211_OpsVirtualInfChg(
IN struct wiphy *pWiphy,
IN int IfIndex,
IN enum nl80211_iftype Type,
IN u32 *pFlags,
struct vif_params *pParams)
#endif /* LINUX_VERSION_CODE */
{
VOID *pAd;
CFG80211_CB *pCfg80211_CB;
struct net_device *pNetDev;
UINT32 Filter;
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
MAC80211_PAD_GET(pAd, pWiphy);
CFG80211DBG(RT_DEBUG_ERROR, ("80211> Type = %d\n", Type));
/* sanity check */
#ifdef CONFIG_STA_SUPPORT
if ((Type != NL80211_IFTYPE_ADHOC) &&
(Type != NL80211_IFTYPE_STATION) &&
(Type != NL80211_IFTYPE_MONITOR))
#endif /* CONFIG_STA_SUPPORT */
{
DBGPRINT(RT_DEBUG_ERROR, ("80211> Wrong interface type %d!\n", Type));
return -EINVAL;
} /* End of if */
/* update interface type */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
pNetDev = pNetDevIn;
#else
pNetDev = __dev_get_by_index(&init_net, IfIndex);
#endif /* LINUX_VERSION_CODE */
if (pNetDev == NULL)
return -ENODEV;
/* End of if */
pNetDev->ieee80211_ptr->iftype = Type;
if (pFlags != NULL)
{
Filter = 0;
if (((*pFlags) & NL80211_MNTR_FLAG_FCSFAIL) == NL80211_MNTR_FLAG_FCSFAIL)
Filter |= RT_CMD_80211_FILTER_FCSFAIL;
if (((*pFlags) & NL80211_MNTR_FLAG_FCSFAIL) == NL80211_MNTR_FLAG_PLCPFAIL)
Filter |= RT_CMD_80211_FILTER_PLCPFAIL;
if (((*pFlags) & NL80211_MNTR_FLAG_CONTROL) == NL80211_MNTR_FLAG_CONTROL)
Filter |= RT_CMD_80211_FILTER_CONTROL;
if (((*pFlags) & NL80211_MNTR_FLAG_CONTROL) == NL80211_MNTR_FLAG_OTHER_BSS)
Filter |= RT_CMD_80211_FILTER_OTHER_BSS;
} /* End of if */
RTMP_DRIVER_80211_VIF_SET(pAd, Filter, Type);
RTMP_DRIVER_80211_CB_GET(pAd, &pCfg80211_CB);
pCfg80211_CB->MonFilterFlag = Filter;
return 0;
} /* End of CFG80211_OpsVirtualInfChg */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30))
#if defined(SIOCGIWSCAN) || defined(RT_CFG80211_SUPPORT)
extern int rt_ioctl_siwscan(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wreq, char *extra);
#endif
/*
========================================================================
Routine Description:
Request to do a scan. If returning zero, the scan request is given
the driver, and will be valid until passed to cfg80211_scan_done().
For scan results, call cfg80211_inform_bss(); you can call this outside
the scan/scan_done bracket too.
Arguments:
pWiphy - Wireless hardware description
pNdev - Network device interface
pRequest - Scan request
Return Value:
0 - success
-x - fail
Note:
For iw utility: scan
struct cfg80211_scan_request {
struct cfg80211_ssid *ssids;
int n_ssids;
struct ieee80211_channel **channels;
u32 n_channels;
const u8 *ie;
size_t ie_len;
* @ssids: SSIDs to scan for (active scan only)
* @n_ssids: number of SSIDs
* @channels: channels to scan on.
* @n_channels: number of channels for each band
* @ie: optional information element(s) to add into Probe Request or %NULL
* @ie_len: length of ie in octets
========================================================================
*/
static int CFG80211_OpsScan(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev,
IN struct cfg80211_scan_request *pRequest)
{
#ifdef CONFIG_STA_SUPPORT
VOID *pAd;
CFG80211_CB *pCfg80211_CB;
#ifdef WPA_SUPPLICANT_SUPPORT
struct iw_scan_req IwReq;
union iwreq_data Wreq;
#endif /* WPA_SUPPLICANT_SUPPORT */
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
MAC80211_PAD_GET(pAd, pWiphy);
/* sanity check */
if ((pNdev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) &&
(pNdev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC))
{
return -EOPNOTSUPP;
} /* End of if */
if (RTMP_DRIVER_IOCTL_SANITY_CHECK(pAd, NULL) != NDIS_STATUS_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE, ("80211> Network is down!\n"));
return -ENETDOWN;
} /* End of if */
if (RTMP_DRIVER_80211_SCAN(pAd) != NDIS_STATUS_SUCCESS)
return -EBUSY; /* scanning */
/* End of if */
RTMP_DRIVER_80211_CB_GET(pAd, &pCfg80211_CB);
pCfg80211_CB->pCfg80211_ScanReq = pRequest; /* used in scan end */
#ifdef WPA_SUPPLICANT_SUPPORT
memset(&Wreq, 0, sizeof(Wreq));
memset(&IwReq, 0, sizeof(IwReq));
if ((pRequest->ssids != NULL) &&
(sizeof(pRequest->ssids->ssid) <= sizeof(IwReq.essid)))
{
/* use 1st SSID in the requested SSID list */
IwReq.essid_len = pRequest->ssids->ssid_len;
memcpy(IwReq.essid, pRequest->ssids->ssid, sizeof(IwReq.essid));
#if WIRELESS_EXT > 17
Wreq.data.flags |= IW_SCAN_THIS_ESSID;
Wreq.data.length = sizeof(struct iw_scan_req);
#endif /* WIRELESS_EXT */
}
rt_ioctl_siwscan(pNdev, NULL, &Wreq, (char *)&IwReq);
#else
rt_ioctl_siwscan(pNdev, NULL, NULL, NULL);
#endif /* WPA_SUPPLICANT_SUPPORT */
return 0;
#else
return -EOPNOTSUPP;
#endif /* CONFIG_STA_SUPPORT */
} /* End of CFG80211_OpsScan */
#endif /* LINUX_VERSION_CODE */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
#ifdef CONFIG_STA_SUPPORT
/*
========================================================================
Routine Description:
Join the specified IBSS (or create if necessary). Once done, call
cfg80211_ibss_joined(), also call that function when changing BSSID due
to a merge.
Arguments:
pWiphy - Wireless hardware description
pNdev - Network device interface
pParams - IBSS parameters
Return Value:
0 - success
-x - fail
Note:
For iw utility: ibss join
No fixed-freq and fixed-bssid support.
========================================================================
*/
static int CFG80211_OpsIbssJoin(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev,
IN struct cfg80211_ibss_params *pParams)
{
VOID *pAd;
CMD_RTPRIV_IOCTL_80211_IBSS IbssInfo;
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
MAC80211_PAD_GET(pAd, pWiphy);
CFG80211DBG(RT_DEBUG_ERROR, ("80211> SSID = %s\n",
pParams->ssid));
CFG80211DBG(RT_DEBUG_ERROR, ("80211> Beacon Interval = %d\n",
pParams->beacon_interval));
/* init */
memset(&IbssInfo, 0, sizeof(IbssInfo));
IbssInfo.BeaconInterval = pParams->beacon_interval;
IbssInfo.pSsid = pParams->ssid;
/* ibss join */
RTMP_DRIVER_80211_IBSS_JOIN(pAd, &IbssInfo);
return 0;
} /* End of CFG80211_OpsIbssJoin */
/*
========================================================================
Routine Description:
Leave the IBSS.
Arguments:
pWiphy - Wireless hardware description
pNdev - Network device interface
Return Value:
0 - success
-x - fail
Note:
For iw utility: ibss leave
========================================================================
*/
static int CFG80211_OpsIbssLeave(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev)
{
VOID *pAd;
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
MAC80211_PAD_GET(pAd, pWiphy);
RTMP_DRIVER_80211_STA_LEAVE(pAd);
return 0;
} /* End of CFG80211_OpsIbssLeave */
#endif /* CONFIG_STA_SUPPORT */
#endif /* LINUX_VERSION_CODE */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
/*
========================================================================
Routine Description:
Set the transmit power according to the parameters.
Arguments:
pWiphy - Wireless hardware description
Type -
dBm - dBm
Return Value:
0 - success
-x - fail
Note:
Type -
TX_POWER_AUTOMATIC: the dbm parameter is ignored
TX_POWER_LIMITED: limit TX power by the dbm parameter
TX_POWER_FIXED: fix TX power to the dbm parameter
========================================================================
*/
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
static int CFG80211_OpsTxPwrSet(
IN struct wiphy *pWiphy,
IN enum nl80211_tx_power_setting Type,
IN int dBm)
{
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
return -EOPNOTSUPP;
} /* End of CFG80211_OpsTxPwrSet */
#else
static int CFG80211_OpsTxPwrSet(
IN struct wiphy *pWiphy,
IN enum tx_power_setting Type,
IN int dBm)
{
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
return -EOPNOTSUPP;
} /* End of CFG80211_OpsTxPwrSet */
#endif /* LINUX_VERSION_CODE */
/*
========================================================================
Routine Description:
Store the current TX power into the dbm variable.
Arguments:
pWiphy - Wireless hardware description
pdBm - dBm
Return Value:
0 - success
-x - fail
Note:
========================================================================
*/
static int CFG80211_OpsTxPwrGet(
IN struct wiphy *pWiphy,
IN int *pdBm)
{
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
return -EOPNOTSUPP;
} /* End of CFG80211_OpsTxPwrGet */
/*
========================================================================
Routine Description:
Power management.
Arguments:
pWiphy - Wireless hardware description
pNdev -
FlgIsEnabled -
Timeout -
Return Value:
0 - success
-x - fail
Note:
========================================================================
*/
static int CFG80211_OpsPwrMgmt(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev,
IN bool FlgIsEnabled,
IN int Timeout)
{
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
return -EOPNOTSUPP;
} /* End of CFG80211_OpsPwrMgmt */
/*
========================================================================
Routine Description:
Get information for a specific station.
Arguments:
pWiphy - Wireless hardware description
pNdev -
pMac - STA MAC
pSinfo - STA INFO
Return Value:
0 - success
-x - fail
Note:
========================================================================
*/
static int CFG80211_OpsStaGet(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev,
IN UINT8 *pMac,
IN struct station_info *pSinfo)
{
VOID *pAd;
CMD_RTPRIV_IOCTL_80211_STA StaInfo;
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
MAC80211_PAD_GET(pAd, pWiphy);
/* init */
memset(pSinfo, 0, sizeof(*pSinfo));
memset(&StaInfo, 0, sizeof(StaInfo));
memcpy(StaInfo.MAC, pMac, 6);
/* get sta information */
if (RTMP_DRIVER_80211_STA_GET(pAd, &StaInfo) != NDIS_STATUS_SUCCESS)
return -ENOENT;
if (StaInfo.TxRateFlags != RT_CMD_80211_TXRATE_LEGACY)
{
pSinfo->txrate.flags = RATE_INFO_FLAGS_MCS;
if (StaInfo.TxRateFlags & RT_CMD_80211_TXRATE_BW_40)
pSinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
/* End of if */
if (StaInfo.TxRateFlags & RT_CMD_80211_TXRATE_SHORT_GI)
pSinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
/* End of if */
pSinfo->txrate.mcs = StaInfo.TxRateMCS;
}
else
{
pSinfo->txrate.legacy = StaInfo.TxRateMCS;
} /* End of if */
pSinfo->filled |= STATION_INFO_TX_BITRATE;
/* fill signal */
pSinfo->signal = StaInfo.Signal;
pSinfo->filled |= STATION_INFO_SIGNAL;
return 0;
} /* End of CFG80211_OpsStaGet */
/*
========================================================================
Routine Description:
List all stations known, e.g. the AP on managed interfaces.
Arguments:
pWiphy - Wireless hardware description
pNdev -
Idx -
pMac -
pSinfo -
Return Value:
0 - success
-x - fail
Note:
========================================================================
*/
static int CFG80211_OpsStaDump(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev,
IN int Idx,
IN UINT8 *pMac,
IN struct station_info *pSinfo)
{
VOID *pAd;
if (Idx != 0)
return -ENOENT;
/* End of if */
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
MAC80211_PAD_GET(pAd, pWiphy);
#ifdef CONFIG_STA_SUPPORT
if (RTMP_DRIVER_AP_SSID_GET(pAd, pMac) != NDIS_STATUS_SUCCESS)
return -EBUSY;
else
return CFG80211_OpsStaGet(pWiphy, pNdev, pMac, pSinfo);
#endif /* CONFIG_STA_SUPPORT */
return -EOPNOTSUPP;
} /* End of CFG80211_OpsStaDump */
/*
========================================================================
Routine Description:
Notify that wiphy parameters have changed.
Arguments:
pWiphy - Wireless hardware description
Changed -
Return Value:
0 - success
-x - fail
Note:
========================================================================
*/
static int CFG80211_OpsWiphyParamsSet(
IN struct wiphy *pWiphy,
IN UINT32 Changed)
{
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
return -EOPNOTSUPP;
} /* End of CFG80211_OpsWiphyParamsSet */
/*
========================================================================
Routine Description:
Add a key with the given parameters.
Arguments:
pWiphy - Wireless hardware description
pNdev -
KeyIdx -
Pairwise -
pMacAddr -
pParams -
Return Value:
0 - success
-x - fail
Note:
pMacAddr will be NULL when adding a group key.
========================================================================
*/
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
static int CFG80211_OpsKeyAdd(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev,
IN UINT8 KeyIdx,
IN bool Pairwise,
IN const UINT8 *pMacAddr,
IN struct key_params *pParams)
#else
static int CFG80211_OpsKeyAdd(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev,
IN UINT8 KeyIdx,
IN const UINT8 *pMacAddr,
IN struct key_params *pParams)
#endif /* LINUX_VERSION_CODE */
{
VOID *pAd;
CMD_RTPRIV_IOCTL_80211_KEY KeyInfo;
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
MAC80211_PAD_GET(pAd, pWiphy);
#ifdef RT_CFG80211_DEBUG
hex_dump("KeyBuf=", (UINT8 *)pParams->key, pParams->key_len);
#endif /* RT_CFG80211_DEBUG */
CFG80211DBG(RT_DEBUG_ERROR, ("80211> KeyIdx = %d\n", KeyIdx));
if (pParams->key_len >= sizeof(KeyInfo.KeyBuf))
return -EINVAL;
/* End of if */
#ifdef CONFIG_STA_SUPPORT
/* init */
memset(&KeyInfo, 0, sizeof(KeyInfo));
memcpy(KeyInfo.KeyBuf, pParams->key, pParams->key_len);
KeyInfo.KeyBuf[pParams->key_len] = 0x00;
if ((pParams->cipher == WLAN_CIPHER_SUITE_WEP40) ||
(pParams->cipher == WLAN_CIPHER_SUITE_WEP104))
{
KeyInfo.KeyType = RT_CMD_80211_KEY_WEP;
}
else if ((pParams->cipher == WLAN_CIPHER_SUITE_TKIP) ||
(pParams->cipher == WLAN_CIPHER_SUITE_CCMP))
{
KeyInfo.KeyType = RT_CMD_80211_KEY_WPA;
}
else
return -ENOTSUPP;
KeyInfo.KeyId = KeyIdx+1;
/* add key */
RTMP_DRIVER_80211_KEY_ADD(pAd, &KeyInfo);
return 0;
#endif /* CONFIG_STA_SUPPORT */
} /* End of CFG80211_OpsKeyAdd */
/*
========================================================================
Routine Description:
Get information about the key with the given parameters.
Arguments:
pWiphy - Wireless hardware description
pNdev -
KeyIdx -
Pairwise -
pMacAddr -
pCookie -
pCallback -
Return Value:
0 - success
-x - fail
Note:
pMacAddr will be NULL when requesting information for a group key.
All pointers given to the pCallback function need not be valid after
it returns.
This function should return an error if it is not possible to
retrieve the key, -ENOENT if it doesn't exist.
========================================================================
*/
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
static int CFG80211_OpsKeyGet(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev,
IN UINT8 KeyIdx,
IN bool Pairwise,
IN const UINT8 *pMacAddr,
IN void *pCookie,
IN void (*pCallback)(void *cookie,
struct key_params *))
#else
static int CFG80211_OpsKeyGet(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev,
IN UINT8 KeyIdx,
IN const UINT8 *pMacAddr,
IN void *pCookie,
IN void (*pCallback)(void *cookie,
struct key_params *))
#endif /* LINUX_VERSION_CODE */
{
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
return -ENOTSUPP;
} /* End of CFG80211_OpsKeyGet */
/*
========================================================================
Routine Description:
Remove a key given the pMacAddr (NULL for a group key) and KeyIdx.
Arguments:
pWiphy - Wireless hardware description
pNdev -
KeyIdx -
pMacAddr -
Return Value:
0 - success
-x - fail
Note:
return -ENOENT if the key doesn't exist.
========================================================================
*/
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
static int CFG80211_OpsKeyDel(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev,
IN UINT8 KeyIdx,
IN bool Pairwise,
IN const UINT8 *pMacAddr)
#else
static int CFG80211_OpsKeyDel(
IN struct wiphy *pWiphy,
IN struct net_device *pNdev,
IN UINT8 KeyIdx,
IN const UINT8 *pMacAddr)
#endif /* LINUX_VERSION_CODE */
{
CFG80211DBG(RT_DEBUG_ERROR, ("80211> %s ==>\n", __FUNCTION__));
return -ENOTSUPP;
} /* End of CFG80211_OpsKeyDel */
/*
========================================================================
Routine Description:
Set the default key on an interface.
Arguments:
pWiphy - Wireless hardware description
pNdev -
KeyIdx -
Return Value: