2011-06-04 17:43:27

by Matteo Croce

[permalink] [raw]
Subject: [PATCH v3] 802.11n frame injection

Allow to set the tx rate and retries when injecting:
read the information from the radiotap header and populate the retry chain

Signed-off-by: Matteo Croce <[email protected]>

--- a/net/mac80211/tx.c 2011-06-01 21:04:32.000000000 +0200
+++ b/net/mac80211/tx.c 2011-06-04 19:38:36.356443309 +0200
@@ -1092,6 +1092,46 @@
tx->flags |= IEEE80211_TX_FRAGMENTED;
break;

+ case IEEE80211_RADIOTAP_RATE: {
+ struct ieee80211_supported_band *sband =
+ tx->local->hw.wiphy->bands[tx->channel->band];
+ info->control.rates[0].idx = 0;
+ if (*iterator.this_arg) {
+ int i;
+ for (i = 0; i < sband->n_bitrates; i++)
+ if (sband->bitrates[i].bitrate ==
+ *iterator.this_arg * 5) {
+ info->control.rates[0].idx = i;
+ break;
+ }
+ }
+ info->control.rates[0].flags = 0;
+ info->control.rates[1].idx = -1;
+ info->control.rates[2].idx = -1;
+ info->control.rates[3].idx = -1;
+ info->control.rates[4].idx = -1;
+ break;
+ }
+
+ case IEEE80211_RADIOTAP_DATA_RETRIES:
+ info->control.rates[0].count = *iterator.this_arg;
+ break;
+
+ case IEEE80211_RADIOTAP_MCS: {
+ u8 flags = iterator.this_arg[1];
+ u8 mcs = iterator.this_arg[2];
+ info->control.rates[0].idx = mcs;
+ info->control.rates[0].flags |=
+ IEEE80211_TX_RC_MCS;
+ if (flags & IEEE80211_RADIOTAP_MCS_BW_40)
+ info->control.rates[0].flags |=
+ IEEE80211_TX_RC_40_MHZ_WIDTH;
+ if (flags & IEEE80211_RADIOTAP_MCS_SGI)
+ info->control.rates[0].flags |=
+ IEEE80211_TX_RC_SHORT_GI;
+ break;
+ }
+
/*
* Please update the file
* Documentation/networking/mac80211-injection.txt
--- a/net/wireless/radiotap.c 2011-06-01 21:04:24.000000000 +0200
+++ b/net/wireless/radiotap.c 2011-06-04 19:00:49.453007027 +0200
@@ -40,6 +40,7 @@
[IEEE80211_RADIOTAP_TX_FLAGS] = { .align = 2, .size = 2, },
[IEEE80211_RADIOTAP_RTS_RETRIES] = { .align = 1, .size = 1, },
[IEEE80211_RADIOTAP_DATA_RETRIES] = { .align = 1, .size = 1, },
+ [IEEE80211_RADIOTAP_MCS] = { .align = 1, .size = 3, },
/*
* add more here as they are defined in radiotap.h
*/

--
Matteo Croce
OpenWrt Developer
 _______                     ________        __
|       |.-----.-----.-----.|  |  |  |.----.|  |_
|   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
|_______||   __|_____|__|__||________||__|  |____|
         |__| W I R E L E S S   F R E E D O M
ATTITUDE ADJUSTMENT (bleeding edge) --------------
 * 1/4 oz Vodka      Pour all ingredents into mixing
 * 1/4 oz Gin        tin with ice, strain into glass.
 * 1/4 oz Amaretto
 * 1/4 oz Triple sec
 * 1/4 oz Peach schnapps
 * 1/4 oz Sour mix
 * 1 splash Cranberry juice
-----------------------------------------------------


2011-06-06 10:33:34

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH v3] 802.11n frame injection

On Mon, 2011-06-06 at 12:28 +0200, Matteo Croce wrote:

> > Also, have you actually _tested_ this patch? I see nothing that would
> > cause rate control to be skipped, so rate control should always override
> > the data you set up here.

> Actually I use this patch on many devices.
> The rate control is not an issue as this patch is intended for
> injecting in monitor mode

Even monitor mode frames still go through rate control handling.

johannes


2011-06-06 09:35:03

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH v3] 802.11n frame injection

On Sat, 2011-06-04 at 19:42 +0200, Matteo Croce wrote:

> + case IEEE80211_RADIOTAP_RATE: {
> + struct ieee80211_supported_band *sband =
> + tx->local->hw.wiphy->bands[tx->channel->band];
> + info->control.rates[0].idx = 0;
> + if (*iterator.this_arg) {
> + int i;
> + for (i = 0; i < sband->n_bitrates; i++)
> + if (sband->bitrates[i].bitrate ==
> + *iterator.this_arg * 5) {
> + info->control.rates[0].idx = i;
> + break;

I don't think you should set the index if the bitrate doesn't exist.

Also, have you actually _tested_ this patch? I see nothing that would
cause rate control to be skipped, so rate control should always override
the data you set up here.

johannes


2011-06-06 10:29:25

by Matteo Croce

[permalink] [raw]
Subject: Re: [PATCH v3] 802.11n frame injection

MjAxMS82LzYgSm9oYW5uZXMgQmVyZyA8am9oYW5uZXNAc2lwc29sdXRpb25zLm5ldD46Cj4gT24g
U2F0LCAyMDExLTA2LTA0IGF0IDE5OjQyICswMjAwLCBNYXR0ZW8gQ3JvY2Ugd3JvdGU6Cj4KPj4g
KyDCoCDCoCDCoCDCoCDCoCDCoCBjYXNlIElFRUU4MDIxMV9SQURJT1RBUF9SQVRFOiB7Cj4+ICsg
wqAgwqAgwqAgwqAgwqAgwqAgwqAgwqAgwqAgwqAgc3RydWN0IGllZWU4MDIxMV9zdXBwb3J0ZWRf
YmFuZCAqc2JhbmQgPQo+PiArIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKg
IMKgIHR4LT5sb2NhbC0+aHcud2lwaHktPmJhbmRzW3R4LT5jaGFubmVsLT5iYW5kXTsKPj4gKyDC
oCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCBpbmZvLT5jb250cm9sLnJhdGVzWzBdLmlkeCA9
IDA7Cj4+ICsgwqAgwqAgwqAgwqAgwqAgwqAgwqAgwqAgwqAgwqAgaWYgKCppdGVyYXRvci50aGlz
X2FyZykgewo+PiArIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIGlu
dCBpOwo+PiArIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIGZvciAo
aSA9IDA7IGkgPCBzYmFuZC0+bl9iaXRyYXRlczsgaSsrKQo+PiArIMKgIMKgIMKgIMKgIMKgIMKg
IMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIGlmIChzYmFuZC0+Yml0cmF0ZXNb
aV0uYml0cmF0ZSA9PQo+PiArIMKgIMKgIMKgIMK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