[pkg-wpa-devel] r1239 - in /iw: ./ branches/ branches/upstream/ branches/upstream/current/ branches/upstream/current/debian/

kelmo-guest at users.alioth.debian.org kelmo-guest at users.alioth.debian.org
Fri Sep 19 14:42:50 UTC 2008


Author: kelmo-guest
Date: Fri Sep 19 14:42:49 2008
New Revision: 1239

URL: http://svn.debian.org/wsvn/?sc=1&rev=1239
Log:
[svn-inject] Installing original source of iw

Added:
    iw/
    iw/branches/
    iw/branches/upstream/
    iw/branches/upstream/current/
    iw/branches/upstream/current/.gitignore
    iw/branches/upstream/current/.gitmodules
    iw/branches/upstream/current/COPYING
    iw/branches/upstream/current/Makefile
    iw/branches/upstream/current/README
    iw/branches/upstream/current/debian/
    iw/branches/upstream/current/defconfig
    iw/branches/upstream/current/info.c
    iw/branches/upstream/current/interface.c
    iw/branches/upstream/current/iw.8
    iw/branches/upstream/current/iw.c
    iw/branches/upstream/current/iw.h
    iw/branches/upstream/current/mpath.c
    iw/branches/upstream/current/nl80211.h
    iw/branches/upstream/current/phy.c
    iw/branches/upstream/current/reg.c
    iw/branches/upstream/current/station.c
    iw/branches/upstream/current/util.c
    iw/branches/upstream/current/version.sh   (with props)

Added: iw/branches/upstream/current/.gitignore
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/.gitignore?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/.gitignore (added)
+++ iw/branches/upstream/current/.gitignore Fri Sep 19 14:42:49 2008
@@ -1,0 +1,7 @@
+iw
+*~
+*.o
+.config
+version.h
+iw.8.gz
+*-stamp

Added: iw/branches/upstream/current/.gitmodules
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/.gitmodules?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/.gitmodules (added)
+++ iw/branches/upstream/current/.gitmodules Fri Sep 19 14:42:49 2008
@@ -1,0 +1,3 @@
+[submodule "debian"]
+	path = debian
+	url = http://git.sipsolutions.net/iw-debian.git/

Added: iw/branches/upstream/current/COPYING
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/COPYING?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/COPYING (added)
+++ iw/branches/upstream/current/COPYING Fri Sep 19 14:42:49 2008
@@ -1,0 +1,29 @@
+Copyright (c) 2007, 2008	Johannes Berg
+Copyright (c) 2007		Andy Lutomirski
+Copyright (c) 2007		Mike Kershaw
+Copyright (c) 2008		Luis R. Rodriguez
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer. 
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.

Added: iw/branches/upstream/current/Makefile
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/Makefile?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/Makefile (added)
+++ iw/branches/upstream/current/Makefile Fri Sep 19 14:42:49 2008
@@ -1,0 +1,59 @@
+-include .config
+
+MAKEFLAGS += --no-print-directory
+
+MKDIR ?= mkdir -p
+INSTALL ?= install
+PREFIX ?= /usr
+CC ?= "gcc"
+CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration `pkg-config --cflags libnl-1`
+CFLAGS += -O2 -g
+LDFLAGS += `pkg-config --libs libnl-1`
+NLVERSION = 1.0
+
+OBJS = iw.o info.o phy.o interface.o station.o util.o mpath.o reg.o
+ALL = iw
+
+ifeq ($(V),1)
+Q=
+NQ=true
+else
+Q=@
+NQ=echo
+endif
+
+all: version_check $(ALL)
+
+version_check:
+	@if ! pkg-config --atleast-version=$(NLVERSION) libnl-1; then echo "You need at least libnl version $(NLVERSION)"; exit 1; fi
+
+
+version.h: version.sh
+	@$(NQ) ' GEN  version.h'
+	$(Q)./version.sh
+
+%.o: %.c iw.h version.h
+	@$(NQ) ' CC  ' $@
+	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
+
+iw:	$(OBJS)
+	@$(NQ) ' CC  ' iw
+	$(Q)$(CC) $(LDFLAGS) $(OBJS) -o iw
+
+check:
+	$(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
+
+%.gz: %
+	@$(NQ) ' GZIP' $<
+	$(Q)gzip < $< > $@
+
+install: iw iw.8.gz
+	@$(NQ) ' INST iw'
+	$(Q)$(MKDIR) $(DESTDIR)$(PREFIX)/bin/
+	$(Q)$(INSTALL) -m 755 -o root -g root -t $(DESTDIR)$(PREFIX)/bin/ iw
+	@$(NQ) ' INST iw.8'
+	$(Q)$(MKDIR) $(DESTDIR)$(PREFIX)/share/man/man8/
+	$(Q)$(INSTALL) -m 644 -o root -g root -t $(DESTDIR)$(PREFIX)/share/man/man8/ iw.8.gz
+
+clean:
+	$(Q)rm -f iw *.o *~ *.gz version.h *-stamp

Added: iw/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/README?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/README (added)
+++ iw/branches/upstream/current/README Fri Sep 19 14:42:49 2008
@@ -1,0 +1,6 @@
+
+This is 'iw', a tool to use nl80211.
+
+
+To build iw, just enter 'make'. If that fails, copy the file
+defconfig to .config and adjust the settings in it.

Added: iw/branches/upstream/current/defconfig
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/defconfig?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/defconfig (added)
+++ iw/branches/upstream/current/defconfig Fri Sep 19 14:42:49 2008
@@ -1,0 +1,19 @@
+# Example iw build time configuration
+#
+# This file lists the configuration options that are used when building the
+# iw binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out completely, if they are not to be included,
+# i.e. just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cases, these lines should use += in order not
+# to override previous values of the variables.
+
+# LibNL location
+# (if not installed in a way that makes the compiler/linker find it)
+# by default, libnl's 'make install' installs to /usr/local/ so you may
+# need this
+#
+# CONFIG_LIBNL_LOC = /usr/local/
+# CFLAGS += -I$(CONFIG_LIBNL_LOC)/include
+# LDFLAGS += -L$(CONFIG_LIBNL_LOC)/lib

Added: iw/branches/upstream/current/info.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/info.c?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/info.c (added)
+++ iw/branches/upstream/current/info.c Fri Sep 19 14:42:49 2008
@@ -1,0 +1,127 @@
+#include <errno.h>
+#include <net/if.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 void print_flag(const char *name, int *open)
+{
+	if (!*open)
+		printf(" (");
+	else
+		printf(", ");
+	printf(name);
+	*open = 1;
+}
+
+static int print_phy_handler(struct nl_msg *msg, void *arg)
+{
+	struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
+	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+
+	struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1];
+
+	struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1];
+	static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
+		[NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
+		[NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
+		[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
+		[NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
+		[NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
+	};
+
+	struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1];
+	static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = {
+		[NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 },
+		[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] = { .type = NLA_FLAG },
+	};
+
+	struct nlattr *nl_band;
+	struct nlattr *nl_freq;
+	struct nlattr *nl_rate;
+	struct nlattr *nl_mode;
+	int bandidx = 1;
+	int rem_band, rem_freq, rem_rate, rem_mode;
+	int open;
+
+	nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+		  genlmsg_attrlen(gnlh, 0), NULL);
+
+	if (!tb_msg[NL80211_ATTR_WIPHY_BANDS])
+		return NL_SKIP;
+
+	if (tb_msg[NL80211_ATTR_WIPHY_NAME])
+		printf("Wiphy %s\n", nla_get_string(tb_msg[NL80211_ATTR_WIPHY_NAME]));
+
+	nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) {
+		printf("\tBand %d:\n", bandidx);
+		bandidx++;
+
+		nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band),
+			  nla_len(nl_band), NULL);
+
+		printf("\t\tFrequencies:\n");
+
+		nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) {
+			nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq),
+				  nla_len(nl_freq), freq_policy);
+			if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
+				continue;
+			printf("\t\t\t* %d MHz", nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]));
+			open = 0;
+			if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
+				print_flag("disabled", &open);
+			if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN])
+				print_flag("passive scanning", &open);
+			if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS])
+				print_flag("no IBSS", &open);
+			if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR])
+				print_flag("radar detection", &open);
+			if (open)
+				printf(")");
+			printf("\n");
+		}
+
+		printf("\t\tBitrates:\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),
+				  nla_len(nl_rate), rate_policy);
+			if (!tb_rate[NL80211_BITRATE_ATTR_RATE])
+				continue;
+			printf("\t\t\t* %2.1f Mbps", 0.1 * nla_get_u32(tb_rate[NL80211_BITRATE_ATTR_RATE]));
+			open = 0;
+			if (tb_rate[NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE])
+				print_flag("short preamble supported", &open);
+			if (open)
+				printf(")");
+			printf("\n");
+		}
+	}
+
+	if (!tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES])
+		return NL_SKIP;
+
+	printf("\tSupported interface modes:\n");
+	nla_for_each_nested(nl_mode, tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES], rem_mode)
+		printf("\t\t * %s\n", iftype_name(nl_mode->nla_type));
+
+	return NL_SKIP;
+}
+
+static int handle_info(struct nl_cb *cb,
+		       struct nl_msg *msg,
+		       int argc, char **argv)
+{
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_phy_handler, NULL);
+
+	return 0;
+}
+TOPLEVEL(info, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_PHY, handle_info);
+TOPLEVEL(list, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info);

