WPS: Remove old OOB NFC interface

The old WPS interface for using NFC has no known deployments and even
the binary libraries referenced here are not easily available anymore.
Since the new interface for using NFC with WPS covers the same
functionality, remove the old implementation to clean up WPS
implementation.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2012-10-28 18:20:03 +02:00
parent bd3a373767
commit 9f36eac6e5
18 changed files with 19 additions and 322 deletions

View file

@ -378,16 +378,7 @@ endif
ifdef CONFIG_WPS_NFC
L_CFLAGS += -DCONFIG_WPS_NFC
OBJS += src/wps/ndef.c
OBJS += src/wps/wps_nfc.c
NEED_WPS_OOB=y
ifdef CONFIG_WPS_NFC_PN531
PN531_PATH ?= /usr/local/src/nfc
L_CFLAGS += -DCONFIG_WPS_NFC_PN531
L_CFLAGS += -I${PN531_PATH}/inc
OBJS += src/wps/wps_nfc_pn531.c
LIBS += ${PN531_PATH}/lib/wpsnfc.dll
LIBS += ${PN531_PATH}/lib/libnfc_mapping_pn53x.dll
endif
endif
ifdef NEED_WPS_OOB

View file

@ -370,16 +370,7 @@ endif
ifdef CONFIG_WPS_NFC
CFLAGS += -DCONFIG_WPS_NFC
OBJS += ../src/wps/ndef.o
OBJS += ../src/wps/wps_nfc.o
NEED_WPS_OOB=y
ifdef CONFIG_WPS_NFC_PN531
PN531_PATH ?= /usr/local/src/nfc
CFLAGS += -DCONFIG_WPS_NFC_PN531
CFLAGS += -I${PN531_PATH}/inc
OBJS += ../src/wps/wps_nfc_pn531.o
LIBS += ${PN531_PATH}/lib/wpsnfc.dll
LIBS += ${PN531_PATH}/lib/libnfc_mapping_pn53x.dll
endif
endif
ifdef NEED_WPS_OOB

View file

@ -253,7 +253,7 @@ static int hostapd_ctrl_iface_wps_check_pin(
#ifdef CONFIG_WPS_OOB
static int hostapd_ctrl_iface_wps_oob(struct hostapd_data *hapd, char *txt)
{
char *path, *method, *name;
char *path, *method;
path = os_strchr(txt, ' ');
if (path == NULL)
@ -265,11 +265,7 @@ static int hostapd_ctrl_iface_wps_oob(struct hostapd_data *hapd, char *txt)
return -1;
*method++ = '\0';
name = os_strchr(method, ' ');
if (name != NULL)
*name++ = '\0';
return hostapd_wps_start_oob(hapd, txt, path, method, name);
return hostapd_wps_start_oob(hapd, txt, path, method);
}
#endif /* CONFIG_WPS_OOB */

View file

@ -412,24 +412,18 @@ static int hostapd_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc,
char cmd[256];
int res;
if (argc != 3 && argc != 4) {
printf("Invalid WPS_OOB command: need three or four "
if (argc != 3) {
printf("Invalid WPS_OOB command: need three "
"arguments:\n"
"- DEV_TYPE: use 'ufd' or 'nfc'\n"
"- DEV_TYPE: use 'ufd'\n"
"- PATH: path of OOB device like '/mnt'\n"
"- METHOD: OOB method 'pin-e' or 'pin-r', "
"'cred'\n"
"- DEV_NAME: (only for NFC) device name like "
"'pn531'\n");
"'cred'\n");
return -1;
}
if (argc == 3)
res = os_snprintf(cmd, sizeof(cmd), "WPS_OOB %s %s %s",
argv[0], argv[1], argv[2]);
else
res = os_snprintf(cmd, sizeof(cmd), "WPS_OOB %s %s %s %s",
argv[0], argv[1], argv[2], argv[3]);
res = os_snprintf(cmd, sizeof(cmd), "WPS_OOB %s %s %s",
argv[0], argv[1], argv[2]);
if (res < 0 || (size_t) res >= sizeof(cmd) - 1) {
printf("Too long WPS_OOB command.\n");
return -1;

View file

@ -1157,7 +1157,7 @@ int hostapd_wps_cancel(struct hostapd_data *hapd)
#ifdef CONFIG_WPS_OOB
int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type,
char *path, char *method, char *name)
char *path, char *method)
{
struct wps_context *wps = hapd->wps;
struct oob_device_data *oob_dev;
@ -1166,7 +1166,6 @@ int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type,
if (oob_dev == NULL)
return -1;
oob_dev->device_path = path;
oob_dev->device_name = name;
wps->oob_conf.oob_method = wps_get_oob_method(method);
if (wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_R) {

View file

@ -22,7 +22,7 @@ int hostapd_wps_button_pushed(struct hostapd_data *hapd,
const u8 *p2p_dev_addr);
int hostapd_wps_cancel(struct hostapd_data *hapd);
int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type,
char *path, char *method, char *name);
char *path, char *method);
int hostapd_wps_get_mib_sta(struct hostapd_data *hapd, const u8 *addr,
char *buf, size_t buflen);
void hostapd_wps_ap_pin_disable(struct hostapd_data *hapd);

View file

@ -767,7 +767,6 @@ struct wps_context {
};
struct oob_device_data {
char *device_name;
char *device_path;
void * (*init_func)(struct wps_context *, struct oob_device_data *,
int);
@ -776,13 +775,6 @@ struct oob_device_data {
void (*deinit_func)(void *);
};
struct oob_nfc_device_data {
int (*init_func)(char *);
void * (*read_func)(size_t *);
int (*write_func)(void *, size_t);
void (*deinit_func)(void);
};
struct wps_registrar *
wps_registrar_init(struct wps_context *wps,
const struct wps_registrar_config *cfg);
@ -822,7 +814,6 @@ int wps_pin_str_valid(const char *pin);
void wps_free_pending_msgs(struct upnp_pending_message *msgs);
struct oob_device_data * wps_get_oob_device(char *device_type);
struct oob_nfc_device_data * wps_get_oob_nfc_device(char *device_name);
int wps_get_oob_method(char *method);
int wps_process_oob(struct wps_context *wps, struct oob_device_data *oob_dev,
int registrar);

View file

@ -543,30 +543,11 @@ struct oob_device_data * wps_get_oob_device(char *device_type)
if (os_strstr(device_type, "ufd") != NULL)
return &oob_ufd_device_data;
#endif /* CONFIG_WPS_UFD */
#ifdef CONFIG_WPS_NFC
if (os_strstr(device_type, "nfc") != NULL)
return &oob_nfc_device_data;
#endif /* CONFIG_WPS_NFC */
return NULL;
}
#ifdef CONFIG_WPS_NFC
struct oob_nfc_device_data * wps_get_oob_nfc_device(char *device_name)
{
if (device_name == NULL)
return NULL;
#ifdef CONFIG_WPS_NFC_PN531
if (os_strstr(device_name, "pn531") != NULL)
return &oob_nfc_pn531_device_data;
#endif /* CONFIG_WPS_NFC_PN531 */
return NULL;
}
#endif /* CONFIG_WPS_NFC */
int wps_get_oob_method(char *method)
{
if (os_strstr(method, "pin-e") != NULL)

View file

@ -138,8 +138,6 @@ void wps_pbc_overlap_event(struct wps_context *wps);
void wps_pbc_timeout_event(struct wps_context *wps);
extern struct oob_device_data oob_ufd_device_data;
extern struct oob_device_data oob_nfc_device_data;
extern struct oob_nfc_device_data oob_nfc_pn531_device_data;
struct wpabuf * wps_build_wsc_ack(struct wps_data *wps);
struct wpabuf * wps_build_wsc_nack(struct wps_data *wps);

View file

@ -1,111 +0,0 @@
/*
* NFC routines for Wi-Fi Protected Setup
* Copyright (c) 2009-2012, Masashi Honma <masashi.honma@gmail.com>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include "common.h"
#include "wps/wps.h"
#include "wps_i.h"
struct wps_nfc_data {
struct oob_nfc_device_data *oob_nfc_dev;
};
static void * init_nfc(struct wps_context *wps,
struct oob_device_data *oob_dev, int registrar)
{
struct oob_nfc_device_data *oob_nfc_dev;
struct wps_nfc_data *data;
oob_nfc_dev = wps_get_oob_nfc_device(oob_dev->device_name);
if (oob_nfc_dev == NULL) {
wpa_printf(MSG_ERROR, "WPS (NFC): Unknown NFC device (%s)",
oob_dev->device_name);
return NULL;
}
if (oob_nfc_dev->init_func(oob_dev->device_path) < 0)
return NULL;
data = os_zalloc(sizeof(*data));
if (data == NULL) {
wpa_printf(MSG_ERROR, "WPS (NFC): Failed to allocate "
"nfc data area");
return NULL;
}
data->oob_nfc_dev = oob_nfc_dev;
return data;
}
static struct wpabuf * read_nfc(void *priv)
{
struct wps_nfc_data *data = priv;
struct wpabuf *wifi, *buf;
char *raw_data;
size_t len;
raw_data = data->oob_nfc_dev->read_func(&len);
if (raw_data == NULL)
return NULL;
wifi = wpabuf_alloc_copy(raw_data, len);
os_free(raw_data);
if (wifi == NULL) {
wpa_printf(MSG_ERROR, "WPS (NFC): Failed to allocate "
"nfc read area");
return NULL;
}
buf = ndef_parse_wifi(wifi);
wpabuf_free(wifi);
if (buf == NULL)
wpa_printf(MSG_ERROR, "WPS (NFC): Failed to unwrap");
return buf;
}
static int write_nfc(void *priv, struct wpabuf *buf)
{
struct wps_nfc_data *data = priv;
struct wpabuf *wifi;
int ret;
wifi = ndef_build_wifi(buf);
if (wifi == NULL) {
wpa_printf(MSG_ERROR, "WPS (NFC): Failed to wrap");
return -1;
}
ret = data->oob_nfc_dev->write_func(wpabuf_mhead(wifi),
wpabuf_len(wifi));
wpabuf_free(wifi);
return ret;
}
static void deinit_nfc(void *priv)
{
struct wps_nfc_data *data = priv;
data->oob_nfc_dev->deinit_func();
os_free(data);
}
struct oob_device_data oob_nfc_device_data = {
.device_name = NULL,
.device_path = NULL,
.init_func = init_nfc,
.read_func = read_nfc,
.write_func = write_nfc,
.deinit_func = deinit_nfc,
};

View file

@ -1,107 +0,0 @@
/*
* NFC PN531 routines for Wi-Fi Protected Setup
* Copyright (c) 2009-2012, Masashi Honma <masashi.honma@gmail.com>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include "common.h"
#include "wps/wps.h"
#include "wps_i.h"
#include "WpsNfcType.h"
#include "WpsNfc.h"
static int init_nfc_pn531(char *path)
{
u32 ret;
ret = WpsNfcInit();
if (ret != WPS_NFCLIB_ERR_SUCCESS) {
wpa_printf(MSG_ERROR, "WPS (PN531): Failed to initialize "
"NFC Library: 0x%08x", ret);
return -1;
}
ret = WpsNfcOpenDevice((int8 *) path);
if (ret != WPS_NFCLIB_ERR_SUCCESS) {
wpa_printf(MSG_ERROR, "WPS (PN531): Failed to open "
"NFC Device(%s): 0x%08x", path, ret);
goto fail;
}
ret = WpsNfcTokenDiscovery();
if (ret != WPS_NFCLIB_ERR_SUCCESS) {
wpa_printf(MSG_ERROR, "WPS (PN531): Failed to discover "
"token: 0x%08x", ret);
WpsNfcCloseDevice();
goto fail;
}
return 0;
fail:
WpsNfcDeinit();
return -1;
}
static void * read_nfc_pn531(size_t *size)
{
uint32 len;
u32 ret;
int8 *data;
ret = WpsNfcRawReadToken(&data, &len);
if (ret != WPS_NFCLIB_ERR_SUCCESS) {
wpa_printf(MSG_ERROR, "WPS (PN531): Failed to read: 0x%08x",
ret);
return NULL;
}
*size = len;
return data;
}
static int write_nfc_pn531(void *data, size_t len)
{
u32 ret;
ret = WpsNfcRawWriteToken(data, len);
if (ret != WPS_NFCLIB_ERR_SUCCESS) {
wpa_printf(MSG_ERROR, "WPS (PN531): Failed to write: 0x%08x",
ret);
return -1;
}
return 0;
}
static void deinit_nfc_pn531(void)
{
u32 ret;
ret = WpsNfcCloseDevice();
if (ret != WPS_NFCLIB_ERR_SUCCESS)
wpa_printf(MSG_ERROR, "WPS (PN531): Failed to close "
"NFC Device: 0x%08x", ret);
ret = WpsNfcDeinit();
if (ret != WPS_NFCLIB_ERR_SUCCESS)
wpa_printf(MSG_ERROR, "WPS (PN531): Failed to deinitialize "
"NFC Library: 0x%08x", ret);
}
struct oob_nfc_device_data oob_nfc_pn531_device_data = {
.init_func = init_nfc_pn531,
.read_func = read_nfc_pn531,
.write_func = write_nfc_pn531,
.deinit_func = deinit_nfc_pn531,
};

View file

@ -221,7 +221,6 @@ static void deinit_ufd(void *priv)
struct oob_device_data oob_ufd_device_data = {
.device_name = NULL,
.device_path = NULL,
.init_func = init_ufd,
.read_func = read_ufd,

View file

@ -593,16 +593,7 @@ endif
ifdef CONFIG_WPS_NFC
L_CFLAGS += -DCONFIG_WPS_NFC
OBJS += src/wps/ndef.c
OBJS += src/wps/wps_nfc.c
NEED_WPS_OOB=y
ifdef CONFIG_WPS_NFC_PN531
PN531_PATH ?= /usr/local/src/nfc
L_CFLAGS += -DCONFIG_WPS_NFC_PN531
L_CFLAGS += -I${PN531_PATH}/inc
OBJS += src/wps/wps_nfc_pn531.c
LIBS += ${PN531_PATH}/lib/wpsnfc.dll
LIBS += ${PN531_PATH}/lib/libnfc_mapping_pn53x.dll
endif
endif
ifdef NEED_WPS_OOB

View file

@ -601,16 +601,7 @@ endif
ifdef CONFIG_WPS_NFC
CFLAGS += -DCONFIG_WPS_NFC
OBJS += ../src/wps/ndef.o
OBJS += ../src/wps/wps_nfc.o
NEED_WPS_OOB=y
ifdef CONFIG_WPS_NFC_PN531
PN531_PATH ?= /usr/local/src/nfc
CFLAGS += -DCONFIG_WPS_NFC_PN531
CFLAGS += -I${PN531_PATH}/inc
OBJS += ../src/wps/wps_nfc_pn531.o
LIBS += ${PN531_PATH}/lib/wpsnfc.dll
LIBS += ${PN531_PATH}/lib/libnfc_mapping_pn53x.dll
endif
endif
ifdef NEED_WPS_OOB

View file

@ -754,7 +754,7 @@ static int wpa_supplicant_ctrl_iface_wps_check_pin(
static int wpa_supplicant_ctrl_iface_wps_oob(struct wpa_supplicant *wpa_s,
char *cmd)
{
char *path, *method, *name;
char *path, *method;
path = os_strchr(cmd, ' ');
if (path == NULL)
@ -766,11 +766,7 @@ static int wpa_supplicant_ctrl_iface_wps_oob(struct wpa_supplicant *wpa_s,
return -1;
*method++ = '\0';
name = os_strchr(method, ' ');
if (name != NULL)
*name++ = '\0';
return wpas_wps_start_oob(wpa_s, cmd, path, method, name);
return wpas_wps_start_oob(wpa_s, cmd, path, method);
}
#endif /* CONFIG_WPS_OOB */

View file

@ -739,15 +739,13 @@ static int wpa_cli_cmd_wps_cancel(struct wpa_ctrl *ctrl, int argc,
#ifdef CONFIG_WPS_OOB
static int wpa_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc, char *argv[])
{
if (argc != 3 && argc != 4) {
printf("Invalid WPS_OOB command: need three or four "
if (argc != 3) {
printf("Invalid WPS_OOB command: need three "
"arguments:\n"
"- DEV_TYPE: use 'ufd' or 'nfc'\n"
"- DEV_TYPE: use 'ufd'\n"
"- PATH: path of OOB device like '/mnt'\n"
"- METHOD: OOB method 'pin-e' or 'pin-r', "
"'cred'\n"
"- DEV_NAME: (only for NFC) device name like "
"'pn531'\n");
"'cred'\n");
return -1;
}
@ -2490,7 +2488,7 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
#ifdef CONFIG_WPS_OOB
{ "wps_oob", wpa_cli_cmd_wps_oob, NULL,
cli_cmd_flag_sensitive,
"<DEV_TYPE> <PATH> <METHOD> [DEV_NAME] = start WPS OOB" },
"<DEV_TYPE> <PATH> <METHOD> = start WPS OOB" },
#endif /* CONFIG_WPS_OOB */
#ifdef CONFIG_WPS_NFC
{ "wps_nfc", wpa_cli_cmd_wps_nfc, wpa_cli_complete_bss,

View file

@ -996,7 +996,7 @@ int wpas_wps_cancel(struct wpa_supplicant *wpa_s)
#ifdef CONFIG_WPS_OOB
int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type,
char *path, char *method, char *name)
char *path, char *method)
{
struct wps_context *wps = wpa_s->wps;
struct oob_device_data *oob_dev;
@ -1005,7 +1005,6 @@ int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type,
if (oob_dev == NULL)
return -1;
oob_dev->device_path = path;
oob_dev->device_name = name;
wps->oob_conf.oob_method = wps_get_oob_method(method);
if (wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E) {

View file

@ -36,7 +36,7 @@ int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
const char *pin, int p2p_group, u16 dev_pw_id);
int wpas_wps_cancel(struct wpa_supplicant *wpa_s);
int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type,
char *path, char *method, char *name);
char *path, char *method);
int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
const char *pin, struct wps_new_ap_settings *settings);
int wpas_wps_ssid_bss_match(struct wpa_supplicant *wpa_s,