Changeset 053fc2b in mainline for uspace/lib/ieee80211/src/ieee80211_iface_impl.c
- Timestamp:
- 2015-04-10T13:52:11Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a931b7b
- Parents:
- d7dadcb4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ieee80211/src/ieee80211_iface_impl.c
rd7dadcb4 r053fc2b 48 48 * @param results Structure where should be stored scan results. 49 49 * 50 * @return EOK .50 * @return EOK if everything went OK, EREFUSED when device is not ready yet. 51 51 */ 52 52 int ieee80211_get_scan_results_impl(ddf_fun_t *fun, … … 59 59 return EREFUSED; 60 60 61 fibril_mutex_lock(&ieee80211_dev->ap_list.scan_mutex); 62 time_t scan_span = time(NULL) - ieee80211_dev->ap_list.last_scan; 63 fibril_mutex_unlock(&ieee80211_dev->ap_list.scan_mutex); 64 65 if(now || scan_span > MAX_SCAN_SPAN_SEC) { 61 if(now) { 66 62 ieee80211_dev->ops->scan(ieee80211_dev); 67 63 } 68 64 69 fibril_mutex_lock(&ieee80211_dev->ap_list. scan_mutex);65 fibril_mutex_lock(&ieee80211_dev->ap_list.results_mutex); 70 66 if(results) { 71 67 ieee80211_scan_result_list_t *result_list = … … 82 78 results->length = i; 83 79 } 84 fibril_mutex_unlock(&ieee80211_dev->ap_list. scan_mutex);80 fibril_mutex_unlock(&ieee80211_dev->ap_list.results_mutex); 85 81 86 82 return EOK; … … 103 99 ieee80211_scan_result_link_t *auth_data, char *password) 104 100 { 105 int rc;106 107 101 ieee80211_dev->bssid_info.res_link = auth_data; 108 102 109 103 /* Set channel. */ 110 rc = ieee80211_dev->ops->set_freq(ieee80211_dev,104 int rc = ieee80211_dev->ops->set_freq(ieee80211_dev, 111 105 ieee80211_channel_to_freq(auth_data->scan_result.channel)); 112 106 if(rc != EOK) … … 122 116 if(rc != EOK) 123 117 return rc; 124 if(ieee80211_dev->current_auth_phase != IEEE80211_AUTH_AUTHENTICATED) 118 if(ieee80211_get_auth_phase(ieee80211_dev) != 119 IEEE80211_AUTH_AUTHENTICATED) { 120 ieee80211_set_auth_phase(ieee80211_dev, 121 IEEE80211_AUTH_DISCONNECTED); 125 122 return EINVAL; 123 } 126 124 127 125 /* Try to associate. */ … … 134 132 if(rc != EOK) 135 133 return rc; 136 if(ieee80211_dev->current_auth_phase != IEEE80211_AUTH_ASSOCIATED) 134 if(ieee80211_get_auth_phase(ieee80211_dev) != 135 IEEE80211_AUTH_ASSOCIATED) { 136 ieee80211_set_auth_phase(ieee80211_dev, 137 IEEE80211_AUTH_DISCONNECTED); 137 138 return EINVAL; 139 } 138 140 139 141 /* On open network, we are finished. */ 140 if(auth_data->scan_result.security.type == IEEE80211_SECURITY_OPEN) 141 return EOK; 142 143 /* Otherwise wait for 4-way handshake to complete. */ 144 fibril_mutex_lock(&ieee80211_dev->gen_mutex); 145 rc = fibril_condvar_wait_timeout(&ieee80211_dev->gen_cond, 146 &ieee80211_dev->gen_mutex, 147 HANDSHAKE_TIMEOUT); 148 fibril_mutex_unlock(&ieee80211_dev->gen_mutex); 149 if(rc != EOK) 150 return rc; 151 if(ieee80211_dev->current_auth_phase != IEEE80211_AUTH_ASSOCIATED) 152 return EINVAL; 142 if(auth_data->scan_result.security.type != IEEE80211_SECURITY_OPEN) { 143 /* Otherwise wait for 4-way handshake to complete. */ 144 fibril_mutex_lock(&ieee80211_dev->gen_mutex); 145 rc = fibril_condvar_wait_timeout(&ieee80211_dev->gen_cond, 146 &ieee80211_dev->gen_mutex, 147 HANDSHAKE_TIMEOUT); 148 fibril_mutex_unlock(&ieee80211_dev->gen_mutex); 149 if(rc != EOK) { 150 ieee80211_deauthenticate(ieee80211_dev); 151 return rc; 152 } 153 } 154 155 ieee80211_set_auth_phase(ieee80211_dev, IEEE80211_AUTH_CONNECTED); 153 156 154 157 return EOK; … … 163 166 * @return EOK if everything OK, ETIMEOUT when timeout during authenticating, 164 167 * EINVAL when SSID not in scan results list, EPERM when incorrect password 165 * passed .168 * passed, EREFUSED when device is not ready yet. 166 169 */ 167 170 int ieee80211_connect_impl(ddf_fun_t *fun, char *ssid_start, char *password) … … 170 173 assert(password); 171 174 175 int rc; 176 172 177 nic_t *nic_data = nic_get_from_ddf_fun(fun); 173 178 ieee80211_dev_t *ieee80211_dev = nic_get_specific(nic_data); … … 177 182 178 183 if(ieee80211_is_connected(ieee80211_dev)) { 179 intrc = ieee80211_dev->iface->disconnect(fun);184 rc = ieee80211_dev->iface->disconnect(fun); 180 185 if(rc != EOK) 181 186 return rc; 182 187 } 183 188 184 fibril_mutex_lock(&ieee80211_dev->ap_list.scan_mutex); 189 ieee80211_set_connect_request(ieee80211_dev); 190 191 rc = ENOENT; 192 fibril_mutex_lock(&ieee80211_dev->scan_mutex); 193 194 ieee80211_dev->pending_conn_req = false; 185 195 186 196 ieee80211_scan_result_list_foreach(ieee80211_dev->ap_list, result) { … … 188 198 result->scan_result.ssid, 189 199 str_size(ssid_start))) { 190 fibril_mutex_unlock(&ieee80211_dev->ap_list.scan_mutex); 191 return ieee80211_connect_proc(ieee80211_dev, result, 200 rc = ieee80211_connect_proc(ieee80211_dev, result, 192 201 password); 202 break; 193 203 } 194 204 } 195 205 196 fibril_mutex_unlock(&ieee80211_dev-> ap_list.scan_mutex);197 198 return EINVAL;206 fibril_mutex_unlock(&ieee80211_dev->scan_mutex); 207 208 return rc; 199 209 } 200 210 … … 204 214 * @param fun Device function. 205 215 * 206 * @return EOK if everything OK, E INVAL when not connected to any network.216 * @return EOK if everything OK, EREFUSED if device is not ready yet. 207 217 */ 208 218 int ieee80211_disconnect_impl(ddf_fun_t *fun) … … 215 225 216 226 if(!ieee80211_is_connected(ieee80211_dev)) { 217 return E INVAL;227 return EOK; 218 228 } else { 219 return ieee80211_deauthenticate(ieee80211_dev); 229 fibril_mutex_lock(&ieee80211_dev->ap_list.results_mutex); 230 int rc = ieee80211_deauthenticate(ieee80211_dev); 231 fibril_mutex_unlock(&ieee80211_dev->ap_list.results_mutex); 232 return rc; 220 233 } 221 234 }
Note:
See TracChangeset
for help on using the changeset viewer.