Merge remote-tracking branch 'origin/master' into ieee802154
This commit is contained in:
commit
920b060878
@ -60,16 +60,20 @@ static void cleanup(FAR void * data)
|
||||
FAR struct sync_s *sync = (FAR struct sync_s *) data;
|
||||
int status;
|
||||
|
||||
/* Note: pthread_cond_wait() will release the mutex while it waits on
|
||||
* condition value. So a EPERM error is not a failure.
|
||||
/* Note: The behavior of canceling pthread_cond_wait() with asynchronous
|
||||
* cancellation is not defined. On NuttX we get EPERM here, but application
|
||||
* code must not rely on this.
|
||||
*/
|
||||
|
||||
status = pthread_mutex_unlock(&sync->lock);
|
||||
#ifndef CONFIG_CANCELLATION_POINTS
|
||||
if (status == EPERM)
|
||||
{
|
||||
printf("pthread_cleanup: thread did not have mutex locked: %d\n", status);
|
||||
return;
|
||||
}
|
||||
else if (status != 0)
|
||||
#endif
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_cleanup: ERROR pthread_mutex_unlock in cleanup handler. "
|
||||
"Status: %d\n", status);
|
||||
@ -138,6 +142,7 @@ static void test_cleanup(void)
|
||||
printf("pthread_cleanup: ERROR pthread_join returned wrong result: %p\n", result);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CANCELLATION_POINTS
|
||||
/* Do some operations on lock in order to check if it is in usable state. */
|
||||
|
||||
status = pthread_mutex_trylock(&sync.lock);
|
||||
@ -151,6 +156,7 @@ static void test_cleanup(void)
|
||||
{
|
||||
printf("pthread_cleanup: ERROR pthread_mutex_unlock, status=%d\n", status);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -47,29 +47,74 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define WAPI_IOCTL_STRERROR(cmd) \
|
||||
fprintf( \
|
||||
stderr, "%s:%d:%s():ioctl(%s): %s\n", \
|
||||
__FILE__, __LINE__, __func__, \
|
||||
wapi_ioctl_command_name(cmd), strerror(errno))
|
||||
#ifdef DEBUG_WIRELESS_ERROR
|
||||
# ifdef CONFIG_LIBC_STRERROR
|
||||
# define WAPI_IOCTL_STRERROR(cmd) \
|
||||
fprintf( \
|
||||
stderr, "%s:%d:%s():ioctl(%s): %s\n", \
|
||||
__FILE__, __LINE__, __func__, \
|
||||
wapi_ioctl_command_name(cmd), strerror(errno))
|
||||
|
||||
#define WAPI_STRERROR(fmt, ...) \
|
||||
fprintf( \
|
||||
stderr, "%s:%d:%s():" fmt ": %s\n", \
|
||||
__FILE__, __LINE__, __func__, \
|
||||
## __VA_ARGS__, strerror(errno))
|
||||
# define WAPI_STRERROR(fmt, ...) \
|
||||
fprintf( \
|
||||
stderr, "%s:%d:%s():" fmt ": %s\n", \
|
||||
__FILE__, __LINE__, __func__, \
|
||||
## __VA_ARGS__, strerror(errno))
|
||||
# else
|
||||
# define WAPI_IOCTL_STRERROR(cmd) \
|
||||
fprintf( \
|
||||
stderr, "%s:%d:%s():ioctl(%s): %d\n", \
|
||||
__FILE__, __LINE__, __func__, \
|
||||
wapi_ioctl_command_name(cmd), errno)
|
||||
|
||||
#define WAPI_ERROR(fmt, ...) \
|
||||
fprintf( \
|
||||
stderr, "%s:%d:%s(): " fmt , \
|
||||
__FILE__, __LINE__, __func__, ## __VA_ARGS__)
|
||||
# define WAPI_STRERROR(fmt, ...) \
|
||||
fprintf( \
|
||||
stderr, "%s:%d:%s():" fmt ": %d\n", \
|
||||
__FILE__, __LINE__, __func__, \
|
||||
## __VA_ARGS__, errno)
|
||||
# endif
|
||||
|
||||
# define WAPI_ERROR(fmt, ...) \
|
||||
fprintf( \
|
||||
stderr, "%s:%d:%s(): " fmt , \
|
||||
__FILE__, __LINE__, __func__, ## __VA_ARGS__)
|
||||
|
||||
#else
|
||||
# ifdef CONFIG_LIBC_STRERROR
|
||||
# define WAPI_IOCTL_STRERROR(cmd) \
|
||||
fprintf( \
|
||||
stderr, "ioctl(%s): %s\n", \
|
||||
wapi_ioctl_command_name(cmd), strerror(errno))
|
||||
|
||||
# define WAPI_STRERROR(fmt, ...) \
|
||||
fprintf( \
|
||||
stderr, fmt ": %s\n", \
|
||||
## __VA_ARGS__, strerror(errno))
|
||||
# else
|
||||
# define WAPI_IOCTL_STRERROR(cmd) \
|
||||
fprintf( \
|
||||
stderr, "ioctl(%s): %d\n", \
|
||||
wapi_ioctl_command_name(cmd), errno)
|
||||
|
||||
# define WAPI_STRERROR(fmt, ...) \
|
||||
fprintf( \
|
||||
stderr, fmt ": %d\n", \
|
||||
## __VA_ARGS__, errno)
|
||||
# endif
|
||||
|
||||
# define WAPI_ERROR(fmt, ...) \
|
||||
fprintf( \
|
||||
stderr, fmt , \
|
||||
## __VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
#define WAPI_VALIDATE_PTR(ptr) \
|
||||
if (!ptr) \
|
||||
{ \
|
||||
WAPI_ERROR("Null pointer: %s.\n", #ptr); \
|
||||
return -1; \
|
||||
}
|
||||
if (ptr == NULL) \
|
||||
{ \
|
||||
WAPI_ERROR("Null pointer: %p\n", ptr); \
|
||||
return -EINVAL; \
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
|
@ -76,6 +76,8 @@ typedef void (*cmd3_t)(int sock, FAR const char *arg1,
|
||||
|
||||
static int wapi_str2int(FAR const char *str);
|
||||
static double wapi_str2double(FAR const char *str);
|
||||
static unsigned int wapi_str2ndx(FAR const char *name, FAR const char **list,
|
||||
unsigned int listlen);
|
||||
|
||||
static void wapi_show_cmd(int sock, FAR const char *ifname);
|
||||
static void wapi_ip_cmd(int sock, FAR const char *ifname,
|
||||
@ -114,7 +116,7 @@ static const struct wapi_command_s g_wapi_commands[] =
|
||||
{"mode", 2, (CODE void *)wapi_mode_cmd},
|
||||
{"ap", 2, (CODE void *)wapi_ap_cmd},
|
||||
{"bitrate", 3, (CODE void *)wapi_bitrate_cmd},
|
||||
{"txpower", 2, (CODE void *)wapi_txpower_cmd},
|
||||
{"txpower", 3, (CODE void *)wapi_txpower_cmd},
|
||||
};
|
||||
|
||||
#define NCOMMANDS (sizeof(g_wapi_commands) / sizeof(struct wapi_command_s))
|
||||
@ -175,6 +177,37 @@ static double wapi_str2double(FAR const char *str)
|
||||
return value;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wapi_str2ndx
|
||||
*
|
||||
* Description:
|
||||
* Return the index of a string in a list of strings
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static unsigned int wapi_str2ndx(FAR const char *name, FAR const char **list,
|
||||
unsigned int listlen)
|
||||
{
|
||||
unsigned int ndx;
|
||||
|
||||
for (ndx = 0; ndx < listlen; ndx++)
|
||||
{
|
||||
if (strcmp(name, list[ndx]) == 0)
|
||||
{
|
||||
return ndx;
|
||||
}
|
||||
}
|
||||
|
||||
WAPI_ERROR("ERROR: Invalid option string: %s\n", name);
|
||||
WAPI_ERROR(" Valid options include:\n");
|
||||
for (ndx = 0; ndx < listlen; ndx++)
|
||||
{
|
||||
WAPI_ERROR(" - %s\n", list[ndx]);
|
||||
}
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wapi_show_cmd
|
||||
*
|
||||
@ -418,29 +451,13 @@ static void wapi_freq_cmd(int sock, FAR const char *ifname,
|
||||
{
|
||||
double frequency;
|
||||
wapi_freq_flag_t freq_flag;
|
||||
bool found = false;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
frequency = wapi_str2double(freqstr);
|
||||
|
||||
for (i = 0; i < IW_FREQ_NFLAGS; i++)
|
||||
{
|
||||
if (strcmp(flagstr, g_wapi_freq_flags[i]) == 0)
|
||||
{
|
||||
freq_flag = (wapi_freq_flag_t)i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
WAPI_ERROR("ERROR: Invalid frequency flag: %s\n", flagstr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
freq_flag = (wapi_freq_flag_t)wapi_str2ndx(flagstr, g_wapi_freq_flags,
|
||||
IW_FREQ_NFLAGS);
|
||||
|
||||
/* Set the frequency */
|
||||
|
||||
@ -466,28 +483,12 @@ 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;
|
||||
bool found = false;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (strcmp(flagstr, g_wapi_essid_flags[i]) == 0)
|
||||
{
|
||||
essid_flag = (wapi_essid_flag_t)i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
WAPI_ERROR("ERROR: Invalid ESSID flag: %s\n", flagstr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
essid_flag = (wapi_essid_flag_t)wapi_str2ndx(flagstr, g_wapi_essid_flags, 2);
|
||||
|
||||
/* Set the ESSID */
|
||||
|
||||
ret = wapi_set_essid(sock, ifname, essid, essid_flag);
|
||||
@ -512,27 +513,11 @@ static void wapi_mode_cmd(int sock, FAR const char *ifname,
|
||||
FAR const char *modestr)
|
||||
{
|
||||
wapi_mode_t mode;
|
||||
bool found = false;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
for (i = 0; i < IW_MODE_NFLAGS; i++)
|
||||
{
|
||||
if (strcmp(modestr, g_wapi_modes[i]) == 0)
|
||||
{
|
||||
mode = (wapi_mode_t)i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
WAPI_ERROR("ERROR: Invalid operating mode: %s\n", modestr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
mode = (wapi_mode_t)wapi_str2ndx(modestr, g_wapi_modes, IW_MODE_NFLAGS);
|
||||
|
||||
/* Set operating mode */
|
||||
|
||||
@ -592,30 +577,14 @@ static void wapi_bitrate_cmd(int sock, FAR const char *ifname,
|
||||
|
||||
{
|
||||
wapi_bitrate_flag_t bitrate_flag;
|
||||
bool found = false;
|
||||
int bitrate;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
bitrate = wapi_str2int(ratestr);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (strcmp(flagstr, g_wapi_bitrate_flags[i]) == 0)
|
||||
{
|
||||
bitrate_flag = (wapi_bitrate_flag_t)i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
WAPI_ERROR("ERROR: Invalid bitrate flag: %s\n", flagstr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
bitrate = wapi_str2int(ratestr);
|
||||
bitrate_flag = (wapi_bitrate_flag_t)
|
||||
wapi_str2ndx(flagstr, g_wapi_bitrate_flags, 2);
|
||||
|
||||
/* Set bitrate */
|
||||
|
||||
@ -641,30 +610,14 @@ 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;
|
||||
bool found = false;
|
||||
int txpower;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Convert input strings to values */
|
||||
|
||||
txpower = wapi_str2int(pwrstr);
|
||||
|
||||
for (i = 0; i < IW_TXPOW_NFLAGS; i++)
|
||||
{
|
||||
if (strcmp(flagstr, g_wapi_txpower_flags[i]) == 0)
|
||||
{
|
||||
txpower_flag = (wapi_txpower_flag_t)i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
WAPI_ERROR("ERROR: Invalid TX power flag: %s\n", flagstr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
txpower = wapi_str2int(pwrstr);
|
||||
txpower_flag = (wapi_txpower_flag_t)
|
||||
wapi_str2ndx(flagstr, g_wapi_txpower_flags, IW_TXPOW_NFLAGS);
|
||||
|
||||
/* Set txpower */
|
||||
|
||||
@ -728,7 +681,7 @@ static void wapi_scan_cmd(int sock, FAR const char *ifname)
|
||||
|
||||
for (info = list.head.scan; info; info = info->next)
|
||||
{
|
||||
printf(">> %02x:%02x:%02x:%02x:%02x:%02x %s\n",
|
||||
printf(" %02x:%02x:%02x:%02x:%02x:%02x %s\n",
|
||||
info->ap.ether_addr_octet[0], info->ap.ether_addr_octet[1],
|
||||
info->ap.ether_addr_octet[2], info->ap.ether_addr_octet[3],
|
||||
info->ap.ether_addr_octet[4], info->ap.ether_addr_octet[5],
|
||||
|
Loading…
Reference in New Issue
Block a user