WPS: Moved device attributes into wps_context::dev for Enrollee case
Previously, hardcoded values were used in wps_enrollee.c. These are now moved into shared data in struct wps_context. In case of AP/Authenticator, these are initialized in wps_hostapd.c. In case of client/supplicant, these are now initialized in EAP-WSC peer method, but will probably end up being moved into higher layer for better configuration. EAP-WSC peer method for
This commit is contained in:
parent
4b6a71fa31
commit
ff434cbdda
4 changed files with 35 additions and 93 deletions
|
@ -131,17 +131,29 @@ static void * eap_wsc_init(struct eap_sm *sm)
|
|||
data->state = registrar ? MSG : WAIT_START;
|
||||
data->registrar = registrar;
|
||||
|
||||
if (registrar) {
|
||||
struct wps_registrar_config rcfg;
|
||||
|
||||
wps = os_zalloc(sizeof(*wps));
|
||||
if (wps == NULL) {
|
||||
os_free(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data->wps_ctx = wps;
|
||||
wps->cb_ctx = data;
|
||||
|
||||
/* TODO: store wps_context at higher layer and make the device data
|
||||
* configurable */
|
||||
wps->dev.device_name = "dev name";
|
||||
wps->dev.manufacturer = "manuf";
|
||||
wps->dev.model_name = "model name";
|
||||
wps->dev.model_number = "model number";
|
||||
wps->dev.serial_number = "12345";
|
||||
wps->dev.categ = WPS_DEV_COMPUTER;
|
||||
wps->dev.oui = WPS_DEV_OUI_WFA;
|
||||
wps->dev.sub_categ = WPS_DEV_COMPUTER_PC;
|
||||
|
||||
if (registrar) {
|
||||
struct wps_registrar_config rcfg;
|
||||
|
||||
wps->auth_types = WPS_AUTH_WPA2PSK | WPS_AUTH_WPAPSK;
|
||||
wps->encr_types = WPS_ENCR_AES | WPS_ENCR_TKIP;
|
||||
|
||||
|
@ -160,7 +172,6 @@ static void * eap_wsc_init(struct eap_sm *sm)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
data->wps_ctx = wps;
|
||||
}
|
||||
|
||||
os_memset(&cfg, 0, sizeof(cfg));
|
||||
|
|
|
@ -71,8 +71,7 @@ static int wps_build_serial_number(struct wps_device_data *dev,
|
|||
}
|
||||
|
||||
|
||||
static int wps_build_primary_dev_type(struct wps_device_data *dev,
|
||||
struct wpabuf *msg)
|
||||
int wps_build_primary_dev_type(struct wps_device_data *dev, struct wpabuf *msg)
|
||||
{
|
||||
struct wps_dev_type *d;
|
||||
wpa_printf(MSG_DEBUG, "WPS: * Primary Device Type");
|
||||
|
|
|
@ -19,6 +19,8 @@ struct wps_parse_attr;
|
|||
|
||||
int wps_build_device_attrs(struct wps_device_data *dev, struct wpabuf *msg);
|
||||
int wps_build_os_version(struct wps_device_data *dev, struct wpabuf *msg);
|
||||
int wps_build_primary_dev_type(struct wps_device_data *dev,
|
||||
struct wpabuf *msg);
|
||||
int wps_process_device_attrs(struct wps_device_data *dev,
|
||||
struct wps_parse_attr *attr);
|
||||
int wps_process_os_version(struct wps_device_data *dev, const u8 *ver);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "sha256.h"
|
||||
#include "ieee802_11_defs.h"
|
||||
#include "wps_i.h"
|
||||
#include "wps_dev_attr.h"
|
||||
|
||||
|
||||
static int wps_build_req_type(struct wpabuf *msg, enum wps_request_type type)
|
||||
|
@ -70,70 +71,6 @@ static int wps_build_wps_state(struct wps_data *wps, struct wpabuf *msg)
|
|||
}
|
||||
|
||||
|
||||
static int wps_build_manufacturer(struct wps_data *wps, struct wpabuf *msg)
|
||||
{
|
||||
wpa_printf(MSG_DEBUG, "WPS: * Manufacturer");
|
||||
wpabuf_put_be16(msg, ATTR_MANUFACTURER);
|
||||
wpabuf_put_be16(msg, 5);
|
||||
wpabuf_put_data(msg, "manuf", 5); /* FIX */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int wps_build_model_name(struct wps_data *wps, struct wpabuf *msg)
|
||||
{
|
||||
wpa_printf(MSG_DEBUG, "WPS: * Model Name");
|
||||
wpabuf_put_be16(msg, ATTR_MODEL_NAME);
|
||||
wpabuf_put_be16(msg, 10);
|
||||
wpabuf_put_data(msg, "model name", 10); /* FIX */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int wps_build_model_number(struct wps_data *wps, struct wpabuf *msg)
|
||||
{
|
||||
wpa_printf(MSG_DEBUG, "WPS: * Model Number");
|
||||
wpabuf_put_be16(msg, ATTR_MODEL_NUMBER);
|
||||
wpabuf_put_be16(msg, 12);
|
||||
wpabuf_put_data(msg, "model number", 12); /* FIX */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int wps_build_serial_number(struct wps_data *wps, struct wpabuf *msg)
|
||||
{
|
||||
wpa_printf(MSG_DEBUG, "WPS: * Serial Number");
|
||||
wpabuf_put_be16(msg, ATTR_SERIAL_NUMBER);
|
||||
wpabuf_put_be16(msg, 5);
|
||||
wpabuf_put_data(msg, "12345", 5); /* FIX */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int wps_build_primary_dev_type(struct wps_data *wps, struct wpabuf *msg)
|
||||
{
|
||||
struct wps_dev_type *dev;
|
||||
wpa_printf(MSG_DEBUG, "WPS: * Primary Device Type");
|
||||
wpabuf_put_be16(msg, ATTR_PRIMARY_DEV_TYPE);
|
||||
wpabuf_put_be16(msg, sizeof(*dev));
|
||||
dev = wpabuf_put(msg, sizeof(*dev));
|
||||
WPA_PUT_BE16(dev->categ_id, WPS_DEV_COMPUTER);
|
||||
WPA_PUT_BE32(dev->oui, WPS_DEV_OUI_WFA);
|
||||
WPA_PUT_BE16(dev->sub_categ_id, WPS_DEV_COMPUTER_PC);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int wps_build_dev_name(struct wps_data *wps, struct wpabuf *msg)
|
||||
{
|
||||
wpa_printf(MSG_DEBUG, "WPS: * Device Name");
|
||||
wpabuf_put_be16(msg, ATTR_DEV_NAME);
|
||||
wpabuf_put_be16(msg, 8);
|
||||
wpabuf_put_data(msg, "dev name", 8); /* FIX */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int wps_build_rf_bands(struct wps_data *wps, struct wpabuf *msg)
|
||||
{
|
||||
wpa_printf(MSG_DEBUG, "WPS: * RF Bands");
|
||||
|
@ -167,16 +104,6 @@ static int wps_build_config_error(struct wps_data *wps, struct wpabuf *msg)
|
|||
}
|
||||
|
||||
|
||||
static int wps_build_os_version(struct wps_data *wps, struct wpabuf *msg)
|
||||
{
|
||||
wpa_printf(MSG_DEBUG, "WPS: * OS Version");
|
||||
wpabuf_put_be16(msg, ATTR_OS_VERSION);
|
||||
wpabuf_put_be16(msg, 4);
|
||||
wpabuf_put_be32(msg, 0x80000000); /* FIX */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int wps_build_e_hash(struct wps_data *wps, struct wpabuf *msg)
|
||||
{
|
||||
u8 *hash;
|
||||
|
@ -276,17 +203,12 @@ static struct wpabuf * wps_build_m1(struct wps_data *wps)
|
|||
wps_build_conn_type_flags(wps, msg) ||
|
||||
wps_build_config_methods(msg, methods) ||
|
||||
wps_build_wps_state(wps, msg) ||
|
||||
wps_build_manufacturer(wps, msg) ||
|
||||
wps_build_model_name(wps, msg) ||
|
||||
wps_build_model_number(wps, msg) ||
|
||||
wps_build_serial_number(wps, msg) ||
|
||||
wps_build_primary_dev_type(wps, msg) ||
|
||||
wps_build_dev_name(wps, msg) ||
|
||||
wps_build_device_attrs(&wps->wps->dev, msg) ||
|
||||
wps_build_rf_bands(wps, msg) ||
|
||||
wps_build_assoc_state(wps, msg) ||
|
||||
wps_build_dev_password_id(msg, wps->dev_pw_id) ||
|
||||
wps_build_config_error(wps, msg) ||
|
||||
wps_build_os_version(wps, msg)) {
|
||||
wps_build_os_version(&wps->wps->dev, msg)) {
|
||||
wpabuf_free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1223,8 +1145,16 @@ struct wpabuf * wps_enrollee_build_probe_req_ie(int pbc, const u8 *uuid)
|
|||
struct wpabuf *ie;
|
||||
u8 *len;
|
||||
u16 methods;
|
||||
struct wps_device_data dev;
|
||||
|
||||
wpa_printf(MSG_DEBUG, "WPS: Building WPS IE for Probe Request");
|
||||
|
||||
/* TODO: get device data from caller */
|
||||
os_memset(&dev, 0, sizeof(dev));
|
||||
dev.categ = WPS_DEV_COMPUTER;
|
||||
dev.oui = WPS_DEV_OUI_WFA;
|
||||
dev.sub_categ = WPS_DEV_COMPUTER_PC;
|
||||
|
||||
ie = wpabuf_alloc(200);
|
||||
if (ie == NULL)
|
||||
return NULL;
|
||||
|
@ -1243,7 +1173,7 @@ struct wpabuf * wps_enrollee_build_probe_req_ie(int pbc, const u8 *uuid)
|
|||
wps_build_req_type(ie, WPS_REQ_ENROLLEE) ||
|
||||
wps_build_config_methods(ie, methods) ||
|
||||
wps_build_uuid_e(ie, uuid) ||
|
||||
wps_build_primary_dev_type(NULL, ie) ||
|
||||
wps_build_primary_dev_type(&dev, ie) ||
|
||||
wps_build_rf_bands(NULL, ie) ||
|
||||
wps_build_assoc_state(NULL, ie) ||
|
||||
wps_build_config_error(NULL, ie) ||
|
||||
|
|
Loading…
Reference in a new issue