Added: iw/branches/upstream/current/interface.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/interface.c?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/interface.c (added)
+++ iw/branches/upstream/current/interface.c Fri Sep 19 14:42:49 2008
@@ -1,0 +1,224 @@
+#include <net/if.h>
+#include <errno.h>
+#include <string.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 char *mntr_flags[NL80211_MNTR_FLAG_MAX + 1] = {
+	NULL,
+	"fcsfail",
+	"plcpfail",
+	"control",
+	"otherbss",
+	"cook",
+};
+
+/* return 0 if not found, 1 if ok, -1 on error */
+static int get_if_type(int *argc, char ***argv, enum nl80211_iftype *type)
+{
+	char *tpstr;
+
+	if (*argc < 2)
+		return 0;
+
+	if (strcmp((*argv)[0], "type"))
+		return 0;
+
+	tpstr = (*argv)[1];
+	*argc -= 2;
+	*argv += 2;
+
+	if (strcmp(tpstr, "adhoc") == 0 ||
+	    strcmp(tpstr, "ibss") == 0) {
+		*type = NL80211_IFTYPE_ADHOC;
+		return 1;
+	} else if (strcmp(tpstr, "monitor") == 0) {
+		*type = NL80211_IFTYPE_MONITOR;
+		return 1;
+	} else if (strcmp(tpstr, "__ap") == 0) {
+		*type = NL80211_IFTYPE_AP;
+		return 1;
+	} else if (strcmp(tpstr, "__ap_vlan") == 0) {
+		*type = NL80211_IFTYPE_AP_VLAN;
+		return 1;
+	} else if (strcmp(tpstr, "wds") == 0) {
+		*type = NL80211_IFTYPE_WDS;
+		return 1;
+	} else if (strcmp(tpstr, "station") == 0) {
+		*type = NL80211_IFTYPE_STATION;
+		return 1;
+	} else if (strcmp(tpstr, "mp") == 0 ||
+			strcmp(tpstr, "mesh") == 0) {
+		*type = NL80211_IFTYPE_MESH_POINT;
+		return 1;
+	}
+
+
+	fprintf(stderr, "invalid interface type %s\n", tpstr);
+	return -1;
+}
+
+static int handle_interface_add(struct nl_cb *cb,
+				struct nl_msg *msg,
+				int argc, char **argv)
+{
+	char *name;
+	char *mesh_id = NULL;
+	enum nl80211_iftype type;
+	int tpset;
+
+	if (argc < 1)
+		return 1;
+
+	name = argv[0];
+	argc--;
+	argv++;
+
+	tpset = get_if_type(&argc, &argv, &type);
+	if (tpset <= 0)
+		return 1;
+
+	if (argc) {
+		if (strcmp(argv[0], "mesh_id") != 0)
+			return 1;
+		argc--;
+		argv++;
+
+		if (!argc)
+			return 1;
+		mesh_id = argv[0];
+		argc--;
+		argv++;
+	}
+
+	if (argc)
+		return 1;
+
+	NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, name);
+	if (tpset)
+		NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, type);
+	if (mesh_id)
+		NLA_PUT(msg, NL80211_ATTR_MESH_ID, strlen(mesh_id), mesh_id);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>]",
+	NL80211_CMD_NEW_INTERFACE, 0, CIB_PHY, handle_interface_add);
+COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>]",
+	NL80211_CMD_NEW_INTERFACE, 0, CIB_NETDEV, handle_interface_add);
+
+static int handle_interface_del(struct nl_cb *cb,
+				struct nl_msg *msg,
+				int argc, char **argv)
+{
+	return 0;
+}
+TOPLEVEL(del, NULL, NL80211_CMD_DEL_INTERFACE, 0, CIB_NETDEV, handle_interface_del);
+HIDDEN(interface, del, NULL, NL80211_CMD_DEL_INTERFACE, 0, CIB_NETDEV, handle_interface_del);
+
+static int print_iface_handler(struct nl_msg *msg, void *arg)
+{
+	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+	struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
+
+	nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+		  genlmsg_attrlen(gnlh, 0), NULL);
+
+	if (tb_msg[NL80211_ATTR_IFNAME])
+		printf("Interface %s\n", nla_get_string(tb_msg[NL80211_ATTR_IFNAME]));
+	if (tb_msg[NL80211_ATTR_IFINDEX])
+		printf("\tifindex %d\n", nla_get_u32(tb_msg[NL80211_ATTR_IFINDEX]));
+	if (tb_msg[NL80211_ATTR_IFTYPE])
+		printf("\ttype %s\n", iftype_name(nla_get_u32(tb_msg[NL80211_ATTR_IFTYPE])));
+
+	return NL_SKIP;
+}
+
+static int handle_interface_info(struct nl_cb *cb,
+				 struct nl_msg *msg,
+				 int argc, char **argv)
+{
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_iface_handler, NULL);
+	return 0;
+}
+TOPLEVEL(info, NULL, NL80211_CMD_GET_INTERFACE, 0, CIB_NETDEV, handle_interface_info);
+
+static int handle_interface_set(struct nl_cb *cb,
+				struct nl_msg *msg,
+				int argc, char **argv)
+{
+	enum nl80211_mntr_flags flag;
+	struct nl_msg *flags;
+	int err;
+
+	if (!argc)
+		return 1;
+
+	flags = nlmsg_alloc();
+	if (!flags) {
+		fprintf(stderr, "failed to allocate flags\n");
+		return 2;
+	}
+
+	NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_MONITOR);
+
+	while (argc) {
+		int ok = 0;
+		for (flag = __NL80211_MNTR_FLAG_INVALID + 1;
+		     flag < NL80211_MNTR_FLAG_MAX; flag++) {
+			if (strcmp(*argv, mntr_flags[flag]) == 0) {
+				ok = 1;
+				NLA_PUT_FLAG(flags, flag);
+				break;
+			}
+		}
+		if (!ok) {
+			fprintf(stderr, "unknown flag %s\n", *argv);
+			err = 2;
+			goto out;
+		}
+		argc--;
+		argv++;
+	}
+
+	nla_put_nested(msg, NL80211_ATTR_MNTR_FLAGS, flags);
+
+	err = 0;
+	goto out;
+ nla_put_failure:
+	err = -ENOBUFS;
+ out:
+	nlmsg_free(flags);
+	return err;
+}
+COMMAND(set, monitor, "<flag> [...]",
+	NL80211_CMD_SET_INTERFACE, 0, CIB_NETDEV, handle_interface_set);
+
+static int handle_interface_meshid(struct nl_cb *cb,
+				   struct nl_msg *msg,
+				   int argc, char **argv)
+{
+	char *mesh_id = NULL;
+
+	if (argc != 1)
+		return 1;
+
+	mesh_id = argv[0];
+
+	NLA_PUT(msg, NL80211_ATTR_MESH_ID, strlen(mesh_id), mesh_id);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(set, meshid, "<meshid>",
+	NL80211_CMD_SET_INTERFACE, 0, CIB_NETDEV, handle_interface_meshid);

Added: iw/branches/upstream/current/iw.8
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/iw.8?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/iw.8 (added)
+++ iw/branches/upstream/current/iw.8 Fri Sep 19 14:42:49 2008
@@ -1,0 +1,50 @@
+.TH IW 8 "16 September 2008" "iw" "Linux"
+.SH NAME
+iw \- show / manipulate wireless devices and their configuration
+.SH SYNOPSIS
+
+.ad l
+.in +8
+.ti -8
+.B ip
+.RI [ " OPTIONS " ] " OBJECT " { " COMMAND " | "
+.BR help " }"
+.sp
+
+.ti -8
+.IR OBJECT " := { "
+.BR dev " | " phy " | " reg " }"
+.sp
+
+.ti -8
+.IR OPTIONS " := { --debug }"
+
+.SH OPTIONS
+
+.TP
+.BR " --debug"
+enable netlink message debugging.
+
+.SH IW - COMMAND SYNTAX
+
+.SS
+.I OBJECT
+
+.TP
+.B dev
+- network interface.
+
+.TP
+.B phy
+- wireless hardware device.
+
+.SS
+.I COMMAND
+
+Specifies the action to perform on the object.
+The set of possible actions depends on the object type.
+.B iw help
+will print all supported commands.
+
+.SH SEE ALSO
+.BR ip (8)

Added: iw/branches/upstream/current/iw.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/iw.c?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/iw.c (added)
+++ iw/branches/upstream/current/iw.c Fri Sep 19 14:42:49 2008
@@ -1,0 +1,318 @@
+/*
+ * nl80211 userspace tool
+ *
+ * Copyright 2007, 2008	Johannes Berg <johannes at sipsolutions.net>
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <net/if.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.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"
+#include "version.h"
+
+int debug = 0;
+
+static int nl80211_init(struct nl80211_state *state)
+{
+	int err;
+
+	state->nl_handle = nl_handle_alloc();
+	if (!state->nl_handle) {
+		fprintf(stderr, "Failed to allocate netlink handle.\n");
+		return -ENOMEM;
+	}
+
+	if (genl_connect(state->nl_handle)) {
+		fprintf(stderr, "Failed to connect to generic netlink.\n");
+		err = -ENOLINK;
+		goto out_handle_destroy;
+	}
+
+	state->nl_cache = genl_ctrl_alloc_cache(state->nl_handle);
+	if (!state->nl_cache) {
+		fprintf(stderr, "Failed to allocate generic netlink cache.\n");
+		err = -ENOMEM;
+		goto out_handle_destroy;
+	}
+
+	state->nl80211 = genl_ctrl_search_by_name(state->nl_cache, "nl80211");
+	if (!state->nl80211) {
+		fprintf(stderr, "nl80211 not found.\n");
+		err = -ENOENT;
+		goto out_cache_free;
+	}
+
+	return 0;
+
+ out_cache_free:
+	nl_cache_free(state->nl_cache);
+ out_handle_destroy:
+	nl_handle_destroy(state->nl_handle);
+	return err;
+}
+
+static void nl80211_cleanup(struct nl80211_state *state)
+{
+	genl_family_put(state->nl80211);
+	nl_cache_free(state->nl_cache);
+	nl_handle_destroy(state->nl_handle);
+}
+
+__COMMAND(NULL, NULL, NULL, 0, 0, 0, CIB_NONE, NULL);
+__COMMAND(NULL, NULL, NULL, 1, 0, 0, CIB_NONE, NULL);
+
+static int cmd_size;
+
+static void usage(const char *argv0)
+{
+	struct cmd *cmd;
+
+	fprintf(stderr, "Usage:\t%s [options] command\n", argv0);
+	fprintf(stderr, "Options:\n");
+	fprintf(stderr, "\t--debug\t\tenable netlink debugging\n");
+	fprintf(stderr, "\t--version\tshow version\n");
+	fprintf(stderr, "Commands:\n");
+	for (cmd = &__start___cmd; cmd < &__stop___cmd;
+	     cmd = (struct cmd *)((char *)cmd + cmd_size)) {
+		if (!cmd->handler || cmd->hidden)
+			continue;
+		switch (cmd->idby) {
+		case CIB_NONE:
+			fprintf(stderr, "\t");
+			/* fall through */
+		case CIB_PHY:
+			if (cmd->idby == CIB_PHY)
+				fprintf(stderr, "\tphy <phyname> ");
+			/* fall through */
+		case CIB_NETDEV:
+			if (cmd->idby == CIB_NETDEV)
+				fprintf(stderr, "\tdev <devname> ");
+			if (cmd->section)
+				fprintf(stderr, "%s ", cmd->section);
+			fprintf(stderr, "%s", cmd->name);
+			if (cmd->args)
+				fprintf(stderr, " %s", cmd->args);
+			fprintf(stderr, "\n");
+			break;
+		}
+	}
+}
+
+static void version(void)
+{
+	printf("iw version " IW_VERSION "\n");
+}
+
+static int phy_lookup(char *name)
+{
+	char buf[200];
+	int fd, pos;
+
+	snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", name);
+
+	fd = open(buf, O_RDONLY);
+	pos = read(fd, buf, sizeof(buf) - 1);
+	if (pos < 0)
+		return -1;
+	buf[pos] = '\0';
+	return atoi(buf);
+}
+
+static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
+			 void *arg)
+{
+	int *ret = arg;
+	*ret = err->error;
+	return NL_STOP;
+}
+
+static int finish_handler(struct nl_msg *msg, void *arg)
+{
+	return NL_SKIP;
+}
+
+static int ack_handler(struct nl_msg *msg, void *arg)
+{
+	int *ret = arg;
+	*ret = 0;
+	return NL_STOP;
+}
+
+static int handle_cmd(struct nl80211_state *state,
+		      enum command_identify_by idby,
+		      int argc, char **argv)
+{
+	struct cmd *cmd;
+	struct nl_cb *cb = NULL;
+	struct nl_msg *msg;
+	int devidx = 0;
+	int err;
+	const char *command, *section;
+
+	if (argc <= 1 && idby != CIB_NONE)
+		return 1;
+
+	switch (idby) {
+	case CIB_PHY:
+		devidx = phy_lookup(*argv);
+		argc--;
+		argv++;
+		break;
+	case CIB_NETDEV:
+		devidx = if_nametoindex(*argv);
+		argc--;
+		argv++;
+		break;
+	default:
+		break;
+	}
+
+	section = command = *argv;
+	argc--;
+	argv++;
+
+	for (cmd = &__start___cmd; cmd < &__stop___cmd;
+	     cmd = (struct cmd *)((char *)cmd + cmd_size)) {
+		if (!cmd->handler)
+			continue;
+		if (cmd->idby != idby)
+			continue;
+		if (cmd->section) {
+			if (strcmp(cmd->section, section))
+				continue;
+			/* this is a bit icky ... */
+			if (command == section) {
+				if (argc <= 0)
+					return 1;
+				command = *argv;
+				argc--;
+				argv++;
+			}
+		} else if (section != command)
+			continue;
+		if (strcmp(cmd->name, command))
+			continue;
+		if (argc && !cmd->args)
+			continue;
+		break;
+	}
+
+	if (cmd >= &__stop___cmd)
+		return 1;
+
+	msg = nlmsg_alloc();
+	if (!msg) {
+		fprintf(stderr, "failed to allocate netlink message\n");
+		return 2;
+	}
+
+	cb = nl_cb_alloc(debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
+	if (!cb) {
+		fprintf(stderr, "failed to allocate netlink callbacks\n");
+		err = 2;
+		goto out_free_msg;
+	}
+
+	genlmsg_put(msg, 0, 0, genl_family_get_id(state->nl80211), 0,
+		    cmd->nl_msg_flags, cmd->cmd, 0);
+
+	switch (idby) {
+	case CIB_PHY:
+		NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, devidx);
+		break;
+	case CIB_NETDEV:
+		NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, devidx);
+		break;
+	default:
+		break;
+	}
+
+	err = cmd->handler(cb, msg, argc, argv);
+	if (err)
+		goto out;
+
+	err = nl_send_auto_complete(state->nl_handle, msg);
+	if (err < 0)
+		goto out;
+
+	nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
+	nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, NULL);
+	nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
+
+	nl_recvmsgs(state->nl_handle, cb);
+ out:
+	nl_cb_put(cb);
+ out_free_msg:
+	nlmsg_free(msg);
+	return err;
+ nla_put_failure:
+	fprintf(stderr, "building message failed\n");
+	return 2;
+}
+
+int main(int argc, char **argv)
+{
+	struct nl80211_state nlstate;
+	int err;
+	const char *argv0;
+
+	/* calculate command size including padding */
+	cmd_size = abs((long)&__cmd_NULL_1_CIB_NONE_0
+	             - (long)&__cmd_NULL_0_CIB_NONE_0);
+	/* strip off self */
+	argc--;
+	argv0 = *argv++;
+
+	if (argc > 0 && strcmp(*argv, "--debug") == 0) {
+		debug = 1;
+		argc--;
+		argv++;
+	}
+
+	if (argc > 0 && strcmp(*argv, "--version") == 0) {
+		version();
+		return 0;
+	}
+
+	if (argc == 0 || strcmp(*argv, "help") == 0) {
+		usage(argv0);
+		return 0;
+	}
+
+	err = nl80211_init(&nlstate);
+	if (err)
+		return 1;
+
+	if (strcmp(*argv, "dev") == 0) {
+		argc--;
+		argv++;
+		err = handle_cmd(&nlstate, CIB_NETDEV, argc, argv);
+	} else if (strcmp(*argv, "phy") == 0) {
+		argc--;
+		argv++;
+		err = handle_cmd(&nlstate, CIB_PHY, argc, argv);
+	} else
+		err = handle_cmd(&nlstate, CIB_NONE, argc, argv);
+
+	if (err == 1)
+		usage(argv0);
+	if (err < 0)
+		fprintf(stderr, "command failed: %s (%d)\n", strerror(-err), err);
+
+	nl80211_cleanup(&nlstate);
+
+	return err;
+}

