2008-12-12 12:39:27

by Jouni Malinen

[permalink] [raw]
Subject: [PATCH 3/3] mac80211: Add HT rates into radiotap

Update the radiotap definition based on the format used in FreeBSD to
allows MCS index, HT20/HT40, and short GI information to be reported
for received frames in monitor mode. This format is also supported by
wireshark.

Signed-off-by: Jouni Malinen <[email protected]>
---
include/net/ieee80211_radiotap.h | 7 +++++--
net/mac80211/rx.c | 28 ++++++++++++----------------
2 files changed, 17 insertions(+), 18 deletions(-)

--- wireless-testing.orig/include/net/ieee80211_radiotap.h 2008-12-04 12:56:59.000000000 +0200
+++ wireless-testing/include/net/ieee80211_radiotap.h 2008-12-12 14:10:02.000000000 +0200
@@ -100,9 +100,10 @@ struct ieee80211_radiotap_header {
* For frequency-hopping radios, the hop set (first byte)
* and pattern (second byte).
*
- * IEEE80211_RADIOTAP_RATE u8 500kb/s
+ * IEEE80211_RADIOTAP_RATE u8 500kb/s or index
*
- * Tx/Rx data rate
+ * Tx/Rx data rate. If bit 0x80 is set then it represents an
+ * an MCS index and not an IEEE rate.
*
* IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from
* one milliwatt (dBm)
@@ -230,6 +231,8 @@ enum ieee80211_radiotap_type {
* 802.11 header and payload
* (to 32-bit boundary)
*/
+#define IEEE80211_RADIOTAP_F_SHORTGI 0x80 /* HT short GI */
+
/* For IEEE80211_RADIOTAP_RX_FLAGS */
#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */

--- wireless-testing.orig/net/mac80211/rx.c 2008-12-12 14:09:52.000000000 +0200
+++ wireless-testing/net/mac80211/rx.c 2008-12-12 14:10:02.000000000 +0200
@@ -116,6 +116,7 @@ ieee80211_add_rx_radiotap_header(struct
{
struct ieee80211_radiotap_header *rthdr;
unsigned char *pos;
+ u16 chan_flags;

rthdr = (struct ieee80211_radiotap_header *)skb_push(skb, rtap_len);
memset(rthdr, 0, rtap_len);
@@ -146,19 +147,14 @@ ieee80211_add_rx_radiotap_header(struct
*pos |= IEEE80211_RADIOTAP_F_FCS;
if (status->flag & RX_FLAG_SHORTPRE)
*pos |= IEEE80211_RADIOTAP_F_SHORTPRE;
+ if (status->flag & RX_FLAG_SHORT_GI)
+ *pos |= IEEE80211_RADIOTAP_F_SHORTGI;
pos++;

/* IEEE80211_RADIOTAP_RATE */
- if (status->flag & RX_FLAG_HT) {
- /*
- * TODO: add following information into radiotap header once
- * suitable fields are defined for it:
- * - MCS index (status->rate_idx)
- * - HT40 (status->flag & RX_FLAG_40MHZ)
- * - short-GI (status->flag & RX_FLAG_SHORT_GI)
- */
- *pos = 0;
- } else
+ if (status->flag & RX_FLAG_HT)
+ *pos = 0x80 | status->rate_idx;
+ else
*pos = rate->bitrate / 5;
pos++;

@@ -166,14 +162,14 @@ ieee80211_add_rx_radiotap_header(struct
*(__le16 *)pos = cpu_to_le16(status->freq);
pos += 2;
if (status->band == IEEE80211_BAND_5GHZ)
- *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_OFDM |
- IEEE80211_CHAN_5GHZ);
+ chan_flags = IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ;
else if (rate->flags & IEEE80211_RATE_ERP_G)
- *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_OFDM |
- IEEE80211_CHAN_2GHZ);
+ chan_flags = IEEE80211_CHAN_OFDM | IEEE80211_CHAN_2GHZ;
else
- *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_CCK |
- IEEE80211_CHAN_2GHZ);
+ chan_flags = IEEE80211_CHAN_CCK | IEEE80211_CHAN_2GHZ;
+ if (status->flag & RX_FLAG_40MHZ)
+ chan_flags |= IEEE80211_CHAN_TURBO;
+ *(__le16 *) pos = cpu_to_le16(chan_flags);
pos += 2;

/* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */

--

--
Jouni Malinen PGP id EFC895FA


2008-12-12 15:49:54

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 3/3] mac80211: Add HT rates into radiotap

On Fri, 2008-12-12 at 14:38 +0200, Jouni Malinen wrote:

> - * Tx/Rx data rate
> + * Tx/Rx data rate. If bit 0x80 is set then it represents an
> + * an MCS index and not an IEEE rate.

I really don't like this much because it means that old dissectors will
be confused, and the HT information is at like three different places...

We really should make an HT amendment for radiotap on the radiotap list.
Once that works again. grmbl.

For now I guess we can put this patch into -testing but I'd prefer not
letting it migrate to the official tree, so that we avoid tools starting
to rely on this totally weird information.

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-12-12 15:50:47

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 3/3] mac80211: Add HT rates into radiotap

On Fri, 2008-12-12 at 17:16 +0200, Jouni Malinen wrote:
> On Fri, Dec 12, 2008 at 03:48:47PM +0100, Johannes Berg wrote:
> > On Fri, 2008-12-12 at 15:47 +0100, Stefanik Gábor wrote:
> >
> > > Thanks for the heads up, mail forwarded to Thomas d'Otreppe, as this
> > > will need changes in airodump-ng.
> >
> > Guys! This format is brain-dead, it means we don't know 40MHz or SGI,
> > let's define something proper in radiotap instead!
>
> While I'm not against defining something more officially for radiotap,
> I do not agree with the part about this format being that brain-dead.
> Both 40 MHz and short GI are indicated (IEEE80211_CHAN_TURBO and
> IEEE80211_RADIOTAP_F_SHORTGI) and shown in the current wireshark
> release.

Oh, right, I noticed. Well, as I just said, it's still pretty bogus
because we reuse turbo and confuse older dissectors with the 0x80 for HT
bit.

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-12-12 14:48:53

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 3/3] mac80211: Add HT rates into radiotap

