|
1 /* |
|
2 * Copyright (c) 2005-2006 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 holding all IAP related data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "core_iap_data.h" |
|
20 #include "core_tools.h" |
|
21 #include "am_debug.h" |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 core_iap_data_c::core_iap_data_c( |
|
29 const core_iap_data_s& iap_data ) : |
|
30 iap_data_m( iap_data ), |
|
31 iap_whitelist_m( ), |
|
32 iap_blacklist_m( ) |
|
33 { |
|
34 } |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 core_iap_data_c::~core_iap_data_c() |
|
40 { |
|
41 iap_whitelist_m.clear(); |
|
42 iap_blacklist_m.clear(); |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 u32_t core_iap_data_c::id() const |
|
49 { |
|
50 return iap_data_m.id; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 u32_t core_iap_data_c::iap_id() const |
|
57 { |
|
58 return iap_data_m.iap_id; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 core_operating_mode_e core_iap_data_c::operating_mode() const |
|
65 { |
|
66 return iap_data_m.op_mode; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 const core_ssid_s& core_iap_data_c::ssid() const |
|
73 { |
|
74 return iap_data_m.ssid; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 bool_t core_iap_data_c::is_hidden() const |
|
81 { |
|
82 return iap_data_m.is_hidden; |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 const core_wep_key_s& core_iap_data_c::wep_key( |
|
89 u32_t key_index ) const |
|
90 { |
|
91 switch ( key_index ) |
|
92 { |
|
93 case WEP_KEY1: |
|
94 return iap_data_m.wep_key1; |
|
95 case WEP_KEY2: |
|
96 return iap_data_m.wep_key2; |
|
97 case WEP_KEY3: |
|
98 return iap_data_m.wep_key3; |
|
99 default: |
|
100 return iap_data_m.wep_key4; |
|
101 } |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 u32_t core_iap_data_c::default_wep_key_index() const |
|
108 { |
|
109 return iap_data_m.default_wep_key; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 core_security_mode_e core_iap_data_c::security_mode() const |
|
116 { |
|
117 return iap_data_m.security_mode; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 core_authentication_mode_e core_iap_data_c::authentication_mode() const |
|
124 { |
|
125 return iap_data_m.authentication_mode; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void core_iap_data_c::set_authentication_mode( |
|
132 core_authentication_mode_e mode ) |
|
133 { |
|
134 iap_data_m.authentication_mode = mode; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 bool_t core_iap_data_c::is_psk_used() const |
|
141 { |
|
142 return iap_data_m.wpa_preshared_key_in_use; |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 bool_t core_iap_data_c::is_psk_overridden() const |
|
149 { |
|
150 return iap_data_m.is_wpa_overriden; |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 const core_wpa_preshared_key_s& core_iap_data_c::psk_key() const |
|
157 { |
|
158 return iap_data_m.wpa_preshared_key; |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 u32_t core_iap_data_c::adhoc_channel() const |
|
165 { |
|
166 return iap_data_m.used_adhoc_channel; |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 bool_t core_iap_data_c::is_dynamic_ip_addr() const |
|
173 { |
|
174 return iap_data_m.is_dynamic_ip_addr; |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 bool_t core_iap_data_c::is_roaming_allowed() const |
|
181 { |
|
182 return iap_data_m.is_roaming_allowed; |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 bool_t core_iap_data_c::is_eap_used() const |
|
189 { |
|
190 if ( iap_data_m.security_mode == core_security_mode_802dot1x || |
|
191 iap_data_m.security_mode == core_security_mode_wpa || |
|
192 iap_data_m.security_mode == core_security_mode_wpa2only || |
|
193 iap_data_m.security_mode == core_security_mode_protected_setup ) |
|
194 { |
|
195 return true_t; |
|
196 } |
|
197 |
|
198 return false_t; |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 bool_t core_iap_data_c::is_wapi_used() const |
|
205 { |
|
206 return( iap_data_m.security_mode == core_security_mode_wapi ); |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 bool_t core_iap_data_c::is_802dot1x_used() const |
|
213 { |
|
214 return iap_data_m.security_mode == core_security_mode_802dot1x; |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 bool_t core_iap_data_c::is_iap_whitelist_empty() const |
|
221 { |
|
222 return !iap_whitelist_m.count(); |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 bool_t core_iap_data_c::is_mac_in_iap_whitelist( |
|
229 const core_mac_address_s& mac ) |
|
230 { |
|
231 core_mac_address_s* addr = iap_whitelist_m.first(); |
|
232 while ( addr ) |
|
233 { |
|
234 if ( *addr == mac ) |
|
235 { |
|
236 return true_t; |
|
237 } |
|
238 |
|
239 addr = iap_whitelist_m.next(); |
|
240 } |
|
241 |
|
242 return false_t; |
|
243 } |
|
244 |
|
245 // --------------------------------------------------------------------------- |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 bool_t core_iap_data_c::is_mac_in_iap_blacklist( |
|
249 const core_mac_address_s& mac ) |
|
250 { |
|
251 core_mac_address_s* addr = iap_blacklist_m.first(); |
|
252 while ( addr ) |
|
253 { |
|
254 if ( *addr == mac ) |
|
255 { |
|
256 return true_t; |
|
257 } |
|
258 |
|
259 addr = iap_blacklist_m.next(); |
|
260 } |
|
261 |
|
262 return false_t; |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 void core_iap_data_c::add_mac_to_iap_whitelist( |
|
269 const core_mac_address_s& mac ) |
|
270 { |
|
271 if ( !is_mac_in_iap_whitelist( mac ) ) |
|
272 { |
|
273 core_mac_address_s* entry = new core_mac_address_s; |
|
274 if ( entry ) |
|
275 { |
|
276 *entry = mac; |
|
277 iap_whitelist_m.append( entry ); |
|
278 } |
|
279 } |
|
280 } |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // --------------------------------------------------------------------------- |
|
284 // |
|
285 void core_iap_data_c::remove_mac_from_iap_whitelist( |
|
286 const core_mac_address_s& mac ) |
|
287 { |
|
288 core_mac_address_s* addr = iap_whitelist_m.first(); |
|
289 while ( addr ) |
|
290 { |
|
291 if ( *addr == mac ) |
|
292 { |
|
293 iap_whitelist_m.remove( addr ); |
|
294 delete addr; |
|
295 |
|
296 return; |
|
297 } |
|
298 |
|
299 addr = iap_whitelist_m.next(); |
|
300 } |
|
301 } |
|
302 |
|
303 // --------------------------------------------------------------------------- |
|
304 // --------------------------------------------------------------------------- |
|
305 // |
|
306 void core_iap_data_c::add_mac_to_iap_blacklist( |
|
307 const core_mac_address_s& mac ) |
|
308 { |
|
309 if ( !is_mac_in_iap_blacklist( mac ) ) |
|
310 { |
|
311 core_mac_address_s* entry = new core_mac_address_s; |
|
312 if ( entry ) |
|
313 { |
|
314 *entry = mac; |
|
315 iap_blacklist_m.append( entry ); |
|
316 } |
|
317 } |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------------------------- |
|
321 // --------------------------------------------------------------------------- |
|
322 // |
|
323 void core_iap_data_c::remove_mac_from_iap_blacklist( |
|
324 const core_mac_address_s& mac ) |
|
325 { |
|
326 core_mac_address_s* addr = iap_blacklist_m.first(); |
|
327 while ( addr ) |
|
328 { |
|
329 if ( *addr == mac ) |
|
330 { |
|
331 iap_blacklist_m.remove( addr ); |
|
332 delete addr; |
|
333 |
|
334 return; |
|
335 } |
|
336 |
|
337 addr = iap_blacklist_m.next(); |
|
338 } |
|
339 } |