Move wireless/wext into wireless/wapi/src. Update some naming for better follow the NuttX coding style.

This commit is contained in:
Gregory Nutt 2017-05-06 09:40:09 -06:00
parent 33027bd66e
commit f12d857f0a
11 changed files with 288 additions and 436 deletions

View File

@ -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 <gnutt@nuttx.org>
*
* Adapted for Nuttx from WAPI:
@ -9,27 +9,40 @@
* Copyright (c) 2010, Volkan YAZICI <volkan.yazici@gmail.com>
* All rights reserved.
*
* And includes WPA supplicant logic contributed by:
*
* Author: Simon Piriou <spiriou31@gmail.com>
*
* Which was adapted to NuttX from driver_ext.h
*
* Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
*
* 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,47 @@
#define WAPI_PROC_LINE_SIZE 1024
/* Select options to successfully open a socket in this nework configuration. */
#ifdef CONFIG_NET_UDP
# define NETLIB_SOCK_IOCTL SOCK_DGRAM
#else
# define NETLIB_SOCK_IOCTL SOCK_STREAM
#endif
#define PF_INETX PF_INET
/****************************************************************************
* 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 +120,27 @@ 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;
};
/* WPA **********************************************************************/
enum wpa_alg_e
{
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
};
/* Bitrate flags.
*
@ -109,51 +148,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,19 +205,19 @@ 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;
};
@ -300,7 +339,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 +354,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 +369,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 +380,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 +423,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 +436,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 +446,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 +456,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 +512,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 +523,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 +554,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 +565,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
@ -572,11 +611,92 @@ 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 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 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 char *ifname, enum wpa_alg_e alg,
FAR const uint8_t *key, size_t key_len);
/************************************************************************************
* Name: wpa_driver_wext_associate
*
* Description:
*
* Input Parameters:
*
* Returned Value:
*
************************************************************************************/
int wpa_driver_wext_associate(void);
/************************************************************************************
* 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);
#undef EXTERN
#ifdef __cplusplus

View File

@ -1,104 +0,0 @@
/****************************************************************************
* apps/include/wireless/wapi.h
* WPA Supplicant - wext exported functions
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Simon Piriou <spiriou31@gmail.com>
* Gregory Nutt <gnutt@nuttx.org>
*
* Adapted to NuttX from driver_ext.h
*
* Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
*
* 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.
*
************************************************************************************/
#ifndef __APPS_INCLUDE_WIRELESS_WEXT_H
#define __APPS_INCLUDE_WIRELESS_WEXT_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
#ifdef CONFIG_NET_UDP
# define NETLIB_SOCK_IOCTL SOCK_DGRAM
#else
# define NETLIB_SOCK_IOCTL SOCK_STREAM
#endif
#define SSID_MAX_LEN 32
#define PF_INETX PF_INET
/************************************************************************************
* Public Types
************************************************************************************/
enum wpa_alg
{
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
};
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
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_mode(int sockfd, FAR char *ifname, int mode);
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);
int wpa_driver_wext_associate(void);
int wpa_driver_wext_set_auth_param(int sockfd, FAR char *ifname,
int idx, uint32_t value);
#endif /* __APPS_INCLUDE_WIRELESS_WEXT_H */

View File

@ -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

View File

@ -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 <spiriou31@gmail.com>
* Gregory Nutt <gnutt@nuttx.org>
*
* 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 <j@w1.fi>
*
@ -61,50 +62,12 @@
#include <debug.h>
#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
*
@ -129,7 +92,7 @@ int wpa_driver_wext_set_ssid(int sockfd, FAR char *ifname, FAR const uint8_t *s
int ret = 0;
char buf[33];
if (ssid_len > SSID_MAX_LEN)
if (ssid_len > WAPI_ESSID_MAX_SIZE)
{
return -1;
}
@ -155,6 +118,43 @@ 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 char *ifname, int mode)
{
struct iwreq iwr;
int ret = -1;
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,7 +168,7 @@ 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 char *ifname, enum wpa_alg_e alg,
FAR const uint8_t *key, size_t key_len)
{
struct iwreq iwr;
@ -258,7 +258,7 @@ int wpa_driver_wext_associate(void)
int cipher_mode = IW_AUTH_CIPHER_CCMP;
enum wpa_alg alg = WPA_ALG_CCMP;
enum wpa_alg_e alg = WPA_ALG_CCMP;
char ifname[] = "wlan0";
const uint8_t ssid[] = "myApSSID";
@ -322,38 +322,40 @@ 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 char *ifname, int idx,
uint32_t value)
{
struct iwreq iwr;
int ret = -1;
int errcode;
int ret = 0;
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;
}

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -1,6 +0,0 @@
/.built
/.depend
/Make.dep
/*.src
/*.obj
/*.lst

View File

@ -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

View File

@ -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 <gnutt@nuttx.org>
#
# 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

View File

@ -1,104 +0,0 @@
############################################################################
# apps/wireless/wext/Makefile
#
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# 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: