|
1 /* |
|
2 * Copyright (c) 2005-2009 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: State machine for roaming |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 26 % |
|
20 */ |
|
21 |
|
22 #ifndef CORE_OPERATION_ROAM_H |
|
23 #define CORE_OPERATION_ROAM_H |
|
24 |
|
25 #include "core_operation_base.h" |
|
26 #include "core_type_list.h" |
|
27 #include "core_ap_data.h" |
|
28 #include "core_frame_dot11_ie.h" |
|
29 |
|
30 class core_frame_assoc_resp_c; |
|
31 |
|
32 /** |
|
33 * State machine for roaming between APs. |
|
34 * |
|
35 * @since S60 v3.1 |
|
36 */ |
|
37 NONSHARABLE_CLASS( core_operation_roam_c ) : public core_operation_base_c |
|
38 { |
|
39 |
|
40 public: |
|
41 |
|
42 /** |
|
43 * Data structure for a roaming list entry. |
|
44 */ |
|
45 struct roaming_list_entry_s |
|
46 { |
|
47 core_ap_data_c* ap_data; |
|
48 bool_t is_cached_sa_available; |
|
49 }; |
|
50 |
|
51 /** |
|
52 * The possible states of the state machine. |
|
53 */ |
|
54 enum core_state_e |
|
55 { |
|
56 core_state_init = core_base_state_next, |
|
57 core_state_req_disable_userdata_before_connect, |
|
58 core_state_req_connect, |
|
59 core_state_req_update_ts, |
|
60 core_state_req_enable_userdata, |
|
61 core_state_fail_connect, |
|
62 core_state_fail_set_tx_power, |
|
63 core_state_MAX |
|
64 }; |
|
65 |
|
66 /** |
|
67 * Constructor |
|
68 * |
|
69 * @param request_id An unique identification for the request. |
|
70 * @param server Handle to core server. |
|
71 * @param drivers Handle to low-level management functionality. |
|
72 * @param adaptation Handle upper-level management functionality. |
|
73 * @param is_connected Whether the terminal is currently connected to a BSS. |
|
74 * @param tag Tag used for iterating scan results for a suitable AP. |
|
75 * @param min_required_rcpi Minimum RCPI value required for connection. |
|
76 * @param min_medium_time Minimum amount of free medium time required for connection. |
|
77 * @param ssid SSID used for connection. |
|
78 * @param bssid BSSID used for connection, BROADCAST_MAC_ADDR if any. |
|
79 */ |
|
80 core_operation_roam_c( |
|
81 u32_t request_id, |
|
82 core_server_c* server, |
|
83 abs_core_driverif_c* drivers, |
|
84 abs_core_server_callback_c* adaptation, |
|
85 bool_t& is_connected, |
|
86 u8_t tag, |
|
87 u8_t min_required_rcpi, |
|
88 const medium_time_s& min_medium_time, |
|
89 const core_ssid_s& ssid, |
|
90 const core_mac_address_s& bssid ); |
|
91 |
|
92 /** |
|
93 * Destructor. |
|
94 */ |
|
95 virtual ~core_operation_roam_c(); |
|
96 |
|
97 protected: |
|
98 |
|
99 /** |
|
100 * This method is called when a pending request has been completed |
|
101 * and so sub-operations are pending. |
|
102 * |
|
103 * @return status of the operation: |
|
104 * core_error_request_pending if the operation is not finished, |
|
105 * otherwise the status code of the finished operation |
|
106 */ |
|
107 core_error_e next_state(); |
|
108 |
|
109 /** |
|
110 * This method is called when the operation needs to be canceled. |
|
111 * |
|
112 * @return status of the operation: |
|
113 * core_error_request_pending if the operation is not finished, |
|
114 * otherwise the status code of the finished operation |
|
115 */ |
|
116 core_error_e cancel(); |
|
117 |
|
118 private: |
|
119 |
|
120 /** |
|
121 * Check whether a cached security association is available for the given AP. |
|
122 * |
|
123 * @param ap_data Information about the AP. |
|
124 * @return true_t if a security association exists, false_t otherwise. |
|
125 */ |
|
126 bool_t is_security_association_available( |
|
127 const core_ap_data_c& ap_data ); |
|
128 |
|
129 /** |
|
130 * Determine the connection status based on the status information. |
|
131 * |
|
132 * @param request_status The request completion status. |
|
133 * @param management_status The association response status from the AP. |
|
134 * @return The connection status based on the status information. |
|
135 */ |
|
136 core_connect_status_e connect_status( |
|
137 core_error_e request_status, |
|
138 core_management_status_e management_status ); |
|
139 |
|
140 /** |
|
141 * Decide whether the connection failure is fatal and the AP should |
|
142 * be blacklisted. |
|
143 * |
|
144 * @param request_status The request completion status. |
|
145 * @param management_status The association response status from the AP. |
|
146 * @param is_reassociation Whether the connection attempt was a reassociation. |
|
147 * @return core_ap_blacklist_reason_none if no blacklisting required, |
|
148 * the reason otherwise. |
|
149 */ |
|
150 core_ap_blacklist_reason_e is_fatal_failure( |
|
151 core_error_e request_status, |
|
152 core_management_status_e management_status, |
|
153 bool_t is_reassociation ) const; |
|
154 |
|
155 /** |
|
156 * Determine the connection status based on the EAP information. |
|
157 * |
|
158 * @param security_mode The used security mode. |
|
159 * @param eap_type EAP type used |
|
160 * @param eap_error EAP-specific error code. |
|
161 * @return The connection status based on the EAP information. |
|
162 */ |
|
163 core_connect_status_e eap_connect_status( |
|
164 core_security_mode_e security_mode, |
|
165 u32_t eap_type, |
|
166 u32_t eap_error ) const; |
|
167 |
|
168 /** |
|
169 * Process the frame and add it to the roaming list if suitable for connecting. |
|
170 * |
|
171 * @param ap_data Information about the AP. |
|
172 * @return true_t if the AP was added to the roaming list, false_t otherwise. |
|
173 */ |
|
174 bool_t process_frame( |
|
175 core_ap_data_c& ap_data ); |
|
176 |
|
177 /** |
|
178 * Update roam metrics based on the connection failure reason. |
|
179 * |
|
180 * @param request_status The request completion status. |
|
181 * @param management_status The association response status from the AP. |
|
182 */ |
|
183 void update_roam_failure_count( |
|
184 core_error_e request_status, |
|
185 core_management_status_e management_status ); |
|
186 |
|
187 /** |
|
188 * Create and send neighbor report request. |
|
189 */ |
|
190 void handle_neighbor_request(); |
|
191 |
|
192 private: // data |
|
193 |
|
194 /** Whether we are still connected to an AP. */ |
|
195 bool_t& is_connected_m; |
|
196 |
|
197 /** The scan tag used for iterating suitable APs. */ |
|
198 u8_t tag_m; |
|
199 |
|
200 /** The minimum RCPI value required. */ |
|
201 u8_t min_required_rcpi_m; |
|
202 |
|
203 /** The minimum amount of free medium time required. */ |
|
204 const medium_time_s min_medium_time_m; |
|
205 |
|
206 /** SSID to use for connection. */ |
|
207 const core_ssid_s ssid_m; |
|
208 |
|
209 /** BSSID to use for connection. */ |
|
210 const core_mac_address_s bssid_m; |
|
211 |
|
212 /** List of suitable APs. */ |
|
213 core_type_list_c<roaming_list_entry_s> roaming_list_m; |
|
214 |
|
215 /** Status of connection attempt. */ |
|
216 core_management_status_e management_status_m; |
|
217 |
|
218 /** Connect status for the current connection attempt. */ |
|
219 core_connect_status_e connect_status_m; |
|
220 |
|
221 /** The AP currently tried. Not owned by this pointer. */ |
|
222 core_ap_data_c* current_ap_m; |
|
223 |
|
224 /** BSSID currently connected to. */ |
|
225 core_mac_address_s current_bssid_m; |
|
226 |
|
227 /** The list of IEs that will be added to the association/reassociation request */ |
|
228 core_type_list_c<core_frame_dot11_ie_c> assoc_ie_list_m; |
|
229 |
|
230 /** Whether the connection attempt uses a cached security association. */ |
|
231 bool_t is_cached_sa_used_m; |
|
232 |
|
233 /** The (re-)association response frame is stored here if received. */ |
|
234 core_frame_assoc_resp_c* assoc_resp_m; |
|
235 |
|
236 }; |
|
237 |
|
238 #endif // CORE_OPERATION_ROAM_H |