[pkg-wpa-devel] r1422 - in /iw/branches/upstream/current: Makefile connect.c event.c ibss.c info.c interface.c iw.c iw.h link.c mpath.c phy.c reg.c scan.c sections.c station.c util.c version.sh

kelmo-guest at users.alioth.debian.org kelmo-guest at users.alioth.debian.org
Thu Sep 3 21:13:00 UTC 2009


Author: kelmo-guest
Date: Thu Sep  3 21:13:00 2009
New Revision: 1422

URL: http://svn.debian.org/wsvn/?sc=1&rev=1422
Log:
[svn-upgrade] Integrating new upstream version, iw (0.9.17)

Added:
    iw/branches/upstream/current/link.c
    iw/branches/upstream/current/sections.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/interface.c
    iw/branches/upstream/current/iw.c
    iw/branches/upstream/current/iw.h
    iw/branches/upstream/current/mpath.c
    iw/branches/upstream/current/phy.c
    iw/branches/upstream/current/reg.c
    iw/branches/upstream/current/scan.c
    iw/branches/upstream/current/station.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=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/Makefile (original)
+++ iw/branches/upstream/current/Makefile Thu Sep  3 21:13:00 2009
@@ -14,7 +14,11 @@
 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 util.o mesh.o mpath.o scan.o reg.o version.o reason.o status.o connect.o
+OBJS = iw.o genl.o event.o info.o phy.o \
+	interface.o ibss.o station.o util.o \
+	mesh.o mpath.o scan.o reg.o version.o \
+	reason.o status.o connect.o link.o
+OBJS += sections.o
 ALL = iw
 
 NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)

Modified: iw/branches/upstream/current/connect.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/connect.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/connect.c (original)
+++ iw/branches/upstream/current/connect.c Thu Sep  3 21:13:00 2009
@@ -67,7 +67,6 @@
 TOPLEVEL(disconnect, NULL,
 	NL80211_CMD_DISCONNECT, 0, CIB_NETDEV, disconnect,
 	"Disconnect from the current network.");
-HIDDEN(conn, establish, "", NL80211_CMD_CONNECT, 0, CIB_NETDEV, iw_conn);
 
 static int iw_connect(struct nl80211_state *state, struct nl_cb *cb,
 		      struct nl_msg *msg, int argc, char **argv)
@@ -97,7 +96,7 @@
 	if (!conn_argv)
 		return -ENOMEM;
 	conn_argv[0] = dev;
-	conn_argv[1] = "conn";
+	conn_argv[1] = "connect";
 	conn_argv[2] = "establish";
 	for (i = 0; i < argc; i++)
 		conn_argv[i + 3] = argv[i];
@@ -138,3 +137,4 @@
 	0, 0, CIB_NETDEV, iw_connect,
 	"Join the network with the given SSID (and frequency, BSSID).\n"
 	"With -w, wait for the connect to finish or fail.");
+HIDDEN(connect, establish, "", NL80211_CMD_CONNECT, 0, CIB_NETDEV, iw_conn);

Modified: iw/branches/upstream/current/event.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/event.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/event.c (original)
+++ iw/branches/upstream/current/event.c Thu Sep  3 21:13:00 2009
@@ -7,6 +7,38 @@
 static int no_seq_check(struct nl_msg *msg, void *arg)
 {
 	return NL_OK;
+}
+
+struct ieee80211_beacon_channel {
+	__u16 center_freq;
+	bool passive_scan;
+	bool no_ibss;
+};
+
+static int parse_beacon_hint_chan(struct nlattr *tb,
+				  struct ieee80211_beacon_channel *chan)
+{
+	struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1];
+	static struct nla_policy beacon_freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
+		[NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
+		[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
+		[NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
+	};
+
+	if (nla_parse_nested(tb_freq,
+			     NL80211_FREQUENCY_ATTR_MAX,
+			     tb,
+			     beacon_freq_policy))
+		return -EINVAL;
+
+	chan->center_freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
+
+	if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN])
+		chan->passive_scan = true;
+	if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS])
+		chan->no_ibss = true;
+
+	return 0;
 }
 
 static void print_frame(struct print_event_args *args, struct nlattr *attr)
@@ -70,12 +102,21 @@
 
 static int print_event(struct nl_msg *msg, void *arg)
 {
+#define PARSE_BEACON_CHAN(_attr, _chan) do { \
+	r = parse_beacon_hint_chan(tb[_attr], \
+				   &_chan); \
+	if (r) \
+		return NL_SKIP; \
+} while (0)
 	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
 	struct nlattr *tb[NL80211_ATTR_MAX + 1], *nst;
 	struct print_event_args *args = arg;
 	char ifname[100];
 	char macbuf[6*3];
 	__u8 reg_type;
+	struct ieee80211_beacon_channel chan_before_beacon,  chan_after_beacon;
+	__u32 wiphy_idx = 0;
+	int r;
 	int rem_nst;
 	__u16 status;
 
@@ -159,6 +200,33 @@
 
 		printf("\n");
 		break;
