date and time created 82/02/01 12:59:36 by root
[unix-history] / usr / src / sys / net / if.c
index 68576c0..e0b3422 100644 (file)
@@ -1,42 +1,91 @@
-/*     if.c    4.1     81/11/18        */
+/*     if.c    4.6     81/12/07        */
 
 #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;
+{
+
+COUNT(IF_ATTACH);
+       ifp->if_next = ifnet;
+       ifnet = ifp;
+}
+
+/*ARGSUSED*/
+struct ifnet *
 if_ifwithaddr(in)
        struct in_addr in;
 {
        register struct ifnet *ifp;
 
 if_ifwithaddr(in)
        struct in_addr in;
 {
        register struct ifnet *ifp;
 
-#if 0
+COUNT(IF_IFWITHADDR);
        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);
 }
 
+/*ARGSUSED*/
+struct ifnet *
 if_ifonnetof(in)
        struct in_addr in;
 {
        register struct ifnet *ifp;
 if_ifonnetof(in)
        struct in_addr in;
 {
        register struct ifnet *ifp;
-#if 0
        int net;
 
        int net;
 
-       net = 0;                        /* XXX */
+COUNT(IF_IFONNETOF);
+       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 = { 0, 0, 1024, 0, 0 };
-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;
+       addr = htonl(addr);
+       return (*(struct in_addr *)&addr);
+}