+
+#include "route.h"
+/*
+ * Default action when installing a route with a Link Level gateway.
+ * Lookup an appropriate real ifa to point to.
+ * This should be moved to /sys/net/link.c eventually.
+ */
+link_rtrequest(cmd, rt, sa)
+register struct rtentry *rt;
+struct sockaddr *sa;
+{
+ register struct ifaddr *ifa;
+ struct sockaddr *dst;
+ struct ifnet *ifp, *oldifnet = ifnet;
+
+ if (cmd != RTM_ADD || ((ifa = rt->rt_ifa) == 0) ||
+ ((ifp = ifa->ifa_ifp) == 0) || ((dst = rt_key(rt)) == 0))
+ return;
+ ifnet = ifp;
+ if (((ifa = ifa_ifwithnet(dst)) && ifa->ifa_ifp == ifp) ||
+ ((ifa = ifa_ifwithaf(dst->sa_family)) && ifa->ifa_ifp == ifp)) {
+ ifnet = oldifnet;
+ rt->rt_ifa = ifa;
+ if (ifa->ifa_rtrequest && ifa->ifa_rtrequest != link_rtrequest)
+ ifa->ifa_rtrequest(cmd, rt, sa);
+ } else
+ ifnet = oldifnet;
+}