aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2008-01-12 20:05:35 (GMT)
committerJouni Malinen <j@w1.fi>2008-01-12 20:05:35 (GMT)
commit6ccefe97d98de9b70ac0e1294afa61c74720ac14 (patch)
tree5cfa2275a40cadde880bd7e81745275db8ada204 /hostapd
parentfb7de3c81ca087e5d0660554ebf25c4b1be67bab (diff)
downloadhostap-history-6ccefe97d98de9b70ac0e1294afa61c74720ac14.zip
hostap-history-6ccefe97d98de9b70ac0e1294afa61c74720ac14.tar.gz
hostap-history-6ccefe97d98de9b70ac0e1294afa61c74720ac14.tar.bz2
Added support for configuring WPS IE for Host AP driver
Diffstat (limited to 'hostapd')
-rw-r--r--hostapd/driver_hostap.c84
1 files changed, 77 insertions, 7 deletions
diff --git a/hostapd/driver_hostap.c b/hostapd/driver_hostap.c
index b1c7435..9005800 100644
--- a/hostapd/driver_hostap.c
+++ b/hostapd/driver_hostap.c
@@ -47,6 +47,11 @@ struct hostap_driver_data {
int wext_sock; /* socket for wireless events */
int we_version;
+
+ u8 *generic_ie;
+ size_t generic_ie_len;
+ u8 *wps_ie;
+ size_t wps_ie_len;
};
@@ -750,13 +755,14 @@ static int hostap_set_assoc_ap(void *priv, const u8 *addr)
}
-static int hostap_set_generic_elem(const char *ifname, void *priv,
- const u8 *elem, size_t elem_len)
+static int hostapd_ioctl_set_generic_elem(struct hostap_driver_data *drv)
{
- struct hostap_driver_data *drv = priv;
struct prism2_hostapd_param *param;
int res;
- size_t blen = PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN + elem_len;
+ size_t blen, elem_len;
+
+ elem_len = drv->generic_ie_len + drv->wps_ie_len;
+ blen = PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN + elem_len;
if (blen < sizeof(*param))
blen = sizeof(*param);
@@ -766,15 +772,74 @@ static int hostap_set_generic_elem(const char *ifname, void *priv,
param->cmd = PRISM2_HOSTAPD_SET_GENERIC_ELEMENT;
param->u.generic_elem.len = elem_len;
- memcpy(param->u.generic_elem.data, elem, elem_len);
+ if (drv->generic_ie) {
+ os_memcpy(param->u.generic_elem.data, drv->generic_ie,
+ drv->generic_ie_len);
+ }
+ if (drv->wps_ie) {
+ os_memcpy(&param->u.generic_elem.data[drv->generic_ie_len],
+ drv->wps_ie, drv->wps_ie_len);
+ }
+ wpa_hexdump(MSG_DEBUG, "hostap: Set generic IE",
+ param->u.generic_elem.data, elem_len);
res = hostapd_ioctl(drv, param, blen);
- free(param);
+ os_free(param);
return res;
}
+static int hostap_set_generic_elem(const char *ifname, void *priv,
+ const u8 *elem, size_t elem_len)
+{
+ struct hostap_driver_data *drv = priv;
+
+ os_free(drv->generic_ie);
+ drv->generic_ie = NULL;
+ drv->generic_ie_len = 0;
+ if (elem) {
+ drv->generic_ie = os_malloc(elem_len);
+ if (drv->generic_ie == NULL)
+ return -1;
+ os_memcpy(drv->generic_ie, elem, elem_len);
+ drv->generic_ie_len = elem_len;
+ }
+
+ return hostapd_ioctl_set_generic_elem(drv);
+}
+
+
+static int hostap_set_wps_beacon_ie(const char *ifname, void *priv,
+ const u8 *ie, size_t len)
+{
+ /* Host AP driver supports only one set of extra IEs, so we need to
+ * use the ProbeResp IEs also for Beacon frames since they include more
+ * information. */
+ return 0;
+}
+
+
+static int hostap_set_wps_probe_resp_ie(const char *ifname, void *priv,
+ const u8 *ie, size_t len)
+{
+ struct hostap_driver_data *drv = priv;
+
+ os_free(drv->wps_ie);
+ drv->wps_ie = NULL;
+ drv->wps_ie_len = 0;
+ if (ie) {
+ drv->wps_ie = os_malloc(len);
+ if (drv->wps_ie == NULL)
+ return -1;
+ os_memcpy(drv->wps_ie, ie, len);
+ drv->wps_ie_len = len;
+ }
+
+ return hostapd_ioctl_set_generic_elem(drv);
+}
+
+
static void
hostapd_wireless_event_wireless_custom(struct hostap_driver_data *drv,
char *custom)
@@ -1087,7 +1152,10 @@ static void hostap_driver_deinit(void *priv)
if (drv->sock >= 0)
close(drv->sock);
-
+
+ os_free(drv->generic_ie);
+ os_free(drv->wps_ie);
+
free(drv);
}
@@ -1201,4 +1269,6 @@ const struct wpa_driver_ops wpa_driver_hostap_ops = {
.get_inact_sec = hostap_get_inact_sec,
.sta_clear_stats = hostap_sta_clear_stats,
.get_hw_feature_data = hostap_get_hw_feature_data,
+ .set_wps_beacon_ie = hostap_set_wps_beacon_ie,
+ .set_wps_probe_resp_ie = hostap_set_wps_probe_resp_ie,
};