+	case NL80211_CMD_REG_BEACON_HINT:
+
+		wiphy_idx = nla_get_u32(tb[NL80211_ATTR_WIPHY]);
+
+		memset(&chan_before_beacon, 0, sizeof(chan_before_beacon));
+		memset(&chan_after_beacon, 0, sizeof(chan_after_beacon));
+
+		PARSE_BEACON_CHAN(NL80211_ATTR_FREQ_BEFORE, chan_before_beacon);
+		PARSE_BEACON_CHAN(NL80211_ATTR_FREQ_AFTER, chan_after_beacon);
+
+		if (chan_before_beacon.center_freq != chan_after_beacon.center_freq)
+			break;
+
+		/* A beacon hint is sent _only_ if something _did_ change */
+		printf("beacon hint:\n");
+
+		printf("phy%d %d MHz [%d]:\n",
+		       wiphy_idx,
+		       chan_before_beacon.center_freq,
+		       ieee80211_frequency_to_channel(chan_before_beacon.center_freq));
+
+		if (chan_before_beacon.passive_scan && !chan_after_beacon.passive_scan)
+			printf("\to active scanning enabled\n");
+		if (chan_before_beacon.no_ibss && !chan_after_beacon.no_ibss)
+			printf("\to beaconing enabled\n");
+
+		break;
 	case NL80211_CMD_JOIN_IBSS:
 		mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
 		printf("IBSS %s joined\n", macbuf);
@@ -236,6 +304,7 @@
 	}
 
 	return NL_SKIP;
+#undef PARSE_BEACON_CHAN
 }
 
 struct wait_event {

Modified: iw/branches/upstream/current/ibss.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/ibss.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/ibss.c (original)
+++ iw/branches/upstream/current/ibss.c Thu Sep  3 21:13:00 2009
@@ -8,6 +8,8 @@
 
 #include "nl80211.h"
 #include "iw.h"
+
+SECTION(ibss);
 
 static int join_ibss(struct nl80211_state *state,
 		     struct nl_cb *cb,

Modified: iw/branches/upstream/current/info.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/info.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/info.c (original)
+++ iw/branches/upstream/current/info.c Thu Sep  3 21:13:00 2009
@@ -159,8 +159,8 @@
 			max_rx_supp_data_rate = ((mcs[10] >> 8) & ((mcs[11] & 0x3) << 8));
 			tx_mcs_set_defined = !!(mcs[12] & (1 << 0));
 			tx_mcs_set_equal = !(mcs[12] & (1 << 1));
-			tx_max_num_spatial_streams = (mcs[12] | ((1 << 3) | (1 << 4))) + 1;
-			tx_unequal_modulation = !!(mcs[12] & (1 << 5));
+			tx_max_num_spatial_streams = (mcs[12] & ((1 << 2) | (1 << 3))) + 1;
+			tx_unequal_modulation = !!(mcs[12] & (1 << 4));
 
 			if (max_rx_supp_data_rate)
 				printf("\t\tHT Max RX data rate: %d Mbps\n", max_rx_supp_data_rate);
@@ -247,6 +247,22 @@
 		printf("\tmax # scan SSIDs: %d\n",
 		       nla_get_u8(tb_msg[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]));
 
+	if (tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) {
+		unsigned int frag;
+
+		frag = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]);
+		if (frag != (unsigned int)-1)
+			printf("\tFragmentation threshold: %d\n", frag);
+	}
+
+	if (tb_msg[NL80211_ATTR_WIPHY_RTS_THRESHOLD]) {
+		unsigned int rts;
+
+		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_SUPPORTED_IFTYPES])
 		return NL_SKIP;
 
@@ -266,7 +282,7 @@
 
 	return 0;
 }
-TOPLEVEL(info, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_PHY, handle_info,
+__COMMAND(NULL, info, "info", NULL, NL80211_CMD_GET_WIPHY, 0, 0, CIB_PHY, handle_info,
 	 "Show capabilities for the specified wireless device.");
 TOPLEVEL(list, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info,
 	 "List all wireless devices and their capabilities.");

Modified: iw/branches/upstream/current/interface.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/interface.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/interface.c (original)
+++ iw/branches/upstream/current/interface.c Thu Sep  3 21:13:00 2009
@@ -17,6 +17,8 @@
 			"control:  show control frames\n"\
 			"otherbss: show frames from other BSSes\n"\
 			"cook:     use cooked mode"
+
+SECTION(interface);
 
 static char *mntr_flags[NL80211_MNTR_FLAG_MAX + 1] = {
 	"none",

Modified: iw/branches/upstream/current/iw.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/iw.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/iw.c (original)
+++ iw/branches/upstream/current/iw.c Thu Sep  3 21:13:00 2009
@@ -94,33 +94,38 @@
 	nl_socket_free(state->nl_sock);
 }
 
-__COMMAND(NULL, NULL, "", NULL, 0, 0, 0, CIB_NONE, NULL, NULL);
-__COMMAND(NULL, NULL, "", NULL, 1, 0, 0, CIB_NONE, NULL, NULL);
-
 static int cmd_size;
 
-static void __usage_cmd(struct cmd *cmd, char *indent, bool full)
+extern struct cmd __start___cmd;
+extern struct cmd __stop___cmd;
+
+#define for_each_cmd(_cmd)					\
+	for (_cmd = &__start___cmd; _cmd < &__stop___cmd;		\
+	     _cmd = (const struct cmd *)((char *)_cmd + cmd_size))
+
+
+static void __usage_cmd(const struct cmd *cmd, char *indent, bool full)
 {
 	const char *start, *lend, *end;
 
-	fprintf(stderr, "%s", indent);
+	printf("%s", indent);
 
 	switch (cmd->idby) {
 	case CIB_NONE:
 		break;
 	case CIB_PHY:
-		fprintf(stderr, "phy <phyname> ");
+		printf("phy <phyname> ");
 		break;
 	case CIB_NETDEV:
-		fprintf(stderr, "dev <devname> ");
-		break;
-	}
-	if (cmd->section)
-		fprintf(stderr, "%s ", cmd->section);
-	fprintf(stderr, "%s", cmd->name);
+		printf("dev <devname> ");
+		break;
+	}
+	if (cmd->parent && cmd->parent->name)
+		printf("%s ", cmd->parent->name);
+	printf("%s", cmd->name);
 	if (cmd->args)
-		fprintf(stderr, " %s", cmd->args);
-	fprintf(stderr, "\n");
+		printf(" %s", cmd->args);
+	printf("\n");
 
 	if (!full || !cmd->help)
 		return;
@@ -129,7 +134,7 @@
 	if (strlen(indent))
 		indent = "\t\t";
 	else
-		fprintf(stderr, "\n");
+		printf("\n");
 
 	/* print line by line */
 	start = cmd->help;
@@ -138,40 +143,51 @@
 		lend = strchr(start, '\n');
 		if (!lend)
 			lend = end;
-		fprintf(stderr, "%s", indent);
-		fprintf(stderr, "%.*s\n", (int)(lend - start), start);
+		printf("%s", indent);
+		printf("%.*s\n", (int)(lend - start), start);
 		start = lend + 1;
 	} while (end != lend);
 
