[pkg-wpa-devel] r1404 - in /iw/branches/upstream/current: Makefile connect.c event.c ibss.c info.c iw.c iw.h nl80211.h reason.c scan.c util.c version.sh

kelmo-guest at users.alioth.debian.org kelmo-guest at users.alioth.debian.org
Tue Jul 21 08:19:30 UTC 2009


Author: kelmo-guest
Date: Tue Jul 21 08:19:29 2009
New Revision: 1404

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

Added:
    iw/branches/upstream/current/connect.c
Modified:
    iw/branches/upstream/current/Makefile
    iw/branches/upstream/current/event.c
    iw/branches/upstream/current/ibss.c
    iw/branches/upstream/current/info.c
    iw/branches/upstream/current/iw.c
    iw/branches/upstream/current/iw.h
    iw/branches/upstream/current/nl80211.h
    iw/branches/upstream/current/reason.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=1404&op=diff
==============================================================================
--- iw/branches/upstream/current/Makefile (original)
+++ iw/branches/upstream/current/Makefile Tue Jul 21 08:19:29 2009
@@ -5,6 +5,7 @@
 PREFIX ?= /usr
 BINDIR ?= $(PREFIX)/bin
 MANDIR ?= $(PREFIX)/share/man
+PKG_CONFIG ?= pkg-config
 
 MKDIR ?= mkdir -p
 INSTALL ?= install
@@ -13,11 +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
+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
 ALL = iw
 
-NL1FOUND := $(shell pkg-config --atleast-version=1 libnl-1 && echo Y)
-NL2FOUND := $(shell pkg-config --atleast-version=2 libnl-2.0 && echo Y)
+NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)
+NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y)
 
 ifeq ($(NL1FOUND),Y)
 NLLIBNAME = libnl-1

