Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH] iw: Configure basic rates when joining ibss network
@ 2010-06-15  6:24 Teemu Paasikivi
  2010-06-15  7:18 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Teemu Paasikivi @ 2010-06-15  6:24 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Teemu Paasikivi

This patch adds option to configure basic rates when joining ibss network.

Signed-off-by: Teemu Paasikivi <ext-teemu.3.paasikivi@nokia.com>
---
 ibss.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/ibss.c b/ibss.c
index 4715ac8..cf57cf0 100644
--- a/ibss.c
+++ b/ibss.c
@@ -18,6 +18,11 @@ static int join_ibss(struct nl80211_state *state,
 {
 	char *end;
 	unsigned char abssid[6];
+	unsigned char rates[NL80211_MAX_SUPP_RATES];
+	int n_rates = 0;
+	char *value = NULL, *sptr = NULL;
+	float rate;
+
 
 	if (argc < 2)
 		return 1;
@@ -41,6 +46,31 @@ static int join_ibss(struct nl80211_state *state,
 		argc--;
 	}
 
+	/* basic rates */
+	if (argc > 1 && strcmp(argv[0], "basic-rates") == 0) {
+		argv++;
+		argc--;
+
+		value = strtok_r(argv[0], ",", &sptr);
+
+		while (value && n_rates < NL80211_MAX_SUPP_RATES) {
+			rate = atof(value);
+			rates[n_rates] = rate * 2;
+
+			/* filter out suspicious values  */
+			if (!rates[n_rates] || rate*2 != rates[n_rates])
+				return 1;
+
+			n_rates++;
+			value = strtok_r(NULL, ",", &sptr);
+		}
+
+		NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, n_rates, rates);
+
+		argv++;
+		argc--;
+	}
+
 	if (argc) {
 		if (mac_addr_a2n(abssid, argv[0]) == 0) {
 			NLA_PUT(msg, NL80211_ATTR_MAC, 6, abssid);
@@ -73,7 +103,9 @@ static int leave_ibss(struct nl80211_state *state,
 COMMAND(ibss, leave, NULL,
 	NL80211_CMD_LEAVE_IBSS, 0, CIB_NETDEV, leave_ibss,
 	"Leave the current IBSS cell.");
-COMMAND(ibss, join, "<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>] [key d:0:abcde]",
+COMMAND(ibss, join,
+	"<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>] "
+	"[basic-rates <rate in Mbps,rate2,...>] [key d:0:abcde]",
 	NL80211_CMD_JOIN_IBSS, 0, CIB_NETDEV, join_ibss,
 	"Join the IBSS cell with the given SSID, if it doesn't exist create\n"
 	"it on the given frequency. When fixed frequency is requested, don't\n"
-- 
1.5.6.3


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

* Re: [PATCH] iw: Configure basic rates when joining ibss network
  2010-06-15  6:24 [PATCH] iw: Configure basic rates when joining ibss network Teemu Paasikivi
@ 2010-06-15  7:18 ` Johannes Berg
  2010-06-15  8:50   ` Teemu Paasikivi
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2010-06-15  7:18 UTC (permalink / raw)
  To: Teemu Paasikivi; +Cc: linux-wireless

On Tue, 2010-06-15 at 09:24 +0300, Teemu Paasikivi wrote:

> @@ -41,6 +46,31 @@ static int join_ibss(struct nl80211_state *state,
>  		argc--;
>  	}
>  
> +	/* basic rates */
> +	if (argc > 1 && strcmp(argv[0], "basic-rates") == 0) {
> +		argv++;
> +		argc--;
> +
> +		value = strtok_r(argv[0], ",", &sptr);
> +
> +		while (value && n_rates < NL80211_MAX_SUPP_RATES) {
> +			rate = atof(value);

should that use strtod() to check you didn't give "1a,2b,6c,11d"?

johannes


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

* Re: [PATCH] iw: Configure basic rates when joining ibss network
  2010-06-15  7:18 ` Johannes Berg
@ 2010-06-15  8:50   ` Teemu Paasikivi
  0 siblings, 0 replies; 3+ messages in thread
From: Teemu Paasikivi @ 2010-06-15  8:50 UTC (permalink / raw)
  To: ext Johannes Berg; +Cc: linux-wireless@vger.kernel.org

On Tue, 2010-06-15 at 09:18 +0200, ext Johannes Berg wrote:
> On Tue, 2010-06-15 at 09:24 +0300, Teemu Paasikivi wrote:
> 
> > @@ -41,6 +46,31 @@ static int join_ibss(struct nl80211_state *state,
> >  		argc--;
> >  	}
> >  
> > +	/* basic rates */
> > +	if (argc > 1 && strcmp(argv[0], "basic-rates") == 0) {
> > +		argv++;
> > +		argc--;
> > +
> > +		value = strtok_r(argv[0], ",", &sptr);
> > +
> > +		while (value && n_rates < NL80211_MAX_SUPP_RATES) {
> > +			rate = atof(value);
> 
> should that use strtod() to check you didn't give "1a,2b,6c,11d"?
> 
Sure, it can be used. I think I'll change it to use that. I was just
wondering that how much the values given by the user should/could be
checked here.

> johannes
> 

Br,

Teemu



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

end of thread, other threads:[~2010-06-15  8:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-15  6:24 [PATCH] iw: Configure basic rates when joining ibss network Teemu Paasikivi
2010-06-15  7:18 ` Johannes Berg
2010-06-15  8:50   ` Teemu Paasikivi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox