|
1 /* |
|
2 * Copyright (c) 2006-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: Statemachine for handling received neighbor response. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "core_operation_handle_neighbor_response.h" |
|
20 #include "core_frame_dot11_ie.h" |
|
21 #include "core_frame_mgmt_ie.h" |
|
22 #include "core_frame_nr_ie.h" |
|
23 #include "core_frame_action_nr.h" |
|
24 #include "core_tools.h" |
|
25 #include "core_server.h" |
|
26 #include "am_debug.h" |
|
27 |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 core_operation_handle_neighbor_response_c::core_operation_handle_neighbor_response_c( |
|
33 u32_t request_id, |
|
34 core_server_c* server, |
|
35 abs_core_driverif_c* drivers, |
|
36 abs_core_server_callback_c* adaptation, |
|
37 core_frame_action_nr_c* neighbor_response ) : |
|
38 core_operation_base_c( core_operation_handle_neighbor_response, request_id, server, drivers, adaptation, |
|
39 core_base_flag_none ), |
|
40 neighbor_response_m( neighbor_response ), |
|
41 current_ie_m( NULL ), |
|
42 neighbor_resp_parser_m ( NULL ) |
|
43 { |
|
44 DEBUG( "core_operation_handle_neighbor_response_c::core_operation_handle_neighbor_response_c()" ); |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 core_operation_handle_neighbor_response_c::~core_operation_handle_neighbor_response_c() |
|
51 { |
|
52 DEBUG( "core_operation_handle_neighbor_response_c::~core_operation_handle_neighbor_response_c()" ); |
|
53 |
|
54 ie_list_m.clear(); |
|
55 |
|
56 if ( neighbor_response_m ) |
|
57 { |
|
58 delete neighbor_response_m; |
|
59 neighbor_response_m = NULL; |
|
60 } |
|
61 |
|
62 if ( current_ie_m ) |
|
63 { |
|
64 delete current_ie_m; |
|
65 current_ie_m = NULL; |
|
66 } |
|
67 |
|
68 if ( neighbor_resp_parser_m ) |
|
69 { |
|
70 delete neighbor_resp_parser_m; |
|
71 neighbor_resp_parser_m = NULL; |
|
72 } |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 core_error_e core_operation_handle_neighbor_response_c::next_state() |
|
79 { |
|
80 DEBUG( "core_operation_handle_neighbor_response_c::next_state()" ); |
|
81 |
|
82 switch ( operation_state_m ) |
|
83 { |
|
84 case core_state_init: |
|
85 { |
|
86 DEBUG( "core_operation_handle_neighbor_response_c::next_state() - core_state_init" ); |
|
87 |
|
88 if ( !server_m->get_core_settings().is_connected() ) |
|
89 { |
|
90 DEBUG( "core_operation_handle_neighbor_response_c::next_state() - not connected, nothing to do" ); |
|
91 |
|
92 return core_error_general; |
|
93 } |
|
94 |
|
95 DEBUG1( "core_operation_handle_neighbor_response_c::next_state() - Dialog token: 0x%02X", |
|
96 neighbor_response_m->dialog_token() ); |
|
97 |
|
98 // loop through IEs |
|
99 for ( core_frame_dot11_ie_c* ie = neighbor_response_m->first_ie(); ie; ie = neighbor_response_m->next_ie() ) |
|
100 { |
|
101 DEBUG( "core_operation_handle_neighbor_response_c::next_state() - Found IE:" ); |
|
102 DEBUG1( "core_operation_handle_neighbor_response_c::next_state() - ID: 0x%02X", |
|
103 ie->element_id() ); |
|
104 DEBUG1( "core_operation_handle_neighbor_response_c::next_state() - Length: 0x%02X", |
|
105 ie->length() ); |
|
106 |
|
107 ie_list_m.append( ie ); |
|
108 } |
|
109 |
|
110 if ( ie_list_m.count() == 0 ) |
|
111 { |
|
112 DEBUG( "core_operation_handle_neighbor_response_c::next_state() - Neighbor response didn't contain any IEs" ); |
|
113 DEBUG( "core_operation_handle_neighbor_response_c::next_state() - Going to core_state_operation_finished." ); |
|
114 |
|
115 return goto_state( core_state_operation_finished ); |
|
116 } |
|
117 |
|
118 return goto_state( core_state_get_next_ie ); |
|
119 } |
|
120 case core_state_get_next_ie: |
|
121 { |
|
122 DEBUG( "core_operation_handle_neighbor_response_c::next_state() - state core_state_get_next_ie" ); |
|
123 |
|
124 if ( current_ie_m != NULL ) |
|
125 { |
|
126 // deallocate IE |
|
127 delete current_ie_m; |
|
128 current_ie_m = NULL; |
|
129 } |
|
130 |
|
131 current_ie_m = ie_list_m.first(); |
|
132 |
|
133 if ( current_ie_m == NULL ) |
|
134 { |
|
135 DEBUG( "core_operation_handle_neighbor_response_c::next_state() - All IEs processed" ); |
|
136 return goto_state( core_state_operation_finished ); |
|
137 } |
|
138 |
|
139 // remove ie from list, it is now owned by current_ie_m |
|
140 ie_list_m.remove ( current_ie_m ); |
|
141 |
|
142 return asynch_goto( core_state_process_current_ie ); |
|
143 } |
|
144 case core_state_process_current_ie: |
|
145 { |
|
146 if ( current_ie_m->element_id() == core_frame_dot11_ie_c::core_frame_dot11_ie_element_id_neighbor_report ) |
|
147 { |
|
148 // parse IE |
|
149 parse( current_ie_m ); |
|
150 |
|
151 // deallocate IE |
|
152 delete current_ie_m; |
|
153 current_ie_m = NULL; |
|
154 } |
|
155 |
|
156 DEBUG( "core_operation_handle_neighbor_response_c::next_state() - Going to core_state_get_next_ie." ); |
|
157 |
|
158 return goto_state( core_state_get_next_ie ); |
|
159 } |
|
160 case core_state_operation_finished: |
|
161 { |
|
162 DEBUG( "core_operation_handle_neighbor_response_c::next_state() - state core_state_operation_finished" ); |
|
163 |
|
164 return core_error_ok; |
|
165 } |
|
166 default: |
|
167 { |
|
168 ASSERT( false_t ); |
|
169 } |
|
170 } |
|
171 |
|
172 return core_error_request_pending; |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void core_operation_handle_neighbor_response_c::parse( |
|
179 core_frame_dot11_ie_c* ie ) |
|
180 { |
|
181 DEBUG( "core_operation_handle_neighbor_response_c::parse() - * Neighbor Report Response IE received *" ); |
|
182 |
|
183 if ( neighbor_resp_parser_m != NULL ) |
|
184 { |
|
185 delete neighbor_resp_parser_m; |
|
186 neighbor_resp_parser_m = NULL; |
|
187 } |
|
188 |
|
189 neighbor_resp_parser_m = core_frame_nr_ie_c::instance( *ie ); |
|
190 |
|
191 if ( neighbor_resp_parser_m ) |
|
192 { |
|
193 core_mac_address_s a = neighbor_resp_parser_m->bssid(); |
|
194 DEBUG6( "core_operation_handle_neighbor_response_c::parse() - BSSID: %02X:%02X:%02X:%02X:%02X:%02X", |
|
195 a.addr[0],a.addr[1],a.addr[2],a.addr[3],a.addr[4],a.addr[5] ); |
|
196 DEBUG1( "core_operation_handle_neighbor_response_c::parse() - BSSID Information: 0x%08X", |
|
197 neighbor_resp_parser_m->bssid_info() ); |
|
198 DEBUG1( "core_operation_handle_neighbor_response_c::parse() - Regulatory Class: 0x%02X", |
|
199 neighbor_resp_parser_m->regulatory_class() ); |
|
200 DEBUG1( "core_operation_handle_neighbor_response_c::parse() - Channel Number: 0x%02X", |
|
201 neighbor_resp_parser_m->channel_number() ); |
|
202 DEBUG1( "core_operation_handle_neighbor_response_c::parse() - PHY Type: 0x%02X", |
|
203 neighbor_resp_parser_m->phy_type() ); |
|
204 |
|
205 core_scan_channels_c channels; |
|
206 |
|
207 if ( server_m->get_core_settings().is_valid_channel( |
|
208 SCAN_BAND_2DOT4GHZ, |
|
209 neighbor_resp_parser_m->channel_number() ) ) |
|
210 { |
|
211 channels.add( |
|
212 SCAN_BAND_2DOT4GHZ, |
|
213 neighbor_resp_parser_m->channel_number() ); |
|
214 } |
|
215 else |
|
216 { |
|
217 DEBUG( "core_operation_handle_neighbor_response_c::parse() - channel doesn't match the current regional domain, ignoring." ); |
|
218 } |
|
219 |
|
220 DEBUG1( "core_operation_handle_neighbor_response_c::parse() - adding the current channel %u", |
|
221 server_m->get_connection_data()->current_ap_data()->channel() ); |
|
222 channels.add( |
|
223 SCAN_BAND_2DOT4GHZ, |
|
224 server_m->get_connection_data()->current_ap_data()->channel() ); |
|
225 server_m->get_connection_data()->merge_adjacent_ap_channels( |
|
226 channels ); |
|
227 } |
|
228 } |