From patchwork Fri Sep 19 02:24:35 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: 4935211 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 F06C69F2EC for ; Fri, 19 Sep 2014 02:24:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B3A52017D for ; Fri, 19 Sep 2014 02:24:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9646720166 for ; Fri, 19 Sep 2014 02:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752229AbaISCYw (ORCPT ); Thu, 18 Sep 2014 22:24:52 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:45320 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750895AbaISCYw (ORCPT ); Thu, 18 Sep 2014 22:24:52 -0400 Received: by mail-pd0-f172.google.com with SMTP id v10so2665591pde.31 for ; Thu, 18 Sep 2014 19:24:51 -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=ocFuQKxRve6JsT0g0fK3O78iHR5YAjEiE7WH3KDk6tw=; b=au1YH5dhF90/2fgmM0p5b06im46Z+ktO8kPMacGViJwXDukpJ9Uu/L+QHY04pcWgRC In9Oo2FCWCZLDCgKg01z9RRRy5RU/v9FtR0BKCrssKwD5lMYFsDv3J4cuo+R9HOdLz5h 2/XefD5xlbt4zMmgQ6fo4wlLD8ceJrQoV8ywgZmYhz0I1Yd/f7wV1dfiAd641LHqSX3N 23N8nJuOXv1YUSMBU4IEZaCfLxL/QKlmNQ8VUJwqkcLAJYrVL/p201T55oF7hNibx5DY EaTt5APtvU21EZOubEcMWVNZ+v2iQV32WaByN/QdcyIk12FkNvj1htSYvLRVgTqdBqdg K+jg== X-Received: by 10.68.252.168 with SMTP id zt8mr11646281pbc.14.1411093491716; Thu, 18 Sep 2014 19:24:51 -0700 (PDT) Received: from localhost.localdomain ([58.26.233.145]) by mx.google.com with ESMTPSA id ca2sm318865pbc.26.2014.09.18.19.24.49 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Sep 2014 19:24:50 -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 v2 1/2] iw: Allow user to provide freq during mesh join Date: Fri, 19 Sep 2014 10:24:35 +0800 Message-Id: <1411093476-15685-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 --- 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