All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]: setting bit-rate when injecting
@ 2009-11-09 16:07 Lorenzo Bianconi
  2009-11-09 16:34 ` John W. Linville
  2009-11-09 16:50 ` Johannes Berg
  0 siblings, 2 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2009-11-09 16:07 UTC (permalink / raw)
  To: linux-wireless; +Cc: technoboy85

I and my Matteo Croce made a patch which adds the capability
to set the bit-rate when injecting in monitor mode.

The code parse the bit-rate field from the radiotap header and passes the info
to the struct ieee80211_tx_info

--- a/net/mac80211/tx.c	2009-11-09 16:41:15.000000000 +0100
+++ b/net/mac80211/tx.c	2009-11-09 16:50:12.000000000 +0100
@@ -505,6 +505,9 @@
 	struct ieee80211_tx_rate_control txrc;
 	u32 sta_flags;

+	if (info->control.vif->type == NL80211_IFTYPE_MONITOR)
+		return TX_CONTINUE;
+
 	memset(&txrc, 0, sizeof(txrc));

 	sband = tx->local->hw.wiphy->bands[tx->channel->band];
@@ -932,7 +935,9 @@
 		(struct ieee80211_radiotap_header *) skb->data;
 	struct ieee80211_supported_band *sband;
 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-	int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len);
+	int i, ret = ieee80211_radiotap_iterator_init(&iterator,
+			rthdr, skb->len);
+	struct ieee80211_rate *rates;

 	sband = tx->local->hw.wiphy->bands[tx->channel->band];

@@ -979,6 +984,25 @@
 				tx->flags |= IEEE80211_TX_FRAGMENTED;
 			break;

+		case IEEE80211_RADIOTAP_RATE:
+			rates = sband->bitrates;
+			for (i = 0; i < sband->n_bitrates; i++) {
+				if (rates[i].bitrate/5 == *iterator.this_arg) {
+					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;
+
 		/*
 		 * Please update the file
 		 * Documentation/networking/mac80211-injection.txt
@@ -1518,7 +1542,6 @@
 					 struct net_device *dev)
 {
 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
-	struct ieee80211_channel *chan = local->hw.conf.channel;
 	struct ieee80211_radiotap_header *prthdr =
 		(struct ieee80211_radiotap_header *)skb->data;
 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -1540,9 +1563,6 @@
 	 * radar detection by itself. We can do that later by adding a
 	 * monitor flag interfaces used for AP support.
 	 */
-	if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR |
-	     IEEE80211_CHAN_PASSIVE_SCAN)))
-		goto fail;

 	/* check for not even having the fixed radiotap header part */
 	if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header)))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]: setting bit-rate when injecting
  2009-11-09 16:07 [PATCH]: setting bit-rate when injecting Lorenzo Bianconi
@ 2009-11-09 16:34 ` John W. Linville
  2009-11-09 16:50 ` Johannes Berg
  1 sibling, 0 replies; 4+ messages in thread
From: John W. Linville @ 2009-11-09 16:34 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-wireless, technoboy85

On Mon, Nov 09, 2009 at 05:07:20PM +0100, Lorenzo Bianconi wrote:
> I and my Matteo Croce made a patch which adds the capability
> to set the bit-rate when injecting in monitor mode.
> 
> The code parse the bit-rate field from the radiotap header and passes the info
> to the struct ieee80211_tx_info

Need a "Signed-off-by:" line.  Also, please use the "-p" option to
diff when posting patches.

I'll let Johannes comment since you are touching his baby... :-)

