[patch] receive custom IE in wpa_supplicant
Leonardo Maccari
maccari-thisaintpartofmyaddress-
Thu May 26 08:00:49 PDT 2005
On Wed, May 25, 2005 at 04:55:26PM +0200, Leonardo Maccari wrote:
>
> I was able to make hostapd add a custom IE in beacon frames, I see the IE
if it can be useful to someone, here is the hack.
ciao,
leonardo.
--
Key fingerprint = 3129 C583 F03B 2E73 0115 C040 3489 0185 B592 19FE
Obviously -thisaintpartofmyaddress- is not part of my real email address
-------------- next part --------------
Only in ../hostapd-0.3.7-dev/: .config
diff -u ./config.c ../hostapd-0.3.7-dev/config.c
--- ./config.c 2005-01-22 20:43:16.000000000 +0100
+++ ../hostapd-0.3.7-dev/config.c 2005-05-26 16:27:15.000000000 +0200
@@ -66,7 +66,8 @@
conf->wpa_group = WPA_CIPHER_TKIP;
conf->radius_server_auth_port = 1812;
-
+ conf->generic_ie = NULL;
+
return conf;
}
@@ -935,6 +936,8 @@
} else if (strcmp(buf, "ctrl_interface") == 0) {
free(conf->ctrl_interface);
conf->ctrl_interface = strdup(pos);
+ } else if (strcmp(buf, "generic_ie") == 0) {
+ conf->generic_ie = strdup(pos);
} else if (strcmp(buf, "ctrl_interface_group") == 0) {
struct group *grp;
char *endp;
diff -u ./config.h ../hostapd-0.3.7-dev/config.h
--- ./config.h 2005-01-12 02:58:20.000000000 +0100
+++ ../hostapd-0.3.7-dev/config.h 2005-05-26 16:22:11.000000000 +0200
@@ -150,6 +150,7 @@
int wpa_gmk_rekey;
int rsn_preauth;
char *rsn_preauth_interfaces;
+ char * generic_ie;
char *ctrl_interface; /* directory for UNIX domain sockets */
gid_t ctrl_interface_gid;
Only in ./: defconfig
Only in ../hostapd-0.3.7-dev/: hostapd_cli
Only in ./: hostapd.conf
diff -u ./wpa.c ../hostapd-0.3.7-dev/wpa.c
--- ./wpa.c 2005-01-24 04:36:45.000000000 +0100
+++ ../hostapd-0.3.7-dev/wpa.c 2005-05-26 16:40:54.000000000 +0200
@@ -114,6 +114,16 @@
} __attribute__ ((packed));
+struct gen_ie_hdr {
+ u8 elem_id; /* WLAN_EID_GENERIC */
+ u8 len;
+} __attribute__ ((packed));
+
+
+
+
+
+
/* RSN IE version 1
* 0x01 0x00 (version; little endian)
* (all following fields are optional:)
@@ -135,6 +145,26 @@
u16 version;
} __attribute__ ((packed));
+
+int wpa_gen_ip_address_ie(struct hostapd_data *hapd, u8 * buf)
+{
+
+ struct gen_ie_hdr *hdr;
+ u8 *pos;
+ int ie_len;
+
+ ie_len = strlen(hapd->conf->generic_ie);
+
+ hdr = (struct gen_ie_hdr *) buf;
+ hdr->elem_id = WLAN_EID_GENERIC;
+ hdr->len = ie_len;
+ pos = (u8*) (hdr + 1);
+
+ memcpy(pos, (u8*) hapd->conf->generic_ie, strlen(hapd->conf->generic_ie));
+
+ return ie_len;
+}
+
static int wpa_write_wpa_ie(struct hostapd_data *hapd, u8 *buf, size_t len)
{
@@ -647,8 +677,24 @@
printf("Could not generate WPA IE.\n");
return -1;
}
+ if(hapd->conf->generic_ie)
+ {
+ u8 * buffer;
+ u8 * ptr;
+ buffer = malloc(hapd->wpa_ie_len + strlen(hapd->conf->generic_ie) + 2);
+ memcpy(buffer, hapd->wpa_ie,hapd->wpa_ie_len);
+ ptr = buffer + hapd->wpa_ie_len;
+ wpa_gen_ip_address_ie(hapd, ptr);
+
+ if (hostapd_set_generic_elem(hapd, buffer,hapd->wpa_ie_len + strlen(hapd->conf->generic_ie) + 2 )) {
+ printf("Failed to configure WPA IE for the kernel driver.\n");
+ return -1;
+ }
+ printf("\n\nDEBUG adding duplicate IE\n\n");
+ free(buffer);
- if (hostapd_set_generic_elem(hapd, hapd->wpa_ie, hapd->wpa_ie_len)) {
+ }else if (hostapd_set_generic_elem(hapd, hapd->wpa_ie, hapd->wpa_ie_len)) {
+
printf("Failed to configure WPA IE for the kernel driver.\n");
return -1;
}
More information about the Hostap
mailing list