1
0
Fork 0
forked from nuttx/nuttx-update

rpmsg_usrsock: Support the wireless ioctl which contain pointer 1/2

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2022-03-26 16:41:13 +08:00 committed by Xiang Xiao
parent a191d9bc3c
commit f60480a5db
3 changed files with 39 additions and 4 deletions

View file

@ -144,6 +144,15 @@
#define SIOCSIWCOUNTRY _WLIOC(0x0037) /* Country code extension */
#define WL_IS80211POINTERCMD(cmd) ((cmd) == SIOCGIWSCAN || \
(cmd) == SIOCSIWSCAN || \
(cmd) == SIOCSIWCOUNTRY || \
(cmd) == SIOCGIWRANGE || \
(cmd) == SIOCSIWENCODEEXT || \
(cmd) == SIOCGIWENCODEEXT || \
(cmd) == SIOCGIWESSID || \
(cmd) == SIOCSIWESSID)
/* Device-specific network IOCTL commands *******************************************/
#define WL_NETFIRST 0x0000 /* First network command */

View file

@ -222,7 +222,7 @@ static ssize_t iovec_do(FAR void *srcdst, size_t srcdstlen,
}
}
return total;
return total == 0 && iovcnt == 0 ? -1: total;
}
/****************************************************************************

View file

@ -34,7 +34,9 @@
#include <sys/socket.h>
#include <nuttx/net/net.h>
#include <nuttx/net/usrsock.h>
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
# include <nuttx/wireless/wireless.h>
#endif
#include "socket/socket.h"
#include "usrsock/usrsock.h"
@ -107,7 +109,9 @@ static int do_ioctl_request(FAR struct usrsock_conn_s *conn, int cmd,
{
};
struct iovec bufs[2];
struct iovec bufs[3] =
{
};
if (arglen > UINT16_MAX)
{
@ -126,6 +130,15 @@ static int do_ioctl_request(FAR struct usrsock_conn_s *conn, int cmd,
bufs[1].iov_base = (FAR void *)arg;
bufs[1].iov_len = req.arglen;
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
if (WL_IS80211POINTERCMD(cmd))
{
FAR struct iwreq *wlreq = arg;
bufs[2].iov_base = wlreq->u.data.pointer;
bufs[2].iov_len = wlreq->u.data.length;
}
#endif
return usrsockdev_do_request(conn, bufs, ARRAY_SIZE(bufs));
}
@ -155,7 +168,10 @@ int usrsock_ioctl(FAR struct socket *psock, int cmd, FAR void *arg,
{
};
struct iovec inbufs[1];
struct iovec inbufs[2] =
{
};
int ret;
net_lock();
@ -186,6 +202,16 @@ int usrsock_ioctl(FAR struct socket *psock, int cmd, FAR void *arg,
inbufs[0].iov_base = arg;
inbufs[0].iov_len = arglen;
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
if (WL_IS80211POINTERCMD(cmd))
{
FAR struct iwreq *wlreq = arg;
inbufs[1].iov_base = wlreq->u.data.pointer;
inbufs[1].iov_len = wlreq->u.data.length;
}
#endif
usrsock_setup_datain(conn, inbufs, ARRAY_SIZE(inbufs));
/* Request user-space daemon to handle ioctl. */