Run all .c and .h files modified in last PR through nxstyle.
This commit is contained in:
parent
49c997501a
commit
64bc8f5b7f
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* apps/include/wireless/wapi.h
|
* apps/include/wireless/wapi.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2017, 2019 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Adapted for Nuttx from WAPI:
|
* Adapted for Nuttx from WAPI:
|
||||||
@ -70,7 +70,10 @@
|
|||||||
|
|
||||||
#define WAPI_PROC_LINE_SIZE 1024
|
#define WAPI_PROC_LINE_SIZE 1024
|
||||||
|
|
||||||
/* Select options to successfully open a socket in this nework configuration. */
|
/* Select options to successfully open a socket in this network
|
||||||
|
* configuration.
|
||||||
|
*/
|
||||||
|
|
||||||
/* The address family that we used to create the socket really does not
|
/* The address family that we used to create the socket really does not
|
||||||
* matter. It should, however, be valid in the current configuration.
|
* matter. It should, however, be valid in the current configuration.
|
||||||
*/
|
*/
|
||||||
@ -482,7 +485,8 @@ 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 enum wapi_mode_e *mode);
|
int wapi_get_mode(int sock, FAR const char *ifname,
|
||||||
|
FAR enum wapi_mode_e *mode);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: wapi_set_mode
|
* Name: wapi_set_mode
|
||||||
@ -620,8 +624,8 @@ int wapi_make_socket(void);
|
|||||||
* Name: wapi_scan_init
|
* Name: wapi_scan_init
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Starts a scan on the given interface. Root privileges are required to start a
|
* Starts a scan on the given interface. Root privileges are required to
|
||||||
* scan.
|
* start a scan.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -651,9 +655,10 @@ int wapi_scan_stat(int sock, FAR const char *ifname);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int wapi_scan_coll(int sock, FAR const char *ifname, FAR struct wapi_list_s *aps);
|
int wapi_scan_coll(int sock, FAR const char *ifname,
|
||||||
|
FAR struct wapi_list_s *aps);
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: wpa_driver_wext_set_key_ext
|
* Name: wpa_driver_wext_set_key_ext
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -664,12 +669,13 @@ int wapi_scan_coll(int sock, FAR const char *ifname, FAR struct wapi_list_s *aps
|
|||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int wpa_driver_wext_set_key_ext(int sockfd, FAR const char *ifname, enum wpa_alg_e alg,
|
int wpa_driver_wext_set_key_ext(int sockfd, FAR const char *ifname,
|
||||||
FAR const uint8_t *key, size_t key_len);
|
enum wpa_alg_e alg, FAR const uint8_t *key,
|
||||||
|
size_t key_len);
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: wpa_driver_wext_associate
|
* Name: wpa_driver_wext_associate
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -679,11 +685,11 @@ int wpa_driver_wext_set_key_ext(int sockfd, FAR const char *ifname, enum wpa_alg
|
|||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int wpa_driver_wext_associate(FAR struct wpa_wconfig_s *wconfig);
|
int wpa_driver_wext_associate(FAR struct wpa_wconfig_s *wconfig);
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: wpa_driver_wext_set_auth_param
|
* Name: wpa_driver_wext_set_auth_param
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -692,7 +698,7 @@ int wpa_driver_wext_associate(FAR struct wpa_wconfig_s *wconfig);
|
|||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int wpa_driver_wext_set_auth_param(int sockfd, FAR const char *ifname,
|
int wpa_driver_wext_set_auth_param(int sockfd, FAR const char *ifname,
|
||||||
int idx, uint32_t value);
|
int idx, uint32_t value);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* apps/wireless/wapi/src/driver_wext.c
|
* apps/wireless/wapi/src/driver_wext.c
|
||||||
* Driver interaction with generic Wireless Extensions
|
* Driver interaction with generic Wireless Extensions
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2017, 2019 Gregory Nutt. All rights reserved.
|
||||||
* Author: Simon Piriou <spiriou31@gmail.com>
|
* Author: Simon Piriou <spiriou31@gmail.com>
|
||||||
* Gregory Nutt <gnutt@nuttx.org>
|
* Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
@ -38,7 +38,7 @@
|
|||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* This file implements a driver interface for the Linux Wireless Extensions.
|
/* This file implements a driver interface for the Linux Wireless Extensions.
|
||||||
* When used with WE-18 or newer, this interface can be used as-is with number
|
* When used with WE-18 or newer, this interface can be used as-is with number
|
||||||
@ -47,9 +47,9 @@
|
|||||||
* ioctls, but require private ioctls for some of the functionality.
|
* ioctls, but require private ioctls for some of the functionality.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -65,11 +65,11 @@
|
|||||||
|
|
||||||
#include "wireless/wapi.h"
|
#include "wireless/wapi.h"
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: wpa_driver_wext_set_key_ext
|
* Name: wpa_driver_wext_set_key_ext
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -80,10 +80,11 @@
|
|||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int wpa_driver_wext_set_key_ext(int sockfd, FAR const char *ifname, enum wpa_alg_e alg,
|
int wpa_driver_wext_set_key_ext(int sockfd, FAR const char *ifname,
|
||||||
FAR const uint8_t *key, size_t key_len)
|
enum wpa_alg_e alg, FAR const uint8_t *key,
|
||||||
|
size_t key_len)
|
||||||
{
|
{
|
||||||
struct iwreq iwr;
|
struct iwreq iwr;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -143,7 +144,7 @@ int wpa_driver_wext_set_key_ext(int sockfd, FAR const char *ifname, enum wpa_al
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: wpa_driver_wext_associate
|
* Name: wpa_driver_wext_associate
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -153,7 +154,7 @@ int wpa_driver_wext_set_key_ext(int sockfd, FAR const char *ifname, enum wpa_al
|
|||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int wpa_driver_wext_associate(FAR struct wpa_wconfig_s *wconfig)
|
int wpa_driver_wext_associate(FAR struct wpa_wconfig_s *wconfig)
|
||||||
{
|
{
|
||||||
@ -164,7 +165,8 @@ int wpa_driver_wext_associate(FAR struct wpa_wconfig_s *wconfig)
|
|||||||
DEBUGASSERT(wconfig != NULL);
|
DEBUGASSERT(wconfig != NULL);
|
||||||
|
|
||||||
ninfo("sta_mode=%u auth_wpa=%08x cipher_mode=%08x alg=%d\n",
|
ninfo("sta_mode=%u auth_wpa=%08x cipher_mode=%08x alg=%d\n",
|
||||||
wconfig->sta_mode, wconfig->auth_wpa, wconfig->cipher_mode, wconfig->alg);
|
wconfig->sta_mode, wconfig->auth_wpa, wconfig->cipher_mode,
|
||||||
|
wconfig->alg);
|
||||||
ninfo("ifname=%s ssid[%u]=%s passphrase[%u]=%s\n",
|
ninfo("ifname=%s ssid[%u]=%s passphrase[%u]=%s\n",
|
||||||
wconfig->ifname, wconfig->ssidlen, wconfig->ssid, wconfig->phraselen,
|
wconfig->ifname, wconfig->ssidlen, wconfig->ssid, wconfig->phraselen,
|
||||||
wconfig->passphrase);
|
wconfig->passphrase);
|
||||||
@ -227,7 +229,7 @@ close_socket:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: wpa_driver_wext_set_auth_param
|
* Name: wpa_driver_wext_set_auth_param
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -236,10 +238,10 @@ close_socket:
|
|||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int wpa_driver_wext_set_auth_param(int sockfd, FAR const char *ifname, int idx,
|
int wpa_driver_wext_set_auth_param(int sockfd, FAR const char *ifname,
|
||||||
uint32_t value)
|
int idx, uint32_t value)
|
||||||
{
|
{
|
||||||
struct iwreq iwr;
|
struct iwreq iwr;
|
||||||
int errcode;
|
int errcode;
|
||||||
@ -266,4 +268,3 @@ int wpa_driver_wext_set_auth_param(int sockfd, FAR const char *ifname, int idx,
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* apps/wireless/wapi/src/wapi.c
|
* apps/wireless/wapi/src/wapi.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011, 2017Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011, 2017, 2019 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Largely and original work, but highly influenced by sampled code provided
|
* Largely and original work, but highly influenced by sampled code provided
|
||||||
@ -93,9 +93,11 @@ static void wapi_mode_cmd(int sock, FAR const char *ifname,
|
|||||||
static void wapi_ap_cmd(int sock, FAR const char *ifname,
|
static void wapi_ap_cmd(int sock, FAR const char *ifname,
|
||||||
FAR const char *macstr);
|
FAR const char *macstr);
|
||||||
static void wapi_bitrate_cmd(int sock, FAR const char *ifname,
|
static void wapi_bitrate_cmd(int sock, FAR const char *ifname,
|
||||||
FAR const char *ratestr, FAR const char *flagstr);
|
FAR const char *ratestr,
|
||||||
|
FAR const char *flagstr);
|
||||||
static void wapi_txpower_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);
|
FAR const char *pwrstr,
|
||||||
|
FAR const char *flagstr);
|
||||||
static void wapi_scan_cmd(int sock, FAR const char *ifname);
|
static void wapi_scan_cmd(int sock, FAR const char *ifname);
|
||||||
|
|
||||||
static void wapi_showusage(FAR const char *progname, int exitcode);
|
static void wapi_showusage(FAR const char *progname, int exitcode);
|
||||||
@ -492,7 +494,8 @@ static void wapi_essid_cmd(int sock, FAR const char *ifname,
|
|||||||
|
|
||||||
/* Convert input strings to values */
|
/* Convert input strings to values */
|
||||||
|
|
||||||
essid_flag = (enum wapi_essid_flag_e)wapi_str2ndx(flagstr, g_wapi_essid_flags);
|
essid_flag = (enum wapi_essid_flag_e)
|
||||||
|
wapi_str2ndx(flagstr, g_wapi_essid_flags);
|
||||||
|
|
||||||
/* Set the ESSID */
|
/* Set the ESSID */
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* apps/wireless/wapi/src/wireless.c
|
* apps/wireless/wapi/src/wireless.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011, 2017Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011, 2017, 2019 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Adapted for Nuttx from WAPI:
|
* Adapted for Nuttx from WAPI:
|
||||||
@ -228,7 +228,7 @@ static int wapi_event_stream_extract(FAR struct wapi_event_stream_s *stream,
|
|||||||
FAR struct iw_event *iwe)
|
FAR struct iw_event *iwe)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct iw_event *iwe_stream;
|
FAR struct iw_event *iwe_stream;
|
||||||
|
|
||||||
if (stream->current + offsetof(struct iw_event, u) > stream->end)
|
if (stream->current + offsetof(struct iw_event, u) > stream->end)
|
||||||
{
|
{
|
||||||
@ -237,7 +237,7 @@ static int wapi_event_stream_extract(FAR struct wapi_event_stream_s *stream,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
iwe_stream = (struct iw_event*)stream->current;
|
iwe_stream = (FAR struct iw_event *)stream->current;
|
||||||
|
|
||||||
if (stream->current + iwe_stream->len > stream->end ||
|
if (stream->current + iwe_stream->len > stream->end ||
|
||||||
iwe_stream->len < offsetof(struct iw_event, u))
|
iwe_stream->len < offsetof(struct iw_event, u))
|
||||||
@ -270,6 +270,7 @@ static int wapi_event_stream_extract(FAR struct wapi_event_stream_s *stream,
|
|||||||
iwe->len = offsetof(struct iw_event, u);
|
iwe->len = offsetof(struct iw_event, u);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(iwe, iwe_stream, iwe_stream->len);
|
memcpy(iwe, iwe_stream, iwe_stream->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +287,8 @@ static int wapi_event_stream_extract(FAR struct wapi_event_stream_s *stream,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int wapi_scan_event(FAR struct iw_event *event, FAR struct wapi_list_s *list)
|
static int wapi_scan_event(FAR struct iw_event *event,
|
||||||
|
FAR struct wapi_list_s *list)
|
||||||
{
|
{
|
||||||
FAR struct wapi_scan_info_s *info;
|
FAR struct wapi_scan_info_s *info;
|
||||||
|
|
||||||
@ -317,7 +319,8 @@ static int wapi_scan_event(FAR struct iw_event *event, FAR struct wapi_list_s *l
|
|||||||
|
|
||||||
/* Save cell identifier. */
|
/* Save cell identifier. */
|
||||||
|
|
||||||
memcpy(&temp->ap, &event->u.ap_addr.sa_data, sizeof(struct ether_addr));
|
memcpy(&temp->ap, &event->u.ap_addr.sa_data,
|
||||||
|
sizeof(struct ether_addr));
|
||||||
|
|
||||||
/* Push it to the head of the list. */
|
/* Push it to the head of the list. */
|
||||||
|
|
||||||
@ -348,17 +351,20 @@ static int wapi_scan_event(FAR struct iw_event *event, FAR struct wapi_list_s *l
|
|||||||
|
|
||||||
case SIOCGIWESSID:
|
case SIOCGIWESSID:
|
||||||
info->has_essid = 1;
|
info->has_essid = 1;
|
||||||
info->essid_flag = (event->u.data.flags) ? WAPI_ESSID_ON : WAPI_ESSID_OFF;
|
info->essid_flag = (event->u.data.flags) ? WAPI_ESSID_ON
|
||||||
|
: WAPI_ESSID_OFF;
|
||||||
memset(info->essid, 0, (WAPI_ESSID_MAX_SIZE + 1));
|
memset(info->essid, 0, (WAPI_ESSID_MAX_SIZE + 1));
|
||||||
if ((event->u.essid.pointer) && (event->u.essid.length))
|
if ((event->u.essid.pointer) && (event->u.essid.length))
|
||||||
{
|
{
|
||||||
memcpy(info->essid, event->u.essid.pointer, event->u.essid.length);
|
memcpy(info->essid, event->u.essid.pointer, event->u.essid.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIOCGIWRATE:
|
case SIOCGIWRATE:
|
||||||
/* Scan may return a list of bitrates. As we have space for only a single
|
|
||||||
* bitrate, we only keep the largest one.
|
/* Scan may return a list of bitrates. As we have space for only a
|
||||||
|
* single bitrate, we only keep the largest one.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!info->has_bitrate || event->u.bitrate.value > info->bitrate)
|
if (!info->has_bitrate || event->u.bitrate.value > info->bitrate)
|
||||||
@ -387,7 +393,10 @@ static int wapi_scan_event(FAR struct iw_event *event, FAR struct wapi_list_s *l
|
|||||||
int wapi_get_freq(int sock, FAR const char *ifname, FAR double *freq,
|
int wapi_get_freq(int sock, FAR const char *ifname, FAR double *freq,
|
||||||
FAR enum wapi_freq_flag_e *flag)
|
FAR enum wapi_freq_flag_e *flag)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
WAPI_VALIDATE_PTR(freq);
|
WAPI_VALIDATE_PTR(freq);
|
||||||
@ -438,7 +447,10 @@ 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,
|
int wapi_set_freq(int sock, FAR const char *ifname, double freq,
|
||||||
enum wapi_freq_flag_e flag)
|
enum wapi_freq_flag_e flag)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Set freq. */
|
/* Set freq. */
|
||||||
@ -484,7 +496,10 @@ int wapi_set_freq(int sock, FAR const char *ifname, double freq,
|
|||||||
int wapi_freq2chan(int sock, FAR const char *ifname, double freq,
|
int wapi_freq2chan(int sock, FAR const char *ifname, double freq,
|
||||||
FAR int *chan)
|
FAR int *chan)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
char buf[sizeof(struct iw_range) * 2];
|
char buf[sizeof(struct iw_range) * 2];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -500,7 +515,8 @@ int wapi_freq2chan(int sock, FAR const char *ifname, double freq,
|
|||||||
/* Get range. */
|
/* Get range. */
|
||||||
|
|
||||||
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
||||||
if ((ret = ioctl(sock, SIOCGIWRANGE, (unsigned long)((uintptr_t)&wrq))) >= 0)
|
ret = ioctl(sock, SIOCGIWRANGE, (unsigned long)((uintptr_t)&wrq));
|
||||||
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
struct iw_range *range = (struct iw_range *)buf;
|
struct iw_range *range = (struct iw_range *)buf;
|
||||||
int k;
|
int k;
|
||||||
@ -546,7 +562,10 @@ int wapi_freq2chan(int sock, FAR const char *ifname, double freq,
|
|||||||
int wapi_chan2freq(int sock, FAR const char *ifname, int chan,
|
int wapi_chan2freq(int sock, FAR const char *ifname, int chan,
|
||||||
FAR double *freq)
|
FAR double *freq)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
char buf[sizeof(struct iw_range) * 2];
|
char buf[sizeof(struct iw_range) * 2];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -562,7 +581,8 @@ int wapi_chan2freq(int sock, FAR const char *ifname, int chan,
|
|||||||
/* Get range. */
|
/* Get range. */
|
||||||
|
|
||||||
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
||||||
if ((ret = ioctl(sock, SIOCGIWRANGE, (unsigned long)((uintptr_t)&wrq))) >= 0)
|
ret = ioctl(sock, SIOCGIWRANGE, (unsigned long)((uintptr_t)&wrq));
|
||||||
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
struct iw_range *range = (struct iw_range *)buf;
|
struct iw_range *range = (struct iw_range *)buf;
|
||||||
int k;
|
int k;
|
||||||
@ -605,7 +625,10 @@ int wapi_chan2freq(int sock, FAR const char *ifname, int chan,
|
|||||||
int wapi_get_essid(int sock, FAR const char *ifname, FAR char *essid,
|
int wapi_get_essid(int sock, FAR const char *ifname, FAR char *essid,
|
||||||
FAR enum wapi_essid_flag_e *flag)
|
FAR enum wapi_essid_flag_e *flag)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
WAPI_VALIDATE_PTR(essid);
|
WAPI_VALIDATE_PTR(essid);
|
||||||
@ -645,7 +668,10 @@ int wapi_set_essid(int sock, FAR const char *ifname, FAR const char *essid,
|
|||||||
enum wapi_essid_flag_e flag)
|
enum wapi_essid_flag_e flag)
|
||||||
{
|
{
|
||||||
char buf[WAPI_ESSID_MAX_SIZE + 1];
|
char buf[WAPI_ESSID_MAX_SIZE + 1];
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Prepare request. */
|
/* Prepare request. */
|
||||||
@ -675,15 +701,20 @@ 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 enum wapi_mode_e *mode)
|
int wapi_get_mode(int sock, FAR const char *ifname,
|
||||||
|
FAR enum wapi_mode_e *mode)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
WAPI_VALIDATE_PTR(mode);
|
WAPI_VALIDATE_PTR(mode);
|
||||||
|
|
||||||
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
||||||
if ((ret = ioctl(sock, SIOCGIWMODE, (unsigned long)((uintptr_t)&wrq))) >= 0)
|
ret = ioctl(sock, SIOCGIWMODE, (unsigned long)((uintptr_t)&wrq));
|
||||||
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
ret = wapi_parse_mode(wrq.u.mode, mode);
|
ret = wapi_parse_mode(wrq.u.mode, mode);
|
||||||
}
|
}
|
||||||
@ -707,7 +738,10 @@ int wapi_get_mode(int sock, FAR const char *ifname, FAR enum wapi_mode_e *mode)
|
|||||||
|
|
||||||
int wapi_set_mode(int sock, FAR const char *ifname, enum wapi_mode_e mode)
|
int wapi_set_mode(int sock, FAR const char *ifname, enum wapi_mode_e mode)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
wrq.u.mode = mode;
|
wrq.u.mode = mode;
|
||||||
@ -728,13 +762,13 @@ int wapi_set_mode(int sock, FAR const char *ifname, enum wapi_mode_e mode)
|
|||||||
* Name: wapi_make_broad_ether
|
* Name: wapi_make_broad_ether
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Creates an ethernet broadcast address.
|
* Creates an Ethernet broadcast address.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int wapi_make_broad_ether(FAR struct ether_addr *sa)
|
int wapi_make_broad_ether(FAR struct ether_addr *sa)
|
||||||
{
|
{
|
||||||
return wapi_make_ether(sa, 0xFF);
|
return wapi_make_ether(sa, 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -764,13 +798,17 @@ int wapi_make_null_ether(FAR struct ether_addr *sa)
|
|||||||
|
|
||||||
int wapi_get_ap(int sock, FAR const char *ifname, FAR struct ether_addr *ap)
|
int wapi_get_ap(int sock, FAR const char *ifname, FAR struct ether_addr *ap)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
WAPI_VALIDATE_PTR(ap);
|
WAPI_VALIDATE_PTR(ap);
|
||||||
|
|
||||||
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
||||||
if ((ret = ioctl(sock, SIOCGIWAP, (unsigned long)((uintptr_t)&wrq))) >= 0)
|
ret = ioctl(sock, SIOCGIWAP, (unsigned long)((uintptr_t)&wrq));
|
||||||
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
memcpy(ap, wrq.u.ap_addr.sa_data, sizeof(struct ether_addr));
|
memcpy(ap, wrq.u.ap_addr.sa_data, sizeof(struct ether_addr));
|
||||||
}
|
}
|
||||||
@ -795,7 +833,10 @@ int wapi_get_ap(int sock, FAR const char *ifname, FAR struct ether_addr *ap)
|
|||||||
int wapi_set_ap(int sock, FAR const char *ifname,
|
int wapi_set_ap(int sock, FAR const char *ifname,
|
||||||
FAR const struct ether_addr *ap)
|
FAR const struct ether_addr *ap)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
WAPI_VALIDATE_PTR(ap);
|
WAPI_VALIDATE_PTR(ap);
|
||||||
@ -826,14 +867,18 @@ int wapi_set_ap(int sock, FAR const char *ifname,
|
|||||||
int wapi_get_bitrate(int sock, FAR const char *ifname,
|
int wapi_get_bitrate(int sock, FAR const char *ifname,
|
||||||
FAR int *bitrate, FAR enum wapi_bitrate_flag_e *flag)
|
FAR int *bitrate, FAR enum wapi_bitrate_flag_e *flag)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
WAPI_VALIDATE_PTR(bitrate);
|
WAPI_VALIDATE_PTR(bitrate);
|
||||||
WAPI_VALIDATE_PTR(flag);
|
WAPI_VALIDATE_PTR(flag);
|
||||||
|
|
||||||
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
||||||
if ((ret = ioctl(sock, SIOCGIWRATE, (unsigned long)((uintptr_t)&wrq))) >= 0)
|
ret = ioctl(sock, SIOCGIWRATE, (unsigned long)((uintptr_t)&wrq));
|
||||||
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
/* Check if enabled. */
|
/* Check if enabled. */
|
||||||
|
|
||||||
@ -869,7 +914,10 @@ int wapi_get_bitrate(int sock, FAR const char *ifname,
|
|||||||
int wapi_set_bitrate(int sock, FAR const char *ifname, int bitrate,
|
int wapi_set_bitrate(int sock, FAR const char *ifname, int bitrate,
|
||||||
enum wapi_bitrate_flag_e flag)
|
enum wapi_bitrate_flag_e flag)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
wrq.u.bitrate.value = bitrate;
|
wrq.u.bitrate.value = bitrate;
|
||||||
@ -924,14 +972,18 @@ int wapi_mwatt2dbm(int mwatt)
|
|||||||
int wapi_get_txpower(int sock, FAR const char *ifname, FAR int *power,
|
int wapi_get_txpower(int sock, FAR const char *ifname, FAR int *power,
|
||||||
FAR enum wapi_txpower_flag_e *flag)
|
FAR enum wapi_txpower_flag_e *flag)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
WAPI_VALIDATE_PTR(power);
|
WAPI_VALIDATE_PTR(power);
|
||||||
WAPI_VALIDATE_PTR(flag);
|
WAPI_VALIDATE_PTR(flag);
|
||||||
|
|
||||||
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
||||||
if ((ret = ioctl(sock, SIOCGIWTXPOW, (unsigned long)((uintptr_t)&wrq))) >= 0)
|
ret = ioctl(sock, SIOCGIWTXPOW, (unsigned long)((uintptr_t)&wrq));
|
||||||
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
/* Check if enabled. */
|
/* Check if enabled. */
|
||||||
|
|
||||||
@ -985,7 +1037,10 @@ 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,
|
int wapi_set_txpower(int sock, FAR const char *ifname, int power,
|
||||||
enum wapi_txpower_flag_e flag)
|
enum wapi_txpower_flag_e flag)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Construct the request. */
|
/* Construct the request. */
|
||||||
@ -1024,14 +1079,17 @@ int wapi_set_txpower(int sock, FAR const char *ifname, int power,
|
|||||||
* Name: wapi_scan_init
|
* Name: wapi_scan_init
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Starts a scan on the given interface. Root privileges are required to start a
|
* Starts a scan on the given interface. Root privileges are required to
|
||||||
* scan.
|
* start a scan.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int wapi_scan_init(int sock, const char *ifname)
|
int wapi_scan_init(int sock, const char *ifname)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
||||||
@ -1059,14 +1117,18 @@ int wapi_scan_init(int sock, const char *ifname)
|
|||||||
|
|
||||||
int wapi_scan_stat(int sock, FAR const char *ifname)
|
int wapi_scan_stat(int sock, FAR const char *ifname)
|
||||||
{
|
{
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
char buf;
|
char buf;
|
||||||
|
|
||||||
wrq.u.data.pointer = &buf;
|
wrq.u.data.pointer = &buf;
|
||||||
|
|
||||||
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
|
||||||
if ((ret = ioctl(sock, SIOCGIWSCAN, (unsigned long)((uintptr_t)&wrq))) < 0)
|
ret = ioctl(sock, SIOCGIWSCAN, (unsigned long)((uintptr_t)&wrq));
|
||||||
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
if (errno == E2BIG)
|
if (errno == E2BIG)
|
||||||
{
|
{
|
||||||
@ -1104,11 +1166,15 @@ int wapi_scan_stat(int sock, FAR const char *ifname)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int wapi_scan_coll(int sock, FAR const char *ifname, FAR struct wapi_list_s *aps)
|
int wapi_scan_coll(int sock, FAR const char *ifname,
|
||||||
|
FAR struct wapi_list_s *aps)
|
||||||
{
|
{
|
||||||
FAR char *buf;
|
FAR char *buf;
|
||||||
int buflen;
|
int buflen;
|
||||||
struct iwreq wrq = {};
|
struct iwreq wrq =
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
WAPI_VALIDATE_PTR(aps);
|
WAPI_VALIDATE_PTR(aps);
|
||||||
@ -1122,6 +1188,7 @@ int wapi_scan_coll(int sock, FAR const char *ifname, FAR struct wapi_list_s *aps
|
|||||||
}
|
}
|
||||||
|
|
||||||
alloc:
|
alloc:
|
||||||
|
|
||||||
/* Collect results. */
|
/* Collect results. */
|
||||||
|
|
||||||
wrq.u.data.pointer = buf;
|
wrq.u.data.pointer = buf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user