Changeset 8a64320e in mainline for uspace/lib/drv/generic/remote_ieee80211.c
- Timestamp:
- 2015-04-23T23:40:14Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dcba819
- Parents:
- 09044cb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_ieee80211.c
r09044cb r8a64320e 40 40 #include <inet/dhcp.h> 41 41 #include <inet/inetcfg.h> 42 43 42 #include "ops/ieee80211.h" 44 43 #include "ieee80211_iface.h" 45 44 #include "nic_iface.h" 46 45 47 #define MAX_STRING_SIZE 3246 #define MAX_STRING_SIZE 32 48 47 49 48 /** IEEE 802.11 RPC functions IDs. */ … … 56 55 /** Get scan results from IEEE 802.11 device 57 56 * 58 * @param[in] dev_sess Device session.59 * @param[out] results Structure where to put scan results.57 * @param[in] dev_sess Device session. 58 * @param[out] results Structure where to put scan results. 60 59 * 61 60 * @return EOK If the operation was successfully completed, 62 * negative error code otherwise. 63 */ 64 int ieee80211_get_scan_results(async_sess_t *dev_sess, 65 ieee80211_scan_results_t *results, bool now) 61 * negative error code otherwise. 62 * 63 */ 64 int ieee80211_get_scan_results(async_sess_t *dev_sess, 65 ieee80211_scan_results_t *results, bool now) 66 66 { 67 67 assert(results); … … 71 71 aid_t aid = async_send_2(exch, DEV_IFACE_ID(IEEE80211_DEV_IFACE), 72 72 IEEE80211_GET_SCAN_RESULTS, now, NULL); 73 int rc = async_data_read_start(exch, results, sizeof(ieee80211_scan_results_t)); 73 int rc = async_data_read_start(exch, results, 74 sizeof(ieee80211_scan_results_t)); 74 75 async_exchange_end(exch); 75 76 76 77 sysarg_t res; 77 78 async_wait_for(aid, &res); … … 79 80 if(res != EOK) 80 81 return (int) res; 81 else82 82 83 return rc; 83 84 } 84 85 85 86 static bool mac_matches(uint8_t *mac1, uint8_t *mac2) 86 87 { 87 for (size_t i = 0; i < ETH_ADDR; i++) {88 if (mac1[i] != mac2[i])88 for (size_t i = 0; i < ETH_ADDR; i++) { 89 if (mac1[i] != mac2[i]) 89 90 return false; 90 91 } … … 108 109 return -1; 109 110 110 if (mac_matches(mac, link_info.mac_addr)) {111 if (mac_matches(mac, link_info.mac_addr)) 111 112 return link_list[i]; 112 }113 113 } 114 114 … … 118 118 /** Connect to specified network. 119 119 * 120 * @param[in] dev_sess Device session.120 * @param[in] dev_sess Device session. 121 121 * @param[in] ssid_start Network SSID prefix. 122 * @param[in] password Network password (pass empty string if not needed).122 * @param[in] password Network password (pass empty string if not needed). 123 123 * 124 124 * @return EOK If the operation was successfully completed, 125 * negative error code otherwise. 125 * negative error code otherwise. 126 * 126 127 */ 127 128 int ieee80211_connect(async_sess_t *dev_sess, char *ssid_start, char *password) … … 136 137 IEEE80211_CONNECT, NULL); 137 138 138 sysarg_t rc = async_data_write_start(exch, ssid_start, 139 139 sysarg_t rc = async_data_write_start(exch, ssid_start, 140 str_size(ssid_start) + 1); 140 141 if (rc != EOK) { 141 142 async_exchange_end(exch); … … 144 145 if (rc_orig == EOK) 145 146 return (int) rc; 146 else 147 return (int) rc_orig; 148 } 149 150 if(password == NULL) { 147 148 return (int) rc_orig; 149 } 150 151 // FIXME: Typecasting string literal 152 if (password == NULL) 151 153 password = (char *) ""; 152 }153 154 154 155 rc = async_data_write_start(exch, password, str_size(password) + 1); … … 159 160 if (rc_orig == EOK) 160 161 return (int) rc; 161 else162 162 163 return (int) rc_orig; 163 164 } 164 165 165 166 async_exchange_end(exch); 166 167 167 168 async_wait_for(aid, &rc); 168 169 if (rc != EOK) … … 176 177 177 178 sysarg_t link_id = get_link_id(wifi_mac.address); 178 if (link_id == ((sysarg_t) -1))179 if (link_id == ((sysarg_t) -1)) 179 180 return EINVAL; 180 181 … … 189 190 * 190 191 * @return EOK If the operation was successfully completed, 191 * negative error code otherwise. 192 * negative error code otherwise. 193 * 192 194 */ 193 195 int ieee80211_disconnect(async_sess_t *dev_sess) … … 198 200 async_exchange_end(exch); 199 201 200 if (rc != EOK)202 if (rc != EOK) 201 203 return rc; 202 204 … … 227 229 return rc; 228 230 229 if (mac_matches(wifi_mac.address, link_info.mac_addr)) {230 if (str_test_prefix(addr_info.name, "dhcp")) {231 if (mac_matches(wifi_mac.address, link_info.mac_addr)) { 232 if (str_test_prefix(addr_info.name, "dhcp")) { 231 233 rc = inetcfg_addr_delete(addr_list[i]); 232 if (rc != EOK)234 if (rc != EOK) 233 235 return rc; 236 234 237 break; 235 238 } … … 237 240 } 238 241 239 /* 242 /* 240 243 * TODO: At this moment there can be only one DHCP route, 241 244 * so it must be reimplemented after this limitation will be … … 252 255 return rc; 253 256 254 if (str_test_prefix(route_info.name, "dhcp")) {257 if (str_test_prefix(route_info.name, "dhcp")) { 255 258 rc = inetcfg_sroute_delete(route_list[i]); 256 if (rc != EOK)259 if (rc != EOK) 257 260 return rc; 261 258 262 break; 259 263 }
Note:
See TracChangeset
for help on using the changeset viewer.