* Made some functions static that should have been.
* Added a commented out dump_routes() function for debugging purposes. * Removed weird spaces, fixed indentation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22722 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -53,6 +53,26 @@ net_route_private::~net_route_private()
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static void
|
||||||
|
dump_routes(net_domain_private *domain)
|
||||||
|
{
|
||||||
|
RouteList::Iterator iterator = domain->routes.GetIterator();
|
||||||
|
uint32 count = 1;
|
||||||
|
|
||||||
|
while (iterator.HasNext()) {
|
||||||
|
net_route_private *route = iterator.Next();
|
||||||
|
|
||||||
|
dprintf(" [%lu] dest %s, mask %s, gw %s, flags %lx\n", count++,
|
||||||
|
AddressString(domain, route->destination ? route->destination : NULL).Data(),
|
||||||
|
AddressString(domain, route->mask ? route->mask : NULL).Data(),
|
||||||
|
AddressString(domain, route->gateway ? route->gateway : NULL).Data(),
|
||||||
|
route->flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
user_copy_address(const sockaddr *from, sockaddr **to)
|
user_copy_address(const sockaddr *from, sockaddr **to)
|
||||||
{
|
{
|
||||||
@@ -146,7 +166,7 @@ find_route(struct net_domain *_domain, const struct sockaddr *address)
|
|||||||
net_route_private *route = iterator.Next();
|
net_route_private *route = iterator.Next();
|
||||||
|
|
||||||
bool found;
|
bool found;
|
||||||
if (route->mask != NULL) {
|
if (route->mask != NULL) {
|
||||||
sockaddr maskedAddress;
|
sockaddr maskedAddress;
|
||||||
domain->address_module->mask_address(address, route->mask,
|
domain->address_module->mask_address(address, route->mask,
|
||||||
&maskedAddress);
|
&maskedAddress);
|
||||||
@@ -155,7 +175,7 @@ find_route(struct net_domain *_domain, const struct sockaddr *address)
|
|||||||
} else {
|
} else {
|
||||||
found = domain->address_module->equal_addresses(address,
|
found = domain->address_module->equal_addresses(address,
|
||||||
route->destination);
|
route->destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
TRACE((" found route: %s, flags %lx\n",
|
TRACE((" found route: %s, flags %lx\n",
|
||||||
@@ -182,8 +202,9 @@ put_route_internal(struct net_domain_private *domain, net_route *_route)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct net_route *
|
static struct net_route *
|
||||||
get_route_internal(struct net_domain_private *domain, const struct sockaddr *address)
|
get_route_internal(struct net_domain_private *domain,
|
||||||
|
const struct sockaddr *address)
|
||||||
{
|
{
|
||||||
net_route_private *route = find_route(domain, address);
|
net_route_private *route = find_route(domain, address);
|
||||||
if (route != NULL && atomic_add(&route->ref_count, 1) == 0) {
|
if (route != NULL && atomic_add(&route->ref_count, 1) == 0) {
|
||||||
@@ -195,7 +216,7 @@ get_route_internal(struct net_domain_private *domain, const struct sockaddr *add
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
update_route_infos(struct net_domain_private *domain)
|
update_route_infos(struct net_domain_private *domain)
|
||||||
{
|
{
|
||||||
RouteInfoList::Iterator iterator = domain->route_infos.GetIterator();
|
RouteInfoList::Iterator iterator = domain->route_infos.GetIterator();
|
||||||
@@ -372,10 +393,10 @@ add_route(struct net_domain *_domain, const struct net_route *newRoute)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
if (domain->address_module->copy_address(newRoute->destination,
|
if (domain->address_module->copy_address(newRoute->destination,
|
||||||
&route->destination, (newRoute->flags & RTF_DEFAULT) != 0,
|
&route->destination, (newRoute->flags & RTF_DEFAULT) != 0,
|
||||||
newRoute->mask) != B_OK
|
newRoute->mask) != B_OK
|
||||||
|| domain->address_module->copy_address(newRoute->mask, &route->mask,
|
|| domain->address_module->copy_address(newRoute->mask, &route->mask,
|
||||||
(newRoute->flags & RTF_DEFAULT) != 0, NULL) != B_OK
|
(newRoute->flags & RTF_DEFAULT) != 0, NULL) != B_OK
|
||||||
|| domain->address_module->copy_address(newRoute->gateway,
|
|| domain->address_module->copy_address(newRoute->gateway,
|
||||||
&route->gateway, false, NULL) != B_OK) {
|
&route->gateway, false, NULL) != B_OK) {
|
||||||
delete route;
|
delete route;
|
||||||
@@ -399,7 +420,7 @@ add_route(struct net_domain *_domain, const struct net_route *newRoute)
|
|||||||
// if the before mask is less specific than the one of the route,
|
// if the before mask is less specific than the one of the route,
|
||||||
// we can insert it before that route.
|
// we can insert it before that route.
|
||||||
if (domain->address_module->first_mask_bit(before->mask)
|
if (domain->address_module->first_mask_bit(before->mask)
|
||||||
> domain->address_module->first_mask_bit(route->mask))
|
> domain->address_module->first_mask_bit(route->mask))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,6 +452,7 @@ remove_route(struct net_domain *_domain, const struct net_route *removeRoute)
|
|||||||
|
|
||||||
put_route_internal(domain, route);
|
put_route_internal(domain, route);
|
||||||
update_route_infos(domain);
|
update_route_infos(domain);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user