minor fixes
[unix-history] / usr / src / sbin / routed / if.c
index 4ac75b2..6f49efb 100644 (file)
@@ -1,6 +1,12 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)if.c       4.2 %G%";
-#endif
+static char sccsid[] = "@(#)if.c       5.3 (Berkeley) %G%";
+#endif not lint
 
 /*
  * Routing Table Management Daemon
 
 /*
  * Routing Table Management Daemon
@@ -10,7 +16,7 @@ static char sccsid[] = "@(#)if.c      4.2 %G%";
 extern struct interface *ifnet;
 
 /*
 extern struct interface *ifnet;
 
 /*
- * Find the interface with address add.
+ * Find the interface with address addr.
  */
 struct interface *
 if_ifwithaddr(addr)
  */
 struct interface *
 if_ifwithaddr(addr)
@@ -34,6 +40,24 @@ if_ifwithaddr(addr)
        return (ifp);
 }
 
        return (ifp);
 }
 
+/*
+ * Find the point-to-point interface with destination address addr.
+ */
+struct interface *
+if_ifwithdstaddr(addr)
+       struct sockaddr *addr;
+{
+       register struct interface *ifp;
+
+       for (ifp = ifnet; ifp; ifp = ifp->int_next) {
+               if ((ifp->int_flags & IFF_POINTOPOINT) == 0)
+                       continue;
+               if (same(&ifp->int_dstaddr, addr))
+                       break;
+       }
+       return (ifp);
+}
+
 /*
  * Find the interface on the network 
  * of the specified address.
 /*
  * Find the interface on the network 
  * of the specified address.
@@ -46,7 +70,7 @@ if_ifwithnet(addr)
        register int af = addr->sa_family;
        register int (*netmatch)();
 
        register int af = addr->sa_family;
        register int (*netmatch)();
 
-       if (af >= AF_MAX)
+       if (af >= af_max)
                return (0);
        netmatch = afswitch[af].af_netmatch;
        for (ifp = ifnet; ifp; ifp = ifp->int_next) {
                return (0);
        netmatch = afswitch[af].af_netmatch;
        for (ifp = ifnet; ifp; ifp = ifp->int_next) {
@@ -73,7 +97,7 @@ if_iflookup(addr)
        register int af = addr->sa_family;
        register int (*netmatch)();
 
        register int af = addr->sa_family;
        register int (*netmatch)();
 
-       if (af >= AF_MAX)
+       if (af >= af_max)
                return (0);
        maybe = 0;
        netmatch = afswitch[af].af_netmatch;
                return (0);
        maybe = 0;
        netmatch = afswitch[af].af_netmatch;
@@ -85,6 +109,9 @@ if_iflookup(addr)
                if ((ifp->int_flags & IFF_BROADCAST) &&
                    same(&ifp->int_broadaddr, addr))
                        break;
                if ((ifp->int_flags & IFF_BROADCAST) &&
                    same(&ifp->int_broadaddr, addr))
                        break;
+               if ((ifp->int_flags & IFF_POINTOPOINT) &&
+                   same(&ifp->int_dstaddr, addr))
+                       break;
                if (maybe == 0 && (*netmatch)(addr, &ifp->int_addr))
                        maybe = ifp;
        }
                if (maybe == 0 && (*netmatch)(addr, &ifp->int_addr))
                        maybe = ifp;
        }