Patchwork Android branch compiled against Gingerbread Patch

login
register
mail settings
Submitter Keane, Ben (STRX)
Date April 26, 2012, 5:36 a.m.
Message ID <D33A18D160B4594DBA13CE836DF6DFE5589C4FAF@MDS8AEX12.ATTSMITHS.COM>
Download mbox | patch
Permalink /patch/155156/
State Not Applicable
Headers show

Comments

Keane, Ben (STRX) - April 26, 2012, 5:36 a.m.
Hi,

I recently grabbed the android-stable-2012-03 branch from http://hostap.epitest.fi/hostap.git

I had to modify the source code and Makefile slightly to get it to compile and work with my Gingerbread port (based on rowboat). I would assume that what I have done may not be completely correct, but I hope it is of some use to you. 

The following is a list of issues (no particular order)
1. My Android uses libnl1.1, so I had to:
	1.1 change the location of the headers
	1.2 change the Android.mk to link against version 1.1 instead of 2, and
	1.3 change the call to genl_ctrl_alloc_cache() as it had changed between the versions
2. hostapd would exit with chown: permission denied error. This patch changes the chown to use AID_WIFI for uid and gid (because under Android it isn't running as root).
3. If I use CONFIG_TLS=internal I had to add includes to libtommath

For other gingerbread uses this patch includes mods to android.config which are required to get it working on my system.





I hope this helps the community. 


Signed-hostap: Ben Keane <ben.keane@kaelus.com>


Kind Regards,


Ben Keane

PROPRIETARY: This e-mail contains proprietary information some or all of which may be legally privileged.  It is intended for the recipient only.  If an addressing or transmission error has misdirected this e-mail, please notify the authority by replying to this e-mail.  If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail.

Patch

diff --git a/hostapd/Android.mk b/hostapd/Android.mk
index 8363bd7..989e1f9 100644
--- a/hostapd/Android.mk
+++ b/hostapd/Android.mk
@@ -38,8 +38,15 @@  INCLUDES += $(LOCAL_PATH)/src
 INCLUDES += $(LOCAL_PATH)/src/utils
 INCLUDES += external/openssl/include
 INCLUDES += frameworks/base/cmds/keystore
+ifeq ($(CONFIG_TLS), internal)
+INCLUDES += external/dropbear/libtommath
+endif
 ifdef CONFIG_DRIVER_NL80211
+ifdef CONFIG_LIBNL20
 INCLUDES += external/libnl-headers
+else
+INCLUDES += external/libnl/include
+endif
 endif
 
 
@@ -787,6 +794,10 @@  ifdef CONFIG_ANDROID_LOG
 L_CFLAGS += -DCONFIG_ANDROID_LOG
 endif
 
+#ifdef CONFIG_ANDROID
+#L_CFLAGS += -DANDROID
+#endif
+
 OBJS_c = hostapd_cli.c src/common/wpa_ctrl.c src/utils/os_$(CONFIG_OS).c
 OBJS_c += src/utils/eloop.c
 ifdef CONFIG_WPA_TRACE
@@ -823,7 +834,14 @@  ifneq ($(BOARD_HOSTAPD_PRIVATE_LIB),)
 endif
 LOCAL_SHARED_LIBRARIES := libc libcutils libcrypto libssl
 ifdef CONFIG_DRIVER_NL80211
+ifdef CONFIG_LIBNL20
 LOCAL_STATIC_LIBRARIES += libnl_2
+else
+LOCAL_SHARED_LIBRARIES += libnl
+endif
+endif
+ifeq ($(CONFIG_TLS), internal)
+LOCAL_STATIC_LIBRARIES := libtommath
 endif
 LOCAL_CFLAGS := $(L_CFLAGS)
 LOCAL_SRC_FILES := $(OBJS)
diff --git a/hostapd/android.config b/hostapd/android.config
index 8341d4b..4bbf416 100644
--- a/hostapd/android.config
+++ b/hostapd/android.config
@@ -27,7 +27,7 @@ 
 #LIBNL=/usr/src/libnl
 #CFLAGS += -I$(LIBNL)/include
 #LIBS += -L$(LIBNL)/lib
-CONFIG_LIBNL20=y
+#CONFIG_LIBNL20=y
 
 # Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
 #CONFIG_DRIVER_BSD=y
@@ -55,25 +55,25 @@  CONFIG_LIBNL20=y
 #CONFIG_IEEE80211W=y
 
 # Integrated EAP server
-#CONFIG_EAP=y
+CONFIG_EAP=y
 
 # EAP-MD5 for the integrated EAP server
-#CONFIG_EAP_MD5=y
+CONFIG_EAP_MD5=y
 
 # EAP-TLS for the integrated EAP server
-#CONFIG_EAP_TLS=y
+CONFIG_EAP_TLS=y
 
 # EAP-MSCHAPv2 for the integrated EAP server
-#CONFIG_EAP_MSCHAPV2=y
+CONFIG_EAP_MSCHAPV2=y
 
 # EAP-PEAP for the integrated EAP server
-#CONFIG_EAP_PEAP=y
+CONFIG_EAP_PEAP=y
 
 # EAP-GTC for the integrated EAP server
-#CONFIG_EAP_GTC=y
+CONFIG_EAP_GTC=y
 
 # EAP-TTLS for the integrated EAP server
-#CONFIG_EAP_TTLS=y
+CONFIG_EAP_TTLS=y
 
 # EAP-SIM for the integrated EAP server
 #CONFIG_EAP_SIM=y
@@ -128,7 +128,7 @@  CONFIG_PKCS12=y
 #CONFIG_RADIUS_SERVER=y
 
 # Build IPv6 support for RADIUS operations
-CONFIG_IPV6=y
+#CONFIG_IPV6=y
 
 # IEEE Std 802.11r-2008 (Fast BSS Transition)
 #CONFIG_IEEE80211R=y
@@ -148,6 +148,9 @@  CONFIG_IPV6=y
 # Add support for writing debug log to Android logcat instead of standard output
 CONFIG_ANDROID_LOG=y
 
+# Add support for Android in general
+CONFIG_ANDROID=y
+
 # Remove support for RADIUS accounting
 #CONFIG_NO_ACCOUNTING=y
 
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index b1bafc1..7c9de18 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -34,6 +34,10 @@ 
 #include "config_file.h"
 #include "ctrl_iface.h"
 
+#ifdef ANDROID
+#include <private/android_filesystem_config.h>
+#endif /* ANDROID */
+
 
 struct wpa_ctrl_dst {
 	struct wpa_ctrl_dst *next;
@@ -848,9 +852,16 @@  int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
 		}
 	}
 
