From 390cd3105d35a3ac8bca9b35f0101197a9d8f000 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 26 Feb 2009 22:01:36 +0200 Subject: [PATCH] WPS UFD: Make build conditional on CONFIG_WPS_UFD=y Not all embedded devices have USB interface and it is useful to be able to remove unneeded functionality from the binary. In addition, the current implementation has some UNIX specific calls in it which may make it not compile cleanly on all target systems. --- hostapd/Makefile | 6 +++++- src/wps/wps.c | 8 ++++++-- src/wps/wps_common.c | 2 ++ src/wps/wps_enrollee.c | 6 ++++-- wpa_supplicant/Makefile | 6 +++++- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/hostapd/Makefile b/hostapd/Makefile index c5f12f776..9c44edb1e 100644 --- a/hostapd/Makefile +++ b/hostapd/Makefile @@ -313,12 +313,16 @@ OBJS += ../src/wps/wps_attr_process.o OBJS += ../src/wps/wps_dev_attr.o OBJS += ../src/wps/wps_enrollee.o OBJS += ../src/wps/wps_registrar.o -OBJS += ../src/wps/wps_ufd.o NEED_DH_GROUPS=y NEED_SHA256=y NEED_CRYPTO=y NEED_BASE64=y +ifdef CONFIG_WPS_UFD +CFLAGS += -DCONFIG_WPS_UFD +OBJS += ../src/wps/wps_ufd.o +endif + ifdef CONFIG_WPS_UPNP CFLAGS += -DCONFIG_WPS_UPNP OBJS += ../src/wps/wps_upnp.o diff --git a/src/wps/wps.c b/src/wps/wps.c index d26cb3bc8..79f3512c6 100644 --- a/src/wps/wps.c +++ b/src/wps/wps.c @@ -299,9 +299,13 @@ struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev, if (pbc) methods = WPS_CONFIG_PUSHBUTTON; - else + else { methods = WPS_CONFIG_LABEL | WPS_CONFIG_DISPLAY | - WPS_CONFIG_KEYPAD | WPS_CONFIG_USBA; + WPS_CONFIG_KEYPAD; +#ifdef CONFIG_WPS_UFD + methods |= WPS_CONFIG_USBA; +#endif /* CONFIG_WPS_UFD */ + } if (wps_build_version(ie) || wps_build_req_type(ie, req_type) || diff --git a/src/wps/wps_common.c b/src/wps/wps_common.c index 3e4ec558d..a2c88adea 100644 --- a/src/wps/wps_common.c +++ b/src/wps/wps_common.c @@ -518,8 +518,10 @@ int wps_process_oob(struct wps_context *wps, int registrar) struct oob_device_data * wps_get_oob_device(char *device_type) { +#ifdef CONFIG_WPS_UFD if (os_strstr(device_type, "ufd") != NULL) return &oob_ufd_device_data; +#endif /* CONFIG_WPS_UFD */ return NULL; } diff --git a/src/wps/wps_enrollee.c b/src/wps/wps_enrollee.c index 2c6d40486..3cfc8784c 100644 --- a/src/wps/wps_enrollee.c +++ b/src/wps/wps_enrollee.c @@ -131,8 +131,10 @@ static struct wpabuf * wps_build_m1(struct wps_data *wps) if (msg == NULL) return NULL; - methods = WPS_CONFIG_LABEL | WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD | - WPS_CONFIG_USBA; + methods = WPS_CONFIG_LABEL | WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD; +#ifdef CONFIG_WPS_UFD + methods |= WPS_CONFIG_USBA; +#endif /* CONFIG_WPS_UFD */ if (wps->pbc) methods |= WPS_CONFIG_PUSHBUTTON; diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile index d7f21820a..83252223c 100644 --- a/wpa_supplicant/Makefile +++ b/wpa_supplicant/Makefile @@ -521,13 +521,17 @@ OBJS += ../src/wps/wps_attr_process.o OBJS += ../src/wps/wps_dev_attr.o OBJS += ../src/wps/wps_enrollee.o OBJS += ../src/wps/wps_registrar.o -OBJS += ../src/wps/wps_ufd.o OBJS_h += ../src/eap_server/eap_wsc.o CONFIG_IEEE8021X_EAPOL=y NEED_DH_GROUPS=y NEED_SHA256=y NEED_BASE64=y +ifdef CONFIG_WPS_UFD +CFLAGS += -DCONFIG_WPS_UFD +OBJS += ../src/wps/wps_ufd.o +endif + ifdef CONFIG_WPS_UPNP CFLAGS += -DCONFIG_WPS_UPNP OBJS += ../src/wps/wps_upnp.o