Thanks,

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]: setting bit-rate when injecting
  2009-11-09 16:07 [PATCH]: setting bit-rate when injecting Lorenzo Bianconi
  2009-11-09 16:34 ` John W. Linville
@ 2009-11-09 16:50 ` Johannes Berg
  2009-11-09 17:14   ` Matteo Croce
  1 sibling, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2009-11-09 16:50 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-wireless, technoboy85

[-- Attachment #1: Type: text/plain, Size: 2236 bytes --]

On Mon, 2009-11-09 at 17:07 +0100, Lorenzo Bianconi wrote:
> I and my Matteo Croce made a patch which adds the capability
> to set the bit-rate when injecting in monitor mode.
> 
> The code parse the bit-rate field from the radiotap header and passes the info
> to the struct ieee80211_tx_info
> 
> --- a/net/mac80211/tx.c	2009-11-09 16:41:15.000000000 +0100
> +++ b/net/mac80211/tx.c	2009-11-09 16:50:12.000000000 +0100
> @@ -505,6 +505,9 @@
>  	struct ieee80211_tx_rate_control txrc;
>  	u32 sta_flags;
> 
> +	if (info->control.vif->type == NL80211_IFTYPE_MONITOR)
> +		return TX_CONTINUE;

Sorry, can't do that, we need rate control for packets that are injected
from hostapd.

> -	int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len);
> +	int i, ret = ieee80211_radiotap_iterator_init(&iterator,
> +			rthdr, skb->len);
> +	struct ieee80211_rate *rates;

A separate "int i;" would be a lot cleaner I think.

>  	sband = tx->local->hw.wiphy->bands[tx->channel->band];
> 
> @@ -979,6 +984,25 @@
>  				tx->flags |= IEEE80211_TX_FRAGMENTED;
>  			break;
> 
> +		case IEEE80211_RADIOTAP_RATE:
> +			rates = sband->bitrates;
> +			for (i = 0; i < sband->n_bitrates; i++) {
> +				if (rates[i].bitrate/5 == *iterator.this_arg) {
> +					info->control.rates[0].idx = i;
> +					break;
> +				}
> +			}
> +			info->control.rates[0].flags = 0;

This leaves the number of retries at ... 0. That makes no sense. What
driver are you using that this actually works with?!

> @@ -1518,7 +1542,6 @@
>  					 struct net_device *dev)
>  {
>  	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
> -	struct ieee80211_channel *chan = local->hw.conf.channel;
>  	struct ieee80211_radiotap_header *prthdr =
>  		(struct ieee80211_radiotap_header *)skb->data;
>  	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
> @@ -1540,9 +1563,6 @@
>  	 * radar detection by itself. We can do that later by adding a
>  	 * monitor flag interfaces used for AP support.
>  	 */
> -	if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR |
> -	     IEEE80211_CHAN_PASSIVE_SCAN)))
> -		goto fail;

We don't want to break regulatory rules either ...

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]: setting bit-rate when injecting
  2009-11-09 16:50 ` Johannes Berg
@ 2009-11-09 17:14   ` Matteo Croce
  0 siblings, 0 replies; 4+ messages in thread
From: Matteo Croce @ 2009-11-09 17:14 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Lorenzo Bianconi, linux-wireless

On Mon, Nov 9, 2009 at 5:50 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
>>       sband = tx->local->hw.wiphy->bands[tx->channel->band];
>>
>> @@ -979,6 +984,25 @@
>>                               tx->flags |= IEEE80211_TX_FRAGMENTED;
>>                       break;
>>
>> +             case IEEE80211_RADIOTAP_RATE:
>> +                     rates = sband->bitrates;
>> +                     for (i = 0; i < sband->n_bitrates; i++) {
>> +                             if (rates[i].bitrate/5 == *iterator.this_arg) {
>> +                                     info->control.rates[0].idx = i;
>> +                                     break;
>> +                             }
>> +                     }
>> +                     info->control.rates[0].flags = 0;
>
> This leaves the number of retries at ... 0. That makes no sense. What
> driver are you using that this actually works with?!

Oh no, the retries are set in the IEEE80211_RADIOTAP_DATA_RETRIES case,
parsed from the radiotap header

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-09 17:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-09 16:07 [PATCH]: setting bit-rate when injecting Lorenzo Bianconi
2009-11-09 16:34 ` John W. Linville
2009-11-09 16:50 ` Johannes Berg
2009-11-09 17:14   ` Matteo Croce

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.