From a8ea28ad9064395bf635ecd5d957796e2f0163c4 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Wed, 11 Nov 2009 00:34:42 +0000
Subject: [PATCH] hostapd: update to latest git, remove openssl dependency for
 hostapd-full, it works with internal crypto now

SVN-Revision: 18360
---
 package/hostapd/Makefile                       | 15 +++++++--------
 package/hostapd/files/full.config              | 14 ++++++++++++++
 package/hostapd/files/mini.config              | 13 ++++++++++++-
 package/hostapd/patches/100-madwifi_fix.patch  |  8 ++++----
 ...countrycode.patch => 110-countrycode.patch} |  4 ++--
 .../hostapd/patches/120-nl80211_ap_fix.patch   | 16 ++++++++++++++++
 package/hostapd/patches/130-libnl_update.patch | 18 ------------------
 7 files changed, 55 insertions(+), 33 deletions(-)
 rename package/hostapd/patches/{120-countrycode.patch => 110-countrycode.patch} (72%)
 create mode 100644 package/hostapd/patches/120-nl80211_ap_fix.patch
 delete mode 100644 package/hostapd/patches/130-libnl_update.patch

diff --git a/package/hostapd/Makefile b/package/hostapd/Makefile
index d8a3ac8ac9..606ec67360 100644
--- a/package/hostapd/Makefile
+++ b/package/hostapd/Makefile
@@ -8,14 +8,15 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=hostapd
-PKG_VERSION:=0.6.9
+PKG_VERSION:=20091111
 PKG_RELEASE:=1
+PKG_REV:=dc6d9ac250f793a62b21ca828445967fb484305f
 
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=http://hostap.epitest.fi/releases/
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=git://w1.fi/srv/git/hostap.git
 PKG_SOURCE_SUBDIR:=hostapd-$(PKG_VERSION)
 PKG_SOURCE_VERSION:=$(PKG_REV)
-PKG_MD5SUM:=83630d11fa66ade9091f1b304fccd74c
+PKG_SOURCE_PROTO:=git
 
 PKG_BUILD_DEPENDS:= \
 	PACKAGE_kmod-madwifi:madwifi \
@@ -50,7 +51,6 @@ endef
 define Package/hostapd
 $(call Package/hostapd/Default)
   TITLE+= (full)
-  DEPENDS+= +PACKAGE_hostapd:libopenssl
   VARIANT:=full
 endef
 
@@ -81,6 +81,8 @@ define Package/hostapd-utils/description
 endef
 
 define Build/Configure
+	rm -f $(PKG_BUILD_DIR)/hostapd/hostapd
+	rm -f $(PKG_BUILD_DIR)/src/drivers/drivers.o
 	$(CP) ./files/$(BUILD_VARIANT).config $(PKG_BUILD_DIR)/hostapd/.config
 endef
 
@@ -96,9 +98,6 @@ TARGET_CPPFLAGS := \
 ifdef CONFIG_PACKAGE_kmod-mac80211
   TARGET_LDFLAGS += -lm -lnl-tiny
 endif
-ifeq ($(BUILD_VARIANT),full)
-  TARGET_LDFLAGS += -lssl -lcrypto
-endif
 
 define Build/Compile
 	CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
diff --git a/package/hostapd/files/full.config b/package/hostapd/files/full.config
index 8643a2b0ae..07c924fe90 100644
--- a/package/hostapd/files/full.config
+++ b/package/hostapd/files/full.config
@@ -142,3 +142,17 @@ CONFIG_IEEE80211N=y
 # This can be used to reduce the size of the hostapd considerably if debugging
 # code is not needed.
 #CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove support for RADIUS accounting
+#CONFIG_NO_ACCOUNTING=y
+
+# Remove support for RADIUS
+#CONFIG_NO_RADIUS=y
+
+# Remove support for VLANs
+#CONFIG_NO_VLAN=y
+
+CONFIG_TLS=internal
+CONFIG_INTERNAL_LIBTOMMATH=y
+CONFIG_INTERNAL_AES=y
+NEED_AES_DEC=y
diff --git a/package/hostapd/files/mini.config b/package/hostapd/files/mini.config
index 37f76d1858..1720dddbf8 100644
--- a/package/hostapd/files/mini.config
+++ b/package/hostapd/files/mini.config
@@ -40,7 +40,7 @@ CONFIG_DRIVER_NL80211=y
 #CONFIG_DRIVER_NONE=y
 
 # IEEE 802.11F/IAPP
-CONFIG_IAPP=y
+# CONFIG_IAPP=y
 
 # WPA2/IEEE 802.11i RSN pre-authentication
 CONFIG_RSN_PREAUTH=y
