From 14d0b44b79174d4fd45af46ce4383ef05063cca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 12 Aug 2010 13:38:52 +0000 Subject: [PATCH] * Applied the B_SOCKET_SET_ALIAS address retrieval logic to B_SOCKET_GET_ALIAS as well (of course, no address is created automatically here). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38058 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/network/stack/datalink.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/add-ons/kernel/network/stack/datalink.cpp b/src/add-ons/kernel/network/stack/datalink.cpp index ef779f7e59..2f4f1f1deb 100644 --- a/src/add-ons/kernel/network/stack/datalink.cpp +++ b/src/add-ons/kernel/network/stack/datalink.cpp @@ -775,8 +775,21 @@ interface_protocol_control(net_datalink_protocol* _protocol, int32 option, if (user_memcpy(&request, argument, sizeof(ifaliasreq)) != B_OK) return B_BAD_ADDRESS; - InterfaceAddress* address - = interface->AddressAt(request.ifra_index); + InterfaceAddress* address = NULL; + if (request.ifra_index < 0) { + if (!protocol->domain->address_module->is_empty_address( + (const sockaddr*)&request.ifra_addr, false)) { + // Find first address that matches the local address + address = interface->AddressForLocal(protocol->domain, + (const sockaddr*)&request.ifra_addr); + } + if (address == NULL) { + // Find first address for family + address = interface->FirstForFamily( + protocol->domain->family); + } + } else + address = interface->AddressAt(request.ifra_index); if (address == NULL) return B_BAD_VALUE;