net: Add FIOC_FILEPATH ioctl support for ICMP(v6)/RPMsg/Usrsock sockets
Example of /proc/PID/group/fd in this case: FD OFLAGS TYPE POS PATH 3 3 9 0 icmp:[dev eth0, id 1, flg 1] 4 3 9 0 icmp6:[dev eth0, id 2, flg 1] 5 3 9 0 rpmsg:[ap:[test:0]<->remote] # server side 5 3 9 0 rpmsg:[remote<->ap:[test:0]] # client side Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
8e8d86a7bb
commit
d3bca3c2cf
@ -25,6 +25,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
@ -77,6 +78,12 @@ int icmp_ioctl(FAR struct socket *psock, int cmd, unsigned long arg)
|
||||
case FIONSPACE:
|
||||
*(FAR int *)((uintptr_t)arg) = MIN_UDP_MSS;
|
||||
break;
|
||||
case FIOC_FILEPATH:
|
||||
snprintf((FAR char *)(uintptr_t)arg, PATH_MAX,
|
||||
"icmp:[dev %s, id %" PRIu16 ", flg %" PRIx8 "]",
|
||||
conn->dev ? conn->dev->d_ifname : "NULL",
|
||||
NTOHS(conn->id), conn->sconn.s_flags);
|
||||
break;
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
@ -77,6 +78,12 @@ int icmpv6_ioctl(FAR struct socket *psock, int cmd, unsigned long arg)
|
||||
case FIONSPACE:
|
||||
*(FAR int *)((uintptr_t)arg) = MIN_UDP_MSS;
|
||||
break;
|
||||
case FIOC_FILEPATH:
|
||||
snprintf((FAR char *)(uintptr_t)arg, PATH_MAX,
|
||||
"icmp6:[dev %s, id %" PRIu16 ", flg %" PRIx8 "]",
|
||||
conn->dev ? conn->dev->d_ifname : "NULL",
|
||||
NTOHS(conn->id), conn->sconn.s_flags);
|
||||
break;
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
|
@ -885,7 +885,6 @@ static int local_ioctl(FAR struct socket *psock, int cmd, unsigned long arg)
|
||||
case FIOC_FILEPATH:
|
||||
snprintf((FAR char *)(uintptr_t)arg, PATH_MAX, "local:[%s]",
|
||||
conn->lc_path);
|
||||
ret = OK;
|
||||
break;
|
||||
case BIOC_FLUSH:
|
||||
ret = -EINVAL;
|
||||
|
@ -1591,6 +1591,9 @@ ssize_t net_ioctl_arglen(int cmd)
|
||||
case FIONREAD:
|
||||
return sizeof(int);
|
||||
|
||||
case FIOC_FILEPATH:
|
||||
return PATH_MAX;
|
||||
|
||||
case SIOCGIFCONF:
|
||||
return sizeof(struct ifconf);
|
||||
|
||||
|
@ -1346,6 +1346,25 @@ static int rpmsg_socket_close(FAR struct socket *psock)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rpmsg_socket_path(FAR struct rpmsg_socket_conn_s *conn,
|
||||
FAR char *buf, size_t len)
|
||||
{
|
||||
if (conn->backlog) /* Server */
|
||||
{
|
||||
snprintf(buf, len,
|
||||
"rpmsg:[%s:[%s%s]<->%s]",
|
||||
CONFIG_RPTUN_LOCAL_CPUNAME, conn->rpaddr.rp_name,
|
||||
conn->nameid, conn->rpaddr.rp_cpu);
|
||||
}
|
||||
else /* Client */
|
||||
{
|
||||
snprintf(buf, len,
|
||||
"rpmsg:[%s<->%s:[%s%s]]",
|
||||
CONFIG_RPTUN_LOCAL_CPUNAME, conn->rpaddr.rp_cpu,
|
||||
conn->rpaddr.rp_name, conn->nameid);
|
||||
}
|
||||
}
|
||||
|
||||
static int rpmsg_socket_ioctl(FAR struct socket *psock,
|
||||
int cmd, unsigned long arg)
|
||||
{
|
||||
@ -1362,6 +1381,10 @@ static int rpmsg_socket_ioctl(FAR struct socket *psock,
|
||||
*(FAR int *)((uintptr_t)arg) = rpmsg_socket_get_space(conn);
|
||||
break;
|
||||
|
||||
case FIOC_FILEPATH:
|
||||
rpmsg_socket_path(conn, (FAR char *)(uintptr_t)arg, PATH_MAX);
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
|
@ -154,7 +154,6 @@ int tcp_ioctl(FAR struct tcp_conn_s *conn, int cmd, unsigned long arg)
|
||||
break;
|
||||
case FIOC_FILEPATH:
|
||||
tcp_path(conn, (FAR char *)(uintptr_t)arg, PATH_MAX);
|
||||
ret = OK;
|
||||
break;
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
|
@ -149,7 +149,6 @@ int udp_ioctl(FAR struct udp_conn_s *conn, int cmd, unsigned long arg)
|
||||
break;
|
||||
case FIOC_FILEPATH:
|
||||
udp_path(conn, (FAR char *)(uintptr_t)arg, PATH_MAX);
|
||||
ret = OK;
|
||||
break;
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
|
Loading…
Reference in New Issue
Block a user