netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wpa_supplicant: update driver_prism54.c
@ 2004-08-19 23:27 Luis R. Rodriguez
  2004-08-20  0:10 ` Luis R. Rodriguez
  2004-08-20  2:46 ` Jouni Malinen
  0 siblings, 2 replies; 5+ messages in thread
From: Luis R. Rodriguez @ 2004-08-19 23:27 UTC (permalink / raw)
  To: Jouni Malinen; +Cc: prism54-devel, hostap, Netdev, Jeff Garzik


[-- Attachment #1.1: Type: text/plain, Size: 532 bytes --]


Jouni,

the attached patch adds some startup work for wpa_supplicant support for
prism54. I just integrated some work for wpa_supplicant support into
prism54 CVS and sumbitted to Jeff for inclusion in 2.6 and 2.4. This
work is not yet complete but should get the ball rolling for us to
complete it.

People wishing to help advance this work should check out prism54 CVS
and use the attached patch for wpa_supplicant.

Thanks,

	Luis

-- 
GnuPG Key fingerprint = 113F B290 C6D2 0251 4D84  A34A 6ADD 4937 E20A 525E

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 151 bytes --]

_______________________________________________
Prism54-devel mailing list
Prism54-devel@prism54.org
http://prism54.org/mailman/listinfo/prism54-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] wpa_supplicant: update driver_prism54.c
  2004-08-19 23:27 [PATCH] wpa_supplicant: update driver_prism54.c Luis R. Rodriguez
@ 2004-08-20  0:10 ` Luis R. Rodriguez
  2004-08-20  2:46 ` Jouni Malinen
  1 sibling, 0 replies; 5+ messages in thread
From: Luis R. Rodriguez @ 2004-08-20  0:10 UTC (permalink / raw)
  To: Jouni Malinen, hostap, prism54-devel, Jeff Garzik, Netdev


[-- Attachment #1.1.1: Type: text/plain, Size: 907 bytes --]


Oh yea-- the patch ;)

	Luis

On Thu, Aug 19, 2004 at 07:27:20PM -0400, Luis R. Rodriguez wrote:
> 
> Jouni,
> 
> the attached patch adds some startup work for wpa_supplicant support for
> prism54. I just integrated some work for wpa_supplicant support into
> prism54 CVS and sumbitted to Jeff for inclusion in 2.6 and 2.4. This
> work is not yet complete but should get the ball rolling for us to
> complete it.
> 
> People wishing to help advance this work should check out prism54 CVS
> and use the attached patch for wpa_supplicant.
> 
> Thanks,
> 
> 	Luis
> 
> -- 
> GnuPG Key fingerprint = 113F B290 C6D2 0251 4D84  A34A 6ADD 4937 E20A 525E



> _______________________________________________
> HostAP mailing list
> HostAP@shmoo.com
> http://lists.shmoo.com/mailman/listinfo/hostap


-- 
GnuPG Key fingerprint = 113F B290 C6D2 0251 4D84  A34A 6ADD 4937 E20A 525E

[-- Attachment #1.1.2: prism54-wpa_supplicant.diff --]
[-- Type: text/plain, Size: 7740 bytes --]

--- wpa_supplicant/driver_prism54.c.orig	Thu Aug 19 19:16:50 2004
+++ wpa_supplicant/driver_prism54.c	Thu Aug 19 19:20:47 2004
@@ -1,6 +1,7 @@
 /*
  * WPA Supplicant - driver interaction with Linux Prism54.org driver
  * Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
+ * Copyright (c) 2004, Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -23,25 +24,175 @@
 #include "common.h"
 #include "driver.h"
 #include "driver_wext.h"
+#include "hostap_common.h"
 #include "wpa_supplicant.h"
 
 
-static int wpa_driver_prism54_set_wpa(const char *ifname, int enabled)
+#define PRISM54_SET_WPA    		SIOCIWFIRSTPRIV+12
+#define PRISM54_HOSTAPD    		SIOCIWFIRSTPRIV+25
+#define PRISM54_DROP_UNENCRYPTED	SIOCIWFIRSTPRIV+26
+
+static int hostapd_ioctl_prism54(const char *, struct prism2_hostapd_param *, int, int);
+static void show_set_key_error(struct prism2_hostapd_param *);
+
+static int hostapd_ioctl_prism54(const char *dev,
+				 struct prism2_hostapd_param *param,
+				 int len, int show_err)
 {
-	/* FIX */
-	printf("wpa_driver_prism54_set_wpa - not yet implemented\n");
+	int s;
+	struct iwreq iwr;
+
+	s = socket(PF_INET, SOCK_DGRAM, 0);
+	if (s < 0) {
+		perror("socket");
+		return -1;
+	}
+
+	memset(&iwr, 0, sizeof(iwr));
+	strncpy(iwr.ifr_name, dev, IFNAMSIZ);
+	iwr.u.data.pointer = (caddr_t) param;
+	iwr.u.data.length = len;
+
+	if (ioctl(s, PRISM54_HOSTAPD, &iwr) < 0) {
+		int ret;
+		close(s);
+		ret = errno;
+		if (show_err) 
+			perror("ioctl[PRISM54_HOSTAPD]");
+		return ret;
+	}
+	close(s);
+
 	return 0;
 }
 
 
