icmp and ctlinput working -- missing protocol specific ctlinput's
[unix-history] / usr / src / sys / net / if.c
index bf986a2..ee6ef4f 100644 (file)
@@ -1,8 +1,9 @@
-/*     if.c    4.11    82/03/28        */
+/*     if.c    4.14    82/04/24        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/socket.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/socket.h"
+#include "../h/protosw.h"
 #include "../net/in.h"
 #include "../net/in_systm.h"
 #include "../net/if.h"
 #include "../net/in.h"
 #include "../net/in_systm.h"
 #include "../net/if.h"
@@ -134,6 +135,17 @@ if_ifwithaf(af)
        return (ifp);
 }
 
        return (ifp);
 }
 
+/*
+ * Mark an interface down and notify protocols of
+ * the transition.
+ */
+if_down(ifp)
+       register struct ifnet *ifp;
+{
+       ifp->if_flags &= ~IFF_UP;
+       pfctlinput(PRC_IFDOWN, (caddr_t)&ifp->if_addr);
+}
+
 /*
  * Formulate an Internet address from network + host.  Used in
  * building addresses stored in the ifnet structure.
 /*
  * Formulate an Internet address from network + host.  Used in
  * building addresses stored in the ifnet structure.
@@ -155,3 +167,22 @@ if_makeaddr(net, host)
 #endif
        return (*(struct in_addr *)&addr);
 }
 #endif
        return (*(struct in_addr *)&addr);
 }
+
+/*
+ * Initialize an interface's routing
+ * table entry according to the network.
+ * INTERNET SPECIFIC.
+ */
+if_rtinit(ifp, flags)
+       register struct ifnet *ifp;
+       int flags;
+{
+       struct sockaddr_in sin;
+
+       if (ifp->if_flags & IFF_ROUTE)
+               return;
+       bzero((caddr_t)&sin, sizeof (sin));
+       sin.sin_family = AF_INET;
+       sin.sin_addr = if_makeaddr(ifp->if_net, 0);
+       rtinit(&sin, &ifp->if_addr, flags);
+}