From patchwork Sat Sep 20 06:40:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yeow Yeoh X-Patchwork-Id: 4940741 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A0AB49F2EC for ; Sat, 20 Sep 2014 06:41:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C24220200 for ; Sat, 20 Sep 2014 06:41:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86D0D2017E for ; Sat, 20 Sep 2014 06:41:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751668AbaITGlE (ORCPT ); Sat, 20 Sep 2014 02:41:04 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=tMu8j2BEzDX/iyAXLu5jESIMw81FqOGhmX3N63KdUY8=; b=pe+3H6UJgB3naRTZMiMTO0nOAKFW8merP9/hmLKVfJURs7XgYyTNYaiCLP/8NO9Jkl WWVJ90MAzQB2Xzp5HrWmRmb8/js4iVa3Lf05KJzuxCqGerp3aQ6OaB1guv0hXybM76eK mM9AxjwUNCVTyi8V3YE8SIXcPuZV0+/xN/gOPMK6HUZlFD5I6QfT19tfdfUuGmFSD8Sd 8RZ1iqhxmoPSaScRn38q8gjuXzoK75Vm6/HBANPk6zduHtKfHsMr17MpGplmJtHdiN2B rmzYbu2sRUN5YqnqshILYr9WS0p6smy+uDq+KHAG9FWw8WhsuzhCCiWINbfOq8o31UnG ubqQ== X-Received: by 10.70.90.142 with SMTP id bw14mr7938432pdb.80.1411195262516; Fri, 19 Sep 2014 23:41:02 -0700 (PDT) Received: from nga.lan ([175.139.58.149]) by mx.google.com with ESMTPSA id h4sm3586715pat.11.2014.09.19.23.41.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Sep 2014 23:41:01 -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> X-Mailer: git-send-email 1.9.2 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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