+/* XXX This routine goes in net/if.c. */
+/*
+ * Set/clear promiscuous mode on interface ifp based on the truth value`
+ * of pswitch. The calls are reference counted so that only the first
+ * on request actually has an effect, as does the final off request.
+ * Results are undefined if the off and on requests are not matched.
+ */
+int
+ifpromisc(ifp, pswitch)
+ struct ifnet *ifp;
+ int pswitch;
+{
+ /*
+ * If the device is not configured up, we cannot put it in
+ * promiscuous mode.
+ */
+ if ((ifp->if_flags & IFF_UP) == 0)
+ return (ENETDOWN);
+
+ if (pswitch) {
+ if (ifp->if_pcount++ != 0)
+ return (0);
+ ifp->if_flags |= IFF_PROMISC;
+ } else {
+ if (--ifp->if_pcount > 0)
+ return (0);
+ ifp->if_flags &= ~IFF_PROMISC;
+ }
+ return ((*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)0));
+}
+