mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-10 14:02:43 +00:00
Add the "Monitor" interface flag.
Setting this flag on an ethernet interface blocks transmission of packets and discards incoming packets after BPF processing. This is useful if you want to monitor network trafic but not interact with the network in question. Sponsored by: http://www.babeltech.dk
This commit is contained in:
parent
ca916247cd
commit
afbe3a0f81
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=104044
@ -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 .
|
||||
|
@ -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 },
|
||||
|
@ -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 \
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user