diff --git a/include/wireless/wapi.h b/include/wireless/wapi.h index de46267ae..9e5608c88 100644 --- a/include/wireless/wapi.h +++ b/include/wireless/wapi.h @@ -1,7 +1,7 @@ /**************************************************************************** * apps/include/wireless/wapi.h * - * Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Adapted for Nuttx from WAPI: @@ -9,27 +9,40 @@ * Copyright (c) 2010, Volkan YAZICI * All rights reserved. * + * And includes WPA supplicant logic contributed by: + * + * Author: Simon Piriou + * + * Which was adapted to NuttX from driver_ext.h + * + * Copyright (c) 2003-2005, Jouni Malinen + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * modification, are permitted provided that the following conditions + * are met: * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ @@ -57,41 +70,59 @@ #define WAPI_PROC_LINE_SIZE 1024 +/* Select options to successfully open a socket in this nework configuration. */ +/* The address family that we used to create the socket really does not + * matter. It should, however, be valid in the current configuration. + */ + +#if defined(CONFIG_NET_IPv4) +# define PF_INETX PF_INET +#elif defined(CONFIG_NET_IPv6) +# define PF_INETX PF_INET6 +#endif + +/* SOCK_DGRAM is the preferred socket type to use when we just want a + * socket for performing driver ioctls. However, we can't use SOCK_DRAM + * if UDP is disabled. + */ + +#ifdef CONFIG_NET_UDP +# define SOCK_WAPI SOCK_DGRAM +#else +# define SOCK_WAPI SOCK_STREAM +#endif + /**************************************************************************** * Public Types ****************************************************************************/ -/* Generic linked list (dummy) decleration. (No definition!) */ - -typedef struct wapi_list_t wapi_list_t; - /* Frequency flags. */ -typedef enum +enum wapi_freq_flag_e { WAPI_FREQ_AUTO = IW_FREQ_AUTO, WAPI_FREQ_FIXED = IW_FREQ_FIXED -} wapi_freq_flag_t; +}; /* Route target types. */ -typedef enum +enum wapi_route_target_e { WAPI_ROUTE_TARGET_NET, /* The target is a network. */ WAPI_ROUTE_TARGET_HOST /* The target is a host. */ -} wapi_route_target_t; +}; /* ESSID flags. */ -typedef enum +enum wapi_essid_flag_e { WAPI_ESSID_ON, WAPI_ESSID_OFF -} wapi_essid_flag_t; +}; /* Supported operation modes. */ -typedef enum +enum wapi_mode_e { WAPI_MODE_AUTO = IW_MODE_AUTO, /* Driver decides. */ WAPI_MODE_ADHOC = IW_MODE_ADHOC, /* Single cell network. */ @@ -101,7 +132,7 @@ typedef enum WAPI_MODE_SECOND = IW_MODE_SECOND, /* Secondary master/repeater, backup. */ WAPI_MODE_MONITOR = IW_MODE_MONITOR, /* Passive monitor, listen only. */ WAPI_MODE_MESH = IW_MODE_MESH /* Mesh (IEEE 802.11s) network */ -} wapi_mode_t; +}; /* Bitrate flags. * @@ -109,51 +140,51 @@ typedef enum * (IW_BITRATE_BROADCAST) bitrate flags are not supported. */ -typedef enum +enum wapi_bitrate_flag_e { WAPI_BITRATE_AUTO, WAPI_BITRATE_FIXED -} wapi_bitrate_flag_t; +}; /* Transmit power (txpower) flags. */ -typedef enum +enum wapi_txpower_flag_e { WAPI_TXPOWER_DBM, /* Value is in dBm. */ WAPI_TXPOWER_MWATT, /* Value is in mW. */ WAPI_TXPOWER_RELATIVE /* Value is in arbitrary units. */ -} wapi_txpower_flag_t; +}; /* Linked list container for strings. */ -typedef struct wapi_string_t +struct wapi_string_s { - FAR struct wapi_string_t *next; + FAR struct wapi_string_s *next; FAR char *data; -} wapi_string_t; +}; /* Linked list container for scan results. */ -typedef struct wapi_scan_info_t +struct wapi_scan_info_s { - FAR struct wapi_scan_info_t *next; + FAR struct wapi_scan_info_s *next; struct ether_addr ap; int has_essid; char essid[WAPI_ESSID_MAX_SIZE + 1]; - wapi_essid_flag_t essid_flag; + enum wapi_essid_flag_e essid_flag; int has_freq; double freq; int has_mode; - wapi_mode_t mode; + enum wapi_mode_e mode; int has_bitrate; int bitrate; -} wapi_scan_info_t; +}; /* Linked list container for routing table rows. */ -typedef struct wapi_route_info_t +struct wapi_route_info_s { - FAR struct wapi_route_info_t *next; + FAR struct wapi_route_info_s *next; FAR char *ifname; struct in_addr dest; struct in_addr gw; @@ -166,22 +197,63 @@ typedef struct wapi_route_info_t unsigned int mtu; unsigned int window; unsigned int irtt; -} wapi_route_info_t; +}; -/* A generic linked list container. For functions taking wapi_list_t type of - * argument, caller is resposible for releasing allocated memory. +/* A generic linked list container. For functions taking struct wapi_list_s + * type of argument, caller is resposible for releasing allocated memory. */ -struct wapi_list_t +struct wapi_list_s { union wapi_list_head_t { - FAR wapi_string_t *string; - FAR wapi_scan_info_t *scan; - FAR wapi_route_info_t *route; + FAR struct wapi_string_s *string; + FAR struct wapi_scan_info_s *scan; + FAR struct wapi_route_info_s *route; } head; }; +/* WPA **********************************************************************/ + +enum wpa_alg_e +{ + WPA_ALG_NONE = 0, + WPA_ALG_WEP, + WPA_ALG_TKIP, + WPA_ALG_CCMP, + WPA_ALG_IGTK, + WPA_ALG_PMK, + WPA_ALG_GCMP, + WPA_ALG_SMS4, + WPA_ALG_KRK, + WPA_ALG_GCMP_256, + WPA_ALG_CCMP_256, + WPA_ALG_BIP_GMAC_128, + WPA_ALG_BIP_GMAC_256, + WPA_ALG_BIP_CMAC_256 +}; + +/* This structure provides the wireless configuration to + * wpa_driver_wext_associate(). + */ + +struct wpa_wconfig_s +{ + uint8_t sta_mode; /* Mode of operation, e.g. IW_MODE_INFRA */ + uint8_t auth_wpa; /* IW_AUTH_WPA_VERSION values, e.g. + * IW_AUTH_WPA_VERSION_WPA2 */ + uint8_t cipher_mode; /* IW_AUTH_PAIRWISE_CIPHER and + * IW_AUTH_GROUP_CIPHER values, e.g., + * IW_AUTH_CIPHER_CCMP */ + uint8_t alg; /* See enum wpa_alg_e above, e.g. + * WPA_ALG_CCMP */ + uint8_t ssidlen; /* Length of the SSID */ + uint8_t phraselen; /* Length of the passphrase */ + FAR const char *ifname; /* E.g., "wlan0" */ + FAR const uint8_t *ssid; /* E.g., "myApSSID" */ + FAR const uint8_t *passphrase; /* E.g., "mySSIDpassphrase" */ +}; + /**************************************************************************** * Public Data ****************************************************************************/ @@ -229,7 +301,7 @@ EXTERN FAR const char *g_wapi_txpower_flags[]; * ****************************************************************************/ -int wapi_get_ifup(int sock, const char *ifname, int *is_up); +int wapi_get_ifup(int sock, FAR const char *ifname, FAR int *is_up); /**************************************************************************** * Name: wapi_set_ifup @@ -239,7 +311,7 @@ int wapi_get_ifup(int sock, const char *ifname, int *is_up); * ****************************************************************************/ -int wapi_set_ifup(int sock, const char *ifname); +int wapi_set_ifup(int sock, FAR const char *ifname); /**************************************************************************** * Name: wapi_set_ifdown @@ -249,7 +321,7 @@ int wapi_set_ifup(int sock, const char *ifname); * ****************************************************************************/ -int wapi_set_ifdown(int sock, const char *ifname); +int wapi_set_ifdown(int sock, FAR const char *ifname); /**************************************************************************** * Name: wapi_get_ip @@ -259,7 +331,7 @@ int wapi_set_ifdown(int sock, const char *ifname); * ****************************************************************************/ -int wapi_get_ip(int sock, const char *ifname, struct in_addr *addr); +int wapi_get_ip(int sock, FAR const char *ifname, struct in_addr *addr); /**************************************************************************** * Name: wapi_set_ip @@ -269,7 +341,8 @@ int wapi_get_ip(int sock, const char *ifname, struct in_addr *addr); * ****************************************************************************/ -int wapi_set_ip(int sock, const char *ifname, const struct in_addr *addr); +int wapi_set_ip(int sock, FAR const char *ifname, + FAR const struct in_addr *addr); /**************************************************************************** * Name: wapi_get_netmask @@ -279,7 +352,8 @@ int wapi_set_ip(int sock, const char *ifname, const struct in_addr *addr); * ****************************************************************************/ -int wapi_get_netmask(int sock, const char *ifname, struct in_addr *addr); +int wapi_get_netmask(int sock, FAR const char *ifname, + FAR struct in_addr *addr); /**************************************************************************** * Name: wapi_set_netmask @@ -289,7 +363,8 @@ int wapi_get_netmask(int sock, const char *ifname, struct in_addr *addr); * ****************************************************************************/ -int wapi_set_netmask(int sock, const char *ifname, const struct in_addr *addr); +int wapi_set_netmask(int sock, FAR const char *ifname, + FAR const struct in_addr *addr); /**************************************************************************** * Name: wapi_add_route_gw @@ -300,7 +375,7 @@ int wapi_set_netmask(int sock, const char *ifname, const struct in_addr *addr); ****************************************************************************/ #ifdef CONFIG_NET_ROUTE -int wapi_add_route_gw(int sock, wapi_route_target_t targettype, +int wapi_add_route_gw(int sock, enum wapi_route_target_e targettype, FAR const struct in_addr *target, FAR const struct in_addr *netmask, FAR const struct in_addr *gw); @@ -315,7 +390,7 @@ int wapi_add_route_gw(int sock, wapi_route_target_t targettype, ****************************************************************************/ #ifdef CONFIG_NET_ROUTE -int wapi_del_route_gw(int sock, wapi_route_target_t targettype, +int wapi_del_route_gw(int sock, enum wapi_route_target_e targettype, FAR const struct in_addr *target, FAR const struct in_addr *netmask, FAR const struct in_addr *gw); @@ -330,7 +405,7 @@ int wapi_del_route_gw(int sock, wapi_route_target_t targettype, ****************************************************************************/ int wapi_get_freq(int sock, FAR const char *ifname, FAR double *freq, - FAR wapi_freq_flag_t *flag); + FAR enum wapi_freq_flag_e *flag); /**************************************************************************** * Name: wapi_set_freq @@ -341,7 +416,7 @@ int wapi_get_freq(int sock, FAR const char *ifname, FAR double *freq, ****************************************************************************/ int wapi_set_freq(int sock, FAR const char *ifname, double freq, - wapi_freq_flag_t flag); + enum wapi_freq_flag_e flag); /**************************************************************************** * Name: wapi_freq2chan @@ -384,7 +459,7 @@ int wapi_chan2freq(int sock, FAR const char *ifname, int chan, ****************************************************************************/ int wapi_get_essid(int sock, FAR const char *ifname, FAR char *essid, - FAR wapi_essid_flag_t *flag); + FAR enum wapi_essid_flag_e *flag); /**************************************************************************** * Name: wapi_set_essid @@ -397,7 +472,7 @@ int wapi_get_essid(int sock, FAR const char *ifname, FAR char *essid, ****************************************************************************/ int wapi_set_essid(int sock, FAR const char *ifname, FAR const char *essid, - wapi_essid_flag_t flag); + enum wapi_essid_flag_e flag); /**************************************************************************** * Name: wapi_get_mode @@ -407,7 +482,7 @@ int wapi_set_essid(int sock, FAR const char *ifname, FAR const char *essid, * ****************************************************************************/ -int wapi_get_mode(int sock, FAR const char *ifname, FAR wapi_mode_t *mode); +int wapi_get_mode(int sock, FAR const char *ifname, FAR enum wapi_mode_e *mode); /**************************************************************************** * Name: wapi_set_mode @@ -417,7 +492,7 @@ int wapi_get_mode(int sock, FAR const char *ifname, FAR wapi_mode_t *mode); * ****************************************************************************/ -int wapi_set_mode(int sock, FAR const char *ifname, wapi_mode_t mode); +int wapi_set_mode(int sock, FAR const char *ifname, enum wapi_mode_e mode); /**************************************************************************** * Name: wapi_make_broad_ether @@ -473,7 +548,7 @@ int wapi_set_ap(int sock, FAR const char *ifname, ****************************************************************************/ int wapi_get_bitrate(int sock, FAR const char *ifname, - FAR int *bitrate, FAR wapi_bitrate_flag_t *flag); + FAR int *bitrate, FAR enum wapi_bitrate_flag_e *flag); /**************************************************************************** * Name: wapi_set_bitrate @@ -484,7 +559,7 @@ int wapi_get_bitrate(int sock, FAR const char *ifname, ****************************************************************************/ int wapi_set_bitrate(int sock, FAR const char *ifname, int bitrate, - wapi_bitrate_flag_t flag); + enum wapi_bitrate_flag_e flag); /**************************************************************************** * Name: wapi_dbm2mwatt @@ -515,7 +590,7 @@ int wapi_mwatt2dbm(int mwatt); ****************************************************************************/ int wapi_get_txpower(int sock, FAR const char *ifname, FAR int *power, - FAR wapi_txpower_flag_t *flag); + FAR enum wapi_txpower_flag_e *flag); /**************************************************************************** * Name: wapi_set_txpower @@ -526,7 +601,7 @@ int wapi_get_txpower(int sock, FAR const char *ifname, FAR int *power, ****************************************************************************/ int wapi_set_txpower(int sock, FAR const char *ifname, int power, - wapi_txpower_flag_t flag); + enum wapi_txpower_flag_e flag); /**************************************************************************** * Name: wapi_make_socket @@ -550,7 +625,7 @@ int wapi_make_socket(void); * ****************************************************************************/ -int wapi_scan_init(int sock, const char *ifname); +int wapi_scan_init(int sock, FAR const char *ifname); /**************************************************************************** * Name: wapi_scan_stat @@ -572,11 +647,93 @@ int wapi_scan_stat(int sock, FAR const char *ifname); * Collects the results of a scan process. * * Input Parameters: - * aps - Pushes collected wapi_scan_info_t into this list. + * aps - Pushes collected struct wapi_scan_info_s into this list. * ****************************************************************************/ -int wapi_scan_coll(int sock, FAR const char *ifname, FAR wapi_list_t *aps); +int wapi_scan_coll(int sock, FAR const char *ifname, FAR struct wapi_list_s *aps); + +/************************************************************************************ + * Name: wpa_driver_wext_set_ssid + * + * Description: + * Set SSID, SIOCSIWESSID + * + * Input Parameters: + * sockfd - Opened network socket + * ifname - Interface name + * ssid - SSID + * ssid_len - Length of SSID (0..32) + * + * Returned Value: + * 0 on success, -1 on failure + * + ************************************************************************************/ + +int wpa_driver_wext_set_ssid(int sockfd, FAR const char *ifname, + FAR const uint8_t *ssid, size_t ssid_len); + +/************************************************************************************ + * Name: wpa_driver_wext_set_mode + * + * Description: + * Set wireless mode (infra/adhoc), SIOCSIWMODE + * + * Input Parameters: + * sockfd - Opened network socket + * ifname - Interface name + * mode - 0 = infra/BSS (associate with an AP), 1 = adhoc/IBSS + * + * Returned Value: + * 0 on success, -1 on failure + * + ************************************************************************************/ + +int wpa_driver_wext_set_mode(int sockfd, FAR const char *ifname, int mode); + +/************************************************************************************ + * Name: wpa_driver_wext_set_key_ext + * + * Description: + * + * Input Parameters: + * sockfd - Opened network socket + * ifname - Interface name + * + * Returned Value: + * + ************************************************************************************/ + +int wpa_driver_wext_set_key_ext(int sockfd, FAR const char *ifname, enum wpa_alg_e alg, + FAR const uint8_t *key, size_t key_len); + +/************************************************************************************ + * Name: wpa_driver_wext_associate + * + * Description: + * + * Input Parameters: + * wconfig - Describes the wireless configuration. + * + * Returned Value: + * + ************************************************************************************/ + +int wpa_driver_wext_associate(FAR struct wpa_wconfig_s *wconfig); + +/************************************************************************************ + * Name: wpa_driver_wext_set_auth_param + * + * Description: + * + * Input Parameters: + * + * Returned Value: + * + ************************************************************************************/ + +int wpa_driver_wext_set_auth_param(int sockfd, FAR const char *ifname, + int idx, uint32_t value); #undef EXTERN #ifdef __cplusplus diff --git a/nshlib/Kconfig b/nshlib/Kconfig index b402b5ac0..955d601c4 100644 --- a/nshlib/Kconfig +++ b/nshlib/Kconfig @@ -1465,6 +1465,56 @@ config NSH_PANID ---help--- Select the PAN ID to join upon initialization. +menu "WAPI Configuration" + depends on NET && WIRELESS_WAPI + +config NSH_WAPI_STAMODE + int "Wireless mode of operation" + default 2 + range 0 8 + ---help--- + Mode of operation. See the IW_MODE_* definitions in + include/nuttx/wireless/wireless. The default value corresponds to + IW_MODE_INFRA + +config NSH_WAPI_AUTHWPA + hex "IW_AUTH_WPA_VERSION value" + default 0x00000004 + range 0x00000001 0x00000004 + ---help--- + IW_AUTH_WPA_VERSION values. See the IW_AUTH_WPA_VERSION_* definitions + in include/nuttx/wireless/wireless. The default value corresponds to + IW_AUTH_WPA_VERSION_WPA2. NOTE that this is a bit-encoded field. The + only valid values are 0x00000001, 0x00000002, and 0x00000004 + +config NSH_WAPI_CIPHERMODE + hex " IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values" + default 0x00000008 + range 0x00000001 0x00000010 + ---help--- + IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values. See the + IW_AUTH_CIPHER_* definitions in include/nuttx/wireless/wireless. + The default value corresponds to IW_AUTH_CIPHER_CCMP. NOTE that + this is a bit-encoded field. The only valid values are 0x00000001, + 0x00000002,0x00000004, ... 0x00000010 + +config NSH_WAPI_ALG; + int "Algorithm" + default 3 + range 0 13 + ---help--- + Algorithm. See enum wpa_alg_e in apps/include/wireless/wapi.h. The + default corresponds to WPA_ALG_CCMP. + +config NSH_WAPI_SSID + string "SSID" + default "myApSSID" + +config NSH_WAPI_PASSPHRASE + string "Passprhase" + default "mySSIDpassphrase" + +endmenu # WAPI Configuration endif # NSH_NETINIT config NSH_MAX_ROUNDTRIP diff --git a/nshlib/Makefile b/nshlib/Makefile index feeb28298..6490d74ee 100644 --- a/nshlib/Makefile +++ b/nshlib/Makefile @@ -74,6 +74,9 @@ endif ifeq ($(CONFIG_NET),y) CSRCS += nsh_netinit.c nsh_netcmds.c +ifeq ($(CONFIG_WIRELESS_WAPI),y) +CSRCS += nsh_associate.c +endif ifeq ($(CONFIG_NET_ROUTE),y) CSRCS += nsh_routecmds.c endif diff --git a/nshlib/nsh.h b/nshlib/nsh.h index 9ca6b009f..73cfe9ec5 100644 --- a/nshlib/nsh.h +++ b/nshlib/nsh.h @@ -943,9 +943,9 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, FAR char **argv, FAR const char *redirfile, int oflags); #endif +#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON) /* Working directory support */ -#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON) FAR const char *nsh_getcwd(void); FAR char *nsh_getfullpath(FAR struct nsh_vtbl_s *vtbl, FAR const char *relpath); @@ -957,9 +957,15 @@ void nsh_freefullpath(FAR char *fullpath); void nsh_dumpbuffer(FAR struct nsh_vtbl_s *vtbl, const char *msg, const uint8_t *buffer, ssize_t nbytes); -/* USB debug support */ +#ifdef CONFIG_WIRELESS_WAPI +/* Wireless */ + +int nsh_associate(FAR const char *ifname); +#endif #ifdef CONFIG_NSH_USBDEV_TRACE +/* USB debug support */ + void nsh_usbtrace(void); #endif diff --git a/include/wireless/wext.h b/nshlib/nsh_associate.c similarity index 55% rename from include/wireless/wext.h rename to nshlib/nsh_associate.c index e8b65639a..61a0f75a8 100644 --- a/include/wireless/wext.h +++ b/nshlib/nsh_associate.c @@ -1,14 +1,8 @@ /**************************************************************************** - * apps/include/wireless/wapi.h - * WPA Supplicant - wext exported functions + * apps/nshlib/nsh_associate.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. - * Author: Simon Piriou - * Gregory Nutt - * - * Adapted to NuttX from driver_ext.h - * - * Copyright (c) 2003-2005, Jouni Malinen + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -37,68 +31,57 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************************************/ + ****************************************************************************/ -#ifndef __APPS_INCLUDE_WIRELESS_WEXT_H -#define __APPS_INCLUDE_WIRELESS_WEXT_H - -/************************************************************************************ +/**************************************************************************** * Included Files - ************************************************************************************/ + ****************************************************************************/ #include -#include -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ +#include +#include -#ifdef CONFIG_NET_UDP -# define NETLIB_SOCK_IOCTL SOCK_DGRAM -#else -# define NETLIB_SOCK_IOCTL SOCK_STREAM -#endif +#include -#define SSID_MAX_LEN 32 -#define PF_INETX PF_INET +#include "wireless/wapi.h" +#include "nsh.h" -/************************************************************************************ - * Public Types - ************************************************************************************/ +#ifdef CONFIG_WIRELESS_WAPI -enum wpa_alg +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nsh_associate + ****************************************************************************/ + +int nsh_associate(FAR const char *ifname) { - WPA_ALG_NONE, - WPA_ALG_WEP, - WPA_ALG_TKIP, - WPA_ALG_CCMP, - WPA_ALG_IGTK, - WPA_ALG_PMK, - WPA_ALG_GCMP, - WPA_ALG_SMS4, - WPA_ALG_KRK, - WPA_ALG_GCMP_256, - WPA_ALG_CCMP_256, - WPA_ALG_BIP_GMAC_128, - WPA_ALG_BIP_GMAC_256, - WPA_ALG_BIP_CMAC_256 -}; + static const char ssid[] = CONFIG_NSH_WAPI_SSID; + static const char passphrase[] = CONFIG_NSH_WAPI_PASSPHRASE; + struct wpa_wconfig_s wconfig; + int ret; -/************************************************************************************ - * Public Function Prototypes - ************************************************************************************/ + /* Set up the network configuration */ -int wpa_driver_wext_set_ssid(int sockfd, FAR char *ifname, - FAR const uint8_t *ssid, size_t ssid_len); + wconfig.sta_mode = CONFIG_NSH_WAPI_STAMODE; + wconfig.auth_wpa = CONFIG_NSH_WAPI_AUTHWPA; + wconfig.cipher_mode = CONFIG_NSH_WAPI_CIPHERMODE; + wconfig.ifname = ifname; + wconfig.ssid = (FAR const uint8_t *)ssid; + wconfig.passphrase = (FAR const uint8_t *)passphrase; -int wpa_driver_wext_set_mode(int sockfd, FAR char *ifname, int mode); + wconfig.ssidlen = strlen(ssid); + wconfig.phraselen = strlen(passphrase); -int wpa_driver_wext_set_key_ext(int sockfd, FAR char *ifname, enum wpa_alg alg, - FAR const uint8_t *key, size_t key_len); + /* Associate */ -int wpa_driver_wext_associate(void); + sleep(2); + ret = wpa_driver_wext_associate(&wconfig); + sleep(2); + return ret; +} -int wpa_driver_wext_set_auth_param(int sockfd, FAR char *ifname, - int idx, uint32_t value); - -#endif /* __APPS_INCLUDE_WIRELESS_WEXT_H */ +#endif /* CONFIG_WIRELESS_WAPI */ diff --git a/nshlib/nsh_netinit.c b/nshlib/nsh_netinit.c index 71b504eb6..f9a1da2cc 100644 --- a/nshlib/nsh_netinit.c +++ b/nshlib/nsh_netinit.c @@ -80,10 +80,6 @@ # include "netutils/ntpclient.h" #endif -#ifdef CONFIG_WIRELESS_WEXT -# include "wireless/wext.h" -#endif - #include "nsh.h" #ifdef CONFIG_NSH_NETINIT @@ -367,12 +363,10 @@ static void nsh_netinit_configure(void) netlib_getmacaddr(NET_DEVNAME, mac); -#ifdef CONFIG_WIRELESS_WEXT +#ifdef CONFIG_WIRELESS_WAPI /* Associate the wlan */ - sleep(2); - wpa_driver_wext_associate(); - sleep(2); + nsh_associate(NET_DEVNAME); #endif /* Set up the DHCPC modules */ diff --git a/wireless/wapi/src/Make.defs b/wireless/wapi/src/Make.defs index 95100bb1c..cea03125f 100644 --- a/wireless/wapi/src/Make.defs +++ b/wireless/wapi/src/Make.defs @@ -35,7 +35,7 @@ ifeq ($(CONFIG_WIRELESS_WAPI),y) -CSRCS = network.c util.c wireless.c +CSRCS = network.c util.c wireless.c driver_wext.c ifeq ($(CONFIG_WIRELESS_WAPI_CMDTOOL),y) MAINSRC = wapi.c diff --git a/wireless/wext/wext.c b/wireless/wapi/src/driver_wext.c similarity index 76% rename from wireless/wext/wext.c rename to wireless/wapi/src/driver_wext.c index f952369f4..34ccc66c7 100644 --- a/wireless/wext/wext.c +++ b/wireless/wapi/src/driver_wext.c @@ -1,12 +1,13 @@ /************************************************************************************ - * apps/include/graphics/wext.c + * apps/wireless/wapi/src/driver_wext.c * Driver interaction with generic Wireless Extensions * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Simon Piriou * Gregory Nutt * - * Adapted to NuttX from driver_ext.c + * Adapted for NuttX from the driver_ext.c of WPA suplicant written originally + * by Jouni Malinen * * Copyright (c) 2003-2015, Jouni Malinen * @@ -58,53 +59,16 @@ #include #include #include +#include #include -#include "wireless/wext.h" +#include "wireless/wapi.h" /************************************************************************************ * Public Functions ************************************************************************************/ -/************************************************************************************ - * Name: wpa_driver_wext_set_auth_param - * - * Description: - * - * Input Parameters: - * - * Returned Value: - * - ************************************************************************************/ - -int wpa_driver_wext_set_auth_param(int sockfd, FAR char *ifname, int idx, - uint32_t value) -{ - struct iwreq iwr; - int errcode; - int ret = 0; - - memset(&iwr, 0, sizeof(iwr)); - strncpy(iwr.ifr_name, ifname, IFNAMSIZ); - iwr.u.param.flags = idx & IW_AUTH_INDEX; - iwr.u.param.value = value; - - if (ioctl(sockfd, SIOCSIWAUTH, (unsigned long)&iwr) < 0) - { - errcode = errno; - if (errcode != EOPNOTSUPP) - { - nerr("ERROR: SIOCSIWAUTH(param %d value 0x%x) failed: %d)", - idx, value, errcode); - } - - ret = errcode == EOPNOTSUPP ? -2 : -1; - } - - return ret; -} - /************************************************************************************ * Name: wpa_driver_wext_set_ssid * @@ -122,14 +86,16 @@ int wpa_driver_wext_set_auth_param(int sockfd, FAR char *ifname, int idx, * ************************************************************************************/ -int wpa_driver_wext_set_ssid(int sockfd, FAR char *ifname, FAR const uint8_t *ssid, - size_t ssid_len) +int wpa_driver_wext_set_ssid(int sockfd, FAR const char *ifname, + FAR const uint8_t *ssid, size_t ssid_len) { struct iwreq iwr; int ret = 0; char buf[33]; - if (ssid_len > SSID_MAX_LEN) + DEBUGASSERT(ifname != NULL && ssid != NULL && ssid_len > 0); + + if (ssid_len > WAPI_ESSID_MAX_SIZE) { return -1; } @@ -155,6 +121,45 @@ int wpa_driver_wext_set_ssid(int sockfd, FAR char *ifname, FAR const uint8_t *s return ret; } +/************************************************************************************ + * Name: wpa_driver_wext_set_mode + * + * Description: + * Set wireless mode (infra/adhoc), SIOCSIWMODE + * + * Input Parameters: + * sockfd - Opened network socket + * ifname - Interface name + * mode - 0 = infra/BSS (associate with an AP), 1 = adhoc/IBSS + * + * Returned Value: + * 0 on success, -1 on failure + * + ************************************************************************************/ + +int wpa_driver_wext_set_mode(int sockfd, FAR const char *ifname, int mode) +{ + struct iwreq iwr; + int ret = -1; + + DEBUGASSERT(ifname != NULL); + + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, ifname, IFNAMSIZ); + iwr.u.mode = mode; + + if (ioctl(sockfd, SIOCSIWMODE, (unsigned long)&iwr) == 0) + { + ret = 0; + goto done; + } + + nerr("ERROR: ioctl[SIOCSIWMODE]: %d", errno); + +done: + return ret; +} + /************************************************************************************ * Name: wpa_driver_wext_set_key_ext * @@ -168,13 +173,15 @@ int wpa_driver_wext_set_ssid(int sockfd, FAR char *ifname, FAR const uint8_t *s * ************************************************************************************/ -int wpa_driver_wext_set_key_ext(int sockfd, FAR char *ifname, enum wpa_alg alg, +int wpa_driver_wext_set_key_ext(int sockfd, FAR const char *ifname, enum wpa_alg_e alg, FAR const uint8_t *key, size_t key_len) { struct iwreq iwr; int ret = 0; struct iw_encode_ext *ext; + DEBUGASSERT(ifname != NULL && key != NULL && key_len > 0); + ext = malloc(sizeof(*ext) + key_len); if (ext == NULL) { @@ -233,42 +240,29 @@ int wpa_driver_wext_set_key_ext(int sockfd, FAR char *ifname, enum wpa_alg alg, * Description: * * Input Parameters: + * wconfig - Describes the wireless configuration. * * Returned Value: * ************************************************************************************/ -int wpa_driver_wext_associate(void) +int wpa_driver_wext_associate(FAR struct wpa_wconfig_s *wconfig) { - int ret; - int sockfd; struct iwreq req; + int sockfd; + int ret; - int sta_mode = IW_MODE_INFRA; + DEBUGASSERT(wconfig != NULL); - // IW_AUTH_WPA_VERSION_DISABLED - // IW_AUTH_WPA_VERSION_WPA - - int auth_wpa = IW_AUTH_WPA_VERSION_WPA2; - - // IW_AUTH_CIPHER_NONE - // IW_AUTH_CIPHER_WEP40 - // IW_AUTH_CIPHER_TKIP - // IW_AUTH_CIPHER_WEP104 - - int cipher_mode = IW_AUTH_CIPHER_CCMP; - - enum wpa_alg alg = WPA_ALG_CCMP; - - char ifname[] = "wlan0"; - const uint8_t ssid[] = "myApSSID"; - const uint8_t passphrase[] = "mySSIDpassphrase"; - - ninfo("Entry\n"); + ninfo("sta_mode=%u auth_wpa=%08x cipher_mode=%08x\n", + wconfig->sta_mode, wconfig->auth_wpa, wconfig->cipher_mode); + ninfo("ifname=%s ssid[%u]=%s passphrase[%u]=%s\n", + wconfig->ifname, wconfig->ssidlen, wconfig->ssid, wconfig->phraselen, + wconfig->passphrase); /* Get a socket (only so that we get access to the INET subsystem) */ - sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0); + sockfd = socket(PF_INETX, SOCK_WAPI, 0); if (sockfd < 0) { return sockfd; @@ -276,44 +270,47 @@ int wpa_driver_wext_associate(void) /* Put the driver name into the request */ - strncpy(req.ifr_name, ifname, IFNAMSIZ); + strncpy(req.ifr_name, wconfig->ifname, IFNAMSIZ); - if (wpa_driver_wext_set_mode(sockfd, ifname, sta_mode) < 0) + ret = wpa_driver_wext_set_mode(sockfd, wconfig->ifname, wconfig->sta_mode); + if (ret < 0) { - nerr("Fail set sta mode\n"); + nerr("ERROR: Fail set sta mode: %d\n", ret); + goto close_socket; + } + + ret = wpa_driver_wext_set_auth_param(sockfd, wconfig->ifname, + IW_AUTH_WPA_VERSION, + wconfig->auth_wpa); + if (ret < 0) + { + nerr("ERROR: Fail set wpa version: %d\n", ret); + goto close_socket; + } + + ret = wpa_driver_wext_set_auth_param(sockfd, wconfig->ifname, + IW_AUTH_CIPHER_PAIRWISE, + wconfig->cipher_mode); + if (ret < 0) + { + nerr("ERROR: Fail set cipher mode: %d\n", ret); + goto close_socket; + } + + ret = wpa_driver_wext_set_key_ext(sockfd, wconfig->ifname, wconfig->alg, + wconfig->passphrase, wconfig->phraselen); + if (ret < 0) + { + nerr("ERROR: Fail set key: %d\n", ret); ret = -1; goto close_socket; } - if (wpa_driver_wext_set_auth_param(sockfd, ifname, IW_AUTH_WPA_VERSION, - auth_wpa) < 0) + ret = wpa_driver_wext_set_ssid(sockfd, wconfig->ifname, wconfig->ssid, + wconfig->ssidlen); + if (ret < 0) { - nerr("Fail set wpa version\n"); - ret = -1; - goto close_socket; - } - - if (wpa_driver_wext_set_auth_param(sockfd, ifname, - IW_AUTH_CIPHER_PAIRWISE, cipher_mode) < 0) - { - nerr("Fail set cipher mode\n"); - ret = -1; - goto close_socket; - } - - if (wpa_driver_wext_set_key_ext(sockfd, ifname, alg, passphrase, - sizeof(passphrase)-1)) - { - nerr("Fail set key\n"); - ret = -1; - goto close_socket; - } - - if (wpa_driver_wext_set_ssid(sockfd, ifname, ssid, sizeof(ssid)-1) < 0) - { - nerr("Fail set ssid\n"); - ret = -1; - goto close_socket; + nerr("ERROR: Fail set ssid: %d\n", ret); } close_socket: @@ -322,38 +319,42 @@ close_socket: } /************************************************************************************ - * Name: wpa_driver_wext_set_mode + * Name: wpa_driver_wext_set_auth_param * * Description: - * Set wireless mode (infra/adhoc), SIOCSIWMODE * * Input Parameters: - * sockfd - Opened network socket - * ifname - Interface name - * mode - 0 = infra/BSS (associate with an AP), 1 = adhoc/IBSS * * Returned Value: - * 0 on success, -1 on failure * ************************************************************************************/ -int wpa_driver_wext_set_mode(int sockfd, FAR char *ifname, int mode) +int wpa_driver_wext_set_auth_param(int sockfd, FAR const char *ifname, int idx, + uint32_t value) { struct iwreq iwr; - int ret = -1; + int errcode; + int ret = 0; + + DEBUGASSERT(ifname != NULL); memset(&iwr, 0, sizeof(iwr)); strncpy(iwr.ifr_name, ifname, IFNAMSIZ); - iwr.u.mode = mode; + iwr.u.param.flags = idx & IW_AUTH_INDEX; + iwr.u.param.value = value; - if (ioctl(sockfd, SIOCSIWMODE, (unsigned long)&iwr) == 0) + if (ioctl(sockfd, SIOCSIWAUTH, (unsigned long)&iwr) < 0) { - ret = 0; - goto done; + errcode = errno; + if (errcode != EOPNOTSUPP) + { + nerr("ERROR: SIOCSIWAUTH(param %d value 0x%x) failed: %d)", + idx, value, errcode); + } + + ret = errcode == EOPNOTSUPP ? -2 : -1; } - nerr("ERROR: ioctl[SIOCSIWMODE]: %d", errno); - -done: return ret; } + diff --git a/wireless/wapi/src/network.c b/wireless/wapi/src/network.c index bc472b9ff..162164b4d 100644 --- a/wireless/wapi/src/network.c +++ b/wireless/wapi/src/network.c @@ -104,7 +104,7 @@ static int wapi_set_addr(int sock, FAR const char *ifname, int cmd, #ifdef CONFIG_NET_ROUTE static int wapi_act_route_gw(int sock, int act, - wapi_route_target_t targettype, + enum wapi_route_target_e targettype, FAR const struct in_addr *target, FAR const struct in_addr *netmask, FAR const struct in_addr *gw) @@ -325,7 +325,7 @@ int wapi_set_netmask(int sock, FAR const char *ifname, ****************************************************************************/ #ifdef CONFIG_NET_ROUTE -int wapi_add_route_gw(int sock, wapi_route_target_t targettype, +int wapi_add_route_gw(int sock, enum wapi_route_target_e targettype, FAR const struct in_addr *target, FAR const struct in_addr *netmask, FAR const struct in_addr *gw) @@ -343,7 +343,7 @@ int wapi_add_route_gw(int sock, wapi_route_target_t targettype, ****************************************************************************/ #ifdef CONFIG_NET_ROUTE -int wapi_del_route_gw(int sock, wapi_route_target_t targettype, +int wapi_del_route_gw(int sock, enum wapi_route_target_e targettype, FAR const struct in_addr *target, FAR const struct in_addr *netmask, FAR const struct in_addr *gw) diff --git a/wireless/wapi/src/util.c b/wireless/wapi/src/util.c index 28dd7b600..d7b340863 100644 --- a/wireless/wapi/src/util.c +++ b/wireless/wapi/src/util.c @@ -51,27 +51,6 @@ * Pre-processor Definitions ****************************************************************************/ -/* The address family that we used to create the socket really does not - * matter. It should, however, be valid in the current configuration. - */ - -#if defined(CONFIG_NET_IPv4) -# define PF_INETX PF_INET -#elif defined(CONFIG_NET_IPv6) -# define PF_INETX PF_INET6 -#endif - -/* SOCK_DGRAM is the preferred socket type to use when we just want a - * socket for performing driver ioctls. However, we can't use SOCK_DRAM - * if UDP is disabled. - */ - -#ifdef CONFIG_NET_UDP -# define SOCK_WAPI SOCK_DGRAM -#else -# define SOCK_WAPI SOCK_STREAM -#endif - /* Size of the command buffer */ #define WAPI_IOCTL_COMMAND_NAMEBUFSIZ 24 diff --git a/wireless/wapi/src/wapi.c b/wireless/wapi/src/wapi.c index f2065e8b6..2c4308ce6 100644 --- a/wireless/wapi/src/wapi.c +++ b/wireless/wapi/src/wapi.c @@ -227,20 +227,20 @@ static void wapi_show_cmd(int sock, FAR const char *ifname) struct in_addr addr; double freq; - wapi_freq_flag_t freq_flag; + enum wapi_freq_flag_e freq_flag; char essid[WAPI_ESSID_MAX_SIZE + 1]; - wapi_essid_flag_t essid_flag; + enum wapi_essid_flag_e essid_flag; - wapi_mode_t mode; + enum wapi_mode_e mode; struct ether_addr ap; int bitrate; - wapi_bitrate_flag_t bitrate_flag; + enum wapi_bitrate_flag_e bitrate_flag; int txpower; - wapi_txpower_flag_t txpower_flag; + enum wapi_txpower_flag_e txpower_flag; int ret; @@ -450,13 +450,13 @@ static void wapi_freq_cmd(int sock, FAR const char *ifname, FAR const char *freqstr, FAR const char *flagstr) { double frequency; - wapi_freq_flag_t freq_flag; + enum wapi_freq_flag_e freq_flag; int ret; /* Convert input strings to values */ frequency = wapi_str2double(freqstr); - freq_flag = (wapi_freq_flag_t)wapi_str2ndx(flagstr, g_wapi_freq_flags, + freq_flag = (enum wapi_freq_flag_e)wapi_str2ndx(flagstr, g_wapi_freq_flags, IW_FREQ_NFLAGS); /* Set the frequency */ @@ -482,12 +482,12 @@ static void wapi_freq_cmd(int sock, FAR const char *ifname, static void wapi_essid_cmd(int sock, FAR const char *ifname, FAR const char *essid, FAR const char *flagstr) { - wapi_essid_flag_t essid_flag; + enum wapi_essid_flag_e essid_flag; int ret; /* Convert input strings to values */ - essid_flag = (wapi_essid_flag_t)wapi_str2ndx(flagstr, g_wapi_essid_flags, 2); + essid_flag = (enum wapi_essid_flag_e)wapi_str2ndx(flagstr, g_wapi_essid_flags, 2); /* Set the ESSID */ @@ -512,12 +512,12 @@ static void wapi_essid_cmd(int sock, FAR const char *ifname, static void wapi_mode_cmd(int sock, FAR const char *ifname, FAR const char *modestr) { - wapi_mode_t mode; + enum wapi_mode_e mode; int ret; /* Convert input strings to values */ - mode = (wapi_mode_t)wapi_str2ndx(modestr, g_wapi_modes, IW_MODE_NFLAGS); + mode = (enum wapi_mode_e)wapi_str2ndx(modestr, g_wapi_modes, IW_MODE_NFLAGS); /* Set operating mode */ @@ -576,14 +576,14 @@ static void wapi_bitrate_cmd(int sock, FAR const char *ifname, FAR const char *ratestr, FAR const char *flagstr) { - wapi_bitrate_flag_t bitrate_flag; + enum wapi_bitrate_flag_e bitrate_flag; int bitrate; int ret; /* Convert input strings to values */ bitrate = wapi_str2int(ratestr); - bitrate_flag = (wapi_bitrate_flag_t) + bitrate_flag = (enum wapi_bitrate_flag_e) wapi_str2ndx(flagstr, g_wapi_bitrate_flags, 2); /* Set bitrate */ @@ -609,14 +609,14 @@ static void wapi_bitrate_cmd(int sock, FAR const char *ifname, static void wapi_txpower_cmd(int sock, FAR const char *ifname, FAR const char *pwrstr, FAR const char *flagstr) { - wapi_txpower_flag_t txpower_flag; + enum wapi_txpower_flag_e txpower_flag; int txpower; int ret; /* Convert input strings to values */ txpower = wapi_str2int(pwrstr); - txpower_flag = (wapi_txpower_flag_t) + txpower_flag = (enum wapi_txpower_flag_e) wapi_str2ndx(flagstr, g_wapi_txpower_flags, IW_TXPOW_NFLAGS); /* Set txpower */ @@ -643,8 +643,8 @@ static void wapi_scan_cmd(int sock, FAR const char *ifname) { int sleepdur = 1; int sleeptries = 5; - wapi_list_t list; - FAR wapi_scan_info_t *info; + struct wapi_list_s list; + FAR struct wapi_scan_info_s *info; int ret; /* Start scan */ @@ -670,7 +670,7 @@ static void wapi_scan_cmd(int sock, FAR const char *ifname) /* Collect results */ - bzero(&list, sizeof(wapi_list_t)); + bzero(&list, sizeof(struct wapi_list_s)); ret = wapi_scan_coll(sock, ifname, &list); if (ret < 0) { @@ -693,7 +693,7 @@ static void wapi_scan_cmd(int sock, FAR const char *ifname) info = list.head.scan; while (info) { - FAR wapi_scan_info_t *temp; + FAR struct wapi_scan_info_s *temp; temp = info->next; free(info); diff --git a/wireless/wapi/src/wireless.c b/wireless/wapi/src/wireless.c index 2546ed54b..f76cd250b 100644 --- a/wireless/wapi/src/wireless.c +++ b/wireless/wapi/src/wireless.c @@ -161,7 +161,7 @@ static inline void wapi_float2freq(double floatfreq, struct iw_freq *freq) * ****************************************************************************/ -static int wapi_parse_mode(int iw_mode, FAR wapi_mode_t *wapi_mode) +static int wapi_parse_mode(int iw_mode, FAR enum wapi_mode_e *wapi_mode) { switch (iw_mode) { @@ -234,9 +234,9 @@ return -ENOSYS; * ****************************************************************************/ -static int wapi_scan_event(FAR struct iw_event *event, FAR wapi_list_t *list) +static int wapi_scan_event(FAR struct iw_event *event, FAR struct wapi_list_s *list) { - FAR wapi_scan_info_t *info; + FAR struct wapi_scan_info_s *info; /* Get current "wapi_info_t". */ @@ -248,11 +248,11 @@ static int wapi_scan_event(FAR struct iw_event *event, FAR wapi_list_t *list) { case SIOCGIWAP: { - wapi_scan_info_t *temp; + struct wapi_scan_info_s *temp; /* Allocate a new cell. */ - temp = malloc(sizeof(wapi_scan_info_t)); + temp = malloc(sizeof(struct wapi_scan_info_s)); if (!temp) { WAPI_STRERROR("malloc()"); @@ -261,7 +261,7 @@ static int wapi_scan_event(FAR struct iw_event *event, FAR wapi_list_t *list) /* Reset it. */ - bzero(temp, sizeof(wapi_scan_info_t)); + bzero(temp, sizeof(struct wapi_scan_info_s)); /* Save cell identifier. */ @@ -333,7 +333,7 @@ static int wapi_scan_event(FAR struct iw_event *event, FAR wapi_list_t *list) ****************************************************************************/ int wapi_get_freq(int sock, FAR const char *ifname, FAR double *freq, - FAR wapi_freq_flag_t *flag) + FAR enum wapi_freq_flag_e *flag) { struct iwreq wrq; int ret; @@ -384,7 +384,7 @@ int wapi_get_freq(int sock, FAR const char *ifname, FAR double *freq, ****************************************************************************/ int wapi_set_freq(int sock, FAR const char *ifname, double freq, - wapi_freq_flag_t flag) + enum wapi_freq_flag_e flag) { struct iwreq wrq; int ret; @@ -551,7 +551,7 @@ int wapi_chan2freq(int sock, FAR const char *ifname, int chan, ****************************************************************************/ int wapi_get_essid(int sock, FAR const char *ifname, FAR char *essid, - FAR wapi_essid_flag_t *flag) + FAR enum wapi_essid_flag_e *flag) { struct iwreq wrq; int ret; @@ -590,7 +590,7 @@ int wapi_get_essid(int sock, FAR const char *ifname, FAR char *essid, ****************************************************************************/ int wapi_set_essid(int sock, FAR const char *ifname, FAR const char *essid, - wapi_essid_flag_t flag) + enum wapi_essid_flag_e flag) { char buf[WAPI_ESSID_MAX_SIZE + 1]; struct iwreq wrq; @@ -623,7 +623,7 @@ int wapi_set_essid(int sock, FAR const char *ifname, FAR const char *essid, * ****************************************************************************/ -int wapi_get_mode(int sock, FAR const char *ifname, FAR wapi_mode_t *mode) +int wapi_get_mode(int sock, FAR const char *ifname, FAR enum wapi_mode_e *mode) { struct iwreq wrq; int ret; @@ -653,7 +653,7 @@ int wapi_get_mode(int sock, FAR const char *ifname, FAR wapi_mode_t *mode) * ****************************************************************************/ -int wapi_set_mode(int sock, FAR const char *ifname, wapi_mode_t mode) +int wapi_set_mode(int sock, FAR const char *ifname, enum wapi_mode_e mode) { struct iwreq wrq; int ret; @@ -772,7 +772,7 @@ int wapi_set_ap(int sock, FAR const char *ifname, ****************************************************************************/ int wapi_get_bitrate(int sock, FAR const char *ifname, - FAR int *bitrate, FAR wapi_bitrate_flag_t *flag) + FAR int *bitrate, FAR enum wapi_bitrate_flag_e *flag) { struct iwreq wrq; int ret; @@ -815,7 +815,7 @@ int wapi_get_bitrate(int sock, FAR const char *ifname, ****************************************************************************/ int wapi_set_bitrate(int sock, FAR const char *ifname, int bitrate, - wapi_bitrate_flag_t flag) + enum wapi_bitrate_flag_e flag) { struct iwreq wrq; int ret; @@ -870,7 +870,7 @@ int wapi_mwatt2dbm(int mwatt) ****************************************************************************/ int wapi_get_txpower(int sock, FAR const char *ifname, FAR int *power, - FAR wapi_txpower_flag_t *flag) + FAR enum wapi_txpower_flag_e *flag) { struct iwreq wrq; int ret; @@ -931,7 +931,7 @@ int wapi_get_txpower(int sock, FAR const char *ifname, FAR int *power, ****************************************************************************/ int wapi_set_txpower(int sock, FAR const char *ifname, int power, - wapi_txpower_flag_t flag) + enum wapi_txpower_flag_e flag) { struct iwreq wrq; int ret; @@ -1054,11 +1054,11 @@ int wapi_scan_stat(int sock, FAR const char *ifname) * Collects the results of a scan process. * * Input Parameters: - * aps - Pushes collected wapi_scan_info_t into this list. + * aps - Pushes collected struct wapi_scan_info_s into this list. * ****************************************************************************/ -int wapi_scan_coll(int sock, FAR const char *ifname, FAR wapi_list_t *aps) +int wapi_scan_coll(int sock, FAR const char *ifname, FAR struct wapi_list_s *aps) { FAR char *buf; int buflen; diff --git a/wireless/wext/.gitignore b/wireless/wext/.gitignore deleted file mode 100644 index f21c854d1..000000000 --- a/wireless/wext/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/.built -/.depend -/Make.dep -/*.src -/*.obj -/*.lst diff --git a/wireless/wext/Kconfig b/wireless/wext/Kconfig deleted file mode 100644 index 883e87b26..000000000 --- a/wireless/wext/Kconfig +++ /dev/null @@ -1,16 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see the file kconfig-language.txt in the NuttX tools repository. -# - -menuconfig WIRELESS_WEXT - bool "Driver WEXT" - default n - depends on NET && DRIVERS_WIRELESS - ---help--- - The driver_wext logic from the WPA suplicant written originally - by Jouni Malinen - -if WIRELESS_WEXT - -endif diff --git a/wireless/wext/Make.defs b/wireless/wext/Make.defs deleted file mode 100644 index 9c4d9246a..000000000 --- a/wireless/wext/Make.defs +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################ -# apps/wireless/wext/Make.defs -# Adds selected applications to apps/ build -# -# Copyright (C) 2017 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -ifeq ($(CONFIG_WIRELESS_WEXT),y) -CONFIGURED_APPS += wireless/wext -endif - diff --git a/wireless/wext/Makefile b/wireless/wext/Makefile deleted file mode 100644 index c4d1ad051..000000000 --- a/wireless/wext/Makefile +++ /dev/null @@ -1,104 +0,0 @@ -############################################################################ -# apps/wireless/wext/Makefile -# -# Copyright (C) 2017 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# TODO, this makefile should run make under the app dirs, instead of -# sourcing the Make.defs! - --include $(TOPDIR)/.config --include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs - -ASRCS = -CSRCS = wext.c -MAINSRC = - -VPATH = . -DEPPATH = --dep-path . - -AOBJS = $(ASRCS:.S=$(OBJEXT)) -COBJS = $(CSRCS:.c=$(OBJEXT)) -MAINOBJ = $(MAINSRC:.c=$(OBJEXT)) - -SRCS = $(ASRCS) $(CSRCS) $(MAINSRC) -OBJS = $(AOBJS) $(COBJS) - -ifeq ($(CONFIG_WINDOWS_NATIVE),y) - BIN = ..\..\libapps$(LIBEXT) -else -ifeq ($(WINTOOL),y) - BIN = ..\\..\\libapps$(LIBEXT) -else - BIN = ../../libapps$(LIBEXT) -endif -endif - -# Common build - -all: .built -.PHONY: context depend clean distclean - -$(AOBJS): %$(OBJEXT): %.S - $(call ASSEMBLE, $<, $@) - -$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c - $(call COMPILE, $<, $@) - -.built: $(OBJS) - $(call ARCHIVE, $(BIN), $(OBJS)) - $(Q) touch .built - -install: - -context: - -# Create dependencies - -.depend: Makefile $(SRCS) - $(Q) $(MKDEP) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep - $(Q) touch $@ - -depend: .depend - -clean: - $(call DELFILE, .built) - $(call CLEAN) - -distclean: clean - $(call DELFILE, Make.dep) - $(call DELFILE, .depend) - --include Make.dep -.PHONY: preconfig -preconfig: