From b32a0ceff198e0bf11b5cecff155fc5f7e2443f3 Mon Sep 17 00:00:00 2001
From: nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date: Sun, 3 Apr 2005 18:00:10 +0000
Subject: [PATCH] add wireless tools

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@545 3c298f89-4303-0410-b956-a3cf2f4a3e73
---
 openwrt/package/Config.in                     |  1 +
 openwrt/package/Makefile                      |  1 +
 openwrt/package/wireless-tools/Config.in      |  5 ++
 openwrt/package/wireless-tools/Makefile       | 54 +++++++++++
 .../wireless-tools/patches/debian-2.patch     | 89 +++++++++++++++++++
 .../wireless-tools/wireless-tools.control     |  6 ++
 6 files changed, 156 insertions(+)
 create mode 100644 openwrt/package/wireless-tools/Config.in
 create mode 100644 openwrt/package/wireless-tools/Makefile
 create mode 100644 openwrt/package/wireless-tools/patches/debian-2.patch
 create mode 100644 openwrt/package/wireless-tools/wireless-tools.control

diff --git a/openwrt/package/Config.in b/openwrt/package/Config.in
index 00e0b73eb..bf84536b0 100644
--- a/openwrt/package/Config.in
+++ b/openwrt/package/Config.in
@@ -39,6 +39,7 @@ source "package/chillispot/Config.in"
 source "package/nocatsplash/Config.in"
 source "package/fping/Config.in"
 source "package/arpwatch/Config.in"
+source "package/wireless-tools/Config.in"
 
 comment "Libraries"
 source "package/zlib/Config.in"
diff --git a/openwrt/package/Makefile b/openwrt/package/Makefile
index c769dcb1a..9804dedee 100644
--- a/openwrt/package/Makefile
+++ b/openwrt/package/Makefile
@@ -41,6 +41,7 @@ package-$(BR2_PACKAGE_SER) += ser
 package-$(BR2_PACKAGE_SETSERIAL) += setserial
 package-$(BR2_PACKAGE_STRACE) += strace
 package-$(BR2_PACKAGE_TCPDUMP) += tcpdump
+package-$(BR2_PACKAGE_WIRELESS_TOOLS) += wireless-tools
 package-$(BR2_PACKAGE_WOL) += wol
 package-$(BR2_PACKAGE_ZLIB) += zlib
 package-$(BR2_PACKAGE_DHCPFWD) += dhcp-forwarder
