From 3c7287cce1b4c74a167840a78cd53f6394d23ad8 Mon Sep 17 00:00:00 2001 From: Hugo Santos Date: Sat, 3 Nov 2007 11:36:02 +0000 Subject: [PATCH] r10168@haiku-devel: hugo | 2007-11-03 12:35:29 +0100 find_route() is not really IPv4 specific. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22809 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/network/stack/routes.cpp | 32 +++++++++------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/add-ons/kernel/network/stack/routes.cpp b/src/add-ons/kernel/network/stack/routes.cpp index 657469fad5..c241bac120 100644 --- a/src/add-ons/kernel/network/stack/routes.cpp +++ b/src/add-ons/kernel/network/stack/routes.cpp @@ -149,13 +149,9 @@ find_route(struct net_domain *_domain, const net_route *description) static net_route_private * -find_route(struct net_domain *_domain, const struct sockaddr *address) +find_route(net_domain *_domain, const sockaddr *address) { - struct net_domain_private *domain = (net_domain_private *)_domain; - - // TODO: the following only works for IPv4 routes! - if (domain->family != AF_INET) - panic("you should have known better..."); + net_domain_private *domain = (net_domain_private *)_domain; // find last matching route @@ -165,23 +161,21 @@ find_route(struct net_domain *_domain, const struct sockaddr *address) while (iterator.HasNext()) { net_route_private *route = iterator.Next(); - bool found; - if (route->mask != NULL) { + if (route->mask) { sockaddr maskedAddress; domain->address_module->mask_address(address, route->mask, &maskedAddress); - found = domain->address_module->equal_addresses(&maskedAddress, - route->destination); - } else { - found = domain->address_module->equal_addresses(address, - route->destination); - } + if (!domain->address_module->equal_addresses(&maskedAddress, + route->destination)) + continue; + } else if (!domain->address_module->equal_addresses(address, + route->destination)) + continue - if (found) { - TRACE((" found route: %s, flags %lx\n", - AddressString(domain, route->destination).Data(), route->flags)); - return route; - } + TRACE((" found route: %s, flags %lx\n", + AddressString(domain, route->destination).Data(), route->flags)); + + return route; } return NULL;