From patchwork Mon May 2 19:55:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Stromdahl X-Patchwork-Id: 8995011 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 1CE119F39D for ; Mon, 2 May 2016 19:55:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A28A201BB for ; Mon, 2 May 2016 19:55:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1783A2026C for ; Mon, 2 May 2016 19:55:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755108AbcEBTzk (ORCPT ); Mon, 2 May 2016 15:55:40 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34111 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754649AbcEBTzi (ORCPT ); Mon, 2 May 2016 15:55:38 -0400 Received: by mail-wm0-f67.google.com with SMTP id n129so316593wmn.1 for ; Mon, 02 May 2016 12:55:37 -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=6EqmqX+CwxFf14f6v4pGjGHRz2ajRa3PWyWlLXwZS78=; b=PtGObLrwKqBkR/Ct8q8cZPNgtF8coCJKVnN7w/8jTVGVWPAiU2/4+AOKHi7Avx7+Go V0olFJn4HCbOpN2SFd9y/svxLdJxtVhuBP3+6rhQKyVoCAhOIHZj6Ezgun+0lGIrJ/nN 7+vPh4PXTY0hGfI+y4clX+3eoyoZIZr/hovUiEqpAgw6n79U06kkY0849A/2yj6CBmin X6bZrFV9ri+i0HfN9UPR49DPqyO2oueE0E+mIDELgzbj+6/jj0kGho+JrHpCIDZTY33A r6D+POXCQz3PSS7GR57f6rHMKxXVaBUXr6aNa3RDXkvB5qMgRq8nYnjfrEplPqj5qX8q lQXw== 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; bh=6EqmqX+CwxFf14f6v4pGjGHRz2ajRa3PWyWlLXwZS78=; b=SPRe9Xe0HkZzsqGlS5GDkfRQ+9tCDchOkBq5lhcD6unAmBF7a8gvuQLgESezTI6TYF APO504EJcrQGVCchCu2DhNjKzZoXRveJvDLhtvdT7uJ7WmpAKcB8uCB/eULjUIx2ddlx N82SfR7LTShkz67bSEJ6XKLF1a5hL/ILJynhFhLaqxs45eR4iIWmlSS8OVBaXvn2lTJK 8PbNqlVTtpk1S6ycfLuWClI6Y4y6N3VftCz816pvApG+mF1xy/PqoOtqjUBJoLDSGoTK ZiMFbJqQTZi5ZMnU+cmvLJaKqwyUbKexGxAoaCeBM/swZ/WDC+VudDTmvW14nO+U8tsw I20g== X-Gm-Message-State: AOPr4FXCyFVlUVtaaguNRJ/FvZHZV+/60aZAsrj00AQbOMVmGLnXD4eUeTb8+h8Bzlbaaw== X-Received: by 10.194.48.33 with SMTP id i1mr43363021wjn.53.1462218936984; Mon, 02 May 2016 12:55:36 -0700 (PDT) Received: from erik-desktop.lan (78-72-170-171-no25.tbcn.telia.com. [78.72.170.171]) by smtp.gmail.com with ESMTPSA id w3sm32104611wjt.0.2016.05.02.12.55.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 May 2016 12:55:36 -0700 (PDT) From: Erik Stromdahl To: johannes@sipsolutions.net, johannes.berg@intel.com, linux-wireless@vger.kernel.org Cc: Erik Stromdahl Subject: [PATCH] iw: add vendor command response support Date: Mon, 2 May 2016 21:55:30 +0200 Message-Id: <1462218930-6300-1-git-send-email-erik.stromdahl@gmail.com> X-Mailer: git-send-email 1.7.9.5 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 Introduced two new commands for reading vendor command responses: recv and recvbin Both will send a vendor command (typically some kind of GET request) in the same way as the current send command and print the received response in ASCII or binary. Signed-off-by: Erik Stromdahl --- vendor.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/vendor.c b/vendor.c index 279aac5..860cd48 100644 --- a/vendor.c +++ b/vendor.c @@ -12,6 +12,33 @@ SECTION(vendor); +static int print_vendor_response(struct nl_msg *msg, void *arg) +{ + struct nlattr *attr; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + bool print_ascii = (bool) arg; + uint8_t *data; + int len; + + attr = nla_find(genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), + NL80211_ATTR_VENDOR_DATA); + if (!attr) { + fprintf(stderr, "vendor data attribute missing!\n"); + return NL_SKIP; + } + + data = (uint8_t *) nla_data(attr); + len = nla_len(attr); + + if (print_ascii) + iw_hexdump("vendor response", data, len); + else + fwrite(data, 1, len, stdout); + + return NL_OK; +} + static int read_file(FILE *file, char *buf, size_t size) { size_t count = 0; @@ -96,4 +123,22 @@ nla_put_failure: return -ENOBUFS; } +static int handle_vendor_recv(struct nl80211_state *state, + struct nl_msg *msg, int argc, + char **argv, enum id_input id) +{ + register_handler(print_vendor_response, (void *) true); + return handle_vendor(state, msg, argc, argv, id); +} + +static int handle_vendor_recv_bin(struct nl80211_state *state, + struct nl_msg *msg, int argc, + char **argv, enum id_input id) +{ + register_handler(print_vendor_response, (void *) false); + return handle_vendor(state, msg, argc, argv, id); +} + COMMAND(vendor, send, " ", NL80211_CMD_VENDOR, 0, CIB_NETDEV, handle_vendor, ""); +COMMAND(vendor, recv, " ", NL80211_CMD_VENDOR, 0, CIB_NETDEV, handle_vendor_recv, ""); +COMMAND(vendor, recvbin, " ", NL80211_CMD_VENDOR, 0, CIB_NETDEV, handle_vendor_recv_bin, "");