forked from nuttx/nuttx-update
net: Align the prototype of sock_intf_s::si_ioctl with file_operations::ioctl
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
0978dcf88d
commit
e0bb281e7a
16 changed files with 55 additions and 90 deletions
|
@ -196,8 +196,8 @@ struct sock_intf_s
|
|||
CODE ssize_t (*si_recvmsg)(FAR struct socket *psock,
|
||||
FAR struct msghdr *msg, int flags);
|
||||
CODE int (*si_close)(FAR struct socket *psock);
|
||||
CODE int (*si_ioctl)(FAR struct socket *psock, int cmd,
|
||||
FAR void *arg, size_t arglen);
|
||||
CODE int (*si_ioctl)(FAR struct socket *psock,
|
||||
int cmd, unsigned long arg);
|
||||
CODE int (*si_socketpair)(FAR struct socket *psocks[2]);
|
||||
#ifdef CONFIG_NET_SENDFILE
|
||||
CODE ssize_t (*si_sendfile)(FAR struct socket *psock,
|
||||
|
@ -314,6 +314,23 @@ extern "C"
|
|||
|
||||
void net_initialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_ioctl_arglen
|
||||
*
|
||||
* Description:
|
||||
* Calculate the ioctl argument buffer length.
|
||||
*
|
||||
* Input Parameters:
|
||||
*
|
||||
* cmd The ioctl command
|
||||
*
|
||||
* Returned Value:
|
||||
* The argument buffer length, or error code.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t net_ioctl_arglen(int cmd);
|
||||
|
||||
/****************************************************************************
|
||||
* Critical section management.
|
||||
*
|
||||
|
|
|
@ -621,23 +621,6 @@ int netdev_ifdown(FAR struct net_driver_s *dev);
|
|||
int netdev_carrier_on(FAR struct net_driver_s *dev);
|
||||
int netdev_carrier_off(FAR struct net_driver_s *dev);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_ioctl_arglen
|
||||
*
|
||||
* Description:
|
||||
* Calculate the ioctl argument buffer length.
|
||||
*
|
||||
* Input Parameters:
|
||||
*
|
||||
* cmd The ioctl command
|
||||
*
|
||||
* Returned Value:
|
||||
* The argument buffer length, or error code.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t net_ioctl_arglen(int cmd);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_chksum
|
||||
*
|
||||
|
|
|
@ -390,13 +390,11 @@ void icmp_reply(FAR struct net_driver_s *dev, int type, int code);
|
|||
* conn The ICMP connection of interest
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
* arglen The length of 'arg'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_ICMP_SOCKET
|
||||
int icmp_ioctl(FAR struct socket *psock,
|
||||
int cmd, FAR void *arg, size_t arglen);
|
||||
int icmp_ioctl(FAR struct socket *psock, int cmd, unsigned long arg);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
|
|
|
@ -51,12 +51,10 @@
|
|||
* conn The ICMP connection of interest
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
* arglen The length of 'arg'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int icmp_ioctl(FAR struct socket *psock,
|
||||
int cmd, FAR void *arg, size_t arglen)
|
||||
int icmp_ioctl(FAR struct socket *psock, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct icmp_conn_s *conn = psock->s_conn;
|
||||
int ret = OK;
|
||||
|
|
|
@ -771,13 +771,11 @@ void icmpv6_reply(FAR struct net_driver_s *dev,
|
|||
* conn The ICMP connection of interest
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
* arglen The length of 'arg'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
||||
int icmpv6_ioctl(FAR struct socket *psock,
|
||||
int cmd, FAR void *arg, size_t arglen);
|
||||
int icmpv6_ioctl(FAR struct socket *psock, int cmd, unsigned long arg);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
|
|
|
@ -51,12 +51,10 @@
|
|||
* conn The icmpv6 connection of interest
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
* arglen The length of 'arg'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int icmpv6_ioctl(FAR struct socket *psock,
|
||||
int cmd, FAR void *arg, size_t arglen)
|
||||
int icmpv6_ioctl(FAR struct socket *psock, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct icmpv6_conn_s *conn = psock->s_conn;
|
||||
int ret = OK;
|
||||
|
|
|
@ -88,8 +88,8 @@ static ssize_t inet_sendmsg(FAR struct socket *psock,
|
|||
FAR struct msghdr *msg, int flags);
|
||||
static ssize_t inet_recvmsg(FAR struct socket *psock,
|
||||
FAR struct msghdr *msg, int flags);
|
||||
static int inet_ioctl(FAR struct socket *psock, int cmd,
|
||||
FAR void *arg, size_t arglen);
|
||||
static int inet_ioctl(FAR struct socket *psock,
|
||||
int cmd, unsigned long arg);
|
||||
static int inet_socketpair(FAR struct socket *psocks[2]);
|
||||
#ifdef CONFIG_NET_SENDFILE
|
||||
static ssize_t inet_sendfile(FAR struct socket *psock,
|
||||
|
@ -1338,12 +1338,10 @@ static ssize_t inet_sendmsg(FAR struct socket *psock,
|
|||
* psock A reference to the socket structure of the socket
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
* arglen The length of 'arg'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int inet_ioctl(FAR struct socket *psock, int cmd,
|
||||
FAR void *arg, size_t arglen)
|
||||
static int inet_ioctl(FAR struct socket *psock, int cmd, unsigned long arg)
|
||||
{
|
||||
/* Verify that the sockfd corresponds to valid, allocated socket */
|
||||
|
||||
|
@ -1355,14 +1353,14 @@ static int inet_ioctl(FAR struct socket *psock, int cmd,
|
|||
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
|
||||
if (psock->s_type == SOCK_STREAM)
|
||||
{
|
||||
return tcp_ioctl(psock->s_conn, cmd, arg, arglen);
|
||||
return tcp_ioctl(psock->s_conn, cmd, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NET_UDP) && defined(NET_UDP_HAVE_STACK)
|
||||
if (psock->s_type == SOCK_DGRAM)
|
||||
{
|
||||
return udp_ioctl(psock->s_conn, cmd, arg, arglen);
|
||||
return udp_ioctl(psock->s_conn, cmd, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ static int local_accept(FAR struct socket *psock,
|
|||
static int local_poll(FAR struct socket *psock,
|
||||
FAR struct pollfd *fds, bool setup);
|
||||
static int local_close(FAR struct socket *psock);
|
||||
static int local_ioctl(FAR struct socket *psock, int cmd,
|
||||
FAR void *arg, size_t arglen);
|
||||
static int local_ioctl(FAR struct socket *psock,
|
||||
int cmd, unsigned long arg);
|
||||
static int local_socketpair(FAR struct socket *psocks[2]);
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -704,12 +704,10 @@ static int local_close(FAR struct socket *psock)
|
|||
* psock A reference to the socket structure of the socket
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
* arglen The length of 'arg'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int local_ioctl(FAR struct socket *psock, int cmd,
|
||||
FAR void *arg, size_t arglen)
|
||||
static int local_ioctl(FAR struct socket *psock, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct local_conn_s *conn;
|
||||
int ret = OK;
|
||||
|
|
|
@ -1586,15 +1586,7 @@ static int netdev_ioctl(FAR struct socket *psock, int cmd,
|
|||
{
|
||||
if (psock->s_sockif && psock->s_sockif->si_ioctl)
|
||||
{
|
||||
ssize_t arglen;
|
||||
|
||||
arglen = net_ioctl_arglen(cmd);
|
||||
if (arglen < 0)
|
||||
{
|
||||
return arglen;
|
||||
}
|
||||
|
||||
return psock->s_sockif->si_ioctl(psock, cmd, (FAR void *)arg, arglen);
|
||||
return psock->s_sockif->si_ioctl(psock, cmd, arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -149,8 +149,8 @@ static ssize_t rpmsg_socket_sendmsg(FAR struct socket *psock,
|
|||
static ssize_t rpmsg_socket_recvmsg(FAR struct socket *psock,
|
||||
FAR struct msghdr *msg, int flags);
|
||||
static int rpmsg_socket_close(FAR struct socket *psock);
|
||||
static int rpmsg_socket_ioctl(FAR struct socket *psock, int cmd,
|
||||
FAR void *arg, size_t arglen);
|
||||
static int rpmsg_socket_ioctl(FAR struct socket *psock,
|
||||
int cmd, unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
|
@ -1310,8 +1310,8 @@ static int rpmsg_socket_close(FAR struct socket *psock)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int rpmsg_socket_ioctl(FAR struct socket *psock, int cmd,
|
||||
FAR void *arg, size_t arglen)
|
||||
static int rpmsg_socket_ioctl(FAR struct socket *psock,
|
||||
int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct rpmsg_socket_conn_s *conn = psock->s_conn;
|
||||
int ret = OK;
|
||||
|
@ -1319,25 +1319,13 @@ static int rpmsg_socket_ioctl(FAR struct socket *psock, int cmd,
|
|||
switch (cmd)
|
||||
{
|
||||
case FIONREAD:
|
||||
if (arglen != sizeof(int))
|
||||
{
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
*(FAR int *)((uintptr_t)arg) = circbuf_used(&conn->recvbuf);
|
||||
|
||||
break;
|
||||
|
||||
case FIONSPACE:
|
||||
if (arglen != sizeof(int))
|
||||
{
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
*(FAR int *)((uintptr_t)arg) = rpmsg_socket_get_space(conn);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
|
|
|
@ -2000,12 +2000,10 @@ int tcp_txdrain(FAR struct socket *psock, unsigned int timeout);
|
|||
* conn The TCP connection of interest
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
* arglen The length of 'arg'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int tcp_ioctl(FAR struct tcp_conn_s *conn, int cmd,
|
||||
FAR void *arg, size_t arglen);
|
||||
int tcp_ioctl(FAR struct tcp_conn_s *conn, int cmd, unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tcp_sendbuffer_notify
|
||||
|
|
|
@ -55,8 +55,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int tcp_ioctl(FAR struct tcp_conn_s *conn,
|
||||
int cmd, FAR void *arg, size_t arglen)
|
||||
int tcp_ioctl(FAR struct tcp_conn_s *conn, int cmd, unsigned long arg)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
|
|
|
@ -939,12 +939,10 @@ int udp_txdrain(FAR struct socket *psock, unsigned int timeout);
|
|||
* conn The TCP connection of interest
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
* arglen The length of 'arg'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int udp_ioctl(FAR struct udp_conn_s *conn,
|
||||
int cmd, FAR void *arg, size_t arglen);
|
||||
int udp_ioctl(FAR struct udp_conn_s *conn, int cmd, unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: udp_sendbuffer_notify
|
||||
|
|
|
@ -51,12 +51,10 @@
|
|||
* conn The TCP connection of interest
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
* arglen The length of 'arg'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int udp_ioctl(FAR struct udp_conn_s *conn,
|
||||
int cmd, FAR void *arg, size_t arglen)
|
||||
int udp_ioctl(FAR struct udp_conn_s *conn, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct iob_s *iob;
|
||||
int ret = OK;
|
||||
|
|
|
@ -656,12 +656,10 @@ int usrsock_getpeername(FAR struct socket *psock,
|
|||
* psock A reference to the socket structure of the socket
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
* arglen The length of 'arg'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int usrsock_ioctl(FAR struct socket *psock, int cmd, FAR void *arg,
|
||||
size_t arglen);
|
||||
int usrsock_ioctl(FAR struct socket *psock, int cmd, unsigned long arg);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -103,7 +103,7 @@ static uint16_t ioctl_event(FAR struct net_driver_s *dev,
|
|||
****************************************************************************/
|
||||
|
||||
static int do_ioctl_request(FAR struct usrsock_conn_s *conn, int cmd,
|
||||
FAR void *arg, size_t arglen)
|
||||
FAR void *arg, size_t arglen)
|
||||
{
|
||||
struct usrsock_request_ioctl_s req =
|
||||
{
|
||||
|
@ -125,9 +125,9 @@ static int do_ioctl_request(FAR struct usrsock_conn_s *conn, int cmd,
|
|||
req.cmd = cmd;
|
||||
req.arglen = arglen;
|
||||
|
||||
bufs[0].iov_base = (FAR void *)&req;
|
||||
bufs[0].iov_base = &req;
|
||||
bufs[0].iov_len = sizeof(req);
|
||||
bufs[1].iov_base = (FAR void *)arg;
|
||||
bufs[1].iov_base = arg;
|
||||
bufs[1].iov_len = req.arglen;
|
||||
|
||||
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
|
||||
|
@ -156,12 +156,10 @@ static int do_ioctl_request(FAR struct usrsock_conn_s *conn, int cmd,
|
|||
* psock A reference to the socket structure of the socket
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
* arglen The length of 'arg'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int usrsock_ioctl(FAR struct socket *psock, int cmd, FAR void *arg,
|
||||
size_t arglen)
|
||||
int usrsock_ioctl(FAR struct socket *psock, int cmd, unsigned long arg_)
|
||||
{
|
||||
FAR struct usrsock_conn_s *conn = psock->s_conn;
|
||||
struct usrsock_data_reqstate_s state =
|
||||
|
@ -172,6 +170,8 @@ int usrsock_ioctl(FAR struct socket *psock, int cmd, FAR void *arg,
|
|||
{
|
||||
};
|
||||
|
||||
FAR void *arg = (FAR void *)(uintptr_t)arg_;
|
||||
ssize_t arglen;
|
||||
int ret;
|
||||
|
||||
/* Bypass FIONBIO to socket level,
|
||||
|
@ -183,6 +183,12 @@ int usrsock_ioctl(FAR struct socket *psock, int cmd, FAR void *arg,
|
|||
return -ENOTTY;
|
||||
}
|
||||
|
||||
arglen = net_ioctl_arglen(cmd);
|
||||
if (arglen < 0)
|
||||
{
|
||||
return arglen;
|
||||
}
|
||||
|
||||
net_lock();
|
||||
|
||||
if (conn->state == USRSOCK_CONN_STATE_UNINITIALIZED ||
|
||||
|
|
Loading…
Reference in a new issue