From patchwork Tue Sep 23 01:14:48 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: 4951711 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 DA42F9F2BB for ; Tue, 23 Sep 2014 01:15:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CCBCC201C0 for ; Tue, 23 Sep 2014 01:15:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D48EE20160 for ; Tue, 23 Sep 2014 01:15:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754507AbaIWBPC (ORCPT ); Mon, 22 Sep 2014 21:15:02 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:57105 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754450AbaIWBPB (ORCPT ); Mon, 22 Sep 2014 21:15:01 -0400 Received: by mail-pd0-f169.google.com with SMTP id fp1so1387324pdb.14 for ; Mon, 22 Sep 2014 18:15:00 -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=RhM9whAvMYuwJcJZHV30TPNyqA4aA4GHahHK68wTjWk=; b=Q19RZ0CShS0KwZ44q4B+mAG59UEjHHfNCtjVW75vC7N3IczhW9b9AfnZyT70Riex5t XMWBnyg6NBxkKWx18D627nKj7ViVvYo/c+D+KR50GeOrM32DLBjORgBpPFYF5EDPBhKc 9D/CoFb8OM7qHixSeE7RIUGfFYy+McGIC5d1n37KzkjOwCdvv2TVKrMLPKDMIHMyFyzD wibiwr9iOn2CtSSltKFD8h+x4mRW3NE6yq6yV6WuuyCwlRCbrNzZ8sJLeW4c/g/6r1r3 x7UFxO5VMrygIZgeHwT1EMWli6QejprcmK4yM4ekdr2f7DEjNhkhkUrrW+I5SHQcsBXN W8Gw== X-Received: by 10.70.129.72 with SMTP id nu8mr36162560pdb.91.1411434900822; Mon, 22 Sep 2014 18:15:00 -0700 (PDT) Received: from localhost.localdomain ([58.26.233.145]) by mx.google.com with ESMTPSA id x3sm5104005pdp.53.2014.09.22.18.14.58 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 18:14:59 -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 v4 1/2] iw: Allow user to provide freq during mesh join Date: Tue, 23 Sep 2014 09:14:48 +0800 Message-Id: <1411434889-1456-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.8 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) v4: make the mesh join command more self-explanatory (Bob Copeland) --- mesh.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 3 deletions(-) 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, " [mcast-rate ]" +COMMAND(mesh, join, " [freq ]" + " [mcast-rate ]" " [beacon-interval