Lines Matching refs:route
128 struct net_nbr *net_route_get_nbr(struct net_route_entry *route) in net_route_get_nbr() argument
133 NET_ASSERT(route); in net_route_get_nbr()
144 if (nbr->data == (uint8_t *)route) { in net_route_get_nbr()
250 #define net_route_info(str, route, dst) \ argument
253 struct in6_addr *naddr = net_route_get_nexthop(route); \
260 route->iface); \
264 static inline void update_route_access(struct net_route_entry *route) in update_route_access() argument
266 sys_slist_find_and_remove(&routes, &route->node); in update_route_access()
267 sys_slist_prepend(&routes, &route->node); in update_route_access()
273 struct net_route_entry *route, *found = NULL; in net_route_lookup() local
290 route = net_route_data(nbr); in net_route_lookup()
292 if (route->prefix_len >= longest_match && in net_route_lookup()
294 route->addr.s6_addr, in net_route_lookup()
295 route->prefix_len)) { in net_route_lookup()
296 found = route; in net_route_lookup()
297 longest_match = route->prefix_len; in net_route_lookup()
334 struct net_route_entry *route = NULL; in net_route_add() local
364 route = net_route_lookup(iface, addr); in net_route_add()
365 if (route) { in net_route_add()
369 nexthop_addr = net_route_get_nexthop(route); in net_route_add()
371 NET_DBG("No changes, return old route %p", route); in net_route_add()
374 net_route_update_lifetime(route, lifetime); in net_route_add()
376 route->preference = preference; in net_route_add()
381 if (route_preference_is_lower(route->preference, preference)) { in net_route_add()
383 route = NULL; in net_route_add()
390 net_route_del(route); in net_route_add()
400 route = CONTAINER_OF(last, in net_route_add()
408 in6_addr_tmp = net_route_get_nexthop(route); in net_route_add()
415 net_sprint_ipv6_addr(&route->addr), in net_route_add()
422 net_route_del(route); in net_route_add()
427 route = NULL; in net_route_add()
435 route = NULL; in net_route_add()
441 route = net_route_data(nbr); in net_route_add()
442 route->iface = iface; in net_route_add()
443 route->preference = preference; in net_route_add()
445 net_route_update_lifetime(route, lifetime); in net_route_add()
447 sys_slist_prepend(&routes, &route->node); in net_route_add()
455 sys_slist_init(&route->nexthop); in net_route_add()
456 sys_slist_prepend(&route->nexthop, &nexthop_route->node); in net_route_add()
458 net_route_info("Added", route, addr); in net_route_add()
474 return route; in net_route_add()
477 static void route_expired(struct net_route_entry *route) in route_expired() argument
480 net_sprint_ipv6_addr(&route->addr)); in route_expired()
483 &route->lifetime.node); in route_expired()
485 net_route_del(route); in route_expired()
521 void net_route_update_lifetime(struct net_route_entry *route, uint32_t lifetime) in net_route_update_lifetime() argument
524 net_sprint_ipv6_addr(&route->addr), in net_route_update_lifetime()
527 if (!route) { in net_route_update_lifetime()
534 route->is_infinite = true; in net_route_update_lifetime()
537 &route->lifetime.node); in net_route_update_lifetime()
539 route->is_infinite = false; in net_route_update_lifetime()
541 net_timeout_set(&route->lifetime, lifetime, k_uptime_get_32()); in net_route_update_lifetime()
544 &route->lifetime.node); in net_route_update_lifetime()
546 &route->lifetime.node); in net_route_update_lifetime()
553 int net_route_del(struct net_route_entry *route) in net_route_del() argument
561 if (!route) { in net_route_del()
568 net_ipaddr_copy(&info.addr, &route->addr); in net_route_del()
569 info.prefix_len = route->prefix_len; in net_route_del()
571 net_route_get_nexthop(route)); in net_route_del()
574 route->iface, (void *) &info, in net_route_del()
577 net_mgmt_event_notify(NET_EVENT_IPV6_ROUTE_DEL, route->iface); in net_route_del()
580 if (!route->is_infinite) { in net_route_del()
582 &route->lifetime.node); in net_route_del()
589 sys_slist_find_and_remove(&routes, &route->node); in net_route_del()
591 nbr = net_route_get_nbr(route); in net_route_del()
597 net_route_info("Deleted", route, &route->addr); in net_route_del()
599 SYS_SLIST_FOR_EACH_CONTAINER(&route->nexthop, nexthop_route, node) { in net_route_del()
630 struct net_route_entry *route = net_route_data(nbr); in net_route_del_by_nexthop() local
632 if (!route) { in net_route_del_by_nexthop()
636 SYS_SLIST_FOR_EACH_CONTAINER(&route->nexthop, nexthop_route, in net_route_del_by_nexthop()
640 ret = net_route_del(route); in net_route_del_by_nexthop()
662 struct in6_addr *net_route_get_nexthop(struct net_route_entry *route) in net_route_get_nexthop() argument
667 if (!route) { in net_route_get_nexthop()
673 SYS_SLIST_FOR_EACH_CONTAINER(&route->nexthop, nexthop_route, node) { in net_route_get_nexthop()
699 struct net_route_entry *route; in net_route_foreach() local
711 route = net_route_data(nbr); in net_route_foreach()
712 if (!route) { in net_route_foreach()
716 cb(route, user_data); in net_route_foreach()
801 static void propagate_mld_event(struct net_route_entry_mcast *route, bool route_added) in propagate_mld_event() argument
806 if (route->prefix_len == 128) { in propagate_mld_event()
807 mld_event.addr = &route->group; in propagate_mld_event()
828 ARRAY_FOR_EACH_PTR(route_mcast_entries, route) { in net_route_mcast_forward_packet()
831 if (!route->is_used || in net_route_mcast_forward_packet()
832 !net_ipv6_is_prefix(hdr->dst, route->group.s6_addr, route->prefix_len)) { in net_route_mcast_forward_packet()
836 ARRAY_FOR_EACH(route->ifaces, i) { in net_route_mcast_forward_packet()
837 if (!route->ifaces[i] || pkt->iface == route->ifaces[i] || in net_route_mcast_forward_packet()
838 !net_if_flag_is_set(route->ifaces[i], NET_IF_FORWARD_MULTICASTS)) { in net_route_mcast_forward_packet()
851 net_pkt_set_iface(pkt_cpy, route->ifaces[i]); in net_route_mcast_forward_packet()
871 ARRAY_FOR_EACH_PTR(route_mcast_entries, route) { in net_route_mcast_foreach()
872 if (route->is_used) { in net_route_mcast_foreach()
874 route->group.s6_addr, in net_route_mcast_foreach()
875 route->prefix_len)) { in net_route_mcast_foreach()
879 cb(route, user_data); in net_route_mcast_foreach()
902 ARRAY_FOR_EACH_PTR(route_mcast_entries, route) { in net_route_mcast_add()
903 if (!route->is_used) { in net_route_mcast_add()
904 net_ipaddr_copy(&route->group, group); in net_route_mcast_add()
906 ARRAY_FOR_EACH(route->ifaces, i) { in net_route_mcast_add()
907 route->ifaces[i] = NULL; in net_route_mcast_add()
910 route->prefix_len = prefix_len; in net_route_mcast_add()
911 route->ifaces[0] = iface; in net_route_mcast_add()
912 route->is_used = true; in net_route_mcast_add()
914 propagate_mld_event(route, true); in net_route_mcast_add()
917 return route; in net_route_mcast_add()
925 bool net_route_mcast_del(struct net_route_entry_mcast *route) in net_route_mcast_del() argument
927 if (route > &route_mcast_entries[CONFIG_NET_MAX_MCAST_ROUTES - 1] || in net_route_mcast_del()
928 route < &route_mcast_entries[0]) { in net_route_mcast_del()
932 NET_ASSERT(route->is_used, in net_route_mcast_del()
933 "Multicast route %p to %s was already removed", route, in net_route_mcast_del()
934 net_sprint_ipv6_addr(&route->group)); in net_route_mcast_del()
936 propagate_mld_event(route, false); in net_route_mcast_del()
938 route->is_used = false; in net_route_mcast_del()
946 ARRAY_FOR_EACH_PTR(route_mcast_entries, route) { in net_route_mcast_lookup()
947 if (!route->is_used) { in net_route_mcast_lookup()
952 route->group.s6_addr, in net_route_mcast_lookup()
953 route->prefix_len)) { in net_route_mcast_lookup()
954 return route; in net_route_mcast_lookup()
964 struct net_route_entry **route, in net_route_get_info() argument
975 *route = NULL; in net_route_get_info()
982 *route = net_route_lookup(iface, dst); in net_route_get_info()
983 if (*route) { in net_route_get_info()
984 *nexthop = net_route_get_nexthop(*route); in net_route_get_info()