From 4e45de0e5f58b5a31ea1b56105c6e60467f09df6 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sun, 10 Jan 2010 15:26:46 +0000 Subject: [PATCH] * when connect()ing an UDP socket, we need to set the local address to the default address of the outgoing interface as a side-effect git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34989 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/network/protocols/udp/udp.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/add-ons/kernel/network/protocols/udp/udp.cpp b/src/add-ons/kernel/network/protocols/udp/udp.cpp index bc28440c8a..034003fcb4 100644 --- a/src/add-ons/kernel/network/protocols/udp/udp.cpp +++ b/src/add-ons/kernel/network/protocols/udp/udp.cpp @@ -315,6 +315,15 @@ UdpDomainSupport::ConnectEndpoint(UdpEndpoint *endpoint, status_t status = endpoint->PeerAddress().SetTo(address); if (status < B_OK) return status; + struct net_route *routeToDestination + = gDatalinkModule->get_route(fDomain, address); + if (routeToDestination) { + status = endpoint->LocalAddress().SetTo( + routeToDestination->interface->address); + gDatalinkModule->put_route(fDomain, routeToDestination); + if (status < B_OK) + return status; + } } // we need to activate no matter whether or not we have just disconnected,