From: Erik Stromdahl <erik.stromdahl@gmail.com>
To: johannes@sipsolutions.net, johannes.berg@intel.com,
linux-wireless@vger.kernel.org
Cc: Erik Stromdahl <erik.stromdahl@gmail.com>
Subject: [PATCH] iw: add vendor command response support
Date: Mon, 2 May 2016 21:55:30 +0200 [thread overview]
Message-ID: <1462218930-6300-1-git-send-email-erik.stromdahl@gmail.com> (raw)
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 <erik.stromdahl@gmail.com>
---
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, "<oui> <subcmd> <filename|-|hex data>", NL80211_CMD_VENDOR, 0, CIB_NETDEV, handle_vendor, "");
+COMMAND(vendor, recv, "<oui> <subcmd> <filename|-|hex data>", NL80211_CMD_VENDOR, 0, CIB_NETDEV, handle_vendor_recv, "");
+COMMAND(vendor, recvbin, "<oui> <subcmd> <filename|-|hex data>", NL80211_CMD_VENDOR, 0, CIB_NETDEV, handle_vendor_recv_bin, "");
--
1.7.9.5
next reply other threads:[~2016-05-02 19:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-02 19:55 Erik Stromdahl [this message]
2016-05-31 9:42 ` [PATCH] iw: add vendor command response support Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462218930-6300-1-git-send-email-erik.stromdahl@gmail.com \
--to=erik.stromdahl@gmail.com \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).