diff mbox

[v4,1/2] iw: Allow user to provide freq during mesh join

Message ID 1411434889-1456-1-git-send-email-yeohchunyeow@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Chun-Yeow Yeoh Sept. 23, 2014, 1:14 a.m. UTC
Allow user to configure frequency and channel type during
mesh join command.

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

v2: use chandef similar to IBSS (Johannes)
v4: make the mesh join command more self-explanatory (Bob Copeland)
---
 mesh.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 67 insertions(+), 3 deletions(-)

Comments

Johannes Berg Oct. 6, 2014, 1:06 p.m. UTC | #1
On Tue, 2014-09-23 at 09:14 +0800, Chun-Yeow Yeoh wrote:
> Allow user to configure frequency and channel type during
> mesh join command.

I think I saw another v4 of this, was this meant to be v5?

johannes

--
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
Chun-Yeow Yeoh Oct. 6, 2014, 3:48 p.m. UTC | #2
Hi, Johannes

There are actually two different patches. The latest one, both of them
are named as v4.

[PATCH v4 1/2] iw: Allow user to provide freq during mesh join
[PATCH v4 2/2] iw: Allow basic rates to be configured when joining mesh

----
Chun-Yeow

On Mon, Oct 6, 2014 at 9:06 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Tue, 2014-09-23 at 09:14 +0800, Chun-Yeow Yeoh wrote:
>> Allow user to configure frequency and channel type during
>> mesh join command.
>
> I think I saw another v4 of this, was this meant to be v5?
>
> johannes
>
--
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
Johannes Berg Oct. 6, 2014, 4:05 p.m. UTC | #3
On Mon, 2014-10-06 at 23:48 +0800, Yeoh Chun-Yeow wrote:
> Hi, Johannes
> 
> There are actually two different patches. The latest one, both of them
> are named as v4.

Right, sorry. I'm clearly going through email too quickly.

johannes

--
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
Johannes Berg Oct. 9, 2014, 2:18 p.m. UTC | #4
On Tue, 2014-09-23 at 09:14 +0800, Chun-Yeow Yeoh wrote:
> Allow user to configure frequency and channel type during
> mesh join command.

Both applied.

johannes

--
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 ca065bf..570b4d3 100644
--- a/mesh.c
+++ b/mesh.c
@@ -438,8 +438,32 @@  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;
+	unsigned long freq = 0;
+	static const struct {
+		const char *name;
+		unsigned int width;
+		int freq1_diff;
+		int chantype; /* for older kernel */
+	} *chanmode_selected = NULL, chanmode[] = {
+		{ .name = "HT20",
+		  .width = NL80211_CHAN_WIDTH_20,
+		  .freq1_diff = 0,
+		  .chantype = NL80211_CHAN_HT20 },
+		{ .name = "HT40+",
+		  .width = NL80211_CHAN_WIDTH_40,
+		  .freq1_diff = 10,
+		  .chantype = NL80211_CHAN_HT40PLUS },
+		{ .name = "HT40-",
+		  .width = NL80211_CHAN_WIDTH_40,
+		  .freq1_diff = -10,
+		  .chantype = NL80211_CHAN_HT40MINUS },
+		{ .name = "NOHT",
+		  .width = NL80211_CHAN_WIDTH_20_NOHT,
+		  .freq1_diff = 0,
+		  .chantype = NL80211_CHAN_NO_HT },
+	};
 
 	if (argc < 1)
 		return 1;
@@ -448,6 +472,44 @@  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--;
+
+		freq = strtoul(argv[0], &end, 10);
+		if (*end != '\0')
+			return 1;
+		NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
+
+		argv++;
+		argc--;
+	}
+
+	/* channel type */
+	if (argc) {
+		for (i = 0; i < ARRAY_SIZE(chanmode); i++) {
+			if (strcasecmp(chanmode[i].name, argv[0]) == 0) {
+				chanmode_selected = &chanmode[i];
+				break;
+			}
+		}
+
+		if (chanmode_selected) {
+			NLA_PUT_U32(msg, NL80211_ATTR_CHANNEL_WIDTH,
+				    chanmode_selected->width);
+			NLA_PUT_U32(msg, NL80211_ATTR_CENTER_FREQ1,
+				    freq + chanmode_selected->freq1_diff);
+			if (chanmode_selected->chantype != -1)
+				NLA_PUT_U32(msg,
+					    NL80211_ATTR_WIPHY_CHANNEL_TYPE,
+					    chanmode_selected->chantype);
+
+			argv++;
+			argc--;
+		}
+	}
+
 	if (argc > 1 && strcmp(argv[0], "mcast-rate") == 0) {
 		argv++;
 		argc--;
@@ -513,11 +575,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 <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 frequency, 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,