Merge remote-tracking branch 'origin/master' into ieee802154

This commit is contained in:
Gregory Nutt 2017-03-13 10:37:03 -06:00
commit 8514df95f0
16 changed files with 353 additions and 107 deletions

View File

@ -700,6 +700,7 @@ CONFIG_NET_ETHERNET=y
#
# Network Device Operations
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
#
@ -998,7 +999,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NETTEST is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set

View File

@ -702,6 +702,7 @@ CONFIG_NET_ETHERNET=y
#
# Network Device Operations
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
#
@ -1008,7 +1009,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NETTEST is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set

View File

@ -684,6 +684,7 @@ CONFIG_NET_ETHERNET=y
#
# Network Device Operations
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
#
@ -1011,7 +1012,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NETTEST is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set

View File

@ -712,6 +712,7 @@ CONFIG_NET_ETHERNET=y
#
# Network Device Operations
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
#
@ -1040,7 +1041,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NETTEST is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set

View File

@ -793,6 +793,7 @@ CONFIG_NET_ETHERNET=y
#
# Network Device Operations
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
#
@ -1121,7 +1122,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NETTEST is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set

View File

@ -796,6 +796,7 @@ CONFIG_NET_ETHERNET=y
#
# Network Device Operations
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
#
@ -1125,7 +1126,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NETTEST is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set

View File

@ -797,6 +797,7 @@ CONFIG_NET_ETHERNET=y
#
# Network Device Operations
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
#
@ -1216,7 +1217,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NETTEST is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set

View File

@ -800,6 +800,7 @@ CONFIG_NET_ETHERNET=y
#
# Network Device Operations
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
#
@ -1258,7 +1259,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NETTEST is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
# CONFIG_EXAMPLES_NSH is not set
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set

View File

@ -988,6 +988,7 @@ CONFIG_NET_ETHERNET=y
#
# Network Device Operations
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
#
@ -1329,7 +1330,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NETTEST is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
# CONFIG_EXAMPLES_NULL is not set

View File

@ -661,6 +661,7 @@ CONFIG_NET_ETHERNET=y
#
# Network Device Operations
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
#
@ -957,7 +958,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NETTEST is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set

View File

@ -663,6 +663,7 @@ CONFIG_NET_ETHERNET=y
#
# Network Device Operations
#
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
#
@ -969,7 +970,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
# CONFIG_EXAMPLES_NETTEST is not set
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set

View File

