Changeset 053fc2b in mainline for uspace/lib/drv/generic/remote_ieee80211.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/drv/generic/remote_ieee80211.c
rd7dadcb4 r053fc2b 38 38 #include <macros.h> 39 39 #include <str.h> 40 #include <inet/dhcp.h> 41 #include <inet/inetcfg.h> 40 42 41 43 #include "ops/ieee80211.h" 42 44 #include "ieee80211_iface.h" 45 #include "nic_iface.h" 43 46 44 47 #define MAX_STRING_SIZE 32 … … 80 83 } 81 84 85 static bool mac_matches(uint8_t *mac1, uint8_t *mac2) 86 { 87 for(size_t i = 0; i < ETH_ADDR; i++) { 88 if(mac1[i] != mac2[i]) 89 return false; 90 } 91 92 return true; 93 } 94 95 static sysarg_t get_link_id(uint8_t *mac) 96 { 97 sysarg_t *link_list; 98 inet_link_info_t link_info; 99 size_t count; 100 101 int rc = inetcfg_get_link_list(&link_list, &count); 102 if (rc != EOK) 103 return -1; 104 105 for (size_t i = 0; i < count; i++) { 106 rc = inetcfg_link_get(link_list[i], &link_info); 107 if (rc != EOK) 108 return -1; 109 110 if(mac_matches(mac, link_info.mac_addr)) { 111 return link_list[i]; 112 } 113 } 114 115 return -1; 116 } 117 82 118 /** Connect to specified network. 83 119 * … … 130 166 131 167 async_wait_for(aid, &rc); 168 if (rc != EOK) 169 return rc; 170 171 /* Send DHCP discover. */ 172 nic_address_t wifi_mac; 173 rc = nic_get_address(dev_sess, &wifi_mac); 174 if (rc != EOK) 175 return rc; 176 177 sysarg_t link_id = get_link_id(wifi_mac.address); 178 if(link_id == ((sysarg_t) -1)) 179 return EINVAL; 180 181 rc = dhcp_discover(link_id); 132 182 133 183 return (int) rc; … … 147 197 IEEE80211_DISCONNECT); 148 198 async_exchange_end(exch); 199 200 if(rc != EOK) 201 return rc; 202 203 nic_address_t wifi_mac; 204 rc = nic_get_address(dev_sess, &wifi_mac); 205 if (rc != EOK) 206 return rc; 207 208 inet_link_info_t link_info; 209 inet_addr_info_t addr_info; 210 inet_sroute_info_t route_info; 211 sysarg_t *addr_list; 212 sysarg_t *route_list; 213 size_t count; 214 215 /* Remove previous DHCP address. */ 216 rc = inetcfg_get_addr_list(&addr_list, &count); 217 if (rc != EOK) 218 return rc; 219 220 for (size_t i = 0; i < count; i++) { 221 rc = inetcfg_addr_get(addr_list[i], &addr_info); 222 if (rc != EOK) 223 return rc; 224 225 rc = inetcfg_link_get(addr_info.ilink, &link_info); 226 if (rc != EOK) 227 return rc; 228 229 if(mac_matches(wifi_mac.address, link_info.mac_addr)) { 230 if(str_test_prefix(addr_info.name, "dhcp")) { 231 rc = inetcfg_addr_delete(addr_list[i]); 232 if(rc != EOK) 233 return rc; 234 break; 235 } 236 } 237 } 238 239 /* 240 * TODO: At this moment there can be only one DHCP route, 241 * so it must be reimplemented after this limitation will be 242 * dropped. 243 */ 244 /* Remove previous DHCP static route. */ 245 rc = inetcfg_get_sroute_list(&route_list, &count); 246 if (rc != EOK) 247 return rc; 248 249 for (size_t i = 0; i < count; i++) { 250 rc = inetcfg_sroute_get(route_list[i], &route_info); 251 if (rc != EOK) 252 return rc; 253 254 if(str_test_prefix(route_info.name, "dhcp")) { 255 rc = inetcfg_sroute_delete(route_list[i]); 256 if(rc != EOK) 257 return rc; 258 break; 259 } 260 } 149 261 150 262 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.