+
+ /*
+ * Check whether network is a subnet of a `local' network;
+ * if so, return subnet number.
+ */
+ for (ifp = ifnet; ifp; ifp = ifp->if_next) {
+ if (ifp->if_addr.sa_family != AF_INET)
+ continue;
+ if (ifp->if_flags & IFF_LOCAL) {
+ if (ifp->if_net == net)
+ return (subnet);
+ if ((ifp->if_net >> SUBNETSHIFT) == net)
+ return (subnet);
+ /*
+ * Hack for use in setting if_net initially.
+ */
+ if (ifp->if_net == 0) {
+ register struct sockaddr_in *sin;
+ sin = (struct sockaddr_in *) &ifp->if_addr;
+ if (sin->sin_addr.s_addr == in.s_addr)
+ return (subnet);
+ }
+ }
+ }
+ return (net);