@ -109,84 +109,22 @@
#define SIOCADDRT _SIOC(0x001f) /* Add an entry to the routing table */
#define SIOCDELRT _SIOC(0x0020) /* Delete an entry from the routing table */
/* Wireless ioctl commands **************************************************/
/* Not currently used */
#define SIOCSIWCOMMIT _SIOC(0x0021) /* Commit pending changes to driver */
#define SIOCGIWNAME _SIOC(0x0022) /* Get name of wireless protocol */
#define SIOCSIWNWID _SIOC(0x0023) /* Set network ID (pre-802.11) */
#define SIOCGIWNWID _SIOC(0x0024) /* Get network ID (the cell) */
#define SIOCSIWFREQ _SIOC(0x0025) /* Set channel/frequency (Hz) */
#define SIOCGIWFREQ _SIOC(0x0026) /* Get channel/frequency (Hz) */
#define SIOCSIWMODE _SIOC(0x0027) /* Set operation mode */
#define SIOCGIWMODE _SIOC(0x0028) /* Get operation mode */
#define SIOCSIWSENS _SIOC(0x0029) /* Set sensitivity (dBm) */
#define SIOCGIWSENS _SIOC(0x002a) /* Get sensitivity (dBm) */
#define SIOCGIWRANGE _SIOC(0x002b) /* Get range of parameters */
#define SIOCGIWPRIV _SIOC(0x002c) /* Get private ioctl interface info */
#define SIOCGIWSTATS _SIOC(0x002d) /* Get wireless stats */
#define SIOCSIWSPY _SIOC(0x002e) /* Set spy addresses */
#define SIOCGIWSPY _SIOC(0x002f) /* Get spy info (quality of link) */
#define SIOCSIWTHRSPY _SIOC(0x0030) /* Set spy threshold (spy event) */
#define SIOCGIWTHRSPY _SIOC(0x0031) /* Get spy threshold */
#define SIOCSIWAP _SIOC(0x0032) /* Set access point MAC addresses */
#define SIOCGIWAP _SIOC(0x0033) /* Get access point MAC addresses */
#define SIOCGIWAPLIST _SIOC(0x0034) /* Deprecated in favor of scanning */
#define SIOCSIWSCAN _SIOC(0x0035) /* Trigger scanning (list cells) */
#define SIOCGIWSCAN _SIOC(0x0036) /* Get scanning results */
#define SIOCSIWESSID _SIOC(0x0037) /* Set ESSID (network name) */
#define SIOCGIWESSID _SIOC(0x0038) /* Get ESSID */
#define SIOCSIWNICKN _SIOC(0x0039) /* Set node name/nickname */
#define SIOCGIWNICKN _SIOC(0x003a) /* Get node name/nickname */
#define SIOCSIWRATE _SIOC(0x003b) /* Set default bit rate (bps) */
#define SIOCGIWRATE _SIOC(0x003c) /* Get default bit rate (bps) */
#define SIOCSIWRTS _SIOC(0x003d) /* Set RTS/CTS threshold (bytes) */
#define SIOCGIWRTS _SIOC(0x003e) /* Get RTS/CTS threshold (bytes) */
#define SIOCSIWFRAG _SIOC(0x003f) /* Set fragmentation thr (bytes) */
#define SIOCGIWFRAG _SIOC(0x0040) /* Get fragmentation thr (bytes) */
#define SIOCSIWTXPOW _SIOC(0x0041) /* Set transmit power (dBm) */
#define SIOCGIWTXPOW _SIOC(0x0042) /* Get transmit power (dBm) */
#define SIOCSIWRETRY _SIOC(0x0043) /* Set retry limits and lifetime */
#define SIOCGIWRETRY _SIOC(0x0044) /* Get retry limits and lifetime */
#define SIOCSIWPOWER _SIOC(0x0045) /* Set Power Management settings */
#define SIOCGIWPOWER _SIOC(0x0046) /* Get Power Management settings */
#define SIOCSIWGENIE _SIOC(0x0047) /* Set generic IE */
#define SIOCGIWGENIE _SIOC(0x0048) /* Get generic IE */
#define SIOCSIWMLME _SIOC(0x0049) /* Request MLME operation */
#define SIOCSIWAUTH _SIOC(0x004a) /* Set authentication mode params */
#define SIOCGIWAUTH _SIOC(0x004b) /* Get authentication mode params */
#define SIOCSIWENCODEEXT _SIOC(0x004c) /* Set encoding token & mode */
#define SIOCGIWENCODEEXT _SIOC(0x004d) /* Get encoding token & mode */
#define SIOCSIWPMKSA _SIOC(0x004e) /* PMKSA cache operation */
/* MDIO/MCD *****************************************************************/
#define SIOCMIINOTIFY _SIOC(0x004f) /* Receive notificaion via signal on
#define SIOCMIINOTIFY _SIOC(0x0021) /* Receive notificaion via signal on
* PHY state change */
#define SIOCGMIIPHY _SIOC(0x0050) /* Get address of MII PHY in use */
#define SIOCGMIIREG _SIOC(0x0051) /* Get a MII register via MDIO */
#define SIOCSMIIREG _SIOC(0x0052) /* Set a MII register via MDIO */
#define SIOCGMIIPHY _SIOC(0x0022) /* Get address of MII PHY in use */
#define SIOCGMIIREG _SIOC(0x0023) /* Get a MII register via MDIO */
#define SIOCSMIIREG _SIOC(0x0024) /* Set a MII register via MDIO */
/* Unix domain sockets ******************************************************/
#define SIOCINQ _SIOC(0x0053) /* Returns the amount of queued unread
#define SIOCINQ _SIOC(0x0025) /* Returns the amount of queued unread
* data in the receive */
/* Telnet driver ************************************************************/
#define SIOCTELNET _SIOC(0x0054) /* Create a Telnet sessions.
#define SIOCTELNET _SIOC(0x0026) /* Create a Telnet sessions.
* See include/nuttx/net/telnet.h */
/****************************************************************************

View File

@ -330,7 +330,7 @@ struct net_driver_s
int (*d_addmac)(FAR struct net_driver_s *dev, FAR const uint8_t *mac);
int (*d_rmmac)(FAR struct net_driver_s *dev, FAR const uint8_t *mac);
#endif
#ifdef CONFIG_NETDEV_PHY_IOCTL
#ifdef CONFIG_NETDEV_IOCTL
int (*d_ioctl)(FAR struct net_driver_s *dev, int cmd, long arg);
#endif

View File

@ -45,6 +45,11 @@
************************************************************************************/
#include <nuttx/config.h>
#include <sys/socket.h>
#include <stdint.h>
#include <net/if.h>
#include <nuttx/fs/ioctl.h>
#ifdef CONFIG_DRIVERS_WIRELESS
@ -53,18 +58,115 @@
* Pre-processor Definitions
************************************************************************************/
/* IOCTL Commands *******************************************************************/
/* Common wireless IOCTL commands */
/* Network Driver IOCTL Commands ****************************************************/
/* Wireless identification */
#define WLIOC_SETRADIOFREQ _WLIOC(0x0001) /* arg: Pointer to uint32_t, frequency value (in Mhz) */
#define WLIOC_GETRADIOFREQ _WLIOC(0x0002) /* arg: Pointer to uint32_t, frequency value (in Mhz) */
#define WLIOC_SETADDR _WLIOC(0x0003) /* arg: Pointer to address value, format of the address is driver specific */
#define WLIOC_GETADDR _WLIOC(0x0004) /* arg: Pointer to address value, format of the address is driver specific */
#define WLIOC_SETTXPOWER _WLIOC(0x0005) /* arg: Pointer to int32_t, output power (in dBm) */
#define WLIOC_GETTXPOWER _WLIOC(0x0006) /* arg: Pointer to int32_t, output power (in dBm) */
#define SIOCSIWCOMMIT _WLIOC(0x0001) /* Commit pending changes to driver */
#define SIOCGIWNAME _WLIOC(0x0002) /* Get name of wireless protocol */
#define WL_FIRST 0x0001 /* First common command */
#define WL_NCMDS 6 /* Six common commands */
/* Basic Operations */
#define SIOCSIWNWID _WLIOC(0x0003) /* Set network ID (pre-802.11) */
#define SIOCGIWNWID _WLIOC(0x0004) /* Get network ID (the cell) */
#define SIOCSIWFREQ _WLIOC(0x0005) /* Set channel/frequency (Hz) */
#define SIOCGIWFREQ _WLIOC(0x0006) /* Get channel/frequency (Hz) */
#define SIOCSIWMODE _WLIOC(0x0007) /* Set operation mode */
#define SIOCGIWMODE _WLIOC(0x0008) /* Get operation mode */
#define SIOCSIWSENS _WLIOC(0x0009) /* Set sensitivity (dBm) */
#define SIOCGIWSENS _WLIOC(0x000a) /* Get sensitivity (dBm) */
/* Informational */
#define SIOCGIWRANGE _WLIOC(0x000b) /* Get range of parameters */
#define SIOCGIWPRIV _WLIOC(0x000c) /* Get private ioctl interface info */
#define SIOCGIWRANGE _WLIOC(0x000d) /* Get range of parameters */
#define SIOCGIWPRIV _WLIOC(0x000e) /* Get private ioctl interface info */
#define SIOCGIWSTATS _WLIOC(0x000f) /* Get wireless stats */
/* Spy support (statistics per MAC address - used for Mobile IP support) */
#define SIOCSIWSPY _WLIOC(0x0010) /* Set spy addresses */
#define SIOCGIWSPY _WLIOC(0x0011) /* Get spy info (quality of link) */
#define SIOCSIWTHRSPY _WLIOC(0x0012) /* Set spy threshold (spy event) */
#define SIOCGIWTHRSPY _WLIOC(0x0013) /* Get spy threshold */
/* Access point manipulation */
#define SIOCSIWAP _WLIOC(0x0014) /* Set access point MAC addresses */
#define SIOCGIWAP _WLIOC(0x0015) /* Get access point MAC addresses */
#define SIOCGIWAPLIST _WLIOC(0x0016) /* Deprecated in favor of scanning */
#define SIOCSIWSCAN _WLIOC(0x0017) /* Trigger scanning (list cells) */
#define SIOCGIWSCAN _WLIOC(0x0018) /* Get scanning results */
/* 802.11 specific support */
#define SIOCSIWESSID _WLIOC(0x0019) /* Set ESSID (network name) */
#define SIOCGIWESSID _WLIOC(0x001a) /* Get ESSID */
#define SIOCSIWNICKN _WLIOC(0x001b) /* Set node name/nickname */
#define SIOCGIWNICKN _WLIOC(0x001c) /* Get node name/nickname */
#define SIOCSIWRATE _WLIOC(0x001d) /* Set default bit rate (bps) */
#define SIOCGIWRATE _WLIOC(0x001e) /* Get default bit rate (bps) */
#define SIOCSIWRTS _WLIOC(0x001f) /* Set RTS/CTS threshold (bytes) */
#define SIOCGIWRTS _WLIOC(0x0010) /* Get RTS/CTS threshold (bytes) */
#define SIOCSIWFRAG _WLIOC(0x0011) /* Set fragmentation thr (bytes) */
#define SIOCGIWFRAG _WLIOC(0x0022) /* Get fragmentation thr (bytes) */
#define SIOCSIWTXPOW _WLIOC(0x0023) /* Set transmit power (dBm) */
#define SIOCGIWTXPOW _WLIOC(0x0024) /* Get transmit power (dBm) */
#define SIOCSIWRETRY _WLIOC(0x0025) /* Set retry limits and lifetime */
#define SIOCGIWRETRY _WLIOC(0x0026) /* Get retry limits and lifetime */
/* Encoding */
#define SIOCSIWENCODE _WLIOC(0x0027) /* Set encoding token & mode */
#define SIOCGIWENCODE _WLIOC(0x0028) /* Get encoding token & mode */
/* Power saving */
#define SIOCSIWPOWER _WLIOC(0x0029) /* Set Power Management settings */
#define SIOCGIWPOWER _WLIOC(0x002a) /* Get Power Management settings */
/* WPA : Generic IEEE 802.11 information element */
#define SIOCSIWGENIE _WLIOC(0x002b) /* Set generic IE */
#define SIOCGIWGENIE _WLIOC(0x002c) /* Get generic IE */
/* WPA : IEEE 802.11 MLME requests */
#define SIOCSIWMLME _WLIOC(0x002d) /* Request MLME operation */
/* WPA : Authentication mode parameters */
#define SIOCSIWAUTH _WLIOC(0x002e) /* Set authentication mode params */
#define SIOCGIWAUTH _WLIOC(0x002f) /* Get authentication mode params */
/* WPA : Extended version of encoding configuration */
#define SIOCSIWENCODEEXT _WLIOC(0x0030) /* Set encoding token & mode */
#define SIOCGIWENCODEEXT _WLIOC(0x0031) /* Get encoding token & mode */
/* WPA2 : PMKSA cache management */
#define SIOCSIWPMKSA _WLIOC(0x0032) /* PMKSA cache operation */
#define WL_NNETCMDS 0x0032
/* Character Driver IOCTL commands *************************************************/
/* Non-compatible, NuttX only IOCTL definitions for use with low-level wireless
* drivers that are accessed via a character device.
*/
#define WLIOC_SETRADIOFREQ _WLIOC(0x0033) /* arg: Pointer to uint32_t, frequency value (in Mhz) */
#define WLIOC_GETRADIOFREQ _WLIOC(0x0034) /* arg: Pointer to uint32_t, frequency value (in Mhz) */
#define WLIOC_SETADDR _WLIOC(0x0035) /* arg: Pointer to address value, format of the address is driver specific */
#define WLIOC_GETADDR _WLIOC(0x0036) /* arg: Pointer to address value, format of the address is driver specific */
#define WLIOC_SETTXPOWER _WLIOC(0x0037) /* arg: Pointer to int32_t, output power (in dBm) */
#define WLIOC_GETTXPOWER _WLIOC(0x0038) /* arg: Pointer to int32_t, output power (in dBm) */
/* Device-specific IOCTL commands **************************************************/
#define WL_FIRST 0x0001 /* First common command */
#define WL_NCMDS 0x0038 /* Number of common commands */
/* User defined ioctl commands are also supported. These will be forwarded
* by the upper-half QE driver to the lower-half QE driver via the ioctl()
@ -75,13 +177,120 @@
/* See include/nuttx/wireless/cc3000.h */
#define CC3000_FIRST (WL_FIRST + WL_NCMDS)
#define CC3000_NCMDS 7
#define CC3000_FIRST (WL_FIRST + WL_NCMDS)
#define CC3000_NCMDS 7
/* See include/nuttx/wireless/nrf24l01.h */
#define NRF24L01_FIRST (CC3000_FIRST + CC3000_NCMDS)
#define NRF24L01_NCMDS 14
#define NRF24L01_FIRST (CC3000_FIRST + CC3000_NCMDS)
#define NRF24L01_NCMDS 14
/* Other Definitions ****************************************************************/
/* Maximum size of the ESSID and NICKN strings */
#define IW_ESSID_MAX_SIZE 32
/************************************************************************************
* Public Types
************************************************************************************/
/* TODO:
* - Add types for statistics (struct iw_statistics and related)
* - Add struct iw_range for use with IOCTL commands that need exchange mode data
* that could not fit in iwreq.
* - Private IOCTL data support (struct iw_priv_arg)
* - Quality
* - WPA support.
* - Wireless events.
* - Various flag definitions.
*/
/* Generic format for most parameters that fit in a int32_t */
struct iw_param
{
int32_t value; /* The value of the parameter itself */
uint8_t fixed; /* Hardware should not use auto select */
uint8_t disabled; /* Disable the feature */
uint16_t flags; /* Optional flags */
};
/* Large data reference. For all data larger than 16 octets, we need to use a
* pointer to memory allocated in user space.
*/
struct iw_point
{
FAR void *pointer; /* Pointer to the data (in user space) */
uint16_t length; /* number of fields or size in bytes */
uint16_t flags; /* Optional flags */
};
/* For numbers lower than 10^9, we encode the number in 'm' and set 'e' to 0
* For number greater than 10^9, we divide it by the lowest power of 10 to
* get 'm' lower than 10^9, with 'm'= f / (10^'e')...
* The power of 10 is in 'e', the result of the division is in 'm'.
*/
struct iw_freq
{
int32_t m; /* Mantissa */
int16_t e; /* Exponent */
uint8_t i; /* List index (when in range struct) */
uint8_t flags; /* Flags (fixed/auto) */
};
/* Quality of the link */
struct iw_quality
{
uint8_t qual; /* link quality (%retries, SNR,
* %missed beacons or better...) */
uint8_t level; /* signal level (dBm) */
uint8_t noise; /* noise level (dBm) */
uint8_t updated; /* Flags to know if updated */
};
/* This union defines the data payload of an ioctl, and is used in struct iwreq
* below.
*/
union iwreq_data
{
char name[IFNAMSIZ]; /* Network interface name */
struct iw_point essid; /* Extended network name */
struct iw_param nwid; /* Network id (or domain - the cell) */
struct iw_freq freq; /* frequency or channel :
* 0-1000 = channel
* > 1000 = frequency in Hz */
struct iw_param sens; /* signal level threshold */
struct iw_param bitrate; /* default bit rate */
struct iw_param txpower; /* default transmit power */
struct iw_param rts; /* RTS threshold threshold */
struct iw_param frag; /* Fragmentation threshold */
uint32_t mode; /* Operation mode */
struct iw_param retry; /* Retry limits & lifetime */
struct iw_point encoding; /* Encoding stuff : tokens */
struct iw_param power; /* PM duration/timeout */
struct iw_quality qual; /* Quality part of statistics */
struct sockaddr ap_addr; /* Access point address */
struct sockaddr addr; /* Destination address (hw/mac) */
struct iw_param param; /* Other small parameters */
struct iw_point data; /* Other large parameters */
};
/* This is the structure used to exchange data in wireless IOCTLs. This structure
* is the same as 'struct ifreq', but defined for use with wireless IOCTLs.
*/
struct iwreq
{
char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "eth0" */
union iwreq_data u; /* Data payload */
};
#endif /* CONFIG_DRIVERS_WIRELESS */
#endif /* __INCLUDE_NUTTX_WIRELESS_H */