+static int wpa_driver_prism54_set_wpa_ie(const char *ifname,
+					 const char *wpa_ie,
+					 size_t wpa_ie_len)
+{
+	struct prism2_hostapd_param *param;
+	int res;
+	size_t blen = PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN + wpa_ie_len;
+	if (blen < sizeof(*param))
+		blen = sizeof(*param);
+
+	param = (struct prism2_hostapd_param *) malloc(blen);
+	if (param == NULL)
+		return -1;
+	
+	memset(param, 0, blen);
+	param->cmd = PRISM2_HOSTAPD_SET_GENERIC_ELEMENT;
+	param->u.generic_elem.len = wpa_ie_len;
+	memcpy(param->u.generic_elem.data, wpa_ie, wpa_ie_len);
+	res = hostapd_ioctl_prism54(ifname, param, blen, 1);
+
+	free(param);
+
+	return res;
+}
+
+
+/* This is called at wpa_supplicant daemon init time */
+static int wpa_driver_prism54_set_wpa(const char *ifname, int enabled)
+{
+	struct prism2_hostapd_param *param;
+	int res;
+	size_t blen = PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN;
+	if (blen < sizeof(*param))
+		blen = sizeof(*param);
+
+	param = (struct prism2_hostapd_param *) malloc(blen);
+	if (param == NULL)
+		return -1;
+
+	memset(param, 0, blen);
+	param->cmd = PRISM54_SET_WPA;
+	param->u.generic_elem.len = 0;
+	res = hostapd_ioctl_prism54(ifname, param, blen, 1);
+
+	free(param);
+
+	return res;
+}
+
+
 static int wpa_driver_prism54_set_key(const char *ifname, wpa_alg alg,
 				      unsigned char *addr, int key_idx,
 				      int set_tx, u8 *seq, size_t seq_len,
 				      u8 *key, size_t key_len)
 {
-	/* FIX */
-	printf("wpa_driver_prism54_set_key - not yet implemented\n");
-	return 0;
+	struct prism2_hostapd_param *param;
+	u8 *buf;
+	size_t blen;
+	int ret = 0;
+	char *alg_name;
+
+	switch (alg) {
+	case WPA_ALG_NONE:
+		alg_name = "none";
+		return -1;
+		break;
+	case WPA_ALG_WEP:
+		alg_name = "WEP";
+		return -1;
+		break;
+	case WPA_ALG_TKIP:
+		alg_name = "TKIP";
+		break;
+	case WPA_ALG_CCMP:
+		alg_name = "CCMP";
+		return -1;
+		break;
+	default:
+		return -1;
+	}
+
+	wpa_printf(MSG_DEBUG, "%s: alg=%s key_idx=%d set_tx=%d seq_len=%d "
+		   "key_len=%d", __FUNCTION__, alg_name, key_idx, set_tx,
+		   seq_len, key_len);
+
+	if (seq_len > 8)
+		return -2;
+
+	blen = sizeof(*param) + key_len;
+	buf = malloc(blen);
+	if (buf == NULL)
+		return -1;
+	memset(buf, 0, blen);
+
+	param = (struct prism2_hostapd_param *) buf;
+	param->cmd = PRISM2_SET_ENCRYPTION;
+	/* TODO: In theory, STA in client mode can use five keys; four default
+	 * keys for receiving (with keyidx 0..3) and one individual key for
+	 * both transmitting and receiving (keyidx 0) _unicast_ packets. Now,
+	 * keyidx 0 is reserved for this unicast use and default keys can only
+	 * use keyidx 1..3 (i.e., default key with keyidx 0 is not supported).
+	 * This should be fine for more or less all cases, but for completeness
+	 * sake, the driver could be enhanced to support the missing key. */
+#if 0
+	if (addr == NULL)
+		memset(param->sta_addr, 0xff, ETH_ALEN);
+	else
+		memcpy(param->sta_addr, addr, ETH_ALEN);
+#else
+	memset(param->sta_addr, 0xff, ETH_ALEN);
+#endif
+	strncpy(param->u.crypt.alg, alg_name, HOSTAP_CRYPT_ALG_NAME_LEN);
+	param->u.crypt.flags = set_tx ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
+	param->u.crypt.idx = key_idx;
+	memcpy(param->u.crypt.seq, seq, seq_len);
+	param->u.crypt.key_len = key_len;
+	memcpy((u8 *) (param + 1), key, key_len);
+
+	if (hostapd_ioctl_prism54(ifname, param, blen, 1)) {
+		wpa_printf(MSG_WARNING, "Failed to set encryption.");
+		show_set_key_error(param);
+		ret = -1;
+	}
+	free(buf);
+
+	return ret;
 }
 
 
