Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Jul 2009 15:27:02 +0000 (UTC)
From:      Sam Leffler <sam@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r195846 - head/sys/net80211
Message-ID:  <200907241527.n6OFR2oT013832@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sam
Date: Fri Jul 24 15:27:02 2009
New Revision: 195846
URL: http://svn.freebsd.org/changeset/base/195846

Log:
  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)

Modified:
  head/sys/net80211/ieee80211.c

Modified: head/sys/net80211/ieee80211.c
==============================================================================
--- head/sys/net80211/ieee80211.c	Fri Jul 24 15:22:12 2009	(r195845)
+++ head/sys/net80211/ieee80211.c	Fri Jul 24 15:27:02 2009	(r195846)
@@ -224,12 +224,19 @@ null_update_promisc(struct ifnet *ifp)
 }
 
 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
 		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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907241527.n6OFR2oT013832>