diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-06-08 04:19:26 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-06-08 04:19:26 +0000 |
commit | ccab1f6b14c9d78e76344395812fe5a54b14effe (patch) | |
tree | a4481db74b8c9401c9af649e2b27eb254f91a4c5 /sys | |
parent | d3963a3204117ef322e98e13fee86d490e59c13c (diff) |
Move ifpromisc() from bpf.c to if.c, include cleanup.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/bpf.c | 54 | ||||
-rw-r--r-- | sys/net/if.c | 48 |
2 files changed, 43 insertions, 59 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 47ad8f3348a..5684cfab3d0 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.27 2001/05/28 19:51:06 dugsong Exp $ */ +/* $OpenBSD: bpf.c,v 1.28 2001/06/08 04:19:24 angelos Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -44,28 +44,17 @@ #include "bpfilter.h" #include <sys/param.h> -#include <sys/systm.h> #include <sys/mbuf.h> -#include <sys/time.h> #include <sys/proc.h> #include <sys/signalvar.h> -#include <sys/user.h> #include <sys/ioctl.h> -#include <sys/map.h> #include <sys/conf.h> #include <sys/vnode.h> - #include <sys/file.h> -#include <sys/tty.h> -#include <sys/uio.h> - -#include <sys/protosw.h> #include <sys/socket.h> -#include <sys/errno.h> #include <sys/kernel.h> #include <net/if.h> - #include <net/bpf.h> #include <net/bpfdesc.h> @@ -1260,44 +1249,3 @@ bpfdetach(ifp) } ifp->if_bpf = NULL; } - -/* XXX This routine belongs 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; -{ - struct ifreq ifr; - - if (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 (ifp->if_pcount++ != 0) - return (0); - ifp->if_flags |= IFF_PROMISC; - } else { - if (--ifp->if_pcount > 0) - return (0); - ifp->if_flags &= ~IFF_PROMISC; - /* - * If the device is not configured up, we should not need to - * turn off promiscuous mode (device should have turned it - * off when interface went down; and will look at IFF_PROMISC - * again next time interface comes up). - */ - if ((ifp->if_flags & IFF_UP) == 0) - return (0); - } - ifr.ifr_flags = ifp->if_flags; - return ((*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr)); -} diff --git a/sys/net/if.c b/sys/net/if.c index 71d2c36572c..c79d61482e5 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.44 2001/05/30 02:12:24 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.45 2001/06/08 04:19:25 angelos Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -69,8 +69,8 @@ #include "bridge.h" #include <sys/param.h> -#include <sys/mbuf.h> #include <sys/systm.h> +#include <sys/mbuf.h> #include <sys/proc.h> #include <sys/socket.h> #include <sys/socketvar.h> @@ -80,9 +80,6 @@ #include <net/if.h> #include <net/if_dl.h> -#include <net/if_types.h> -#include <net/radix.h> - #include <net/route.h> #ifdef INET @@ -100,7 +97,6 @@ #include <netinet/in.h> #endif #include <netinet6/in6_ifattach.h> -#include <netinet6/in6_var.h> #endif #if NBPFILTER > 0 @@ -1002,3 +998,43 @@ if_detached_watchdog(struct ifnet *ifp) { /* nothing */ } + +/* + * 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; +{ + struct ifreq ifr; + + if (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 (ifp->if_pcount++ != 0) + return (0); + ifp->if_flags |= IFF_PROMISC; + } else { + if (--ifp->if_pcount > 0) + return (0); + ifp->if_flags &= ~IFF_PROMISC; + /* + * If the device is not configured up, we should not need to + * turn off promiscuous mode (device should have turned it + * off when interface went down; and will look at IFF_PROMISC + * again next time interface comes up). + */ + if ((ifp->if_flags & IFF_UP) == 0) + return (0); + } + ifr.ifr_flags = ifp->if_flags; + return ((*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr)); +} |