Lines Matching defs:route

25 #include <net/route.h>
110 net_route_private* route = iterator.Next();
112 if ((route->flags & RTF_DEFAULT) != 0
114 // there can only be one default route per interface address family
116 if (route->interface_address == description->interface_address)
117 return route;
122 if ((route->flags & (RTF_GATEWAY | RTF_HOST | RTF_LOCAL | RTF_DEFAULT))
126 route->destination, description->destination, description->mask)
127 && domain->address_module->equal_addresses(route->mask,
129 && domain->address_module->equal_addresses(route->gateway,
132 || description->interface_address == route->interface_address))
133 return route;
145 // find last matching route
156 net_route_private* route = iterator.Next();
158 if (route->mask) {
160 domain->address_module->mask_address(address, route->mask,
163 route->destination))
166 route->destination))
170 if ((route->interface_address->interface->device->flags & IFF_LINK)
174 domain, route->destination).Data(), route->flags);
175 candidate = route;
180 TRACE(" found route: %s, flags %lx\n",
181 AddressString(domain, route->destination).Data(), route->flags);
183 return route;
195 net_route_private* route = (net_route_private*)_route;
196 if (route == NULL || atomic_add(&route->ref_count, -1) != 1)
199 // delete route - it must already have been removed at this point
200 if (route->interface_address != NULL)
201 ((InterfaceAddress*)route->interface_address)->ReleaseReference();
203 delete route;
212 net_route_private* route = NULL;
220 route = iterator.Next();
222 net_device* device = route->interface_address->interface->device;
233 route = find_route(domain, address);
235 if (route != NULL && atomic_add(&route->ref_count, 1) == 0) {
236 // route has been deleted already
237 route = NULL;
240 return route;
253 put_route_internal(domain, info->route);
254 info->route = get_route_internal(domain, &info->address);
271 net_route* route)
276 target->destination = copy_address(buffer, route->destination);
277 target->mask = copy_address(buffer, route->mask);
278 target->gateway = copy_address(buffer, route->gateway);
279 target->source = copy_address(buffer, route->interface_address->local);
280 target->flags = route->flags;
281 target->mtu = route->mtu;
301 net_route_private* route = iterator.Next();
304 if (route->destination)
305 size += route->destination->sa_len;
306 if (route->mask)
307 size += route->mask->sa_len;
308 if (route->gateway)
309 size += route->gateway->sa_len;
335 net_route* route = iterator.Next();
344 if (route->destination != NULL) {
346 next += route->destination->sa_len;
347 size += route->destination->sa_len;
349 if (route->mask != NULL) {
351 next += route->mask->sa_len;
352 size += route->mask->sa_len;
354 if (route->gateway != NULL) {
356 next += route->gateway->sa_len;
357 size += route->gateway->sa_len;
366 strlcpy(request.ifr_name, route->interface_address->interface->name,
371 request.ifr_route.mtu = route->mtu;
372 request.ifr_route.flags = route->flags;
376 || (route->destination != NULL
378 route->destination, route->destination->sa_len) < B_OK)
379 || (route->mask != NULL && user_memcpy(request.ifr_route.mask,
380 route->mask, route->mask->sa_len) < B_OK)
381 || (route->gateway != NULL && user_memcpy(request.ifr_route.gateway,
382 route->gateway, route->gateway->sa_len) < B_OK))
405 // add or remove a route
414 net_route_private route;
417 &route.destination)) != B_OK
418 || (status = user_copy_address(entry.mask, &route.mask)) != B_OK
419 || (status = user_copy_address(entry.gateway, &route.gateway))
426 route.mtu = entry.mtu;
427 route.flags = entry.flags;
428 route.interface_address = address;
431 status = add_route(domain, &route);
433 status = remove_route(domain, &route);
449 TRACE("add route to domain %s: dest %s, mask %s, gw %s, flags %lx\n",
469 net_route_private* route = find_route(domain, newRoute);
470 if (route != NULL)
473 route = new (std::nothrow) net_route_private;
474 if (route == NULL)
478 &route->destination, (newRoute->flags & RTF_DEFAULT) != 0,
480 || domain->address_module->copy_address(newRoute->mask, &route->mask,
483 &route->gateway, false, NULL) != B_OK) {
484 delete route;
488 route->flags = newRoute->flags;
489 route->interface_address = newRoute->interface_address;
490 ((InterfaceAddress*)route->interface_address)->AcquireReference();
491 route->mtu = 0;
492 route->ref_count = 1;
494 // Insert the route sorted by completeness of its mask
500 // if the before mask is less specific than the one of the route,
501 // we can insert it before that route.
503 > domain->address_module->first_mask_bit(route->mask))
506 if ((route->flags & RTF_DEFAULT) != 0
511 < route->interface_address->interface->device->link_speed)
516 domain->routes.InsertBefore(before, route);
528 TRACE("remove route from domain %s: dest %s, mask %s, gw %s, flags %lx\n",
540 net_route_private* route = find_route(domain, removeRoute);
541 if (route == NULL)
544 domain->routes.Remove(route);
546 put_route_internal(domain, route);
572 net_route_private* route = find_route(domain, (sockaddr*)&destination);
573 if (route == NULL)
576 status = fill_route_entry(&entry, value, length, route);
594 net_route* route = iterator.Next();
596 if (route->interface_address->interface == interface)
597 remove_route(domain, route);
614 net_route* route = iterator.Next();
616 if (route->interface_address == address)
617 remove_route(domain, route);
639 net_route_private* route
642 atomic_add(&route->ref_count, 1);
643 *_route = route;
657 net_route* route = get_route_internal(domain, buffer->destination);
658 if (route == NULL)
667 if (route->interface_address != NULL
668 && route->interface_address->local != NULL) {
670 route->interface_address->local);
674 put_route_internal(domain, route);
676 *_route = route;
683 put_route(struct net_domain* _domain, net_route* route)
686 if (domain == NULL || route == NULL)
691 put_route_internal(domain, (net_route*)route);
702 info->route = get_route_internal(domain, &info->address);
715 if (info->route != NULL)
716 put_route_internal(domain, info->route);
728 put_route_internal(domain, info->route);
729 info->route = get_route_internal(domain, &info->address);