monitor mode vaps are meant to be read-only so they can operate on any

frequency w/o regulatory issues, do this by hooking if_transmit and
if_output with routines that discard all transmits

Reviewed by:	thompsa, cbzimmer (intent)
Approved by:	re (kensmith)
This commit is contained in:
Sam Leffler 2009-07-24 15:27:02 +00:00
parent 224881b466
commit 983a2c892b

View file

@ -223,13 +223,20 @@ null_update_promisc(struct ifnet *ifp)
if_printf(ifp, "need promiscuous mode update callback\n");
}
static int
null_transmit(struct ifnet *ifp, struct mbuf *m)
{
m_freem(m);
ifp->if_oerrors++;
return EACCES; /* XXX EIO/EPERM? */
}
static int
null_output(struct ifnet *ifp, struct mbuf *m,
struct sockaddr *dst, struct route *ro)
{
if_printf(ifp, "discard raw packet\n");
m_freem(m);
return EIO;
return null_transmit(ifp, m);
}
static void
@ -515,9 +522,15 @@ ieee80211_vap_attach(struct ieee80211vap *vap,
ifp->if_baudrate = IF_Mbps(maxrate);
ether_ifattach(ifp, vap->iv_myaddr);
/* hook output method setup by ether_ifattach */
vap->iv_output = ifp->if_output;
ifp->if_output = ieee80211_output;
if (vap->iv_opmode == IEEE80211_M_MONITOR) {
/* NB: disallow transmit */
ifp->if_transmit = null_transmit;
ifp->if_output = null_output;
} else {
/* hook output method setup by ether_ifattach */
vap->iv_output = ifp->if_output;
ifp->if_output = ieee80211_output;
}
/* NB: if_mtu set by ether_ifattach to ETHERMTU */
IEEE80211_LOCK(ic);