Added: iw/branches/upstream/current/connect.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/connect.c?rev=1404&op=file
==============================================================================
--- iw/branches/upstream/current/connect.c (added)
+++ iw/branches/upstream/current/connect.c Tue Jul 21 08:19:29 2009
@@ -1,0 +1,140 @@
+#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_conn(struct nl80211_state *state, struct nl_cb *cb,
+		   struct nl_msg *msg, int argc, char **argv)
+{
+	char *end;
+	unsigned char bssid[6];
+	int freq;
+
+	if (argc < 1)
+		return 1;
+
+	/* SSID */
+	NLA_PUT(msg, NL80211_ATTR_SSID, strlen(argv[0]), argv[0]);
+	argv++;
+	argc--;
+
+	/* freq */
+	if (argc) {
+		freq = strtoul(argv[0], &end, 10);
+		if (*end == '\0') {
+			NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
+			argv++;
+			argc--;
+		}
+	}
+
+	/* bssid */
+	if (argc) {
+		if (mac_addr_a2n(bssid, argv[0]) == 0) {
+			NLA_PUT(msg, NL80211_ATTR_MAC, 6, bssid);
+			argv++;
+			argc--;
+		}
+	}
+
+	if (!argc)
+		return 0;
+
+	if (strcmp(*argv, "key") != 0 && strcmp(*argv, "keys") != 0)
+		return 1;
+
+	argv++;
+	argc--;
+
+	return parse_keys(msg, argv, argc);
+ nla_put_failure:
+	return -ENOSPC;
+}
+
+static int disconnect(struct nl80211_state *state,
+		      struct nl_cb *cb,
+		      struct nl_msg *msg,
+		      int argc, char **argv)
+{
+	return 0;
+}
+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)
+{
+	char **conn_argv, *dev = argv[0];
+	static const __u32 cmds[] = {
+		NL80211_CMD_CONNECT,
+	};
+	struct print_event_args printargs = { };
+	int conn_argc, err;
+	bool wait = false;
+	int i;
+
+	/* strip "wlan0 connect" */
+	argc -= 2;
+	argv += 2;
+
+	/* check -w */
+	if (argc && strcmp(argv[0], "-w") == 0) {
+		wait = true;
+		argc--;
+		argv++;
+	}
+
+	conn_argc = 3 + argc;
+	conn_argv = calloc(conn_argc, sizeof(*conn_argv));
+	if (!conn_argv)
+		return -ENOMEM;
+	conn_argv[0] = dev;
+	conn_argv[1] = "conn";
+	conn_argv[2] = "establish";
+	for (i = 0; i < argc; i++)
+		conn_argv[i + 3] = argv[i];
+	err = handle_cmd(state, II_NETDEV, conn_argc, conn_argv);
+	free(conn_argv);
+	if (err)
+		return err;
+
+	if (!wait)
+		return 0;
+
+	/*
+	 * 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.
+	 *
+	 * 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.
+	 *
+	 * 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.
+	 *
+	 * Alas, the kernel doesn't do that (yet).
+	 */
+
+	__listen_events(state, ARRAY_SIZE(cmds), cmds, &printargs);
+	return 0;
+}
+TOPLEVEL(connect, "[-w] <SSID> [<freq in MHz>] [<bssid>] [key 0:abcde d:1:6162636465]",
+	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.");

Modified: iw/branches/upstream/current/event.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/event.c?rev=1404&op=diff
==============================================================================
--- iw/branches/upstream/current/event.c (original)
+++ iw/branches/upstream/current/event.c Tue Jul 21 08:19:29 2009
@@ -8,10 +8,6 @@
 {
 	return NL_OK;
 }
-
-struct print_event_args {
-	bool frame, time;
-};
 
 static void print_frame(struct print_event_args *args, struct nlattr *attr)
 {
@@ -75,11 +71,13 @@
 static int print_event(struct nl_msg *msg, void *arg)
 {
 	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
-	struct nlattr *tb[NL80211_ATTR_MAX + 1];
+	struct nlattr *tb[NL80211_ATTR_MAX + 1], *nst;
 	struct print_event_args *args = arg;
 	char ifname[100];
 	char macbuf[6*3];
 	__u8 reg_type;
+	int rem_nst;
+	__u16 status;
 
 	if (args->time) {
 		struct timeval tv;
@@ -104,11 +102,27 @@
 	case NL80211_CMD_NEW_WIPHY:
 		printf("renamed to %s\n", nla_get_string(tb[NL80211_ATTR_WIPHY_NAME]));
 		break;
+	case NL80211_CMD_TRIGGER_SCAN:
+		printf("scan started\n");
+		break;
 	case NL80211_CMD_NEW_SCAN_RESULTS:
-		printf("scan finished\n");
-		break;
+		printf("scan finished:");
 	case NL80211_CMD_SCAN_ABORTED:
-		printf("scan aborted\n");
+		if (gnlh->cmd == NL80211_CMD_SCAN_ABORTED)
+			printf("scan aborted:");
+		if (tb[NL80211_ATTR_SCAN_FREQUENCIES]) {
+			nla_for_each_nested(nst, tb[NL80211_ATTR_SCAN_FREQUENCIES], rem_nst)
+				printf(" %d", nla_get_u32(nst));
+			printf(",");
+		}
+		if (tb[NL80211_ATTR_SCAN_SSIDS]) {
+			nla_for_each_nested(nst, tb[NL80211_ATTR_SCAN_SSIDS], rem_nst) {
+				printf(" \"");
+				print_ssid_escaped(nla_len(nst), nla_data(nst));
+				printf("\"");
+			}
+		}
+		printf("\n");
 		break;
 	case NL80211_CMD_REG_CHANGE:
 		printf("regulatory domain change: ");
@@ -151,12 +165,22 @@
 		break;
 	case NL80211_CMD_AUTHENTICATE:
 		printf("auth");
-		print_frame(args, tb[NL80211_ATTR_FRAME]);
+		if (tb[NL80211_ATTR_FRAME])
+			print_frame(args, tb[NL80211_ATTR_FRAME]);
+		else if (tb[NL80211_ATTR_TIMED_OUT])
+			printf(": timed out");
+		else
+			printf(": unknown event");
 		printf("\n");
 		break;
 	case NL80211_CMD_ASSOCIATE:
 		printf("assoc");
-		print_frame(args, tb[NL80211_ATTR_FRAME]);
+		if (tb[NL80211_ATTR_FRAME])
+			print_frame(args, tb[NL80211_ATTR_FRAME]);
+		else if (tb[NL80211_ATTR_TIMED_OUT])
+			printf(": timed out");
+		else
+			printf(": unknown event");
 		printf("\n");
 		break;
 	case NL80211_CMD_DEAUTHENTICATE:
@@ -167,6 +191,43 @@
 	case NL80211_CMD_DISASSOCIATE:
 		printf("disassoc");
 		print_frame(args, tb[NL80211_ATTR_FRAME]);
+		printf("\n");
+		break;
+	case NL80211_CMD_CONNECT:
+		status = 0;
+		if (!tb[NL80211_ATTR_STATUS_CODE])
+			printf("unknown connect status");
+		else if (nla_get_u16(tb[NL80211_ATTR_STATUS_CODE]) == 0)
+			printf("connected");
+		else {
+			status = nla_get_u16(tb[NL80211_ATTR_STATUS_CODE]);
+			printf("failed to connect");
+		}
+		if (tb[NL80211_ATTR_MAC]) {
+			mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
+			printf(" to %s", macbuf);
+		}
+		if (status)
+			printf(", status: %d: %s", status, get_status_str(status));
+		printf("\n");
+		break;
+	case NL80211_CMD_ROAM:
+		printf("roamed");
+		if (tb[NL80211_ATTR_MAC]) {
+			mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
+			printf(" to %s", macbuf);
+		}
+		printf("\n");
+		break;
+	case NL80211_CMD_DISCONNECT:
+		printf("disconnected");
+		if (tb[NL80211_ATTR_DISCONNECTED_BY_AP])
+			printf(" (by AP)");
+		else
+			printf(" (local request)");
+		if (tb[NL80211_ATTR_REASON_CODE])
+			printf(" reason: %d: %s", nla_get_u16(tb[NL80211_ATTR_REASON_CODE]),
+				get_reason_str(nla_get_u16(tb[NL80211_ATTR_REASON_CODE])));
 		printf("\n");
 		break;
 	default:
@@ -181,6 +242,7 @@
 	int n_cmds;
 	const __u32 *cmds;
 	__u32 cmd;
+	struct print_event_args *pargs;
 };
 
 static int wait_event(struct nl_msg *msg, void *arg)
@@ -192,15 +254,17 @@
 	for (i = 0; i < wait->n_cmds; i++) {
 		if (gnlh->cmd == wait->cmds[i]) {
 			wait->cmd = gnlh->cmd;
+		if (wait->pargs)
+			print_event(msg, wait->pargs);
 		}
 	}
 
 	return NL_SKIP;
 }
 
-static __u32 __listen_events(struct nl80211_state *state,
-			     const int n_waits, const __u32 *waits,
-			     struct print_event_args *args)
+__u32 __listen_events(struct nl80211_state *state,
+		      const int n_waits, const __u32 *waits,
+		      struct print_event_args *args)
 {
 	int mcid, ret;
 	struct nl_cb *cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
@@ -250,10 +314,10 @@
 	if (n_waits && waits) {
 		wait_ev.cmds = waits;
 		wait_ev.n_cmds = n_waits;
+		wait_ev.pargs = args;
 		nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, wait_event, &wait_ev);
-	} else {
+	} else
 		nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_event, args);
-	}
 
 	wait_ev.cmd = 0;
 

Modified: iw/branches/upstream/current/ibss.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/ibss.c?rev=1404&op=diff
==============================================================================
--- iw/branches/upstream/current/ibss.c (original)
+++ iw/branches/upstream/current/ibss.c Tue Jul 21 08:19:29 2009
@@ -40,17 +40,23 @@
 	}
 
 	if (argc) {
-		if (mac_addr_a2n(abssid, argv[0]))
-			return 1;
-		NLA_PUT(msg, NL80211_ATTR_MAC, 6, abssid);
-		argv++;
-		argc--;
+		if (mac_addr_a2n(abssid, argv[0]) == 0) {
+			NLA_PUT(msg, NL80211_ATTR_MAC, 6, abssid);
+			argv++;
+			argc--;
+		}
 	}
 
-	if (argc)
+	if (!argc)
+		return 0;
+
+	if (strcmp(*argv, "key") != 0 && strcmp(*argv, "keys") != 0)
 		return 1;
 
-	return 0;
+	argv++;
+	argc--;
+
+	return parse_keys(msg, argv, argc);
  nla_put_failure:
 	return -ENOSPC;
 }
@@ -65,7 +71,7 @@
 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>]",
+COMMAND(ibss, join, "<SSID> <freq in MHz> [fixed-freq] [<fixed bssid>] [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=1404&op=diff
==============================================================================
--- iw/branches/upstream/current/info.c (original)
+++ iw/branches/upstream/current/info.c Tue Jul 21 08:19:29 2009
@@ -226,7 +226,7 @@
 			printf("\n");
 		}
 
-		printf("\t\tBitrates:\n");
+		printf("\t\tBitrates (non-HT):\n");
 
 		nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
 			nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, nla_data(nl_rate),

Modified: iw/branches/upstream/current/iw.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/iw.c?rev=1404&op=diff
==============================================================================
--- iw/branches/upstream/current/iw.c (original)
+++ iw/branches/upstream/current/iw.c Tue Jul 21 08:19:29 2009
@@ -168,6 +168,10 @@
 			continue;
 		__usage_cmd(cmd, "\t", full);
 	}
+	fprintf(stderr, "\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");
 }
 
 static int print_help(struct nl80211_state *state,
@@ -432,9 +436,17 @@
 		} else if (*(*argv + 3) == '#')
 			err = __handle_cmd(&nlstate, II_PHY_IDX, argc, argv, &cmd);
 		else