+#ifdef ANDROID
+	if (hapd->conf->ctrl_interface_gid_set &&
+	    chown(hapd->conf->ctrl_interface, AID_WIFI,
+		  AID_WIFI) < 0) {
+
+#else
 	if (hapd->conf->ctrl_interface_gid_set &&
 	    chown(hapd->conf->ctrl_interface, 0,
 		  hapd->conf->ctrl_interface_gid) < 0) {
+#endif
 		perror("chown[ctrl_interface]");
 		return -1;
 	}
@@ -906,8 +917,14 @@  int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
 		}
 	}
 
+#ifdef ANDROID
+	if (hapd->conf->ctrl_interface_gid_set &&
+	    chown(fname, AID_WIFI, AID_WIFI) < 0) {
+
+#else
 	if (hapd->conf->ctrl_interface_gid_set &&
 	    chown(fname, 0, hapd->conf->ctrl_interface_gid) < 0) {
+#endif
 		perror("chown[ctrl_interface/ifname]");
 		goto fail;
 	}
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 4282905..d8fe238 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -2674,7 +2674,16 @@  static int android_genl_ctrl_resolve(struct nl_handle *handle,
 	struct genl_family *nl80211 = NULL;
 	int id = -1;
 
+#ifdef CONFIG_LIBNL20
 	if (genl_ctrl_alloc_cache(handle, &cache) < 0) {
+#else
+	/*
+	 * Android Rowboat (libnl-1.1) has a different genl_ctrl_alloc_cache function prototype
+	*/
+	cache = genl_ctrl_alloc_cache(handle);
+	if (cache == NULL) {
+	
+#endif
 		wpa_printf(MSG_ERROR, "nl80211: Failed to allocate generic "
 			   "netlink cache");
 		goto fail;