Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Jun 2012 02:08:04 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r237214 - head/sys/net80211
Message-ID:  <201206180208.q5I284Gq047328@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Mon Jun 18 02:08:04 2012
New Revision: 237214
URL: http://svn.freebsd.org/changeset/base/237214

Log:
  Extend the radiotap code to be aware of the size of any extra vendor
  bitmaps that may occur.
  
  The way this works is:
  
  * the beginning of the radiotap frame has a 32 bit "radiotap" namespace
    bitmap;
  * if the vendor bitmap bit is set, then the next bitmap will be interpreted
    as a vendor bitmap;
  * this can keep going on and on (ie, more vendor and radiotap namespace
    bitmaps can be added) until the last bitmap with no "more bitmaps" set.
  
  Now, the radiotap code gets its grubby fingers into the supplied
  radiotap rx/tx buffer and replaces the channel configuration
  for each frame.  I don't know why it's not up to the drivers themselves
  to do this, but I digress.  So, if a vendor bitmap (or two, etc) exists,
  the offset calculations will be all completely wrong.
  
  This particular patch introduces ieee80211_radiotap_attachv(), which
  includes the number of vendor bitmaps (well, any other bitmaps, vendor
  or otherwise) between the end of the bitmap/header and the start of the
  actual radiotap field entries.  This makes the radiotap calculations
  "right", so it correctly calculates where to overwrite the channel
  configuration.
  
  The long term fix is to go through and make each driver update the channel
  configuration, as some of the fields are already being updated.
  
  That, however, is a longer term fix that will need each driver fixed.
  
  I leave that as an exercise to someone in the future.

Modified:
  head/sys/net80211/ieee80211_radiotap.c
  head/sys/net80211/ieee80211_var.h

Modified: head/sys/net80211/ieee80211_radiotap.c
==============================================================================
--- head/sys/net80211/ieee80211_radiotap.c	Sun Jun 17 21:48:40 2012	(r237213)
+++ head/sys/net80211/ieee80211_radiotap.c	Mon Jun 18 02:08:04 2012	(r237214)
@@ -47,13 +47,24 @@ __FBSDID("$FreeBSD$");
 
 #include <net80211/ieee80211_var.h>
 
-static int radiotap_offset(struct ieee80211_radiotap_header *, int);
+static int radiotap_offset(struct ieee80211_radiotap_header *, int, int);
 
 void
 ieee80211_radiotap_attach(struct ieee80211com *ic,
 	struct ieee80211_radiotap_header *th, int tlen, uint32_t tx_radiotap,
 	struct ieee80211_radiotap_header *rh, int rlen, uint32_t rx_radiotap)
 {
+	ieee80211_radiotap_attachv(ic, th, tlen, 0, tx_radiotap,
+	    rh, rlen, 0, rx_radiotap);
+}
+
+void
+ieee80211_radiotap_attachv(struct ieee80211com *ic,
+	struct ieee80211_radiotap_header *th,
+	int tlen, int n_tx_v, uint32_t tx_radiotap,
+	struct ieee80211_radiotap_header *rh,
+	int rlen, int n_rx_v, uint32_t rx_radiotap)
+{
 #define	B(_v)	(1<<(_v))
 	int off;
 
@@ -63,9 +74,9 @@ ieee80211_radiotap_attach(struct ieee802
 	/* calculate offset to channel data */
 	off = -1;
 	if (tx_radiotap & B(IEEE80211_RADIOTAP_CHANNEL))
-		off = radiotap_offset(th, IEEE80211_RADIOTAP_CHANNEL);
+		off = radiotap_offset(th, n_tx_v, IEEE80211_RADIOTAP_CHANNEL);
 	else if (tx_radiotap & B(IEEE80211_RADIOTAP_XCHANNEL))
-		off = radiotap_offset(th, IEEE80211_RADIOTAP_XCHANNEL);
+		off = radiotap_offset(th, n_tx_v, IEEE80211_RADIOTAP_XCHANNEL);
 	if (off == -1) {
 		if_printf(ic->ic_ifp, "%s: no tx channel, radiotap 0x%x\n",
 		    __func__, tx_radiotap);
@@ -79,9 +90,9 @@ ieee80211_radiotap_attach(struct ieee802
 	/* calculate offset to channel data */
 	off = -1;
 	if (rx_radiotap & B(IEEE80211_RADIOTAP_CHANNEL))
-		off = radiotap_offset(rh, IEEE80211_RADIOTAP_CHANNEL);
+		off = radiotap_offset(rh, n_rx_v, IEEE80211_RADIOTAP_CHANNEL);
 	else if (rx_radiotap & B(IEEE80211_RADIOTAP_XCHANNEL))
-		off = radiotap_offset(rh, IEEE80211_RADIOTAP_XCHANNEL);
+		off = radiotap_offset(rh, n_rx_v, IEEE80211_RADIOTAP_XCHANNEL);
 	if (off == -1) {
 		if_printf(ic->ic_ifp, "%s: no rx channel, radiotap 0x%x\n",
 		    __func__, rx_radiotap);
@@ -260,7 +271,8 @@ ieee80211_radiotap_rx_all(struct ieee802
  * known -1 is returned.
  */
 static int
-radiotap_offset(struct ieee80211_radiotap_header *rh, int item)
+radiotap_offset(struct ieee80211_radiotap_header *rh,
+    int n_vendor_attributes, int item)
 {
 	static const struct {
 		size_t	align, width;
@@ -334,6 +346,8 @@ radiotap_offset(struct ieee80211_radiota
 	int off, i;
 
 	off = sizeof(struct ieee80211_radiotap_header);
+	off += n_vendor_attributes * (sizeof(uint32_t));
+
 	for (i = 0; i < IEEE80211_RADIOTAP_EXT; i++) {
 		if ((present & (1<<i)) == 0)
 			continue;

Modified: head/sys/net80211/ieee80211_var.h
==============================================================================
--- head/sys/net80211/ieee80211_var.h	Sun Jun 17 21:48:40 2012	(r237213)
+++ head/sys/net80211/ieee80211_var.h	Mon Jun 18 02:08:04 2012	(r237214)
@@ -705,6 +705,11 @@ void	ieee80211_radiotap_attach(struct ie
 		uint32_t tx_radiotap,
 	    struct ieee80211_radiotap_header *rh, int rlen,
 		uint32_t rx_radiotap);
+void	ieee80211_radiotap_attachv(struct ieee80211com *,
+	    struct ieee80211_radiotap_header *th,
+	    int tlen, int n_tx_v, uint32_t tx_radiotap,
+	    struct ieee80211_radiotap_header *rh,
+	    int rlen, int n_rx_v, uint32_t rx_radiotap);
 void	ieee80211_radiotap_detach(struct ieee80211com *);
 void	ieee80211_radiotap_vattach(struct ieee80211vap *);
 void	ieee80211_radiotap_vdetach(struct ieee80211vap *);



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