-			err = 1;
-	} else
-		err = __handle_cmd(&nlstate, II_NONE, argc, argv, &cmd);
+			goto detect;
+	} else {
+		int idx;
+		enum id_input idby = II_NONE;
+ detect:
+		if ((idx = if_nametoindex(argv[0])) != 0)
+			idby = II_NETDEV;
+		else if ((idx = phy_lookup(argv[0])) >= 0)
+			idby = II_PHY_NAME;
+		err = __handle_cmd(&nlstate, idby, argc, argv, &cmd);
+	}
 
 	if (err == 1) {
 		if (cmd)

Modified: iw/branches/upstream/current/iw.h
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/iw.h?rev=1404&op=diff
==============================================================================
--- iw/branches/upstream/current/iw.h (original)
+++ iw/branches/upstream/current/iw.h Tue Jul 21 08:19:29 2009
@@ -1,6 +1,7 @@
 #ifndef __IW_H
 #define __IW_H
 
+#include <stdbool.h>
 #include <netlink/netlink.h>
 #include <netlink/genl/genl.h>
 #include <netlink/genl/family.h>
@@ -84,16 +85,28 @@
 
 int handle_cmd(struct nl80211_state *state, enum id_input idby,
 	       int argc, char **argv);
+
+struct print_event_args {
+	bool frame, time;
+};
+
 __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 mac_addr_a2n(unsigned char *mac_addr, char *arg);
 int mac_addr_n2a(char *mac_addr, unsigned char *arg);
 
+int parse_keys(struct nl_msg *msg, char **argv, int argc);
+
 const char *iftype_name(enum nl80211_iftype iftype);
 int ieee80211_channel_to_frequency(int chan);
 int ieee80211_frequency_to_channel(int freq);
+
+void print_ssid_escaped(const uint8_t len, const uint8_t *data);
 
 int nl_get_multicast_id(struct nl_sock *sock, const char *family, const char *group);
 

Modified: iw/branches/upstream/current/nl80211.h
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/nl80211.h?rev=1404&op=diff
==============================================================================
--- iw/branches/upstream/current/nl80211.h (original)
+++ iw/branches/upstream/current/nl80211.h Tue Jul 21 08:19:29 2009
@@ -24,6 +24,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  */
+
+#include <linux/types.h>
 
 /**
  * DOC: Station handling
@@ -77,8 +79,8 @@
  * @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT,
  *	%NL80211_ATTR_KEY_DEFAULT_MGMT, or %NL80211_ATTR_KEY_THRESHOLD.
  * @NL80211_CMD_NEW_KEY: add a key with given %NL80211_ATTR_KEY_DATA,
- *	%NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC and %NL80211_ATTR_KEY_CIPHER
- *	attributes.
+ *	%NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC, %NL80211_ATTR_KEY_CIPHER,
+ *	and %NL80211_ATTR_KEY_SEQ attributes.
  * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
  *	or %NL80211_ATTR_MAC.
  *
@@ -203,8 +205,12 @@
  *	frame, i.e., it was for the local STA and was received in correct
  *	state. This is similar to MLME-AUTHENTICATE.confirm primitive in the
  *	MLME SAP interface (kernel providing MLME, userspace SME). The
- *	included NL80211_ATTR_FRAME attribute contains the management frame
- *	(including both the header and frame body, but not FCS).
+ *	included %NL80211_ATTR_FRAME attribute contains the management frame
+ *	(including both the header and frame body, but not FCS). This event is
+ *	also used to indicate if the authentication attempt timed out. In that
+ *	case the %NL80211_ATTR_FRAME attribute is replaced with a
+ *	%NL80211_ATTR_TIMED_OUT flag (and %NL80211_ATTR_MAC to indicate which
+ *	pending authentication timed out).
  * @NL80211_CMD_ASSOCIATE: association request and notification; like
  *	NL80211_CMD_AUTHENTICATE but for Association and Reassociation
  *	(similar to MLME-ASSOCIATE.request, MLME-REASSOCIATE.request,
@@ -230,9 +236,31 @@
  *	and optionally a MAC (as BSSID) and FREQ_FIXED attribute if those
  *	should be fixed rather than automatically determined. Can only be
  *	executed on a network interface that is UP, and fixed BSSID/FREQ
- *	may be rejected.
+ *	may be rejected. Another optional parameter is the beacon interval,
+ *	given in the %NL80211_ATTR_BEACON_INTERVAL attribute, which if not
+ *	given defaults to 100 TU (102.4ms).
  * @NL80211_CMD_LEAVE_IBSS: Leave the IBSS -- no special arguments, the IBSS is
  *	determined by the network interface.
+ *
+ * @NL80211_CMD_TESTMODE: testmode command, takes a wiphy (or ifindex) attribute
+ *	to identify the device, and the TESTDATA blob attribute to pass through
+ *	to the driver.
+ *
+ * @NL80211_CMD_CONNECT: connection request and notification; this command
+ *	requests to connect to a specified network but without separating
+ *	auth and assoc steps. For this, you need to specify the SSID in a
+ *	%NL80211_ATTR_SSID attribute, and can optionally specify the association
+ *	IEs in %NL80211_ATTR_IE, %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_MAC,
+ *	%NL80211_ATTR_WIPHY_FREQ and %NL80211_ATTR_CONTROL_PORT.
+ *	It is also sent as an event, with the BSSID and response IEs when the
+ *	connection is established or failed to be established. This can be
+ *	determined by the STATUS_CODE attribute.
+ * @NL80211_CMD_ROAM: request that the card roam (currently not implemented),
+ *	sent as an event when the card/driver roamed by itself.
+ * @NL80211_CMD_DISCONNECT: drop a given connection; also used to notify
+ *	userspace that a connection was dropped by the AP or due to other
+ *	reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and
+ *	%NL80211_ATTR_REASON_CODE attributes are used.
  *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
@@ -301,6 +329,12 @@
 
 	NL80211_CMD_JOIN_IBSS,
 	NL80211_CMD_LEAVE_IBSS,
+
+	NL80211_CMD_TESTMODE,
+
+	NL80211_CMD_CONNECT,
+	NL80211_CMD_ROAM,
+	NL80211_CMD_DISCONNECT,
 
 	/* add new commands above here */
 
@@ -374,7 +408,7 @@
  *
  * @NL80211_ATTR_STA_AID: Association ID for the station (u16)
  * @NL80211_ATTR_STA_FLAGS: flags, nested element with NLA_FLAG attributes of
- *	&enum nl80211_sta_flags.
+ *	&enum nl80211_sta_flags (deprecated, use %NL80211_ATTR_STA_FLAGS2)
  * @NL80211_ATTR_STA_LISTEN_INTERVAL: listen interval as defined by
  *	IEEE 802.11 7.3.1.6 (u16).
  * @NL80211_ATTR_STA_SUPPORTED_RATES: supported rates, array of supported
@@ -485,6 +519,60 @@
  * @NL80211_ATTR_FREQ_FIXED: a flag indicating the IBSS should not try to look
  *	for other networks on different channels
  *
+ * @NL80211_ATTR_TIMED_OUT: a flag indicating than an operation timed out; this
+ *	is used, e.g., with %NL80211_CMD_AUTHENTICATE event
+ *
+ * @NL80211_ATTR_USE_MFP: Whether management frame protection (IEEE 802.11w) is
+ *	used for the association (&enum nl80211_mfp, represented as a u32);
+ *	this attribute can be used
+ *	with %NL80211_CMD_ASSOCIATE request
+ *
+ * @NL80211_ATTR_STA_FLAGS2: Attribute containing a
+ *	&struct nl80211_sta_flag_update.
+ *
+ * @NL80211_ATTR_CONTROL_PORT: A flag indicating whether user space controls
+ *	IEEE 802.1X port, i.e., sets/clears %NL80211_STA_FLAG_AUTHORIZED, in
+ *	station mode. If the flag is included in %NL80211_CMD_ASSOCIATE
+ *	request, the driver will assume that the port is unauthorized until
+ *	authorized by user space. Otherwise, port is marked authorized by
+ *	default in station mode.
+ *
+ * @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver.
+ *	We recommend using nested, driver-specific attributes within this.
+ *
+ * @NL80211_ATTR_DISCONNECTED_BY_AP: A flag indicating that the DISCONNECT
+ *	event was due to the AP disconnecting the station, and not due to
+ *	a local disconnect request.
+ * @NL80211_ATTR_STATUS_CODE: StatusCode for the %NL80211_CMD_CONNECT
+ *	event (u16)
+ * @NL80211_ATTR_PRIVACY: Flag attribute, used with connect(), indicating
+ *	that protected APs should be used.
+ *
+ * @NL80211_ATTR_CIPHERS_PAIRWISE: Used with CONNECT and ASSOCIATE to
+ *	indicate which unicast key ciphers will be used with the connection
+ *	(an array of u32).
+ * @NL80211_ATTR_CIPHER_GROUP: Used with CONNECT and ASSOCIATE to indicate
+ *	which group key cipher will be used with the connection (a u32).
+ * @NL80211_ATTR_WPA_VERSIONS: Used with CONNECT and ASSOCIATE to indicate
+ *	which WPA version(s) the AP we want to associate with is using
+ *	(a u32 with flags from &enum nl80211_wpa_versions).
+ * @NL80211_ATTR_AKM_SUITES: Used with CONNECT and ASSOCIATE to indicate
+ *	which key management algorithm(s) to use (an array of u32).
+ *
+ * @NL80211_ATTR_REQ_IE: (Re)association request information elements as
+ *	sent out by the card, for ROAM and successful CONNECT events.
+ * @NL80211_ATTR_RESP_IE: (Re)association response information elements as
+ *	sent by peer, for ROAM and successful CONNECT events.
+ *
+ * @NL80211_ATTR_PREV_BSSID: previous BSSID, to be used by in ASSOCIATE
+ *	commands to specify using a reassociate frame
+ *
+ * @NL80211_ATTR_KEY: key information in a nested attribute with
+ *	%NL80211_KEY_* sub-attributes
+ * @NL80211_ATTR_KEYS: array of keys for static WEP keys for connect()
+ *	and join_ibss(), key information is in a nested attribute each
+ *	with %NL80211_KEY_* sub-attributes
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -585,6 +673,34 @@
 	NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
 	NL80211_ATTR_WIPHY_RTS_THRESHOLD,
 
+	NL80211_ATTR_TIMED_OUT,
+
+	NL80211_ATTR_USE_MFP,
+
+	NL80211_ATTR_STA_FLAGS2,
+
+	NL80211_ATTR_CONTROL_PORT,
+
+	NL80211_ATTR_TESTDATA,
+
+	NL80211_ATTR_PRIVACY,
+
+	NL80211_ATTR_DISCONNECTED_BY_AP,
+	NL80211_ATTR_STATUS_CODE,
+
+	NL80211_ATTR_CIPHER_SUITES_PAIRWISE,
+	NL80211_ATTR_CIPHER_SUITE_GROUP,
+	NL80211_ATTR_WPA_VERSIONS,
+	NL80211_ATTR_AKM_SUITES,
+
+	NL80211_ATTR_REQ_IE,
+	NL80211_ATTR_RESP_IE,
+
+	NL80211_ATTR_PREV_BSSID,
+
+	NL80211_ATTR_KEY,
+	NL80211_ATTR_KEYS,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -595,6 +711,7 @@
  * Allow user space programs to use #ifdef on new attributes by defining them
  * here
  */
+#define NL80211_CMD_CONNECT NL80211_CMD_CONNECT
 #define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY
 #define NL80211_ATTR_BSS_BASIC_RATES NL80211_ATTR_BSS_BASIC_RATES
 #define NL80211_ATTR_WIPHY_TXQ_PARAMS NL80211_ATTR_WIPHY_TXQ_PARAMS
@@ -608,6 +725,12 @@
 #define NL80211_ATTR_SSID NL80211_ATTR_SSID
 #define NL80211_ATTR_AUTH_TYPE NL80211_ATTR_AUTH_TYPE
 #define NL80211_ATTR_REASON_CODE NL80211_ATTR_REASON_CODE
+#define NL80211_ATTR_CIPHER_SUITES_PAIRWISE NL80211_ATTR_CIPHER_SUITES_PAIRWISE
+#define NL80211_ATTR_CIPHER_SUITE_GROUP NL80211_ATTR_CIPHER_SUITE_GROUP
+#define NL80211_ATTR_WPA_VERSIONS NL80211_ATTR_WPA_VERSIONS
+#define NL80211_ATTR_AKM_SUITES NL80211_ATTR_AKM_SUITES
+#define NL80211_ATTR_KEY NL80211_ATTR_KEY
+#define NL80211_ATTR_KEYS NL80211_ATTR_KEYS
 
 #define NL80211_MAX_SUPP_RATES			32
 #define NL80211_MAX_SUPP_REG_RULES		32
@@ -615,6 +738,9 @@
 #define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY	16
 #define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY	24
 #define NL80211_HT_CAPABILITY_LEN		26
+
+#define NL80211_MAX_NR_CIPHER_SUITES		5
+#define NL80211_MAX_NR_AKM_SUITES		2
 
 /**
  * enum nl80211_iftype - (virtual) interface types
@@ -672,6 +798,18 @@
 	__NL80211_STA_FLAG_AFTER_LAST,
 	NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
 };
+
+/**
+ * struct nl80211_sta_flag_update - station flags mask/set
+ * @mask: mask of station flags to set
+ * @set: which values to set them to
+ *
+ * Both mask and set contain bits as per &enum nl80211_sta_flags.
+ */
+struct nl80211_sta_flag_update {
+	__u32 mask;
+	__u32 set;
+} __attribute__((packed));
 
 /**
  * enum nl80211_rate_info - bitrate information
@@ -1122,6 +1260,7 @@
  *	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_AFTER_LAST: internal
  * @NL80211_BSS_MAX: highest BSS attribute
  */
@@ -1135,10 +1274,20 @@
 	NL80211_BSS_INFORMATION_ELEMENTS,
 	NL80211_BSS_SIGNAL_MBM,
 	NL80211_BSS_SIGNAL_UNSPEC,
+	NL80211_BSS_STATUS,
 
 	/* keep last */
 	__NL80211_BSS_AFTER_LAST,
 	NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_bss_status - BSS "status"
+ */
+enum nl80211_bss_status {
+	NL80211_BSS_STATUS_AUTHENTICATED,
+	NL80211_BSS_STATUS_ASSOCIATED,
+	NL80211_BSS_STATUS_IBSS_JOINED,
 };
 
 /**
@@ -1148,12 +1297,22 @@
  * @NL80211_AUTHTYPE_SHARED_KEY: Shared Key authentication (WEP only)
  * @NL80211_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r)
  * @NL80211_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP)
+ * @__NL80211_AUTHTYPE_NUM: internal
+ * @NL80211_AUTHTYPE_MAX: maximum valid auth algorithm
+ * @NL80211_AUTHTYPE_AUTOMATIC: determine automatically (if necessary by
+ *	trying multiple times); this is invalid in netlink -- leave out
+ *	the attribute for this on CONNECT commands.
  */
 enum nl80211_auth_type {
 	NL80211_AUTHTYPE_OPEN_SYSTEM,
 	NL80211_AUTHTYPE_SHARED_KEY,
 	NL80211_AUTHTYPE_FT,
 	NL80211_AUTHTYPE_NETWORK_EAP,
+
+	/* keep last */
+	__NL80211_AUTHTYPE_NUM,
+	NL80211_AUTHTYPE_MAX = __NL80211_AUTHTYPE_NUM - 1,
+	NL80211_AUTHTYPE_AUTOMATIC
 };
 
 /**
@@ -1168,4 +1327,49 @@
 	NL80211_KEYTYPE_PEERKEY,
 };
 
+/**
+ * enum nl80211_mfp - Management frame protection state
+ * @NL80211_MFP_NO: Management frame protection not used
+ * @NL80211_MFP_REQUIRED: Management frame protection required
+ */
+enum nl80211_mfp {
+	NL80211_MFP_NO,
+	NL80211_MFP_REQUIRED,
+};
+
+enum nl80211_wpa_versions {
+	NL80211_WPA_VERSION_1 = 1 << 0,
+	NL80211_WPA_VERSION_2 = 1 << 1,
+};
+
+/**
+ * enum nl80211_key_attributes - key attributes
+ * @__NL80211_KEY_INVALID: invalid
+ * @NL80211_KEY_DATA: (temporal) key data; for TKIP this consists of
+ *	16 bytes encryption key followed by 8 bytes each for TX and RX MIC
+ *	keys
+ * @NL80211_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ *	section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ *	CCMP keys, each six bytes in little endian
+ * @NL80211_KEY_DEFAULT: flag indicating default key
+ * @NL80211_KEY_DEFAULT_MGMT: flag indicating default management key
+ * @__NL80211_KEY_AFTER_LAST: internal
+ * @NL80211_KEY_MAX: highest key attribute
+ */
+enum nl80211_key_attributes {
+	__NL80211_KEY_INVALID,
+	NL80211_KEY_DATA,
+	NL80211_KEY_IDX,
+	NL80211_KEY_CIPHER,
+	NL80211_KEY_SEQ,
+	NL80211_KEY_DEFAULT,
+	NL80211_KEY_DEFAULT_MGMT,
+
+	/* keep last */
+	__NL80211_KEY_AFTER_LAST,
+	NL80211_KEY_MAX = __NL80211_KEY_AFTER_LAST - 1
+};
+
 #endif /* __LINUX_NL80211_H */

Modified: iw/branches/upstream/current/reason.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/reason.c?rev=1404&op=diff
==============================================================================
--- iw/branches/upstream/current/reason.c (original)
+++ iw/branches/upstream/current/reason.c Tue Jul 21 08:19:29 2009
@@ -26,7 +26,7 @@
 	[23] = "IEEE 802.1X authentication failed",
 	[24] = "Cipher Suite rejected per security policy",
 	[31] = "TS deleted because QoS AP lacks sufficient bandwidth for this QoS STA due to a change in BSS service characteristics or operational mode",
-	[32] = "Disassociated for unspecified] =  QoS-related reason",
+	[32] = "Disassociated for unspecified QoS-related reason",
 	[33] = "Disassociated because QAP lacks sufficient bandwidth for this STA",
 	[34] = "Disassociated because of excessive frame losses and/or poor channel conditions",
 	[35] = "Disassociated because QSTA is transmitting outside the limits of its polled TXOPs",

Modified: iw/branches/upstream/current/scan.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/scan.c?rev=1404&op=diff
==============================================================================
--- iw/branches/upstream/current/scan.c (original)
+++ iw/branches/upstream/current/scan.c Tue Jul 21 08:19:29 2009
@@ -122,16 +122,8 @@
 
 static void print_ssid(const uint8_t type, uint8_t len, const uint8_t *data)
 {
-	int i;
-
 	printf(" ");
-
-	for (i = 0; i < len; i++) {
-		if (isprint(data[i]))
-			printf("%c", data[i]);
-		else
-			printf("\\x%.2x", data[i]);
-	}
+	print_ssid_escaped(len, data);
 	printf("\n");
 }
 
@@ -588,9 +580,9 @@
 			printf("\t * Model: %.*s\n", sublen, data + 4);
 			break;
 		case 0x1057: {
-			__u16 val = (data[4] << 8) | data[5];
+			__u8 val = data[4];
 			tab_on_first(&first);
-			printf("\t * AP setup locked: 0x%.4x\n", val);
+			printf("\t * AP setup locked: 0x%.2x\n", val);
 			break;
 		}
 		case 0x1008: {
@@ -715,6 +707,7 @@
 		[NL80211_BSS_INFORMATION_ELEMENTS] = { },
 		[NL80211_BSS_SIGNAL_MBM] = { .type = NLA_U32 },
 		[NL80211_BSS_SIGNAL_UNSPEC] = { .type = NLA_U8 },
+		[NL80211_BSS_STATUS] = { .type = NLA_U32 },
 	};
 
 	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
@@ -736,7 +729,26 @@
 
 	mac_addr_n2a(mac_addr, nla_data(bss[NL80211_BSS_BSSID]));
 	if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), dev);
