Hi Ivan,
Thanks for your input. Your suggestion of keeping the route selection separate seems doable. I could have my routing functions in a separate static_route_table.c/h file and enable the LWIP_HOOK_IPV6_ROUTE macro with the route lookup function.
However, regarding the next-hop selection based on the gateway, I had added the following snippet in the nd6_get_next_hop_entry(..) for populating the next_hop within the destination cache's nd6_cached_destination_index entry. After the destination cache's nexthop entry is populated, the neighbor cache entry is also populated accordingly. All this happens inside this function in nd6.c.
However, if I have to do this prior to nd6_get_nest_hop_entry(..) in ethip6_output(), could you suggest how the destination cache's cached index entries could be populated appropriately?
The modification that I made in nd6_get_next_hop_entry(..) in nd6.c is something like this:-
}
else {
#if LWIP_IPV6_ROUTER_SUPPORT
/* We need to select a router. */
i = nd6_select_router(ip6addr, netif);
if (i < 0) {
/* No router found. */
ip6_addr_set_any(&(destination_cache[nd6_cached_destination_index].destination_addr));
return ERR_RTE;
}
destination_cache[nd6_cached_destination_index].pmtu = netif->mtu; /* Start with netif mtu, correct through ICMPv6 if necessary */
ip6_addr_copy(destination_cache[nd6_cached_destination_index].next_hop_addr, default_router_list[i].neighbor_entry->next_hop_address);
+#if LWIP_IPV6_STATIC_ROUTES_SUPPORT
+ /* See if a static route is configured for the destination address */
+ i = ip6_find_route_entry(ip6addr);
+ if (i >= 0) {
+ if (static_route_table[i].gateway != NULL) {
+ ip6_addr_copy(destination_cache[nd6_cached_destination_index].next_hop_addr, *static_route_table[i].gateway);
+ }
+ }
+#endif
#else
ip6_addr_set_any(&(destination_cache[nd6_cached_destination_index].destination_addr));
return ERR_RTE;
#endif /* LWIP_IPV6_ROUTER_SUPPORT */
Thanks,
Pradip