forked from coolstar/wificx-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
device.cpp
132 lines (113 loc) · 4.53 KB
/
device.cpp
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
#include "precomp.h"
#include "trace.h"
#include "device.h"
#include "adapter.h"
NTSTATUS
MtkInitializeHardware(
_In_ MTK_DEVICE* pDevice,
_In_ WDFCMRESLIST resourcesRaw,
_In_ WDFCMRESLIST resourcesTranslated)
{
TraceEntry();
//
// Read the registry parameters
//
NTSTATUS status = STATUS_SUCCESS;
WIFI_DEVICE_CAPABILITIES deviceCapabilities = { 0 };
deviceCapabilities.Size = sizeof(deviceCapabilities);
deviceCapabilities.HardwareRadioState = 1;
deviceCapabilities.SoftwareRadioState = 1;
deviceCapabilities.ActionFramesSupported = 0;
deviceCapabilities.NumRxStreams = 1;
deviceCapabilities.NumTxStreams = 1;
deviceCapabilities.Support_eCSA = 0;
deviceCapabilities.MACAddressRandomization = 0;
deviceCapabilities.BluetoothCoexistenceSupport = WDI_BLUETOOTH_COEXISTENCE_PERFORMANCE_MAINTAINED;
deviceCapabilities.SupportsNonWdiOidRequests = 0;
deviceCapabilities.FastTransitionSupported = 0;
deviceCapabilities.MU_MIMOSupported = 0;
deviceCapabilities.BSSTransitionSupported = 0;
deviceCapabilities.SAEAuthenticationSupported = 0;
deviceCapabilities.MBOSupported = 0;
deviceCapabilities.BeaconReportsImplemented = 0;
GOTO_IF_NOT_NT_SUCCESS(Exit, status,
WifiDeviceSetDeviceCapabilities(pDevice->FxDevice, &deviceCapabilities));
DOT11_AUTH_CIPHER_PAIR cipherPairs;
cipherPairs.AuthAlgoId = DOT11_AUTH_ALGO_80211_OPEN;
cipherPairs.CipherAlgoId = DOT11_CIPHER_ALGO_NONE;
WIFI_STATION_CAPABILITIES stationCapabilities = { 0 };
stationCapabilities.Size = sizeof(stationCapabilities);
stationCapabilities.ScanSSIDListSize = 32;
stationCapabilities.DesiredSSIDListSize = 32;
stationCapabilities.PrivacyExemptionListSize = 16;
stationCapabilities.KeyMappingTableSize = 16;
stationCapabilities.DefaultKeyTableSize = 16;
stationCapabilities.WEPKeyValueMaxLength = 16;
stationCapabilities.MaxNumPerSTA = 16;
stationCapabilities.NumSupportedUnicastAlgorithms = 1;
stationCapabilities.UnicastAlgorithmsList = &cipherPairs;
stationCapabilities.NumSupportedMulticastDataAlgorithms = 1;
stationCapabilities.MulticastDataAlgorithmsList = &cipherPairs;
stationCapabilities.NumSupportedMulticastMgmtAlgorithms = 1;
stationCapabilities.MulticastMgmtAlgorithmsList = &cipherPairs;
GOTO_IF_NOT_NT_SUCCESS(Exit, status,
WifiDeviceSetStationCapabilities(pDevice->FxDevice, &stationCapabilities));
WIFI_BAND_INFO bandInfo[2];
RtlZeroMemory(&bandInfo, sizeof(bandInfo));
bandInfo[0].BandID = WDI_BAND_ID_2400;
bandInfo[0].BandState = TRUE;
bandInfo[0].NumValidPhyTypes = 0;
bandInfo[0].NumValidChannelTypes = 0;
bandInfo[0].NumChannelWidths = 0;
bandInfo[1].BandID = WDI_BAND_ID_5000;
bandInfo[1].BandState = TRUE;
bandInfo[1].NumValidPhyTypes = 0;
bandInfo[1].NumValidChannelTypes = 0;
bandInfo[1].NumChannelWidths = 0;
WIFI_BAND_CAPABILITIES bandCapabilities = { 0 };
bandCapabilities.Size = sizeof(bandCapabilities);
bandCapabilities.NumBands = 2;
bandCapabilities.BandInfoList = bandInfo;
GOTO_IF_NOT_NT_SUCCESS(Exit, status,
WifiDeviceSetBandCapabilities(pDevice->FxDevice, &bandCapabilities));
WIFI_PHY_CAPABILITIES phyCapabilities = { 0 };
phyCapabilities.Size = sizeof(phyCapabilities);
phyCapabilities.NumPhyTypes = 0;
GOTO_IF_NOT_NT_SUCCESS(Exit, status,
WifiDeviceSetPhyCapabilities(pDevice->FxDevice, &phyCapabilities));
WIFI_WIFIDIRECT_CAPABILITIES wifiDirectCapabilities = { 0 };
wifiDirectCapabilities.Size = sizeof(wifiDirectCapabilities);
GOTO_IF_NOT_NT_SUCCESS(Exit, status,
WifiDeviceSetWiFiDirectCapabilities(pDevice->FxDevice, &wifiDirectCapabilities));
Exit:
TraceExitResult(status);
return status;
}
_Use_decl_annotations_
NTSTATUS
EvtDevicePrepareHardware(
_In_ WDFDEVICE device,
_In_ WDFCMRESLIST resourcesRaw,
_In_ WDFCMRESLIST resourcesTranslated)
{
MTK_DEVICE* devContext = MtkGetDeviceContext(device);
TraceEntry();
NTSTATUS status = STATUS_SUCCESS;
GOTO_IF_NOT_NT_SUCCESS(Exit, status, MtkInitializeHardware(devContext, resourcesRaw, resourcesTranslated));
Exit:
TraceExitResult(status);
return status;
}
_Use_decl_annotations_
NTSTATUS
EvtDeviceReleaseHardware(
_In_ WDFDEVICE device,
_In_ WDFCMRESLIST resourcesTranslated)
{
UNREFERENCED_PARAMETER(resourcesTranslated);
MTK_DEVICE* devContext = MtkGetDeviceContext(device);
TraceEntry();
NTSTATUS status = STATUS_SUCCESS;
TraceExitResult(status);
return status;
}