On Fri, 2008-12-12 at 15:47 +0100, Stefanik Gábor wrote:

> Thanks for the heads up, mail forwarded to Thomas d'Otreppe, as this
> will need changes in airodump-ng.

Guys! This format is brain-dead, it means we don't know 40MHz or SGI,
let's define something proper in radiotap instead!

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2008-12-12 15:32:02

by Henning Rogge

[permalink] [raw]
Subject: Re: [PATCH 3/3] mac80211: Add HT rates into radiotap

On Friday 12 December 2008 16:16:19 Jouni Malinen wrote:
> While I'm not against defining something more officially for radiotap,
> I do not agree with the part about this format being that brain-dead.
> Both 40 MHz and short GI are indicated (IEEE80211_CHAN_TURBO and
> IEEE80211_RADIOTAP_F_SHORTGI) and shown in the current wireshark
> release.
Changing the meaning of the old "txrate" field (by putting an index inside) is
a great way to break the userspace interface to any existing program. :(

Just get a new field for the mcs index.

Henning


Attachments:
(No filename) (550.00 B)
signature.asc (197.00 B)
This is a digitally signed message part.
Download all attachments

2008-12-12 16:37:22

by Jouni Malinen

[permalink] [raw]
Subject: Re: [PATCH 3/3] mac80211: Add HT rates into radiotap

On Fri, Dec 12, 2008 at 04:31:51PM +0100, Henning Rogge wrote:
> On Friday 12 December 2008 16:16:19 Jouni Malinen wrote:

> Changing the meaning of the old "txrate" field (by putting an index inside) is
> a great way to break the userspace interface to any existing program. :(

Well, depends on what you mean with breaking ;-). In this particular
case, the output may show incorrect rate in a case where the previous
version showed incorrect rate (e.g., ath9k just reported the highest
legacy rate when HT rates were used). In context of Linux and radiotap,
there wasn't really anything working before that this would break.

> Just get a new field for the mcs index.

Unfortunately, that does not seem to be that easy a task.. I tried to
subscribe to the radiotap mailing list, but the info page is returning
403 Forbidden. Then I tried looking at the archive, and that returned
404.. If I've understood correctly, that has been the state of the
mailing list for a long time. Furthermore, many (most?) people working
with radiotap for Linux/*BSD/wireshark/tcpdump seem to have more or less
given up on the effort to come up with a shared specification for the
format.

--
Jouni Malinen PGP id EFC895FA

2008-12-12 14:47:58

by Gábor Stefanik

[permalink] [raw]
Subject: Re: [PATCH 3/3] mac80211: Add HT rates into radiotap

On Fri, Dec 12, 2008 at 1:38 PM, Jouni Malinen
<[email protected]> wrote:
> Update the radiotap definition based on the format used in FreeBSD to
> allows MCS index, HT20/HT40, and short GI information to be reported
> for received frames in monitor mode. This format is also supported by
> wireshark.
>
> Signed-off-by: Jouni Malinen <[email protected]>
> ---
> include/net/ieee80211_radiotap.h | 7 +++++--
> net/mac80211/rx.c | 28 ++++++++++++----------------
> 2 files changed, 17 insertions(+), 18 deletions(-)
>
> --- wireless-testing.orig/include/net/ieee80211_radiotap.h 2008-12-04 12:56:59.000000000 +0200
> +++ wireless-testing/include/net/ieee80211_radiotap.h 2008-12-12 14:10:02.000000000 +0200
> @@ -100,9 +100,10 @@ struct ieee80211_radiotap_header {
> * For frequency-hopping radios, the hop set (first byte)
> * and pattern (second byte).
> *
> - * IEEE80211_RADIOTAP_RATE u8 500kb/s
> + * IEEE80211_RADIOTAP_RATE u8 500kb/s or index
> *
> - * Tx/Rx data rate
> + * Tx/Rx data rate. If bit 0x80 is set then it represents an
> + * an MCS index and not an IEEE rate.
> *
> * IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from
> * one milliwatt (dBm)
> @@ -230,6 +231,8 @@ enum ieee80211_radiotap_type {
> * 802.11 header and payload
> * (to 32-bit boundary)
> */
> +#define IEEE80211_RADIOTAP_F_SHORTGI 0x80 /* HT short GI */
> +
> /* For IEEE80211_RADIOTAP_RX_FLAGS */
> #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
>
> --- wireless-testing.orig/net/mac80211/rx.c 2008-12-12 14:09:52.000000000 +0200
> +++ wireless-testing/net/mac80211/rx.c 2008-12-12 14:10:02.000000000 +0200
> @@ -116,6 +116,7 @@ ieee80211_add_rx_radiotap_header(struct
> {
> struct ieee80211_radiotap_header *rthdr;
> unsigned char *pos;
> + u16 chan_flags;
>
> rthdr = (struct ieee80211_radiotap_header *)skb_push(skb, rtap_len);
> memset(rthdr, 0, rtap_len);
> @@ -146,19 +147,14 @@ ieee80211_add_rx_radiotap_header(struct
> *pos |= IEEE80211_RADIOTAP_F_FCS;
> if (status->flag & RX_FLAG_SHORTPRE)
> *pos |= IEEE80211_RADIOTAP_F_SHORTPRE;
> + if (status->flag & RX_FLAG_SHORT_GI)
> + *pos |= IEEE80211_RADIOTAP_F_SHORTGI;
> pos++;
>
> /* IEEE80211_RADIOTAP_RATE */
> - if (status->flag & RX_FLAG_HT) {
> - /*
> - * TODO: add following information into radiotap header once
> - * suitable fields are defined for it:
> - * - MCS index (status->rate_idx)
> - * - HT40 (status->flag & RX_FLAG_40MHZ)
> - * - short-GI (status->flag & RX_FLAG_SHORT_GI)
> - */
> - *pos = 0;
> - } else
> + if (status->flag & RX_FLAG_HT)
> + *pos = 0x80 | status->rate_idx;
> + else
> *pos = rate->bitrate / 5;
> pos++;
>
> @@ -166,14 +162,14 @@ ieee80211_add_rx_radiotap_header(struct
> *(__le16 *)pos = cpu_to_le16(status->freq);
> pos += 2;
> if (status->band == IEEE80211_BAND_5GHZ)
> - *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_OFDM |
> - IEEE80211_CHAN_5GHZ);
> + chan_flags = IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ;
> else if (rate->flags & IEEE80211_RATE_ERP_G)
> - *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_OFDM |
> - IEEE80211_CHAN_2GHZ);
> + chan_flags = IEEE80211_CHAN_OFDM | IEEE80211_CHAN_2GHZ;
> else
> - *(__le16 *)pos = cpu_to_le16(IEEE80211_CHAN_CCK |
> - IEEE80211_CHAN_2GHZ);
> + chan_flags = IEEE80211_CHAN_CCK | IEEE80211_CHAN_2GHZ;
> + if (status->flag & RX_FLAG_40MHZ)
> + chan_flags |= IEEE80211_CHAN_TURBO;
> + *(__le16 *) pos = cpu_to_le16(chan_flags);
> pos += 2;
>
> /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */
>
> --
>
> --
> Jouni Malinen PGP id EFC895FA
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

Thanks for the heads up, mail forwarded to Thomas d'Otreppe, as this
will need changes in airodump-ng.

--
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)

2008-12-12 15:19:14

by Jouni Malinen

[permalink] [raw]
Subject: Re: [PATCH 3/3] mac80211: Add HT rates into radiotap

On Fri, Dec 12, 2008 at 03:48:47PM +0100, Johannes Berg wrote:
> On Fri, 2008-12-12 at 15:47 +0100, Stefanik G=C3=A1bor wrote:
>=20
> > Thanks for the heads up, mail forwarded to Thomas d'Otreppe, as thi=
s
> > will need changes in airodump-ng.
>=20
> Guys! This format is brain-dead, it means we don't know 40MHz or SGI,
> let's define something proper in radiotap instead!

While I'm not against defining something more officially for radiotap,
I do not agree with the part about this format being that brain-dead.
Both 40 MHz and short GI are indicated (IEEE80211_CHAN_TURBO and
IEEE80211_RADIOTAP_F_SHORTGI) and shown in the current wireshark
release.

--=20
Jouni Malinen PGP id EFC895F=
A