diff mbox

[v2,2/2] iw: Allow basic rates to be configured when joining mesh

Message ID 1411093476-15685-2-git-send-email-yeohchunyeow@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Chun-Yeow Yeoh Sept. 19, 2014, 2:24 a.m. UTC
This patch adds option to configure basic rates during mesh join.

Signed-off-by: Ashok Nagarajan <ashok.dragon@gmail.com>
Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>

v2: minor change for upstream
---
 mesh.c | 40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)

Comments

Colleen Twitty Sept. 20, 2014, 1:19 a.m. UTC | #1
On Thu, Sep 18, 2014 at 7:24 PM, Chun-Yeow Yeoh via Devel
<devel@lists.open80211s.org> wrote:
> This patch adds option to configure basic rates during mesh join.
>
> Signed-off-by: Ashok Nagarajan <ashok.dragon@gmail.com>
> Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
>
> v2: minor change for upstream
> ---
>  mesh.c | 40 ++++++++++++++++++++++++++++++++++------
>  1 file changed, 34 insertions(+), 6 deletions(-)
>
> diff --git a/mesh.c b/mesh.c
> index 69c54cc..b21a302 100644
> --- a/mesh.c
> +++ b/mesh.c
> @@ -438,8 +438,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;
>         unsigned long freq = 0;
>         static const struct {
>                 const char *name;
> @@ -510,6 +511,32 @@ 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--;
> @@ -575,13 +602,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 frequency, 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.");

I think you have a typo here.  Remove "be"?

>  static int leave_mesh(struct nl80211_state *state, struct nl_cb *cb,
>                       struct nl_msg *msg, int argc, char **argv,
> --
> 1.9.2
>
> _______________________________________________
> Devel mailing list
> Devel@lists.open80211s.org
> http://lists.open80211s.org/cgi-bin/mailman/listinfo/devel

- Colleen
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/mesh.c b/mesh.c
index 69c54cc..b21a302 100644
--- a/mesh.c
+++ b/mesh.c
@@ -438,8 +438,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;
 	unsigned long freq = 0;
 	static const struct {
 		const char *name;
@@ -510,6 +511,32 @@  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--;
@@ -575,13 +602,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 frequency, 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,