View File

@ -5,10 +5,23 @@
menu "Network Device Operations"
config NETDEV_IOCTL
bool
default n
config NETDEV_PHY_IOCTL
bool "Enable PHY ioctl()"
default n
select NETDEV_IOCTL
---help---
Enable support for ioctl() commands to access PHY registers"
Enable support for ioctl() commands to access PHY registers
config NETDEV_WIRELESS_IOCTL
bool "Enable Wireless ioctl()"
default n
select NETDEV_IOCTL
depends on DRIVERS_WIRELESS
---help---
Enable support for wireless device ioctl() commands
endmenu # Network Device Operations

View File

@ -60,8 +60,12 @@
#include <nuttx/net/arp.h>
#ifdef CONFIG_NET_IGMP
# include "sys/sockio.h"
# include "nuttx/net/igmp.h"
# include <sys/sockio.h>
# include <nuttx/net/igmp.h>
#endif
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
# include <nuttx/wireless/wireless.h>
#endif
#include "arp/arp.h"
@ -311,6 +315,80 @@ static void ioctl_setipv6addr(FAR net_ipv6addr_t outaddr,
}
#endif
/****************************************************************************
* Name: netdev_wifrdev
*
* Description:
* Verify the struct iwreq and get the Wireless device.
*
* Parameters:
* req - The argument of the ioctl cmd
*
* Return:
* A pointer to the driver structure on success; NULL on failure.
*
****************************************************************************/
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NETDEV_WIRELESS_IOCTL)
static FAR struct net_driver_s *netdev_wifrdev(FAR struct iwreq *req)
{
if (req != NULL)
{
/* Find the network device associated with the device name
* in the request data.
*/
return netdev_findbyname(req->ifrn_name);
}
return NULL;
}
#endif
/****************************************************************************
* Name: netdev_wifrioctl
*
* Description:
* Perform wireless network device specific operations.
*
* Parameters:
* psock Socket structure
* dev Ethernet driver device structure
* cmd The ioctl command
* req The argument of the ioctl cmd
*
* Return:
* >=0 on success (positive non-zero values are cmd-specific)
* Negated errno returned on failure.
*
****************************************************************************/
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NETDEV_WIRELESS_IOCTL)
static int netdev_wifrioctl(FAR struct socket *psock, int cmd,
FAR struct iwreq *req)
{
FAR struct net_driver_s *dev;
int ret = -ENOTTY;
/* Verify that this is a valid wireless network IOCTL command */
if (_WLIOCVALID(cmd) && (unsigned)_IOC_NR(cmd) <= WL_NNETCMDS)
{
/* Get the wireless device associated with the IOCTL command */
dev = netdev_wifrdev(req);
if (dev)
{
/* Just forward the IOCTL to the wireless driver */
ret = dev->d_ioctl(dev, cmd, ((long)(uintptr_t)req));
}
}
return ret;
}
#endif
/****************************************************************************
* Name: netdev_ifrdev
*
@ -327,16 +405,16 @@ static void ioctl_setipv6addr(FAR net_ipv6addr_t outaddr,
static FAR struct net_driver_s *netdev_ifrdev(FAR struct ifreq *req)
{
if (!req)
if (req != NULL)
{
return NULL;
/* Find the network device associated with the device name
* in the request data.
*/
return netdev_findbyname(req->ifr_name);
}
/* Find the network device associated with the device name
* in the request data.
*/
return netdev_findbyname(req->ifr_name);
return NULL;
}
/****************************************************************************
@ -347,7 +425,6 @@ static FAR struct net_driver_s *netdev_ifrdev(FAR struct ifreq *req)
*
* Parameters:
* psock Socket structure
* dev Ethernet driver device structure
* cmd The ioctl command
* req The argument of the ioctl cmd
*
@ -676,7 +753,7 @@ static int netdev_ifrioctl(FAR struct socket *psock, int cmd,
}
break;
#ifdef CONFIG_NETDEV_PHY_IOCTL
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NETDEV_PHY_IOCTL)
#ifdef CONFIG_ARCH_PHY_INTERRUPT
case SIOCMIINOTIFY: /* Set up for PHY event notifications */
{
@ -1079,10 +1156,19 @@ int psock_ioctl(FAR struct socket *psock, int cmd, unsigned long arg)
goto errout;
}
/* Execute the command */
/* Execute the command. First check for a standard network IOCTL command. */
ret = netdev_ifrioctl(psock, cmd, (FAR struct ifreq *)((uintptr_t)arg));
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NETDEV_WIRELESS_IOCTL)
/* Check a wireless network command */
if (ret == -ENOTTY)
{
ret = netdev_wifrioctl(psock, cmd, (FAR struct iwreq *)((uintptr_t)arg));
}
#endif
#ifdef CONFIG_NET_IGMP
/* Check for address filtering commands */