if_attach now puts interfaces on the end of the q
[unix-history] / usr / src / sys / net / if.c
index 6b1ccaa..7b7df75 100644 (file)
@@ -1,11 +1,41 @@
-/*     if.c    4.2     81/11/20        */
+/*     if.c    4.8     82/02/03        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
-#include "../net/inet.h"
-#include "../net/inet_systm.h"
+#include "../net/in.h"
+#include "../net/in_systm.h"
 #include "../net/if.h"
 
 #include "../net/if.h"
 
+ifinit()
+{
+       register struct ifnet *ifp;
+
+       for (ifp = ifnet; ifp; ifp = ifp->if_next)
+               if (ifp->if_init)
+                       (*ifp->if_init)();
+}
+
+ifubareset(uban)
+       int uban;
+{
+       register struct ifnet *ifp;
+
+       for (ifp = ifnet; ifp; ifp = ifp->if_next)
+               if (ifp->if_ubareset)
+                       (*ifp->if_ubareset)(uban);
+}
+
+if_attach(ifp)
+       struct ifnet *ifp;
+{
+       register struct ifnet **p = &ifnet;
+
+COUNT(IF_ATTACH);
+       while (*p)
+               p = &((*p)->if_next);
+       *p = ifp;
+}
+
 /*ARGSUSED*/
 struct ifnet *
 if_ifwithaddr(in)
 /*ARGSUSED*/
 struct ifnet *
 if_ifwithaddr(in)
@@ -14,13 +44,9 @@ if_ifwithaddr(in)
        register struct ifnet *ifp;
 
 COUNT(IF_IFWITHADDR);
        register struct ifnet *ifp;
 
 COUNT(IF_IFWITHADDR);
-#if 0
        for (ifp = ifnet; ifp; ifp = ifp->if_next)
                if (ifp->if_addr.s_addr == in.s_addr)
                        break;
        for (ifp = ifnet; ifp; ifp = ifp->if_next)
                if (ifp->if_addr.s_addr == in.s_addr)
                        break;
-#else
-       ifp = ifnet;
-#endif
        return (ifp);
 }
 
        return (ifp);
 }
 
@@ -30,19 +56,40 @@ if_ifonnetof(in)
        struct in_addr in;
 {
        register struct ifnet *ifp;
        struct in_addr in;
 {
        register struct ifnet *ifp;
-#if 0
        int net;
 
 COUNT(IF_IFONNETOF);
        int net;
 
 COUNT(IF_IFONNETOF);
-       net = 0;                        /* XXX */
+       net = in.s_net;                 /* XXX */
        for (ifp = ifnet; ifp; ifp = ifp->if_next)
                if (ifp->if_net == net)
                        break;
        for (ifp = ifnet; ifp; ifp = ifp->if_next)
                if (ifp->if_net == net)
                        break;
-#else
-       ifp = ifnet;
-#endif
        return (ifp);
 }
 
        return (ifp);
 }
 
-struct ifnet ifen;
-struct ifnet *ifnet = &ifen;
+/*ARGSUSED*/
+struct ifnet *
+if_gatewayfor(addr)
+       struct in_addr addr;
+{
+
+COUNT(IF_GATEWAYFOR);
+       return (0);
+}
+
+struct in_addr
+if_makeaddr(net, host)
+       int net, host;
+{
+       u_long addr;
+
+       if (net < 128)
+               addr = (net << 24) | host;
+       else if (net < 65536)
+               addr = (net << 16) | host;
+       else
+               addr = (net << 8) | host;
+#ifdef vax
+       addr = htonl(addr);
+#endif
+       return (*(struct in_addr *)&addr);
+}