39
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* WLAN Management API stubbing for WLAN Qt Utilities.
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <e32base.h>
|
|
19 |
#include "wlanscaninfo.h"
|
|
20 |
|
|
21 |
#include <cmmanager_shim.h>
|
|
22 |
|
|
23 |
#include "wlanqtutilstestcontext.h"
|
|
24 |
#include "wlanqtutilsap.h"
|
|
25 |
|
|
26 |
extern WlanQtUtilsTestContext testContext;
|
|
27 |
|
|
28 |
// Information Element ID for SSID as specified in 802.11.
|
|
29 |
static const TUint8 KWlan802Dot11SsidIE = 0;
|
|
30 |
|
|
31 |
// Bit mask for Capability info field to get type (Infra/AdHoc).
|
|
32 |
static const TUint8 KWlan802Dot11CapabilityEssMask = 0x0001;
|
|
33 |
|
|
34 |
// ---------------------------------------------------------
|
|
35 |
// CWlanScanInfo::NewL
|
|
36 |
// ---------------------------------------------------------
|
|
37 |
//
|
|
38 |
CWlanScanInfo* CWlanScanInfo::NewL()
|
|
39 |
{
|
|
40 |
CWlanScanInfo* self = new CWlanScanInfo;
|
|
41 |
return self;
|
|
42 |
}
|
|
43 |
|
|
44 |
// ---------------------------------------------------------
|
|
45 |
// CWlanScanInfo::~CWlanScanInfo
|
|
46 |
// ---------------------------------------------------------
|
|
47 |
//
|
|
48 |
CWlanScanInfo::~CWlanScanInfo()
|
|
49 |
{
|
|
50 |
}
|
|
51 |
|
|
52 |
// ---------------------------------------------------------
|
|
53 |
// CWlanScanInfo::~First
|
|
54 |
// ---------------------------------------------------------
|
|
55 |
//
|
|
56 |
const TWlanScanInfoFrame* CWlanScanInfo::First()
|
|
57 |
{
|
|
58 |
// Rewind to the beginning of scan result list
|
|
59 |
testContext.mScan.mScanResultIterator = 0;
|
|
60 |
|
|
61 |
return (TWlanScanInfoFrame*)1; // Info frame is not supported
|
|
62 |
}
|
|
63 |
|
|
64 |
// ---------------------------------------------------------
|
|
65 |
// CWlanScanInfo::~Next
|
|
66 |
// ---------------------------------------------------------
|
|
67 |
//
|
|
68 |
const TWlanScanInfoFrame* CWlanScanInfo::Next()
|
|
69 |
{
|
|
70 |
// Go to next AP in scan results
|
|
71 |
testContext.mScan.mScanResultIterator++;
|
|
72 |
|
|
73 |
return (TWlanScanInfoFrame*)1; // Info frame is not supported
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------
|
|
77 |
// CWlanScanInfo::~IsDone
|
|
78 |
// ---------------------------------------------------------
|
|
79 |
//
|
|
80 |
TBool CWlanScanInfo::IsDone() const
|
|
81 |
{
|
|
82 |
TBool result = EFalse;
|
|
83 |
|
|
84 |
// Iterating is complete when iterator is one past the last item
|
|
85 |
if (testContext.mScan.mScanResultIterator >=
|
53
|
86 |
testContext.mScan.mWlanScanApResultList.count()) {
|
39
|
87 |
result = ETrue;
|
|
88 |
}
|
|
89 |
|
|
90 |
return result;
|
|
91 |
}
|
|
92 |
|
|
93 |
// ---------------------------------------------------------
|
|
94 |
// CWlanScanInfo::RXLevel
|
|
95 |
// ---------------------------------------------------------
|
|
96 |
//
|
|
97 |
TUint8 CWlanScanInfo::RXLevel() const
|
|
98 |
{
|
|
99 |
QSharedPointer<WlanQtUtilsAp> ap(GetCurrentAp());
|
|
100 |
int rxlevel = ap->value(WlanQtUtilsAp::ConfIdSignalStrength).toInt();
|
|
101 |
|
|
102 |
return (TUint8)rxlevel;
|
|
103 |
}
|
|
104 |
|
|
105 |
// ---------------------------------------------------------
|
|
106 |
// CWlanScanInfo::Bssid
|
|
107 |
// ---------------------------------------------------------
|
|
108 |
//
|
|
109 |
void CWlanScanInfo::Bssid(
|
|
110 |
TWlanBssid& aBssid ) const
|
|
111 |
{
|
|
112 |
QSharedPointer<WlanQtUtilsAp> ap(GetCurrentAp());
|
|
113 |
QByteArray bssid = ap->value(WlanQtUtilsAp::ConfIdBssid).toByteArray();
|
|
114 |
|
|
115 |
// Length must match, since BSSID is always the same length
|
|
116 |
Q_ASSERT(bssid.length() == KWlanMaxBssidLength);
|
|
117 |
|
|
118 |
// Copy the BSSID
|
|
119 |
aBssid.Copy((const unsigned char *)bssid.constData(), bssid.length());
|
|
120 |
}
|
|
121 |
|
|
122 |
// ---------------------------------------------------------
|
|
123 |
// CWlanScanInfo::Capability
|
|
124 |
// ---------------------------------------------------------
|
|
125 |
//
|
|
126 |
TUint16 CWlanScanInfo::Capability() const
|
|
127 |
{
|
|
128 |
QSharedPointer<WlanQtUtilsAp> ap(GetCurrentAp());
|
|
129 |
|
|
130 |
TUint16 capabilities = 0;
|
|
131 |
|
|
132 |
// Only connection mode cabability is supported
|
|
133 |
int connMode = ap->value(WlanQtUtilsAp::ConfIdConnectionMode).toInt();
|
|
134 |
if (connMode == CMManagerShim::Infra) {
|
|
135 |
capabilities |= KWlan802Dot11CapabilityEssMask;
|
|
136 |
}
|
|
137 |
|
|
138 |
return capabilities;
|
|
139 |
}
|
|
140 |
|
|
141 |
// ---------------------------------------------------------
|
|
142 |
// CWlanScanInfo::InformationElement
|
|
143 |
// ---------------------------------------------------------
|
|
144 |
//
|
|
145 |
TInt CWlanScanInfo::InformationElement(
|
|
146 |
TUint8 aIE,
|
|
147 |
TUint8& aLength,
|
|
148 |
const TUint8** aData )
|
|
149 |
{
|
|
150 |
// Static SSID buffer
|
|
151 |
static TBuf8<255> ssidBuffer;
|
|
152 |
|
|
153 |
QSharedPointer<WlanQtUtilsAp> ap(GetCurrentAp());
|
|
154 |
|
|
155 |
aLength = 0;
|
|
156 |
|
|
157 |
// Only SSID IE is supported
|
|
158 |
Q_ASSERT(aIE == KWlan802Dot11SsidIE);
|
|
159 |
(void)aIE;
|
|
160 |
|
|
161 |
// Cypy the SSID
|
53
|
162 |
ssidBuffer.SetLength(0);
|
39
|
163 |
QString ssid = ap->value(WlanQtUtilsAp::ConfIdSsid).toString();
|
53
|
164 |
for (int i = 0; i < ssid.length(); i++) {
|
|
165 |
QChar character = ssid[i];
|
|
166 |
ssidBuffer.Append((TUint8)(character.unicode() & 0x000000FF));
|
|
167 |
}
|
39
|
168 |
|
|
169 |
// Give reference to the buffer to the caller
|
|
170 |
*aData = ssidBuffer.Ptr();
|
|
171 |
aLength = (TUint8)ssidBuffer.Length();
|
|
172 |
|
|
173 |
return KErrNone;
|
|
174 |
}
|
|
175 |
|
|
176 |
// ---------------------------------------------------------
|
|
177 |
// CWlanScanInfo::IsProtectedSetupSupported
|
|
178 |
// ---------------------------------------------------------
|
|
179 |
//
|
|
180 |
TBool CWlanScanInfo::IsProtectedSetupSupported()
|
|
181 |
{
|
|
182 |
QSharedPointer<WlanQtUtilsAp> ap(GetCurrentAp());
|
|
183 |
|
|
184 |
TBool wpsSupport;
|
|
185 |
bool wps = ap->value(WlanQtUtilsAp::ConfIdWpsSupported).toBool();
|
|
186 |
if (wps) {
|
|
187 |
wpsSupport = ETrue;
|
|
188 |
} else {
|
|
189 |
wpsSupport = EFalse;
|
|
190 |
}
|
|
191 |
|
|
192 |
return wpsSupport;
|
|
193 |
}
|
|
194 |
|
|
195 |
// ---------------------------------------------------------
|
|
196 |
// CWlanScanInfo::ExtendedSecurityMode
|
|
197 |
// ---------------------------------------------------------
|
|
198 |
//
|
|
199 |
TWlanConnectionExtentedSecurityMode CWlanScanInfo::ExtendedSecurityMode() const
|
|
200 |
{
|
|
201 |
QSharedPointer<WlanQtUtilsAp> ap(GetCurrentAp());
|
|
202 |
int secMode = ap->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt();
|
|
203 |
bool pskUse = ap->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool();
|
|
204 |
|
|
205 |
TWlanConnectionExtentedSecurityMode ret;
|
|
206 |
switch (secMode) {
|
|
207 |
case CMManagerShim::WlanSecModeWep:
|
|
208 |
// Both WEP security modes are mapped to same WEP sec mode value.
|
|
209 |
// We test both of them, and toggle the used value each time.
|
|
210 |
static bool wepOpen = true;
|
|
211 |
if (wepOpen) {
|
|
212 |
ret = EWlanConnectionExtentedSecurityModeWepOpen;
|
|
213 |
} else {
|
|
214 |
ret = EWlanConnectionExtentedSecurityModeWepShared;
|
|
215 |
}
|
|
216 |
wepOpen = !wepOpen;
|
|
217 |
break;
|
|
218 |
|
|
219 |
case CMManagerShim::WlanSecMode802_1x:
|
|
220 |
ret = EWlanConnectionExtentedSecurityMode802d1x;
|
|
221 |
break;
|
|
222 |
|
|
223 |
case CMManagerShim::WlanSecModeWpa:
|
|
224 |
if (pskUse)
|
|
225 |
{
|
|
226 |
ret = EWlanConnectionExtentedSecurityModeWpaPsk;
|
|
227 |
}
|
|
228 |
else
|
|
229 |
{
|
|
230 |
ret = EWlanConnectionExtentedSecurityModeWpa;
|
|
231 |
}
|
|
232 |
break;
|
|
233 |
|
|
234 |
case CMManagerShim::WlanSecModeWpa2:
|
|
235 |
if (pskUse)
|
|
236 |
{
|
|
237 |
ret = EWlanConnectionExtentedSecurityModeWpa2Psk;
|
|
238 |
}
|
|
239 |
else
|
|
240 |
{
|
|
241 |
ret = EWlanConnectionExtentedSecurityModeWpa2;
|
|
242 |
}
|
|
243 |
break;
|
|
244 |
|
|
245 |
case CMManagerShim::WlanSecModeWapi:
|
|
246 |
if (pskUse)
|
|
247 |
{
|
|
248 |
ret = EWlanConnectionExtentedSecurityModeWapiPsk;
|
|
249 |
}
|
|
250 |
else
|
|
251 |
{
|
|
252 |
ret = EWlanConnectionExtentedSecurityModeWapi;
|
|
253 |
}
|
|
254 |
break;
|
|
255 |
|
|
256 |
default:
|
|
257 |
ret = EWlanConnectionExtentedSecurityModeOpen;
|
|
258 |
break;
|
|
259 |
}
|
|
260 |
|
|
261 |
return ret;
|
|
262 |
}
|
|
263 |
|
|
264 |
// ---------------------------------------------------------
|
|
265 |
// CWlanScanInfo::CWlanScanInfo
|
|
266 |
// ---------------------------------------------------------
|
|
267 |
//
|
|
268 |
CWlanScanInfo::CWlanScanInfo()
|
|
269 |
{
|
|
270 |
}
|
|
271 |
|
|
272 |
// ---------------------------------------------------------
|
|
273 |
// CWlanScanInfo::GetCurrentAp
|
|
274 |
// ---------------------------------------------------------
|
|
275 |
//
|
|
276 |
QSharedPointer<WlanQtUtilsAp> CWlanScanInfo::GetCurrentAp() const
|
|
277 |
{
|
|
278 |
// If this fails, client iterates erroneously
|
|
279 |
Q_ASSERT(!IsDone());
|
|
280 |
|
|
281 |
// Get the currently iterated AP
|
|
282 |
QSharedPointer<WlanQtUtilsAp> ap(
|
53
|
283 |
testContext.mScan.mWlanScanApResultList[
|
39
|
284 |
testContext.mScan.mScanResultIterator]);
|
|
285 |
|
|
286 |
return ap;
|
|
287 |
}
|