-	fprintf(stderr, "\n");
+	printf("\n");
 }
 
 static void usage_options(void)
 {
-	fprintf(stderr, "Options:\n");
-	fprintf(stderr, "\t--debug\t\tenable netlink debugging\n");
+	printf("Options:\n");
+	printf("\t--debug\t\tenable netlink debugging\n");
 }
 
 static const char *argv0;
 
 static void usage(bool full)
 {
-	struct cmd *cmd;
-
-	fprintf(stderr, "Usage:\t%s [options] command\n", argv0);
+	const struct cmd *section, *cmd;
+
+	printf("Usage:\t%s [options] command\n", argv0);
 	usage_options();
-	fprintf(stderr, "\t--version\tshow version (%s)\n", iw_version);
-	fprintf(stderr, "Commands:\n");
-	for (cmd = &__start___cmd; cmd < &__stop___cmd;
-	     cmd = (struct cmd *)((char *)cmd + cmd_size)) {
-		if (!cmd->handler || cmd->hidden)
+	printf("\t--version\tshow version (%s)\n", iw_version);
+	printf("Commands:\n");
+	for_each_cmd(section) {
+		if (section->parent)
 			continue;
-		__usage_cmd(cmd, "\t", full);
-	}
-	fprintf(stderr, "\nYou can omit the 'phy' or 'dev' if "
+
+		if (section->handler && !section->hidden)
+			__usage_cmd(section, "\t", full);
+
+		for_each_cmd(cmd) {
+			if (section != cmd->parent)
+				continue;
+			if (!cmd->handler || cmd->hidden)
+				continue;
+			__usage_cmd(cmd, "\t", full);
+		}
+	}
+	printf("\nYou can omit the 'phy' or 'dev' if "
 			"the identification is unique,\n"
 			"e.g. \"iw wlan0 info\" or \"iw phy0 info\". "
-			"(Don't when scripting.)\n\n");
+			"(Don't when scripting.)\n\n"
+			"Do NOT screenscrape this tool, we don't "
+			"consider its output stable.\n\n");
 }
 
 static int print_help(struct nl80211_state *state,
@@ -184,9 +200,9 @@
 TOPLEVEL(help, NULL, 0, 0, CIB_NONE, print_help,
 	 "Print usage for each command.");
 
-static void usage_cmd(struct cmd *cmd)
-{
-	fprintf(stderr, "Usage:\t%s [options] ", argv0);
+static void usage_cmd(const struct cmd *cmd)
+{
+	printf("Usage:\t%s [options] ", argv0);
 	__usage_cmd(cmd, "", true);
 	usage_options();
 }
@@ -236,9 +252,9 @@
 }
 
 static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
-			int argc, char **argv, struct cmd **cmdout)
-{
-	struct cmd *cmd, *match = NULL;
+			int argc, char **argv, const struct cmd **cmdout)
+{
+	const struct cmd *cmd, *match = NULL, *sectcmd;
 	struct nl_cb *cb;
 	struct nl_msg *msg;
 	int devidx = 0;
@@ -283,44 +299,61 @@
 	if (devidx < 0)
 		return -errno;
 
-	section = command = *argv;
+	section = *argv;
 	argc--;
 	argv++;
 
-	for (cmd = &__start___cmd; cmd < &__stop___cmd;
-	     cmd = (struct cmd *)((char *)cmd + cmd_size)) {
+	for_each_cmd(sectcmd) {
+		if (sectcmd->parent)
+			continue;
+		/* ok ... bit of a hack for the dupe 'info' section */
+		if (match && sectcmd->idby != command_idby)
+			continue;
+		if (strcmp(sectcmd->name, section) == 0)
+			match = sectcmd;
+	}
+
+	sectcmd = match;
+	match = NULL;
+	if (!sectcmd)
+		return 1;
+
+	if (argc > 0) {
+		command = *argv;
+
+		for_each_cmd(cmd) {
+			if (!cmd->handler)
+				continue;
+			if (cmd->parent != sectcmd)
+				continue;
+			if (cmd->idby != command_idby)
+				continue;
+			if (strcmp(cmd->name, command))
+				continue;
+			if (argc > 1 && !cmd->args)
+				continue;
+			match = cmd;
+			break;
+		}
+
+		if (match) {
+			argc--;
+			argv++;
+		}
+	}
+
+	if (match)
+		cmd = match;
+	else {
+		/* Use the section itself, if possible. */
+		cmd = sectcmd;
+		if (argc && !cmd->args)
+			return 1;
+		if (cmd->idby != command_idby)
+			return 1;
 		if (!cmd->handler)
-			continue;
-		if (cmd->idby != command_idby)
-			continue;
-		if (cmd->section) {
-			if (strcmp(cmd->section, section))
-				continue;
-			/* this is a bit icky ... */
-			if (command == section) {
-				if (argc <= 0) {
-					if (match)
-						break;
-					return 1;
-				}
-				command = *argv;
-				argc--;
-				argv++;
-			}
-		} else if (section != command)
-			continue;
-		if (strcmp(cmd->name, command))
-			continue;
-		if (argc && !cmd->args)
-			continue;
-
-		match = cmd;
-	}
-
-	cmd = match;
-
-	if (!cmd)
-		return 1;
+			return 1;
+	}
 
 	if (cmdout)
 		*cmdout = cmd;
@@ -394,11 +427,10 @@
 {
 	struct nl80211_state nlstate;
 	int err;
-	struct cmd *cmd = NULL;
+	const struct cmd *cmd = NULL;
 
 	/* calculate command size including padding */
-	cmd_size = abs((long)&__cmd_NULL_NULL_1_CIB_NONE_0
-	             - (long)&__cmd_NULL_NULL_0_CIB_NONE_0);
+	cmd_size = abs((long)&__section_set - (long)&__section_get);
 	/* strip off self */
 	argc--;
 	argv0 = *argv++;

Modified: iw/branches/upstream/current/iw.h
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/iw.h?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/iw.h (original)
+++ iw/branches/upstream/current/iw.h Thu Sep  3 21:13:00 2009
@@ -35,7 +35,6 @@
 };
 
 struct cmd {
-	const char *section;
 	const char *name;
 	const char *args;
 	const char *help;
@@ -52,6 +51,7 @@
 		       struct nl_cb *cb,
 		       struct nl_msg *msg,
 		       int argc, char **argv);
+	const struct cmd *parent;
 };
 
 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