Added: iw/branches/upstream/current/iw.h
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/iw.h?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/iw.h (added)
+++ iw/branches/upstream/current/iw.h Fri Sep 19 14:42:49 2008
@@ -1,0 +1,61 @@
+#ifndef __IW_H
+#define __IW_H
+
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+
+#include "nl80211.h"
+
+#define ETH_ALEN 6
+
+struct nl80211_state {
+	struct nl_handle *nl_handle;
+	struct nl_cache *nl_cache;
+	struct genl_family *nl80211;
+};
+
+enum command_identify_by {
+	CIB_NONE,
+	CIB_PHY,
+	CIB_NETDEV,
+};
+
+struct cmd {
+	const char *section;
+	const char *name;
+	const char *args;
+	const enum nl80211_commands cmd;
+	int nl_msg_flags;
+	int hidden;
+	const enum command_identify_by idby;
+	/*
+	 * The handler should return a negative error code,
+	 * zero on success, 1 if the arguments were wrong
+	 * and the usage message should and 2 otherwise.
+	 */
+	int (*handler)(struct nl_cb *cb,
+		       struct nl_msg *msg,
+		       int argc, char **argv);
+};
+
+#define __COMMAND(sect, name, args, nlcmd, flags, hidden, idby, handler)\
+	static const struct cmd						\
+	__cmd_ ## handler ## _ ## nlcmd ## _ ## idby ## _ ## hidden	\
+	__attribute__((used)) __attribute__((section("__cmd")))		\
+	= { sect, name, args, nlcmd, flags, hidden, idby, handler }
+#define COMMAND(section, name, args, cmd, flags, idby, handler)	\
+	__COMMAND(#section, #name, args, cmd, flags, 0, idby, handler)
+#define HIDDEN(section, name, args, cmd, flags, idby, handler)	\
+	__COMMAND(#section, #name, args, cmd, flags, 1, idby, handler)
+#define TOPLEVEL(name, args, cmd, flags, idby, handler)		\
+	__COMMAND(NULL, #name, args, cmd, flags, 0, idby, handler)
+extern struct cmd __start___cmd;
+extern struct cmd __stop___cmd;
+
+int mac_addr_a2n(unsigned char *mac_addr, char *arg);
+int mac_addr_n2a(char *mac_addr, unsigned char *arg);
+
+const char *iftype_name(enum nl80211_iftype iftype);
+
+#endif /* __IW_H */

Added: iw/branches/upstream/current/mpath.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/mpath.c?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/mpath.c (added)
+++ iw/branches/upstream/current/mpath.c Fri Sep 19 14:42:49 2008
@@ -1,0 +1,182 @@
+#include <net/if.h>
+#include <errno.h>
+#include <string.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"
+
+enum plink_state {
+	LISTEN,
+	OPN_SNT,
+	OPN_RCVD,
+	CNF_RCVD,
+	ESTAB,
+	HOLDING,
+	BLOCKED
+};
+
+enum plink_actions {
+	PLINK_ACTION_UNDEFINED,
+	PLINK_ACTION_OPEN,
+	PLINK_ACTION_BLOCK,
+};
+
+
+static int print_mpath_handler(struct nl_msg *msg, void *arg)
+{
+	struct nlattr *tb[NL80211_ATTR_MAX + 1];
+	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+	struct nlattr *pinfo[NL80211_MPATH_INFO_MAX + 1];
+	char dst[20], next_hop[20], dev[20];
+	static struct nla_policy mpath_policy[NL80211_MPATH_INFO_MAX + 1] = {
+		[NL80211_MPATH_INFO_FRAME_QLEN] = { .type = NLA_U32 },
+		[NL80211_MPATH_INFO_DSN] = { .type = NLA_U32 },
+		[NL80211_MPATH_INFO_METRIC] = { .type = NLA_U32 },
+		[NL80211_MPATH_INFO_EXPTIME] = { .type = NLA_U32 },
+		[NL80211_MPATH_INFO_DISCOVERY_TIMEOUT] = { .type = NLA_U32 },
+		[NL80211_MPATH_INFO_DISCOVERY_RETRIES] = { .type = NLA_U8 },
+		[NL80211_MPATH_INFO_FLAGS] = { .type = NLA_U8 },
+	};
+
+	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+		  genlmsg_attrlen(gnlh, 0), NULL);
+
+	/*
+	 * TODO: validate the interface and mac address!
+	 * Otherwise, there's a race condition as soon as
+	 * the kernel starts sending mpath notifications.
+	 */
+
+	if (!tb[NL80211_ATTR_MPATH_INFO]) {
+		fprintf(stderr, "mpath info missing!");
+		return NL_SKIP;
+	}
+	if (nla_parse_nested(pinfo, NL80211_MPATH_INFO_MAX,
+			     tb[NL80211_ATTR_MPATH_INFO],
+			     mpath_policy)) {
+		fprintf(stderr, "failed to parse nested attributes!");
+		return NL_SKIP;
+	}
+
+	mac_addr_n2a(dst, nla_data(tb[NL80211_ATTR_MAC]));
+	mac_addr_n2a(next_hop, nla_data(tb[NL80211_ATTR_MPATH_NEXT_HOP]));
+	if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), dev);
+	printf("%s %s %s", dst, next_hop, dev);
+	if (pinfo[NL80211_MPATH_INFO_DSN])
+		printf("\t%u",
+			nla_get_u32(pinfo[NL80211_MPATH_INFO_DSN]));
+	if (pinfo[NL80211_MPATH_INFO_METRIC])
+		printf("\t%u",
+			nla_get_u32(pinfo[NL80211_MPATH_INFO_METRIC]));
+	if (pinfo[NL80211_MPATH_INFO_FRAME_QLEN])
+		printf("\t%u",
+			nla_get_u32(pinfo[NL80211_MPATH_INFO_FRAME_QLEN]));
+	if (pinfo[NL80211_MPATH_INFO_EXPTIME])
+		printf("\t%u",
+			nla_get_u32(pinfo[NL80211_MPATH_INFO_EXPTIME]));
+	if (pinfo[NL80211_MPATH_INFO_DISCOVERY_TIMEOUT])
+		printf("\t%u",
+		nla_get_u32(pinfo[NL80211_MPATH_INFO_DISCOVERY_TIMEOUT]));
+	if (pinfo[NL80211_MPATH_INFO_DISCOVERY_RETRIES])
+		printf("\t%u",
+		nla_get_u8(pinfo[NL80211_MPATH_INFO_DISCOVERY_RETRIES]));
+	if (pinfo[NL80211_MPATH_INFO_FLAGS])
+		printf("\t0x%x",
+			nla_get_u8(pinfo[NL80211_MPATH_INFO_FLAGS]));
+
+	printf("\n");
+	return NL_SKIP;
+}
+
+static int handle_mpath_get(struct nl_cb *cb,
+			    struct nl_msg *msg,
+			    int argc, char **argv)
+{
+	unsigned char dst[ETH_ALEN];
+
+	if (argc < 1)
+		return 1;
+
+	if (mac_addr_a2n(dst, argv[0])) {
+		fprintf(stderr, "invalid mac address\n");
+		return 2;
+	}
+	argc--;
+	argv++;
+
+	if (argc)
+		return 1;
+
+	NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst);
+
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_mpath_handler, NULL);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(mpath, get, "<MAC address>",
+	NL80211_CMD_GET_MPATH, 0, CIB_NETDEV, handle_mpath_get);
+COMMAND(mpath, del, "<MAC address>",
+	NL80211_CMD_DEL_MPATH, 0, CIB_NETDEV, handle_mpath_get);
+
+static int handle_mpath_set(struct nl_cb *cb,
+			    struct nl_msg *msg,
+			    int argc, char **argv)
+{
+	unsigned char dst[ETH_ALEN];
+	unsigned char next_hop[ETH_ALEN];
+
+	if (argc < 3)
+		return 1;
+
+	if (mac_addr_a2n(dst, argv[0])) {
+		fprintf(stderr, "invalid destination mac address\n");
+		return 2;
+	}
+	argc--;
+	argv++;
+
+	if (strcmp("next_hop", argv[0]) != 0)
+		return 1;
+	argc--;
+	argv++;
+
+	if (mac_addr_a2n(next_hop, argv[0])) {
+		fprintf(stderr, "invalid next hop mac address\n");
+		return 2;
+	}
+	argc--;
+	argv++;
+
+	if (argc)
+		return 1;
+
+	NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst);
+	NLA_PUT(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop);
+
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_mpath_handler, NULL);
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(mpath, new, "<destination MAC address> next_hop <next hop MAC address>",
+	NL80211_CMD_NEW_MPATH, 0, CIB_NETDEV, handle_mpath_set);
+COMMAND(mpath, set, "<destination MAC address> next_hop <next hop MAC address>",
+	NL80211_CMD_SET_MPATH, 0, CIB_NETDEV, handle_mpath_set);
+
+static int handle_mpath_dump(struct nl_cb *cb,
+			     struct nl_msg *msg,
+			     int argc, char **argv)
+{
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_mpath_handler, NULL);
+	return 0;
+}
+COMMAND(mpath, dump, NULL,
+	NL80211_CMD_GET_MPATH, NLM_F_DUMP, CIB_NETDEV, handle_mpath_dump);

