wireless/wapi: add scan partial channel support

Change-Id: I2279406a9ca0cc3a9535ce79fbf651dbaf14ad4c
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2020-09-02 19:37:21 +08:00 committed by Xiang Xiao
parent 77aa0e8908
commit a0f6b14c0d
2 changed files with 42 additions and 3 deletions

View File

@ -643,6 +643,19 @@ int wapi_make_socket(void);
int wapi_scan_init(int sock, FAR const char *ifname, FAR const char *essid); int wapi_scan_init(int sock, FAR const char *ifname, FAR const char *essid);
/****************************************************************************
* Name: wapi_scan_channel_init
*
* Description:
* Starts a scan on the given interface. Root privileges are required to
* start a scan with specified channels.
*
****************************************************************************/
int wapi_scan_channel_init(int sock, FAR const char *ifname,
FAR const char *essid,
uint8_t *channels, int num_channels);
/**************************************************************************** /****************************************************************************
* Name: wapi_scan_stat * Name: wapi_scan_stat
* *

View File

@ -1138,15 +1138,17 @@ int wapi_set_txpower(int sock, FAR const char *ifname, int power,
} }
/**************************************************************************** /****************************************************************************
* Name: wapi_scan_init * Name: wapi_scan_channel_init
* *
* Description: * Description:
* Starts a scan on the given interface. Root privileges are required to * Starts a scan on the given interface. Root privileges are required to
* start a scan. * start a scan with specified channels.
* *
****************************************************************************/ ****************************************************************************/
int wapi_scan_init(int sock, const char *ifname, const char *essid) int wapi_scan_channel_init(int sock, FAR const char *ifname,
FAR const char *essid,
uint8_t *channels, int num_channels)
{ {
struct iw_scan_req req; struct iw_scan_req req;
struct iwreq wrq = struct iwreq wrq =
@ -1155,6 +1157,7 @@ int wapi_scan_init(int sock, const char *ifname, const char *essid)
size_t essid_len; size_t essid_len;
int ret; int ret;
int i;
if (essid && (essid_len = strlen(essid)) > 0) if (essid && (essid_len = strlen(essid)) > 0)
{ {
@ -1168,6 +1171,15 @@ int wapi_scan_init(int sock, const char *ifname, const char *essid)
wrq.u.data.flags = IW_SCAN_THIS_ESSID; wrq.u.data.flags = IW_SCAN_THIS_ESSID;
} }
if (channels && num_channels > 0)
{
req.num_channels = num_channels;
for (i = 0; i < num_channels; i++)
{
req.channel_list[i].m = channels[i];
}
}
strncpy(wrq.ifr_name, ifname, IFNAMSIZ); strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
ret = ioctl(sock, SIOCSIWSCAN, (unsigned long)((uintptr_t)&wrq)); ret = ioctl(sock, SIOCSIWSCAN, (unsigned long)((uintptr_t)&wrq));
if (ret < 0) if (ret < 0)
@ -1180,6 +1192,20 @@ int wapi_scan_init(int sock, const char *ifname, const char *essid)
return ret; return ret;
} }
/****************************************************************************
* Name: wapi_scan_init
*
* Description:
* Starts a scan on the given interface. Root privileges are required to
* start a scan.
*
****************************************************************************/
int wapi_scan_init(int sock, FAR const char *ifname, FAR const char *essid)
{
return wapi_scan_channel_init(sock, ifname, essid, NULL, 0);
}
/**************************************************************************** /****************************************************************************
* Name: wapi_scan_stat * Name: wapi_scan_stat
* *