@@ -58,10 +209,24 @@ static int wpa_driver_prism54_set_counte
 static int wpa_driver_prism54_set_drop_unencrypted(const char *ifname,
 						  int enabled)
 {
-	/* FIX */
-	printf("wpa_driver_prism54_set_drop_unencrypted - not yet "
-	       "implemented\n");
-	return 0;
+	struct prism2_hostapd_param *param;
+	int res;
+	size_t blen = PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN;
+	if (blen < sizeof(*param))
+		blen = sizeof(*param);
+
+	param = (struct prism2_hostapd_param *) malloc(blen);
+	if (param == NULL)
+		return -1;
+
+	memset(param, 0, blen);
+	param->cmd = PRISM54_DROP_UNENCRYPTED;
+	param->u.generic_elem.len = 0;
+	res = hostapd_ioctl_prism54(ifname, param, blen, 1);
+
+	free(param);
+
+	return res;
 }
 
 
@@ -93,9 +258,8 @@ static int wpa_driver_prism54_associate(
 {
 	int ret = 0;
 
-	/* FIX: set wpa_ie */
-	printf("wpa_driver_prism54_associate - WPA IE setting not yet "
-	       "implemented\n");
+	if (wpa_driver_prism54_set_wpa_ie(ifname, wpa_ie, wpa_ie_len) < 0)
+		ret = -1;
 	if (wpa_driver_wext_set_freq(ifname, freq) < 0)
 		ret = -1;
 	if (wpa_driver_wext_set_ssid(ifname, ssid, ssid_len) < 0)
@@ -106,6 +270,35 @@ static int wpa_driver_prism54_associate(
 	return ret;
 }
 
+static void show_set_key_error(struct prism2_hostapd_param *param)
+{
+	switch (param->u.crypt.err) {
+	case HOSTAP_CRYPT_ERR_UNKNOWN_ALG:
+		wpa_printf(MSG_INFO, "Unknown algorithm '%s'.",
+			   param->u.crypt.alg);
+		wpa_printf(MSG_INFO, "You may need to load kernel module to "
+			   "register that algorithm.");
+		wpa_printf(MSG_INFO, "E.g., 'modprobe hostap_crypt_wep' for "
+			   "WEP.");
+		break;
+	case HOSTAP_CRYPT_ERR_UNKNOWN_ADDR:
+		wpa_printf(MSG_INFO, "Unknown address " MACSTR ".",
+			   MAC2STR(param->sta_addr));
+		break;
+	case HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED:
+		wpa_printf(MSG_INFO, "Crypt algorithm initialization failed.");
+		break;
+	case HOSTAP_CRYPT_ERR_KEY_SET_FAILED:
+		wpa_printf(MSG_INFO, "Key setting failed.");
+		break;
+	case HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED:
+		wpa_printf(MSG_INFO, "TX key index setting failed.");
+		break;
+	case HOSTAP_CRYPT_ERR_CARD_CONF_FAILED:
+		wpa_printf(MSG_INFO, "Card configuration failed.");
+		break;
+	}
+}
 
 struct wpa_driver_ops wpa_driver_prism54_ops = {
 	.get_bssid = wpa_driver_wext_get_bssid,

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 151 bytes --]

_______________________________________________
Prism54-devel mailing list
Prism54-devel@prism54.org
http://prism54.org/mailman/listinfo/prism54-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] wpa_supplicant: update driver_prism54.c
  2004-08-19 23:27 [PATCH] wpa_supplicant: update driver_prism54.c Luis R. Rodriguez
  2004-08-20  0:10 ` Luis R. Rodriguez
@ 2004-08-20  2:46 ` Jouni Malinen
  2004-08-28 23:27   ` Jeff Garzik
  1 sibling, 1 reply; 5+ messages in thread
From: Jouni Malinen @ 2004-08-20  2:46 UTC (permalink / raw)
  To: hostap; +Cc: Jeff Garzik, prism54-devel, Netdev

On Thu, Aug 19, 2004 at 07:27:20PM -0400, Luis R. Rodriguez wrote:

> the attached patch adds some startup work for wpa_supplicant support for
> prism54. I just integrated some work for wpa_supplicant support into
> prism54 CVS and sumbitted to Jeff for inclusion in 2.6 and 2.4. This
> work is not yet complete but should get the ball rolling for us to
> complete it.

Thanks, applied to wpa_supplicant CVS. I did not test this yet, but I
hope to get some time to test the latest CVS version of the driver at
some point.

-- 
Jouni Malinen                                            PGP id EFC895FA

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] wpa_supplicant: update driver_prism54.c
  2004-08-20  2:46 ` Jouni Malinen
@ 2004-08-28 23:27   ` Jeff Garzik
  2004-08-30  6:12     ` wireless-2.6 (was: [PATCH] wpa_supplicant: update driver_prism54.c) Jouni Malinen
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2004-08-28 23:27 UTC (permalink / raw)
  To: Jouni Malinen; +Cc: prism54-devel, hostap, Netdev

Jouni Malinen wrote:
> On Thu, Aug 19, 2004 at 07:27:20PM -0400, Luis R. Rodriguez wrote:
> 
> 
>>the attached patch adds some startup work for wpa_supplicant support for
>>prism54. I just integrated some work for wpa_supplicant support into
>>prism54 CVS and sumbitted to Jeff for inclusion in 2.6 and 2.4. This
>>work is not yet complete but should get the ball rolling for us to
>>complete it.
> 
> 
> Thanks, applied to wpa_supplicant CVS. I did not test this yet, but I
> hope to get some time to test the latest CVS version of the driver at
> some point.


Am I ever going to see an update to HostAP in wireless-2.6?

	Jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* wireless-2.6 (was: [PATCH] wpa_supplicant: update driver_prism54.c)
  2004-08-28 23:27   ` Jeff Garzik
@ 2004-08-30  6:12     ` Jouni Malinen
  0 siblings, 0 replies; 5+ messages in thread
From: Jouni Malinen @ 2004-08-30  6:12 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: prism54-devel, hostap, netdev

On Sat, Aug 28, 2004 at 07:27:54PM -0400, Jeff Garzik wrote:

> Am I ever going to see an update to HostAP in wireless-2.6?

I sure hope so. Unfortunately, there have been couple of things delaying
this on my part. One being lack of time (or not being on top of the
priority list), another being wait for getting a resolution for somewhat
related negotiations with my current employer.

Time/priority part is hopefully getting better. I wanted to first finish
the proposal for adding WPA/WPA2 to wireless extensions, but that is
starting to be near completion. After this, working on cleaning up the
generic IEEE 802.11 code in Host AP driver would be quite good next
project. If you are willing to add WE-18 first to wireless-2.6, I could
easily send you patches for this (both for adding WE-18 and to make Host
AP use it).

The other delaying factor is a bit more complicated. My current employer
happens to be involved with very similar areas as wireless-2.6
development and I need to be a bit careful on what I'm doing on my
free time. I took care of getting written agreement about Host AP
development before joining the company (lucky me ;-), but future
wireless-2.6 changes are starting to get beyond this. I had hoped to get
this resolved long time ago. However, getting a new agreement about
extended area (like wireless-2.6) has unfortunately already taken way
more than enough time and is still ongoing.

Apparently, I will have to start pushing more on this to actually
get some kind of conclusion so that I could start working more actively
with wireless-2.6. If nothing else works, I may have to start looking
for a new employer in order to be able to work with wireless-2.6..

-- 
Jouni Malinen                                            PGP id EFC895FA

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-08-30  6:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-19 23:27 [PATCH] wpa_supplicant: update driver_prism54.c Luis R. Rodriguez
2004-08-20  0:10 ` Luis R. Rodriguez
2004-08-20  2:46 ` Jouni Malinen
2004-08-28 23:27   ` Jeff Garzik
2004-08-30  6:12     ` wireless-2.6 (was: [PATCH] wpa_supplicant: update driver_prism54.c) Jouni Malinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).