@@ -142,3 +142,14 @@ CONFIG_IEEE80211N=y
 # This can be used to reduce the size of the hostapd considerably if debugging
 # code is not needed.
 #CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove support for RADIUS accounting
+CONFIG_NO_ACCOUNTING=y
+
+# Remove support for RADIUS
+CONFIG_NO_RADIUS=y
+
+# Remove support for VLANs
+#CONFIG_NO_VLAN=y
+
+CONFIG_TLS=internal
diff --git a/package/hostapd/patches/100-madwifi_fix.patch b/package/hostapd/patches/100-madwifi_fix.patch
index 8f8be442b9..915b86a641 100644
--- a/package/hostapd/patches/100-madwifi_fix.patch
+++ b/package/hostapd/patches/100-madwifi_fix.patch
@@ -1,6 +1,6 @@
---- a/hostapd/driver_madwifi.c
-+++ b/hostapd/driver_madwifi.c
-@@ -312,6 +312,7 @@ madwifi_set_iface_flags(void *priv, int 
+--- a/src/drivers/driver_madwifi.c
++++ b/src/drivers/driver_madwifi.c
+@@ -318,6 +318,7 @@ madwifi_set_iface_flags(void *priv, int 
  {
  	struct madwifi_driver_data *drv = priv;
  	struct ifreq ifr;
@@ -8,7 +8,7 @@
  
  	wpa_printf(MSG_DEBUG, "%s: dev_up=%d", __func__, dev_up);
  
-@@ -326,10 +327,14 @@ madwifi_set_iface_flags(void *priv, int 
+@@ -332,10 +333,14 @@ madwifi_set_iface_flags(void *priv, int 
  		return -1;
  	}
  
diff --git a/package/hostapd/patches/120-countrycode.patch b/package/hostapd/patches/110-countrycode.patch
similarity index 72%
rename from package/hostapd/patches/120-countrycode.patch
rename to package/hostapd/patches/110-countrycode.patch
index 8ffc65ca21..7c9d0219d9 100644
--- a/package/hostapd/patches/120-countrycode.patch
+++ b/package/hostapd/patches/110-countrycode.patch
@@ -1,6 +1,6 @@
 --- a/hostapd/hostapd.c
 +++ b/hostapd/hostapd.c
-@@ -1546,10 +1546,8 @@ static int setup_interface(struct hostap
+@@ -1344,10 +1344,8 @@ static int setup_interface(struct hostap
  	if (hapd->iconf->country[0] && hapd->iconf->country[1]) {
  		os_memcpy(country, hapd->iconf->country, 3);
  		country[3] = '\0';
@@ -11,4 +11,4 @@
 -		}
  	}
  
- 	if (hapd->iconf->ieee80211d &&
+ 	if (hapd->iconf->bridge_packets != INTERNAL_BRIDGE_DO_NOT_CONTROL &&
diff --git a/package/hostapd/patches/120-nl80211_ap_fix.patch b/package/hostapd/patches/120-nl80211_ap_fix.patch
new file mode 100644
index 0000000000..78475e87d5
--- /dev/null
+++ b/package/hostapd/patches/120-nl80211_ap_fix.patch
@@ -0,0 +1,16 @@
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -4418,10 +4418,10 @@ static void *i802_init(struct hostapd_da
+ 	/* start listening for EAPOL on the default AP interface */
+ 	add_ifidx(drv, drv->ifindex);
+ 
+-	if (params->bssid) {
+-		if (hostapd_set_iface_flags(drv, drv->ifname, 0))
+-			goto failed;
++	if (hostapd_set_iface_flags(drv, drv->ifname, 0))
++		goto failed;
+ 
++	if (params->bssid) {
+ 		if (set_ifhwaddr(drv, drv->ifname, params->bssid))
+ 			goto failed;
+ 	}
diff --git a/package/hostapd/patches/130-libnl_update.patch b/package/hostapd/patches/130-libnl_update.patch
deleted file mode 100644
index 51bc58a08a..0000000000
--- a/package/hostapd/patches/130-libnl_update.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/hostapd/driver_nl80211.c
-+++ b/hostapd/driver_nl80211.c
-@@ -29,6 +29,7 @@
- #include "wireless_copy.h"
- #include <linux/filter.h>
- #include <net/if_arp.h>
-+#include <linux/rtnetlink.h>
- 
- #include "hostapd.h"
- #include "driver.h"
-@@ -45,6 +46,7 @@
- /* libnl 2.0 compatibility code */
- #define nl_handle_alloc_cb nl_socket_alloc_cb
- #define nl_handle_destroy nl_socket_free
-+#define nl_handle nl_sock
- #endif /* CONFIG_LIBNL20 */
- 
- enum ieee80211_msg_type {
-- 
2.30.2