|
1 /* |
|
2 * Copyright (c) 2002-2005 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 the License "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: Class to dig information from scan results. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef GENSCANINFO_H |
|
20 #define GENSCANINFO_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include "genscanlistiterator.h" |
|
25 |
|
26 // CONSTANTS |
|
27 /** Length of BSSID element. */ |
|
28 const u8_t BSSID_LENGTH = 6; |
|
29 /** The bitmask for determining operating mode. */ |
|
30 const u16_t SCAN_CAPABILITY_BIT_MASK_ESS = 0x0001; |
|
31 /** The bitmask for privacy bit. */ |
|
32 const u16_t SCAN_CAPABILITY_BIT_MASK_PRIVACY = 0x0010; |
|
33 /** Length of OUI element. */ |
|
34 const u8_t SCAN_IE_OUI_LENGTH = 3; |
|
35 /** Length of TSF element. */ |
|
36 const u8_t TIMESTAMP_LENGTH = 8; |
|
37 |
|
38 // LOCAL DATATYPES |
|
39 /** The possible error codes returned by parsing methods. */ |
|
40 typedef enum _WlanScanError |
|
41 { |
|
42 WlanScanError_Ok, |
|
43 WlanScanError_IeNotFound |
|
44 } WlanScanError; |
|
45 |
|
46 /** The possible security modes of a BSS. */ |
|
47 typedef enum _WlanSecurityMode |
|
48 { |
|
49 WlanSecurityModeOpen, |
|
50 WlanSecurityModeWep, |
|
51 WlanSecurityMode802_1x, |
|
52 WlanSecurityModeWpaEap, |
|
53 WlanSecurityModeWpaPsk, |
|
54 WlanSecurityModeWpa2Eap, |
|
55 WlanSecurityModeWpa2Psk, |
|
56 WlanSecurityModeWapi, |
|
57 WlanSecurityModeWapiPsk |
|
58 } WlanSecurityMode; |
|
59 |
|
60 /** The possible operating modes of a BSS. */ |
|
61 typedef enum _WlanOperatingMode |
|
62 { |
|
63 WlanOperatingModeInfra, |
|
64 WlanOperatingModeAdhoc |
|
65 } WlanOperatingMode; |
|
66 |
|
67 /** Type definition for OUI element. */ |
|
68 typedef u8_t WlanIeOui[SCAN_IE_OUI_LENGTH]; |
|
69 |
|
70 /** |
|
71 * Wrapper class to parse data fields from scan info. |
|
72 */ |
|
73 NONSHARABLE_CLASS( ScanInfo ) : public ScanListIterator |
|
74 { |
|
75 public: // Methods |
|
76 |
|
77 /** |
|
78 * C++ constructor. |
|
79 * |
|
80 * @param scan_list Reference to the scan list container. |
|
81 */ |
|
82 ScanInfo( const ScanList& scan_list ); |
|
83 |
|
84 // New methods |
|
85 |
|
86 /** |
|
87 * Return the measured signal noise ratio of the BSS. |
|
88 * |
|
89 * @return Signal noise ratio (SNR). |
|
90 * @deprecated |
|
91 */ |
|
92 inline u8_t SignalNoiseRatio() const; |
|
93 |
|
94 /** |
|
95 * Return the measured Received Channel Power Indicator value of the BSS. |
|
96 * |
|
97 * @return RCPI value. |
|
98 */ |
|
99 inline u8_t RXLevel() const; |
|
100 |
|
101 /** |
|
102 * Return BSSID of the BSS. |
|
103 * |
|
104 * @param bssid BSSID of the BSS. |
|
105 */ |
|
106 inline void BSSID( |
|
107 u8_t bssid[BSSID_LENGTH] ) const; |
|
108 |
|
109 /** |
|
110 * Return the beacon interval of the BSS. |
|
111 * |
|
112 * @return The beacon interval in TUs. |
|
113 */ |
|
114 inline u16_t BeaconInterval() const; |
|
115 |
|
116 /** |
|
117 * Return the capability information of the BSS. |
|
118 * |
|
119 * @return The capability information. |
|
120 */ |
|
121 inline u16_t Capability() const; |
|
122 |
|
123 /** |
|
124 * Return whether the privacy bit is enabled in BSs capabilities. |
|
125 * |
|
126 * @return Whether the privacy is enabled. |
|
127 */ |
|
128 inline bool_t Privacy() const; |
|
129 |
|
130 /** |
|
131 * Return the operating mode of the BSS. |
|
132 * |
|
133 * @return The operating mode of the BSS. |
|
134 */ |
|
135 inline WlanOperatingMode OperatingMode() const; |
|
136 |
|
137 /** |
|
138 * Return the security mode of the BSS. |
|
139 * @return The security mode of the BSS. |
|
140 */ |
|
141 WlanSecurityMode SecurityMode(); |
|
142 |
|
143 /** |
|
144 * Return the timestamp (TSF) of the BSS. |
|
145 * |
|
146 * @param timestamp Timestamp of the BSS. |
|
147 */ |
|
148 inline void Timestamp( |
|
149 u8_t timestamp[TIMESTAMP_LENGTH] ) const; |
|
150 |
|
151 /** |
|
152 * Return the requested information element. |
|
153 * |
|
154 * @param ie_id Element ID of the information element. |
|
155 * @param ie_length Length of the IE. Zero if IE not found. |
|
156 * @param ie_data Pointer to the beginning of the IE data. NULL if IE not found. |
|
157 * @return WlanScanError_Ok if IE was found, an error otherwise. |
|
158 */ |
|
159 WlanScanError InformationElement( |
|
160 u8_t ie_id, |
|
161 u8_t& ie_length, |
|
162 const u8_t** ie_data ); |
|
163 |
|
164 /** |
|
165 * Return the WPA information element. |
|
166 * |
|
167 * @param ie_length Length of the IE. Zero if IE not found. |
|
168 * @param ie_data Pointer to the beginning of the IE data. NULL if IE not found. |
|
169 * @return WlanScanError_Ok if IE was found, an error otherwise. |
|
170 */ |
|
171 WlanScanError WpaIE( |
|
172 u8_t& ie_length, |
|
173 const u8_t** ie_data ); |
|
174 |
|
175 /** |
|
176 * Return the first information element. |
|
177 * |
|
178 * @param ie_id Element ID of the information element. |
|
179 * @param ie_length Length of the IE. Zero if IE not found. |
|
180 * @param ie_data Pointer to the beginning of the IE data. NULL if IE not found. |
|
181 * @return WlanScanError_Ok if IE was found, an error otherwise. |
|
182 */ |
|
183 WlanScanError FirstIE( |
|
184 u8_t& ie_id, |
|
185 u8_t& ie_length, |
|
186 const u8_t** ie_data ); |
|
187 |
|
188 /** |
|
189 * Return next information element. |
|
190 * |
|
191 * @param ie_id Element ID of the information element. |
|
192 * @param ie_length Length of the IE. Zero if IE not found. |
|
193 * @param ie_data Pointer to the beginning of the IE data. NULL if IE not found. |
|
194 * @return WlanScanError_Ok if IE was found, an error otherwise. |
|
195 */ |
|
196 WlanScanError NextIE( |
|
197 u8_t& ie_id, |
|
198 u8_t& ie_length, |
|
199 const u8_t** ie_data ); |
|
200 |
|
201 /** |
|
202 * Return the first information element with given OUI and OUI type. |
|
203 * |
|
204 * @param ie_id Element ID of the information element. |
|
205 * @param ie_oui OUI element of the requested IE. |
|
206 * @param ie_oui_type OUI type element of the requested IE. |
|
207 * @param ie_length Length of the IE. Zero if IE not found. |
|
208 * @param ie_data Pointer to the beginning of the IE data. NULL if IE not found. |
|
209 * @return WlanScanError_Ok if IE was found, an error otherwise. |
|
210 */ |
|
211 WlanScanError InformationElement( |
|
212 u8_t ie_id, |
|
213 const WlanIeOui& ie_oui, |
|
214 u8_t ie_oui_type, |
|
215 u8_t& ie_length, |
|
216 const u8_t** ie_data ); |
|
217 |
|
218 /** |
|
219 * Return the first information element with given OUI, OUI type and OUI subtype. |
|
220 * |
|
221 * @param ie_id Element ID of the information element. |
|
222 * @param ie_oui OUI element of the requested IE. |
|
223 * @param ie_oui_type OUI type element of the requested IE. |
|
224 * @param ie_oui_subtype OUI subtype element of the requested IE. |
|
225 * @param ie_length Length of the IE. Zero if IE not found. |
|
226 * @param ie_data Pointer to the beginning of the IE data. NULL if IE not found. |
|
227 * @return WlanScanError_Ok if IE was found, an error otherwise. |
|
228 */ |
|
229 WlanScanError InformationElement( |
|
230 u8_t ie_id, |
|
231 const WlanIeOui& ie_oui, |
|
232 u8_t ie_oui_type, |
|
233 u8_t ie_oui_subtype, |
|
234 u8_t& ie_length, |
|
235 const u8_t** ie_data ); |
|
236 |
|
237 /** |
|
238 * Check whether Wi-Fi Protected Setup is supported. |
|
239 * |
|
240 * @return true_t if AP supports Wi-Fi Protected Setup, |
|
241 * false_t otherwise. |
|
242 */ |
|
243 bool_t IsProtectedSetupSupported(); |
|
244 |
|
245 private: //Methods |
|
246 |
|
247 /** |
|
248 * Prohibit copy constructor. |
|
249 */ |
|
250 ScanInfo( |
|
251 const ScanInfo& ); |
|
252 /** |
|
253 * Prohibit assigment operator. |
|
254 */ |
|
255 ScanInfo& operator= ( |
|
256 const ScanInfo& ); |
|
257 |
|
258 /** |
|
259 * Return current information element. |
|
260 * |
|
261 * @param ie_id Element ID of the information element. |
|
262 * @param ie_length Length of the IE. Zero if IE not found. |
|
263 * @param ie_data Pointer to the beginning of the IE data. NULL if IE not found. |
|
264 * @return WlanScanError_Ok if IE was found, an error otherwise. |
|
265 */ |
|
266 WlanScanError CurrentIE( |
|
267 u8_t& ie_id, |
|
268 u8_t& ie_length, |
|
269 const u8_t** ie_data ) const; |
|
270 |
|
271 /** |
|
272 * Search through WSC IE and return value of AP setup locked attribute. |
|
273 * |
|
274 * @param ie_data Pointer to the beginning of the IE data. |
|
275 * @param ie_length Length of the IE. |
|
276 * @return true_t if value of AP setup locked is true. |
|
277 * false_t otherwise. |
|
278 */ |
|
279 bool_t IsApSetupLocked( |
|
280 const u8_t* ie_data, |
|
281 const u8_t ie_length ) const; |
|
282 |
|
283 private: // Data |
|
284 |
|
285 /** Iterator for going through IEs of scan info. */ |
|
286 const u8_t* ie_iter_m; |
|
287 }; |
|
288 |
|
289 #include "genscaninfo.inl" |
|
290 |
|
291 #endif // GENSCANINFO_H |
|
292 |
|
293 // End of File |