@@ -60,7 +60,6 @@
 	static const struct cmd						\
 	__cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden\
 	__attribute__((used)) __attribute__((section("__cmd")))	= {	\
-		.section = (_section),					\
 		.name = (_name),					\
 		.args = (_args),					\
 		.cmd = (_nlcmd),					\
@@ -69,15 +68,34 @@
 		.idby = (_idby),					\
 		.handler = (_handler),					\
 		.help = (_help),					\
+		.parent = _section,					\
 	 }
 #define COMMAND(section, name, args, cmd, flags, idby, handler, help)	\
-	__COMMAND(#section, name, #name, args, cmd, flags, 0, idby, handler, help)
+	__COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 0, idby, handler, help)
 #define HIDDEN(section, name, args, cmd, flags, idby, handler)		\
-	__COMMAND(#section, name, #name, args, cmd, flags, 1, idby, handler, NULL)
-#define TOPLEVEL(name, args, cmd, flags, idby, handler, help)		\
-	__COMMAND(NULL, name, #name, args, cmd, flags, 0, idby, handler, help)
-extern struct cmd __start___cmd;
-extern struct cmd __stop___cmd;
+	__COMMAND(&(__section ## _ ## section), name, #name, args, cmd, flags, 1, idby, handler, NULL)
+
+#define TOPLEVEL(_name, _args, _nlcmd, _flags, _idby, _handler, _help)	\
+	const struct cmd						\
+	__section ## _ ## _name						\
+	__attribute__((used)) __attribute__((section("__cmd")))	= {	\
+		.name = (#_name),					\
+		.args = (_args),					\
+		.cmd = (_nlcmd),					\
+		.nl_msg_flags = (_flags),				\
+		.idby = (_idby),					\
+		.handler = (_handler),					\
+		.help = (_help),					\
+	 }
+#define SECTION(_name)							\
+	const struct cmd __section ## _ ## _name			\
+	__attribute__((used)) __attribute__((section("__cmd"))) = {	\
+		.name = (#_name),					\
+		.hidden = 1,						\
+	}
+
+#define DECLARE_SECTION(_name)						\
+	extern const struct cmd __section ## _ ## _name;
 
 extern const char iw_version[];
 
@@ -98,7 +116,7 @@
 
 
 int mac_addr_a2n(unsigned char *mac_addr, char *arg);
-int mac_addr_n2a(char *mac_addr, unsigned char *arg);
+void mac_addr_n2a(char *mac_addr, unsigned char *arg);
 
 int parse_keys(struct nl_msg *msg, char **argv, int argc);
 
@@ -115,4 +133,18 @@
 const char *get_reason_str(uint16_t reason);
 const char *get_status_str(uint16_t status);
 
+enum print_ie_type {
+	PRINT_SCAN,
+	PRINT_LINK,
+};
+
+#define BIT(x) (1ULL<<(x))
+
+void print_ies(unsigned char *ie, int ielen, bool unknown,
+	       enum print_ie_type ptype);
+
+
+DECLARE_SECTION(set);
+DECLARE_SECTION(get);
+
 #endif /* __IW_H */

Added: iw/branches/upstream/current/link.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/link.c?rev=1422&op=file
==============================================================================
--- iw/branches/upstream/current/link.c (added)
+++ iw/branches/upstream/current/link.c Thu Sep  3 21:13:00 2009
@@ -1,0 +1,257 @@
+#include <net/if.h>
+#include <errno.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdbool.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"
+
+struct link_result {
+	uint8_t bssid[8];
+	bool link_found;
+	bool anything_found;
+};
+
+static struct link_result lr = { .link_found = false };
+
+static int link_bss_handler(struct nl_msg *msg, void *arg)
+{
+	struct nlattr *tb[NL80211_ATTR_MAX + 1];
+	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+	struct nlattr *bss[NL80211_BSS_MAX + 1];
+	static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
+		[NL80211_BSS_TSF] = { .type = NLA_U64 },
+		[NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
+		[NL80211_BSS_BSSID] = { },
+		[NL80211_BSS_BEACON_INTERVAL] = { .type = NLA_U16 },
+		[NL80211_BSS_CAPABILITY] = { .type = NLA_U16 },
+		[NL80211_BSS_INFORMATION_ELEMENTS] = { },
+		[NL80211_BSS_SIGNAL_MBM] = { .type = NLA_U32 },
+		[NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 },
+		[NL80211_BSS_STATUS] = { .type = NLA_U32 },
+	};
+	struct link_result *result = arg;
+	char mac_addr[20], dev[20];
+
+	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+		  genlmsg_attrlen(gnlh, 0), NULL);
+
+	if (!tb[NL80211_ATTR_BSS]) {
+		fprintf(stderr, "bss info missing!");
+		return NL_SKIP;
+	}
+	if (nla_parse_nested(bss, NL80211_BSS_MAX,
+			     tb[NL80211_ATTR_BSS],
+			     bss_policy)) {
+		fprintf(stderr, "failed to parse nested attributes!");
+		return NL_SKIP;
+	}
+
+	if (!bss[NL80211_BSS_BSSID])
+		return NL_SKIP;
+
+	if (!bss[NL80211_BSS_STATUS])
+		return NL_SKIP;
+
+	mac_addr_n2a(mac_addr, nla_data(bss[NL80211_BSS_BSSID]));
+	if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), dev);
+
+	switch (nla_get_u32(bss[NL80211_BSS_STATUS])) {
+	case NL80211_BSS_STATUS_ASSOCIATED:
+		printf("Connected to %s (on %s)\n", mac_addr, dev);
+		break;
+	case NL80211_BSS_STATUS_AUTHENTICATED:
+		printf("Authenticated with %s (on %s)\n", mac_addr, dev);
+		return NL_SKIP;
+	default:
+		return NL_SKIP;
+	}
+
+	result->anything_found = true;
+
+	if (bss[NL80211_BSS_INFORMATION_ELEMENTS])
+		print_ies(nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]),
+			  nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]),
+			  false, PRINT_LINK);
+
+	if (bss[NL80211_BSS_FREQUENCY])
+		printf("\tfreq: %d\n",
+			nla_get_u32(bss[NL80211_BSS_FREQUENCY]));
+
+	if (nla_get_u32(bss[NL80211_BSS_STATUS]) != NL80211_BSS_STATUS_ASSOCIATED)
+		return NL_SKIP;
+
+	/* only in the assoc case do we want more info from station get */
+	result->link_found = true;
+	memcpy(result->bssid, nla_data(bss[NL80211_BSS_BSSID]), 6);
+	return NL_SKIP;
+}
+
+static int handle_scan_for_link(struct nl80211_state *state,
+				struct nl_cb *cb,
+				struct nl_msg *msg,
+				int argc, char **argv)
+{
+	if (argc > 0)
+		return 1;
+
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, link_bss_handler, &lr);
+	return 0;
+}
+
+static int print_link_sta(struct nl_msg *msg, void *arg)
+{
+	struct nlattr *tb[NL80211_ATTR_MAX + 1];
+	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+	struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1];
+	struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1];
+	static struct nla_policy stats_policy[NL80211_STA_INFO_MAX + 1] = {
+		[NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
+		[NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
+		[NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
+		[NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 },
+		[NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
+		[NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
+		[NL80211_STA_INFO_TX_BITRATE] = { .type = NLA_NESTED },
+		[NL80211_STA_INFO_LLID] = { .type = NLA_U16 },
+		[NL80211_STA_INFO_PLID] = { .type = NLA_U16 },
+		[NL80211_STA_INFO_PLINK_STATE] = { .type = NLA_U8 },
+	};
+
+	static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
+		[NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
+		[NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
+		[NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
+		[NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
+	};
+
+	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+		  genlmsg_attrlen(gnlh, 0), NULL);
+
+	if (!tb[NL80211_ATTR_STA_INFO]) {
+		fprintf(stderr, "sta stats missing!");
+		return NL_SKIP;
+	}
+	if (nla_parse_nested(sinfo, NL80211_STA_INFO_MAX,
+			     tb[NL80211_ATTR_STA_INFO],
+			     stats_policy)) {
+		fprintf(stderr, "failed to parse nested attributes!");
+		return NL_SKIP;
+	}
+
+	if (sinfo[NL80211_STA_INFO_RX_BYTES] && sinfo[NL80211_STA_INFO_RX_PACKETS])
+		printf("\tRX: %u bytes (%u packets)\n",
+			nla_get_u32(sinfo[NL80211_STA_INFO_RX_BYTES]),
+			nla_get_u32(sinfo[NL80211_STA_INFO_RX_PACKETS]));
+	if (sinfo[NL80211_STA_INFO_TX_BYTES] && sinfo[NL80211_STA_INFO_TX_PACKETS])
+		printf("\tTX: %u bytes (%u packets)\n",
+			nla_get_u32(sinfo[NL80211_STA_INFO_TX_BYTES]),
+			nla_get_u32(sinfo[NL80211_STA_INFO_TX_PACKETS]));
+	if (sinfo[NL80211_STA_INFO_SIGNAL])
+		printf("\tsignal: %d dBm\n",
+			(int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]));
+
+	if (sinfo[NL80211_STA_INFO_TX_BITRATE]) {
+		if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX,
+				     sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy)) {
+			fprintf(stderr, "failed to parse nested rate attributes!");
+		} else {
+			printf("\ttx bitrate: ");
+			if (rinfo[NL80211_RATE_INFO_BITRATE]) {
+				int rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+				printf("%d.%d MBit/s", rate / 10, rate % 10);
+			}
+
+			if (rinfo[NL80211_RATE_INFO_MCS])
+				printf(" MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
+			if (rinfo[NL80211_RATE_INFO_40_MHZ_WIDTH])
+				printf(" 40Mhz");
+			if (rinfo[NL80211_RATE_INFO_SHORT_GI])
+				printf(" short GI");
+			printf("\n");
+		}
+	}
+
+	return NL_SKIP;
+}
+
+static int handle_link_sta(struct nl80211_state *state,
+			   struct nl_cb *cb,
+			   struct nl_msg *msg,
+			   int argc, char **argv)
+{
+	unsigned char mac_addr[ETH_ALEN];
+
+	if (argc < 1)
+		return 1;
+
+	if (mac_addr_a2n(mac_addr, argv[0])) {
+		fprintf(stderr, "invalid mac address\n");
+		return 2;
+	}
+
+	argc--;
+	argv++;
+
+	if (argc)
+		return 1;
+
+	NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
+
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_link_sta, NULL);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+
+static int handle_link(struct nl80211_state *state, struct nl_cb *cb,
+		       struct nl_msg *msg, int argc, char **argv)
+{
+	char *link_argv[] = {
+		NULL,
+		"link",
+		"get_bss",
+		NULL,
+	};
+	char *station_argv[] = {
+		NULL,
+		"link",
+		"get_sta",
+		NULL,
+		NULL,
+	};
+	char bssid_buf[3*6];
+	int err;
+
+	link_argv[0] = argv[0];
+	err = handle_cmd(state, II_NETDEV, 3, link_argv);
+	if (err)
+		return err;
+
+	if (!lr.link_found) {
+		if (!lr.anything_found)
+			printf("Not connected.\n");
+		return 0;
+	}
+
+	mac_addr_n2a(bssid_buf, lr.bssid);
+	bssid_buf[17] = '\0';
+
+	station_argv[0] = argv[0];
+	station_argv[3] = bssid_buf;
+	return handle_cmd(state, II_NETDEV, 4, station_argv);
+}
+TOPLEVEL(link, NULL, 0, 0, CIB_NETDEV, handle_link,
+	 "Print information about the current link, if any.");
+HIDDEN(link, get_sta, "", NL80211_CMD_GET_STATION, 0,
+	CIB_NETDEV, handle_link_sta);
+HIDDEN(link, get_bss, NULL, NL80211_CMD_GET_SCAN, NLM_F_DUMP,
+	CIB_NETDEV, handle_scan_for_link);

Modified: iw/branches/upstream/current/mpath.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/mpath.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/mpath.c (original)
+++ iw/branches/upstream/current/mpath.c Thu Sep  3 21:13:00 2009
@@ -10,6 +10,8 @@
 
 #include "nl80211.h"
 #include "iw.h"
+
+SECTION(mpath);
 
 enum plink_state {
 	LISTEN,

Modified: iw/branches/upstream/current/phy.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/phy.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/phy.c (original)
+++ iw/branches/upstream/current/phy.c Thu Sep  3 21:13:00 2009
@@ -92,3 +92,51 @@
 	NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_chan, NULL);
 COMMAND(set, channel, "<channel> [HT20|HT40+|HT40-]",
 	NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_chan, NULL);
+
+static int handle_fragmentation(struct nl80211_state *state,
+				struct nl_cb *cb, struct nl_msg *msg,
+				int argc, char **argv)
+{
+	unsigned int frag;
+
+	if (argc != 1)
+		return 1;
+
+	if (strcmp("off", argv[0]) == 0)
+		frag = -1;
+	else
+		frag = strtoul(argv[0], NULL, 10);
+
+	NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FRAG_THRESHOLD, frag);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(set, frag, "<fragmentation threshold|off>",
+	NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_fragmentation,
+	"Set fragmentation threshold.");
+
+static int handle_rts(struct nl80211_state *state,
+		      struct nl_cb *cb, struct nl_msg *msg,
+		      int argc, char **argv)
+{
+	unsigned int rts;
+
+	if (argc != 1)
+		return 1;
+
+	if (strcmp("off", argv[0]) == 0)
+		rts = -1;
+	else
+		rts = strtoul(argv[0], NULL, 10);
+
+	NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, rts);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(set, rts, "<rts threshold|off>",
+	NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_rts,
+	"Set rts threshold.");

Modified: iw/branches/upstream/current/reg.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/reg.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/reg.c (original)
+++ iw/branches/upstream/current/reg.c Thu Sep  3 21:13:00 2009
@@ -11,6 +11,8 @@
 
 #include "nl80211.h"
 #include "iw.h"
+
+SECTION(reg);
 
 #define MHZ_TO_KHZ(freq) ((freq) * 1000)
 #define KHZ_TO_MHZ(freq) ((freq) / 1000)

Modified: iw/branches/upstream/current/scan.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/scan.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/scan.c (original)
+++ iw/branches/upstream/current/scan.c Thu Sep  3 21:13:00 2009
@@ -32,6 +32,7 @@
 
 struct scan_params {
 	bool unknown;
+	enum print_ie_type type;
 };
 
 static int handle_scan(struct nl80211_state *state,
@@ -107,10 +108,6 @@
 	nlmsg_free(freqs);
 	return err;
 }
-COMMAND(scan, trigger, "[freq <freq>*] [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.");
 
 static void tab_on_first(bool *first)
 {
@@ -478,6 +475,7 @@
 	const char *name;
 	void (*print)(const uint8_t type, uint8_t len, const uint8_t *data);
 	uint8_t minlen, maxlen;
+	uint8_t flags;
 };
 
 static void print_ie(const struct ie_print *p, const uint8_t type,
@@ -513,21 +511,63 @@
 }
 
 static const struct ie_print ieprinters[] = {
-	[0] = { "SSID", print_ssid, 0, 32, },
-	[1] = { "Supported rates", print_supprates, 0, 255, },
-	[3] = { "DS Paramater set", print_ds, 1, 1, },
+	[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,
-	[7] = { "Country", print_country, 3, 255, },
-	[32] = { "Power constraint", print_powerconstraint, 1, 1, },
-	[42] = { "ERP", print_erp, 1, 255, },
-	[48] = { "RSN", print_rsn, 2, 255, },
-	[50] = { "Extended supported rates", print_supprates, 0, 255, },
-	[127] = { "Extended capabilities", print_capabilities, 0, 255, },
+	[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), },
+	[48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
+	[50] = { "Extended supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
+	[127] = { "Extended capabilities", print_capabilities, 0, 255, BIT(PRINT_SCAN), },
 };
 
 static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data)
 {
 	print_rsn_ie("TKIP", "IEEE 802.1X", len, data);
+}
+
+static bool print_wifi_wmm_param(const uint8_t *data, uint8_t len)
+{
+	int i;
+	static const char *aci_tbl[] = { "BE", "BK", "VI", "VO" };
+
+	if (len < 19)
+		goto invalid;
+
+	if (data[0] != 1) {
+		printf("Parameter: not version 1: ");
+		return false;
+	}
+
+	printf("\t* Parameter version 1");
+
+	data++;
+
+	if (data[0] & 0x80)
+		printf("\n\t\t* u-APSD");
+
+	data += 2;
+
+	for (i = 0; i < 4; i++) {
+		printf("\n\t\t* %s:", aci_tbl[(data[0] >> 5) & 3]);
+		if (data[4] & 0x10)
+			printf(" acm");
+		printf(" CW %d-%d", (1 << (data[1] & 0xf)) - 1,
+				    (1 << (data[1] >> 4)) - 1);
+		printf(", AIFSN %d", data[0] & 0xf);
+		if (data[2] | data[3])
+			printf(", TXOP %d usec", (data[2] + (data[3] << 8)) * 32);
+		data += 4;
+	}
+
+	printf("\n");
+	return true;
+
+ invalid:
+ 	printf("invalid: ");
+ 	return false;
 }
 
 static void print_wifi_wmm(const uint8_t type, uint8_t len, const uint8_t *data)
@@ -539,15 +579,16 @@
 		printf(" information:");
 		break;
 	case 0x01:
-		printf(" parameter:");
+		if (print_wifi_wmm_param(data + 1, len - 1))
+			return;
 		break;
 	default:
 		printf(" type %d:", data[0]);
 		break;
 	}
 
-	for(i = 0; i < len - 1; i++)
-		printf(" %.02x", data[i + 1]);
+	for(i = 1; i < len; i++)
+		printf(" %.02x", data[i]);
 	printf("\n");
 }
 
@@ -630,13 +671,13 @@
 }
 
 static const struct ie_print wifiprinters[] = {
-	[1] = { "WPA", print_wifi_wpa, 2, 255, },
-	[2] = { "WMM", print_wifi_wmm, 1, 255, },
-	[4] = { "WPS", print_wifi_wps, 0, 255, },
+	[1] = { "WPA", print_wifi_wpa, 2, 255, BIT(PRINT_SCAN), },
+	[2] = { "WMM", print_wifi_wmm, 1, 255, BIT(PRINT_SCAN), },
+	[4] = { "WPS", print_wifi_wps, 0, 255, BIT(PRINT_SCAN), },
 };
 
 static void print_vendor(unsigned char len, unsigned char *data,
-			 struct scan_params *params)
+			 bool unknown, enum print_ie_type ptype)
 {
 	int i;
 
@@ -649,11 +690,13 @@
 	}
 
 	if (len >= 4 && memcmp(data, wifi_oui, 3) == 0) {
-		if (data[3] < ARRAY_SIZE(wifiprinters) && wifiprinters[data[3]].name) {
+		if (data[3] < ARRAY_SIZE(wifiprinters) &&
+		    wifiprinters[data[3]].name &&
+		    wifiprinters[data[3]].flags & BIT(ptype)) {
 			print_ie(&wifiprinters[data[3]], data[3], len - 4, data + 4);
 			return;
 		}
-		if (!params->unknown)
+		if (!unknown)
 			return;
 		printf("\tWiFi OUI %#.2x, data:", data[3]);
 		for(i = 0; i < len - 4; i++)
@@ -662,7 +705,7 @@
 		return;
 	}
 
-	if (!params->unknown)
+	if (!unknown)
 		return;
 
 	printf("\tVendor specific: OUI %.2x:%.2x:%.2x, data:",
@@ -672,14 +715,17 @@
 	printf("\n");
 }
 
-static void print_ies(unsigned char *ie, int ielen, struct scan_params *params)
+void print_ies(unsigned char *ie, int ielen, bool unknown,
+	       enum print_ie_type ptype)
 {
 	while (ielen >= 2 && ielen >= ie[1]) {
-		if (ie[0] < ARRAY_SIZE(ieprinters) && ieprinters[ie[0]].name) {
+		if (ie[0] < ARRAY_SIZE(ieprinters) &&
+		    ieprinters[ie[0]].name &&
+		    ieprinters[ie[0]].flags & BIT(ptype)) {
 			print_ie(&ieprinters[ie[0]], ie[0], ie[1], ie + 2);
 		} else if (ie[0] == 221 /* vendor */) {
-			print_vendor(ie[1], ie + 2, params);
-		} else if (params->unknown) {
+			print_vendor(ie[1], ie + 2, unknown, ptype);
+		} else if (unknown) {
 			int i;
 
 			printf("\tUnknown IE (%d):", ie[0]);
@@ -709,6 +755,7 @@
 		[NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 },
 		[NL80211_BSS_STATUS] = { .type = NLA_U32 },
 	};
+	struct scan_params *params = arg;
 
 	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
 		  genlmsg_attrlen(gnlh, 0), NULL);
@@ -801,7 +848,7 @@
 	if (bss[NL80211_BSS_INFORMATION_ELEMENTS])
 		print_ies(nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]),
 			  nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]),
-			  arg);
+			  params->unknown, params->type);
 
 	return NL_SKIP;
 }
