From patchwork Mon Jan 12 12:49:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rostislav Lisovy X-Patchwork-Id: 5610261 X-Patchwork-Delegate: johannes@sipsolutions.net 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 700A79F2ED for ; Mon, 12 Jan 2015 12:50:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7EDFA20395 for ; Mon, 12 Jan 2015 12:50:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 74BFC20394 for ; Mon, 12 Jan 2015 12:50:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752711AbbALMuP (ORCPT ); Mon, 12 Jan 2015 07:50:15 -0500 Received: from mail-wg0-f45.google.com ([74.125.82.45]:61657 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751083AbbALMuK (ORCPT ); Mon, 12 Jan 2015 07:50:10 -0500 Received: by mail-wg0-f45.google.com with SMTP id y19so2945580wgg.4; Mon, 12 Jan 2015 04:50:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=PfUWzHI7brBSaFipEHmPm92SSCS1E89Ws66TG8RpW+Q=; b=FtOrNy7lQyCWt/6JsD/K6WugxMTK3VoYmyxPtTQvveFhua9tIQFIR6iqMvN4kcmnZi Geam+IvxqRuU689ZWHJ4JlImWk0ZzfS47UHM50pLjuVq3JsR1d1nZbwT/8OXnfE5OWJJ VGRiOUP+Xt5tIhKS4JpbfpaidpHtHzl4fp3+6Y1YXEZfUku92PFQVCy8KQNsEOHtJA8/ GD7xtJ2dDsDxkOt8ul7qb0tVkac6YvZKaWtrg5PnunHN3pt96+uKxUQNWHCXFpMUTR6F 8UA+PkGXbv8nPJsRabUxE1d7vW1Ej5kC3iufQRi+alrqL71PCFFL0R0G4hUWRg5GYK6u 4v9g== X-Received: by 10.180.21.133 with SMTP id v5mr30417237wie.44.1421067008135; Mon, 12 Jan 2015 04:50:08 -0800 (PST) Received: from c2c-vostro1.felk.cvut.cz ([147.32.86.216]) by mx.google.com with ESMTPSA id e4sm21486654wjw.48.2015.01.12.04.50.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Jan 2015 04:50:07 -0800 (PST) From: Rostislav Lisovy X-Google-Original-From: Rostislav Lisovy To: Johannes Berg , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michal Sojka , s.sander@nordsys.de, jan-niklas.meier@volkswagen.de, burak.simsek@volkswagen.de, bernd.lehmann@volkswagen.de, lisovy@gmail.com, Rostislav Lisovy Subject: [PATCH] iw: Add OCB mode handling Date: Mon, 12 Jan 2015 13:49:57 +0100 Message-Id: <1421066997-8676-1-git-send-email-rostislav.lisovy@fel.cvut.cz> X-Mailer: git-send-email 2.0.0.rc4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Since the commit 6e0bd6c35b021dc73a81ebd1ef79761233c48b50 ("cfg80211: 802.11p OCB mode handling") and 239281f803e2efdb77d906ef296086b6917e5d71 ("mac80211: 802.11p OCB mode support") does the Linux kernel support OCB mode. This commit adds proper OCB mode handling. Modify the command for device type setting to support OCB mode. Add commands for "joining" and "leaving" the OCB mode network. When joining two arguments are mandatory -- frequency and channel bandwidth (5 or 10 MHz). Signed-off-by: Rostislav Lisovy --- Makefile | 2 +- interface.c | 3 +++ ocb.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ util.c | 1 + 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 ocb.c diff --git a/Makefile b/Makefile index 58755dc..548591a 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ CFLAGS ?= -O2 -g CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration OBJS = iw.o genl.o event.o info.o phy.o \ - interface.o ibss.o station.o survey.o util.o \ + interface.o ibss.o station.o survey.o util.o ocb.o \ mesh.o mpath.o mpp.o scan.o reg.o version.o \ reason.o status.o connect.o link.o offch.o ps.o cqm.o \ bitrate.o wowlan.o coalesce.o roc.o p2p.o vendor.o diff --git a/interface.c b/interface.c index f8e39b3..80437bd 100644 --- a/interface.c +++ b/interface.c @@ -104,6 +104,9 @@ static int get_if_type(int *argc, char ***argv, enum nl80211_iftype *type, strcmp(tpstr, "ibss") == 0) { *type = NL80211_IFTYPE_ADHOC; return 0; + } else if (strcmp(tpstr, "ocb") == 0) { + *type = NL80211_IFTYPE_OCB; + return 0; } else if (strcmp(tpstr, "monitor") == 0) { *type = NL80211_IFTYPE_MONITOR; return 0; diff --git a/ocb.c b/ocb.c new file mode 100644 index 0000000..7da05d1 --- /dev/null +++ b/ocb.c @@ -0,0 +1,76 @@ +#include +#include +#include + +#include "nl80211.h" +#include "iw.h" + +SECTION(ocb); + +static int join_ocb(struct nl80211_state *state, struct nl_cb *cb, + struct nl_msg *msg, int argc, char **argv, + enum id_input id) +{ + unsigned long freq; + char *end; + int i; + static const struct { + const char *name; + unsigned int width; + } *chanmode_selected, chanmode[] = { + { .name = "5MHZ", + .width = NL80211_CHAN_WIDTH_5 }, + { .name = "10MHZ", + .width = NL80211_CHAN_WIDTH_10 }, + }; + + if (argc < 2) + return 1; + + /* freq */ + freq = strtoul(argv[0], &end, 10); + if (*end != '\0') + return 1; + + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); + argv++; + argc--; + + /* channel width */ + 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); + + argv++; + argc--; + } else { + return 1; + } + + return 0; + +nla_put_failure: + return -ENOBUFS; +} +COMMAND(ocb, join, " <5MHZ|10MHZ>", + NL80211_CMD_JOIN_OCB, 0, CIB_NETDEV, join_ocb, + "Join the OCB mode network."); + +static int leave_ocb(struct nl80211_state *state, struct nl_cb *cb, + struct nl_msg *msg, int argc, char **argv, + enum id_input id) +{ + if (argc) + return 1; + + return 0; +} +COMMAND(ocb, leave, NULL, NL80211_CMD_LEAVE_OCB, 0, CIB_NETDEV, leave_ocb, + "Leave the OCB mode network."); diff --git a/util.c b/util.c index 7b51b23..411fea1 100644 --- a/util.c +++ b/util.c @@ -133,6 +133,7 @@ static const char *ifmodes[NL80211_IFTYPE_MAX + 1] = { "P2P-client", "P2P-GO", "P2P-device", + "outside context of a BSS", }; static char modebuf[100];