Return-path: Received: from mail-pa0-f54.google.com ([209.85.220.54]:53437 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbaITGlD (ORCPT ); Sat, 20 Sep 2014 02:41:03 -0400 Received: by mail-pa0-f54.google.com with SMTP id fb1so1460799pad.27 for ; Fri, 19 Sep 2014 23:41:02 -0700 (PDT) From: Chun-Yeow Yeoh To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, devel@lists.open80211s.org, Chun-Yeow Yeoh , Ashok Nagarajan Subject: [PATCH v3 1/2] iw: Allow user to provide freq during mesh join Date: Sat, 20 Sep 2014 14:40:43 +0800 Message-Id: <1411195244-9130-1-git-send-email-yeohchunyeow@gmail.com> (sfid-20140920_084108_301951_C33ABF85) Sender: linux-wireless-owner@vger.kernel.org List-ID: Allow user to configure frequency and channel type during mesh join command. Signed-off-by: Ashok Nagarajan Signed-off-by: Chun-Yeow Yeoh v2: use chandef similar to IBSS (Johannes) --- mesh.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/mesh.c b/mesh.c index ca065bf..69c54cc 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, " [mcast-rate ]" +COMMAND(mesh, join, " [freq in MHz] [HT20|HT40+|HT40-|NOHT]" + " [mcast-rate ]" " [beacon-interval