Added: iw/branches/upstream/current/nl80211.h
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/nl80211.h?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/nl80211.h (added)
+++ iw/branches/upstream/current/nl80211.h Fri Sep 19 14:42:49 2008
@@ -1,0 +1,597 @@
+#ifndef __LINUX_NL80211_H
+#define __LINUX_NL80211_H
+/*
+ * 802.11 netlink interface public header
+ *
+ * Copyright 2006, 2007 Johannes Berg <johannes at sipsolutions.net>
+ */
+
+/**
+ * DOC: Station handling
+ *
+ * Stations are added per interface, but a special case exists with VLAN
+ * interfaces. When a station is bound to an AP interface, it may be moved
+ * into a VLAN identified by a VLAN interface index (%NL80211_ATTR_STA_VLAN).
+ * The station is still assumed to belong to the AP interface it was added
+ * to.
+ *
+ * TODO: need more info?
+ */
+
+/**
+ * enum nl80211_commands - supported nl80211 commands
+ *
+ * @NL80211_CMD_UNSPEC: unspecified command to catch errors
+ *
+ * @NL80211_CMD_GET_WIPHY: request information about a wiphy or dump request
+ *	to get a list of all present wiphys.
+ * @NL80211_CMD_SET_WIPHY: set wiphy name, needs %NL80211_ATTR_WIPHY and
+ *	%NL80211_ATTR_WIPHY_NAME.
+ * @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request
+ *	or rename notification. Has attributes %NL80211_ATTR_WIPHY and
+ *	%NL80211_ATTR_WIPHY_NAME.
+ * @NL80211_CMD_DEL_WIPHY: Wiphy deleted. Has attributes
+ *	%NL80211_ATTR_WIPHY and %NL80211_ATTR_WIPHY_NAME.
+ *
+ * @NL80211_CMD_GET_INTERFACE: Request an interface's configuration;
+ *	either a dump request on a %NL80211_ATTR_WIPHY or a specific get
+ *	on an %NL80211_ATTR_IFINDEX is supported.
+ * @NL80211_CMD_SET_INTERFACE: Set type of a virtual interface, requires
+ *	%NL80211_ATTR_IFINDEX and %NL80211_ATTR_IFTYPE.
+ * @NL80211_CMD_NEW_INTERFACE: Newly created virtual interface or response
+ *	to %NL80211_CMD_GET_INTERFACE. Has %NL80211_ATTR_IFINDEX,
+ *	%NL80211_ATTR_WIPHY and %NL80211_ATTR_IFTYPE attributes. Can also
+ *	be sent from userspace to request creation of a new virtual interface,
+ *	then requires attributes %NL80211_ATTR_WIPHY, %NL80211_ATTR_IFTYPE and
+ *	%NL80211_ATTR_IFNAME.
+ * @NL80211_CMD_DEL_INTERFACE: Virtual interface was deleted, has attributes
+ *	%NL80211_ATTR_IFINDEX and %NL80211_ATTR_WIPHY. Can also be sent from
+ *	userspace to request deletion of a virtual interface, then requires
+ *	attribute %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_KEY: Get sequence counter information for a key specified
+ *	by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC.
+ * @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT 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_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
+ *	or %NL80211_ATTR_MAC.
+ *
+ * @NL80211_CMD_GET_BEACON: retrieve beacon information (returned in a
+ *	%NL80222_CMD_NEW_BEACON message)
+ * @NL80211_CMD_SET_BEACON: set the beacon on an access point interface
+ *	using the %NL80211_ATTR_BEACON_INTERVAL, %NL80211_ATTR_DTIM_PERIOD,
+ *	%NL80211_BEACON_HEAD and %NL80211_BEACON_TAIL attributes.
+ * @NL80211_CMD_NEW_BEACON: add a new beacon to an access point interface,
+ *	parameters are like for %NL80211_CMD_SET_BEACON.
+ * @NL80211_CMD_DEL_BEACON: remove the beacon, stop sending it
+ *
+ * @NL80211_CMD_GET_STATION: Get station attributes for station identified by
+ *	%NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_STATION: Set station attributes for station identified by
+ *	%NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_STATION: Add a station with given attributes to the
+ *	the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC
+ *	or, if no MAC address given, all stations, on the interface identified
+ *	by %NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to
+ * 	destination %NL80211_ATTR_MAC on the interface identified by
+ * 	%NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_MPATH:  Set mesh path attributes for mesh path to
+ * 	destination %NL80211_ATTR_MAC on the interface identified by
+ * 	%NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the
+ *	the interface identified by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC
+ *	or, if no MAC address given, all mesh paths, on the interface identified
+ *	by %NL80211_ATTR_IFINDEX.
+ * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by
+ *	%NL80211_ATTR_IFINDEX.
+ *
+ * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
+ *	after being queried by the kernel. CRDA replies by sending a regulatory
+ *	domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
+ *	current alpha2 if it found a match. It also provides
+ * 	NL80211_ATTR_REG_RULE_FLAGS, and a set of regulatory rules. Each
+ * 	regulatory rule is a nested set of attributes  given by
+ * 	%NL80211_ATTR_REG_RULE_FREQ_[START|END] and
+ * 	%NL80211_ATTR_FREQ_RANGE_MAX_BW with an attached power rule given by
+ * 	%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
+ * 	store this as a valid request and then query userspace for it.
+ *
+ * @NL80211_CMD_MAX: highest used command number
+ * @__NL80211_CMD_AFTER_LAST: internal use
+ */
+enum nl80211_commands {
+/* don't change the order or add anything inbetween, this is ABI! */
+	NL80211_CMD_UNSPEC,
+
+	NL80211_CMD_GET_WIPHY,		/* can dump */
+	NL80211_CMD_SET_WIPHY,
+	NL80211_CMD_NEW_WIPHY,
+	NL80211_CMD_DEL_WIPHY,
+
+	NL80211_CMD_GET_INTERFACE,	/* can dump */
+	NL80211_CMD_SET_INTERFACE,
+	NL80211_CMD_NEW_INTERFACE,
+	NL80211_CMD_DEL_INTERFACE,
+
+	NL80211_CMD_GET_KEY,
+	NL80211_CMD_SET_KEY,
+	NL80211_CMD_NEW_KEY,
+	NL80211_CMD_DEL_KEY,
+
+	NL80211_CMD_GET_BEACON,
+	NL80211_CMD_SET_BEACON,
+	NL80211_CMD_NEW_BEACON,
+	NL80211_CMD_DEL_BEACON,
+
+	NL80211_CMD_GET_STATION,
+	NL80211_CMD_SET_STATION,
+	NL80211_CMD_NEW_STATION,
+	NL80211_CMD_DEL_STATION,
+
+	NL80211_CMD_GET_MPATH,
+	NL80211_CMD_SET_MPATH,
+	NL80211_CMD_NEW_MPATH,
+	NL80211_CMD_DEL_MPATH,
+
+	NL80211_CMD_SET_BSS,
+
+	NL80211_CMD_SET_REG,
+	NL80211_CMD_REQ_SET_REG,
+
+	/* add new commands above here */
+
+	/* used to define NL80211_CMD_MAX below */
+	__NL80211_CMD_AFTER_LAST,
+	NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1
+};
+
+/*
+ * Allow user space programs to use #ifdef on new commands by defining them
+ * here
+ */
+#define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS
+
+/**
+ * enum nl80211_attrs - nl80211 netlink attributes
+ *
+ * @NL80211_ATTR_UNSPEC: unspecified attribute to catch errors
+ *
+ * @NL80211_ATTR_WIPHY: index of wiphy to operate on, cf.
+ *	/sys/class/ieee80211/<phyname>/index
+ * @NL80211_ATTR_WIPHY_NAME: wiphy name (used for renaming)
+ *
+ * @NL80211_ATTR_IFINDEX: network interface index of the device to operate on
+ * @NL80211_ATTR_IFNAME: network interface name
+ * @NL80211_ATTR_IFTYPE: type of virtual interface, see &enum nl80211_iftype
+ *
+ * @NL80211_ATTR_MAC: MAC address (various uses)
+ *
+ * @NL80211_ATTR_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_ATTR_KEY_IDX: key ID (u8, 0-3)
+ * @NL80211_ATTR_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
+ *	section 7.3.2.25.1, e.g. 0x000FAC04)
+ * @NL80211_ATTR_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
+ *	CCMP keys, each six bytes in little endian
+ *
+ * @NL80211_ATTR_BEACON_INTERVAL: beacon interval in TU
+ * @NL80211_ATTR_DTIM_PERIOD: DTIM period for beaconing
+ * @NL80211_ATTR_BEACON_HEAD: portion of the beacon before the TIM IE
+ * @NL80211_ATTR_BEACON_TAIL: portion of the beacon after the TIM IE
+ *
+ * @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.
+ * @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
+ *	rates as defined by IEEE 802.11 7.3.2.2 but without the length
+ *	restriction (at most %NL80211_MAX_SUPP_RATES).
+ * @NL80211_ATTR_STA_VLAN: interface index of VLAN interface to move station
+ *	to, or the AP interface the station was originally added to to.
+ * @NL80211_ATTR_STA_INFO: information about a station, part of station info
+ *	given for %NL80211_CMD_GET_STATION, nested attribute containing
+ *	info as possible, see &enum nl80211_sta_info.
+ *
+ * @NL80211_ATTR_WIPHY_BANDS: Information about an operating bands,
+ *	consisting of a nested array.
+ *
+ * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes).
+ * @NL80211_ATTR_PLINK_ACTION: action to perform on the mesh peer link.
+ * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path.
+ * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path
+ * 	info given for %NL80211_CMD_GET_MPATH, nested attribute described at
+ *	&enum nl80211_mpath_info.
+ *
+ * @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of
+ *      &enum nl80211_mntr_flags.
+ *
+ * @NL80211_ATTR_REG_ALPHA2: an ISO-3166-alpha2 country code for which the
+ * 	current regulatory domain should be set to or is already set to.
+ * 	For example, 'CR', for Costa Rica. This attribute is used by the kernel
+ * 	to query the CRDA to retrieve one regulatory domain. This attribute can
+ * 	also be used by userspace to query the kernel for the currently set
+ * 	regulatory domain. We chose an alpha2 as that is also used by the
+ * 	IEEE-802.11d country information element to identify a country.
+ * 	Users can also simply ask the wireless core to set regulatory domain
+ * 	to a specific alpha2.
+ * @NL80211_ATTR_REG_RULES: a nested array of regulatory domain regulatory
+ *	rules.
+ *
+ * @NL80211_ATTR_BSS_CTS_PROT: whether CTS protection is enabled (u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_PREAMBLE: whether short preamble is enabled
+ *	(u8, 0 or 1)
+ * @NL80211_ATTR_BSS_SHORT_SLOT_TIME: whether short slot time enabled
+ *	(u8, 0 or 1)
+ *
+ * @NL80211_ATTR_HT_CAPABILITY: HT Capability information element (from
+ *	association request when used with NL80211_CMD_NEW_STATION)
+ *
+ * @NL80211_ATTR_SUPPORTED_IFTYPES: nested attribute containing all
+ *	supported interface types, each a flag attribute with the number
+ *	of the interface mode.
+ *
+ * @NL80211_ATTR_MAX: highest attribute number currently defined
+ * @__NL80211_ATTR_AFTER_LAST: internal use
+ */
+enum nl80211_attrs {
+/* don't change the order or add anything inbetween, this is ABI! */
+	NL80211_ATTR_UNSPEC,
+
+	NL80211_ATTR_WIPHY,
+	NL80211_ATTR_WIPHY_NAME,
+
+	NL80211_ATTR_IFINDEX,
+	NL80211_ATTR_IFNAME,
+	NL80211_ATTR_IFTYPE,
+
+	NL80211_ATTR_MAC,
+
+	NL80211_ATTR_KEY_DATA,
+	NL80211_ATTR_KEY_IDX,
+	NL80211_ATTR_KEY_CIPHER,
+	NL80211_ATTR_KEY_SEQ,
+	NL80211_ATTR_KEY_DEFAULT,
+
+	NL80211_ATTR_BEACON_INTERVAL,
+	NL80211_ATTR_DTIM_PERIOD,
+	NL80211_ATTR_BEACON_HEAD,
+	NL80211_ATTR_BEACON_TAIL,
+
+	NL80211_ATTR_STA_AID,
+	NL80211_ATTR_STA_FLAGS,
+	NL80211_ATTR_STA_LISTEN_INTERVAL,
+	NL80211_ATTR_STA_SUPPORTED_RATES,
+	NL80211_ATTR_STA_VLAN,
+	NL80211_ATTR_STA_INFO,
+
+	NL80211_ATTR_WIPHY_BANDS,
+
+	NL80211_ATTR_MNTR_FLAGS,
+
+	NL80211_ATTR_MESH_ID,
+	NL80211_ATTR_STA_PLINK_ACTION,
+	NL80211_ATTR_MPATH_NEXT_HOP,
+	NL80211_ATTR_MPATH_INFO,
+
+	NL80211_ATTR_BSS_CTS_PROT,
+	NL80211_ATTR_BSS_SHORT_PREAMBLE,
+	NL80211_ATTR_BSS_SHORT_SLOT_TIME,
+
+	NL80211_ATTR_HT_CAPABILITY,
+
+	NL80211_ATTR_SUPPORTED_IFTYPES,
+
+	NL80211_ATTR_REG_ALPHA2,
+	NL80211_ATTR_REG_RULES,
+
+	/* add attributes here, update the policy in nl80211.c */
+
+	__NL80211_ATTR_AFTER_LAST,
+	NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
+};
+
+/*
+ * Allow user space programs to use #ifdef on new attributes by defining them
+ * here
+ */
+#define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY
+
+#define NL80211_MAX_SUPP_RATES			32
+#define NL80211_MAX_SUPP_REG_RULES		32
+#define NL80211_TKIP_DATA_OFFSET_ENCR_KEY	0
+#define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY	16
+#define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY	24
+#define NL80211_HT_CAPABILITY_LEN		26
+
+/**
+ * enum nl80211_iftype - (virtual) interface types
+ *
+ * @NL80211_IFTYPE_UNSPECIFIED: unspecified type, driver decides
+ * @NL80211_IFTYPE_ADHOC: independent BSS member
+ * @NL80211_IFTYPE_STATION: managed BSS member
+ * @NL80211_IFTYPE_AP: access point
+ * @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points
+ * @NL80211_IFTYPE_WDS: wireless distribution interface
+ * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
+ * @NL80211_IFTYPE_MESH_POINT: mesh point
+ * @NL80211_IFTYPE_MAX: highest interface type number currently defined
+ * @__NL80211_IFTYPE_AFTER_LAST: internal use
+ *
+ * These values are used with the %NL80211_ATTR_IFTYPE
+ * to set the type of an interface.
+ *
+ */
+enum nl80211_iftype {
+	NL80211_IFTYPE_UNSPECIFIED,
+	NL80211_IFTYPE_ADHOC,
+	NL80211_IFTYPE_STATION,
+	NL80211_IFTYPE_AP,
+	NL80211_IFTYPE_AP_VLAN,
+	NL80211_IFTYPE_WDS,
+	NL80211_IFTYPE_MONITOR,
+	NL80211_IFTYPE_MESH_POINT,
+
+	/* keep last */
+	__NL80211_IFTYPE_AFTER_LAST,
+	NL80211_IFTYPE_MAX = __NL80211_IFTYPE_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_flags - station flags
+ *
+ * Station flags. When a station is added to an AP interface, it is
+ * assumed to be already associated (and hence authenticated.)
+ *
+ * @NL80211_STA_FLAG_AUTHORIZED: station is authorized (802.1X)
+ * @NL80211_STA_FLAG_SHORT_PREAMBLE: station is capable of receiving frames
+ *	with short barker preamble
+ * @NL80211_STA_FLAG_WME: station is WME/QoS capable
+ */
+enum nl80211_sta_flags {
+	__NL80211_STA_FLAG_INVALID,
+	NL80211_STA_FLAG_AUTHORIZED,
+	NL80211_STA_FLAG_SHORT_PREAMBLE,
+	NL80211_STA_FLAG_WME,
+
+	/* keep last */
+	__NL80211_STA_FLAG_AFTER_LAST,
+	NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_sta_info - station information
+ *
+ * These attribute types are used with %NL80211_ATTR_STA_INFO
+ * when getting information about a station.
+ *
+ * @__NL80211_STA_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs)
+ * @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station)
+ * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station)
+ * @__NL80211_STA_INFO_AFTER_LAST: internal
+ * @NL80211_STA_INFO_MAX: highest possible station info attribute
+ */
+enum nl80211_sta_info {
+	__NL80211_STA_INFO_INVALID,
+	NL80211_STA_INFO_INACTIVE_TIME,
+	NL80211_STA_INFO_RX_BYTES,
+	NL80211_STA_INFO_TX_BYTES,
+	NL80211_STA_INFO_LLID,
+	NL80211_STA_INFO_PLID,
+	NL80211_STA_INFO_PLINK_STATE,
+
+	/* keep last */
+	__NL80211_STA_INFO_AFTER_LAST,
+	NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_mpath_flags - nl80211 mesh path flags
+ *
+ * @NL80211_MPATH_FLAG_ACTIVE: the mesh path is active
+ * @NL80211_MPATH_FLAG_RESOLVING: the mesh path discovery process is running
+ * @NL80211_MPATH_FLAG_DSN_VALID: the mesh path contains a valid DSN
+ * @NL80211_MPATH_FLAG_FIXED: the mesh path has been manually set
+ * @NL80211_MPATH_FLAG_RESOLVED: the mesh path discovery process succeeded
+ */
+enum nl80211_mpath_flags {
+	NL80211_MPATH_FLAG_ACTIVE =	1<<0,
+	NL80211_MPATH_FLAG_RESOLVING =	1<<1,
+	NL80211_MPATH_FLAG_DSN_VALID =	1<<2,
+	NL80211_MPATH_FLAG_FIXED =	1<<3,
+	NL80211_MPATH_FLAG_RESOLVED =	1<<4,
+};
+
+/**
+ * enum nl80211_mpath_info - mesh path information
+ *
+ * These attribute types are used with %NL80211_ATTR_MPATH_INFO when getting
+ * information about a mesh path.
+ *
+ * @__NL80211_MPATH_INFO_INVALID: attribute number 0 is reserved
+ * @NL80211_ATTR_MPATH_FRAME_QLEN: number of queued frames for this destination
+ * @NL80211_ATTR_MPATH_DSN: destination sequence number
+ * @NL80211_ATTR_MPATH_METRIC: metric (cost) of this mesh path
+ * @NL80211_ATTR_MPATH_EXPTIME: expiration time for the path, in msec from now
+ * @NL80211_ATTR_MPATH_FLAGS: mesh path flags, enumerated in
+ * 	&enum nl80211_mpath_flags;
+ * @NL80211_ATTR_MPATH_DISCOVERY_TIMEOUT: total path discovery timeout, in msec
+ * @NL80211_ATTR_MPATH_DISCOVERY_RETRIES: mesh path discovery retries
+ */
+enum nl80211_mpath_info {
+	__NL80211_MPATH_INFO_INVALID,
+	NL80211_MPATH_INFO_FRAME_QLEN,
+	NL80211_MPATH_INFO_DSN,
+	NL80211_MPATH_INFO_METRIC,
+	NL80211_MPATH_INFO_EXPTIME,
+	NL80211_MPATH_INFO_FLAGS,
+	NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
+	NL80211_MPATH_INFO_DISCOVERY_RETRIES,
+
+	/* keep last */
+	__NL80211_MPATH_INFO_AFTER_LAST,
+	NL80211_MPATH_INFO_MAX = __NL80211_MPATH_INFO_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_band_attr - band attributes
+ * @__NL80211_BAND_ATTR_INVALID: attribute number 0 is reserved
+ * @NL80211_BAND_ATTR_FREQS: supported frequencies in this band,
+ *	an array of nested frequency attributes
+ * @NL80211_BAND_ATTR_RATES: supported bitrates in this band,
+ *	an array of nested bitrate attributes
+ */
+enum nl80211_band_attr {
+	__NL80211_BAND_ATTR_INVALID,
+	NL80211_BAND_ATTR_FREQS,
+	NL80211_BAND_ATTR_RATES,
+
+	/* keep last */
+	__NL80211_BAND_ATTR_AFTER_LAST,
+	NL80211_BAND_ATTR_MAX = __NL80211_BAND_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_frequency_attr - frequency attributes
+ * @NL80211_FREQUENCY_ATTR_FREQ: Frequency in MHz
+ * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current
+ *	regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_PASSIVE_SCAN: Only passive scanning is
+ *	permitted on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_NO_IBSS: IBSS networks are not permitted
+ *	on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_RADAR: Radar detection is mandatory
+ *	on this channel in current regulatory domain.
+ */
+enum nl80211_frequency_attr {
+	__NL80211_FREQUENCY_ATTR_INVALID,
+	NL80211_FREQUENCY_ATTR_FREQ,
+	NL80211_FREQUENCY_ATTR_DISABLED,
+	NL80211_FREQUENCY_ATTR_PASSIVE_SCAN,
+	NL80211_FREQUENCY_ATTR_NO_IBSS,
+	NL80211_FREQUENCY_ATTR_RADAR,
+
+	/* keep last */
+	__NL80211_FREQUENCY_ATTR_AFTER_LAST,
+	NL80211_FREQUENCY_ATTR_MAX = __NL80211_FREQUENCY_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_bitrate_attr - bitrate attributes
+ * @NL80211_BITRATE_ATTR_RATE: Bitrate in units of 100 kbps
+ * @NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE: Short preamble supported
+ *	in 2.4 GHz band.
+ */
+enum nl80211_bitrate_attr {
+	__NL80211_BITRATE_ATTR_INVALID,
+	NL80211_BITRATE_ATTR_RATE,
+	NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE,
+
+	/* keep last */
+	__NL80211_BITRATE_ATTR_AFTER_LAST,
+	NL80211_BITRATE_ATTR_MAX = __NL80211_BITRATE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_reg_rule_attr - regulatory rule attributes
+ * @NL80211_ATTR_REG_RULE_FLAGS: a set of flags which specify additional
+ * 	considerations for a given frequency range. These are the
+ * 	&enum nl80211_reg_rule_flags.
+ * @NL80211_ATTR_FREQ_RANGE_START: starting frequencry for the regulatory
+ * 	rule in KHz. This is not a center of frequency but an actual regulatory
+ * 	band edge.
+ * @NL80211_ATTR_FREQ_RANGE_END: ending frequency for the regulatory rule
+ * 	in KHz. This is not a center a frequency but an actual regulatory
+ * 	band edge.
+ * @NL80211_ATTR_FREQ_RANGE_MAX_BW: maximum allowed bandwidth for this
+ * 	frequency range, in KHz.
+ * @NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN: the maximum allowed antenna gain
+ * 	for a given frequency range. The value is in mBi (100 * dBi).
+ * 	If you don't have one then don't send this.
+ * @NL80211_ATTR_POWER_RULE_MAX_EIRP: the maximum allowed EIRP for
+ * 	a given frequency range. The value is in mBm (100 * dBm).
+ */
+enum nl80211_reg_rule_attr {
+	__NL80211_REG_RULE_ATTR_INVALID,
+	NL80211_ATTR_REG_RULE_FLAGS,
+
+	NL80211_ATTR_FREQ_RANGE_START,
+	NL80211_ATTR_FREQ_RANGE_END,
+	NL80211_ATTR_FREQ_RANGE_MAX_BW,
+
+	NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN,
+	NL80211_ATTR_POWER_RULE_MAX_EIRP,
+
+	/* keep last */
+	__NL80211_REG_RULE_ATTR_AFTER_LAST,
+	NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1
+};
+
+/**
+ * enum nl80211_reg_rule_flags - regulatory rule flags
+ *
+ * @NL80211_RRF_NO_OFDM: OFDM modulation not allowed
+ * @NL80211_RRF_NO_CCK: CCK modulation not allowed
+ * @NL80211_RRF_NO_INDOOR: indoor operation not allowed
+ * @NL80211_RRF_NO_OUTDOOR: outdoor operation not allowed
+ * @NL80211_RRF_DFS: DFS support is required to be used
+ * @NL80211_RRF_PTP_ONLY: this is only for Point To Point links
+ * @NL80211_RRF_PTMP_ONLY: this is only for Point To Multi Point links
+ * @NL80211_RRF_PASSIVE_SCAN: passive scan is required
+ * @NL80211_RRF_NO_IBSS: no IBSS is allowed
+ */
+enum nl80211_reg_rule_flags {
+	NL80211_RRF_NO_OFDM		= 1<<0,
+	NL80211_RRF_NO_CCK		= 1<<1,
+	NL80211_RRF_NO_INDOOR		= 1<<2,
+	NL80211_RRF_NO_OUTDOOR		= 1<<3,
+	NL80211_RRF_DFS			= 1<<4,
+	NL80211_RRF_PTP_ONLY		= 1<<5,
+	NL80211_RRF_PTMP_ONLY		= 1<<6,
+	NL80211_RRF_PASSIVE_SCAN	= 1<<7,
+	NL80211_RRF_NO_IBSS		= 1<<8,
+};
+
+/**
+ * enum nl80211_mntr_flags - monitor configuration flags
+ *
+ * Monitor configuration flags.
+ *
+ * @__NL80211_MNTR_FLAG_INVALID: reserved
+ *
+ * @NL80211_MNTR_FLAG_FCSFAIL: pass frames with bad FCS
+ * @NL80211_MNTR_FLAG_PLCPFAIL: pass frames with bad PLCP
+ * @NL80211_MNTR_FLAG_CONTROL: pass control frames
+ * @NL80211_MNTR_FLAG_OTHER_BSS: disable BSSID filtering
+ * @NL80211_MNTR_FLAG_COOK_FRAMES: report frames after processing.
+ *	overrides all other flags.
+ *
+ * @__NL80211_MNTR_FLAG_AFTER_LAST: internal use
+ * @NL80211_MNTR_FLAG_MAX: highest possible monitor flag
+ */
+enum nl80211_mntr_flags {
+	__NL80211_MNTR_FLAG_INVALID,
+	NL80211_MNTR_FLAG_FCSFAIL,
+	NL80211_MNTR_FLAG_PLCPFAIL,
+	NL80211_MNTR_FLAG_CONTROL,
+	NL80211_MNTR_FLAG_OTHER_BSS,
+	NL80211_MNTR_FLAG_COOK_FRAMES,
+
+	/* keep last */
+	__NL80211_MNTR_FLAG_AFTER_LAST,
+	NL80211_MNTR_FLAG_MAX = __NL80211_MNTR_FLAG_AFTER_LAST - 1
+};
+
+#endif /* __LINUX_NL80211_H */

Added: iw/branches/upstream/current/phy.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/phy.c?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/phy.c (added)
+++ iw/branches/upstream/current/phy.c Fri Sep 19 14:42:49 2008
@@ -1,0 +1,26 @@
+#include <errno.h>
+#include <net/if.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 handle_name(struct nl_cb *cb,
+		       struct nl_msg *msg,
+		       int argc, char **argv)
+{
+	if (argc != 1)
+		return 1;
+
+	NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, *argv);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(set, name, "<new name>", NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_name);

Added: iw/branches/upstream/current/reg.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/reg.c?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/reg.c (added)
+++ iw/branches/upstream/current/reg.c Fri Sep 19 14:42:49 2008
@@ -1,0 +1,69 @@
+#include <net/if.h>
+#include <errno.h>
+#include <string.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"
+
+int isalpha_upper(char letter)
+{
+	if (letter >= 65 && letter <= 90)
+		return 1;
+	return 0;
+}
+
+static int is_alpha2(char *alpha2)
+{
+	if (isalpha_upper(alpha2[0]) && isalpha_upper(alpha2[1]))
+		return 1;
+	return 0;
+}
+
+static int is_world_regdom(char *alpha2)
+{
+	/* ASCII 0 */
+	if (alpha2[0] == 48 && alpha2[1] == 48)
+		return 1;
+	return 0;
+}
+
+static int handle_reg_set(struct nl_cb *cb,
+			  struct nl_msg *msg,
+			  int argc, char **argv)
+{
+	char alpha2[3];
+
+	if (argc < 1)
+		return 1;
+
+	if (!is_alpha2(argv[0]) && !is_world_regdom(argv[0])) {
+		fprintf(stderr, "not a valid ISO/IEC 3166-1 alpha2\n");
+		fprintf(stderr, "Special non-alpha2 usable entries:\n");
+		fprintf(stderr, "\t00\tWorld Regulatory domain\n");
+		return 2;
+	}
+
+	alpha2[0] = argv[0][0];
+	alpha2[1] = argv[0][1];
+	alpha2[2] = '\0';
+
+	argc--;
+	argv++;
+
+	if (argc)
+		return 1;
+
+	NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, alpha2);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(reg, set, "<ISO/IEC 3166-1 alpha2>",
+	NL80211_CMD_REQ_SET_REG, 0, CIB_NONE, handle_reg_set);

Added: iw/branches/upstream/current/station.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/station.c?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/station.c (added)
+++ iw/branches/upstream/current/station.c Fri Sep 19 14:42:49 2008
@@ -1,0 +1,206 @@
+#include <net/if.h>
+#include <errno.h>
+#include <string.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"
+
+enum plink_state {
+	LISTEN,
+	OPN_SNT,
+	OPN_RCVD,
+	CNF_RCVD,
+	ESTAB,
+	HOLDING,
+	BLOCKED
+};
+
+enum plink_actions {
+	PLINK_ACTION_UNDEFINED,
+	PLINK_ACTION_OPEN,
+	PLINK_ACTION_BLOCK,
+};
+
+
+static int print_sta_handler(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];
+	char mac_addr[20], state_name[10], dev[20];
+	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_LLID] = { .type = NLA_U16 },
+		[NL80211_STA_INFO_PLID] = { .type = NLA_U16 },
+		[NL80211_STA_INFO_PLINK_STATE] = { .type = NLA_U8 },
+	};
+
+	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+		  genlmsg_attrlen(gnlh, 0), NULL);
+
+	/*
+	 * TODO: validate the interface and mac address!
+	 * Otherwise, there's a race condition as soon as
+	 * the kernel starts sending station notifications.
+	 */
+
+	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;
+	}
+
+	mac_addr_n2a(mac_addr, nla_data(tb[NL80211_ATTR_MAC]));
+	if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), dev);
+	printf("Station %s (on %s)", mac_addr, dev);
+
+	if (sinfo[NL80211_STA_INFO_INACTIVE_TIME])
+		printf("\n\tinactive time:\t%d ms",
+			nla_get_u32(sinfo[NL80211_STA_INFO_INACTIVE_TIME]));
+	if (sinfo[NL80211_STA_INFO_RX_BYTES])
+		printf("\n\trx bytes:\t%d",
+			nla_get_u32(sinfo[NL80211_STA_INFO_RX_BYTES]));
+	if (sinfo[NL80211_STA_INFO_TX_BYTES])
+		printf("\n\ttx bytes:\t%d",
+			nla_get_u32(sinfo[NL80211_STA_INFO_TX_BYTES]));
+	if (sinfo[NL80211_STA_INFO_LLID])
+		printf("\n\tmesh llid:\t%d",
+			nla_get_u16(sinfo[NL80211_STA_INFO_LLID]));
+	if (sinfo[NL80211_STA_INFO_PLID])
+		printf("\n\tmesh plid:\t%d",
+			nla_get_u16(sinfo[NL80211_STA_INFO_PLID]));
+	if (sinfo[NL80211_STA_INFO_PLINK_STATE]) {
+		switch (nla_get_u16(sinfo[NL80211_STA_INFO_PLINK_STATE])) {
+		case LISTEN:
+			strcpy(state_name, "LISTEN");
+			break;
+		case OPN_SNT:
+			strcpy(state_name, "OPN_SNT");
+			break;
+		case OPN_RCVD:
+			strcpy(state_name, "OPN_RCVD");
+			break;
+		case CNF_RCVD:
+			strcpy(state_name, "CNF_RCVD");
+			break;
+		case ESTAB:
+			strcpy(state_name, "ESTAB");
+			break;
+		case HOLDING:
+			strcpy(state_name, "HOLDING");
+			break;
+		case BLOCKED:
+			strcpy(state_name, "BLOCKED");
+			break;
+		default:
+			strcpy(state_name, "UNKNOWN");
+			break;
+		}
+		printf("\n\tmesh plink:\t%s", state_name);
+	}
+
+	printf("\n");
+	return NL_SKIP;
+}
+
+static int handle_station_get(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_sta_handler, NULL);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(station, get, "<MAC address>",
+	NL80211_CMD_GET_STATION, 0, CIB_NETDEV, handle_station_get);
+COMMAND(station, del, "<MAC address>",
+	NL80211_CMD_DEL_STATION, 0, CIB_NETDEV, handle_station_get);
+
+static int handle_station_set(struct nl_cb *cb,
+			      struct nl_msg *msg,
+			      int argc, char **argv)
+{
+	unsigned char plink_action;
+	unsigned char mac_addr[ETH_ALEN];
+
+	if (argc < 3)
+		return 1;
+
+	if (mac_addr_a2n(mac_addr, argv[0])) {
+		fprintf(stderr, "invalid mac address\n");
+		return 2;
+	}
+	argc--;
+	argv++;
+
+	if (strcmp("plink_action", argv[0]) != 0)
+		return 1;
+	argc--;
+	argv++;
+
+	if (strcmp("open", argv[0]) == 0)
+		plink_action = PLINK_ACTION_OPEN;
+	else if (strcmp("block", argv[0]) == 0)
+		plink_action = PLINK_ACTION_BLOCK;
+	else {
+		fprintf(stderr, "plink action not supported\n");
+		return 2;
+	}
+	argc--;
+	argv++;
+
+	if (argc)
+		return 1;
+
+	NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
+	NLA_PUT_U8(msg, NL80211_ATTR_STA_PLINK_ACTION, plink_action);
+
+	return 0;
+ nla_put_failure:
+	return -ENOBUFS;
+}
+COMMAND(station, set, "<MAC address> plink_action <open|block>",
+	NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set);
+
+static int handle_station_dump(struct nl_cb *cb,
+			       struct nl_msg *msg,
+			       int argc, char **argv)
+{
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_sta_handler, NULL);
+	return 0;
+}
+COMMAND(station, dump, NULL,
+	NL80211_CMD_GET_STATION, NLM_F_DUMP, CIB_NETDEV, handle_station_dump);