-	printf("BSS %s (on %s)\n", mac_addr, dev);
+	printf("BSS %s (on %s)", mac_addr, dev);
+
+	if (bss[NL80211_BSS_STATUS]) {
+		switch (nla_get_u32(bss[NL80211_BSS_STATUS])) {
+		case NL80211_BSS_STATUS_AUTHENTICATED:
+			printf(" -- authenticated");
+			break;
+		case NL80211_BSS_STATUS_ASSOCIATED:
+			printf(" -- associated");
+			break;
+		case NL80211_BSS_STATUS_IBSS_JOINED:
+			printf(" -- joined");
+			break;
+		default:
+			printf(" -- unknown status: %d",
+				nla_get_u32(bss[NL80211_BSS_STATUS]));
+			break;
+		}
+	}
+	printf("\n");
 
 	if (bss[NL80211_BSS_TSF]) {
 		unsigned long long tsf;

Modified: iw/branches/upstream/current/util.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/util.c?rev=1404&op=diff
==============================================================================
--- iw/branches/upstream/current/util.c (original)
+++ iw/branches/upstream/current/util.c Tue Jul 21 08:19:29 2009
@@ -1,3 +1,7 @@
+#include <ctype.h>
+#include <netlink/attr.h>
+#include <errno.h>
+#include <stdbool.h>
 #include "iw.h"
 #include "nl80211.h"
 
@@ -89,3 +93,133 @@
 	/* FIXME: dot11ChannelStartingFactor (802.11-2007 17.3.8.3.2) */
 	return freq/5 - 1000;
 }
