WPS: Set Request Type properly into WPS IE in ProbeReq/AssocReq

This commit is contained in:
Jouni Malinen 2008-11-29 13:38:03 +02:00
parent b8a8c299c8
commit b01c18a8ef
6 changed files with 26 additions and 15 deletions

View File

@ -174,7 +174,7 @@ const u8 * wps_get_uuid_e(const u8 *buf, size_t len)
}
struct wpabuf * wps_build_assoc_req_ie(void)
struct wpabuf * wps_build_assoc_req_ie(u8 req_type)
{
struct wpabuf *ie;
u8 *len;
@ -190,7 +190,7 @@ struct wpabuf * wps_build_assoc_req_ie(void)
wpabuf_put_be32(ie, WPS_DEV_OUI_WFA);
if (wps_build_version(ie) ||
wps_build_req_type(ie, WPS_REQ_ENROLLEE)) {
wps_build_req_type(ie, req_type)) {
wpabuf_free(ie);
return NULL;
}
@ -202,7 +202,7 @@ struct wpabuf * wps_build_assoc_req_ie(void)
struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev,
const u8 *uuid)
const u8 *uuid, u8 req_type)
{
struct wpabuf *ie;
u8 *len;
@ -225,7 +225,7 @@ struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev,
WPS_CONFIG_KEYPAD;
if (wps_build_version(ie) ||
wps_build_req_type(ie, WPS_REQ_ENROLLEE) ||
wps_build_req_type(ie, req_type) ||
wps_build_config_methods(ie, methods) ||
wps_build_uuid_e(ie, uuid) ||
wps_build_primary_dev_type(dev, ie) ||

View File

@ -79,9 +79,9 @@ struct wpabuf * wps_get_msg(struct wps_data *wps, u8 *op_code);
int wps_is_selected_pbc_registrar(const u8 *buf, size_t len);
int wps_is_selected_pin_registrar(const u8 *buf, size_t len);
const u8 * wps_get_uuid_e(const u8 *buf, size_t len);
struct wpabuf * wps_build_assoc_req_ie(void);
struct wpabuf * wps_build_assoc_req_ie(u8 req_type);
struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev,
const u8 *uuid);
const u8 *uuid, u8 req_type);
struct wps_registrar_config {

View File

@ -20,6 +20,7 @@
#include "wpa_supplicant_i.h"
#include "mlme.h"
#include "wps/wps.h"
#include "wps_supplicant.h"
static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s)
@ -42,7 +43,7 @@ static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s)
#ifdef CONFIG_WPS
static int wpas_wps_in_use(struct wpa_config *conf)
static int wpas_wps_in_use(struct wpa_config *conf, u8 *req_type)
{
struct wpa_ssid *ssid;
int wps = 0;
@ -52,6 +53,7 @@ static int wpas_wps_in_use(struct wpa_config *conf)
continue;
wps = 1;
*req_type = wpas_wps_get_req_type(ssid);
if (!ssid->eap.phase1)
continue;
@ -72,6 +74,9 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
const u8 *extra_ie = NULL;
size_t extra_ie_len = 0;
int wps = 0;
#ifdef CONFIG_WPS
u8 req_type = 0;
#endif /* CONFIG_WPS */
if (wpa_s->disconnected && !wpa_s->scan_req)
return;
@ -159,7 +164,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
wpa_s->prev_scan_ssid = BROADCAST_SSID_SCAN;
#ifdef CONFIG_WPS
wps = wpas_wps_in_use(wpa_s->conf);
wps = wpas_wps_in_use(wpa_s->conf, &req_type);
#endif /* CONFIG_WPS */
if (wpa_s->scan_res_tried == 0 && wpa_s->conf->ap_scan == 1 &&
@ -176,7 +181,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
#ifdef CONFIG_WPS
if (wps) {
wps_ie = wps_build_probe_req_ie(wps == 2, &wpa_s->wps->dev,
wpa_s->conf->uuid);
wpa_s->conf->uuid, req_type);
if (wps_ie) {
extra_ie = wpabuf_head(wps_ie);
extra_ie_len = wpabuf_len(wps_ie);

View File

@ -1012,7 +1012,8 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
}
#ifdef CONFIG_WPS
} else if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
struct wpabuf *wps_ie = wps_build_assoc_req_ie();
struct wpabuf *wps_ie;
wps_ie = wps_build_assoc_req_ie(wpas_wps_get_req_type(ssid));
if (wps_ie && wpabuf_len(wps_ie) <= sizeof(wpa_ie)) {
wpa_ie_len = wpabuf_len(wps_ie);
os_memcpy(wpa_ie, wpabuf_head(wps_ie), wpa_ie_len);

View File

@ -18,6 +18,7 @@
#include "ieee802_11_defs.h"
#include "wpa_common.h"
#include "config.h"
#include "eap_peer/eap.h"
#include "wpa_supplicant_i.h"
#include "wps/wps.h"
#include "wps/wps_defs.h"
@ -171,9 +172,13 @@ static int wpa_supplicant_wps_cred(void *ctx,
}
void * wpas_wps_get_cred_cb(void)
u8 wpas_wps_get_req_type(struct wpa_ssid *ssid)
{
return wpa_supplicant_wps_cred;
if (eap_is_wps_pbc_enrollee(&ssid->eap) ||
eap_is_wps_pin_enrollee(&ssid->eap))
return WPS_REQ_ENROLLEE;
else
return WPS_REQ_REGISTRAR;
}

View File

@ -20,7 +20,7 @@
int wpas_wps_init(struct wpa_supplicant *wpa_s);
void wpas_wps_deinit(struct wpa_supplicant *wpa_s);
int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s);
void * wpas_wps_get_cred_cb(void);
u8 wpas_wps_get_req_type(struct wpa_ssid *ssid);
#else /* CONFIG_WPS */
@ -38,9 +38,9 @@ static inline int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
return 0;
}
static inline void * wpas_wps_get_cred_cb(void)
u8 wpas_wps_get_req_type(struct wpa_ssid *ssid)
{
return NULL;
return 0;
}
#endif /* CONFIG_WPS */