--- wireless-tools-30~pre9.orig/Makefile
+++ wireless-tools-30~pre9/Makefile
@@ -106,7 +106,7 @@ endif
 # Other flags
 #CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
 	-Wpointer-arith -Wcast-qual -Winline -I.
-CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
+CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I. -DIW_USES_ITS_OWN_DOGFOOD
 DEPFLAGS=-MMD
 XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
 PICFLAG=-fPIC
--- /dev/null
+++ wireless-tools-30~pre9/wireless-tools_29-2ubuntu6.patch
@@ -0,0 +1,1169 @@
+diff -pruN 29-2/Makefile 29-2ubuntu6/Makefile
+--- 29-2/Makefile	2009-10-21 15:29:10.000000000 +0100
++++ 29-2ubuntu6/Makefile	2009-10-21 15:29:10.000000000 +0100
+@@ -104,7 +104,7 @@ endif
+ # Other flags
+ #CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
+ 	-Wpointer-arith -Wcast-qual -Winline -I.
+-CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
++CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I. -DIW_USES_ITS_OWN_DOGFOOD
+ DEPFLAGS=-MMD
+ XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
+ PICFLAG=-fPIC
+diff -pruN 29-2/debian/README.Debian 29-2ubuntu6/debian/README.Debian
+--- 29-2/debian/README.Debian	2009-10-21 15:29:10.000000000 +0100
++++ 29-2ubuntu6/debian/README.Debian	2009-10-21 15:29:10.000000000 +0100
+@@ -48,3 +48,19 @@ Example of multiple keys:
+     wireless-key3 s:password
+     wireless-defaultkey 2
+     wireless-keymode open
++
++---------------------------------------------------------------------------
++
++rfkill/README:
++
++This is 'rfkill', a tool to use /dev/rfkill.
++
++
++To build rfkill, just enter 'make'.
++
++'rfkill' is currently maintained at http://git.sipsolutions.net/rfkill.git/,
++some more documentation is available at
++http://wireless.kernel.org/en/users/Documentation/rfkill.
++
++Please send all patches to Johannes Berg <johannes@sipsolutions.net>
++and CC linux-wireless@vger.kernel.org for community review.
+diff -pruN 29-2/debian/changelog 29-2ubuntu6/debian/changelog
+--- 29-2/debian/changelog	2009-10-21 15:29:10.000000000 +0100
++++ 29-2ubuntu6/debian/changelog	2009-10-21 15:29:10.000000000 +0100
+@@ -18,6 +104,34 @@ wireless-tools (29-1.1) unstable; urgenc
+ 
+  -- Frans Pop <fjp@debian.org>  Sun, 13 Jul 2008 00:07:00 +0200
+ 
++wireless-tools (29-1ubuntu2) hardy; urgency=low
++
++  * Dropped change:
++    - Don't diverge unnecessarily from upstream on socket.h header
++      inclusions, this only applies to ancient versions of the
++      wireless.h header that won't be shipped in the binary packages
++      (current versions of the header have a proper #ifdef __KERNEL__ guard)
++
++ -- Steve Langasek <vorlon@debian.org>  Wed, 28 Nov 2007 16:49:17 -0800
++
++wireless-tools (29-1ubuntu1) hardy; urgency=low
++
++  * Merge from Debian unstable, remaining changes:
++    - Fix confusing text in iftab(5) about mapping ordering.
++    - Use <sys/socket.h> like the socket(2) manpage says.
++    - Rather than just warning about NULL MAC addresses, ignore them totally
++      and treat their appearance as an error, and try and hint where the
++      NULL MAC address is so the user can remove it.
++    - Remove the ifrename package; it conflicts with our own udev package
++      which provides /etc/iftab support.
++    - Bring up the interface before making any changes to the wireless
++      settings - required for at least softmac drivers.
++    - Set Ubuntu maintainer address.
++  * Use sys/socket.h instead of linux/socket.h for the new version 21
++    and 22 headers as well
++
++ -- Steve Langasek <vorlon@debian.org>  Tue, 27 Nov 2007 18:10:48 -0800
++
+ wireless-tools (29-1) unstable; urgency=low
+ 
+   * New upstream release.
+@@ -43,6 +157,22 @@ wireless-tools (29~pre21-1) unstable; ur
+ 
+  -- Guus Sliepen <guus@debian.org>  Thu, 03 May 2007 13:55:01 +0200
+ 
++wireless-tools (29~pre20-1ubuntu1) gutsy; urgency=low
++
++  * Resynchronise with Debian. Remaining changes:
++    - Fix confusing text in iftab(5) about mapping ordering.
++    - Use <sys/socket.h> like the socket(2) manpage says.
++    - Rather than just warning about NULL MAC addresses, ignore them totally
++      and treat their appearance as an error, and try and hint where the
++      NULL MAC address is so the user can remove it.
++    - Remove the ifrename package; it conflicts with our own udev package
++      which provides /etc/iftab support.
++    - Bring up the interface before making any changes to the wireless
++      settings - required for at least softmac drivers.
++  * Set Ubuntu maintainer address.
++
++ -- Colin Watson <cjwatson@ubuntu.com>  Fri, 27 Apr 2007 14:37:37 +0100
++
+ wireless-tools (29~pre20-1) unstable; urgency=low
+ 
+   * New upstream release.
+@@ -89,6 +219,27 @@ wireless-tools (28+29pre7-1) experimenta
+ 
+  -- Guus Sliepen <guus@debian.org>  Tue, 11 Apr 2006 20:10:21 +0200
+ 
++wireless-tools (28-1ubuntu3) feisty; urgency=low
++
++  * Bring up the interface before making any changes to the wireless
++    settings - required for at least softmac drivers (Ubuntu: #63664)
++
++ -- Matthew Garrett <mjg59@srcf.ucam.org>  Thu, 21 Dec 2006 04:09:56 +0000
++
++wireless-tools (28-1ubuntu2) edgy; urgency=low
++
++  * Remove the ifrename package, it conflicts with our own udev package
++    which provides /etc/iftab support.
++
++ -- Scott James Remnant <scott@ubuntu.com>  Wed, 23 Aug 2006 09:36:17 +0200
++
++wireless-tools (28-1ubuntu1) edgy; urgency=low
++
++  [ Ongoing Merge Process ]
++  * Merge from debian unstable.
++
++ -- Scott James Remnant <scott@ubuntu.com>  Wed, 28 Jun 2006 23:40:55 +0100
++
+ wireless-tools (28-1) unstable; urgency=low
+ 
+   * New upstream release.
+@@ -118,6 +269,18 @@ wireless-tools (27+28pre14-1) unstable; 
+ 
+  -- Guus Sliepen <guus@debian.org>  Tue, 14 Feb 2006 12:29:31 +0100
+ 
++wireless-tools (27+28pre13-1ubuntu2) dapper; urgency=low
++
++  * Don't run the init script if the udev renaming rules are in place.
++
++ -- Scott James Remnant <scott@ubuntu.com>  Thu,  9 Feb 2006 22:30:07 +0000
++
++wireless-tools (27+28pre13-1ubuntu1) dapper; urgency=low
++
++  * Resynchronise with Debian.
++
++ -- Scott James Remnant <scott@ubuntu.com>  Mon, 30 Jan 2006 09:54:45 +0000
++
+ wireless-tools (27+28pre13-1) unstable; urgency=low
+ 
+   * New upstream release.
+@@ -132,6 +295,12 @@ wireless-tools (27+28pre11-1) unstable; 
+ 
+  -- Guus Sliepen <guus@debian.org>  Fri,  2 Dec 2005 12:30:21 +0100
+ 
++wireless-tools (27+28pre10-1ubuntu1) dapper; urgency=low
++
++  * Resynchronise with Debian.
++
++ -- Colin Watson <cjwatson@ubuntu.com>  Mon, 31 Oct 2005 06:49:46 -0500
++
+ wireless-tools (27+28pre10-1) unstable; urgency=low
+ 
+   * New upstream release. Closes: #272662
+@@ -146,6 +315,34 @@ wireless-tools (27+28pre9-1) unstable; u
+ 
+  -- Guus Sliepen <guus@debian.org>  Wed,  7 Sep 2005 12:59:48 +0200
+ 
++wireless-tools (27+28pre8-1ubuntu4) breezy; urgency=low
++
++  * Make the NULL MAC address error a little less scary, and try and hint
++    where it is so the user can remove it.  (Ubuntu #15342).
++
++ -- Scott James Remnant <scott@ubuntu.com>  Mon, 19 Sep 2005 12:52:12 +0100
++
++wireless-tools (27+28pre8-1ubuntu3) breezy; urgency=low
++
++  * Rather than just warning about NULL MAC addresses, ignore them totally
++    and treat their appearance as an error.  (Ubuntu #13993).
++
++ -- Scott James Remnant <scott@ubuntu.com>  Sat, 27 Aug 2005 00:53:35 +0100
++
++wireless-tools (27+28pre8-1ubuntu2) breezy; urgency=low
++
++  * Enable takeover support in ifrename startup script, this will allow
++    interfaces to swap names.  (Ubuntu #8391, #10240, #13551).
++
++ -- Scott James Remnant <scott@ubuntu.com>  Thu, 18 Aug 2005 02:23:57 +0100
++
++wireless-tools (27+28pre8-1ubuntu1) breezy; urgency=low
++
++  * Resynchronise with Debian, resolving merge conflicts (Ubuntu #11980)
++  * New version is greater than 28pre3, so this should close #11434
++
++ -- Adam Conrad <adconrad@ubuntu.com>  Wed, 29 Jun 2005 11:00:47 +0000
++
+ wireless-tools (27+28pre8-1) unstable; urgency=low
+ 
+   * New upstream release.
+@@ -153,6 +350,18 @@ wireless-tools (27+28pre8-1) unstable; u
+ 
+  -- Guus Sliepen <guus@debian.org>  Mon, 13 Jun 2005 11:41:28 +0200
+ 
++wireless-tools (27-3ubuntu2) breezy; urgency=low
++
++  * Use <sys/socket.h> like the socket(2) manpage says.
++
++ -- LaMont Jones <lamont@ubuntu.com>  Mon, 23 May 2005 10:43:12 -0600
++
++wireless-tools (27-3ubuntu1) breezy; urgency=low
++
++  * Resynchronise with Debian.
++
++ -- Scott James Remnant <scott@ubuntu.com>  Fri, 15 Apr 2005 00:00:56 +0100
++
+ wireless-tools (27-3) unstable; urgency=low
+ 
+   * Add a post-down script that reverts any wireless setting present in
+@@ -169,6 +378,12 @@ wireless-tools (27-2) unstable; urgency=
+ 
+  -- Guus Sliepen <guus@debian.org>  Sat,  5 Feb 2005 12:21:30 +0100
+ 
++wireless-tools (27-1ubuntu1) hoary; urgency=low
++
++  * fixed weird fromulation in iftab manpage (closes ubuntu bug #5727)
++
++ -- Oliver Grawert (ogra) <hostmaster@grawert.net>  Thu, 17 Mar 2005 20:23:25 +0100
++
+ wireless-tools (27-1) unstable; urgency=low
+ 
+   * New upstream release, that "hopefully will help the prompt release of the
+diff -pruN 29-2/debian/rules 29-2ubuntu6/debian/rules
+--- 29-2/debian/rules	2009-10-21 15:29:10.000000000 +0100
++++ 29-2ubuntu6/debian/rules	2009-10-21 15:29:10.000000000 +0100
+@@ -9,6 +9,7 @@ build: build-stamp
+ build-stamp:
+ 	dh_testdir
+ 	$(MAKE) all libiw.a
++	$(MAKE) -C rfkill rfkill
+ 	touch build-stamp
+ 
+ clean:
+@@ -16,6 +17,7 @@ clean:
+ 	dh_testroot
+ 	rm -f build-stamp
+ 	$(MAKE) realclean
++	$(MAKE) -C rfkill clean
+ 	dh_clean
+ 
+ install: build
+diff -pruN 29-2/debian/wireless-tools.install 29-2ubuntu6/debian/wireless-tools.install
+--- 29-2/debian/wireless-tools.install	2009-10-21 15:29:10.000000000 +0100
++++ 29-2ubuntu6/debian/wireless-tools.install	2009-10-21 15:29:10.000000000 +0100
+@@ -1,5 +1,7 @@
+ debian/tmp/sbin/iw*
++debian/tmp/sbin/rfkill
+ debian/tmp/usr/share/man/man8/iw*.8
+ debian/tmp/usr/share/man/man7/*.7
+ debian/tmp/usr/share/man/*/man8/iw*.8
+ debian/tmp/usr/share/man/*/man7/*.7
++debian/tmp/usr/share/man/man1/*.1.gz
+diff -pruN 29-2/ifrename.c 29-2ubuntu6/ifrename.c
+--- 29-2/ifrename.c	2007-03-15 18:44:50.000000000 +0000
++++ 29-2ubuntu6/ifrename.c	2009-10-21 15:29:10.000000000 +0100
+@@ -692,9 +692,9 @@ mapping_addmac(struct if_mapping *	ifnod
+       /* Check that it's not NULL */
+       if((ifnode->mac_len == 6) && (!memcmp(&ifnode->mac, &zero_mac, 6)))
+ 	{
+-	  fprintf(stderr,
+-		  "Warning: MAC address is null at line %d, this is dangerous...\n",
+-		  linenum);
++	  fprintf(stderr, "Error: Null MAC address (`%s') at line %d\n",
++		  ifnode->mac_filter, linenum);
++	  return(-1);
+ 	}
+ 
+       ifnode->active[SELECT_MAC] = HAS_MAC_EXACT;
+@@ -2197,11 +2197,11 @@ mapping_readfile(const char *	filename)
+ 	{
+ 	  /* If we have not yet printed an error, now is a good time ;-) */
+ 	  if(ret == -13)
+-	    fprintf(stderr, "Error: Line %d ignored, no valid selectors\n",
+-		    linenum);
++	    fprintf(stderr, "Error: %s line %d ignored, no valid selectors.  Please correct or remove this line.\n",
++		    filename, linenum);
+ 	  else
+-	    fprintf(stderr, "Error: Line %d ignored due to prior errors\n",
+-		    linenum);
++	    fprintf(stderr, "Error: %s line %d ignored due to above errors.  Please correct or remove this line.\n",
++		    filename, linenum);
+ 
+ 	  free(ifnode);
+ 	}
+diff -pruN 29-2/iftab.5 29-2ubuntu6/iftab.5
+--- 29-2/iftab.5	2007-03-03 01:34:12.000000000 +0000
++++ 29-2ubuntu6/iftab.5	2009-10-21 15:29:10.000000000 +0100
+@@ -50,11 +50,7 @@ If you want to use alternate descriptors
+ (logical or), specify two different mappings with the same interface
+ name (one on each line).
+ .B Ifrename
+-always use the first matching mapping starting from the
+-.I end
+-of
+-.BR iftab ,
+-therefore more restrictive mapping should be specified last.
++always uses the last matching mapping in iftab.
+ .\"
+ .\" INTERFACE NAME part
+ .\"
+diff -pruN 29-2/rfkill/COPYING 29-2ubuntu6/rfkill/COPYING
+--- 29-2/rfkill/COPYING	1970-01-01 01:00:00.000000000 +0100
++++ 29-2ubuntu6/rfkill/COPYING	2009-10-21 15:29:10.000000000 +0100
+@@ -0,0 +1,15 @@
++Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
++Copyright 2009 Marcel Holtmann <marcel@holtmann.org>
++Copyright 2009 Tim Gardner <tim.gardner@canonical.com>
++
++Permission to use, copy, modify, and/or distribute this software for any
++purpose with or without fee is hereby granted, provided that the above
++copyright notice and this permission notice appear in all copies.
++
++THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+diff -pruN 29-2/rfkill/Makefile 29-2ubuntu6/rfkill/Makefile
+--- 29-2/rfkill/Makefile	1970-01-01 01:00:00.000000000 +0100
++++ 29-2ubuntu6/rfkill/Makefile	2009-10-21 15:29:10.000000000 +0100
+@@ -0,0 +1,58 @@
++MAKEFLAGS += --no-print-directory
++
++PREFIX ?= /usr
++BINDIR ?= $(PREFIX)/bin
++MANDIR ?= $(PREFIX)/share/man
++
++MKDIR ?= mkdir -p
++INSTALL ?= install
++CC ?= "gcc"
++
++CFLAGS ?= -O2 -g
++CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
++
++OBJS = rfkill.o version.o
++ALL = rfkill
++
++ifeq ($(V),1)
++Q=
++NQ=true
++else
++Q=@
++NQ=echo
++endif
++
++all: $(ALL)
++
++VERSION_OBJS := $(filter-out version.o, $(OBJS))
++
++version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) rfkill.h Makefile \
++		$(wildcard .git/index .git/refs/tags)
++	@$(NQ) ' GEN ' $@
++	$(Q)sh ./version.sh $@
++
++%.o: %.c rfkill.h
++	@$(NQ) ' CC  ' $@
++	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
++
++rfkill:	$(OBJS)
++	@$(NQ) ' CC  ' rfkill
++	$(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o rfkill
++
++check:
++	$(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
++
++%.gz: %
++	@$(NQ) ' GZIP' $<
++	$(Q)gzip < $< > $@
++
++install: rfkill rfkill.1.gz
++	@$(NQ) ' INST rfkill'
++	$(Q)$(MKDIR) $(DESTDIR)$(BINDIR)
++	$(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(BINDIR) rfkill
++	@$(NQ) ' INST rfkill.1'
++	$(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man1/
++	$(Q)$(INSTALL) -m 644 -t $(DESTDIR)$(MANDIR)/man1/ rfkill.1.gz
++
++clean:
++	$(Q)rm -f rfkill *.o *~ *.gz version.c *-stamp
+diff -pruN 29-2/rfkill/README 29-2ubuntu6/rfkill/README
+--- 29-2/rfkill/README	1970-01-01 01:00:00.000000000 +0100
++++ 29-2ubuntu6/rfkill/README	2009-10-21 15:29:10.000000000 +0100
+@@ -0,0 +1,12 @@
++
++This is 'rfkill', a tool to use /dev/rfkill.
++
++
++To build rfkill, just enter 'make'.
++
++'rfkill' is currently maintained at http://git.sipsolutions.net/rfkill.git/,
++some more documentation is available at
++http://wireless.kernel.org/en/users/Documentation/rfkill.
++
++Please send all patches to Johannes Berg <johannes@sipsolutions.net>
++and CC linux-wireless@vger.kernel.org for community review.
+diff -pruN 29-2/rfkill/core.h 29-2ubuntu6/rfkill/core.h
+--- 29-2/rfkill/core.h	1970-01-01 01:00:00.000000000 +0100
++++ 29-2ubuntu6/rfkill/core.h	2009-10-21 15:29:10.000000000 +0100
+@@ -0,0 +1,8 @@
++#ifndef __CORE
++#define __CORE
++
++#include "rfkill.h"
++
++extern const char rfkill_version[];
++
++#endif
+diff -pruN 29-2/rfkill/rfkill.1 29-2ubuntu6/rfkill/rfkill.1
+--- 29-2/rfkill/rfkill.1	1970-01-01 01:00:00.000000000 +0100
++++ 29-2ubuntu6/rfkill/rfkill.1	2009-10-21 15:29:10.000000000 +0100
+@@ -0,0 +1,36 @@
++.\"                                      Hey, EMACS: -*- nroff -*-
++.TH RFKILL 1 "July 10, 2009"
++.SH NAME
++rfkill \- tool for enabling and disabling wireless devices
++.SH SYNOPSIS
++.B rfkill
++.RI [ options ] " command"
++.SH OPTIONS
++.TP
++.B \-\-version
++Show the version of rfkill.
++.SH COMMANDS
++.TP
++.B help
++Show rfkill's built-in help text.
++.TP
++.B event
++Listen for rfkill events and display them on stdout.
++.TP
++.B list
++List the current state of all available rfkill-using devices.
++.TP
++.BI block " index|type"
++Disable the device corresponding to the given index.
++\fItype\fR is one of "all", "wifi", "bluetooth", "uwb", "wimax", "wwan" or "gps".
++.TP
++.BI unblock " index|type"
++Enable the device corresponding to the given index. If the device is
++hard-blocked, e.g. via a hardware switch, it will remain unavailable though
++it is now soft-unblocked.
++.SH AUTHORS
++rfkill was originally written by Johannes Berg <johannes@sipsolutions.net>
++and Marcel Holtmann <marcel@holtmann.org>.
++.PP
++This manual page was written by Darren Salt <linux@youmustbejoking.demon.co.uk>,
++for the Debian project (and may be used by others).
+diff -pruN 29-2/rfkill/rfkill.c 29-2ubuntu6/rfkill/rfkill.c
+--- 29-2/rfkill/rfkill.c	1970-01-01 01:00:00.000000000 +0100
++++ 29-2ubuntu6/rfkill/rfkill.c	2009-10-21 15:29:10.000000000 +0100
+@@ -0,0 +1,297 @@
++/*
++ * rfkill userspace tool
++ */
++
++#include <stdio.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include <string.h>
++#include <ctype.h>
++#include <stdbool.h>
++#include <sys/types.h>
++#include <sys/poll.h>
++
++#include "rfkill.h"
++#include "core.h"
++
++static void rfkill_event(void)
++{
++	struct rfkill_event event;
++	struct pollfd p;
++	ssize_t len;
++	int fd, n;
++
++	fd = open("/dev/rfkill", O_RDONLY);
++	if (fd < 0) {
++		perror("Can't open RFKILL control device");
++		return;
++	}
++
++	memset(&p, 0, sizeof(p));
++	p.fd = fd;
++	p.events = POLLIN | POLLHUP;
++
++	while (1) {
++		n = poll(&p, 1, -1);
++		if (n < 0) {
++			perror("Failed to poll RFKILL control device");
++			break;
++		}
++
++		if (n == 0)
++			continue;
++
++		len = read(fd, &event, sizeof(event));
++		if (len < 0) {
++			perror("Reading of RFKILL events failed");
++			break;
++		}
++
++		if (len != RFKILL_EVENT_SIZE_V1) {
++			fprintf(stderr, "Wrong size of RFKILL event\n");
++			continue;
++		}
++
++		printf("RFKILL event: idx %u type %u op %u soft %u hard %u\n",
++					event.idx, event.type, event.op,
++					event.soft, event.hard);
++	}
++
++	close(fd);
++}
++
++static const char *get_name(__u32 idx)
++{
++	static char name[128];
++	ssize_t len;
++	char *pos, filename[64];
++	int fd;
++
++	snprintf(filename, sizeof(filename) - 1,
++				"/sys/class/rfkill/rfkill%u/name", idx);
++
++	fd = open(filename, O_RDONLY);
++	if (fd < 0)
++		return NULL;
++
++	memset(name, 0, sizeof(name));
++	len = read(fd, name, sizeof(name) - 1);
++
++	pos = strchr(name, '\n');
++	if (pos)
++		*pos = '\0';
++
++	close(fd);
++
++	return name;
++}
++
++static const char *type2string(enum rfkill_type type)
++{
++	switch (type) {
++	case RFKILL_TYPE_ALL:
++		return "All";
++	case RFKILL_TYPE_WLAN:
++		return "Wireless LAN";
++	case RFKILL_TYPE_BLUETOOTH:
++		return "Bluetooth";
++	case RFKILL_TYPE_UWB:
++		return "Ultra-Wideband";
++	case RFKILL_TYPE_WIMAX:
++		return "WiMAX";
++	case RFKILL_TYPE_WWAN:
++		return "Wireless WAN";
++	case RFKILL_TYPE_GPS:
++		return "GPS";
++	case NUM_RFKILL_TYPES:
++		return NULL;
++	}
++
++	return NULL;
++}
++
++static void rfkill_list(void)
++{
++	struct rfkill_event event;
++	const char *name;
++	ssize_t len;
++	int fd;
++
++	fd = open("/dev/rfkill", O_RDONLY);
++	if (fd < 0) {
++		perror("Can't open RFKILL control device");
++		return;
++	}
++
++	if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
++		perror("Can't set RFKILL control device to non-blocking");
++		close(fd);
++	}
++
++	while (1) {
++		len = read(fd, &event, sizeof(event));
++		if (len < 0) {
++			if (errno == EAGAIN)
++				break;
++			perror("Reading of RFKILL events failed");
++			break;
++		}
++
++		if (len != RFKILL_EVENT_SIZE_V1) {
++			fprintf(stderr, "Wrong size of RFKILL event\n");
++			continue;
++		}
++
++		if (event.op != RFKILL_OP_ADD)
++			continue;
++
++		name = get_name(event.idx);
++
++		printf("%u: %s: %s\n", event.idx, name,
++						type2string(event.type));
++		printf("\tSoft blocked: %s\n", event.soft ? "yes" : "no");
++		printf("\tHard blocked: %s\n", event.hard ? "yes" : "no");
++	}
++
++	close(fd);
++}
++
++static void rfkill_block(bool all, __u32 idx, __u8 block, __u8 type)
++{
++	struct rfkill_event event;
++	ssize_t len;
++	int fd;
++
++	fd = open("/dev/rfkill", O_RDWR);
++	if (fd < 0) {
++		perror("Can't open RFKILL control device");
++		return;
++	}
++
++	memset(&event, 0, sizeof(event));
++	if (!all) {
++		event.idx = idx;
++		event.op = RFKILL_OP_CHANGE;
++	} else {
++		event.op = RFKILL_OP_CHANGE_ALL;
++		event.type = type;
++	}
++	event.soft = block;
++
++	len = write(fd, &event, sizeof(event));
++	if (len < 0)
++		perror("Failed to change RFKILL state");
++
++	close(fd);
++}
++
++struct rfkill_type_str {
++	enum rfkill_type type;
++	char *name;
++};
++static struct rfkill_type_str rfkill_type_strings[] = {
++	{	.type = RFKILL_TYPE_ALL,		.name = "all"	},
++	{	.type = RFKILL_TYPE_WLAN,		.name = "wifi"	},
++	{	.type = RFKILL_TYPE_BLUETOOTH,	.name = "bluetooth"	},
++	{	.type = RFKILL_TYPE_UWB,		.name = "uwb"	},
++	{	.type = RFKILL_TYPE_WIMAX,		.name = "wimax"	},
++	{	.type = RFKILL_TYPE_WWAN,		.name = "wwan"	},
++	{	.type = RFKILL_TYPE_GPS,		.name = "gps"	},
++	{	.name = NULL }
++};
++
++static enum rfkill_type rfkill_str_to_type(char *s)
++{
++	struct rfkill_type_str *p;
++
++	for (p = rfkill_type_strings; p->name != NULL; p++) {
++		if ((strlen(s) == strlen(p->name)) && (!strcmp(s,p->name)))
++			return p->type;
++	}
++	return NUM_RFKILL_TYPES;
++}
++
++static const char *argv0;
++
++#define BLOCK_PARAMS "{<idx>,all,wifi,bluetooth,uwb,wimax,wwan,gps}"
++
++static void usage(void)
++{
++	fprintf(stderr, "Usage:\t%s [options] command\n", argv0);
++	fprintf(stderr, "Options:\n");
++	fprintf(stderr, "\t--version\tshow version (%s)\n", rfkill_version);
++	fprintf(stderr, "Commands:\n");
++	fprintf(stderr, "\thelp\n");
++	fprintf(stderr, "\tevent\n");
++	fprintf(stderr, "\tlist\n");
++	fprintf(stderr, "\tblock "BLOCK_PARAMS"\n");
++	fprintf(stderr, "\tunblock "BLOCK_PARAMS"\n");
++}
++
++static void version(void)
++{
++	printf("rfkill %s\n", rfkill_version);
++}
++
++static void do_block_unblock(__u8 block, char *param)
++{
++	enum rfkill_type t;
++	__u32 idx;
++
++	if (islower(*param)) {
++		/* assume alphabetic characters imply a wireless type name */
++		t = rfkill_str_to_type(param);
++		if (t < NUM_RFKILL_TYPES)
++			rfkill_block(true, 0, block, t);
++		else
++			goto err;
++	} else if (isdigit(*param)) {
++		/* assume a numeric character implies an index. */
++		idx = atoi(param);
++		rfkill_block(false, idx, block, 0);
++	} else
++		goto err;
++
++	return;
++err:
++	fprintf(stderr,"Bogus %sblock argument '%s'.\n",block?"":"un",param);
++	exit(1);
++}
++
++int main(int argc, char **argv)
++{
++	/* strip off self */
++	argc--;
++	argv0 = *argv++;
++
++	if (argc > 0 && strcmp(*argv, "--version") == 0) {
++		version();
++		return 0;
++	}
++
++	if (argc == 0 || strcmp(*argv, "help") == 0) {
++		usage();
++		return 0;
++	}
++
++	if (strcmp(*argv, "event") == 0) {
++		rfkill_event();
++	} else if (strcmp(*argv, "list") == 0) {
++		rfkill_list();
++	} else if (strcmp(*argv, "block") == 0 && argc > 1) {
++		argc--;
++		argv++;
++		do_block_unblock(1,*argv);
++	} else if (strcmp(*argv, "unblock") == 0 && argc > 1) {
++		argc--;
++		argv++;
++		do_block_unblock(0,*argv);
++	} else {
++		usage();
++		return 1;
++	}
++
++	return 0;
++}
+diff -pruN 29-2/rfkill/rfkill.h 29-2ubuntu6/rfkill/rfkill.h
+--- 29-2/rfkill/rfkill.h	1970-01-01 01:00:00.000000000 +0100
++++ 29-2ubuntu6/rfkill/rfkill.h	2009-10-21 15:29:10.000000000 +0100
+@@ -0,0 +1,387 @@
++#ifndef __RFKILL_H
++#define __RFKILL_H
++
++/*
++ * Copyright (C) 2006 - 2007 Ivo van Doorn
++ * Copyright (C) 2007 Dmitry Torokhov
++ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
++ *
++ * Permission to use, copy, modify, and/or distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ */
++
++#include <linux/types.h>
++
++/* define userspace visible states */
++#define RFKILL_STATE_SOFT_BLOCKED	0
++#define RFKILL_STATE_UNBLOCKED		1
++#define RFKILL_STATE_HARD_BLOCKED	2
++
++/**
++ * enum rfkill_type - type of rfkill switch.
++ *
++ * @RFKILL_TYPE_ALL: toggles all switches (userspace only)
++ * @RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device.
++ * @RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device.
++ * @RFKILL_TYPE_UWB: switch is on a ultra wideband device.
++ * @RFKILL_TYPE_WIMAX: switch is on a WiMAX device.
++ * @RFKILL_TYPE_WWAN: switch is on a wireless WAN device.
++ * @NUM_RFKILL_TYPES: number of defined rfkill types
++ */
++enum rfkill_type {
++	RFKILL_TYPE_ALL = 0,
++	RFKILL_TYPE_WLAN,
++	RFKILL_TYPE_BLUETOOTH,
++	RFKILL_TYPE_UWB,
++	RFKILL_TYPE_WIMAX,
++	RFKILL_TYPE_WWAN,
++	RFKILL_TYPE_GPS,
++	NUM_RFKILL_TYPES,
++};
++
++/**
++ * enum rfkill_operation - operation types
++ * @RFKILL_OP_ADD: a device was added
++ * @RFKILL_OP_DEL: a device was removed
++ * @RFKILL_OP_CHANGE: a device's state changed -- userspace changes one device
++ * @RFKILL_OP_CHANGE_ALL: userspace changes all devices (of a type, or all)
++ */
++enum rfkill_operation {
++	RFKILL_OP_ADD = 0,
++	RFKILL_OP_DEL,
++	RFKILL_OP_CHANGE,
++	RFKILL_OP_CHANGE_ALL,
++};
++
++/**
++ * struct rfkill_event - events for userspace on /dev/rfkill
++ * @idx: index of dev rfkill
++ * @type: type of the rfkill struct
++ * @op: operation code
++ * @hard: hard state (0/1)
++ * @soft: soft state (0/1)
++ *
++ * Structure used for userspace communication on /dev/rfkill,
++ * used for events from the kernel and control to the kernel.
++ */
++struct rfkill_event {
++	__u32 idx;
++	__u8  type;
++	__u8  op;
++	__u8  soft, hard;
++} __packed;
++
++/*
++ * We are planning to be backward and forward compatible with changes
++ * to the event struct, by adding new, optional, members at the end.
++ * When reading an event (whether the kernel from userspace or vice
++ * versa) we need to accept anything that's at least as large as the
++ * version 1 event size, but might be able to accept other sizes in
++ * the future.
++ *
++ * One exception is the kernel -- we already have two event sizes in
++ * that we've made the 'hard' member optional since our only option
++ * is to ignore it anyway.
++ */
++#define RFKILL_EVENT_SIZE_V1	8
++
++/* ioctl for turning off rfkill-input (if present) */
++#define RFKILL_IOC_MAGIC	'R'
++#define RFKILL_IOC_NOINPUT	1
++#define RFKILL_IOCTL_NOINPUT	_IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT)
++
++/* and that's all userspace gets */
++#ifdef __KERNEL__
++/* don't allow anyone to use these in the kernel */
++enum rfkill_user_states {
++	RFKILL_USER_STATE_SOFT_BLOCKED	= RFKILL_STATE_SOFT_BLOCKED,
++	RFKILL_USER_STATE_UNBLOCKED	= RFKILL_STATE_UNBLOCKED,
++	RFKILL_USER_STATE_HARD_BLOCKED	= RFKILL_STATE_HARD_BLOCKED,
++};
++#undef RFKILL_STATE_SOFT_BLOCKED
++#undef RFKILL_STATE_UNBLOCKED
++#undef RFKILL_STATE_HARD_BLOCKED
++
++#include <linux/kernel.h>
++#include <linux/list.h>
++#include <linux/mutex.h>
++#include <linux/device.h>
++#include <linux/leds.h>
++#include <linux/err.h>
++
++/* this is opaque */
++struct rfkill;
++
++/**
++ * struct rfkill_ops - rfkill driver methods
++ *
++ * @poll: poll the rfkill block state(s) -- only assign this method
++ *	when you need polling. When called, simply call one of the
++ *	rfkill_set{,_hw,_sw}_state family of functions. If the hw
++ *	is getting unblocked you need to take into account the return
++ *	value of those functions to make sure the software block is
++ *	properly used.
++ * @query: query the rfkill block state(s) and call exactly one of the
++ *	rfkill_set{,_hw,_sw}_state family of functions. Assign this
++ *	method if input events can cause hardware state changes to make
++ *	the rfkill core query your driver before setting a requested
++ *	block.
++ * @set_block: turn the transmitter on (blocked == false) or off
++ *	(blocked == true) -- ignore and return 0 when hard blocked.
++ *	This callback must be assigned.
++ */
++struct rfkill_ops {
++	void	(*poll)(struct rfkill *rfkill, void *data);
++	void	(*query)(struct rfkill *rfkill, void *data);
++	int	(*set_block)(void *data, bool blocked);
++};
++
++#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
++/**
++ * rfkill_alloc - allocate rfkill structure
++ * @name: name of the struct -- the string is not copied internally
++ * @parent: device that has rf switch on it
++ * @type: type of the switch (RFKILL_TYPE_*)
++ * @ops: rfkill methods
++ * @ops_data: data passed to each method
++ *
++ * This function should be called by the transmitter driver to allocate an
++ * rfkill structure. Returns %NULL on failure.
++ */
++struct rfkill * __must_check rfkill_alloc(const char *name,
++					  struct device *parent,
++					  const enum rfkill_type type,
++					  const struct rfkill_ops *ops,
++					  void *ops_data);
++
++/**
++ * rfkill_register - Register a rfkill structure.
++ * @rfkill: rfkill structure to be registered
++ *
++ * This function should be called by the transmitter driver to register
++ * the rfkill structure. Before calling this function the driver needs
++ * to be ready to service method calls from rfkill.
++ *
++ * If rfkill_init_sw_state() is not called before registration,
++ * set_block() will be called to initialize the software blocked state
++ * to a default value.
++ *
++ * If the hardware blocked state is not set before registration,
++ * it is assumed to be unblocked.
++ */
++int __must_check rfkill_register(struct rfkill *rfkill);
++
++/**
++ * rfkill_pause_polling(struct rfkill *rfkill)
++ *
++ * Pause polling -- say transmitter is off for other reasons.
++ * NOTE: not necessary for suspend/resume -- in that case the
++ * core stops polling anyway
++ */
++void rfkill_pause_polling(struct rfkill *rfkill);
++
++/**
++ * rfkill_resume_polling(struct rfkill *rfkill)
++ *
++ * Pause polling -- say transmitter is off for other reasons.
++ * NOTE: not necessary for suspend/resume -- in that case the
++ * core stops polling anyway
++ */
++void rfkill_resume_polling(struct rfkill *rfkill);
++
++
++/**
++ * rfkill_unregister - Unregister a rfkill structure.
++ * @rfkill: rfkill structure to be unregistered
++ *
++ * This function should be called by the network driver during device
++ * teardown to destroy rfkill structure. Until it returns, the driver
++ * needs to be able to service method calls.
++ */
++void rfkill_unregister(struct rfkill *rfkill);
++
++/**
++ * rfkill_destroy - free rfkill structure
++ * @rfkill: rfkill structure to be destroyed
++ *
++ * Destroys the rfkill structure.
++ */
++void rfkill_destroy(struct rfkill *rfkill);
++
++/**
++ * rfkill_set_hw_state - Set the internal rfkill hardware block state
++ * @rfkill: pointer to the rfkill class to modify.
++ * @state: the current hardware block state to set
++ *
++ * rfkill drivers that get events when the hard-blocked state changes
++ * use this function to notify the rfkill core (and through that also
++ * userspace) of the current state.  They should also use this after
++ * resume if the state could have changed.
++ *
++ * You need not (but may) call this function if poll_state is assigned.
++ *
++ * This function can be called in any context, even from within rfkill
++ * callbacks.
++ *
++ * The function returns the combined block state (true if transmitter
++ * should be blocked) so that drivers need not keep track of the soft
++ * block state -- which they might not be able to.
++ */
++bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked);
++
++/**
++ * rfkill_set_sw_state - Set the internal rfkill software block state
++ * @rfkill: pointer to the rfkill class to modify.
++ * @state: the current software block state to set
++ *
++ * rfkill drivers that get events when the soft-blocked state changes
++ * (yes, some platforms directly act on input but allow changing again)
++ * use this function to notify the rfkill core (and through that also
++ * userspace) of the current state.
++ *
++ * Drivers should also call this function after resume if the state has
++ * been changed by the user.  This only makes sense for "persistent"
++ * devices (see rfkill_init_sw_state()).
++ *
++ * This function can be called in any context, even from within rfkill
++ * callbacks.
++ *
++ * The function returns the combined block state (true if transmitter
++ * should be blocked).
++ */
++bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked);
++
++/**
++ * rfkill_init_sw_state - Initialize persistent software block state
++ * @rfkill: pointer to the rfkill class to modify.
++ * @state: the current software block state to set
++ *
++ * rfkill drivers that preserve their software block state over power off
++ * use this function to notify the rfkill core (and through that also
++ * userspace) of their initial state.  It should only be used before
++ * registration.
++ *
++ * In addition, it marks the device as "persistent", an attribute which
++ * can be read by userspace.  Persistent devices are expected to preserve
++ * their own state when suspended.
++ */
++void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked);
++
++/**
++ * rfkill_set_states - Set the internal rfkill block states
++ * @rfkill: pointer to the rfkill class to modify.
++ * @sw: the current software block state to set
++ * @hw: the current hardware block state to set
++ *
++ * This function can be called in any context, even from within rfkill
++ * callbacks.
++ */
++void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw);
++
++/**
++ * rfkill_blocked - query rfkill block
++ *
++ * @rfkill: rfkill struct to query
++ */
++bool rfkill_blocked(struct rfkill *rfkill);
++#else /* !RFKILL */
++static inline struct rfkill * __must_check
++rfkill_alloc(const char *name,
++	     struct device *parent,
++	     const enum rfkill_type type,
++	     const struct rfkill_ops *ops,
++	     void *ops_data)
++{
++	return ERR_PTR(-ENODEV);
++}
++
++static inline int __must_check rfkill_register(struct rfkill *rfkill)
++{
++	if (rfkill == ERR_PTR(-ENODEV))
++		return 0;
++	return -EINVAL;
++}
++
++static inline void rfkill_pause_polling(struct rfkill *rfkill)
++{
++}
++
++static inline void rfkill_resume_polling(struct rfkill *rfkill)
++{
++}
++
++static inline void rfkill_unregister(struct rfkill *rfkill)
++{
++}
++
++static inline void rfkill_destroy(struct rfkill *rfkill)
++{
++}
++
++static inline bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked)
++{
++	return blocked;
++}
++
++static inline bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
++{
++	return blocked;
++}
++
++static inline void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked)
++{
++}
++
++static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
++{
++}
++
++static inline bool rfkill_blocked(struct rfkill *rfkill)
++{
++	return false;
++}
++#endif /* RFKILL || RFKILL_MODULE */
++
++
++#ifdef CONFIG_RFKILL_LEDS
++/**
++ * rfkill_get_led_trigger_name - Get the LED trigger name for the button's LED.
++ * This function might return a NULL pointer if registering of the
++ * LED trigger failed. Use this as "default_trigger" for the LED.
++ */
++const char *rfkill_get_led_trigger_name(struct rfkill *rfkill);
++
++/**
++ * rfkill_set_led_trigger_name -- set the LED trigger name
++ * @rfkill: rfkill struct
++ * @name: LED trigger name
++ *
++ * This function sets the LED trigger name of the radio LED
++ * trigger that rfkill creates. It is optional, but if called
++ * must be called before rfkill_register() to be effective.
++ */
++void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name);
++#else
++static inline const char *rfkill_get_led_trigger_name(struct rfkill *rfkill)
++{
++	return NULL;
++}
++
++static inline void
++rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name)
++{
++}
++#endif
++
++#endif /* __KERNEL__ */
++
++#endif /* RFKILL_H */
+diff -pruN 29-2/rfkill/version.sh 29-2ubuntu6/rfkill/version.sh
+--- 29-2/rfkill/version.sh	1970-01-01 01:00:00.000000000 +0100
++++ 29-2ubuntu6/rfkill/version.sh	2009-10-21 15:29:10.000000000 +0100
+@@ -0,0 +1,23 @@
++#!/bin/sh
++
++VERSION="0.3"
++OUT="$1"
++
++if head=`git rev-parse --verify HEAD 2>/dev/null`; then
++	git update-index --refresh --unmerged > /dev/null
++	descr=$(git describe 2>/dev/null || echo "v$VERSION")
++
++	# on git builds check that the version number above
++	# is correct...
++	[ "${descr%%-*}" = "v$VERSION" ] || exit 2
++
++	echo -n 'const char rfkill_version[] = "' > "$OUT"
++	v="${descr#v}"
++	if git diff-index --name-only HEAD | read dummy ; then
++		v="$v"-dirty
++	fi
++else
++	v="$VERSION"
++fi
++
++echo "const char rfkill_version[] = \"$v\";" > "$OUT"
--- wireless-tools-30~pre9.orig/ifrename.c
+++ wireless-tools-30~pre9/ifrename.c
@@ -695,9 +695,9 @@ mapping_addmac(struct if_mapping *	ifnod
       /* Check that it's not NULL */
       if((ifnode->mac_len == 6) && (!memcmp(&ifnode->mac, &zero_mac, 6)))
 	{
-	  fprintf(stderr,
-		  "Warning: MAC address is null at line %d, this is dangerous...\n",
-		  linenum);
+	  fprintf(stderr, "Error: Null MAC address (`%s') at line %d\n",
+		  ifnode->mac_filter, linenum);
+	  return(-1);
 	}
 
       ifnode->active[SELECT_MAC] = HAS_MAC_EXACT;
@@ -2200,11 +2200,11 @@ mapping_readfile(const char *	filename)
 	{
 	  /* If we have not yet printed an error, now is a good time ;-) */
 	  if(ret == -13)
-	    fprintf(stderr, "Error: Line %d ignored, no valid selectors\n",
-		    linenum);
+	    fprintf(stderr, "Error: %s line %d ignored, no valid selectors.  Please correct or remove this line.\n",
+		    filename, linenum);
 	  else
-	    fprintf(stderr, "Error: Line %d ignored due to prior errors\n",
-		    linenum);
+	    fprintf(stderr, "Error: %s line %d ignored due to above errors.  Please correct or remove this line.\n",
+		    filename, linenum);
 
 	  free(ifnode);
 	}
--- wireless-tools-30~pre9.orig/iftab.5
+++ wireless-tools-30~pre9/iftab.5
@@ -50,11 +50,7 @@ If you want to use alternate descriptors
 (logical or), specify two different mappings with the same interface
 name (one on each line).
 .B Ifrename
-always use the first matching mapping starting from the
-.I end
-of
-.BR iftab ,
-therefore more restrictive mapping should be specified last.
+always uses the last matching mapping in iftab.
 .\"
 .\" INTERFACE NAME part
 .\"
--- /dev/null
+++ wireless-tools-30~pre9/rfkill/rfkill.c
@@ -0,0 +1,297 @@
+/*
+ * rfkill userspace tool
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdbool.h>
+#include <sys/types.h>
+#include <sys/poll.h>
+
+#include "rfkill.h"
+#include "core.h"
+
+static void rfkill_event(void)
+{
+	struct rfkill_event event;
+	struct pollfd p;
+	ssize_t len;
+	int fd, n;
+
+	fd = open("/dev/rfkill", O_RDONLY);
+	if (fd < 0) {
+		perror("Can't open RFKILL control device");
+		return;
+	}
+
+	memset(&p, 0, sizeof(p));
+	p.fd = fd;
+	p.events = POLLIN | POLLHUP;
+
+	while (1) {
+		n = poll(&p, 1, -1);
+		if (n < 0) {
+			perror("Failed to poll RFKILL control device");
+			break;
+		}
+
+		if (n == 0)
+			continue;
+
+		len = read(fd, &event, sizeof(event));
+		if (len < 0) {
+			perror("Reading of RFKILL events failed");
+			break;
+		}
+
+		if (len != RFKILL_EVENT_SIZE_V1) {
+			fprintf(stderr, "Wrong size of RFKILL event\n");
+			continue;
+		}
+
+		printf("RFKILL event: idx %u type %u op %u soft %u hard %u\n",
+					event.idx, event.type, event.op,
+					event.soft, event.hard);
+	}
+
+	close(fd);
+}
+
+static const char *get_name(__u32 idx)
+{
+	static char name[128];
+	ssize_t len;
+	char *pos, filename[64];
+	int fd;
+
+	snprintf(filename, sizeof(filename) - 1,
+				"/sys/class/rfkill/rfkill%u/name", idx);
+
+	fd = open(filename, O_RDONLY);
+	if (fd < 0)
+		return NULL;
+
+	memset(name, 0, sizeof(name));
+	len = read(fd, name, sizeof(name) - 1);
+
+	pos = strchr(name, '\n');
+	if (pos)
+		*pos = '\0';
+
+	close(fd);
+
+	return name;
+}
+
+static const char *type2string(enum rfkill_type type)
+{
+	switch (type) {
+	case RFKILL_TYPE_ALL:
+		return "All";
+	case RFKILL_TYPE_WLAN:
+		return "Wireless LAN";
+	case RFKILL_TYPE_BLUETOOTH:
+		return "Bluetooth";
+	case RFKILL_TYPE_UWB:
+		return "Ultra-Wideband";
+	case RFKILL_TYPE_WIMAX:
+		return "WiMAX";
+	case RFKILL_TYPE_WWAN:
+		return "Wireless WAN";
+	case RFKILL_TYPE_GPS:
+		return "GPS";
+	case NUM_RFKILL_TYPES:
+		return NULL;
+	}
+
+	return NULL;
+}
+
+static void rfkill_list(void)
+{
+	struct rfkill_event event;
+	const char *name;
+	ssize_t len;
+	int fd;
+
+	fd = open("/dev/rfkill", O_RDONLY);
+	if (fd < 0) {
+		perror("Can't open RFKILL control device");
+		return;
+	}
+
+	if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
+		perror("Can't set RFKILL control device to non-blocking");
+		close(fd);
+	}
+
+	while (1) {
+		len = read(fd, &event, sizeof(event));
+		if (len < 0) {
+			if (errno == EAGAIN)
+				break;
+			perror("Reading of RFKILL events failed");
+			break;
+		}
+
+		if (len != RFKILL_EVENT_SIZE_V1) {
+			fprintf(stderr, "Wrong size of RFKILL event\n");
+			continue;
+		}
+
+		if (event.op != RFKILL_OP_ADD)
+			continue;
+
+		name = get_name(event.idx);
+
+		printf("%u: %s: %s\n", event.idx, name,
+						type2string(event.type));
+		printf("\tSoft blocked: %s\n", event.soft ? "yes" : "no");
+		printf("\tHard blocked: %s\n", event.hard ? "yes" : "no");
+	}
+
+	close(fd);
+}
+
+static void rfkill_block(bool all, __u32 idx, __u8 block, __u8 type)
+{
+	struct rfkill_event event;
+	ssize_t len;
+	int fd;
+
+	fd = open("/dev/rfkill", O_RDWR);
+	if (fd < 0) {
+		perror("Can't open RFKILL control device");
+		return;
+	}
+
+	memset(&event, 0, sizeof(event));
+	if (!all) {
+		event.idx = idx;
+		event.op = RFKILL_OP_CHANGE;
+	} else {
+		event.op = RFKILL_OP_CHANGE_ALL;
+		event.type = type;
+	}
+	event.soft = block;
+
+	len = write(fd, &event, sizeof(event));
+	if (len < 0)
+		perror("Failed to change RFKILL state");
+
+	close(fd);
+}
+
+struct rfkill_type_str {
+	enum rfkill_type type;
+	char *name;
+};
+static struct rfkill_type_str rfkill_type_strings[] = {
+	{	.type = RFKILL_TYPE_ALL,		.name = "all"	},
+	{	.type = RFKILL_TYPE_WLAN,		.name = "wifi"	},
+	{	.type = RFKILL_TYPE_BLUETOOTH,	.name = "bluetooth"	},
+	{	.type = RFKILL_TYPE_UWB,		.name = "uwb"	},
+	{	.type = RFKILL_TYPE_WIMAX,		.name = "wimax"	},
+	{	.type = RFKILL_TYPE_WWAN,		.name = "wwan"	},
+	{	.type = RFKILL_TYPE_GPS,		.name = "gps"	},
+	{	.name = NULL }
+};
+
+static enum rfkill_type rfkill_str_to_type(char *s)
+{
+	struct rfkill_type_str *p;
+
+	for (p = rfkill_type_strings; p->name != NULL; p++) {
+		if ((strlen(s) == strlen(p->name)) && (!strcmp(s,p->name)))
+			return p->type;
+	}
+	return NUM_RFKILL_TYPES;
+}
+
+static const char *argv0;
+
+#define BLOCK_PARAMS "{<idx>,all,wifi,bluetooth,uwb,wimax,wwan,gps}"
+
+static void usage(void)
+{
+	fprintf(stderr, "Usage:\t%s [options] command\n", argv0);
+	fprintf(stderr, "Options:\n");
+	fprintf(stderr, "\t--version\tshow version (%s)\n", rfkill_version);
+	fprintf(stderr, "Commands:\n");
+	fprintf(stderr, "\thelp\n");
+	fprintf(stderr, "\tevent\n");
+	fprintf(stderr, "\tlist\n");
+	fprintf(stderr, "\tblock "BLOCK_PARAMS"\n");
+	fprintf(stderr, "\tunblock "BLOCK_PARAMS"\n");
+}
+
+static void version(void)
+{
+	printf("rfkill %s\n", rfkill_version);
+}
+
+static void do_block_unblock(__u8 block, char *param)
+{
+	enum rfkill_type t;
+	__u32 idx;
+
+	if (islower(*param)) {
+		/* assume alphabetic characters imply a wireless type name */
+		t = rfkill_str_to_type(param);
+		if (t < NUM_RFKILL_TYPES)
+			rfkill_block(true, 0, block, t);
+		else
+			goto err;
+	} else if (isdigit(*param)) {
+		/* assume a numeric character implies an index. */
+		idx = atoi(param);
+		rfkill_block(false, idx, block, 0);
+	} else
+		goto err;
+
+	return;
+err:
+	fprintf(stderr,"Bogus %sblock argument '%s'.\n",block?"":"un",param);
+	exit(1);
+}
+
+int main(int argc, char **argv)
+{
+	/* strip off self */
+	argc--;
+	argv0 = *argv++;
+
+	if (argc > 0 && strcmp(*argv, "--version") == 0) {
+		version();
+		return 0;
+	}
+
+	if (argc == 0 || strcmp(*argv, "help") == 0) {
+		usage();
+		return 0;
+	}
+
+	if (strcmp(*argv, "event") == 0) {
+		rfkill_event();
+	} else if (strcmp(*argv, "list") == 0) {
+		rfkill_list();
+	} else if (strcmp(*argv, "block") == 0 && argc > 1) {
+		argc--;
+		argv++;
+		do_block_unblock(1,*argv);
+	} else if (strcmp(*argv, "unblock") == 0 && argc > 1) {
+		argc--;
+		argv++;
+		do_block_unblock(0,*argv);
+	} else {
+		usage();
+		return 1;
+	}
+
+	return 0;
+}
--- /dev/null
+++ wireless-tools-30~pre9/rfkill/version.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+VERSION="0.3"
+OUT="$1"
+
+if head=`git rev-parse --verify HEAD 2>/dev/null`; then
+	git update-index --refresh --unmerged > /dev/null
+	descr=$(git describe 2>/dev/null || echo "v$VERSION")
+
+	# on git builds check that the version number above
+	# is correct...
+	[ "${descr%%-*}" = "v$VERSION" ] || exit 2
+
+	echo -n 'const char rfkill_version[] = "' > "$OUT"
+	v="${descr#v}"
+	if git diff-index --name-only HEAD | read dummy ; then
+		v="$v"-dirty
+	fi
+else
+	v="$VERSION"
+fi
+
+echo "const char rfkill_version[] = \"$v\";" > "$OUT"
--- /dev/null
+++ wireless-tools-30~pre9/rfkill/COPYING
@@ -0,0 +1,15 @@
+Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+Copyright 2009 Marcel Holtmann <marcel@holtmann.org>
+Copyright 2009 Tim Gardner <tim.gardner@canonical.com>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--- /dev/null
+++ wireless-tools-30~pre9/rfkill/Makefile
@@ -0,0 +1,58 @@
+MAKEFLAGS += --no-print-directory
+
+PREFIX ?= /usr
+BINDIR ?= $(PREFIX)/bin
+MANDIR ?= $(PREFIX)/share/man
+
+MKDIR ?= mkdir -p
+INSTALL ?= install
+CC ?= "gcc"
+
+CFLAGS ?= -O2 -g
+CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
+
+OBJS = rfkill.o version.o
+ALL = rfkill
+
+ifeq ($(V),1)
+Q=
+NQ=true
+else
+Q=@
+NQ=echo
+endif
+
+all: $(ALL)
+
+VERSION_OBJS := $(filter-out version.o, $(OBJS))
+
+version.c: version.sh $(patsubst %.o,%.c,$(VERSION_OBJS)) rfkill.h Makefile \
+		$(wildcard .git/index .git/refs/tags)
+	@$(NQ) ' GEN ' $@
+	$(Q)sh ./version.sh $@
+
+%.o: %.c rfkill.h
+	@$(NQ) ' CC  ' $@
+	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
+
+rfkill:	$(OBJS)
+	@$(NQ) ' CC  ' rfkill
+	$(Q)$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o rfkill
+
+check:
+	$(Q)$(MAKE) all CC="REAL_CC=$(CC) CHECK=\"sparse -Wall\" cgcc"
+
+%.gz: %
+	@$(NQ) ' GZIP' $<
+	$(Q)gzip < $< > $@
+
+install: rfkill rfkill.1.gz
+	@$(NQ) ' INST rfkill'
+	$(Q)$(MKDIR) $(DESTDIR)$(BINDIR)
+	$(Q)$(INSTALL) -m 755 -t $(DESTDIR)$(BINDIR) rfkill
+	@$(NQ) ' INST rfkill.1'
+	$(Q)$(MKDIR) $(DESTDIR)$(MANDIR)/man1/
+	$(Q)$(INSTALL) -m 644 -t $(DESTDIR)$(MANDIR)/man1/ rfkill.1.gz
+
+clean:
+	$(Q)rm -f rfkill *.o *~ *.gz version.c *-stamp
--- /dev/null
+++ wireless-tools-30~pre9/rfkill/README
@@ -0,0 +1,12 @@
+
+This is 'rfkill', a tool to use /dev/rfkill.
+
+
+To build rfkill, just enter 'make'.
+
+'rfkill' is currently maintained at http://git.sipsolutions.net/rfkill.git/,
+some more documentation is available at
+http://wireless.kernel.org/en/users/Documentation/rfkill.
+
+Please send all patches to Johannes Berg <johannes@sipsolutions.net>
+and CC linux-wireless@vger.kernel.org for community review.
--- /dev/null
+++ wireless-tools-30~pre9/rfkill/rfkill.h
@@ -0,0 +1,387 @@
+#ifndef __RFKILL_H
+#define __RFKILL_H
+
+/*
+ * Copyright (C) 2006 - 2007 Ivo van Doorn
+ * Copyright (C) 2007 Dmitry Torokhov
+ * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <linux/types.h>
+
+/* define userspace visible states */
+#define RFKILL_STATE_SOFT_BLOCKED	0
+#define RFKILL_STATE_UNBLOCKED		1
+#define RFKILL_STATE_HARD_BLOCKED	2
+
+/**
+ * enum rfkill_type - type of rfkill switch.
+ *
+ * @RFKILL_TYPE_ALL: toggles all switches (userspace only)
+ * @RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device.
+ * @RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device.
+ * @RFKILL_TYPE_UWB: switch is on a ultra wideband device.
+ * @RFKILL_TYPE_WIMAX: switch is on a WiMAX device.
+ * @RFKILL_TYPE_WWAN: switch is on a wireless WAN device.
+ * @NUM_RFKILL_TYPES: number of defined rfkill types
+ */
+enum rfkill_type {
+	RFKILL_TYPE_ALL = 0,
+	RFKILL_TYPE_WLAN,
+	RFKILL_TYPE_BLUETOOTH,
+	RFKILL_TYPE_UWB,
+	RFKILL_TYPE_WIMAX,
+	RFKILL_TYPE_WWAN,
+	RFKILL_TYPE_GPS,
+	NUM_RFKILL_TYPES,
+};
+
+/**
+ * enum rfkill_operation - operation types
+ * @RFKILL_OP_ADD: a device was added
+ * @RFKILL_OP_DEL: a device was removed
+ * @RFKILL_OP_CHANGE: a device's state changed -- userspace changes one device
+ * @RFKILL_OP_CHANGE_ALL: userspace changes all devices (of a type, or all)
+ */
+enum rfkill_operation {
+	RFKILL_OP_ADD = 0,
+	RFKILL_OP_DEL,
+	RFKILL_OP_CHANGE,
+	RFKILL_OP_CHANGE_ALL,
+};
+
+/**
+ * struct rfkill_event - events for userspace on /dev/rfkill
+ * @idx: index of dev rfkill
+ * @type: type of the rfkill struct
+ * @op: operation code
+ * @hard: hard state (0/1)
+ * @soft: soft state (0/1)
+ *
+ * Structure used for userspace communication on /dev/rfkill,
+ * used for events from the kernel and control to the kernel.
+ */
+struct rfkill_event {
+	__u32 idx;
+	__u8  type;
+	__u8  op;
+	__u8  soft, hard;
+} __packed;
+
+/*
+ * We are planning to be backward and forward compatible with changes
+ * to the event struct, by adding new, optional, members at the end.
+ * When reading an event (whether the kernel from userspace or vice
+ * versa) we need to accept anything that's at least as large as the
+ * version 1 event size, but might be able to accept other sizes in
+ * the future.
+ *
+ * One exception is the kernel -- we already have two event sizes in
+ * that we've made the 'hard' member optional since our only option
+ * is to ignore it anyway.
+ */
+#define RFKILL_EVENT_SIZE_V1	8
+
+/* ioctl for turning off rfkill-input (if present) */
+#define RFKILL_IOC_MAGIC	'R'
+#define RFKILL_IOC_NOINPUT	1
+#define RFKILL_IOCTL_NOINPUT	_IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT)
+
+/* and that's all userspace gets */
+#ifdef __KERNEL__
+/* don't allow anyone to use these in the kernel */
+enum rfkill_user_states {
+	RFKILL_USER_STATE_SOFT_BLOCKED	= RFKILL_STATE_SOFT_BLOCKED,
+	RFKILL_USER_STATE_UNBLOCKED	= RFKILL_STATE_UNBLOCKED,
+	RFKILL_USER_STATE_HARD_BLOCKED	= RFKILL_STATE_HARD_BLOCKED,
+};
+#undef RFKILL_STATE_SOFT_BLOCKED
+#undef RFKILL_STATE_UNBLOCKED
+#undef RFKILL_STATE_HARD_BLOCKED
+
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/device.h>
+#include <linux/leds.h>
+#include <linux/err.h>
+
+/* this is opaque */
+struct rfkill;
+
+/**
+ * struct rfkill_ops - rfkill driver methods
+ *
+ * @poll: poll the rfkill block state(s) -- only assign this method
+ *	when you need polling. When called, simply call one of the
+ *	rfkill_set{,_hw,_sw}_state family of functions. If the hw
+ *	is getting unblocked you need to take into account the return
+ *	value of those functions to make sure the software block is
+ *	properly used.
+ * @query: query the rfkill block state(s) and call exactly one of the
+ *	rfkill_set{,_hw,_sw}_state family of functions. Assign this
+ *	method if input events can cause hardware state changes to make
+ *	the rfkill core query your driver before setting a requested
+ *	block.
+ * @set_block: turn the transmitter on (blocked == false) or off
+ *	(blocked == true) -- ignore and return 0 when hard blocked.
+ *	This callback must be assigned.
+ */
+struct rfkill_ops {
+	void	(*poll)(struct rfkill *rfkill, void *data);
+	void	(*query)(struct rfkill *rfkill, void *data);
+	int	(*set_block)(void *data, bool blocked);
+};
+
+#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
+/**
+ * rfkill_alloc - allocate rfkill structure
+ * @name: name of the struct -- the string is not copied internally
+ * @parent: device that has rf switch on it
+ * @type: type of the switch (RFKILL_TYPE_*)
+ * @ops: rfkill methods
+ * @ops_data: data passed to each method
+ *
+ * This function should be called by the transmitter driver to allocate an
+ * rfkill structure. Returns %NULL on failure.
+ */
+struct rfkill * __must_check rfkill_alloc(const char *name,
+					  struct device *parent,
+					  const enum rfkill_type type,
+					  const struct rfkill_ops *ops,
+					  void *ops_data);
+
+/**
+ * rfkill_register - Register a rfkill structure.
+ * @rfkill: rfkill structure to be registered
+ *
+ * This function should be called by the transmitter driver to register
+ * the rfkill structure. Before calling this function the driver needs
+ * to be ready to service method calls from rfkill.
+ *
+ * If rfkill_init_sw_state() is not called before registration,
+ * set_block() will be called to initialize the software blocked state
+ * to a default value.
+ *
+ * If the hardware blocked state is not set before registration,
+ * it is assumed to be unblocked.
+ */
+int __must_check rfkill_register(struct rfkill *rfkill);
+
+/**
+ * rfkill_pause_polling(struct rfkill *rfkill)
+ *
+ * Pause polling -- say transmitter is off for other reasons.
+ * NOTE: not necessary for suspend/resume -- in that case the
+ * core stops polling anyway
+ */
+void rfkill_pause_polling(struct rfkill *rfkill);
+
+/**
+ * rfkill_resume_polling(struct rfkill *rfkill)
+ *
+ * Pause polling -- say transmitter is off for other reasons.
+ * NOTE: not necessary for suspend/resume -- in that case the
+ * core stops polling anyway
+ */
+void rfkill_resume_polling(struct rfkill *rfkill);
+
+
+/**
+ * rfkill_unregister - Unregister a rfkill structure.
+ * @rfkill: rfkill structure to be unregistered
+ *
+ * This function should be called by the network driver during device
+ * teardown to destroy rfkill structure. Until it returns, the driver
+ * needs to be able to service method calls.
+ */
+void rfkill_unregister(struct rfkill *rfkill);
+
+/**
+ * rfkill_destroy - free rfkill structure
+ * @rfkill: rfkill structure to be destroyed
+ *
+ * Destroys the rfkill structure.
+ */
+void rfkill_destroy(struct rfkill *rfkill);
+
+/**
+ * rfkill_set_hw_state - Set the internal rfkill hardware block state
+ * @rfkill: pointer to the rfkill class to modify.
+ * @state: the current hardware block state to set
+ *
+ * rfkill drivers that get events when the hard-blocked state changes
+ * use this function to notify the rfkill core (and through that also
+ * userspace) of the current state.  They should also use this after
+ * resume if the state could have changed.
+ *
+ * You need not (but may) call this function if poll_state is assigned.
+ *
+ * This function can be called in any context, even from within rfkill
+ * callbacks.
+ *
+ * The function returns the combined block state (true if transmitter
+ * should be blocked) so that drivers need not keep track of the soft
+ * block state -- which they might not be able to.
+ */
+bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked);
+
+/**
+ * rfkill_set_sw_state - Set the internal rfkill software block state
+ * @rfkill: pointer to the rfkill class to modify.
+ * @state: the current software block state to set
+ *
+ * rfkill drivers that get events when the soft-blocked state changes
+ * (yes, some platforms directly act on input but allow changing again)
+ * use this function to notify the rfkill core (and through that also
+ * userspace) of the current state.
+ *
+ * Drivers should also call this function after resume if the state has
+ * been changed by the user.  This only makes sense for "persistent"
+ * devices (see rfkill_init_sw_state()).
+ *
+ * This function can be called in any context, even from within rfkill
+ * callbacks.
+ *
+ * The function returns the combined block state (true if transmitter
+ * should be blocked).
+ */
+bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked);
+
+/**
+ * rfkill_init_sw_state - Initialize persistent software block state
+ * @rfkill: pointer to the rfkill class to modify.
+ * @state: the current software block state to set
+ *
+ * rfkill drivers that preserve their software block state over power off
+ * use this function to notify the rfkill core (and through that also
+ * userspace) of their initial state.  It should only be used before
+ * registration.
+ *
+ * In addition, it marks the device as "persistent", an attribute which
+ * can be read by userspace.  Persistent devices are expected to preserve
+ * their own state when suspended.
+ */
+void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked);
+
+/**
+ * rfkill_set_states - Set the internal rfkill block states
+ * @rfkill: pointer to the rfkill class to modify.
+ * @sw: the current software block state to set
+ * @hw: the current hardware block state to set
+ *
+ * This function can be called in any context, even from within rfkill
+ * callbacks.
+ */
+void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw);
+
+/**
+ * rfkill_blocked - query rfkill block
+ *
+ * @rfkill: rfkill struct to query
+ */
+bool rfkill_blocked(struct rfkill *rfkill);
+#else /* !RFKILL */
+static inline struct rfkill * __must_check
+rfkill_alloc(const char *name,
+	     struct device *parent,
+	     const enum rfkill_type type,
+	     const struct rfkill_ops *ops,
+	     void *ops_data)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline int __must_check rfkill_register(struct rfkill *rfkill)
+{
+	if (rfkill == ERR_PTR(-ENODEV))
+		return 0;
+	return -EINVAL;
+}
+
+static inline void rfkill_pause_polling(struct rfkill *rfkill)
+{
+}
+
+static inline void rfkill_resume_polling(struct rfkill *rfkill)
+{
+}
+
+static inline void rfkill_unregister(struct rfkill *rfkill)
+{
+}
+
+static inline void rfkill_destroy(struct rfkill *rfkill)
+{
+}
+
+static inline bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked)
+{
+	return blocked;
+}
+
+static inline bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
+{
+	return blocked;
+}
+
+static inline void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked)
+{
+}
+
+static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
+{
+}
+
+static inline bool rfkill_blocked(struct rfkill *rfkill)
+{
+	return false;
+}
+#endif /* RFKILL || RFKILL_MODULE */
+
+
+#ifdef CONFIG_RFKILL_LEDS
+/**
+ * rfkill_get_led_trigger_name - Get the LED trigger name for the button's LED.
+ * This function might return a NULL pointer if registering of the
+ * LED trigger failed. Use this as "default_trigger" for the LED.
+ */
+const char *rfkill_get_led_trigger_name(struct rfkill *rfkill);
+
+/**
+ * rfkill_set_led_trigger_name -- set the LED trigger name
+ * @rfkill: rfkill struct
+ * @name: LED trigger name
+ *
+ * This function sets the LED trigger name of the radio LED
+ * trigger that rfkill creates. It is optional, but if called
+ * must be called before rfkill_register() to be effective.
+ */
+void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name);
+#else
+static inline const char *rfkill_get_led_trigger_name(struct rfkill *rfkill)
+{
+	return NULL;
+}
+
+static inline void
+rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name)
+{
+}
+#endif
+
+#endif /* __KERNEL__ */
+
+#endif /* RFKILL_H */
--- /dev/null
+++ wireless-tools-30~pre9/rfkill/core.h
@@ -0,0 +1,8 @@
+#ifndef __CORE
+#define __CORE
+
+#include "rfkill.h"
+
+extern const char rfkill_version[];
+
+#endif
--- /dev/null
+++ wireless-tools-30~pre9/rfkill/rfkill.1
@@ -0,0 +1,36 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.TH RFKILL 1 "July 10, 2009"
+.SH NAME
+rfkill \- tool for enabling and disabling wireless devices
+.SH SYNOPSIS
+.B rfkill
+.RI [ options ] " command"
+.SH OPTIONS
+.TP
+.B \-\-version
+Show the version of rfkill.
+.SH COMMANDS
+.TP
+.B help
+Show rfkill's built-in help text.
+.TP
+.B event
+Listen for rfkill events and display them on stdout.
+.TP
+.B list
+List the current state of all available rfkill-using devices.
+.TP
+.BI block " index|type"
+Disable the device corresponding to the given index.
+\fItype\fR is one of "all", "wifi", "bluetooth", "uwb", "wimax", "wwan" or "gps".
+.TP
+.BI unblock " index|type"
+Enable the device corresponding to the given index. If the device is
+hard-blocked, e.g. via a hardware switch, it will remain unavailable though
+it is now soft-unblocked.
+.SH AUTHORS
+rfkill was originally written by Johannes Berg <johannes@sipsolutions.net>
+and Marcel Holtmann <marcel@holtmann.org>.
+.PP
+This manual page was written by Darren Salt <linux@youmustbejoking.demon.co.uk>,
+for the Debian project (and may be used by others).
