Zhe Weng
d3dd349649
net: Implement shutdown() for usrsock
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-31 11:15:01 +08:00
Zhe Weng
8819eeaf15
net: Implement shutdown() interface and tcp shutdown
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-31 11:15:01 +08:00
chao an
1f75d02bb5
net/tcp: correct behavior of SO_LINGER
...
1. Remove tcp_txdrain() from close() to avoid indefinitely block
2. Send TCP_RST immediately if linger timeout
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 02:47:12 +08:00
Xiang Xiao
695f42f8d2
net: Move accept to libc after https://github.com/apache/nuttx/pull/8083
...
since accept can simply forward to kernel accept4 function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-13 11:23:42 +02:00
zhanghongyu
48c9d10336
net_socket: add accept4 function
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-11 23:28:08 +08:00
zhanghongyu
ec8cc6db37
net: add parameter check in psock_setsockopt
...
0 0x565a60bd in memmove (dest=0xf7fbaabe, src=0x0, count=3) at string/lib_memmove.c:58
1 0x565d8b90 in usrsock_iovec_do (srcdst=0xf7fbaab0, srcdstlen=2018, iov=0xf3de798c, iovcnt=0, pos=0, from_iov=true, done=0xf3de78e7) at usrsock/usrsock_devif.c:155
2 0x565d9349 in usrsock_iovec_get (dst=0xf7fbaab0, dstlen=2032, iov=0xf3de797c, iovcnt=2, pos=0, done=0xf3de78e7) at usrsock/usrsock_devif.c:612
3 0x5659f4b9 in usrsock_request (iov=0xf3de797c, iovcnt=2) at usrsock/usrsock_rpmsg.c:210
4 0x565d9436 in usrsock_do_request (conn=0x566316c0 <g_usrsock_connections>, iov=0xf3de797c, iovcnt=2) at usrsock/usrsock_devif.c:659
5 0x565dcfe9 in do_setsockopt_request (conn=0x566316c0 <g_usrsock_connections>, level=1, option=7, value=0x0, value_len=4) at usrsock/usrsock_setsockopt.c:131
6 0x565dd11e in usrsock_setsockopt (psock=0xf3dea840, level=1, option=7, value=0x0, value_len=4) at usrsock/usrsock_setsockopt.c:208
7 0x565d4d31 in psock_setsockopt (psock=0xf3dea840, level=1, option=7, value=0x0, value_len=4) at socket/setsockopt.c:310
8 0x565d4dde in setsockopt (sockfd=3, level=1, option=7, value=0x0, value_len=4) at socket/setsockopt.c:396
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-11-29 00:20:09 +08:00
Xiang Xiao
c38d6f1ae4
net: Remove usrsock specific process from common code as much as possible
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-28 16:32:41 +09:00
chao an
f2a7711ef8
net/soerr: add new _SO_CONN_SETERRNO() macro
...
support so error code set from conn instance
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-24 22:57:42 +08:00
dongjiuzhu1
d5b08a7ef1
net/usrsock: fix get/setsockopt issue about usrsock protocol
...
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-11-23 21:27:15 +09:00
dongjiuzhu1
e6f8ccda4a
net/get/setsockopt: add si_get/setsockopt interface to simply get/setsockopt
...
move private option to protocol sockif
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-11-23 15:01:54 +08:00
zhanghongyu
f00c11aec4
socket: separation error code EBADF and ENOTSOCK
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-29 08:18:02 +02:00
Xiang Xiao
1047b65ab5
net: Remove the unused nx_[send|recv]msg
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-28 08:27:29 +02:00
Xiang Xiao
05d40eeeff
net: Remove the unused nx_recv[from] to prefer psock_recv[from] for kernel
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-27 16:47:32 +02:00
Xiang Xiao
3e982b6556
net: Remove the unused nx_send to prefer psock_send for kernel
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-27 16:47:32 +02:00
zhanghongyu
ae3e1d8ec5
setsockopt: Change return errno to EFAULT when value is NULL
...
behavior alignment to Linux for some testsuite
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
zhanghongyu
dc577b66e4
psock_socket: Add type field check
...
behavior alignment to Linux
Return EINVAL when type field include nonsupport bit
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
zhanghongyu
2be529121a
socketpair: Add SOCK_NONBLOCK support into type field
...
behavior alignment to Linux
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
Xiang Xiao
386547676d
net: Return -ENOPROTOOPT for unsupported/unknown socket option
...
so usrsock implementation could support more option than built-in stack
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-28 20:47:48 +09:00
Xiang Xiao
f4812e0a83
net: Implement SO_RCVBUF and SO_SNDBUF for getsockopt
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-21 09:03:20 +02:00
chao an
fe7badf2ac
net/getsockname: small addrlen should be a valid value
...
fix usrsock getsockname fail
nsh> usrsocktest
...
Testing group "basic_getsockname" =>
[TEST ASSERT FAILED!]
In function "basic_getsockname_open":
line 170: Assertion `(ssize_t)((ret)) == (ssize_t)((0))' failed.
got value: -1
should be: 0
Group "basic_getsockname": [FAILED]
...
Reference:
GETSOCKNAME(2)
NAME
getsockname - get socket name
...
DESCRIPTION
...
The returned address is truncated if the buffer provided is too small;
in this case, addrlen will return a value greater than was supplied to the call.
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-01 01:19:09 +08:00
chao.an
9cb17841d8
net/sockopt: move BINDTODEVICE to socket level
...
rename the UDP_BINDTODEVICE to SO_BINDTODEVICE to follow the linux
style to be compatible with non-UDP protocol binding requirements
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-25 17:56:52 +08:00
hejianliang3
e9648d8a73
net:fix coverity warning
...
Signed-off-by: hejianliang3 <hejianliang3@xiaomi.com>
2022-04-03 14:37:53 +03:00
chao.an
660b80b329
net/sockopt: bypass the SO_RCVBUF/SO_SNDBUF to usrsock
...
SO_RCVBUF/SO_SNDBUF tightly coupled with stack
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-18 00:19:31 +08:00
Xiang Xiao
b2c86f808d
net: Remove psock_fcntl related code
...
since the nonblocking mode set through psock_ioctl now
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-04 22:03:55 +02:00
chao.an
c73df52c46
net/socket: fix shadow variable
...
socket/setsockopt.c: In function ‘psock_socketlevel_option’:
socket/setsockopt.c:168:38: warning: declaration of ‘conn’ shadows a previous local [-Wshadow]
168 | FAR struct tcp_conn_s *conn;
| ^~~~
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-17 17:55:16 +01:00
chao.an
e749f6ca7e
net/tcp/monitor: do not migrate the state to close
...
1. remove the unnecessary interfaces tcp_close_monitor()
socket flags(s_flags) is a global state for net connection
remove the incorrect update for stop monitor
2. do not start the tcp monitor from duplicated psock
the tcp monitor has already registered in connect callback
------------------------------------------------------------
This patch also fix the telnet issue reported by:
https://github.com/apache/incubator-nuttx/pull/5434#issuecomment-1035600651
the orignal session fd is closed after dup, the connect state
has incorrectly migrated to close:
drivers/net/telnet.c:
977 static int telnet_session(FAR struct telnet_session_s *session)
...
1031 ret = psock_dup2(psock, &priv->td_psock);
...
1082 nx_close(session->ts_sd);
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-11 18:56:40 +09:00
chao.an
0d19a3a248
net/inet: move socket timestamp into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
9317626c32
net/inet: move socket linger into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
3fce144aeb
net/inet: move recv/send timeout into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
cc6add58dc
net/inet: move socket options into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
1659513edb
net/inet: move socket error into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
99cde13a11
net/inet: move socket flags into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
39e142243d
net/tcp/udp: move the send callback into tcp/udp structure
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
Petro Karashchenko
8d3bf05fd2
include: fix double include pre-processor guards
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-16 11:11:14 -03:00
chao.an
b10dcf7c0d
net/udp: fix the invaild udp destination address
...
If the udp socket not connected, it is possible to have
multi-different destination address in each iob entry,
update the remote address every time to avoid sent to the
incorrect destination.
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-17 11:25:06 -06:00
Jiuzhu Dong
887ec01f3e
net: limit NET_NACTIVESOCKETS to 4 when enable DEFAULT_SMALL
...
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-10-10 19:59:28 -07:00
Jiuzhu Dong
93bdecf2c3
net: always compile listen.c and accept.c when enable CONFIG_NET
...
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-10-10 19:59:02 -07:00
chao.an
5a2510d48d
net/dup: only start tcp monitor on INET domain
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-23 19:02:03 -07:00
Alin Jerpelea
91a5f90a7f
author: UVC Ingenieure : update licenses to Apache
...
Gregory Nutt has submitted the SGA
UVC Ingenieure has submitted the SGA
Max Holtzberg has submitted the ICLA
as a result we can migrate the licenses to Apache.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-09-15 15:57:55 +08:00
SPRESENSE
9732334b5d
net/socket: Fix bug that sendto did not return an error
...
When `tolen` is not 0 and `to` is NULL, it causes illegal buffer access.
Add a parameter check in this condition.
2021-08-19 01:31:05 -07:00
chao.an
7d4502aca6
net/socket: add SO_SNDBUF support
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-20 20:24:58 -07:00
Xiang Xiao
663104a2e9
fs: Simplify sendfile implementation
...
and avoid call nx_ file API in the kernel space
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id951ca161df2c2ee267dc4b5a0d7dfa67df4c1e6
2021-07-17 07:39:15 -03:00
chao.an
940a07e1e5
net/socketpair: move socketpair implement into socket internal
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-08 03:05:43 -05:00
chao.an
b901f22c27
net/socket: add SO_RCVBUF support
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-06 01:44:55 -05:00
chao.an
b6bf9cf44b
net/accept: alloc the accept fd after accept success
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-11 05:00:21 -05:00
chao.an
0d8e5b66fd
net/sock: move the psock calloc out of sockfd_allocate
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-11 05:00:21 -05:00
Xiang Xiao
001e7c3e76
sched: Don't include nuttx/sched.h inside sched.h
...
But let nuttx/sched.h include sched.h instead to
avoid expose nuttx kernel API to userspace.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-05-24 12:11:53 +09:00
Xu Xingliang
f07df9dfc8
net: Forward socket option only when the socket type is usrsock
...
Change-Id: I5e102c4c648936f96834120e2c508f7072436246
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-05-19 03:07:04 -05:00
chao.an
60407c8c8a
net/tcp: do not start the tcp monitor if unestablished
...
Add more sanity checks to avoid TCP moniter start fail if the
TCP handle unestablished, the dup(2) operation should work at any time
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-19 17:23:18 +09:00
Jiuzhu Dong
e96c8b9283
fs: allocate file/socket dynamically
...
Change-Id: I8aea63eaf0275f47f21fc8d5482b51ffecd5c906
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-03-17 06:46:42 -07:00