diff --git a/openwrt/package/wireless-tools/Config.in b/openwrt/package/wireless-tools/Config.in
new file mode 100644
index 000000000..452d30ded
--- /dev/null
+++ b/openwrt/package/wireless-tools/Config.in
@@ -0,0 +1,5 @@
+config BR2_PACKAGE_WIRELESS_TOOLS
+	tristate "wireless-tools"
+	default m
+	help
+	  Tools for configuring Wireless Adapters implementing the "Wireless Extension"
diff --git a/openwrt/package/wireless-tools/Makefile b/openwrt/package/wireless-tools/Makefile
new file mode 100644
index 000000000..df251625b
--- /dev/null
+++ b/openwrt/package/wireless-tools/Makefile
@@ -0,0 +1,54 @@
+# $Id$
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=wireless-tools
+PKG_VERSION:=27
+PKG_RELEASE:=1
+PKG_MD5SUM:=29891b66f23565e7e381d28404abb29a
+
+PKG_SOURCE_URL:=http://pcmcia-cs.sourceforge.net/ftp/contrib/
+PKG_SOURCE:=wireless_tools.$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(BUILD_DIR)/wireless_tools.$(PKG_VERSION)
+PKG_CAT:=zcat
+PKG_IPK:=$(PACKAGE_DIR)/$(PKG_NAME)_$(PKG_VERSION)-$(PKG_RELEASE)_$(ARCH).ipk
+PKG_IPK_DIR:=$(PKG_BUILD_DIR)/ipkg
+
+$(DL_DIR)/$(PKG_SOURCE):
+	$(SCRIPT_DIR)/download.pl $(DL_DIR) $(PKG_SOURCE) $(PKG_MD5SUM) $(PKG_SOURCE_URL)
+
+$(PKG_BUILD_DIR)/.patched: $(DL_DIR)/$(PKG_SOURCE)
+	$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
+	$(PATCH) $(PKG_BUILD_DIR) ./patches
+	touch $(PKG_BUILD_DIR)/.patched
+
+$(PKG_BUILD_DIR)/$(PKG_NAME): $(PKG_BUILD_DIR)/.patched
+	$(MAKE) CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS) -I." -C $(PKG_BUILD_DIR)
+
+$(PKG_IPK): $(PKG_BUILD_DIR)/$(PKG_NAME)
+	$(SCRIPT_DIR)/make-ipkg-dir.sh $(PKG_IPK_DIR) $(PKG_NAME).control $(PKG_VERSION)-$(PKG_RELEASE) $(ARCH)
+	mkdir -p $(PKG_IPK_DIR)/usr/lib
+	mkdir -p $(PKG_IPK_DIR)/usr/sbin
+	cp $(PKG_BUILD_DIR)/libiw.so.27 $(PKG_IPK_DIR)/usr/lib
+	cp $(PKG_BUILD_DIR)/iwconfig $(PKG_IPK_DIR)/usr/sbin
+	cp $(PKG_BUILD_DIR)/ifrename $(PKG_IPK_DIR)/usr/sbin
+	cp $(PKG_BUILD_DIR)/iwlist $(PKG_IPK_DIR)/usr/sbin
+	cp $(PKG_BUILD_DIR)/iwspy $(PKG_IPK_DIR)/usr/sbin
+	cp $(PKG_BUILD_DIR)/iwpriv $(PKG_IPK_DIR)/usr/sbin
+	cp $(PKG_BUILD_DIR)/iwevent $(PKG_IPK_DIR)/usr/sbin
+	cp $(PKG_BUILD_DIR)/iwgetid $(PKG_IPK_DIR)/usr/sbin
+	$(STRIP) $(PKG_IPK_DIR)/usr/sbin/*
+	mkdir -p $(PACKAGE_DIR)
+	$(IPKG_BUILD) $(PKG_IPK_DIR) $(PACKAGE_DIR)
+
+$(IPKG_STATE_DIR)/info/$(PKG_NAME).list: $(PKG_IPK)
+	$(IPKG) install $(PKG_IPK)
+
+source: $(DL_DIR)/$(PKG_SOURCE)
+prepare: $(PKG_BUILD_DIR)/.patched
+compile: $(PKG_IPK)
+install: $(IPKG_STATE_DIR)/info/$(PKG_NAME).list
+
+clean:
+	rm -rf $(PKG_BUILD_DIR)
+	rm -f $(PKG_IPK)
diff --git a/openwrt/package/wireless-tools/patches/debian-2.patch b/openwrt/package/wireless-tools/patches/debian-2.patch
new file mode 100644
index 000000000..158e63439
--- /dev/null
+++ b/openwrt/package/wireless-tools/patches/debian-2.patch
@@ -0,0 +1,89 @@
+--- wireless-tools-27.orig/iwlib.c
++++ wireless-tools-27/iwlib.c
+@@ -622,6 +622,7 @@
+ {
+   struct iwreq		wrq;
+ 
++  memset((char *) &wrq, 0, sizeof(struct iwreq));
+   memset((char *) info, 0, sizeof(struct wireless_config));
+ 
+   /* Get wireless name */
+--- wireless-tools-27.orig/Makefile
++++ wireless-tools-27/Makefile
+@@ -64,8 +64,8 @@
+ # Install directories
+ INSTALL_DIR= $(PREFIX)/sbin/
+ INSTALL_LIB= $(PREFIX)/lib/
+-INSTALL_INC= $(PREFIX)/include/
+-INSTALL_MAN= $(PREFIX)/man/
++INSTALL_INC= $(PREFIX)/usr/include/
++INSTALL_MAN= $(PREFIX)/usr/share/man/
+ 
+ # Various commands
+ RM = rm -f
+@@ -81,9 +81,9 @@
+ endif
+ 
+ # Other flags
+-CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
++#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.
+ DEPFLAGS=-MMD
+ XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG)
+ PICFLAG=-fPIC
+--- wireless-tools-27.orig/iwlist.c
++++ wireless-tools-27/iwlist.c
+@@ -870,7 +870,7 @@
+   struct iw_range	range;
+   int			has_range;
+   struct timeval	tv;				/* Select timeout */
+-  int			timeout = 5000000;		/* 5s */
++  int			timeout = 15000000;		/* 15s */
+ 
+   /* Avoid "Unused parameter" warning */
+   args = args; count = count;
+--- wireless-tools-27.orig/iwconfig.c
++++ wireless-tools-27/iwconfig.c
+@@ -835,10 +835,10 @@
+ 	      }
+ 	    else
+ 	      {
+-		/* '-' allow to escape the ESSID string, allowing
++		/* '-' or '--' allow to escape the ESSID string, allowing
+ 		 * to set it to the string "any" or "off".
+ 		 * This is a big ugly, but it will do for now */
+-		if(!strcmp(args[i], "-"))
++		if(!strcmp(args[i], "-") || !strcmp(args[i], "--"))
+ 		  {
+ 		    i++;
+ 		    if(i >= count)
+@@ -1377,12 +1377,21 @@
+       if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))
+ 	goterr = iw_print_version_info("iwconfig");
+       else
+-	/* The device name must be the first argument */
+-	if(argc == 2)
+-	  print_info(skfd, argv[1], NULL, 0);
+-	else
+-	  /* The other args on the line specify options to be set... */
+-	  goterr = set_info(skfd, argv + 2, argc - 2, argv[1]);
++      {
++        /* '--' escape device name */
++        if((argc > 2) && !strcmp(argv[1], "--"))
++          {
++            argv++;
++            argc--;
++          }
++
++        /* The device name must be the first argument */
++        if(argc == 2)
++          print_info(skfd, argv[1], NULL, 0);
++        else
++          /* The other args on the line specify options to be set... */
++          goterr = set_info(skfd, argv + 2, argc - 2, argv[1]);
++      }
+ 
+   /* Close the socket. */
+   iw_sockets_close(skfd);
diff --git a/openwrt/package/wireless-tools/wireless-tools.control b/openwrt/package/wireless-tools/wireless-tools.control
new file mode 100644
index 000000000..f6405f64b
--- /dev/null
+++ b/openwrt/package/wireless-tools/wireless-tools.control
@@ -0,0 +1,6 @@
+Package: wireless-tools
+Priority: optional
+Section: net
+Maintainer: Felix Fietkau <nbd@vd-s.ath.cx>
+Source: buildroot internal
+Description: Tools for setting up WiFi cards using the Wireless Extension
-- 
2.20.1