2013-06-03 17:34:26

by Ashok Nagarajan

[permalink] [raw]
Subject: [PATCH 1/2] iw: Allow user to provide freq during mesh join

Allow user to configure frequency and channel type during mesh join command.

Signed-off-by: Ashok Nagarajan <[email protected]>
---
mesh.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/mesh.c b/mesh.c
index 5a09b62..ec202c9 100644
--- a/mesh.c
+++ b/mesh.c
@@ -431,8 +431,18 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
{
struct nlattr *container;
float rate;
- int bintval, dtim_period;
+ int bintval, dtim_period, i;
char *end;
+ static const struct {
+ const char *name;
+ unsigned int val;
+ } htmap[] = {
+ { .name = "HT20", .val = NL80211_CHAN_HT20, },
+ { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
+ { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
+ { .name = "NOHT", .val = NL80211_CHAN_NO_HT, },
+ };
+ unsigned int htval;

if (argc < 1)
return 1;
@@ -441,6 +451,37 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
argc--;
argv++;

+ /* freq */
+ if (argc > 1 && strcmp(argv[0], "freq") == 0) {
+ argv++;
+ argc--;
+
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ,
+ strtoul(argv[0], &end, 10));
+ if (*end != '\0')
+ return 1;
+ argv++;
+ argc--;
+
+ }
+
+ /* channel type */
+ if (argc) {
+ for (i = 0; i < ARRAY_SIZE(htmap); i++) {
+ if (strcasecmp(htmap[i].name, argv[0]) == 0) {
+ htval = htmap[i].val;
+ break;
+ }
+ }
+ if (i != ARRAY_SIZE(htmap)) {
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
+ htval);
+ argv++;
+ argc--;
+ }
+
+ }
+
if (argc > 1 && strcmp(argv[0], "mcast-rate") == 0) {
argv++;
argc--;
@@ -506,11 +547,13 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
nla_put_failure:
return -ENOBUFS;
}
-COMMAND(mesh, join, "<mesh ID> [mcast-rate <rate in Mbps>]"
+COMMAND(mesh, join, "<mesh ID> [freq in MHz] [HT20|HT40+|HT40-|NOHT]"
+ " [mcast-rate <rate in Mbps>]"
" [beacon-interval <time in TUs>] [dtim-period <value>]"
" [vendor_sync on|off] [<param>=<value>]*",
NL80211_CMD_JOIN_MESH, 0, CIB_NETDEV, join_mesh,
- "Join a mesh with the given mesh ID with mcast-rate and mesh parameters.");
+ "Join a mesh with the given mesh ID with freq, mcast-rate, "
+ "and mesh parameters.");

static int leave_mesh(struct nl80211_state *state, struct nl_cb *cb,
struct nl_msg *msg, int argc, char **argv,
--
1.7.5.4



2013-06-14 21:39:54

by Ashok Nagarajan

[permalink] [raw]
Subject: Re: [PATCH 1/2] iw: Allow user to provide freq during mesh join

On Tue, Jun 11, 2013 at 5:26 AM, Johannes Berg
<[email protected]> wrote:
> On Mon, 2013-06-03 at 10:34 -0700, Ashok Nagarajan wrote:
>> Allow user to configure frequency and channel type during mesh join command.
>>
>> Signed-off-by: Ashok Nagarajan <[email protected]>
>> ---
>> mesh.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
>> 1 files changed, 46 insertions(+), 3 deletions(-)
>>
>> diff --git a/mesh.c b/mesh.c
>> index 5a09b62..ec202c9 100644
>> --- a/mesh.c
>> +++ b/mesh.c
>> @@ -431,8 +431,18 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
>> {
>> struct nlattr *container;
>> float rate;
>> - int bintval, dtim_period;
>> + int bintval, dtim_period, i;
>> char *end;
>> + static const struct {
>> + const char *name;
>> + unsigned int val;
>> + } htmap[] = {
>> + { .name = "HT20", .val = NL80211_CHAN_HT20, },
>> + { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
>> + { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
>> + { .name = "NOHT", .val = NL80211_CHAN_NO_HT, },
>> + };
>
> I think you should use chandefs already, to allow for VHT. Also, it'd be
> good to refactor the channel parsing for this, monitor and IBSS (though
> I wonder why I haven't done that already?)
>

Sure. That makes sense. I will get that in the next version.

Thanks,
Ashok
> johannes
>



--
Ashok Raj Nagarajan,
cozybit Inc.
http://www.cozybit.com

2013-06-03 17:34:28

by Ashok Nagarajan

[permalink] [raw]
Subject: [PATCH 2/2] iw: Allow basic rates to be configured when joining mesh

This patch adds option to configure basic rates during mesh join. basic-rates
has to be passed along with "freq" attribute. For instance:

iw $MESH_IFACE mesh join mymeshid freq 2437 basic-rates 5.5,11

Signed-off-by: Ashok Nagarajan <[email protected]>
---
mesh.c | 42 ++++++++++++++++++++++++++++++++++++------
1 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/mesh.c b/mesh.c
index ec202c9..f7c4c35 100644
--- a/mesh.c
+++ b/mesh.c
@@ -431,8 +431,9 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
{
struct nlattr *container;
float rate;
- int bintval, dtim_period, i;
- char *end;
+ unsigned char rates[NL80211_MAX_SUPP_RATES];
+ int bintval, dtim_period, i, n_rates = 0;
+ char *end, *value = NULL, *sptr = NULL;
static const struct {
const char *name;
unsigned int val;
@@ -482,6 +483,34 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,

}

+ /* 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 = strtod(value, &end);
+ rates[n_rates] = rate * 2;
+
+ /* filter out suspicious values */
+ if (*end != '\0' || !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--;
+ }
+
+ /* multicast rate */
+
if (argc > 1 && strcmp(argv[0], "mcast-rate") == 0) {
argv++;
argc--;
@@ -547,13 +576,14 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
nla_put_failure:
return -ENOBUFS;
}
-COMMAND(mesh, join, "<mesh ID> [freq in MHz] [HT20|HT40+|HT40-|NOHT]"
- " [mcast-rate <rate in Mbps>]"
+COMMAND(mesh, join, "<mesh ID> [freq in MHz [HT20|HT40+|HT40-|NOHT]"
+ " [basic-rates <rate in Mbps,rate2,...>]], [mcast-rate <rate in Mbps>]"
" [beacon-interval <time in TUs>] [dtim-period <value>]"
" [vendor_sync on|off] [<param>=<value>]*",
NL80211_CMD_JOIN_MESH, 0, CIB_NETDEV, join_mesh,
- "Join a mesh with the given mesh ID with freq, mcast-rate, "
- "and mesh parameters.");
+ "Join a mesh with the given mesh ID with frequency, basic-rates,\n"
+ "mcast-rate and mesh parameters. basic-rates are be applied only if\n"
+ "frequency is provided.");

static int leave_mesh(struct nl80211_state *state, struct nl_cb *cb,
struct nl_msg *msg, int argc, char **argv,
--
1.7.5.4


2013-06-11 12:26:58

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/2] iw: Allow user to provide freq during mesh join

On Mon, 2013-06-03 at 10:34 -0700, Ashok Nagarajan wrote:
> Allow user to configure frequency and channel type during mesh join command.
>
> Signed-off-by: Ashok Nagarajan <[email protected]>
> ---
> mesh.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
> 1 files changed, 46 insertions(+), 3 deletions(-)
>
> diff --git a/mesh.c b/mesh.c
> index 5a09b62..ec202c9 100644
> --- a/mesh.c
> +++ b/mesh.c
> @@ -431,8 +431,18 @@ static int join_mesh(struct nl80211_state *state, struct nl_cb *cb,
> {
> struct nlattr *container;
> float rate;
> - int bintval, dtim_period;
> + int bintval, dtim_period, i;
> char *end;
> + static const struct {
> + const char *name;
> + unsigned int val;
> + } htmap[] = {
> + { .name = "HT20", .val = NL80211_CHAN_HT20, },
> + { .name = "HT40+", .val = NL80211_CHAN_HT40PLUS, },
> + { .name = "HT40-", .val = NL80211_CHAN_HT40MINUS, },
> + { .name = "NOHT", .val = NL80211_CHAN_NO_HT, },
> + };

I think you should use chandefs already, to allow for VHT. Also, it'd be
good to refactor the channel parsing for this, monitor and IBSS (though
I wonder why I haven't done that already?)

johannes