summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sbin/ifconfig/ifconfig.811
-rw-r--r--sbin/ifconfig/ifconfig.c2
-rw-r--r--sys/net/if.h1
-rw-r--r--sys/net/if_ethersubr.c7
4 files changed, 21 insertions, 0 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index 39761fb..57468e9 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -504,6 +504,17 @@ for more information.
.It Fl link Op Cm 0 No - Cm 2
.Sm on
Disable special processing at the link level with the specified interface.
+.It Cm monitor
+.Sm on
+Put the interface in monitor mode.
+No packets are transmitted and received packets are discarded after
+.Xr bpf 4
+processing.
+.Sm off
+.It Fl monitor
+.Sm on
+Take the interface out of monitor mode.
+.Sm off
.It Cm up
Mark an interface
.Dq up .
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index c9ab382..35ac555 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -241,6 +241,8 @@ struct cmd {
{ "-link1", -IFF_LINK1, setifflags },
{ "link2", IFF_LINK2, setifflags },
{ "-link2", -IFF_LINK2, setifflags },
+ { "monitor", IFF_MONITOR, setifflags },
+ { "-monitor", -IFF_MONITOR, setifflags },
#ifdef USE_IF_MEDIA
{ "media", NEXTARG, setmedia },
{ "mediaopt", NEXTARG, setmediaopt },
diff --git a/sys/net/if.h b/sys/net/if.h
index a11dc39..a87dd47 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -141,6 +141,7 @@ struct if_data {
#define IFF_MULTICAST 0x8000 /* supports multicast */
#define IFF_POLLING 0x10000 /* Interface is in polling mode. */
#define IFF_PPROMISC 0x20000 /* user-requested promisc mode */
+#define IFF_MONITOR 0x40000 /* user-requested monitor mode */
/* flags set internally only: */
#define IFF_CANTCHANGE \
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index d92f405..0983724 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -162,6 +162,8 @@ ether_output(ifp, m, dst, rt0)
senderr(error);
#endif
+ if (ifp->if_flags & IFF_MONITOR)
+ senderr(ENETDOWN);
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
rt = rt0;
@@ -583,6 +585,11 @@ ether_input(struct ifnet *ifp, struct ether_header *eh, struct mbuf *m)
bpf_mtap(ifp, (struct mbuf *)&mh);
}
+ if (ifp->if_flags & IFF_MONITOR) {
+ m_freem(m);
+ return;
+ }
+
#ifdef MAC
mac_create_mbuf_from_ifnet(ifp, m);
#endif
OpenPOWER on IntegriCloud