[pkg-wpa-devel] r1540 - in /iw/branches/upstream/current: Makefile connect.c cqm.c event.c ibss.c info.c iw.h link.c nl80211.h offch.c phy.c ps.c scan.c util.c version.sh
slh-guest at users.alioth.debian.org
slh-guest at users.alioth.debian.org
Tue Jul 20 13:37:56 UTC 2010
Author: slh-guest
Date: Tue Jul 20 13:37:49 2010
New Revision: 1540
URL: http://svn.debian.org/wsvn/?sc=1&rev=1540
Log:
[svn-upgrade] new version iw (0.9.20)
Added:
iw/branches/upstream/current/cqm.c
iw/branches/upstream/current/offch.c
iw/branches/upstream/current/ps.c
Modified:
iw/branches/upstream/current/Makefile
iw/branches/upstream/current/connect.c
iw/branches/upstream/current/event.c
iw/branches/upstream/current/ibss.c
iw/branches/upstream/current/info.c
iw/branches/upstream/current/iw.h
iw/branches/upstream/current/link.c
iw/branches/upstream/current/nl80211.h
iw/branches/upstream/current/phy.c
iw/branches/upstream/current/scan.c
iw/branches/upstream/current/util.c
iw/branches/upstream/current/version.sh
Modified: iw/branches/upstream/current/Makefile
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/Makefile?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/Makefile (original)
+++ iw/branches/upstream/current/Makefile Tue Jul 20 13:37:49 2010
@@ -17,7 +17,7 @@
OBJS = iw.o genl.o event.o info.o phy.o \
interface.o ibss.o station.o survey.o util.o \
mesh.o mpath.o scan.o reg.o version.o \
- reason.o status.o connect.o link.o
+ reason.o status.o connect.o link.o offch.o ps.o cqm.o
OBJS += sections.o
ALL = iw
@@ -86,10 +86,10 @@
install: iw iw.8.gz
@$(NQ) ' INST iw'
$(Q)$(MKDIR) $(DESTDIR)$(SBINDIR)
- $(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(SBINDIR) iw
+ $(Q)$(INSTALL) -m 755 iw $(DESTDIR)$(SBINDIR)
@$(NQ) ' INST iw.8'
$(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man8/
- $(Q)$(INSTALL) -m 644 -t $(DESTDIR)$(MANDIR)/man8/ iw.8.gz
+ $(Q)$(INSTALL) -m 644 iw.8.gz $(DESTDIR)$(MANDIR)/man8/
clean:
$(Q)rm -f iw *.o *~ *.gz version.c *-stamp
Modified: iw/branches/upstream/current/connect.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/connect.c?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/connect.c (original)
+++ iw/branches/upstream/current/connect.c Tue Jul 20 13:37:49 2010
@@ -95,6 +95,11 @@
conn_argv = calloc(conn_argc, sizeof(*conn_argv));
if (!conn_argv)
return -ENOMEM;
+
+ err = __prepare_listen_events(state);
+ if (err)
+ return err;
+
conn_argv[0] = dev;
conn_argv[1] = "connect";
conn_argv[2] = "establish";
@@ -111,26 +116,25 @@
/*
* WARNING: DO NOT COPY THIS CODE INTO YOUR APPLICATION
*
- * This code has a bug, which requires creating a separate
- * nl80211 socket to fix:
- * It is possible for a NL80211_CMD_NEW_SCAN_RESULTS or
- * NL80211_CMD_SCAN_ABORTED message to be sent by the kernel
- * before (!) we listen to it, because we only start listening
- * after we send our scan request.
+ * This code has a bug:
*
- * Doing it the other way around has a race condition as well,
- * if you first open the events socket you may get a notification
- * for a previous scan.
+ * It is possible for a connect result message from another
+ * connect attempt to be processed here first, because we
+ * start listening to the multicast group before starting
+ * our own connect request, which may succeed but we get a
+ * fail message from a previous attempt that raced with us,
+ * or similar.
*
* The only proper way to fix this would be to listen to events
* before sending the command, and for the kernel to send the
- * connect request along with the event, so that you can match
- * up whether the connect _you_ requested was finished or aborted.
+ * connect request or a cookie along with the event, so that you
+ * can match up whether the connect _you_ requested was finished
+ * or aborted.
*
* Alas, the kernel doesn't do that (yet).
*/
- __listen_events(state, ARRAY_SIZE(cmds), cmds, &printargs);
+ __do_listen_events(state, ARRAY_SIZE(cmds), cmds, &printargs);
return 0;
}
TOPLEVEL(connect, "[-w] <SSID> [<freq in MHz>] [<bssid>] [key 0:abcde d:1:6162636465]",
Added: iw/branches/upstream/current/cqm.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/cqm.c?rev=1540&op=file
==============================================================================
--- iw/branches/upstream/current/cqm.c (added)
+++ iw/branches/upstream/current/cqm.c Tue Jul 20 13:37:49 2010
@@ -1,0 +1,54 @@
+#include <errno.h>
+
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+#include "nl80211.h"
+#include "iw.h"
+
+static int iw_cqm_rssi(struct nl80211_state *state, struct nl_cb *cb,
+ struct nl_msg *msg, int argc, char **argv)
+{
+ struct nl_msg *cqm = NULL;
+ int thold = 0;
+ int hyst = 0;
+ int ret = -ENOSPC;
+
+ /* get the required args */
+ if (argc < 1 || argc > 2)
+ return 1;
+
+ if (strcmp(argv[0], "off")) {
+ thold = atoi(argv[0]);
+
+ if (thold == 0)
+ return -EINVAL;
+
+ if (argc == 2)
+ hyst = atoi(argv[1]);
+ }
+
+ /* connection quality monitor attributes */
+ cqm = nlmsg_alloc();
+
+ NLA_PUT_U32(cqm, NL80211_ATTR_CQM_RSSI_THOLD, thold);
+ NLA_PUT_U32(cqm, NL80211_ATTR_CQM_RSSI_HYST, hyst);
+
+ nla_put_nested(msg, NL80211_ATTR_CQM, cqm);
+ ret = 0;
+
+ nla_put_failure:
+ nlmsg_free(cqm);
+ return ret;
+}
+
+TOPLEVEL(cqm, "",
+ 0, 0, CIB_NETDEV, NULL,
+ "Configure the WLAN connection quality monitor.\n");
+
+COMMAND(cqm, rssi, "<threshold|off> [<hysteresis>]",
+ NL80211_CMD_SET_CQM, 0, CIB_NETDEV, iw_cqm_rssi,
+ "Set connection quality monitor RSSI threshold.\n");
Modified: iw/branches/upstream/current/event.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/event.c?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/event.c (original)
+++ iw/branches/upstream/current/event.c Tue Jul 20 13:37:49 2010
@@ -99,6 +99,34 @@
printf(" %.02x", frame[i]);
printf("]");
}
+
+static void parse_cqm_event(struct nlattr *tb)
+{
+ static struct nla_policy cqm_policy[NL80211_ATTR_CQM_MAX + 1] = {
+ [NL80211_ATTR_CQM_RSSI_THOLD] = { .type = NLA_U32 },
+ [NL80211_ATTR_CQM_RSSI_HYST] = { .type = NLA_U32 },
+ [NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT] = { .type = NLA_U32 },
+ };
+ struct nlattr *cqm[NL80211_ATTR_CQM_MAX + 1];
+
+ printf("connection quality monitor event: ");
+
+ if (!tb || nla_parse_nested(cqm, NL80211_ATTR_CQM_MAX, tb, cqm_policy)) {
+ printf("missing data!\n");
+ return;
+ }
+
+ if (cqm[NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT]) {
+ enum nl80211_cqm_rssi_threshold_event rssi_event;
+ rssi_event = nla_get_u32(cqm[NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT]);
+ if (rssi_event == NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH)
+ printf("RSSI went above threshold");
+ else
+ printf("RSSI went below threshold");
+ }
+ printf("\n");
+}
+
static int print_event(struct nl_msg *msg, void *arg)
{
@@ -302,6 +330,20 @@
get_reason_str(nla_get_u16(tb[NL80211_ATTR_REASON_CODE])));
printf("\n");
break;
+ case NL80211_CMD_REMAIN_ON_CHANNEL:
+ printf("remain on freq %d (%dms, cookie %llx)\n",
+ nla_get_u32(tb[NL80211_ATTR_WIPHY_FREQ]),
+ nla_get_u32(tb[NL80211_ATTR_DURATION]),
+ (unsigned long long)nla_get_u64(tb[NL80211_ATTR_COOKIE]));
+ break;
+ case NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL:
+ printf("done with remain on freq %d (cookie %llx)\n",
+ nla_get_u32(tb[NL80211_ATTR_WIPHY_FREQ]),
+ (unsigned long long)nla_get_u64(tb[NL80211_ATTR_COOKIE]));
+ break;
+ case NL80211_CMD_NOTIFY_CQM:
+ parse_cqm_event(tb[NL80211_ATTR_CQM]);
+ break;
default:
printf("unknown event %d\n", gnlh->cmd);
break;
@@ -335,18 +377,9 @@
return NL_SKIP;
}
-__u32 __listen_events(struct nl80211_state *state,
- const int n_waits, const __u32 *waits,
- struct print_event_args *args)
+int __prepare_listen_events(struct nl80211_state *state)
{
int mcid, ret;
- struct nl_cb *cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
- struct wait_event wait_ev;
-
- if (!cb) {
- fprintf(stderr, "failed to allocate netlink callbacks\n");
- return -ENOMEM;
- }
/* Configuration multicast group */
mcid = nl_get_multicast_id(state->nl_sock, "nl80211", "config");
@@ -379,6 +412,21 @@
ret = nl_socket_add_membership(state->nl_sock, mcid);
if (ret)
return ret;
+ }
+
+ return 0;
+}
+
+__u32 __do_listen_events(struct nl80211_state *state,
+ const int n_waits, const __u32 *waits,
+ struct print_event_args *args)
+{
+ struct nl_cb *cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
+ struct wait_event wait_ev;
+
+ if (!cb) {
+ fprintf(stderr, "failed to allocate netlink callbacks\n");
+ return -ENOMEM;
}
/* no sequence checking for multicast messages */
@@ -405,7 +453,13 @@
__u32 listen_events(struct nl80211_state *state,
const int n_waits, const __u32 *waits)
{
- return __listen_events(state, n_waits, waits, NULL);
+ int ret;
+
+ ret = __prepare_listen_events(state);
+ if (ret)
+ return ret;
+
+ return __do_listen_events(state, n_waits, waits, NULL);
}
static int print_events(struct nl80211_state *state,
@@ -414,6 +468,7 @@
int argc, char **argv)
{
struct print_event_args args;
+ int ret;
memset(&args, 0, sizeof(args));
@@ -434,7 +489,11 @@
if (argc)
return 1;
- return __listen_events(state, 0, NULL, &args);
+ ret = __prepare_listen_events(state);
+ if (ret)
+ return ret;
+
+ return __do_listen_events(state, 0, NULL, &args);
}
TOPLEVEL(event, "[-t] [-f]", 0, 0, CIB_NONE, print_events,
"Monitor events from the kernel.\n"
Modified: iw/branches/upstream/current/ibss.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/ibss.c?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/ibss.c (original)
+++ iw/branches/upstream/current/ibss.c Tue Jul 20 13:37:49 2010
@@ -18,6 +18,10 @@
{
char *end;
unsigned char abssid[6];
+ unsigned char rates[NL80211_MAX_SUPP_RATES];
+ int n_rates = 0;
+ char *value = NULL, *sptr = NULL;
+ float rate;
if (argc < 2)
return 1;
@@ -49,6 +53,32 @@
}
}
+ /* basic rates */
+ if (argc > 1 && strcmp(argv[0], "basic-rates") == 0) {
+ argv++;
+ argc--;
+
+ value = strtok_r(argv[0], ",", &sptr);
+
+ while (value && n_rates < NL80211_MAX_SUPP_RATES) {
+ rate = strtod(value, &end);
+ rates[n_rates] = rate * 2;
+
+ /* filter out suspicious values */
+ if (*end != '\0' || !rates[n_rates] ||
+ rate*2 != rates[n_rates])
+ return 1;
+
+ n_rates++;
+ value = strtok_r(NULL, ",", &sptr);
+ }
+
+ NLA_PUT(msg, NL80211_ATTR_BSS_BASIC_RATES, n_rates, rates);
+
+ argv++;
+ argc--;
+ }
+
if (!argc)
return 0;
@@ -73,7 +103,9 @@
COMMAND(ibss, leave, NULL,
NL80211_CMD_LEAVE_IBSS, 0, CIB_NETDEV, leave_ibss,
"Leave the current IBSS cell.");
-COMMAND(ibss, join, "<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>] [key d:0:abcde]",
+COMMAND(ibss, join,
+ "<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>] "
+ "[basic-rates <rate in Mbps,rate2,...>] [key d:0:abcde]",
NL80211_CMD_JOIN_IBSS, 0, CIB_NETDEV, join_ibss,
"Join the IBSS cell with the given SSID, if it doesn't exist create\n"
"it on the given frequency. When fixed frequency is requested, don't\n"
Modified: iw/branches/upstream/current/info.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/info.c?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/info.c (original)
+++ iw/branches/upstream/current/info.c Tue Jul 20 13:37:49 2010
@@ -139,6 +139,9 @@
if (tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS])
printf("\tmax # scan SSIDs: %d\n",
nla_get_u8(tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]));
+ if (tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN])
+ printf("\tmax scan IEs length: %d bytes\n",
+ nla_get_u32(tb_msg[NL80211_ATTR_MAX_SCAN_IE_LEN]));
if (tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) {
unsigned int frag;
@@ -154,6 +157,14 @@
rts = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]);
if (rts != (unsigned int)-1)
printf("\tRTS threshold: %d\n", rts);
+ }
+
+ if (tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) {
+ unsigned char coverage;
+
+ coverage = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]);
+ /* See handle_distance() for an explanation where the '450' comes from */
+ printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
}
if (!tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES])
Modified: iw/branches/upstream/current/iw.h
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/iw.h?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/iw.h (original)
+++ iw/branches/upstream/current/iw.h Tue Jul 20 13:37:49 2010
@@ -110,13 +110,15 @@
__u32 listen_events(struct nl80211_state *state,
const int n_waits, const __u32 *waits);
-__u32 __listen_events(struct nl80211_state *state,
- const int n_waits, const __u32 *waits,
- struct print_event_args *args);
+int __prepare_listen_events(struct nl80211_state *state);
+__u32 __do_listen_events(struct nl80211_state *state,
+ const int n_waits, const __u32 *waits,
+ struct print_event_args *args);
int mac_addr_a2n(unsigned char *mac_addr, char *arg);
void mac_addr_n2a(char *mac_addr, unsigned char *arg);
+unsigned char *parse_hex(char *hex, size_t *outlen);
int parse_keys(struct nl_msg *msg, char **argv, int argc);
Modified: iw/branches/upstream/current/link.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/link.c?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/link.c (original)
+++ iw/branches/upstream/current/link.c Tue Jul 20 13:37:49 2010
@@ -70,6 +70,9 @@
case NL80211_BSS_STATUS_AUTHENTICATED:
printf("Authenticated with %s (on %s)\n", mac_addr, dev);
return NL_SKIP;
+ case NL80211_BSS_STATUS_IBSS_JOINED:
+ printf("Joined IBSS %s (on %s)\n", mac_addr, dev);
+ break;
default:
return NL_SKIP;
}
Modified: iw/branches/upstream/current/nl80211.h
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/nl80211.h?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/nl80211.h (original)
+++ iw/branches/upstream/current/nl80211.h Tue Jul 20 13:37:49 2010
@@ -3,7 +3,7 @@
/*
* 802.11 netlink interface public header
*
- * Copyright 2006, 2007, 2008 Johannes Berg <johannes at sipsolutions.net>
+ * Copyright 2006-2010 Johannes Berg <johannes at sipsolutions.net>
* Copyright 2008 Michael Wu <flamingice at sourmilk.net>
* Copyright 2008 Luis Carlos Cobo <luisca at cozybit.com>
* Copyright 2008 Michael Buesch <mb at bu3sch.de>
@@ -52,6 +52,8 @@
* %NL80211_ATTR_WIPHY_CHANNEL_TYPE, %NL80211_ATTR_WIPHY_RETRY_SHORT,
* %NL80211_ATTR_WIPHY_RETRY_LONG, %NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
* and/or %NL80211_ATTR_WIPHY_RTS_THRESHOLD.
+ * However, for setting the channel, see %NL80211_CMD_SET_CHANNEL
+ * instead, the support here is for backward compatibility only.
* @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request
* or rename notification. Has attributes %NL80211_ATTR_WIPHY and
* %NL80211_ATTR_WIPHY_NAME.
@@ -130,7 +132,7 @@
* %NL80211_ATTR_REG_RULE_POWER_MAX_ANT_GAIN and
* %NL80211_ATTR_REG_RULE_POWER_MAX_EIRP.
* @NL80211_CMD_REQ_SET_REG: ask the wireless core to set the regulatory domain
- * to the the specified ISO/IEC 3166-1 alpha2 country code. The core will
+ * to the specified ISO/IEC 3166-1 alpha2 country code. The core will
* store this as a valid request and then query userspace for it.
*
* @NL80211_CMD_GET_MESH_PARAMS: Get mesh networking properties for the
@@ -270,6 +272,75 @@
* @NL80211_CMD_SET_WIPHY_NETNS: Set a wiphy's netns. Note that all devices
* associated with this wiphy must be down and will follow.
*
+ * @NL80211_CMD_REMAIN_ON_CHANNEL: Request to remain awake on the specified
+ * channel for the specified amount of time. This can be used to do
+ * off-channel operations like transmit a Public Action frame and wait for
+ * a response while being associated to an AP on another channel.
+ * %NL80211_ATTR_WIPHY or %NL80211_ATTR_IFINDEX is used to specify which
+ * radio is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the
+ * frequency for the operation and %NL80211_ATTR_WIPHY_CHANNEL_TYPE may be
+ * optionally used to specify additional channel parameters.
+ * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds
+ * to remain on the channel. This command is also used as an event to
+ * notify when the requested duration starts (it may take a while for the
+ * driver to schedule this time due to other concurrent needs for the
+ * radio).
+ * When called, this operation returns a cookie (%NL80211_ATTR_COOKIE)
+ * that will be included with any events pertaining to this request;
+ * the cookie is also used to cancel the request.
+ * @NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL: This command can be used to cancel a
+ * pending remain-on-channel duration if the desired operation has been
+ * completed prior to expiration of the originally requested duration.
+ * %NL80211_ATTR_WIPHY or %NL80211_ATTR_IFINDEX is used to specify the
+ * radio. The %NL80211_ATTR_COOKIE attribute must be given as well to
+ * uniquely identify the request.
+ * This command is also used as an event to notify when a requested
+ * remain-on-channel duration has expired.
+ *
+ * @NL80211_CMD_SET_TX_BITRATE_MASK: Set the mask of rates to be used in TX
+ * rate selection. %NL80211_ATTR_IFINDEX is used to specify the interface
+ * and @NL80211_ATTR_TX_RATES the set of allowed rates.
+ *
+ * @NL80211_CMD_REGISTER_ACTION: Register for receiving certain action frames
+ * (via @NL80211_CMD_ACTION) for processing in userspace. This command
+ * requires an interface index and a match attribute containing the first
+ * few bytes of the frame that should match, e.g. a single byte for only
+ * a category match or four bytes for vendor frames including the OUI.
+ * The registration cannot be dropped, but is removed automatically
+ * when the netlink socket is closed. Multiple registrations can be made.
+ * @NL80211_CMD_ACTION: Action frame TX request and RX notification. This
+ * command is used both as a request to transmit an Action frame and as an
+ * event indicating reception of an Action frame that was not processed in
+ * kernel code, but is for us (i.e., which may need to be processed in a
+ * user space application). %NL80211_ATTR_FRAME is used to specify the
+ * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ (and
+ * optionally %NL80211_ATTR_WIPHY_CHANNEL_TYPE) is used to indicate on
+ * which channel the frame is to be transmitted or was received. This
+ * channel has to be the current channel (remain-on-channel or the
+ * operational channel). When called, this operation returns a cookie
+ * (%NL80211_ATTR_COOKIE) that will be included with the TX status event
+ * pertaining to the TX request.
+ * @NL80211_CMD_ACTION_TX_STATUS: Report TX status of an Action frame
+ * transmitted with %NL80211_CMD_ACTION. %NL80211_ATTR_COOKIE identifies
+ * the TX command and %NL80211_ATTR_FRAME includes the contents of the
+ * frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged
+ * the frame.
+ * @NL80211_CMD_SET_CQM: Connection quality monitor configuration. This command
+ * is used to configure connection quality monitoring notification trigger
+ * levels.
+ * @NL80211_CMD_NOTIFY_CQM: Connection quality monitor notification. This
+ * command is used as an event to indicate the that a trigger level was
+ * reached.
+ * @NL80211_CMD_SET_CHANNEL: Set the channel (using %NL80211_ATTR_WIPHY_FREQ
+ * and %NL80211_ATTR_WIPHY_CHANNEL_TYPE) the given interface (identifed
+ * by %NL80211_ATTR_IFINDEX) shall operate on.
+ * In case multiple channels are supported by the device, the mechanism
+ * with which it switches channels is implementation-defined.
+ * When a monitor interface is given, it can only switch channel while
+ * no other interfaces are operating to avoid disturbing the operation
+ * of any other interfaces, and other interfaces will again take
+ * precedence when they are used.
+ *
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
*/
@@ -348,6 +419,27 @@
NL80211_CMD_GET_SURVEY,
NL80211_CMD_NEW_SURVEY_RESULTS,
+
+ NL80211_CMD_SET_PMKSA,
+ NL80211_CMD_DEL_PMKSA,
+ NL80211_CMD_FLUSH_PMKSA,
+
+ NL80211_CMD_REMAIN_ON_CHANNEL,
+ NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL,
+
+ NL80211_CMD_SET_TX_BITRATE_MASK,
+
+ NL80211_CMD_REGISTER_ACTION,
+ NL80211_CMD_ACTION,
+ NL80211_CMD_ACTION_TX_STATUS,
+
+ NL80211_CMD_SET_POWER_SAVE,
+ NL80211_CMD_GET_POWER_SAVE,
+
+ NL80211_CMD_SET_CQM,
+ NL80211_CMD_NOTIFY_CQM,
+
+ NL80211_CMD_SET_CHANNEL,
/* add new commands above here */
@@ -398,6 +490,8 @@
* @NL80211_ATTR_WIPHY_RTS_THRESHOLD: RTS threshold (TX frames with length
* larger than or equal to this use RTS/CTS handshake); allowed range:
* 0..65536, disable with (u32)-1; dot11RTSThreshold; u32
+ * @NL80211_ATTR_WIPHY_COVERAGE_CLASS: Coverage Class as defined by IEEE 802.11
+ * section 7.3.2.9; dot11CoverageClass; u8
*
* @NL80211_ATTR_IFINDEX: network interface index of the device to operate on
* @NL80211_ATTR_IFNAME: network interface name
@@ -598,6 +692,39 @@
* the survey response for %NL80211_CMD_GET_SURVEY, nested attribute
* containing info as possible, see &enum survey_info.
*
+ * @NL80211_ATTR_PMKID: PMK material for PMKSA caching.
+ * @NL80211_ATTR_MAX_NUM_PMKIDS: maximum number of PMKIDs a firmware can
+ * cache, a wiphy attribute.
+ *
+ * @NL80211_ATTR_DURATION: Duration of an operation in milliseconds, u32.
+ *
+ * @NL80211_ATTR_COOKIE: Generic 64-bit cookie to identify objects.
+ *
+ * @NL80211_ATTR_TX_RATES: Nested set of attributes
+ * (enum nl80211_tx_rate_attributes) describing TX rates per band. The
+ * enum nl80211_band value is used as the index (nla_type() of the nested
+ * data. If a band is not included, it will be configured to allow all
+ * rates based on negotiated supported rates information. This attribute
+ * is used with %NL80211_CMD_SET_TX_BITRATE_MASK.
+ *
+ * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain
+ * at least one byte, currently used with @NL80211_CMD_REGISTER_ACTION.
+ *
+ * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was
+ * acknowledged by the recipient.
+ *
+ * @NL80211_ATTR_CQM: connection quality monitor configuration in a
+ * nested attribute with %NL80211_ATTR_CQM_* sub-attributes.
+ *
+ * @NL80211_ATTR_LOCAL_STATE_CHANGE: Flag attribute to indicate that a command
+ * is requesting a local authentication/association state change without
+ * invoking actual management frame exchange. This can be used with
+ * NL80211_CMD_AUTHENTICATE, NL80211_CMD_DEAUTHENTICATE,
+ * NL80211_CMD_DISASSOCIATE.
+ *
+ * @NL80211_ATTR_AP_ISOLATE: (AP mode) Do not forward traffic between stations
+ * connected to this BSS.
+ *
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
*/
@@ -731,6 +858,29 @@
NL80211_ATTR_4ADDR,
NL80211_ATTR_SURVEY_INFO,
+
+ NL80211_ATTR_PMKID,
+ NL80211_ATTR_MAX_NUM_PMKIDS,
+
+ NL80211_ATTR_DURATION,
+
+ NL80211_ATTR_COOKIE,
+
+ NL80211_ATTR_WIPHY_COVERAGE_CLASS,
+
+ NL80211_ATTR_TX_RATES,
+
+ NL80211_ATTR_FRAME_MATCH,
+
+ NL80211_ATTR_ACK,
+
+ NL80211_ATTR_PS_STATE,
+
+ NL80211_ATTR_CQM,
+
+ NL80211_ATTR_LOCAL_STATE_CHANGE,
+
+ NL80211_ATTR_AP_ISOLATE,
/* add attributes here, update the policy in nl80211.c */
@@ -1312,13 +1462,20 @@
* @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16)
* @NL80211_BSS_CAPABILITY: capability field (CPU order, u16)
* @NL80211_BSS_INFORMATION_ELEMENTS: binary attribute containing the
- * raw information elements from the probe response/beacon (bin)
+ * raw information elements from the probe response/beacon (bin);
+ * if the %NL80211_BSS_BEACON_IES attribute is present, the IEs here are
+ * from a Probe Response frame; otherwise they are from a Beacon frame.
+ * However, if the driver does not indicate the source of the IEs, these
+ * IEs may be from either frame subtype.
* @NL80211_BSS_SIGNAL_MBM: signal strength of probe response/beacon
* in mBm (100 * dBm) (s32)
* @NL80211_BSS_SIGNAL_UNSPEC: signal strength of the probe response/beacon
* in unspecified units, scaled to 0..100 (u8)
* @NL80211_BSS_STATUS: status, if this BSS is "used"
* @NL80211_BSS_SEEN_MS_AGO: age of this BSS entry in ms
+ * @NL80211_BSS_BEACON_IES: binary attribute containing the raw information
+ * elements from a Beacon frame (bin); not present if no Beacon frame has
+ * yet been received
* @__NL80211_BSS_AFTER_LAST: internal
* @NL80211_BSS_MAX: highest BSS attribute
*/
@@ -1334,6 +1491,7 @@
NL80211_BSS_SIGNAL_UNSPEC,
NL80211_BSS_STATUS,
NL80211_BSS_SEEN_MS_AGO,
+ NL80211_BSS_BEACON_IES,
/* keep last */
__NL80211_BSS_AFTER_LAST,
@@ -1431,4 +1589,74 @@
NL80211_KEY_MAX = __NL80211_KEY_AFTER_LAST - 1
};
+/**
+ * enum nl80211_tx_rate_attributes - TX rate set attributes
+ * @__NL80211_TXRATE_INVALID: invalid
+ * @NL80211_TXRATE_LEGACY: Legacy (non-MCS) rates allowed for TX rate selection
+ * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with
+ * 1 = 500 kbps) but without the IE length restriction (at most
+ * %NL80211_MAX_SUPP_RATES in a single array).
+ * @__NL80211_TXRATE_AFTER_LAST: internal
+ * @NL80211_TXRATE_MAX: highest TX rate attribute
+ */
+enum nl80211_tx_rate_attributes {
+ __NL80211_TXRATE_INVALID,
+ NL80211_TXRATE_LEGACY,
+
+ /* keep last */
+ __NL80211_TXRATE_AFTER_LAST,
+ NL80211_TXRATE_MAX = __NL80211_TXRATE_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_band - Frequency band
+ * @NL80211_BAND_2GHZ - 2.4 GHz ISM band
+ * @NL80211_BAND_5GHZ - around 5 GHz band (4.9 - 5.7 GHz)
+ */
+enum nl80211_band {
+ NL80211_BAND_2GHZ,
+ NL80211_BAND_5GHZ,
+};
+
+enum nl80211_ps_state {
+ NL80211_PS_DISABLED,
+ NL80211_PS_ENABLED,
+};
+
+/**
+ * enum nl80211_attr_cqm - connection quality monitor attributes
+ * @__NL80211_ATTR_CQM_INVALID: invalid
+ * @NL80211_ATTR_CQM_RSSI_THOLD: RSSI threshold in dBm. This value specifies
+ * the threshold for the RSSI level at which an event will be sent. Zero
+ * to disable.
+ * @NL80211_ATTR_CQM_RSSI_HYST: RSSI hysteresis in dBm. This value specifies
+ * the minimum amount the RSSI level must change after an event before a
+ * new event may be issued (to reduce effects of RSSI oscillation).
+ * @NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT: RSSI threshold event
+ * @__NL80211_ATTR_CQM_AFTER_LAST: internal
+ * @NL80211_ATTR_CQM_MAX: highest key attribute
+ */
+enum nl80211_attr_cqm {
+ __NL80211_ATTR_CQM_INVALID,
+ NL80211_ATTR_CQM_RSSI_THOLD,
+ NL80211_ATTR_CQM_RSSI_HYST,
+ NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT,
+
+ /* keep last */
+ __NL80211_ATTR_CQM_AFTER_LAST,
+ NL80211_ATTR_CQM_MAX = __NL80211_ATTR_CQM_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_cqm_rssi_threshold_event - RSSI threshold event
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW - The RSSI level is lower than the
+ * configured threshold
+ * @NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH - The RSSI is higher than the
+ * configured threshold
+ */
+enum nl80211_cqm_rssi_threshold_event {
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
+ NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
+};
+
#endif /* __LINUX_NL80211_H */
Added: iw/branches/upstream/current/offch.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/offch.c?rev=1540&op=file
==============================================================================
--- iw/branches/upstream/current/offch.c (added)
+++ iw/branches/upstream/current/offch.c Tue Jul 20 13:37:49 2010
@@ -1,0 +1,43 @@
+#include <errno.h>
+
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+#include "nl80211.h"
+#include "iw.h"
+
+static int offchannel(struct nl80211_state *state, struct nl_cb *cb,
+ struct nl_msg *msg, int argc, char **argv)
+{
+ char *end;
+
+ /* freq */
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ,
+ strtoul(argv[0], &end, 10));
+ if (*end != '\0')
+ return 1;
+ argv++;
+ argc--;
+
+ /* duration */
+ NLA_PUT_U32(msg, NL80211_ATTR_DURATION,
+ strtoul(argv[0], &end, 10));
+ if (*end != '\0')
+ return 1;
+ argv++;
+ argc--;
+
+ if (argc)
+ return 1;
+
+ return 0;
+ nla_put_failure:
+ return -ENOSPC;
+}
+
+TOPLEVEL(offchannel, "<freq> <duration>", NL80211_CMD_REMAIN_ON_CHANNEL, 0,
+ CIB_NETDEV, offchannel,
+ "Leave operating channel and go to the given channel for a while.");
Modified: iw/branches/upstream/current/phy.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/phy.c?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/phy.c (original)
+++ iw/branches/upstream/current/phy.c Tue Jul 20 13:37:49 2010
@@ -31,6 +31,7 @@
static int handle_freqchan(struct nl_msg *msg, bool chan,
int argc, char **argv)
{
+ char *end;
static const struct {
const char *name;
unsigned int val;
@@ -57,7 +58,12 @@
return 1;
}
- freq = strtoul(argv[0], NULL, 10);
+ if (!*argv[0])
+ return 1;
+ freq = strtoul(argv[0], &end, 10);
+ if (*end)
+ return 1;
+
if (chan)
freq = ieee80211_channel_to_frequency(freq);
@@ -104,8 +110,15 @@
if (strcmp("off", argv[0]) == 0)
frag = -1;
- else
- frag = strtoul(argv[0], NULL, 10);
+ else {
+ char *end;
+
+ if (!*argv[0])
+ return 1;
+ frag = strtoul(argv[0], &end, 10);
+ if (*end != '\0')
+ return 1;
+ }
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FRAG_THRESHOLD, frag);
@@ -128,8 +141,15 @@
if (strcmp("off", argv[0]) == 0)
rts = -1;
- else
- rts = strtoul(argv[0], NULL, 10);
+ else {
+ char *end;
+
+ if (!*argv[0])
+ return 1;
+ rts = strtoul(argv[0], &end, 10);
+ if (*end != '\0')
+ return 1;
+ }
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, rts);
@@ -151,6 +171,9 @@
if (argc != 1)
return 1;
+ if (!*argv[0])
+ return 1;
+
NLA_PUT_U32(msg, NL80211_ATTR_PID,
strtoul(argv[0], &end, 10));
@@ -164,3 +187,74 @@
COMMAND(set, netns, "<pid>",
NL80211_CMD_SET_WIPHY_NETNS, 0, CIB_PHY, handle_netns,
"Put this wireless device into a different network namespace");
+
+static int handle_coverage(struct nl80211_state *state,
+ struct nl_cb *cb,
+ struct nl_msg *msg,
+ int argc, char **argv)
+{
+ char *end;
+ unsigned int coverage;
+
+ if (argc != 1)
+ return 1;
+
+ if (!*argv[0])
+ return 1;
+ coverage = strtoul(argv[0], &end, 10);
+ if (coverage > 255)
+ return 1;
+
+ if (*end)
+ return 1;
+
+ NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, coverage);
+
+ return 0;
+ nla_put_failure:
+ return -ENOBUFS;
+}
+COMMAND(set, coverage, "<coverage class>",
+ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_coverage,
+ "Set coverage class (1 for every 3 usec of air propagation time).\n"
+ "Valid values: 0 - 255.");
+
+static int handle_distance(struct nl80211_state *state,
+ struct nl_cb *cb,
+ struct nl_msg *msg,
+ int argc, char **argv)
+{
+ char *end;
+ unsigned int distance, coverage;
+
+ if (argc != 1)
+ return 1;
+
+ if (!*argv[0])
+ return 1;
+
+ distance = strtoul(argv[0], &end, 10);
+
+ if (*end)
+ return 1;
+
+ /*
+ * Divide double the distance by the speed of light in m/usec (300) to
+ * get round-trip time in microseconds and then divide the result by
+ * three to get coverage class as specified in IEEE 802.11-2007 table
+ * 7-27. Values are rounded upwards.
+ */
+ coverage = (distance + 449) / 450;
+ if (coverage > 255)
+ return 1;
+
+ NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, coverage);
+
+ return 0;
+ nla_put_failure:
+ return -ENOBUFS;
+}
+COMMAND(set, distance, "<distance>",
+ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_distance,
+ "Set appropriate coverage class for given link distance in meters.\n"
+ "Valid values: 0 - 114750");
Added: iw/branches/upstream/current/ps.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/ps.c?rev=1540&op=file
==============================================================================
--- iw/branches/upstream/current/ps.c (added)
+++ iw/branches/upstream/current/ps.c Tue Jul 20 13:37:49 2010
@@ -1,0 +1,83 @@
+#include <errno.h>
+#include <string.h>
+
+#include <netlink/genl/genl.h>
+#include <netlink/msg.h>
+#include <netlink/attr.h>
+
+#include "nl80211.h"
+#include "iw.h"
+
+static int set_power_save(struct nl80211_state *state,
+ struct nl_cb *cb,
+ struct nl_msg *msg,
+ int argc, char **argv)
+{
+ enum nl80211_ps_state ps_state;
+
+ if (argc != 1) {
+ printf("Invalid parameters!\n");
+ return 2;
+ }
+
+ if (strcmp(argv[0], "on") == 0)
+ ps_state = NL80211_PS_ENABLED;
+ else if (strcmp(argv[0], "off") == 0)
+ ps_state = NL80211_PS_DISABLED;
+ else {
+ printf("Invalid parameter: %s\n", argv[0]);
+ return 2;
+ }
+
+ NLA_PUT_U32(msg, NL80211_ATTR_PS_STATE, ps_state);
+
+ return 0;
+
+ nla_put_failure:
+ return -ENOBUFS;
+}
+
+COMMAND(set, power_save, "<on|off>",
+ NL80211_CMD_SET_POWER_SAVE, 0, CIB_NETDEV, set_power_save,
+ "Set power save state to on or off.");
+
+static int print_power_save_handler(struct nl_msg *msg, void *arg)
+{
+ struct nlattr *attrs[NL80211_ATTR_MAX + 1];
+ struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+ const char *s;
+
+ nla_parse(attrs, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL);
+
+ if (!attrs[NL80211_ATTR_PS_STATE])
+ return NL_SKIP;
+
+ switch (nla_get_u32(attrs[NL80211_ATTR_PS_STATE])) {
+ case NL80211_PS_ENABLED:
+ s = "on";
+ break;
+ case NL80211_PS_DISABLED:
+ default:
+ s = "off";
+ break;
+ }
+
+ printf("Power save: %s\n", s);
+
+ return NL_SKIP;
+}
+
+static int get_power_save(struct nl80211_state *state,
+ struct nl_cb *cb,
+ struct nl_msg *msg,
+ int argc, char **argv)
+{
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
+ print_power_save_handler, NULL);
+ return 0;
+}
+
+COMMAND(get, power_save, "<param>",
+ NL80211_CMD_GET_POWER_SAVE, 0, CIB_NETDEV, get_power_save,
+ "Retrieve power save state.");
Modified: iw/branches/upstream/current/scan.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/scan.c?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/scan.c (original)
+++ iw/branches/upstream/current/scan.c Tue Jul 20 13:37:49 2010
@@ -33,7 +33,25 @@
struct scan_params {
bool unknown;
enum print_ie_type type;
+ bool show_both_ie_sets;
};
+
+#define IEEE80211_COUNTRY_EXTENSION_ID 201
+
+struct ieee80211_country_ie_triplet {
+ union {
+ struct {
+ __u8 first_channel;
+ __u8 num_channels;
+ __s8 max_power;
+ } __attribute__ ((packed)) chans;
+ struct {
+ __u8 reg_extension_id;
+ __u8 reg_class;
+ __u8 coverage_class;
+ } __attribute__ ((packed)) ext;
+ };
+} __attribute__ ((packed));
static int handle_scan(struct nl80211_state *state,
struct nl_cb *cb,
@@ -47,11 +65,14 @@
enum {
NONE,
FREQ,
+ IES,
SSID,
DONE,
} parse = NONE;
int freq;
bool passive = false, have_ssids = false, have_freqs = false;
+ size_t tmp;
+ unsigned char *ies;
ssids = nlmsg_alloc();
if (!ssids)
@@ -64,22 +85,24 @@
}
for (i = 0; i < argc; i++) {
- if (parse == NONE && strcmp(argv[i], "freq") == 0) {
- parse = FREQ;
- have_freqs = true;
- continue;
- } else if (parse < SSID && strcmp(argv[i], "ssid") == 0) {
- parse = SSID;
- have_ssids = true;
- continue;
- } else if (parse < SSID && strcmp(argv[i], "passive") == 0) {
- parse = DONE;
- passive = true;
- continue;
- }
-
switch (parse) {
case NONE:
+ if (strcmp(argv[i], "freq") == 0) {
+ parse = FREQ;
+ have_freqs = true;
+ break;
+ } else if (strcmp(argv[i], "ies") == 0) {
+ parse = IES;
+ break;
+ } else if (strcmp(argv[i], "ssid") == 0) {
+ parse = SSID;
+ have_ssids = true;
+ break;
+ } else if (strcmp(argv[i], "passive") == 0) {
+ parse = DONE;
+ passive = true;
+ break;
+ }
case DONE:
return 1;
case FREQ:
@@ -87,6 +110,15 @@
if (eptr != argv[i] + strlen(argv[i]))
return 1;
NLA_PUT_U32(freqs, i, freq);
+ parse = NONE;
+ break;
+ case IES:
+ ies = parse_hex(argv[i], &tmp);
+ if (!ies)
+ goto nla_put_failure;
+ NLA_PUT(msg, NL80211_ATTR_IE, tmp, ies);
+ free(ies);
+ parse = NONE;
break;
case SSID:
NLA_PUT(ssids, i, strlen(argv[i]), argv[i]);
@@ -142,29 +174,64 @@
printf(" channel %d\n", data[0]);
}
+static const char *country_env_str(char environment)
+{
+ switch (environment) {
+ case 'I':
+ return "Indoor only";
+ case 'O':
+ return "Outdoor only";
+ case ' ':
+ return "Indoor/Outdoor";
+ default:
+ return "bogus";
+ }
+}
+
static void print_country(const uint8_t type, uint8_t len, const uint8_t *data)
{
- int i;
-
printf(" %.*s", 2, data);
- switch (data[2]) {
- case 'I':
- printf(" (indoor)");
- break;
- case 'O':
- printf(" (outdoor)");
- break;
- case ' ':
- printf(" (in/outdoor)");
- break;
- default:
- printf(" (invalid environment)");
- break;
- }
- printf(", data:");
- for(i=0; i<len-3; i++)
- printf(" %.02x", data[i + 3]);
- printf("\n");
+
+ printf("\tEnvironment: %s\n", country_env_str(data[2]));
+
+ data += 3;
+ len -= 3;
+
+ if (len < 3) {
+ printf("\t\tNo country IE triplets present\n");
+ return;
+ }
+
+ while (len >= 3) {
+ int end_channel;
+ struct ieee80211_country_ie_triplet *triplet =
+ (struct ieee80211_country_ie_triplet *) data;
+
+ if (triplet->ext.reg_extension_id >= IEEE80211_COUNTRY_EXTENSION_ID) {
+ printf("\t\tExtension ID: %d Regulatory Class: %d Coverage class: %d (up to %dm)\n",
+ triplet->ext.reg_extension_id,
+ triplet->ext.reg_class,
+ triplet->ext.coverage_class,
+ triplet->ext.coverage_class * 450);
+
+ data += 3;
+ len -= 3;
+ continue;
+ }
+
+ /* 2 GHz */
+ if (triplet->chans.first_channel <= 14)
+ end_channel = triplet->chans.first_channel + (triplet->chans.num_channels - 1);
+ else
+ end_channel = triplet->chans.first_channel + (4 * (triplet->chans.num_channels - 1));
+
+ printf("\t\tChannels [%d - %d]\n", triplet->chans.first_channel, end_channel);
+
+ data += 3;
+ len -= 3;
+ }
+
+ return;
}
static void print_powerconstraint(const uint8_t type, uint8_t len, const uint8_t *data)
@@ -430,7 +497,7 @@
printf("\n");
print_ht_capability(data[0] | (data[1] << 8));
print_ampdu_length(data[2] & 3);
- print_ampdu_spacing((data[2] >> 2) & 3);
+ print_ampdu_spacing((data[2] >> 2) & 7);
print_ht_mcs(data + 3);
}
@@ -481,6 +548,16 @@
}
}
+ printf("\n");
+}
+
+static void print_tim(const uint8_t type, uint8_t len, const uint8_t *data)
+{
+ printf(" DTIM Count %u DTIM Period %u Bitmap Control 0x%x "
+ "Bitmap[0] 0x%x",
+ data[0], data[1], data[2], data[3]);
+ if (len - 4)
+ printf(" (+ %u octet%s)", len - 4, len - 4 == 1 ? "" : "s");
printf("\n");
}
@@ -527,7 +604,7 @@
[0] = { "SSID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
[1] = { "Supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
[3] = { "DS Parameter set", print_ds, 1, 1, BIT(PRINT_SCAN), },
- [5] = PRINT_IGN,
+ [5] = { "TIM", print_tim, 4, 255, BIT(PRINT_SCAN), },
[7] = { "Country", print_country, 3, 255, BIT(PRINT_SCAN), },
[32] = { "Power constraint", print_powerconstraint, 1, 1, BIT(PRINT_SCAN), },
[42] = { "ERP", print_erp, 1, 255, BIT(PRINT_SCAN), },
@@ -606,6 +683,26 @@
printf("\n");
}
+static const char * wifi_wps_dev_passwd_id(uint16_t id)
+{
+ switch (id) {
+ case 0:
+ return "Default (PIN)";
+ case 1:
+ return "User-specified";
+ case 2:
+ return "Machine-specified";
+ case 3:
+ return "Rekey";
+ case 4:
+ return "PushButton";
+ case 5:
+ return "Registrar-specified";
+ default:
+ return "??";
+ }
+}
+
static void print_wifi_wps(const uint8_t type, uint8_t len, const uint8_t *data)
{
bool first = true;
@@ -626,6 +723,19 @@
tab_on_first(&first);
printf("\t * Device name: %.*s\n", sublen, data + 4);
break;
+ case 0x1012: {
+ uint16_t id;
+ tab_on_first(&first);
+ if (sublen != 2) {
+ printf("\t * Device Password ID: (invalid "
+ "length %d)\n", sublen);
+ break;
+ }
+ id = data[4] << 8 | data[5];
+ printf("\t * Device Password ID: %u (%s)\n",
+ id, wifi_wps_dev_passwd_id(id));
+ break;
+ }
case 0x1021:
tab_on_first(&first);
printf("\t * Manufacturer: %.*s\n", sublen, data + 4);
@@ -634,17 +744,69 @@
tab_on_first(&first);
printf("\t * Model: %.*s\n", sublen, data + 4);
break;
+ case 0x1024:
+ tab_on_first(&first);
+ printf("\t * Model Number: %.*s\n", sublen, data + 4);
+ break;
+ case 0x103b: {
+ __u8 val = data[4];
+ tab_on_first(&first);
+ printf("\t * Response Type: %d%s\n",
+ val, val == 3 ? " (AP)" : "");
+ break;
+ }
+ case 0x103c: {
+ __u8 val = data[4];
+ tab_on_first(&first);
+ printf("\t * RF Bands: 0x%x\n", val);
+ break;
+ }
+ case 0x1041: {
+ __u8 val = data[4];
+ tab_on_first(&first);
+ printf("\t * Selected Registrar: 0x%x\n", val);
+ break;
+ }
+ case 0x1042:
+ tab_on_first(&first);
+ printf("\t * Serial Number: %.*s\n", sublen, data + 4);
+ break;
+ case 0x1044: {
+ __u8 val = data[4];
+ tab_on_first(&first);
+ printf("\t * Wi-Fi Protected Setup State: %d%s%s\n",
+ val,
+ val == 1 ? " (Unconfigured)" : "",
+ val == 2 ? " (Configured)" : "");
+ break;
+ }
+ case 0x1054: {
+ tab_on_first(&first);
+ if (sublen != 8) {
+ printf("\t * Primary Device Type: (invalid "
+ "length %d)\n", sublen);
+ break;
+ }
+ printf("\t * Primary Device Type: "
+ "%u-%02x%02x%02x%02x-%u\n",
+ data[4] << 8 | data[5],
+ data[6], data[7], data[8], data[9],
+ data[10] << 8 | data[11]);
+ break;
+ }
case 0x1057: {
__u8 val = data[4];
tab_on_first(&first);
printf("\t * AP setup locked: 0x%.2x\n", val);
break;
}
- case 0x1008: {
+ case 0x1008:
+ case 0x1053: {
__u16 meth = (data[4] << 8) + data[5];
bool comma = false;
tab_on_first(&first);
- printf("\t * Config methods:");
+ printf("\t * %sConfig methods:",
+ subtype == 0x1053 ? "Selected Registrar ": "");
#define T(bit, name) do { \
if (meth & (1<<bit)) { \
if (comma) \
@@ -665,8 +827,21 @@
break;
#undef T
}
- default:
- break;
+ default: {
+ const __u8 *subdata = data + 4;
+ __u16 tmplen = sublen;
+
+ tab_on_first(&first);
+ printf("\t * Unknown TLV (%#.4x, %d bytes):",
+ subtype, tmplen);
+ while (tmplen) {
+ printf(" %.2x", *subdata);
+ subdata++;
+ tmplen--;
+ }
+ printf("\n");
+ break;
+ }
}
data += sublen + 4;
@@ -769,8 +944,10 @@
[NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 },
[NL80211_BSS_STATUS] = { .type = NLA_U32 },
[NL80211_BSS_SEEN_MS_AGO] = { .type = NLA_U32 },
+ [NL80211_BSS_BEACON_IES] = { },
};
struct scan_params *params = arg;
+ int show = params->show_both_ie_sets ? 2 : 1;
nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
genlmsg_attrlen(gnlh, 0), NULL);
@@ -864,10 +1041,21 @@
int age = nla_get_u32(bss[NL80211_BSS_SEEN_MS_AGO]);
printf("\tlast seen: %d ms ago\n", age);
}
- if (bss[NL80211_BSS_INFORMATION_ELEMENTS])
+
+ if (bss[NL80211_BSS_INFORMATION_ELEMENTS] && show--) {
+ if (bss[NL80211_BSS_BEACON_IES])
+ printf("\tInformation elements from Probe Response "
+ "frame:\n");
print_ies(nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]),
nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]),
params->unknown, params->type);
+ }
+ if (bss[NL80211_BSS_BEACON_IES] && show--) {
+ printf("\tInformation elements from Beacon frame:\n");
+ print_ies(nla_data(bss[NL80211_BSS_BEACON_IES]),
+ nla_len(bss[NL80211_BSS_BEACON_IES]),
+ params->unknown, params->type);
+ }
return NL_SKIP;
}
@@ -882,9 +1070,12 @@
if (argc > 1)
return 1;
- scan_params.unknown = false;
+ memset(&scan_params, 0, sizeof(scan_params));
+
if (argc == 1 && !strcmp(argv[0], "-u"))
scan_params.unknown = true;
+ else if (argc == 1 && !strcmp(argv[0], "-b"))
+ scan_params.show_both_ie_sets = true;
scan_params.type = PRINT_SCAN;
@@ -914,6 +1105,9 @@
if (argc >= 3 && !strcmp(argv[2], "-u")) {
dump_argc = 4;
dump_argv[3] = "-u";
+ } else if (argc >= 3 && !strcmp(argv[2], "-b")) {
+ dump_argc = 4;
+ dump_argv[3] = "-b";
} else
dump_argc = 3;
@@ -965,16 +1159,17 @@
dump_argv[0] = argv[0];
return handle_cmd(state, II_NETDEV, dump_argc, dump_argv);
}
-TOPLEVEL(scan, "[-u] [freq <freq>*] [ssid <ssid>*|passive]", 0, 0,
+TOPLEVEL(scan, "[-u] [freq <freq>*] [ies <hex as 00:11:..>] [ssid <ssid>*|passive]", 0, 0,
CIB_NETDEV, handle_scan_combined,
"Scan on the given frequencies and probe for the given SSIDs\n"
"(or wildcard if not given) unless passive scanning is requested.\n"
- "If -u is specified print unknown data in the scan results.");
+ "If -u is specified print unknown data in the scan results.\n"
+ "Specified (vendor) IEs must be well-formed.");
COMMAND(scan, dump, "[-u]",
NL80211_CMD_GET_SCAN, NLM_F_DUMP, CIB_NETDEV, handle_scan_dump,
"Dump the current scan results. If -u is specified, print unknown\n"
"data in scan results.");
-COMMAND(scan, trigger, "[freq <freq>*] [ssid <ssid>*|passive]",
+COMMAND(scan, trigger, "[freq <freq>*] [ies <hex as 00:11:..>] [ssid <ssid>*|passive]",
NL80211_CMD_TRIGGER_SCAN, 0, CIB_NETDEV, handle_scan,
"Trigger a scan on the given frequencies with probing for the given\n"
"SSIDs (or wildcard if not given) unless passive scanning is requested.");
Modified: iw/branches/upstream/current/util.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/util.c?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/util.c (original)
+++ iw/branches/upstream/current/util.c Tue Jul 20 13:37:49 2010
@@ -46,6 +46,43 @@
return -1;
return 0;
+}
+
+unsigned char *parse_hex(char *hex, size_t *outlen)
+{
+ size_t len = strlen(hex);
+ unsigned char *result = calloc(len/2 + 2, 1);
+ int pos = 0;
+
+ if (!result)
+ return NULL;
+
+ *outlen = 0;
+
+ while (1) {
+ int temp;
+ char *cp = strchr(hex, ':');
+ if (cp) {
+ *cp = 0;
+ cp++;
+ }
+ if (sscanf(hex, "%x", &temp) != 1)
+ goto error;
+ if (temp < 0 || temp > 255)
+ goto error;
+
+ (*outlen)++;
+
+ result[pos++] = temp;
+ if (!cp)
+ break;
+ hex = cp;
+ }
+
+ return result;
+ error:
+ free(result);
+ return NULL;
}
static const char *ifmodes[NL80211_IFTYPE_MAX + 1] = {
@@ -70,63 +107,72 @@
}
static const char *commands[NL80211_CMD_MAX + 1] = {
- "unspecified",
- "get_wiphy",
- "set_wiphy",
- "new_wiphy",
- "del_wiphy",
- "get_interface",
- "set_interface",
- "new_interface",
- "del_interface",
- "get_key",
- "set_key",
- "new_key",
- "del_key",
- "get_beacon",
- "set_beacon",
- "new_beacon",
- "del_beacon",
- "get_station",
- "set_station",
- "new_station",
- "del_station",
- "get_mpath",
- "set_mpath",
- "new_mpath",
- "del_mpath",
- "set_bss",
- "set_reg",
- "reg_set_reg",
- "get_mesh_params",
- "set_mesh_params",
- "set_mgmt_extra_ie",
- "get_reg",
- "get_scan",
- "trigger_scan",
- "new_scan_results",
- "scan_aborted",
- "reg_change",
- "authenticate",
- "associate",
- "deauthenticate",
- "disassociate",
- "michael_mic_failure",
- "reg_beacon_hint",
- "join_ibss",
- "leave_ibss",
- "testmode",
- "connect",
- "roam",
- "disconnect",
- "set_wiphy_netns"
+ [NL80211_CMD_GET_WIPHY] = "get_wiphy",
+ [NL80211_CMD_SET_WIPHY] = "set_wiphy",
+ [NL80211_CMD_NEW_WIPHY] = "new_wiphy",
+ [NL80211_CMD_DEL_WIPHY] = "del_wiphy",
+ [NL80211_CMD_GET_INTERFACE] = "get_interface",
+ [NL80211_CMD_SET_INTERFACE] = "set_interface",
+ [NL80211_CMD_NEW_INTERFACE] = "new_interface",
+ [NL80211_CMD_DEL_INTERFACE] = "del_interface",
+ [NL80211_CMD_GET_KEY] = "get_key",
+ [NL80211_CMD_SET_KEY] = "set_key",
+ [NL80211_CMD_NEW_KEY] = "new_key",
+ [NL80211_CMD_DEL_KEY] = "del_key",
+ [NL80211_CMD_GET_BEACON] = "get_beacon",
+ [NL80211_CMD_SET_BEACON] = "set_beacon",
+ [NL80211_CMD_NEW_BEACON] = "new_beacon",
+ [NL80211_CMD_DEL_BEACON] = "del_beacon",
+ [NL80211_CMD_GET_STATION] = "get_station",
+ [NL80211_CMD_SET_STATION] = "set_station",
+ [NL80211_CMD_NEW_STATION] = "new_station",
+ [NL80211_CMD_DEL_STATION] = "del_station",
+ [NL80211_CMD_GET_MPATH] = "get_mpath",
+ [NL80211_CMD_SET_MPATH] = "set_mpath",
+ [NL80211_CMD_NEW_MPATH] = "new_mpath",
+ [NL80211_CMD_DEL_MPATH] = "del_mpath",
+ [NL80211_CMD_SET_BSS] = "set_bss",
+ [NL80211_CMD_SET_REG] = "set_reg",
+ [NL80211_CMD_REQ_SET_REG] = "reg_set_reg",
+ [NL80211_CMD_GET_MESH_PARAMS] = "get_mesh_params",
+ [NL80211_CMD_SET_MESH_PARAMS] = "set_mesh_params",
+ [NL80211_CMD_SET_MGMT_EXTRA_IE] = "set_mgmt_extra_ie",
+ [NL80211_CMD_GET_REG] = "get_reg",
+ [NL80211_CMD_GET_SCAN] = "get_scan",
+ [NL80211_CMD_TRIGGER_SCAN] = "trigger_scan",
+ [NL80211_CMD_NEW_SCAN_RESULTS] = "new_scan_results",
+ [NL80211_CMD_SCAN_ABORTED] = "scan_aborted",
+ [NL80211_CMD_REG_CHANGE] = "reg_change",
+ [NL80211_CMD_AUTHENTICATE] = "authenticate",
+ [NL80211_CMD_ASSOCIATE] = "associate",
+ [NL80211_CMD_DEAUTHENTICATE] = "deauthenticate",
+ [NL80211_CMD_DISASSOCIATE] = "disassociate",
+ [NL80211_CMD_MICHAEL_MIC_FAILURE] = "michael_mic_failure",
+ [NL80211_CMD_REG_BEACON_HINT] = "reg_beacon_hint",
+ [NL80211_CMD_JOIN_IBSS] = "join_ibss",
+ [NL80211_CMD_LEAVE_IBSS] = "leave_ibss",
+ [NL80211_CMD_TESTMODE] = "testmode",
+ [NL80211_CMD_CONNECT] = "connect",
+ [NL80211_CMD_ROAM] = "roam",
+ [NL80211_CMD_DISCONNECT] = "disconnect",
+ [NL80211_CMD_SET_WIPHY_NETNS] = "set_wiphy_netns",
+ [NL80211_CMD_GET_SURVEY] = "get_survey",
+ [NL80211_CMD_SET_PMKSA] = "set_pmksa",
+ [NL80211_CMD_DEL_PMKSA] = "del_pmksa",
+ [NL80211_CMD_FLUSH_PMKSA] = "flush_pmksa",
+ [NL80211_CMD_REMAIN_ON_CHANNEL] = "remain_on_channel",
+ [NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL] = "cancel_remain_on_channel",
+ [NL80211_CMD_SET_TX_BITRATE_MASK] = "set_tx_bitrate_mask",
+ [NL80211_CMD_REGISTER_ACTION] = "register_action",
+ [NL80211_CMD_ACTION] = "action",
+ [NL80211_CMD_SET_CHANNEL] = "set_channel",
};
static char cmdbuf[100];
const char *command_name(enum nl80211_commands cmd)
{
- if (cmd <= NL80211_CMD_MAX)
+ if (cmd <= NL80211_CMD_MAX && commands[cmd])
return commands[cmd];
sprintf(cmdbuf, "Unknown command (%d)", cmd);
return cmdbuf;
@@ -391,7 +437,7 @@
printf("\t\tCapabilities: 0x%02x\n", cap);
- PRINT_HT_CAP((cap & BIT(0)), "RX LDCP");
+ PRINT_HT_CAP((cap & BIT(0)), "RX LDPC");
PRINT_HT_CAP((cap & BIT(1)), "HT20/HT40");
PRINT_HT_CAP(!(cap & BIT(1)), "HT20");
@@ -411,8 +457,8 @@
PRINT_HT_CAP((cap & BIT(10)), "HT Delayed Block Ack");
- PRINT_HT_CAP((cap & BIT(11)), "Max AMSDU length: 3839 bytes");
- PRINT_HT_CAP(!(cap & BIT(11)), "Max AMSDU length: 7935 bytes");
+ PRINT_HT_CAP(!(cap & BIT(11)), "Max AMSDU length: 3839 bytes");
+ PRINT_HT_CAP((cap & BIT(11)), "Max AMSDU length: 7935 bytes");
/*
* For beacons and probe response this would mean the BSS
Modified: iw/branches/upstream/current/version.sh
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/version.sh?rev=1540&op=diff
==============================================================================
--- iw/branches/upstream/current/version.sh (original)
+++ iw/branches/upstream/current/version.sh Tue Jul 20 13:37:49 2010
@@ -1,6 +1,6 @@
#!/bin/sh
-VERSION="0.9.19"
+VERSION="0.9.20"
OUT="$1"
echo '#include "iw.h"' > "$OUT"
More information about the Pkg-wpa-devel
mailing list