-struct ifnet ifen = { 0, 0, 1024, 0, 0 };
-struct ifnet *ifnet = &ifen;
+/*
+ * Find an interface using a specific address family
+ */
+struct ifnet *
+if_ifwithaf(af)
+ register int af;
+{
+ register struct ifnet *ifp;
+
+ for (ifp = ifnet; ifp; ifp = ifp->if_next)
+ if (ifp->if_addr.sa_family == af)
+ break;
+ 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.
+ */
+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);
+}
+
+/*
+ * 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);
+}