Changes in uspace/srv/net/ethip/ethip_nic.c [83781a22:02a09ed] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/ethip/ethip_nic.c
r83781a22 r02a09ed 45 45 #include <device/nic.h> 46 46 #include <stdlib.h> 47 #include <net/socket_codes.h> 48 #include <mem.h> 47 49 48 #include "ethip.h" 50 49 #include "ethip_nic.h" … … 84 83 already_known = false; 85 84 86 list_foreach(ethip_nic_list, link) {87 ethip_nic_t *nic = list_get_instance( link,88 ethip_nic_t, link);85 list_foreach(ethip_nic_list, nic_link) { 86 ethip_nic_t *nic = list_get_instance(nic_link, 87 ethip_nic_t, nic_list); 89 88 if (nic->svc_id == svcs[i]) { 90 89 already_known = true; … … 109 108 { 110 109 ethip_nic_t *nic = calloc(1, sizeof(ethip_nic_t)); 110 111 111 if (nic == NULL) { 112 112 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed allocating NIC structure. " … … 114 114 return NULL; 115 115 } 116 117 link_initialize(&nic-> link);116 117 link_initialize(&nic->nic_list); 118 118 list_initialize(&nic->addr_list); 119 119 120 120 return nic; 121 121 } … … 130 130 } 131 131 132 link_initialize(&laddr-> link);132 link_initialize(&laddr->addr_list); 133 133 laddr->addr = *addr; 134 134 … … 140 140 if (nic->svc_name != NULL) 141 141 free(nic->svc_name); 142 143 142 free(nic); 144 143 } … … 181 180 182 181 log_msg(LOG_DEFAULT, LVL_DEBUG, "Opened NIC '%s'", nic->svc_name); 183 list_append(&nic-> link, ðip_nic_list);182 list_append(&nic->nic_list, ðip_nic_list); 184 183 in_list = true; 185 184 … … 210 209 error: 211 210 if (in_list) 212 list_remove(&nic->link); 213 211 list_remove(&nic->nic_list); 214 212 if (nic->sess != NULL) 215 213 async_hangup(nic->sess); 216 217 214 ethip_nic_delete(nic); 218 215 return rc; … … 315 312 list_foreach(ethip_nic_list, link) { 316 313 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_find_by_iplink_sid - element"); 317 ethip_nic_t *nic = list_get_instance(link, ethip_nic_t, link); 314 ethip_nic_t *nic = list_get_instance(link, ethip_nic_t, 315 nic_list); 318 316 319 317 if (nic->iplink_sid == iplink_sid) { … … 336 334 } 337 335 338 /** Setup accepted multicast addresses339 *340 * Currently the set of accepted multicast addresses is341 * determined only based on IPv6 addresses.342 *343 */344 static int ethip_nic_setup_multicast(ethip_nic_t *nic)345 {346 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_setup_multicast()");347 348 /* Count the number of multicast addresses */349 350 size_t count = 0;351 352 list_foreach(nic->addr_list, link) {353 ethip_link_addr_t *laddr = list_get_instance(link,354 ethip_link_addr_t, link);355 356 uint16_t af = inet_addr_get(&laddr->addr, NULL, NULL);357 if (af == AF_INET6)358 count++;359 }360 361 if (count == 0)362 return nic_multicast_set_mode(nic->sess, NIC_MULTICAST_BLOCKED,363 NULL, 0);364 365 nic_address_t *mac_list = calloc(count, sizeof(nic_address_t));366 if (mac_list == NULL)367 return ENOMEM;368 369 /* Create the multicast MAC list */370 371 size_t i = 0;372 373 list_foreach(nic->addr_list, link) {374 assert(i < count);375 376 ethip_link_addr_t *laddr = list_get_instance(link,377 ethip_link_addr_t, link);378 379 addr128_t v6;380 uint16_t af = inet_addr_get(&laddr->addr, NULL, &v6);381 if (af != AF_INET6)382 continue;383 384 addr48_t mac;385 addr48_solicited_node(v6, mac);386 387 /* Avoid duplicate addresses in the list */388 389 bool found = false;390 391 for (size_t j = 0; j < i; j++) {392 if (addr48_compare(mac_list[j].address, mac)) {393 found = true;394 break;395 }396 }397 398 if (!found) {399 addr48(mac, mac_list[i].address);400 i++;401 } else402 count--;403 }404 405 /* Setup the multicast MAC list */406 407 int rc = nic_multicast_set_mode(nic->sess, NIC_MULTICAST_LIST,408 mac_list, count);409 410 free(mac_list);411 return rc;412 }413 414 336 int ethip_nic_addr_add(ethip_nic_t *nic, inet_addr_t *addr) 415 337 { … … 420 342 return ENOMEM; 421 343 422 list_append(&laddr->link, &nic->addr_list); 423 424 return ethip_nic_setup_multicast(nic); 344 list_append(&laddr->addr_list, &nic->addr_list); 345 return EOK; 425 346 } 426 347 … … 433 354 return ENOENT; 434 355 435 list_remove(&laddr-> link);356 list_remove(&laddr->addr_list); 436 357 ethip_link_addr_delete(laddr); 437 438 return ethip_nic_setup_multicast(nic); 358 return EOK; 439 359 } 440 360 … … 446 366 list_foreach(nic->addr_list, link) { 447 367 ethip_link_addr_t *laddr = list_get_instance(link, 448 ethip_link_addr_t, link);368 ethip_link_addr_t, addr_list); 449 369 450 370 if (inet_addr_compare(addr, &laddr->addr))
Note:
See TracChangeset
for help on using the changeset viewer.