Changeset 3bb5735 in mainline
- Timestamp:
- 2010-11-23T20:50:09Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 442ebbe
- Parents:
- da9f13f3
- git-author:
- Radim Vansa <radim.vansa@…> (2010-11-23 20:50:09)
- git-committer:
- Jakub Jermar <jakub@…> (2010-11-23 20:50:09)
- Location:
- uspace/srv/net/il
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/il/arp/arp.c
rda9f13f3 r3bb5735 516 516 * @param[in] protocol The protocol service. 517 517 * @param[in] target The target protocol address. 518 * @return The hardware address of the target. 519 * @return NULL if the target parameter is NULL. 520 * @return NULL if the device is not found. 521 * @return NULL if the device packet is too small to send a 522 * request. 523 * @return NULL if the hardware address is not found in the cache. 524 */ 525 static measured_string_t * 518 * @param[out] translation Where the hardware address of the target is stored. 519 * @return EOK on success. 520 * @return EAGAIN if the caller should try again. 521 * @return Other error codes in case of error. 522 */ 523 static int 526 524 arp_translate_message(device_id_t device_id, services_t protocol, 527 measured_string_t *target )525 measured_string_t *target, measured_string_t **translation) 528 526 { 529 527 arp_device_t *device; … … 533 531 packet_t *packet; 534 532 arp_header_t *header; 535 536 if (!target) 537 return NULL; 533 int rc; 534 535 if (!target || !translation) 536 return EBADMEM; 538 537 539 538 device = arp_cache_find(&arp_globals.cache, device_id); 540 539 if (!device) 541 return NULL;540 return ENOENT; 542 541 543 542 proto = arp_protos_find(&device->protos, protocol); 544 543 if (!proto || (proto->addr->length != target->length)) 545 return NULL;544 return ENOENT; 546 545 547 546 addr = arp_addr_find(&proto->addresses, target->value, target->length); 548 if (addr) 549 return addr; 547 if (addr) { 548 *translation = addr; 549 return EOK; 550 } 550 551 551 552 /* ARP packet content size = header + (address + translation) * 2 */ … … 553 554 CONVERT_SIZE(char, uint8_t, device->addr->length)); 554 555 if (length > device->packet_dimension.content) 555 return NULL;556 return ELIMIT; 556 557 557 558 packet = packet_get_4_remote(arp_globals.net_phone, … … 559 560 length, device->packet_dimension.suffix); 560 561 if (!packet) 561 return NULL;562 return ENOMEM; 562 563 563 564 header = (arp_header_t *) packet_suffix(packet, length); 564 565 if (!header) { 565 566 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 566 return NULL;567 return ENOMEM; 567 568 } 568 569 … … 583 584 memcpy(((uint8_t *) header) + length, target->value, target->length); 584 585 585 if (packet_set_addr(packet, (uint8_t *) device->addr->value,586 rc = packet_set_addr(packet, (uint8_t *) device->addr->value, 586 587 (uint8_t *) device->broadcast_addr->value, 587 CONVERT_SIZE(char, uint8_t, device->addr->length)) != EOK) { 588 CONVERT_SIZE(char, uint8_t, device->addr->length)); 589 if (rc != EOK) { 588 590 pq_release_remote(arp_globals.net_phone, packet_get_id(packet)); 589 return NULL;591 return rc; 590 592 } 591 593 592 594 nil_send_msg(device->phone, device_id, packet, SERVICE_ARP); 593 return NULL;595 return EAGAIN; 594 596 } 595 597 … … 643 645 644 646 fibril_rwlock_read_lock(&arp_globals.lock); 645 translation= arp_translate_message(IPC_GET_DEVICE(call),646 IPC_GET_SERVICE(call), address );647 rc = arp_translate_message(IPC_GET_DEVICE(call), 648 IPC_GET_SERVICE(call), address, &translation); 647 649 free(address); 648 650 free(data); 651 if (rc != EOK) { 652 fibril_rwlock_read_unlock(&arp_globals.lock); 653 return rc; 654 } 649 655 if (!translation) { 650 656 fibril_rwlock_read_unlock(&arp_globals.lock); -
uspace/srv/net/il/ip/ip.c
rda9f13f3 r3bb5735 115 115 /** The IP localhost address. */ 116 116 #define IPV4_LOCALHOST_ADDRESS htonl((127 << 24) + 1) 117 118 /** How many times can arp_translate_req respond EAGAIN before IP gives up */ 119 #define ARP_EAGAIN_MAX_COUNT 10 117 120 118 121 /** IP global data. */ … … 1008 1011 destination.length = CONVERT_SIZE(dest.s_addr, char, 1); 1009 1012 1010 rc = arp_translate_req(netif->arp->phone, netif->device_id, 1011 SERVICE_IP, &destination, &translation, &data); 1013 /** Try calling translate several times, then give up */ 1014 int count = 0; 1015 do { 1016 rc = arp_translate_req(netif->arp->phone, 1017 netif->device_id, SERVICE_IP, &destination, 1018 &translation, &data); 1019 count++; 1020 } while (rc == EAGAIN && count <= ARP_EAGAIN_MAX_COUNT); 1012 1021 if (rc != EOK) { 1013 1022 pq_release_remote(ip_globals.net_phone,
Note:
See TracChangeset
for help on using the changeset viewer.