[PATCH] Mac OS X: Fix driver_osx.c build

Masashi Honma honma
Sun Dec 13 16:12:26 PST 2009


Hello.

On Mac OS X 10.6, driver_osx.c build fails with message below.

cc -MMD -O2 -Wall -g -I../src -I../src/utils -DCONFIG_BACKEND_FILE -DCONFIG_PEERKEY -DCONFIG_DRIVER_OSX -DCONFIG_DRIVER_WIRED -DEAP_TLS -DEAP_PEAP -DEAP_TTLS -DEAP_MD5 -DEAP_MSCHAPv2 -DEAP_GTC -DEAP_OTP -DEAP_LEAP -DIEEE8021X_EAPOL -DPKCS12_FUNCS -DCONFIG_SMARTCARD -DCONFIG_TLS_INTERNAL_CLIENT -DCONFIG_CRYPTO_INTERNAL -DCONFIG_INTERNAL_LIBTOMMATH -DCONFIG_CTRL_IFACE -DCONFIG_CTRL_IFACE_UNIX    -c -o ../src/drivers/driver_osx.o ../src/drivers/driver_osx.m
../src/drivers/driver_osx.m:161: warning: ?struct wpa_scan_result? declared inside parameter list
../src/drivers/driver_osx.m:161: warning: its scope is only this definition or declaration, which is probably not what you want
../src/drivers/driver_osx.m: In function ?wpa_driver_osx_get_scan_results?:
../src/drivers/driver_osx.m:172: error: invalid application of ?sizeof? to incomplete type ?struct wpa_scan_result? 
../src/drivers/driver_osx.m:172: error: invalid application of ?sizeof? to incomplete type ?struct wpa_scan_result? 
../src/drivers/driver_osx.m:175: error: invalid use of undefined type ?struct wpa_scan_result?
../src/drivers/driver_osx.m:175: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:181: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:181: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:181: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:181: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:187: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:187: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:187: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:187: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:188: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:189: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:190: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:191: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m:192: error: dereferencing pointer to incomplete type
../src/drivers/driver_osx.m: At top level:
../src/drivers/driver_osx.m:427: error: unknown field ?scan? specified in initializer
../src/drivers/driver_osx.m:427: warning: initialization from incompatible pointer type
../src/drivers/driver_osx.m:428: error: unknown field ?get_scan_results? specified in initializer
../src/drivers/driver_osx.m:428: warning: initialization from incompatible pointer type
../src/drivers/driver_osx.m:430: warning: initialization from incompatible pointer type
make: *** [../src/drivers/driver_osx.o] Error 1


I made a patch. But I didn't test yet, because initialization error
below occured.


Initializing interface 'en1' conf 'examples/wep.conf' driver 'osx' ctrl_interface 'N/A' bridge 'N/A'
Configuration file 'examples/wep.conf' -> '/Users/honma/wpa_supplicant-osx/wpa_supplicant/examples/wep.conf'
Reading configuration file '/Users/honma/wpa_supplicant-osx/wpa_supplicant/examples/wep.conf'
ctrl_interface='/var/run/wpa_supplicant'
Line: 5 - start of a new network block
ssid - hexdump_ascii(len=19):
     65 78 61 6d 70 6c 65 20 77 65 70 20 6e 65 74 77   example wep netw
     6f 72 6b                                          ork             
key_mgmt: 0x4
wep_key0 - hexdump(len=5): [REMOVED]
wep_key1 - hexdump(len=5): [REMOVED]
wep_tx_keyidx=0 (0x0)
Priority group 0
   id=0 ssid='example wep network'
WirelessAttach: IOServiceOpen error: e00002c7
OSX: WirelessAttach failed: -2013261827
Failed to initialize driver interface
Failed to add interface en1
Cancelling scan request
Cancelling authentication timeout


I have googled the Apple proprietary library error measseges
and I guessed this is a matter on Snow Leopard (Mac OS X 10.6).
As far as I know, there is not any document about the new library.
(I am a member of Apple developer connection.) So I can't debug
this any more. This patch solves compilation error only.


diff --git a/src/drivers/driver_osx.m b/src/drivers/driver_osx.m
index 93d7df0..9f2ab0b 100644
--- a/src/drivers/driver_osx.m
+++ b/src/drivers/driver_osx.m
@@ -20,6 +20,7 @@
 #include "common.h"
 #include "driver.h"
 #include "eloop.h"
+#include "common/ieee802_11_defs.h"
 
 #include "Apple80211.h"
 
@@ -111,10 +112,12 @@ static void wpa_driver_osx_scan_timeout(void *eloop_ctx, void *timeout_ctx)
 }
 
 