Added: iw/branches/upstream/current/util.c
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/util.c?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/util.c (added)
+++ iw/branches/upstream/current/util.c Fri Sep 19 14:42:49 2008
@@ -1,0 +1,67 @@
+#include "nl80211.h"
+#include "iw.h"
+
+int mac_addr_n2a(char *mac_addr, unsigned char *arg)
+{
+	int i, l;
+
+	l = 0;
+	for (i = 0; i < ETH_ALEN ; i++) {
+		if (i == 0) {
+			sprintf(mac_addr+l, "%02x", arg[i]);
+			l += 2;
+		} else {
+			sprintf(mac_addr+l, ":%02x", arg[i]);
+			l += 3;
+		}
+	}
+	return 0;
+}
+
+int mac_addr_a2n(unsigned char *mac_addr, char *arg)
+{
+	int i;
+
+	for (i = 0; i < ETH_ALEN ; i++) {
+		int temp;
+		char *cp = strchr(arg, ':');
+		if (cp) {
+			*cp = 0;
+			cp++;
+		}
+		if (sscanf(arg, "%x", &temp) != 1)
+			return -1;
+		if (temp < 0 || temp > 255)
+			return -1;
+
+		mac_addr[i] = temp;
+		if (!cp)
+			break;
+		arg = cp;
+	}
+	if (i < ETH_ALEN - 1)
+		return -1;
+
+	return 0;
+}
+
+static const char *ifmodes[NL80211_IFTYPE_MAX + 1] = {
+	"unspecified",
+	"IBSS",
+	"Station",
+	"AP",
+	"AP(VLAN)",
+	"WDS",
+	"Monitor",
+	"mesh point"
+};
+
+static char modebuf[100];
+
+const char *iftype_name(enum nl80211_iftype iftype)
+{
+	if (iftype <= NL80211_IFTYPE_MAX)
+		return ifmodes[iftype];
+	sprintf(modebuf, "Unknown mode (%d)", iftype);
+	return modebuf;
+}

Added: iw/branches/upstream/current/version.sh
URL: http://svn.debian.org/wsvn/iw/branches/upstream/current/version.sh?rev=1239&op=file
==============================================================================
--- iw/branches/upstream/current/version.sh (added)
+++ iw/branches/upstream/current/version.sh Fri Sep 19 14:42:49 2008
@@ -1,0 +1,23 @@
+#!/bin/sh
+
+VERSION="0.9.5"
+
+(
+if head=`git rev-parse --verify HEAD 2>/dev/null`; then
+	git update-index --refresh --unmerged > /dev/null
+	descr=$(git describe)
+
+	# on git builds check that the version number above
+	# is correct...
+	[ "${descr%%-*}" = "v$VERSION" ] || exit 2
+	
+	echo -n '#define IW_VERSION "'
+	echo -n "${descr#v}"
+	if git diff-index --name-only HEAD | read dummy ; then
+		echo -n "-dirty"
+	fi
+	echo '"'
+else
+echo "#define IW_VERSION \"$VERSION-nogit\""
+fi
+) > version.h

Propchange: iw/branches/upstream/current/version.sh
------------------------------------------------------------------------------
    svn:executable = 




More information about the Pkg-wpa-devel mailing list