From patchwork Wed May 4 15:38:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 9016231 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5E6CDBF29F for ; Wed, 4 May 2016 15:39:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 788C620382 for ; Wed, 4 May 2016 15:39:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B4B62025B for ; Wed, 4 May 2016 15:39:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751952AbcEDPjK (ORCPT ); Wed, 4 May 2016 11:39:10 -0400 Received: from mail-lf0-f54.google.com ([209.85.215.54]:34359 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbcEDPjJ (ORCPT ); Wed, 4 May 2016 11:39:09 -0400 Received: by mail-lf0-f54.google.com with SMTP id m64so64686644lfd.1 for ; Wed, 04 May 2016 08:39:08 -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:mime-version :content-transfer-encoding; bh=BHIwZungw95M9wHcrm9TtEfPSEbWBQj2PRMSnq5JJYk=; b=0nLdn/BzrVvmlrSSv1LTFJty/sgQovNGGcJRv4a36BsafRKU+zbXBpvSaWg3svA6/4 ryc9nWAr7vj39p63n1/Rj7YL6RNjqVhAgcFdhZrXHUZDu2NN0oKCWlocgOjRmvE0gELb GA9vAL8h+pyCpQ908X72IkwnooYF+1UMgSVc4PyaiF/DqOHtLbVzWI6zB8SAqteJOB1Q X/6UsdAS42IV1e6D7DAPuYbjmwszwvuM6xjFFqf3XBC/q+toOzi90/Atmo0zwz2w9Qqj OYv8ykBFaTv6yTYe83fSw+UQgjy7zFttz/n/M9t4Po+tB7KuPlRpAVLIRiAHspyceqpw Jipw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BHIwZungw95M9wHcrm9TtEfPSEbWBQj2PRMSnq5JJYk=; b=dH0jPZ9fIjwX9izI90AC6VkkIM4gMggRl92ptmLhSKS/GA8/OxKrD+q5+J4n83ZRdB g+aMQfENdzi8tWb0tme1E/i5QoMstN4xfEZ14vWWVhn6xQvkExhSTxVKkPe38WLIu5HA 0bWx/JJXx/aW2uPnGbLNOvFgyJ9UOH2R53c47Dd5iPavMNtm/j2jR4yIFq0Bw5G/7NhT T3IpzT3pEFoEWe9/bskMtKVL8OH2lcZyEwP3Wlv1O9wj6SC5qp6q4TIhdtHxV6bxVMaa 4+VYcW3yGHB4LrZBzXyziA25sziLc2bTB3j+hr/W9lBKytFUfjOw2oi1XaAH6V/Lb2u7 YZSQ== X-Gm-Message-State: AOPr4FVd/sN3F8jasjbmgv+f//+xQY4dr1QUZwm42rEuYOmVtUkWt43BC/8Fwp8jgoeWxg== X-Received: by 10.112.53.168 with SMTP id c8mr4396309lbp.10.1462376347359; Wed, 04 May 2016 08:39:07 -0700 (PDT) Received: from linux-samsung.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id h8sm722593lfh.6.2016.05.04.08.39.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 May 2016 08:39:06 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Johannes Berg Cc: linux-wireless@vger.kernel.org, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH] iw: support setting frame subtype and reason code when deleting station Date: Wed, 4 May 2016 17:38:57 +0200 Message-Id: <1462376337-26902-1-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-8.9 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 Signed-off-by: Rafa? Mi?ecki --- station.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/station.c b/station.c index 8fdb83a..b29b788 100644 --- a/station.c +++ b/station.c @@ -498,9 +498,68 @@ static int handle_station_get(struct nl80211_state *state, COMMAND(station, get, "", NL80211_CMD_GET_STATION, 0, CIB_NETDEV, handle_station_get, "Get information for a specific station."); -COMMAND(station, del, "", - NL80211_CMD_DEL_STATION, 0, CIB_NETDEV, handle_station_get, - "Remove the given station entry (use with caution!)"); + +static int handle_station_del(struct nl80211_state *state, + struct nl_msg *msg, + int argc, char **argv, + enum id_input id) +{ + char *end; + unsigned char mac_addr[ETH_ALEN]; + int subtype; + int reason_code; + + if (argc < 1) + return 1; + + if (mac_addr_a2n(mac_addr, argv[0])) { + fprintf(stderr, "invalid mac address\n"); + return 2; + } + + argc--; + argv++; + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); + + if (argc > 1 && strcmp(argv[0], "subtype") == 0) { + argv++; + argc--; + + subtype = strtod(argv[0], &end); + if (*end != '\0') + return 1; + + NLA_PUT_U8(msg, NL80211_ATTR_MGMT_SUBTYPE, subtype); + argv++; + argc--; + } + + if (argc > 1 && strcmp(argv[0], "reason-code") == 0) { + argv++; + argc--; + + reason_code = strtod(argv[0], &end); + if (*end != '\0') + return 1; + + NLA_PUT_U16(msg, NL80211_ATTR_REASON_CODE, reason_code); + argv++; + argc--; + } + + if (argc) + return 1; + + register_handler(print_sta_handler, NULL); + + return 0; + nla_put_failure: + return -ENOBUFS; +} +COMMAND(station, del, " [subtype ] [reason-code ]", + NL80211_CMD_DEL_STATION, 0, CIB_NETDEV, handle_station_del, + "Remove the given station entry (use with caution!)\n" + "Example subtype values: 0xA (disassociation), 0xC (deauthentication)"); static const struct cmd *station_set_plink; static const struct cmd *station_set_vlan;