-static int wpa_driver_osx_scan(void *priv, const u8 *ssid, size_t ssid_len)
+static int wpa_driver_osx_scan(void *priv, struct wpa_driver_scan_params *params)
 {
 	struct wpa_driver_osx_data *drv = priv;
 	WirelessError err;
+	const u8 *ssid = params->ssids[0].ssid;
+	size_t ssid_len = params->ssids[0].ssid_len;
 
 	if (drv->scan_results) {
 		CFRelease(drv->scan_results);
@@ -156,43 +159,66 @@ static int wpa_driver_osx_scan(void *priv, const u8 *ssid, size_t ssid_len)
 }
 
 
-static int wpa_driver_osx_get_scan_results(void *priv,
-					   struct wpa_scan_result *results,
-					   size_t max_size)
+static void wpa_driver_osx_add_scan_entry(struct wpa_scan_results *res,
+					  WirelessNetworkInfo *info)
+{
+	struct wpa_scan_res *result, **tmp;
+	size_t extra_len;
+	u8 *pos;
+
+	extra_len = 2 + info->ssid_len;
+
+	result = os_zalloc(sizeof(*result) + extra_len);
+	if (result == NULL)
+		return;
+	os_memcpy(result->bssid, info->bssid, ETH_ALEN);
+	result->freq = 2407 + info->channel * 5;
+	//result->beacon_int =;
+	result->caps = info->capability;
+	//result->qual = info->signal;
+	result->noise = info->noise;
+
+	pos = (u8 *)(result + 1);
+
+	*pos++ = WLAN_EID_SSID;
+	*pos++ = info->ssid_len;
+	os_memcpy(pos, info->ssid, info->ssid_len);
+	pos += info->ssid_len;
+
+	result->ie_len = pos - (u8 *)(result + 1);
+
+	tmp = os_realloc(res->res,
+			 (res->num + 1) * sizeof(struct wpa_scan_res *));
+	if (tmp == NULL) {
+		os_free(result);
+		return;
+	}
+	tmp[res->num++] = result;
+	res->res = tmp;
+}
+
+
+static struct wpa_scan_results * wpa_driver_osx_get_scan_results(void *priv)
 {
 	struct wpa_driver_osx_data *drv = priv;
+	struct wpa_scan_results *res;
 	size_t i, num;
 
 	if (drv->scan_results == NULL)
 		return 0;
 
 	num = CFArrayGetCount(drv->scan_results);
-	if (num > max_size)
-		num = max_size;
-	os_memset(results, 0, num * sizeof(struct wpa_scan_result));
-
-	for (i = 0; i < num; i++) {
-		struct wpa_scan_result *res = &results[i];
-		WirelessNetworkInfo *info;
-		info = (WirelessNetworkInfo *)
-			CFDataGetBytePtr(CFArrayGetValueAtIndex(
-						 drv->scan_results, i));
 
-		os_memcpy(res->bssid, info->bssid, ETH_ALEN);
-		if (info->ssid_len > 32) {
-			wpa_printf(MSG_DEBUG, "OSX: Invalid SSID length %d in "
-				   "scan results", (int) info->ssid_len);
-			continue;
-		}
-		os_memcpy(res->ssid, info->ssid, info->ssid_len);
-		res->ssid_len = info->ssid_len;
-		res->caps = info->capability;
-		res->freq = 2407 + info->channel * 5;
-		res->level = info->signal;
-		res->noise = info->noise;
-	}
+	res = os_zalloc(sizeof(*res));
+	if (res == NULL)
+		return NULL;
+
+	for (i = 0; i < num; i++)
+		wpa_driver_osx_add_scan_entry(res, (WirelessNetworkInfo *)
+			CFDataGetBytePtr(CFArrayGetValueAtIndex(
+				drv->scan_results, i)));
 
-	return num;
+	return res;
 }
 
 
@@ -277,7 +303,7 @@ static int wpa_driver_osx_associate(void *priv,
 }
 
 
-static int wpa_driver_osx_set_key(void *priv, wpa_alg alg, const u8 *addr,
+static int wpa_driver_osx_set_key(const char *ifname, void *priv, wpa_alg alg, const u8 *addr,
 				  int key_idx, int set_tx, const u8 *seq,
 				  size_t seq_len, const u8 *key,
 				  size_t key_len)
@@ -424,8 +450,8 @@ const struct wpa_driver_ops wpa_driver_osx_ops = {
 	.get_bssid = wpa_driver_osx_get_bssid,
 	.init = wpa_driver_osx_init,
 	.deinit = wpa_driver_osx_deinit,
-	.scan = wpa_driver_osx_scan,
-	.get_scan_results = wpa_driver_osx_get_scan_results,
+	.scan2 = wpa_driver_osx_scan,
+	.get_scan_results2 = wpa_driver_osx_get_scan_results,
 	.associate = wpa_driver_osx_associate,
 	.set_key = wpa_driver_osx_set_key,
 	.get_capa = wpa_driver_osx_get_capa,


Regards,
Masashi Honma.



More information about the Hostap mailing list