+
+void print_ssid_escaped(const uint8_t len, const uint8_t *data)
+{
+	int i;
+
+	for (i = 0; i < len; i++) {
+		if (isprint(data[i]))
+			printf("%c", data[i]);
+		else
+			printf("\\x%.2x", data[i]);
+	}
+}
+
+static int hex2num(char digit)
+{
+	if (!isxdigit(digit))
+		return -1;
+	if (isdigit(digit))
+		return digit - '0';
+	return tolower(digit) - 'a' + 10;
+}
+
+static int hex2byte(char *hex)
+{
+	int d1, d2;
+
+	d1 = hex2num(hex[0]);
+	if (d1 < 0)
+		return -1;
+	d2 = hex2num(hex[1]);
+	if (d2 < 0)
+		return -1;
+	return (d1 << 4) | d2;
+}
+
+static char *hex2bin(char *hex, char *buf)
+{
+	char *result = buf;
+	int d;
+
+	while (hex[0]) {
+		d = hex2byte(hex);
+		if (d < 0)
+			return NULL;
+		buf[0] = d;
+		buf++;
+		hex += 2;
+	}
+
+	return result;
+}
+
+int parse_keys(struct nl_msg *msg, char **argv, int argc)
+{
+	struct nlattr *keys;
+	int i = 0;
+	char keybuf[13];
+
+	if (!argc)
+		return 1;
+
+	NLA_PUT_FLAG(msg, NL80211_ATTR_PRIVACY);
+
+	keys = nla_nest_start(msg, NL80211_ATTR_KEYS);
+	if (!keys)
+		return -ENOBUFS;
+
+	do {
+		char *arg = *argv;
+		int pos = 0, keylen;
+		struct nlattr *key = nla_nest_start(msg, ++i);
+		char *keydata;
+
+		if (!key)
+			return -ENOBUFS;
+
+		if (arg[pos] == 'd') {
+			NLA_PUT_FLAG(msg, NL80211_KEY_DEFAULT);
+			pos++;
+			if (arg[pos] == ':')
+				pos++;
+		}
+
+		if (!isdigit(arg[pos]))
+			goto explain;
+		NLA_PUT_U8(msg, NL80211_KEY_IDX, arg[pos++] - '0');
+		if (arg[pos++] != ':')
+			goto explain;
+		keydata = arg + pos;
+		switch (strlen(keydata)) {
+		case 10:
+			keydata = hex2bin(keydata, keybuf);
+		case 5:
+			NLA_PUT_U32(msg, NL80211_KEY_CIPHER, 0x000FAC01);
+			keylen = 5;
+			break;
+		case 26:
+			keydata = hex2bin(keydata, keybuf);
+		case 13:
+			NLA_PUT_U32(msg, NL80211_KEY_CIPHER, 0x000FAC05);
+			keylen = 13;
+			break;
+		default:
+			goto explain;
+		}
+
+		if (!keydata)
+			goto explain;
+
+		NLA_PUT(msg, NL80211_KEY_DATA, keylen, keydata);
+
+		nla_nest_end(msg, key);
+		argv++;
+		argc--;
+	} while (argc);
+
+	nla_nest_end(msg, keys);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+ explain:
+	fprintf(stderr, "key must be [d:]index:data where\n"
+			"  'd:'     means default (transmit) key\n"
+			"  'index:' is a single digit (0-3)\n"
+			"  'data'   must be 5 or 13 ascii chars\n"
+			"           or 10 or 26 hex digits\n"
+			"for example: d:2:6162636465 is the same as d:2:abcde\n");
+	return 2;
+}

Modified: iw/branches/upstream/current/version.sh
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/version.sh?rev=1404&op=diff
==============================================================================
--- iw/branches/upstream/current/version.sh (original)
+++ iw/branches/upstream/current/version.sh Tue Jul 21 08:19:29 2009
@@ -1,7 +1,9 @@
 #!/bin/sh
 
-VERSION="0.9.14"
+VERSION="0.9.15"
 OUT="$1"
+
+echo '#include "iw.h"' > "$OUT"
 
 if head=`git rev-parse --verify HEAD 2>/dev/null`; then
 	git update-index --refresh --unmerged > /dev/null
@@ -11,7 +13,6 @@
 	# is correct...
 	[ "${descr%%-*}" = "v$VERSION" ] || exit 2
 
-	echo -n 'const char iw_version[] = "' > "$OUT"
 	v="${descr#v}"
 	if git diff-index --name-only HEAD | read dummy ; then
 		v="$v"-dirty
@@ -20,4 +21,4 @@
 	v="$VERSION"
 fi
 
-echo "const char iw_version[] = \"$v\";" > "$OUT"
+echo "const char iw_version[] = \"$v\";" >> "$OUT"




More information about the Pkg-wpa-devel mailing list