@@ -820,14 +867,12 @@
 	if (argc == 1 && !strcmp(argv[0], "-u"))
 		scan_params.unknown = true;
 
+	scan_params.type = PRINT_SCAN;
+
 	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_bss_handler,
 		  &scan_params);
 	return 0;
 }
-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.");
 
 static int handle_scan_combined(struct nl80211_state *state,
 				struct nl_cb *cb,
@@ -906,3 +951,11 @@
 	 "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.");
+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]",
+	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.");

Added: iw/branches/upstream/current/sections.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/sections.c?rev=1422&op=file
==============================================================================
--- iw/branches/upstream/current/sections.c (added)
+++ iw/branches/upstream/current/sections.c Thu Sep  3 21:13:00 2009
@@ -1,0 +1,4 @@
+#include "iw.h"
+
+SECTION(get);
+SECTION(set);

Modified: iw/branches/upstream/current/station.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/station.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/station.c (original)
+++ iw/branches/upstream/current/station.c Thu Sep  3 21:13:00 2009
@@ -10,6 +10,8 @@
 
 #include "nl80211.h"
 #include "iw.h"
+
+SECTION(station);
 
 enum plink_state {
 	LISTEN,
@@ -80,19 +82,19 @@
 	printf("Station %s (on %s)", mac_addr, dev);
 
 	if (sinfo[NL80211_STA_INFO_INACTIVE_TIME])
-		printf("\n\tinactive time:\t%d ms",
+		printf("\n\tinactive time:\t%u ms",
 			nla_get_u32(sinfo[NL80211_STA_INFO_INACTIVE_TIME]));
 	if (sinfo[NL80211_STA_INFO_RX_BYTES])
-		printf("\n\trx bytes:\t%d",
+		printf("\n\trx bytes:\t%u",
 			nla_get_u32(sinfo[NL80211_STA_INFO_RX_BYTES]));
 	if (sinfo[NL80211_STA_INFO_RX_PACKETS])
-		printf("\n\trx packets:\t%d",
+		printf("\n\trx packets:\t%u",
 			nla_get_u32(sinfo[NL80211_STA_INFO_RX_PACKETS]));
 	if (sinfo[NL80211_STA_INFO_TX_BYTES])
-		printf("\n\ttx bytes:\t%d",
+		printf("\n\ttx bytes:\t%u",
 			nla_get_u32(sinfo[NL80211_STA_INFO_TX_BYTES]));
 	if (sinfo[NL80211_STA_INFO_TX_PACKETS])
-		printf("\n\ttx packets:\t%d",
+		printf("\n\ttx packets:\t%u",
 			nla_get_u32(sinfo[NL80211_STA_INFO_TX_PACKETS]));
 	if (sinfo[NL80211_STA_INFO_SIGNAL])
 		printf("\n\tsignal:  \t%d dBm",

Modified: iw/branches/upstream/current/util.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/util.c?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/util.c (original)
+++ iw/branches/upstream/current/util.c Thu Sep  3 21:13:00 2009
@@ -5,7 +5,7 @@
 #include "iw.h"
 #include "nl80211.h"
 
-int mac_addr_n2a(char *mac_addr, unsigned char *arg)
+void mac_addr_n2a(char *mac_addr, unsigned char *arg)
 {
 	int i, l;
 
@@ -19,7 +19,6 @@
 			l += 3;
 		}
 	}
-	return 0;
 }
 
 int mac_addr_a2n(unsigned char *mac_addr, char *arg)
@@ -149,6 +148,7 @@
 {
 	struct nlattr *keys;
 	int i = 0;
+	bool have_default = false;
 	char keybuf[13];
 
 	if (!argc)
@@ -174,6 +174,7 @@
 			pos++;
 			if (arg[pos] == ':')
 				pos++;
+			have_default = true;
 		}
 
 		if (!isdigit(arg[pos]))
@@ -204,9 +205,14 @@
 
 		NLA_PUT(msg, NL80211_KEY_DATA, keylen, keydata);
 
-		nla_nest_end(msg, key);
 		argv++;
 		argc--;
+
+		/* one key should be TX key */
+		if (!have_default && !argc)
+			NLA_PUT_FLAG(msg, NL80211_KEY_DEFAULT);
+
+		nla_nest_end(msg, key);
 	} while (argc);
 
 	nla_nest_end(msg, keys);

Modified: iw/branches/upstream/current/version.sh
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/version.sh?rev=1422&op=diff
==============================================================================
--- iw/branches/upstream/current/version.sh (original)
+++ iw/branches/upstream/current/version.sh Thu Sep  3 21:13:00 2009
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-VERSION="0.9.15"
+VERSION="0.9.17"
 OUT="$1"
 
 echo '#include "iw.h"' > "$OUT"




More information about the Pkg-wpa-devel mailing list