Packet* LL::sendto(Packet* p, Handler* h) { int nh = (lanrouter_) ? lanrouter_-\>next_hop(p) : -1; . . . }LanRouter is able to find the next hop by querying the current RouteLogic:
int LanRouter::next_hop(Packet *p) { int next_hopIP; if (enableHrouting_) { routelogic_-\>lookup_hier(lanaddr_, adst, next_hopIP); } else { routelogic_-\>lookup_flat(lanaddr_, adst, next_hopIP); }One limitation of this is that RouteLogic may not be aware of dynamic changes to the routing. But it is always possible to derive a new class from LanRouter so that to re-define its next_hop method to handle dynamic changes appopriately.