Changeset a35b458 in mainline for uspace/lib/drv/generic/remote_ieee80211.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_ieee80211.c
r3061bc1 ra35b458 66 66 { 67 67 assert(results); 68 68 69 69 async_exch_t *exch = async_exchange_begin(dev_sess); 70 70 71 71 aid_t aid = async_send_2(exch, DEV_IFACE_ID(IEEE80211_DEV_IFACE), 72 72 IEEE80211_GET_SCAN_RESULTS, now, NULL); … … 74 74 sizeof(ieee80211_scan_results_t)); 75 75 async_exchange_end(exch); 76 76 77 77 errno_t res; 78 78 async_wait_for(aid, &res); 79 79 80 80 if(res != EOK) 81 81 return (errno_t) res; 82 82 83 83 return rc; 84 84 } … … 90 90 return false; 91 91 } 92 92 93 93 return true; 94 94 } … … 99 99 inet_link_info_t link_info; 100 100 size_t count; 101 101 102 102 errno_t rc = inetcfg_get_link_list(&link_list, &count); 103 103 if (rc != EOK) 104 104 return -1; 105 105 106 106 for (size_t i = 0; i < count; i++) { 107 107 rc = inetcfg_link_get(link_list[i], &link_info); 108 108 if (rc != EOK) 109 109 return -1; 110 110 111 111 if (mac_matches(mac, link_info.mac_addr)) 112 112 return link_list[i]; 113 113 } 114 114 115 115 return -1; 116 116 } … … 129 129 { 130 130 assert(ssid_start); 131 131 132 132 errno_t rc_orig; 133 133 134 134 async_exch_t *exch = async_exchange_begin(dev_sess); 135 135 136 136 aid_t aid = async_send_1(exch, DEV_IFACE_ID(IEEE80211_DEV_IFACE), 137 137 IEEE80211_CONNECT, NULL); 138 138 139 139 errno_t rc = async_data_write_start(exch, ssid_start, 140 140 str_size(ssid_start) + 1); … … 142 142 async_exchange_end(exch); 143 143 async_wait_for(aid, &rc_orig); 144 144 145 145 if (rc_orig == EOK) 146 146 return (errno_t) rc; 147 147 148 148 return (errno_t) rc_orig; 149 149 } 150 150 151 151 // FIXME: Typecasting string literal 152 152 if (password == NULL) 153 153 password = (char *) ""; 154 154 155 155 rc = async_data_write_start(exch, password, str_size(password) + 1); 156 156 if (rc != EOK) { 157 157 async_exchange_end(exch); 158 158 async_wait_for(aid, &rc_orig); 159 159 160 160 if (rc_orig == EOK) 161 161 return (errno_t) rc; 162 162 163 163 return (errno_t) rc_orig; 164 164 } 165 165 166 166 async_exchange_end(exch); 167 167 168 168 async_wait_for(aid, &rc); 169 169 if (rc != EOK) 170 170 return rc; 171 171 172 172 /* Send DHCP discover. */ 173 173 nic_address_t wifi_mac; … … 175 175 if (rc != EOK) 176 176 return rc; 177 177 178 178 sysarg_t link_id = get_link_id(wifi_mac.address); 179 179 if (link_id == ((sysarg_t) -1)) 180 180 return EINVAL; 181 181 182 182 rc = dhcp_discover(link_id); 183 183 184 184 return (errno_t) rc; 185 185 } … … 199 199 IEEE80211_DISCONNECT); 200 200 async_exchange_end(exch); 201 202 if (rc != EOK) 203 return rc; 204 201 202 if (rc != EOK) 203 return rc; 204 205 205 nic_address_t wifi_mac; 206 206 rc = nic_get_address(dev_sess, &wifi_mac); 207 207 if (rc != EOK) 208 208 return rc; 209 209 210 210 inet_link_info_t link_info; 211 211 inet_addr_info_t addr_info; … … 214 214 sysarg_t *route_list; 215 215 size_t count; 216 216 217 217 /* Remove previous DHCP address. */ 218 218 rc = inetcfg_get_addr_list(&addr_list, &count); 219 219 if (rc != EOK) 220 220 return rc; 221 221 222 222 for (size_t i = 0; i < count; i++) { 223 223 rc = inetcfg_addr_get(addr_list[i], &addr_info); 224 224 if (rc != EOK) 225 225 return rc; 226 226 227 227 rc = inetcfg_link_get(addr_info.ilink, &link_info); 228 228 if (rc != EOK) 229 229 return rc; 230 230 231 231 if (mac_matches(wifi_mac.address, link_info.mac_addr)) { 232 232 if (str_test_prefix(addr_info.name, "dhcp")) { … … 234 234 if (rc != EOK) 235 235 return rc; 236 236 237 237 break; 238 238 } 239 239 } 240 240 } 241 241 242 242 /* 243 243 * TODO: At this moment there can be only one DHCP route, … … 249 249 if (rc != EOK) 250 250 return rc; 251 251 252 252 for (size_t i = 0; i < count; i++) { 253 253 rc = inetcfg_sroute_get(route_list[i], &route_info); 254 254 if (rc != EOK) 255 255 return rc; 256 256 257 257 if (str_test_prefix(route_info.name, "dhcp")) { 258 258 rc = inetcfg_sroute_delete(route_list[i]); 259 259 if (rc != EOK) 260 260 return rc; 261 261 262 262 break; 263 263 } 264 264 } 265 265 266 266 return rc; 267 267 } … … 272 272 ieee80211_iface_t *ieee80211_iface = (ieee80211_iface_t *) iface; 273 273 assert(ieee80211_iface->get_scan_results); 274 274 275 275 ieee80211_scan_results_t scan_results; 276 276 memset(&scan_results, 0, sizeof(ieee80211_scan_results_t)); 277 277 278 278 bool now = IPC_GET_ARG2(*call); 279 279 280 280 errno_t rc = ieee80211_iface->get_scan_results(fun, &scan_results, now); 281 281 if (rc == EOK) { … … 287 287 return; 288 288 } 289 289 290 290 if (max_len < sizeof(ieee80211_scan_results_t)) { 291 291 async_answer_0(data_callid, ELIMIT); … … 293 293 return; 294 294 } 295 295 296 296 async_data_read_finalize(data_callid, &scan_results, 297 297 sizeof(ieee80211_scan_results_t)); 298 298 } 299 299 300 300 async_answer_0(callid, rc); 301 301 } … … 306 306 ieee80211_iface_t *ieee80211_iface = (ieee80211_iface_t *) iface; 307 307 assert(ieee80211_iface->connect); 308 308 309 309 char ssid_start[MAX_STRING_SIZE]; 310 310 char password[MAX_STRING_SIZE]; 311 311 312 312 ipc_callid_t data_callid; 313 313 size_t len; … … 317 317 return; 318 318 } 319 319 320 320 if (len > MAX_STRING_SIZE) { 321 321 async_answer_0(data_callid, EINVAL); … … 323 323 return; 324 324 } 325 325 326 326 errno_t rc = async_data_write_finalize(data_callid, ssid_start, len); 327 327 if (rc != EOK) { … … 330 330 return; 331 331 } 332 332 333 333 if (!async_data_write_receive(&data_callid, &len)) { 334 334 async_answer_0(data_callid, EINVAL); … … 336 336 return; 337 337 } 338 338 339 339 if (len > MAX_STRING_SIZE) { 340 340 async_answer_0(data_callid, EINVAL); … … 342 342 return; 343 343 } 344 344 345 345 rc = async_data_write_finalize(data_callid, password, len); 346 346 if (rc != EOK) { … … 349 349 return; 350 350 } 351 351 352 352 rc = ieee80211_iface->connect(fun, ssid_start, password); 353 353 354 354 async_answer_0(callid, rc); 355 355 }
Note:
See TracChangeset
for help on using the changeset viewer.