Changeset f94b24c8 in mainline for uspace/srv/net/ethip/ethip_nic.c
- Timestamp:
- 2013-07-29T13:54:20Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1c95da
- Parents:
- 09d6695 (diff), ccdc63e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/ethip/ethip_nic.c
r09d6695 rf94b24c8 45 45 #include <device/nic.h> 46 46 #include <stdlib.h> 47 47 #include <net/socket_codes.h> 48 #include <mem.h> 48 49 #include "ethip.h" 49 50 #include "ethip_nic.h" … … 83 84 already_known = false; 84 85 85 list_foreach(ethip_nic_list, nic_link) {86 ethip_nic_t *nic = list_get_instance( nic_link,87 ethip_nic_t, nic_list);86 list_foreach(ethip_nic_list, link) { 87 ethip_nic_t *nic = list_get_instance(link, 88 ethip_nic_t, link); 88 89 if (nic->svc_id == svcs[i]) { 89 90 already_known = true; … … 108 109 { 109 110 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-> nic_list);116 117 link_initialize(&nic->link); 118 118 list_initialize(&nic->addr_list); 119 119 120 120 return nic; 121 121 } … … 130 130 } 131 131 132 link_initialize(&laddr-> addr_list);132 link_initialize(&laddr->link); 133 133 laddr->addr = *addr; 134 134 … … 140 140 if (nic->svc_name != NULL) 141 141 free(nic->svc_name); 142 142 143 free(nic); 143 144 } … … 180 181 181 182 log_msg(LOG_DEFAULT, LVL_DEBUG, "Opened NIC '%s'", nic->svc_name); 182 list_append(&nic-> nic_list, ðip_nic_list);183 list_append(&nic->link, ðip_nic_list); 183 184 in_list = true; 184 185 … … 209 210 error: 210 211 if (in_list) 211 list_remove(&nic->nic_list); 212 list_remove(&nic->link); 213 212 214 if (nic->sess != NULL) 213 215 async_hangup(nic->sess); 216 214 217 ethip_nic_delete(nic); 215 218 return rc; … … 312 315 list_foreach(ethip_nic_list, link) { 313 316 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_find_by_iplink_sid - element"); 314 ethip_nic_t *nic = list_get_instance(link, ethip_nic_t, 315 nic_list); 317 ethip_nic_t *nic = list_get_instance(link, ethip_nic_t, link); 316 318 317 319 if (nic->iplink_sid == iplink_sid) { … … 334 336 } 335 337 338 /** Setup accepted multicast addresses 339 * 340 * Currently the set of accepted multicast addresses is 341 * 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 } else 402 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 336 414 int ethip_nic_addr_add(ethip_nic_t *nic, inet_addr_t *addr) 337 415 { … … 342 420 return ENOMEM; 343 421 344 list_append(&laddr->addr_list, &nic->addr_list); 345 return EOK; 422 list_append(&laddr->link, &nic->addr_list); 423 424 return ethip_nic_setup_multicast(nic); 346 425 } 347 426 … … 354 433 return ENOENT; 355 434 356 list_remove(&laddr-> addr_list);435 list_remove(&laddr->link); 357 436 ethip_link_addr_delete(laddr); 358 return EOK; 437 438 return ethip_nic_setup_multicast(nic); 359 439 } 360 440 … … 366 446 list_foreach(nic->addr_list, link) { 367 447 ethip_link_addr_t *laddr = list_get_instance(link, 368 ethip_link_addr_t, addr_list);448 ethip_link_addr_t, link); 369 449 370 450 if (inet_addr_compare(addr, &laddr->addr))
Note:
See TracChangeset
for help on using the changeset viewer.